flujo-ai 3.35.0 → 3.37.0
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/.next/BUILD_ID +1 -1
- package/.next/app-build-manifest.json +125 -125
- package/.next/app-path-routes-manifest.json +21 -21
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +24 -24
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/api/approvals/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/approvals/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/backup/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/browse/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/bugs/enhance/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/cwd/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/encryption/secure/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/env/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/[id]/versions/[versionId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/[id]/versions/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/compile/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/generate/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/generator/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/improve/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/prompt-renderer/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/quick-chat/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/repair/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/init/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/local-models/capability/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/local-models/pull/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/local-models/suggest/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/app-sandbox/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/cancel/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/oauth-capability/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/prompts/get/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/prompts/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/resources/read/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/resources/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/status/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/tools/[toolName]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/tools/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/test-connection/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/test-connection/stream/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp-registry/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp-registry/spotlight/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/model/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/model/provider/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/model/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/model/test/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/oauth/callback/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/oauth/initiate/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/oauth/reset/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/packages/build/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/packages/derive-secrets/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/packages/install/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/packages/install/status/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/packages/installed/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/packages/resolve/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/packages/scan-targets/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/packages/search/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/packages/uninstall/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/[id]/run/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/[id]/runs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/preview-schedule/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/reconcile/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/registry/auth/resend/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/registry/auth/reset/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/registry/auth/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/registry/feedback/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/registry/oauth/callback/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/registry/oauth/initiate/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/registry/packages/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/registry/publish/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/registry/settings/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/restore/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/runs/active/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/storage/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/telemetry/daily-active/route.js +1 -1
- package/.next/server/app/api/telemetry/daily-active/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/waves/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/webhooks/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/chat/page_client-reference-manifest.js +1 -1
- package/.next/server/app/chat.html +1 -1
- package/.next/server/app/chat.rsc +2 -2
- package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
- package/.next/server/app/docs.html +1 -1
- package/.next/server/app/docs.rsc +1 -1
- package/.next/server/app/executions/page_client-reference-manifest.js +1 -1
- package/.next/server/app/executions.html +1 -1
- package/.next/server/app/executions.rsc +1 -1
- package/.next/server/app/flows/page_client-reference-manifest.js +1 -1
- package/.next/server/app/flows.html +1 -1
- package/.next/server/app/flows.rsc +2 -2
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +1 -1
- package/.next/server/app/mcp/page_client-reference-manifest.js +1 -1
- package/.next/server/app/mcp-flows/route.js +1 -1
- package/.next/server/app/mcp-flows/route_client-reference-manifest.js +1 -1
- package/.next/server/app/mcp-proxy/[server]/route.js +1 -1
- package/.next/server/app/mcp-proxy/[server]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/mcp.html +1 -1
- package/.next/server/app/mcp.rsc +2 -2
- package/.next/server/app/models/page_client-reference-manifest.js +1 -1
- package/.next/server/app/packages/page.js +1 -1
- package/.next/server/app/packages/page_client-reference-manifest.js +1 -1
- package/.next/server/app/packages.html +1 -1
- package/.next/server/app/packages.rsc +2 -2
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings.html +1 -1
- package/.next/server/app/settings.rsc +1 -1
- package/.next/server/app/v1/chat/completions/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/breakpoints/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/cancel/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/debug/continue/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/debug/step/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/edit-state/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/events/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/inject/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/resources/[resourceId]/content/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/resources/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/respond/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/events/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/models/route_client-reference-manifest.js +1 -1
- package/.next/server/app/waves/page_client-reference-manifest.js +1 -1
- package/.next/server/app/waves.html +1 -1
- package/.next/server/app/waves.rsc +1 -1
- package/.next/server/app-paths-manifest.json +21 -21
- package/.next/server/chunks/1227.js +1 -1
- package/.next/server/chunks/2273.js +1 -1
- package/.next/server/chunks/544.js +1 -1
- package/.next/server/chunks/6747.js +1 -1
- package/.next/server/chunks/8645.js +1 -1
- package/.next/server/functions-config-manifest.json +1 -1
- package/.next/server/middleware-manifest.json +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/{8650-aa22dbf7b37348f0.js → 8650-27bd62ba2381da1d.js} +1 -1
- package/.next/static/chunks/app/packages/{page-f1a22789a6c0e0b6.js → page-2f2d29c17841b3cf.js} +1 -1
- package/.next/trace +10 -10
- package/README.md +1 -1
- package/package.json +1 -1
- /package/.next/static/{hbjnLG9RCje2AApS9TzP8 → -8j0oqKN3S4zlsA4kJRYr}/_buildManifest.js +0 -0
- /package/.next/static/{hbjnLG9RCje2AApS9TzP8 → -8j0oqKN3S4zlsA4kJRYr}/_ssgManifest.js +0 -0
package/.next/static/chunks/app/packages/{page-f1a22789a6c0e0b6.js → page-2f2d29c17841b3cf.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7262],{70479:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>e1});var n=a(95155),r=a(12115),s=a(94049),l=a(20063),i=a(80777),o=a(25635),c=a(28548),d=a(91871),u=a(2300),h=a(86946),p=a(40047),m=a(33567),g=a(15712),x=a(9562),f=a(56422),y=a(41602),v=a(23820),j=a(73707),w=a(49501),b=a(22822),A=a(17681),k=a(4474),S=a(22003),C=a(41275),I=a(21067),E=a(55606),T=a(86973),F=a(99944),P=a(9957),N=a(2778),W=a(52363),z=a(65036),R=a(95844),O=a(71908),U=a(64246),L=a(75912),M=a(51611),H=a(66087),D=a(57813),J=a(26466),q=a(87021);let _=(0,q.h)("frontend/services/registry");async function G(e){return await e.json().catch(()=>({}))}class B{async getStatus(){let e=await fetch("/api/registry/auth",{method:"GET"});if(!e.ok)throw Error("HTTP ".concat(e.status));return G(e)}async auth(e,t,a,n){let r=await fetch("/api/registry/auth",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e,email:t,password:a,...n?{handle:n}:{}})}),s=await G(r);if(!r.ok&&(null==s?void 0:s.status)===void 0)throw Error((null==s?void 0:s.error)||"HTTP ".concat(r.status));return s}signup(e,t,a){return this.auth("signup",e,t,a)}login(e,t){return this.auth("login",e,t)}async logout(){let e=await fetch("/api/registry/auth",{method:"DELETE"});if(!e.ok)throw Error("HTTP ".concat(e.status))}async beginOAuth(e){let t=await fetch("/api/registry/oauth/initiate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e})}),a=await G(t);if(!t.ok||!(null==a?void 0:a.authorizationUrl))throw Error((null==a?void 0:a.error)||"HTTP ".concat(t.status));return{authorizationUrl:a.authorizationUrl}}async resendConfirmation(e){return G(await fetch("/api/registry/auth/resend",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e?{email:e}:{})}))}async requestPasswordReset(e){return G(await fetch("/api/registry/auth/reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})}))}async getSettings(){let e=await fetch("/api/registry/settings",{method:"GET"});if(!e.ok)throw Error("HTTP ".concat(e.status));return G(e)}async saveSettings(e){return G(await fetch("/api/registry/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:e})}))}async publish(e){let t=await fetch("/api/registry/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({manifest:e})}),a=await G(t);return(null==a?void 0:a.ok)===void 0?(_.warn("Unexpected publish response shape",{status:t.status}),{ok:!1,code:"error",error:"HTTP ".concat(t.status)}):a}async deletePackage(e){let t=await fetch("/api/registry/packages",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({packageId:e})}),a=await G(t);return(null==a?void 0:a.ok)===void 0?(_.warn("Unexpected package deletion response shape",{status:t.status}),{ok:!1,code:"error",error:(null==a?void 0:a.error)||"HTTP ".concat(t.status)}):a}}let V=null,Z=()=>(V||(V=new B),V),$=new Proxy({},{get(e,t){let a=Z(),n=a[t];return"function"==typeof n?n.bind(a):n}}),K=(0,q.h)("frontend/components/Packages/RegistryAccountSettings");function Y(){let[e,t]=(0,r.useState)(null),[a,l]=(0,r.useState)(!0),[u,h]=(0,r.useState)(!1),[p,m]=(0,r.useState)(null),[g,f]=(0,r.useState)("login"),[y,v]=(0,r.useState)(""),[j,w]=(0,r.useState)(""),[b,A]=(0,r.useState)(""),[C,E]=(0,r.useState)(""),[T,F]=(0,r.useState)(""),P=(0,r.useCallback)(async()=>{try{let[e,a]=await Promise.all([$.getStatus(),$.getSettings()]);t(e),F(a.defaultUrl),E(a.usingDefault?"":a.baseUrl)}catch(e){K.warn("Failed to load registry account status",e)}finally{l(!1)}},[]);(0,r.useEffect)(()=>{P()},[P]),(0,r.useEffect)(()=>{let e=new URLSearchParams(window.location.search),t=e.get("registry_oauth");if(!t)return;m("success"===t?{type:"success",text:"Signed in to the package registry."}:{type:"error",text:"OAuth sign-in did not complete. Please try again."}),P(),e.delete("registry_oauth");let a=e.toString();window.history.replaceState({},"",window.location.pathname+(a?"?".concat(a):""))},[P]);let N=async()=>{h(!0),m(null);try{let e="signup"===g?await $.signup(y.trim(),j,b.trim()):await $.login(y.trim(),j);"authenticated"===e.status?(m({type:"success",text:"Signed in to the package registry."}),w("")):"confirmation_required"===e.status?(m({type:"info",text:e.message||"Check your inbox to confirm your email."}),w("")):m({type:"error",text:e.message||"Authentication failed."}),e.account?t(e.account):await P()}catch(e){m({type:"error",text:e instanceof Error?e.message:"Authentication failed."})}finally{h(!1)}},W=async()=>{h(!0),m(null);try{await $.logout(),await P(),m({type:"success",text:"Logged out."})}catch(e){m({type:"error",text:e instanceof Error?e.message:"Failed to log out."})}finally{h(!1)}},z=async e=>{h(!0),m(null);try{let{authorizationUrl:t}=await $.beginOAuth(e);window.location.assign(t)}catch(e){m({type:"error",text:e instanceof Error?e.message:"Failed to start OAuth sign-in."}),h(!1)}},R=async()=>{h(!0),m(null);try{let e=await $.resendConfirmation();m(e.success?{type:"success",text:"Confirmation email sent."}:{type:"error",text:e.message||"Failed to resend confirmation."})}finally{h(!1)}},O=async()=>{let e=y.trim();if(!e)return void m({type:"info",text:"Enter your account email above, then tap “Forgot password?”."});h(!0),m(null);try{await $.requestPasswordReset(e),m({type:"info",text:"If an account exists for that email, a password-reset link is on its way. Follow the link to set a new password."})}catch(e){m({type:"error",text:e instanceof Error?e.message:"Failed to request a password reset."})}finally{h(!1)}},U=async()=>{h(!0),m(null);try{let e=await $.saveSettings(C.trim());m(e.success?{type:"success",text:"Registry URL saved."}:{type:"error",text:e.message||"Invalid registry URL."})}finally{h(!1)}};if(a)return(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",p:3},children:(0,n.jsx)(k.default,{size:28})});let L=!!(null==e?void 0:e.signedIn),M=!!((null==e?void 0:e.email)&&!L&&e&&!e.isConfirmed);return(0,n.jsxs)(s.default,{sx:{width:"100%"},children:[(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Sign in to the FLUJO package registry to publish packages. Browsing and installing packages does not require an account — only publishing does, and your email must be confirmed first. Your registry tokens are encrypted at rest and never shown here."}),p&&(0,n.jsx)(S.A,{severity:p.type,sx:{mb:2},onClose:()=>m(null),children:p.text}),L?(0,n.jsxs)(i.A,{spacing:2,children:[(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",flexWrap:"wrap",useFlexGap:!0,children:[(0,n.jsx)(o.default,{variant:"subtitle1",children:null==e?void 0:e.email}),(null==e?void 0:e.publisherHandle)&&(0,n.jsx)(c.A,{size:"small",label:"@".concat(e.publisherHandle)}),(null==e?void 0:e.isConfirmed)?(0,n.jsx)(c.A,{size:"small",color:"success",label:"Confirmed"}):(0,n.jsx)(c.A,{size:"small",color:"warning",label:"Unconfirmed"})]}),(0,n.jsx)(s.default,{children:(0,n.jsx)(d.A,{variant:"outlined",onClick:W,disabled:u,children:"Log out"})})]}):M?(0,n.jsxs)(i.A,{spacing:2,children:[(0,n.jsxs)(S.A,{severity:"info",children:["We sent a confirmation link to ",(0,n.jsx)("strong",{children:null==e?void 0:e.email}),". Confirm your email, then log in to start publishing."]}),(0,n.jsxs)(i.A,{direction:"row",spacing:1,children:[(0,n.jsx)(d.A,{variant:"outlined",onClick:R,disabled:u,children:"Resend confirmation email"}),(0,n.jsx)(d.A,{onClick:W,disabled:u,children:"Use a different account"})]})]}):(0,n.jsxs)(i.A,{spacing:2,children:[(0,n.jsxs)(D.A,{value:g,onChange:(e,t)=>f(t),children:[(0,n.jsx)(J.A,{value:"login",label:"Log in"}),(0,n.jsx)(J.A,{value:"signup",label:"Sign up"})]}),(0,n.jsx)(x.A,{label:"Email",type:"email",value:y,onChange:e=>v(e.target.value),fullWidth:!0,autoComplete:"username"}),(0,n.jsx)(x.A,{label:"Password",type:"password",value:j,onChange:e=>w(e.target.value),fullWidth:!0,autoComplete:"signup"===g?"new-password":"current-password"}),"signup"===g&&(0,n.jsx)(x.A,{label:"Publisher handle",value:b,onChange:e=>A(e.target.value),fullWidth:!0,autoComplete:"username",helperText:"A unique handle for publishing packages, e.g. your-name"}),(0,n.jsx)(s.default,{children:(0,n.jsx)(d.A,{variant:"contained",onClick:N,disabled:u||!y.trim()||!j||"signup"===g&&!b.trim(),children:"signup"===g?"Sign up":"Log in"})}),"login"===g&&(0,n.jsx)(s.default,{children:(0,n.jsx)(d.A,{variant:"text",size:"small",onClick:O,disabled:u,sx:{textTransform:"none",px:0},children:"Forgot password?"})}),(0,n.jsx)(I.A,{children:"or"}),(0,n.jsx)(i.A,{direction:"row",spacing:1,flexWrap:"wrap",useFlexGap:!0,children:(0,n.jsx)(d.A,{variant:"outlined",onClick:()=>z("github"),disabled:u,children:"Continue with GitHub"})})]}),(0,n.jsx)(I.A,{sx:{my:3}}),(0,n.jsx)(o.default,{variant:"subtitle2",gutterBottom:!0,children:"Registry URL"}),(0,n.jsxs)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:1},children:["Leave blank to use the default (",T,")."]}),(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",flexWrap:"wrap",useFlexGap:!0,children:[(0,n.jsx)(x.A,{size:"small",placeholder:T,value:C,onChange:e=>E(e.target.value),sx:{minWidth:320}}),(0,n.jsx)(d.A,{variant:"outlined",onClick:U,disabled:u,children:"Save"})]})]})}var Q=a(90057),X=a(43076),ee=a(17897),et=a(93632);let ea=(0,q.h)("frontend/services/packages");class en{async resolve(e){let t=await fetch("/api/packages/resolve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await t.json();if(!t.ok)throw Error((null==a?void 0:a.error)||"HTTP ".concat(t.status));return a}async deriveSecrets(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=await fetch("/api/packages/derive-secrets",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({selection:e,modelIdentifier:t.modelIdentifier,enableEntropy:t.enableEntropy,enableRepoSlug:t.enableRepoSlug})}),n=await a.json();if(!a.ok)throw Error((null==n?void 0:n.error)||"HTTP ".concat(a.status));return n}async scanTargets(e){var t;let a=await fetch("/api/packages/scan-targets",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({selection:e})}),n=await a.json();if(!a.ok)throw Error((null==n?void 0:n.error)||"HTTP ".concat(a.status));return null!=(t=null==n?void 0:n.candidates)?t:[]}async searchRegistry(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new URLSearchParams;e.q&&t.set("q",e.q),e.tag&&t.set("tag",e.tag),e.page&&t.set("page",String(e.page)),e.pageSize&&t.set("pageSize",String(e.pageSize));let a=await fetch("/api/packages/search".concat(t.toString()?"?".concat(t.toString()):"")),n=await a.json();if(!a.ok&&!(null==n?void 0:n.items))throw Error((null==n?void 0:n.error)||"HTTP ".concat(a.status));return n}async installFromRegistry(e){let t=await fetch("/api/packages/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:"registry",...e})}),a=await t.json();if(!t.ok&&(null==a?void 0:a.ok)===void 0)throw Error((null==a?void 0:a.error)||"HTTP ".concat(t.status));return a}async build(e,t){var a;let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],l=await fetch("/api/packages/build",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({selection:e,metadata:t,acceptedSecrets:n,globals:r,excludedSecrets:s})}),i=null!=(a=l.headers.get("content-type"))?a:"";if(!i.includes("application/json")){let e=await l.text();throw ea.error("Package build returned a non-JSON response",{status:l.status,contentType:i,preview:e.slice(0,200)}),Error("Package build failed: HTTP ".concat(l.status," returned a non-JSON response"))}let o=await l.json();if(!l.ok&&(null==o?void 0:o.ok)===void 0)throw Error((null==o?void 0:o.error)||"HTTP ".concat(l.status));return o}}let er=null,es=()=>(er||(er=new en),er),el=new Proxy({},{get(e,t){let a=es(),n=a[t];return"function"==typeof n?n.bind(a):n}}),ei=/\{\{secret\.([A-Za-z0-9_.-]+)\}\}/g,eo="encrypted:",ec=/^[A-Za-z0-9_.-]+$/,ed=["path","repo","token","email","url-cred","name","other"];function eu(e){let t=new Set,a=e=>{if("string"==typeof e){for(let a of function(e){let t;if("string"!=typeof e)return[];let a=[],n=RegExp(ei.source,"g");for(;null!==(t=n.exec(e));)a.includes(t[1])||a.push(t[1]);return a}(e))t.add(a);return}if(Array.isArray(e)){for(let t of e)a(t);return}if(e&&"object"==typeof e)for(let t of Object.values(e))a(t)};return a(e),Array.from(t)}var eh=a(2750);let ep=eh.object({name:eh.string().min(1).regex(ec,"invalid secret name"),description:eh.string().optional(),required:eh.boolean(),default:eh.string().optional()}).strict(),em=eh.object({name:eh.string().min(1).regex(ec,"invalid global variable name"),description:eh.string().optional(),required:eh.boolean(),isSecret:eh.boolean().optional()}).strict(),eg=eh.discriminatedUnion("kind",[eh.object({kind:eh.literal("secret"),secret:eh.string().min(1)}).strict(),eh.object({kind:eh.literal("global"),var:eh.string().min(1)}).strict(),eh.object({kind:eh.literal("none")}).strict()]),ex=eh.object({id:eh.string().min(1),name:eh.string().min(1),displayName:eh.string().optional(),description:eh.string().optional(),baseUrl:eh.string().optional(),provider:eh.string().optional(),adapter:eh.string().optional(),promptTemplate:eh.string().optional(),reasoningSchema:eh.string().optional(),temperature:eh.string().optional(),reasoningEffort:eh.enum(["minimal","low","medium","high","xhigh","max","ultra"]).optional(),thinkingLevel:eh.enum(["minimal","low","medium","high"]).optional(),thinkingBudget:eh.number().int().min(-1).optional(),serviceTier:eh.enum(["default","priority"]).optional(),functionCallingSchema:eh.string().optional(),contextWindow:eh.number().optional(),maxTurns:eh.number().optional(),maxTokens:eh.number().optional(),folder:eh.string().optional(),favorite:eh.boolean().optional(),apiKeyRef:eg}).strict(),ef=eh.object({sourceType:eh.enum(["github","registry","marketplace","remote"]),ref:eh.string().optional(),url:eh.string().optional(),name:eh.string().optional()}).strict().superRefine((e,t)=>{"remote"!==e.sourceType||e.url||t.addIssue({code:"custom",message:"installOrigin 'remote' requires a url"}),"github"!==e.sourceType&&"registry"!==e.sourceType||e.ref||t.addIssue({code:"custom",message:"installOrigin '".concat(e.sourceType,"' requires a ref")})}),ey=eh.object({name:eh.string().min(1),isSecret:eh.boolean(),secretRef:eh.string().optional(),globalVar:eh.string().optional(),globalTemplate:eh.string().optional()}).strict().superRefine((e,t)=>{void 0===e.globalTemplate||/\$\{global:[A-Za-z0-9_.-]+\}/.test(e.globalTemplate)||t.addIssue({code:"custom",path:["globalTemplate"],message:"globalTemplate must contain at least one ${global:NAME} reference"})}),ev=eh.object({index:eh.number().int().nonnegative(),value:eh.string().min(1)}).strict().superRefine((e,t)=>{/\$\{global:[A-Za-z0-9_.-]+\}/.test(e.value)||t.addIssue({code:"custom",path:["value"],message:"argument template must contain at least one ${global:NAME} reference"})}),ej=eh.object({name:eh.string().min(1),transport:eh.enum(["stdio","sse","streamable","websocket"]),disabled:eh.boolean().optional(),autoApprove:eh.array(eh.string()).optional(),folder:eh.string().optional(),installOrigin:ef,envDeclarations:eh.array(ey),headerDeclarations:eh.array(ey).optional(),argTemplates:eh.array(ev).optional()}).strict(),ew=eh.object({flow:eh.object({id:eh.string().min(1),name:eh.string().min(1),nodes:eh.array(eh.any()),edges:eh.array(eh.any())}).catchall(eh.unknown()),references:eh.object({flowIds:eh.array(eh.string()).optional(),modelIds:eh.array(eh.string()).optional(),mcpServerNames:eh.array(eh.string()).optional()}).optional()}),eb=eh.object({id:eh.string().min(1),name:eh.string().min(1),enabled:eh.boolean(),flowId:eh.string().min(1),prompt:eh.string(),trigger:eh.any()}).catchall(eh.unknown()),eA=eh.object({schemaVersion:eh.literal(1),id:eh.string().min(1),name:eh.string().min(1),description:eh.string().optional(),version:eh.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?(?:\+[0-9A-Za-z-.]+)?$/,"version must be valid semver"),author:eh.string().optional(),publisher:eh.string().optional(),tags:eh.array(eh.string()).optional(),requiredGlobals:eh.array(eh.string()).optional(),globals:eh.array(em).optional(),secrets:eh.array(ep),models:eh.array(ex),mcpServers:eh.array(ej),flows:eh.array(ew),plannedExecutions:eh.array(eb)}).superRefine((e,t)=>{(function e(t){return"string"==typeof t?t.startsWith(eo):Array.isArray(t)?t.some(e):!!t&&"object"==typeof t&&Object.values(t).some(e)})(e)&&t.addIssue({code:"custom",message:"package contains an '".concat(eo,"' value; secret material must never be serialized")});let a=new Set(e.secrets.map(e=>e.name)),n=new Set(eu(e));for(let t of e.models)"secret"===t.apiKeyRef.kind&&n.add(t.apiKeyRef.secret);for(let t of e.mcpServers){var r;for(let e of[...t.envDeclarations,...null!=(r=t.headerDeclarations)?r:[]])e.secretRef&&n.add(e.secretRef)}for(let e of n)a.has(e)||t.addIssue({code:"custom",message:'secret "'.concat(e,'" is referenced but not declared in secrets[]')});let s=new Set(e.flows.map(e=>e.flow.id));e.plannedExecutions.forEach((e,a)=>{s.has(e.flowId)||t.addIssue({code:"custom",path:["plannedExecutions",a,"flowId"],message:'plannedExecution "'.concat(e.name,'" references unknown flow id "').concat(e.flowId,'"')})}),e.flows.forEach((e,a)=>{var n,r;for(let l of null!=(r=null==(n=e.references)?void 0:n.flowIds)?r:[])s.has(l)||t.addIssue({code:"custom",path:["flows",a,"references","flowIds"],message:'flow "'.concat(e.flow.name,'" references unknown subflow id "').concat(l,'"')})})}),ek=(0,q.h)("frontend/components/Packages/PackageWizard"),eS=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?(?:\+[0-9A-Za-z-.]+)?$/,eC=["Select contents","Resolve & validate","Secret review","Metadata","Export"];function eI(e){return e.replace(/^SECRET_/,"")}function eE(e){let{open:t,onClose:a}=e,l=(0,m.A)(),u=(0,g.A)(l.breakpoints.down("sm")),[h,p]=(0,r.useState)(0),[D,J]=(0,r.useState)({flows:[],models:[],mcpServers:[],plannedExecutions:[]}),[q,_]=(0,r.useState)(!0),[G,B]=(0,r.useState)(new Set),[V,$]=(0,r.useState)(new Set),[K,ea]=(0,r.useState)(new Set),[en,er]=(0,r.useState)(new Set),[el,ei]=(0,r.useState)(""),[eo,eh]=(0,r.useState)(""),[ep,em]=(0,r.useState)(""),[eg,ex]=(0,r.useState)(""),[ef,ey]=(0,r.useState)(null),[ev,ej]=(0,r.useState)([]),[ew,eb]=(0,r.useState)(!1),[eE,eT]=(0,r.useState)(null),[eF,eP]=(0,r.useState)(null),[eN,eW]=(0,r.useState)({}),[ez,eR]=(0,r.useState)(new Set),[eO,eU]=(0,r.useState)([]),[eL,eM]=(0,r.useState)(!1),[eH,eD]=(0,r.useState)(!1),[eJ,eq]=(0,r.useState)(null),[e_,eG]=(0,r.useState)([]),[eB,eV]=(0,r.useState)(""),[eZ,e$]=(0,r.useState)(""),[eK,eY]=(0,r.useState)(!1),[eQ,eX]=(0,r.useState)(!1),[e0,e1]=(0,r.useState)(""),[e2,e5]=(0,r.useState)(""),[e4,e3]=(0,r.useState)("other"),[e6,e7]=(0,r.useState)(null),[e9,e8]=(0,r.useState)(!1),[te,tt]=(0,r.useState)(!1),[ta,tn]=(0,r.useState)(null),[tr,ts]=(0,r.useState)([]),[tl,ti]=(0,r.useState)(""),[to,tc]=(0,r.useState)(!1),[td,tu]=(0,r.useState)(""),[th,tp]=(0,r.useState)("1.0.0"),[tm,tg]=(0,r.useState)(""),[tx,tf]=(0,r.useState)(""),[ty,tv]=(0,r.useState)(!1),[tj,tw]=(0,r.useState)(null),[tb,tA]=(0,r.useState)(null),[tk,tS]=(0,r.useState)(!1),[tC,tI]=(0,r.useState)(null);(0,r.useEffect)(()=>{if(!t)return;let e=!1;return(async()=>{_(!0);try{var t;let[a,n,r,s]=await Promise.all([Q.g.loadFlows(),X.N.loadModels(),ee.S.loadServerConfigs(),et.P.list()]);if(e)return;let l=Array.isArray(r)?r:[];J({flows:(null!=a?a:[]).map(e=>({id:e.id,label:e.name||e.id})),models:(null!=n?n:[]).map(e=>({id:e.id,label:e.displayName||e.name||e.id})),mcpServers:l.map(e=>({id:e.name,label:e.name})),plannedExecutions:(null!=(t=null==s?void 0:s.executions)?t:[]).map(e=>({id:e.execution.id,label:e.execution.name||e.execution.id}))})}catch(e){ek.warn("Failed to load packageable entities",e)}finally{e||_(!1)}})(),()=>{e=!0}},[t]);let tE=(0,r.useMemo)(()=>({flowIds:Array.from(G),modelIds:Array.from(V),mcpServerNames:Array.from(K),plannedExecutionIds:Array.from(en)}),[G,V,K,en]),tT=0===G.size&&0===V.size&&0===K.size&&0===en.size,tF=e=>t=>{e(e=>{let a=new Set(e);return a.has(t)?a.delete(t):a.add(t),a})},tP=(0,r.useCallback)(async e=>{let t;ej([]);try{t=await e.text()}catch(e){ej([e instanceof Error?e.message:"Failed to read the file"]);return}let a=function(e){let t;try{t=JSON.parse(e)}catch(e){return{ok:!1,errors:["Not valid JSON: ".concat(e instanceof Error?e.message:String(e))]}}let a=function(e){let t=eA.safeParse(e);if(!t.success)return{success:!1,errors:t.error.issues.map(e=>{let t=e.path.join(".");return t?"".concat(t,": ").concat(e.message):e.message})};let a=t.data;return{success:!0,data:a,warnings:function(e){let t=new Set(eu(e));for(let a of e.models)"secret"===a.apiKeyRef.kind&&t.add(a.apiKeyRef.secret);for(let n of e.mcpServers){var a;for(let e of[...n.envDeclarations,...null!=(a=n.headerDeclarations)?a:[]])e.secretRef&&t.add(e.secretRef)}return e.secrets.filter(e=>!t.has(e.name)).map(e=>'secret "'.concat(e.name,'" is declared but never referenced'))}(a)}}(t);if(!a.success||!a.data){var n;return{ok:!1,errors:null!=(n=a.errors)?n:["Not a valid FLUJO package manifest"]}}return{ok:!0,package:a.data}}(t);if(!a.ok){ey(null),ej(a.errors.slice(0,8));return}let n=function(e,t){var a,n,r,s,l,i,o,c,d,u;let h=new Set(t.flowIds),p=new Set(t.modelIds),m=new Set(t.mcpServerNames),g=new Set(t.plannedExecutionIds),x=[],f={flowIds:[],modelIds:[],mcpServerNames:[],plannedExecutionIds:[]};for(let t of null!=(a=e.flows)?a:[]){let e=null==t||null==(n=t.flow)?void 0:n.id;e&&(h.has(e)?f.flowIds.push(e):x.push({type:"flow",label:(null==(r=t.flow)?void 0:r.name)?"".concat(t.flow.name," (").concat(e,")"):e}))}for(let t of null!=(s=e.models)?s:[])(null==t?void 0:t.id)&&(p.has(t.id)?f.modelIds.push(t.id):x.push({type:"model",label:t.displayName||t.name||t.id}));for(let t of null!=(l=e.mcpServers)?l:[])(null==t?void 0:t.name)&&(m.has(t.name)?f.mcpServerNames.push(t.name):x.push({type:"mcpServer",label:t.name}));for(let t of null!=(i=e.plannedExecutions)?i:[]){let e=null==t?void 0:t.id;e&&(g.has(e)?f.plannedExecutionIds.push(e):x.push({type:"plannedExecution",label:t.name||e}))}return{selection:f,metadata:{name:null!=(o=e.name)?o:"",version:null!=(c=e.version)?c:"",description:null!=(d=e.description)?d:"",tags:e.tags?[...e.tags]:[]},secretNames:(null!=(u=e.secrets)?u:[]).map(e=>e.name).filter(Boolean),missing:x}}(a.package,{flowIds:D.flows.map(e=>e.id),modelIds:D.models.map(e=>e.id),mcpServerNames:D.mcpServers.map(e=>e.id),plannedExecutionIds:D.plannedExecutions.map(e=>e.id)});B(new Set(n.selection.flowIds)),$(new Set(n.selection.modelIds)),ea(new Set(n.selection.mcpServerNames)),er(new Set(n.selection.plannedExecutionIds)),tu(n.metadata.name),tp(n.metadata.version),tg(n.metadata.description),tf(n.metadata.tags.join(", ")),eT(null),eP(null),eW({}),eR(new Set),eU([]),eD(!1),eq(null),eG([]),tw(null),tA(null),tI(null),ey(n),ek.info("Imported package manifest into the wizard",{name:n.metadata.name,version:n.metadata.version,missing:n.missing.length})},[D]),tN=(0,r.useCallback)(async()=>{eb(!0),eP(null),eT(null),eW({}),eR(new Set),eU([]),eD(!1),eq(null),eG([]);try{var e;let t=await es().resolve(tE);eT(t),eW(Object.fromEntries((null!=(e=t.globals)?e:[]).map(e=>{var t;return[e.name,null!=(t=e.description)?t:""]})))}catch(e){eP(e instanceof Error?e.message:"Failed to resolve dependencies")}finally{eb(!1)}},[tE]),tW=(0,r.useMemo)(()=>ef?new Set(ef.secretNames):null,[ef]),tz=(0,r.useCallback)(async e=>{eM(!0),eq(null);try{var t;let a=await es().deriveSecrets(tE,{modelIdentifier:e,enableEntropy:eK,enableRepoSlug:eQ});eU(e=>{let t=new Map(e.map(e=>[e.id,e.accepted])),n=new Map(e.map(e=>[e.id,e.suggestedSecretName])),r=e.filter(e=>"manual"===e.source),s=a.proposals.map(e=>{var a;return{...e,accepted:t.has(e.id)?t.get(e.id):tW?tW.has(e.suggestedSecretName):"low"!==e.confidence,suggestedSecretName:null!=(a=n.get(e.id))?a:e.suggestedSecretName}}),l=new Set(s.map(e=>e.id));return[...s,...r.filter(e=>!l.has(e.id))]}),eG(null!=(t=a.warnings)?t:[])}catch(e){eq(e instanceof Error?e.message:"Failed to derive secrets")}finally{eM(!1),eD(!0)}},[tE,eK,eQ,tW]),tR=e=>eU(t=>t.map(t=>({...t,accepted:e}))),tO=()=>{e7(null);let e=function(e){var t,a,n,r,s;let l=(null!=(a=e.excerpt)?a:"").trim();if(!l||l.length>2e3)return null;let i=(null!=(n=e.secretName)?n:"").trim();if(i.length>128)return null;let o=null!=(r=e.kind)?r:"other",c=ec.test(i)?i.toUpperCase():function(e,t){let a="".concat(e,"_").concat(t).toUpperCase().replace(/[^A-Z0-9_.-]+/g,"_").replace(/^[_.-]+|[_.-]+$/g,"")||"".concat(e,"_SECRET");return ec.test(a)?a:"".concat(e,"_SECRET")}("SECRET",i||l.slice(0,16)),d=(null!=(s=e.location)?s:"manual").trim()||"manual";return{id:"sp_".concat(function(e){let t=5381;for(let a=0;a<e.length;a++)t=(t<<5)+t^e.charCodeAt(a);return(t>>>0).toString(16).padStart(8,"0")}("".concat(d,"\0").concat(l))),location:d,excerpt:l,kind:o,source:"manual",confidence:"high",suggestedSecretName:c,suggestedDescription:(null==(t=e.description)?void 0:t.trim())||void 0,rationale:"Added manually",accepted:!0}}({excerpt:e0,secretName:e2,kind:e4});if(!e)return void e7("Enter a non-empty value to redact (under 2000 characters).");eU(t=>t.some(t=>t.id===e.id)?t:[e,...t]),e1(""),e5(""),e3("other")},tU=(0,r.useCallback)(async()=>{e8(!0),tn(null),ti(""),tt(!0);try{let e=await es().scanTargets(tE);ts(e)}catch(e){tn(e instanceof Error?e.message:"Failed to load candidate values"),ts([])}finally{tt(!1)}},[tE]),tL=(0,r.useMemo)(()=>{let e=tl.trim().toLowerCase();return e?tr.filter(t=>"".concat(t.text," ").concat(t.location," ").concat(t.source).toLowerCase().includes(e)):tr},[tr,tl]),tM=(0,r.useMemo)(()=>{let e=new Map;for(let t of eO){let a="".concat(t.kind,"::").concat(t.excerpt),n=e.get(a);n?(n.ids.push(t.id),n.locations.push(t.location)):e.set(a,{key:a,ids:[t.id],locations:[t.location],kind:t.kind,source:t.source,confidence:t.confidence,excerpt:t.excerpt,suggestedSecretName:t.suggestedSecretName,rationale:t.rationale,accepted:t.accepted})}return Array.from(e.values())},[eO]),tH=(0,r.useMemo)(()=>{let e=eZ.trim().toLowerCase();return e?tM.filter(t=>"".concat(t.excerpt," ").concat(t.locations.join(" ")," ").concat(t.kind," ").concat(t.suggestedSecretName).toLowerCase().includes(e)):tM},[tM,eZ]),tD=(0,r.useMemo)(()=>{var e;if(!ef||!eH)return[];let t=new Set([...(null!=(e=null==eE?void 0:eE.secrets)?e:[]).map(e=>e.name),...eO.map(e=>e.suggestedSecretName)]);return ef.secretNames.filter(e=>!t.has(e))},[ef,eH,eE,eO]),tJ=(0,r.useMemo)(()=>{var e;let t=new Map;for(let a of tM)t.set(a.kind,(null!=(e=t.get(a.kind))?e:0)+1);return Array.from(t.entries()).sort((e,t)=>t[1]-e[1])},[tM]);(0,r.useEffect)(()=>{2!==h||!eE||eH||eL||tz()},[h,eE,eH,eL,tz]);let tq=(0,r.useCallback)(async()=>{tv(!0),tA(null),tw(null);try{var e;let t=tx.split(",").map(e=>e.trim()).filter(Boolean),a=await es().build(tE,{id:"pkg-".concat(Date.now()),name:td.trim(),version:th.trim(),description:tm.trim()||void 0,tags:t.length?t:void 0},eO.filter(e=>e.accepted),(null!=(e=null==eE?void 0:eE.globals)?e:[]).map(e=>{var t;return{...e,description:(null==(t=eN[e.name])?void 0:t.trim())||e.description}}),Array.from(ez));tw(a),a.ok||tA(a.errors&&a.errors[0]||"Package build failed")}catch(e){tA(e instanceof Error?e.message:"Failed to build package")}finally{tv(!1)}},[tE,td,th,tm,tx,eO,eE,eN,ez]),t_=(0,r.useCallback)(async()=>{if(null==tj?void 0:tj.json){tS(!0),tI(null);try{let e=JSON.parse(tj.json),t=await Z().publish(e);tI(t)}catch(e){tI({ok:!1,code:"error",error:e instanceof Error?e.message:"Failed to publish package"})}finally{tS(!1)}}},[tj]),tG=()=>{if(!(null==tj?void 0:tj.json))return;let e=new Blob([tj.json],{type:"application/json"}),t=URL.createObjectURL(e),a=document.createElement("a");a.href=t;let n=td.trim().replace(/[^A-Za-z0-9_.-]+/g,"-").replace(/^-+|-+$/g,"")||"package";a.download="".concat(n,"-").concat(th.trim(),".flujo-package.json"),document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(t)},tB=async()=>{if(0===h){await tN(),p(1);return}if(3===h){p(4),await tq();return}p(e=>Math.min(e+1,eC.length-1))},tV=eS.test(th.trim()),tZ=td.trim().length>0&&tV,t$=!!(eE&&!eE.mcp.ok),tK=0===h?tT||ew:1===h?ew||!!eF||t$:3===h?!tZ:4===h,tY=(e,t,a,r,l,i)=>{let d=l.trim().toLowerCase(),u=d?t.filter(e=>e.label.toLowerCase().includes(d)):t;return(0,n.jsxs)(s.default,{sx:{flex:1,minWidth:240},children:[(0,n.jsxs)(o.default,{variant:"subtitle2",gutterBottom:!0,children:[e," ",a.size>0&&(0,n.jsx)(c.A,{label:a.size,size:"small"})]}),(0,n.jsx)(x.A,{size:"small",fullWidth:!0,placeholder:"Search ".concat(e.toLowerCase(),"…"),value:l,onChange:e=>i(e.target.value),InputProps:{startAdornment:(0,n.jsx)(f.A,{position:"start",children:(0,n.jsx)(M.A,{fontSize:"small"})})},sx:{mb:1}}),0===t.length?(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"None available"}):0===u.length?(0,n.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["No matches for “",l,"”."]}):(0,n.jsx)(y.A,{dense:!0,sx:{maxHeight:{xs:240,md:"45vh"},overflow:"auto",border:1,borderColor:"divider",borderRadius:1},children:u.map(e=>(0,n.jsx)(v.Ay,{disablePadding:!0,children:(0,n.jsxs)(j.A,{onClick:()=>r(e.id),dense:!0,children:[(0,n.jsx)(w.A,{sx:{minWidth:36},children:(0,n.jsx)(b.A,{edge:"start",checked:a.has(e.id),tabIndex:-1,disableRipple:!0})}),(0,n.jsx)(A.A,{primary:e.label})]})},e.id))})]})};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(N.A,{open:t,onClose:a,maxWidth:"lg",fullWidth:!0,fullScreen:u,PaperProps:{sx:{height:u?"100%":"90vh",maxHeight:u?"100%":"90vh"}},children:[(0,n.jsx)(W.A,{children:"Create package"}),(0,n.jsxs)(z.A,{dividers:!0,sx:{overflow:"auto"},children:[(0,n.jsx)(R.A,{activeStep:h,sx:{mb:3},children:eC.map(e=>(0,n.jsx)(O.A,{children:(0,n.jsx)(U.A,{children:e})},e))}),(()=>{switch(h){case 0:return q?(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",p:4},children:(0,n.jsx)(k.default,{})}):(0,n.jsxs)(i.A,{spacing:2,children:[(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Pick the entities to include. Dependencies (subflows, referenced models and MCP servers, planned-execution flows) are pulled in automatically in the next step."}),(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",flexWrap:"wrap",useFlexGap:!0,children:[(0,n.jsxs)(d.A,{component:"label",variant:"outlined",startIcon:(0,n.jsx)(H.A,{}),children:["Import manifest (.json)",(0,n.jsx)("input",{type:"file",accept:"application/json,.json",hidden:!0,onChange:e=>{var t;let a=null==(t=e.target.files)?void 0:t[0];e.target.value="",a&&tP(a)}})]}),(0,n.jsx)(o.default,{variant:"caption",color:"text.secondary",children:"Restores the selection, metadata and accepted secrets from a package you exported earlier."})]}),ev.length>0&&(0,n.jsxs)(S.A,{severity:"error",onClose:()=>ej([]),children:[(0,n.jsx)(C.A,{children:"Could not import that file"}),ev.map((e,t)=>(0,n.jsx)("div",{children:e},t))]}),ef&&(0,n.jsxs)(S.A,{severity:ef.missing.length>0?"warning":"success",children:[(0,n.jsxs)(C.A,{children:["Imported “",ef.metadata.name,"” v",ef.metadata.version]}),"Restored ",ef.selection.flowIds.length," flow(s),"," ",ef.selection.modelIds.length," model(s),"," ",ef.selection.mcpServerNames.length," MCP server(s),"," ",ef.selection.plannedExecutionIds.length," planned execution(s) and"," ",ef.secretNames.length," secret name(s).",ef.missing.length>0&&(0,n.jsxs)(s.default,{sx:{mt:1},children:["No longer on this host (left unselected):",ef.missing.map((e,t)=>(0,n.jsxs)("div",{children:[e.type,": ",e.label]},t))]})]}),(0,n.jsxs)(i.A,{direction:"row",spacing:2,flexWrap:"wrap",useFlexGap:!0,children:[tY("Flows",D.flows,G,tF(B),el,ei),tY("Models",D.models,V,tF($),eo,eh),tY("MCP servers",D.mcpServers,K,tF(ea),ep,em),tY("Planned executions",D.plannedExecutions,en,tF(er),eg,ex)]})]});case 1:if(ew)return(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",p:4},children:(0,n.jsx)(k.default,{})});if(eF)return(0,n.jsx)(S.A,{severity:"error",children:eF});if(!eE)return null;return(0,n.jsxs)(i.A,{spacing:2,children:[t$&&(0,n.jsxs)(S.A,{severity:"error",children:[(0,n.jsx)(C.A,{children:"Local MCP server(s) cannot be packaged"}),eE.mcp.errors.map((e,t)=>(0,n.jsx)("div",{children:e},t))]}),eE.resolved.autoAdded.length>0&&(0,n.jsxs)(S.A,{severity:"info",children:[(0,n.jsx)(C.A,{children:"Automatically included dependencies"}),eE.resolved.autoAdded.map((e,t)=>(0,n.jsxs)("div",{children:[e.type,": ",(0,n.jsx)("code",{children:e.id})," — ",e.reason]},t))]}),eE.resolved.warnings.length>0&&(0,n.jsxs)(S.A,{severity:"warning",children:[(0,n.jsx)(C.A,{children:"Warnings"}),eE.resolved.warnings.map((e,t)=>(0,n.jsx)("div",{children:e},t))]}),(0,n.jsx)(I.A,{}),(0,n.jsxs)(o.default,{variant:"body2",children:["Resolved: ",eE.resolved.flowIds.length," flow(s),"," ",eE.resolved.modelIds.length," model(s),"," ",eE.resolved.mcpServerNames.length," MCP server(s),"," ",eE.resolved.plannedExecutionIds.length," planned execution(s)."]}),eE.mcp.servers.length>0&&(0,n.jsx)(i.A,{direction:"row",spacing:1,flexWrap:"wrap",useFlexGap:!0,children:eE.mcp.servers.map(e=>(0,n.jsx)(c.A,{label:"".concat(e.name," \xb7 ").concat(e.sourceType),size:"small",color:"success",variant:"outlined"},e.name))})]});case 2:var e;return(0,n.jsxs)(i.A,{spacing:2,children:[(0,n.jsx)(o.default,{variant:"subtitle2",children:"Global variables"}),(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Global variables referenced by the package. Add a useful description for each one; installers will supply values and FLUJO will create them in Global Variables."}),eE&&0!==(null!=(e=eE.globals)?e:[]).length?(0,n.jsx)(i.A,{spacing:1.5,children:eE.globals.map(e=>{var t;return(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"flex-start",children:[(0,n.jsx)(x.A,{size:"small",label:e.name,value:null!=(t=eN[e.name])?t:"",onChange:t=>eW(a=>({...a,[e.name]:t.target.value})),helperText:e.isSecret?"Secret global; its value is never included in the package":"Description shown during package installation",fullWidth:!0}),e.isSecret&&(0,n.jsx)(c.A,{label:"secret global",size:"small",color:"warning",variant:"outlined"})]},e.name)})}):(0,n.jsx)(S.A,{severity:"success",children:"No global variables referenced by this package."}),(0,n.jsx)(I.A,{}),(0,n.jsx)(o.default,{variant:"subtitle2",children:"Declared secrets (entity keys)"}),(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Secrets the package will declare from model API keys and MCP env/headers. Values are never included — whoever installs must supply them."}),eE&&0!==eE.secrets.length?(0,n.jsx)(y.A,{dense:!0,children:eE.secrets.map(e=>(0,n.jsxs)(v.Ay,{children:[(0,n.jsx)(b.A,{edge:"start",checked:!ez.has(e.name),onChange:t=>eR(a=>{let n=new Set(a);return t.target.checked?n.delete(e.name):n.add(e.name),n}),inputProps:{"aria-label":"Include ".concat(e.name," in package secrets")}}),(0,n.jsx)(A.A,{primary:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("code",{children:eI(e.name)})," ",e.required&&(0,n.jsx)(c.A,{label:"required",size:"small",color:"warning"})]}),secondary:ez.has(e.name)?"Excluded — the package will not request this value":e.description})]},e.name))}):(0,n.jsx)(S.A,{severity:"success",children:"No entity secrets to declare."}),(0,n.jsx)(I.A,{}),(0,n.jsx)(o.default,{variant:"subtitle2",children:"Detected secrets in content"}),(0,n.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["Values that look secret or instance-specific (paths, repos, tokens, URLs, emails) found in flow prompts, node properties, model config and planned- execution prompts. Accepted rows are replaced with a"," ",(0,n.jsx)("code",{children:"{{secret.NAME}}"})," placeholder everywhere they occur."]}),eL&&(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",p:2},children:(0,n.jsx)(k.default,{size:28})}),eJ&&(0,n.jsx)(S.A,{severity:"error",children:eJ}),!eL&&eH&&0===eO.length&&(0,n.jsx)(S.A,{severity:"success",children:"No likely secrets detected in the packaged content."}),eO.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.A,{direction:"row",spacing:.5,flexWrap:"wrap",useFlexGap:!0,children:tJ.map(e=>{let[t,a]=e;return(0,n.jsx)(c.A,{size:"small",variant:"outlined",label:"".concat(t,": ").concat(a)},t)})}),(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",flexWrap:"wrap",useFlexGap:!0,children:[(0,n.jsx)(d.A,{size:"small",onClick:()=>tR(!0),children:"Accept all"}),(0,n.jsx)(d.A,{size:"small",onClick:()=>tR(!1),children:"Reject all"}),(0,n.jsx)(x.A,{size:"small",placeholder:"Filter detected secrets…",value:eZ,onChange:e=>e$(e.target.value),sx:{minWidth:200,flex:1}}),(0,n.jsxs)(o.default,{variant:"caption",color:"text.secondary",sx:{alignSelf:"center"},children:[tM.filter(e=>e.accepted).length," of ",tM.length," accepted"]})]}),(0,n.jsxs)(y.A,{dense:!0,sx:{border:1,borderColor:"divider",borderRadius:1,maxHeight:280,overflow:"auto"},children:[0===tH.length&&(0,n.jsx)(v.Ay,{children:(0,n.jsx)(A.A,{primary:(0,n.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["No rows match “",eZ,"”."]})})}),tH.map(e=>(0,n.jsxs)(v.Ay,{alignItems:"flex-start",divider:!0,children:[(0,n.jsx)(w.A,{sx:{minWidth:36,mt:1},children:(0,n.jsx)(b.A,{edge:"start",checked:!!e.accepted,onChange:()=>{let t;return t=e.ids,eU(e=>{var a;let n=new Set(t),r=!(null==(a=e.find(e=>n.has(e.id)))?void 0:a.accepted);return e.map(e=>n.has(e.id)?{...e,accepted:r}:e)})},tabIndex:-1,disableRipple:!0})}),(0,n.jsx)(A.A,{primary:(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",flexWrap:"wrap",useFlexGap:!0,children:[(0,n.jsx)(c.A,{label:e.kind,size:"small"}),(0,n.jsx)(c.A,{label:e.source,size:"small",variant:"outlined",color:"model"===e.source?"secondary":"manual"===e.source?"primary":"default"}),e.confidence&&(0,n.jsx)(c.A,{label:e.confidence,size:"small",variant:"outlined",color:"high"===e.confidence?"success":"low"===e.confidence?"warning":"default"}),e.locations.length>1&&(0,n.jsx)(c.A,{label:"".concat(e.locations.length,"\xd7"),size:"small",variant:"outlined"}),(0,n.jsx)(s.default,{component:"code",sx:{wordBreak:"break-all"},children:e.excerpt.length>80?"".concat(e.excerpt.slice(0,80),"…"):e.excerpt})]}),secondary:(0,n.jsxs)(i.A,{spacing:.5,sx:{mt:.5},children:[(0,n.jsxs)(o.default,{variant:"caption",color:"text.secondary",children:[e.locations.length>1?"".concat(e.locations.length," locations: ").concat(e.locations.slice(0,3).join(", ")).concat(e.locations.length>3?", …":""):e.locations[0],e.rationale?" — ".concat(e.rationale):""]}),(0,n.jsx)(x.A,{size:"small",label:"Secret name",value:eI(e.suggestedSecretName),onChange:t=>{var a,n;let r,s;return r=e.ids,a=e.suggestedSecretName,n=t.target.value,s=a.startsWith("SECRET_")?"SECRET_".concat(n.replace(/^SECRET_/,"")):n,eU(e=>{let t=new Set(r);return e.map(e=>t.has(e.id)?{...e,suggestedSecretName:s}:e)})},disabled:!e.accepted,sx:{maxWidth:320}})]}),primaryTypographyProps:{component:"div"},secondaryTypographyProps:{component:"div"}})]},e.key))]})]}),tD.length>0&&(0,n.jsxs)(S.A,{severity:"warning",children:[(0,n.jsx)(C.A,{children:"Secrets from the imported manifest that need re-adding"}),"A manifest never carries secret values, so these declarations could not be matched to anything in the current content — re-add them below if they still apply: ",tD.map(eI).join(", "),"."]}),e_.length>0&&(0,n.jsxs)(S.A,{severity:"warning",children:[(0,n.jsx)(C.A,{children:"Notes"}),e_.map((e,t)=>(0,n.jsx)("div",{children:e},t))]}),(0,n.jsx)(I.A,{}),(0,n.jsx)(o.default,{variant:"subtitle2",children:"Add a secret manually"}),(0,n.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["Enter any value that should be redacted from the package. It is treated purely as text to replace with a ",(0,n.jsx)("code",{children:"{{secret.NAME}}"})," placeholder — it is never executed."]}),e6&&(0,n.jsx)(S.A,{severity:"error",children:e6}),(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"flex-start",flexWrap:"wrap",useFlexGap:!0,children:[(0,n.jsx)(x.A,{size:"small",label:"Value to redact",value:e0,onChange:e=>e1(e.target.value),sx:{minWidth:240,flex:1}}),(0,n.jsx)(x.A,{size:"small",label:"Secret name",value:e2,onChange:e=>e5(e.target.value),sx:{minWidth:180}}),(0,n.jsx)(E.A,{size:"small",value:e4,onChange:e=>e3(e.target.value),sx:{minWidth:120},children:ed.map(e=>(0,n.jsx)(T.A,{value:e,children:e},e))}),(0,n.jsx)(d.A,{variant:"outlined",onClick:tO,disabled:!e0.trim(),children:"Add"}),(0,n.jsx)(d.A,{variant:"text",startIcon:(0,n.jsx)(M.A,{}),onClick:()=>void tU(),disabled:tT,children:"Pick from app"})]}),(0,n.jsx)(I.A,{}),(0,n.jsx)(o.default,{variant:"subtitle2",children:"Advanced scan options"}),(0,n.jsxs)(i.A,{direction:"row",spacing:2,flexWrap:"wrap",useFlexGap:!0,children:[(0,n.jsx)(F.A,{control:(0,n.jsx)(P.A,{checked:eK,onChange:e=>{eY(e.target.checked),eD(!1)}}),label:"Aggressive entropy scan"}),(0,n.jsx)(F.A,{control:(0,n.jsx)(P.A,{checked:eQ,onChange:e=>{eX(e.target.checked),eD(!1)}}),label:"Detect bare owner/repo slugs"}),(0,n.jsx)(d.A,{size:"small",variant:"text",onClick:()=>void tz(),disabled:eL,children:"Re-scan"})]}),(0,n.jsx)(I.A,{}),(0,n.jsx)(o.default,{variant:"subtitle2",children:"Optional: model-driven scan"}),(0,n.jsx)(S.A,{severity:"info",children:"Running the model-driven pass sends the packaged content above to the selected model provider. The offline heuristic scan never leaves your machine."}),(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",flexWrap:"wrap",useFlexGap:!0,children:[(0,n.jsxs)(E.A,{size:"small",displayEmpty:!0,value:eB,onChange:e=>eV(e.target.value),sx:{minWidth:220},children:[(0,n.jsx)(T.A,{value:"",children:(0,n.jsx)("em",{children:"Select a model…"})}),D.models.map(e=>(0,n.jsx)(T.A,{value:e.id,children:e.label},e.id))]}),(0,n.jsx)(d.A,{variant:"outlined",disabled:!eB||eL,onClick:()=>void tz(eB),children:"Scan with model"})]})]});case 3:return(0,n.jsxs)(i.A,{spacing:2,children:[(0,n.jsx)(x.A,{label:"Package name",value:td,onChange:e=>tu(e.target.value),required:!0,fullWidth:!0,error:td.length>0&&0===td.trim().length}),(0,n.jsx)(x.A,{label:"Version",value:th,onChange:e=>tp(e.target.value),required:!0,fullWidth:!0,error:th.length>0&&!tV,helperText:th.length>0&&!tV?"Must be a semantic version (e.g. 1.0.0)":" "}),(0,n.jsx)(x.A,{label:"Description",value:tm,onChange:e=>tg(e.target.value),fullWidth:!0,multiline:!0,minRows:2}),(0,n.jsx)(x.A,{label:"Tags (comma-separated)",value:tx,onChange:e=>tf(e.target.value),fullWidth:!0})]});case 4:if(ty)return(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",p:4},children:(0,n.jsx)(k.default,{})});if(tb)return(0,n.jsx)(S.A,{severity:"error",children:tb});if(null==tj?void 0:tj.ok)return(0,n.jsxs)(i.A,{spacing:2,children:[(0,n.jsxs)(S.A,{severity:"success",children:[(0,n.jsx)(C.A,{children:"Package built"}),(0,n.jsx)("code",{children:td.trim()})," v",th.trim()," is ready to export."]}),tj.warnings.length>0&&(0,n.jsxs)(S.A,{severity:"warning",children:[(0,n.jsx)(C.A,{children:"Warnings"}),tj.warnings.map((e,t)=>(0,n.jsx)("div",{children:e},t))]}),(0,n.jsx)(d.A,{variant:"contained",onClick:tG,children:"Download package manifest (.json)"}),(0,n.jsx)(I.A,{}),(0,n.jsx)(o.default,{variant:"subtitle2",children:"Publish to the FLUJO package registry"}),(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Publishing requires a confirmed registry account (set one up on the Packages page). Only the secret-safe manifest above is uploaded — no secret values ever leave your machine."}),(null==tC?void 0:tC.ok)?(0,n.jsxs)(S.A,{severity:"success",children:[(0,n.jsx)(C.A,{children:"Published"}),tC.name||td.trim()," v",tC.version||th.trim()," is live.",tC.url&&(0,n.jsx)("div",{children:(0,n.jsx)("a",{href:tC.url,target:"_blank",rel:"noreferrer",children:tC.url})})]}):(0,n.jsxs)(n.Fragment,{children:[tC&&!tC.ok&&(0,n.jsx)(S.A,{severity:"unconfirmed"===tC.code||"not_authenticated"===tC.code?"warning":"error",children:tC.error||"Failed to publish package."}),(0,n.jsxs)(i.A,{direction:"row",spacing:1,flexWrap:"wrap",useFlexGap:!0,children:[(0,n.jsx)(d.A,{variant:"outlined",onClick:()=>void t_(),disabled:tk,children:tk?"Publishing…":"Publish to registry"}),tC&&!tC.ok&&("not_authenticated"===tC.code||"unconfirmed"===tC.code)&&(0,n.jsx)(d.A,{variant:"contained",onClick:()=>tc(!0),disabled:tk,children:"Log in to registry"})]})]})]});return null;default:return null}})()]}),(0,n.jsxs)(L.A,{children:[(0,n.jsx)(d.A,{onClick:a,children:(null==tj?void 0:tj.ok)?"Close":"Cancel"}),(0,n.jsx)(s.default,{sx:{flex:1}}),(0,n.jsx)(d.A,{onClick:()=>p(e=>Math.max(e-1,0)),disabled:0===h||ty||ew,children:"Back"}),h<4&&(0,n.jsx)(d.A,{variant:"contained",onClick:tB,disabled:tK,children:3===h?"Build":"Next"})]})]}),(0,n.jsxs)(N.A,{open:to,onClose:()=>tc(!1),maxWidth:"sm",fullWidth:!0,children:[(0,n.jsx)(W.A,{children:"Log in to the package registry"}),(0,n.jsx)(z.A,{dividers:!0,children:(0,n.jsx)(Y,{})}),(0,n.jsxs)(L.A,{children:[(0,n.jsx)(d.A,{onClick:()=>tc(!1),children:"Done"}),(0,n.jsx)(d.A,{variant:"contained",onClick:()=>{tc(!1),t_()},disabled:tk,children:"Retry publish"})]})]}),(0,n.jsxs)(N.A,{open:e9,onClose:()=>e8(!1),maxWidth:"md",fullWidth:!0,children:[(0,n.jsx)(W.A,{children:"Pick a value to redact"}),(0,n.jsxs)(z.A,{dividers:!0,children:[(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"These are plaintext values found in the packaged flows, models and planned executions. Pick one to pre-fill the value to redact. API keys and MCP env/header values are never listed — they are already declared as secrets."}),(0,n.jsx)(x.A,{size:"small",fullWidth:!0,placeholder:"Search values…",value:tl,onChange:e=>ti(e.target.value),InputProps:{startAdornment:(0,n.jsx)(f.A,{position:"start",children:(0,n.jsx)(M.A,{fontSize:"small"})})},sx:{mb:2}}),te?(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",p:4},children:(0,n.jsx)(k.default,{})}):ta?(0,n.jsx)(S.A,{severity:"error",children:ta}):0===tr.length?(0,n.jsx)(S.A,{severity:"info",children:"No pickable plaintext values found in the packaged content."}):0===tL.length?(0,n.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["No values match “",tl,"”."]}):(0,n.jsx)(y.A,{dense:!0,sx:{border:1,borderColor:"divider",borderRadius:1,maxHeight:"50vh",overflow:"auto"},children:tL.map((e,t)=>(0,n.jsx)(v.Ay,{disablePadding:!0,divider:!0,children:(0,n.jsx)(j.A,{onClick:()=>{e1(e.text),e7(null),e8(!1)},alignItems:"flex-start",children:(0,n.jsx)(A.A,{primary:(0,n.jsx)(s.default,{component:"code",sx:{wordBreak:"break-all"},children:e.text.length>120?"".concat(e.text.slice(0,120),"…"):e.text}),secondary:(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",flexWrap:"wrap",useFlexGap:!0,sx:{mt:.5},children:[(0,n.jsx)(c.A,{label:e.source,size:"small",variant:"outlined"}),(0,n.jsx)(o.default,{variant:"caption",color:"text.secondary",children:e.location})]}),primaryTypographyProps:{component:"div"},secondaryTypographyProps:{component:"div"}})})},"".concat(e.location,"-").concat(t)))})]}),(0,n.jsx)(L.A,{children:(0,n.jsx)(d.A,{onClick:()=>e8(!1),children:"Close"})})]})]})}var eT=a(50001),eF=a(51314),eP=a(76530);let eN=(0,q.h)("frontend/components/Packages/InstalledPackagesList");function eW(){let[e,t]=(0,r.useState)([]),[a,l]=(0,r.useState)(!0),[h,p]=(0,r.useState)(null),[m,g]=(0,r.useState)(null),[y,v]=(0,r.useState)(!1),[j,w]=(0,r.useState)(null),[b,A]=(0,r.useState)(""),C=(0,r.useCallback)(async()=>{l(!0),p(null);try{var e;let a=await fetch("/api/packages/installed");if(!a.ok)throw Error("Failed to load installed packages (".concat(a.status,")"));let n=await a.json();t(null!=(e=n.packages)?e:[])}catch(e){eN.warn("Failed to load installed packages",e),p(e instanceof Error?e.message:String(e))}finally{l(!1)}},[]);(0,r.useEffect)(()=>{C()},[C]);let I=(0,r.useCallback)(async e=>{v(!0),w(null);try{let a=await fetch("/api/packages/uninstall",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({packageName:e.packageName})}),n=await a.json();if(!a.ok){var t;throw Error(null!=(t=n.error)?t:"Uninstall failed (".concat(a.status,")"))}w(n),await C()}catch(e){eN.warn("Uninstall failed",e),p(e instanceof Error?e.message:String(e))}finally{v(!1),g(null)}},[C]),E=(0,r.useMemo)(()=>{let t=b.trim().toLowerCase();return t?e.filter(e=>"".concat(e.packageName," ").concat(e.version).toLowerCase().includes(t)):e},[e,b]);return(0,n.jsxs)(s.default,{sx:{maxWidth:{xs:"100%",md:1100},mx:"auto",mt:3},children:[(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",sx:{mb:1},children:[(0,n.jsx)(o.default,{variant:"h6",children:"Installed packages"}),(0,n.jsx)(d.A,{size:"small",startIcon:(0,n.jsx)(eP.A,{}),onClick:()=>void C(),disabled:a,children:"Refresh"})]}),e.length>0&&(0,n.jsx)(x.A,{size:"small",fullWidth:!0,placeholder:"Search installed packages…",value:b,onChange:e=>A(e.target.value),InputProps:{startAdornment:(0,n.jsx)(f.A,{position:"start",children:(0,n.jsx)(M.A,{fontSize:"small"})})},sx:{mb:2}}),h&&(0,n.jsx)(S.A,{severity:"error",sx:{mb:2},onClose:()=>p(null),children:h}),j&&(0,n.jsxs)(S.A,{severity:j.hasErrors?"warning":"success",sx:{mb:2},onClose:()=>w(null),children:['Uninstalled "',j.packageName,'": ',j.removed.length," removed,"," ",j.skipped.length," preserved/skipped",j.hasErrors?", ".concat(j.errors.length," error(s)"):"","."]}),a?(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",p:3},children:(0,n.jsx)(k.default,{size:24})}):0===e.length?(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"No packages installed yet."}):0===E.length?(0,n.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["No packages match “",b,"”."]}):(0,n.jsx)(i.A,{spacing:1,children:E.map(e=>(0,n.jsxs)(u.A,{variant:"outlined",sx:{p:2,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,n.jsxs)(s.default,{children:[(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",children:[(0,n.jsx)(o.default,{variant:"subtitle1",children:e.packageName}),(0,n.jsx)(c.A,{label:"v".concat(e.version),size:"small",variant:"outlined"})]}),(0,n.jsxs)(o.default,{variant:"caption",color:"text.secondary",children:[e.entityCounts.flows," flows \xb7 ",e.entityCounts.models," models \xb7"," ",e.entityCounts.servers," servers \xb7 ",e.entityCounts.plannedExecutions," planned \xb7 installed ",new Date(e.installedAt).toLocaleString()]})]}),(0,n.jsx)(d.A,{color:"error",size:"small",startIcon:(0,n.jsx)(eF.A,{}),onClick:()=>g(e),disabled:y,children:"Uninstall"})]},e.packageName))}),(0,n.jsxs)(N.A,{open:null!==m,onClose:()=>y?void 0:g(null),children:[(0,n.jsxs)(W.A,{children:['Uninstall "',null==m?void 0:m.packageName,'"?']}),(0,n.jsx)(z.A,{children:(0,n.jsxs)(eT.A,{children:["This removes the flows, models, MCP servers and planned executions this package",(0,n.jsx)("strong",{children:" created"}),". Pre-existing entities the package merely updated in place are preserved. This cannot be undone."]})}),(0,n.jsxs)(L.A,{children:[(0,n.jsx)(d.A,{onClick:()=>g(null),disabled:y,children:"Cancel"}),(0,n.jsx)(d.A,{color:"error",variant:"contained",onClick:()=>m&&void I(m),disabled:y,startIcon:y?(0,n.jsx)(k.default,{size:16}):(0,n.jsx)(eF.A,{}),children:"Uninstall"})]})]})]})}var ez=a(33077),eR=a(29767),eO=a(53062),eU=a(84578),eL=a(1702),eM=a(41983),eH=a(23789),eD=a(17438),eJ=a(14418),eq=a(52550),e_=a(12402),eG=a(61563),eB=a(42063),eV=a(68212);let eZ=(0,q.h)("frontend/components/Packages/InstallPackageCard");function e$(e){var t,a,l,u,h;let{onInstalled:p}=e,[m,g]=(0,r.useState)(""),[y,v]=(0,r.useState)([]),[j,w]=(0,r.useState)(!1),[b,A]=(0,r.useState)(null),[C,E]=(0,r.useState)(!1),[T,F]=(0,r.useState)(null),[P,H]=(0,r.useState)(null),[D,J]=(0,r.useState)(!1),[q,_]=(0,r.useState)(null),[G,B]=(0,r.useState)(null),[V,Z]=(0,r.useState)(!1),[K,Y]=(0,r.useState)(null),[Q,X]=(0,r.useState)(null),[ee,et]=(0,r.useState)({}),[ea,en]=(0,r.useState)({}),[er,es]=(0,r.useState)(null),[ei,eo]=(0,r.useState)(!1),[ec,ed]=(0,r.useState)(0),[eu,eh]=(0,r.useState)(null),[ep,em]=(0,r.useState)({}),eg=(0,r.useCallback)(async e=>{w(!0),A(null);try{var t;let a=await el.searchRegistry({q:e.trim()||void 0,pageSize:24});v(null!=(t=a.items)?t:[]),E(!0)}catch(e){eZ.warn("Failed to search package registry",e),A(e instanceof Error?e.message:String(e)),v([])}finally{w(!1)}},[]);(0,r.useEffect)(()=>{eg(""),$.getStatus().then(e=>F(e.signedIn?e.publisherHandle:null)).catch(e=>eZ.debug("Registry account status unavailable",e))},[eg]);let ex=(0,r.useCallback)(async()=>{if(P){J(!0),_(null);try{let e=await $.deletePackage(P.id);if(!e.ok)return void _(e.error||"Failed to delete package.");v(e=>e.filter(e=>e.id!==P.id)),H(null),await eg(m)}catch(e){eZ.warn("Package deletion failed",e),_(e instanceof Error?e.message:String(e))}finally{J(!1)}}},[P,m,eg]),ef=(0,r.useCallback)(async e=>{B(e),X(null),eh(null),et({}),en({}),es(null),eo(!1),ed(0),em({}),Y(null),Z(!0);try{var t,a,n;let r=await el.installFromRegistry({packageId:e.id,version:e.latestVersion,consentGranted:!1});if(!r.ok)return void Y((null==(a=r.errors)?void 0:a[0])||"Failed to fetch package preview.");X(r);let s=null==(t=r.preview)?void 0:t.models[0];es(null!=(n=null==s?void 0:s.id)?n:null),ed(+!s)}catch(e){eZ.warn("Failed to fetch package preview",e),Y(e instanceof Error?e.message:String(e))}finally{Z(!1)}},[]),ey=(0,r.useCallback)(async()=>{if(G&&Q){Z(!0),Y(null);try{let e=await el.installFromRegistry({packageId:G.id,version:G.latestVersion,secrets:ee,modelMappings:Object.fromEntries(Object.entries(ea).filter(e=>{let[,t]=e;return""!==t})),consentGranted:!0});eh(e),X(null),e.ok&&(null==p||p())}catch(e){eZ.warn("Install failed",e),Y(e instanceof Error?e.message:String(e))}finally{Z(!1)}}},[G,Q,ee,ea,p]),ev=(0,r.useCallback)(()=>{B(null),X(null),eh(null),et({}),en({}),es(null),eo(!1),ed(0),em({}),Y(null)},[]),ej=null==Q?void 0:Q.preview,ew=null!=(a=null==ej?void 0:ej.models.find(e=>e.id===er))?a:null==ej?void 0:ej.models[0],eb=null!=(l=null==ej?void 0:ej.models.filter(e=>Object.prototype.hasOwnProperty.call(ea,e.id)).length)?l:0,eA=null==(u=null==ej?void 0:ej.models.every(e=>Object.prototype.hasOwnProperty.call(ea,e.id)))||u,ek=(0,r.useCallback)(e=>{es(e),eo(!!ea[e])},[ea]),eS=(0,r.useCallback)(e=>{en(t=>({...t,[e]:""})),eo(!1)},[]),eC=(0,r.useCallback)((e,t)=>{en(a=>({...a,[e]:t}))},[]);return(0,n.jsxs)(s.default,{sx:{maxWidth:{xs:"100%",md:1100},mx:"auto",mt:3},children:[(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",sx:{mb:1},children:[(0,n.jsx)(e_.A,{color:"action"}),(0,n.jsx)(o.default,{variant:"h6",children:"Browse registry"})]}),(0,n.jsx)(x.A,{size:"small",fullWidth:!0,placeholder:"Search published packages…",value:m,onChange:e=>g(e.target.value),onKeyDown:e=>{"Enter"===e.key&&eg(m)},InputProps:{startAdornment:(0,n.jsx)(f.A,{position:"start",children:(0,n.jsx)(M.A,{fontSize:"small"})}),endAdornment:j?(0,n.jsx)(f.A,{position:"end",children:(0,n.jsx)(k.default,{size:16})}):void 0},sx:{mb:2}}),b&&(0,n.jsx)(S.A,{severity:"error",sx:{mb:2},onClose:()=>A(null),children:b}),C&&!j&&0===y.length&&!b&&(0,n.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["No packages match “",m,"”."]}),(0,n.jsx)(ez.Ay,{container:!0,spacing:2,children:y.map(e=>(0,n.jsx)(ez.Ay,{item:!0,xs:12,sm:6,md:4,children:(0,n.jsxs)(eR.A,{variant:"outlined",sx:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,n.jsx)(eO.A,{onClick:()=>void ef(e),sx:{flex:1},children:(0,n.jsxs)(eU.A,{children:[(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"baseline",justifyContent:"space-between",children:[(0,n.jsx)(o.default,{variant:"subtitle1",noWrap:!0,children:e.name}),(0,n.jsx)(c.A,{size:"small",variant:"outlined",label:"v".concat(e.latestVersion)})]}),(0,n.jsx)(o.default,{variant:"caption",color:"text.secondary",display:"block",children:e.handle}),(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mt:.5,minHeight:"2.5em"},children:e.description||"No description provided."}),(0,n.jsx)(i.A,{direction:"row",spacing:.5,sx:{mt:1,flexWrap:"wrap",gap:.5},children:e.tags.map(e=>(0,n.jsx)(c.A,{size:"small",label:e},e))}),(0,n.jsxs)(i.A,{direction:"row",spacing:.5,alignItems:"center",sx:{mt:1},children:[(0,n.jsx)(eG.A,{fontSize:"inherit",color:"disabled"}),(0,n.jsx)(o.default,{variant:"caption",color:"text.secondary",children:e.downloads})]})]})}),function(e,t){var a;let n=null==t?void 0:t.trim().replace(/^@/,"").toLocaleLowerCase();if(!n)return!1;let r=null==(a=e.handle)?void 0:a.trim().replace(/^@/,"");if(r)return r.split("/")[0].toLocaleLowerCase()===n;let s=e.id.trim().replace(/^@/,"");return s.includes("/")&&s.split("/")[0].toLocaleLowerCase()===n}(e,T)&&(0,n.jsx)(eL.A,{sx:{justifyContent:"flex-end",pt:0},children:(0,n.jsx)(eM.A,{size:"small",color:"error","aria-label":"Delete ".concat(e.name),onClick:()=>{_(null),H(e)},children:(0,n.jsx)(eF.A,{fontSize:"small"})})})]})},e.id))}),(0,n.jsxs)(N.A,{open:null!==P,onClose:D?void 0:()=>H(null),maxWidth:"xs",fullWidth:!0,children:[(0,n.jsx)(W.A,{children:"Delete package?"}),(0,n.jsxs)(z.A,{children:[q&&(0,n.jsx)(S.A,{severity:"error",sx:{mb:2},children:q}),(0,n.jsxs)(o.default,{variant:"body2",children:["This permanently deletes ",(0,n.jsx)("strong",{children:null==P?void 0:P.name})," and all of its published versions from the registry. This action cannot be undone."]})]}),(0,n.jsxs)(L.A,{children:[(0,n.jsx)(d.A,{onClick:()=>H(null),disabled:D,children:"Cancel"}),(0,n.jsx)(d.A,{color:"error",variant:"contained",onClick:()=>void ex(),disabled:D,startIcon:D?(0,n.jsx)(k.default,{size:16,color:"inherit"}):(0,n.jsx)(eF.A,{}),children:"Delete package"})]})]}),(0,n.jsxs)(N.A,{open:null!==G,onClose:V?void 0:ev,maxWidth:!1,fullWidth:!0,PaperProps:{sx:{width:"min(1400px, calc(100vw - 32px))",maxWidth:"none",minHeight:{xs:"calc(100vh - 32px)",md:760},maxHeight:"calc(100vh - 32px)",borderRadius:{xs:2,md:3}}},children:[(0,n.jsxs)(W.A,{sx:{px:{xs:2,md:4},pt:{xs:2,md:3},pb:1},children:[(0,n.jsxs)(o.default,{component:"span",variant:"h5",fontWeight:700,children:["Install ",null==G?void 0:G.name]}),(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:"Match the package to your FLUJO, then review and install it."})]}),(0,n.jsxs)(z.A,{sx:{px:{xs:2,md:4},pb:3},children:[K&&(0,n.jsx)(S.A,{severity:"error",sx:{mb:2},onClose:()=>Y(null),children:K}),V&&!Q&&!eu&&(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:420},children:(0,n.jsx)(k.default,{size:24})}),ej&&(null==Q?void 0:Q.package)&&(0,n.jsxs)(s.default,{children:[(0,n.jsxs)(i.A,{direction:{xs:"column",sm:"row"},spacing:1,alignItems:{sm:"center"},justifyContent:"space-between",sx:{mb:2.5},children:[(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",children:[(0,n.jsx)(c.A,{size:"small",variant:"outlined",label:"v".concat(Q.package.version)}),Q.package.publisher&&(0,n.jsx)(c.A,{size:"small",variant:"outlined",label:Q.package.publisher}),(0,n.jsxs)(o.default,{variant:"caption",color:"text.secondary",children:[ej.servers.length," server(s) \xb7 ",ej.models.length," model(s) \xb7"," ",ej.flows.length," flow(s) \xb7 ",ej.plannedExecutions.length," planned execution(s)"]})]}),(0,n.jsxs)(o.default,{variant:"caption",color:"text.secondary",children:["Step ",ec+1," of 2"]})]}),(0,n.jsxs)(R.A,{activeStep:ec,sx:{maxWidth:720,mx:"auto",mb:3},children:[(0,n.jsx)(O.A,{children:(0,n.jsx)(U.A,{children:"Match models"})}),(0,n.jsx)(O.A,{children:(0,n.jsx)(U.A,{children:"Review & install"})})]}),0===ec&&ej.models.length>0&&ew&&(0,n.jsxs)(s.default,{children:[(0,n.jsxs)(s.default,{sx:{textAlign:"center",maxWidth:820,mx:"auto",mb:3},children:[(0,n.jsx)(o.default,{variant:"h4",fontWeight:750,sx:{mb:1},children:"The package was created with models that are not installed in your FLUJO."}),(0,n.jsx)(o.default,{variant:"h6",color:"text.secondary",fontWeight:400,children:"Let's replace or recreate them!"})]}),(0,n.jsxs)(s.default,{sx:{display:"grid",gridTemplateColumns:{xs:"minmax(0, 1fr)",md:"minmax(260px, 0.85fr) 88px minmax(420px, 1.35fr)"},gap:{xs:2,md:2.5},alignItems:"stretch"},children:[(0,n.jsxs)(s.default,{children:[(0,n.jsxs)(i.A,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{mb:1.25},children:[(0,n.jsx)(o.default,{variant:"overline",color:"text.secondary",fontWeight:700,children:"Models in this package"}),(0,n.jsx)(c.A,{size:"small",color:eA?"success":"default",label:"".concat(eb,"/").concat(ej.models.length," ready")})]}),(0,n.jsx)(i.A,{spacing:1.25,children:ej.models.map(e=>{let t=e.id===ew.id,a=Object.prototype.hasOwnProperty.call(ea,e.id),r=ej.installedModels.find(t=>t.id===ea[e.id]);return(0,n.jsx)(eR.A,{variant:"outlined",sx:{borderWidth:t?2:1,borderColor:t?"primary.main":"divider",bgcolor:t?"action.selected":"background.paper",transition:"border-color 120ms ease, background-color 120ms ease"},children:(0,n.jsx)(eO.A,{onClick:()=>ek(e.id),"aria-label":"Configure ".concat(e.displayName),sx:{minHeight:104,p:2},children:(0,n.jsxs)(i.A,{direction:"row",spacing:1.5,alignItems:"center",children:[(0,n.jsx)(s.default,{sx:{width:44,height:44,borderRadius:2,display:"grid",placeItems:"center",bgcolor:t?"primary.main":"action.hover",color:t?"primary.contrastText":"text.secondary",flex:"0 0 auto"},children:(0,n.jsx)(eq.A,{})}),(0,n.jsxs)(s.default,{sx:{minWidth:0,flex:1},children:[(0,n.jsx)(o.default,{variant:"subtitle1",fontWeight:700,noWrap:!0,children:e.displayName}),(0,n.jsx)(o.default,{variant:"caption",color:"text.secondary",display:"block",children:"Package model"}),a&&(0,n.jsxs)(i.A,{direction:"row",spacing:.5,alignItems:"center",sx:{mt:.5},children:[(0,n.jsx)(eJ.A,{color:"success",sx:{fontSize:16}}),(0,n.jsx)(o.default,{variant:"caption",color:"success.main",noWrap:!0,children:r?"Using ".concat(r.displayName):"Will be created"})]})]})]})})},e.id)})})]}),(0,n.jsx)(s.default,{"aria-hidden":!0,sx:{display:"grid",placeItems:"center",minHeight:{xs:64,md:360}},children:(0,n.jsx)(s.default,{sx:{width:64,height:64,borderRadius:"50%",display:"grid",placeItems:"center",bgcolor:"primary.main",color:"primary.contrastText",boxShadow:3,transform:{xs:"rotate(90deg)",md:"none"}},children:(0,n.jsx)(eD.A,{sx:{fontSize:38}})})}),(0,n.jsxs)(eR.A,{variant:"outlined",sx:{p:{xs:2,md:3},minHeight:{md:420},bgcolor:"background.default"},children:[(0,n.jsxs)(o.default,{variant:"overline",color:"text.secondary",fontWeight:700,children:["Replace ",ew.displayName]}),(0,n.jsx)(o.default,{variant:"h5",fontWeight:700,sx:{mt:.25,mb:2.5},children:"What would you like to do?"}),(0,n.jsxs)(ez.Ay,{container:!0,spacing:2,children:[(0,n.jsx)(ez.Ay,{item:!0,xs:12,sm:6,children:(0,n.jsx)(d.A,{fullWidth:!0,"aria-label":"Create new one",variant:Object.prototype.hasOwnProperty.call(ea,ew.id)&&""===ea[ew.id]?"contained":"outlined",onClick:()=>eS(ew.id),sx:{minHeight:154,p:2.5,textTransform:"none",alignItems:"stretch",justifyContent:"flex-start",textAlign:"left"},children:(0,n.jsxs)(i.A,{spacing:1,alignItems:"flex-start",children:[(0,n.jsx)(eH.A,{sx:{fontSize:36}}),(0,n.jsx)(o.default,{variant:"h6",fontWeight:700,children:"Create new one"}),(0,n.jsx)(o.default,{variant:"body2",color:Object.prototype.hasOwnProperty.call(ea,ew.id)&&""===ea[ew.id]?"inherit":"text.secondary",children:"Recreate this model in your FLUJO with the package's configuration."})]})})}),(0,n.jsx)(ez.Ay,{item:!0,xs:12,sm:6,children:(0,n.jsx)(d.A,{fullWidth:!0,"aria-label":"Use one of yours",variant:ea[ew.id]?"contained":"outlined",onClick:()=>eo(!0),sx:{minHeight:154,p:2.5,textTransform:"none",alignItems:"stretch",justifyContent:"flex-start",textAlign:"left"},children:(0,n.jsxs)(i.A,{spacing:1,alignItems:"flex-start",children:[(0,n.jsx)(eq.A,{sx:{fontSize:36}}),(0,n.jsx)(o.default,{variant:"h6",fontWeight:700,children:"Use one of yours"}),(0,n.jsx)(o.default,{variant:"body2",color:ea[ew.id]?"inherit":"text.secondary",children:"Connect the package to a model you already have installed."})]})})})]}),ei&&(0,n.jsxs)(s.default,{sx:{mt:2.5},children:[(0,n.jsx)(I.A,{sx:{mb:2}}),(0,n.jsx)(o.default,{variant:"subtitle1",fontWeight:700,sx:{mb:1},children:"Choose one of your installed models"}),ej.installedModels.length>0?(0,n.jsx)(ez.Ay,{container:!0,spacing:1.25,children:ej.installedModels.map(e=>{let t=ea[ew.id]===e.id;return(0,n.jsx)(ez.Ay,{item:!0,xs:12,sm:6,children:(0,n.jsx)(eR.A,{variant:"outlined",sx:{height:"100%",borderWidth:t?2:1,borderColor:t?"primary.main":"divider",bgcolor:t?"action.selected":"background.paper"},children:(0,n.jsx)(eO.A,{onClick:()=>eC(ew.id,e.id),"aria-label":"Use ".concat(e.displayName),sx:{minHeight:76,p:1.5},children:(0,n.jsxs)(i.A,{direction:"row",spacing:1.25,alignItems:"center",children:[(0,n.jsx)(eq.A,{color:t?"primary":"action"}),(0,n.jsxs)(s.default,{sx:{minWidth:0},children:[(0,n.jsx)(o.default,{variant:"subtitle2",fontWeight:700,noWrap:!0,children:e.displayName}),(0,n.jsx)(o.default,{variant:"caption",color:"text.secondary",noWrap:!0,display:"block",children:e.name})]}),t&&(0,n.jsx)(eJ.A,{color:"primary",sx:{ml:"auto !important",flex:"0 0 auto"}})]})})})},e.id)})}):(0,n.jsx)(S.A,{severity:"info",children:"You do not have any installed models yet. Create this package model as new instead."})]})]})]}),(0,n.jsx)(I.A,{sx:{my:3}}),(0,n.jsxs)(i.A,{direction:"row",spacing:1.5,justifyContent:"space-between",alignItems:"center",children:[(0,n.jsx)(d.A,{onClick:ev,children:"Cancel"}),(0,n.jsxs)(i.A,{direction:"row",spacing:1.5,alignItems:"center",children:[!eA&&(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Choose an option for every model to continue."}),(0,n.jsx)(d.A,{variant:"contained",size:"large",disabled:!eA,endIcon:(0,n.jsx)(eD.A,{}),onClick:()=>ed(1),children:"Continue to review"})]})]})]}),1===ec&&(0,n.jsxs)(s.default,{sx:{maxWidth:980,mx:"auto"},children:[(0,n.jsxs)(i.A,{direction:{xs:"column",sm:"row"},spacing:1,alignItems:{sm:"center"},justifyContent:"space-between",sx:{mb:2},children:[(0,n.jsxs)(s.default,{children:[(0,n.jsx)(o.default,{variant:"h4",fontWeight:750,children:"Review and install"}),(0,n.jsx)(o.default,{variant:"body1",color:"text.secondary",children:"Check your model choices and add any package secrets."})]}),ej.models.length>0&&(0,n.jsx)(d.A,{onClick:()=>{var e,t;ed(0),es(null!=(t=null==(e=ej.models.find(e=>!Object.prototype.hasOwnProperty.call(ea,e.id)))?void 0:e.id)?t:ej.models[0].id),eo(!1)},children:"Change model choices"})]}),ej.models.length>0&&(0,n.jsxs)(s.default,{sx:{mb:2.5},children:[(0,n.jsx)(o.default,{variant:"subtitle2",sx:{mb:1},children:"Model plan"}),(0,n.jsx)(ez.Ay,{container:!0,spacing:1.5,children:ej.models.map(e=>{var t;let a=ej.installedModels.find(t=>t.id===ea[e.id]);return(0,n.jsx)(ez.Ay,{item:!0,xs:12,sm:6,children:(0,n.jsx)(eR.A,{variant:"outlined",sx:{p:1.75,height:"100%"},children:(0,n.jsxs)(i.A,{direction:"row",spacing:1.25,alignItems:"center",children:[(0,n.jsxs)(s.default,{sx:{minWidth:0,flex:1},children:[(0,n.jsx)(o.default,{variant:"caption",color:"text.secondary",children:"Package model"}),(0,n.jsx)(o.default,{variant:"subtitle2",noWrap:!0,children:e.displayName})]}),(0,n.jsx)(eD.A,{color:"action"}),(0,n.jsxs)(s.default,{sx:{minWidth:0,flex:1},children:[(0,n.jsx)(o.default,{variant:"caption",color:"text.secondary",children:a?"Your model":"New model"}),(0,n.jsx)(o.default,{variant:"subtitle2",noWrap:!0,children:null!=(t=null==a?void 0:a.displayName)?t:e.displayName})]})]})})},e.id)})})]}),ej.servers.some(e=>e.requiredEnvMissing.length>0)&&(0,n.jsx)(S.A,{severity:"warning",sx:{mb:1.5},children:"Some MCP servers require environment values that aren't covered by a secret below — those servers will install disabled."}),ej.missingGlobals.length>0&&(0,n.jsxs)(S.A,{severity:"warning",sx:{mb:1.5},children:["This package expects host global variable(s) that aren't set yet:"," ",ej.missingGlobals.join(", "),". Set them in Settings after install, or the bound model(s)/server(s) won't have a working API key."]}),(0,n.jsx)(I.A,{sx:{my:2.5}}),ej.secrets.length>0?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(o.default,{variant:"subtitle2",sx:{mb:1},children:"Secrets requested by this package"}),(0,n.jsx)(i.A,{spacing:1.5,sx:{mb:2.5},children:ej.secrets.map(e=>{var t;return(0,n.jsx)(x.A,{size:"small",type:ep[e.key]?"text":"password",label:e.label||e.key,helperText:e.required?"Required — leave blank to install the dependent entity disabled":"Optional",value:null!=(t=ee[e.key])?t:"",onChange:t=>et(a=>({...a,[e.key]:t.target.value})),fullWidth:!0,InputProps:{endAdornment:(0,n.jsx)(f.A,{position:"end",children:(0,n.jsx)(eM.A,{size:"small",tabIndex:-1,"aria-label":ep[e.key]?"Hide secret":"Show secret",onClick:()=>em(t=>({...t,[e.key]:!t[e.key]})),children:ep[e.key]?(0,n.jsx)(eV.A,{fontSize:"small"}):(0,n.jsx)(eB.A,{fontSize:"small"})})})}},e.key)})})]}):(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:2.5},children:"This package doesn't request any secrets."}),(0,n.jsxs)(i.A,{direction:"row",spacing:1,justifyContent:"space-between",children:[(0,n.jsx)(d.A,{onClick:ej.models.length>0?()=>ed(0):ev,disabled:V,children:ej.models.length>0?"Back":"Cancel"}),(0,n.jsx)(d.A,{variant:"contained",color:"primary",size:"large",onClick:()=>void ey(),disabled:V,startIcon:V?(0,n.jsx)(k.default,{size:16}):(0,n.jsx)(e_.A,{}),children:"Install package"})]})]})]}),eu&&(0,n.jsxs)(s.default,{children:[(0,n.jsx)(S.A,{severity:eu.ok?"success":"error",sx:{mb:1},children:eu.ok?'Installed "'.concat(null==(t=eu.package)?void 0:t.name,'": ').concat(eu.created.length," created, ").concat(eu.updated.length," updated, ").concat(eu.disabled.length," disabled."):"Install failed: ".concat(null!=(h=eu.errors[0])?h:"unknown error")}),eu.missingGlobals.length>0&&(0,n.jsxs)(S.A,{severity:"warning",sx:{mb:1},children:["Set these global variable(s) in Settings for the installed entities to work:"," ",eu.missingGlobals.join(", "),"."]}),(0,n.jsx)(d.A,{size:"small",onClick:ev,children:"Close"})]})]})]})]})}let eK=(0,q.h)("frontend/components/Packages");function eY(){let[e,t]=(0,r.useState)(!1),[a,l]=(0,r.useState)(0);return eK.debug("Rendering PackagesManager",{wizardOpen:e}),(0,n.jsxs)(s.default,{sx:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,n.jsxs)(s.default,{sx:{p:2,display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:1,borderColor:"divider"},children:[(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",children:[(0,n.jsx)(o.default,{variant:"h5",children:"Packages"}),(0,n.jsx)(c.A,{label:"experimental",size:"small",color:"warning",variant:"outlined"})]}),(0,n.jsx)(d.A,{variant:"contained",startIcon:(0,n.jsx)(h.A,{}),onClick:()=>t(!0),"data-tour":"packages-create",children:"Create package"})]}),(0,n.jsxs)(s.default,{sx:{flex:1,overflow:"auto",p:3},children:[(0,n.jsxs)(u.A,{variant:"outlined",sx:{p:4,display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",gap:2,maxWidth:{xs:"100%",md:1100},mx:"auto"},children:[(0,n.jsx)(p.A,{sx:{fontSize:48,color:"text.secondary"}}),(0,n.jsx)(o.default,{variant:"h6",children:"Bundle your FLUJO setup into a shareable package"}),(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"A package bundles flows, models, MCP servers (by reference) and planned executions into a single manifest you can export and share. Secret values (API keys, tokens) are never included — only declarations of the secrets a recipient must supply at install time."}),(0,n.jsx)(d.A,{variant:"contained",startIcon:(0,n.jsx)(h.A,{}),onClick:()=>t(!0),children:"Create package"})]}),(0,n.jsxs)(u.A,{variant:"outlined",sx:{p:3,mt:3,maxWidth:{xs:"100%",md:1100},mx:"auto"},children:[(0,n.jsx)(o.default,{variant:"h6",gutterBottom:!0,children:"Package registry account"}),(0,n.jsx)(Y,{})]}),(0,n.jsx)(e$,{onInstalled:()=>l(e=>e+1)}),(0,n.jsx)(eW,{},a)]}),e&&(0,n.jsx)(eE,{open:e,onClose:()=>t(!1)})]})}var eQ=a(9164),eX=a(94929);let e0=(0,q.h)("app/packages/page");function e1(){var e,t;let a=(0,l.useRouter)(),{settings:i,settingsHydrated:o}=(0,eQ.useStorage)(),c=o&&null!=(t=null==i||null==(e=i.experimental)?void 0:e.enabled)&&t;return((0,r.useEffect)(()=>{o&&!c&&(e0.debug("Experimental features disabled — redirecting away from /packages"),a.replace("/settings"))},[o,c,a]),o&&c)?(0,n.jsx)(s.default,{sx:{height:"100%",display:"flex",flexDirection:"column"},children:(0,n.jsx)(eY,{})}):(0,n.jsx)(eX.default,{})}},90057:(e,t,a)=>{"use strict";a.d(t,{g:()=>l});var n=a(74879);let r=(0,a(87021).h)("frontend/services/flow/index");class s{async loadFlows(){r.debug("loadFlows: Entering method");try{if(this.flowsCache)return r.debug("loadFlows: Using cached flows",{count:this.flowsCache.length}),this.flowsCache;let e=await fetch("/api/flow");if(!e.ok){let t=await e.json();throw Error(t.error||"Failed to load flows")}let t=await e.json();return r.debug("loadFlows: Loaded flows from API",{count:t.length}),this.flowsCache=t,t}catch(e){return r.warn("loadFlows: Failed to load flows:",e),[]}}async getFlow(e){r.debug("getFlow: Entering method",{flowId:e});try{if(this.flowsCache){let t=this.flowsCache.find(t=>t.id===e);if(t)return r.debug("getFlow: Using cached flow",{flowId:e}),t}let t=await fetch("/api/flow/".concat(encodeURIComponent(e)));if(!t.ok){if(404===t.status)return r.debug("getFlow: Flow ".concat(e," not found")),null;let a=await t.json();throw Error(a.error||"Failed to get flow: ".concat(e))}let a=await t.json();return r.debug("getFlow: Retrieved flow from API",{flowId:e}),a}catch(t){return r.warn("getFlow: Failed to get flow ".concat(e,":"),t),null}}async addFlow(e){r.debug("addFlow: Entering method",{flowId:e.id,flowName:e.name,nodeCount:e.nodes.length,edgeCount:e.edges.length});try{let t=await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.json();return{success:!1,error:e.error||"Failed to add flow"}}let a=await t.json();return this.flowsCache&&this.flowsCache.push(a),r.debug("addFlow: Flow added successfully",{flowId:e.id}),{success:!0}}catch(e){return r.warn("addFlow: Failed to add flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to add flow"}}}async generateFlow(e,t,a){r.debug("generateFlow: Entering method",{modelId:t,allowInstall:null==a?void 0:a.allowInstall,allowSubflows:null==a?void 0:a.allowSubflows,maxDepth:null==a?void 0:a.maxDepth});try{var n,s,l,i,o,c,d;let u=await fetch("/api/flow/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:e,modelId:t,allowInstall:(null==a?void 0:a.allowInstall)===!0,allowSubflows:(null==a?void 0:a.allowSubflows)!==!1,..."number"==typeof(null==a?void 0:a.maxDepth)?{maxDepth:a.maxDepth}:{}})}),h=await u.json().catch(()=>null);if(!u.ok)return{success:!1,error:(null==h?void 0:h.error)||"Failed to generate flow"};let p=Array.isArray(h.flows)&&h.flows.length>0?h.flows:[{flow:h.flow,validation:h.validation}];return r.debug("generateFlow: Draft generated",{flowId:null==(n=h.flow)?void 0:n.id,flowCount:p.length,attempts:h.attempts,errorCount:null==(s=h.validation)?void 0:s.errorCount,installedServers:null!=(o=null==(l=h.installedServers)?void 0:l.length)?o:0}),{success:!0,flow:h.flow,validation:h.validation,flows:p,rootFlowId:null!=(c=h.rootFlowId)?c:null==(i=h.flow)?void 0:i.id,attempts:h.attempts,installedServers:null!=(d=h.installedServers)?d:[]}}catch(e){return r.warn("generateFlow: Failed to generate flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to generate flow"}}}async improveFlow(e,t,a,n){r.debug("improveFlow: Entering method",{flowId:null==e?void 0:e.id,modelId:a,allowInstall:null==n?void 0:n.allowInstall});try{var s,l,i,o,c,d,u;let h=await fetch("/api/flow/improve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flow:e,relatedFlows:null==n?void 0:n.relatedFlows,description:t,modelId:a,allowInstall:(null==n?void 0:n.allowInstall)===!0})}),p=await h.json().catch(()=>null);if(!h.ok)return{success:!1,error:(null==p?void 0:p.error)||"Failed to improve flow"};return r.debug("improveFlow: Draft revised",{flowId:null==(s=p.flow)?void 0:s.id,attempts:p.attempts,errorCount:null==(l=p.validation)?void 0:l.errorCount,installedServers:null!=(c=null==(i=p.installedServers)?void 0:i.length)?c:0}),{success:!0,flow:p.flow,validation:p.validation,flows:Array.isArray(p.flows)&&p.flows.length>0?p.flows:[{flow:p.flow,validation:p.validation}],rootFlowId:null!=(d=p.rootFlowId)?d:null==(o=p.flow)?void 0:o.id,attempts:p.attempts,installedServers:null!=(u=p.installedServers)?u:[]}}catch(e){return r.warn("improveFlow: Failed to improve flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to improve flow"}}}async updateFlow(e){r.debug("updateFlow: Entering method",{flowId:e.id,flowName:e.name,nodeCount:e.nodes.length,edgeCount:e.edges.length});try{let t=await fetch("/api/flow/".concat(encodeURIComponent(e.id)),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.json();return{success:!1,error:e.error||"Failed to update flow"}}let a=await t.json();if(this.flowsCache){let t=this.flowsCache.findIndex(t=>t.id===e.id);t>=0?this.flowsCache[t]=a:this.flowsCache.push(a)}return r.debug("updateFlow: Flow updated successfully",{flowId:e.id}),{success:!0}}catch(e){return r.warn("updateFlow: Failed to update flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to update flow"}}}async deleteFlow(e){r.debug("deleteFlow: Entering method",{flowId:e});try{let t=await fetch("/api/flow/".concat(encodeURIComponent(e)),{method:"DELETE"});if(!t.ok){let e=await t.json();return{success:!1,error:e.error||"Failed to delete flow"}}return this.flowsCache&&(this.flowsCache=this.flowsCache.filter(t=>t.id!==e)),r.debug("deleteFlow: Flow deleted successfully",{flowId:e}),{success:!0}}catch(e){return r.warn("deleteFlow: Failed to delete flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to delete flow"}}}async listFlowVersions(e){r.debug("listFlowVersions: Entering method",{flowId:e});try{let t=await fetch("/api/flow/".concat(encodeURIComponent(e),"/versions"));if(!t.ok){let e=await t.json().catch(()=>null);throw Error((null==e?void 0:e.error)||"Failed to list flow versions")}let a=await t.json();return Array.isArray(a.versions)?a.versions:[]}catch(t){return r.warn("listFlowVersions: Failed for flow ".concat(e,":"),t),[]}}async getFlowVersion(e,t){r.debug("getFlowVersion: Entering method",{flowId:e,versionId:t});try{let a=await fetch("/api/flow/".concat(encodeURIComponent(e),"/versions/").concat(encodeURIComponent(t)));if(!a.ok){if(404===a.status)return null;let e=await a.json().catch(()=>null);throw Error((null==e?void 0:e.error)||"Failed to get flow version")}return await a.json()}catch(a){return r.warn("getFlowVersion: Failed for ".concat(e,"/").concat(t,":"),a),null}}createNode(e,t){return r.debug("createNode: Entering method",{type:e,position:t}),{id:(0,n.A)(),type:e,position:t,data:{label:"".concat("mcp"===e?"MCP":e.charAt(0).toUpperCase()+e.slice(1)," Node"),type:e,properties:"process"===e?{inputMode:"full-history"}:{}}}}createStartNode(){return{id:(0,n.A)(),type:"start",position:{x:250,y:150},data:{label:"Start Node",type:"start",properties:{promptTemplate:""}}}}createNewFlow(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"NewFlow";r.debug("createNewFlow: Entering method",{name:e});let t=Date.now();return{id:(0,n.A)(),name:e,createdAt:t,updatedAt:t,nodes:[this.createStartNode()],edges:[]}}createHistoryEntry(e,t){return r.debug("createHistoryEntry: Entering method"),{nodes:[...e],edges:[...t]}}generateSampleFlow(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Sample Flow";return r.debug("generateSampleFlow: Entering method",{name:e}),{id:(0,n.A)(),name:e,nodes:[{id:"1",type:"start",position:{x:250,y:50},data:{label:"Start Node",type:"start",properties:{prompt:"Enter your query here",systemMessage:"You are a helpful assistant",temperature:0}}},{id:"2",type:"process",position:{x:250,y:200},data:{label:"Process Node",type:"process",properties:{operation:"transform",enabled:!0}}},{id:"3",type:"finish",position:{x:250,y:350},data:{label:"Finish Node",type:"finish",properties:{format:"json",template:'{ "result": {{data}} }'}}},{id:"4",type:"mcp",position:{x:450,y:200},data:{label:"MCP Node",type:"mcp",properties:{channels:2,mode:"parallel"}}}],edges:[{id:"e1-2",source:"1",target:"2",type:"custom"},{id:"e2-3",source:"2",target:"3",type:"custom"}]}}constructor(){this.flowsCache=null}}let l=new s},93632:(e,t,a)=>{"use strict";a.d(t,{P:()=>s});let n=(0,a(87021).h)("frontend/services/plannedExecutions");class r{async list(){try{let e=await fetch("/api/planned-executions");if(!e.ok)throw Error("HTTP ".concat(e.status));return await e.json()}catch(e){return n.warn("Failed to list planned executions",e),{paused:!1,executions:[]}}}async create(e){try{let t=await fetch("/api/planned-executions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await t.json();if(!t.ok)return{success:!1,error:(null==a?void 0:a.error)||"HTTP ".concat(t.status)};return{success:!0,execution:a.execution}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async update(e,t){try{let a=await fetch("/api/planned-executions/".concat(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),n=await a.json();if(!a.ok)return{success:!1,error:(null==n?void 0:n.error)||"HTTP ".concat(a.status)};return{success:!0,execution:n.execution}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async delete(e){try{let t=await fetch("/api/planned-executions/".concat(e),{method:"DELETE"});if(!t.ok){let e=await t.json().catch(()=>null);return{success:!1,error:(null==e?void 0:e.error)||"HTTP ".concat(t.status)}}return{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async setPaused(e){try{let t=await fetch("/api/planned-executions",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({paused:e})});if(!t.ok){let e=await t.json().catch(()=>null);return{success:!1,error:(null==e?void 0:e.error)||"HTTP ".concat(t.status)}}return{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async runNow(e){try{let t=await fetch("/api/planned-executions/".concat(e,"/run"),{method:"POST"}),a=await t.json();if(!t.ok)return{success:!1,error:(null==a?void 0:a.error)||"HTTP ".concat(t.status)};return{success:!0,record:a.record}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async loadRuns(e){try{let t=await fetch("/api/planned-executions/".concat(e,"/runs"));if(!t.ok)throw Error("HTTP ".concat(t.status));let a=await t.json();return Array.isArray(null==a?void 0:a.runs)?a.runs:[]}catch(t){return n.warn("Failed to load runs for ".concat(e),t),[]}}async previewSchedule(e,t){try{let a=await fetch("/api/planned-executions/preview-schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cron:e,timezone:t})});if(!a.ok)throw Error("HTTP ".concat(a.status));return await a.json()}catch(e){return{valid:!1,error:e instanceof Error?e.message:"Preview failed",nextRuns:[]}}}}let s=new r},94460:(e,t,a)=>{Promise.resolve().then(a.bind(a,70479))}},e=>{e.O(0,[2678,4754,9244,3392,1871,981,2003,9562,488,3272,3077,9581,3659,7328,8551,6428,7264,9951,9164,3772,8441,1255,7358],()=>e(e.s=94460)),_N_E=e.O()}]);
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7262],{70479:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>e1});var n=a(95155),r=a(12115),s=a(94049),l=a(20063),i=a(80777),o=a(25635),c=a(28548),d=a(91871),u=a(2300),h=a(86946),p=a(40047),m=a(33567),g=a(15712),x=a(9562),f=a(56422),y=a(41602),v=a(23820),j=a(73707),w=a(49501),b=a(22822),A=a(17681),k=a(4474),S=a(22003),C=a(41275),E=a(21067),I=a(55606),T=a(86973),F=a(99944),P=a(9957),N=a(2778),z=a(52363),W=a(65036),O=a(95844),R=a(71908),U=a(64246),L=a(75912),H=a(51611),M=a(66087),D=a(57813),q=a(26466),J=a(87021);let _=(0,J.h)("frontend/services/registry");async function G(e){return await e.json().catch(()=>({}))}class B{async getStatus(){let e=await fetch("/api/registry/auth",{method:"GET"});if(!e.ok)throw Error("HTTP ".concat(e.status));return G(e)}async auth(e,t,a,n){let r=await fetch("/api/registry/auth",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e,email:t,password:a,...n?{handle:n}:{}})}),s=await G(r);if(!r.ok&&(null==s?void 0:s.status)===void 0)throw Error((null==s?void 0:s.error)||"HTTP ".concat(r.status));return s}signup(e,t,a){return this.auth("signup",e,t,a)}login(e,t){return this.auth("login",e,t)}async logout(){let e=await fetch("/api/registry/auth",{method:"DELETE"});if(!e.ok)throw Error("HTTP ".concat(e.status))}async beginOAuth(e){let t=await fetch("/api/registry/oauth/initiate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e})}),a=await G(t);if(!t.ok||!(null==a?void 0:a.authorizationUrl))throw Error((null==a?void 0:a.error)||"HTTP ".concat(t.status));return{authorizationUrl:a.authorizationUrl}}async resendConfirmation(e){return G(await fetch("/api/registry/auth/resend",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e?{email:e}:{})}))}async requestPasswordReset(e){return G(await fetch("/api/registry/auth/reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})}))}async getSettings(){let e=await fetch("/api/registry/settings",{method:"GET"});if(!e.ok)throw Error("HTTP ".concat(e.status));return G(e)}async saveSettings(e){return G(await fetch("/api/registry/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:e})}))}async publish(e){let t=await fetch("/api/registry/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({manifest:e})}),a=await G(t);return(null==a?void 0:a.ok)===void 0?(_.warn("Unexpected publish response shape",{status:t.status}),{ok:!1,code:"error",error:"HTTP ".concat(t.status)}):a}async deletePackage(e){let t=await fetch("/api/registry/packages",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({packageId:e})}),a=await G(t);return(null==a?void 0:a.ok)===void 0?(_.warn("Unexpected package deletion response shape",{status:t.status}),{ok:!1,code:"error",error:(null==a?void 0:a.error)||"HTTP ".concat(t.status)}):a}}let V=null,Z=()=>(V||(V=new B),V),$=new Proxy({},{get(e,t){let a=Z(),n=a[t];return"function"==typeof n?n.bind(a):n}}),K=(0,J.h)("frontend/components/Packages/RegistryAccountSettings");function Y(){let[e,t]=(0,r.useState)(null),[a,l]=(0,r.useState)(!0),[u,h]=(0,r.useState)(!1),[p,m]=(0,r.useState)(null),[g,f]=(0,r.useState)("login"),[y,v]=(0,r.useState)(""),[j,w]=(0,r.useState)(""),[b,A]=(0,r.useState)(""),[C,I]=(0,r.useState)(""),[T,F]=(0,r.useState)(""),P=(0,r.useCallback)(async()=>{try{let[e,a]=await Promise.all([$.getStatus(),$.getSettings()]);t(e),F(a.defaultUrl),I(a.usingDefault?"":a.baseUrl)}catch(e){K.warn("Failed to load registry account status",e)}finally{l(!1)}},[]);(0,r.useEffect)(()=>{P()},[P]),(0,r.useEffect)(()=>{let e=new URLSearchParams(window.location.search),t=e.get("registry_oauth");if(!t)return;m("success"===t?{type:"success",text:"Signed in to the package registry."}:{type:"error",text:"OAuth sign-in did not complete. Please try again."}),P(),e.delete("registry_oauth");let a=e.toString();window.history.replaceState({},"",window.location.pathname+(a?"?".concat(a):""))},[P]);let N=async()=>{h(!0),m(null);try{let e="signup"===g?await $.signup(y.trim(),j,b.trim()):await $.login(y.trim(),j);"authenticated"===e.status?(m({type:"success",text:"Signed in to the package registry."}),w("")):"confirmation_required"===e.status?(m({type:"info",text:e.message||"Check your inbox to confirm your email."}),w("")):m({type:"error",text:e.message||"Authentication failed."}),e.account?t(e.account):await P()}catch(e){m({type:"error",text:e instanceof Error?e.message:"Authentication failed."})}finally{h(!1)}},z=async()=>{h(!0),m(null);try{await $.logout(),await P(),m({type:"success",text:"Logged out."})}catch(e){m({type:"error",text:e instanceof Error?e.message:"Failed to log out."})}finally{h(!1)}},W=async e=>{h(!0),m(null);try{let{authorizationUrl:t}=await $.beginOAuth(e);window.location.assign(t)}catch(e){m({type:"error",text:e instanceof Error?e.message:"Failed to start OAuth sign-in."}),h(!1)}},O=async()=>{h(!0),m(null);try{let e=await $.resendConfirmation();m(e.success?{type:"success",text:"Confirmation email sent."}:{type:"error",text:e.message||"Failed to resend confirmation."})}finally{h(!1)}},R=async()=>{let e=y.trim();if(!e)return void m({type:"info",text:"Enter your account email above, then tap “Forgot password?”."});h(!0),m(null);try{await $.requestPasswordReset(e),m({type:"info",text:"If an account exists for that email, a password-reset link is on its way. Follow the link to set a new password."})}catch(e){m({type:"error",text:e instanceof Error?e.message:"Failed to request a password reset."})}finally{h(!1)}},U=async()=>{h(!0),m(null);try{let e=await $.saveSettings(C.trim());m(e.success?{type:"success",text:"Registry URL saved."}:{type:"error",text:e.message||"Invalid registry URL."})}finally{h(!1)}};if(a)return(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",p:3},children:(0,n.jsx)(k.default,{size:28})});let L=!!(null==e?void 0:e.signedIn),H=!!((null==e?void 0:e.email)&&!L&&e&&!e.isConfirmed);return(0,n.jsxs)(s.default,{sx:{width:"100%"},children:[(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Sign in to the FLUJO package registry to publish packages. Browsing and installing packages does not require an account — only publishing does, and your email must be confirmed first. Your registry tokens are encrypted at rest and never shown here."}),p&&(0,n.jsx)(S.A,{severity:p.type,sx:{mb:2},onClose:()=>m(null),children:p.text}),L?(0,n.jsxs)(i.A,{spacing:2,children:[(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",flexWrap:"wrap",useFlexGap:!0,children:[(0,n.jsx)(o.default,{variant:"subtitle1",children:null==e?void 0:e.email}),(null==e?void 0:e.publisherHandle)&&(0,n.jsx)(c.A,{size:"small",label:"@".concat(e.publisherHandle)}),(null==e?void 0:e.isConfirmed)?(0,n.jsx)(c.A,{size:"small",color:"success",label:"Confirmed"}):(0,n.jsx)(c.A,{size:"small",color:"warning",label:"Unconfirmed"})]}),(0,n.jsx)(s.default,{children:(0,n.jsx)(d.A,{variant:"outlined",onClick:z,disabled:u,children:"Log out"})})]}):H?(0,n.jsxs)(i.A,{spacing:2,children:[(0,n.jsxs)(S.A,{severity:"info",children:["We sent a confirmation link to ",(0,n.jsx)("strong",{children:null==e?void 0:e.email}),". Confirm your email, then log in to start publishing."]}),(0,n.jsxs)(i.A,{direction:"row",spacing:1,children:[(0,n.jsx)(d.A,{variant:"outlined",onClick:O,disabled:u,children:"Resend confirmation email"}),(0,n.jsx)(d.A,{onClick:z,disabled:u,children:"Use a different account"})]})]}):(0,n.jsxs)(i.A,{spacing:2,children:[(0,n.jsxs)(D.A,{value:g,onChange:(e,t)=>f(t),children:[(0,n.jsx)(q.A,{value:"login",label:"Log in"}),(0,n.jsx)(q.A,{value:"signup",label:"Sign up"})]}),(0,n.jsx)(x.A,{label:"Email",type:"email",value:y,onChange:e=>v(e.target.value),fullWidth:!0,autoComplete:"username"}),(0,n.jsx)(x.A,{label:"Password",type:"password",value:j,onChange:e=>w(e.target.value),fullWidth:!0,autoComplete:"signup"===g?"new-password":"current-password"}),"signup"===g&&(0,n.jsx)(x.A,{label:"Publisher handle",value:b,onChange:e=>A(e.target.value),fullWidth:!0,autoComplete:"username",helperText:"A unique handle for publishing packages, e.g. your-name"}),(0,n.jsx)(s.default,{children:(0,n.jsx)(d.A,{variant:"contained",onClick:N,disabled:u||!y.trim()||!j||"signup"===g&&!b.trim(),children:"signup"===g?"Sign up":"Log in"})}),"login"===g&&(0,n.jsx)(s.default,{children:(0,n.jsx)(d.A,{variant:"text",size:"small",onClick:R,disabled:u,sx:{textTransform:"none",px:0},children:"Forgot password?"})}),(0,n.jsx)(E.A,{children:"or"}),(0,n.jsx)(i.A,{direction:"row",spacing:1,flexWrap:"wrap",useFlexGap:!0,children:(0,n.jsx)(d.A,{variant:"outlined",onClick:()=>W("github"),disabled:u,children:"Continue with GitHub"})})]}),(0,n.jsx)(E.A,{sx:{my:3}}),(0,n.jsx)(o.default,{variant:"subtitle2",gutterBottom:!0,children:"Registry URL"}),(0,n.jsxs)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:1},children:["Leave blank to use the default (",T,")."]}),(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",flexWrap:"wrap",useFlexGap:!0,children:[(0,n.jsx)(x.A,{size:"small",placeholder:T,value:C,onChange:e=>I(e.target.value),sx:{minWidth:320}}),(0,n.jsx)(d.A,{variant:"outlined",onClick:U,disabled:u,children:"Save"})]})]})}var Q=a(90057),X=a(43076),ee=a(17897),et=a(93632);let ea=(0,J.h)("frontend/services/packages");class en{async resolve(e){let t=await fetch("/api/packages/resolve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await t.json();if(!t.ok)throw Error((null==a?void 0:a.error)||"HTTP ".concat(t.status));return a}async deriveSecrets(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=await fetch("/api/packages/derive-secrets",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({selection:e,modelIdentifier:t.modelIdentifier,enableEntropy:t.enableEntropy,enableRepoSlug:t.enableRepoSlug})}),n=await a.json();if(!a.ok)throw Error((null==n?void 0:n.error)||"HTTP ".concat(a.status));return n}async scanTargets(e){var t;let a=await fetch("/api/packages/scan-targets",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({selection:e})}),n=await a.json();if(!a.ok)throw Error((null==n?void 0:n.error)||"HTTP ".concat(a.status));return null!=(t=null==n?void 0:n.candidates)?t:[]}async searchRegistry(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new URLSearchParams;e.q&&t.set("q",e.q),e.tag&&t.set("tag",e.tag),e.page&&t.set("page",String(e.page)),e.pageSize&&t.set("pageSize",String(e.pageSize));let a=await fetch("/api/packages/search".concat(t.toString()?"?".concat(t.toString()):"")),n=await a.json();if(!a.ok&&!(null==n?void 0:n.items))throw Error((null==n?void 0:n.error)||"HTTP ".concat(a.status));return n}async installFromRegistry(e){let t=await fetch("/api/packages/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:"registry",...e})}),a=await t.json();if(!t.ok&&(null==a?void 0:a.ok)===void 0)throw Error((null==a?void 0:a.error)||"HTTP ".concat(t.status));return a}async build(e,t){var a;let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],l=await fetch("/api/packages/build",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({selection:e,metadata:t,acceptedSecrets:n,globals:r,excludedSecrets:s})}),i=null!=(a=l.headers.get("content-type"))?a:"";if(!i.includes("application/json")){let e=await l.text();throw ea.error("Package build returned a non-JSON response",{status:l.status,contentType:i,preview:e.slice(0,200)}),Error("Package build failed: HTTP ".concat(l.status," returned a non-JSON response"))}let o=await l.json();if(!l.ok&&(null==o?void 0:o.ok)===void 0)throw Error((null==o?void 0:o.error)||"HTTP ".concat(l.status));return o}}let er=null,es=()=>(er||(er=new en),er),el=new Proxy({},{get(e,t){let a=es(),n=a[t];return"function"==typeof n?n.bind(a):n}}),ei=/\{\{secret\.([A-Za-z0-9_.-]+)\}\}/g,eo="encrypted:",ec=/^[A-Za-z0-9_.-]+$/,ed=["path","repo","token","email","url-cred","name","other"];function eu(e){let t=new Set,a=e=>{if("string"==typeof e){for(let a of function(e){let t;if("string"!=typeof e)return[];let a=[],n=RegExp(ei.source,"g");for(;null!==(t=n.exec(e));)a.includes(t[1])||a.push(t[1]);return a}(e))t.add(a);return}if(Array.isArray(e)){for(let t of e)a(t);return}if(e&&"object"==typeof e)for(let t of Object.values(e))a(t)};return a(e),Array.from(t)}var eh=a(2750);let ep=eh.object({name:eh.string().min(1).regex(ec,"invalid secret name"),description:eh.string().optional(),required:eh.boolean(),default:eh.string().optional()}).strict(),em=eh.object({name:eh.string().min(1).regex(ec,"invalid global variable name"),description:eh.string().optional(),required:eh.boolean(),isSecret:eh.boolean().optional()}).strict(),eg=eh.discriminatedUnion("kind",[eh.object({kind:eh.literal("secret"),secret:eh.string().min(1)}).strict(),eh.object({kind:eh.literal("global"),var:eh.string().min(1)}).strict(),eh.object({kind:eh.literal("none")}).strict()]),ex=eh.object({id:eh.string().min(1),name:eh.string().min(1),displayName:eh.string().optional(),description:eh.string().optional(),baseUrl:eh.string().optional(),provider:eh.string().optional(),adapter:eh.string().optional(),promptTemplate:eh.string().optional(),reasoningSchema:eh.string().optional(),temperature:eh.string().optional(),reasoningEffort:eh.enum(["minimal","low","medium","high","xhigh","max","ultra"]).optional(),thinkingLevel:eh.enum(["minimal","low","medium","high"]).optional(),thinkingBudget:eh.number().int().min(-1).optional(),serviceTier:eh.enum(["default","priority"]).optional(),functionCallingSchema:eh.string().optional(),contextWindow:eh.number().optional(),maxTurns:eh.number().optional(),maxTokens:eh.number().optional(),folder:eh.string().optional(),favorite:eh.boolean().optional(),apiKeyRef:eg}).strict(),ef=eh.object({sourceType:eh.enum(["github","registry","marketplace","remote"]),ref:eh.string().optional(),url:eh.string().optional(),name:eh.string().optional()}).strict().superRefine((e,t)=>{"remote"!==e.sourceType||e.url||t.addIssue({code:"custom",message:"installOrigin 'remote' requires a url"}),"github"!==e.sourceType&&"registry"!==e.sourceType||e.ref||t.addIssue({code:"custom",message:"installOrigin '".concat(e.sourceType,"' requires a ref")})}),ey=eh.object({name:eh.string().min(1),isSecret:eh.boolean(),secretRef:eh.string().optional(),globalVar:eh.string().optional(),globalTemplate:eh.string().optional()}).strict().superRefine((e,t)=>{void 0===e.globalTemplate||/\$\{global:[A-Za-z0-9_.-]+\}/.test(e.globalTemplate)||t.addIssue({code:"custom",path:["globalTemplate"],message:"globalTemplate must contain at least one ${global:NAME} reference"})}),ev=eh.object({index:eh.number().int().nonnegative(),value:eh.string().min(1)}).strict().superRefine((e,t)=>{/\$\{global:[A-Za-z0-9_.-]+\}/.test(e.value)||t.addIssue({code:"custom",path:["value"],message:"argument template must contain at least one ${global:NAME} reference"})}),ej=eh.object({name:eh.string().min(1),transport:eh.enum(["stdio","sse","streamable","websocket"]),disabled:eh.boolean().optional(),autoApprove:eh.array(eh.string()).optional(),folder:eh.string().optional(),installOrigin:ef,envDeclarations:eh.array(ey),headerDeclarations:eh.array(ey).optional(),argTemplates:eh.array(ev).optional()}).strict(),ew=eh.object({flow:eh.object({id:eh.string().min(1),name:eh.string().min(1),nodes:eh.array(eh.any()),edges:eh.array(eh.any())}).catchall(eh.unknown()),references:eh.object({flowIds:eh.array(eh.string()).optional(),modelIds:eh.array(eh.string()).optional(),mcpServerNames:eh.array(eh.string()).optional()}).optional()}),eb=eh.object({id:eh.string().min(1),name:eh.string().min(1),enabled:eh.boolean(),flowId:eh.string().min(1),prompt:eh.string(),trigger:eh.any()}).catchall(eh.unknown()),eA=eh.object({schemaVersion:eh.literal(1),id:eh.string().min(1),name:eh.string().min(1),description:eh.string().optional(),version:eh.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?(?:\+[0-9A-Za-z-.]+)?$/,"version must be valid semver"),author:eh.string().optional(),publisher:eh.string().optional(),tags:eh.array(eh.string()).optional(),requiredGlobals:eh.array(eh.string()).optional(),globals:eh.array(em).optional(),secrets:eh.array(ep),models:eh.array(ex),mcpServers:eh.array(ej),flows:eh.array(ew),plannedExecutions:eh.array(eb)}).superRefine((e,t)=>{(function e(t){return"string"==typeof t?t.startsWith(eo):Array.isArray(t)?t.some(e):!!t&&"object"==typeof t&&Object.values(t).some(e)})(e)&&t.addIssue({code:"custom",message:"package contains an '".concat(eo,"' value; secret material must never be serialized")});let a=new Set(e.secrets.map(e=>e.name)),n=new Set(eu(e));for(let t of e.models)"secret"===t.apiKeyRef.kind&&n.add(t.apiKeyRef.secret);for(let t of e.mcpServers){var r;for(let e of[...t.envDeclarations,...null!=(r=t.headerDeclarations)?r:[]])e.secretRef&&n.add(e.secretRef)}for(let e of n)a.has(e)||t.addIssue({code:"custom",message:'secret "'.concat(e,'" is referenced but not declared in secrets[]')});let s=new Set(e.flows.map(e=>e.flow.id));e.plannedExecutions.forEach((e,a)=>{s.has(e.flowId)||t.addIssue({code:"custom",path:["plannedExecutions",a,"flowId"],message:'plannedExecution "'.concat(e.name,'" references unknown flow id "').concat(e.flowId,'"')})}),e.flows.forEach((e,a)=>{var n,r;for(let l of null!=(r=null==(n=e.references)?void 0:n.flowIds)?r:[])s.has(l)||t.addIssue({code:"custom",path:["flows",a,"references","flowIds"],message:'flow "'.concat(e.flow.name,'" references unknown subflow id "').concat(l,'"')})})}),ek=(0,J.h)("frontend/components/Packages/PackageWizard"),eS=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?(?:\+[0-9A-Za-z-.]+)?$/,eC=["Select contents","Resolve & validate","Secret review","Metadata","Export"];function eE(e){return e.replace(/^SECRET_/,"")}function eI(e){let{open:t,onClose:a}=e,l=(0,m.A)(),u=(0,g.A)(l.breakpoints.down("sm")),[h,p]=(0,r.useState)(0),[D,q]=(0,r.useState)({flows:[],models:[],mcpServers:[],plannedExecutions:[]}),[J,_]=(0,r.useState)(!0),[G,B]=(0,r.useState)(new Set),[V,$]=(0,r.useState)(new Set),[K,ea]=(0,r.useState)(new Set),[en,er]=(0,r.useState)(new Set),[el,ei]=(0,r.useState)(""),[eo,eh]=(0,r.useState)(""),[ep,em]=(0,r.useState)(""),[eg,ex]=(0,r.useState)(""),[ef,ey]=(0,r.useState)(null),[ev,ej]=(0,r.useState)([]),[ew,eb]=(0,r.useState)(!1),[eI,eT]=(0,r.useState)(null),[eF,eP]=(0,r.useState)(null),[eN,ez]=(0,r.useState)({}),[eW,eO]=(0,r.useState)(new Set),[eR,eU]=(0,r.useState)([]),[eL,eH]=(0,r.useState)(!1),[eM,eD]=(0,r.useState)(!1),[eq,eJ]=(0,r.useState)(null),[e_,eG]=(0,r.useState)([]),[eB,eV]=(0,r.useState)(""),[eZ,e$]=(0,r.useState)(""),[eK,eY]=(0,r.useState)(!1),[eQ,eX]=(0,r.useState)(!1),[e0,e1]=(0,r.useState)(""),[e2,e5]=(0,r.useState)(""),[e4,e3]=(0,r.useState)("other"),[e6,e7]=(0,r.useState)(null),[e9,e8]=(0,r.useState)(!1),[te,tt]=(0,r.useState)(!1),[ta,tn]=(0,r.useState)(null),[tr,ts]=(0,r.useState)([]),[tl,ti]=(0,r.useState)(""),[to,tc]=(0,r.useState)(!1),[td,tu]=(0,r.useState)(""),[th,tp]=(0,r.useState)("1.0.0"),[tm,tg]=(0,r.useState)(""),[tx,tf]=(0,r.useState)(""),[ty,tv]=(0,r.useState)(!1),[tj,tw]=(0,r.useState)(null),[tb,tA]=(0,r.useState)(null),[tk,tS]=(0,r.useState)(!1),[tC,tE]=(0,r.useState)(null);(0,r.useEffect)(()=>{if(!t)return;let e=!1;return(async()=>{_(!0);try{var t;let[a,n,r,s]=await Promise.all([Q.g.loadFlows(),X.N.loadModels(),ee.S.loadServerConfigs(),et.P.list()]);if(e)return;let l=Array.isArray(r)?r:[];q({flows:(null!=a?a:[]).map(e=>({id:e.id,label:e.name||e.id})),models:(null!=n?n:[]).map(e=>({id:e.id,label:e.displayName||e.name||e.id})),mcpServers:l.map(e=>({id:e.name,label:e.name})),plannedExecutions:(null!=(t=null==s?void 0:s.executions)?t:[]).map(e=>({id:e.execution.id,label:e.execution.name||e.execution.id}))})}catch(e){ek.warn("Failed to load packageable entities",e)}finally{e||_(!1)}})(),()=>{e=!0}},[t]);let tI=(0,r.useMemo)(()=>({flowIds:Array.from(G),modelIds:Array.from(V),mcpServerNames:Array.from(K),plannedExecutionIds:Array.from(en)}),[G,V,K,en]),tT=0===G.size&&0===V.size&&0===K.size&&0===en.size,tF=e=>t=>{e(e=>{let a=new Set(e);return a.has(t)?a.delete(t):a.add(t),a})},tP=(0,r.useCallback)(async e=>{let t;ej([]);try{t=await e.text()}catch(e){ej([e instanceof Error?e.message:"Failed to read the file"]);return}let a=function(e){let t;try{t=JSON.parse(e)}catch(e){return{ok:!1,errors:["Not valid JSON: ".concat(e instanceof Error?e.message:String(e))]}}let a=function(e){let t=eA.safeParse(e);if(!t.success)return{success:!1,errors:t.error.issues.map(e=>{let t=e.path.join(".");return t?"".concat(t,": ").concat(e.message):e.message})};let a=t.data;return{success:!0,data:a,warnings:function(e){let t=new Set(eu(e));for(let a of e.models)"secret"===a.apiKeyRef.kind&&t.add(a.apiKeyRef.secret);for(let n of e.mcpServers){var a;for(let e of[...n.envDeclarations,...null!=(a=n.headerDeclarations)?a:[]])e.secretRef&&t.add(e.secretRef)}return e.secrets.filter(e=>!t.has(e.name)).map(e=>'secret "'.concat(e.name,'" is declared but never referenced'))}(a)}}(t);if(!a.success||!a.data){var n;return{ok:!1,errors:null!=(n=a.errors)?n:["Not a valid FLUJO package manifest"]}}return{ok:!0,package:a.data}}(t);if(!a.ok){ey(null),ej(a.errors.slice(0,8));return}let n=function(e,t){var a,n,r,s,l,i,o,c,d,u;let h=new Set(t.flowIds),p=new Set(t.modelIds),m=new Set(t.mcpServerNames),g=new Set(t.plannedExecutionIds),x=[],f={flowIds:[],modelIds:[],mcpServerNames:[],plannedExecutionIds:[]};for(let t of null!=(a=e.flows)?a:[]){let e=null==t||null==(n=t.flow)?void 0:n.id;e&&(h.has(e)?f.flowIds.push(e):x.push({type:"flow",label:(null==(r=t.flow)?void 0:r.name)?"".concat(t.flow.name," (").concat(e,")"):e}))}for(let t of null!=(s=e.models)?s:[])(null==t?void 0:t.id)&&(p.has(t.id)?f.modelIds.push(t.id):x.push({type:"model",label:t.displayName||t.name||t.id}));for(let t of null!=(l=e.mcpServers)?l:[])(null==t?void 0:t.name)&&(m.has(t.name)?f.mcpServerNames.push(t.name):x.push({type:"mcpServer",label:t.name}));for(let t of null!=(i=e.plannedExecutions)?i:[]){let e=null==t?void 0:t.id;e&&(g.has(e)?f.plannedExecutionIds.push(e):x.push({type:"plannedExecution",label:t.name||e}))}return{selection:f,metadata:{name:null!=(o=e.name)?o:"",version:null!=(c=e.version)?c:"",description:null!=(d=e.description)?d:"",tags:e.tags?[...e.tags]:[]},secretNames:(null!=(u=e.secrets)?u:[]).map(e=>e.name).filter(Boolean),missing:x}}(a.package,{flowIds:D.flows.map(e=>e.id),modelIds:D.models.map(e=>e.id),mcpServerNames:D.mcpServers.map(e=>e.id),plannedExecutionIds:D.plannedExecutions.map(e=>e.id)});B(new Set(n.selection.flowIds)),$(new Set(n.selection.modelIds)),ea(new Set(n.selection.mcpServerNames)),er(new Set(n.selection.plannedExecutionIds)),tu(n.metadata.name),tp(n.metadata.version),tg(n.metadata.description),tf(n.metadata.tags.join(", ")),eT(null),eP(null),ez({}),eO(new Set),eU([]),eD(!1),eJ(null),eG([]),tw(null),tA(null),tE(null),ey(n),ek.info("Imported package manifest into the wizard",{name:n.metadata.name,version:n.metadata.version,missing:n.missing.length})},[D]),tN=(0,r.useCallback)(async()=>{eb(!0),eP(null),eT(null),ez({}),eO(new Set),eU([]),eD(!1),eJ(null),eG([]);try{var e;let t=await es().resolve(tI);eT(t),ez(Object.fromEntries((null!=(e=t.globals)?e:[]).map(e=>{var t;return[e.name,null!=(t=e.description)?t:""]})))}catch(e){eP(e instanceof Error?e.message:"Failed to resolve dependencies")}finally{eb(!1)}},[tI]),tz=(0,r.useMemo)(()=>ef?new Set(ef.secretNames):null,[ef]),tW=(0,r.useCallback)(async e=>{eH(!0),eJ(null);try{var t;let a=await es().deriveSecrets(tI,{modelIdentifier:e,enableEntropy:eK,enableRepoSlug:eQ});eU(e=>{let t=new Map(e.map(e=>[e.id,e.accepted])),n=new Map(e.map(e=>[e.id,e.suggestedSecretName])),r=e.filter(e=>"manual"===e.source),s=a.proposals.map(e=>{var a;return{...e,accepted:t.has(e.id)?t.get(e.id):tz?tz.has(e.suggestedSecretName):"low"!==e.confidence,suggestedSecretName:null!=(a=n.get(e.id))?a:e.suggestedSecretName}}),l=new Set(s.map(e=>e.id));return[...s,...r.filter(e=>!l.has(e.id))]}),eG(null!=(t=a.warnings)?t:[])}catch(e){eJ(e instanceof Error?e.message:"Failed to derive secrets")}finally{eH(!1),eD(!0)}},[tI,eK,eQ,tz]),tO=e=>eU(t=>t.map(t=>({...t,accepted:e}))),tR=()=>{e7(null);let e=function(e){var t,a,n,r,s;let l=(null!=(a=e.excerpt)?a:"").trim();if(!l||l.length>2e3)return null;let i=(null!=(n=e.secretName)?n:"").trim();if(i.length>128)return null;let o=null!=(r=e.kind)?r:"other",c=ec.test(i)?i.toUpperCase():function(e,t){let a="".concat(e,"_").concat(t).toUpperCase().replace(/[^A-Z0-9_.-]+/g,"_").replace(/^[_.-]+|[_.-]+$/g,"")||"".concat(e,"_SECRET");return ec.test(a)?a:"".concat(e,"_SECRET")}("SECRET",i||l.slice(0,16)),d=(null!=(s=e.location)?s:"manual").trim()||"manual";return{id:"sp_".concat(function(e){let t=5381;for(let a=0;a<e.length;a++)t=(t<<5)+t^e.charCodeAt(a);return(t>>>0).toString(16).padStart(8,"0")}("".concat(d,"\0").concat(l))),location:d,excerpt:l,kind:o,source:"manual",confidence:"high",suggestedSecretName:c,suggestedDescription:(null==(t=e.description)?void 0:t.trim())||void 0,rationale:"Added manually",accepted:!0}}({excerpt:e0,secretName:e2,kind:e4});if(!e)return void e7("Enter a non-empty value to redact (under 2000 characters).");eU(t=>t.some(t=>t.id===e.id)?t:[e,...t]),e1(""),e5(""),e3("other")},tU=(0,r.useCallback)(async()=>{e8(!0),tn(null),ti(""),tt(!0);try{let e=await es().scanTargets(tI);ts(e)}catch(e){tn(e instanceof Error?e.message:"Failed to load candidate values"),ts([])}finally{tt(!1)}},[tI]),tL=(0,r.useMemo)(()=>{let e=tl.trim().toLowerCase();return e?tr.filter(t=>"".concat(t.text," ").concat(t.location," ").concat(t.source).toLowerCase().includes(e)):tr},[tr,tl]),tH=(0,r.useMemo)(()=>{let e=new Map;for(let t of eR){let a="".concat(t.kind,"::").concat(t.excerpt),n=e.get(a);n?(n.ids.push(t.id),n.locations.push(t.location)):e.set(a,{key:a,ids:[t.id],locations:[t.location],kind:t.kind,source:t.source,confidence:t.confidence,excerpt:t.excerpt,suggestedSecretName:t.suggestedSecretName,rationale:t.rationale,accepted:t.accepted})}return Array.from(e.values())},[eR]),tM=(0,r.useMemo)(()=>{let e=eZ.trim().toLowerCase();return e?tH.filter(t=>"".concat(t.excerpt," ").concat(t.locations.join(" ")," ").concat(t.kind," ").concat(t.suggestedSecretName).toLowerCase().includes(e)):tH},[tH,eZ]),tD=(0,r.useMemo)(()=>{var e;if(!ef||!eM)return[];let t=new Set([...(null!=(e=null==eI?void 0:eI.secrets)?e:[]).map(e=>e.name),...eR.map(e=>e.suggestedSecretName)]);return ef.secretNames.filter(e=>!t.has(e))},[ef,eM,eI,eR]),tq=(0,r.useMemo)(()=>{var e;let t=new Map;for(let a of tH)t.set(a.kind,(null!=(e=t.get(a.kind))?e:0)+1);return Array.from(t.entries()).sort((e,t)=>t[1]-e[1])},[tH]);(0,r.useEffect)(()=>{2!==h||!eI||eM||eL||tW()},[h,eI,eM,eL,tW]);let tJ=(0,r.useCallback)(async()=>{tv(!0),tA(null),tw(null);try{var e;let t=tx.split(",").map(e=>e.trim()).filter(Boolean),a=await es().build(tI,{id:"pkg-".concat(Date.now()),name:td.trim(),version:th.trim(),description:tm.trim()||void 0,tags:t.length?t:void 0},eR.filter(e=>e.accepted),(null!=(e=null==eI?void 0:eI.globals)?e:[]).map(e=>{var t;return{...e,description:(null==(t=eN[e.name])?void 0:t.trim())||e.description}}),Array.from(eW));tw(a),a.ok||tA(a.errors&&a.errors[0]||"Package build failed")}catch(e){tA(e instanceof Error?e.message:"Failed to build package")}finally{tv(!1)}},[tI,td,th,tm,tx,eR,eI,eN,eW]),t_=(0,r.useCallback)(async()=>{if(null==tj?void 0:tj.json){tS(!0),tE(null);try{let e=JSON.parse(tj.json),t=await Z().publish(e);tE(t)}catch(e){tE({ok:!1,code:"error",error:e instanceof Error?e.message:"Failed to publish package"})}finally{tS(!1)}}},[tj]),tG=()=>{if(!(null==tj?void 0:tj.json))return;let e=new Blob([tj.json],{type:"application/json"}),t=URL.createObjectURL(e),a=document.createElement("a");a.href=t;let n=td.trim().replace(/[^A-Za-z0-9_.-]+/g,"-").replace(/^-+|-+$/g,"")||"package";a.download="".concat(n,"-").concat(th.trim(),".flujo-package.json"),document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(t)},tB=async()=>{if(0===h){await tN(),p(1);return}if(3===h){p(4),await tJ();return}p(e=>Math.min(e+1,eC.length-1))},tV=eS.test(th.trim()),tZ=td.trim().length>0&&tV,t$=!!(eI&&!eI.mcp.ok),tK=0===h?tT||ew:1===h?ew||!!eF||t$:3===h?!tZ:4===h,tY=(e,t,a,r,l,i)=>{let d=l.trim().toLowerCase(),u=d?t.filter(e=>e.label.toLowerCase().includes(d)):t;return(0,n.jsxs)(s.default,{sx:{flex:1,minWidth:240},children:[(0,n.jsxs)(o.default,{variant:"subtitle2",gutterBottom:!0,children:[e," ",a.size>0&&(0,n.jsx)(c.A,{label:a.size,size:"small"})]}),(0,n.jsx)(x.A,{size:"small",fullWidth:!0,placeholder:"Search ".concat(e.toLowerCase(),"…"),value:l,onChange:e=>i(e.target.value),InputProps:{startAdornment:(0,n.jsx)(f.A,{position:"start",children:(0,n.jsx)(H.A,{fontSize:"small"})})},sx:{mb:1}}),0===t.length?(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"None available"}):0===u.length?(0,n.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["No matches for “",l,"”."]}):(0,n.jsx)(y.A,{dense:!0,sx:{maxHeight:{xs:240,md:"45vh"},overflow:"auto",border:1,borderColor:"divider",borderRadius:1},children:u.map(e=>(0,n.jsx)(v.Ay,{disablePadding:!0,children:(0,n.jsxs)(j.A,{onClick:()=>r(e.id),dense:!0,children:[(0,n.jsx)(w.A,{sx:{minWidth:36},children:(0,n.jsx)(b.A,{edge:"start",checked:a.has(e.id),tabIndex:-1,disableRipple:!0})}),(0,n.jsx)(A.A,{primary:e.label})]})},e.id))})]})};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(N.A,{open:t,onClose:a,maxWidth:"lg",fullWidth:!0,fullScreen:u,PaperProps:{sx:{height:u?"100%":"90vh",maxHeight:u?"100%":"90vh"}},children:[(0,n.jsx)(z.A,{children:"Create package"}),(0,n.jsxs)(W.A,{dividers:!0,sx:{overflow:"auto"},children:[(0,n.jsx)(O.A,{activeStep:h,sx:{mb:3},children:eC.map(e=>(0,n.jsx)(R.A,{children:(0,n.jsx)(U.A,{children:e})},e))}),(()=>{switch(h){case 0:return J?(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",p:4},children:(0,n.jsx)(k.default,{})}):(0,n.jsxs)(i.A,{spacing:2,children:[(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Pick the entities to include. Dependencies (subflows, referenced models and MCP servers, planned-execution flows) are pulled in automatically in the next step."}),(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",flexWrap:"wrap",useFlexGap:!0,children:[(0,n.jsxs)(d.A,{component:"label",variant:"outlined",startIcon:(0,n.jsx)(M.A,{}),children:["Import manifest (.json)",(0,n.jsx)("input",{type:"file",accept:"application/json,.json",hidden:!0,onChange:e=>{var t;let a=null==(t=e.target.files)?void 0:t[0];e.target.value="",a&&tP(a)}})]}),(0,n.jsx)(o.default,{variant:"caption",color:"text.secondary",children:"Restores the selection, metadata and accepted secrets from a package you exported earlier."})]}),ev.length>0&&(0,n.jsxs)(S.A,{severity:"error",onClose:()=>ej([]),children:[(0,n.jsx)(C.A,{children:"Could not import that file"}),ev.map((e,t)=>(0,n.jsx)("div",{children:e},t))]}),ef&&(0,n.jsxs)(S.A,{severity:ef.missing.length>0?"warning":"success",children:[(0,n.jsxs)(C.A,{children:["Imported “",ef.metadata.name,"” v",ef.metadata.version]}),"Restored ",ef.selection.flowIds.length," flow(s),"," ",ef.selection.modelIds.length," model(s),"," ",ef.selection.mcpServerNames.length," MCP server(s),"," ",ef.selection.plannedExecutionIds.length," planned execution(s) and"," ",ef.secretNames.length," secret name(s).",ef.missing.length>0&&(0,n.jsxs)(s.default,{sx:{mt:1},children:["No longer on this host (left unselected):",ef.missing.map((e,t)=>(0,n.jsxs)("div",{children:[e.type,": ",e.label]},t))]})]}),(0,n.jsxs)(i.A,{direction:"row",spacing:2,flexWrap:"wrap",useFlexGap:!0,children:[tY("Flows",D.flows,G,tF(B),el,ei),tY("Models",D.models,V,tF($),eo,eh),tY("MCP servers",D.mcpServers,K,tF(ea),ep,em),tY("Planned executions",D.plannedExecutions,en,tF(er),eg,ex)]})]});case 1:if(ew)return(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",p:4},children:(0,n.jsx)(k.default,{})});if(eF)return(0,n.jsx)(S.A,{severity:"error",children:eF});if(!eI)return null;return(0,n.jsxs)(i.A,{spacing:2,children:[t$&&(0,n.jsxs)(S.A,{severity:"error",children:[(0,n.jsx)(C.A,{children:"Local MCP server(s) cannot be packaged"}),eI.mcp.errors.map((e,t)=>(0,n.jsx)("div",{children:e},t))]}),eI.resolved.autoAdded.length>0&&(0,n.jsxs)(S.A,{severity:"info",children:[(0,n.jsx)(C.A,{children:"Automatically included dependencies"}),eI.resolved.autoAdded.map((e,t)=>(0,n.jsxs)("div",{children:[e.type,": ",(0,n.jsx)("code",{children:e.id})," — ",e.reason]},t))]}),eI.resolved.warnings.length>0&&(0,n.jsxs)(S.A,{severity:"warning",children:[(0,n.jsx)(C.A,{children:"Warnings"}),eI.resolved.warnings.map((e,t)=>(0,n.jsx)("div",{children:e},t))]}),(0,n.jsx)(E.A,{}),(0,n.jsxs)(o.default,{variant:"body2",children:["Resolved: ",eI.resolved.flowIds.length," flow(s),"," ",eI.resolved.modelIds.length," model(s),"," ",eI.resolved.mcpServerNames.length," MCP server(s),"," ",eI.resolved.plannedExecutionIds.length," planned execution(s)."]}),eI.mcp.servers.length>0&&(0,n.jsx)(i.A,{direction:"row",spacing:1,flexWrap:"wrap",useFlexGap:!0,children:eI.mcp.servers.map(e=>(0,n.jsx)(c.A,{label:"".concat(e.name," \xb7 ").concat(e.sourceType),size:"small",color:"success",variant:"outlined"},e.name))})]});case 2:var e;return(0,n.jsxs)(i.A,{spacing:2,children:[(0,n.jsx)(o.default,{variant:"subtitle2",children:"Global variables"}),(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Global variables referenced by the package. Add a useful description for each one; installers will supply values and FLUJO will create them in Global Variables."}),eI&&0!==(null!=(e=eI.globals)?e:[]).length?(0,n.jsx)(i.A,{spacing:1.5,children:eI.globals.map(e=>{var t;return(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"flex-start",children:[(0,n.jsx)(x.A,{size:"small",label:e.name,value:null!=(t=eN[e.name])?t:"",onChange:t=>ez(a=>({...a,[e.name]:t.target.value})),helperText:e.isSecret?"Secret global; its value is never included in the package":"Description shown during package installation",fullWidth:!0}),e.isSecret&&(0,n.jsx)(c.A,{label:"secret global",size:"small",color:"warning",variant:"outlined"})]},e.name)})}):(0,n.jsx)(S.A,{severity:"success",children:"No global variables referenced by this package."}),(0,n.jsx)(E.A,{}),(0,n.jsx)(o.default,{variant:"subtitle2",children:"Declared secrets (entity keys)"}),(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Secrets the package will declare from model API keys and MCP env/headers. Values are never included — whoever installs must supply them."}),eI&&0!==eI.secrets.length?(0,n.jsx)(y.A,{dense:!0,children:eI.secrets.map(e=>(0,n.jsxs)(v.Ay,{children:[(0,n.jsx)(b.A,{edge:"start",checked:!eW.has(e.name),onChange:t=>eO(a=>{let n=new Set(a);return t.target.checked?n.delete(e.name):n.add(e.name),n}),inputProps:{"aria-label":"Include ".concat(e.name," in package secrets")}}),(0,n.jsx)(A.A,{primary:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("code",{children:eE(e.name)})," ",e.required&&(0,n.jsx)(c.A,{label:"required",size:"small",color:"warning"})]}),secondary:eW.has(e.name)?"Excluded — the package will not request this value":e.description})]},e.name))}):(0,n.jsx)(S.A,{severity:"success",children:"No entity secrets to declare."}),(0,n.jsx)(E.A,{}),(0,n.jsx)(o.default,{variant:"subtitle2",children:"Detected secrets in content"}),(0,n.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["Values that look secret or instance-specific (paths, repos, tokens, URLs, emails) found in flow prompts, node properties, model config and planned- execution prompts. Accepted rows are replaced with a"," ",(0,n.jsx)("code",{children:"{{secret.NAME}}"})," placeholder everywhere they occur."]}),eL&&(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",p:2},children:(0,n.jsx)(k.default,{size:28})}),eq&&(0,n.jsx)(S.A,{severity:"error",children:eq}),!eL&&eM&&0===eR.length&&(0,n.jsx)(S.A,{severity:"success",children:"No likely secrets detected in the packaged content."}),eR.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.A,{direction:"row",spacing:.5,flexWrap:"wrap",useFlexGap:!0,children:tq.map(e=>{let[t,a]=e;return(0,n.jsx)(c.A,{size:"small",variant:"outlined",label:"".concat(t,": ").concat(a)},t)})}),(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",flexWrap:"wrap",useFlexGap:!0,children:[(0,n.jsx)(d.A,{size:"small",onClick:()=>tO(!0),children:"Accept all"}),(0,n.jsx)(d.A,{size:"small",onClick:()=>tO(!1),children:"Reject all"}),(0,n.jsx)(x.A,{size:"small",placeholder:"Filter detected secrets…",value:eZ,onChange:e=>e$(e.target.value),sx:{minWidth:200,flex:1}}),(0,n.jsxs)(o.default,{variant:"caption",color:"text.secondary",sx:{alignSelf:"center"},children:[tH.filter(e=>e.accepted).length," of ",tH.length," accepted"]})]}),(0,n.jsxs)(y.A,{dense:!0,sx:{border:1,borderColor:"divider",borderRadius:1,maxHeight:280,overflow:"auto"},children:[0===tM.length&&(0,n.jsx)(v.Ay,{children:(0,n.jsx)(A.A,{primary:(0,n.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["No rows match “",eZ,"”."]})})}),tM.map(e=>(0,n.jsxs)(v.Ay,{alignItems:"flex-start",divider:!0,children:[(0,n.jsx)(w.A,{sx:{minWidth:36,mt:1},children:(0,n.jsx)(b.A,{edge:"start",checked:!!e.accepted,onChange:()=>{let t;return t=e.ids,eU(e=>{var a;let n=new Set(t),r=!(null==(a=e.find(e=>n.has(e.id)))?void 0:a.accepted);return e.map(e=>n.has(e.id)?{...e,accepted:r}:e)})},tabIndex:-1,disableRipple:!0})}),(0,n.jsx)(A.A,{primary:(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",flexWrap:"wrap",useFlexGap:!0,children:[(0,n.jsx)(c.A,{label:e.kind,size:"small"}),(0,n.jsx)(c.A,{label:e.source,size:"small",variant:"outlined",color:"model"===e.source?"secondary":"manual"===e.source?"primary":"default"}),e.confidence&&(0,n.jsx)(c.A,{label:e.confidence,size:"small",variant:"outlined",color:"high"===e.confidence?"success":"low"===e.confidence?"warning":"default"}),e.locations.length>1&&(0,n.jsx)(c.A,{label:"".concat(e.locations.length,"\xd7"),size:"small",variant:"outlined"}),(0,n.jsx)(s.default,{component:"code",sx:{wordBreak:"break-all"},children:e.excerpt.length>80?"".concat(e.excerpt.slice(0,80),"…"):e.excerpt})]}),secondary:(0,n.jsxs)(i.A,{spacing:.5,sx:{mt:.5},children:[(0,n.jsxs)(o.default,{variant:"caption",color:"text.secondary",children:[e.locations.length>1?"".concat(e.locations.length," locations: ").concat(e.locations.slice(0,3).join(", ")).concat(e.locations.length>3?", …":""):e.locations[0],e.rationale?" — ".concat(e.rationale):""]}),(0,n.jsx)(x.A,{size:"small",label:"Secret name",value:eE(e.suggestedSecretName),onChange:t=>{var a,n;let r,s;return r=e.ids,a=e.suggestedSecretName,n=t.target.value,s=a.startsWith("SECRET_")?"SECRET_".concat(n.replace(/^SECRET_/,"")):n,eU(e=>{let t=new Set(r);return e.map(e=>t.has(e.id)?{...e,suggestedSecretName:s}:e)})},disabled:!e.accepted,sx:{maxWidth:320}})]}),primaryTypographyProps:{component:"div"},secondaryTypographyProps:{component:"div"}})]},e.key))]})]}),tD.length>0&&(0,n.jsxs)(S.A,{severity:"warning",children:[(0,n.jsx)(C.A,{children:"Secrets from the imported manifest that need re-adding"}),"A manifest never carries secret values, so these declarations could not be matched to anything in the current content — re-add them below if they still apply: ",tD.map(eE).join(", "),"."]}),e_.length>0&&(0,n.jsxs)(S.A,{severity:"warning",children:[(0,n.jsx)(C.A,{children:"Notes"}),e_.map((e,t)=>(0,n.jsx)("div",{children:e},t))]}),(0,n.jsx)(E.A,{}),(0,n.jsx)(o.default,{variant:"subtitle2",children:"Add a secret manually"}),(0,n.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["Enter any value that should be redacted from the package. It is treated purely as text to replace with a ",(0,n.jsx)("code",{children:"{{secret.NAME}}"})," placeholder — it is never executed."]}),e6&&(0,n.jsx)(S.A,{severity:"error",children:e6}),(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"flex-start",flexWrap:"wrap",useFlexGap:!0,children:[(0,n.jsx)(x.A,{size:"small",label:"Value to redact",value:e0,onChange:e=>e1(e.target.value),sx:{minWidth:240,flex:1}}),(0,n.jsx)(x.A,{size:"small",label:"Secret name",value:e2,onChange:e=>e5(e.target.value),sx:{minWidth:180}}),(0,n.jsx)(I.A,{size:"small",value:e4,onChange:e=>e3(e.target.value),sx:{minWidth:120},children:ed.map(e=>(0,n.jsx)(T.A,{value:e,children:e},e))}),(0,n.jsx)(d.A,{variant:"outlined",onClick:tR,disabled:!e0.trim(),children:"Add"}),(0,n.jsx)(d.A,{variant:"text",startIcon:(0,n.jsx)(H.A,{}),onClick:()=>void tU(),disabled:tT,children:"Pick from app"})]}),(0,n.jsx)(E.A,{}),(0,n.jsx)(o.default,{variant:"subtitle2",children:"Advanced scan options"}),(0,n.jsxs)(i.A,{direction:"row",spacing:2,flexWrap:"wrap",useFlexGap:!0,children:[(0,n.jsx)(F.A,{control:(0,n.jsx)(P.A,{checked:eK,onChange:e=>{eY(e.target.checked),eD(!1)}}),label:"Aggressive entropy scan"}),(0,n.jsx)(F.A,{control:(0,n.jsx)(P.A,{checked:eQ,onChange:e=>{eX(e.target.checked),eD(!1)}}),label:"Detect bare owner/repo slugs"}),(0,n.jsx)(d.A,{size:"small",variant:"text",onClick:()=>void tW(),disabled:eL,children:"Re-scan"})]}),(0,n.jsx)(E.A,{}),(0,n.jsx)(o.default,{variant:"subtitle2",children:"Optional: model-driven scan"}),(0,n.jsx)(S.A,{severity:"info",children:"Running the model-driven pass sends the packaged content above to the selected model provider. The offline heuristic scan never leaves your machine."}),(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",flexWrap:"wrap",useFlexGap:!0,children:[(0,n.jsxs)(I.A,{size:"small",displayEmpty:!0,value:eB,onChange:e=>eV(e.target.value),sx:{minWidth:220},children:[(0,n.jsx)(T.A,{value:"",children:(0,n.jsx)("em",{children:"Select a model…"})}),D.models.map(e=>(0,n.jsx)(T.A,{value:e.id,children:e.label},e.id))]}),(0,n.jsx)(d.A,{variant:"outlined",disabled:!eB||eL,onClick:()=>void tW(eB),children:"Scan with model"})]})]});case 3:return(0,n.jsxs)(i.A,{spacing:2,children:[(0,n.jsx)(x.A,{label:"Package name",value:td,onChange:e=>tu(e.target.value),required:!0,fullWidth:!0,error:td.length>0&&0===td.trim().length}),(0,n.jsx)(x.A,{label:"Version",value:th,onChange:e=>tp(e.target.value),required:!0,fullWidth:!0,error:th.length>0&&!tV,helperText:th.length>0&&!tV?"Must be a semantic version (e.g. 1.0.0)":" "}),(0,n.jsx)(x.A,{label:"Description",value:tm,onChange:e=>tg(e.target.value),fullWidth:!0,multiline:!0,minRows:2}),(0,n.jsx)(x.A,{label:"Tags (comma-separated)",value:tx,onChange:e=>tf(e.target.value),fullWidth:!0})]});case 4:if(ty)return(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",p:4},children:(0,n.jsx)(k.default,{})});if(tb)return(0,n.jsx)(S.A,{severity:"error",children:tb});if(null==tj?void 0:tj.ok)return(0,n.jsxs)(i.A,{spacing:2,children:[(0,n.jsxs)(S.A,{severity:"success",children:[(0,n.jsx)(C.A,{children:"Package built"}),(0,n.jsx)("code",{children:td.trim()})," v",th.trim()," is ready to export."]}),tj.warnings.length>0&&(0,n.jsxs)(S.A,{severity:"warning",children:[(0,n.jsx)(C.A,{children:"Warnings"}),tj.warnings.map((e,t)=>(0,n.jsx)("div",{children:e},t))]}),(0,n.jsx)(d.A,{variant:"contained",onClick:tG,children:"Download package manifest (.json)"}),(0,n.jsx)(E.A,{}),(0,n.jsx)(o.default,{variant:"subtitle2",children:"Publish to the FLUJO package registry"}),(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Publishing requires a confirmed registry account (set one up on the Packages page). Only the secret-safe manifest above is uploaded — no secret values ever leave your machine."}),(null==tC?void 0:tC.ok)?(0,n.jsxs)(S.A,{severity:"success",children:[(0,n.jsx)(C.A,{children:"Published"}),tC.name||td.trim()," v",tC.version||th.trim()," is live.",tC.url&&(0,n.jsx)("div",{children:(0,n.jsx)("a",{href:tC.url,target:"_blank",rel:"noreferrer",children:tC.url})})]}):(0,n.jsxs)(n.Fragment,{children:[tC&&!tC.ok&&(0,n.jsx)(S.A,{severity:"unconfirmed"===tC.code||"not_authenticated"===tC.code?"warning":"error",children:tC.error||"Failed to publish package."}),(0,n.jsxs)(i.A,{direction:"row",spacing:1,flexWrap:"wrap",useFlexGap:!0,children:[(0,n.jsx)(d.A,{variant:"outlined",onClick:()=>void t_(),disabled:tk,children:tk?"Publishing…":"Publish to registry"}),tC&&!tC.ok&&("not_authenticated"===tC.code||"unconfirmed"===tC.code)&&(0,n.jsx)(d.A,{variant:"contained",onClick:()=>tc(!0),disabled:tk,children:"Log in to registry"})]})]})]});return null;default:return null}})()]}),(0,n.jsxs)(L.A,{children:[(0,n.jsx)(d.A,{onClick:a,children:(null==tj?void 0:tj.ok)?"Close":"Cancel"}),(0,n.jsx)(s.default,{sx:{flex:1}}),(0,n.jsx)(d.A,{onClick:()=>p(e=>Math.max(e-1,0)),disabled:0===h||ty||ew,children:"Back"}),h<4&&(0,n.jsx)(d.A,{variant:"contained",onClick:tB,disabled:tK,children:3===h?"Build":"Next"})]})]}),(0,n.jsxs)(N.A,{open:to,onClose:()=>tc(!1),maxWidth:"sm",fullWidth:!0,children:[(0,n.jsx)(z.A,{children:"Log in to the package registry"}),(0,n.jsx)(W.A,{dividers:!0,children:(0,n.jsx)(Y,{})}),(0,n.jsxs)(L.A,{children:[(0,n.jsx)(d.A,{onClick:()=>tc(!1),children:"Done"}),(0,n.jsx)(d.A,{variant:"contained",onClick:()=>{tc(!1),t_()},disabled:tk,children:"Retry publish"})]})]}),(0,n.jsxs)(N.A,{open:e9,onClose:()=>e8(!1),maxWidth:"md",fullWidth:!0,children:[(0,n.jsx)(z.A,{children:"Pick a value to redact"}),(0,n.jsxs)(W.A,{dividers:!0,children:[(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"These are plaintext values found in the packaged flows, models and planned executions. Pick one to pre-fill the value to redact. API keys and MCP env/header values are never listed — they are already declared as secrets."}),(0,n.jsx)(x.A,{size:"small",fullWidth:!0,placeholder:"Search values…",value:tl,onChange:e=>ti(e.target.value),InputProps:{startAdornment:(0,n.jsx)(f.A,{position:"start",children:(0,n.jsx)(H.A,{fontSize:"small"})})},sx:{mb:2}}),te?(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",p:4},children:(0,n.jsx)(k.default,{})}):ta?(0,n.jsx)(S.A,{severity:"error",children:ta}):0===tr.length?(0,n.jsx)(S.A,{severity:"info",children:"No pickable plaintext values found in the packaged content."}):0===tL.length?(0,n.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["No values match “",tl,"”."]}):(0,n.jsx)(y.A,{dense:!0,sx:{border:1,borderColor:"divider",borderRadius:1,maxHeight:"50vh",overflow:"auto"},children:tL.map((e,t)=>(0,n.jsx)(v.Ay,{disablePadding:!0,divider:!0,children:(0,n.jsx)(j.A,{onClick:()=>{e1(e.text),e7(null),e8(!1)},alignItems:"flex-start",children:(0,n.jsx)(A.A,{primary:(0,n.jsx)(s.default,{component:"code",sx:{wordBreak:"break-all"},children:e.text.length>120?"".concat(e.text.slice(0,120),"…"):e.text}),secondary:(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",flexWrap:"wrap",useFlexGap:!0,sx:{mt:.5},children:[(0,n.jsx)(c.A,{label:e.source,size:"small",variant:"outlined"}),(0,n.jsx)(o.default,{variant:"caption",color:"text.secondary",children:e.location})]}),primaryTypographyProps:{component:"div"},secondaryTypographyProps:{component:"div"}})})},"".concat(e.location,"-").concat(t)))})]}),(0,n.jsx)(L.A,{children:(0,n.jsx)(d.A,{onClick:()=>e8(!1),children:"Close"})})]})]})}var eT=a(50001),eF=a(51314),eP=a(76530);let eN=(0,J.h)("frontend/components/Packages/InstalledPackagesList");function ez(){let[e,t]=(0,r.useState)([]),[a,l]=(0,r.useState)(!0),[h,p]=(0,r.useState)(null),[m,g]=(0,r.useState)(null),[y,v]=(0,r.useState)(!1),[j,w]=(0,r.useState)(null),[b,A]=(0,r.useState)(""),C=(0,r.useCallback)(async()=>{l(!0),p(null);try{var e;let a=await fetch("/api/packages/installed");if(!a.ok)throw Error("Failed to load installed packages (".concat(a.status,")"));let n=await a.json();t(null!=(e=n.packages)?e:[])}catch(e){eN.warn("Failed to load installed packages",e),p(e instanceof Error?e.message:String(e))}finally{l(!1)}},[]);(0,r.useEffect)(()=>{C()},[C]);let E=(0,r.useCallback)(async e=>{v(!0),w(null);try{let a=await fetch("/api/packages/uninstall",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({packageName:e.packageName})}),n=await a.json();if(!a.ok){var t;throw Error(null!=(t=n.error)?t:"Uninstall failed (".concat(a.status,")"))}w(n),await C()}catch(e){eN.warn("Uninstall failed",e),p(e instanceof Error?e.message:String(e))}finally{v(!1),g(null)}},[C]),I=(0,r.useMemo)(()=>{let t=b.trim().toLowerCase();return t?e.filter(e=>"".concat(e.packageName," ").concat(e.version).toLowerCase().includes(t)):e},[e,b]);return(0,n.jsxs)(s.default,{sx:{maxWidth:{xs:"100%",md:1100},mx:"auto",mt:3},children:[(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",sx:{mb:1},children:[(0,n.jsx)(o.default,{variant:"h6",children:"Installed packages"}),(0,n.jsx)(d.A,{size:"small",startIcon:(0,n.jsx)(eP.A,{}),onClick:()=>void C(),disabled:a,children:"Refresh"})]}),e.length>0&&(0,n.jsx)(x.A,{size:"small",fullWidth:!0,placeholder:"Search installed packages…",value:b,onChange:e=>A(e.target.value),InputProps:{startAdornment:(0,n.jsx)(f.A,{position:"start",children:(0,n.jsx)(H.A,{fontSize:"small"})})},sx:{mb:2}}),h&&(0,n.jsx)(S.A,{severity:"error",sx:{mb:2},onClose:()=>p(null),children:h}),j&&(0,n.jsxs)(S.A,{severity:j.hasErrors?"warning":"success",sx:{mb:2},onClose:()=>w(null),children:['Uninstalled "',j.packageName,'": ',j.removed.length," removed,"," ",j.skipped.length," preserved/skipped",j.hasErrors?", ".concat(j.errors.length," error(s)"):"","."]}),a?(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",p:3},children:(0,n.jsx)(k.default,{size:24})}):0===e.length?(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"No packages installed yet."}):0===I.length?(0,n.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["No packages match “",b,"”."]}):(0,n.jsx)(i.A,{spacing:1,children:I.map(e=>(0,n.jsxs)(u.A,{variant:"outlined",sx:{p:2,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,n.jsxs)(s.default,{children:[(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",children:[(0,n.jsx)(o.default,{variant:"subtitle1",children:e.packageName}),(0,n.jsx)(c.A,{label:"v".concat(e.version),size:"small",variant:"outlined"})]}),(0,n.jsxs)(o.default,{variant:"caption",color:"text.secondary",children:[e.entityCounts.flows," flows \xb7 ",e.entityCounts.models," models \xb7"," ",e.entityCounts.servers," servers \xb7 ",e.entityCounts.plannedExecutions," planned \xb7 installed ",new Date(e.installedAt).toLocaleString()]})]}),(0,n.jsx)(d.A,{color:"error",size:"small",startIcon:(0,n.jsx)(eF.A,{}),onClick:()=>g(e),disabled:y,children:"Uninstall"})]},e.packageName))}),(0,n.jsxs)(N.A,{open:null!==m,onClose:()=>y?void 0:g(null),children:[(0,n.jsxs)(z.A,{children:['Uninstall "',null==m?void 0:m.packageName,'"?']}),(0,n.jsx)(W.A,{children:(0,n.jsxs)(eT.A,{children:["This removes the flows, models, MCP servers and planned executions this package",(0,n.jsx)("strong",{children:" created"}),". Pre-existing entities the package merely updated in place are preserved. This cannot be undone."]})}),(0,n.jsxs)(L.A,{children:[(0,n.jsx)(d.A,{onClick:()=>g(null),disabled:y,children:"Cancel"}),(0,n.jsx)(d.A,{color:"error",variant:"contained",onClick:()=>m&&void E(m),disabled:y,startIcon:y?(0,n.jsx)(k.default,{size:16}):(0,n.jsx)(eF.A,{}),children:"Uninstall"})]})]})]})}var eW=a(33077),eO=a(29767),eR=a(53062),eU=a(84578),eL=a(1702),eH=a(41983),eM=a(23789),eD=a(17438),eq=a(14418),eJ=a(52550),e_=a(12402),eG=a(61563),eB=a(42063),eV=a(68212);let eZ=(0,J.h)("frontend/components/Packages/InstallPackageCard");function e$(e){var t,a,l,u,h;let{onInstalled:p}=e,[m,g]=(0,r.useState)(""),[y,v]=(0,r.useState)([]),[j,w]=(0,r.useState)(!1),[b,A]=(0,r.useState)(null),[C,I]=(0,r.useState)(!1),[T,F]=(0,r.useState)(null),[P,M]=(0,r.useState)(null),[D,q]=(0,r.useState)(!1),[J,_]=(0,r.useState)(null),[G,B]=(0,r.useState)(null),[V,Z]=(0,r.useState)(!1),[K,Y]=(0,r.useState)(null),[Q,X]=(0,r.useState)(null),[ee,et]=(0,r.useState)({}),[ea,en]=(0,r.useState)({}),[er,es]=(0,r.useState)({}),[ei,eo]=(0,r.useState)(null),[ec,ed]=(0,r.useState)(!1),[eu,eh]=(0,r.useState)(0),[ep,em]=(0,r.useState)(null),[eg,ex]=(0,r.useState)({}),ef=(0,r.useCallback)(async e=>{w(!0),A(null);try{var t;let a=await el.searchRegistry({q:e.trim()||void 0,pageSize:24});v(null!=(t=a.items)?t:[]),I(!0)}catch(e){eZ.warn("Failed to search package registry",e),A(e instanceof Error?e.message:String(e)),v([])}finally{w(!1)}},[]);(0,r.useEffect)(()=>{ef(""),$.getStatus().then(e=>F(e.signedIn?e.publisherHandle:null)).catch(e=>eZ.debug("Registry account status unavailable",e))},[ef]);let ey=(0,r.useCallback)(async()=>{if(P){q(!0),_(null);try{let e=await $.deletePackage(P.id);if(!e.ok)return void _(e.error||"Failed to delete package.");v(e=>e.filter(e=>e.id!==P.id)),M(null),await ef(m)}catch(e){eZ.warn("Package deletion failed",e),_(e instanceof Error?e.message:String(e))}finally{q(!1)}}},[P,m,ef]),ev=(0,r.useCallback)(async e=>{B(e),X(null),em(null),et({}),en({}),es({}),eo(null),ed(!1),eh(0),ex({}),Y(null),Z(!0);try{var t,a,n;let r=await el.installFromRegistry({packageId:e.id,version:e.latestVersion,consentGranted:!1});if(!r.ok)return void Y((null==(a=r.errors)?void 0:a[0])||"Failed to fetch package preview.");X(r);let s=null==(t=r.preview)?void 0:t.models[0];eo(null!=(n=null==s?void 0:s.id)?n:null),eh(+!s)}catch(e){eZ.warn("Failed to fetch package preview",e),Y(e instanceof Error?e.message:String(e))}finally{Z(!1)}},[]),ej=(0,r.useCallback)(async()=>{if(G&&Q){Z(!0),Y(null);try{var e,t;let a=Object.fromEntries((null!=(t=null==(e=Q.preview)?void 0:e.globals)?t:[]).map(e=>{var t,a;return[e.name,{value:null!=(a=null==(t=ea[e.name])?void 0:t.trim())?a:"",metadata:{isSecret:!0===e.isSecret}}]}).filter(e=>{let[,t]=e;return t.value.length>0}));if(Object.keys(a).length>0){let e=await fetch("/api/env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"setAll",variables:a})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error((null==t?void 0:t.error)||"Failed to save package globals (HTTP ".concat(e.status,")"))}}let n=await el.installFromRegistry({packageId:G.id,version:G.latestVersion,secrets:ee,modelMappings:Object.fromEntries(Object.entries(er).filter(e=>{let[,t]=e;return""!==t})),consentGranted:!0});em(n),X(null),n.ok&&(null==p||p())}catch(e){eZ.warn("Install failed",e),Y(e instanceof Error?e.message:String(e))}finally{Z(!1)}}},[G,Q,ee,ea,er,p]),ew=(0,r.useCallback)(()=>{B(null),X(null),em(null),et({}),en({}),es({}),eo(null),ed(!1),eh(0),ex({}),Y(null)},[]),eb=null==Q?void 0:Q.preview,eA=null!=(a=null==eb?void 0:eb.models.find(e=>e.id===ei))?a:null==eb?void 0:eb.models[0],ek=null!=(l=null==eb?void 0:eb.models.filter(e=>Object.prototype.hasOwnProperty.call(er,e.id)).length)?l:0,eS=null==(u=null==eb?void 0:eb.models.every(e=>Object.prototype.hasOwnProperty.call(er,e.id)))||u,eC=(0,r.useCallback)(e=>{eo(e),ed(!!er[e])},[er]),eE=(0,r.useCallback)(e=>{es(t=>({...t,[e]:""})),ed(!1)},[]),eI=(0,r.useCallback)((e,t)=>{es(a=>({...a,[e]:t}))},[]);return(0,n.jsxs)(s.default,{sx:{maxWidth:{xs:"100%",md:1100},mx:"auto",mt:3},children:[(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",sx:{mb:1},children:[(0,n.jsx)(e_.A,{color:"action"}),(0,n.jsx)(o.default,{variant:"h6",children:"Browse registry"})]}),(0,n.jsx)(x.A,{size:"small",fullWidth:!0,placeholder:"Search published packages…",value:m,onChange:e=>g(e.target.value),onKeyDown:e=>{"Enter"===e.key&&ef(m)},InputProps:{startAdornment:(0,n.jsx)(f.A,{position:"start",children:(0,n.jsx)(H.A,{fontSize:"small"})}),endAdornment:j?(0,n.jsx)(f.A,{position:"end",children:(0,n.jsx)(k.default,{size:16})}):void 0},sx:{mb:2}}),b&&(0,n.jsx)(S.A,{severity:"error",sx:{mb:2},onClose:()=>A(null),children:b}),C&&!j&&0===y.length&&!b&&(0,n.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["No packages match “",m,"”."]}),(0,n.jsx)(eW.Ay,{container:!0,spacing:2,children:y.map(e=>(0,n.jsx)(eW.Ay,{item:!0,xs:12,sm:6,md:4,children:(0,n.jsxs)(eO.A,{variant:"outlined",sx:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,n.jsx)(eR.A,{onClick:()=>void ev(e),sx:{flex:1},children:(0,n.jsxs)(eU.A,{children:[(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"baseline",justifyContent:"space-between",children:[(0,n.jsx)(o.default,{variant:"subtitle1",noWrap:!0,children:e.name}),(0,n.jsx)(c.A,{size:"small",variant:"outlined",label:"v".concat(e.latestVersion)})]}),(0,n.jsx)(o.default,{variant:"caption",color:"text.secondary",display:"block",children:e.handle}),(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mt:.5,minHeight:"2.5em"},children:e.description||"No description provided."}),(0,n.jsx)(i.A,{direction:"row",spacing:.5,sx:{mt:1,flexWrap:"wrap",gap:.5},children:e.tags.map(e=>(0,n.jsx)(c.A,{size:"small",label:e},e))}),(0,n.jsxs)(i.A,{direction:"row",spacing:.5,alignItems:"center",sx:{mt:1},children:[(0,n.jsx)(eG.A,{fontSize:"inherit",color:"disabled"}),(0,n.jsx)(o.default,{variant:"caption",color:"text.secondary",children:e.downloads})]})]})}),function(e,t){var a;let n=null==t?void 0:t.trim().replace(/^@/,"").toLocaleLowerCase();if(!n)return!1;let r=null==(a=e.handle)?void 0:a.trim().replace(/^@/,"");if(r)return r.split("/")[0].toLocaleLowerCase()===n;let s=e.id.trim().replace(/^@/,"");return s.includes("/")&&s.split("/")[0].toLocaleLowerCase()===n}(e,T)&&(0,n.jsx)(eL.A,{sx:{justifyContent:"flex-end",pt:0},children:(0,n.jsx)(eH.A,{size:"small",color:"error","aria-label":"Delete ".concat(e.name),onClick:()=>{_(null),M(e)},children:(0,n.jsx)(eF.A,{fontSize:"small"})})})]})},e.id))}),(0,n.jsxs)(N.A,{open:null!==P,onClose:D?void 0:()=>M(null),maxWidth:"xs",fullWidth:!0,children:[(0,n.jsx)(z.A,{children:"Delete package?"}),(0,n.jsxs)(W.A,{children:[J&&(0,n.jsx)(S.A,{severity:"error",sx:{mb:2},children:J}),(0,n.jsxs)(o.default,{variant:"body2",children:["This permanently deletes ",(0,n.jsx)("strong",{children:null==P?void 0:P.name})," and all of its published versions from the registry. This action cannot be undone."]})]}),(0,n.jsxs)(L.A,{children:[(0,n.jsx)(d.A,{onClick:()=>M(null),disabled:D,children:"Cancel"}),(0,n.jsx)(d.A,{color:"error",variant:"contained",onClick:()=>void ey(),disabled:D,startIcon:D?(0,n.jsx)(k.default,{size:16,color:"inherit"}):(0,n.jsx)(eF.A,{}),children:"Delete package"})]})]}),(0,n.jsxs)(N.A,{open:null!==G,onClose:V?void 0:ew,maxWidth:!1,fullWidth:!0,PaperProps:{sx:{width:"min(1400px, calc(100vw - 32px))",maxWidth:"none",minHeight:{xs:"calc(100vh - 32px)",md:760},maxHeight:"calc(100vh - 32px)",borderRadius:{xs:2,md:3}}},children:[(0,n.jsxs)(z.A,{sx:{px:{xs:2,md:4},pt:{xs:2,md:3},pb:1},children:[(0,n.jsxs)(o.default,{component:"span",variant:"h5",fontWeight:700,children:["Install ",null==G?void 0:G.name]}),(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:"Match the package to your FLUJO, then review and install it."})]}),(0,n.jsxs)(W.A,{sx:{px:{xs:2,md:4},pb:3},children:[K&&(0,n.jsx)(S.A,{severity:"error",sx:{mb:2},onClose:()=>Y(null),children:K}),V&&!Q&&!ep&&(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:420},children:(0,n.jsx)(k.default,{size:24})}),eb&&(null==Q?void 0:Q.package)&&(0,n.jsxs)(s.default,{children:[(0,n.jsxs)(i.A,{direction:{xs:"column",sm:"row"},spacing:1,alignItems:{sm:"center"},justifyContent:"space-between",sx:{mb:2.5},children:[(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",children:[(0,n.jsx)(c.A,{size:"small",variant:"outlined",label:"v".concat(Q.package.version)}),Q.package.publisher&&(0,n.jsx)(c.A,{size:"small",variant:"outlined",label:Q.package.publisher}),(0,n.jsxs)(o.default,{variant:"caption",color:"text.secondary",children:[eb.servers.length," server(s) \xb7 ",eb.models.length," model(s) \xb7"," ",eb.flows.length," flow(s) \xb7 ",eb.plannedExecutions.length," planned execution(s)"]})]}),(0,n.jsxs)(o.default,{variant:"caption",color:"text.secondary",children:["Step ",eu+1," of 2"]})]}),(0,n.jsxs)(O.A,{activeStep:eu,sx:{maxWidth:720,mx:"auto",mb:3},children:[(0,n.jsx)(R.A,{children:(0,n.jsx)(U.A,{children:"Match models"})}),(0,n.jsx)(R.A,{children:(0,n.jsx)(U.A,{children:"Review & install"})})]}),0===eu&&eb.models.length>0&&eA&&(0,n.jsxs)(s.default,{children:[(0,n.jsxs)(s.default,{sx:{textAlign:"center",maxWidth:820,mx:"auto",mb:3},children:[(0,n.jsx)(o.default,{variant:"h4",fontWeight:750,sx:{mb:1},children:"The package was created with models that are not installed in your FLUJO."}),(0,n.jsx)(o.default,{variant:"h6",color:"text.secondary",fontWeight:400,children:"Let's replace or recreate them!"})]}),(0,n.jsxs)(s.default,{sx:{display:"grid",gridTemplateColumns:{xs:"minmax(0, 1fr)",md:"minmax(260px, 0.85fr) 88px minmax(420px, 1.35fr)"},gap:{xs:2,md:2.5},alignItems:"stretch"},children:[(0,n.jsxs)(s.default,{children:[(0,n.jsxs)(i.A,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{mb:1.25},children:[(0,n.jsx)(o.default,{variant:"overline",color:"text.secondary",fontWeight:700,children:"Models in this package"}),(0,n.jsx)(c.A,{size:"small",color:eS?"success":"default",label:"".concat(ek,"/").concat(eb.models.length," ready")})]}),(0,n.jsx)(i.A,{spacing:1.25,children:eb.models.map(e=>{let t=e.id===eA.id,a=Object.prototype.hasOwnProperty.call(er,e.id),r=eb.installedModels.find(t=>t.id===er[e.id]);return(0,n.jsx)(eO.A,{variant:"outlined",sx:{borderWidth:t?2:1,borderColor:t?"primary.main":"divider",bgcolor:t?"action.selected":"background.paper",transition:"border-color 120ms ease, background-color 120ms ease"},children:(0,n.jsx)(eR.A,{onClick:()=>eC(e.id),"aria-label":"Configure ".concat(e.displayName),sx:{minHeight:104,p:2},children:(0,n.jsxs)(i.A,{direction:"row",spacing:1.5,alignItems:"center",children:[(0,n.jsx)(s.default,{sx:{width:44,height:44,borderRadius:2,display:"grid",placeItems:"center",bgcolor:t?"primary.main":"action.hover",color:t?"primary.contrastText":"text.secondary",flex:"0 0 auto"},children:(0,n.jsx)(eJ.A,{})}),(0,n.jsxs)(s.default,{sx:{minWidth:0,flex:1},children:[(0,n.jsx)(o.default,{variant:"subtitle1",fontWeight:700,noWrap:!0,children:e.displayName}),(0,n.jsx)(o.default,{variant:"caption",color:"text.secondary",display:"block",children:"Package model"}),a&&(0,n.jsxs)(i.A,{direction:"row",spacing:.5,alignItems:"center",sx:{mt:.5},children:[(0,n.jsx)(eq.A,{color:"success",sx:{fontSize:16}}),(0,n.jsx)(o.default,{variant:"caption",color:"success.main",noWrap:!0,children:r?"Using ".concat(r.displayName):"Will be created"})]})]})]})})},e.id)})})]}),(0,n.jsx)(s.default,{"aria-hidden":!0,sx:{display:"grid",placeItems:"center",minHeight:{xs:64,md:360}},children:(0,n.jsx)(s.default,{sx:{width:64,height:64,borderRadius:"50%",display:"grid",placeItems:"center",bgcolor:"primary.main",color:"primary.contrastText",boxShadow:3,transform:{xs:"rotate(90deg)",md:"none"}},children:(0,n.jsx)(eD.A,{sx:{fontSize:38}})})}),(0,n.jsxs)(eO.A,{variant:"outlined",sx:{p:{xs:2,md:3},minHeight:{md:420},bgcolor:"background.default"},children:[(0,n.jsxs)(o.default,{variant:"overline",color:"text.secondary",fontWeight:700,children:["Replace ",eA.displayName]}),(0,n.jsx)(o.default,{variant:"h5",fontWeight:700,sx:{mt:.25,mb:2.5},children:"What would you like to do?"}),(0,n.jsxs)(eW.Ay,{container:!0,spacing:2,children:[(0,n.jsx)(eW.Ay,{item:!0,xs:12,sm:6,children:(0,n.jsx)(d.A,{fullWidth:!0,"aria-label":"Create new one",variant:Object.prototype.hasOwnProperty.call(er,eA.id)&&""===er[eA.id]?"contained":"outlined",onClick:()=>eE(eA.id),sx:{minHeight:154,p:2.5,textTransform:"none",alignItems:"stretch",justifyContent:"flex-start",textAlign:"left"},children:(0,n.jsxs)(i.A,{spacing:1,alignItems:"flex-start",children:[(0,n.jsx)(eM.A,{sx:{fontSize:36}}),(0,n.jsx)(o.default,{variant:"h6",fontWeight:700,children:"Create new one"}),(0,n.jsx)(o.default,{variant:"body2",color:Object.prototype.hasOwnProperty.call(er,eA.id)&&""===er[eA.id]?"inherit":"text.secondary",children:"Recreate this model in your FLUJO with the package's configuration."})]})})}),(0,n.jsx)(eW.Ay,{item:!0,xs:12,sm:6,children:(0,n.jsx)(d.A,{fullWidth:!0,"aria-label":"Use one of yours",variant:er[eA.id]?"contained":"outlined",onClick:()=>ed(!0),sx:{minHeight:154,p:2.5,textTransform:"none",alignItems:"stretch",justifyContent:"flex-start",textAlign:"left"},children:(0,n.jsxs)(i.A,{spacing:1,alignItems:"flex-start",children:[(0,n.jsx)(eJ.A,{sx:{fontSize:36}}),(0,n.jsx)(o.default,{variant:"h6",fontWeight:700,children:"Use one of yours"}),(0,n.jsx)(o.default,{variant:"body2",color:er[eA.id]?"inherit":"text.secondary",children:"Connect the package to a model you already have installed."})]})})})]}),ec&&(0,n.jsxs)(s.default,{sx:{mt:2.5},children:[(0,n.jsx)(E.A,{sx:{mb:2}}),(0,n.jsx)(o.default,{variant:"subtitle1",fontWeight:700,sx:{mb:1},children:"Choose one of your installed models"}),eb.installedModels.length>0?(0,n.jsx)(eW.Ay,{container:!0,spacing:1.25,children:eb.installedModels.map(e=>{let t=er[eA.id]===e.id;return(0,n.jsx)(eW.Ay,{item:!0,xs:12,sm:6,children:(0,n.jsx)(eO.A,{variant:"outlined",sx:{height:"100%",borderWidth:t?2:1,borderColor:t?"primary.main":"divider",bgcolor:t?"action.selected":"background.paper"},children:(0,n.jsx)(eR.A,{onClick:()=>eI(eA.id,e.id),"aria-label":"Use ".concat(e.displayName),sx:{minHeight:76,p:1.5},children:(0,n.jsxs)(i.A,{direction:"row",spacing:1.25,alignItems:"center",children:[(0,n.jsx)(eJ.A,{color:t?"primary":"action"}),(0,n.jsxs)(s.default,{sx:{minWidth:0},children:[(0,n.jsx)(o.default,{variant:"subtitle2",fontWeight:700,noWrap:!0,children:e.displayName}),(0,n.jsx)(o.default,{variant:"caption",color:"text.secondary",noWrap:!0,display:"block",children:e.name})]}),t&&(0,n.jsx)(eq.A,{color:"primary",sx:{ml:"auto !important",flex:"0 0 auto"}})]})})})},e.id)})}):(0,n.jsx)(S.A,{severity:"info",children:"You do not have any installed models yet. Create this package model as new instead."})]})]})]}),(0,n.jsx)(E.A,{sx:{my:3}}),(0,n.jsxs)(i.A,{direction:"row",spacing:1.5,justifyContent:"space-between",alignItems:"center",children:[(0,n.jsx)(d.A,{onClick:ew,children:"Cancel"}),(0,n.jsxs)(i.A,{direction:"row",spacing:1.5,alignItems:"center",children:[!eS&&(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Choose an option for every model to continue."}),(0,n.jsx)(d.A,{variant:"contained",size:"large",disabled:!eS,endIcon:(0,n.jsx)(eD.A,{}),onClick:()=>eh(1),children:"Continue to review"})]})]})]}),1===eu&&(0,n.jsxs)(s.default,{sx:{maxWidth:980,mx:"auto"},children:[(0,n.jsxs)(i.A,{direction:{xs:"column",sm:"row"},spacing:1,alignItems:{sm:"center"},justifyContent:"space-between",sx:{mb:2},children:[(0,n.jsxs)(s.default,{children:[(0,n.jsx)(o.default,{variant:"h4",fontWeight:750,children:"Review and install"}),(0,n.jsx)(o.default,{variant:"body1",color:"text.secondary",children:"Check your model choices and add the package configuration."})]}),eb.models.length>0&&(0,n.jsx)(d.A,{onClick:()=>{var e,t;eh(0),eo(null!=(t=null==(e=eb.models.find(e=>!Object.prototype.hasOwnProperty.call(er,e.id)))?void 0:e.id)?t:eb.models[0].id),ed(!1)},children:"Change model choices"})]}),eb.models.length>0&&(0,n.jsxs)(s.default,{sx:{mb:2.5},children:[(0,n.jsx)(o.default,{variant:"subtitle2",sx:{mb:1},children:"Model plan"}),(0,n.jsx)(eW.Ay,{container:!0,spacing:1.5,children:eb.models.map(e=>{var t;let a=eb.installedModels.find(t=>t.id===er[e.id]);return(0,n.jsx)(eW.Ay,{item:!0,xs:12,sm:6,children:(0,n.jsx)(eO.A,{variant:"outlined",sx:{p:1.75,height:"100%"},children:(0,n.jsxs)(i.A,{direction:"row",spacing:1.25,alignItems:"center",children:[(0,n.jsxs)(s.default,{sx:{minWidth:0,flex:1},children:[(0,n.jsx)(o.default,{variant:"caption",color:"text.secondary",children:"Package model"}),(0,n.jsx)(o.default,{variant:"subtitle2",noWrap:!0,children:e.displayName})]}),(0,n.jsx)(eD.A,{color:"action"}),(0,n.jsxs)(s.default,{sx:{minWidth:0,flex:1},children:[(0,n.jsx)(o.default,{variant:"caption",color:"text.secondary",children:a?"Your model":"New model"}),(0,n.jsx)(o.default,{variant:"subtitle2",noWrap:!0,children:null!=(t=null==a?void 0:a.displayName)?t:e.displayName})]})]})})},e.id)})})]}),eb.servers.some(e=>e.requiredEnvMissing.length>0)&&(0,n.jsx)(S.A,{severity:"warning",sx:{mb:1.5},children:"Some MCP servers require environment values that aren't covered by a secret below — those servers will install disabled."}),eb.globals.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(o.default,{variant:"subtitle2",sx:{mb:1},children:"Global variables requested by this package"}),(0,n.jsx)(i.A,{spacing:1.5,sx:{mb:2.5},children:eb.globals.map(e=>{var t,a;return(0,n.jsx)(x.A,{size:"small",type:e.isSecret&&!eg["global:".concat(e.name)]?"password":"text",label:e.name,helperText:"".concat(null!=(t=e.description)?t:e.required?"Required":"Optional").concat(eb.missingGlobals.includes(e.name)?" — not currently set":" — leave blank to keep the current value"),value:null!=(a=ea[e.name])?a:"",onChange:t=>en(a=>({...a,[e.name]:t.target.value})),fullWidth:!0,InputProps:e.isSecret?{endAdornment:(0,n.jsx)(f.A,{position:"end",children:(0,n.jsx)(eH.A,{size:"small",tabIndex:-1,"aria-label":eg["global:".concat(e.name)]?"Hide global":"Show global",onClick:()=>ex(t=>({...t,["global:".concat(e.name)]:!t["global:".concat(e.name)]})),children:eg["global:".concat(e.name)]?(0,n.jsx)(eV.A,{fontSize:"small"}):(0,n.jsx)(eB.A,{fontSize:"small"})})})}:void 0},e.name)})})]}),(0,n.jsx)(E.A,{sx:{my:2.5}}),eb.secrets.length>0?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(o.default,{variant:"subtitle2",sx:{mb:1},children:"Secrets requested by this package"}),(0,n.jsx)(i.A,{spacing:1.5,sx:{mb:2.5},children:eb.secrets.map(e=>{var t;return(0,n.jsx)(x.A,{size:"small",type:eg[e.key]?"text":"password",label:e.label||e.key,helperText:e.required?"Required — leave blank to install the dependent entity disabled":"Optional",value:null!=(t=ee[e.key])?t:"",onChange:t=>et(a=>({...a,[e.key]:t.target.value})),fullWidth:!0,InputProps:{endAdornment:(0,n.jsx)(f.A,{position:"end",children:(0,n.jsx)(eH.A,{size:"small",tabIndex:-1,"aria-label":eg[e.key]?"Hide secret":"Show secret",onClick:()=>ex(t=>({...t,[e.key]:!t[e.key]})),children:eg[e.key]?(0,n.jsx)(eV.A,{fontSize:"small"}):(0,n.jsx)(eB.A,{fontSize:"small"})})})}},e.key)})})]}):(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:2.5},children:"This package doesn't request any secrets."}),(0,n.jsxs)(i.A,{direction:"row",spacing:1,justifyContent:"space-between",children:[(0,n.jsx)(d.A,{onClick:eb.models.length>0?()=>eh(0):ew,disabled:V,children:eb.models.length>0?"Back":"Cancel"}),(0,n.jsx)(d.A,{variant:"contained",color:"primary",size:"large",onClick:()=>void ej(),disabled:V,startIcon:V?(0,n.jsx)(k.default,{size:16}):(0,n.jsx)(e_.A,{}),children:"Install package"})]})]})]}),ep&&(0,n.jsxs)(s.default,{children:[(0,n.jsx)(S.A,{severity:ep.ok?"success":"error",sx:{mb:1},children:ep.ok?'Installed "'.concat(null==(t=ep.package)?void 0:t.name,'": ').concat(ep.created.length," created, ").concat(ep.updated.length," updated, ").concat(ep.disabled.length," disabled."):"Install failed: ".concat(null!=(h=ep.errors[0])?h:"unknown error")}),ep.missingGlobals.length>0&&(0,n.jsxs)(S.A,{severity:"warning",sx:{mb:1},children:["Set these global variable(s) in Settings for the installed entities to work:"," ",ep.missingGlobals.join(", "),"."]}),(0,n.jsx)(d.A,{size:"small",onClick:ew,children:"Close"})]})]})]})]})}let eK=(0,J.h)("frontend/components/Packages");function eY(){let[e,t]=(0,r.useState)(!1),[a,l]=(0,r.useState)(0);return eK.debug("Rendering PackagesManager",{wizardOpen:e}),(0,n.jsxs)(s.default,{sx:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,n.jsxs)(s.default,{sx:{p:2,display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:1,borderColor:"divider"},children:[(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",children:[(0,n.jsx)(o.default,{variant:"h5",children:"Packages"}),(0,n.jsx)(c.A,{label:"experimental",size:"small",color:"warning",variant:"outlined"})]}),(0,n.jsx)(d.A,{variant:"contained",startIcon:(0,n.jsx)(h.A,{}),onClick:()=>t(!0),"data-tour":"packages-create",children:"Create package"})]}),(0,n.jsxs)(s.default,{sx:{flex:1,overflow:"auto",p:3},children:[(0,n.jsxs)(u.A,{variant:"outlined",sx:{p:4,display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",gap:2,maxWidth:{xs:"100%",md:1100},mx:"auto"},children:[(0,n.jsx)(p.A,{sx:{fontSize:48,color:"text.secondary"}}),(0,n.jsx)(o.default,{variant:"h6",children:"Bundle your FLUJO setup into a shareable package"}),(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"A package bundles flows, models, MCP servers (by reference) and planned executions into a single manifest you can export and share. Secret values (API keys, tokens) are never included — only declarations of the secrets a recipient must supply at install time."}),(0,n.jsx)(d.A,{variant:"contained",startIcon:(0,n.jsx)(h.A,{}),onClick:()=>t(!0),children:"Create package"})]}),(0,n.jsxs)(u.A,{variant:"outlined",sx:{p:3,mt:3,maxWidth:{xs:"100%",md:1100},mx:"auto"},children:[(0,n.jsx)(o.default,{variant:"h6",gutterBottom:!0,children:"Package registry account"}),(0,n.jsx)(Y,{})]}),(0,n.jsx)(e$,{onInstalled:()=>l(e=>e+1)}),(0,n.jsx)(ez,{},a)]}),e&&(0,n.jsx)(eI,{open:e,onClose:()=>t(!1)})]})}var eQ=a(9164),eX=a(94929);let e0=(0,J.h)("app/packages/page");function e1(){var e,t;let a=(0,l.useRouter)(),{settings:i,settingsHydrated:o}=(0,eQ.useStorage)(),c=o&&null!=(t=null==i||null==(e=i.experimental)?void 0:e.enabled)&&t;return((0,r.useEffect)(()=>{o&&!c&&(e0.debug("Experimental features disabled — redirecting away from /packages"),a.replace("/settings"))},[o,c,a]),o&&c)?(0,n.jsx)(s.default,{sx:{height:"100%",display:"flex",flexDirection:"column"},children:(0,n.jsx)(eY,{})}):(0,n.jsx)(eX.default,{})}},90057:(e,t,a)=>{"use strict";a.d(t,{g:()=>l});var n=a(74879);let r=(0,a(87021).h)("frontend/services/flow/index");class s{async loadFlows(){r.debug("loadFlows: Entering method");try{if(this.flowsCache)return r.debug("loadFlows: Using cached flows",{count:this.flowsCache.length}),this.flowsCache;let e=await fetch("/api/flow");if(!e.ok){let t=await e.json();throw Error(t.error||"Failed to load flows")}let t=await e.json();return r.debug("loadFlows: Loaded flows from API",{count:t.length}),this.flowsCache=t,t}catch(e){return r.warn("loadFlows: Failed to load flows:",e),[]}}async getFlow(e){r.debug("getFlow: Entering method",{flowId:e});try{if(this.flowsCache){let t=this.flowsCache.find(t=>t.id===e);if(t)return r.debug("getFlow: Using cached flow",{flowId:e}),t}let t=await fetch("/api/flow/".concat(encodeURIComponent(e)));if(!t.ok){if(404===t.status)return r.debug("getFlow: Flow ".concat(e," not found")),null;let a=await t.json();throw Error(a.error||"Failed to get flow: ".concat(e))}let a=await t.json();return r.debug("getFlow: Retrieved flow from API",{flowId:e}),a}catch(t){return r.warn("getFlow: Failed to get flow ".concat(e,":"),t),null}}async addFlow(e){r.debug("addFlow: Entering method",{flowId:e.id,flowName:e.name,nodeCount:e.nodes.length,edgeCount:e.edges.length});try{let t=await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.json();return{success:!1,error:e.error||"Failed to add flow"}}let a=await t.json();return this.flowsCache&&this.flowsCache.push(a),r.debug("addFlow: Flow added successfully",{flowId:e.id}),{success:!0}}catch(e){return r.warn("addFlow: Failed to add flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to add flow"}}}async generateFlow(e,t,a){r.debug("generateFlow: Entering method",{modelId:t,allowInstall:null==a?void 0:a.allowInstall,allowSubflows:null==a?void 0:a.allowSubflows,maxDepth:null==a?void 0:a.maxDepth});try{var n,s,l,i,o,c,d;let u=await fetch("/api/flow/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:e,modelId:t,allowInstall:(null==a?void 0:a.allowInstall)===!0,allowSubflows:(null==a?void 0:a.allowSubflows)!==!1,..."number"==typeof(null==a?void 0:a.maxDepth)?{maxDepth:a.maxDepth}:{}})}),h=await u.json().catch(()=>null);if(!u.ok)return{success:!1,error:(null==h?void 0:h.error)||"Failed to generate flow"};let p=Array.isArray(h.flows)&&h.flows.length>0?h.flows:[{flow:h.flow,validation:h.validation}];return r.debug("generateFlow: Draft generated",{flowId:null==(n=h.flow)?void 0:n.id,flowCount:p.length,attempts:h.attempts,errorCount:null==(s=h.validation)?void 0:s.errorCount,installedServers:null!=(o=null==(l=h.installedServers)?void 0:l.length)?o:0}),{success:!0,flow:h.flow,validation:h.validation,flows:p,rootFlowId:null!=(c=h.rootFlowId)?c:null==(i=h.flow)?void 0:i.id,attempts:h.attempts,installedServers:null!=(d=h.installedServers)?d:[]}}catch(e){return r.warn("generateFlow: Failed to generate flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to generate flow"}}}async improveFlow(e,t,a,n){r.debug("improveFlow: Entering method",{flowId:null==e?void 0:e.id,modelId:a,allowInstall:null==n?void 0:n.allowInstall});try{var s,l,i,o,c,d,u;let h=await fetch("/api/flow/improve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flow:e,relatedFlows:null==n?void 0:n.relatedFlows,description:t,modelId:a,allowInstall:(null==n?void 0:n.allowInstall)===!0})}),p=await h.json().catch(()=>null);if(!h.ok)return{success:!1,error:(null==p?void 0:p.error)||"Failed to improve flow"};return r.debug("improveFlow: Draft revised",{flowId:null==(s=p.flow)?void 0:s.id,attempts:p.attempts,errorCount:null==(l=p.validation)?void 0:l.errorCount,installedServers:null!=(c=null==(i=p.installedServers)?void 0:i.length)?c:0}),{success:!0,flow:p.flow,validation:p.validation,flows:Array.isArray(p.flows)&&p.flows.length>0?p.flows:[{flow:p.flow,validation:p.validation}],rootFlowId:null!=(d=p.rootFlowId)?d:null==(o=p.flow)?void 0:o.id,attempts:p.attempts,installedServers:null!=(u=p.installedServers)?u:[]}}catch(e){return r.warn("improveFlow: Failed to improve flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to improve flow"}}}async updateFlow(e){r.debug("updateFlow: Entering method",{flowId:e.id,flowName:e.name,nodeCount:e.nodes.length,edgeCount:e.edges.length});try{let t=await fetch("/api/flow/".concat(encodeURIComponent(e.id)),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.json();return{success:!1,error:e.error||"Failed to update flow"}}let a=await t.json();if(this.flowsCache){let t=this.flowsCache.findIndex(t=>t.id===e.id);t>=0?this.flowsCache[t]=a:this.flowsCache.push(a)}return r.debug("updateFlow: Flow updated successfully",{flowId:e.id}),{success:!0}}catch(e){return r.warn("updateFlow: Failed to update flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to update flow"}}}async deleteFlow(e){r.debug("deleteFlow: Entering method",{flowId:e});try{let t=await fetch("/api/flow/".concat(encodeURIComponent(e)),{method:"DELETE"});if(!t.ok){let e=await t.json();return{success:!1,error:e.error||"Failed to delete flow"}}return this.flowsCache&&(this.flowsCache=this.flowsCache.filter(t=>t.id!==e)),r.debug("deleteFlow: Flow deleted successfully",{flowId:e}),{success:!0}}catch(e){return r.warn("deleteFlow: Failed to delete flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to delete flow"}}}async listFlowVersions(e){r.debug("listFlowVersions: Entering method",{flowId:e});try{let t=await fetch("/api/flow/".concat(encodeURIComponent(e),"/versions"));if(!t.ok){let e=await t.json().catch(()=>null);throw Error((null==e?void 0:e.error)||"Failed to list flow versions")}let a=await t.json();return Array.isArray(a.versions)?a.versions:[]}catch(t){return r.warn("listFlowVersions: Failed for flow ".concat(e,":"),t),[]}}async getFlowVersion(e,t){r.debug("getFlowVersion: Entering method",{flowId:e,versionId:t});try{let a=await fetch("/api/flow/".concat(encodeURIComponent(e),"/versions/").concat(encodeURIComponent(t)));if(!a.ok){if(404===a.status)return null;let e=await a.json().catch(()=>null);throw Error((null==e?void 0:e.error)||"Failed to get flow version")}return await a.json()}catch(a){return r.warn("getFlowVersion: Failed for ".concat(e,"/").concat(t,":"),a),null}}createNode(e,t){return r.debug("createNode: Entering method",{type:e,position:t}),{id:(0,n.A)(),type:e,position:t,data:{label:"".concat("mcp"===e?"MCP":e.charAt(0).toUpperCase()+e.slice(1)," Node"),type:e,properties:"process"===e?{inputMode:"full-history"}:{}}}}createStartNode(){return{id:(0,n.A)(),type:"start",position:{x:250,y:150},data:{label:"Start Node",type:"start",properties:{promptTemplate:""}}}}createNewFlow(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"NewFlow";r.debug("createNewFlow: Entering method",{name:e});let t=Date.now();return{id:(0,n.A)(),name:e,createdAt:t,updatedAt:t,nodes:[this.createStartNode()],edges:[]}}createHistoryEntry(e,t){return r.debug("createHistoryEntry: Entering method"),{nodes:[...e],edges:[...t]}}generateSampleFlow(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Sample Flow";return r.debug("generateSampleFlow: Entering method",{name:e}),{id:(0,n.A)(),name:e,nodes:[{id:"1",type:"start",position:{x:250,y:50},data:{label:"Start Node",type:"start",properties:{prompt:"Enter your query here",systemMessage:"You are a helpful assistant",temperature:0}}},{id:"2",type:"process",position:{x:250,y:200},data:{label:"Process Node",type:"process",properties:{operation:"transform",enabled:!0}}},{id:"3",type:"finish",position:{x:250,y:350},data:{label:"Finish Node",type:"finish",properties:{format:"json",template:'{ "result": {{data}} }'}}},{id:"4",type:"mcp",position:{x:450,y:200},data:{label:"MCP Node",type:"mcp",properties:{channels:2,mode:"parallel"}}}],edges:[{id:"e1-2",source:"1",target:"2",type:"custom"},{id:"e2-3",source:"2",target:"3",type:"custom"}]}}constructor(){this.flowsCache=null}}let l=new s},93632:(e,t,a)=>{"use strict";a.d(t,{P:()=>s});let n=(0,a(87021).h)("frontend/services/plannedExecutions");class r{async list(){try{let e=await fetch("/api/planned-executions");if(!e.ok)throw Error("HTTP ".concat(e.status));return await e.json()}catch(e){return n.warn("Failed to list planned executions",e),{paused:!1,executions:[]}}}async create(e){try{let t=await fetch("/api/planned-executions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await t.json();if(!t.ok)return{success:!1,error:(null==a?void 0:a.error)||"HTTP ".concat(t.status)};return{success:!0,execution:a.execution}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async update(e,t){try{let a=await fetch("/api/planned-executions/".concat(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),n=await a.json();if(!a.ok)return{success:!1,error:(null==n?void 0:n.error)||"HTTP ".concat(a.status)};return{success:!0,execution:n.execution}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async delete(e){try{let t=await fetch("/api/planned-executions/".concat(e),{method:"DELETE"});if(!t.ok){let e=await t.json().catch(()=>null);return{success:!1,error:(null==e?void 0:e.error)||"HTTP ".concat(t.status)}}return{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async setPaused(e){try{let t=await fetch("/api/planned-executions",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({paused:e})});if(!t.ok){let e=await t.json().catch(()=>null);return{success:!1,error:(null==e?void 0:e.error)||"HTTP ".concat(t.status)}}return{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async runNow(e){try{let t=await fetch("/api/planned-executions/".concat(e,"/run"),{method:"POST"}),a=await t.json();if(!t.ok)return{success:!1,error:(null==a?void 0:a.error)||"HTTP ".concat(t.status)};return{success:!0,record:a.record}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async loadRuns(e){try{let t=await fetch("/api/planned-executions/".concat(e,"/runs"));if(!t.ok)throw Error("HTTP ".concat(t.status));let a=await t.json();return Array.isArray(null==a?void 0:a.runs)?a.runs:[]}catch(t){return n.warn("Failed to load runs for ".concat(e),t),[]}}async previewSchedule(e,t){try{let a=await fetch("/api/planned-executions/preview-schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cron:e,timezone:t})});if(!a.ok)throw Error("HTTP ".concat(a.status));return await a.json()}catch(e){return{valid:!1,error:e instanceof Error?e.message:"Preview failed",nextRuns:[]}}}}let s=new r},94460:(e,t,a)=>{Promise.resolve().then(a.bind(a,70479))}},e=>{e.O(0,[2678,4754,9244,3392,1871,981,2003,9562,488,3272,3077,9581,3659,7328,8551,6428,7264,9951,9164,3772,8441,1255,7358],()=>e(e.s=94460)),_N_E=e.O()}]);
|