@boomi/embedkit 1.4.6 → 1.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +158 -14
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -6
- package/dist/index.umd.cjs +4 -4
- package/package.json +1 -1
- package/license.txt +0 -3
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
BSD-2-Clause License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2026, Boomi. All rights reserved.
|
|
4
4
|
|
|
5
5
|
Redistribution and use in source and binary forms, with or without
|
|
6
6
|
modification, are permitted provided that the following conditions are met:
|
package/README.md
CHANGED
|
@@ -1,31 +1,175 @@
|
|
|
1
1
|
# Boomi EmbedKit
|
|
2
2
|
|
|
3
|
-
**Boomi EmbedKit** is
|
|
3
|
+
**Boomi EmbedKit** (`@boomi/embedkit`) is a white-label embeddable plugin that lets you surface Boomi-powered experiences — Integrations, Connections, Scheduling, Data Mapping, and AI Agents — directly inside your own application. It runs inside a Shadow DOM so its styles are fully isolated from your host app, and it ships its own React/ReactDOM bundle so no dependencies are required on the host page.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
- **React**
|
|
7
|
-
- **Vanilla JavaScript (ES Modules)**
|
|
8
|
-
- **CommonJS**
|
|
5
|
+
This is the official Boomi EmbedKit. If you fork or change this code, you should not use the name Boomi for your version.
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
### What You Can Embed
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
| Component | Description |
|
|
10
|
+
|-----------|-------------|
|
|
11
|
+
| **Integrations** | List, run, and monitor integration pack instances for a Boomi sub-account |
|
|
12
|
+
| **Connections** | Let users configure and save connection credentials |
|
|
13
|
+
| **Schedules** | View and modify process schedule settings |
|
|
14
|
+
| **Mapping** | Interactive data mapping canvas for field-level transformations |
|
|
15
|
+
| **AI Agents** | Conversational AI agent chat UI backed by your Boomi Agentic flows |
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
### Integration Methods
|
|
18
|
+
|
|
19
|
+
EmbedKit supports three integration paths depending on your stack:
|
|
15
20
|
|
|
16
|
-
|
|
21
|
+
| Method | Package | Best For |
|
|
22
|
+
|--------|---------|----------|
|
|
23
|
+
| **React** | `@boomi/embedkit` via npm | React applications — use `EmbedKitProvider` + `RenderComponent` |
|
|
24
|
+
| **ES Module / CommonJS** | `@boomi/embedkit` via npm | Vanilla JS, Node-backed apps, any bundler |
|
|
25
|
+
| **CDN (Public Embed)** | Drop-in UMD script via `cdn.boomi.space` | Any existing website — no build tools required |
|
|
26
|
+
|
|
27
|
+
### Authentication
|
|
28
|
+
|
|
29
|
+
EmbedKit uses a nonce → JWT exchange pattern. Your server authenticates the user, calls the EmbedKit Server to get a short-lived nonce, and passes it to the client. The plugin exchanges the nonce for a JWT and handles all token refresh automatically. The CDN path uses a public token + per-project allow-listed origins instead of a server-side session.
|
|
17
30
|
|
|
18
31
|
---
|
|
19
32
|
|
|
20
33
|
## Documentation
|
|
21
34
|
|
|
22
|
-
|
|
35
|
+
| Guide | Description |
|
|
36
|
+
|-------|-------------|
|
|
37
|
+
| [Getting Started](./public-docs/GettingStarted.md) | Installation, server-side setup, client initialization, component rendering, theming |
|
|
38
|
+
| [CDN Configuration](./public-docs/CDNConfiguration.md) | Full CDN (public embed) setup — Admin Console walkthrough, embed types, configuration reference, troubleshooting |
|
|
39
|
+
| [Release Notes](./public-docs/ReleaseNotes.md) | Version history and upgrade notes |
|
|
40
|
+
| [API Reference](./docs-md/README.md) | Full TypeDoc-generated API reference (types, hooks, functions) |
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
npm install @boomi/embedkit
|
|
48
|
+
# or
|
|
49
|
+
yarn add @boomi/embedkit
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Quick Start — React
|
|
55
|
+
|
|
56
|
+
```jsx
|
|
57
|
+
import BoomiPlugin, { RenderComponent } from '@boomi/embedkit';
|
|
58
|
+
import uiConfig from './boomi.config';
|
|
59
|
+
|
|
60
|
+
// After your server returns a nonce:
|
|
61
|
+
BoomiPlugin({
|
|
62
|
+
serverBase: 'https://your-embedkit-server.com/api/v1',
|
|
63
|
+
tenantId: 'YOUR_BOOMI_PARENT_ACCOUNT_ID',
|
|
64
|
+
nonce: nonceFromServer,
|
|
65
|
+
boomiConfig: uiConfig,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Render a component into <div id="boomi" />
|
|
69
|
+
RenderComponent({
|
|
70
|
+
hostId: 'boomi',
|
|
71
|
+
component: 'Integrations',
|
|
72
|
+
props: { componentKey: 'integrationsMain' },
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Quick Start — CDN (Public Embed)
|
|
79
|
+
|
|
80
|
+
For embedding Boomi AI Agents on any existing website — no npm, no build pipeline required.
|
|
81
|
+
|
|
82
|
+
**1. Create a project** in the [EmbedKit Admin Console](https://admin.boomi.space), configure your agent and origins, and copy the generated public token.
|
|
83
|
+
|
|
84
|
+
**2. Add to your HTML:**
|
|
85
|
+
|
|
86
|
+
```html
|
|
87
|
+
<!-- EmbedKit stylesheet -->
|
|
88
|
+
<link rel="stylesheet" href="https://cdn.boomi.space/cdn/embedkit-cdn.css" />
|
|
23
89
|
|
|
24
|
-
|
|
90
|
+
<!-- Configure the embed -->
|
|
91
|
+
<script>
|
|
92
|
+
window.BoomiEmbed = {
|
|
93
|
+
publicToken: "pk_xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
|
|
94
|
+
agentId: "project_xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
|
|
95
|
+
mountId: "boomi-agent",
|
|
96
|
+
serverBase: "https://api.boomi.space/api/v1"
|
|
97
|
+
};
|
|
98
|
+
</script>
|
|
99
|
+
|
|
100
|
+
<!-- Load the bundle (React + ReactDOM bundled in) -->
|
|
101
|
+
<script src="https://cdn.boomi.space/embedkit-cdn.umd.cjs" async></script>
|
|
102
|
+
|
|
103
|
+
<!-- Mount target -->
|
|
104
|
+
<div id="boomi-agent"></div>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### CDN Assets
|
|
108
|
+
|
|
109
|
+
| File | Purpose |
|
|
110
|
+
|------|---------|
|
|
111
|
+
| `https://cdn.boomi.space/embedkit-cdn.umd.cjs` | JavaScript bundle (UMD — works in all browsers) |
|
|
112
|
+
| `https://cdn.boomi.space/cdn/embedkit-cdn.css` | Required stylesheet |
|
|
113
|
+
|
|
114
|
+
### CDN Configuration Properties
|
|
115
|
+
|
|
116
|
+
| Property | Required | Description |
|
|
117
|
+
|----------|----------|-------------|
|
|
118
|
+
| `publicToken` | Yes | The `pk_...` token from your project in Admin Console |
|
|
119
|
+
| `agentId` | Yes | The project ID (`project_...`) from Admin Console |
|
|
120
|
+
| `serverBase` | Yes | EmbedKit API base URL: `https://api.boomi.space/api/v1` |
|
|
121
|
+
| `mountId` | No | ID of the `<div>` to mount into. Defaults to `"boomi-agent"` |
|
|
122
|
+
| `userId` | No | Your user's identifier for session tracking / analytics |
|
|
123
|
+
| `autoInit` | No | Set to `false` to defer initialization until you call it manually |
|
|
124
|
+
|
|
125
|
+
### CDN Embed Types
|
|
126
|
+
|
|
127
|
+
The CDN supports three presentation modes, configured in the Admin Console:
|
|
128
|
+
|
|
129
|
+
| Type | Description |
|
|
130
|
+
|------|-------------|
|
|
131
|
+
| `single` | Floating launcher pill → opens one agent in a modal |
|
|
132
|
+
| `tiles` | Inline grid of agent cards — users pick and launch |
|
|
133
|
+
| `list` | Floating pill → opens a searchable agent list modal |
|
|
134
|
+
|
|
135
|
+
For the full CDN setup walkthrough including CORS configuration, the Admin Console, all agent UI options, platform-specific examples (WordPress, Salesforce), and troubleshooting, see [CDN Configuration](./public-docs/CDNConfiguration.md).
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Theming
|
|
140
|
+
|
|
141
|
+
EmbedKit ships three built-in themes (`boomi`, `light`, `dark`) and supports fully custom themes via CSS variables in `boomi.config.js`.
|
|
142
|
+
|
|
143
|
+
```js
|
|
144
|
+
// boomi.config.js
|
|
145
|
+
export default {
|
|
146
|
+
theme: {
|
|
147
|
+
defaultTheme: 'boomi', // 'light' | 'dark' | 'boomi' | '<your-custom>'
|
|
148
|
+
allowThemes: true,
|
|
149
|
+
},
|
|
150
|
+
cssVarsByTheme: {
|
|
151
|
+
'my-brand': {
|
|
152
|
+
'--boomi-root-bg-color': '#0f172a',
|
|
153
|
+
'--boomi-btn-primary-bg': '#2563eb',
|
|
154
|
+
'--boomi-btn-primary-fg': '#ffffff',
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Full theming reference (all CSS tokens, built-in themes, runtime switching) is in [Getting Started](./public-docs/GettingStarted.md#styling--theming-overview).
|
|
25
161
|
|
|
26
162
|
---
|
|
27
163
|
|
|
28
|
-
##
|
|
164
|
+
## Examples
|
|
165
|
+
|
|
166
|
+
Working examples are available in the **[embedkit-examples](https://github.com/OfficialBoomi/embedkit-examples)** repository, including React and vanilla JS implementations.
|
|
167
|
+
|
|
168
|
+
You can also open the React example directly on StackBlitz:
|
|
169
|
+
[Boomi EmbedKit React Example](https://stackblitz.com/~/github.com/OfficialBoomi/embedkit)
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Release Notes
|
|
29
174
|
|
|
30
|
-
|
|
31
|
-
🔗 **[Boomi EmbedKit React Example](https://stackblitz.com/~/github.com/OfficialBoomi/embedkit)**
|
|
175
|
+
See [Release Notes](./public-docs/ReleaseNotes.md) for version history.
|
package/dist/index.cjs
CHANGED
|
@@ -2103,17 +2103,17 @@ https://sweetalert2.github.io/#ajax-request`),c3(t),typeof t.title=="string"&&(t
|
|
|
2103
2103
|
* flows can match other admin mutation hooks.
|
|
2104
2104
|
*/const xH=()=>{const[t,e]=O.useState(!1),[n,o]=O.useState(null),{deleteCorsConfig:i}=Wu(),r=O.useCallback(async s=>{e(!0),o(null);try{await i(s),ge.debug("[useDeleteCors] deleted config",{primaryAccountId:s.primaryAccountId})}catch(c){const a=(c==null?void 0:c.message)||"Failed to delete CORS configuration";throw ge.error({err:c},"[useDeleteCors] failed"),o(a),c}finally{e(!1)}},[i]);return O.useMemo(()=>({deleteCors:r,isDeleting:t,error:n}),[r,n,t])},EH=({isOpen:t,onClose:e,onSubmit:n,isSaving:o,serverError:i})=>{const[r,s]=O.useState(""),[c,a]=O.useState(null);O.useEffect(()=>{t&&(s(""),a(null))},[t]);const u=async()=>{const l=r.trim();if(!l){a("Origin is required");return}a(null),await n(l)};return w.jsx(no,{isOpen:t,title:"Add Allowed Origin",description:"Add a new origin to the allowed list for this tenant.",onClose:e,onSubmit:u,submitLabel:o?"Saving...":"Add Origin",showSaveButton:!o,children:w.jsx(bn,{formName:"corsAdd",label:"Origin",required:!0,inputName:"origin",readOnly:!1,value:r,onChange:l=>s(l.target.value),placeholder:"https://app.example.com",helperText:'Use "null" to allow file:// and sandboxed iframe origins.',error:c||i||void 0})})},TH=({isOpen:t,origin:e,onClose:n,onSubmit:o,isSaving:i,serverError:r})=>{const[s,c]=O.useState(e??""),[a,u]=O.useState(null);O.useEffect(()=>{t&&(c(e??""),u(null))},[t,e]);const l=async()=>{const d=s.trim();if(!d){u("Origin is required");return}u(null),await o(d)};return w.jsx(no,{isOpen:t,title:"Edit Allowed Origin",description:"Update the selected origin for this tenant.",onClose:n,onSubmit:l,submitLabel:i?"Saving...":"Save Changes",showSaveButton:!i,children:w.jsx(bn,{formName:"corsEdit",label:"Origin",required:!0,inputName:"origin",readOnly:!1,value:s,onChange:d=>c(d.target.value),placeholder:"https://app.example.com",helperText:'Use "null" to allow file:// and sandboxed iframe origins.',error:a||r||void 0})})},AH=({isOpen:t,origin:e,onClose:n,onConfirm:o,isDeleting:i})=>w.jsx(no,{isOpen:t,title:"Delete Allowed Origin",description:"Remove this origin from the allowed list for this tenant.",onClose:n,onSubmit:o,submitLabel:i?"Deleting...":"Delete",showSaveButton:!i,children:w.jsxs("p",{className:"text-sm",children:["Are you sure you want to remove"," ",w.jsx("span",{className:"font-semibold",children:e})," from the allowed origins?"]})});function tL(){const t=fo(),e=O.useCallback(async(m={})=>{const{signal:p,...g}=m;return t.get("/admin/redis/sessions",{params:g,signal:p})},[t]),n=O.useCallback(async(m={})=>{const{signal:p,...g}=m;return t.get("/admin/redis/sessions/all",{params:g,signal:p})},[t]),o=O.useCallback(async(m={})=>{const{signal:p,...g}=m;return t.get("/admin/redis/keys",{params:g,signal:p})},[t]),i=O.useCallback(async(m={})=>{const{signal:p,...g}=m;return t.get("/admin/redis/keys/all",{params:g,signal:p})},[t]),r=O.useCallback(async(m,p)=>t.get("/admin/redis/sub-accounts",{params:{tenantId:m},signal:p}),[t]),s=O.useCallback(async m=>t.get("/admin/redis/tenants",{signal:m}),[t]),c=O.useCallback(async m=>t.get("/admin/redis/key-types",{signal:m}),[t]),a=O.useCallback(async(m,p)=>(ge.debug("[useAdminRedisService.getKeyDetails]",{key:m,reveal:p==null?void 0:p.reveal}),t.get("/admin/redis/keys/detail",{params:{key:m,reveal:p==null?void 0:p.reveal},signal:p==null?void 0:p.signal})),[t]),u=O.useCallback(async(m,p,g,b)=>{await t.put("/admin/redis/keys",{key:m,value:p,ttlSeconds:g},{signal:b})},[t]),l=O.useCallback(async(m,p)=>{await t.del("/admin/redis/keys",{params:{key:m},signal:p})},[t]),d=O.useCallback(async m=>t.post("/admin/redis/clear/tenant",{},{signal:m}),[t]),f=O.useCallback(async(m,p)=>t.post("/admin/redis/clear/sub-account",{subAccountId:m},{signal:p}),[t]),h=O.useCallback(async(m,p)=>t.post("/admin/redis/sessions/revoke",{subAccountId:m},{signal:p}),[t]);return O.useMemo(()=>({listSessions:e,listSessionsAll:n,listKeys:o,listKeysAll:i,listSubAccounts:r,listTenants:s,listKeyTypes:c,getKeyDetails:a,deleteKey:l,clearTenant:d,clearSubAccount:f,revokeSessions:h,updateKey:u}),[e,n,o,i,r,s,c,a,l,d,f,h,u])}const Th=12,nL=({componentKey:t,primaryAccountId:e})=>{var Fe,$e,re,be,je,qe,De;const{boomiConfig:n,tenantId:o,setPageIsLoading:i}=yt(),r=e??o??(n==null?void 0:n.tenantId),s=`cors-view:${t}`,c=($e=(Fe=n==null?void 0:n.components)==null?void 0:Fe[t])==null?void 0:$e.cors;(re=c==null?void 0:c.search)==null||re.show;const a=((be=c==null?void 0:c.addButton)==null?void 0:be.show)??!0,u=((je=c==null?void 0:c.viewTypeButton)==null?void 0:je.show)??!0,l=fo(),{listTenants:d,listSubAccounts:f,listKeyTypes:h}=tL(),{allowedOrigins:m,refetch:p,isLoading:g,error:b}=wH({primaryAccountId:r,auto:!!r}),{updateCors:v,isUpdating:E,error:T}=yH(),{deleteCors:y,isDeleting:x,error:_}=xH(),[N,C]=O.useState([]),[L,D]=O.useState(""),[k,I]=O.useState(""),[S,A]=O.useState(""),[R,$]=O.useState([]),[P,U]=O.useState([]),[F,B]=O.useState(!1),[G,z]=O.useState(1),[Q,W]=O.useState("off"),[V,K]=O.useState(!1),[q,X]=O.useState(!1),[J,se]=O.useState(!1),[Y,he]=O.useState(null),[ie,ye]=O.useState(null),[Ae,Re]=O.useState(null),[Ye,ze]=O.useState({add:!1,edit:!1,delete:!1});O.useEffect(()=>{try{const pe=localStorage.getItem(s);(pe==="on"||pe==="off")&&W(pe)}catch{}},[s]),O.useEffect(()=>{F||r&&C(m.map(pe=>({origin:pe,tenantId:r})))},[m,F,r]),O.useEffect(()=>{const pe=new AbortController;return h(pe.signal).then(Ie=>B(!!Ie.isSuperAdmin)).catch(()=>B(!1)),()=>pe.abort()},[h]),O.useEffect(()=>{if(!F)return;const pe=new AbortController;return d(pe.signal).then(Ie=>$(Ie.items??[])).catch(()=>$([])),()=>pe.abort()},[F,d]),O.useEffect(()=>{if(!F)return;const pe=new AbortController;return f(k||void 0,pe.signal).then(Ge=>U(Ge.items??[])).catch(()=>U([])),()=>pe.abort()},[F,k,f]);const Ke=O.useCallback(pe=>l.get("/admin/cors",{signal:pe}).then(Ie=>{const Ge=((Ie==null?void 0:Ie.items)??[]).flatMap(le=>(le.allowedOrigins||[]).map(ne=>({origin:ne,tenantId:le.primaryAccountId})));C(Ge)}),[l]);O.useEffect(()=>{if(!F)return;const pe=new AbortController;return Ke(pe.signal).catch(()=>C([])),()=>pe.abort()},[F,Ke]);const Pe=O.useMemo(()=>{const pe=L.trim().toLowerCase(),Ie=k?N.filter(Ge=>Ge.tenantId===k):N;return pe?Ie.filter(Ge=>Ge.origin.toLowerCase().includes(pe)):Ie},[N,L,k]),Xe=O.useMemo(()=>Pe,[Pe,S]),Ce=Math.max(1,Math.ceil(Xe.length/Th)),Ue=Xe.slice((G-1)*Th,G*Th),fe=pe=>{ze(Ie=>({...Ie,[pe]:!0})),setTimeout(()=>ze(Ie=>({...Ie,[pe]:!1})),3e3)},Ee=()=>r||(Re("primaryAccountId is required to manage CORS."),null),we=()=>F?k||(Re("Select a tenant to modify CORS configuration."),null):Ee(),Te=O.useCallback(()=>{W(pe=>{const Ie=pe==="on"?"off":"on";try{localStorage.setItem(s,Ie)}catch{}return Ie})},[s]),ue=async pe=>{const Ie=we();if(!Ie)return;const Ge=Array.from(new Set([...N.filter(le=>le.tenantId===Ie).map(le=>le.origin),pe]));i(!0);try{const le=await v({primaryAccountId:Ie,allowedOrigins:Ge});F||C(le.allowedOrigins.map(ne=>({origin:ne,tenantId:Ie}))),K(!1),fe("add"),F?await Ke():await p()}catch(le){ge.error({err:le},"[Cors] add failed")}finally{i(!1)}},oe=async pe=>{if(!Y)return;const Ie=F?ie||we():Ee();if(!Ie)return;const Ge=N.filter(ne=>ne.tenantId===Ie).map(ne=>ne.origin===Y?pe:ne.origin),le=Array.from(new Set(Ge));i(!0);try{const ne=await v({primaryAccountId:Ie,allowedOrigins:le});F||C(ne.allowedOrigins.map(ve=>({origin:ve,tenantId:Ie}))),X(!1),he(null),ye(null),fe("edit"),F?await Ke():await p()}catch(ne){ge.error({err:ne},"[Cors] edit failed")}finally{i(!1)}},ce=async()=>{if(!Y)return;const pe=F?ie||we():Ee();if(!pe)return;const Ie=N.filter(Ge=>Ge.tenantId===pe).map(Ge=>Ge.origin).filter(Ge=>Ge!==Y);i(!0);try{if(Ie.length===0)await y({primaryAccountId:pe}),F||C([]);else{const Ge=await v({primaryAccountId:pe,allowedOrigins:Ie});F||C(Ge.allowedOrigins.map(le=>({origin:le,tenantId:pe})))}se(!1),he(null),ye(null),fe("delete"),F?await Ke():await p()}catch(Ge){ge.error({err:Ge},"[Cors] delete failed")}finally{i(!1)}},Ne=({origin:pe,tenantId:Ie})=>w.jsxs(nr,{children:[w.jsx(Ft.Item,{children:({active:Ge})=>w.jsxs("button",{onClick:()=>{he(pe),ye(Ie),X(!0)},className:"boomi-menu-item","data-headlessui-state":Ge?"active":void 0,children:[w.jsx(fu,{className:"boomi-menu-icon"}),"Edit"]})}),w.jsx("div",{className:"boomi-menu-divider"}),w.jsx(Ft.Item,{children:({active:Ge})=>w.jsxs("button",{onClick:()=>{he(pe),ye(Ie),se(!0)},className:"boomi-menu-item boomi-menu-item--danger","data-headlessui-state":Ge?"active":void 0,children:[w.jsx(uo,{className:"boomi-menu-icon"}),"Delete"]})})]}),ke=Ae||b||T||_||null;return w.jsxs(w.Fragment,{children:[Ye.add&&w.jsx(lo,{type:"success",content:"Origin added."}),Ye.edit&&w.jsx(lo,{type:"success",content:"Origin updated."}),Ye.delete&&w.jsx(lo,{type:"success",content:"Origin deleted."}),w.jsx(EH,{isOpen:V,onClose:()=>K(!1),onSubmit:ue,isSaving:E,serverError:V?T:null}),w.jsx(TH,{isOpen:q,origin:Y,onClose:()=>{X(!1),he(null)},onSubmit:oe,isSaving:E,serverError:q?T:null}),w.jsx(AH,{isOpen:J,origin:Y,onClose:()=>{se(!1),he(null)},onConfirm:ce,isDeleting:x}),w.jsxs("div",{className:"w-full h-full p-6",children:[w.jsxs("div",{className:"space-y-2",children:[w.jsx("h1",{className:"text-2xl font-semibold",children:"CORS Configuration"}),w.jsx("p",{className:"text-sm opacity-70",children:"Manage allowed origins for this tenant."})]}),w.jsxs("div",{className:"flex items-end gap-3 mb-4 mt-4",children:[w.jsxs("div",{className:"flex flex-wrap items-end gap-3 flex-1 min-w-0",children:[w.jsx("div",{className:`min-w-[220px]${F?" pt-6":""}`,children:w.jsx(Fr,{searchCallback:pe=>{D(pe),z(1)}})}),F&&w.jsxs("label",{className:"text-xs font-semibold",children:["Tenant",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:k,onChange:pe=>{I(pe.target.value),A(""),z(1)},children:[w.jsx("option",{value:"",children:"All"}),R.map(pe=>w.jsx("option",{value:pe,children:pe},pe))]})]})]}),w.jsxs("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:[u&&w.jsx(rt,{toggle:!0,primary:!1,viewLoc:s,onClass:"flex w-full justify-center rounded-md px-2 py-2 text-xs font-semibold leading-6 shadow-md transition-colors duration-100",showIcon:!0,label:(qe=c==null?void 0:c.viewTypeButton)==null?void 0:qe.label,icon:w.jsx(Kf,{className:"h-5 w-5"}),onIcon:w.jsx(Gf,{className:"h-5 w-5"}),onClick:Te}),a&&w.jsx(rt,{toggle:!1,primary:!0,showIcon:!0,label:`Add ${((De=c==null?void 0:c.addButton)==null?void 0:De.label)??""}`.trim(),icon:w.jsx(Hr,{className:"h-5 w-5"}),onClick:()=>K(!0)})]})]}),ke&&w.jsx("div",{className:"boomi-notice boomi-notice--error text-sm",children:ke}),Q==="off"?w.jsxs(w.Fragment,{children:[w.jsx("ul",{role:"list",className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-x-6 gap-y-8",children:g?w.jsx("div",{className:"col-span-full flex justify-center items-center",children:w.jsx(on,{})}):Ue.length>0?Ue.map(pe=>{var Ie;return w.jsxs("li",{className:"boomi-card boomi-cors-card",children:[w.jsx("div",{className:"flex gap-4 p-4",children:w.jsxs("div",{className:"flex flex-col w-full",children:[w.jsx("h3",{className:"text-base font-semibold break-words truncate overflow-hidden pr-2",children:pe.origin}),w.jsxs("p",{className:"text-xs mt-1 line-clamp-2 break-words overflow-hidden",children:["Origin allowed for tenant ",pe.tenantId,"."]})]})}),w.jsxs("div",{className:"flex w-full p-2 justify-end items-center gap-x-2 relative overflow-visible",children:[w.jsx(rt,{toggle:!1,primary:!0,showIcon:!1,label:((Ie=c==null?void 0:c.editButton)==null?void 0:Ie.label)??"Edit",onClick:()=>{he(pe.origin),ye(pe.tenantId),X(!0)}}),w.jsx(Ne,{origin:pe.origin,tenantId:pe.tenantId})]})]},`${pe.tenantId}:${pe.origin}`)}):w.jsx("div",{className:"col-span-full flex justify-center items-center",children:w.jsx("p",{className:"text-gray-500 text-xs",children:"No allowed origins found."})})}),!g&&Ce>1&&w.jsx(jr,{currentPage:G,totalPages:Ce,onPageChange:pe=>z(pe)})]}):w.jsxs(w.Fragment,{children:[w.jsxs("table",{className:"w-full table-auto rounded-lg shadow-sm",children:[w.jsx("thead",{className:"boomi-table-header",children:w.jsxs("tr",{children:[w.jsx("th",{className:"py-3 px-4 text-left text-sm font-semibold w-3/4",children:"Origin"}),F&&w.jsx("th",{className:"py-3 px-4 text-left text-sm font-semibold",children:"Tenant"}),w.jsx("th",{className:"py-3 px-4 text-right text-sm font-semibold w-1/4",children:"Actions"})]})}),w.jsx("tbody",{className:"divide-y",children:g?w.jsx("tr",{children:w.jsx("td",{colSpan:F?3:2,children:w.jsx("div",{className:"flex justify-center items-center py-6",children:w.jsx(on,{})})})}):Ue.length>0?Ue.map(pe=>w.jsxs("tr",{className:"boomi-table-row",children:[w.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2 max-w-md break-words",children:pe.origin}),F&&w.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2",children:pe.tenantId}),w.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2",children:w.jsx("div",{className:"flex justify-end",children:w.jsx(Ne,{origin:pe.origin,tenantId:pe.tenantId})})})]},`${pe.tenantId}:${pe.origin}`)):w.jsx("tr",{children:w.jsx("td",{colSpan:F?3:2,children:w.jsx("div",{className:"flex justify-center items-center py-4",children:w.jsx("p",{className:"text-gray-500 text-xs",children:"No allowed origins found."})})})})})]}),!g&&Ce>1&&w.jsx("div",{className:"mt-4 flex justify-end",children:w.jsx(jr,{currentPage:G,totalPages:Ce,onPageChange:z})})]})]})]})};function oL(){const t=fo(),e=O.useCallback(s=>`/admin/agents/${encodeURIComponent(s)}`,[]),n=O.useCallback(async s=>{const{primaryAccountId:c,includeDetails:a,signal:u}=s;return t.get(e(c),{signal:u,params:a?{includeDetails:!0}:void 0})},[t,e]),o=O.useCallback(async s=>{const{primaryAccountId:c,signal:a}=s;return t.get(`${e(c)}/available`,{signal:a})},[t,e]),i=O.useCallback(async s=>{const{primaryAccountId:c,agentId:a,boomiAgentId:u,label:l,allowedOrigins:d,config:f,publicTokenIds:h,createToken:m,rateLimit:p,signal:g}=s,b={agentId:a};return u!==void 0&&(b.boomiAgentId=u),l!==void 0&&(b.label=l),d!==void 0&&(b.allowedOrigins=d),f!==void 0&&(b.config=f),h!==void 0&&(b.publicTokenIds=h),m!==void 0&&(b.createToken=m),p!==void 0&&(b.rateLimit=p),t.post(e(c),b,{signal:g})},[t,e]),r=O.useCallback(async s=>{const{primaryAccountId:c,agentId:a,signal:u}=s;await t.del(`${e(c)}/${encodeURIComponent(a)}`,{signal:u})},[t,e]);return O.useMemo(()=>({listAgents:n,listAvailableAgents:o,createAgent:i,deleteAgent:r}),[n,o,i,r])}const iL=({label:t,labelAddon:e,value:n,placeholder:o,helperText:i,error:r,onChange:s})=>{const c=O.useMemo(()=>Math.max(1,n.split(`
|
|
2105
2105
|
`).length),[n]),a=O.useMemo(()=>Array.from({length:c},(u,l)=>String(l+1)).join(`
|
|
2106
|
-
`),[c]);return w.jsxs("div",{children:[w.jsxs("label",{className:"boomi-form-label inline-flex items-center gap-2",children:[w.jsx("span",{children:t}),e]}),w.jsxs("div",{className:["flex w-full rounded-md border overflow-hidden","bg-[color-mix(in_srgb,var(--boomi-card-bg,#ffffff)_92%,#000000)]",r?"boomi-input--error":""].join(" ").trim(),children:[w.jsx("pre",{className:["m-0 py-2 px-3 text-xs font-mono leading-5","text-[color-mix(in_srgb,var(--boomi-card-fg,#111)_55%,transparent)]","bg-[color-mix(in_srgb,var(--boomi-card-bg,#ffffff)_86%,#000000)]","border-r border-[color-mix(in_srgb,var(--boomi-card-border,#e5e7eb)_80%,transparent)]","select-none text-right min-w-[2.5rem]"].join(" "),children:a}),w.jsx("textarea",{className:["boomi-input flex-1 rounded-none border-0 font-mono text-xs leading-5","bg-transparent p-2 min-h-[120px]","focus:outline-none"].join(" "),placeholder:o,value:n,onChange:u=>s(u.target.value)})]}),i&&w.jsx("p",{className:"boomi-form-helper",children:i}),r&&w.jsx("p",{className:"boomi-form-error",children:r})]})},rs=[{value:"",label:"None"},{value:"🤖",label:"🤖 Robot"},{value:"💬",label:"💬 Chat"},{value:"🗣️",label:"🗣️ Speaking"},{value:"✨",label:"✨ Sparkles"},{value:"🧠",label:"🧠 Brain"},{value:"💡",label:"💡 Idea"},{value:"🚀",label:"🚀 Rocket"},{value:"⚡",label:"⚡ Lightning"},{value:"🔍",label:"🔍 Search"},{value:"🛠️",label:"🛠️ Tools"},{value:"🤝",label:"🤝 Handshake"},{value:"🌐",label:"🌐 Globe"},{value:"🎯",label:"🎯 Target"},{value:"📊",label:"📊 Analytics"}],_r=["bottom-right","bottom-left","top-right","top-left"],Lf=()=>({label:"",description:"",icon:"🤖",hideIcon:!1,buttonLabel:"Launch"}),SH=t=>/^#[0-9a-fA-F]{3,8}$/.test(t.trim()),AT=["--boomi-font","--default-font-family","--boomi-accent","--boomi-agent-bg","--boomi-agent-blur","--boomi-agent-border","--boomi-agent-bubble-agent-bg","--boomi-agent-bubble-agent-border","--boomi-agent-bubble-agent-fg","--boomi-agent-bubble-border","--boomi-agent-bubble-shadow","--boomi-agent-bubble-user-bg","--boomi-agent-bubble-user-border","--boomi-agent-bubble-user-fg","--boomi-agent-card-tint","--boomi-agent-chat-bg","--boomi-agent-chat-border","--boomi-agent-chat-fg","--boomi-agent-close-bg-hover","--boomi-agent-close-fg","--boomi-agent-close-hover-fg","--boomi-agent-compose-bg","--boomi-agent-compose-border","--boomi-agent-compose-input-bg","--boomi-agent-compose-input-border","--boomi-agent-compose-secondary-bg","--boomi-agent-compose-secondary-border","--boomi-agent-compose-shadow","--boomi-agent-fg","--boomi-agent-header-bg","--boomi-agent-header-border","--boomi-agent-pane-bg","--boomi-agent-pane-bg-color","--boomi-agent-pane-fg","--boomi-agent-pane-fg-color","--boomi-agent-radius","--boomi-agent-ring","--boomi-agent-row-shimmer-opacity","--boomi-agent-row-tint","--boomi-agent-section-bg","--boomi-agent-section-border","--boomi-agent-section-fg","--boomi-agent-section-shadow","--boomi-agent-shadow","--boomi-agent-shimmer-1","--boomi-agent-shimmer-2","--boomi-agent-shimmer-angle","--boomi-agent-shimmer-direction","--boomi-agent-shimmer-opacity","--boomi-agent-shimmer-speed","--boomi-agent-tab-bg","--boomi-agent-tab-bg-active","--boomi-agent-tab-border","--boomi-agent-tab-border-active","--boomi-agent-tab-fg","--boomi-agent-tab-fg-active","--boomi-agent-tab-shadow-active","--boomi-agent-text-bg","--boomi-agent-text-border","--boomi-agent-text-copy-bg","--boomi-agent-text-copy-bg-hover","--boomi-agent-text-copy-fg","--boomi-agent-text-fg","--boomi-agent-thread-separator","--boomi-agent-update-bg","--boomi-agent-update-border","--boomi-agent-update-content-bg","--boomi-agent-update-content-fg","--boomi-agent-update-desc-fg","--boomi-agent-update-fg","--boomi-agent-update-radius","--boomi-agent-update-shadow","--boomi-agent-update-title-fg","--boomi-angle","--boomi-btn-primary-bg","--boomi-btn-primary-bg-active","--boomi-btn-primary-bg-hover","--boomi-btn-primary-border","--boomi-btn-primary-border-active","--boomi-btn-primary-border-hover","--boomi-btn-primary-fg","--boomi-btn-primary-fg-active","--boomi-btn-primary-fg-hover","--boomi-btn-primary-shadow","--boomi-btn-primary-shadow-active","--boomi-btn-primary-shadow-hover","--boomi-btn-secondary-bg","--boomi-btn-secondary-bg-active","--boomi-btn-secondary-bg-hover","--boomi-btn-secondary-border","--boomi-btn-secondary-border-active","--boomi-btn-secondary-border-hover","--boomi-btn-secondary-fg","--boomi-btn-secondary-fg-active","--boomi-btn-secondary-fg-hover","--boomi-btn-secondary-shadow","--boomi-btn-secondary-shadow-active","--boomi-btn-secondary-shadow-hover","--boomi-card-bg","--boomi-card-border","--boomi-card-fg","--boomi-card-hover-scale","--boomi-card-hover-shadow","--boomi-card-radius","--boomi-card-shadow","--boomi-chip-bg","--boomi-chip-border","--boomi-chip-error-bg","--boomi-chip-error-border","--boomi-chip-error-fg","--boomi-chip-fg","--boomi-chip-pulse-color","--boomi-chip-success-bg","--boomi-chip-success-border","--boomi-chip-success-fg","--boomi-chip-warning-bg","--boomi-chip-warning-border","--boomi-chip-warning-fg","--boomi-root-bg-color","--boomi-root-fg-color","--boomi-page-bg-color","--boomi-page-fg-color","--boomi-muted","--boomi-header-bg-color","--boomi-header-fg-color","--boomi-header-fg-hover","--boomi-header-border-color","--boomi-header-shadow","--boomi-input-bg","--boomi-input-fg","--boomi-input-placeholder","--boomi-input-border","--boomi-input-shadow","--boomi-input-border-focus","--boomi-input-shadow-focus","--boomi-input-outline-focus","--boomi-input-bg-disabled","--boomi-input-fg-disabled","--boomi-input-border-disabled","--boomi-input-border-invalid","--boomi-input-outline-invalid","--boomi-table-header-bg","--boomi-table-header-fg","--boomi-table-header-border","--boomi-table-row-odd-bg","--boomi-table-row-even-bg","--boomi-table-row-hover-shadow","--boomi-menu-bg","--boomi-menu-fg","--boomi-menu-border","--boomi-menu-shadow","--boomi-menu-item-bg","--boomi-menu-item-bg-hover","--boomi-menu-item-fg","--boomi-menu-item-fg-hover","--boomi-menu-divider","--boomi-menu-danger-fg","--boomi-menu-danger-fg-hover","--boomi-menu-danger-bg-hover","--boomi-modal-overlay-bg","--boomi-modal-bg","--boomi-modal-fg","--boomi-modal-border","--boomi-modal-shadow","--boomi-modal-close-fg","--boomi-modal-close-hover-fg","--boomi-form-label-fg","--boomi-form-helper-fg","--boomi-form-error-fg","--boomi-form-required-fg","--boomi-select-bg","--boomi-select-fg","--boomi-select-border","--boomi-select-shadow","--boomi-select-border-focus","--boomi-select-shadow-focus","--boomi-select-icon","--boomi-options-bg","--boomi-options-fg","--boomi-options-border","--boomi-options-shadow","--boomi-options-search-bg","--boomi-option-bg-active","--boomi-option-fg-selected","--boomi-loader-dot-bg","--boomi-loader-dot-size","--boomi-loader-dot1-opacity","--boomi-loader-dot2-opacity","--boomi-loader-dot3-opacity","--boomi-loader-msg-fg","--boomi-spinner-overlay-bg","--boomi-spinner-ring-color","--boomi-spinner-ping-color","--boomi-spinner-message-fg","--boomi-spinner-size","--boomi-spinner-border-width","--boomi-wizard-step-dot-bg","--boomi-wizard-step-dot-fg","--boomi-wizard-step-dot-border","--boomi-wizard-step-dot-shadow","--boomi-wizard-step-dot-bg-active","--boomi-wizard-step-dot-fg-active","--boomi-wizard-step-dot-border-active","--boomi-wizard-step-dot-shadow-active","--boomi-wizard-step-dot-bg-completed","--boomi-wizard-step-dot-fg-completed","--boomi-wizard-step-dot-border-completed","--boomi-wizard-step-dot-shadow-completed","--boomi-wizard-connector-bg","--boomi-wizard-label-fg","--boomi-wizard-card-bg","--boomi-wizard-card-fg","--boomi-wizard-card-border","--boomi-wizard-card-shadow","--boomi-wizard-link-fg","--boomi-wizard-link-fg-hover","--boomi-wizard-link-strong-fg","--boomi-notice-warning-bg","--boomi-notice-warning-fg","--boomi-notice-warning-border","--boomi-notice-success-bg","--boomi-notice-success-fg","--boomi-notice-success-border","--boomi-notice-error-bg","--boomi-notice-error-fg","--boomi-notice-error-border","--boomi-notice-shadow","--boomi-notice-radius","--boomi-update-bg","--boomi-update-fg","--boomi-update-border","--boomi-update-shadow","--boomi-update-title-fg","--boomi-update-desc-fg","--boomi-update-radius","--boomi-update-content","--boomi-tablist-border","--boomi-tab-bg","--boomi-tab-fg","--boomi-tab-border","--boomi-tab-bg-hover","--boomi-tab-bg-active","--boomi-tab-fg-active","--boomi-tab-border-active","--boomi-map-line","--boomi-map-line-width","--boomi-map-line-filter","--boomi-map-heading-fg","--boomi-map-card-bg","--boomi-map-card-border","--boomi-map-card-shadow","--boomi-map-card-shadow-hover","--boomi-map-card-transform-hover","--boomi-map-source-bg-mapped","--boomi-map-source-border-mapped","--boomi-map-source-outline","--boomi-map-target-bg-mapped","--boomi-map-target-border-mapped","--boomi-map-target-outline","--boomi-map-func-bg","--boomi-map-func-fg","--boomi-map-func-title-fg","--boomi-map-pin-source-bg","--boomi-map-pin-target-bg","--boomi-map-pin-input-bg","--boomi-map-pin-output-bg","--boomi-map-pin-badge-bg","--boomi-map-pin-badge-fg","--boomi-map-pin-danger-bg","--boomi-map-pulse-color","--boomi-map-pin-pulse","--boomi-map-add-bg","--boomi-map-add-fg","--boomi-map-add-border","--boomi-map-add-shadow","--boomi-map-add-bg-hover","--boomi-sched-card-bg","--boomi-sched-card-fg","--boomi-sched-card-border","--boomi-sched-card-shadow","--boomi-sched-card-shadow-hover","--boomi-sched-card-radius","--boomi-sched-header-bg","--boomi-sched-header-fg","--boomi-sched-header-border","--boomi-sched-header-shadow","--boomi-sched-toggle-fg","--boomi-sched-toggle-fg-hover","--boomi-sched-row-bg","--boomi-sched-row-border","--boomi-sched-row-shadow","--boomi-sched-row-hover-shadow","--boomi-sched-label-fg","--boomi-sched-helper-fg","--boomi-sched-error-fg","--boomi-sched-select-bg","--boomi-sched-select-fg","--boomi-sched-select-border","--boomi-sched-select-shadow","--boomi-sched-select-border-focus","--boomi-sched-select-shadow-focus","--boomi-sched-input-bg","--boomi-sched-input-fg","--boomi-sched-input-border","--boomi-sched-input-shadow","--boomi-sched-input-border-focus","--boomi-sched-input-shadow-focus","--boomi-sched-checkbox-border","--boomi-sched-checkbox-bg","--boomi-sched-checkbox-bg-checked","--boomi-sched-checkbox-symbol","--boomi-sched-action-bg","--boomi-sched-action-fg","--boomi-sched-action-border","--boomi-sched-action-shadow","--boomi-sched-action-bg-hover","--boomi-conn-bg","--boomi-conn-border","--boomi-conn-card-shadow","--boomi-conn-heading-fg","--boomi-conn-field-bg","--boomi-conn-field-border","--boomi-conn-field-label-fg","--boomi-conn-field-error-fg","--boomi-conn-btn-save-bg","--boomi-conn-btn-save-fg","--boomi-conn-btn-auth-bg","--boomi-conn-btn-auth-fg","--boomi-conn-btn-disabled-bg","--boomi-conn-btn-disabled-fg","--boomi-swal-bg","--boomi-swal-fg","--boomi-swal-border","--boomi-swal-shadow","--boomi-swal-title-fg","--boomi-swal-desc-fg","--boomi-swal-icon-success","--boomi-swal-icon-warning","--boomi-swal-icon-error","--boomi-swal-overlay-bg"],_H=()=>({themeSelection:"boomi",themeDefault:"boomi",themeCustomName:"",themeCustomVars:[],launcherCorner:"bottom-right",launcherOffsetX:"20",launcherOffsetY:"40",launcherShape:"pill",launcherLabel:"Find an Agent",launcherIcon:"🤖",launcherHideIcon:!1,listModalWidth:"500",listModalHeight:"600",listModalCorner:"bottom-right",listModalOffsetX:"20",listModalOffsetY:"100",listWelcomeTitle:"Agents",listWelcomeSubtitle:"Search for an agent and click to launch.",listHeaderShow:!0,listHeaderTitle:"Agents",listHeaderDescription:"Select an agent to launch.",listSearchShow:!0,tilesHeaderShow:!0,tilesHeaderTitle:"Agents",tilesHeaderDescription:"Browse and launch an agent.",tilesSearchShow:!0,tilesViewToggleShow:!0,agentUiMode:"modal",agentModalWidth:"600",agentModalHeight:"800",agentModalCorner:"top-right",agentModalOffsetX:"20",agentModalOffsetY:"40",agentSidebarShow:!0,agentSidebarWidth:"280",agentWelcomeTitle:"Let's Talk",agentWelcomeSubtitle:"Ask me about your Boomi deployment.",agentOverrides:{}}),ro=t=>{const e=t.trim();if(!e)return;const n=Number(e);return Number.isNaN(n)?e:n},CH=(t,e,n,o)=>{var r,s,c,a,u,l,d,f,h,m,p,g,b,v,E,T,y,x,_,N,C,L,D,k,I,S,A,R;const i={...e};if(i.themeCustomVars=[],!t.trim())return i;try{const $=JSON.parse(t);if($!=null&&$.theme&&typeof $.theme.defaultTheme=="string"){const K=$.theme.defaultTheme;K==="boomi"||K==="base"?(i.themeSelection=K,i.themeDefault=K,i.themeCustomName=""):(i.themeSelection="custom",i.themeDefault=K,i.themeCustomName=K);const q=$==null?void 0:$.cssVarsByTheme;let X=q==null?void 0:q[K],J=K;if((!X||typeof X!="object")&&q&&typeof q=="object"){const se=Object.keys(q)[0];se&&(X=q[se],J=se,J!=="boomi"&&J!=="base"&&(i.themeSelection="custom",i.themeCustomName=J,i.themeDefault=J))}X&&typeof X=="object"&&(i.themeCustomVars=Object.entries(X).map(([se,Y])=>({id:`var_${se}`,varName:se,value:typeof Y=="string"?Y:String(Y)})))}const P=(r=$==null?void 0:$.components)==null?void 0:r.agentList,U=(s=$==null?void 0:$.components)==null?void 0:s.agentTiles;if(n==="list"&&P){const K=P.launcher??{},q=K.position??{};_r.includes(q.corner)&&(i.launcherCorner=q.corner),q.offsetX!==void 0&&(i.launcherOffsetX=String(q.offsetX)),q.offsetY!==void 0&&(i.launcherOffsetY=String(q.offsetY)),(K.shape==="pill"||K.shape==="circle")&&(i.launcherShape=K.shape),typeof K.label=="string"&&(i.launcherLabel=K.label),typeof K.icon=="string"&&(i.launcherIcon=K.icon),typeof K.hideIcon=="boolean"&&(i.launcherHideIcon=K.hideIcon);const X=P.modal??{};X.width!==void 0&&(i.listModalWidth=String(X.width)),X.height!==void 0&&(i.listModalHeight=String(X.height));const J=X.position??{};_r.includes(J.corner)&&(i.listModalCorner=J.corner),J.offsetX!==void 0&&(i.listModalOffsetX=String(J.offsetX)),J.offsetY!==void 0&&(i.listModalOffsetY=String(J.offsetY)),(c=P.welcome)!=null&&c.title&&(i.listWelcomeTitle=P.welcome.title),(a=P.welcome)!=null&&a.subtitle&&(i.listWelcomeSubtitle=P.welcome.subtitle),((u=P.header)==null?void 0:u.show)!==void 0&&(i.listHeaderShow=!!P.header.show),(l=P.header)!=null&&l.title&&(i.listHeaderTitle=P.header.title),(d=P.header)!=null&&d.description&&(i.listHeaderDescription=P.header.description),((f=P.search)==null?void 0:f.show)!==void 0&&(i.listSearchShow=!!P.search.show)}n==="tiles"&&U&&(((h=U.header)==null?void 0:h.show)!==void 0&&(i.tilesHeaderShow=!!U.header.show),(m=U.header)!=null&&m.title&&(i.tilesHeaderTitle=U.header.title),(p=U.header)!=null&&p.description&&(i.tilesHeaderDescription=U.header.description),((g=U.search)==null?void 0:g.show)!==void 0&&(i.tilesSearchShow=!!U.search.show),((b=U.viewToggle)==null?void 0:b.show)!==void 0&&(i.tilesViewToggleShow=!!U.viewToggle.show));const F=($==null?void 0:$.agents)??{},B=o.find(K=>F[K])??Object.keys(F)[0],G=B?F[B]:null;G!=null&&G.position&&typeof G.position=="object"&&"corner"in G.position&&(_r.includes(G.position.corner)&&(i.launcherCorner=G.position.corner),G.position.offsetX!==void 0&&(i.launcherOffsetX=String(G.position.offsetX)),G.position.offsetY!==void 0&&(i.launcherOffsetY=String(G.position.offsetY))),((G==null?void 0:G.shape)==="pill"||(G==null?void 0:G.shape)==="circle")&&(i.launcherShape=G.shape),typeof(G==null?void 0:G.label)=="string"&&(i.launcherLabel=G.label),typeof(G==null?void 0:G.icon)=="string"&&(i.launcherIcon=G.icon),typeof(G==null?void 0:G.hideIcon)=="boolean"&&(i.launcherHideIcon=G.hideIcon);const z=(G==null?void 0:G.ui)??{};(z.mode==="modal"||z.mode==="full")&&(i.agentUiMode=z.mode),((v=z.modal)==null?void 0:v.width)!==void 0&&(i.agentModalWidth=String(z.modal.width)),((E=z.modal)==null?void 0:E.height)!==void 0&&(i.agentModalHeight=String(z.modal.height)),(y=(T=z.modal)==null?void 0:T.position)!=null&&y.corner&&_r.includes(z.modal.position.corner)&&(i.agentModalCorner=z.modal.position.corner),((_=(x=z.modal)==null?void 0:x.position)==null?void 0:_.offsetX)!==void 0&&(i.agentModalOffsetX=String(z.modal.position.offsetX)),((C=(N=z.modal)==null?void 0:N.position)==null?void 0:C.offsetY)!==void 0&&(i.agentModalOffsetY=String(z.modal.position.offsetY));const Q=z.sessionScope==="mount"?!1:z.sessionScope==="multi"?!0:void 0,V=(((L=z.sidebar)==null?void 0:L.show)!==void 0?!!z.sidebar.show:void 0)??Q;if(V!==void 0&&(i.agentSidebarShow=V),((D=z.sidebar)==null?void 0:D.width)!==void 0&&(i.agentSidebarWidth=String(z.sidebar.width)),(k=z.welcome)!=null&&k.title&&(i.agentWelcomeTitle=z.welcome.title),(I=z.welcome)!=null&&I.subtitle&&(i.agentWelcomeSubtitle=z.welcome.subtitle),n==="list"||n==="tiles"){const K={};for(const q of o){const X=F[q];X&&(K[q]={label:typeof X.label=="string"?X.label:"",description:typeof((S=X.ui)==null?void 0:S.pageDescription)=="string"?X.ui.pageDescription:typeof((R=(A=X.ui)==null?void 0:A.welcome)==null?void 0:R.subtitle)=="string"?X.ui.welcome.subtitle:"",icon:typeof X.icon=="string"?X.icon:"🤖",hideIcon:typeof X.hideIcon=="boolean"?X.hideIcon:!1,buttonLabel:typeof X.buttonLabel=="string"?X.buttonLabel:"Launch"})}i.agentOverrides=K}}catch{return i}return i},ST=(t,e,n)=>{const o=t.themeSelection==="custom"?t.themeCustomName.trim()||t.themeDefault||"custom":t.themeSelection,i={transport:"boomi-direct",theme:{allowThemes:!0,defaultTheme:o}},r={};for(const c of t.themeCustomVars)c.varName&&c.value&&(r[c.varName]=c.value);Object.keys(r).length&&(i.cssVarsByTheme={[o]:r}),e==="list"&&(i.components={agentList:{launcher:{position:{corner:t.launcherCorner,offsetX:ro(t.launcherOffsetX),offsetY:ro(t.launcherOffsetY)},shape:t.launcherShape,label:t.launcherLabel,icon:t.launcherIcon,hideIcon:t.launcherHideIcon},modal:{width:ro(t.listModalWidth),height:ro(t.listModalHeight),position:{corner:t.listModalCorner,offsetX:ro(t.listModalOffsetX),offsetY:ro(t.listModalOffsetY)}},welcome:{title:t.listWelcomeTitle,subtitle:t.listWelcomeSubtitle},header:{show:t.listHeaderShow,title:t.listHeaderTitle,description:t.listHeaderDescription},search:{show:t.listSearchShow}}}),e==="tiles"&&(i.components={agentTiles:{header:{show:t.tilesHeaderShow,title:t.tilesHeaderTitle,description:t.tilesHeaderDescription},search:{show:t.tilesSearchShow},viewToggle:{show:t.tilesViewToggleShow}}});const s=n.length?n:["agent-id"];return i.agents=s.reduce((c,a)=>{const u=e==="list"||e==="tiles"?t.agentOverrides[a]??Lf():void 0,l={transport:"boomi-direct"};return e==="single"?(l.position={corner:t.launcherCorner,offsetX:ro(t.launcherOffsetX),offsetY:ro(t.launcherOffsetY)},l.shape=t.launcherShape,l.label=t.launcherLabel,l.icon=t.launcherIcon,l.hideIcon=t.launcherHideIcon):u&&(u.label&&(l.label=u.label),l.icon=u.icon,l.hideIcon=u.hideIcon,u.buttonLabel&&u.buttonLabel!=="Launch"&&(l.buttonLabel=u.buttonLabel)),l.ui={mode:t.agentUiMode,sessionScope:t.agentSidebarShow?"multi":"mount",modal:{width:ro(t.agentModalWidth),height:ro(t.agentModalHeight),position:{corner:t.agentModalCorner,offsetX:ro(t.agentModalOffsetX),offsetY:ro(t.agentModalOffsetY)}},sidebar:{show:t.agentSidebarShow,width:ro(t.agentSidebarWidth)},welcome:{title:t.agentWelcomeTitle,subtitle:t.agentWelcomeSubtitle},...u!=null&&u.description?{pageDescription:u.description}:{}},c[a]=l,c},{}),i.project={embedType:e,agentIds:s},i},rL=O.forwardRef(({embedType:t,agentIds:e,configRaw:n,onChangeConfig:o,onUpdateBuilder:i,syncFromConfig:r=!1,availableAgents:s},c)=>{const a=O.useMemo(_H,[]),[u,l]=O.useState(a),d=O.useRef(!1);O.useImperativeHandle(c,()=>({getConfig:()=>ST(u,t,e)}),[u,t,e]),O.useEffect(()=>{(r||!d.current)&&(l(CH(n,a,t,e)),d.current=!0)},[n,a,t,e,r]),O.useEffect(()=>{i==null||i(u)},[u,i]),O.useEffect(()=>{const p=ST(u,t,e);o(p)},[u,t,e,o]);const f=()=>{const p=AT[0]??"--boomi-root-bg-color";l(g=>({...g,themeCustomVars:[...g.themeCustomVars,{id:`var_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,varName:p,value:""}]}))},h=(p,g)=>{l(b=>({...b,themeCustomVars:b.themeCustomVars.map(v=>v.id===p?{...v,...g}:v)}))},m=p=>{l(g=>({...g,themeCustomVars:g.themeCustomVars.filter(b=>b.id!==p)}))};return w.jsxs("div",{className:"boomi-card p-4 space-y-4",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-sm font-semibold",children:"Config Builder"}),w.jsx("div",{className:"text-xs opacity-70",children:"Updates the JSON configuration automatically as you make changes."})]}),w.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[w.jsxs("div",{className:"space-y-3",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Agent UI"}),w.jsxs("label",{className:"boomi-form-label",children:["Mode",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.agentUiMode,onChange:p=>l(g=>({...g,agentUiMode:p.target.value})),children:[w.jsx("option",{value:"modal",children:"Modal"}),w.jsx("option",{value:"full",children:"Full Page"})]})]}),u.agentUiMode==="modal"&&w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Modal width",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.agentModalWidth,onChange:p=>l(g=>({...g,agentModalWidth:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Modal height",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.agentModalHeight,onChange:p=>l(g=>({...g,agentModalHeight:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Modal corner",w.jsx("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.agentModalCorner,onChange:p=>l(g=>({...g,agentModalCorner:p.target.value})),children:_r.map(p=>w.jsx("option",{value:p,children:p},p))})]}),w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Offset X",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.agentModalOffsetX,onChange:p=>l(g=>({...g,agentModalOffsetX:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Offset Y",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.agentModalOffsetY,onChange:p=>l(g=>({...g,agentModalOffsetY:p.target.value}))})]})]})]}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:u.agentSidebarShow,onChange:p=>l(g=>({...g,agentSidebarShow:p.target.checked}))}),"Show sidebar"]}),w.jsxs("label",{className:"boomi-form-label",children:["Sidebar width",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.agentSidebarWidth,onChange:p=>l(g=>({...g,agentSidebarWidth:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Welcome title",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.agentWelcomeTitle,onChange:p=>l(g=>({...g,agentWelcomeTitle:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Welcome subtitle",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.agentWelcomeSubtitle,onChange:p=>l(g=>({...g,agentWelcomeSubtitle:p.target.value}))})]})]}),w.jsxs("div",{className:"space-y-3",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Theme"}),w.jsxs("label",{className:"boomi-form-label",children:["Theme",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.themeSelection,onChange:p=>l(g=>({...g,themeSelection:p.target.value,themeDefault:p.target.value==="custom"?g.themeDefault:p.target.value})),children:[w.jsx("option",{value:"boomi",children:"boomi"}),w.jsx("option",{value:"base",children:"base"}),w.jsx("option",{value:"custom",children:"custom"})]})]}),u.themeSelection==="custom"&&w.jsxs(w.Fragment,{children:[w.jsxs("label",{className:"boomi-form-label",children:["Custom theme name",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.themeCustomName,onChange:p=>l(g=>({...g,themeCustomName:p.target.value,themeDefault:p.target.value})),placeholder:"my-theme"})]}),w.jsxs("div",{className:"space-y-2",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"CSS Variable Overrides"}),u.themeCustomVars.length===0&&w.jsx("div",{className:"text-xs opacity-70",children:"No custom variables yet."}),w.jsx("div",{className:"space-y-2",children:u.themeCustomVars.map(p=>w.jsxs("div",{className:"flex items-center gap-2 flex-nowrap w-full overflow-x-auto",children:[w.jsx("select",{className:"boomi-input flex-1 min-w-0 rounded-md p-2 text-sm",value:p.varName,onChange:g=>h(p.id,{varName:g.target.value}),children:AT.map(g=>w.jsx("option",{value:g,children:g},g))}),w.jsx("input",{type:"text",value:p.value,onChange:g=>h(p.id,{value:g.target.value}),className:"boomi-input flex-1 min-w-0 rounded-md p-2 text-sm",placeholder:"#000000 or rgba(...) or value"}),SH(p.value)&&w.jsx("input",{type:"color",value:p.value,onChange:g=>h(p.id,{value:g.target.value}),className:"h-9 w-12 shrink-0 cursor-pointer rounded-md border border-[var(--boomi-card-border)] bg-transparent"}),w.jsx("button",{type:"button",className:"text-xs text-red-500 whitespace-nowrap shrink-0",onClick:()=>m(p.id),children:"Remove"})]},p.id))}),w.jsx("div",{children:w.jsx("button",{type:"button",className:"boomi-btn-primary px-3 py-2 text-xs",onClick:f,children:"Add CSS Variable"})})]})]})]})]}),(t==="list"||t==="single")&&w.jsxs("div",{className:t==="list"?"grid gap-4 md:grid-cols-2":"space-y-3",children:[w.jsxs("div",{className:"space-y-3",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Launcher (Pill)"}),w.jsxs("label",{className:"boomi-form-label",children:["Corner",w.jsx("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.launcherCorner,onChange:p=>l(g=>({...g,launcherCorner:p.target.value})),children:_r.map(p=>w.jsx("option",{value:p,children:p},p))})]}),w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Offset X",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.launcherOffsetX,onChange:p=>l(g=>({...g,launcherOffsetX:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Offset Y",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.launcherOffsetY,onChange:p=>l(g=>({...g,launcherOffsetY:p.target.value}))})]})]}),w.jsxs("label",{className:"boomi-form-label",children:["Shape",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.launcherShape,onChange:p=>l(g=>({...g,launcherShape:p.target.value})),children:[w.jsx("option",{value:"pill",children:"Pill"}),w.jsx("option",{value:"circle",children:"Circle"})]})]}),w.jsxs("label",{className:"boomi-form-label",children:["Label",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.launcherLabel,onChange:p=>l(g=>({...g,launcherLabel:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Icon",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:rs.some(p=>p.value===u.launcherIcon)?u.launcherIcon:"__custom__",onChange:p=>l(g=>({...g,launcherIcon:p.target.value==="__custom__"?g.launcherIcon:p.target.value})),children:[!rs.some(p=>p.value===u.launcherIcon)&&w.jsxs("option",{value:"__custom__",children:[u.launcherIcon," (custom)"]}),rs.map(p=>w.jsx("option",{value:p.value,children:p.label},p.value))]})]}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:u.launcherHideIcon,onChange:p=>l(g=>({...g,launcherHideIcon:p.target.checked}))}),"Hide icon"]})]}),t==="list"&&w.jsxs("div",{className:"space-y-3",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"List Modal"}),w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Width",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.listModalWidth,onChange:p=>l(g=>({...g,listModalWidth:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Height",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.listModalHeight,onChange:p=>l(g=>({...g,listModalHeight:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Corner",w.jsx("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.listModalCorner,onChange:p=>l(g=>({...g,listModalCorner:p.target.value})),children:_r.map(p=>w.jsx("option",{value:p,children:p},p))})]}),w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Offset X",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.listModalOffsetX,onChange:p=>l(g=>({...g,listModalOffsetX:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Offset Y",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.listModalOffsetY,onChange:p=>l(g=>({...g,listModalOffsetY:p.target.value}))})]})]})]}),w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70 pt-2",children:"List Header & Search"}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:u.listHeaderShow,onChange:p=>l(g=>({...g,listHeaderShow:p.target.checked}))}),"Show header"]}),w.jsxs("label",{className:"boomi-form-label",children:["Header title",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.listHeaderTitle,onChange:p=>l(g=>({...g,listHeaderTitle:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Header description",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.listHeaderDescription,onChange:p=>l(g=>({...g,listHeaderDescription:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:u.listSearchShow,onChange:p=>l(g=>({...g,listSearchShow:p.target.checked}))}),"Show search"]}),w.jsxs("label",{className:"boomi-form-label",children:["Welcome title",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.listWelcomeTitle,onChange:p=>l(g=>({...g,listWelcomeTitle:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Welcome subtitle",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.listWelcomeSubtitle,onChange:p=>l(g=>({...g,listWelcomeSubtitle:p.target.value}))})]})]})]}),t==="tiles"&&w.jsxs("div",{className:"space-y-3",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Tiles Header & Search"}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:u.tilesHeaderShow,onChange:p=>l(g=>({...g,tilesHeaderShow:p.target.checked}))}),"Show header"]}),w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Header title",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.tilesHeaderTitle,onChange:p=>l(g=>({...g,tilesHeaderTitle:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Header description",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.tilesHeaderDescription,onChange:p=>l(g=>({...g,tilesHeaderDescription:p.target.value}))})]})]}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:u.tilesSearchShow,onChange:p=>l(g=>({...g,tilesSearchShow:p.target.checked}))}),"Show search"]}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:u.tilesViewToggleShow,onChange:p=>l(g=>({...g,tilesViewToggleShow:p.target.checked}))}),"Show tiles/table toggle"]})]}),(t==="list"||t==="tiles")&&e.length>0&&w.jsxs("div",{className:"space-y-3",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Agent Cards"}),w.jsxs("div",{className:"text-xs opacity-70",children:["Configure how each agent appears in the ",t," view."]}),w.jsx("div",{className:"space-y-3",children:e.map(p=>{var v;const g=u.agentOverrides[p]??Lf(),b=E=>l(T=>({...T,agentOverrides:{...T.agentOverrides,[p]:{...T.agentOverrides[p]??Lf(),...E}}}));return w.jsxs("div",{className:"boomi-card p-3 space-y-3",children:[w.jsxs("div",{className:"space-y-0.5",children:[w.jsx("div",{className:"text-sm font-semibold",children:((v=s==null?void 0:s.find(E=>E.id===p))==null?void 0:v.label)??p}),w.jsx("div",{className:"text-xs font-mono opacity-50",children:p})]}),w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Card title",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:g.label,placeholder:"Agent name",onChange:E=>b({label:E.target.value})})]}),w.jsxs("label",{className:"boomi-form-label",children:["Card description",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:g.description,placeholder:"Brief description",onChange:E=>b({description:E.target.value})})]}),w.jsxs("label",{className:"boomi-form-label",children:["Icon",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:rs.some(E=>E.value===g.icon)?g.icon:"__custom__",onChange:E=>b({icon:E.target.value==="__custom__"?g.icon:E.target.value}),children:[!rs.some(E=>E.value===g.icon)&&w.jsxs("option",{value:"__custom__",children:[g.icon," (custom)"]}),rs.map(E=>w.jsx("option",{value:E.value,children:E.label},E.value))]})]}),w.jsxs("label",{className:"boomi-form-label",children:["Button label",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:g.buttonLabel,placeholder:"Launch",onChange:E=>b({buttonLabel:E.target.value})})]})]}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:g.hideIcon,onChange:E=>b({hideIcon:E.target.checked})}),"Hide icon"]})]},p)})})]})]})});function NH(t){try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}const LH=({isOpen:t,onClose:e,onSubmit:n,isSaving:o,defaultOrigins:i,availableAgents:r})=>{const[s,c]=O.useState(""),[a,u]=O.useState(null),[l,d]=O.useState(!1),[f,h]=O.useState([]),[m,p]=O.useState(""),g=O.useRef(null),b=O.useRef(null),v=O.useCallback(K=>{g.current=K,p(q=>{const X=JSON.stringify(K,null,2);return X!==q?X:q})},[]),[E,T]=O.useState("single"),[y,x]=O.useState(""),[_,N]=O.useState([]),[C,L]=O.useState(null),[D,k]=O.useState(null),[I,S]=O.useState(null),[A,R]=O.useState("builder"),$=(K,q)=>(K.length>0?K:["agent-id"]).reduce((J,se)=>(J[se]={transport:"boomi-direct",ui:{mode:q,modal:{width:500,height:600,position:{corner:"bottom-right",offsetX:20,offsetY:100}},sidebar:{show:q==="full",width:280},welcome:{title:"Let's Talk",subtitle:"Ask me about your Boomi deployment."}}},J),{}),F=JSON.stringify(((K,q)=>{const X={transport:"boomi-direct",theme:{allowThemes:!0,defaultTheme:"boomi"},cssVarsByTheme:{oem:{"--boomi-root-bg-color":"#0b1220","--boomi-root-fg-color":"#e5e7eb","--boomi-page-bg-color":"#0b1220","--boomi-page-fg-color":"#e5e7eb","--boomi-header-bg-color":"rgba(15, 23, 42, 0.8)","--boomi-header-fg-color":"#e5e7eb","--boomi-btn-primary-bg":"#2563eb","--boomi-btn-primary-fg":"#ffffff","--boomi-card-bg":"#0f172a","--boomi-card-border":"#1f2937","--boomi-menu-bg":"#0f172a","--boomi-menu-fg":"#e5e7eb","--boomi-modal-bg":"#0f172a","--boomi-modal-fg":"#e5e7eb","--boomi-input-bg":"#0b1220","--boomi-input-fg":"#e5e7eb"}}};K==="list"&&(X.components={agentList:{launcher:{position:{corner:"bottom-right",offsetX:20,offsetY:40},shape:"pill",label:"Find an Agent",icon:"bot",hideIcon:!1},modal:{width:500,height:600,position:{corner:"bottom-right",offsetX:20,offsetY:100}},welcome:{title:"Agents",subtitle:"Search for an agent and click to launch."}}});const J=q.length>0?q:["agent-id"];return X.agents=$(J,K==="single"?"modal":"full"),X})(E,E==="single"?y?[y]:[]:_),null,2);O.useEffect(()=>{t&&(c(""),u(null),d(!1),h([]),p(""),T("single"),x(""),N([]),L(null),k(null),S(null),R("builder"))},[t]),O.useEffect(()=>{!t||!(r!=null&&r.length)||(x(K=>K||r[0].id),N(K=>K.length?K:[r[0].id]))},[t,r]),O.useEffect(()=>{E==="single"?!y&&_[0]&&x(_[0]):_.length===0&&y&&N([y])},[E,_,y]);const B=K=>{N(q=>q.includes(K)?q.filter(X=>X!==K):[...q,K])},G=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`project_${crypto.randomUUID()}`:`project_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`,z=async()=>{var he;if(!s.trim()){d(!0),u("Project name is required.");return}u(null);const K=E==="single"?y?[y]:[]:_;if(!K.length){L("Select at least one agent");return}L(null);let q;if(A==="builder")q=((he=b.current)==null?void 0:he.getConfig())??void 0;else{const ie=m.trim();if(ie)try{q=JSON.parse(ie)}catch{S("Config must be valid JSON");return}}S(null);const X=q&&typeof q=="object"?{...q}:{},J=X.project&&typeof X.project=="object"?{...X.project}:{};X.project={...J,embedType:E,agentIds:K};const se=Array.from(new Set(f.map(ie=>ie.trim()).filter(Boolean)));if(!se.length){k("At least one allowed origin is required.");return}for(const ie of se)if(!NH(ie)){k(`Invalid origin (must be http/https): ${ie}`);return}k(null);const Y=G();if(E==="single"&&y){const ie={...X.agents??{}};ie[y]&&!ie[Y]&&(ie[Y]=ie[y],X.agents=ie)}console.log("[AddAgentModal] submitting configBase:",JSON.stringify(X,null,2)),await n({agentId:Y,boomiAgentId:E==="single"?y:void 0,label:s.trim()||void 0,allowedOrigins:se,config:X})},Q=()=>{h(K=>[...K,""])},W=(K,q)=>{h(X=>X.map((J,se)=>se===K?q:J))},V=K=>{h(q=>q.filter((X,J)=>J!==K))};return w.jsxs(no,{isOpen:t,title:"Add Project",description:"Create a new embedded agent group and its allowed embed origins.",onClose:e,onSubmit:z,submitLabel:o?"Saving...":"Create Project",showSaveButton:!o,children:[w.jsxs("div",{className:"boomi-card p-4 space-y-2",children:[w.jsx("div",{className:"text-sm font-semibold",children:"Project Summary"}),w.jsxs("div",{className:"text-xs opacity-80",children:["Embed type: ",w.jsx("strong",{children:E==="single"?"Single Agent":E==="tiles"?"Multi-Agent (Tiles)":"Multi-Agent (List)"})]}),w.jsxs("div",{className:"text-xs opacity-80",children:["Selected agents: ",w.jsx("strong",{children:E==="single"?y?1:0:_.length})]}),w.jsx("div",{className:"text-xs opacity-70",children:"You can start with the form below and optionally layer in advanced JSON config."})]}),w.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[w.jsxs("div",{className:"space-y-4",children:[w.jsx(bn,{formName:"agentAdd",label:"Project Name",required:!0,inputName:"name",readOnly:!1,value:s,onChange:K=>{c(K.target.value),a&&u(null)},onBlur:()=>{d(!0),s.trim()||u("Project name is required.")},placeholder:"Customer Support Project"}),l&&a&&w.jsx("div",{className:"boomi-form-error",children:a}),w.jsxs("label",{className:"boomi-form-label",children:["Embed Type",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:E,onChange:K=>T(K.target.value),children:[w.jsx("option",{value:"single",children:"Single Agent"}),w.jsx("option",{value:"tiles",children:"Multi-Agent (Tiles)"}),w.jsx("option",{value:"list",children:"Multi-Agent (Pill + Modal List)"})]})]}),E==="single"?w.jsxs("label",{className:"boomi-form-label",children:["Agent",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:y,onChange:K=>x(K.target.value),children:[(r??[]).length===0&&w.jsx("option",{value:"",children:"No agents available"}),(r??[]).map(K=>w.jsx("option",{value:K.id,children:K.label},K.id))]}),C&&w.jsx("div",{className:"text-xs text-red-500 mt-1",children:C})]}):w.jsxs("div",{children:[w.jsx("label",{className:"boomi-form-label",children:"Agents"}),w.jsx("div",{className:"boomi-input w-full rounded-md p-2 text-sm space-y-2 max-h-48 overflow-auto",children:(r??[]).length===0?w.jsx("div",{className:"text-xs opacity-70",children:"No agents available"}):(r??[]).map(K=>w.jsxs("label",{className:"flex items-center gap-2",children:[w.jsx("input",{type:"checkbox",checked:_.includes(K.id),onChange:()=>B(K.id)}),w.jsx("span",{className:"text-xs",children:K.label})]},K.id))}),C&&w.jsx("div",{className:"text-xs text-red-500 mt-1",children:C})]})]}),w.jsx("div",{className:"space-y-4",children:w.jsxs("div",{className:"space-y-2",children:[w.jsx("label",{className:"boomi-form-label",children:"Allowed Origins"}),w.jsx("div",{className:"text-xs opacity-70",children:"Select origins from your CORS list. If you don’t see one you need, add it first in the CORS page."}),w.jsxs("div",{className:"space-y-2",children:[f.length===0&&w.jsx("div",{className:"text-xs opacity-70",children:"No origins selected."}),f.map((K,q)=>{const X=new Set(f.map(Y=>Y.trim()).filter(Boolean)),J=(i??[]).filter(Y=>Y===K||!X.has(Y)),se=J.includes(K);return w.jsxs("div",{className:"flex items-center gap-2",children:[w.jsxs("select",{className:"boomi-input w-full rounded-md p-2 text-sm",value:K,onChange:Y=>W(q,Y.target.value),children:[!K&&w.jsx("option",{value:"",children:"Select an origin"}),se?null:K?w.jsx("option",{value:K,children:K}):null,J.map(Y=>w.jsx("option",{value:Y,children:Y},Y))]}),w.jsx("span",{role:"button",tabIndex:0,className:"text-red-500 text-lg cursor-pointer",onClick:()=>V(q),onKeyDown:Y=>{(Y.key==="Enter"||Y.key===" ")&&V(q)},"aria-label":"Remove origin",children:w.jsx(uo,{})})]},`${K}-${q}`)})]}),w.jsx("div",{className:"flex",children:w.jsx(rt,{toggle:!1,primary:!1,showIcon:!1,label:"Add Allowed Origin",onClick:Q})}),D&&w.jsx("div",{className:"text-xs text-red-500",children:D}),w.jsx("div",{className:"text-xs opacity-70",children:"Add new origins from the CORS page before selecting them here."})]})})]}),w.jsxs("div",{className:"space-y-3",children:[w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-sm font-semibold",children:"UI Configuration"}),w.jsx("div",{className:"text-xs opacity-70",children:"Optional. Use JSON to customize themes, layout, and agent UI beyond the form inputs."})]}),w.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-[var(--boomi-card-bg)] p-1 border border-[var(--boomi-card-border)]",children:[w.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${A==="builder"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>R("builder"),children:"Builder"}),w.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${A==="json"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>R("json"),children:"JSON"})]})]}),A==="builder"?w.jsx(rL,{ref:b,embedType:E,agentIds:E==="single"?y?[y]:[]:_,configRaw:m,onChangeConfig:v,syncFromConfig:!1,availableAgents:r}):w.jsxs(w.Fragment,{children:[w.jsx(iL,{label:"Config (JSON)",value:m,placeholder:F,error:I,onChange:p}),w.jsx("div",{className:"flex justify-end",children:w.jsx(rt,{toggle:!1,primary:!1,showIcon:!1,label:"Insert Starter Config",onClick:()=>p(F)})})]})]})]})},kH=({isOpen:t,agentId:e,onClose:n,onConfirm:o,isDeleting:i})=>w.jsx(no,{isOpen:t,title:"Delete Agent",description:"Remove this agent and all associated public tokens.",onClose:n,onSubmit:o,submitLabel:i?"Deleting...":"Delete",showSaveButton:!i,children:w.jsxs("p",{className:"text-sm",children:["Are you sure you want to delete"," ",w.jsx("span",{className:"font-semibold",children:e}),"?"]})});function _T(t){if(t.trim().toLowerCase()==="null")return!0;try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}const IH=({isOpen:t,agentId:e,label:n,allowedOrigins:o,defaultOrigins:i,onAddOrigin:r,config:s,onClose:c,onSubmit:a,isSaving:u,availableAgents:l})=>{const[d,f]=O.useState(""),[h,m]=O.useState([]),[p,g]=O.useState(""),[b,v]=O.useState(!1),[E,T]=O.useState(""),[y,x]=O.useState(0),[_,N]=O.useState(null),[C,L]=O.useState(null),[D,k]=O.useState("builder"),I=(Q,W)=>(Q.length>0?Q:["agent-id"]).reduce((K,q)=>(K[q]={transport:"boomi-direct",ui:{mode:W,modal:{width:500,height:600,position:{corner:"bottom-right",offsetX:20,offsetY:100}},sidebar:{show:W==="full",width:280},welcome:{title:"Let's Talk",subtitle:"Ask me about your Boomi deployment."}}},K),{}),S=(Q,W)=>{const V={transport:"boomi-direct",theme:{allowThemes:!0,defaultTheme:"boomi"},cssVarsByTheme:{oem:{"--boomi-root-bg-color":"#0b1220","--boomi-root-fg-color":"#e5e7eb","--boomi-page-bg-color":"#0b1220","--boomi-page-fg-color":"#e5e7eb","--boomi-header-bg-color":"rgba(15, 23, 42, 0.8)","--boomi-header-fg-color":"#e5e7eb","--boomi-btn-primary-bg":"#2563eb","--boomi-btn-primary-fg":"#ffffff","--boomi-card-bg":"#0f172a","--boomi-card-border":"#1f2937","--boomi-menu-bg":"#0f172a","--boomi-menu-fg":"#e5e7eb","--boomi-modal-bg":"#0f172a","--boomi-modal-fg":"#e5e7eb","--boomi-input-bg":"#0b1220","--boomi-input-fg":"#e5e7eb"}}};Q==="list"&&(V.components={agentList:{launcher:{position:{corner:"bottom-right",offsetX:20,offsetY:40},shape:"pill",label:"Find an Agent",icon:"bot",hideIcon:!1},modal:{width:500,height:600,position:{corner:"bottom-right",offsetX:20,offsetY:100}},welcome:{title:"Agents",subtitle:"Search for an agent and click to launch."}}});const K=W.length>0?W:["agent-id"];return V.agents=I(K,Q==="single"?"modal":"full"),V},R=(()=>{try{const Q=E.trim()?JSON.parse(E):null,W=Q&&typeof Q=="object"?Q.project:null,V=typeof(W==null?void 0:W.embedType)=="string"?W.embedType:"single",K=Array.isArray(W==null?void 0:W.agentIds)?W.agentIds.filter(Boolean):[];return{embedType:V,agentIds:K}}catch{return{embedType:"single",agentIds:[]}}})(),$=R.agentIds.length>0?R.agentIds:e?[e]:[],P=JSON.stringify(S(R.embedType,$),null,2);O.useEffect(()=>{if(t){f(n??"");const Q=(o&&o.length?o:i)??[];m(Q),g(""),T(s?JSON.stringify(s,null,2):""),x(W=>W+1),N(null),L(null),k("builder")}},[t,n,s,o,i]);const U=async()=>{if(!e)return;let Q;const W=E.trim();if(W)try{Q=JSON.parse(W)}catch{L("Config must be valid JSON");return}L(null);const V=Array.from(new Set(h.map(K=>K.trim()).filter(Boolean)));if(!V.length){N("At least one allowed origin is required.");return}for(const K of V)if(!_T(K)){N(`Invalid origin (must be http/https): ${K}`);return}if(N(null),Q&&e){const K=Q.project,q=K==null?void 0:K.embedType,X=Array.isArray(K==null?void 0:K.agentIds)?K.agentIds[0]:null;if(q==="single"&&X){const J={...Q.agents??{}};J[X]&&!J[e]&&(J[e]=J[X],Q.agents=J)}}await a({agentId:e,label:d.trim()||void 0,allowedOrigins:V,config:Q})},F=()=>{const Q=i??[],W=new Set(h.map(K=>K.trim()).filter(Boolean)),V=Q.find(K=>!W.has(K))??"";m(K=>[...K,V])},B=(Q,W)=>{m(V=>V.map((K,q)=>q===Q?W:K))},G=Q=>{m(W=>W.filter((V,K)=>K!==Q))},z=async()=>{const Q=p.trim();if(!Q){N("Enter an origin before adding.");return}if(!_T(Q)){N(`Invalid origin (must be http/https): ${Q}`);return}if(N(null),!r){m(W=>W.includes(Q)?W:[...W,Q]),g("");return}v(!0);try{await r(Q),m(W=>W.includes(Q)?W:[...W,Q]),g("")}catch(W){N((W==null?void 0:W.message)||"Failed to add origin.")}finally{v(!1)}};return w.jsxs(no,{isOpen:t,title:"Edit Agent",description:"Update agent details and allowed origins.",onClose:c,onSubmit:U,submitLabel:u?"Saving...":"Save Changes",showSaveButton:!u,children:[w.jsxs("div",{className:"boomi-card p-4 space-y-2",children:[w.jsx("div",{className:"text-sm font-semibold",children:"Agent Overview"}),w.jsxs("div",{className:"text-xs opacity-80",children:["Agent ID: ",w.jsx("strong",{children:e??"—"})]}),w.jsx("div",{className:"text-xs opacity-70",children:"Update the friendly name, allowed origins, and optional config overrides below."})]}),w.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[w.jsxs("div",{className:"space-y-4",children:[w.jsx(bn,{formName:"agentEdit",label:"Name",required:!1,inputName:"name",readOnly:!1,value:d,onChange:Q=>f(Q.target.value),placeholder:"Customer Support Agent"}),w.jsx(bn,{formName:"agentEdit",label:"Agent ID",required:!0,inputName:"agentId",readOnly:!0,value:e??"",onChange:()=>{},helperText:"This is the Boomi Agent ID for your agent and cannot be changed."})]}),w.jsxs("div",{className:"space-y-2",children:[w.jsx("label",{className:"boomi-form-label",children:"Allowed Origins"}),w.jsxs("div",{className:"space-y-2",children:[h.length===0&&w.jsx("div",{className:"text-xs opacity-70",children:"No origins selected."}),h.map((Q,W)=>{const V=new Set(h.map(X=>X.trim()).filter(Boolean)),K=(i??[]).filter(X=>X===Q||!V.has(X)),q=K.includes(Q);return w.jsxs("div",{className:"flex items-center gap-2",children:[w.jsxs("select",{className:"boomi-input w-full rounded-md p-2 text-sm",value:Q,onChange:X=>B(W,X.target.value),children:[!Q&&w.jsx("option",{value:"",children:"Select an origin"}),q?null:Q?w.jsx("option",{value:Q,children:Q}):null,K.map(X=>w.jsx("option",{value:X,children:X},X))]}),w.jsx("span",{role:"button",tabIndex:0,className:"text-red-500 text-lg cursor-pointer",onClick:()=>G(W),onKeyDown:X=>{(X.key==="Enter"||X.key===" ")&&G(W)},"aria-label":"Remove origin",children:w.jsx(uo,{})})]},`${Q}-${W}`)})]}),_&&w.jsx("div",{className:"text-xs text-red-500",children:_}),w.jsxs("div",{className:"flex items-center gap-2",children:[w.jsx(rt,{toggle:!1,primary:!1,showIcon:!1,label:"Add Row",onClick:F}),w.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[w.jsx("input",{className:"boomi-input w-full rounded-md p-2 text-sm",value:p,onChange:Q=>g(Q.target.value),placeholder:"https://example.com"}),w.jsx("button",{type:"button",className:"boomi-btn-primary px-2 py-2 text-xs",onClick:z,disabled:b,"aria-label":"Add new origin",children:w.jsx(Hr,{})})]})]}),w.jsx("div",{className:"text-xs opacity-70",children:"Pick from existing CORS origins or add a new one here."})]})]}),w.jsxs("div",{className:"space-y-3",children:[w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-sm font-semibold",children:"UI Configuration"}),w.jsx("div",{className:"text-xs opacity-70",children:"Optional. Use JSON to customize themes, layout, and agent UI."})]}),w.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-[var(--boomi-card-bg)] p-1 border border-[var(--boomi-card-border)]",children:[w.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${D==="builder"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>k("builder"),children:"Builder"}),w.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${D==="json"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>k("json"),children:"JSON"})]})]}),D==="builder"?w.jsx(rL,{embedType:R.embedType,agentIds:$,configRaw:E,onChangeConfig:Q=>{const W=JSON.stringify(Q,null,2);W!==E&&T(W)},syncFromConfig:!1,availableAgents:l},y):w.jsxs(w.Fragment,{children:[w.jsx(iL,{label:"Config (JSON)",value:E,placeholder:P,error:C,onChange:T}),w.jsx("div",{className:"flex justify-end",children:w.jsx(rt,{toggle:!1,primary:!1,showIcon:!1,label:"Insert Starter Config",onClick:()=>T(P)})})]})]})]})},RH=({isOpen:t,agentId:e,tokenId:n,agents:o,primaryAccountId:i,onTokenGenerated:r,onClose:s})=>{const[c,a]=O.useState(!1),[u,l]=O.useState(!1),[d,f]=O.useState("single"),[h,m]=O.useState([]),[p,g]=O.useState(""),[b,v]=O.useState(!1),[E,T]=O.useState(null),[y,x]=O.useState(null),{createAgent:_}=oL(),N=O.useMemo(()=>(o??[]).map(A=>{var R;return{id:A.agentId,label:((R=A.label)==null?void 0:R.trim())||A.agentId,tokenIds:A.publicTokenIds??[]}}),[o]);O.useEffect(()=>{var A;if(!t)return;const S=e||((A=N[0])==null?void 0:A.id)||"";g(S),m(S?[S]:[]),T(null),x(null),e&&f("single")},[t,e,N]);const C=S=>{m(A=>A.includes(S)?A.filter(R=>R!==S):[...A,S])},L=async()=>{const S=n??y;if(!i||!S)return;const A=h.filter(R=>{var P;const $=N.find(U=>U.id===R);return!((P=$==null?void 0:$.tokenIds)!=null&&P.includes(S))});if(A.length===0){T("Token already attached to selected agents.");return}v(!0),T(null);try{await Promise.all(A.map(R=>_({primaryAccountId:i,agentId:R,publicTokenIds:[S]}))),T("Token attached to selected agents.")}catch(R){T((R==null?void 0:R.message)||"Failed to attach token to selected agents.")}finally{v(!1)}},D=async()=>{var A;if(!i)return;const S=d==="single"?p:h[0];if(!S){T("Select at least one agent first.");return}v(!0),T(null);try{const $=((A=(await _({primaryAccountId:i,agentId:S,createToken:!0})).createdToken)==null?void 0:A.tokenId)||null;if(!$)throw new Error("Token generation failed.");x($),r==null||r($);const P=d==="single"?[]:h.filter(U=>U!==S);P.length>0&&await Promise.all(P.map(U=>_({primaryAccountId:i,agentId:U,publicTokenIds:[$]}))),T("Token generated and attached to selected agents.")}catch(R){T((R==null?void 0:R.message)||"Failed to generate token.")}finally{v(!1)}},k=O.useMemo(()=>{const S=n??y;if(!S)return"";const A=p||e||"";return h.length,`<link rel="stylesheet" href="https://cdn.boomi.space/cdn/embedkit-cdn.css" />
|
|
2106
|
+
`),[c]);return w.jsxs("div",{children:[w.jsxs("label",{className:"boomi-form-label inline-flex items-center gap-2",children:[w.jsx("span",{children:t}),e]}),w.jsxs("div",{className:["flex w-full rounded-md border overflow-hidden","bg-[color-mix(in_srgb,var(--boomi-card-bg,#ffffff)_92%,#000000)]",r?"boomi-input--error":""].join(" ").trim(),children:[w.jsx("pre",{className:["m-0 py-2 px-3 text-xs font-mono leading-5","text-[color-mix(in_srgb,var(--boomi-card-fg,#111)_55%,transparent)]","bg-[color-mix(in_srgb,var(--boomi-card-bg,#ffffff)_86%,#000000)]","border-r border-[color-mix(in_srgb,var(--boomi-card-border,#e5e7eb)_80%,transparent)]","select-none text-right min-w-[2.5rem]"].join(" "),children:a}),w.jsx("textarea",{className:["boomi-input flex-1 rounded-none border-0 font-mono text-xs leading-5","bg-transparent p-2 min-h-[120px]","focus:outline-none"].join(" "),placeholder:o,value:n,onChange:u=>s(u.target.value)})]}),i&&w.jsx("p",{className:"boomi-form-helper",children:i}),r&&w.jsx("p",{className:"boomi-form-error",children:r})]})},rs=[{value:"",label:"None"},{value:"🤖",label:"🤖 Robot"},{value:"💬",label:"💬 Chat"},{value:"🗣️",label:"🗣️ Speaking"},{value:"✨",label:"✨ Sparkles"},{value:"🧠",label:"🧠 Brain"},{value:"💡",label:"💡 Idea"},{value:"🚀",label:"🚀 Rocket"},{value:"⚡",label:"⚡ Lightning"},{value:"🔍",label:"🔍 Search"},{value:"🛠️",label:"🛠️ Tools"},{value:"🤝",label:"🤝 Handshake"},{value:"🌐",label:"🌐 Globe"},{value:"🎯",label:"🎯 Target"},{value:"📊",label:"📊 Analytics"}],_r=["bottom-right","bottom-left","top-right","top-left"],Lf=()=>({label:"",description:"",icon:"🤖",hideIcon:!1,buttonLabel:"Launch"}),SH=t=>/^#[0-9a-fA-F]{3,8}$/.test(t.trim()),AT=["--boomi-font","--default-font-family","--boomi-accent","--boomi-agent-bg","--boomi-agent-blur","--boomi-agent-border","--boomi-agent-bubble-agent-bg","--boomi-agent-bubble-agent-border","--boomi-agent-bubble-agent-fg","--boomi-agent-bubble-border","--boomi-agent-bubble-shadow","--boomi-agent-bubble-user-bg","--boomi-agent-bubble-user-border","--boomi-agent-bubble-user-fg","--boomi-agent-card-tint","--boomi-agent-chat-bg","--boomi-agent-chat-border","--boomi-agent-chat-fg","--boomi-agent-close-bg-hover","--boomi-agent-close-fg","--boomi-agent-close-hover-fg","--boomi-agent-compose-bg","--boomi-agent-compose-border","--boomi-agent-compose-input-bg","--boomi-agent-compose-input-border","--boomi-agent-compose-secondary-bg","--boomi-agent-compose-secondary-border","--boomi-agent-compose-shadow","--boomi-agent-fg","--boomi-agent-header-bg","--boomi-agent-header-border","--boomi-agent-pane-bg","--boomi-agent-pane-bg-color","--boomi-agent-pane-fg","--boomi-agent-pane-fg-color","--boomi-agent-radius","--boomi-agent-ring","--boomi-agent-row-shimmer-opacity","--boomi-agent-row-tint","--boomi-agent-section-bg","--boomi-agent-section-border","--boomi-agent-section-fg","--boomi-agent-section-shadow","--boomi-agent-shadow","--boomi-agent-shimmer-1","--boomi-agent-shimmer-2","--boomi-agent-shimmer-angle","--boomi-agent-shimmer-direction","--boomi-agent-shimmer-opacity","--boomi-agent-shimmer-speed","--boomi-agent-tab-bg","--boomi-agent-tab-bg-active","--boomi-agent-tab-border","--boomi-agent-tab-border-active","--boomi-agent-tab-fg","--boomi-agent-tab-fg-active","--boomi-agent-tab-shadow-active","--boomi-agent-text-bg","--boomi-agent-text-border","--boomi-agent-text-copy-bg","--boomi-agent-text-copy-bg-hover","--boomi-agent-text-copy-fg","--boomi-agent-text-fg","--boomi-agent-thread-separator","--boomi-agent-update-bg","--boomi-agent-update-border","--boomi-agent-update-content-bg","--boomi-agent-update-content-fg","--boomi-agent-update-desc-fg","--boomi-agent-update-fg","--boomi-agent-update-radius","--boomi-agent-update-shadow","--boomi-agent-update-title-fg","--boomi-angle","--boomi-btn-primary-bg","--boomi-btn-primary-bg-active","--boomi-btn-primary-bg-hover","--boomi-btn-primary-border","--boomi-btn-primary-border-active","--boomi-btn-primary-border-hover","--boomi-btn-primary-fg","--boomi-btn-primary-fg-active","--boomi-btn-primary-fg-hover","--boomi-btn-primary-shadow","--boomi-btn-primary-shadow-active","--boomi-btn-primary-shadow-hover","--boomi-btn-secondary-bg","--boomi-btn-secondary-bg-active","--boomi-btn-secondary-bg-hover","--boomi-btn-secondary-border","--boomi-btn-secondary-border-active","--boomi-btn-secondary-border-hover","--boomi-btn-secondary-fg","--boomi-btn-secondary-fg-active","--boomi-btn-secondary-fg-hover","--boomi-btn-secondary-shadow","--boomi-btn-secondary-shadow-active","--boomi-btn-secondary-shadow-hover","--boomi-card-bg","--boomi-card-border","--boomi-card-fg","--boomi-card-hover-scale","--boomi-card-hover-shadow","--boomi-card-radius","--boomi-card-shadow","--boomi-chip-bg","--boomi-chip-border","--boomi-chip-error-bg","--boomi-chip-error-border","--boomi-chip-error-fg","--boomi-chip-fg","--boomi-chip-pulse-color","--boomi-chip-success-bg","--boomi-chip-success-border","--boomi-chip-success-fg","--boomi-chip-warning-bg","--boomi-chip-warning-border","--boomi-chip-warning-fg","--boomi-root-bg-color","--boomi-root-fg-color","--boomi-page-bg-color","--boomi-page-fg-color","--boomi-muted","--boomi-header-bg-color","--boomi-header-fg-color","--boomi-header-fg-hover","--boomi-header-border-color","--boomi-header-shadow","--boomi-input-bg","--boomi-input-fg","--boomi-input-placeholder","--boomi-input-border","--boomi-input-shadow","--boomi-input-border-focus","--boomi-input-shadow-focus","--boomi-input-outline-focus","--boomi-input-bg-disabled","--boomi-input-fg-disabled","--boomi-input-border-disabled","--boomi-input-border-invalid","--boomi-input-outline-invalid","--boomi-table-header-bg","--boomi-table-header-fg","--boomi-table-header-border","--boomi-table-row-odd-bg","--boomi-table-row-even-bg","--boomi-table-row-hover-shadow","--boomi-menu-bg","--boomi-menu-fg","--boomi-menu-border","--boomi-menu-shadow","--boomi-menu-item-bg","--boomi-menu-item-bg-hover","--boomi-menu-item-fg","--boomi-menu-item-fg-hover","--boomi-menu-divider","--boomi-menu-danger-fg","--boomi-menu-danger-fg-hover","--boomi-menu-danger-bg-hover","--boomi-modal-overlay-bg","--boomi-modal-bg","--boomi-modal-fg","--boomi-modal-border","--boomi-modal-shadow","--boomi-modal-close-fg","--boomi-modal-close-hover-fg","--boomi-form-label-fg","--boomi-form-helper-fg","--boomi-form-error-fg","--boomi-form-required-fg","--boomi-select-bg","--boomi-select-fg","--boomi-select-border","--boomi-select-shadow","--boomi-select-border-focus","--boomi-select-shadow-focus","--boomi-select-icon","--boomi-options-bg","--boomi-options-fg","--boomi-options-border","--boomi-options-shadow","--boomi-options-search-bg","--boomi-option-bg-active","--boomi-option-fg-selected","--boomi-loader-dot-bg","--boomi-loader-dot-size","--boomi-loader-dot1-opacity","--boomi-loader-dot2-opacity","--boomi-loader-dot3-opacity","--boomi-loader-msg-fg","--boomi-spinner-overlay-bg","--boomi-spinner-ring-color","--boomi-spinner-ping-color","--boomi-spinner-message-fg","--boomi-spinner-size","--boomi-spinner-border-width","--boomi-wizard-step-dot-bg","--boomi-wizard-step-dot-fg","--boomi-wizard-step-dot-border","--boomi-wizard-step-dot-shadow","--boomi-wizard-step-dot-bg-active","--boomi-wizard-step-dot-fg-active","--boomi-wizard-step-dot-border-active","--boomi-wizard-step-dot-shadow-active","--boomi-wizard-step-dot-bg-completed","--boomi-wizard-step-dot-fg-completed","--boomi-wizard-step-dot-border-completed","--boomi-wizard-step-dot-shadow-completed","--boomi-wizard-connector-bg","--boomi-wizard-label-fg","--boomi-wizard-card-bg","--boomi-wizard-card-fg","--boomi-wizard-card-border","--boomi-wizard-card-shadow","--boomi-wizard-link-fg","--boomi-wizard-link-fg-hover","--boomi-wizard-link-strong-fg","--boomi-notice-warning-bg","--boomi-notice-warning-fg","--boomi-notice-warning-border","--boomi-notice-success-bg","--boomi-notice-success-fg","--boomi-notice-success-border","--boomi-notice-error-bg","--boomi-notice-error-fg","--boomi-notice-error-border","--boomi-notice-shadow","--boomi-notice-radius","--boomi-update-bg","--boomi-update-fg","--boomi-update-border","--boomi-update-shadow","--boomi-update-title-fg","--boomi-update-desc-fg","--boomi-update-radius","--boomi-update-content","--boomi-tablist-border","--boomi-tab-bg","--boomi-tab-fg","--boomi-tab-border","--boomi-tab-bg-hover","--boomi-tab-bg-active","--boomi-tab-fg-active","--boomi-tab-border-active","--boomi-map-line","--boomi-map-line-width","--boomi-map-line-filter","--boomi-map-heading-fg","--boomi-map-card-bg","--boomi-map-card-border","--boomi-map-card-shadow","--boomi-map-card-shadow-hover","--boomi-map-card-transform-hover","--boomi-map-source-bg-mapped","--boomi-map-source-border-mapped","--boomi-map-source-outline","--boomi-map-target-bg-mapped","--boomi-map-target-border-mapped","--boomi-map-target-outline","--boomi-map-func-bg","--boomi-map-func-fg","--boomi-map-func-title-fg","--boomi-map-pin-source-bg","--boomi-map-pin-target-bg","--boomi-map-pin-input-bg","--boomi-map-pin-output-bg","--boomi-map-pin-badge-bg","--boomi-map-pin-badge-fg","--boomi-map-pin-danger-bg","--boomi-map-pulse-color","--boomi-map-pin-pulse","--boomi-map-add-bg","--boomi-map-add-fg","--boomi-map-add-border","--boomi-map-add-shadow","--boomi-map-add-bg-hover","--boomi-sched-card-bg","--boomi-sched-card-fg","--boomi-sched-card-border","--boomi-sched-card-shadow","--boomi-sched-card-shadow-hover","--boomi-sched-card-radius","--boomi-sched-header-bg","--boomi-sched-header-fg","--boomi-sched-header-border","--boomi-sched-header-shadow","--boomi-sched-toggle-fg","--boomi-sched-toggle-fg-hover","--boomi-sched-row-bg","--boomi-sched-row-border","--boomi-sched-row-shadow","--boomi-sched-row-hover-shadow","--boomi-sched-label-fg","--boomi-sched-helper-fg","--boomi-sched-error-fg","--boomi-sched-select-bg","--boomi-sched-select-fg","--boomi-sched-select-border","--boomi-sched-select-shadow","--boomi-sched-select-border-focus","--boomi-sched-select-shadow-focus","--boomi-sched-input-bg","--boomi-sched-input-fg","--boomi-sched-input-border","--boomi-sched-input-shadow","--boomi-sched-input-border-focus","--boomi-sched-input-shadow-focus","--boomi-sched-checkbox-border","--boomi-sched-checkbox-bg","--boomi-sched-checkbox-bg-checked","--boomi-sched-checkbox-symbol","--boomi-sched-action-bg","--boomi-sched-action-fg","--boomi-sched-action-border","--boomi-sched-action-shadow","--boomi-sched-action-bg-hover","--boomi-conn-bg","--boomi-conn-border","--boomi-conn-card-shadow","--boomi-conn-heading-fg","--boomi-conn-field-bg","--boomi-conn-field-border","--boomi-conn-field-label-fg","--boomi-conn-field-error-fg","--boomi-conn-btn-save-bg","--boomi-conn-btn-save-fg","--boomi-conn-btn-auth-bg","--boomi-conn-btn-auth-fg","--boomi-conn-btn-disabled-bg","--boomi-conn-btn-disabled-fg","--boomi-swal-bg","--boomi-swal-fg","--boomi-swal-border","--boomi-swal-shadow","--boomi-swal-title-fg","--boomi-swal-desc-fg","--boomi-swal-icon-success","--boomi-swal-icon-warning","--boomi-swal-icon-error","--boomi-swal-overlay-bg"],_H=()=>({themeSelection:"boomi",themeDefault:"boomi",themeCustomName:"",themeCustomVars:[],launcherCorner:"bottom-right",launcherOffsetX:"20",launcherOffsetY:"40",launcherShape:"pill",launcherLabel:"Find an Agent",launcherIcon:"🤖",launcherHideIcon:!1,listModalWidth:"500",listModalHeight:"600",listModalCorner:"bottom-right",listModalOffsetX:"20",listModalOffsetY:"100",listWelcomeTitle:"Agents",listWelcomeSubtitle:"Search for an agent and click to launch.",listHeaderShow:!0,listHeaderTitle:"Agents",listHeaderDescription:"Select an agent to launch.",listSearchShow:!0,tilesHeaderShow:!0,tilesHeaderTitle:"Agents",tilesHeaderDescription:"Browse and launch an agent.",tilesSearchShow:!0,tilesViewToggleShow:!0,agentUiMode:"modal",agentModalWidth:"600",agentModalHeight:"800",agentModalCorner:"top-right",agentModalOffsetX:"20",agentModalOffsetY:"40",agentSidebarShow:!0,agentSidebarWidth:"280",agentWelcomeTitle:"Let's Talk",agentWelcomeSubtitle:"Ask me about your Boomi deployment.",agentOverrides:{}}),ro=t=>{const e=t.trim();if(!e)return;const n=Number(e);return Number.isNaN(n)?e:n},CH=(t,e,n,o)=>{var r,s,c,a,u,l,d,f,h,m,p,g,b,v,E,T,y,x,_,N,C,L,D,k,I,S,A,R;const i={...e};if(i.themeCustomVars=[],!t.trim())return i;try{const $=JSON.parse(t);if($!=null&&$.theme&&typeof $.theme.defaultTheme=="string"){const K=$.theme.defaultTheme;K==="boomi"||K==="base"?(i.themeSelection=K,i.themeDefault=K,i.themeCustomName=""):(i.themeSelection="custom",i.themeDefault=K,i.themeCustomName=K);const q=$==null?void 0:$.cssVarsByTheme;let X=q==null?void 0:q[K],J=K;if((!X||typeof X!="object")&&q&&typeof q=="object"){const se=Object.keys(q)[0];se&&(X=q[se],J=se,J!=="boomi"&&J!=="base"&&(i.themeSelection="custom",i.themeCustomName=J,i.themeDefault=J))}X&&typeof X=="object"&&(i.themeCustomVars=Object.entries(X).map(([se,Y])=>({id:`var_${se}`,varName:se,value:typeof Y=="string"?Y:String(Y)})))}const P=(r=$==null?void 0:$.components)==null?void 0:r.agentList,U=(s=$==null?void 0:$.components)==null?void 0:s.agentTiles;if(n==="list"&&P){const K=P.launcher??{},q=K.position??{};_r.includes(q.corner)&&(i.launcherCorner=q.corner),q.offsetX!==void 0&&(i.launcherOffsetX=String(q.offsetX)),q.offsetY!==void 0&&(i.launcherOffsetY=String(q.offsetY)),(K.shape==="pill"||K.shape==="circle")&&(i.launcherShape=K.shape),typeof K.label=="string"&&(i.launcherLabel=K.label),typeof K.icon=="string"&&(i.launcherIcon=K.icon),typeof K.hideIcon=="boolean"&&(i.launcherHideIcon=K.hideIcon);const X=P.modal??{};X.width!==void 0&&(i.listModalWidth=String(X.width)),X.height!==void 0&&(i.listModalHeight=String(X.height));const J=X.position??{};_r.includes(J.corner)&&(i.listModalCorner=J.corner),J.offsetX!==void 0&&(i.listModalOffsetX=String(J.offsetX)),J.offsetY!==void 0&&(i.listModalOffsetY=String(J.offsetY)),(c=P.welcome)!=null&&c.title&&(i.listWelcomeTitle=P.welcome.title),(a=P.welcome)!=null&&a.subtitle&&(i.listWelcomeSubtitle=P.welcome.subtitle),((u=P.header)==null?void 0:u.show)!==void 0&&(i.listHeaderShow=!!P.header.show),(l=P.header)!=null&&l.title&&(i.listHeaderTitle=P.header.title),(d=P.header)!=null&&d.description&&(i.listHeaderDescription=P.header.description),((f=P.search)==null?void 0:f.show)!==void 0&&(i.listSearchShow=!!P.search.show)}n==="tiles"&&U&&(((h=U.header)==null?void 0:h.show)!==void 0&&(i.tilesHeaderShow=!!U.header.show),(m=U.header)!=null&&m.title&&(i.tilesHeaderTitle=U.header.title),(p=U.header)!=null&&p.description&&(i.tilesHeaderDescription=U.header.description),((g=U.search)==null?void 0:g.show)!==void 0&&(i.tilesSearchShow=!!U.search.show),((b=U.viewToggle)==null?void 0:b.show)!==void 0&&(i.tilesViewToggleShow=!!U.viewToggle.show));const F=($==null?void 0:$.agents)??{},B=o.find(K=>F[K])??Object.keys(F)[0],G=B?F[B]:null;G!=null&&G.position&&typeof G.position=="object"&&"corner"in G.position&&(_r.includes(G.position.corner)&&(i.launcherCorner=G.position.corner),G.position.offsetX!==void 0&&(i.launcherOffsetX=String(G.position.offsetX)),G.position.offsetY!==void 0&&(i.launcherOffsetY=String(G.position.offsetY))),((G==null?void 0:G.shape)==="pill"||(G==null?void 0:G.shape)==="circle")&&(i.launcherShape=G.shape),typeof(G==null?void 0:G.label)=="string"&&(i.launcherLabel=G.label),typeof(G==null?void 0:G.icon)=="string"&&(i.launcherIcon=G.icon),typeof(G==null?void 0:G.hideIcon)=="boolean"&&(i.launcherHideIcon=G.hideIcon);const z=(G==null?void 0:G.ui)??{};(z.mode==="modal"||z.mode==="full")&&(i.agentUiMode=z.mode),((v=z.modal)==null?void 0:v.width)!==void 0&&(i.agentModalWidth=String(z.modal.width)),((E=z.modal)==null?void 0:E.height)!==void 0&&(i.agentModalHeight=String(z.modal.height)),(y=(T=z.modal)==null?void 0:T.position)!=null&&y.corner&&_r.includes(z.modal.position.corner)&&(i.agentModalCorner=z.modal.position.corner),((_=(x=z.modal)==null?void 0:x.position)==null?void 0:_.offsetX)!==void 0&&(i.agentModalOffsetX=String(z.modal.position.offsetX)),((C=(N=z.modal)==null?void 0:N.position)==null?void 0:C.offsetY)!==void 0&&(i.agentModalOffsetY=String(z.modal.position.offsetY));const Q=z.sessionScope==="mount"?!1:z.sessionScope==="multi"?!0:void 0,V=(((L=z.sidebar)==null?void 0:L.show)!==void 0?!!z.sidebar.show:void 0)??Q;if(V!==void 0&&(i.agentSidebarShow=V),((D=z.sidebar)==null?void 0:D.width)!==void 0&&(i.agentSidebarWidth=String(z.sidebar.width)),(k=z.welcome)!=null&&k.title&&(i.agentWelcomeTitle=z.welcome.title),(I=z.welcome)!=null&&I.subtitle&&(i.agentWelcomeSubtitle=z.welcome.subtitle),n==="list"||n==="tiles"){const K={};for(const q of o){const X=F[q];X&&(K[q]={label:typeof X.label=="string"?X.label:"",description:typeof((S=X.ui)==null?void 0:S.pageDescription)=="string"?X.ui.pageDescription:typeof((R=(A=X.ui)==null?void 0:A.welcome)==null?void 0:R.subtitle)=="string"?X.ui.welcome.subtitle:"",icon:typeof X.icon=="string"?X.icon:"🤖",hideIcon:typeof X.hideIcon=="boolean"?X.hideIcon:!1,buttonLabel:typeof X.buttonLabel=="string"?X.buttonLabel:"Launch"})}i.agentOverrides=K}}catch{return i}return i},ST=(t,e,n)=>{const o=t.themeSelection==="custom"?t.themeCustomName.trim()||t.themeDefault||"custom":t.themeSelection,i={transport:"boomi-direct",theme:{allowThemes:!0,defaultTheme:o}},r={};for(const c of t.themeCustomVars)c.varName&&c.value&&(r[c.varName]=c.value);Object.keys(r).length&&(i.cssVarsByTheme={[o]:r}),e==="list"&&(i.components={agentList:{launcher:{position:{corner:t.launcherCorner,offsetX:ro(t.launcherOffsetX),offsetY:ro(t.launcherOffsetY)},shape:t.launcherShape,label:t.launcherLabel,icon:t.launcherIcon,hideIcon:t.launcherHideIcon},modal:{width:ro(t.listModalWidth),height:ro(t.listModalHeight),position:{corner:t.listModalCorner,offsetX:ro(t.listModalOffsetX),offsetY:ro(t.listModalOffsetY)}},welcome:{title:t.listWelcomeTitle,subtitle:t.listWelcomeSubtitle},header:{show:t.listHeaderShow,title:t.listHeaderTitle,description:t.listHeaderDescription},search:{show:t.listSearchShow}}}),e==="tiles"&&(i.components={agentTiles:{header:{show:t.tilesHeaderShow,title:t.tilesHeaderTitle,description:t.tilesHeaderDescription},search:{show:t.tilesSearchShow},viewToggle:{show:t.tilesViewToggleShow}}});const s=n.length?n:["agent-id"];return i.agents=s.reduce((c,a)=>{const u=e==="list"||e==="tiles"?t.agentOverrides[a]??Lf():void 0,l={transport:"boomi-direct"};return e==="single"?(l.position={corner:t.launcherCorner,offsetX:ro(t.launcherOffsetX),offsetY:ro(t.launcherOffsetY)},l.shape=t.launcherShape,l.label=t.launcherLabel,l.icon=t.launcherIcon,l.hideIcon=t.launcherHideIcon):u&&(u.label&&(l.label=u.label),l.icon=u.icon,l.hideIcon=u.hideIcon,u.buttonLabel&&u.buttonLabel!=="Launch"&&(l.buttonLabel=u.buttonLabel)),l.ui={mode:t.agentUiMode,sessionScope:t.agentSidebarShow?"multi":"mount",modal:{width:ro(t.agentModalWidth),height:ro(t.agentModalHeight),position:{corner:t.agentModalCorner,offsetX:ro(t.agentModalOffsetX),offsetY:ro(t.agentModalOffsetY)}},sidebar:{show:t.agentSidebarShow,width:ro(t.agentSidebarWidth)},welcome:{title:t.agentWelcomeTitle,subtitle:t.agentWelcomeSubtitle},...u!=null&&u.description?{pageDescription:u.description}:{}},c[a]=l,c},{}),i.project={embedType:e,agentIds:s},i},rL=O.forwardRef(({embedType:t,agentIds:e,configRaw:n,onChangeConfig:o,onUpdateBuilder:i,syncFromConfig:r=!1,availableAgents:s},c)=>{const a=O.useMemo(_H,[]),[u,l]=O.useState(a),d=O.useRef(!1);O.useImperativeHandle(c,()=>({getConfig:()=>ST(u,t,e)}),[u,t,e]),O.useEffect(()=>{(r||!d.current)&&(l(CH(n,a,t,e)),d.current=!0)},[n,a,t,e,r]),O.useEffect(()=>{i==null||i(u)},[u,i]),O.useEffect(()=>{const p=ST(u,t,e);o(p)},[u,t,e,o]);const f=()=>{const p=AT[0]??"--boomi-root-bg-color";l(g=>({...g,themeCustomVars:[...g.themeCustomVars,{id:`var_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,varName:p,value:""}]}))},h=(p,g)=>{l(b=>({...b,themeCustomVars:b.themeCustomVars.map(v=>v.id===p?{...v,...g}:v)}))},m=p=>{l(g=>({...g,themeCustomVars:g.themeCustomVars.filter(b=>b.id!==p)}))};return w.jsxs("div",{className:"boomi-card p-4 space-y-4",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-sm font-semibold",children:"Config Builder"}),w.jsx("div",{className:"text-xs opacity-70",children:"Updates the JSON configuration automatically as you make changes."})]}),w.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[w.jsxs("div",{className:"space-y-3",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Agent UI"}),w.jsxs("label",{className:"boomi-form-label",children:["Mode",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.agentUiMode,onChange:p=>l(g=>({...g,agentUiMode:p.target.value})),children:[w.jsx("option",{value:"modal",children:"Modal"}),w.jsx("option",{value:"full",children:"Full Page"})]})]}),u.agentUiMode==="modal"&&w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Modal width",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.agentModalWidth,onChange:p=>l(g=>({...g,agentModalWidth:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Modal height",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.agentModalHeight,onChange:p=>l(g=>({...g,agentModalHeight:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Modal corner",w.jsx("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.agentModalCorner,onChange:p=>l(g=>({...g,agentModalCorner:p.target.value})),children:_r.map(p=>w.jsx("option",{value:p,children:p},p))})]}),w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Offset X",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.agentModalOffsetX,onChange:p=>l(g=>({...g,agentModalOffsetX:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Offset Y",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.agentModalOffsetY,onChange:p=>l(g=>({...g,agentModalOffsetY:p.target.value}))})]})]})]}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:u.agentSidebarShow,onChange:p=>l(g=>({...g,agentSidebarShow:p.target.checked}))}),"Show sidebar"]}),w.jsxs("label",{className:"boomi-form-label",children:["Sidebar width",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.agentSidebarWidth,onChange:p=>l(g=>({...g,agentSidebarWidth:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Welcome title",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.agentWelcomeTitle,onChange:p=>l(g=>({...g,agentWelcomeTitle:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Welcome subtitle",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.agentWelcomeSubtitle,onChange:p=>l(g=>({...g,agentWelcomeSubtitle:p.target.value}))})]})]}),w.jsxs("div",{className:"space-y-3",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Theme"}),w.jsxs("label",{className:"boomi-form-label",children:["Theme",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.themeSelection,onChange:p=>l(g=>({...g,themeSelection:p.target.value,themeDefault:p.target.value==="custom"?g.themeDefault:p.target.value})),children:[w.jsx("option",{value:"boomi",children:"boomi"}),w.jsx("option",{value:"base",children:"base"}),w.jsx("option",{value:"custom",children:"custom"})]})]}),u.themeSelection==="custom"&&w.jsxs(w.Fragment,{children:[w.jsxs("label",{className:"boomi-form-label",children:["Custom theme name",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.themeCustomName,onChange:p=>l(g=>({...g,themeCustomName:p.target.value,themeDefault:p.target.value})),placeholder:"my-theme"})]}),w.jsxs("div",{className:"space-y-2",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"CSS Variable Overrides"}),u.themeCustomVars.length===0&&w.jsx("div",{className:"text-xs opacity-70",children:"No custom variables yet."}),w.jsx("div",{className:"space-y-2",children:u.themeCustomVars.map(p=>w.jsxs("div",{className:"flex items-center gap-2 flex-nowrap w-full overflow-x-auto",children:[w.jsx("select",{className:"boomi-input flex-1 min-w-0 rounded-md p-2 text-sm",value:p.varName,onChange:g=>h(p.id,{varName:g.target.value}),children:AT.map(g=>w.jsx("option",{value:g,children:g},g))}),w.jsx("input",{type:"text",value:p.value,onChange:g=>h(p.id,{value:g.target.value}),className:"boomi-input flex-1 min-w-0 rounded-md p-2 text-sm",placeholder:"#000000 or rgba(...) or value"}),SH(p.value)&&w.jsx("input",{type:"color",value:p.value,onChange:g=>h(p.id,{value:g.target.value}),className:"h-9 w-12 shrink-0 cursor-pointer rounded-md border border-[var(--boomi-card-border)] bg-transparent"}),w.jsx("button",{type:"button",className:"text-xs text-red-500 whitespace-nowrap shrink-0",onClick:()=>m(p.id),children:"Remove"})]},p.id))}),w.jsx("div",{children:w.jsx("button",{type:"button",className:"boomi-btn-primary px-3 py-2 text-xs",onClick:f,children:"Add CSS Variable"})})]})]})]})]}),(t==="list"||t==="single")&&w.jsxs("div",{className:t==="list"?"grid gap-4 md:grid-cols-2":"space-y-3",children:[w.jsxs("div",{className:"space-y-3",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Launcher (Pill)"}),w.jsxs("label",{className:"boomi-form-label",children:["Corner",w.jsx("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.launcherCorner,onChange:p=>l(g=>({...g,launcherCorner:p.target.value})),children:_r.map(p=>w.jsx("option",{value:p,children:p},p))})]}),w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Offset X",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.launcherOffsetX,onChange:p=>l(g=>({...g,launcherOffsetX:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Offset Y",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.launcherOffsetY,onChange:p=>l(g=>({...g,launcherOffsetY:p.target.value}))})]})]}),w.jsxs("label",{className:"boomi-form-label",children:["Shape",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.launcherShape,onChange:p=>l(g=>({...g,launcherShape:p.target.value})),children:[w.jsx("option",{value:"pill",children:"Pill"}),w.jsx("option",{value:"circle",children:"Circle"})]})]}),w.jsxs("label",{className:"boomi-form-label",children:["Label",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.launcherLabel,onChange:p=>l(g=>({...g,launcherLabel:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Icon",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:rs.some(p=>p.value===u.launcherIcon)?u.launcherIcon:"__custom__",onChange:p=>l(g=>({...g,launcherIcon:p.target.value==="__custom__"?g.launcherIcon:p.target.value})),children:[!rs.some(p=>p.value===u.launcherIcon)&&w.jsxs("option",{value:"__custom__",children:[u.launcherIcon," (custom)"]}),rs.map(p=>w.jsx("option",{value:p.value,children:p.label},p.value))]})]}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:u.launcherHideIcon,onChange:p=>l(g=>({...g,launcherHideIcon:p.target.checked}))}),"Hide icon"]})]}),t==="list"&&w.jsxs("div",{className:"space-y-3",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"List Modal"}),w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Width",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.listModalWidth,onChange:p=>l(g=>({...g,listModalWidth:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Height",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.listModalHeight,onChange:p=>l(g=>({...g,listModalHeight:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Corner",w.jsx("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.listModalCorner,onChange:p=>l(g=>({...g,listModalCorner:p.target.value})),children:_r.map(p=>w.jsx("option",{value:p,children:p},p))})]}),w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Offset X",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.listModalOffsetX,onChange:p=>l(g=>({...g,listModalOffsetX:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Offset Y",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.listModalOffsetY,onChange:p=>l(g=>({...g,listModalOffsetY:p.target.value}))})]})]})]}),w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70 pt-2",children:"List Header & Search"}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:u.listHeaderShow,onChange:p=>l(g=>({...g,listHeaderShow:p.target.checked}))}),"Show header"]}),w.jsxs("label",{className:"boomi-form-label",children:["Header title",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.listHeaderTitle,onChange:p=>l(g=>({...g,listHeaderTitle:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Header description",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.listHeaderDescription,onChange:p=>l(g=>({...g,listHeaderDescription:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:u.listSearchShow,onChange:p=>l(g=>({...g,listSearchShow:p.target.checked}))}),"Show search"]}),w.jsxs("label",{className:"boomi-form-label",children:["Welcome title",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.listWelcomeTitle,onChange:p=>l(g=>({...g,listWelcomeTitle:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Welcome subtitle",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.listWelcomeSubtitle,onChange:p=>l(g=>({...g,listWelcomeSubtitle:p.target.value}))})]})]})]}),t==="tiles"&&w.jsxs("div",{className:"space-y-3",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Tiles Header & Search"}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:u.tilesHeaderShow,onChange:p=>l(g=>({...g,tilesHeaderShow:p.target.checked}))}),"Show header"]}),w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Header title",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.tilesHeaderTitle,onChange:p=>l(g=>({...g,tilesHeaderTitle:p.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Header description",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:u.tilesHeaderDescription,onChange:p=>l(g=>({...g,tilesHeaderDescription:p.target.value}))})]})]}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:u.tilesSearchShow,onChange:p=>l(g=>({...g,tilesSearchShow:p.target.checked}))}),"Show search"]}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:u.tilesViewToggleShow,onChange:p=>l(g=>({...g,tilesViewToggleShow:p.target.checked}))}),"Show tiles/table toggle"]})]}),(t==="list"||t==="tiles")&&e.length>0&&w.jsxs("div",{className:"space-y-3",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Agent Cards"}),w.jsxs("div",{className:"text-xs opacity-70",children:["Configure how each agent appears in the ",t," view."]}),w.jsx("div",{className:"space-y-3",children:e.map(p=>{var v;const g=u.agentOverrides[p]??Lf(),b=E=>l(T=>({...T,agentOverrides:{...T.agentOverrides,[p]:{...T.agentOverrides[p]??Lf(),...E}}}));return w.jsxs("div",{className:"boomi-card p-3 space-y-3",children:[w.jsxs("div",{className:"space-y-0.5",children:[w.jsx("div",{className:"text-sm font-semibold",children:((v=s==null?void 0:s.find(E=>E.id===p))==null?void 0:v.label)??p}),w.jsx("div",{className:"text-xs font-mono opacity-50",children:p})]}),w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Card title",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:g.label,placeholder:"Agent name",onChange:E=>b({label:E.target.value})})]}),w.jsxs("label",{className:"boomi-form-label",children:["Card description",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:g.description,placeholder:"Brief description",onChange:E=>b({description:E.target.value})})]}),w.jsxs("label",{className:"boomi-form-label",children:["Icon",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:rs.some(E=>E.value===g.icon)?g.icon:"__custom__",onChange:E=>b({icon:E.target.value==="__custom__"?g.icon:E.target.value}),children:[!rs.some(E=>E.value===g.icon)&&w.jsxs("option",{value:"__custom__",children:[g.icon," (custom)"]}),rs.map(E=>w.jsx("option",{value:E.value,children:E.label},E.value))]})]}),w.jsxs("label",{className:"boomi-form-label",children:["Button label",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:g.buttonLabel,placeholder:"Launch",onChange:E=>b({buttonLabel:E.target.value})})]})]}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:g.hideIcon,onChange:E=>b({hideIcon:E.target.checked})}),"Hide icon"]})]},p)})})]})]})});function NH(t){try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}const LH=({isOpen:t,onClose:e,onSubmit:n,isSaving:o,defaultOrigins:i,availableAgents:r})=>{const[s,c]=O.useState(""),[a,u]=O.useState(null),[l,d]=O.useState(!1),[f,h]=O.useState([]),[m,p]=O.useState(""),g=O.useRef(null),b=O.useRef(null),v=O.useCallback(K=>{g.current=K,p(q=>{const X=JSON.stringify(K,null,2);return X!==q?X:q})},[]),[E,T]=O.useState("single"),[y,x]=O.useState(""),[_,N]=O.useState([]),[C,L]=O.useState(null),[D,k]=O.useState(null),[I,S]=O.useState(null),[A,R]=O.useState("builder"),$=(K,q)=>(K.length>0?K:["agent-id"]).reduce((J,se)=>(J[se]={transport:"boomi-direct",ui:{mode:q,modal:{width:500,height:600,position:{corner:"bottom-right",offsetX:20,offsetY:100}},sidebar:{show:q==="full",width:280},welcome:{title:"Let's Talk",subtitle:"Ask me about your Boomi deployment."}}},J),{}),F=JSON.stringify(((K,q)=>{const X={transport:"boomi-direct",theme:{allowThemes:!0,defaultTheme:"boomi"},cssVarsByTheme:{oem:{"--boomi-root-bg-color":"#0b1220","--boomi-root-fg-color":"#e5e7eb","--boomi-page-bg-color":"#0b1220","--boomi-page-fg-color":"#e5e7eb","--boomi-header-bg-color":"rgba(15, 23, 42, 0.8)","--boomi-header-fg-color":"#e5e7eb","--boomi-btn-primary-bg":"#2563eb","--boomi-btn-primary-fg":"#ffffff","--boomi-card-bg":"#0f172a","--boomi-card-border":"#1f2937","--boomi-menu-bg":"#0f172a","--boomi-menu-fg":"#e5e7eb","--boomi-modal-bg":"#0f172a","--boomi-modal-fg":"#e5e7eb","--boomi-input-bg":"#0b1220","--boomi-input-fg":"#e5e7eb"}}};K==="list"&&(X.components={agentList:{launcher:{position:{corner:"bottom-right",offsetX:20,offsetY:40},shape:"pill",label:"Find an Agent",icon:"bot",hideIcon:!1},modal:{width:500,height:600,position:{corner:"bottom-right",offsetX:20,offsetY:100}},welcome:{title:"Agents",subtitle:"Search for an agent and click to launch."}}});const J=q.length>0?q:["agent-id"];return X.agents=$(J,K==="single"?"modal":"full"),X})(E,E==="single"?y?[y]:[]:_),null,2);O.useEffect(()=>{t&&(c(""),u(null),d(!1),h([]),p(""),T("single"),x(""),N([]),L(null),k(null),S(null),R("builder"))},[t]),O.useEffect(()=>{!t||!(r!=null&&r.length)||(x(K=>K||r[0].id),N(K=>K.length?K:[r[0].id]))},[t,r]),O.useEffect(()=>{E==="single"?!y&&_[0]&&x(_[0]):_.length===0&&y&&N([y])},[E,_,y]);const B=K=>{N(q=>q.includes(K)?q.filter(X=>X!==K):[...q,K])},G=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`project_${crypto.randomUUID()}`:`project_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`,z=async()=>{var he;if(!s.trim()){d(!0),u("Project name is required.");return}u(null);const K=E==="single"?y?[y]:[]:_;if(!K.length){L("Select at least one agent");return}L(null);let q;if(A==="builder")q=((he=b.current)==null?void 0:he.getConfig())??void 0;else{const ie=m.trim();if(ie)try{q=JSON.parse(ie)}catch{S("Config must be valid JSON");return}}S(null);const X=q&&typeof q=="object"?{...q}:{},J=X.project&&typeof X.project=="object"?{...X.project}:{};X.project={...J,embedType:E,agentIds:K};const se=Array.from(new Set(f.map(ie=>ie.trim()).filter(Boolean)));if(!se.length){k("At least one allowed origin is required.");return}for(const ie of se)if(!NH(ie)){k(`Invalid origin (must be http/https): ${ie}`);return}k(null);const Y=G();if(E==="single"&&y){const ie={...X.agents??{}};ie[y]&&!ie[Y]&&(ie[Y]=ie[y],X.agents=ie)}console.log("[AddAgentModal] submitting configBase:",JSON.stringify(X,null,2)),await n({agentId:Y,boomiAgentId:E==="single"?y:void 0,label:s.trim()||void 0,allowedOrigins:se,config:X})},Q=()=>{h(K=>[...K,""])},W=(K,q)=>{h(X=>X.map((J,se)=>se===K?q:J))},V=K=>{h(q=>q.filter((X,J)=>J!==K))};return w.jsxs(no,{isOpen:t,title:"Add Project",description:"Create a new embedded agent group and its allowed embed origins.",onClose:e,onSubmit:z,submitLabel:o?"Saving...":"Create Project",showSaveButton:!o,children:[w.jsxs("div",{className:"boomi-card p-4 space-y-2",children:[w.jsx("div",{className:"text-sm font-semibold",children:"Project Summary"}),w.jsxs("div",{className:"text-xs opacity-80",children:["Embed type: ",w.jsx("strong",{children:E==="single"?"Single Agent":E==="tiles"?"Multi-Agent (Tiles)":"Multi-Agent (List)"})]}),w.jsxs("div",{className:"text-xs opacity-80",children:["Selected agents: ",w.jsx("strong",{children:E==="single"?y?1:0:_.length})]}),w.jsx("div",{className:"text-xs opacity-70",children:"You can start with the form below and optionally layer in advanced JSON config."})]}),w.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[w.jsxs("div",{className:"space-y-4",children:[w.jsx(bn,{formName:"agentAdd",label:"Project Name",required:!0,inputName:"name",readOnly:!1,value:s,onChange:K=>{c(K.target.value),a&&u(null)},onBlur:()=>{d(!0),s.trim()||u("Project name is required.")},placeholder:"Customer Support Project"}),l&&a&&w.jsx("div",{className:"boomi-form-error",children:a}),w.jsxs("label",{className:"boomi-form-label",children:["Embed Type",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:E,onChange:K=>T(K.target.value),children:[w.jsx("option",{value:"single",children:"Single Agent"}),w.jsx("option",{value:"tiles",children:"Multi-Agent (Tiles)"}),w.jsx("option",{value:"list",children:"Multi-Agent (Pill + Modal List)"})]})]}),E==="single"?w.jsxs("label",{className:"boomi-form-label",children:["Agent",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:y,onChange:K=>x(K.target.value),children:[(r??[]).length===0&&w.jsx("option",{value:"",children:"No agents available"}),(r??[]).map(K=>w.jsx("option",{value:K.id,children:K.label},K.id))]}),C&&w.jsx("div",{className:"text-xs text-red-500 mt-1",children:C})]}):w.jsxs("div",{children:[w.jsx("label",{className:"boomi-form-label",children:"Agents"}),w.jsx("div",{className:"boomi-input w-full rounded-md p-2 text-sm space-y-2 max-h-48 overflow-auto",children:(r??[]).length===0?w.jsx("div",{className:"text-xs opacity-70",children:"No agents available"}):(r??[]).map(K=>w.jsxs("label",{className:"flex items-center gap-2",children:[w.jsx("input",{type:"checkbox",checked:_.includes(K.id),onChange:()=>B(K.id)}),w.jsx("span",{className:"text-xs",children:K.label})]},K.id))}),C&&w.jsx("div",{className:"text-xs text-red-500 mt-1",children:C})]})]}),w.jsx("div",{className:"space-y-4",children:w.jsxs("div",{className:"space-y-2",children:[w.jsx("label",{className:"boomi-form-label",children:"Allowed Origins"}),w.jsx("div",{className:"text-xs opacity-70",children:"Select origins from your CORS list. If you don’t see one you need, add it first in the CORS page."}),w.jsxs("div",{className:"space-y-2",children:[f.length===0&&w.jsx("div",{className:"text-xs opacity-70",children:"No origins selected."}),f.map((K,q)=>{const X=new Set(f.map(Y=>Y.trim()).filter(Boolean)),J=(i??[]).filter(Y=>Y===K||!X.has(Y)),se=J.includes(K);return w.jsxs("div",{className:"flex items-center gap-2",children:[w.jsxs("select",{className:"boomi-input w-full rounded-md p-2 text-sm",value:K,onChange:Y=>W(q,Y.target.value),children:[!K&&w.jsx("option",{value:"",children:"Select an origin"}),se?null:K?w.jsx("option",{value:K,children:K}):null,J.map(Y=>w.jsx("option",{value:Y,children:Y},Y))]}),w.jsx("span",{role:"button",tabIndex:0,className:"text-red-500 text-lg cursor-pointer",onClick:()=>V(q),onKeyDown:Y=>{(Y.key==="Enter"||Y.key===" ")&&V(q)},"aria-label":"Remove origin",children:w.jsx(uo,{})})]},`${K}-${q}`)})]}),w.jsx("div",{className:"flex",children:w.jsx(rt,{toggle:!1,primary:!1,showIcon:!1,label:"Add Allowed Origin",onClick:Q})}),D&&w.jsx("div",{className:"text-xs text-red-500",children:D}),w.jsx("div",{className:"text-xs opacity-70",children:"Add new origins from the CORS page before selecting them here."})]})})]}),w.jsxs("div",{className:"space-y-3",children:[w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-sm font-semibold",children:"UI Configuration"}),w.jsx("div",{className:"text-xs opacity-70",children:"Optional. Use JSON to customize themes, layout, and agent UI beyond the form inputs."})]}),w.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-[var(--boomi-card-bg)] p-1 border border-[var(--boomi-card-border)]",children:[w.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${A==="builder"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>R("builder"),children:"Builder"}),w.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${A==="json"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>R("json"),children:"JSON"})]})]}),A==="builder"?w.jsx(rL,{ref:b,embedType:E,agentIds:E==="single"?y?[y]:[]:_,configRaw:m,onChangeConfig:v,syncFromConfig:!1,availableAgents:r}):w.jsxs(w.Fragment,{children:[w.jsx(iL,{label:"Config (JSON)",value:m,placeholder:F,error:I,onChange:p}),w.jsx("div",{className:"flex justify-end",children:w.jsx(rt,{toggle:!1,primary:!1,showIcon:!1,label:"Insert Starter Config",onClick:()=>p(F)})})]})]})]})},kH=({isOpen:t,agentId:e,onClose:n,onConfirm:o,isDeleting:i})=>w.jsx(no,{isOpen:t,title:"Delete Agent",description:"Remove this agent and all associated public tokens.",onClose:n,onSubmit:o,submitLabel:i?"Deleting...":"Delete",showSaveButton:!i,children:w.jsxs("p",{className:"text-sm",children:["Are you sure you want to delete"," ",w.jsx("span",{className:"font-semibold",children:e}),"?"]})});function _T(t){if(t.trim().toLowerCase()==="null")return!0;try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}const IH=({isOpen:t,agentId:e,label:n,allowedOrigins:o,defaultOrigins:i,onAddOrigin:r,config:s,onClose:c,onSubmit:a,isSaving:u,availableAgents:l})=>{const[d,f]=O.useState(""),[h,m]=O.useState([]),[p,g]=O.useState(""),[b,v]=O.useState(!1),[E,T]=O.useState(""),[y,x]=O.useState(0),[_,N]=O.useState(null),[C,L]=O.useState(null),[D,k]=O.useState("builder"),I=(Q,W)=>(Q.length>0?Q:["agent-id"]).reduce((K,q)=>(K[q]={transport:"boomi-direct",ui:{mode:W,modal:{width:500,height:600,position:{corner:"bottom-right",offsetX:20,offsetY:100}},sidebar:{show:W==="full",width:280},welcome:{title:"Let's Talk",subtitle:"Ask me about your Boomi deployment."}}},K),{}),S=(Q,W)=>{const V={transport:"boomi-direct",theme:{allowThemes:!0,defaultTheme:"boomi"},cssVarsByTheme:{oem:{"--boomi-root-bg-color":"#0b1220","--boomi-root-fg-color":"#e5e7eb","--boomi-page-bg-color":"#0b1220","--boomi-page-fg-color":"#e5e7eb","--boomi-header-bg-color":"rgba(15, 23, 42, 0.8)","--boomi-header-fg-color":"#e5e7eb","--boomi-btn-primary-bg":"#2563eb","--boomi-btn-primary-fg":"#ffffff","--boomi-card-bg":"#0f172a","--boomi-card-border":"#1f2937","--boomi-menu-bg":"#0f172a","--boomi-menu-fg":"#e5e7eb","--boomi-modal-bg":"#0f172a","--boomi-modal-fg":"#e5e7eb","--boomi-input-bg":"#0b1220","--boomi-input-fg":"#e5e7eb"}}};Q==="list"&&(V.components={agentList:{launcher:{position:{corner:"bottom-right",offsetX:20,offsetY:40},shape:"pill",label:"Find an Agent",icon:"bot",hideIcon:!1},modal:{width:500,height:600,position:{corner:"bottom-right",offsetX:20,offsetY:100}},welcome:{title:"Agents",subtitle:"Search for an agent and click to launch."}}});const K=W.length>0?W:["agent-id"];return V.agents=I(K,Q==="single"?"modal":"full"),V},R=(()=>{try{const Q=E.trim()?JSON.parse(E):null,W=Q&&typeof Q=="object"?Q.project:null,V=typeof(W==null?void 0:W.embedType)=="string"?W.embedType:"single",K=Array.isArray(W==null?void 0:W.agentIds)?W.agentIds.filter(Boolean):[];return{embedType:V,agentIds:K}}catch{return{embedType:"single",agentIds:[]}}})(),$=R.agentIds.length>0?R.agentIds:e?[e]:[],P=JSON.stringify(S(R.embedType,$),null,2);O.useEffect(()=>{if(t){f(n??"");const Q=(o&&o.length?o:i)??[];m(Q),g(""),T(s?JSON.stringify(s,null,2):""),x(W=>W+1),N(null),L(null),k("builder")}},[t,n,s,o,i]);const U=async()=>{if(!e)return;let Q;const W=E.trim();if(W)try{Q=JSON.parse(W)}catch{L("Config must be valid JSON");return}L(null);const V=Array.from(new Set(h.map(K=>K.trim()).filter(Boolean)));if(!V.length){N("At least one allowed origin is required.");return}for(const K of V)if(!_T(K)){N(`Invalid origin (must be http/https): ${K}`);return}if(N(null),Q&&e){const K=Q.project,q=K==null?void 0:K.embedType,X=Array.isArray(K==null?void 0:K.agentIds)?K.agentIds[0]:null;if(q==="single"&&X){const J={...Q.agents??{}};J[X]&&!J[e]&&(J[e]=J[X],Q.agents=J)}}await a({agentId:e,label:d.trim()||void 0,allowedOrigins:V,config:Q})},F=()=>{const Q=i??[],W=new Set(h.map(K=>K.trim()).filter(Boolean)),V=Q.find(K=>!W.has(K))??"";m(K=>[...K,V])},B=(Q,W)=>{m(V=>V.map((K,q)=>q===Q?W:K))},G=Q=>{m(W=>W.filter((V,K)=>K!==Q))},z=async()=>{const Q=p.trim();if(!Q){N("Enter an origin before adding.");return}if(!_T(Q)){N(`Invalid origin (must be http/https): ${Q}`);return}if(N(null),!r){m(W=>W.includes(Q)?W:[...W,Q]),g("");return}v(!0);try{await r(Q),m(W=>W.includes(Q)?W:[...W,Q]),g("")}catch(W){N((W==null?void 0:W.message)||"Failed to add origin.")}finally{v(!1)}};return w.jsxs(no,{isOpen:t,title:"Edit Agent",description:"Update agent details and allowed origins.",onClose:c,onSubmit:U,submitLabel:u?"Saving...":"Save Changes",showSaveButton:!u,children:[w.jsxs("div",{className:"boomi-card p-4 space-y-2",children:[w.jsx("div",{className:"text-sm font-semibold",children:"Agent Overview"}),w.jsxs("div",{className:"text-xs opacity-80",children:["Agent ID: ",w.jsx("strong",{children:e??"—"})]}),w.jsx("div",{className:"text-xs opacity-70",children:"Update the friendly name, allowed origins, and optional config overrides below."})]}),w.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[w.jsxs("div",{className:"space-y-4",children:[w.jsx(bn,{formName:"agentEdit",label:"Name",required:!1,inputName:"name",readOnly:!1,value:d,onChange:Q=>f(Q.target.value),placeholder:"Customer Support Agent"}),w.jsx(bn,{formName:"agentEdit",label:"Agent ID",required:!0,inputName:"agentId",readOnly:!0,value:e??"",onChange:()=>{},helperText:"This is the Boomi Agent ID for your agent and cannot be changed."})]}),w.jsxs("div",{className:"space-y-2",children:[w.jsx("label",{className:"boomi-form-label",children:"Allowed Origins"}),w.jsxs("div",{className:"space-y-2",children:[h.length===0&&w.jsx("div",{className:"text-xs opacity-70",children:"No origins selected."}),h.map((Q,W)=>{const V=new Set(h.map(X=>X.trim()).filter(Boolean)),K=(i??[]).filter(X=>X===Q||!V.has(X)),q=K.includes(Q);return w.jsxs("div",{className:"flex items-center gap-2",children:[w.jsxs("select",{className:"boomi-input w-full rounded-md p-2 text-sm",value:Q,onChange:X=>B(W,X.target.value),children:[!Q&&w.jsx("option",{value:"",children:"Select an origin"}),q?null:Q?w.jsx("option",{value:Q,children:Q}):null,K.map(X=>w.jsx("option",{value:X,children:X},X))]}),w.jsx("span",{role:"button",tabIndex:0,className:"text-red-500 text-lg cursor-pointer",onClick:()=>G(W),onKeyDown:X=>{(X.key==="Enter"||X.key===" ")&&G(W)},"aria-label":"Remove origin",children:w.jsx(uo,{})})]},`${Q}-${W}`)})]}),_&&w.jsx("div",{className:"text-xs text-red-500",children:_}),w.jsxs("div",{className:"flex items-center gap-2",children:[w.jsx(rt,{toggle:!1,primary:!1,showIcon:!1,label:"Add Row",onClick:F}),w.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[w.jsx("input",{className:"boomi-input w-full rounded-md p-2 text-sm",value:p,onChange:Q=>g(Q.target.value),placeholder:"https://example.com"}),w.jsx("button",{type:"button",className:"boomi-btn-primary px-2 py-2 text-xs",onClick:z,disabled:b,"aria-label":"Add new origin",children:w.jsx(Hr,{})})]})]}),w.jsx("div",{className:"text-xs opacity-70",children:"Pick from existing CORS origins or add a new one here."})]})]}),w.jsxs("div",{className:"space-y-3",children:[w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-sm font-semibold",children:"UI Configuration"}),w.jsx("div",{className:"text-xs opacity-70",children:"Optional. Use JSON to customize themes, layout, and agent UI."})]}),w.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-[var(--boomi-card-bg)] p-1 border border-[var(--boomi-card-border)]",children:[w.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${D==="builder"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>k("builder"),children:"Builder"}),w.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${D==="json"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>k("json"),children:"JSON"})]})]}),D==="builder"?w.jsx(rL,{embedType:R.embedType,agentIds:$,configRaw:E,onChangeConfig:Q=>{const W=JSON.stringify(Q,null,2);W!==E&&T(W)},syncFromConfig:!1,availableAgents:l},y):w.jsxs(w.Fragment,{children:[w.jsx(iL,{label:"Config (JSON)",value:E,placeholder:P,error:C,onChange:T}),w.jsx("div",{className:"flex justify-end",children:w.jsx(rt,{toggle:!1,primary:!1,showIcon:!1,label:"Insert Starter Config",onClick:()=>T(P)})})]})]})]})},RH=({isOpen:t,agentId:e,tokenId:n,agents:o,primaryAccountId:i,onTokenGenerated:r,onClose:s})=>{const[c,a]=O.useState(!1),[u,l]=O.useState(!1),[d,f]=O.useState("single"),[h,m]=O.useState([]),[p,g]=O.useState(""),[b,v]=O.useState(!1),[E,T]=O.useState(null),[y,x]=O.useState(null),{createAgent:_}=oL(),N=O.useMemo(()=>(o??[]).map(A=>{var R;return{id:A.agentId,label:((R=A.label)==null?void 0:R.trim())||A.agentId,tokenIds:A.publicTokenIds??[]}}),[o]);O.useEffect(()=>{var A;if(!t)return;const S=e||((A=N[0])==null?void 0:A.id)||"";g(S),m(S?[S]:[]),T(null),x(null),e&&f("single")},[t,e,N]);const C=S=>{m(A=>A.includes(S)?A.filter(R=>R!==S):[...A,S])},L=async()=>{const S=n??y;if(!i||!S)return;const A=h.filter(R=>{var P;const $=N.find(U=>U.id===R);return!((P=$==null?void 0:$.tokenIds)!=null&&P.includes(S))});if(A.length===0){T("Token already attached to selected agents.");return}v(!0),T(null);try{await Promise.all(A.map(R=>_({primaryAccountId:i,agentId:R,publicTokenIds:[S]}))),T("Token attached to selected agents.")}catch(R){T((R==null?void 0:R.message)||"Failed to attach token to selected agents.")}finally{v(!1)}},D=async()=>{var A;if(!i)return;const S=d==="single"?p:h[0];if(!S){T("Select at least one agent first.");return}v(!0),T(null);try{const $=((A=(await _({primaryAccountId:i,agentId:S,createToken:!0})).createdToken)==null?void 0:A.tokenId)||null;if(!$)throw new Error("Token generation failed.");x($),r==null||r($);const P=d==="single"?[]:h.filter(U=>U!==S);P.length>0&&await Promise.all(P.map(U=>_({primaryAccountId:i,agentId:U,publicTokenIds:[$]}))),T("Token generated and attached to selected agents.")}catch(R){T((R==null?void 0:R.message)||"Failed to generate token.")}finally{v(!1)}},k=O.useMemo(()=>{const S=n??y;return S?`<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@boomi/embedkit-cdn/embedkit-cdn.css" />
|
|
2107
2107
|
<script>
|
|
2108
2108
|
window.BoomiEmbed = {
|
|
2109
2109
|
publicToken: "${S}",
|
|
2110
|
-
agentId: "${
|
|
2110
|
+
agentId: "${p||e||""||"project-id"}",
|
|
2111
2111
|
mountId: "boomi-agent",
|
|
2112
2112
|
serverBase: "https://api.boomi.space/api/v1"
|
|
2113
2113
|
};
|
|
2114
2114
|
<\/script>
|
|
2115
|
-
<script src="https://cdn.
|
|
2116
|
-
<div id="boomi-agent"></div>`},[e,n,y,d,h,p]),I=async(S,A)=>{try{await navigator.clipboard.writeText(S),A(!0),setTimeout(()=>A(!1),2e3)}catch{A(!1)}};return t?w.jsx(no,{isOpen:t,title:"Public Token",description:"Use this token in your embed snippet. Store it securely in your app configuration.",onClose:s,onSubmit:s,showSaveButton:!0,showCancelButton:!1,submitLabel:"Close",children:w.jsxs("div",{className:"space-y-3",children:[w.jsxs("div",{children:[w.jsx("label",{className:"boomi-form-label",children:"Token"}),w.jsxs("div",{className:"flex gap-2 items-center",children:[w.jsx("input",{className:"boomi-input w-full rounded-md p-2 font-mono text-xs",readOnly:!0,value:n??y??""}),w.jsx(rt,{toggle:!1,primary:!1,showIcon:!1,label:c?"Copied":"Copy",onClick:()=>{const S=n??y;S&&I(S,a)}})]}),!n&&w.jsx("div",{className:"mt-2",children:w.jsx(rt,{toggle:!1,primary:!0,showIcon:!1,label:b?"Generating…":"Generate Token",onClick:D,disabled:!i||b})})]}),!e&&w.jsxs("div",{children:[w.jsx("label",{className:"boomi-form-label",children:"Embed Type"}),w.jsxs("select",{className:"boomi-input w-full rounded-md p-2 text-sm",value:d,onChange:S=>f(S.target.value),children:[w.jsx("option",{value:"single",children:"Single Agent"}),w.jsx("option",{value:"tiles",children:"Multi-Agent (Tiles)"}),w.jsx("option",{value:"list",children:"Multi-Agent (Pill + Modal List)"})]})]}),d!=="single"?w.jsxs("div",{children:[w.jsx("label",{className:"boomi-form-label",children:"Agents"}),w.jsx("div",{className:"boomi-input w-full rounded-md p-2 text-sm space-y-2 max-h-48 overflow-auto",children:N.length===0?w.jsx("div",{className:"text-xs opacity-70",children:"No agents available"}):N.map(S=>w.jsxs("label",{className:"flex items-center gap-2",children:[w.jsx("input",{type:"checkbox",checked:h.includes(S.id),onChange:()=>C(S.id)}),w.jsx("span",{className:"text-xs",children:S.label})]},S.id))}),w.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[w.jsx(rt,{toggle:!1,primary:!1,showIcon:!1,label:b?"Attaching…":"Attach Existing Token to Selected Agents",onClick:L,disabled:!i||!(n??y)||h.length===0||b}),E&&w.jsx("span",{className:"text-xs opacity-70",children:E})]})]}):null,w.jsxs("div",{children:[w.jsx("label",{className:"boomi-form-label",children:"Embed Snippet"}),w.jsx("textarea",{className:"boomi-input w-full rounded-md p-2 font-mono text-xs min-h-[140px]",readOnly:!0,value:k}),w.jsx("div",{className:"mt-2",children:w.jsx(rt,{toggle:!1,primary:!1,showIcon:!1,label:u?"Copied":"Copy Snippet",onClick:()=>I(k,l)})})]})]})}):null},Ah=10,OH=({componentKey:t,primaryAccountId:e})=>{const{boomiConfig:n,tenantId:o,setPageIsLoading:i}=yt(),r=e??o??(n==null?void 0:n.tenantId),s=`agents-view:${t}`,{listAgents:c,listAvailableAgents:a,createAgent:u,deleteAgent:l}=oL(),{getCorsConfig:d,createCorsConfig:f,updateCorsConfig:h}=Wu(),[m,p]=O.useState([]),[g,b]=O.useState([]),[v,E]=O.useState([]),[T,y]=O.useState(!1),[x,_]=O.useState(null),[N,C]=O.useState(""),[L,D]=O.useState(1),[k,I]=O.useState("off"),[S,A]=O.useState(!1),[R,$]=O.useState(!1),[P,U]=O.useState(!1),[F,B]=O.useState(!1),[G,z]=O.useState(null),[Q,W]=O.useState(null),[V,K]=O.useState(null),[q,X]=O.useState(!1),[J,se]=O.useState(!1),[Y,he]=O.useState({add:!1,edit:!1,delete:!1});O.useEffect(()=>{try{const oe=localStorage.getItem(s);(oe==="on"||oe==="off")&&I(oe)}catch{}},[s]);const ie=O.useCallback(()=>{I(oe=>{const ce=oe==="on"?"off":"on";try{localStorage.setItem(s,ce)}catch{}return ce})},[s]),ye=oe=>{he(ce=>({...ce,[oe]:!0})),setTimeout(()=>he(ce=>({...ce,[oe]:!1})),3e3)},Ae=()=>r||(_("primaryAccountId is required to manage agents."),null),Re=O.useCallback(async()=>{const oe=Ae();if(oe){y(!0),_(null);try{const ce=await c({primaryAccountId:oe,includeDetails:!0});p(ce.items??[])}catch(ce){const Ne=(ce==null?void 0:ce.message)||"Failed to load agents";ge.error({err:ce},"[Agents] list failed"),_(Ne)}finally{y(!1)}}},[c,r]),Ye=O.useCallback(async()=>{const oe=Ae();if(oe)try{const ce=await d({primaryAccountId:oe});E(ce.allowedOrigins??[])}catch(ce){if((ce==null?void 0:ce.status)===404){E([]);return}ge.error({err:ce},"[Agents] cors list failed"),E([])}},[d,r]),ze=O.useCallback(async oe=>{const ce=Ae();if(!ce)return;const Ne=Array.from(new Set([...v??[],oe]));try{const ke=await h({primaryAccountId:ce,allowedOrigins:Ne});E(ke.allowedOrigins??Ne)}catch(ke){if((ke==null?void 0:ke.status)===404){const Fe=await f({primaryAccountId:ce,allowedOrigins:Ne});E(Fe.allowedOrigins??Ne);return}throw ke}},[f,h,v,r]),Ke=O.useCallback(async()=>{const oe=Ae();if(oe)try{const ce=await a({primaryAccountId:oe});b(ce.items??[])}catch(ce){ge.error({err:ce},"[Agents] available list failed"),b([])}},[a,r]);O.useEffect(()=>{Re()},[Re]),O.useEffect(()=>{Ye()},[Ye]),O.useEffect(()=>{Ke()},[Ke]),O.useEffect(()=>{S&&Ke()},[S,Ke]),O.useEffect(()=>{R&&Ke()},[R,Ke]);const Pe=O.useMemo(()=>{const oe=N.trim().toLowerCase();return oe?m.filter(ce=>{var ke;const Ne=((ke=ce.label)==null?void 0:ke.toLowerCase())??"";return ce.agentId.toLowerCase().includes(oe)||Ne.includes(oe)}):m},[m,N]),Xe=Math.max(1,Math.ceil(Pe.length/Ah)),Ce=Pe.slice((L-1)*Ah,L*Ah),Ue=O.useMemo(()=>g.map(oe=>({id:oe.id,label:oe.name||oe.id})),[g]),fe=async oe=>{var Ne,ke;const ce=Ae();if(ce){X(!0),i(!0);try{const Fe=await u({primaryAccountId:ce,agentId:oe.agentId,boomiAgentId:oe.boomiAgentId,label:oe.label,allowedOrigins:oe.allowedOrigins,config:oe.config,createToken:!0});await Re(),A(!1),ye("add");const $e=((Ne=Fe.createdToken)==null?void 0:Ne.tokenId)||((ke=Fe.agent.publicTokenIds)==null?void 0:ke[Fe.agent.publicTokenIds.length-1])||null;z(Fe.agent.agentId),W($e),B(!0)}catch(Fe){ge.error({err:Fe},"[Agents] create failed"),_((Fe==null?void 0:Fe.message)||"Failed to create agent")}finally{X(!1),i(!1)}}},Ee=async oe=>{const ce=Ae();if(ce){X(!0),i(!0);try{await u({primaryAccountId:ce,agentId:oe.agentId,boomiAgentId:V==null?void 0:V.boomiAgentId,label:oe.label,allowedOrigins:oe.allowedOrigins,config:oe.config}),await Re(),$(!1),K(null),ye("edit")}catch(Ne){ge.error({err:Ne},"[Agents] edit failed"),_((Ne==null?void 0:Ne.message)||"Failed to update agent")}finally{X(!1),i(!1)}}},we=async()=>{if(!G)return;const oe=Ae();if(oe){se(!0),i(!0);try{await l({primaryAccountId:oe,agentId:G}),await Re(),U(!1),z(null),ye("delete")}catch(ce){ge.error({err:ce},"[Agents] delete failed"),_((ce==null?void 0:ce.message)||"Failed to delete agent")}finally{se(!1),i(!1)}}},Te=({agent:oe})=>{var Ne;const ce=((Ne=oe.publicTokenIds)==null?void 0:Ne[oe.publicTokenIds.length-1])||null;return w.jsxs(nr,{children:[w.jsx(Ft.Item,{children:({active:ke})=>w.jsxs("button",{onClick:()=>{K(oe),$(!0)},className:"boomi-menu-item","data-headlessui-state":ke?"active":void 0,children:[w.jsx(fu,{className:"boomi-menu-icon"}),"Edit"]})}),w.jsx(Ft.Item,{children:({active:ke})=>w.jsxs("button",{onClick:()=>{z(oe.agentId),W(ce),B(!0)},className:"boomi-menu-item","data-headlessui-state":ke?"active":void 0,children:[w.jsx(iS,{className:"boomi-menu-icon"}),"View Embed"]})}),w.jsx("div",{className:"boomi-menu-divider"}),w.jsx(Ft.Item,{children:({active:ke})=>w.jsxs("button",{onClick:()=>{z(oe.agentId),U(!0)},className:"boomi-menu-item boomi-menu-item--danger","data-headlessui-state":ke?"active":void 0,disabled:J,children:[w.jsx(uo,{className:"boomi-menu-icon"}),"Delete"]})})]})},ue=x||null;return w.jsxs(w.Fragment,{children:[Y.add&&w.jsx(lo,{type:"success",content:"Agent created."}),Y.edit&&w.jsx(lo,{type:"success",content:"Agent updated."}),Y.delete&&w.jsx(lo,{type:"success",content:"Agent deleted."}),w.jsx(LH,{isOpen:S,onClose:()=>A(!1),onSubmit:fe,isSaving:q,defaultOrigins:v,availableAgents:Ue}),w.jsx(IH,{isOpen:R,agentId:(V==null?void 0:V.agentId)??null,label:(V==null?void 0:V.label)??null,allowedOrigins:(V==null?void 0:V.allowedOrigins)??null,defaultOrigins:v,config:(V==null?void 0:V.config)??null,onAddOrigin:ze,onClose:()=>{$(!1),K(null)},onSubmit:Ee,isSaving:q,availableAgents:Ue}),w.jsx(kH,{isOpen:P,agentId:G,onClose:()=>{U(!1),z(null)},onConfirm:we,isDeleting:J}),w.jsx(RH,{isOpen:F,agentId:G,tokenId:Q,agents:m,primaryAccountId:r??void 0,onTokenGenerated:oe=>W(oe),onClose:()=>{B(!1),W(null)}}),w.jsxs("div",{className:"w-full h-full p-6",children:[w.jsxs("div",{className:"space-y-2",children:[w.jsx("h1",{className:"text-2xl font-semibold",children:"Projects"}),w.jsx("p",{className:"text-sm opacity-70",children:"Create and manage embedded agent groups, including tokens, allowed origins, and launch options."})]}),w.jsxs("div",{className:"flex items-end gap-3 mb-4 mt-4",children:[w.jsx("div",{className:"flex flex-wrap items-end gap-3 flex-1 min-w-0",children:w.jsx("div",{className:"min-w-[220px]",children:w.jsx(Fr,{searchCallback:oe=>{C(oe),D(1)}})})}),w.jsxs("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:[w.jsx(rt,{toggle:!0,primary:!1,viewLoc:s,onClass:"flex w-full justify-center rounded-md px-2 py-2 text-xs font-semibold leading-6 shadow-md transition-colors duration-100",showIcon:!0,label:"View",icon:w.jsx(Kf,{className:"h-5 w-5"}),onIcon:w.jsx(Gf,{className:"h-5 w-5"}),onClick:ie}),w.jsx(rt,{toggle:!1,primary:!0,showIcon:!0,label:"Add Project",icon:w.jsx(Hr,{className:"h-5 w-5"}),onClick:()=>A(!0)})]})]}),ue&&w.jsx("div",{className:"boomi-notice boomi-notice--error text-sm",children:ue}),k==="off"?w.jsxs(w.Fragment,{children:[w.jsx("ul",{role:"list",className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-x-6 gap-y-8",children:T?w.jsx("div",{className:"col-span-full flex justify-center items-center",children:w.jsx(on,{})}):Ce.length>0?Ce.map(oe=>{var Ne;const ce=((Ne=oe.label)==null?void 0:Ne.trim())||"Untitled Agent";return w.jsxs("li",{className:"boomi-card",children:[w.jsx("div",{className:"flex gap-4 p-4",children:w.jsxs("div",{className:"flex flex-col w-full",children:[w.jsx("h3",{className:"text-base font-semibold break-words truncate overflow-hidden pr-2",children:ce}),w.jsx("p",{className:"text-xs mt-1 opacity-70 break-words overflow-hidden",children:oe.agentId})]})}),w.jsxs("div",{className:"flex w-full p-2 justify-end items-center gap-x-2 relative overflow-visible",children:[w.jsx(rt,{toggle:!1,primary:!0,showIcon:!1,label:"Edit",onClick:()=>{K(oe),$(!0)}}),w.jsx(Te,{agent:oe})]})]},oe.agentId)}):w.jsx("div",{className:"col-span-full flex justify-center items-center",children:w.jsx("p",{className:"text-gray-500 text-xs",children:"No agents found."})})}),!T&&Xe>1&&w.jsx(jr,{currentPage:L,totalPages:Xe,onPageChange:oe=>D(oe)})]}):w.jsxs(w.Fragment,{children:[w.jsxs("table",{className:"w-full table-auto rounded-lg shadow-sm",children:[w.jsx("thead",{className:"boomi-table-header",children:w.jsxs("tr",{children:[w.jsx("th",{className:"py-3 px-4 text-left text-sm font-semibold",children:"Agent"}),w.jsx("th",{className:"py-3 px-4 text-left text-sm font-semibold",children:"Name"}),w.jsx("th",{className:"py-3 px-4 text-left text-sm font-semibold",children:"Agent ID"}),w.jsx("th",{className:"py-3 px-4 text-right text-sm font-semibold",children:"Actions"})]})}),w.jsx("tbody",{className:"divide-y",children:T?w.jsx("tr",{children:w.jsx("td",{colSpan:3,children:w.jsx("div",{className:"flex justify-center items-center py-6",children:w.jsx(on,{})})})}):Ce.length>0?Ce.map(oe=>{var Ne;const ce=((Ne=oe.label)==null?void 0:Ne.trim())||"Untitled Agent";return w.jsxs("tr",{className:"boomi-table-row",children:[w.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2 max-w-xs break-words",children:ce}),w.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2 max-w-xs break-words",children:oe.agentId}),w.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2",children:w.jsx("div",{className:"flex justify-end",children:w.jsx(Te,{agent:oe})})})]},oe.agentId)}):w.jsx("tr",{children:w.jsx("td",{colSpan:3,children:w.jsx("div",{className:"flex justify-center items-center py-4",children:w.jsx("p",{className:"text-gray-500 text-xs",children:"No agents found."})})})})})]}),!T&&Xe>1&&w.jsx("div",{className:"mt-4 flex justify-end",children:w.jsx(jr,{currentPage:L,totalPages:Xe,onPageChange:D})})]})]})]})};var yc={exports:{}};/*!
|
|
2115
|
+
<script src="https://cdn.jsdelivr.net/npm/@boomi/embedkit-cdn/embedkit-cdn.umd.cjs" async><\/script>
|
|
2116
|
+
<div id="boomi-agent"></div>`:""},[e,n,y,d,h,p]),I=async(S,A)=>{try{await navigator.clipboard.writeText(S),A(!0),setTimeout(()=>A(!1),2e3)}catch{A(!1)}};return t?w.jsx(no,{isOpen:t,title:"Public Token",description:"Use this token in your embed snippet. Store it securely in your app configuration.",onClose:s,onSubmit:s,showSaveButton:!0,showCancelButton:!1,submitLabel:"Close",children:w.jsxs("div",{className:"space-y-3",children:[w.jsxs("div",{children:[w.jsx("label",{className:"boomi-form-label",children:"Token"}),w.jsxs("div",{className:"flex gap-2 items-center",children:[w.jsx("input",{className:"boomi-input w-full rounded-md p-2 font-mono text-xs",readOnly:!0,value:n??y??""}),w.jsx(rt,{toggle:!1,primary:!1,showIcon:!1,label:c?"Copied":"Copy",onClick:()=>{const S=n??y;S&&I(S,a)}})]}),!n&&w.jsx("div",{className:"mt-2",children:w.jsx(rt,{toggle:!1,primary:!0,showIcon:!1,label:b?"Generating…":"Generate Token",onClick:D,disabled:!i||b})})]}),!e&&w.jsxs("div",{children:[w.jsx("label",{className:"boomi-form-label",children:"Embed Type"}),w.jsxs("select",{className:"boomi-input w-full rounded-md p-2 text-sm",value:d,onChange:S=>f(S.target.value),children:[w.jsx("option",{value:"single",children:"Single Agent"}),w.jsx("option",{value:"tiles",children:"Multi-Agent (Tiles)"}),w.jsx("option",{value:"list",children:"Multi-Agent (Pill + Modal List)"})]})]}),d!=="single"?w.jsxs("div",{children:[w.jsx("label",{className:"boomi-form-label",children:"Agents"}),w.jsx("div",{className:"boomi-input w-full rounded-md p-2 text-sm space-y-2 max-h-48 overflow-auto",children:N.length===0?w.jsx("div",{className:"text-xs opacity-70",children:"No agents available"}):N.map(S=>w.jsxs("label",{className:"flex items-center gap-2",children:[w.jsx("input",{type:"checkbox",checked:h.includes(S.id),onChange:()=>C(S.id)}),w.jsx("span",{className:"text-xs",children:S.label})]},S.id))}),w.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[w.jsx(rt,{toggle:!1,primary:!1,showIcon:!1,label:b?"Attaching…":"Attach Existing Token to Selected Agents",onClick:L,disabled:!i||!(n??y)||h.length===0||b}),E&&w.jsx("span",{className:"text-xs opacity-70",children:E})]})]}):null,w.jsxs("div",{children:[w.jsx("label",{className:"boomi-form-label",children:"Embed Snippet"}),w.jsx("textarea",{className:"boomi-input w-full rounded-md p-2 font-mono text-xs min-h-[140px]",readOnly:!0,value:k}),w.jsx("div",{className:"mt-2",children:w.jsx(rt,{toggle:!1,primary:!1,showIcon:!1,label:u?"Copied":"Copy Snippet",onClick:()=>I(k,l)})})]})]})}):null},Ah=10,OH=({componentKey:t,primaryAccountId:e})=>{const{boomiConfig:n,tenantId:o,setPageIsLoading:i}=yt(),r=e??o??(n==null?void 0:n.tenantId),s=`agents-view:${t}`,{listAgents:c,listAvailableAgents:a,createAgent:u,deleteAgent:l}=oL(),{getCorsConfig:d,createCorsConfig:f,updateCorsConfig:h}=Wu(),[m,p]=O.useState([]),[g,b]=O.useState([]),[v,E]=O.useState([]),[T,y]=O.useState(!1),[x,_]=O.useState(null),[N,C]=O.useState(""),[L,D]=O.useState(1),[k,I]=O.useState("off"),[S,A]=O.useState(!1),[R,$]=O.useState(!1),[P,U]=O.useState(!1),[F,B]=O.useState(!1),[G,z]=O.useState(null),[Q,W]=O.useState(null),[V,K]=O.useState(null),[q,X]=O.useState(!1),[J,se]=O.useState(!1),[Y,he]=O.useState({add:!1,edit:!1,delete:!1});O.useEffect(()=>{try{const oe=localStorage.getItem(s);(oe==="on"||oe==="off")&&I(oe)}catch{}},[s]);const ie=O.useCallback(()=>{I(oe=>{const ce=oe==="on"?"off":"on";try{localStorage.setItem(s,ce)}catch{}return ce})},[s]),ye=oe=>{he(ce=>({...ce,[oe]:!0})),setTimeout(()=>he(ce=>({...ce,[oe]:!1})),3e3)},Ae=()=>r||(_("primaryAccountId is required to manage agents."),null),Re=O.useCallback(async()=>{const oe=Ae();if(oe){y(!0),_(null);try{const ce=await c({primaryAccountId:oe,includeDetails:!0});p(ce.items??[])}catch(ce){const Ne=(ce==null?void 0:ce.message)||"Failed to load agents";ge.error({err:ce},"[Agents] list failed"),_(Ne)}finally{y(!1)}}},[c,r]),Ye=O.useCallback(async()=>{const oe=Ae();if(oe)try{const ce=await d({primaryAccountId:oe});E(ce.allowedOrigins??[])}catch(ce){if((ce==null?void 0:ce.status)===404){E([]);return}ge.error({err:ce},"[Agents] cors list failed"),E([])}},[d,r]),ze=O.useCallback(async oe=>{const ce=Ae();if(!ce)return;const Ne=Array.from(new Set([...v??[],oe]));try{const ke=await h({primaryAccountId:ce,allowedOrigins:Ne});E(ke.allowedOrigins??Ne)}catch(ke){if((ke==null?void 0:ke.status)===404){const Fe=await f({primaryAccountId:ce,allowedOrigins:Ne});E(Fe.allowedOrigins??Ne);return}throw ke}},[f,h,v,r]),Ke=O.useCallback(async()=>{const oe=Ae();if(oe)try{const ce=await a({primaryAccountId:oe});b(ce.items??[])}catch(ce){ge.error({err:ce},"[Agents] available list failed"),b([])}},[a,r]);O.useEffect(()=>{Re()},[Re]),O.useEffect(()=>{Ye()},[Ye]),O.useEffect(()=>{Ke()},[Ke]),O.useEffect(()=>{S&&Ke()},[S,Ke]),O.useEffect(()=>{R&&Ke()},[R,Ke]);const Pe=O.useMemo(()=>{const oe=N.trim().toLowerCase();return oe?m.filter(ce=>{var ke;const Ne=((ke=ce.label)==null?void 0:ke.toLowerCase())??"";return ce.agentId.toLowerCase().includes(oe)||Ne.includes(oe)}):m},[m,N]),Xe=Math.max(1,Math.ceil(Pe.length/Ah)),Ce=Pe.slice((L-1)*Ah,L*Ah),Ue=O.useMemo(()=>g.map(oe=>({id:oe.id,label:oe.name||oe.id})),[g]),fe=async oe=>{var Ne,ke;const ce=Ae();if(ce){X(!0),i(!0);try{const Fe=await u({primaryAccountId:ce,agentId:oe.agentId,boomiAgentId:oe.boomiAgentId,label:oe.label,allowedOrigins:oe.allowedOrigins,config:oe.config,createToken:!0});await Re(),A(!1),ye("add");const $e=((Ne=Fe.createdToken)==null?void 0:Ne.tokenId)||((ke=Fe.agent.publicTokenIds)==null?void 0:ke[Fe.agent.publicTokenIds.length-1])||null;z(Fe.agent.agentId),W($e),B(!0)}catch(Fe){ge.error({err:Fe},"[Agents] create failed"),_((Fe==null?void 0:Fe.message)||"Failed to create agent")}finally{X(!1),i(!1)}}},Ee=async oe=>{const ce=Ae();if(ce){X(!0),i(!0);try{await u({primaryAccountId:ce,agentId:oe.agentId,boomiAgentId:V==null?void 0:V.boomiAgentId,label:oe.label,allowedOrigins:oe.allowedOrigins,config:oe.config}),await Re(),$(!1),K(null),ye("edit")}catch(Ne){ge.error({err:Ne},"[Agents] edit failed"),_((Ne==null?void 0:Ne.message)||"Failed to update agent")}finally{X(!1),i(!1)}}},we=async()=>{if(!G)return;const oe=Ae();if(oe){se(!0),i(!0);try{await l({primaryAccountId:oe,agentId:G}),await Re(),U(!1),z(null),ye("delete")}catch(ce){ge.error({err:ce},"[Agents] delete failed"),_((ce==null?void 0:ce.message)||"Failed to delete agent")}finally{se(!1),i(!1)}}},Te=({agent:oe})=>{var Ne;const ce=((Ne=oe.publicTokenIds)==null?void 0:Ne[oe.publicTokenIds.length-1])||null;return w.jsxs(nr,{children:[w.jsx(Ft.Item,{children:({active:ke})=>w.jsxs("button",{onClick:()=>{K(oe),$(!0)},className:"boomi-menu-item","data-headlessui-state":ke?"active":void 0,children:[w.jsx(fu,{className:"boomi-menu-icon"}),"Edit"]})}),w.jsx(Ft.Item,{children:({active:ke})=>w.jsxs("button",{onClick:()=>{z(oe.agentId),W(ce),B(!0)},className:"boomi-menu-item","data-headlessui-state":ke?"active":void 0,children:[w.jsx(iS,{className:"boomi-menu-icon"}),"View Embed"]})}),w.jsx("div",{className:"boomi-menu-divider"}),w.jsx(Ft.Item,{children:({active:ke})=>w.jsxs("button",{onClick:()=>{z(oe.agentId),U(!0)},className:"boomi-menu-item boomi-menu-item--danger","data-headlessui-state":ke?"active":void 0,disabled:J,children:[w.jsx(uo,{className:"boomi-menu-icon"}),"Delete"]})})]})},ue=x||null;return w.jsxs(w.Fragment,{children:[Y.add&&w.jsx(lo,{type:"success",content:"Agent created."}),Y.edit&&w.jsx(lo,{type:"success",content:"Agent updated."}),Y.delete&&w.jsx(lo,{type:"success",content:"Agent deleted."}),w.jsx(LH,{isOpen:S,onClose:()=>A(!1),onSubmit:fe,isSaving:q,defaultOrigins:v,availableAgents:Ue}),w.jsx(IH,{isOpen:R,agentId:(V==null?void 0:V.agentId)??null,label:(V==null?void 0:V.label)??null,allowedOrigins:(V==null?void 0:V.allowedOrigins)??null,defaultOrigins:v,config:(V==null?void 0:V.config)??null,onAddOrigin:ze,onClose:()=>{$(!1),K(null)},onSubmit:Ee,isSaving:q,availableAgents:Ue}),w.jsx(kH,{isOpen:P,agentId:G,onClose:()=>{U(!1),z(null)},onConfirm:we,isDeleting:J}),w.jsx(RH,{isOpen:F,agentId:G,tokenId:Q,agents:m,primaryAccountId:r??void 0,onTokenGenerated:oe=>W(oe),onClose:()=>{B(!1),W(null)}}),w.jsxs("div",{className:"w-full h-full p-6",children:[w.jsxs("div",{className:"space-y-2",children:[w.jsx("h1",{className:"text-2xl font-semibold",children:"Projects"}),w.jsx("p",{className:"text-sm opacity-70",children:"Create and manage embedded agent groups, including tokens, allowed origins, and launch options."})]}),w.jsxs("div",{className:"flex items-end gap-3 mb-4 mt-4",children:[w.jsx("div",{className:"flex flex-wrap items-end gap-3 flex-1 min-w-0",children:w.jsx("div",{className:"min-w-[220px]",children:w.jsx(Fr,{searchCallback:oe=>{C(oe),D(1)}})})}),w.jsxs("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:[w.jsx(rt,{toggle:!0,primary:!1,viewLoc:s,onClass:"flex w-full justify-center rounded-md px-2 py-2 text-xs font-semibold leading-6 shadow-md transition-colors duration-100",showIcon:!0,label:"View",icon:w.jsx(Kf,{className:"h-5 w-5"}),onIcon:w.jsx(Gf,{className:"h-5 w-5"}),onClick:ie}),w.jsx(rt,{toggle:!1,primary:!0,showIcon:!0,label:"Add Project",icon:w.jsx(Hr,{className:"h-5 w-5"}),onClick:()=>A(!0)})]})]}),ue&&w.jsx("div",{className:"boomi-notice boomi-notice--error text-sm",children:ue}),k==="off"?w.jsxs(w.Fragment,{children:[w.jsx("ul",{role:"list",className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-x-6 gap-y-8",children:T?w.jsx("div",{className:"col-span-full flex justify-center items-center",children:w.jsx(on,{})}):Ce.length>0?Ce.map(oe=>{var Ne;const ce=((Ne=oe.label)==null?void 0:Ne.trim())||"Untitled Agent";return w.jsxs("li",{className:"boomi-card",children:[w.jsx("div",{className:"flex gap-4 p-4",children:w.jsxs("div",{className:"flex flex-col w-full",children:[w.jsx("h3",{className:"text-base font-semibold break-words truncate overflow-hidden pr-2",children:ce}),w.jsx("p",{className:"text-xs mt-1 opacity-70 break-words overflow-hidden",children:oe.agentId})]})}),w.jsxs("div",{className:"flex w-full p-2 justify-end items-center gap-x-2 relative overflow-visible",children:[w.jsx(rt,{toggle:!1,primary:!0,showIcon:!1,label:"Edit",onClick:()=>{K(oe),$(!0)}}),w.jsx(Te,{agent:oe})]})]},oe.agentId)}):w.jsx("div",{className:"col-span-full flex justify-center items-center",children:w.jsx("p",{className:"text-gray-500 text-xs",children:"No agents found."})})}),!T&&Xe>1&&w.jsx(jr,{currentPage:L,totalPages:Xe,onPageChange:oe=>D(oe)})]}):w.jsxs(w.Fragment,{children:[w.jsxs("table",{className:"w-full table-auto rounded-lg shadow-sm",children:[w.jsx("thead",{className:"boomi-table-header",children:w.jsxs("tr",{children:[w.jsx("th",{className:"py-3 px-4 text-left text-sm font-semibold",children:"Agent"}),w.jsx("th",{className:"py-3 px-4 text-left text-sm font-semibold",children:"Name"}),w.jsx("th",{className:"py-3 px-4 text-left text-sm font-semibold",children:"Agent ID"}),w.jsx("th",{className:"py-3 px-4 text-right text-sm font-semibold",children:"Actions"})]})}),w.jsx("tbody",{className:"divide-y",children:T?w.jsx("tr",{children:w.jsx("td",{colSpan:3,children:w.jsx("div",{className:"flex justify-center items-center py-6",children:w.jsx(on,{})})})}):Ce.length>0?Ce.map(oe=>{var Ne;const ce=((Ne=oe.label)==null?void 0:Ne.trim())||"Untitled Agent";return w.jsxs("tr",{className:"boomi-table-row",children:[w.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2 max-w-xs break-words",children:ce}),w.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2 max-w-xs break-words",children:oe.agentId}),w.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2",children:w.jsx("div",{className:"flex justify-end",children:w.jsx(Te,{agent:oe})})})]},oe.agentId)}):w.jsx("tr",{children:w.jsx("td",{colSpan:3,children:w.jsx("div",{className:"flex justify-center items-center py-4",children:w.jsx("p",{className:"text-gray-500 text-xs",children:"No agents found."})})})})})]}),!T&&Xe>1&&w.jsx("div",{className:"mt-4 flex justify-end",children:w.jsx(jr,{currentPage:L,totalPages:Xe,onPageChange:D})})]})]})]})};var yc={exports:{}};/*!
|
|
2117
2117
|
* sweetalert2 v11.23.0
|
|
2118
2118
|
* Released under the MIT License.
|
|
2119
2119
|
*/var ki=yc.exports,CT;function MH(){return CT||(CT=1,(function(t,e){(function(n,o){t.exports=o()})(ki,(function(){function n(M,j,H){if(typeof M=="function"?M===j:M.has(j))return arguments.length<3?j:H;throw new TypeError("Private element is not present on this object")}function o(M,j){if(j.has(M))throw new TypeError("Cannot initialize the same private elements twice on an object")}function i(M,j){return M.get(n(M,j))}function r(M,j,H){o(M,j),j.set(M,H)}function s(M,j,H){return M.set(n(M,j),H),H}const c=100,a={},u=()=>{a.previousActiveElement instanceof HTMLElement?(a.previousActiveElement.focus(),a.previousActiveElement=null):document.body&&document.body.focus()},l=M=>new Promise(j=>{if(!M)return j();const H=window.scrollX,Z=window.scrollY;a.restoreFocusTimeout=setTimeout(()=>{u(),j()},c),window.scrollTo(H,Z)}),d="swal2-",h=["container","shown","height-auto","iosfix","popup","modal","no-backdrop","no-transition","toast","toast-shown","show","hide","close","title","html-container","actions","confirm","deny","cancel","footer","icon","icon-content","image","input","file","range","select","radio","checkbox","label","textarea","inputerror","input-label","validation-message","progress-steps","active-progress-step","progress-step","progress-step-line","loader","loading","styled","top","top-start","top-end","top-left","top-right","center","center-start","center-end","center-left","center-right","bottom","bottom-start","bottom-end","bottom-left","bottom-right","grow-row","grow-column","grow-fullscreen","rtl","timer-progress-bar","timer-progress-bar-container","scrollbar-measure","icon-success","icon-warning","icon-info","icon-question","icon-error","draggable","dragging"].reduce((M,j)=>(M[j]=d+j,M),{}),p=["success","warning","info","question","error"].reduce((M,j)=>(M[j]=d+j,M),{}),g="SweetAlert2:",b=M=>M.charAt(0).toUpperCase()+M.slice(1),v=M=>{console.warn(`${g} ${typeof M=="object"?M.join(" "):M}`)},E=M=>{console.error(`${g} ${M}`)},T=[],y=M=>{T.includes(M)||(T.push(M),v(M))},x=(M,j=null)=>{y(`"${M}" is deprecated and will be removed in the next major release.${j?` Use "${j}" instead.`:""}`)},_=M=>typeof M=="function"?M():M,N=M=>M&&typeof M.toPromise=="function",C=M=>N(M)?M.toPromise():Promise.resolve(M),L=M=>M&&Promise.resolve(M)===M,D=()=>document.body.querySelector(`.${h.container}`),k=M=>{const j=D();return j?j.querySelector(M):null},I=M=>k(`.${M}`),S=()=>I(h.popup),A=()=>I(h.icon),R=()=>I(h["icon-content"]),$=()=>I(h.title),P=()=>I(h["html-container"]),U=()=>I(h.image),F=()=>I(h["progress-steps"]),B=()=>I(h["validation-message"]),G=()=>k(`.${h.actions} .${h.confirm}`),z=()=>k(`.${h.actions} .${h.cancel}`),Q=()=>k(`.${h.actions} .${h.deny}`),W=()=>I(h["input-label"]),V=()=>k(`.${h.loader}`),K=()=>I(h.actions),q=()=>I(h.footer),X=()=>I(h["timer-progress-bar"]),J=()=>I(h.close),se=`
|
package/dist/index.js
CHANGED
|
@@ -44335,19 +44335,17 @@ const X8 = ({
|
|
|
44335
44335
|
}
|
|
44336
44336
|
}, I = Ye(() => {
|
|
44337
44337
|
const A = n ?? w;
|
|
44338
|
-
|
|
44339
|
-
const T = p || e || "";
|
|
44340
|
-
return h.length, `<link rel="stylesheet" href="https://cdn.boomi.space/cdn/embedkit-cdn.css" />
|
|
44338
|
+
return A ? `<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@boomi/embedkit-cdn/embedkit-cdn.css" />
|
|
44341
44339
|
<script>
|
|
44342
44340
|
window.BoomiEmbed = {
|
|
44343
44341
|
publicToken: "${A}",
|
|
44344
|
-
agentId: "${
|
|
44342
|
+
agentId: "${p || e || "" || "project-id"}",
|
|
44345
44343
|
mountId: "boomi-agent",
|
|
44346
44344
|
serverBase: "https://api.boomi.space/api/v1"
|
|
44347
44345
|
};
|
|
44348
44346
|
<\/script>
|
|
44349
|
-
<script src="https://cdn.
|
|
44350
|
-
<div id="boomi-agent"></div
|
|
44347
|
+
<script src="https://cdn.jsdelivr.net/npm/@boomi/embedkit-cdn/embedkit-cdn.umd.cjs" async><\/script>
|
|
44348
|
+
<div id="boomi-agent"></div>` : "";
|
|
44351
44349
|
}, [e, n, w, u, h, p]), k = async (A, T) => {
|
|
44352
44350
|
try {
|
|
44353
44351
|
await navigator.clipboard.writeText(A), T(!0), setTimeout(() => T(!1), 2e3);
|
package/dist/index.umd.cjs
CHANGED
|
@@ -2103,17 +2103,17 @@ https://sweetalert2.github.io/#ajax-request`),W5(t),typeof t.title=="string"&&(t
|
|
|
2103
2103
|
* flows can match other admin mutation hooks.
|
|
2104
2104
|
*/const YB=()=>{const[t,e]=M.useState(!1),[n,o]=M.useState(null),{deleteCorsConfig:i}=Yc(),r=M.useCallback(async s=>{e(!0),o(null);try{await i(s),me.debug("[useDeleteCors] deleted config",{primaryAccountId:s.primaryAccountId})}catch(c){const a=(c==null?void 0:c.message)||"Failed to delete CORS configuration";throw me.error({err:c},"[useDeleteCors] failed"),o(a),c}finally{e(!1)}},[i]);return M.useMemo(()=>({deleteCors:r,isDeleting:t,error:n}),[r,n,t])},XB=({isOpen:t,onClose:e,onSubmit:n,isSaving:o,serverError:i})=>{const[r,s]=M.useState(""),[c,a]=M.useState(null);M.useEffect(()=>{t&&(s(""),a(null))},[t]);const d=async()=>{const l=r.trim();if(!l){a("Origin is required");return}a(null),await n(l)};return w.jsx(Jn,{isOpen:t,title:"Add Allowed Origin",description:"Add a new origin to the allowed list for this tenant.",onClose:e,onSubmit:d,submitLabel:o?"Saving...":"Add Origin",showSaveButton:!o,children:w.jsx(mn,{formName:"corsAdd",label:"Origin",required:!0,inputName:"origin",readOnly:!1,value:r,onChange:l=>s(l.target.value),placeholder:"https://app.example.com",helperText:'Use "null" to allow file:// and sandboxed iframe origins.',error:c||i||void 0})})},qB=({isOpen:t,origin:e,onClose:n,onSubmit:o,isSaving:i,serverError:r})=>{const[s,c]=M.useState(e??""),[a,d]=M.useState(null);M.useEffect(()=>{t&&(c(e??""),d(null))},[t,e]);const l=async()=>{const u=s.trim();if(!u){d("Origin is required");return}d(null),await o(u)};return w.jsx(Jn,{isOpen:t,title:"Edit Allowed Origin",description:"Update the selected origin for this tenant.",onClose:n,onSubmit:l,submitLabel:i?"Saving...":"Save Changes",showSaveButton:!i,children:w.jsx(mn,{formName:"corsEdit",label:"Origin",required:!0,inputName:"origin",readOnly:!1,value:s,onChange:u=>c(u.target.value),placeholder:"https://app.example.com",helperText:'Use "null" to allow file:// and sandboxed iframe origins.',error:a||r||void 0})})},ZB=({isOpen:t,origin:e,onClose:n,onConfirm:o,isDeleting:i})=>w.jsx(Jn,{isOpen:t,title:"Delete Allowed Origin",description:"Remove this origin from the allowed list for this tenant.",onClose:n,onSubmit:o,submitLabel:i?"Deleting...":"Delete",showSaveButton:!i,children:w.jsxs("p",{className:"text-sm",children:["Are you sure you want to remove"," ",w.jsx("span",{className:"font-semibold",children:e})," from the allowed origins?"]})});function eC(){const t=ro(),e=M.useCallback(async(p={})=>{const{signal:m,...g}=p;return t.get("/admin/redis/sessions",{params:g,signal:m})},[t]),n=M.useCallback(async(p={})=>{const{signal:m,...g}=p;return t.get("/admin/redis/sessions/all",{params:g,signal:m})},[t]),o=M.useCallback(async(p={})=>{const{signal:m,...g}=p;return t.get("/admin/redis/keys",{params:g,signal:m})},[t]),i=M.useCallback(async(p={})=>{const{signal:m,...g}=p;return t.get("/admin/redis/keys/all",{params:g,signal:m})},[t]),r=M.useCallback(async(p,m)=>t.get("/admin/redis/sub-accounts",{params:{tenantId:p},signal:m}),[t]),s=M.useCallback(async p=>t.get("/admin/redis/tenants",{signal:p}),[t]),c=M.useCallback(async p=>t.get("/admin/redis/key-types",{signal:p}),[t]),a=M.useCallback(async(p,m)=>(me.debug("[useAdminRedisService.getKeyDetails]",{key:p,reveal:m==null?void 0:m.reveal}),t.get("/admin/redis/keys/detail",{params:{key:p,reveal:m==null?void 0:m.reveal},signal:m==null?void 0:m.signal})),[t]),d=M.useCallback(async(p,m,g,b)=>{await t.put("/admin/redis/keys",{key:p,value:m,ttlSeconds:g},{signal:b})},[t]),l=M.useCallback(async(p,m)=>{await t.del("/admin/redis/keys",{params:{key:p},signal:m})},[t]),u=M.useCallback(async p=>t.post("/admin/redis/clear/tenant",{},{signal:p}),[t]),f=M.useCallback(async(p,m)=>t.post("/admin/redis/clear/sub-account",{subAccountId:p},{signal:m}),[t]),h=M.useCallback(async(p,m)=>t.post("/admin/redis/sessions/revoke",{subAccountId:p},{signal:m}),[t]);return M.useMemo(()=>({listSessions:e,listSessionsAll:n,listKeys:o,listKeysAll:i,listSubAccounts:r,listTenants:s,listKeyTypes:c,getKeyDetails:a,deleteKey:l,clearTenant:u,clearSubAccount:f,revokeSessions:h,updateKey:d}),[e,n,o,i,r,s,c,a,l,u,f,h,d])}const Np=12,tC=({componentKey:t,primaryAccountId:e})=>{var Ue,Pe,re,be,Fe,qe,$e;const{boomiConfig:n,tenantId:o,setPageIsLoading:i}=vt(),r=e??o??(n==null?void 0:n.tenantId),s=`cors-view:${t}`,c=(Pe=(Ue=n==null?void 0:n.components)==null?void 0:Ue[t])==null?void 0:Pe.cors;(re=c==null?void 0:c.search)==null||re.show;const a=((be=c==null?void 0:c.addButton)==null?void 0:be.show)??!0,d=((Fe=c==null?void 0:c.viewTypeButton)==null?void 0:Fe.show)??!0,l=ro(),{listTenants:u,listSubAccounts:f,listKeyTypes:h}=eC(),{allowedOrigins:p,refetch:m,isLoading:g,error:b}=QB({primaryAccountId:r,auto:!!r}),{updateCors:v,isUpdating:x,error:T}=KB(),{deleteCors:y,isDeleting:E,error:_}=YB(),[N,C]=M.useState([]),[L,$]=M.useState(""),[k,I]=M.useState(""),[S,A]=M.useState(""),[O,P]=M.useState([]),[R,B]=M.useState([]),[U,H]=M.useState(!1),[G,W]=M.useState(1),[Q,V]=M.useState("off"),[j,K]=M.useState(!1),[q,X]=M.useState(!1),[J,se]=M.useState(!1),[Y,he]=M.useState(null),[ie,ye]=M.useState(null),[Ae,Oe]=M.useState(null),[Ye,We]=M.useState({add:!1,edit:!1,delete:!1});M.useEffect(()=>{try{const ge=localStorage.getItem(s);(ge==="on"||ge==="off")&&V(ge)}catch{}},[s]),M.useEffect(()=>{U||r&&C(p.map(ge=>({origin:ge,tenantId:r})))},[p,U,r]),M.useEffect(()=>{const ge=new AbortController;return h(ge.signal).then(Ie=>H(!!Ie.isSuperAdmin)).catch(()=>H(!1)),()=>ge.abort()},[h]),M.useEffect(()=>{if(!U)return;const ge=new AbortController;return u(ge.signal).then(Ie=>P(Ie.items??[])).catch(()=>P([])),()=>ge.abort()},[U,u]),M.useEffect(()=>{if(!U)return;const ge=new AbortController;return f(k||void 0,ge.signal).then(Ge=>B(Ge.items??[])).catch(()=>B([])),()=>ge.abort()},[U,k,f]);const Ke=M.useCallback(ge=>l.get("/admin/cors",{signal:ge}).then(Ie=>{const Ge=((Ie==null?void 0:Ie.items)??[]).flatMap(le=>(le.allowedOrigins||[]).map(ne=>({origin:ne,tenantId:le.primaryAccountId})));C(Ge)}),[l]);M.useEffect(()=>{if(!U)return;const ge=new AbortController;return Ke(ge.signal).catch(()=>C([])),()=>ge.abort()},[U,Ke]);const Re=M.useMemo(()=>{const ge=L.trim().toLowerCase(),Ie=k?N.filter(Ge=>Ge.tenantId===k):N;return ge?Ie.filter(Ge=>Ge.origin.toLowerCase().includes(ge)):Ie},[N,L,k]),Xe=M.useMemo(()=>Re,[Re,S]),Ce=Math.max(1,Math.ceil(Xe.length/Np)),Be=Xe.slice((G-1)*Np,G*Np),fe=ge=>{We(Ie=>({...Ie,[ge]:!0})),setTimeout(()=>We(Ie=>({...Ie,[ge]:!1})),3e3)},xe=()=>r||(Oe("primaryAccountId is required to manage CORS."),null),we=()=>U?k||(Oe("Select a tenant to modify CORS configuration."),null):xe(),Te=M.useCallback(()=>{V(ge=>{const Ie=ge==="on"?"off":"on";try{localStorage.setItem(s,Ie)}catch{}return Ie})},[s]),de=async ge=>{const Ie=we();if(!Ie)return;const Ge=Array.from(new Set([...N.filter(le=>le.tenantId===Ie).map(le=>le.origin),ge]));i(!0);try{const le=await v({primaryAccountId:Ie,allowedOrigins:Ge});U||C(le.allowedOrigins.map(ne=>({origin:ne,tenantId:Ie}))),K(!1),fe("add"),U?await Ke():await m()}catch(le){me.error({err:le},"[Cors] add failed")}finally{i(!1)}},oe=async ge=>{if(!Y)return;const Ie=U?ie||we():xe();if(!Ie)return;const Ge=N.filter(ne=>ne.tenantId===Ie).map(ne=>ne.origin===Y?ge:ne.origin),le=Array.from(new Set(Ge));i(!0);try{const ne=await v({primaryAccountId:Ie,allowedOrigins:le});U||C(ne.allowedOrigins.map(ve=>({origin:ve,tenantId:Ie}))),X(!1),he(null),ye(null),fe("edit"),U?await Ke():await m()}catch(ne){me.error({err:ne},"[Cors] edit failed")}finally{i(!1)}},ce=async()=>{if(!Y)return;const ge=U?ie||we():xe();if(!ge)return;const Ie=N.filter(Ge=>Ge.tenantId===ge).map(Ge=>Ge.origin).filter(Ge=>Ge!==Y);i(!0);try{if(Ie.length===0)await y({primaryAccountId:ge}),U||C([]);else{const Ge=await v({primaryAccountId:ge,allowedOrigins:Ie});U||C(Ge.allowedOrigins.map(le=>({origin:le,tenantId:ge})))}se(!1),he(null),ye(null),fe("delete"),U?await Ke():await m()}catch(Ge){me.error({err:Ge},"[Cors] delete failed")}finally{i(!1)}},Ne=({origin:ge,tenantId:Ie})=>w.jsxs(Mi,{children:[w.jsx(Ut.Item,{children:({active:Ge})=>w.jsxs("button",{onClick:()=>{he(ge),ye(Ie),X(!0)},className:"boomi-menu-item","data-headlessui-state":Ge?"active":void 0,children:[w.jsx(Cl,{className:"boomi-menu-icon"}),"Edit"]})}),w.jsx("div",{className:"boomi-menu-divider"}),w.jsx(Ut.Item,{children:({active:Ge})=>w.jsxs("button",{onClick:()=>{he(ge),ye(Ie),se(!0)},className:"boomi-menu-item boomi-menu-item--danger","data-headlessui-state":Ge?"active":void 0,children:[w.jsx(io,{className:"boomi-menu-icon"}),"Delete"]})})]}),ke=Ae||b||T||_||null;return w.jsxs(w.Fragment,{children:[Ye.add&&w.jsx(ho,{type:"success",content:"Origin added."}),Ye.edit&&w.jsx(ho,{type:"success",content:"Origin updated."}),Ye.delete&&w.jsx(ho,{type:"success",content:"Origin deleted."}),w.jsx(XB,{isOpen:j,onClose:()=>K(!1),onSubmit:de,isSaving:x,serverError:j?T:null}),w.jsx(qB,{isOpen:q,origin:Y,onClose:()=>{X(!1),he(null)},onSubmit:oe,isSaving:x,serverError:q?T:null}),w.jsx(ZB,{isOpen:J,origin:Y,onClose:()=>{se(!1),he(null)},onConfirm:ce,isDeleting:E}),w.jsxs("div",{className:"w-full h-full p-6",children:[w.jsxs("div",{className:"space-y-2",children:[w.jsx("h1",{className:"text-2xl font-semibold",children:"CORS Configuration"}),w.jsx("p",{className:"text-sm opacity-70",children:"Manage allowed origins for this tenant."})]}),w.jsxs("div",{className:"flex items-end gap-3 mb-4 mt-4",children:[w.jsxs("div",{className:"flex flex-wrap items-end gap-3 flex-1 min-w-0",children:[w.jsx("div",{className:`min-w-[220px]${U?" pt-6":""}`,children:w.jsx(Tr,{searchCallback:ge=>{$(ge),W(1)}})}),U&&w.jsxs("label",{className:"text-xs font-semibold",children:["Tenant",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:k,onChange:ge=>{I(ge.target.value),A(""),W(1)},children:[w.jsx("option",{value:"",children:"All"}),O.map(ge=>w.jsx("option",{value:ge,children:ge},ge))]})]})]}),w.jsxs("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:[d&&w.jsx(it,{toggle:!0,primary:!1,viewLoc:s,onClass:"flex w-full justify-center rounded-md px-2 py-2 text-xs font-semibold leading-6 shadow-md transition-colors duration-100",showIcon:!0,label:(qe=c==null?void 0:c.viewTypeButton)==null?void 0:qe.label,icon:w.jsx(ou,{className:"h-5 w-5"}),onIcon:w.jsx(tu,{className:"h-5 w-5"}),onClick:Te}),a&&w.jsx(it,{toggle:!1,primary:!0,showIcon:!0,label:`Add ${(($e=c==null?void 0:c.addButton)==null?void 0:$e.label)??""}`.trim(),icon:w.jsx(sr,{className:"h-5 w-5"}),onClick:()=>K(!0)})]})]}),ke&&w.jsx("div",{className:"boomi-notice boomi-notice--error text-sm",children:ke}),Q==="off"?w.jsxs(w.Fragment,{children:[w.jsx("ul",{role:"list",className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-x-6 gap-y-8",children:g?w.jsx("div",{className:"col-span-full flex justify-center items-center",children:w.jsx(en,{})}):Be.length>0?Be.map(ge=>{var Ie;return w.jsxs("li",{className:"boomi-card boomi-cors-card",children:[w.jsx("div",{className:"flex gap-4 p-4",children:w.jsxs("div",{className:"flex flex-col w-full",children:[w.jsx("h3",{className:"text-base font-semibold break-words truncate overflow-hidden pr-2",children:ge.origin}),w.jsxs("p",{className:"text-xs mt-1 line-clamp-2 break-words overflow-hidden",children:["Origin allowed for tenant ",ge.tenantId,"."]})]})}),w.jsxs("div",{className:"flex w-full p-2 justify-end items-center gap-x-2 relative overflow-visible",children:[w.jsx(it,{toggle:!1,primary:!0,showIcon:!1,label:((Ie=c==null?void 0:c.editButton)==null?void 0:Ie.label)??"Edit",onClick:()=>{he(ge.origin),ye(ge.tenantId),X(!0)}}),w.jsx(Ne,{origin:ge.origin,tenantId:ge.tenantId})]})]},`${ge.tenantId}:${ge.origin}`)}):w.jsx("div",{className:"col-span-full flex justify-center items-center",children:w.jsx("p",{className:"text-gray-500 text-xs",children:"No allowed origins found."})})}),!g&&Ce>1&&w.jsx(xr,{currentPage:G,totalPages:Ce,onPageChange:ge=>W(ge)})]}):w.jsxs(w.Fragment,{children:[w.jsxs("table",{className:"w-full table-auto rounded-lg shadow-sm",children:[w.jsx("thead",{className:"boomi-table-header",children:w.jsxs("tr",{children:[w.jsx("th",{className:"py-3 px-4 text-left text-sm font-semibold w-3/4",children:"Origin"}),U&&w.jsx("th",{className:"py-3 px-4 text-left text-sm font-semibold",children:"Tenant"}),w.jsx("th",{className:"py-3 px-4 text-right text-sm font-semibold w-1/4",children:"Actions"})]})}),w.jsx("tbody",{className:"divide-y",children:g?w.jsx("tr",{children:w.jsx("td",{colSpan:U?3:2,children:w.jsx("div",{className:"flex justify-center items-center py-6",children:w.jsx(en,{})})})}):Be.length>0?Be.map(ge=>w.jsxs("tr",{className:"boomi-table-row",children:[w.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2 max-w-md break-words",children:ge.origin}),U&&w.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2",children:ge.tenantId}),w.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2",children:w.jsx("div",{className:"flex justify-end",children:w.jsx(Ne,{origin:ge.origin,tenantId:ge.tenantId})})})]},`${ge.tenantId}:${ge.origin}`)):w.jsx("tr",{children:w.jsx("td",{colSpan:U?3:2,children:w.jsx("div",{className:"flex justify-center items-center py-4",children:w.jsx("p",{className:"text-gray-500 text-xs",children:"No allowed origins found."})})})})})]}),!g&&Ce>1&&w.jsx("div",{className:"mt-4 flex justify-end",children:w.jsx(xr,{currentPage:G,totalPages:Ce,onPageChange:W})})]})]})]})};function nC(){const t=ro(),e=M.useCallback(s=>`/admin/agents/${encodeURIComponent(s)}`,[]),n=M.useCallback(async s=>{const{primaryAccountId:c,includeDetails:a,signal:d}=s;return t.get(e(c),{signal:d,params:a?{includeDetails:!0}:void 0})},[t,e]),o=M.useCallback(async s=>{const{primaryAccountId:c,signal:a}=s;return t.get(`${e(c)}/available`,{signal:a})},[t,e]),i=M.useCallback(async s=>{const{primaryAccountId:c,agentId:a,boomiAgentId:d,label:l,allowedOrigins:u,config:f,publicTokenIds:h,createToken:p,rateLimit:m,signal:g}=s,b={agentId:a};return d!==void 0&&(b.boomiAgentId=d),l!==void 0&&(b.label=l),u!==void 0&&(b.allowedOrigins=u),f!==void 0&&(b.config=f),h!==void 0&&(b.publicTokenIds=h),p!==void 0&&(b.createToken=p),m!==void 0&&(b.rateLimit=m),t.post(e(c),b,{signal:g})},[t,e]),r=M.useCallback(async s=>{const{primaryAccountId:c,agentId:a,signal:d}=s;await t.del(`${e(c)}/${encodeURIComponent(a)}`,{signal:d})},[t,e]);return M.useMemo(()=>({listAgents:n,listAvailableAgents:o,createAgent:i,deleteAgent:r}),[n,o,i,r])}const oC=({label:t,labelAddon:e,value:n,placeholder:o,helperText:i,error:r,onChange:s})=>{const c=M.useMemo(()=>Math.max(1,n.split(`
|
|
2105
2105
|
`).length),[n]),a=M.useMemo(()=>Array.from({length:c},(d,l)=>String(l+1)).join(`
|
|
2106
|
-
`),[c]);return w.jsxs("div",{children:[w.jsxs("label",{className:"boomi-form-label inline-flex items-center gap-2",children:[w.jsx("span",{children:t}),e]}),w.jsxs("div",{className:["flex w-full rounded-md border overflow-hidden","bg-[color-mix(in_srgb,var(--boomi-card-bg,#ffffff)_92%,#000000)]",r?"boomi-input--error":""].join(" ").trim(),children:[w.jsx("pre",{className:["m-0 py-2 px-3 text-xs font-mono leading-5","text-[color-mix(in_srgb,var(--boomi-card-fg,#111)_55%,transparent)]","bg-[color-mix(in_srgb,var(--boomi-card-bg,#ffffff)_86%,#000000)]","border-r border-[color-mix(in_srgb,var(--boomi-card-border,#e5e7eb)_80%,transparent)]","select-none text-right min-w-[2.5rem]"].join(" "),children:a}),w.jsx("textarea",{className:["boomi-input flex-1 rounded-none border-0 font-mono text-xs leading-5","bg-transparent p-2 min-h-[120px]","focus:outline-none"].join(" "),placeholder:o,value:n,onChange:d=>s(d.target.value)})]}),i&&w.jsx("p",{className:"boomi-form-helper",children:i}),r&&w.jsx("p",{className:"boomi-form-error",children:r})]})},Ns=[{value:"",label:"None"},{value:"🤖",label:"🤖 Robot"},{value:"💬",label:"💬 Chat"},{value:"🗣️",label:"🗣️ Speaking"},{value:"✨",label:"✨ Sparkles"},{value:"🧠",label:"🧠 Brain"},{value:"💡",label:"💡 Idea"},{value:"🚀",label:"🚀 Rocket"},{value:"⚡",label:"⚡ Lightning"},{value:"🔍",label:"🔍 Search"},{value:"🛠️",label:"🛠️ Tools"},{value:"🤝",label:"🤝 Handshake"},{value:"🌐",label:"🌐 Globe"},{value:"🎯",label:"🎯 Target"},{value:"📊",label:"📊 Analytics"}],kr=["bottom-right","bottom-left","top-right","top-left"],Lp=()=>({label:"",description:"",icon:"🤖",hideIcon:!1,buttonLabel:"Launch"}),JB=t=>/^#[0-9a-fA-F]{3,8}$/.test(t.trim()),iC=["--boomi-font","--default-font-family","--boomi-accent","--boomi-agent-bg","--boomi-agent-blur","--boomi-agent-border","--boomi-agent-bubble-agent-bg","--boomi-agent-bubble-agent-border","--boomi-agent-bubble-agent-fg","--boomi-agent-bubble-border","--boomi-agent-bubble-shadow","--boomi-agent-bubble-user-bg","--boomi-agent-bubble-user-border","--boomi-agent-bubble-user-fg","--boomi-agent-card-tint","--boomi-agent-chat-bg","--boomi-agent-chat-border","--boomi-agent-chat-fg","--boomi-agent-close-bg-hover","--boomi-agent-close-fg","--boomi-agent-close-hover-fg","--boomi-agent-compose-bg","--boomi-agent-compose-border","--boomi-agent-compose-input-bg","--boomi-agent-compose-input-border","--boomi-agent-compose-secondary-bg","--boomi-agent-compose-secondary-border","--boomi-agent-compose-shadow","--boomi-agent-fg","--boomi-agent-header-bg","--boomi-agent-header-border","--boomi-agent-pane-bg","--boomi-agent-pane-bg-color","--boomi-agent-pane-fg","--boomi-agent-pane-fg-color","--boomi-agent-radius","--boomi-agent-ring","--boomi-agent-row-shimmer-opacity","--boomi-agent-row-tint","--boomi-agent-section-bg","--boomi-agent-section-border","--boomi-agent-section-fg","--boomi-agent-section-shadow","--boomi-agent-shadow","--boomi-agent-shimmer-1","--boomi-agent-shimmer-2","--boomi-agent-shimmer-angle","--boomi-agent-shimmer-direction","--boomi-agent-shimmer-opacity","--boomi-agent-shimmer-speed","--boomi-agent-tab-bg","--boomi-agent-tab-bg-active","--boomi-agent-tab-border","--boomi-agent-tab-border-active","--boomi-agent-tab-fg","--boomi-agent-tab-fg-active","--boomi-agent-tab-shadow-active","--boomi-agent-text-bg","--boomi-agent-text-border","--boomi-agent-text-copy-bg","--boomi-agent-text-copy-bg-hover","--boomi-agent-text-copy-fg","--boomi-agent-text-fg","--boomi-agent-thread-separator","--boomi-agent-update-bg","--boomi-agent-update-border","--boomi-agent-update-content-bg","--boomi-agent-update-content-fg","--boomi-agent-update-desc-fg","--boomi-agent-update-fg","--boomi-agent-update-radius","--boomi-agent-update-shadow","--boomi-agent-update-title-fg","--boomi-angle","--boomi-btn-primary-bg","--boomi-btn-primary-bg-active","--boomi-btn-primary-bg-hover","--boomi-btn-primary-border","--boomi-btn-primary-border-active","--boomi-btn-primary-border-hover","--boomi-btn-primary-fg","--boomi-btn-primary-fg-active","--boomi-btn-primary-fg-hover","--boomi-btn-primary-shadow","--boomi-btn-primary-shadow-active","--boomi-btn-primary-shadow-hover","--boomi-btn-secondary-bg","--boomi-btn-secondary-bg-active","--boomi-btn-secondary-bg-hover","--boomi-btn-secondary-border","--boomi-btn-secondary-border-active","--boomi-btn-secondary-border-hover","--boomi-btn-secondary-fg","--boomi-btn-secondary-fg-active","--boomi-btn-secondary-fg-hover","--boomi-btn-secondary-shadow","--boomi-btn-secondary-shadow-active","--boomi-btn-secondary-shadow-hover","--boomi-card-bg","--boomi-card-border","--boomi-card-fg","--boomi-card-hover-scale","--boomi-card-hover-shadow","--boomi-card-radius","--boomi-card-shadow","--boomi-chip-bg","--boomi-chip-border","--boomi-chip-error-bg","--boomi-chip-error-border","--boomi-chip-error-fg","--boomi-chip-fg","--boomi-chip-pulse-color","--boomi-chip-success-bg","--boomi-chip-success-border","--boomi-chip-success-fg","--boomi-chip-warning-bg","--boomi-chip-warning-border","--boomi-chip-warning-fg","--boomi-root-bg-color","--boomi-root-fg-color","--boomi-page-bg-color","--boomi-page-fg-color","--boomi-muted","--boomi-header-bg-color","--boomi-header-fg-color","--boomi-header-fg-hover","--boomi-header-border-color","--boomi-header-shadow","--boomi-input-bg","--boomi-input-fg","--boomi-input-placeholder","--boomi-input-border","--boomi-input-shadow","--boomi-input-border-focus","--boomi-input-shadow-focus","--boomi-input-outline-focus","--boomi-input-bg-disabled","--boomi-input-fg-disabled","--boomi-input-border-disabled","--boomi-input-border-invalid","--boomi-input-outline-invalid","--boomi-table-header-bg","--boomi-table-header-fg","--boomi-table-header-border","--boomi-table-row-odd-bg","--boomi-table-row-even-bg","--boomi-table-row-hover-shadow","--boomi-menu-bg","--boomi-menu-fg","--boomi-menu-border","--boomi-menu-shadow","--boomi-menu-item-bg","--boomi-menu-item-bg-hover","--boomi-menu-item-fg","--boomi-menu-item-fg-hover","--boomi-menu-divider","--boomi-menu-danger-fg","--boomi-menu-danger-fg-hover","--boomi-menu-danger-bg-hover","--boomi-modal-overlay-bg","--boomi-modal-bg","--boomi-modal-fg","--boomi-modal-border","--boomi-modal-shadow","--boomi-modal-close-fg","--boomi-modal-close-hover-fg","--boomi-form-label-fg","--boomi-form-helper-fg","--boomi-form-error-fg","--boomi-form-required-fg","--boomi-select-bg","--boomi-select-fg","--boomi-select-border","--boomi-select-shadow","--boomi-select-border-focus","--boomi-select-shadow-focus","--boomi-select-icon","--boomi-options-bg","--boomi-options-fg","--boomi-options-border","--boomi-options-shadow","--boomi-options-search-bg","--boomi-option-bg-active","--boomi-option-fg-selected","--boomi-loader-dot-bg","--boomi-loader-dot-size","--boomi-loader-dot1-opacity","--boomi-loader-dot2-opacity","--boomi-loader-dot3-opacity","--boomi-loader-msg-fg","--boomi-spinner-overlay-bg","--boomi-spinner-ring-color","--boomi-spinner-ping-color","--boomi-spinner-message-fg","--boomi-spinner-size","--boomi-spinner-border-width","--boomi-wizard-step-dot-bg","--boomi-wizard-step-dot-fg","--boomi-wizard-step-dot-border","--boomi-wizard-step-dot-shadow","--boomi-wizard-step-dot-bg-active","--boomi-wizard-step-dot-fg-active","--boomi-wizard-step-dot-border-active","--boomi-wizard-step-dot-shadow-active","--boomi-wizard-step-dot-bg-completed","--boomi-wizard-step-dot-fg-completed","--boomi-wizard-step-dot-border-completed","--boomi-wizard-step-dot-shadow-completed","--boomi-wizard-connector-bg","--boomi-wizard-label-fg","--boomi-wizard-card-bg","--boomi-wizard-card-fg","--boomi-wizard-card-border","--boomi-wizard-card-shadow","--boomi-wizard-link-fg","--boomi-wizard-link-fg-hover","--boomi-wizard-link-strong-fg","--boomi-notice-warning-bg","--boomi-notice-warning-fg","--boomi-notice-warning-border","--boomi-notice-success-bg","--boomi-notice-success-fg","--boomi-notice-success-border","--boomi-notice-error-bg","--boomi-notice-error-fg","--boomi-notice-error-border","--boomi-notice-shadow","--boomi-notice-radius","--boomi-update-bg","--boomi-update-fg","--boomi-update-border","--boomi-update-shadow","--boomi-update-title-fg","--boomi-update-desc-fg","--boomi-update-radius","--boomi-update-content","--boomi-tablist-border","--boomi-tab-bg","--boomi-tab-fg","--boomi-tab-border","--boomi-tab-bg-hover","--boomi-tab-bg-active","--boomi-tab-fg-active","--boomi-tab-border-active","--boomi-map-line","--boomi-map-line-width","--boomi-map-line-filter","--boomi-map-heading-fg","--boomi-map-card-bg","--boomi-map-card-border","--boomi-map-card-shadow","--boomi-map-card-shadow-hover","--boomi-map-card-transform-hover","--boomi-map-source-bg-mapped","--boomi-map-source-border-mapped","--boomi-map-source-outline","--boomi-map-target-bg-mapped","--boomi-map-target-border-mapped","--boomi-map-target-outline","--boomi-map-func-bg","--boomi-map-func-fg","--boomi-map-func-title-fg","--boomi-map-pin-source-bg","--boomi-map-pin-target-bg","--boomi-map-pin-input-bg","--boomi-map-pin-output-bg","--boomi-map-pin-badge-bg","--boomi-map-pin-badge-fg","--boomi-map-pin-danger-bg","--boomi-map-pulse-color","--boomi-map-pin-pulse","--boomi-map-add-bg","--boomi-map-add-fg","--boomi-map-add-border","--boomi-map-add-shadow","--boomi-map-add-bg-hover","--boomi-sched-card-bg","--boomi-sched-card-fg","--boomi-sched-card-border","--boomi-sched-card-shadow","--boomi-sched-card-shadow-hover","--boomi-sched-card-radius","--boomi-sched-header-bg","--boomi-sched-header-fg","--boomi-sched-header-border","--boomi-sched-header-shadow","--boomi-sched-toggle-fg","--boomi-sched-toggle-fg-hover","--boomi-sched-row-bg","--boomi-sched-row-border","--boomi-sched-row-shadow","--boomi-sched-row-hover-shadow","--boomi-sched-label-fg","--boomi-sched-helper-fg","--boomi-sched-error-fg","--boomi-sched-select-bg","--boomi-sched-select-fg","--boomi-sched-select-border","--boomi-sched-select-shadow","--boomi-sched-select-border-focus","--boomi-sched-select-shadow-focus","--boomi-sched-input-bg","--boomi-sched-input-fg","--boomi-sched-input-border","--boomi-sched-input-shadow","--boomi-sched-input-border-focus","--boomi-sched-input-shadow-focus","--boomi-sched-checkbox-border","--boomi-sched-checkbox-bg","--boomi-sched-checkbox-bg-checked","--boomi-sched-checkbox-symbol","--boomi-sched-action-bg","--boomi-sched-action-fg","--boomi-sched-action-border","--boomi-sched-action-shadow","--boomi-sched-action-bg-hover","--boomi-conn-bg","--boomi-conn-border","--boomi-conn-card-shadow","--boomi-conn-heading-fg","--boomi-conn-field-bg","--boomi-conn-field-border","--boomi-conn-field-label-fg","--boomi-conn-field-error-fg","--boomi-conn-btn-save-bg","--boomi-conn-btn-save-fg","--boomi-conn-btn-auth-bg","--boomi-conn-btn-auth-fg","--boomi-conn-btn-disabled-bg","--boomi-conn-btn-disabled-fg","--boomi-swal-bg","--boomi-swal-fg","--boomi-swal-border","--boomi-swal-shadow","--boomi-swal-title-fg","--boomi-swal-desc-fg","--boomi-swal-icon-success","--boomi-swal-icon-warning","--boomi-swal-icon-error","--boomi-swal-overlay-bg"],eH=()=>({themeSelection:"boomi",themeDefault:"boomi",themeCustomName:"",themeCustomVars:[],launcherCorner:"bottom-right",launcherOffsetX:"20",launcherOffsetY:"40",launcherShape:"pill",launcherLabel:"Find an Agent",launcherIcon:"🤖",launcherHideIcon:!1,listModalWidth:"500",listModalHeight:"600",listModalCorner:"bottom-right",listModalOffsetX:"20",listModalOffsetY:"100",listWelcomeTitle:"Agents",listWelcomeSubtitle:"Search for an agent and click to launch.",listHeaderShow:!0,listHeaderTitle:"Agents",listHeaderDescription:"Select an agent to launch.",listSearchShow:!0,tilesHeaderShow:!0,tilesHeaderTitle:"Agents",tilesHeaderDescription:"Browse and launch an agent.",tilesSearchShow:!0,tilesViewToggleShow:!0,agentUiMode:"modal",agentModalWidth:"600",agentModalHeight:"800",agentModalCorner:"top-right",agentModalOffsetX:"20",agentModalOffsetY:"40",agentSidebarShow:!0,agentSidebarWidth:"280",agentWelcomeTitle:"Let's Talk",agentWelcomeSubtitle:"Ask me about your Boomi deployment.",agentOverrides:{}}),po=t=>{const e=t.trim();if(!e)return;const n=Number(e);return Number.isNaN(n)?e:n},tH=(t,e,n,o)=>{var r,s,c,a,d,l,u,f,h,p,m,g,b,v,x,T,y,E,_,N,C,L,$,k,I,S,A,O;const i={...e};if(i.themeCustomVars=[],!t.trim())return i;try{const P=JSON.parse(t);if(P!=null&&P.theme&&typeof P.theme.defaultTheme=="string"){const K=P.theme.defaultTheme;K==="boomi"||K==="base"?(i.themeSelection=K,i.themeDefault=K,i.themeCustomName=""):(i.themeSelection="custom",i.themeDefault=K,i.themeCustomName=K);const q=P==null?void 0:P.cssVarsByTheme;let X=q==null?void 0:q[K],J=K;if((!X||typeof X!="object")&&q&&typeof q=="object"){const se=Object.keys(q)[0];se&&(X=q[se],J=se,J!=="boomi"&&J!=="base"&&(i.themeSelection="custom",i.themeCustomName=J,i.themeDefault=J))}X&&typeof X=="object"&&(i.themeCustomVars=Object.entries(X).map(([se,Y])=>({id:`var_${se}`,varName:se,value:typeof Y=="string"?Y:String(Y)})))}const R=(r=P==null?void 0:P.components)==null?void 0:r.agentList,B=(s=P==null?void 0:P.components)==null?void 0:s.agentTiles;if(n==="list"&&R){const K=R.launcher??{},q=K.position??{};kr.includes(q.corner)&&(i.launcherCorner=q.corner),q.offsetX!==void 0&&(i.launcherOffsetX=String(q.offsetX)),q.offsetY!==void 0&&(i.launcherOffsetY=String(q.offsetY)),(K.shape==="pill"||K.shape==="circle")&&(i.launcherShape=K.shape),typeof K.label=="string"&&(i.launcherLabel=K.label),typeof K.icon=="string"&&(i.launcherIcon=K.icon),typeof K.hideIcon=="boolean"&&(i.launcherHideIcon=K.hideIcon);const X=R.modal??{};X.width!==void 0&&(i.listModalWidth=String(X.width)),X.height!==void 0&&(i.listModalHeight=String(X.height));const J=X.position??{};kr.includes(J.corner)&&(i.listModalCorner=J.corner),J.offsetX!==void 0&&(i.listModalOffsetX=String(J.offsetX)),J.offsetY!==void 0&&(i.listModalOffsetY=String(J.offsetY)),(c=R.welcome)!=null&&c.title&&(i.listWelcomeTitle=R.welcome.title),(a=R.welcome)!=null&&a.subtitle&&(i.listWelcomeSubtitle=R.welcome.subtitle),((d=R.header)==null?void 0:d.show)!==void 0&&(i.listHeaderShow=!!R.header.show),(l=R.header)!=null&&l.title&&(i.listHeaderTitle=R.header.title),(u=R.header)!=null&&u.description&&(i.listHeaderDescription=R.header.description),((f=R.search)==null?void 0:f.show)!==void 0&&(i.listSearchShow=!!R.search.show)}n==="tiles"&&B&&(((h=B.header)==null?void 0:h.show)!==void 0&&(i.tilesHeaderShow=!!B.header.show),(p=B.header)!=null&&p.title&&(i.tilesHeaderTitle=B.header.title),(m=B.header)!=null&&m.description&&(i.tilesHeaderDescription=B.header.description),((g=B.search)==null?void 0:g.show)!==void 0&&(i.tilesSearchShow=!!B.search.show),((b=B.viewToggle)==null?void 0:b.show)!==void 0&&(i.tilesViewToggleShow=!!B.viewToggle.show));const U=(P==null?void 0:P.agents)??{},H=o.find(K=>U[K])??Object.keys(U)[0],G=H?U[H]:null;G!=null&&G.position&&typeof G.position=="object"&&"corner"in G.position&&(kr.includes(G.position.corner)&&(i.launcherCorner=G.position.corner),G.position.offsetX!==void 0&&(i.launcherOffsetX=String(G.position.offsetX)),G.position.offsetY!==void 0&&(i.launcherOffsetY=String(G.position.offsetY))),((G==null?void 0:G.shape)==="pill"||(G==null?void 0:G.shape)==="circle")&&(i.launcherShape=G.shape),typeof(G==null?void 0:G.label)=="string"&&(i.launcherLabel=G.label),typeof(G==null?void 0:G.icon)=="string"&&(i.launcherIcon=G.icon),typeof(G==null?void 0:G.hideIcon)=="boolean"&&(i.launcherHideIcon=G.hideIcon);const W=(G==null?void 0:G.ui)??{};(W.mode==="modal"||W.mode==="full")&&(i.agentUiMode=W.mode),((v=W.modal)==null?void 0:v.width)!==void 0&&(i.agentModalWidth=String(W.modal.width)),((x=W.modal)==null?void 0:x.height)!==void 0&&(i.agentModalHeight=String(W.modal.height)),(y=(T=W.modal)==null?void 0:T.position)!=null&&y.corner&&kr.includes(W.modal.position.corner)&&(i.agentModalCorner=W.modal.position.corner),((_=(E=W.modal)==null?void 0:E.position)==null?void 0:_.offsetX)!==void 0&&(i.agentModalOffsetX=String(W.modal.position.offsetX)),((C=(N=W.modal)==null?void 0:N.position)==null?void 0:C.offsetY)!==void 0&&(i.agentModalOffsetY=String(W.modal.position.offsetY));const Q=W.sessionScope==="mount"?!1:W.sessionScope==="multi"?!0:void 0,j=(((L=W.sidebar)==null?void 0:L.show)!==void 0?!!W.sidebar.show:void 0)??Q;if(j!==void 0&&(i.agentSidebarShow=j),(($=W.sidebar)==null?void 0:$.width)!==void 0&&(i.agentSidebarWidth=String(W.sidebar.width)),(k=W.welcome)!=null&&k.title&&(i.agentWelcomeTitle=W.welcome.title),(I=W.welcome)!=null&&I.subtitle&&(i.agentWelcomeSubtitle=W.welcome.subtitle),n==="list"||n==="tiles"){const K={};for(const q of o){const X=U[q];X&&(K[q]={label:typeof X.label=="string"?X.label:"",description:typeof((S=X.ui)==null?void 0:S.pageDescription)=="string"?X.ui.pageDescription:typeof((O=(A=X.ui)==null?void 0:A.welcome)==null?void 0:O.subtitle)=="string"?X.ui.welcome.subtitle:"",icon:typeof X.icon=="string"?X.icon:"🤖",hideIcon:typeof X.hideIcon=="boolean"?X.hideIcon:!1,buttonLabel:typeof X.buttonLabel=="string"?X.buttonLabel:"Launch"})}i.agentOverrides=K}}catch{return i}return i},rC=(t,e,n)=>{const o=t.themeSelection==="custom"?t.themeCustomName.trim()||t.themeDefault||"custom":t.themeSelection,i={transport:"boomi-direct",theme:{allowThemes:!0,defaultTheme:o}},r={};for(const c of t.themeCustomVars)c.varName&&c.value&&(r[c.varName]=c.value);Object.keys(r).length&&(i.cssVarsByTheme={[o]:r}),e==="list"&&(i.components={agentList:{launcher:{position:{corner:t.launcherCorner,offsetX:po(t.launcherOffsetX),offsetY:po(t.launcherOffsetY)},shape:t.launcherShape,label:t.launcherLabel,icon:t.launcherIcon,hideIcon:t.launcherHideIcon},modal:{width:po(t.listModalWidth),height:po(t.listModalHeight),position:{corner:t.listModalCorner,offsetX:po(t.listModalOffsetX),offsetY:po(t.listModalOffsetY)}},welcome:{title:t.listWelcomeTitle,subtitle:t.listWelcomeSubtitle},header:{show:t.listHeaderShow,title:t.listHeaderTitle,description:t.listHeaderDescription},search:{show:t.listSearchShow}}}),e==="tiles"&&(i.components={agentTiles:{header:{show:t.tilesHeaderShow,title:t.tilesHeaderTitle,description:t.tilesHeaderDescription},search:{show:t.tilesSearchShow},viewToggle:{show:t.tilesViewToggleShow}}});const s=n.length?n:["agent-id"];return i.agents=s.reduce((c,a)=>{const d=e==="list"||e==="tiles"?t.agentOverrides[a]??Lp():void 0,l={transport:"boomi-direct"};return e==="single"?(l.position={corner:t.launcherCorner,offsetX:po(t.launcherOffsetX),offsetY:po(t.launcherOffsetY)},l.shape=t.launcherShape,l.label=t.launcherLabel,l.icon=t.launcherIcon,l.hideIcon=t.launcherHideIcon):d&&(d.label&&(l.label=d.label),l.icon=d.icon,l.hideIcon=d.hideIcon,d.buttonLabel&&d.buttonLabel!=="Launch"&&(l.buttonLabel=d.buttonLabel)),l.ui={mode:t.agentUiMode,sessionScope:t.agentSidebarShow?"multi":"mount",modal:{width:po(t.agentModalWidth),height:po(t.agentModalHeight),position:{corner:t.agentModalCorner,offsetX:po(t.agentModalOffsetX),offsetY:po(t.agentModalOffsetY)}},sidebar:{show:t.agentSidebarShow,width:po(t.agentSidebarWidth)},welcome:{title:t.agentWelcomeTitle,subtitle:t.agentWelcomeSubtitle},...d!=null&&d.description?{pageDescription:d.description}:{}},c[a]=l,c},{}),i.project={embedType:e,agentIds:s},i},sC=M.forwardRef(({embedType:t,agentIds:e,configRaw:n,onChangeConfig:o,onUpdateBuilder:i,syncFromConfig:r=!1,availableAgents:s},c)=>{const a=M.useMemo(eH,[]),[d,l]=M.useState(a),u=M.useRef(!1);M.useImperativeHandle(c,()=>({getConfig:()=>rC(d,t,e)}),[d,t,e]),M.useEffect(()=>{(r||!u.current)&&(l(tH(n,a,t,e)),u.current=!0)},[n,a,t,e,r]),M.useEffect(()=>{i==null||i(d)},[d,i]),M.useEffect(()=>{const m=rC(d,t,e);o(m)},[d,t,e,o]);const f=()=>{const m=iC[0]??"--boomi-root-bg-color";l(g=>({...g,themeCustomVars:[...g.themeCustomVars,{id:`var_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,varName:m,value:""}]}))},h=(m,g)=>{l(b=>({...b,themeCustomVars:b.themeCustomVars.map(v=>v.id===m?{...v,...g}:v)}))},p=m=>{l(g=>({...g,themeCustomVars:g.themeCustomVars.filter(b=>b.id!==m)}))};return w.jsxs("div",{className:"boomi-card p-4 space-y-4",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-sm font-semibold",children:"Config Builder"}),w.jsx("div",{className:"text-xs opacity-70",children:"Updates the JSON configuration automatically as you make changes."})]}),w.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[w.jsxs("div",{className:"space-y-3",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Agent UI"}),w.jsxs("label",{className:"boomi-form-label",children:["Mode",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.agentUiMode,onChange:m=>l(g=>({...g,agentUiMode:m.target.value})),children:[w.jsx("option",{value:"modal",children:"Modal"}),w.jsx("option",{value:"full",children:"Full Page"})]})]}),d.agentUiMode==="modal"&&w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Modal width",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.agentModalWidth,onChange:m=>l(g=>({...g,agentModalWidth:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Modal height",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.agentModalHeight,onChange:m=>l(g=>({...g,agentModalHeight:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Modal corner",w.jsx("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.agentModalCorner,onChange:m=>l(g=>({...g,agentModalCorner:m.target.value})),children:kr.map(m=>w.jsx("option",{value:m,children:m},m))})]}),w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Offset X",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.agentModalOffsetX,onChange:m=>l(g=>({...g,agentModalOffsetX:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Offset Y",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.agentModalOffsetY,onChange:m=>l(g=>({...g,agentModalOffsetY:m.target.value}))})]})]})]}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:d.agentSidebarShow,onChange:m=>l(g=>({...g,agentSidebarShow:m.target.checked}))}),"Show sidebar"]}),w.jsxs("label",{className:"boomi-form-label",children:["Sidebar width",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.agentSidebarWidth,onChange:m=>l(g=>({...g,agentSidebarWidth:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Welcome title",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.agentWelcomeTitle,onChange:m=>l(g=>({...g,agentWelcomeTitle:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Welcome subtitle",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.agentWelcomeSubtitle,onChange:m=>l(g=>({...g,agentWelcomeSubtitle:m.target.value}))})]})]}),w.jsxs("div",{className:"space-y-3",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Theme"}),w.jsxs("label",{className:"boomi-form-label",children:["Theme",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.themeSelection,onChange:m=>l(g=>({...g,themeSelection:m.target.value,themeDefault:m.target.value==="custom"?g.themeDefault:m.target.value})),children:[w.jsx("option",{value:"boomi",children:"boomi"}),w.jsx("option",{value:"base",children:"base"}),w.jsx("option",{value:"custom",children:"custom"})]})]}),d.themeSelection==="custom"&&w.jsxs(w.Fragment,{children:[w.jsxs("label",{className:"boomi-form-label",children:["Custom theme name",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.themeCustomName,onChange:m=>l(g=>({...g,themeCustomName:m.target.value,themeDefault:m.target.value})),placeholder:"my-theme"})]}),w.jsxs("div",{className:"space-y-2",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"CSS Variable Overrides"}),d.themeCustomVars.length===0&&w.jsx("div",{className:"text-xs opacity-70",children:"No custom variables yet."}),w.jsx("div",{className:"space-y-2",children:d.themeCustomVars.map(m=>w.jsxs("div",{className:"flex items-center gap-2 flex-nowrap w-full overflow-x-auto",children:[w.jsx("select",{className:"boomi-input flex-1 min-w-0 rounded-md p-2 text-sm",value:m.varName,onChange:g=>h(m.id,{varName:g.target.value}),children:iC.map(g=>w.jsx("option",{value:g,children:g},g))}),w.jsx("input",{type:"text",value:m.value,onChange:g=>h(m.id,{value:g.target.value}),className:"boomi-input flex-1 min-w-0 rounded-md p-2 text-sm",placeholder:"#000000 or rgba(...) or value"}),JB(m.value)&&w.jsx("input",{type:"color",value:m.value,onChange:g=>h(m.id,{value:g.target.value}),className:"h-9 w-12 shrink-0 cursor-pointer rounded-md border border-[var(--boomi-card-border)] bg-transparent"}),w.jsx("button",{type:"button",className:"text-xs text-red-500 whitespace-nowrap shrink-0",onClick:()=>p(m.id),children:"Remove"})]},m.id))}),w.jsx("div",{children:w.jsx("button",{type:"button",className:"boomi-btn-primary px-3 py-2 text-xs",onClick:f,children:"Add CSS Variable"})})]})]})]})]}),(t==="list"||t==="single")&&w.jsxs("div",{className:t==="list"?"grid gap-4 md:grid-cols-2":"space-y-3",children:[w.jsxs("div",{className:"space-y-3",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Launcher (Pill)"}),w.jsxs("label",{className:"boomi-form-label",children:["Corner",w.jsx("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.launcherCorner,onChange:m=>l(g=>({...g,launcherCorner:m.target.value})),children:kr.map(m=>w.jsx("option",{value:m,children:m},m))})]}),w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Offset X",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.launcherOffsetX,onChange:m=>l(g=>({...g,launcherOffsetX:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Offset Y",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.launcherOffsetY,onChange:m=>l(g=>({...g,launcherOffsetY:m.target.value}))})]})]}),w.jsxs("label",{className:"boomi-form-label",children:["Shape",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.launcherShape,onChange:m=>l(g=>({...g,launcherShape:m.target.value})),children:[w.jsx("option",{value:"pill",children:"Pill"}),w.jsx("option",{value:"circle",children:"Circle"})]})]}),w.jsxs("label",{className:"boomi-form-label",children:["Label",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.launcherLabel,onChange:m=>l(g=>({...g,launcherLabel:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Icon",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:Ns.some(m=>m.value===d.launcherIcon)?d.launcherIcon:"__custom__",onChange:m=>l(g=>({...g,launcherIcon:m.target.value==="__custom__"?g.launcherIcon:m.target.value})),children:[!Ns.some(m=>m.value===d.launcherIcon)&&w.jsxs("option",{value:"__custom__",children:[d.launcherIcon," (custom)"]}),Ns.map(m=>w.jsx("option",{value:m.value,children:m.label},m.value))]})]}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:d.launcherHideIcon,onChange:m=>l(g=>({...g,launcherHideIcon:m.target.checked}))}),"Hide icon"]})]}),t==="list"&&w.jsxs("div",{className:"space-y-3",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"List Modal"}),w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Width",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.listModalWidth,onChange:m=>l(g=>({...g,listModalWidth:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Height",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.listModalHeight,onChange:m=>l(g=>({...g,listModalHeight:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Corner",w.jsx("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.listModalCorner,onChange:m=>l(g=>({...g,listModalCorner:m.target.value})),children:kr.map(m=>w.jsx("option",{value:m,children:m},m))})]}),w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Offset X",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.listModalOffsetX,onChange:m=>l(g=>({...g,listModalOffsetX:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Offset Y",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.listModalOffsetY,onChange:m=>l(g=>({...g,listModalOffsetY:m.target.value}))})]})]})]}),w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70 pt-2",children:"List Header & Search"}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:d.listHeaderShow,onChange:m=>l(g=>({...g,listHeaderShow:m.target.checked}))}),"Show header"]}),w.jsxs("label",{className:"boomi-form-label",children:["Header title",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.listHeaderTitle,onChange:m=>l(g=>({...g,listHeaderTitle:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Header description",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.listHeaderDescription,onChange:m=>l(g=>({...g,listHeaderDescription:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:d.listSearchShow,onChange:m=>l(g=>({...g,listSearchShow:m.target.checked}))}),"Show search"]}),w.jsxs("label",{className:"boomi-form-label",children:["Welcome title",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.listWelcomeTitle,onChange:m=>l(g=>({...g,listWelcomeTitle:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Welcome subtitle",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.listWelcomeSubtitle,onChange:m=>l(g=>({...g,listWelcomeSubtitle:m.target.value}))})]})]})]}),t==="tiles"&&w.jsxs("div",{className:"space-y-3",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Tiles Header & Search"}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:d.tilesHeaderShow,onChange:m=>l(g=>({...g,tilesHeaderShow:m.target.checked}))}),"Show header"]}),w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Header title",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.tilesHeaderTitle,onChange:m=>l(g=>({...g,tilesHeaderTitle:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Header description",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.tilesHeaderDescription,onChange:m=>l(g=>({...g,tilesHeaderDescription:m.target.value}))})]})]}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:d.tilesSearchShow,onChange:m=>l(g=>({...g,tilesSearchShow:m.target.checked}))}),"Show search"]}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:d.tilesViewToggleShow,onChange:m=>l(g=>({...g,tilesViewToggleShow:m.target.checked}))}),"Show tiles/table toggle"]})]}),(t==="list"||t==="tiles")&&e.length>0&&w.jsxs("div",{className:"space-y-3",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Agent Cards"}),w.jsxs("div",{className:"text-xs opacity-70",children:["Configure how each agent appears in the ",t," view."]}),w.jsx("div",{className:"space-y-3",children:e.map(m=>{var v;const g=d.agentOverrides[m]??Lp(),b=x=>l(T=>({...T,agentOverrides:{...T.agentOverrides,[m]:{...T.agentOverrides[m]??Lp(),...x}}}));return w.jsxs("div",{className:"boomi-card p-3 space-y-3",children:[w.jsxs("div",{className:"space-y-0.5",children:[w.jsx("div",{className:"text-sm font-semibold",children:((v=s==null?void 0:s.find(x=>x.id===m))==null?void 0:v.label)??m}),w.jsx("div",{className:"text-xs font-mono opacity-50",children:m})]}),w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Card title",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:g.label,placeholder:"Agent name",onChange:x=>b({label:x.target.value})})]}),w.jsxs("label",{className:"boomi-form-label",children:["Card description",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:g.description,placeholder:"Brief description",onChange:x=>b({description:x.target.value})})]}),w.jsxs("label",{className:"boomi-form-label",children:["Icon",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:Ns.some(x=>x.value===g.icon)?g.icon:"__custom__",onChange:x=>b({icon:x.target.value==="__custom__"?g.icon:x.target.value}),children:[!Ns.some(x=>x.value===g.icon)&&w.jsxs("option",{value:"__custom__",children:[g.icon," (custom)"]}),Ns.map(x=>w.jsx("option",{value:x.value,children:x.label},x.value))]})]}),w.jsxs("label",{className:"boomi-form-label",children:["Button label",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:g.buttonLabel,placeholder:"Launch",onChange:x=>b({buttonLabel:x.target.value})})]})]}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:g.hideIcon,onChange:x=>b({hideIcon:x.target.checked})}),"Hide icon"]})]},m)})})]})]})});function nH(t){try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}const oH=({isOpen:t,onClose:e,onSubmit:n,isSaving:o,defaultOrigins:i,availableAgents:r})=>{const[s,c]=M.useState(""),[a,d]=M.useState(null),[l,u]=M.useState(!1),[f,h]=M.useState([]),[p,m]=M.useState(""),g=M.useRef(null),b=M.useRef(null),v=M.useCallback(K=>{g.current=K,m(q=>{const X=JSON.stringify(K,null,2);return X!==q?X:q})},[]),[x,T]=M.useState("single"),[y,E]=M.useState(""),[_,N]=M.useState([]),[C,L]=M.useState(null),[$,k]=M.useState(null),[I,S]=M.useState(null),[A,O]=M.useState("builder"),P=(K,q)=>(K.length>0?K:["agent-id"]).reduce((J,se)=>(J[se]={transport:"boomi-direct",ui:{mode:q,modal:{width:500,height:600,position:{corner:"bottom-right",offsetX:20,offsetY:100}},sidebar:{show:q==="full",width:280},welcome:{title:"Let's Talk",subtitle:"Ask me about your Boomi deployment."}}},J),{}),U=JSON.stringify(((K,q)=>{const X={transport:"boomi-direct",theme:{allowThemes:!0,defaultTheme:"boomi"},cssVarsByTheme:{oem:{"--boomi-root-bg-color":"#0b1220","--boomi-root-fg-color":"#e5e7eb","--boomi-page-bg-color":"#0b1220","--boomi-page-fg-color":"#e5e7eb","--boomi-header-bg-color":"rgba(15, 23, 42, 0.8)","--boomi-header-fg-color":"#e5e7eb","--boomi-btn-primary-bg":"#2563eb","--boomi-btn-primary-fg":"#ffffff","--boomi-card-bg":"#0f172a","--boomi-card-border":"#1f2937","--boomi-menu-bg":"#0f172a","--boomi-menu-fg":"#e5e7eb","--boomi-modal-bg":"#0f172a","--boomi-modal-fg":"#e5e7eb","--boomi-input-bg":"#0b1220","--boomi-input-fg":"#e5e7eb"}}};K==="list"&&(X.components={agentList:{launcher:{position:{corner:"bottom-right",offsetX:20,offsetY:40},shape:"pill",label:"Find an Agent",icon:"bot",hideIcon:!1},modal:{width:500,height:600,position:{corner:"bottom-right",offsetX:20,offsetY:100}},welcome:{title:"Agents",subtitle:"Search for an agent and click to launch."}}});const J=q.length>0?q:["agent-id"];return X.agents=P(J,K==="single"?"modal":"full"),X})(x,x==="single"?y?[y]:[]:_),null,2);M.useEffect(()=>{t&&(c(""),d(null),u(!1),h([]),m(""),T("single"),E(""),N([]),L(null),k(null),S(null),O("builder"))},[t]),M.useEffect(()=>{!t||!(r!=null&&r.length)||(E(K=>K||r[0].id),N(K=>K.length?K:[r[0].id]))},[t,r]),M.useEffect(()=>{x==="single"?!y&&_[0]&&E(_[0]):_.length===0&&y&&N([y])},[x,_,y]);const H=K=>{N(q=>q.includes(K)?q.filter(X=>X!==K):[...q,K])},G=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`project_${crypto.randomUUID()}`:`project_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`,W=async()=>{var he;if(!s.trim()){u(!0),d("Project name is required.");return}d(null);const K=x==="single"?y?[y]:[]:_;if(!K.length){L("Select at least one agent");return}L(null);let q;if(A==="builder")q=((he=b.current)==null?void 0:he.getConfig())??void 0;else{const ie=p.trim();if(ie)try{q=JSON.parse(ie)}catch{S("Config must be valid JSON");return}}S(null);const X=q&&typeof q=="object"?{...q}:{},J=X.project&&typeof X.project=="object"?{...X.project}:{};X.project={...J,embedType:x,agentIds:K};const se=Array.from(new Set(f.map(ie=>ie.trim()).filter(Boolean)));if(!se.length){k("At least one allowed origin is required.");return}for(const ie of se)if(!nH(ie)){k(`Invalid origin (must be http/https): ${ie}`);return}k(null);const Y=G();if(x==="single"&&y){const ie={...X.agents??{}};ie[y]&&!ie[Y]&&(ie[Y]=ie[y],X.agents=ie)}console.log("[AddAgentModal] submitting configBase:",JSON.stringify(X,null,2)),await n({agentId:Y,boomiAgentId:x==="single"?y:void 0,label:s.trim()||void 0,allowedOrigins:se,config:X})},Q=()=>{h(K=>[...K,""])},V=(K,q)=>{h(X=>X.map((J,se)=>se===K?q:J))},j=K=>{h(q=>q.filter((X,J)=>J!==K))};return w.jsxs(Jn,{isOpen:t,title:"Add Project",description:"Create a new embedded agent group and its allowed embed origins.",onClose:e,onSubmit:W,submitLabel:o?"Saving...":"Create Project",showSaveButton:!o,children:[w.jsxs("div",{className:"boomi-card p-4 space-y-2",children:[w.jsx("div",{className:"text-sm font-semibold",children:"Project Summary"}),w.jsxs("div",{className:"text-xs opacity-80",children:["Embed type: ",w.jsx("strong",{children:x==="single"?"Single Agent":x==="tiles"?"Multi-Agent (Tiles)":"Multi-Agent (List)"})]}),w.jsxs("div",{className:"text-xs opacity-80",children:["Selected agents: ",w.jsx("strong",{children:x==="single"?y?1:0:_.length})]}),w.jsx("div",{className:"text-xs opacity-70",children:"You can start with the form below and optionally layer in advanced JSON config."})]}),w.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[w.jsxs("div",{className:"space-y-4",children:[w.jsx(mn,{formName:"agentAdd",label:"Project Name",required:!0,inputName:"name",readOnly:!1,value:s,onChange:K=>{c(K.target.value),a&&d(null)},onBlur:()=>{u(!0),s.trim()||d("Project name is required.")},placeholder:"Customer Support Project"}),l&&a&&w.jsx("div",{className:"boomi-form-error",children:a}),w.jsxs("label",{className:"boomi-form-label",children:["Embed Type",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:x,onChange:K=>T(K.target.value),children:[w.jsx("option",{value:"single",children:"Single Agent"}),w.jsx("option",{value:"tiles",children:"Multi-Agent (Tiles)"}),w.jsx("option",{value:"list",children:"Multi-Agent (Pill + Modal List)"})]})]}),x==="single"?w.jsxs("label",{className:"boomi-form-label",children:["Agent",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:y,onChange:K=>E(K.target.value),children:[(r??[]).length===0&&w.jsx("option",{value:"",children:"No agents available"}),(r??[]).map(K=>w.jsx("option",{value:K.id,children:K.label},K.id))]}),C&&w.jsx("div",{className:"text-xs text-red-500 mt-1",children:C})]}):w.jsxs("div",{children:[w.jsx("label",{className:"boomi-form-label",children:"Agents"}),w.jsx("div",{className:"boomi-input w-full rounded-md p-2 text-sm space-y-2 max-h-48 overflow-auto",children:(r??[]).length===0?w.jsx("div",{className:"text-xs opacity-70",children:"No agents available"}):(r??[]).map(K=>w.jsxs("label",{className:"flex items-center gap-2",children:[w.jsx("input",{type:"checkbox",checked:_.includes(K.id),onChange:()=>H(K.id)}),w.jsx("span",{className:"text-xs",children:K.label})]},K.id))}),C&&w.jsx("div",{className:"text-xs text-red-500 mt-1",children:C})]})]}),w.jsx("div",{className:"space-y-4",children:w.jsxs("div",{className:"space-y-2",children:[w.jsx("label",{className:"boomi-form-label",children:"Allowed Origins"}),w.jsx("div",{className:"text-xs opacity-70",children:"Select origins from your CORS list. If you don’t see one you need, add it first in the CORS page."}),w.jsxs("div",{className:"space-y-2",children:[f.length===0&&w.jsx("div",{className:"text-xs opacity-70",children:"No origins selected."}),f.map((K,q)=>{const X=new Set(f.map(Y=>Y.trim()).filter(Boolean)),J=(i??[]).filter(Y=>Y===K||!X.has(Y)),se=J.includes(K);return w.jsxs("div",{className:"flex items-center gap-2",children:[w.jsxs("select",{className:"boomi-input w-full rounded-md p-2 text-sm",value:K,onChange:Y=>V(q,Y.target.value),children:[!K&&w.jsx("option",{value:"",children:"Select an origin"}),se?null:K?w.jsx("option",{value:K,children:K}):null,J.map(Y=>w.jsx("option",{value:Y,children:Y},Y))]}),w.jsx("span",{role:"button",tabIndex:0,className:"text-red-500 text-lg cursor-pointer",onClick:()=>j(q),onKeyDown:Y=>{(Y.key==="Enter"||Y.key===" ")&&j(q)},"aria-label":"Remove origin",children:w.jsx(io,{})})]},`${K}-${q}`)})]}),w.jsx("div",{className:"flex",children:w.jsx(it,{toggle:!1,primary:!1,showIcon:!1,label:"Add Allowed Origin",onClick:Q})}),$&&w.jsx("div",{className:"text-xs text-red-500",children:$}),w.jsx("div",{className:"text-xs opacity-70",children:"Add new origins from the CORS page before selecting them here."})]})})]}),w.jsxs("div",{className:"space-y-3",children:[w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-sm font-semibold",children:"UI Configuration"}),w.jsx("div",{className:"text-xs opacity-70",children:"Optional. Use JSON to customize themes, layout, and agent UI beyond the form inputs."})]}),w.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-[var(--boomi-card-bg)] p-1 border border-[var(--boomi-card-border)]",children:[w.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${A==="builder"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>O("builder"),children:"Builder"}),w.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${A==="json"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>O("json"),children:"JSON"})]})]}),A==="builder"?w.jsx(sC,{ref:b,embedType:x,agentIds:x==="single"?y?[y]:[]:_,configRaw:p,onChangeConfig:v,syncFromConfig:!1,availableAgents:r}):w.jsxs(w.Fragment,{children:[w.jsx(oC,{label:"Config (JSON)",value:p,placeholder:U,error:I,onChange:m}),w.jsx("div",{className:"flex justify-end",children:w.jsx(it,{toggle:!1,primary:!1,showIcon:!1,label:"Insert Starter Config",onClick:()=>m(U)})})]})]})]})},iH=({isOpen:t,agentId:e,onClose:n,onConfirm:o,isDeleting:i})=>w.jsx(Jn,{isOpen:t,title:"Delete Agent",description:"Remove this agent and all associated public tokens.",onClose:n,onSubmit:o,submitLabel:i?"Deleting...":"Delete",showSaveButton:!i,children:w.jsxs("p",{className:"text-sm",children:["Are you sure you want to delete"," ",w.jsx("span",{className:"font-semibold",children:e}),"?"]})});function aC(t){if(t.trim().toLowerCase()==="null")return!0;try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}const rH=({isOpen:t,agentId:e,label:n,allowedOrigins:o,defaultOrigins:i,onAddOrigin:r,config:s,onClose:c,onSubmit:a,isSaving:d,availableAgents:l})=>{const[u,f]=M.useState(""),[h,p]=M.useState([]),[m,g]=M.useState(""),[b,v]=M.useState(!1),[x,T]=M.useState(""),[y,E]=M.useState(0),[_,N]=M.useState(null),[C,L]=M.useState(null),[$,k]=M.useState("builder"),I=(Q,V)=>(Q.length>0?Q:["agent-id"]).reduce((K,q)=>(K[q]={transport:"boomi-direct",ui:{mode:V,modal:{width:500,height:600,position:{corner:"bottom-right",offsetX:20,offsetY:100}},sidebar:{show:V==="full",width:280},welcome:{title:"Let's Talk",subtitle:"Ask me about your Boomi deployment."}}},K),{}),S=(Q,V)=>{const j={transport:"boomi-direct",theme:{allowThemes:!0,defaultTheme:"boomi"},cssVarsByTheme:{oem:{"--boomi-root-bg-color":"#0b1220","--boomi-root-fg-color":"#e5e7eb","--boomi-page-bg-color":"#0b1220","--boomi-page-fg-color":"#e5e7eb","--boomi-header-bg-color":"rgba(15, 23, 42, 0.8)","--boomi-header-fg-color":"#e5e7eb","--boomi-btn-primary-bg":"#2563eb","--boomi-btn-primary-fg":"#ffffff","--boomi-card-bg":"#0f172a","--boomi-card-border":"#1f2937","--boomi-menu-bg":"#0f172a","--boomi-menu-fg":"#e5e7eb","--boomi-modal-bg":"#0f172a","--boomi-modal-fg":"#e5e7eb","--boomi-input-bg":"#0b1220","--boomi-input-fg":"#e5e7eb"}}};Q==="list"&&(j.components={agentList:{launcher:{position:{corner:"bottom-right",offsetX:20,offsetY:40},shape:"pill",label:"Find an Agent",icon:"bot",hideIcon:!1},modal:{width:500,height:600,position:{corner:"bottom-right",offsetX:20,offsetY:100}},welcome:{title:"Agents",subtitle:"Search for an agent and click to launch."}}});const K=V.length>0?V:["agent-id"];return j.agents=I(K,Q==="single"?"modal":"full"),j},O=(()=>{try{const Q=x.trim()?JSON.parse(x):null,V=Q&&typeof Q=="object"?Q.project:null,j=typeof(V==null?void 0:V.embedType)=="string"?V.embedType:"single",K=Array.isArray(V==null?void 0:V.agentIds)?V.agentIds.filter(Boolean):[];return{embedType:j,agentIds:K}}catch{return{embedType:"single",agentIds:[]}}})(),P=O.agentIds.length>0?O.agentIds:e?[e]:[],R=JSON.stringify(S(O.embedType,P),null,2);M.useEffect(()=>{if(t){f(n??"");const Q=(o&&o.length?o:i)??[];p(Q),g(""),T(s?JSON.stringify(s,null,2):""),E(V=>V+1),N(null),L(null),k("builder")}},[t,n,s,o,i]);const B=async()=>{if(!e)return;let Q;const V=x.trim();if(V)try{Q=JSON.parse(V)}catch{L("Config must be valid JSON");return}L(null);const j=Array.from(new Set(h.map(K=>K.trim()).filter(Boolean)));if(!j.length){N("At least one allowed origin is required.");return}for(const K of j)if(!aC(K)){N(`Invalid origin (must be http/https): ${K}`);return}if(N(null),Q&&e){const K=Q.project,q=K==null?void 0:K.embedType,X=Array.isArray(K==null?void 0:K.agentIds)?K.agentIds[0]:null;if(q==="single"&&X){const J={...Q.agents??{}};J[X]&&!J[e]&&(J[e]=J[X],Q.agents=J)}}await a({agentId:e,label:u.trim()||void 0,allowedOrigins:j,config:Q})},U=()=>{const Q=i??[],V=new Set(h.map(K=>K.trim()).filter(Boolean)),j=Q.find(K=>!V.has(K))??"";p(K=>[...K,j])},H=(Q,V)=>{p(j=>j.map((K,q)=>q===Q?V:K))},G=Q=>{p(V=>V.filter((j,K)=>K!==Q))},W=async()=>{const Q=m.trim();if(!Q){N("Enter an origin before adding.");return}if(!aC(Q)){N(`Invalid origin (must be http/https): ${Q}`);return}if(N(null),!r){p(V=>V.includes(Q)?V:[...V,Q]),g("");return}v(!0);try{await r(Q),p(V=>V.includes(Q)?V:[...V,Q]),g("")}catch(V){N((V==null?void 0:V.message)||"Failed to add origin.")}finally{v(!1)}};return w.jsxs(Jn,{isOpen:t,title:"Edit Agent",description:"Update agent details and allowed origins.",onClose:c,onSubmit:B,submitLabel:d?"Saving...":"Save Changes",showSaveButton:!d,children:[w.jsxs("div",{className:"boomi-card p-4 space-y-2",children:[w.jsx("div",{className:"text-sm font-semibold",children:"Agent Overview"}),w.jsxs("div",{className:"text-xs opacity-80",children:["Agent ID: ",w.jsx("strong",{children:e??"—"})]}),w.jsx("div",{className:"text-xs opacity-70",children:"Update the friendly name, allowed origins, and optional config overrides below."})]}),w.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[w.jsxs("div",{className:"space-y-4",children:[w.jsx(mn,{formName:"agentEdit",label:"Name",required:!1,inputName:"name",readOnly:!1,value:u,onChange:Q=>f(Q.target.value),placeholder:"Customer Support Agent"}),w.jsx(mn,{formName:"agentEdit",label:"Agent ID",required:!0,inputName:"agentId",readOnly:!0,value:e??"",onChange:()=>{},helperText:"This is the Boomi Agent ID for your agent and cannot be changed."})]}),w.jsxs("div",{className:"space-y-2",children:[w.jsx("label",{className:"boomi-form-label",children:"Allowed Origins"}),w.jsxs("div",{className:"space-y-2",children:[h.length===0&&w.jsx("div",{className:"text-xs opacity-70",children:"No origins selected."}),h.map((Q,V)=>{const j=new Set(h.map(X=>X.trim()).filter(Boolean)),K=(i??[]).filter(X=>X===Q||!j.has(X)),q=K.includes(Q);return w.jsxs("div",{className:"flex items-center gap-2",children:[w.jsxs("select",{className:"boomi-input w-full rounded-md p-2 text-sm",value:Q,onChange:X=>H(V,X.target.value),children:[!Q&&w.jsx("option",{value:"",children:"Select an origin"}),q?null:Q?w.jsx("option",{value:Q,children:Q}):null,K.map(X=>w.jsx("option",{value:X,children:X},X))]}),w.jsx("span",{role:"button",tabIndex:0,className:"text-red-500 text-lg cursor-pointer",onClick:()=>G(V),onKeyDown:X=>{(X.key==="Enter"||X.key===" ")&&G(V)},"aria-label":"Remove origin",children:w.jsx(io,{})})]},`${Q}-${V}`)})]}),_&&w.jsx("div",{className:"text-xs text-red-500",children:_}),w.jsxs("div",{className:"flex items-center gap-2",children:[w.jsx(it,{toggle:!1,primary:!1,showIcon:!1,label:"Add Row",onClick:U}),w.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[w.jsx("input",{className:"boomi-input w-full rounded-md p-2 text-sm",value:m,onChange:Q=>g(Q.target.value),placeholder:"https://example.com"}),w.jsx("button",{type:"button",className:"boomi-btn-primary px-2 py-2 text-xs",onClick:W,disabled:b,"aria-label":"Add new origin",children:w.jsx(sr,{})})]})]}),w.jsx("div",{className:"text-xs opacity-70",children:"Pick from existing CORS origins or add a new one here."})]})]}),w.jsxs("div",{className:"space-y-3",children:[w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-sm font-semibold",children:"UI Configuration"}),w.jsx("div",{className:"text-xs opacity-70",children:"Optional. Use JSON to customize themes, layout, and agent UI."})]}),w.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-[var(--boomi-card-bg)] p-1 border border-[var(--boomi-card-border)]",children:[w.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${$==="builder"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>k("builder"),children:"Builder"}),w.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${$==="json"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>k("json"),children:"JSON"})]})]}),$==="builder"?w.jsx(sC,{embedType:O.embedType,agentIds:P,configRaw:x,onChangeConfig:Q=>{const V=JSON.stringify(Q,null,2);V!==x&&T(V)},syncFromConfig:!1,availableAgents:l},y):w.jsxs(w.Fragment,{children:[w.jsx(oC,{label:"Config (JSON)",value:x,placeholder:R,error:C,onChange:T}),w.jsx("div",{className:"flex justify-end",children:w.jsx(it,{toggle:!1,primary:!1,showIcon:!1,label:"Insert Starter Config",onClick:()=>T(R)})})]})]})]})},sH=({isOpen:t,agentId:e,tokenId:n,agents:o,primaryAccountId:i,onTokenGenerated:r,onClose:s})=>{const[c,a]=M.useState(!1),[d,l]=M.useState(!1),[u,f]=M.useState("single"),[h,p]=M.useState([]),[m,g]=M.useState(""),[b,v]=M.useState(!1),[x,T]=M.useState(null),[y,E]=M.useState(null),{createAgent:_}=nC(),N=M.useMemo(()=>(o??[]).map(A=>{var O;return{id:A.agentId,label:((O=A.label)==null?void 0:O.trim())||A.agentId,tokenIds:A.publicTokenIds??[]}}),[o]);M.useEffect(()=>{var A;if(!t)return;const S=e||((A=N[0])==null?void 0:A.id)||"";g(S),p(S?[S]:[]),T(null),E(null),e&&f("single")},[t,e,N]);const C=S=>{p(A=>A.includes(S)?A.filter(O=>O!==S):[...A,S])},L=async()=>{const S=n??y;if(!i||!S)return;const A=h.filter(O=>{var R;const P=N.find(B=>B.id===O);return!((R=P==null?void 0:P.tokenIds)!=null&&R.includes(S))});if(A.length===0){T("Token already attached to selected agents.");return}v(!0),T(null);try{await Promise.all(A.map(O=>_({primaryAccountId:i,agentId:O,publicTokenIds:[S]}))),T("Token attached to selected agents.")}catch(O){T((O==null?void 0:O.message)||"Failed to attach token to selected agents.")}finally{v(!1)}},$=async()=>{var A;if(!i)return;const S=u==="single"?m:h[0];if(!S){T("Select at least one agent first.");return}v(!0),T(null);try{const P=((A=(await _({primaryAccountId:i,agentId:S,createToken:!0})).createdToken)==null?void 0:A.tokenId)||null;if(!P)throw new Error("Token generation failed.");E(P),r==null||r(P);const R=u==="single"?[]:h.filter(B=>B!==S);R.length>0&&await Promise.all(R.map(B=>_({primaryAccountId:i,agentId:B,publicTokenIds:[P]}))),T("Token generated and attached to selected agents.")}catch(O){T((O==null?void 0:O.message)||"Failed to generate token.")}finally{v(!1)}},k=M.useMemo(()=>{const S=n??y;if(!S)return"";const A=m||e||"";return h.length,`<link rel="stylesheet" href="https://cdn.boomi.space/cdn/embedkit-cdn.css" />
|
|
2106
|
+
`),[c]);return w.jsxs("div",{children:[w.jsxs("label",{className:"boomi-form-label inline-flex items-center gap-2",children:[w.jsx("span",{children:t}),e]}),w.jsxs("div",{className:["flex w-full rounded-md border overflow-hidden","bg-[color-mix(in_srgb,var(--boomi-card-bg,#ffffff)_92%,#000000)]",r?"boomi-input--error":""].join(" ").trim(),children:[w.jsx("pre",{className:["m-0 py-2 px-3 text-xs font-mono leading-5","text-[color-mix(in_srgb,var(--boomi-card-fg,#111)_55%,transparent)]","bg-[color-mix(in_srgb,var(--boomi-card-bg,#ffffff)_86%,#000000)]","border-r border-[color-mix(in_srgb,var(--boomi-card-border,#e5e7eb)_80%,transparent)]","select-none text-right min-w-[2.5rem]"].join(" "),children:a}),w.jsx("textarea",{className:["boomi-input flex-1 rounded-none border-0 font-mono text-xs leading-5","bg-transparent p-2 min-h-[120px]","focus:outline-none"].join(" "),placeholder:o,value:n,onChange:d=>s(d.target.value)})]}),i&&w.jsx("p",{className:"boomi-form-helper",children:i}),r&&w.jsx("p",{className:"boomi-form-error",children:r})]})},Ns=[{value:"",label:"None"},{value:"🤖",label:"🤖 Robot"},{value:"💬",label:"💬 Chat"},{value:"🗣️",label:"🗣️ Speaking"},{value:"✨",label:"✨ Sparkles"},{value:"🧠",label:"🧠 Brain"},{value:"💡",label:"💡 Idea"},{value:"🚀",label:"🚀 Rocket"},{value:"⚡",label:"⚡ Lightning"},{value:"🔍",label:"🔍 Search"},{value:"🛠️",label:"🛠️ Tools"},{value:"🤝",label:"🤝 Handshake"},{value:"🌐",label:"🌐 Globe"},{value:"🎯",label:"🎯 Target"},{value:"📊",label:"📊 Analytics"}],kr=["bottom-right","bottom-left","top-right","top-left"],Lp=()=>({label:"",description:"",icon:"🤖",hideIcon:!1,buttonLabel:"Launch"}),JB=t=>/^#[0-9a-fA-F]{3,8}$/.test(t.trim()),iC=["--boomi-font","--default-font-family","--boomi-accent","--boomi-agent-bg","--boomi-agent-blur","--boomi-agent-border","--boomi-agent-bubble-agent-bg","--boomi-agent-bubble-agent-border","--boomi-agent-bubble-agent-fg","--boomi-agent-bubble-border","--boomi-agent-bubble-shadow","--boomi-agent-bubble-user-bg","--boomi-agent-bubble-user-border","--boomi-agent-bubble-user-fg","--boomi-agent-card-tint","--boomi-agent-chat-bg","--boomi-agent-chat-border","--boomi-agent-chat-fg","--boomi-agent-close-bg-hover","--boomi-agent-close-fg","--boomi-agent-close-hover-fg","--boomi-agent-compose-bg","--boomi-agent-compose-border","--boomi-agent-compose-input-bg","--boomi-agent-compose-input-border","--boomi-agent-compose-secondary-bg","--boomi-agent-compose-secondary-border","--boomi-agent-compose-shadow","--boomi-agent-fg","--boomi-agent-header-bg","--boomi-agent-header-border","--boomi-agent-pane-bg","--boomi-agent-pane-bg-color","--boomi-agent-pane-fg","--boomi-agent-pane-fg-color","--boomi-agent-radius","--boomi-agent-ring","--boomi-agent-row-shimmer-opacity","--boomi-agent-row-tint","--boomi-agent-section-bg","--boomi-agent-section-border","--boomi-agent-section-fg","--boomi-agent-section-shadow","--boomi-agent-shadow","--boomi-agent-shimmer-1","--boomi-agent-shimmer-2","--boomi-agent-shimmer-angle","--boomi-agent-shimmer-direction","--boomi-agent-shimmer-opacity","--boomi-agent-shimmer-speed","--boomi-agent-tab-bg","--boomi-agent-tab-bg-active","--boomi-agent-tab-border","--boomi-agent-tab-border-active","--boomi-agent-tab-fg","--boomi-agent-tab-fg-active","--boomi-agent-tab-shadow-active","--boomi-agent-text-bg","--boomi-agent-text-border","--boomi-agent-text-copy-bg","--boomi-agent-text-copy-bg-hover","--boomi-agent-text-copy-fg","--boomi-agent-text-fg","--boomi-agent-thread-separator","--boomi-agent-update-bg","--boomi-agent-update-border","--boomi-agent-update-content-bg","--boomi-agent-update-content-fg","--boomi-agent-update-desc-fg","--boomi-agent-update-fg","--boomi-agent-update-radius","--boomi-agent-update-shadow","--boomi-agent-update-title-fg","--boomi-angle","--boomi-btn-primary-bg","--boomi-btn-primary-bg-active","--boomi-btn-primary-bg-hover","--boomi-btn-primary-border","--boomi-btn-primary-border-active","--boomi-btn-primary-border-hover","--boomi-btn-primary-fg","--boomi-btn-primary-fg-active","--boomi-btn-primary-fg-hover","--boomi-btn-primary-shadow","--boomi-btn-primary-shadow-active","--boomi-btn-primary-shadow-hover","--boomi-btn-secondary-bg","--boomi-btn-secondary-bg-active","--boomi-btn-secondary-bg-hover","--boomi-btn-secondary-border","--boomi-btn-secondary-border-active","--boomi-btn-secondary-border-hover","--boomi-btn-secondary-fg","--boomi-btn-secondary-fg-active","--boomi-btn-secondary-fg-hover","--boomi-btn-secondary-shadow","--boomi-btn-secondary-shadow-active","--boomi-btn-secondary-shadow-hover","--boomi-card-bg","--boomi-card-border","--boomi-card-fg","--boomi-card-hover-scale","--boomi-card-hover-shadow","--boomi-card-radius","--boomi-card-shadow","--boomi-chip-bg","--boomi-chip-border","--boomi-chip-error-bg","--boomi-chip-error-border","--boomi-chip-error-fg","--boomi-chip-fg","--boomi-chip-pulse-color","--boomi-chip-success-bg","--boomi-chip-success-border","--boomi-chip-success-fg","--boomi-chip-warning-bg","--boomi-chip-warning-border","--boomi-chip-warning-fg","--boomi-root-bg-color","--boomi-root-fg-color","--boomi-page-bg-color","--boomi-page-fg-color","--boomi-muted","--boomi-header-bg-color","--boomi-header-fg-color","--boomi-header-fg-hover","--boomi-header-border-color","--boomi-header-shadow","--boomi-input-bg","--boomi-input-fg","--boomi-input-placeholder","--boomi-input-border","--boomi-input-shadow","--boomi-input-border-focus","--boomi-input-shadow-focus","--boomi-input-outline-focus","--boomi-input-bg-disabled","--boomi-input-fg-disabled","--boomi-input-border-disabled","--boomi-input-border-invalid","--boomi-input-outline-invalid","--boomi-table-header-bg","--boomi-table-header-fg","--boomi-table-header-border","--boomi-table-row-odd-bg","--boomi-table-row-even-bg","--boomi-table-row-hover-shadow","--boomi-menu-bg","--boomi-menu-fg","--boomi-menu-border","--boomi-menu-shadow","--boomi-menu-item-bg","--boomi-menu-item-bg-hover","--boomi-menu-item-fg","--boomi-menu-item-fg-hover","--boomi-menu-divider","--boomi-menu-danger-fg","--boomi-menu-danger-fg-hover","--boomi-menu-danger-bg-hover","--boomi-modal-overlay-bg","--boomi-modal-bg","--boomi-modal-fg","--boomi-modal-border","--boomi-modal-shadow","--boomi-modal-close-fg","--boomi-modal-close-hover-fg","--boomi-form-label-fg","--boomi-form-helper-fg","--boomi-form-error-fg","--boomi-form-required-fg","--boomi-select-bg","--boomi-select-fg","--boomi-select-border","--boomi-select-shadow","--boomi-select-border-focus","--boomi-select-shadow-focus","--boomi-select-icon","--boomi-options-bg","--boomi-options-fg","--boomi-options-border","--boomi-options-shadow","--boomi-options-search-bg","--boomi-option-bg-active","--boomi-option-fg-selected","--boomi-loader-dot-bg","--boomi-loader-dot-size","--boomi-loader-dot1-opacity","--boomi-loader-dot2-opacity","--boomi-loader-dot3-opacity","--boomi-loader-msg-fg","--boomi-spinner-overlay-bg","--boomi-spinner-ring-color","--boomi-spinner-ping-color","--boomi-spinner-message-fg","--boomi-spinner-size","--boomi-spinner-border-width","--boomi-wizard-step-dot-bg","--boomi-wizard-step-dot-fg","--boomi-wizard-step-dot-border","--boomi-wizard-step-dot-shadow","--boomi-wizard-step-dot-bg-active","--boomi-wizard-step-dot-fg-active","--boomi-wizard-step-dot-border-active","--boomi-wizard-step-dot-shadow-active","--boomi-wizard-step-dot-bg-completed","--boomi-wizard-step-dot-fg-completed","--boomi-wizard-step-dot-border-completed","--boomi-wizard-step-dot-shadow-completed","--boomi-wizard-connector-bg","--boomi-wizard-label-fg","--boomi-wizard-card-bg","--boomi-wizard-card-fg","--boomi-wizard-card-border","--boomi-wizard-card-shadow","--boomi-wizard-link-fg","--boomi-wizard-link-fg-hover","--boomi-wizard-link-strong-fg","--boomi-notice-warning-bg","--boomi-notice-warning-fg","--boomi-notice-warning-border","--boomi-notice-success-bg","--boomi-notice-success-fg","--boomi-notice-success-border","--boomi-notice-error-bg","--boomi-notice-error-fg","--boomi-notice-error-border","--boomi-notice-shadow","--boomi-notice-radius","--boomi-update-bg","--boomi-update-fg","--boomi-update-border","--boomi-update-shadow","--boomi-update-title-fg","--boomi-update-desc-fg","--boomi-update-radius","--boomi-update-content","--boomi-tablist-border","--boomi-tab-bg","--boomi-tab-fg","--boomi-tab-border","--boomi-tab-bg-hover","--boomi-tab-bg-active","--boomi-tab-fg-active","--boomi-tab-border-active","--boomi-map-line","--boomi-map-line-width","--boomi-map-line-filter","--boomi-map-heading-fg","--boomi-map-card-bg","--boomi-map-card-border","--boomi-map-card-shadow","--boomi-map-card-shadow-hover","--boomi-map-card-transform-hover","--boomi-map-source-bg-mapped","--boomi-map-source-border-mapped","--boomi-map-source-outline","--boomi-map-target-bg-mapped","--boomi-map-target-border-mapped","--boomi-map-target-outline","--boomi-map-func-bg","--boomi-map-func-fg","--boomi-map-func-title-fg","--boomi-map-pin-source-bg","--boomi-map-pin-target-bg","--boomi-map-pin-input-bg","--boomi-map-pin-output-bg","--boomi-map-pin-badge-bg","--boomi-map-pin-badge-fg","--boomi-map-pin-danger-bg","--boomi-map-pulse-color","--boomi-map-pin-pulse","--boomi-map-add-bg","--boomi-map-add-fg","--boomi-map-add-border","--boomi-map-add-shadow","--boomi-map-add-bg-hover","--boomi-sched-card-bg","--boomi-sched-card-fg","--boomi-sched-card-border","--boomi-sched-card-shadow","--boomi-sched-card-shadow-hover","--boomi-sched-card-radius","--boomi-sched-header-bg","--boomi-sched-header-fg","--boomi-sched-header-border","--boomi-sched-header-shadow","--boomi-sched-toggle-fg","--boomi-sched-toggle-fg-hover","--boomi-sched-row-bg","--boomi-sched-row-border","--boomi-sched-row-shadow","--boomi-sched-row-hover-shadow","--boomi-sched-label-fg","--boomi-sched-helper-fg","--boomi-sched-error-fg","--boomi-sched-select-bg","--boomi-sched-select-fg","--boomi-sched-select-border","--boomi-sched-select-shadow","--boomi-sched-select-border-focus","--boomi-sched-select-shadow-focus","--boomi-sched-input-bg","--boomi-sched-input-fg","--boomi-sched-input-border","--boomi-sched-input-shadow","--boomi-sched-input-border-focus","--boomi-sched-input-shadow-focus","--boomi-sched-checkbox-border","--boomi-sched-checkbox-bg","--boomi-sched-checkbox-bg-checked","--boomi-sched-checkbox-symbol","--boomi-sched-action-bg","--boomi-sched-action-fg","--boomi-sched-action-border","--boomi-sched-action-shadow","--boomi-sched-action-bg-hover","--boomi-conn-bg","--boomi-conn-border","--boomi-conn-card-shadow","--boomi-conn-heading-fg","--boomi-conn-field-bg","--boomi-conn-field-border","--boomi-conn-field-label-fg","--boomi-conn-field-error-fg","--boomi-conn-btn-save-bg","--boomi-conn-btn-save-fg","--boomi-conn-btn-auth-bg","--boomi-conn-btn-auth-fg","--boomi-conn-btn-disabled-bg","--boomi-conn-btn-disabled-fg","--boomi-swal-bg","--boomi-swal-fg","--boomi-swal-border","--boomi-swal-shadow","--boomi-swal-title-fg","--boomi-swal-desc-fg","--boomi-swal-icon-success","--boomi-swal-icon-warning","--boomi-swal-icon-error","--boomi-swal-overlay-bg"],eH=()=>({themeSelection:"boomi",themeDefault:"boomi",themeCustomName:"",themeCustomVars:[],launcherCorner:"bottom-right",launcherOffsetX:"20",launcherOffsetY:"40",launcherShape:"pill",launcherLabel:"Find an Agent",launcherIcon:"🤖",launcherHideIcon:!1,listModalWidth:"500",listModalHeight:"600",listModalCorner:"bottom-right",listModalOffsetX:"20",listModalOffsetY:"100",listWelcomeTitle:"Agents",listWelcomeSubtitle:"Search for an agent and click to launch.",listHeaderShow:!0,listHeaderTitle:"Agents",listHeaderDescription:"Select an agent to launch.",listSearchShow:!0,tilesHeaderShow:!0,tilesHeaderTitle:"Agents",tilesHeaderDescription:"Browse and launch an agent.",tilesSearchShow:!0,tilesViewToggleShow:!0,agentUiMode:"modal",agentModalWidth:"600",agentModalHeight:"800",agentModalCorner:"top-right",agentModalOffsetX:"20",agentModalOffsetY:"40",agentSidebarShow:!0,agentSidebarWidth:"280",agentWelcomeTitle:"Let's Talk",agentWelcomeSubtitle:"Ask me about your Boomi deployment.",agentOverrides:{}}),po=t=>{const e=t.trim();if(!e)return;const n=Number(e);return Number.isNaN(n)?e:n},tH=(t,e,n,o)=>{var r,s,c,a,d,l,u,f,h,p,m,g,b,v,x,T,y,E,_,N,C,L,$,k,I,S,A,O;const i={...e};if(i.themeCustomVars=[],!t.trim())return i;try{const P=JSON.parse(t);if(P!=null&&P.theme&&typeof P.theme.defaultTheme=="string"){const K=P.theme.defaultTheme;K==="boomi"||K==="base"?(i.themeSelection=K,i.themeDefault=K,i.themeCustomName=""):(i.themeSelection="custom",i.themeDefault=K,i.themeCustomName=K);const q=P==null?void 0:P.cssVarsByTheme;let X=q==null?void 0:q[K],J=K;if((!X||typeof X!="object")&&q&&typeof q=="object"){const se=Object.keys(q)[0];se&&(X=q[se],J=se,J!=="boomi"&&J!=="base"&&(i.themeSelection="custom",i.themeCustomName=J,i.themeDefault=J))}X&&typeof X=="object"&&(i.themeCustomVars=Object.entries(X).map(([se,Y])=>({id:`var_${se}`,varName:se,value:typeof Y=="string"?Y:String(Y)})))}const R=(r=P==null?void 0:P.components)==null?void 0:r.agentList,B=(s=P==null?void 0:P.components)==null?void 0:s.agentTiles;if(n==="list"&&R){const K=R.launcher??{},q=K.position??{};kr.includes(q.corner)&&(i.launcherCorner=q.corner),q.offsetX!==void 0&&(i.launcherOffsetX=String(q.offsetX)),q.offsetY!==void 0&&(i.launcherOffsetY=String(q.offsetY)),(K.shape==="pill"||K.shape==="circle")&&(i.launcherShape=K.shape),typeof K.label=="string"&&(i.launcherLabel=K.label),typeof K.icon=="string"&&(i.launcherIcon=K.icon),typeof K.hideIcon=="boolean"&&(i.launcherHideIcon=K.hideIcon);const X=R.modal??{};X.width!==void 0&&(i.listModalWidth=String(X.width)),X.height!==void 0&&(i.listModalHeight=String(X.height));const J=X.position??{};kr.includes(J.corner)&&(i.listModalCorner=J.corner),J.offsetX!==void 0&&(i.listModalOffsetX=String(J.offsetX)),J.offsetY!==void 0&&(i.listModalOffsetY=String(J.offsetY)),(c=R.welcome)!=null&&c.title&&(i.listWelcomeTitle=R.welcome.title),(a=R.welcome)!=null&&a.subtitle&&(i.listWelcomeSubtitle=R.welcome.subtitle),((d=R.header)==null?void 0:d.show)!==void 0&&(i.listHeaderShow=!!R.header.show),(l=R.header)!=null&&l.title&&(i.listHeaderTitle=R.header.title),(u=R.header)!=null&&u.description&&(i.listHeaderDescription=R.header.description),((f=R.search)==null?void 0:f.show)!==void 0&&(i.listSearchShow=!!R.search.show)}n==="tiles"&&B&&(((h=B.header)==null?void 0:h.show)!==void 0&&(i.tilesHeaderShow=!!B.header.show),(p=B.header)!=null&&p.title&&(i.tilesHeaderTitle=B.header.title),(m=B.header)!=null&&m.description&&(i.tilesHeaderDescription=B.header.description),((g=B.search)==null?void 0:g.show)!==void 0&&(i.tilesSearchShow=!!B.search.show),((b=B.viewToggle)==null?void 0:b.show)!==void 0&&(i.tilesViewToggleShow=!!B.viewToggle.show));const U=(P==null?void 0:P.agents)??{},H=o.find(K=>U[K])??Object.keys(U)[0],G=H?U[H]:null;G!=null&&G.position&&typeof G.position=="object"&&"corner"in G.position&&(kr.includes(G.position.corner)&&(i.launcherCorner=G.position.corner),G.position.offsetX!==void 0&&(i.launcherOffsetX=String(G.position.offsetX)),G.position.offsetY!==void 0&&(i.launcherOffsetY=String(G.position.offsetY))),((G==null?void 0:G.shape)==="pill"||(G==null?void 0:G.shape)==="circle")&&(i.launcherShape=G.shape),typeof(G==null?void 0:G.label)=="string"&&(i.launcherLabel=G.label),typeof(G==null?void 0:G.icon)=="string"&&(i.launcherIcon=G.icon),typeof(G==null?void 0:G.hideIcon)=="boolean"&&(i.launcherHideIcon=G.hideIcon);const W=(G==null?void 0:G.ui)??{};(W.mode==="modal"||W.mode==="full")&&(i.agentUiMode=W.mode),((v=W.modal)==null?void 0:v.width)!==void 0&&(i.agentModalWidth=String(W.modal.width)),((x=W.modal)==null?void 0:x.height)!==void 0&&(i.agentModalHeight=String(W.modal.height)),(y=(T=W.modal)==null?void 0:T.position)!=null&&y.corner&&kr.includes(W.modal.position.corner)&&(i.agentModalCorner=W.modal.position.corner),((_=(E=W.modal)==null?void 0:E.position)==null?void 0:_.offsetX)!==void 0&&(i.agentModalOffsetX=String(W.modal.position.offsetX)),((C=(N=W.modal)==null?void 0:N.position)==null?void 0:C.offsetY)!==void 0&&(i.agentModalOffsetY=String(W.modal.position.offsetY));const Q=W.sessionScope==="mount"?!1:W.sessionScope==="multi"?!0:void 0,j=(((L=W.sidebar)==null?void 0:L.show)!==void 0?!!W.sidebar.show:void 0)??Q;if(j!==void 0&&(i.agentSidebarShow=j),(($=W.sidebar)==null?void 0:$.width)!==void 0&&(i.agentSidebarWidth=String(W.sidebar.width)),(k=W.welcome)!=null&&k.title&&(i.agentWelcomeTitle=W.welcome.title),(I=W.welcome)!=null&&I.subtitle&&(i.agentWelcomeSubtitle=W.welcome.subtitle),n==="list"||n==="tiles"){const K={};for(const q of o){const X=U[q];X&&(K[q]={label:typeof X.label=="string"?X.label:"",description:typeof((S=X.ui)==null?void 0:S.pageDescription)=="string"?X.ui.pageDescription:typeof((O=(A=X.ui)==null?void 0:A.welcome)==null?void 0:O.subtitle)=="string"?X.ui.welcome.subtitle:"",icon:typeof X.icon=="string"?X.icon:"🤖",hideIcon:typeof X.hideIcon=="boolean"?X.hideIcon:!1,buttonLabel:typeof X.buttonLabel=="string"?X.buttonLabel:"Launch"})}i.agentOverrides=K}}catch{return i}return i},rC=(t,e,n)=>{const o=t.themeSelection==="custom"?t.themeCustomName.trim()||t.themeDefault||"custom":t.themeSelection,i={transport:"boomi-direct",theme:{allowThemes:!0,defaultTheme:o}},r={};for(const c of t.themeCustomVars)c.varName&&c.value&&(r[c.varName]=c.value);Object.keys(r).length&&(i.cssVarsByTheme={[o]:r}),e==="list"&&(i.components={agentList:{launcher:{position:{corner:t.launcherCorner,offsetX:po(t.launcherOffsetX),offsetY:po(t.launcherOffsetY)},shape:t.launcherShape,label:t.launcherLabel,icon:t.launcherIcon,hideIcon:t.launcherHideIcon},modal:{width:po(t.listModalWidth),height:po(t.listModalHeight),position:{corner:t.listModalCorner,offsetX:po(t.listModalOffsetX),offsetY:po(t.listModalOffsetY)}},welcome:{title:t.listWelcomeTitle,subtitle:t.listWelcomeSubtitle},header:{show:t.listHeaderShow,title:t.listHeaderTitle,description:t.listHeaderDescription},search:{show:t.listSearchShow}}}),e==="tiles"&&(i.components={agentTiles:{header:{show:t.tilesHeaderShow,title:t.tilesHeaderTitle,description:t.tilesHeaderDescription},search:{show:t.tilesSearchShow},viewToggle:{show:t.tilesViewToggleShow}}});const s=n.length?n:["agent-id"];return i.agents=s.reduce((c,a)=>{const d=e==="list"||e==="tiles"?t.agentOverrides[a]??Lp():void 0,l={transport:"boomi-direct"};return e==="single"?(l.position={corner:t.launcherCorner,offsetX:po(t.launcherOffsetX),offsetY:po(t.launcherOffsetY)},l.shape=t.launcherShape,l.label=t.launcherLabel,l.icon=t.launcherIcon,l.hideIcon=t.launcherHideIcon):d&&(d.label&&(l.label=d.label),l.icon=d.icon,l.hideIcon=d.hideIcon,d.buttonLabel&&d.buttonLabel!=="Launch"&&(l.buttonLabel=d.buttonLabel)),l.ui={mode:t.agentUiMode,sessionScope:t.agentSidebarShow?"multi":"mount",modal:{width:po(t.agentModalWidth),height:po(t.agentModalHeight),position:{corner:t.agentModalCorner,offsetX:po(t.agentModalOffsetX),offsetY:po(t.agentModalOffsetY)}},sidebar:{show:t.agentSidebarShow,width:po(t.agentSidebarWidth)},welcome:{title:t.agentWelcomeTitle,subtitle:t.agentWelcomeSubtitle},...d!=null&&d.description?{pageDescription:d.description}:{}},c[a]=l,c},{}),i.project={embedType:e,agentIds:s},i},sC=M.forwardRef(({embedType:t,agentIds:e,configRaw:n,onChangeConfig:o,onUpdateBuilder:i,syncFromConfig:r=!1,availableAgents:s},c)=>{const a=M.useMemo(eH,[]),[d,l]=M.useState(a),u=M.useRef(!1);M.useImperativeHandle(c,()=>({getConfig:()=>rC(d,t,e)}),[d,t,e]),M.useEffect(()=>{(r||!u.current)&&(l(tH(n,a,t,e)),u.current=!0)},[n,a,t,e,r]),M.useEffect(()=>{i==null||i(d)},[d,i]),M.useEffect(()=>{const m=rC(d,t,e);o(m)},[d,t,e,o]);const f=()=>{const m=iC[0]??"--boomi-root-bg-color";l(g=>({...g,themeCustomVars:[...g.themeCustomVars,{id:`var_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,varName:m,value:""}]}))},h=(m,g)=>{l(b=>({...b,themeCustomVars:b.themeCustomVars.map(v=>v.id===m?{...v,...g}:v)}))},p=m=>{l(g=>({...g,themeCustomVars:g.themeCustomVars.filter(b=>b.id!==m)}))};return w.jsxs("div",{className:"boomi-card p-4 space-y-4",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-sm font-semibold",children:"Config Builder"}),w.jsx("div",{className:"text-xs opacity-70",children:"Updates the JSON configuration automatically as you make changes."})]}),w.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[w.jsxs("div",{className:"space-y-3",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Agent UI"}),w.jsxs("label",{className:"boomi-form-label",children:["Mode",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.agentUiMode,onChange:m=>l(g=>({...g,agentUiMode:m.target.value})),children:[w.jsx("option",{value:"modal",children:"Modal"}),w.jsx("option",{value:"full",children:"Full Page"})]})]}),d.agentUiMode==="modal"&&w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Modal width",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.agentModalWidth,onChange:m=>l(g=>({...g,agentModalWidth:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Modal height",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.agentModalHeight,onChange:m=>l(g=>({...g,agentModalHeight:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Modal corner",w.jsx("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.agentModalCorner,onChange:m=>l(g=>({...g,agentModalCorner:m.target.value})),children:kr.map(m=>w.jsx("option",{value:m,children:m},m))})]}),w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Offset X",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.agentModalOffsetX,onChange:m=>l(g=>({...g,agentModalOffsetX:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Offset Y",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.agentModalOffsetY,onChange:m=>l(g=>({...g,agentModalOffsetY:m.target.value}))})]})]})]}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:d.agentSidebarShow,onChange:m=>l(g=>({...g,agentSidebarShow:m.target.checked}))}),"Show sidebar"]}),w.jsxs("label",{className:"boomi-form-label",children:["Sidebar width",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.agentSidebarWidth,onChange:m=>l(g=>({...g,agentSidebarWidth:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Welcome title",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.agentWelcomeTitle,onChange:m=>l(g=>({...g,agentWelcomeTitle:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Welcome subtitle",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.agentWelcomeSubtitle,onChange:m=>l(g=>({...g,agentWelcomeSubtitle:m.target.value}))})]})]}),w.jsxs("div",{className:"space-y-3",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Theme"}),w.jsxs("label",{className:"boomi-form-label",children:["Theme",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.themeSelection,onChange:m=>l(g=>({...g,themeSelection:m.target.value,themeDefault:m.target.value==="custom"?g.themeDefault:m.target.value})),children:[w.jsx("option",{value:"boomi",children:"boomi"}),w.jsx("option",{value:"base",children:"base"}),w.jsx("option",{value:"custom",children:"custom"})]})]}),d.themeSelection==="custom"&&w.jsxs(w.Fragment,{children:[w.jsxs("label",{className:"boomi-form-label",children:["Custom theme name",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.themeCustomName,onChange:m=>l(g=>({...g,themeCustomName:m.target.value,themeDefault:m.target.value})),placeholder:"my-theme"})]}),w.jsxs("div",{className:"space-y-2",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"CSS Variable Overrides"}),d.themeCustomVars.length===0&&w.jsx("div",{className:"text-xs opacity-70",children:"No custom variables yet."}),w.jsx("div",{className:"space-y-2",children:d.themeCustomVars.map(m=>w.jsxs("div",{className:"flex items-center gap-2 flex-nowrap w-full overflow-x-auto",children:[w.jsx("select",{className:"boomi-input flex-1 min-w-0 rounded-md p-2 text-sm",value:m.varName,onChange:g=>h(m.id,{varName:g.target.value}),children:iC.map(g=>w.jsx("option",{value:g,children:g},g))}),w.jsx("input",{type:"text",value:m.value,onChange:g=>h(m.id,{value:g.target.value}),className:"boomi-input flex-1 min-w-0 rounded-md p-2 text-sm",placeholder:"#000000 or rgba(...) or value"}),JB(m.value)&&w.jsx("input",{type:"color",value:m.value,onChange:g=>h(m.id,{value:g.target.value}),className:"h-9 w-12 shrink-0 cursor-pointer rounded-md border border-[var(--boomi-card-border)] bg-transparent"}),w.jsx("button",{type:"button",className:"text-xs text-red-500 whitespace-nowrap shrink-0",onClick:()=>p(m.id),children:"Remove"})]},m.id))}),w.jsx("div",{children:w.jsx("button",{type:"button",className:"boomi-btn-primary px-3 py-2 text-xs",onClick:f,children:"Add CSS Variable"})})]})]})]})]}),(t==="list"||t==="single")&&w.jsxs("div",{className:t==="list"?"grid gap-4 md:grid-cols-2":"space-y-3",children:[w.jsxs("div",{className:"space-y-3",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Launcher (Pill)"}),w.jsxs("label",{className:"boomi-form-label",children:["Corner",w.jsx("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.launcherCorner,onChange:m=>l(g=>({...g,launcherCorner:m.target.value})),children:kr.map(m=>w.jsx("option",{value:m,children:m},m))})]}),w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Offset X",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.launcherOffsetX,onChange:m=>l(g=>({...g,launcherOffsetX:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Offset Y",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.launcherOffsetY,onChange:m=>l(g=>({...g,launcherOffsetY:m.target.value}))})]})]}),w.jsxs("label",{className:"boomi-form-label",children:["Shape",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.launcherShape,onChange:m=>l(g=>({...g,launcherShape:m.target.value})),children:[w.jsx("option",{value:"pill",children:"Pill"}),w.jsx("option",{value:"circle",children:"Circle"})]})]}),w.jsxs("label",{className:"boomi-form-label",children:["Label",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.launcherLabel,onChange:m=>l(g=>({...g,launcherLabel:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Icon",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:Ns.some(m=>m.value===d.launcherIcon)?d.launcherIcon:"__custom__",onChange:m=>l(g=>({...g,launcherIcon:m.target.value==="__custom__"?g.launcherIcon:m.target.value})),children:[!Ns.some(m=>m.value===d.launcherIcon)&&w.jsxs("option",{value:"__custom__",children:[d.launcherIcon," (custom)"]}),Ns.map(m=>w.jsx("option",{value:m.value,children:m.label},m.value))]})]}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:d.launcherHideIcon,onChange:m=>l(g=>({...g,launcherHideIcon:m.target.checked}))}),"Hide icon"]})]}),t==="list"&&w.jsxs("div",{className:"space-y-3",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"List Modal"}),w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Width",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.listModalWidth,onChange:m=>l(g=>({...g,listModalWidth:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Height",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.listModalHeight,onChange:m=>l(g=>({...g,listModalHeight:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Corner",w.jsx("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.listModalCorner,onChange:m=>l(g=>({...g,listModalCorner:m.target.value})),children:kr.map(m=>w.jsx("option",{value:m,children:m},m))})]}),w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Offset X",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.listModalOffsetX,onChange:m=>l(g=>({...g,listModalOffsetX:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Offset Y",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.listModalOffsetY,onChange:m=>l(g=>({...g,listModalOffsetY:m.target.value}))})]})]})]}),w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70 pt-2",children:"List Header & Search"}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:d.listHeaderShow,onChange:m=>l(g=>({...g,listHeaderShow:m.target.checked}))}),"Show header"]}),w.jsxs("label",{className:"boomi-form-label",children:["Header title",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.listHeaderTitle,onChange:m=>l(g=>({...g,listHeaderTitle:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Header description",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.listHeaderDescription,onChange:m=>l(g=>({...g,listHeaderDescription:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:d.listSearchShow,onChange:m=>l(g=>({...g,listSearchShow:m.target.checked}))}),"Show search"]}),w.jsxs("label",{className:"boomi-form-label",children:["Welcome title",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.listWelcomeTitle,onChange:m=>l(g=>({...g,listWelcomeTitle:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Welcome subtitle",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.listWelcomeSubtitle,onChange:m=>l(g=>({...g,listWelcomeSubtitle:m.target.value}))})]})]})]}),t==="tiles"&&w.jsxs("div",{className:"space-y-3",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Tiles Header & Search"}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:d.tilesHeaderShow,onChange:m=>l(g=>({...g,tilesHeaderShow:m.target.checked}))}),"Show header"]}),w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Header title",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.tilesHeaderTitle,onChange:m=>l(g=>({...g,tilesHeaderTitle:m.target.value}))})]}),w.jsxs("label",{className:"boomi-form-label",children:["Header description",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:d.tilesHeaderDescription,onChange:m=>l(g=>({...g,tilesHeaderDescription:m.target.value}))})]})]}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:d.tilesSearchShow,onChange:m=>l(g=>({...g,tilesSearchShow:m.target.checked}))}),"Show search"]}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:d.tilesViewToggleShow,onChange:m=>l(g=>({...g,tilesViewToggleShow:m.target.checked}))}),"Show tiles/table toggle"]})]}),(t==="list"||t==="tiles")&&e.length>0&&w.jsxs("div",{className:"space-y-3",children:[w.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Agent Cards"}),w.jsxs("div",{className:"text-xs opacity-70",children:["Configure how each agent appears in the ",t," view."]}),w.jsx("div",{className:"space-y-3",children:e.map(m=>{var v;const g=d.agentOverrides[m]??Lp(),b=x=>l(T=>({...T,agentOverrides:{...T.agentOverrides,[m]:{...T.agentOverrides[m]??Lp(),...x}}}));return w.jsxs("div",{className:"boomi-card p-3 space-y-3",children:[w.jsxs("div",{className:"space-y-0.5",children:[w.jsx("div",{className:"text-sm font-semibold",children:((v=s==null?void 0:s.find(x=>x.id===m))==null?void 0:v.label)??m}),w.jsx("div",{className:"text-xs font-mono opacity-50",children:m})]}),w.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[w.jsxs("label",{className:"boomi-form-label",children:["Card title",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:g.label,placeholder:"Agent name",onChange:x=>b({label:x.target.value})})]}),w.jsxs("label",{className:"boomi-form-label",children:["Card description",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:g.description,placeholder:"Brief description",onChange:x=>b({description:x.target.value})})]}),w.jsxs("label",{className:"boomi-form-label",children:["Icon",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:Ns.some(x=>x.value===g.icon)?g.icon:"__custom__",onChange:x=>b({icon:x.target.value==="__custom__"?g.icon:x.target.value}),children:[!Ns.some(x=>x.value===g.icon)&&w.jsxs("option",{value:"__custom__",children:[g.icon," (custom)"]}),Ns.map(x=>w.jsx("option",{value:x.value,children:x.label},x.value))]})]}),w.jsxs("label",{className:"boomi-form-label",children:["Button label",w.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:g.buttonLabel,placeholder:"Launch",onChange:x=>b({buttonLabel:x.target.value})})]})]}),w.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[w.jsx("input",{type:"checkbox",checked:g.hideIcon,onChange:x=>b({hideIcon:x.target.checked})}),"Hide icon"]})]},m)})})]})]})});function nH(t){try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}const oH=({isOpen:t,onClose:e,onSubmit:n,isSaving:o,defaultOrigins:i,availableAgents:r})=>{const[s,c]=M.useState(""),[a,d]=M.useState(null),[l,u]=M.useState(!1),[f,h]=M.useState([]),[p,m]=M.useState(""),g=M.useRef(null),b=M.useRef(null),v=M.useCallback(K=>{g.current=K,m(q=>{const X=JSON.stringify(K,null,2);return X!==q?X:q})},[]),[x,T]=M.useState("single"),[y,E]=M.useState(""),[_,N]=M.useState([]),[C,L]=M.useState(null),[$,k]=M.useState(null),[I,S]=M.useState(null),[A,O]=M.useState("builder"),P=(K,q)=>(K.length>0?K:["agent-id"]).reduce((J,se)=>(J[se]={transport:"boomi-direct",ui:{mode:q,modal:{width:500,height:600,position:{corner:"bottom-right",offsetX:20,offsetY:100}},sidebar:{show:q==="full",width:280},welcome:{title:"Let's Talk",subtitle:"Ask me about your Boomi deployment."}}},J),{}),U=JSON.stringify(((K,q)=>{const X={transport:"boomi-direct",theme:{allowThemes:!0,defaultTheme:"boomi"},cssVarsByTheme:{oem:{"--boomi-root-bg-color":"#0b1220","--boomi-root-fg-color":"#e5e7eb","--boomi-page-bg-color":"#0b1220","--boomi-page-fg-color":"#e5e7eb","--boomi-header-bg-color":"rgba(15, 23, 42, 0.8)","--boomi-header-fg-color":"#e5e7eb","--boomi-btn-primary-bg":"#2563eb","--boomi-btn-primary-fg":"#ffffff","--boomi-card-bg":"#0f172a","--boomi-card-border":"#1f2937","--boomi-menu-bg":"#0f172a","--boomi-menu-fg":"#e5e7eb","--boomi-modal-bg":"#0f172a","--boomi-modal-fg":"#e5e7eb","--boomi-input-bg":"#0b1220","--boomi-input-fg":"#e5e7eb"}}};K==="list"&&(X.components={agentList:{launcher:{position:{corner:"bottom-right",offsetX:20,offsetY:40},shape:"pill",label:"Find an Agent",icon:"bot",hideIcon:!1},modal:{width:500,height:600,position:{corner:"bottom-right",offsetX:20,offsetY:100}},welcome:{title:"Agents",subtitle:"Search for an agent and click to launch."}}});const J=q.length>0?q:["agent-id"];return X.agents=P(J,K==="single"?"modal":"full"),X})(x,x==="single"?y?[y]:[]:_),null,2);M.useEffect(()=>{t&&(c(""),d(null),u(!1),h([]),m(""),T("single"),E(""),N([]),L(null),k(null),S(null),O("builder"))},[t]),M.useEffect(()=>{!t||!(r!=null&&r.length)||(E(K=>K||r[0].id),N(K=>K.length?K:[r[0].id]))},[t,r]),M.useEffect(()=>{x==="single"?!y&&_[0]&&E(_[0]):_.length===0&&y&&N([y])},[x,_,y]);const H=K=>{N(q=>q.includes(K)?q.filter(X=>X!==K):[...q,K])},G=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`project_${crypto.randomUUID()}`:`project_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`,W=async()=>{var he;if(!s.trim()){u(!0),d("Project name is required.");return}d(null);const K=x==="single"?y?[y]:[]:_;if(!K.length){L("Select at least one agent");return}L(null);let q;if(A==="builder")q=((he=b.current)==null?void 0:he.getConfig())??void 0;else{const ie=p.trim();if(ie)try{q=JSON.parse(ie)}catch{S("Config must be valid JSON");return}}S(null);const X=q&&typeof q=="object"?{...q}:{},J=X.project&&typeof X.project=="object"?{...X.project}:{};X.project={...J,embedType:x,agentIds:K};const se=Array.from(new Set(f.map(ie=>ie.trim()).filter(Boolean)));if(!se.length){k("At least one allowed origin is required.");return}for(const ie of se)if(!nH(ie)){k(`Invalid origin (must be http/https): ${ie}`);return}k(null);const Y=G();if(x==="single"&&y){const ie={...X.agents??{}};ie[y]&&!ie[Y]&&(ie[Y]=ie[y],X.agents=ie)}console.log("[AddAgentModal] submitting configBase:",JSON.stringify(X,null,2)),await n({agentId:Y,boomiAgentId:x==="single"?y:void 0,label:s.trim()||void 0,allowedOrigins:se,config:X})},Q=()=>{h(K=>[...K,""])},V=(K,q)=>{h(X=>X.map((J,se)=>se===K?q:J))},j=K=>{h(q=>q.filter((X,J)=>J!==K))};return w.jsxs(Jn,{isOpen:t,title:"Add Project",description:"Create a new embedded agent group and its allowed embed origins.",onClose:e,onSubmit:W,submitLabel:o?"Saving...":"Create Project",showSaveButton:!o,children:[w.jsxs("div",{className:"boomi-card p-4 space-y-2",children:[w.jsx("div",{className:"text-sm font-semibold",children:"Project Summary"}),w.jsxs("div",{className:"text-xs opacity-80",children:["Embed type: ",w.jsx("strong",{children:x==="single"?"Single Agent":x==="tiles"?"Multi-Agent (Tiles)":"Multi-Agent (List)"})]}),w.jsxs("div",{className:"text-xs opacity-80",children:["Selected agents: ",w.jsx("strong",{children:x==="single"?y?1:0:_.length})]}),w.jsx("div",{className:"text-xs opacity-70",children:"You can start with the form below and optionally layer in advanced JSON config."})]}),w.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[w.jsxs("div",{className:"space-y-4",children:[w.jsx(mn,{formName:"agentAdd",label:"Project Name",required:!0,inputName:"name",readOnly:!1,value:s,onChange:K=>{c(K.target.value),a&&d(null)},onBlur:()=>{u(!0),s.trim()||d("Project name is required.")},placeholder:"Customer Support Project"}),l&&a&&w.jsx("div",{className:"boomi-form-error",children:a}),w.jsxs("label",{className:"boomi-form-label",children:["Embed Type",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:x,onChange:K=>T(K.target.value),children:[w.jsx("option",{value:"single",children:"Single Agent"}),w.jsx("option",{value:"tiles",children:"Multi-Agent (Tiles)"}),w.jsx("option",{value:"list",children:"Multi-Agent (Pill + Modal List)"})]})]}),x==="single"?w.jsxs("label",{className:"boomi-form-label",children:["Agent",w.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:y,onChange:K=>E(K.target.value),children:[(r??[]).length===0&&w.jsx("option",{value:"",children:"No agents available"}),(r??[]).map(K=>w.jsx("option",{value:K.id,children:K.label},K.id))]}),C&&w.jsx("div",{className:"text-xs text-red-500 mt-1",children:C})]}):w.jsxs("div",{children:[w.jsx("label",{className:"boomi-form-label",children:"Agents"}),w.jsx("div",{className:"boomi-input w-full rounded-md p-2 text-sm space-y-2 max-h-48 overflow-auto",children:(r??[]).length===0?w.jsx("div",{className:"text-xs opacity-70",children:"No agents available"}):(r??[]).map(K=>w.jsxs("label",{className:"flex items-center gap-2",children:[w.jsx("input",{type:"checkbox",checked:_.includes(K.id),onChange:()=>H(K.id)}),w.jsx("span",{className:"text-xs",children:K.label})]},K.id))}),C&&w.jsx("div",{className:"text-xs text-red-500 mt-1",children:C})]})]}),w.jsx("div",{className:"space-y-4",children:w.jsxs("div",{className:"space-y-2",children:[w.jsx("label",{className:"boomi-form-label",children:"Allowed Origins"}),w.jsx("div",{className:"text-xs opacity-70",children:"Select origins from your CORS list. If you don’t see one you need, add it first in the CORS page."}),w.jsxs("div",{className:"space-y-2",children:[f.length===0&&w.jsx("div",{className:"text-xs opacity-70",children:"No origins selected."}),f.map((K,q)=>{const X=new Set(f.map(Y=>Y.trim()).filter(Boolean)),J=(i??[]).filter(Y=>Y===K||!X.has(Y)),se=J.includes(K);return w.jsxs("div",{className:"flex items-center gap-2",children:[w.jsxs("select",{className:"boomi-input w-full rounded-md p-2 text-sm",value:K,onChange:Y=>V(q,Y.target.value),children:[!K&&w.jsx("option",{value:"",children:"Select an origin"}),se?null:K?w.jsx("option",{value:K,children:K}):null,J.map(Y=>w.jsx("option",{value:Y,children:Y},Y))]}),w.jsx("span",{role:"button",tabIndex:0,className:"text-red-500 text-lg cursor-pointer",onClick:()=>j(q),onKeyDown:Y=>{(Y.key==="Enter"||Y.key===" ")&&j(q)},"aria-label":"Remove origin",children:w.jsx(io,{})})]},`${K}-${q}`)})]}),w.jsx("div",{className:"flex",children:w.jsx(it,{toggle:!1,primary:!1,showIcon:!1,label:"Add Allowed Origin",onClick:Q})}),$&&w.jsx("div",{className:"text-xs text-red-500",children:$}),w.jsx("div",{className:"text-xs opacity-70",children:"Add new origins from the CORS page before selecting them here."})]})})]}),w.jsxs("div",{className:"space-y-3",children:[w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-sm font-semibold",children:"UI Configuration"}),w.jsx("div",{className:"text-xs opacity-70",children:"Optional. Use JSON to customize themes, layout, and agent UI beyond the form inputs."})]}),w.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-[var(--boomi-card-bg)] p-1 border border-[var(--boomi-card-border)]",children:[w.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${A==="builder"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>O("builder"),children:"Builder"}),w.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${A==="json"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>O("json"),children:"JSON"})]})]}),A==="builder"?w.jsx(sC,{ref:b,embedType:x,agentIds:x==="single"?y?[y]:[]:_,configRaw:p,onChangeConfig:v,syncFromConfig:!1,availableAgents:r}):w.jsxs(w.Fragment,{children:[w.jsx(oC,{label:"Config (JSON)",value:p,placeholder:U,error:I,onChange:m}),w.jsx("div",{className:"flex justify-end",children:w.jsx(it,{toggle:!1,primary:!1,showIcon:!1,label:"Insert Starter Config",onClick:()=>m(U)})})]})]})]})},iH=({isOpen:t,agentId:e,onClose:n,onConfirm:o,isDeleting:i})=>w.jsx(Jn,{isOpen:t,title:"Delete Agent",description:"Remove this agent and all associated public tokens.",onClose:n,onSubmit:o,submitLabel:i?"Deleting...":"Delete",showSaveButton:!i,children:w.jsxs("p",{className:"text-sm",children:["Are you sure you want to delete"," ",w.jsx("span",{className:"font-semibold",children:e}),"?"]})});function aC(t){if(t.trim().toLowerCase()==="null")return!0;try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}const rH=({isOpen:t,agentId:e,label:n,allowedOrigins:o,defaultOrigins:i,onAddOrigin:r,config:s,onClose:c,onSubmit:a,isSaving:d,availableAgents:l})=>{const[u,f]=M.useState(""),[h,p]=M.useState([]),[m,g]=M.useState(""),[b,v]=M.useState(!1),[x,T]=M.useState(""),[y,E]=M.useState(0),[_,N]=M.useState(null),[C,L]=M.useState(null),[$,k]=M.useState("builder"),I=(Q,V)=>(Q.length>0?Q:["agent-id"]).reduce((K,q)=>(K[q]={transport:"boomi-direct",ui:{mode:V,modal:{width:500,height:600,position:{corner:"bottom-right",offsetX:20,offsetY:100}},sidebar:{show:V==="full",width:280},welcome:{title:"Let's Talk",subtitle:"Ask me about your Boomi deployment."}}},K),{}),S=(Q,V)=>{const j={transport:"boomi-direct",theme:{allowThemes:!0,defaultTheme:"boomi"},cssVarsByTheme:{oem:{"--boomi-root-bg-color":"#0b1220","--boomi-root-fg-color":"#e5e7eb","--boomi-page-bg-color":"#0b1220","--boomi-page-fg-color":"#e5e7eb","--boomi-header-bg-color":"rgba(15, 23, 42, 0.8)","--boomi-header-fg-color":"#e5e7eb","--boomi-btn-primary-bg":"#2563eb","--boomi-btn-primary-fg":"#ffffff","--boomi-card-bg":"#0f172a","--boomi-card-border":"#1f2937","--boomi-menu-bg":"#0f172a","--boomi-menu-fg":"#e5e7eb","--boomi-modal-bg":"#0f172a","--boomi-modal-fg":"#e5e7eb","--boomi-input-bg":"#0b1220","--boomi-input-fg":"#e5e7eb"}}};Q==="list"&&(j.components={agentList:{launcher:{position:{corner:"bottom-right",offsetX:20,offsetY:40},shape:"pill",label:"Find an Agent",icon:"bot",hideIcon:!1},modal:{width:500,height:600,position:{corner:"bottom-right",offsetX:20,offsetY:100}},welcome:{title:"Agents",subtitle:"Search for an agent and click to launch."}}});const K=V.length>0?V:["agent-id"];return j.agents=I(K,Q==="single"?"modal":"full"),j},O=(()=>{try{const Q=x.trim()?JSON.parse(x):null,V=Q&&typeof Q=="object"?Q.project:null,j=typeof(V==null?void 0:V.embedType)=="string"?V.embedType:"single",K=Array.isArray(V==null?void 0:V.agentIds)?V.agentIds.filter(Boolean):[];return{embedType:j,agentIds:K}}catch{return{embedType:"single",agentIds:[]}}})(),P=O.agentIds.length>0?O.agentIds:e?[e]:[],R=JSON.stringify(S(O.embedType,P),null,2);M.useEffect(()=>{if(t){f(n??"");const Q=(o&&o.length?o:i)??[];p(Q),g(""),T(s?JSON.stringify(s,null,2):""),E(V=>V+1),N(null),L(null),k("builder")}},[t,n,s,o,i]);const B=async()=>{if(!e)return;let Q;const V=x.trim();if(V)try{Q=JSON.parse(V)}catch{L("Config must be valid JSON");return}L(null);const j=Array.from(new Set(h.map(K=>K.trim()).filter(Boolean)));if(!j.length){N("At least one allowed origin is required.");return}for(const K of j)if(!aC(K)){N(`Invalid origin (must be http/https): ${K}`);return}if(N(null),Q&&e){const K=Q.project,q=K==null?void 0:K.embedType,X=Array.isArray(K==null?void 0:K.agentIds)?K.agentIds[0]:null;if(q==="single"&&X){const J={...Q.agents??{}};J[X]&&!J[e]&&(J[e]=J[X],Q.agents=J)}}await a({agentId:e,label:u.trim()||void 0,allowedOrigins:j,config:Q})},U=()=>{const Q=i??[],V=new Set(h.map(K=>K.trim()).filter(Boolean)),j=Q.find(K=>!V.has(K))??"";p(K=>[...K,j])},H=(Q,V)=>{p(j=>j.map((K,q)=>q===Q?V:K))},G=Q=>{p(V=>V.filter((j,K)=>K!==Q))},W=async()=>{const Q=m.trim();if(!Q){N("Enter an origin before adding.");return}if(!aC(Q)){N(`Invalid origin (must be http/https): ${Q}`);return}if(N(null),!r){p(V=>V.includes(Q)?V:[...V,Q]),g("");return}v(!0);try{await r(Q),p(V=>V.includes(Q)?V:[...V,Q]),g("")}catch(V){N((V==null?void 0:V.message)||"Failed to add origin.")}finally{v(!1)}};return w.jsxs(Jn,{isOpen:t,title:"Edit Agent",description:"Update agent details and allowed origins.",onClose:c,onSubmit:B,submitLabel:d?"Saving...":"Save Changes",showSaveButton:!d,children:[w.jsxs("div",{className:"boomi-card p-4 space-y-2",children:[w.jsx("div",{className:"text-sm font-semibold",children:"Agent Overview"}),w.jsxs("div",{className:"text-xs opacity-80",children:["Agent ID: ",w.jsx("strong",{children:e??"—"})]}),w.jsx("div",{className:"text-xs opacity-70",children:"Update the friendly name, allowed origins, and optional config overrides below."})]}),w.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[w.jsxs("div",{className:"space-y-4",children:[w.jsx(mn,{formName:"agentEdit",label:"Name",required:!1,inputName:"name",readOnly:!1,value:u,onChange:Q=>f(Q.target.value),placeholder:"Customer Support Agent"}),w.jsx(mn,{formName:"agentEdit",label:"Agent ID",required:!0,inputName:"agentId",readOnly:!0,value:e??"",onChange:()=>{},helperText:"This is the Boomi Agent ID for your agent and cannot be changed."})]}),w.jsxs("div",{className:"space-y-2",children:[w.jsx("label",{className:"boomi-form-label",children:"Allowed Origins"}),w.jsxs("div",{className:"space-y-2",children:[h.length===0&&w.jsx("div",{className:"text-xs opacity-70",children:"No origins selected."}),h.map((Q,V)=>{const j=new Set(h.map(X=>X.trim()).filter(Boolean)),K=(i??[]).filter(X=>X===Q||!j.has(X)),q=K.includes(Q);return w.jsxs("div",{className:"flex items-center gap-2",children:[w.jsxs("select",{className:"boomi-input w-full rounded-md p-2 text-sm",value:Q,onChange:X=>H(V,X.target.value),children:[!Q&&w.jsx("option",{value:"",children:"Select an origin"}),q?null:Q?w.jsx("option",{value:Q,children:Q}):null,K.map(X=>w.jsx("option",{value:X,children:X},X))]}),w.jsx("span",{role:"button",tabIndex:0,className:"text-red-500 text-lg cursor-pointer",onClick:()=>G(V),onKeyDown:X=>{(X.key==="Enter"||X.key===" ")&&G(V)},"aria-label":"Remove origin",children:w.jsx(io,{})})]},`${Q}-${V}`)})]}),_&&w.jsx("div",{className:"text-xs text-red-500",children:_}),w.jsxs("div",{className:"flex items-center gap-2",children:[w.jsx(it,{toggle:!1,primary:!1,showIcon:!1,label:"Add Row",onClick:U}),w.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[w.jsx("input",{className:"boomi-input w-full rounded-md p-2 text-sm",value:m,onChange:Q=>g(Q.target.value),placeholder:"https://example.com"}),w.jsx("button",{type:"button",className:"boomi-btn-primary px-2 py-2 text-xs",onClick:W,disabled:b,"aria-label":"Add new origin",children:w.jsx(sr,{})})]})]}),w.jsx("div",{className:"text-xs opacity-70",children:"Pick from existing CORS origins or add a new one here."})]})]}),w.jsxs("div",{className:"space-y-3",children:[w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-sm font-semibold",children:"UI Configuration"}),w.jsx("div",{className:"text-xs opacity-70",children:"Optional. Use JSON to customize themes, layout, and agent UI."})]}),w.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-[var(--boomi-card-bg)] p-1 border border-[var(--boomi-card-border)]",children:[w.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${$==="builder"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>k("builder"),children:"Builder"}),w.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${$==="json"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>k("json"),children:"JSON"})]})]}),$==="builder"?w.jsx(sC,{embedType:O.embedType,agentIds:P,configRaw:x,onChangeConfig:Q=>{const V=JSON.stringify(Q,null,2);V!==x&&T(V)},syncFromConfig:!1,availableAgents:l},y):w.jsxs(w.Fragment,{children:[w.jsx(oC,{label:"Config (JSON)",value:x,placeholder:R,error:C,onChange:T}),w.jsx("div",{className:"flex justify-end",children:w.jsx(it,{toggle:!1,primary:!1,showIcon:!1,label:"Insert Starter Config",onClick:()=>T(R)})})]})]})]})},sH=({isOpen:t,agentId:e,tokenId:n,agents:o,primaryAccountId:i,onTokenGenerated:r,onClose:s})=>{const[c,a]=M.useState(!1),[d,l]=M.useState(!1),[u,f]=M.useState("single"),[h,p]=M.useState([]),[m,g]=M.useState(""),[b,v]=M.useState(!1),[x,T]=M.useState(null),[y,E]=M.useState(null),{createAgent:_}=nC(),N=M.useMemo(()=>(o??[]).map(A=>{var O;return{id:A.agentId,label:((O=A.label)==null?void 0:O.trim())||A.agentId,tokenIds:A.publicTokenIds??[]}}),[o]);M.useEffect(()=>{var A;if(!t)return;const S=e||((A=N[0])==null?void 0:A.id)||"";g(S),p(S?[S]:[]),T(null),E(null),e&&f("single")},[t,e,N]);const C=S=>{p(A=>A.includes(S)?A.filter(O=>O!==S):[...A,S])},L=async()=>{const S=n??y;if(!i||!S)return;const A=h.filter(O=>{var R;const P=N.find(B=>B.id===O);return!((R=P==null?void 0:P.tokenIds)!=null&&R.includes(S))});if(A.length===0){T("Token already attached to selected agents.");return}v(!0),T(null);try{await Promise.all(A.map(O=>_({primaryAccountId:i,agentId:O,publicTokenIds:[S]}))),T("Token attached to selected agents.")}catch(O){T((O==null?void 0:O.message)||"Failed to attach token to selected agents.")}finally{v(!1)}},$=async()=>{var A;if(!i)return;const S=u==="single"?m:h[0];if(!S){T("Select at least one agent first.");return}v(!0),T(null);try{const P=((A=(await _({primaryAccountId:i,agentId:S,createToken:!0})).createdToken)==null?void 0:A.tokenId)||null;if(!P)throw new Error("Token generation failed.");E(P),r==null||r(P);const R=u==="single"?[]:h.filter(B=>B!==S);R.length>0&&await Promise.all(R.map(B=>_({primaryAccountId:i,agentId:B,publicTokenIds:[P]}))),T("Token generated and attached to selected agents.")}catch(O){T((O==null?void 0:O.message)||"Failed to generate token.")}finally{v(!1)}},k=M.useMemo(()=>{const S=n??y;return S?`<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@boomi/embedkit-cdn/embedkit-cdn.css" />
|
|
2107
2107
|
<script>
|
|
2108
2108
|
window.BoomiEmbed = {
|
|
2109
2109
|
publicToken: "${S}",
|
|
2110
|
-
agentId: "${
|
|
2110
|
+
agentId: "${m||e||""||"project-id"}",
|
|
2111
2111
|
mountId: "boomi-agent",
|
|
2112
2112
|
serverBase: "https://api.boomi.space/api/v1"
|
|
2113
2113
|
};
|
|
2114
2114
|
<\/script>
|
|
2115
|
-
<script src="https://cdn.
|
|
2116
|
-
<div id="boomi-agent"></div>`},[e,n,y,u,h,m]),I=async(S,A)=>{try{await navigator.clipboard.writeText(S),A(!0),setTimeout(()=>A(!1),2e3)}catch{A(!1)}};return t?w.jsx(Jn,{isOpen:t,title:"Public Token",description:"Use this token in your embed snippet. Store it securely in your app configuration.",onClose:s,onSubmit:s,showSaveButton:!0,showCancelButton:!1,submitLabel:"Close",children:w.jsxs("div",{className:"space-y-3",children:[w.jsxs("div",{children:[w.jsx("label",{className:"boomi-form-label",children:"Token"}),w.jsxs("div",{className:"flex gap-2 items-center",children:[w.jsx("input",{className:"boomi-input w-full rounded-md p-2 font-mono text-xs",readOnly:!0,value:n??y??""}),w.jsx(it,{toggle:!1,primary:!1,showIcon:!1,label:c?"Copied":"Copy",onClick:()=>{const S=n??y;S&&I(S,a)}})]}),!n&&w.jsx("div",{className:"mt-2",children:w.jsx(it,{toggle:!1,primary:!0,showIcon:!1,label:b?"Generating…":"Generate Token",onClick:$,disabled:!i||b})})]}),!e&&w.jsxs("div",{children:[w.jsx("label",{className:"boomi-form-label",children:"Embed Type"}),w.jsxs("select",{className:"boomi-input w-full rounded-md p-2 text-sm",value:u,onChange:S=>f(S.target.value),children:[w.jsx("option",{value:"single",children:"Single Agent"}),w.jsx("option",{value:"tiles",children:"Multi-Agent (Tiles)"}),w.jsx("option",{value:"list",children:"Multi-Agent (Pill + Modal List)"})]})]}),u!=="single"?w.jsxs("div",{children:[w.jsx("label",{className:"boomi-form-label",children:"Agents"}),w.jsx("div",{className:"boomi-input w-full rounded-md p-2 text-sm space-y-2 max-h-48 overflow-auto",children:N.length===0?w.jsx("div",{className:"text-xs opacity-70",children:"No agents available"}):N.map(S=>w.jsxs("label",{className:"flex items-center gap-2",children:[w.jsx("input",{type:"checkbox",checked:h.includes(S.id),onChange:()=>C(S.id)}),w.jsx("span",{className:"text-xs",children:S.label})]},S.id))}),w.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[w.jsx(it,{toggle:!1,primary:!1,showIcon:!1,label:b?"Attaching…":"Attach Existing Token to Selected Agents",onClick:L,disabled:!i||!(n??y)||h.length===0||b}),x&&w.jsx("span",{className:"text-xs opacity-70",children:x})]})]}):null,w.jsxs("div",{children:[w.jsx("label",{className:"boomi-form-label",children:"Embed Snippet"}),w.jsx("textarea",{className:"boomi-input w-full rounded-md p-2 font-mono text-xs min-h-[140px]",readOnly:!0,value:k}),w.jsx("div",{className:"mt-2",children:w.jsx(it,{toggle:!1,primary:!1,showIcon:!1,label:d?"Copied":"Copy Snippet",onClick:()=>I(k,l)})})]})]})}):null},kp=10,aH=({componentKey:t,primaryAccountId:e})=>{const{boomiConfig:n,tenantId:o,setPageIsLoading:i}=vt(),r=e??o??(n==null?void 0:n.tenantId),s=`agents-view:${t}`,{listAgents:c,listAvailableAgents:a,createAgent:d,deleteAgent:l}=nC(),{getCorsConfig:u,createCorsConfig:f,updateCorsConfig:h}=Yc(),[p,m]=M.useState([]),[g,b]=M.useState([]),[v,x]=M.useState([]),[T,y]=M.useState(!1),[E,_]=M.useState(null),[N,C]=M.useState(""),[L,$]=M.useState(1),[k,I]=M.useState("off"),[S,A]=M.useState(!1),[O,P]=M.useState(!1),[R,B]=M.useState(!1),[U,H]=M.useState(!1),[G,W]=M.useState(null),[Q,V]=M.useState(null),[j,K]=M.useState(null),[q,X]=M.useState(!1),[J,se]=M.useState(!1),[Y,he]=M.useState({add:!1,edit:!1,delete:!1});M.useEffect(()=>{try{const oe=localStorage.getItem(s);(oe==="on"||oe==="off")&&I(oe)}catch{}},[s]);const ie=M.useCallback(()=>{I(oe=>{const ce=oe==="on"?"off":"on";try{localStorage.setItem(s,ce)}catch{}return ce})},[s]),ye=oe=>{he(ce=>({...ce,[oe]:!0})),setTimeout(()=>he(ce=>({...ce,[oe]:!1})),3e3)},Ae=()=>r||(_("primaryAccountId is required to manage agents."),null),Oe=M.useCallback(async()=>{const oe=Ae();if(oe){y(!0),_(null);try{const ce=await c({primaryAccountId:oe,includeDetails:!0});m(ce.items??[])}catch(ce){const Ne=(ce==null?void 0:ce.message)||"Failed to load agents";me.error({err:ce},"[Agents] list failed"),_(Ne)}finally{y(!1)}}},[c,r]),Ye=M.useCallback(async()=>{const oe=Ae();if(oe)try{const ce=await u({primaryAccountId:oe});x(ce.allowedOrigins??[])}catch(ce){if((ce==null?void 0:ce.status)===404){x([]);return}me.error({err:ce},"[Agents] cors list failed"),x([])}},[u,r]),We=M.useCallback(async oe=>{const ce=Ae();if(!ce)return;const Ne=Array.from(new Set([...v??[],oe]));try{const ke=await h({primaryAccountId:ce,allowedOrigins:Ne});x(ke.allowedOrigins??Ne)}catch(ke){if((ke==null?void 0:ke.status)===404){const Ue=await f({primaryAccountId:ce,allowedOrigins:Ne});x(Ue.allowedOrigins??Ne);return}throw ke}},[f,h,v,r]),Ke=M.useCallback(async()=>{const oe=Ae();if(oe)try{const ce=await a({primaryAccountId:oe});b(ce.items??[])}catch(ce){me.error({err:ce},"[Agents] available list failed"),b([])}},[a,r]);M.useEffect(()=>{Oe()},[Oe]),M.useEffect(()=>{Ye()},[Ye]),M.useEffect(()=>{Ke()},[Ke]),M.useEffect(()=>{S&&Ke()},[S,Ke]),M.useEffect(()=>{O&&Ke()},[O,Ke]);const Re=M.useMemo(()=>{const oe=N.trim().toLowerCase();return oe?p.filter(ce=>{var ke;const Ne=((ke=ce.label)==null?void 0:ke.toLowerCase())??"";return ce.agentId.toLowerCase().includes(oe)||Ne.includes(oe)}):p},[p,N]),Xe=Math.max(1,Math.ceil(Re.length/kp)),Ce=Re.slice((L-1)*kp,L*kp),Be=M.useMemo(()=>g.map(oe=>({id:oe.id,label:oe.name||oe.id})),[g]),fe=async oe=>{var Ne,ke;const ce=Ae();if(ce){X(!0),i(!0);try{const Ue=await d({primaryAccountId:ce,agentId:oe.agentId,boomiAgentId:oe.boomiAgentId,label:oe.label,allowedOrigins:oe.allowedOrigins,config:oe.config,createToken:!0});await Oe(),A(!1),ye("add");const Pe=((Ne=Ue.createdToken)==null?void 0:Ne.tokenId)||((ke=Ue.agent.publicTokenIds)==null?void 0:ke[Ue.agent.publicTokenIds.length-1])||null;W(Ue.agent.agentId),V(Pe),H(!0)}catch(Ue){me.error({err:Ue},"[Agents] create failed"),_((Ue==null?void 0:Ue.message)||"Failed to create agent")}finally{X(!1),i(!1)}}},xe=async oe=>{const ce=Ae();if(ce){X(!0),i(!0);try{await d({primaryAccountId:ce,agentId:oe.agentId,boomiAgentId:j==null?void 0:j.boomiAgentId,label:oe.label,allowedOrigins:oe.allowedOrigins,config:oe.config}),await Oe(),P(!1),K(null),ye("edit")}catch(Ne){me.error({err:Ne},"[Agents] edit failed"),_((Ne==null?void 0:Ne.message)||"Failed to update agent")}finally{X(!1),i(!1)}}},we=async()=>{if(!G)return;const oe=Ae();if(oe){se(!0),i(!0);try{await l({primaryAccountId:oe,agentId:G}),await Oe(),B(!1),W(null),ye("delete")}catch(ce){me.error({err:ce},"[Agents] delete failed"),_((ce==null?void 0:ce.message)||"Failed to delete agent")}finally{se(!1),i(!1)}}},Te=({agent:oe})=>{var Ne;const ce=((Ne=oe.publicTokenIds)==null?void 0:Ne[oe.publicTokenIds.length-1])||null;return w.jsxs(Mi,{children:[w.jsx(Ut.Item,{children:({active:ke})=>w.jsxs("button",{onClick:()=>{K(oe),P(!0)},className:"boomi-menu-item","data-headlessui-state":ke?"active":void 0,children:[w.jsx(Cl,{className:"boomi-menu-icon"}),"Edit"]})}),w.jsx(Ut.Item,{children:({active:ke})=>w.jsxs("button",{onClick:()=>{W(oe.agentId),V(ce),H(!0)},className:"boomi-menu-item","data-headlessui-state":ke?"active":void 0,children:[w.jsx(Jm,{className:"boomi-menu-icon"}),"View Embed"]})}),w.jsx("div",{className:"boomi-menu-divider"}),w.jsx(Ut.Item,{children:({active:ke})=>w.jsxs("button",{onClick:()=>{W(oe.agentId),B(!0)},className:"boomi-menu-item boomi-menu-item--danger","data-headlessui-state":ke?"active":void 0,disabled:J,children:[w.jsx(io,{className:"boomi-menu-icon"}),"Delete"]})})]})},de=E||null;return w.jsxs(w.Fragment,{children:[Y.add&&w.jsx(ho,{type:"success",content:"Agent created."}),Y.edit&&w.jsx(ho,{type:"success",content:"Agent updated."}),Y.delete&&w.jsx(ho,{type:"success",content:"Agent deleted."}),w.jsx(oH,{isOpen:S,onClose:()=>A(!1),onSubmit:fe,isSaving:q,defaultOrigins:v,availableAgents:Be}),w.jsx(rH,{isOpen:O,agentId:(j==null?void 0:j.agentId)??null,label:(j==null?void 0:j.label)??null,allowedOrigins:(j==null?void 0:j.allowedOrigins)??null,defaultOrigins:v,config:(j==null?void 0:j.config)??null,onAddOrigin:We,onClose:()=>{P(!1),K(null)},onSubmit:xe,isSaving:q,availableAgents:Be}),w.jsx(iH,{isOpen:R,agentId:G,onClose:()=>{B(!1),W(null)},onConfirm:we,isDeleting:J}),w.jsx(sH,{isOpen:U,agentId:G,tokenId:Q,agents:p,primaryAccountId:r??void 0,onTokenGenerated:oe=>V(oe),onClose:()=>{H(!1),V(null)}}),w.jsxs("div",{className:"w-full h-full p-6",children:[w.jsxs("div",{className:"space-y-2",children:[w.jsx("h1",{className:"text-2xl font-semibold",children:"Projects"}),w.jsx("p",{className:"text-sm opacity-70",children:"Create and manage embedded agent groups, including tokens, allowed origins, and launch options."})]}),w.jsxs("div",{className:"flex items-end gap-3 mb-4 mt-4",children:[w.jsx("div",{className:"flex flex-wrap items-end gap-3 flex-1 min-w-0",children:w.jsx("div",{className:"min-w-[220px]",children:w.jsx(Tr,{searchCallback:oe=>{C(oe),$(1)}})})}),w.jsxs("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:[w.jsx(it,{toggle:!0,primary:!1,viewLoc:s,onClass:"flex w-full justify-center rounded-md px-2 py-2 text-xs font-semibold leading-6 shadow-md transition-colors duration-100",showIcon:!0,label:"View",icon:w.jsx(ou,{className:"h-5 w-5"}),onIcon:w.jsx(tu,{className:"h-5 w-5"}),onClick:ie}),w.jsx(it,{toggle:!1,primary:!0,showIcon:!0,label:"Add Project",icon:w.jsx(sr,{className:"h-5 w-5"}),onClick:()=>A(!0)})]})]}),de&&w.jsx("div",{className:"boomi-notice boomi-notice--error text-sm",children:de}),k==="off"?w.jsxs(w.Fragment,{children:[w.jsx("ul",{role:"list",className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-x-6 gap-y-8",children:T?w.jsx("div",{className:"col-span-full flex justify-center items-center",children:w.jsx(en,{})}):Ce.length>0?Ce.map(oe=>{var Ne;const ce=((Ne=oe.label)==null?void 0:Ne.trim())||"Untitled Agent";return w.jsxs("li",{className:"boomi-card",children:[w.jsx("div",{className:"flex gap-4 p-4",children:w.jsxs("div",{className:"flex flex-col w-full",children:[w.jsx("h3",{className:"text-base font-semibold break-words truncate overflow-hidden pr-2",children:ce}),w.jsx("p",{className:"text-xs mt-1 opacity-70 break-words overflow-hidden",children:oe.agentId})]})}),w.jsxs("div",{className:"flex w-full p-2 justify-end items-center gap-x-2 relative overflow-visible",children:[w.jsx(it,{toggle:!1,primary:!0,showIcon:!1,label:"Edit",onClick:()=>{K(oe),P(!0)}}),w.jsx(Te,{agent:oe})]})]},oe.agentId)}):w.jsx("div",{className:"col-span-full flex justify-center items-center",children:w.jsx("p",{className:"text-gray-500 text-xs",children:"No agents found."})})}),!T&&Xe>1&&w.jsx(xr,{currentPage:L,totalPages:Xe,onPageChange:oe=>$(oe)})]}):w.jsxs(w.Fragment,{children:[w.jsxs("table",{className:"w-full table-auto rounded-lg shadow-sm",children:[w.jsx("thead",{className:"boomi-table-header",children:w.jsxs("tr",{children:[w.jsx("th",{className:"py-3 px-4 text-left text-sm font-semibold",children:"Agent"}),w.jsx("th",{className:"py-3 px-4 text-left text-sm font-semibold",children:"Name"}),w.jsx("th",{className:"py-3 px-4 text-left text-sm font-semibold",children:"Agent ID"}),w.jsx("th",{className:"py-3 px-4 text-right text-sm font-semibold",children:"Actions"})]})}),w.jsx("tbody",{className:"divide-y",children:T?w.jsx("tr",{children:w.jsx("td",{colSpan:3,children:w.jsx("div",{className:"flex justify-center items-center py-6",children:w.jsx(en,{})})})}):Ce.length>0?Ce.map(oe=>{var Ne;const ce=((Ne=oe.label)==null?void 0:Ne.trim())||"Untitled Agent";return w.jsxs("tr",{className:"boomi-table-row",children:[w.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2 max-w-xs break-words",children:ce}),w.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2 max-w-xs break-words",children:oe.agentId}),w.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2",children:w.jsx("div",{className:"flex justify-end",children:w.jsx(Te,{agent:oe})})})]},oe.agentId)}):w.jsx("tr",{children:w.jsx("td",{colSpan:3,children:w.jsx("div",{className:"flex justify-center items-center py-4",children:w.jsx("p",{className:"text-gray-500 text-xs",children:"No agents found."})})})})})]}),!T&&Xe>1&&w.jsx("div",{className:"mt-4 flex justify-end",children:w.jsx(xr,{currentPage:L,totalPages:Xe,onPageChange:$})})]})]})]})};var Xc={exports:{}};/*!
|
|
2115
|
+
<script src="https://cdn.jsdelivr.net/npm/@boomi/embedkit-cdn/embedkit-cdn.umd.cjs" async><\/script>
|
|
2116
|
+
<div id="boomi-agent"></div>`:""},[e,n,y,u,h,m]),I=async(S,A)=>{try{await navigator.clipboard.writeText(S),A(!0),setTimeout(()=>A(!1),2e3)}catch{A(!1)}};return t?w.jsx(Jn,{isOpen:t,title:"Public Token",description:"Use this token in your embed snippet. Store it securely in your app configuration.",onClose:s,onSubmit:s,showSaveButton:!0,showCancelButton:!1,submitLabel:"Close",children:w.jsxs("div",{className:"space-y-3",children:[w.jsxs("div",{children:[w.jsx("label",{className:"boomi-form-label",children:"Token"}),w.jsxs("div",{className:"flex gap-2 items-center",children:[w.jsx("input",{className:"boomi-input w-full rounded-md p-2 font-mono text-xs",readOnly:!0,value:n??y??""}),w.jsx(it,{toggle:!1,primary:!1,showIcon:!1,label:c?"Copied":"Copy",onClick:()=>{const S=n??y;S&&I(S,a)}})]}),!n&&w.jsx("div",{className:"mt-2",children:w.jsx(it,{toggle:!1,primary:!0,showIcon:!1,label:b?"Generating…":"Generate Token",onClick:$,disabled:!i||b})})]}),!e&&w.jsxs("div",{children:[w.jsx("label",{className:"boomi-form-label",children:"Embed Type"}),w.jsxs("select",{className:"boomi-input w-full rounded-md p-2 text-sm",value:u,onChange:S=>f(S.target.value),children:[w.jsx("option",{value:"single",children:"Single Agent"}),w.jsx("option",{value:"tiles",children:"Multi-Agent (Tiles)"}),w.jsx("option",{value:"list",children:"Multi-Agent (Pill + Modal List)"})]})]}),u!=="single"?w.jsxs("div",{children:[w.jsx("label",{className:"boomi-form-label",children:"Agents"}),w.jsx("div",{className:"boomi-input w-full rounded-md p-2 text-sm space-y-2 max-h-48 overflow-auto",children:N.length===0?w.jsx("div",{className:"text-xs opacity-70",children:"No agents available"}):N.map(S=>w.jsxs("label",{className:"flex items-center gap-2",children:[w.jsx("input",{type:"checkbox",checked:h.includes(S.id),onChange:()=>C(S.id)}),w.jsx("span",{className:"text-xs",children:S.label})]},S.id))}),w.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[w.jsx(it,{toggle:!1,primary:!1,showIcon:!1,label:b?"Attaching…":"Attach Existing Token to Selected Agents",onClick:L,disabled:!i||!(n??y)||h.length===0||b}),x&&w.jsx("span",{className:"text-xs opacity-70",children:x})]})]}):null,w.jsxs("div",{children:[w.jsx("label",{className:"boomi-form-label",children:"Embed Snippet"}),w.jsx("textarea",{className:"boomi-input w-full rounded-md p-2 font-mono text-xs min-h-[140px]",readOnly:!0,value:k}),w.jsx("div",{className:"mt-2",children:w.jsx(it,{toggle:!1,primary:!1,showIcon:!1,label:d?"Copied":"Copy Snippet",onClick:()=>I(k,l)})})]})]})}):null},kp=10,aH=({componentKey:t,primaryAccountId:e})=>{const{boomiConfig:n,tenantId:o,setPageIsLoading:i}=vt(),r=e??o??(n==null?void 0:n.tenantId),s=`agents-view:${t}`,{listAgents:c,listAvailableAgents:a,createAgent:d,deleteAgent:l}=nC(),{getCorsConfig:u,createCorsConfig:f,updateCorsConfig:h}=Yc(),[p,m]=M.useState([]),[g,b]=M.useState([]),[v,x]=M.useState([]),[T,y]=M.useState(!1),[E,_]=M.useState(null),[N,C]=M.useState(""),[L,$]=M.useState(1),[k,I]=M.useState("off"),[S,A]=M.useState(!1),[O,P]=M.useState(!1),[R,B]=M.useState(!1),[U,H]=M.useState(!1),[G,W]=M.useState(null),[Q,V]=M.useState(null),[j,K]=M.useState(null),[q,X]=M.useState(!1),[J,se]=M.useState(!1),[Y,he]=M.useState({add:!1,edit:!1,delete:!1});M.useEffect(()=>{try{const oe=localStorage.getItem(s);(oe==="on"||oe==="off")&&I(oe)}catch{}},[s]);const ie=M.useCallback(()=>{I(oe=>{const ce=oe==="on"?"off":"on";try{localStorage.setItem(s,ce)}catch{}return ce})},[s]),ye=oe=>{he(ce=>({...ce,[oe]:!0})),setTimeout(()=>he(ce=>({...ce,[oe]:!1})),3e3)},Ae=()=>r||(_("primaryAccountId is required to manage agents."),null),Oe=M.useCallback(async()=>{const oe=Ae();if(oe){y(!0),_(null);try{const ce=await c({primaryAccountId:oe,includeDetails:!0});m(ce.items??[])}catch(ce){const Ne=(ce==null?void 0:ce.message)||"Failed to load agents";me.error({err:ce},"[Agents] list failed"),_(Ne)}finally{y(!1)}}},[c,r]),Ye=M.useCallback(async()=>{const oe=Ae();if(oe)try{const ce=await u({primaryAccountId:oe});x(ce.allowedOrigins??[])}catch(ce){if((ce==null?void 0:ce.status)===404){x([]);return}me.error({err:ce},"[Agents] cors list failed"),x([])}},[u,r]),We=M.useCallback(async oe=>{const ce=Ae();if(!ce)return;const Ne=Array.from(new Set([...v??[],oe]));try{const ke=await h({primaryAccountId:ce,allowedOrigins:Ne});x(ke.allowedOrigins??Ne)}catch(ke){if((ke==null?void 0:ke.status)===404){const Ue=await f({primaryAccountId:ce,allowedOrigins:Ne});x(Ue.allowedOrigins??Ne);return}throw ke}},[f,h,v,r]),Ke=M.useCallback(async()=>{const oe=Ae();if(oe)try{const ce=await a({primaryAccountId:oe});b(ce.items??[])}catch(ce){me.error({err:ce},"[Agents] available list failed"),b([])}},[a,r]);M.useEffect(()=>{Oe()},[Oe]),M.useEffect(()=>{Ye()},[Ye]),M.useEffect(()=>{Ke()},[Ke]),M.useEffect(()=>{S&&Ke()},[S,Ke]),M.useEffect(()=>{O&&Ke()},[O,Ke]);const Re=M.useMemo(()=>{const oe=N.trim().toLowerCase();return oe?p.filter(ce=>{var ke;const Ne=((ke=ce.label)==null?void 0:ke.toLowerCase())??"";return ce.agentId.toLowerCase().includes(oe)||Ne.includes(oe)}):p},[p,N]),Xe=Math.max(1,Math.ceil(Re.length/kp)),Ce=Re.slice((L-1)*kp,L*kp),Be=M.useMemo(()=>g.map(oe=>({id:oe.id,label:oe.name||oe.id})),[g]),fe=async oe=>{var Ne,ke;const ce=Ae();if(ce){X(!0),i(!0);try{const Ue=await d({primaryAccountId:ce,agentId:oe.agentId,boomiAgentId:oe.boomiAgentId,label:oe.label,allowedOrigins:oe.allowedOrigins,config:oe.config,createToken:!0});await Oe(),A(!1),ye("add");const Pe=((Ne=Ue.createdToken)==null?void 0:Ne.tokenId)||((ke=Ue.agent.publicTokenIds)==null?void 0:ke[Ue.agent.publicTokenIds.length-1])||null;W(Ue.agent.agentId),V(Pe),H(!0)}catch(Ue){me.error({err:Ue},"[Agents] create failed"),_((Ue==null?void 0:Ue.message)||"Failed to create agent")}finally{X(!1),i(!1)}}},xe=async oe=>{const ce=Ae();if(ce){X(!0),i(!0);try{await d({primaryAccountId:ce,agentId:oe.agentId,boomiAgentId:j==null?void 0:j.boomiAgentId,label:oe.label,allowedOrigins:oe.allowedOrigins,config:oe.config}),await Oe(),P(!1),K(null),ye("edit")}catch(Ne){me.error({err:Ne},"[Agents] edit failed"),_((Ne==null?void 0:Ne.message)||"Failed to update agent")}finally{X(!1),i(!1)}}},we=async()=>{if(!G)return;const oe=Ae();if(oe){se(!0),i(!0);try{await l({primaryAccountId:oe,agentId:G}),await Oe(),B(!1),W(null),ye("delete")}catch(ce){me.error({err:ce},"[Agents] delete failed"),_((ce==null?void 0:ce.message)||"Failed to delete agent")}finally{se(!1),i(!1)}}},Te=({agent:oe})=>{var Ne;const ce=((Ne=oe.publicTokenIds)==null?void 0:Ne[oe.publicTokenIds.length-1])||null;return w.jsxs(Mi,{children:[w.jsx(Ut.Item,{children:({active:ke})=>w.jsxs("button",{onClick:()=>{K(oe),P(!0)},className:"boomi-menu-item","data-headlessui-state":ke?"active":void 0,children:[w.jsx(Cl,{className:"boomi-menu-icon"}),"Edit"]})}),w.jsx(Ut.Item,{children:({active:ke})=>w.jsxs("button",{onClick:()=>{W(oe.agentId),V(ce),H(!0)},className:"boomi-menu-item","data-headlessui-state":ke?"active":void 0,children:[w.jsx(Jm,{className:"boomi-menu-icon"}),"View Embed"]})}),w.jsx("div",{className:"boomi-menu-divider"}),w.jsx(Ut.Item,{children:({active:ke})=>w.jsxs("button",{onClick:()=>{W(oe.agentId),B(!0)},className:"boomi-menu-item boomi-menu-item--danger","data-headlessui-state":ke?"active":void 0,disabled:J,children:[w.jsx(io,{className:"boomi-menu-icon"}),"Delete"]})})]})},de=E||null;return w.jsxs(w.Fragment,{children:[Y.add&&w.jsx(ho,{type:"success",content:"Agent created."}),Y.edit&&w.jsx(ho,{type:"success",content:"Agent updated."}),Y.delete&&w.jsx(ho,{type:"success",content:"Agent deleted."}),w.jsx(oH,{isOpen:S,onClose:()=>A(!1),onSubmit:fe,isSaving:q,defaultOrigins:v,availableAgents:Be}),w.jsx(rH,{isOpen:O,agentId:(j==null?void 0:j.agentId)??null,label:(j==null?void 0:j.label)??null,allowedOrigins:(j==null?void 0:j.allowedOrigins)??null,defaultOrigins:v,config:(j==null?void 0:j.config)??null,onAddOrigin:We,onClose:()=>{P(!1),K(null)},onSubmit:xe,isSaving:q,availableAgents:Be}),w.jsx(iH,{isOpen:R,agentId:G,onClose:()=>{B(!1),W(null)},onConfirm:we,isDeleting:J}),w.jsx(sH,{isOpen:U,agentId:G,tokenId:Q,agents:p,primaryAccountId:r??void 0,onTokenGenerated:oe=>V(oe),onClose:()=>{H(!1),V(null)}}),w.jsxs("div",{className:"w-full h-full p-6",children:[w.jsxs("div",{className:"space-y-2",children:[w.jsx("h1",{className:"text-2xl font-semibold",children:"Projects"}),w.jsx("p",{className:"text-sm opacity-70",children:"Create and manage embedded agent groups, including tokens, allowed origins, and launch options."})]}),w.jsxs("div",{className:"flex items-end gap-3 mb-4 mt-4",children:[w.jsx("div",{className:"flex flex-wrap items-end gap-3 flex-1 min-w-0",children:w.jsx("div",{className:"min-w-[220px]",children:w.jsx(Tr,{searchCallback:oe=>{C(oe),$(1)}})})}),w.jsxs("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:[w.jsx(it,{toggle:!0,primary:!1,viewLoc:s,onClass:"flex w-full justify-center rounded-md px-2 py-2 text-xs font-semibold leading-6 shadow-md transition-colors duration-100",showIcon:!0,label:"View",icon:w.jsx(ou,{className:"h-5 w-5"}),onIcon:w.jsx(tu,{className:"h-5 w-5"}),onClick:ie}),w.jsx(it,{toggle:!1,primary:!0,showIcon:!0,label:"Add Project",icon:w.jsx(sr,{className:"h-5 w-5"}),onClick:()=>A(!0)})]})]}),de&&w.jsx("div",{className:"boomi-notice boomi-notice--error text-sm",children:de}),k==="off"?w.jsxs(w.Fragment,{children:[w.jsx("ul",{role:"list",className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-x-6 gap-y-8",children:T?w.jsx("div",{className:"col-span-full flex justify-center items-center",children:w.jsx(en,{})}):Ce.length>0?Ce.map(oe=>{var Ne;const ce=((Ne=oe.label)==null?void 0:Ne.trim())||"Untitled Agent";return w.jsxs("li",{className:"boomi-card",children:[w.jsx("div",{className:"flex gap-4 p-4",children:w.jsxs("div",{className:"flex flex-col w-full",children:[w.jsx("h3",{className:"text-base font-semibold break-words truncate overflow-hidden pr-2",children:ce}),w.jsx("p",{className:"text-xs mt-1 opacity-70 break-words overflow-hidden",children:oe.agentId})]})}),w.jsxs("div",{className:"flex w-full p-2 justify-end items-center gap-x-2 relative overflow-visible",children:[w.jsx(it,{toggle:!1,primary:!0,showIcon:!1,label:"Edit",onClick:()=>{K(oe),P(!0)}}),w.jsx(Te,{agent:oe})]})]},oe.agentId)}):w.jsx("div",{className:"col-span-full flex justify-center items-center",children:w.jsx("p",{className:"text-gray-500 text-xs",children:"No agents found."})})}),!T&&Xe>1&&w.jsx(xr,{currentPage:L,totalPages:Xe,onPageChange:oe=>$(oe)})]}):w.jsxs(w.Fragment,{children:[w.jsxs("table",{className:"w-full table-auto rounded-lg shadow-sm",children:[w.jsx("thead",{className:"boomi-table-header",children:w.jsxs("tr",{children:[w.jsx("th",{className:"py-3 px-4 text-left text-sm font-semibold",children:"Agent"}),w.jsx("th",{className:"py-3 px-4 text-left text-sm font-semibold",children:"Name"}),w.jsx("th",{className:"py-3 px-4 text-left text-sm font-semibold",children:"Agent ID"}),w.jsx("th",{className:"py-3 px-4 text-right text-sm font-semibold",children:"Actions"})]})}),w.jsx("tbody",{className:"divide-y",children:T?w.jsx("tr",{children:w.jsx("td",{colSpan:3,children:w.jsx("div",{className:"flex justify-center items-center py-6",children:w.jsx(en,{})})})}):Ce.length>0?Ce.map(oe=>{var Ne;const ce=((Ne=oe.label)==null?void 0:Ne.trim())||"Untitled Agent";return w.jsxs("tr",{className:"boomi-table-row",children:[w.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2 max-w-xs break-words",children:ce}),w.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2 max-w-xs break-words",children:oe.agentId}),w.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2",children:w.jsx("div",{className:"flex justify-end",children:w.jsx(Te,{agent:oe})})})]},oe.agentId)}):w.jsx("tr",{children:w.jsx("td",{colSpan:3,children:w.jsx("div",{className:"flex justify-center items-center py-4",children:w.jsx("p",{className:"text-gray-500 text-xs",children:"No agents found."})})})})})]}),!T&&Xe>1&&w.jsx("div",{className:"mt-4 flex justify-end",children:w.jsx(xr,{currentPage:L,totalPages:Xe,onPageChange:$})})]})]})]})};var Xc={exports:{}};/*!
|
|
2117
2117
|
* sweetalert2 v11.23.0
|
|
2118
2118
|
* Released under the MIT License.
|
|
2119
2119
|
*/var Gi=Xc.exports,lC;function lH(){return lC||(lC=1,(function(t,e){(function(n,o){t.exports=o()})(Gi,(function(){function n(D,F,z){if(typeof D=="function"?D===F:D.has(F))return arguments.length<3?F:z;throw new TypeError("Private element is not present on this object")}function o(D,F){if(F.has(D))throw new TypeError("Cannot initialize the same private elements twice on an object")}function i(D,F){return D.get(n(D,F))}function r(D,F,z){o(D,F),F.set(D,z)}function s(D,F,z){return D.set(n(D,F),z),z}const c=100,a={},d=()=>{a.previousActiveElement instanceof HTMLElement?(a.previousActiveElement.focus(),a.previousActiveElement=null):document.body&&document.body.focus()},l=D=>new Promise(F=>{if(!D)return F();const z=window.scrollX,Z=window.scrollY;a.restoreFocusTimeout=setTimeout(()=>{d(),F()},c),window.scrollTo(z,Z)}),u="swal2-",h=["container","shown","height-auto","iosfix","popup","modal","no-backdrop","no-transition","toast","toast-shown","show","hide","close","title","html-container","actions","confirm","deny","cancel","footer","icon","icon-content","image","input","file","range","select","radio","checkbox","label","textarea","inputerror","input-label","validation-message","progress-steps","active-progress-step","progress-step","progress-step-line","loader","loading","styled","top","top-start","top-end","top-left","top-right","center","center-start","center-end","center-left","center-right","bottom","bottom-start","bottom-end","bottom-left","bottom-right","grow-row","grow-column","grow-fullscreen","rtl","timer-progress-bar","timer-progress-bar-container","scrollbar-measure","icon-success","icon-warning","icon-info","icon-question","icon-error","draggable","dragging"].reduce((D,F)=>(D[F]=u+F,D),{}),m=["success","warning","info","question","error"].reduce((D,F)=>(D[F]=u+F,D),{}),g="SweetAlert2:",b=D=>D.charAt(0).toUpperCase()+D.slice(1),v=D=>{console.warn(`${g} ${typeof D=="object"?D.join(" "):D}`)},x=D=>{console.error(`${g} ${D}`)},T=[],y=D=>{T.includes(D)||(T.push(D),v(D))},E=(D,F=null)=>{y(`"${D}" is deprecated and will be removed in the next major release.${F?` Use "${F}" instead.`:""}`)},_=D=>typeof D=="function"?D():D,N=D=>D&&typeof D.toPromise=="function",C=D=>N(D)?D.toPromise():Promise.resolve(D),L=D=>D&&Promise.resolve(D)===D,$=()=>document.body.querySelector(`.${h.container}`),k=D=>{const F=$();return F?F.querySelector(D):null},I=D=>k(`.${D}`),S=()=>I(h.popup),A=()=>I(h.icon),O=()=>I(h["icon-content"]),P=()=>I(h.title),R=()=>I(h["html-container"]),B=()=>I(h.image),U=()=>I(h["progress-steps"]),H=()=>I(h["validation-message"]),G=()=>k(`.${h.actions} .${h.confirm}`),W=()=>k(`.${h.actions} .${h.cancel}`),Q=()=>k(`.${h.actions} .${h.deny}`),V=()=>I(h["input-label"]),j=()=>k(`.${h.loader}`),K=()=>I(h.actions),q=()=>I(h.footer),X=()=>I(h["timer-progress-bar"]),J=()=>I(h.close),se=`
|
package/package.json
CHANGED
package/license.txt
DELETED