@boomi/embedkit 1.4.0 β 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/embedkit-cdn.js +5 -5
- package/dist/embedkit-cdn.umd.cjs +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.js +2 -1
- package/dist/index.umd.cjs +2 -1
- package/package.json +1 -1
- package/dist/index.d.ts +0 -910
package/dist/index.umd.cjs
CHANGED
|
@@ -2103,7 +2103,8 @@ 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}=Xc(),r=M.useCallback(async s=>{e(!0),o(null);try{await i(s),pe.debug("[useDeleteCors] deleted config",{primaryAccountId:s.primaryAccountId})}catch(c){const a=(c==null?void 0:c.message)||"Failed to delete CORS configuration";throw pe.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})=>{const[i,r]=M.useState(""),[s,c]=M.useState(null);M.useEffect(()=>{t&&(r(""),c(null))},[t]);const a=async()=>{const u=i.trim();if(!u){c("Origin is required");return}c(null),await n(u)};return v.jsx(En,{isOpen:t,title:"Add Allowed Origin",description:"Add a new origin to the allowed list for this tenant.",onClose:e,onSubmit:a,submitLabel:o?"Saving...":"Add Origin",showSaveButton:!o,children:v.jsx(Mt,{formName:"corsAdd",label:"Origin",required:!0,inputName:"origin",readOnly:!1,value:i,onChange:u=>r(u.target.value),placeholder:"https://app.example.com",error:s||void 0})})},qB=({isOpen:t,origin:e,onClose:n,onSubmit:o,isSaving:i})=>{const[r,s]=M.useState(e??""),[c,a]=M.useState(null);M.useEffect(()=>{t&&(s(e??""),a(null))},[t,e]);const u=async()=>{const l=r.trim();if(!l){a("Origin is required");return}a(null),await o(l)};return v.jsx(En,{isOpen:t,title:"Edit Allowed Origin",description:"Update the selected origin for this tenant.",onClose:n,onSubmit:u,submitLabel:i?"Saving...":"Save Changes",showSaveButton:!i,children:v.jsx(Mt,{formName:"corsEdit",label:"Origin",required:!0,inputName:"origin",readOnly:!1,value:r,onChange:l=>s(l.target.value),placeholder:"https://app.example.com",error:c||void 0})})},ZB=({isOpen:t,origin:e,onClose:n,onConfirm:o,isDeleting:i})=>v.jsx(En,{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:v.jsxs("p",{className:"text-sm",children:["Are you sure you want to remove"," ",v.jsx("span",{className:"font-semibold",children:e})," from the allowed origins?"]})});function eC(){const t=eo(),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)=>(pe.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]),u=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]),h=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]),d=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:h,clearSubAccount:f,revokeSessions:d,updateKey:u}),[e,n,o,i,r,s,c,a,l,h,f,d,u])}const Cp=12,tC=({componentKey:t,primaryAccountId:e})=>{var Ue,Pe,re,ve,Re,qe,$e;const{boomiConfig:n,tenantId:o,setPageIsLoading:i}=bt(),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=((ve=c==null?void 0:c.addButton)==null?void 0:ve.show)??!0,u=((Re=c==null?void 0:c.viewTypeButton)==null?void 0:Re.show)??!0,l=eo(),{listTenants:h,listSubAccounts:f,listKeyTypes:d}=eC(),{allowedOrigins:p,refetch:m,isLoading:g,error:b}=QB({primaryAccountId:r,auto:!!r}),{updateCors:w,isUpdating:x,error:T}=KB(),{deleteCors:y,isDeleting:E,error:_}=YB(),[N,C]=M.useState([]),[L,$]=M.useState(""),[I,k]=M.useState(""),[S,A]=M.useState(""),[O,P]=M.useState([]),[F,B]=M.useState([]),[U,H]=M.useState(!1),[Q,W]=M.useState(1),[G,V]=M.useState("off"),[j,Y]=M.useState(!1),[Z,ee]=M.useState(!1),[J,ae]=M.useState(!1),[K,fe]=M.useState(null),[te,ue]=M.useState(null),[Ee,ke]=M.useState(null),[Ke,ze]=M.useState({add:!1,edit:!1,delete:!1});M.useEffect(()=>{try{const be=localStorage.getItem(s);(be==="on"||be==="off")&&V(be)}catch{}},[s]),M.useEffect(()=>{U||r&&C(p.map(be=>({origin:be,tenantId:r})))},[p,U,r]),M.useEffect(()=>{const be=new AbortController;return d(be.signal).then(Oe=>H(!!Oe.isSuperAdmin)).catch(()=>H(!1)),()=>be.abort()},[d]),M.useEffect(()=>{if(!U)return;const be=new AbortController;return h(be.signal).then(Oe=>P(Oe.items??[])).catch(()=>P([])),()=>be.abort()},[U,h]),M.useEffect(()=>{if(!U)return;const be=new AbortController;return f(I||void 0,be.signal).then(Ge=>B(Ge.items??[])).catch(()=>B([])),()=>be.abort()},[U,I,f]);const Xe=M.useCallback(be=>l.get("/admin/cors",{signal:be}).then(Oe=>{const Ge=((Oe==null?void 0:Oe.items)??[]).flatMap(le=>(le.allowedOrigins||[]).map(oe=>({origin:oe,tenantId:le.primaryAccountId})));C(Ge)}),[l]);M.useEffect(()=>{if(!U)return;const be=new AbortController;return Xe(be.signal).catch(()=>C([])),()=>be.abort()},[U,Xe]);const Fe=M.useMemo(()=>{const be=L.trim().toLowerCase(),Oe=I?N.filter(Ge=>Ge.tenantId===I):N;return be?Oe.filter(Ge=>Ge.origin.toLowerCase().includes(be)):Oe},[N,L,I]),Ye=M.useMemo(()=>Fe,[Fe,S]),Ce=Math.max(1,Math.ceil(Ye.length/Cp)),We=Ye.slice((Q-1)*Cp,Q*Cp),me=be=>{ze(Oe=>({...Oe,[be]:!0})),setTimeout(()=>ze(Oe=>({...Oe,[be]:!1})),3e3)},Te=()=>r||(ke("primaryAccountId is required to manage CORS."),null),ye=()=>U?I||(ke("Select a tenant to modify CORS configuration."),null):Te(),Ae=M.useCallback(()=>{V(be=>{const Oe=be==="on"?"off":"on";try{localStorage.setItem(s,Oe)}catch{}return Oe})},[s]),de=async be=>{const Oe=ye();if(!Oe)return;const Ge=Array.from(new Set([...N.filter(le=>le.tenantId===Oe).map(le=>le.origin),be]));i(!0);try{const le=await w({primaryAccountId:Oe,allowedOrigins:Ge});U||C(le.allowedOrigins.map(oe=>({origin:oe,tenantId:Oe}))),Y(!1),me("add"),U?await Xe():await m()}catch(le){pe.error({err:le},"[Cors] add failed")}finally{i(!1)}},ie=async be=>{if(!K)return;const Oe=U?te||ye():Te();if(!Oe)return;const Ge=N.filter(oe=>oe.tenantId===Oe).map(oe=>oe.origin===K?be:oe.origin),le=Array.from(new Set(Ge));i(!0);try{const oe=await w({primaryAccountId:Oe,allowedOrigins:le});U||C(oe.allowedOrigins.map(we=>({origin:we,tenantId:Oe}))),ee(!1),fe(null),ue(null),me("edit"),U?await Xe():await m()}catch(oe){pe.error({err:oe},"[Cors] edit failed")}finally{i(!1)}},ce=async()=>{if(!K)return;const be=U?te||ye():Te();if(!be)return;const Oe=N.filter(Ge=>Ge.tenantId===be).map(Ge=>Ge.origin).filter(Ge=>Ge!==K);i(!0);try{if(Oe.length===0)await y({primaryAccountId:be}),U||C([]);else{const Ge=await w({primaryAccountId:be,allowedOrigins:Oe});U||C(Ge.allowedOrigins.map(le=>({origin:le,tenantId:be})))}ae(!1),fe(null),ue(null),me("delete"),U?await Xe():await m()}catch(Ge){pe.error({err:Ge},"[Cors] delete failed")}finally{i(!1)}},Ne=({origin:be,tenantId:Oe})=>v.jsxs(ai,{children:[v.jsx(Ft.Item,{children:({active:Ge})=>v.jsxs("button",{onClick:()=>{fe(be),ue(Oe),ee(!0)},className:"boomi-menu-item","data-headlessui-state":Ge?"active":void 0,children:[v.jsx(Cl,{className:"boomi-menu-icon"}),"Edit"]})}),v.jsx("div",{className:"boomi-menu-divider"}),v.jsx(Ft.Item,{children:({active:Ge})=>v.jsxs("button",{onClick:()=>{fe(be),ue(Oe),ae(!0)},className:"boomi-menu-item boomi-menu-item--danger","data-headlessui-state":Ge?"active":void 0,children:[v.jsx(Jn,{className:"boomi-menu-icon"}),"Delete"]})})]}),Ie=Ee||b||T||_||null;return v.jsxs(v.Fragment,{children:[Ke.add&&v.jsx(On,{type:"success",content:"Origin added."}),Ke.edit&&v.jsx(On,{type:"success",content:"Origin updated."}),Ke.delete&&v.jsx(On,{type:"success",content:"Origin deleted."}),v.jsx(XB,{isOpen:j,onClose:()=>Y(!1),onSubmit:de,isSaving:x}),v.jsx(qB,{isOpen:Z,origin:K,onClose:()=>{ee(!1),fe(null)},onSubmit:ie,isSaving:x}),v.jsx(ZB,{isOpen:J,origin:K,onClose:()=>{ae(!1),fe(null)},onConfirm:ce,isDeleting:E}),v.jsxs("div",{className:"w-full h-full p-6",children:[v.jsxs("div",{className:"space-y-2",children:[v.jsx("h1",{className:"text-2xl font-semibold",children:"CORS Configuration"}),v.jsx("p",{className:"text-sm opacity-70",children:"Manage allowed origins for this tenant."})]}),v.jsxs("div",{className:"flex items-end gap-3 mb-4 mt-4",children:[v.jsxs("div",{className:"flex flex-wrap items-end gap-3 flex-1 min-w-0",children:[v.jsx("div",{className:`min-w-[220px]${U?" pt-6":""}`,children:v.jsx(Vi,{searchCallback:be=>{$(be),W(1)}})}),U&&v.jsxs("label",{className:"text-xs font-semibold",children:["Tenant",v.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:I,onChange:be=>{k(be.target.value),A(""),W(1)},children:[v.jsx("option",{value:"",children:"All"}),O.map(be=>v.jsx("option",{value:be,children:be},be))]})]})]}),v.jsxs("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:[u&&v.jsx(tt,{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:v.jsx(Nl,{className:"h-5 w-5"}),onIcon:v.jsx(_l,{className:"h-5 w-5"}),onClick:Ae}),a&&v.jsx(tt,{toggle:!1,primary:!0,showIcon:!0,label:`Add ${(($e=c==null?void 0:c.addButton)==null?void 0:$e.label)??""}`.trim(),icon:v.jsx(Si,{className:"h-5 w-5"}),onClick:()=>Y(!0)})]})]}),Ie&&v.jsx("div",{className:"boomi-notice boomi-notice--error text-sm",children:Ie}),G==="off"?v.jsxs(v.Fragment,{children:[v.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?v.jsx("div",{className:"col-span-full flex justify-center items-center",children:v.jsx(Yt,{})}):We.length>0?We.map(be=>{var Oe;return v.jsxs("li",{className:"boomi-card boomi-cors-card",children:[v.jsx("div",{className:"flex gap-4 p-4",children:v.jsxs("div",{className:"flex flex-col w-full",children:[v.jsx("h3",{className:"text-base font-semibold break-words truncate overflow-hidden pr-2",children:be.origin}),v.jsxs("p",{className:"text-xs mt-1 line-clamp-2 break-words overflow-hidden",children:["Origin allowed for tenant ",be.tenantId,"."]})]})}),v.jsxs("div",{className:"flex w-full p-2 justify-end items-center gap-x-2 relative overflow-visible",children:[v.jsx(tt,{toggle:!1,primary:!0,showIcon:!1,label:((Oe=c==null?void 0:c.editButton)==null?void 0:Oe.label)??"Edit",onClick:()=>{fe(be.origin),ue(be.tenantId),ee(!0)}}),v.jsx(Ne,{origin:be.origin,tenantId:be.tenantId})]})]},`${be.tenantId}:${be.origin}`)}):v.jsx("div",{className:"col-span-full flex justify-center items-center",children:v.jsx("p",{className:"text-gray-500 text-xs",children:"No allowed origins found."})})}),!g&&Ce>1&&v.jsx(di,{currentPage:Q,totalPages:Ce,onPageChange:be=>W(be)})]}):v.jsxs(v.Fragment,{children:[v.jsxs("table",{className:"w-full table-auto rounded-lg shadow-sm",children:[v.jsx("thead",{className:"boomi-table-header",children:v.jsxs("tr",{children:[v.jsx("th",{className:"py-3 px-4 text-left text-sm font-semibold w-3/4",children:"Origin"}),U&&v.jsx("th",{className:"py-3 px-4 text-left text-sm font-semibold",children:"Tenant"}),v.jsx("th",{className:"py-3 px-4 text-right text-sm font-semibold w-1/4",children:"Actions"})]})}),v.jsx("tbody",{className:"divide-y",children:g?v.jsx("tr",{children:v.jsx("td",{colSpan:U?3:2,children:v.jsx("div",{className:"flex justify-center items-center py-6",children:v.jsx(Yt,{})})})}):We.length>0?We.map(be=>v.jsxs("tr",{className:"boomi-table-row",children:[v.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2 max-w-md break-words",children:be.origin}),U&&v.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2",children:be.tenantId}),v.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2",children:v.jsx("div",{className:"flex justify-end",children:v.jsx(Ne,{origin:be.origin,tenantId:be.tenantId})})})]},`${be.tenantId}:${be.origin}`)):v.jsx("tr",{children:v.jsx("td",{colSpan:U?3:2,children:v.jsx("div",{className:"flex justify-center items-center py-4",children:v.jsx("p",{className:"text-gray-500 text-xs",children:"No allowed origins found."})})})})})]}),!g&&Ce>1&&v.jsx("div",{className:"mt-4 flex justify-end",children:v.jsx(di,{currentPage:Q,totalPages:Ce,onPageChange:W})})]})]})]})};function nC(){const t=eo(),e=M.useCallback(s=>`/admin/agents/${encodeURIComponent(s)}`,[]),n=M.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=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:u,label:l,allowedOrigins:h,config:f,publicTokenIds:d,createToken:p,rateLimit:m,signal:g}=s,b={agentId:a};return u!==void 0&&(b.boomiAgentId=u),l!==void 0&&(b.label=l),h!==void 0&&(b.allowedOrigins=h),f!==void 0&&(b.config=f),d!==void 0&&(b.publicTokenIds=d),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:u}=s;await t.del(`${e(c)}/${encodeURIComponent(a)}`,{signal:u})},[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},(u,l)=>String(l+1)).join(`
|
|
2106
|
-
`),[c]);return v.jsxs("div",{children:[v.jsxs("label",{className:"boomi-form-label inline-flex items-center gap-2",children:[v.jsx("span",{children:t}),e]}),v.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:[v.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}),v.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&&v.jsx("p",{className:"boomi-form-helper",children:i}),r&&v.jsx("p",{className:"boomi-form-error",children:r})]})},Np=[{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"],JB=t=>/font|family|radius|scale|speed|direction|angle|opacity|blur/.test(t),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"],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."}),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,u,l,h,f,d,p,m,g,b,w,x,T,y,E,_,N,C,L,$,I,k,S;const i={...e};if(i.themeCustomVars=[],!t.trim())return i;try{const A=JSON.parse(t);if(A!=null&&A.theme&&typeof A.theme.defaultTheme=="string"){const V=A.theme.defaultTheme;V==="boomi"||V==="base"?(i.themeSelection=V,i.themeDefault=V,i.themeCustomName=""):(i.themeSelection="custom",i.themeDefault=V,i.themeCustomName=V);const j=(r=A==null?void 0:A.cssVarsByTheme)==null?void 0:r[V];j&&typeof j=="object"&&(i.themeCustomVars=Object.entries(j).map(([Y,Z])=>({id:`var_${Y}`,varName:Y,value:typeof Z=="string"?Z:String(Z)})))}const O=(s=A==null?void 0:A.components)==null?void 0:s.agentList,P=(c=A==null?void 0:A.components)==null?void 0:c.agentTiles;if(n==="list"&&O){const V=O.launcher??{},j=V.position??{};kr.includes(j.corner)&&(i.launcherCorner=j.corner),j.offsetX!==void 0&&(i.launcherOffsetX=String(j.offsetX)),j.offsetY!==void 0&&(i.launcherOffsetY=String(j.offsetY)),(V.shape==="pill"||V.shape==="circle")&&(i.launcherShape=V.shape),typeof V.label=="string"&&(i.launcherLabel=V.label),typeof V.icon=="string"&&(i.launcherIcon=V.icon),typeof V.hideIcon=="boolean"&&(i.launcherHideIcon=V.hideIcon);const Y=O.modal??{};Y.width!==void 0&&(i.listModalWidth=String(Y.width)),Y.height!==void 0&&(i.listModalHeight=String(Y.height));const Z=Y.position??{};kr.includes(Z.corner)&&(i.listModalCorner=Z.corner),Z.offsetX!==void 0&&(i.listModalOffsetX=String(Z.offsetX)),Z.offsetY!==void 0&&(i.listModalOffsetY=String(Z.offsetY)),(a=O.welcome)!=null&&a.title&&(i.listWelcomeTitle=O.welcome.title),(u=O.welcome)!=null&&u.subtitle&&(i.listWelcomeSubtitle=O.welcome.subtitle),((l=O.header)==null?void 0:l.show)!==void 0&&(i.listHeaderShow=!!O.header.show),(h=O.header)!=null&&h.title&&(i.listHeaderTitle=O.header.title),(f=O.header)!=null&&f.description&&(i.listHeaderDescription=O.header.description),((d=O.search)==null?void 0:d.show)!==void 0&&(i.listSearchShow=!!O.search.show)}n==="tiles"&&P&&(((p=P.header)==null?void 0:p.show)!==void 0&&(i.tilesHeaderShow=!!P.header.show),(m=P.header)!=null&&m.title&&(i.tilesHeaderTitle=P.header.title),(g=P.header)!=null&&g.description&&(i.tilesHeaderDescription=P.header.description),((b=P.search)==null?void 0:b.show)!==void 0&&(i.tilesSearchShow=!!P.search.show),((w=P.viewToggle)==null?void 0:w.show)!==void 0&&(i.tilesViewToggleShow=!!P.viewToggle.show));const F=(A==null?void 0:A.agents)??{},B=o.find(V=>F[V])??Object.keys(F)[0],U=B?F[B]:null;U!=null&&U.position&&typeof U.position=="object"&&"corner"in U.position&&(kr.includes(U.position.corner)&&(i.launcherCorner=U.position.corner),U.position.offsetX!==void 0&&(i.launcherOffsetX=String(U.position.offsetX)),U.position.offsetY!==void 0&&(i.launcherOffsetY=String(U.position.offsetY))),((U==null?void 0:U.shape)==="pill"||(U==null?void 0:U.shape)==="circle")&&(i.launcherShape=U.shape),typeof(U==null?void 0:U.label)=="string"&&(i.launcherLabel=U.label),typeof(U==null?void 0:U.icon)=="string"&&(i.launcherIcon=U.icon),typeof(U==null?void 0:U.hideIcon)=="boolean"&&(i.launcherHideIcon=U.hideIcon);const H=(U==null?void 0:U.ui)??{};(H.mode==="modal"||H.mode==="full")&&(i.agentUiMode=H.mode),((x=H.modal)==null?void 0:x.width)!==void 0&&(i.agentModalWidth=String(H.modal.width)),((T=H.modal)==null?void 0:T.height)!==void 0&&(i.agentModalHeight=String(H.modal.height)),(E=(y=H.modal)==null?void 0:y.position)!=null&&E.corner&&kr.includes(H.modal.position.corner)&&(i.agentModalCorner=H.modal.position.corner),((N=(_=H.modal)==null?void 0:_.position)==null?void 0:N.offsetX)!==void 0&&(i.agentModalOffsetX=String(H.modal.position.offsetX)),((L=(C=H.modal)==null?void 0:C.position)==null?void 0:L.offsetY)!==void 0&&(i.agentModalOffsetY=String(H.modal.position.offsetY));const Q=H.sessionScope==="mount"?!1:H.sessionScope==="multi"?!0:void 0,G=((($=H.sidebar)==null?void 0:$.show)!==void 0?!!H.sidebar.show:void 0)??Q;G!==void 0&&(i.agentSidebarShow=G),((I=H.sidebar)==null?void 0:I.width)!==void 0&&(i.agentSidebarWidth=String(H.sidebar.width)),(k=H.welcome)!=null&&k.title&&(i.agentWelcomeTitle=H.welcome.title),(S=H.welcome)!=null&&S.subtitle&&(i.agentWelcomeSubtitle=H.welcome.subtitle)}catch{return i}return i},nH=(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}};if(t.themeSelection==="custom"){const s={};for(const c of t.themeCustomVars)c.varName&&c.value&&(s[c.varName]=c.value);Object.keys(s).length&&(i.cssVarsByTheme={[o]:s})}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 r=n.length?n:["agent-id"];return i.agents=r.reduce((s,c)=>(s[c]={transport:"boomi-direct",...e==="single"?{position:{corner:t.launcherCorner,offsetX:po(t.launcherOffsetX),offsetY:po(t.launcherOffsetY)},shape:t.launcherShape,label:t.launcherLabel,icon:t.launcherIcon,hideIcon:t.launcherHideIcon}:{},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}}},s),{}),i.project={embedType:e,agentIds:r},i},rC=({embedType:t,agentIds:e,configRaw:n,onChangeConfig:o,onUpdateBuilder:i,syncFromConfig:r=!1})=>{const s=M.useMemo(eH,[]),[c,a]=M.useState(s),u=M.useRef(!1);M.useEffect(()=>{(r||!u.current)&&(a(tH(n,s,t,e)),u.current=!0)},[n,s,t,e,r]),M.useEffect(()=>{i==null||i(c)},[c,i]),M.useEffect(()=>{const d=nH(c,t,e);o(d)},[c,t,e,o]);const l=()=>{const d=iC[0]??"--boomi-root-bg-color";a(p=>({...p,themeCustomVars:[...p.themeCustomVars,{id:`var_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,varName:d,value:"#000000"}]}))},h=(d,p)=>{a(m=>({...m,themeCustomVars:m.themeCustomVars.map(g=>g.id===d?{...g,...p}:g)}))},f=d=>{a(p=>({...p,themeCustomVars:p.themeCustomVars.filter(m=>m.id!==d)}))};return v.jsxs("div",{className:"boomi-card p-4 space-y-4",children:[v.jsxs("div",{children:[v.jsx("div",{className:"text-sm font-semibold",children:"Config Builder"}),v.jsx("div",{className:"text-xs opacity-70",children:"Updates the JSON configuration automatically as you make changes."})]}),v.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[v.jsxs("div",{className:"space-y-3",children:[v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Agent UI"}),v.jsxs("label",{className:"boomi-form-label",children:["Mode",v.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentUiMode,onChange:d=>a(p=>({...p,agentUiMode:d.target.value})),children:[v.jsx("option",{value:"modal",children:"Modal"}),v.jsx("option",{value:"full",children:"Full Page"})]})]}),c.agentUiMode==="modal"&&v.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[v.jsxs("label",{className:"boomi-form-label",children:["Modal width",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentModalWidth,onChange:d=>a(p=>({...p,agentModalWidth:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Modal height",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentModalHeight,onChange:d=>a(p=>({...p,agentModalHeight:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Modal corner",v.jsx("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentModalCorner,onChange:d=>a(p=>({...p,agentModalCorner:d.target.value})),children:kr.map(d=>v.jsx("option",{value:d,children:d},d))})]}),v.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[v.jsxs("label",{className:"boomi-form-label",children:["Offset X",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentModalOffsetX,onChange:d=>a(p=>({...p,agentModalOffsetX:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Offset Y",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentModalOffsetY,onChange:d=>a(p=>({...p,agentModalOffsetY:d.target.value}))})]})]})]}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.agentSidebarShow,onChange:d=>a(p=>({...p,agentSidebarShow:d.target.checked}))}),"Show sidebar"]}),v.jsxs("label",{className:"boomi-form-label",children:["Sidebar width",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentSidebarWidth,onChange:d=>a(p=>({...p,agentSidebarWidth:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Welcome title",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentWelcomeTitle,onChange:d=>a(p=>({...p,agentWelcomeTitle:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Welcome subtitle",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentWelcomeSubtitle,onChange:d=>a(p=>({...p,agentWelcomeSubtitle:d.target.value}))})]})]}),v.jsxs("div",{className:"space-y-3",children:[v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Theme"}),v.jsxs("label",{className:"boomi-form-label",children:["Theme",v.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.themeSelection,onChange:d=>a(p=>({...p,themeSelection:d.target.value,themeDefault:d.target.value==="custom"?p.themeDefault:d.target.value})),children:[v.jsx("option",{value:"boomi",children:"boomi"}),v.jsx("option",{value:"base",children:"base"}),v.jsx("option",{value:"custom",children:"custom"})]})]}),c.themeSelection==="custom"&&v.jsxs(v.Fragment,{children:[v.jsxs("label",{className:"boomi-form-label",children:["Custom theme name",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.themeCustomName,onChange:d=>a(p=>({...p,themeCustomName:d.target.value,themeDefault:d.target.value})),placeholder:"my-theme"})]}),v.jsxs("div",{className:"space-y-2",children:[v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Custom CSS Vars"}),c.themeCustomVars.length===0&&v.jsx("div",{className:"text-xs opacity-70",children:"No custom variables yet."}),v.jsx("div",{className:"space-y-2",children:c.themeCustomVars.map(d=>v.jsxs("div",{className:"flex items-center gap-2 flex-nowrap w-full overflow-x-auto",children:[v.jsx("select",{className:"boomi-input flex-1 min-w-0 rounded-md p-2 text-sm",value:d.varName,onChange:p=>h(d.id,{varName:p.target.value}),children:iC.map(p=>v.jsx("option",{value:p,children:p},p))}),JB(d.varName)?v.jsx("input",{type:"text",value:d.value,onChange:p=>h(d.id,{value:p.target.value}),className:"boomi-input flex-1 min-w-0 rounded-md p-2 text-sm",placeholder:"e.g. Inter, sans-serif"}):v.jsx("input",{type:"color",value:d.value,onChange:p=>h(d.id,{value:p.target.value}),className:"h-9 w-12 shrink-0 cursor-pointer rounded-md border border-[var(--boomi-card-border)] bg-transparent"}),v.jsx("button",{type:"button",className:"text-xs text-red-500 whitespace-nowrap shrink-0",onClick:()=>f(d.id),children:"Remove"})]},d.id))}),v.jsx("div",{children:v.jsx("button",{type:"button",className:"boomi-btn-primary px-3 py-2 text-xs disabled:opacity-50",onClick:l,disabled:!c.themeCustomName.trim(),children:"Add CSS Variable"})})]})]})]})]}),(t==="list"||t==="single")&&v.jsxs("div",{className:t==="list"?"grid gap-4 md:grid-cols-2":"space-y-3",children:[v.jsxs("div",{className:"space-y-3",children:[v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Launcher (Pill)"}),v.jsxs("label",{className:"boomi-form-label",children:["Corner",v.jsx("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.launcherCorner,onChange:d=>a(p=>({...p,launcherCorner:d.target.value})),children:kr.map(d=>v.jsx("option",{value:d,children:d},d))})]}),v.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[v.jsxs("label",{className:"boomi-form-label",children:["Offset X",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.launcherOffsetX,onChange:d=>a(p=>({...p,launcherOffsetX:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Offset Y",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.launcherOffsetY,onChange:d=>a(p=>({...p,launcherOffsetY:d.target.value}))})]})]}),v.jsxs("label",{className:"boomi-form-label",children:["Shape",v.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.launcherShape,onChange:d=>a(p=>({...p,launcherShape:d.target.value})),children:[v.jsx("option",{value:"pill",children:"Pill"}),v.jsx("option",{value:"circle",children:"Circle"})]})]}),v.jsxs("label",{className:"boomi-form-label",children:["Label",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.launcherLabel,onChange:d=>a(p=>({...p,launcherLabel:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Icon",v.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:Np.some(d=>d.value===c.launcherIcon)?c.launcherIcon:"__custom__",onChange:d=>a(p=>({...p,launcherIcon:d.target.value==="__custom__"?p.launcherIcon:d.target.value})),children:[!Np.some(d=>d.value===c.launcherIcon)&&v.jsxs("option",{value:"__custom__",children:[c.launcherIcon," (custom)"]}),Np.map(d=>v.jsx("option",{value:d.value,children:d.label},d.value))]})]}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.launcherHideIcon,onChange:d=>a(p=>({...p,launcherHideIcon:d.target.checked}))}),"Hide icon"]})]}),t==="list"&&v.jsxs("div",{className:"space-y-3",children:[v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"List Modal"}),v.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[v.jsxs("label",{className:"boomi-form-label",children:["Width",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listModalWidth,onChange:d=>a(p=>({...p,listModalWidth:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Height",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listModalHeight,onChange:d=>a(p=>({...p,listModalHeight:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Corner",v.jsx("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listModalCorner,onChange:d=>a(p=>({...p,listModalCorner:d.target.value})),children:kr.map(d=>v.jsx("option",{value:d,children:d},d))})]}),v.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[v.jsxs("label",{className:"boomi-form-label",children:["Offset X",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listModalOffsetX,onChange:d=>a(p=>({...p,listModalOffsetX:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Offset Y",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listModalOffsetY,onChange:d=>a(p=>({...p,listModalOffsetY:d.target.value}))})]})]})]}),v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70 pt-2",children:"List Header & Search"}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.listHeaderShow,onChange:d=>a(p=>({...p,listHeaderShow:d.target.checked}))}),"Show header"]}),v.jsxs("label",{className:"boomi-form-label",children:["Header title",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listHeaderTitle,onChange:d=>a(p=>({...p,listHeaderTitle:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Header description",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listHeaderDescription,onChange:d=>a(p=>({...p,listHeaderDescription:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.listSearchShow,onChange:d=>a(p=>({...p,listSearchShow:d.target.checked}))}),"Show search"]}),v.jsxs("label",{className:"boomi-form-label",children:["Welcome title",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listWelcomeTitle,onChange:d=>a(p=>({...p,listWelcomeTitle:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Welcome subtitle",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listWelcomeSubtitle,onChange:d=>a(p=>({...p,listWelcomeSubtitle:d.target.value}))})]})]})]}),t==="tiles"&&v.jsxs("div",{className:"space-y-3",children:[v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Tiles Header & Search"}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.tilesHeaderShow,onChange:d=>a(p=>({...p,tilesHeaderShow:d.target.checked}))}),"Show header"]}),v.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[v.jsxs("label",{className:"boomi-form-label",children:["Header title",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.tilesHeaderTitle,onChange:d=>a(p=>({...p,tilesHeaderTitle:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Header description",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.tilesHeaderDescription,onChange:d=>a(p=>({...p,tilesHeaderDescription:d.target.value}))})]})]}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.tilesSearchShow,onChange:d=>a(p=>({...p,tilesSearchShow:d.target.checked}))}),"Show search"]}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.tilesViewToggleShow,onChange:d=>a(p=>({...p,tilesViewToggleShow:d.target.checked}))}),"Show tiles/table toggle"]})]})]})};function oH(t){try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}const iH=({isOpen:t,onClose:e,onSubmit:n,isSaving:o,defaultOrigins:i,availableAgents:r})=>{const[s,c]=M.useState(""),[a,u]=M.useState(null),[l,h]=M.useState(!1),[f,d]=M.useState([]),[p,m]=M.useState(""),[g,b]=M.useState("single"),[w,x]=M.useState(""),[T,y]=M.useState([]),[E,_]=M.useState(null),[N,C]=M.useState(null),[L,$]=M.useState(null),[I,k]=M.useState("builder"),S=(G,V)=>(G.length>0?G:["agent-id"]).reduce((Y,Z)=>(Y[Z]={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."}}},Y),{}),P=JSON.stringify(((G,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"}}};G==="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 Y=V.length>0?V:["agent-id"];return j.agents=S(Y,G==="single"?"modal":"full"),j})(g,g==="single"?w?[w]:[]:T),null,2);M.useEffect(()=>{var V;if(!t)return;const G=((V=r==null?void 0:r[0])==null?void 0:V.id)||"";c(""),u(null),h(!1),d([]),m(""),b("single"),x(G),y(G?[G]:[]),_(null),C(null),$(null),k("builder")},[t,i,r]),M.useEffect(()=>{g==="single"?!w&&T[0]&&x(T[0]):T.length===0&&w&&y([w])},[g,T,w]);const F=G=>{y(V=>V.includes(G)?V.filter(j=>j!==G):[...V,G])},B=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`project_${crypto.randomUUID()}`:`project_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`,U=async()=>{if(!s.trim()){h(!0),u("Project name is required.");return}u(null);const G=g==="single"?w?[w]:[]:T;if(!G.length){_("Select at least one agent");return}_(null);let V;const j=p.trim();if(j)try{V=JSON.parse(j)}catch{$("Config must be valid JSON");return}$(null);const Y=V&&typeof V=="object"?{...V}:{},Z=Y.project&&typeof Y.project=="object"?{...Y.project}:{};Y.project={...Z,embedType:g,agentIds:G};const ee=Array.from(new Set(f.map(ae=>ae.trim()).filter(Boolean)));if(!ee.length){C("At least one allowed origin is required.");return}for(const ae of ee)if(!oH(ae)){C(`Invalid origin (must be http/https): ${ae}`);return}C(null);const J=B();if(g==="single"&&w){const ae={...Y.agents??{}};ae[w]&&!ae[J]&&(ae[J]=ae[w],Y.agents=ae)}await n({agentId:J,boomiAgentId:g==="single"?w:void 0,label:s.trim()||void 0,allowedOrigins:ee,config:Y})},H=()=>{d(G=>[...G,""])},Q=(G,V)=>{d(j=>j.map((Y,Z)=>Z===G?V:Y))},W=G=>{d(V=>V.filter((j,Y)=>Y!==G))};return v.jsxs(En,{isOpen:t,title:"Add Project",description:"Create a new embedded agent group and its allowed embed origins.",onClose:e,onSubmit:U,submitLabel:o?"Saving...":"Create Project",showSaveButton:!o,children:[v.jsxs("div",{className:"boomi-card p-4 space-y-2",children:[v.jsx("div",{className:"text-sm font-semibold",children:"Project Summary"}),v.jsxs("div",{className:"text-xs opacity-80",children:["Embed type: ",v.jsx("strong",{children:g==="single"?"Single Agent":g==="tiles"?"Multi-Agent (Tiles)":"Multi-Agent (List)"})]}),v.jsxs("div",{className:"text-xs opacity-80",children:["Selected agents: ",v.jsx("strong",{children:g==="single"?w?1:0:T.length})]}),v.jsx("div",{className:"text-xs opacity-70",children:"You can start with the form below and optionally layer in advanced JSON config."})]}),v.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[v.jsxs("div",{className:"space-y-4",children:[v.jsx(Mt,{formName:"agentAdd",label:"Project Name",required:!0,inputName:"name",readOnly:!1,value:s,onChange:G=>{c(G.target.value),a&&u(null)},onBlur:()=>{h(!0),s.trim()||u("Project name is required.")},placeholder:"Customer Support Project"}),l&&a&&v.jsx("div",{className:"boomi-form-error",children:a}),v.jsxs("label",{className:"boomi-form-label",children:["Embed Type",v.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:g,onChange:G=>b(G.target.value),children:[v.jsx("option",{value:"single",children:"Single Agent"}),v.jsx("option",{value:"tiles",children:"Multi-Agent (Tiles)"}),v.jsx("option",{value:"list",children:"Multi-Agent (Pill + Modal List)"})]})]}),g==="single"?v.jsxs("label",{className:"boomi-form-label",children:["Agent",v.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:w,onChange:G=>x(G.target.value),children:[(r??[]).length===0&&v.jsx("option",{value:"",children:"No agents available"}),(r??[]).map(G=>v.jsx("option",{value:G.id,children:G.label},G.id))]}),E&&v.jsx("div",{className:"text-xs text-red-500 mt-1",children:E})]}):v.jsxs("div",{children:[v.jsx("label",{className:"boomi-form-label",children:"Agents"}),v.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?v.jsx("div",{className:"text-xs opacity-70",children:"No agents available"}):(r??[]).map(G=>v.jsxs("label",{className:"flex items-center gap-2",children:[v.jsx("input",{type:"checkbox",checked:T.includes(G.id),onChange:()=>F(G.id)}),v.jsx("span",{className:"text-xs",children:G.label})]},G.id))}),E&&v.jsx("div",{className:"text-xs text-red-500 mt-1",children:E})]})]}),v.jsx("div",{className:"space-y-4",children:v.jsxs("div",{className:"space-y-2",children:[v.jsx("label",{className:"boomi-form-label",children:"Allowed Origins"}),v.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."}),v.jsxs("div",{className:"space-y-2",children:[f.length===0&&v.jsx("div",{className:"text-xs opacity-70",children:"No origins selected."}),f.map((G,V)=>{const j=new Set(f.map(ee=>ee.trim()).filter(Boolean)),Y=(i??[]).filter(ee=>ee===G||!j.has(ee)),Z=Y.includes(G);return v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsxs("select",{className:"boomi-input w-full rounded-md p-2 text-sm",value:G,onChange:ee=>Q(V,ee.target.value),children:[!G&&v.jsx("option",{value:"",children:"Select an origin"}),Z?null:G?v.jsx("option",{value:G,children:G}):null,Y.map(ee=>v.jsx("option",{value:ee,children:ee},ee))]}),v.jsx("span",{role:"button",tabIndex:0,className:"text-red-500 text-lg cursor-pointer",onClick:()=>W(V),onKeyDown:ee=>{(ee.key==="Enter"||ee.key===" ")&&W(V)},"aria-label":"Remove origin",children:v.jsx(Jn,{})})]},`${G}-${V}`)})]}),v.jsx("div",{className:"flex",children:v.jsx(tt,{toggle:!1,primary:!1,showIcon:!1,label:"Add Allowed Origin",onClick:H})}),N&&v.jsx("div",{className:"text-xs text-red-500",children:N}),v.jsx("div",{className:"text-xs opacity-70",children:"Add new origins from the CORS page before selecting them here."})]})})]}),v.jsxs("div",{className:"space-y-3",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsxs("div",{children:[v.jsx("div",{className:"text-sm font-semibold",children:"UI Configuration"}),v.jsx("div",{className:"text-xs opacity-70",children:"Optional. Use JSON to customize themes, layout, and agent UI beyond the form inputs."})]}),v.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:[v.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${I==="builder"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>k("builder"),children:"Builder"}),v.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${I==="json"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>k("json"),children:"JSON"})]})]}),I==="builder"?v.jsx(rC,{embedType:g,agentIds:g==="single"?w?[w]:[]:T,configRaw:p,onChangeConfig:G=>{const V=JSON.stringify(G,null,2);V!==p&&m(V)},syncFromConfig:!1}):v.jsxs(v.Fragment,{children:[v.jsx(oC,{label:"Config (JSON)",value:p,placeholder:P,error:L,onChange:m}),v.jsx("div",{className:"flex justify-end",children:v.jsx(tt,{toggle:!1,primary:!1,showIcon:!1,label:"Insert Starter Config",onClick:()=>m(P)})})]})]})]})},rH=({isOpen:t,agentId:e,onClose:n,onConfirm:o,isDeleting:i})=>v.jsx(En,{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:v.jsxs("p",{className:"text-sm",children:["Are you sure you want to delete"," ",v.jsx("span",{className:"font-semibold",children:e}),"?"]})});function sC(t){try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}const sH=({isOpen:t,agentId:e,label:n,allowedOrigins:o,defaultOrigins:i,onAddOrigin:r,config:s,onClose:c,onSubmit:a,isSaving:u})=>{const[l,h]=M.useState(""),[f,d]=M.useState([]),[p,m]=M.useState(""),[g,b]=M.useState(!1),[w,x]=M.useState(""),[T,y]=M.useState(null),[E,_]=M.useState(null),[N,C]=M.useState("builder"),L=(H,Q)=>(H.length>0?H:["agent-id"]).reduce((G,V)=>(G[V]={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."}}},G),{}),$=(H,Q)=>{const W={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"}}};H==="list"&&(W.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 G=Q.length>0?Q:["agent-id"];return W.agents=L(G,H==="single"?"modal":"full"),W},k=(()=>{try{const H=w.trim()?JSON.parse(w):null,Q=H&&typeof H=="object"?H.project:null,W=typeof(Q==null?void 0:Q.embedType)=="string"?Q.embedType:"single",G=Array.isArray(Q==null?void 0:Q.agentIds)?Q.agentIds.filter(Boolean):[];return{embedType:W,agentIds:G}}catch{return{embedType:"single",agentIds:[]}}})(),S=k.agentIds.length>0?k.agentIds:e?[e]:[],A=JSON.stringify($(k.embedType,S),null,2);M.useEffect(()=>{if(t){h(n??"");const H=(o&&o.length?o:i)??[];d(H),m(""),x(s?JSON.stringify(s,null,2):""),y(null),_(null),C("builder")}},[t,n,s,o,i]);const O=async()=>{if(!e)return;let H;const Q=w.trim();if(Q)try{H=JSON.parse(Q)}catch{_("Config must be valid JSON");return}_(null);const W=Array.from(new Set(f.map(G=>G.trim()).filter(Boolean)));if(!W.length){y("At least one allowed origin is required.");return}for(const G of W)if(!sC(G)){y(`Invalid origin (must be http/https): ${G}`);return}if(y(null),H&&e){const G=H.project,V=G==null?void 0:G.embedType,j=Array.isArray(G==null?void 0:G.agentIds)?G.agentIds[0]:null;if(V==="single"&&j){const Y={...H.agents??{}};Y[j]&&!Y[e]&&(Y[e]=Y[j],H.agents=Y)}}await a({agentId:e,label:l.trim()||void 0,allowedOrigins:W,config:H})},P=()=>{const H=i??[],Q=new Set(f.map(G=>G.trim()).filter(Boolean)),W=H.find(G=>!Q.has(G))??"";d(G=>[...G,W])},F=(H,Q)=>{d(W=>W.map((G,V)=>V===H?Q:G))},B=H=>{d(Q=>Q.filter((W,G)=>G!==H))},U=async()=>{const H=p.trim();if(!H){y("Enter an origin before adding.");return}if(!sC(H)){y(`Invalid origin (must be http/https): ${H}`);return}if(y(null),!r){d(Q=>Q.includes(H)?Q:[...Q,H]),m("");return}b(!0);try{await r(H),d(Q=>Q.includes(H)?Q:[...Q,H]),m("")}catch(Q){y((Q==null?void 0:Q.message)||"Failed to add origin.")}finally{b(!1)}};return v.jsxs(En,{isOpen:t,title:"Edit Agent",description:"Update agent details and allowed origins.",onClose:c,onSubmit:O,submitLabel:u?"Saving...":"Save Changes",showSaveButton:!u,children:[v.jsxs("div",{className:"boomi-card p-4 space-y-2",children:[v.jsx("div",{className:"text-sm font-semibold",children:"Agent Overview"}),v.jsxs("div",{className:"text-xs opacity-80",children:["Agent ID: ",v.jsx("strong",{children:e??"β"})]}),v.jsx("div",{className:"text-xs opacity-70",children:"Update the friendly name, allowed origins, and optional config overrides below."})]}),v.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[v.jsxs("div",{className:"space-y-4",children:[v.jsx(Mt,{formName:"agentEdit",label:"Name",required:!1,inputName:"name",readOnly:!1,value:l,onChange:H=>h(H.target.value),placeholder:"Customer Support Agent"}),v.jsx(Mt,{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."})]}),v.jsxs("div",{className:"space-y-2",children:[v.jsx("label",{className:"boomi-form-label",children:"Allowed Origins"}),v.jsxs("div",{className:"space-y-2",children:[f.length===0&&v.jsx("div",{className:"text-xs opacity-70",children:"No origins selected."}),f.map((H,Q)=>{const W=new Set(f.map(j=>j.trim()).filter(Boolean)),G=(i??[]).filter(j=>j===H||!W.has(j)),V=G.includes(H);return v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsxs("select",{className:"boomi-input w-full rounded-md p-2 text-sm",value:H,onChange:j=>F(Q,j.target.value),children:[!H&&v.jsx("option",{value:"",children:"Select an origin"}),V?null:H?v.jsx("option",{value:H,children:H}):null,G.map(j=>v.jsx("option",{value:j,children:j},j))]}),v.jsx("span",{role:"button",tabIndex:0,className:"text-red-500 text-lg cursor-pointer",onClick:()=>B(Q),onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&B(Q)},"aria-label":"Remove origin",children:v.jsx(Jn,{})})]},`${H}-${Q}`)})]}),T&&v.jsx("div",{className:"text-xs text-red-500",children:T}),v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(tt,{toggle:!1,primary:!1,showIcon:!1,label:"Add Row",onClick:P}),v.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[v.jsx("input",{className:"boomi-input w-full rounded-md p-2 text-sm",value:p,onChange:H=>m(H.target.value),placeholder:"https://example.com"}),v.jsx("button",{type:"button",className:"boomi-btn-primary px-2 py-2 text-xs",onClick:U,disabled:g,"aria-label":"Add new origin",children:v.jsx(Si,{})})]})]}),v.jsx("div",{className:"text-xs opacity-70",children:"Pick from existing CORS origins or add a new one here."})]})]}),v.jsxs("div",{className:"space-y-3",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsxs("div",{children:[v.jsx("div",{className:"text-sm font-semibold",children:"UI Configuration"}),v.jsx("div",{className:"text-xs opacity-70",children:"Optional. Use JSON to customize themes, layout, and agent UI."})]}),v.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:[v.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${N==="builder"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>C("builder"),children:"Builder"}),v.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${N==="json"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>C("json"),children:"JSON"})]})]}),N==="builder"?v.jsx(rC,{embedType:k.embedType,agentIds:S,configRaw:w,onChangeConfig:H=>{const Q=JSON.stringify(H,null,2);Q!==w&&x(Q)},syncFromConfig:!1}):v.jsxs(v.Fragment,{children:[v.jsx(oC,{label:"Config (JSON)",value:w,placeholder:A,error:E,onChange:x}),v.jsx("div",{className:"flex justify-end",children:v.jsx(tt,{toggle:!1,primary:!1,showIcon:!1,label:"Insert Starter Config",onClick:()=>x(A)})})]})]})]})},aH=({isOpen:t,agentId:e,tokenId:n,agents:o,primaryAccountId:i,onTokenGenerated:r,onClose:s})=>{const[c,a]=M.useState(!1),[u,l]=M.useState(!1),[h,f]=M.useState("single"),[d,p]=M.useState([]),[m,g]=M.useState(""),[b,w]=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=d.filter(O=>{var F;const P=N.find(B=>B.id===O);return!((F=P==null?void 0:P.tokenIds)!=null&&F.includes(S))});if(A.length===0){T("Token already attached to selected agents.");return}w(!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{w(!1)}},$=async()=>{var A;if(!i)return;const S=h==="single"?m:d[0];if(!S){T("Select at least one agent first.");return}w(!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 F=h==="single"?[]:d.filter(B=>B!==S);F.length>0&&await Promise.all(F.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{w(!1)}},I=M.useMemo(()=>{const S=n??y;if(!S)return"";const A=m||e||"";return d.length,`<script>
|
|
2106
|
+
`),[c]);return v.jsxs("div",{children:[v.jsxs("label",{className:"boomi-form-label inline-flex items-center gap-2",children:[v.jsx("span",{children:t}),e]}),v.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:[v.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}),v.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&&v.jsx("p",{className:"boomi-form-helper",children:i}),r&&v.jsx("p",{className:"boomi-form-error",children:r})]})},Np=[{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"],JB=t=>/font|family|radius|scale|speed|direction|angle|opacity|blur/.test(t),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"],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."}),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,u,l,h,f,d,p,m,g,b,w,x,T,y,E,_,N,C,L,$,I,k,S;const i={...e};if(i.themeCustomVars=[],!t.trim())return i;try{const A=JSON.parse(t);if(A!=null&&A.theme&&typeof A.theme.defaultTheme=="string"){const V=A.theme.defaultTheme;V==="boomi"||V==="base"?(i.themeSelection=V,i.themeDefault=V,i.themeCustomName=""):(i.themeSelection="custom",i.themeDefault=V,i.themeCustomName=V);const j=(r=A==null?void 0:A.cssVarsByTheme)==null?void 0:r[V];j&&typeof j=="object"&&(i.themeCustomVars=Object.entries(j).map(([Y,Z])=>({id:`var_${Y}`,varName:Y,value:typeof Z=="string"?Z:String(Z)})))}const O=(s=A==null?void 0:A.components)==null?void 0:s.agentList,P=(c=A==null?void 0:A.components)==null?void 0:c.agentTiles;if(n==="list"&&O){const V=O.launcher??{},j=V.position??{};kr.includes(j.corner)&&(i.launcherCorner=j.corner),j.offsetX!==void 0&&(i.launcherOffsetX=String(j.offsetX)),j.offsetY!==void 0&&(i.launcherOffsetY=String(j.offsetY)),(V.shape==="pill"||V.shape==="circle")&&(i.launcherShape=V.shape),typeof V.label=="string"&&(i.launcherLabel=V.label),typeof V.icon=="string"&&(i.launcherIcon=V.icon),typeof V.hideIcon=="boolean"&&(i.launcherHideIcon=V.hideIcon);const Y=O.modal??{};Y.width!==void 0&&(i.listModalWidth=String(Y.width)),Y.height!==void 0&&(i.listModalHeight=String(Y.height));const Z=Y.position??{};kr.includes(Z.corner)&&(i.listModalCorner=Z.corner),Z.offsetX!==void 0&&(i.listModalOffsetX=String(Z.offsetX)),Z.offsetY!==void 0&&(i.listModalOffsetY=String(Z.offsetY)),(a=O.welcome)!=null&&a.title&&(i.listWelcomeTitle=O.welcome.title),(u=O.welcome)!=null&&u.subtitle&&(i.listWelcomeSubtitle=O.welcome.subtitle),((l=O.header)==null?void 0:l.show)!==void 0&&(i.listHeaderShow=!!O.header.show),(h=O.header)!=null&&h.title&&(i.listHeaderTitle=O.header.title),(f=O.header)!=null&&f.description&&(i.listHeaderDescription=O.header.description),((d=O.search)==null?void 0:d.show)!==void 0&&(i.listSearchShow=!!O.search.show)}n==="tiles"&&P&&(((p=P.header)==null?void 0:p.show)!==void 0&&(i.tilesHeaderShow=!!P.header.show),(m=P.header)!=null&&m.title&&(i.tilesHeaderTitle=P.header.title),(g=P.header)!=null&&g.description&&(i.tilesHeaderDescription=P.header.description),((b=P.search)==null?void 0:b.show)!==void 0&&(i.tilesSearchShow=!!P.search.show),((w=P.viewToggle)==null?void 0:w.show)!==void 0&&(i.tilesViewToggleShow=!!P.viewToggle.show));const F=(A==null?void 0:A.agents)??{},B=o.find(V=>F[V])??Object.keys(F)[0],U=B?F[B]:null;U!=null&&U.position&&typeof U.position=="object"&&"corner"in U.position&&(kr.includes(U.position.corner)&&(i.launcherCorner=U.position.corner),U.position.offsetX!==void 0&&(i.launcherOffsetX=String(U.position.offsetX)),U.position.offsetY!==void 0&&(i.launcherOffsetY=String(U.position.offsetY))),((U==null?void 0:U.shape)==="pill"||(U==null?void 0:U.shape)==="circle")&&(i.launcherShape=U.shape),typeof(U==null?void 0:U.label)=="string"&&(i.launcherLabel=U.label),typeof(U==null?void 0:U.icon)=="string"&&(i.launcherIcon=U.icon),typeof(U==null?void 0:U.hideIcon)=="boolean"&&(i.launcherHideIcon=U.hideIcon);const H=(U==null?void 0:U.ui)??{};(H.mode==="modal"||H.mode==="full")&&(i.agentUiMode=H.mode),((x=H.modal)==null?void 0:x.width)!==void 0&&(i.agentModalWidth=String(H.modal.width)),((T=H.modal)==null?void 0:T.height)!==void 0&&(i.agentModalHeight=String(H.modal.height)),(E=(y=H.modal)==null?void 0:y.position)!=null&&E.corner&&kr.includes(H.modal.position.corner)&&(i.agentModalCorner=H.modal.position.corner),((N=(_=H.modal)==null?void 0:_.position)==null?void 0:N.offsetX)!==void 0&&(i.agentModalOffsetX=String(H.modal.position.offsetX)),((L=(C=H.modal)==null?void 0:C.position)==null?void 0:L.offsetY)!==void 0&&(i.agentModalOffsetY=String(H.modal.position.offsetY));const Q=H.sessionScope==="mount"?!1:H.sessionScope==="multi"?!0:void 0,G=((($=H.sidebar)==null?void 0:$.show)!==void 0?!!H.sidebar.show:void 0)??Q;G!==void 0&&(i.agentSidebarShow=G),((I=H.sidebar)==null?void 0:I.width)!==void 0&&(i.agentSidebarWidth=String(H.sidebar.width)),(k=H.welcome)!=null&&k.title&&(i.agentWelcomeTitle=H.welcome.title),(S=H.welcome)!=null&&S.subtitle&&(i.agentWelcomeSubtitle=H.welcome.subtitle)}catch{return i}return i},nH=(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}};if(t.themeSelection==="custom"){const s={};for(const c of t.themeCustomVars)c.varName&&c.value&&(s[c.varName]=c.value);Object.keys(s).length&&(i.cssVarsByTheme={[o]:s})}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 r=n.length?n:["agent-id"];return i.agents=r.reduce((s,c)=>(s[c]={transport:"boomi-direct",...e==="single"?{position:{corner:t.launcherCorner,offsetX:po(t.launcherOffsetX),offsetY:po(t.launcherOffsetY)},shape:t.launcherShape,label:t.launcherLabel,icon:t.launcherIcon,hideIcon:t.launcherHideIcon}:{},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}}},s),{}),i.project={embedType:e,agentIds:r},i},rC=({embedType:t,agentIds:e,configRaw:n,onChangeConfig:o,onUpdateBuilder:i,syncFromConfig:r=!1})=>{const s=M.useMemo(eH,[]),[c,a]=M.useState(s),u=M.useRef(!1);M.useEffect(()=>{(r||!u.current)&&(a(tH(n,s,t,e)),u.current=!0)},[n,s,t,e,r]),M.useEffect(()=>{i==null||i(c)},[c,i]),M.useEffect(()=>{const d=nH(c,t,e);o(d)},[c,t,e,o]);const l=()=>{const d=iC[0]??"--boomi-root-bg-color";a(p=>({...p,themeCustomVars:[...p.themeCustomVars,{id:`var_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,varName:d,value:"#000000"}]}))},h=(d,p)=>{a(m=>({...m,themeCustomVars:m.themeCustomVars.map(g=>g.id===d?{...g,...p}:g)}))},f=d=>{a(p=>({...p,themeCustomVars:p.themeCustomVars.filter(m=>m.id!==d)}))};return v.jsxs("div",{className:"boomi-card p-4 space-y-4",children:[v.jsxs("div",{children:[v.jsx("div",{className:"text-sm font-semibold",children:"Config Builder"}),v.jsx("div",{className:"text-xs opacity-70",children:"Updates the JSON configuration automatically as you make changes."})]}),v.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[v.jsxs("div",{className:"space-y-3",children:[v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Agent UI"}),v.jsxs("label",{className:"boomi-form-label",children:["Mode",v.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentUiMode,onChange:d=>a(p=>({...p,agentUiMode:d.target.value})),children:[v.jsx("option",{value:"modal",children:"Modal"}),v.jsx("option",{value:"full",children:"Full Page"})]})]}),c.agentUiMode==="modal"&&v.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[v.jsxs("label",{className:"boomi-form-label",children:["Modal width",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentModalWidth,onChange:d=>a(p=>({...p,agentModalWidth:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Modal height",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentModalHeight,onChange:d=>a(p=>({...p,agentModalHeight:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Modal corner",v.jsx("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentModalCorner,onChange:d=>a(p=>({...p,agentModalCorner:d.target.value})),children:kr.map(d=>v.jsx("option",{value:d,children:d},d))})]}),v.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[v.jsxs("label",{className:"boomi-form-label",children:["Offset X",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentModalOffsetX,onChange:d=>a(p=>({...p,agentModalOffsetX:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Offset Y",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentModalOffsetY,onChange:d=>a(p=>({...p,agentModalOffsetY:d.target.value}))})]})]})]}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.agentSidebarShow,onChange:d=>a(p=>({...p,agentSidebarShow:d.target.checked}))}),"Show sidebar"]}),v.jsxs("label",{className:"boomi-form-label",children:["Sidebar width",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentSidebarWidth,onChange:d=>a(p=>({...p,agentSidebarWidth:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Welcome title",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentWelcomeTitle,onChange:d=>a(p=>({...p,agentWelcomeTitle:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Welcome subtitle",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentWelcomeSubtitle,onChange:d=>a(p=>({...p,agentWelcomeSubtitle:d.target.value}))})]})]}),v.jsxs("div",{className:"space-y-3",children:[v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Theme"}),v.jsxs("label",{className:"boomi-form-label",children:["Theme",v.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.themeSelection,onChange:d=>a(p=>({...p,themeSelection:d.target.value,themeDefault:d.target.value==="custom"?p.themeDefault:d.target.value})),children:[v.jsx("option",{value:"boomi",children:"boomi"}),v.jsx("option",{value:"base",children:"base"}),v.jsx("option",{value:"custom",children:"custom"})]})]}),c.themeSelection==="custom"&&v.jsxs(v.Fragment,{children:[v.jsxs("label",{className:"boomi-form-label",children:["Custom theme name",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.themeCustomName,onChange:d=>a(p=>({...p,themeCustomName:d.target.value,themeDefault:d.target.value})),placeholder:"my-theme"})]}),v.jsxs("div",{className:"space-y-2",children:[v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Custom CSS Vars"}),c.themeCustomVars.length===0&&v.jsx("div",{className:"text-xs opacity-70",children:"No custom variables yet."}),v.jsx("div",{className:"space-y-2",children:c.themeCustomVars.map(d=>v.jsxs("div",{className:"flex items-center gap-2 flex-nowrap w-full overflow-x-auto",children:[v.jsx("select",{className:"boomi-input flex-1 min-w-0 rounded-md p-2 text-sm",value:d.varName,onChange:p=>h(d.id,{varName:p.target.value}),children:iC.map(p=>v.jsx("option",{value:p,children:p},p))}),JB(d.varName)?v.jsx("input",{type:"text",value:d.value,onChange:p=>h(d.id,{value:p.target.value}),className:"boomi-input flex-1 min-w-0 rounded-md p-2 text-sm",placeholder:"e.g. Inter, sans-serif"}):v.jsx("input",{type:"color",value:d.value,onChange:p=>h(d.id,{value:p.target.value}),className:"h-9 w-12 shrink-0 cursor-pointer rounded-md border border-[var(--boomi-card-border)] bg-transparent"}),v.jsx("button",{type:"button",className:"text-xs text-red-500 whitespace-nowrap shrink-0",onClick:()=>f(d.id),children:"Remove"})]},d.id))}),v.jsx("div",{children:v.jsx("button",{type:"button",className:"boomi-btn-primary px-3 py-2 text-xs disabled:opacity-50",onClick:l,disabled:!c.themeCustomName.trim(),children:"Add CSS Variable"})})]})]})]})]}),(t==="list"||t==="single")&&v.jsxs("div",{className:t==="list"?"grid gap-4 md:grid-cols-2":"space-y-3",children:[v.jsxs("div",{className:"space-y-3",children:[v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Launcher (Pill)"}),v.jsxs("label",{className:"boomi-form-label",children:["Corner",v.jsx("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.launcherCorner,onChange:d=>a(p=>({...p,launcherCorner:d.target.value})),children:kr.map(d=>v.jsx("option",{value:d,children:d},d))})]}),v.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[v.jsxs("label",{className:"boomi-form-label",children:["Offset X",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.launcherOffsetX,onChange:d=>a(p=>({...p,launcherOffsetX:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Offset Y",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.launcherOffsetY,onChange:d=>a(p=>({...p,launcherOffsetY:d.target.value}))})]})]}),v.jsxs("label",{className:"boomi-form-label",children:["Shape",v.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.launcherShape,onChange:d=>a(p=>({...p,launcherShape:d.target.value})),children:[v.jsx("option",{value:"pill",children:"Pill"}),v.jsx("option",{value:"circle",children:"Circle"})]})]}),v.jsxs("label",{className:"boomi-form-label",children:["Label",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.launcherLabel,onChange:d=>a(p=>({...p,launcherLabel:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Icon",v.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:Np.some(d=>d.value===c.launcherIcon)?c.launcherIcon:"__custom__",onChange:d=>a(p=>({...p,launcherIcon:d.target.value==="__custom__"?p.launcherIcon:d.target.value})),children:[!Np.some(d=>d.value===c.launcherIcon)&&v.jsxs("option",{value:"__custom__",children:[c.launcherIcon," (custom)"]}),Np.map(d=>v.jsx("option",{value:d.value,children:d.label},d.value))]})]}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.launcherHideIcon,onChange:d=>a(p=>({...p,launcherHideIcon:d.target.checked}))}),"Hide icon"]})]}),t==="list"&&v.jsxs("div",{className:"space-y-3",children:[v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"List Modal"}),v.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[v.jsxs("label",{className:"boomi-form-label",children:["Width",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listModalWidth,onChange:d=>a(p=>({...p,listModalWidth:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Height",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listModalHeight,onChange:d=>a(p=>({...p,listModalHeight:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Corner",v.jsx("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listModalCorner,onChange:d=>a(p=>({...p,listModalCorner:d.target.value})),children:kr.map(d=>v.jsx("option",{value:d,children:d},d))})]}),v.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[v.jsxs("label",{className:"boomi-form-label",children:["Offset X",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listModalOffsetX,onChange:d=>a(p=>({...p,listModalOffsetX:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Offset Y",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listModalOffsetY,onChange:d=>a(p=>({...p,listModalOffsetY:d.target.value}))})]})]})]}),v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70 pt-2",children:"List Header & Search"}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.listHeaderShow,onChange:d=>a(p=>({...p,listHeaderShow:d.target.checked}))}),"Show header"]}),v.jsxs("label",{className:"boomi-form-label",children:["Header title",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listHeaderTitle,onChange:d=>a(p=>({...p,listHeaderTitle:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Header description",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listHeaderDescription,onChange:d=>a(p=>({...p,listHeaderDescription:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.listSearchShow,onChange:d=>a(p=>({...p,listSearchShow:d.target.checked}))}),"Show search"]}),v.jsxs("label",{className:"boomi-form-label",children:["Welcome title",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listWelcomeTitle,onChange:d=>a(p=>({...p,listWelcomeTitle:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Welcome subtitle",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listWelcomeSubtitle,onChange:d=>a(p=>({...p,listWelcomeSubtitle:d.target.value}))})]})]})]}),t==="tiles"&&v.jsxs("div",{className:"space-y-3",children:[v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Tiles Header & Search"}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.tilesHeaderShow,onChange:d=>a(p=>({...p,tilesHeaderShow:d.target.checked}))}),"Show header"]}),v.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[v.jsxs("label",{className:"boomi-form-label",children:["Header title",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.tilesHeaderTitle,onChange:d=>a(p=>({...p,tilesHeaderTitle:d.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Header description",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.tilesHeaderDescription,onChange:d=>a(p=>({...p,tilesHeaderDescription:d.target.value}))})]})]}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.tilesSearchShow,onChange:d=>a(p=>({...p,tilesSearchShow:d.target.checked}))}),"Show search"]}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.tilesViewToggleShow,onChange:d=>a(p=>({...p,tilesViewToggleShow:d.target.checked}))}),"Show tiles/table toggle"]})]})]})};function oH(t){try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}const iH=({isOpen:t,onClose:e,onSubmit:n,isSaving:o,defaultOrigins:i,availableAgents:r})=>{const[s,c]=M.useState(""),[a,u]=M.useState(null),[l,h]=M.useState(!1),[f,d]=M.useState([]),[p,m]=M.useState(""),[g,b]=M.useState("single"),[w,x]=M.useState(""),[T,y]=M.useState([]),[E,_]=M.useState(null),[N,C]=M.useState(null),[L,$]=M.useState(null),[I,k]=M.useState("builder"),S=(G,V)=>(G.length>0?G:["agent-id"]).reduce((Y,Z)=>(Y[Z]={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."}}},Y),{}),P=JSON.stringify(((G,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"}}};G==="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 Y=V.length>0?V:["agent-id"];return j.agents=S(Y,G==="single"?"modal":"full"),j})(g,g==="single"?w?[w]:[]:T),null,2);M.useEffect(()=>{var V;if(!t)return;const G=((V=r==null?void 0:r[0])==null?void 0:V.id)||"";c(""),u(null),h(!1),d([]),m(""),b("single"),x(G),y(G?[G]:[]),_(null),C(null),$(null),k("builder")},[t,i,r]),M.useEffect(()=>{g==="single"?!w&&T[0]&&x(T[0]):T.length===0&&w&&y([w])},[g,T,w]);const F=G=>{y(V=>V.includes(G)?V.filter(j=>j!==G):[...V,G])},B=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`project_${crypto.randomUUID()}`:`project_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`,U=async()=>{if(!s.trim()){h(!0),u("Project name is required.");return}u(null);const G=g==="single"?w?[w]:[]:T;if(!G.length){_("Select at least one agent");return}_(null);let V;const j=p.trim();if(j)try{V=JSON.parse(j)}catch{$("Config must be valid JSON");return}$(null);const Y=V&&typeof V=="object"?{...V}:{},Z=Y.project&&typeof Y.project=="object"?{...Y.project}:{};Y.project={...Z,embedType:g,agentIds:G};const ee=Array.from(new Set(f.map(ae=>ae.trim()).filter(Boolean)));if(!ee.length){C("At least one allowed origin is required.");return}for(const ae of ee)if(!oH(ae)){C(`Invalid origin (must be http/https): ${ae}`);return}C(null);const J=B();if(g==="single"&&w){const ae={...Y.agents??{}};ae[w]&&!ae[J]&&(ae[J]=ae[w],Y.agents=ae)}await n({agentId:J,boomiAgentId:g==="single"?w:void 0,label:s.trim()||void 0,allowedOrigins:ee,config:Y})},H=()=>{d(G=>[...G,""])},Q=(G,V)=>{d(j=>j.map((Y,Z)=>Z===G?V:Y))},W=G=>{d(V=>V.filter((j,Y)=>Y!==G))};return v.jsxs(En,{isOpen:t,title:"Add Project",description:"Create a new embedded agent group and its allowed embed origins.",onClose:e,onSubmit:U,submitLabel:o?"Saving...":"Create Project",showSaveButton:!o,children:[v.jsxs("div",{className:"boomi-card p-4 space-y-2",children:[v.jsx("div",{className:"text-sm font-semibold",children:"Project Summary"}),v.jsxs("div",{className:"text-xs opacity-80",children:["Embed type: ",v.jsx("strong",{children:g==="single"?"Single Agent":g==="tiles"?"Multi-Agent (Tiles)":"Multi-Agent (List)"})]}),v.jsxs("div",{className:"text-xs opacity-80",children:["Selected agents: ",v.jsx("strong",{children:g==="single"?w?1:0:T.length})]}),v.jsx("div",{className:"text-xs opacity-70",children:"You can start with the form below and optionally layer in advanced JSON config."})]}),v.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[v.jsxs("div",{className:"space-y-4",children:[v.jsx(Mt,{formName:"agentAdd",label:"Project Name",required:!0,inputName:"name",readOnly:!1,value:s,onChange:G=>{c(G.target.value),a&&u(null)},onBlur:()=>{h(!0),s.trim()||u("Project name is required.")},placeholder:"Customer Support Project"}),l&&a&&v.jsx("div",{className:"boomi-form-error",children:a}),v.jsxs("label",{className:"boomi-form-label",children:["Embed Type",v.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:g,onChange:G=>b(G.target.value),children:[v.jsx("option",{value:"single",children:"Single Agent"}),v.jsx("option",{value:"tiles",children:"Multi-Agent (Tiles)"}),v.jsx("option",{value:"list",children:"Multi-Agent (Pill + Modal List)"})]})]}),g==="single"?v.jsxs("label",{className:"boomi-form-label",children:["Agent",v.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:w,onChange:G=>x(G.target.value),children:[(r??[]).length===0&&v.jsx("option",{value:"",children:"No agents available"}),(r??[]).map(G=>v.jsx("option",{value:G.id,children:G.label},G.id))]}),E&&v.jsx("div",{className:"text-xs text-red-500 mt-1",children:E})]}):v.jsxs("div",{children:[v.jsx("label",{className:"boomi-form-label",children:"Agents"}),v.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?v.jsx("div",{className:"text-xs opacity-70",children:"No agents available"}):(r??[]).map(G=>v.jsxs("label",{className:"flex items-center gap-2",children:[v.jsx("input",{type:"checkbox",checked:T.includes(G.id),onChange:()=>F(G.id)}),v.jsx("span",{className:"text-xs",children:G.label})]},G.id))}),E&&v.jsx("div",{className:"text-xs text-red-500 mt-1",children:E})]})]}),v.jsx("div",{className:"space-y-4",children:v.jsxs("div",{className:"space-y-2",children:[v.jsx("label",{className:"boomi-form-label",children:"Allowed Origins"}),v.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."}),v.jsxs("div",{className:"space-y-2",children:[f.length===0&&v.jsx("div",{className:"text-xs opacity-70",children:"No origins selected."}),f.map((G,V)=>{const j=new Set(f.map(ee=>ee.trim()).filter(Boolean)),Y=(i??[]).filter(ee=>ee===G||!j.has(ee)),Z=Y.includes(G);return v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsxs("select",{className:"boomi-input w-full rounded-md p-2 text-sm",value:G,onChange:ee=>Q(V,ee.target.value),children:[!G&&v.jsx("option",{value:"",children:"Select an origin"}),Z?null:G?v.jsx("option",{value:G,children:G}):null,Y.map(ee=>v.jsx("option",{value:ee,children:ee},ee))]}),v.jsx("span",{role:"button",tabIndex:0,className:"text-red-500 text-lg cursor-pointer",onClick:()=>W(V),onKeyDown:ee=>{(ee.key==="Enter"||ee.key===" ")&&W(V)},"aria-label":"Remove origin",children:v.jsx(Jn,{})})]},`${G}-${V}`)})]}),v.jsx("div",{className:"flex",children:v.jsx(tt,{toggle:!1,primary:!1,showIcon:!1,label:"Add Allowed Origin",onClick:H})}),N&&v.jsx("div",{className:"text-xs text-red-500",children:N}),v.jsx("div",{className:"text-xs opacity-70",children:"Add new origins from the CORS page before selecting them here."})]})})]}),v.jsxs("div",{className:"space-y-3",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsxs("div",{children:[v.jsx("div",{className:"text-sm font-semibold",children:"UI Configuration"}),v.jsx("div",{className:"text-xs opacity-70",children:"Optional. Use JSON to customize themes, layout, and agent UI beyond the form inputs."})]}),v.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:[v.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${I==="builder"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>k("builder"),children:"Builder"}),v.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${I==="json"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>k("json"),children:"JSON"})]})]}),I==="builder"?v.jsx(rC,{embedType:g,agentIds:g==="single"?w?[w]:[]:T,configRaw:p,onChangeConfig:G=>{const V=JSON.stringify(G,null,2);V!==p&&m(V)},syncFromConfig:!1}):v.jsxs(v.Fragment,{children:[v.jsx(oC,{label:"Config (JSON)",value:p,placeholder:P,error:L,onChange:m}),v.jsx("div",{className:"flex justify-end",children:v.jsx(tt,{toggle:!1,primary:!1,showIcon:!1,label:"Insert Starter Config",onClick:()=>m(P)})})]})]})]})},rH=({isOpen:t,agentId:e,onClose:n,onConfirm:o,isDeleting:i})=>v.jsx(En,{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:v.jsxs("p",{className:"text-sm",children:["Are you sure you want to delete"," ",v.jsx("span",{className:"font-semibold",children:e}),"?"]})});function sC(t){try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}const sH=({isOpen:t,agentId:e,label:n,allowedOrigins:o,defaultOrigins:i,onAddOrigin:r,config:s,onClose:c,onSubmit:a,isSaving:u})=>{const[l,h]=M.useState(""),[f,d]=M.useState([]),[p,m]=M.useState(""),[g,b]=M.useState(!1),[w,x]=M.useState(""),[T,y]=M.useState(null),[E,_]=M.useState(null),[N,C]=M.useState("builder"),L=(H,Q)=>(H.length>0?H:["agent-id"]).reduce((G,V)=>(G[V]={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."}}},G),{}),$=(H,Q)=>{const W={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"}}};H==="list"&&(W.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 G=Q.length>0?Q:["agent-id"];return W.agents=L(G,H==="single"?"modal":"full"),W},k=(()=>{try{const H=w.trim()?JSON.parse(w):null,Q=H&&typeof H=="object"?H.project:null,W=typeof(Q==null?void 0:Q.embedType)=="string"?Q.embedType:"single",G=Array.isArray(Q==null?void 0:Q.agentIds)?Q.agentIds.filter(Boolean):[];return{embedType:W,agentIds:G}}catch{return{embedType:"single",agentIds:[]}}})(),S=k.agentIds.length>0?k.agentIds:e?[e]:[],A=JSON.stringify($(k.embedType,S),null,2);M.useEffect(()=>{if(t){h(n??"");const H=(o&&o.length?o:i)??[];d(H),m(""),x(s?JSON.stringify(s,null,2):""),y(null),_(null),C("builder")}},[t,n,s,o,i]);const O=async()=>{if(!e)return;let H;const Q=w.trim();if(Q)try{H=JSON.parse(Q)}catch{_("Config must be valid JSON");return}_(null);const W=Array.from(new Set(f.map(G=>G.trim()).filter(Boolean)));if(!W.length){y("At least one allowed origin is required.");return}for(const G of W)if(!sC(G)){y(`Invalid origin (must be http/https): ${G}`);return}if(y(null),H&&e){const G=H.project,V=G==null?void 0:G.embedType,j=Array.isArray(G==null?void 0:G.agentIds)?G.agentIds[0]:null;if(V==="single"&&j){const Y={...H.agents??{}};Y[j]&&!Y[e]&&(Y[e]=Y[j],H.agents=Y)}}await a({agentId:e,label:l.trim()||void 0,allowedOrigins:W,config:H})},P=()=>{const H=i??[],Q=new Set(f.map(G=>G.trim()).filter(Boolean)),W=H.find(G=>!Q.has(G))??"";d(G=>[...G,W])},F=(H,Q)=>{d(W=>W.map((G,V)=>V===H?Q:G))},B=H=>{d(Q=>Q.filter((W,G)=>G!==H))},U=async()=>{const H=p.trim();if(!H){y("Enter an origin before adding.");return}if(!sC(H)){y(`Invalid origin (must be http/https): ${H}`);return}if(y(null),!r){d(Q=>Q.includes(H)?Q:[...Q,H]),m("");return}b(!0);try{await r(H),d(Q=>Q.includes(H)?Q:[...Q,H]),m("")}catch(Q){y((Q==null?void 0:Q.message)||"Failed to add origin.")}finally{b(!1)}};return v.jsxs(En,{isOpen:t,title:"Edit Agent",description:"Update agent details and allowed origins.",onClose:c,onSubmit:O,submitLabel:u?"Saving...":"Save Changes",showSaveButton:!u,children:[v.jsxs("div",{className:"boomi-card p-4 space-y-2",children:[v.jsx("div",{className:"text-sm font-semibold",children:"Agent Overview"}),v.jsxs("div",{className:"text-xs opacity-80",children:["Agent ID: ",v.jsx("strong",{children:e??"β"})]}),v.jsx("div",{className:"text-xs opacity-70",children:"Update the friendly name, allowed origins, and optional config overrides below."})]}),v.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[v.jsxs("div",{className:"space-y-4",children:[v.jsx(Mt,{formName:"agentEdit",label:"Name",required:!1,inputName:"name",readOnly:!1,value:l,onChange:H=>h(H.target.value),placeholder:"Customer Support Agent"}),v.jsx(Mt,{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."})]}),v.jsxs("div",{className:"space-y-2",children:[v.jsx("label",{className:"boomi-form-label",children:"Allowed Origins"}),v.jsxs("div",{className:"space-y-2",children:[f.length===0&&v.jsx("div",{className:"text-xs opacity-70",children:"No origins selected."}),f.map((H,Q)=>{const W=new Set(f.map(j=>j.trim()).filter(Boolean)),G=(i??[]).filter(j=>j===H||!W.has(j)),V=G.includes(H);return v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsxs("select",{className:"boomi-input w-full rounded-md p-2 text-sm",value:H,onChange:j=>F(Q,j.target.value),children:[!H&&v.jsx("option",{value:"",children:"Select an origin"}),V?null:H?v.jsx("option",{value:H,children:H}):null,G.map(j=>v.jsx("option",{value:j,children:j},j))]}),v.jsx("span",{role:"button",tabIndex:0,className:"text-red-500 text-lg cursor-pointer",onClick:()=>B(Q),onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&B(Q)},"aria-label":"Remove origin",children:v.jsx(Jn,{})})]},`${H}-${Q}`)})]}),T&&v.jsx("div",{className:"text-xs text-red-500",children:T}),v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(tt,{toggle:!1,primary:!1,showIcon:!1,label:"Add Row",onClick:P}),v.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[v.jsx("input",{className:"boomi-input w-full rounded-md p-2 text-sm",value:p,onChange:H=>m(H.target.value),placeholder:"https://example.com"}),v.jsx("button",{type:"button",className:"boomi-btn-primary px-2 py-2 text-xs",onClick:U,disabled:g,"aria-label":"Add new origin",children:v.jsx(Si,{})})]})]}),v.jsx("div",{className:"text-xs opacity-70",children:"Pick from existing CORS origins or add a new one here."})]})]}),v.jsxs("div",{className:"space-y-3",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsxs("div",{children:[v.jsx("div",{className:"text-sm font-semibold",children:"UI Configuration"}),v.jsx("div",{className:"text-xs opacity-70",children:"Optional. Use JSON to customize themes, layout, and agent UI."})]}),v.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:[v.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${N==="builder"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>C("builder"),children:"Builder"}),v.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${N==="json"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>C("json"),children:"JSON"})]})]}),N==="builder"?v.jsx(rC,{embedType:k.embedType,agentIds:S,configRaw:w,onChangeConfig:H=>{const Q=JSON.stringify(H,null,2);Q!==w&&x(Q)},syncFromConfig:!1}):v.jsxs(v.Fragment,{children:[v.jsx(oC,{label:"Config (JSON)",value:w,placeholder:A,error:E,onChange:x}),v.jsx("div",{className:"flex justify-end",children:v.jsx(tt,{toggle:!1,primary:!1,showIcon:!1,label:"Insert Starter Config",onClick:()=>x(A)})})]})]})]})},aH=({isOpen:t,agentId:e,tokenId:n,agents:o,primaryAccountId:i,onTokenGenerated:r,onClose:s})=>{const[c,a]=M.useState(!1),[u,l]=M.useState(!1),[h,f]=M.useState("single"),[d,p]=M.useState([]),[m,g]=M.useState(""),[b,w]=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=d.filter(O=>{var F;const P=N.find(B=>B.id===O);return!((F=P==null?void 0:P.tokenIds)!=null&&F.includes(S))});if(A.length===0){T("Token already attached to selected agents.");return}w(!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{w(!1)}},$=async()=>{var A;if(!i)return;const S=h==="single"?m:d[0];if(!S){T("Select at least one agent first.");return}w(!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 F=h==="single"?[]:d.filter(B=>B!==S);F.length>0&&await Promise.all(F.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{w(!1)}},I=M.useMemo(()=>{const S=n??y;if(!S)return"";const A=m||e||"";return d.length,`<link rel="stylesheet" href="https://cdn.boomi.space/cdn/embedkit-cdn.css" />
|
|
2107
|
+
<script>
|
|
2107
2108
|
window.BoomiEmbed = {
|
|
2108
2109
|
publicToken: "${S}",
|
|
2109
2110
|
agentId: "${A||"project-id"}",
|