@collective-intelligence/extensions-sdk-frontend-react 0.1.12 → 0.1.13
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/README.md
CHANGED
|
@@ -257,3 +257,17 @@ A successful page and its relation IDs are complete. Per-field includes can carr
|
|
|
257
257
|
existing truncation marker; paging within nested includes is not supported. A typed
|
|
258
258
|
`KnowledgeReadLimitExceeded` response requires narrowing the query, page, or includes;
|
|
259
259
|
do not silently trim the response or retry the unchanged oversized request.
|
|
260
|
+
|
|
261
|
+
### Host-provided workflow User selection
|
|
262
|
+
|
|
263
|
+
`WorkflowFieldComponentContext.userSelection` is an optional Host renderer for
|
|
264
|
+
Organization member selection. It receives `multiple`, `value`, `onChange`,
|
|
265
|
+
`controlId`, `labelledBy`, `readOnly`, and `required`; it returns a React node.
|
|
266
|
+
Values and changes contain only user IDs (`null` for an empty single selection,
|
|
267
|
+
`[]` for an empty list). The Host binds resource-authorized search and selected-ID
|
|
268
|
+
resolution; public contributions never import the Host's private picker or data
|
|
269
|
+
client. A contribution that requires this renderer must show an unavailable
|
|
270
|
+
state if the Host omits it, rather than accepting arbitrary text input.
|
|
271
|
+
|
|
272
|
+
Catalog adapters preserve the explicit `field.user: { multiple }` descriptor in
|
|
273
|
+
`WorkflowFieldCatalogContract`. A UUID schema does not activate User selection.
|
|
@@ -204,7 +204,7 @@ export type StudioViewDataSearchMembersData = {
|
|
|
204
204
|
filters?: Array<{
|
|
205
205
|
caseSensitive?: boolean;
|
|
206
206
|
field: string;
|
|
207
|
-
operator: "eq" | "ne" | "in" | "nin" | "contains" | "not_contains" | "starts_with" | "ends_with" | "gt" | "gte" | "lt" | "lte" | "exists" | "is_empty" | "is_not_empty";
|
|
207
|
+
operator: "eq" | "ne" | "in" | "nin" | "contains" | "not_contains" | "starts_with" | "ends_with" | "gt" | "gte" | "lt" | "lte" | "exists" | "is_empty" | "is_not_empty" | "contains_any" | "contains_all" | "contains_none" | "not_in";
|
|
208
208
|
value: Suspend2 | Array<Suspend2>;
|
|
209
209
|
}>;
|
|
210
210
|
include?: Array<string>;
|
|
@@ -263,7 +263,7 @@ export type StudioViewDataSearchData = {
|
|
|
263
263
|
filters?: Array<{
|
|
264
264
|
caseSensitive?: boolean;
|
|
265
265
|
field: string;
|
|
266
|
-
operator: "eq" | "ne" | "in" | "nin" | "contains" | "not_contains" | "starts_with" | "ends_with" | "gt" | "gte" | "lt" | "lte" | "exists" | "is_empty" | "is_not_empty";
|
|
266
|
+
operator: "eq" | "ne" | "in" | "nin" | "contains" | "not_contains" | "starts_with" | "ends_with" | "gt" | "gte" | "lt" | "lte" | "exists" | "is_empty" | "is_not_empty" | "contains_any" | "contains_all" | "contains_none" | "not_in";
|
|
267
267
|
value: Suspend2 | Array<Suspend2>;
|
|
268
268
|
}>;
|
|
269
269
|
include?: Array<string>;
|
package/dist/workflow.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Mn=Object.defineProperty;var Bn=(o)=>o;function Ln(o,e){this[o]=Bn.bind(null,e)}var _n=(o,e)=>{for(var n in e)Mn(o,n,{get:e[n],enumerable:!0,configurable:!0,set:Ln.bind(e,n)})};var b=(o,e,n)=>()=>{if(o)try{e=o(o=0)}catch(t){n=[t]}if(n)throw n[0];return e};var se=(o)=>Boolean(o)===o,Hn=(o)=>Object.prototype.toString.call(o)==="[object Function]",J=(o)=>Number(o)===o,W=(o)=>o!==null&&Object(o)===o&&!Hn(o),P=(o)=>{let e=Object.prototype.toString.call(o);if(o===null||e==="[object Boolean]"||e==="[object Number]"||e==="[object String]")return!0;if(Array.isArray(o))return o.every(P);return W(o)&&Object.values(o).every(P)},T=(o)=>P(o)&&W(o)&&!Array.isArray(o),u=(o)=>String(o)===o,Si=(o)=>o===void 0,Ei=(o)=>{let e=o;if(u(e))return e;if(se(e)||J(e))return String(e);return""};import{ArrowRight as Kn,CheckCircle2 as Un,Wrench as zn,Zap as Qn}from"@collective-intelligence/ui-react/icons";var vo=function(e){switch(e){case"trigger":case"trigger_node":return{icon:Qn,label:"Trigger",tone:"bg-violet-500/12 text-violet-600 dark:text-violet-400"};case"input_node":return{icon:Kn,label:"Input",tone:"bg-sky-500/12 text-sky-600 dark:text-sky-400"};case"output_node":return{icon:Un,label:"Output",tone:"bg-emerald-500/12 text-emerald-600 dark:text-emerald-400"};default:return{icon:zn,label:"Action",tone:"bg-slate-500/12 text-slate-600 dark:text-slate-400"}}};var Wo=()=>{};import{AlertTriangle as Gn,Plus as Yn}from"@collective-intelligence/ui-react/icons";import{Tooltip as Zn,TooltipContent as Xn,TooltipTrigger as et}from"@collective-intelligence/ui-react/ui";import{Handle as ot,Position as Co,useNodeId as nt,useUpdateNodeInternals as tt}from"@xyflow/react";import{useEffect as rt}from"react";import{jsx as k,jsxs as D,Fragment as lt}from"react/jsx-runtime";var it,Fo=function(e){if(u(e))return e;if(W(e)&&"kind"in e&&"text"in e){let n=e;if(n.kind==="literal"&&u(n.text))return n.text}if(W(e)&&"en"in e){let n=e.en;return u(n)?n:""}return""},st=({issues:o,title:e})=>{let n=`${o.length} ${o.length===1?"issue":"issues"} on ${e}`;return D(Zn,{children:[k(et,{asChild:!0,children:k("button",{type:"button","aria-label":n,className:"nodrag nopan absolute -right-2 -top-2 z-20 flex size-7 items-center justify-center rounded-full border border-[color-mix(in_oklab,var(--warning)_45%,var(--border))] bg-[color-mix(in_oklab,var(--warning)_16%,var(--card))] text-[color-mix(in_oklab,var(--warning)_80%,var(--foreground))] shadow-sm transition hover:bg-[color-mix(in_oklab,var(--warning)_24%,var(--card))] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40",onClick:(t)=>{t.stopPropagation()},onPointerDown:(t)=>{t.stopPropagation()},children:k(Gn,{"aria-hidden":"true",className:"size-4"})})}),D(Xn,{side:"top",sideOffset:6,className:"max-w-72 p-3",children:[k("p",{className:"font-semibold",children:n}),k("ul",{className:"mt-1.5 space-y-1",children:o.map((t)=>k("li",{className:"leading-snug",children:t.message},`${t.code}:${t.message}`))})]})]})},So=({port:o,side:e,index:n=0,count:t=1})=>{let r=e==="left"?Co.Left:Co.Right,i={top:`${(n+1)/(t+1)*100}%`},s=o.maxConnections===null?"unlimited connections":`maximum ${o.maxConnections??1} connections`,a=[...Array.isArray(o.allowedTemplateKinds)?o.allowedTemplateKinds.filter(u):[],...Array.isArray(o.allowedTemplateFqns)?o.allowedTemplateFqns.filter(u):[]],l=`${o.key} — ${o.direction}, ${s}${a.length?`; accepts ${a.join(", ")}`:""}`;return D(lt,{children:[k(ot,{id:o.key,type:o.direction==="input"?"target":"source",position:r,title:l,"aria-label":l,style:i,className:o.direction==="input"?"!h-5 !w-5 !rounded-sm !border-2 !border-background !bg-primary":"!h-5 !w-5 !border-2 !border-background !bg-primary"}),k("span",{style:i,className:`pointer-events-none absolute z-10 -translate-y-full whitespace-nowrap rounded bg-card px-1 text-[10px] text-muted-foreground ${e==="left"?"right-full mr-2":"left-full ml-2"}`,children:o.key})]})},at=({signature:o})=>{let e=nt(),n=tt();return rt(()=>{if(e!==null)n(e)},[e,o,n]),null},oe=({context:o,accent:e})=>{let n=o.ports.filter((f)=>f.direction==="input"),t=o.ports.filter((f)=>f.direction==="output"),r=new Set(o.chart.connectedOutputPortKeys),i=o.chart.fields??[],s=Fo(o.template.label),a=o.chart.title??s,l=o.chart.subtitle??(a===s?void 0:s),d=o.chart.description??Fo(o.template.description),{icon:c}=o.chart.presentation??vo(o.template.kind),x=o.chart.presentation?.tone??it[e],w=o.diagnostics.filter((f)=>f.severity!=="info");return D("div",{className:"relative w-[262px]",children:[w.length?k(st,{issues:w,title:a}):null,D("button",{type:"button","aria-label":`Edit ${a}`,style:{minHeight:(Math.max(n.length,t.length)+1)*28},onDoubleClick:()=>{o.chart.onOpenDetails()},className:`workflow-node-drag group relative z-10 w-full cursor-pointer rounded-2xl border bg-card p-4 text-left shadow-[0_2px_10px_-4px_rgba(30,29,26,0.12)] transition-[border-color,box-shadow] hover:shadow-[0_8px_24px_-14px_rgba(30,29,26,0.24)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 ${x}`,children:[o.ports.length>0?k(at,{signature:o.ports.map((f)=>`${f.direction}:${f.key}`).join("|")}):null,n.map((f,m)=>k(So,{port:f,side:"left",index:m,count:n.length},f.key)),t.map((f,m)=>k(So,{port:f,side:"right",index:m,count:t.length},f.key)),D("div",{className:"flex items-start gap-3",children:[k("div",{className:`flex size-10 shrink-0 items-center justify-center rounded-xl ${x}`,children:k(c,{className:"size-5"})}),D("div",{className:"min-w-0",children:[k("div",{className:"truncate text-sm font-semibold text-foreground",children:a}),u(l)&&l.length>0?k("p",{className:"truncate font-mono text-[11px] text-muted-foreground",children:l}):null]})]}),(()=>{if(u(d)&&d.length>0)return D("div",{className:"mt-3 space-y-2 border-t border-border/70 pt-3",children:[u(d)&&d.length>0?k("p",{className:"line-clamp-2 text-xs leading-snug text-muted-foreground [overflow-wrap:anywhere]",children:d}):null,u(o.chart.summary)&&o.chart.summary.length>0?k("div",{className:"rounded-lg bg-muted/60 px-2.5 py-2",children:k("p",{className:"line-clamp-3 whitespace-pre-line font-mono text-[11px] leading-4 text-muted-foreground [overflow-wrap:anywhere]",children:o.chart.summary})}):null]});return null})(),i.length?k("div",{className:"mt-3 space-y-1.5 border-t border-border/70 pt-3",children:i.slice(0,4).map((f)=>k("div",{className:"truncate rounded-md bg-muted px-2.5 py-1.5 font-mono text-[11px] text-foreground",children:f},f))}):null]}),(()=>{if(t.length)return k("div",{className:`absolute left-full top-0 h-full ${t.length===1?"w-24":"w-36"}`,children:t.map((f,m)=>r.has(f.key)?null:D("div",{className:"absolute left-0 right-0 flex -translate-y-1/2 items-center gap-1.5",style:{top:`${(m+1)/(t.length+1)*100}%`},children:[k("div",{className:"h-px min-w-8 flex-1 bg-foreground/40"}),r.has(f.key)?null:k("button",{type:"button",className:"flex size-6 shrink-0 items-center justify-center rounded-md border border-border-strong bg-card text-muted-foreground shadow-sm transition hover:border-primary hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40","aria-label":`Add after ${a} ${f.key}`,title:`Add after ${f.key}`,onClick:(p)=>{p.stopPropagation(),o.chart.onAddFromPort?.(f)},children:k(Yn,{className:"size-3.5"})})]},f.key))});return null})()]})};var je=b(()=>{Wo();it={emerald:"bg-[color-mix(in_oklab,var(--chart-2)_12%,var(--card))] text-emerald-600 border-emerald-500/30",sky:"bg-[color-mix(in_oklab,var(--chart-4)_12%,var(--card))] text-sky-600 border-sky-500/30",slate:"bg-[color-mix(in_oklab,var(--bg-surface-alt)_55%,var(--card))] text-slate-600 border-slate-500/30",violet:"bg-[color-mix(in_oklab,var(--chart-5)_12%,var(--card))] text-violet-600 border-violet-500/30"}});var dt=(o)=>o.trim().replaceAll(/[^a-zA-Z0-9]+/gu,"_").toUpperCase(),ct=(o)=>{if(typeof o.module==="string")return{exportName:o.exportName,module:o.module};return{exportName:o.exportName,module:o.module.pathname.split("/").pop()??"unknown-module"}},ae=(o)=>{let{declaration:e,phase:n,message:t,cause:r,sourceMap:i}=o,{target:s}=e,a=["FE",n.toUpperCase(),s.packageFqn,s.fqn,s.version,s.role].map(dt).join("-");return{componentFqn:s.fqn,diagnosticId:a,message:t,packageFqn:s.packageFqn,phase:n,role:s.role,source:ct(e.implementation.render),version:s.version,...i===void 0?void 0:{sourceMap:i},...r===void 0?void 0:{cause:String(r instanceof Error?r.message:r)}}};var Eo=()=>{};import{Component as pt,createContext as ut,createElement as ft,useContext as mt,useEffect as gt,useLayoutEffect as xt,useRef as yt,useState as bt}from"react";import"react";import{jsx as be,jsxs as ht}from"react/jsx-runtime";var kt=(o)=>ht("div",{role:"alert","data-diagnostic-id":o.diagnosticId,children:["Hosted extension failed. Diagnostic ID: ",o.diagnosticId]}),To,Oo,Jo,Po=({diagnostic:o})=>mt(Jo)(o),Vo=(o,e)=>{console.error(`Hosted extension ${o.diagnosticId}: ${o.message}`,e)},Do,wt,ne=({componentProps:o,declaration:e,fallback:n=wt,implementationRole:t="render",load:r,onDiagnostic:i})=>{let[s,a]=bt(null),l=yt({load:r,onDiagnostic:i});xt(()=>{l.current={load:r,onDiagnostic:i}},[r,i]),gt(()=>{let x=!0;return(async()=>{try{let f=await l.current.load();if(!x)return;let m=e.implementation[t]??e.implementation.render,p=f[m.exportName];if(p===void 0){let h=ae({declaration:e,message:`Export "${m.exportName}" was not a React component.`,phase:"load"});Vo(h,h),l.current.onDiagnostic?.(h),a({declaration:e,diagnostic:h,implementationRole:t,kind:"failed"});return}a({component:p,declaration:e,implementationRole:t,kind:"ready"})}catch(f){if(!x)return;let m=ae({cause:f,declaration:e,message:"The hosted component could not be loaded.",phase:"load"});Vo(m,f),l.current.onDiagnostic?.(m),a({declaration:e,diagnostic:m,implementationRole:t,kind:"failed"})}})(),()=>{x=!1}},[e,t]);let d=s?.declaration===e&&s.implementationRole===t?s:null;if(d===null)return n;if(d.kind==="failed")return be(Po,{diagnostic:d.diagnostic});let c={children:ft(d.component,o),declaration:e,...i===void 0?void 0:{onDiagnostic:i}};return be(Do,{...c})};var ke=b(()=>{Eo();To=Symbol.for("@collective-intelligence/extensions-sdk-frontend-react/hosted-extension-failure"),Oo=globalThis,Jo=Oo[To]??ut(kt);Oo[To]=Jo;Do=class Do extends pt{constructor(o){super(o);this.state={error:null}}static getDerivedStateFromError(o){return{error:o}}componentDidCatch(o,e){let n=ae({cause:o,declaration:this.props.declaration,message:"The hosted component threw while rendering.",phase:"render"});this.props.onDiagnostic?.(n)}render(){if(this.state.error!==null){let o=ae({cause:this.state.error,declaration:this.props.declaration,message:"The hosted component threw while rendering.",phase:"render"});return be(Po,{diagnostic:o})}return this.props.children}};wt=be("output",{children:"Loading extension…"})});var te=async(o,e="render")=>{let n=o.implementation[e]??o.implementation.render;if(n.load===void 0)throw Error(`Workflow contribution "${o.target.fqn}" requires a retained module loader for "${e}".`);return await n.load()};import{infiniteQueryOptions as vt,queryOptions as Wt}from"@tanstack/react-query";var Ro,Ui=(o)=>{Ro=o},No=(o)=>{let{optionsProvider:e,...n}=o;return n},Ao=(o)=>["workflow-field-options",No(o)],Io=(o,e)=>{let n=o.optionsProvider??Ro;return n===void 0?Promise.resolve({options:[]}):n(No(o),e.signal)},le=(o)=>Wt({queryFn:async(e)=>await Io(o,e),queryKey:Ao(o)}),zi=(o)=>vt({getNextPageParam:(e)=>e.nextCursor,initialPageParam:null,queryFn:async({pageParam:e,signal:n})=>await Io({...o,cursor:e},{signal:n}),queryKey:Ao({...o,cursor:null})});var $e=()=>{};import{Combobox as Ct,Label as Ft}from"@collective-intelligence/ui-react/ui";import{useQuery as St}from"@tanstack/react-query";import{jsx as jo,jsxs as Vt}from"react/jsx-runtime";var Et=(o)=>{if(o?.kind==="literal")return o.text;return o?.kind==="translation"?o.default:void 0},$o=({context:o})=>{let{remoteOptions:e}=o,n={catalogTemplateId:e?.catalogTemplateId??"",dependencies:e?.dependencies??{},limit:50,organizationId:e?.organizationId??""},t=e?.config===void 0?le(n):le({...n,config:e.config}),r=(()=>{if(e?.optionsProvider===void 0)return t;if(e.config===void 0)return le({...n,optionsProvider:e.optionsProvider});return le({...n,config:e.config,optionsProvider:e.optionsProvider})})(),i=St({...r,enabled:Boolean(e)}),s=i.data?.options??o.options,a=Et(o.field.placeholder);return Vt("div",{className:"space-y-2",children:[jo(Ft,{htmlFor:`workflow-field-${o.field.key}`,children:o.field.label.kind==="literal"?o.field.label.text:o.field.label.default}),jo(Ct,{className:"w-full",disabled:o.readOnly||Boolean(e&&i.isPending),emptyMessage:"No options are available.",id:`workflow-field-${o.field.key}`,modal:!0,onChange:(l)=>o.onValueChange(l),options:s.map((l)=>({label:l.label,value:String(l.value)})),placeholder:a??"Select an option",searchPlaceholder:"Search options...",value:o.value===null||!u(o.value)&&!J(o.value)?"":String(o.value),width:"100%"})]})};var qo=b(()=>{$e()});var L;var qe=b(()=>{L={field:"Field",unavailableConfiguration:(o)=>`${o} has configuration that this Dashboard cannot edit. Its saved configuration is preserved.`,unavailableControl:(o,e)=>`${o} uses an unavailable ${e} control. Its saved value is preserved.`}});import{Alert as Tt,AlertDescription as Ot}from"@collective-intelligence/ui-react/ui";import{jsx as R,jsxs as Be,Fragment as Pt}from"react/jsx-runtime";var Me=({diagnostics:o})=>R(Pt,{children:o.map((e)=>R(Tt,{variant:"destructive",children:R(Ot,{children:e.message})},`${e.code}:${e.message}`))}),Jt=(o)=>{if(u(o))return o;if(o!==null&&W(o)&&"text"in o){let{text:e}=o;return u(e)?e:L.field}if(o!==null&&W(o)&&"default"in o){let{default:e}=o;return u(e)?e:L.field}return L.field},Le=({context:o})=>{let e={widget:o.field.widget};if(o.field.fieldFqn!==void 0&&o.field.fieldFqn!==null)e.fqn=o.field.fieldFqn;if(o.field.fieldVersion!==void 0&&o.field.fieldVersion!==null)e.version=o.field.fieldVersion;let n=de(e),t=o.mode??(o.readOnly?"read_only":"value"),r={...o,readOnly:t==="read_only"||o.readOnly};if(n.kind==="resolved"&&n.source==="fallback"&&o.field.optionSource?.kind==="remote")return Be("div",{className:"space-y-2",children:[R($o,{context:r}),R(Me,{diagnostics:o.diagnostics})]});if(n.kind==="resolved")return Be("div",{className:"space-y-2",children:[R(ne,{componentProps:r,declaration:n.entry.declaration,load:()=>te(n.entry.declaration)}),Mo(n.entry).handlesDiagnostics===!0?null:R(Me,{diagnostics:o.diagnostics})]});return Be("div",{className:"space-y-2",children:[R("div",{className:"rounded-lg border border-dashed border-border px-3 py-2 text-sm text-muted-foreground",children:L.unavailableControl(Jt(o.field.label),o.field.fieldFqn??o.field.widget)}),R(Me,{diagnostics:o.diagnostics})]})};var _e=b(()=>{ke();ce();qo();qe()});var Bo;var Lo=b(()=>{Bo={noEditableFields:"This template does not expose editable fields."}});import{jsx as He,jsxs as Ho}from"react/jsx-runtime";var Dt=function(e){if(u(e))return e;if(W(e)&&!Array.isArray(e)&&"en"in e){let n=e.en;return u(n)?n:""}return""},_o=function(e){return[...e].sort((n,t)=>(n.order??0)-(t.order??0))},Rt=function(e){return _o(e).map((n)=>({...n,fields:_o(n.fields??[])}))},_=({context:o})=>{let e=Rt("editor"in o.template.contract?o.template.contract.editor?.form?.sections??[]:[]);return Ho("div",{className:"space-y-5",children:[e.map((n)=>Ho("section",{className:"space-y-3 rounded-xl border border-border p-4",children:[He("h3",{className:"text-sm font-semibold text-foreground",children:Dt(n.label)}),(n.fields??[]).filter((t)=>o.isFieldVisible?.(t)??!0).map((t)=>o.getFieldContext?He(Le,{context:o.getFieldContext(t)},t.key):null)]},n.key)),e.length?null:He("p",{className:"rounded-xl border border-dashed border-border p-4 text-sm text-muted-foreground",children:Bo.noEditableFields})]})};var we=b(()=>{_e();Lo()});var Nt,Ko=(o)=>Nt.has(o),H=(o)=>T(o)?o:void 0,ve=(o)=>{let e=o.anyOf??o.oneOf;return Array.isArray(e)?e.flatMap((n)=>{let t=H(n);return t===void 0?[]:ve(t)}):[o]},Uo=(o)=>{if(o===null)return"null";if(Array.isArray(o))return"array";if(T(o))return"object";if(u(o))return"string";if(J(o))return Number.isInteger(o)?"integer":"number";return"boolean"},Qo=(o)=>{let{type:e}=o;if(u(e))return Ko(e)?new Set([e]):void 0;if(Array.isArray(e))return new Set(e.filter(u).filter(Ko));if(o.const!==void 0)return new Set([Uo(o.const)]);if(Array.isArray(o.enum))return new Set(o.enum.map(Uo));if(o.properties!==void 0)return new Set(["object"]);if(o.items!==void 0)return new Set(["array"]);return},N=(o)=>{let e=new Set;for(let n of ve(o)){let t=Qo(n);if(t===void 0)return;for(let r of t)e.add(r)}return e},Go=(o)=>{let[e]=o;if(e===void 0)return{};return o.length===1?e:{anyOf:[...o]}},pe=(o,e)=>ve(o).filter((n)=>{let t=Qo(n);return t===void 0||t.has(e)}),he=(o)=>Go(pe(o,"array").map((e)=>H(e.items)??{})),At=(o,e)=>o.has(e)||e==="integer"&&o.has("number"),It=(o,e)=>{let[n]=pe(o,"object"),t=H(n?.properties);if(t===void 0)return!0;let r=Array.isArray(n?.required)?n.required.filter(u):[];return pe(e,"object").every((i)=>{let s=H(i.properties);if(s===void 0)return!0;return r.every((a)=>(a in s))&&Object.entries(t).every(([a,l])=>{let d=H(s[a]),c=H(l);return d===void 0||c===void 0?!0:K(c,d)})})},K=(o,e)=>{let n=N(o),t=N(e);if(n===void 0||t===void 0)return!0;for(let r of t)if(!At(n,r))return!1;if(t.has("array")&&!K(he(o),he(e)))return!1;return!t.has("object")||It(o,e)},jt=(o)=>Go(ve(o).flatMap((e)=>{let{type:n}=e;if(n==="null")return[];if(Array.isArray(n)){let t=n.filter((r)=>r!=="null");return t.length===0?[]:[{...e,type:t}]}return[e]})),$t=(o)=>{let e=N(o);if(e?.has("string")===!0)return'""';if(e?.has("number")===!0||e?.has("integer")===!0)return"0";if(e?.has("boolean")===!0)return"false";return},qt=(o)=>{let e=pe(o,"array").every((t)=>J(t.minItems)&&t.minItems>=1),n=he(o);return e||N(n)?.has("null")===!0?n:{anyOf:[n,{type:"null"}]}},Ke=(o,e)=>{if(e===void 0||N(e)===void 0||N(o)===void 0)return{status:"unknown"};if(K(e,o))return{status:"compatible"};let n=$t(e),t=(l,d)=>{if(K(e,l))return d;return n!==void 0&&K(e,jt(l))?[...d,`coalesce(${n})`]:void 0},r=t(o,[]),i=N(o),s=r===void 0&&i?.has("array")===!0?t(qt(o),["first"]):void 0,a=r??s;return a===void 0||a.length===0?{status:"incompatible"}:{pipes:a.map((l)=>`| ${l}`).join(" "),status:"fixable"}},zo=4,Mt=(o)=>{let e=pe(o,"object").flatMap((t)=>Object.keys(H(t.properties)??{}));if(e.length===0)return"object";return`{${e.slice(0,zo).join(", ")}${e.length>zo?", …":""}}`},Ue=(o)=>{let e=N(o);if(e===void 0)return"any";return["string","integer","number","boolean","object","array","null"].filter((t)=>e.has(t)).map((t)=>{if(t==="array"){let r=he(o),i=N(r);return`array of ${i?.size===1&&i.has("object")?Mt(r):Ue(r)}`}return t}).join(" | ")};var We=b(()=>{Nt=new Set(["array","boolean","integer","null","number","object","string"])});var hs=function(e){let n=e.mode==="fixed"?e.value:null;return{expression:e.mode==="expression"?e.source:"",fixed:n,mode:e.mode}},vs=function(e){return e.mode==="fixed"?{mode:"fixed",value:e.fixed}:{languageVersion:1,mode:"expression",source:e.expression}},Yo=function(e,n){return{availability:n.availability,id:n.id,label:n.label,path:n.path??[],schema:n.schema,sourceId:e}},Bt=(o,e)=>o.length===e.length&&o.every((n,t)=>n===e[t]),Lt=function(e,n,t){let r=t.path??[];if(r.length===0){e.children.push(Yo(n,t));return}let i=e;for(let[s,a]of r.entries()){let l=r.slice(0,s+1),d=i.children.findIndex((w)=>Bt(w.path,l)),c=i.children[d];if(s===r.length-1){if(!c)i.children.push(Yo(n,t));return}if(c&&"children"in c){i=c;continue}let x=c?{...c,children:[],conditional:c.availability==="conditional",selectors:[]}:{availability:t.availability,children:[],conditional:t.availability==="conditional",id:`${n}:${l.join(".")}`,label:String(a),path:l,schema:{},selectors:[],sourceId:n};if(c)i.children[d]=x;else i.children.push(x);i=x}},_t=function o(e){return e.flatMap((n)=>[n,...o(n.children??[])])},Ht=function(e){let n=e.availability??"guaranteed",t={availability:n,children:[],conditional:n==="conditional",id:e.id,label:e.label,path:[],schema:e.schema,selectors:(e.selectors??[]).map((r)=>r.kind),sourceId:e.id};if(e.nodeKey!==void 0&&e.nodeKey!==null)t.nodeKey=e.nodeKey;for(let r of _t(e.fields??[]))Lt(t,e.id,r);return t},Kt=function(e){return{compatibility:e.targetCompatibility??[],language:e.languageManifest,sources:(e.availableSources??[]).map(Ht)}},Ut=function(e){return{canonicalSource:e.canonicalSource??null,diagnostics:(e.diagnostics??[]).map((n)=>({actualSchema:n.actualSchema,code:n.code,expectedSchema:n.expectedSchema,message:n.message,remediation:n.remediation,severity:n.severity,span:n.span})),inferredSchema:e.inferredSchema,references:e.references??[]}},Ws=function(e,n){return K(n,e)},Zo=function(e,n,t){let r=Math.max(0,Math.min(n,e.length));return{cursor:r+t.length,source:`${e.slice(0,r)}${t}${e.slice(r)}`}};var Ce=b(()=>{We()});var zt=function(e){if(e.id==="trigger")return"trigger";if(e.id==="workflow_input")return"input";let[,n]=e.id.split(":port:");return`nodes[${JSON.stringify(e.nodeKey??e.label)}]${n?`.${n}`:""}`},Qt=function(e){return e.map((n)=>(()=>{if(J(n))return`[${n}]`;if(/^[A-Za-z_$][\w$]*$/u.test(n))return`.${n}`;return`[${JSON.stringify(n)}]`})()).join("")},Gt=function(e){if(e.id==="trigger")return{id:"trigger",label:"Trigger data"};if(e.id==="workflow_input")return{id:"workflow_input",label:"Workflow input"};return{id:e.id,label:e.label}},Yt=function o(e){let{source:n}=e;return e.nodes.flatMap((t)=>{let r=`${n.id}:${t.id}`,i=[...e.parentLabels,t.label],s="children"in t?t.children:[],a=`${zt(n)}${Qt(t.path)}`;return[{conditional:t.availability==="conditional",depth:e.depth,expandable:s.length>0,group:e.group,id:r,insertion:`{{ ${a} }}`,label:`${n.label} · ${i.join(".")}`,name:t.label,parentId:e.parentId,pathLabel:i.join("."),reference:a,schema:t.schema,selectors:n.selectors},...o({depth:e.depth+1,group:e.group,nodes:s,parentId:r,parentLabels:i,source:n})]})},Zt=function(e){let n=e.children.length?e.children:[{availability:e.availability,id:e.id,label:"Output",path:[],schema:e.schema,sourceId:e.id}];return Yt({depth:0,group:Gt(e),nodes:n,parentId:null,parentLabels:[],source:e})},ze=function(e){return e.sources.flatMap((n)=>Zt(n))},U=function(e){return Ue(e)};var Fe=b(()=>{We()});import{jsx as F,jsxs as en,Fragment as Xt}from"react/jsx-runtime";var V=({title:o,values:e})=>en("section",{"aria-label":o,children:[F("h3",{className:"font-medium",children:o}),e.length>0?F("ul",{className:"mt-1 list-disc pl-5 font-mono text-xs",children:e.map((n,t)=>F("li",{children:n},`${n}-${t}`))}):F("p",{className:"text-muted-foreground",children:"No entries in this language manifest."})]}),Xo=function(e){return e.map((n)=>n.example??n.name)},Qe=({manifest:o})=>en(Xt,{children:[F(V,{title:"Syntax overview",values:[o.grammar]}),F(V,{title:"Interpolation",values:[`Whole value preserves type: ${o.interpolation.wholeValuePreservesType}`,`Mixed text returns: ${o.interpolation.mixedTextReturns}`]}),F(V,{title:"References",values:[o.grammar]}),F(V,{title:"Selectors",values:o.selectors.map(({kind:e})=>e)}),F(V,{title:"Unavailable-value policies",values:o.availabilityPolicies}),F(V,{title:"Operators",values:o.operators}),F(V,{title:"Functions",values:Xo(o.functions)}),F(V,{title:"Casts and pipes",values:o.pipes}),F(V,{title:"Strings",values:o.pipes}),F(V,{title:"Collections",values:o.pipes}),F(V,{title:"Objects",values:o.pipes}),F(V,{title:"Dates",values:o.pipes}),F(V,{title:"If conditions",values:o.ifExamples}),F(V,{title:"Comparators",values:Xo(o.comparators)})]});var Ge=()=>{};var z;var on=b(()=>{z={applyPipes:(o)=>`Append ${o}`,expectedType:"Field expects",incompatibleType:"Incompatible type",insertWithPipes:"Insert with the pipes that make this value fit the field",validationFailed:(o)=>`We couldn't validate this expression: ${o}`,validationUnavailable:"We couldn't validate this expression right now. Check its syntax and referenced values, then try again."}});import{ChevronRight as er}from"@collective-intelligence/ui-react/icons";import{Badge as or,Button as G,Input as nn,Popover as nr,PopoverAnchor as tr,PopoverContent as rr,Textarea as ir}from"@collective-intelligence/ui-react/ui";import{Fragment as sr,useEffect as ar,useRef as lr,useState as Q}from"react";import{jsx as y,jsxs as S}from"react/jsx-runtime";var tn=(o)=>o!==null&&W(o)&&!Array.isArray(o),A=(o)=>o!==null&&o!==void 0&&o!=="",dr=function o(e){if(u(e))return e;if(Array.isArray(e)){let n=e.map(o).filter((t)=>A(t));return n.length?n.join("; "):void 0}if(!tn(e))return;if(u(e.msg))return e.msg;if(u(e.message))return e.message;if(u(e.detail))return e.detail;return},cr=function(e){if(e instanceof Error&&A(e.message))return e.message;if(!P(e))return;if(!tn(e))return;return[e.detail,e.body,e.error,e.message].map(dr).find((n)=>A(n))},pr=function(e){let n=cr(e);return A(n)?z.validationFailed(n):z.validationUnavailable},rn,ur,sn=function(e,n){return ur.flatMap((t)=>e.filter((r)=>n(r)===t))},fr=function(e){let n=new Map;for(let i of e){let s=n.get(i.option.parentId)??[];s.push(i),n.set(i.option.parentId,s)}let t=new Map,r=(i)=>{let s=t.get(i.option.id);if(s!==void 0)return s;let a=Math.min(rn[i.compatibility.status],...(n.get(i.option.id)??[]).map(r));return t.set(i.option.id,a),a};for(let[i,s]of n)n.set(i,sn(s,r));return n},an=({entry:o,expanded:e,onInsert:n,onToggle:t})=>{let{compatibility:r,option:i}=o,s=t===void 0,a=r.status==="incompatible";return S("div",{className:"mt-1 flex items-start gap-1",style:{paddingInlineStart:s?0:`${i.depth*1.25}rem`},children:[!s&&i.expandable?y(G,{"aria-expanded":e,"aria-label":`${e?"Collapse":"Expand"} ${i.label}`,className:"mt-1 size-7 shrink-0",onClick:t,size:"icon",type:"button",variant:"ghost",children:y(er,{"aria-hidden":!0,className:e?"size-4 rotate-90":"size-4"})}):y("span",{"aria-hidden":!0,className:"size-7 shrink-0"}),S(G,{"aria-label":`Insert ${i.label}`,className:`block h-auto min-w-0 flex-1 whitespace-normal px-2 py-1.5 text-left ${a?"opacity-60":""}`,onClick:()=>{n(i.insertion)},type:"button",variant:"ghost",children:[y("span",{className:"block text-sm",children:s?i.pathLabel:i.name}),S("span",{className:"flex flex-wrap items-center gap-1.5 font-mono text-xs text-muted-foreground",children:[U(i.schema),a?y(or,{className:"font-sans",variant:"outline",children:z.incompatibleType}):null]})]}),r.status==="fixable"?y(G,{"aria-label":`Insert ${i.label} with ${r.pipes}`,className:"mt-1 h-auto shrink-0 px-1.5 py-0.5 font-mono text-xs",onClick:()=>{n(`{{ ${i.reference} ${r.pipes} }}`)},size:"sm",title:z.insertWithPipes,type:"button",variant:"outline",children:r.pipes}):null]})},ln=({tree:o,expanded:e,onInsert:n,onToggle:t,parentId:r})=>(o.get(r)??[]).map((i)=>{let s=e.has(i.option.id);return S(sr,{children:[y(an,{entry:i,expanded:s,onInsert:n,onToggle:()=>{t(i.option.id)}}),s?y(ln,{expanded:e,onInsert:n,onToggle:t,parentId:i.option.id,tree:o}):null]},i.option.id)}),mr=({environment:o,onInsert:e,onQueryChange:n,options:t,query:r,targetSchema:i})=>{let[s,a]=Q(new Set),l=new Map(t.map(({group:p})=>[p.id,p])),d=["trigger","workflow_input"],c=[...d.flatMap((p)=>l.get(p)??[]),...[...l.values()].filter(({id:p})=>!d.includes(p))],x=t.map((p)=>({compatibility:Ke(p.schema,i),option:p})),w=r.trim()!=="",f=x.filter(({option:p})=>[p.label,p.insertion,U(p.schema)].join(" ").toLowerCase().includes(r.trim().toLowerCase())),m=(p)=>{a((h)=>{let v=new Set(h);if(v.has(p))v.delete(p);else v.add(p);return v})};return S("div",{className:"grid h-96 max-h-[calc(100dvh-3rem)] grid-cols-[minmax(0,1fr)_14rem] overflow-hidden",children:[S("div",{className:"min-h-0 touch-pan-y overflow-y-auto overscroll-y-contain border-r p-2",onWheel:(p)=>{p.stopPropagation()},children:[y(nn,{"aria-label":"Search expression suggestions",onChange:(p)=>{n(p.target.value)},placeholder:"Search available values",value:r}),c.map((p)=>{let h=(w?f:x).filter(({option:v})=>v.group.id===p.id);if(h.length===0)return null;return S("section",{"aria-label":p.label,className:"mt-3",children:[y("h3",{className:"px-2 text-xs font-semibold text-muted-foreground",children:p.label}),w?sn(h,(v)=>rn[v.compatibility.status]).map((v)=>y(an,{entry:v,expanded:!1,onInsert:e},v.option.id)):y(ln,{expanded:s,onInsert:e,onToggle:m,parentId:null,tree:fr(h)})]},p.id)}),(w?f:x).length===0?y("p",{className:"p-3 text-sm text-muted-foreground",children:"No matching workflow sources."}):null]}),S("aside",{className:"space-y-3 p-3","aria-label":"Expression helper",children:[i===void 0?null:S("p",{className:"text-xs",children:[S("span",{className:"text-muted-foreground",children:[z.expectedType," "]}),y("span",{className:"font-mono",children:U(i)})]}),y("p",{className:"text-xs text-muted-foreground",children:"Select a typed source. Expand an object to pick one of its fields, or insert the whole object."}),y("h3",{className:"text-xs font-semibold",children:"Pipes"}),o.language.pipes.map((p)=>S(G,{className:"mr-1 mb-1 h-auto px-1.5 py-0.5 font-mono text-xs",onClick:()=>{e(` | ${p}`)},size:"sm",type:"button",variant:"outline",children:["| ",p]},p))]})]})},gr,xr=function(e,n){let t=gr.exec(e)?.groups?.body;return t===void 0||t.includes("{{")?void 0:`{{ ${t.trim()} ${n} }}`},yr=({diagnostic:o,onApplyFix:e,source:n,targetSchema:t})=>{let r=o.expectedSchema??t,i=o.code==="incompatible_expression_type"&&o.actualSchema!==null?Ke(o.actualSchema,r??void 0):void 0,s=i?.status==="fixable"?xr(n,i.pipes):void 0;return S("div",{className:"space-y-1 text-sm text-destructive",role:"alert",children:[S("p",{children:[o.message," (characters ",o.span.start,"–",o.span.end,")"]}),A(o.remediation)?y("p",{className:"text-xs text-muted-foreground",children:o.remediation}):null,i?.status==="fixable"&&s!==void 0&&e!==void 0?y(G,{className:"h-auto px-1.5 py-0.5 font-mono text-xs",onClick:()=>{e(s)},size:"sm",type:"button",variant:"outline",children:z.applyPipes(i.pipes)}):null]})},Ye=({describedBy:o,environment:e,inputLabel:n="Expression",source:t,onChange:r,validate:i,multiline:s=!1,readOnly:a=!1,targetSchema:l})=>{let d=lr(null),c=(g)=>{d.current=g},[x,w]=Q(t.length),[f,m]=Q(!1),[p,h]=Q("suggestions"),[v,Y]=Q(""),[De,Re]=Q(null),[B,Z]=Q(null),ie=i===void 0||t===""?null:De,C=i===void 0||t===""?null:B,O=[o,A(C)?"expression-validation":void 0].filter(Boolean).join(" ")||void 0;ar(()=>{let g=new AbortController;if(!i||t==="");else{let Ne=async()=>{try{let Ae=await i(t,g.signal);if(!g.signal.aborted)Re(Ae),Z(null)}catch(Ae){if(!g.signal.aborted)Z(pr(Ae))}},ee=window.setTimeout(()=>{Ne()},300);return()=>{g.abort(),window.clearTimeout(ee)}}return()=>{g.abort()}},[t,i]);let j=ze(e),X=(g)=>{let Ne=d.current?.selectionStart??x,ee=Zo(t,Ne,g);w(ee.cursor),r(ee.source),queueMicrotask(()=>{d.current?.focus(),d.current?.setSelectionRange(ee.cursor,ee.cursor)})};return S("div",{className:"space-y-2",children:[S(nr,{onOpenChange:(g)=>{if(m(g),!g)Y(""),h("suggestions")},open:f,children:[y(tr,{asChild:!0,children:y("div",{children:(()=>{if(s)return y(ir,{"aria-describedby":O,"aria-invalid":A(C)||(ie?.diagnostics.length??0)>0,"aria-label":n,className:"min-h-24 text-sm",disabled:a,onChange:(g)=>{r(g.target.value),w(g.currentTarget.selectionStart??t.length)},onFocus:()=>{m(!0)},onKeyDown:(g)=>{if(g.key==="Escape")m(!1)},onSelect:(g)=>{w(g.currentTarget.selectionStart??t.length)},placeholder:"Choose a source or start typing",ref:c,value:t});return y(nn,{"aria-describedby":O,"aria-invalid":A(C)||(ie?.diagnostics.length??0)>0,"aria-label":n,className:"text-sm",disabled:a,onChange:(g)=>{r(g.target.value),w(g.currentTarget.selectionStart??t.length)},onFocus:()=>{m(!0)},onKeyDown:(g)=>{if(g.key==="Escape")m(!1)},onSelect:(g)=>{w(g.currentTarget.selectionStart??t.length)},placeholder:"Choose a source or start typing",ref:c,value:t})})()})}),S(rr,{align:"start",className:"w-[min(48rem,calc(100vw-3rem))] p-0",onOpenAutoFocus:(g)=>{g.preventDefault()},children:[S("div",{className:"flex border-b p-1",role:"tablist",children:[y(G,{"aria-selected":p==="suggestions",onClick:()=>{h("suggestions")},role:"tab",size:"sm",type:"button",variant:p==="suggestions"?"secondary":"ghost",children:"Suggestions"}),y(G,{"aria-selected":p==="syntax",onClick:()=>{h("syntax")},role:"tab",size:"sm",type:"button",variant:p==="syntax"?"secondary":"ghost",children:"Syntax reference"})]}),p==="suggestions"?y(mr,{environment:e,onInsert:X,onQueryChange:Y,options:j,query:v,targetSchema:l}):y("div",{className:"max-h-96 touch-pan-y overflow-y-auto overscroll-y-contain p-4 text-sm",onWheel:(g)=>{g.stopPropagation()},children:y(Qe,{manifest:e.language})})]})]}),A(C)?y("p",{id:"expression-validation",role:"alert",children:C}):null,ie?.diagnostics.map((g)=>y(yr,{diagnostic:g,onApplyFix:a?void 0:r,source:t,targetSchema:l},`${g.code}-${g.span.start}`))]})};var dn=b(()=>{Ce();We();Fe();Ge();on();rn={compatible:0,fixable:1,incompatible:3,unknown:2},ur=[0,1,2,3],gr=/^\s*\{\{(?<body>[\s\S]*?)\}\}\s*$/u});var Se=b(()=>{dn();Ge();Fe()});var I;var cn=b(()=>{I={expression:"Expression",expressionHelp:"Calculates a value from the data available when this step runs.",fixed:"Fixed",fixedHelp:"Uses the saved value as written.",modesHelp:"Fixed uses the saved value as written. Expression calculates a value from the data available when the step runs."}});import{Alert as br,AlertDescription as kr,Label as wr,ToggleGroup as hr,ToggleGroupItem as pn}from"@collective-intelligence/ui-react/ui";import{useId as vr,useState as un}from"react";import{jsx as E,jsxs as Ee}from"react/jsx-runtime";var Wr,fn=function(e){return e.mode==="expression"?{expression:e.source,fixed:null,mode:"expression"}:{expression:"",fixed:e.value,mode:"fixed"}},Cr=({mode:o})=>E("span",{className:"shrink-0 text-xs text-muted-foreground",title:o==="expression"?I.expressionHelp:I.fixedHelp,children:o==="expression"?I.expression:I.fixed}),ue=({allowExpression:o=!1,allowFixed:e=!0,controlId:n,diagnostics:t=Wr,expressionEditor:r,expressionMultiline:i=!1,help:s,label:a,onValueChange:l,readOnly:d=!1,renderExpression:c,renderFixed:x,required:w=!1,sensitive:f=!1,value:m})=>{let p=vr(),[h,v]=un(()=>fn(m)),Y=JSON.stringify(m),[De,Re]=un(Y),B=n===void 0?void 0:`${n}-label`;if(Y!==De)Re(Y),v(fn(m));let Z=(()=>{if(o&&!e)return"expression";if(e&&!o)return"fixed";return h.mode})(),ie=d;return Ee("section",{className:"space-y-2",children:[Ee("div",{className:"flex items-center justify-between gap-3",children:[E("div",{className:"min-w-0",children:Ee("div",{className:"flex items-center gap-1",children:[E(wr,{htmlFor:n,id:B,children:a}),w?E("span",{"aria-label":"Required",children:"*"}):null,f?E("span",{className:"ml-1 text-xs text-muted-foreground",children:"Sensitive"}):null]})}),o&&d?E(Cr,{mode:Z}):null,o&&e&&!d?E("div",{"aria-label":`${a} mode controls`,className:"flex shrink-0 items-center gap-1",children:Ee(hr,{"aria-label":`${a} mode`,className:"gap-0",disabled:ie,onValueChange:(C)=>{if(C==="fixed"||C==="expression")v((O)=>({...O,mode:C}))},size:"sm",type:"single",value:Z,variant:"outline",children:[E(pn,{className:"h-7 px-4 text-xs",title:I.fixedHelp,value:"fixed",children:I.fixed}),E(pn,{className:"h-7 px-4 text-xs",title:I.expressionHelp,value:"expression",children:I.expression})]})}):null]}),s!==void 0&&s!==""?E("p",{id:p,className:"text-xs leading-relaxed text-muted-foreground",children:s}):null,(()=>{if(Z==="expression"){if(r?.environment){let j=r.validate===void 0?{}:{validate:r.validate};return E(Ye,{...s?{describedBy:p}:{},environment:r.environment,multiline:i,onChange:(X)=>{v((g)=>({...g,expression:X})),l({languageVersion:1,mode:"expression",source:X})},readOnly:d,source:h.expression,targetSchema:r.targetSchema,...j})}if(r?.loading===!0)return E("output",{children:"Loading expression editor…"});if(r?.error!==void 0&&r.error!=="")return E("p",{role:"alert",children:r.error});let O={disabled:d,onChange:(j)=>{v((X)=>({...X,expression:j})),l({languageVersion:1,mode:"expression",source:j})},value:h.expression};if(s)O.describedBy=p;if(n!==void 0)O.controlId=`${n}-expression`;if(B!==void 0)O.labelledBy=B;return c?.(O)}let C={disabled:d,onChange:(O)=>{v((j)=>({...j,fixed:O})),l({mode:"fixed",value:O})},value:h.fixed};if(s)C.describedBy=p;if(n!==void 0)C.controlId=n;if(B!==void 0)C.labelledBy=B;return x(C)})(),t.map((C)=>E(br,{variant:"destructive",children:E(kr,{children:C.message})},`${C.code}:${C.message}`))]})};var Ze=b(()=>{Se();cn();Wr=[]});var Xe=b(()=>{Ze()});var eo;var mn=b(()=>{eo={inputBindingsDescription:"Map workflow input field names to literal or dynamic expressions.",inputBindingsTitle:"Input adapter bindings"}});var fe=function(e){return T(e)?e:{}},oo=function(e){return fe(e)},Fr=function(e,n,t){let r=e.anyOf;if(!Array.isArray(r))return;let i=r.filter((d)=>fe(d).type!=="null");if(i.length!==1||i.length===r.length)return;let s=oo(t(i[0],n)),{type:a}=s,l={...s,...Object.fromEntries(Object.entries(e).filter(([d])=>d!=="anyOf"&&d!=="$defs"))};if(u(a))l.type=[a,"null"];return l},Sr=function(e){let n=fe(e.$defs),t=(r,i=new Set)=>{if(Array.isArray(r))return r.map((c)=>t(c,i));if(!T(r))return r;let s=fe(r),a=s.$ref,l=u(a)?a:void 0;if(l!==void 0&&l.startsWith("#/$defs/")){let c=l.slice(8),x=n[c];if(x!==void 0&&!i.has(c))return t(x,new Set(i).add(c))}let d=Fr(s,i,t);if(d)return d;return Object.fromEntries(Object.entries(s).filter(([c])=>c!=="$defs").map(([c,x])=>[c,t(x,i)]))};return oo(t(e))},Er=function(e){let{type:n}=e;return n==="null"||Array.isArray(n)&&n.includes("null")},Vr=function(e){let{type:n}=e;if(u(n))return n==="null"?e:{...e,type:[n,"null"]};if(Array.isArray(n))return n.includes("null")?e:{...e,type:[...n,"null"]};return e},Tr=function o(e,n=[],t=!1){return Object.entries(fe(e.properties)).map(([r,i])=>{let s=oo(i),a=t?Vr(s):s,l=[...n,r],d=o(s,l,t||Er(s)),c={availability:"guaranteed",id:`trigger:${l.join(".")}`,label:r,path:l,schema:a,sourceId:"trigger"};return d.length?{...c,children:d,conditional:!1,selectors:[]}:c})},gn=function(e){let{triggerInput:n}=e;if(!n)return;let t=Sr(n.schema);return{compatibility:[],language:n.languageManifest,sources:[{availability:"guaranteed",children:Tr(t),conditional:!1,id:"trigger",label:"Trigger data",path:[],schema:t,selectors:[],sourceId:"trigger"}]}};var xn=()=>{};import{Input as Or,Label as Jr}from"@collective-intelligence/ui-react/ui";import{jsx as ge,jsxs as yn}from"react/jsx-runtime";var Pr=(o)=>{if(o===null||o===void 0||u(o)||J(o)||se(o))return String(o??"");return JSON.stringify(o)??""},me=function(e){return T(e)?e:{}},Dr=function(e,n){return e?.length===n.length&&e.every((t,r)=>t===n[r])},Rr=function(e,n){if(n==="number"||n==="integer"){let t=Number(e);return Number.isFinite(t)?t:e}if(n==="boolean")return e==="true";return e},Nr=function(e){if(!T(e))return{mode:"fixed",value:e??null};if(e.mode==="expression"&&u(e.source))return{languageVersion:1,mode:"expression",source:e.source};if(e.mode==="fixed"&&P(e.value))return{mode:"fixed",value:e.value};return{mode:"fixed",value:e}},bn=({context:o})=>{let e=me(o.workflowContracts?.inputContract.jsonSchema.properties),n=o.trigger?.inputBindings??{},t=gn(o.template.contract);return yn("div",{className:"space-y-5",children:[ge(_,{context:o}),yn("section",{className:"space-y-2 rounded-xl border border-border p-4",children:[ge(Jr,{htmlFor:"workflow-trigger-input-bindings",children:eo.inputBindingsTitle}),ge("p",{className:"text-xs text-muted-foreground",children:eo.inputBindingsDescription}),Object.entries(e).map(([r,i])=>{let s=me(n[r]),a=Nr(s?.value),l=o.triggerInputExpressionValidator?.(r),d=t===void 0?void 0:{environment:t,targetSchema:me(i)};if(d!==void 0&&l!==void 0)d.validate=l;return ge(ue,{allowExpression:!0,...d===void 0?{}:{expressionEditor:d},diagnostics:o.diagnostics.filter((c)=>Dr(c.path,["inputBindings",r])),label:`${r} (${U(me(i))})`,readOnly:o.readOnly,value:a,onValueChange:(c)=>o.commands.updateTriggerConfiguration?.({inputBindings:{...n,[r]:{overridePolicy:"locked",value:c}}}),renderFixed:({value:c,onChange:x})=>ge(Or,{value:Pr(c),onChange:(w)=>{x(Rr(w.target.value,me(i)?.type))}})},r)})]})]})};var kn=b(()=>{Se();Xe();we();mn();xn()});var Vn={};_n(Vn,{renderDefaultActionChart:()=>wn,renderDefaultActionDetails:()=>hn,renderDefaultInputChart:()=>Cn,renderDefaultInputDetails:()=>Fn,renderDefaultOutputChart:()=>Sn,renderDefaultOutputDetails:()=>En,renderDefaultTriggerChart:()=>vn,renderDefaultTriggerDetails:()=>Wn});import{jsx as q}from"react/jsx-runtime";var wn=(o)=>q(oe,{context:o,accent:"slate"}),hn=(o)=>q(_,{context:o}),vn=(o)=>q(oe,{context:o,accent:"violet"}),Wn=(o)=>q(bn,{context:o}),Cn=(o)=>q(oe,{context:o,accent:"sky"}),Fn=(o)=>q(_,{context:o}),Sn=(o)=>q(oe,{context:o,accent:"emerald"}),En=(o)=>q(_,{context:o});var no=b(()=>{je();we();kn()});import{declareFrontendComponent as Ar}from"@collective-intelligence/extensions-sdk-frontend";var to=(o)=>({exportName:o,load:()=>Promise.resolve().then(() => (no(),Vn)),module:import.meta.url}),Ve=(o,e,n)=>Ar({implementation:{chart:to(e),details:to(n),render:to(n)},metadata:{kind:o,mode:"default"},target:{fqn:`builtin.core.workflows.nodes.${o.replace(/_node$/u,"")}`,packageFqn:"builtin.core",role:"workflow_template_default",version:"1.0.0"}}),ro;var io=b(()=>{ro=[Ve("action_node","renderDefaultActionChart","renderDefaultActionDetails"),Ve("trigger_node","renderDefaultTriggerChart","renderDefaultTriggerDetails"),Ve("input_node","renderDefaultInputChart","renderDefaultInputDetails"),Ve("output_node","renderDefaultOutputChart","renderDefaultOutputDetails")]});import{WorkflowTemplateKinds as Ir}from"@collective-intelligence/extensions-sdk";var xe=(o)=>Ir.find((e)=>e===o);var so=()=>{};import{createFrontendCatalog as jr,declareFrontendPackage as $r}from"@collective-intelligence/extensions-sdk-frontend";var co,Te,po=(o)=>{let{declaration:{metadata:e}}=o;if(!T(e))return{};let n=u(e.kind)?xe(e.kind):void 0,t;if(u(e.mode)){if(e.mode==="default")t="default";else if(e.mode==="override")t="override"}let r={};if(u(e.fqn))r.fqn=e.fqn;if(se(e.handlesDiagnostics))r.handlesDiagnostics=e.handlesDiagnostics;if(n!==void 0)r.kind=n;if(t!==void 0)r.mode=t;if(u(e.widget))r.widget=e.widget;return r},Oe=(o)=>{let e=o?.trim().toLowerCase();return e===void 0||e===""?void 0:e},Tn=()=>co.snapshot().entries,On=(o,e,n)=>{let t=Oe(o),r=Oe(e);if(t===void 0||r===void 0)return;return Tn().find((i)=>i.target.toLowerCase()===t&&i.version.toLowerCase()===r&&i.role===n)},ao=(o,e,n)=>{let t=Oe(e);return Tn().find((r)=>{let i=po(r);return Oe(i[o])===t&&r.role===n})},Jn=(o)=>{Te=[...Te.filter((t)=>!o.some((r)=>r.manifest.fqn===t.manifest.fqn)),...o];let n=co.activate(Te);if(n.kind==="invalid")throw Error(n.errors.map((t)=>t.message).join("; "));if(n.kind!=="activated")throw Error(`Workflow catalog activation became stale (${n.reason}).`)},lo,qr=()=>{if(Te.some((o)=>o.manifest.fqn===lo.manifest.fqn))return;Jn([lo])},Mr=()=>co.snapshot(),de=(o)=>{let e=u(o)?{widget:o}:o,n=e.fqn??void 0,t=e.version??void 0,r=On(n,t,"workflow_field");if(r!==void 0)return{entry:r,kind:"resolved",source:"exact"};if(n!==void 0&&t!==void 0){let a=ao("widget",e.widget??"","workflow_field_fallback");if(a!==void 0&&n.toLowerCase().startsWith("builtin."))return{entry:a,kind:"resolved",source:"fallback"};let l={fqn:n,kind:"unavailable"};if(e.widget!==void 0)l.widget=e.widget;return l}let i=ao("widget",e.widget??"","workflow_field_fallback");if(i!==void 0)return{entry:i,kind:"resolved",source:"fallback"};let s={kind:"unavailable"};if(e.fqn!==void 0&&e.fqn!==null)s.fqn=e.fqn;if(e.widget!==void 0)s.widget=e.widget;return s},uo=(o)=>{let e=xe(o.kind);if(e===void 0)return{fqn:o.fqn,kind:"unavailable",templateKind:o.kind};let n=On(o.fqn,o.version??"1.0.0","workflow_template_override");if(n!==void 0&&po(n).kind===e)return{entry:n,kind:"resolved",source:"override"};let t=ao("kind",e,"workflow_template_default");if(t!==void 0)return{entry:t,kind:"resolved",source:"default"};return{fqn:o.fqn,kind:"unavailable",templateKind:o.kind}},Mo;var ce=b(()=>{io();so();so();co=jr(),Te=[],lo=$r({components:ro,manifest:{fqn:"builtin.core",name:"Dashboard Workflow UI",version:"1.0.0"}}),Mo=po});ce();ke();ce();qe();import{jsx as Pn}from"react/jsx-runtime";var Br=({context:o})=>{let e=de(o.field);if(e.kind==="resolved"&&e.entry.declaration.implementation.configuration!==void 0)return Pn(ne,{componentProps:o,declaration:e.entry.declaration,implementationRole:"configuration",load:()=>te(e.entry.declaration,"configuration")});return Pn("div",{className:"rounded-md border border-dashed border-border p-2 text-xs text-muted-foreground",children:L.unavailableConfiguration(o.field.label)})};_e();Ce();Xe();Ze();import{Textarea as Lr}from"@collective-intelligence/ui-react/ui";import{jsx as Dn}from"react/jsx-runtime";import{createElement as Hr}from"react";var Aa=({help:o,label:e,onValueChange:n,expressionEditor:t,readOnly:r,renderFixed:i,resetKey:s,slotId:a,value:l})=>Dn("div",{"data-expression-slot":a,children:Hr(ue,{allowExpression:!0,...o===void 0?{}:{help:o},...t===void 0?{}:{expressionEditor:t},key:`${a}:${s??"current"}`,label:e,onValueChange:n,...r===void 0?{}:{readOnly:r},renderExpression:({describedBy:d,disabled:c,onChange:x,value:w})=>Dn(Lr,{"aria-describedby":d,"aria-label":`${e} expression`,disabled:c,onChange:(f)=>{x(f.target.value)},placeholder:"{{ input.value }}",value:w}),renderFixed:i,value:l})}),_r=function(e){if(!T(e))return!1;if(e.mode==="fixed")return P(e.value);return e.mode==="expression"&&J(e.languageVersion)&&e.languageVersion===1&&u(e.source)},Ia=function(e){if(_r(e))return e;return{mode:"fixed",value:e}};var fo=function(e,n){let t=[...e];for(let r=0;r<t.length;r+=1)for(let i=r+1;i<t.length;i+=1){let s=t[r],a=t[i];if(s!==void 0&&a!==void 0&&n(s,a)>0)t[r]=a,t[i]=s}return t};var Nn=function(e){return W(e)&&!Array.isArray(e)},Kr=function o(e){return e.flatMap((n)=>[...n.templates??[],...o(n.children??[])])},mo=function(e){return e.kind==="field_collection"&&"collection"in e.contract},go=function(e){return`${e.fqn}@${e.version}`},Rn=function(e){return e.kind==="literal"?e.text:e.default},Ur=function(e){return e.kind==="field"&&"field"in e.contract},zr=function(e,n){if(!e.enabled||e.state!=="available")return!1;return n==="input"?e.contract.field.availableForInput!==!1:e.contract.field.availableForOutput!==!1},Qr=function(e,n){let t=e.find((r)=>mo(r)&&go(r.contract.collection)===n);return t&&mo(t)?t.contract.collection.weight??0:0},Je=function(e){return e!==void 0&&Nn(e)?e:{}},_a=function(e,n){let t=Kr(e?.categories??[]),r=new Map;for(let s of t){if(!mo(s))continue;r.set(go(s.contract.collection),Rn(s.label))}let i=new Map;for(let s of t){if(!Ur(s)||!zr(s,n))continue;let a=s.contract.field,l=go({fqn:a.collectionFqn,version:a.collectionVersion}),d=i.get(l)??{fields:[],key:l,label:r.get(l)??a.collectionFqn,weight:Qr(t,l)};d.fields.push({catalogTemplateId:s.id,collectionKey:l,configSchema:Je(a.configSchema),fqn:a.fqn,label:Rn(s.label),schema:Je(a.valueSchema),version:a.version}),i.set(l,d)}return fo([...i.values()].map((s)=>({...s,fields:fo(s.fields,(a,l)=>a.label.localeCompare(l.label)||a.fqn.localeCompare(l.fqn))})),(s,a)=>s.weight-a.weight||s.label.localeCompare(a.label)||s.key.localeCompare(a.key))},Ha=function(e){return{key:e.key,label:e.label,options:e.fields.map((n)=>({fqn:n.fqn,label:n.label,searchTerms:[n.fqn],version:n.version}))}},Gr=function(e){let n=Je(e.$defs),t=(r,i=new Set)=>{if(Array.isArray(r))return r.map((d)=>t(d,i));if(r===null||!Nn(r))return r;let s=r,a=s.$ref,l=u(a)?a:void 0;if(l!==void 0&&l.startsWith("#/$defs/")){let d=l.slice(8),c=n[d];if(c!==void 0&&c!==null&&!i.has(d))return t(c,new Set(i).add(d))}return Object.fromEntries(Object.entries(s).filter(([d])=>d!=="$defs").map(([d,c])=>[d,t(c,i)]))};return Je(t(e))},Ka=function(e,n){let{title:t,...r}=Gr(n.schema),i={...r};if(u(e.title))i.title=e.title;return i};import{useDebouncedCallback as Yr}from"@collective-intelligence/ui-react/hooks";import{Check as Zr,ChevronsUpDown as Xr}from"@collective-intelligence/ui-react/icons";import{Button as ei,Command as oi,CommandGroup as ni,CommandInput as ti,CommandItem as ri,CommandList as ii,Popover as si,PopoverContent as ai,PopoverTrigger as li}from"@collective-intelligence/ui-react/ui";import{useMemo as di,useState as xo}from"react";import{jsx as M,jsxs as ye}from"react/jsx-runtime";var ci=250,yo=function(e){return`${e.fqn}@${e.version}`},pi=function(e,n){let t=n.trim().toLocaleLowerCase();if(!t)return e;return e.flatMap((r)=>{let i=r.options.filter((s)=>[s.label,s.fqn,...s.searchTerms??[]].join(" ").toLocaleLowerCase().includes(t));return i.length?[{...r,options:i}]:[]})},Za=({collections:o,value:e,onChange:n,ariaLabel:t="Field type"})=>{let[r,i]=xo(!1),[s,a]=xo(""),[l,d]=xo(""),c=Yr(d,ci),x=o.flatMap((m)=>m.options).find((m)=>yo(m)===e),w=di(()=>pi(o,l),[o,l]),f=w.some((m)=>m.options.length>0);return ye(si,{modal:!0,open:r,onOpenChange:(m)=>{if(i(m),!m)c.cancel(),a(""),d("")},children:[M(li,{asChild:!0,children:ye(ei,{type:"button",variant:"outline","aria-label":t,"aria-expanded":r,className:"mt-1 w-full justify-between font-normal",children:[M("span",{className:"truncate",children:x?.label??"Select a field type"}),M(Xr,{className:"ml-2 size-4 shrink-0 opacity-50"})]})}),M(ai,{align:"start",className:"w-[var(--radix-popover-trigger-width)] p-0",children:ye(oi,{shouldFilter:!1,children:[M(ti,{placeholder:"Search field types...",value:s,onValueChange:(m)=>{a(m),c(m)}}),ye(ii,{children:[f?null:M("p",{className:"py-6 text-center text-sm",children:"No field type found."}),w.map((m)=>M(ni,{heading:m.label,children:m.options.map((p)=>{let h=yo(p);return ye(ri,{value:yo(p),onSelect:()=>{n(p),i(!1)},children:[M(Zr,{className:e===h?"mr-2 size-4 opacity-100":"mr-2 size-4 opacity-0"}),p.label]},h)})},m.key))]})]})})]})};je();we();io();no();ke();ce();import{jsx as An,jsxs as fi}from"react/jsx-runtime";var ui=({context:o})=>{let e=uo(o.template);if(e.kind==="resolved")return An(ne,{componentProps:o,declaration:e.entry.declaration,implementationRole:"details",load:()=>te(e.entry.declaration,"details")});return fi("div",{className:"rounded-xl border border-dashed border-border p-4 text-sm text-muted-foreground",children:["No dashboard editor is available for template kind"," ",An("code",{children:e.templateKind}),". The workflow draft has not been changed."]})};var bo=(o)=>o!==void 0&&o!==null&&W(o)&&!Array.isArray(o),In=function(e,n){return Object.fromEntries(Object.entries(e).filter(([t])=>t!==n))},jn=function(e){if(e==="input_binding")return"inputs";if(e==="setting")return"settings";if(e==="metadata")return"metadata";return"config"},re=function(e){return bo(e)?e:void 0},ko=function(e){let n=re(e);if(n===void 0||!("value"in n))return e;return n.mode==="fixed"||n.kind==="literal"?n.value:e},Pe=function(e,n){let t=e[jn(n.target)];for(let r of n.path){let i=re(ko(t));if(i===void 0)return;t=i[r]}return ko(t)},mi=function(e,n){return Pe(e,n.binding)},gi=function o(e,n,t){let[r,...i]=n;if(r===void 0)return e??{};let s=e??{};if(!i.length)return{...s,[r]:t};let a=re(s[r]),l=re(ko(a));if(a?.mode==="fixed")return{...s,[r]:{...a,value:o(l,i,t)}};return{...s,[r]:o(l,i,t)}},wo=function(e,n){return[e==="input_binding"?"inputBinding":e,...n].map((t)=>encodeURIComponent(String(t))).join("/")},xi=function(e,n,t){let r={...re(e?.fieldDisplayValues)},i=wo(n.binding.target,n.binding.path);if(t)r[i]=t;else return{...e,fieldDisplayValues:In(r,i)};return{...e,fieldDisplayValues:r}},yi=function(e,n,t,r){let i=jn(n.binding.target),s={[i]:gi(e[i],n.binding.path,t)};if(r!==void 0)s.metadata=xi(i==="metadata"?s.metadata:e.metadata,n,r);return s},$n=function(e,n,t){let r=e.metadata?.fieldDisplayValues;if(r===void 0||r===null||!bo(r))return;let i=r[wo(n.binding.target,t)];if(i===void 0||i===null||!bo(i))return;return u(i.label)&&"value"in i?{label:i.label,value:i.value}:void 0},bi=function(e,n){return $n(e,n,n.binding.path)},ki=function(e,n,t){return $n(e,n,[...n.binding.path,...t])},wi=function(e,n,t,r){let i={...re(e?.fieldDisplayValues)},s=wo(n,t);if(r)i[s]=r;else return{...e,fieldDisplayValues:In(i,s)};return{...e,fieldDisplayValues:i}},hi=function(e,n,t,r){return{metadata:wi(e.metadata,n.binding.target,[...n.binding.path,...t],r)}};var ho=function o(e,n){if(Array.isArray(e)||Array.isArray(n))return Array.isArray(e)&&Array.isArray(n)&&e.length===n.length&&e.every((t,r)=>o(t,n[r]));if(e!==null&&n!==null&&e!==void 0&&n!==void 0&&W(e)&&W(n)){let t=Object.keys(e);return t.length===Object.keys(n).length&&t.every((r)=>o(e[r],n[r]))}return e===n},qn=function(e){return e!==void 0&&e!==null&&e!==""},vi=function(e,n){if(!Array.isArray(n)||e===void 0)return!1;return(Array.isArray(e)?e:[e]).some((r)=>n.some((i)=>ho(r,i)))},Wi=function(e,n){return(e.visibleWhen??[]).every((t)=>{let r=Pe(n,t.binding);switch(t.operator){case"equals":return ho(r,t.value);case"not_equals":return!ho(r,t.value);case"is_set":return qn(r);case"is_not_set":return!qn(r);case"in":return vi(r,t.value);default:return!1}})};var Ci=function(e){if(!e)return"";return e.kind==="literal"?e.text:e.default};Ce();Se();Fe();$e();export{oe as CatalogNodeChartBlock,_ as CatalogNodeDetailsEditor,Ye as ExpressionEditor,Aa as ExpressionSlot,Qe as ExpressionSyntaxReference,Za as FieldTypeSelect,Br as WorkflowFieldConfigurationResolver,ue as WorkflowFieldFrame,Le as WorkflowFieldResolver,ui as WorkflowTemplateDetails,qr as activateDashboardWorkflowCatalog,Jn as activateWorkflowCatalog,Ia as asExpressionSlotValue,Ci as catalogText,Ui as configureWorkflowFieldOptionsProvider,hs as createExpressionDraft,lo as dashboardWorkflowPackage,ro as defaultWorkflowTemplateDeclarations,ze as expressionSourceOptions,_a as fieldCollectionsFromCatalog,yo as fieldTypeIdentity,Zo as insertExpressionAtCursor,se as isBoolean,Hn as isFunction,P as isJsonValue,J as isNumber,W as isObject,T as isRecord,Ws as isSchemaCompatible,u as isString,Si as isUndefined,Wi as isWorkflowFieldVisible,Kt as normalizeExpressionEnvironment,Ut as normalizeExpressionValidation,xe as parseWorkflowTemplateKind,hi as patchWorkflowFieldPartDisplayValue,yi as patchWorkflowFieldValue,Pe as readWorkflowBindingValue,bi as readWorkflowFieldDisplayValue,ki as readWorkflowFieldPartDisplayValue,mi as readWorkflowFieldValue,wn as renderDefaultActionChart,hn as renderDefaultActionDetails,Cn as renderDefaultInputChart,Fn as renderDefaultInputDetails,Sn as renderDefaultOutputChart,En as renderDefaultOutputDetails,vn as renderDefaultTriggerChart,Wn as renderDefaultTriggerDetails,de as resolveWorkflowField,uo as resolveWorkflowTemplate,Ka as schemaForWorkflowField,U as schemaLabel,vs as serializeExpressionDraft,Ei as toDisplayString,Ha as toFieldTypeCollection,Mr as workflowCatalogSnapshot,le as workflowFieldOptions,zi as workflowFieldOptionsInfinite};
|
|
1
|
+
var Mn=Object.defineProperty;var Bn=(o)=>o;function Ln(o,e){this[o]=Bn.bind(null,e)}var _n=(o,e)=>{for(var n in e)Mn(o,n,{get:e[n],enumerable:!0,configurable:!0,set:Ln.bind(e,n)})};var b=(o,e,n)=>()=>{if(o)try{e=o(o=0)}catch(t){n=[t]}if(n)throw n[0];return e};var se=(o)=>Boolean(o)===o,Hn=(o)=>Object.prototype.toString.call(o)==="[object Function]",J=(o)=>Number(o)===o,W=(o)=>o!==null&&Object(o)===o&&!Hn(o),P=(o)=>{let e=Object.prototype.toString.call(o);if(o===null||e==="[object Boolean]"||e==="[object Number]"||e==="[object String]")return!0;if(Array.isArray(o))return o.every(P);return W(o)&&Object.values(o).every(P)},T=(o)=>P(o)&&W(o)&&!Array.isArray(o),p=(o)=>String(o)===o,Si=(o)=>o===void 0,Ei=(o)=>{let e=o;if(p(e))return e;if(se(e)||J(e))return String(e);return""};import{ArrowRight as Kn,CheckCircle2 as Un,Wrench as zn,Zap as Qn}from"@collective-intelligence/ui-react/icons";var vo=function(e){switch(e){case"trigger":case"trigger_node":return{icon:Qn,label:"Trigger",tone:"bg-violet-500/12 text-violet-600 dark:text-violet-400"};case"input_node":return{icon:Kn,label:"Input",tone:"bg-sky-500/12 text-sky-600 dark:text-sky-400"};case"output_node":return{icon:Un,label:"Output",tone:"bg-emerald-500/12 text-emerald-600 dark:text-emerald-400"};default:return{icon:zn,label:"Action",tone:"bg-slate-500/12 text-slate-600 dark:text-slate-400"}}};var Wo=()=>{};import{AlertTriangle as Gn,Plus as Yn}from"@collective-intelligence/ui-react/icons";import{Tooltip as Zn,TooltipContent as Xn,TooltipTrigger as et}from"@collective-intelligence/ui-react/ui";import{Handle as ot,Position as Co,useNodeId as nt,useUpdateNodeInternals as tt}from"@xyflow/react";import{useEffect as rt}from"react";import{jsx as k,jsxs as D,Fragment as lt}from"react/jsx-runtime";var it,Fo=function(e){if(p(e))return e;if(W(e)&&"kind"in e&&"text"in e){let n=e;if(n.kind==="literal"&&p(n.text))return n.text}if(W(e)&&"en"in e){let n=e.en;return p(n)?n:""}return""},st=({issues:o,title:e})=>{let n=`${o.length} ${o.length===1?"issue":"issues"} on ${e}`;return D(Zn,{children:[k(et,{asChild:!0,children:k("button",{type:"button","aria-label":n,className:"nodrag nopan absolute -right-2 -top-2 z-20 flex size-7 items-center justify-center rounded-full border border-[color-mix(in_oklab,var(--warning)_45%,var(--border))] bg-[color-mix(in_oklab,var(--warning)_16%,var(--card))] text-[color-mix(in_oklab,var(--warning)_80%,var(--foreground))] shadow-sm transition hover:bg-[color-mix(in_oklab,var(--warning)_24%,var(--card))] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40",onClick:(t)=>{t.stopPropagation()},onPointerDown:(t)=>{t.stopPropagation()},children:k(Gn,{"aria-hidden":"true",className:"size-4"})})}),D(Xn,{side:"top",sideOffset:6,className:"max-w-72 p-3",children:[k("p",{className:"font-semibold",children:n}),k("ul",{className:"mt-1.5 space-y-1",children:o.map((t)=>k("li",{className:"leading-snug",children:t.message},`${t.code}:${t.message}`))})]})]})},So=({port:o,side:e,index:n=0,count:t=1})=>{let r=e==="left"?Co.Left:Co.Right,i={top:`${(n+1)/(t+1)*100}%`},s=o.maxConnections===null?"unlimited connections":`maximum ${o.maxConnections??1} connections`,a=[...Array.isArray(o.allowedTemplateKinds)?o.allowedTemplateKinds.filter(p):[],...Array.isArray(o.allowedTemplateFqns)?o.allowedTemplateFqns.filter(p):[]],l=`${o.key} — ${o.direction}, ${s}${a.length?`; accepts ${a.join(", ")}`:""}`;return D(lt,{children:[k(ot,{id:o.key,type:o.direction==="input"?"target":"source",position:r,title:l,"aria-label":l,style:i,className:o.direction==="input"?"!h-5 !w-5 !rounded-sm !border-2 !border-background !bg-primary":"!h-5 !w-5 !border-2 !border-background !bg-primary"}),k("span",{style:i,className:`pointer-events-none absolute z-10 -translate-y-full whitespace-nowrap rounded bg-card px-1 text-[10px] text-muted-foreground ${e==="left"?"right-full mr-2":"left-full ml-2"}`,children:o.key})]})},at=({signature:o})=>{let e=nt(),n=tt();return rt(()=>{if(e!==null)n(e)},[e,o,n]),null},oe=({context:o,accent:e})=>{let n=o.ports.filter((f)=>f.direction==="input"),t=o.ports.filter((f)=>f.direction==="output"),r=new Set(o.chart.connectedOutputPortKeys),i=o.chart.fields??[],s=Fo(o.template.label),a=o.chart.title??s,l=o.chart.subtitle??(a===s?void 0:s),d=o.chart.description??Fo(o.template.description),{icon:c}=o.chart.presentation??vo(o.template.kind),x=o.chart.presentation?.tone??it[e],w=o.diagnostics.filter((f)=>f.severity!=="info");return D("div",{className:"relative w-[262px]",children:[w.length?k(st,{issues:w,title:a}):null,D("button",{type:"button","aria-label":`Edit ${a}`,style:{minHeight:(Math.max(n.length,t.length)+1)*28},onDoubleClick:()=>{o.chart.onOpenDetails()},className:`workflow-node-drag group relative z-10 w-full cursor-pointer rounded-2xl border bg-card p-4 text-left shadow-[0_2px_10px_-4px_rgba(30,29,26,0.12)] transition-[border-color,box-shadow] hover:shadow-[0_8px_24px_-14px_rgba(30,29,26,0.24)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 ${x}`,children:[o.ports.length>0?k(at,{signature:o.ports.map((f)=>`${f.direction}:${f.key}`).join("|")}):null,n.map((f,m)=>k(So,{port:f,side:"left",index:m,count:n.length},f.key)),t.map((f,m)=>k(So,{port:f,side:"right",index:m,count:t.length},f.key)),D("div",{className:"flex items-start gap-3",children:[k("div",{className:`flex size-10 shrink-0 items-center justify-center rounded-xl ${x}`,children:k(c,{className:"size-5"})}),D("div",{className:"min-w-0",children:[k("div",{className:"truncate text-sm font-semibold text-foreground",children:a}),p(l)&&l.length>0?k("p",{className:"truncate font-mono text-[11px] text-muted-foreground",children:l}):null]})]}),(()=>{if(p(d)&&d.length>0)return D("div",{className:"mt-3 space-y-2 border-t border-border/70 pt-3",children:[p(d)&&d.length>0?k("p",{className:"line-clamp-2 text-xs leading-snug text-muted-foreground [overflow-wrap:anywhere]",children:d}):null,p(o.chart.summary)&&o.chart.summary.length>0?k("div",{className:"rounded-lg bg-muted/60 px-2.5 py-2",children:k("p",{className:"line-clamp-3 whitespace-pre-line font-mono text-[11px] leading-4 text-muted-foreground [overflow-wrap:anywhere]",children:o.chart.summary})}):null]});return null})(),i.length?k("div",{className:"mt-3 space-y-1.5 border-t border-border/70 pt-3",children:i.slice(0,4).map((f)=>k("div",{className:"truncate rounded-md bg-muted px-2.5 py-1.5 font-mono text-[11px] text-foreground",children:f},f))}):null]}),(()=>{if(t.length)return k("div",{className:`absolute left-full top-0 h-full ${t.length===1?"w-24":"w-36"}`,children:t.map((f,m)=>r.has(f.key)?null:D("div",{className:"absolute left-0 right-0 flex -translate-y-1/2 items-center gap-1.5",style:{top:`${(m+1)/(t.length+1)*100}%`},children:[k("div",{className:"h-px min-w-8 flex-1 bg-foreground/40"}),r.has(f.key)?null:k("button",{type:"button",className:"flex size-6 shrink-0 items-center justify-center rounded-md border border-border-strong bg-card text-muted-foreground shadow-sm transition hover:border-primary hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40","aria-label":`Add after ${a} ${f.key}`,title:`Add after ${f.key}`,onClick:(u)=>{u.stopPropagation(),o.chart.onAddFromPort?.(f)},children:k(Yn,{className:"size-3.5"})})]},f.key))});return null})()]})};var je=b(()=>{Wo();it={emerald:"bg-[color-mix(in_oklab,var(--chart-2)_12%,var(--card))] text-emerald-600 border-emerald-500/30",sky:"bg-[color-mix(in_oklab,var(--chart-4)_12%,var(--card))] text-sky-600 border-sky-500/30",slate:"bg-[color-mix(in_oklab,var(--bg-surface-alt)_55%,var(--card))] text-slate-600 border-slate-500/30",violet:"bg-[color-mix(in_oklab,var(--chart-5)_12%,var(--card))] text-violet-600 border-violet-500/30"}});var dt=(o)=>o.trim().replaceAll(/[^a-zA-Z0-9]+/gu,"_").toUpperCase(),ct=(o)=>{if(typeof o.module==="string")return{exportName:o.exportName,module:o.module};return{exportName:o.exportName,module:o.module.pathname.split("/").pop()??"unknown-module"}},ae=(o)=>{let{declaration:e,phase:n,message:t,cause:r,sourceMap:i}=o,{target:s}=e,a=["FE",n.toUpperCase(),s.packageFqn,s.fqn,s.version,s.role].map(dt).join("-");return{componentFqn:s.fqn,diagnosticId:a,message:t,packageFqn:s.packageFqn,phase:n,role:s.role,source:ct(e.implementation.render),version:s.version,...i===void 0?void 0:{sourceMap:i},...r===void 0?void 0:{cause:String(r instanceof Error?r.message:r)}}};var Eo=()=>{};import{Component as ut,createContext as pt,createElement as ft,useContext as mt,useEffect as gt,useLayoutEffect as xt,useRef as yt,useState as bt}from"react";import"react";import{jsx as be,jsxs as ht}from"react/jsx-runtime";var kt=(o)=>ht("div",{role:"alert","data-diagnostic-id":o.diagnosticId,children:["Hosted extension failed. Diagnostic ID: ",o.diagnosticId]}),To,Oo,Jo,Po=({diagnostic:o})=>mt(Jo)(o),Vo=(o,e)=>{console.error(`Hosted extension ${o.diagnosticId}: ${o.message}`,e)},Do,wt,ne=({componentProps:o,declaration:e,fallback:n=wt,implementationRole:t="render",load:r,onDiagnostic:i})=>{let[s,a]=bt(null),l=yt({load:r,onDiagnostic:i});xt(()=>{l.current={load:r,onDiagnostic:i}},[r,i]),gt(()=>{let x=!0;return(async()=>{try{let f=await l.current.load();if(!x)return;let m=e.implementation[t]??e.implementation.render,u=f[m.exportName];if(u===void 0){let h=ae({declaration:e,message:`Export "${m.exportName}" was not a React component.`,phase:"load"});Vo(h,h),l.current.onDiagnostic?.(h),a({declaration:e,diagnostic:h,implementationRole:t,kind:"failed"});return}a({component:u,declaration:e,implementationRole:t,kind:"ready"})}catch(f){if(!x)return;let m=ae({cause:f,declaration:e,message:"The hosted component could not be loaded.",phase:"load"});Vo(m,f),l.current.onDiagnostic?.(m),a({declaration:e,diagnostic:m,implementationRole:t,kind:"failed"})}})(),()=>{x=!1}},[e,t]);let d=s?.declaration===e&&s.implementationRole===t?s:null;if(d===null)return n;if(d.kind==="failed")return be(Po,{diagnostic:d.diagnostic});let c={children:ft(d.component,o),declaration:e,...i===void 0?void 0:{onDiagnostic:i}};return be(Do,{...c})};var ke=b(()=>{Eo();To=Symbol.for("@collective-intelligence/extensions-sdk-frontend-react/hosted-extension-failure"),Oo=globalThis,Jo=Oo[To]??pt(kt);Oo[To]=Jo;Do=class Do extends ut{constructor(o){super(o);this.state={error:null}}static getDerivedStateFromError(o){return{error:o}}componentDidCatch(o,e){let n=ae({cause:o,declaration:this.props.declaration,message:"The hosted component threw while rendering.",phase:"render"});this.props.onDiagnostic?.(n)}render(){if(this.state.error!==null){let o=ae({cause:this.state.error,declaration:this.props.declaration,message:"The hosted component threw while rendering.",phase:"render"});return be(Po,{diagnostic:o})}return this.props.children}};wt=be("output",{children:"Loading extension…"})});var te=async(o,e="render")=>{let n=o.implementation[e]??o.implementation.render;if(n.load===void 0)throw Error(`Workflow contribution "${o.target.fqn}" requires a retained module loader for "${e}".`);return await n.load()};import{infiniteQueryOptions as vt,queryOptions as Wt}from"@tanstack/react-query";var Ro,Ui=(o)=>{Ro=o},No=(o)=>{let{optionsProvider:e,...n}=o;return n},Ao=(o)=>["workflow-field-options",No(o)],Io=(o,e)=>{let n=o.optionsProvider??Ro;return n===void 0?Promise.resolve({options:[]}):n(No(o),e.signal)},le=(o)=>Wt({queryFn:async(e)=>await Io(o,e),queryKey:Ao(o)}),zi=(o)=>vt({getNextPageParam:(e)=>e.nextCursor,initialPageParam:null,queryFn:async({pageParam:e,signal:n})=>await Io({...o,cursor:e},{signal:n}),queryKey:Ao({...o,cursor:null})});var $e=()=>{};import{Combobox as Ct,Label as Ft}from"@collective-intelligence/ui-react/ui";import{useQuery as St}from"@tanstack/react-query";import{jsx as jo,jsxs as Vt}from"react/jsx-runtime";var Et=(o)=>{if(o?.kind==="literal")return o.text;return o?.kind==="translation"?o.default:void 0},$o=({context:o})=>{let{remoteOptions:e}=o,n={catalogTemplateId:e?.catalogTemplateId??"",dependencies:e?.dependencies??{},limit:50,organizationId:e?.organizationId??""},t=e?.config===void 0?le(n):le({...n,config:e.config}),r=(()=>{if(e?.optionsProvider===void 0)return t;if(e.config===void 0)return le({...n,optionsProvider:e.optionsProvider});return le({...n,config:e.config,optionsProvider:e.optionsProvider})})(),i=St({...r,enabled:Boolean(e)}),s=i.data?.options??o.options,a=Et(o.field.placeholder);return Vt("div",{className:"space-y-2",children:[jo(Ft,{htmlFor:`workflow-field-${o.field.key}`,children:o.field.label.kind==="literal"?o.field.label.text:o.field.label.default}),jo(Ct,{className:"w-full",disabled:o.readOnly||Boolean(e&&i.isPending),emptyMessage:"No options are available.",id:`workflow-field-${o.field.key}`,modal:!0,onChange:(l)=>o.onValueChange(l),options:s.map((l)=>({label:l.label,value:String(l.value)})),placeholder:a??"Select an option",searchPlaceholder:"Search options...",value:o.value===null||!p(o.value)&&!J(o.value)?"":String(o.value),width:"100%"})]})};var qo=b(()=>{$e()});var L;var qe=b(()=>{L={field:"Field",unavailableConfiguration:(o)=>`${o} has configuration that this Dashboard cannot edit. Its saved configuration is preserved.`,unavailableControl:(o,e)=>`${o} uses an unavailable ${e} control. Its saved value is preserved.`}});import{Alert as Tt,AlertDescription as Ot}from"@collective-intelligence/ui-react/ui";import{jsx as R,jsxs as Be,Fragment as Pt}from"react/jsx-runtime";var Me=({diagnostics:o})=>R(Pt,{children:o.map((e)=>R(Tt,{variant:"destructive",children:R(Ot,{children:e.message})},`${e.code}:${e.message}`))}),Jt=(o)=>{if(p(o))return o;if(o!==null&&W(o)&&"text"in o){let{text:e}=o;return p(e)?e:L.field}if(o!==null&&W(o)&&"default"in o){let{default:e}=o;return p(e)?e:L.field}return L.field},Le=({context:o})=>{let e={widget:o.field.widget};if(o.field.fieldFqn!==void 0&&o.field.fieldFqn!==null)e.fqn=o.field.fieldFqn;if(o.field.fieldVersion!==void 0&&o.field.fieldVersion!==null)e.version=o.field.fieldVersion;let n=de(e),t=o.mode??(o.readOnly?"read_only":"value"),r={...o,readOnly:t==="read_only"||o.readOnly};if(n.kind==="resolved"&&n.source==="fallback"&&o.field.optionSource?.kind==="remote")return Be("div",{className:"space-y-2",children:[R($o,{context:r}),R(Me,{diagnostics:o.diagnostics})]});if(n.kind==="resolved")return Be("div",{className:"space-y-2",children:[R(ne,{componentProps:r,declaration:n.entry.declaration,load:()=>te(n.entry.declaration)}),Mo(n.entry).handlesDiagnostics===!0?null:R(Me,{diagnostics:o.diagnostics})]});return Be("div",{className:"space-y-2",children:[R("div",{className:"rounded-lg border border-dashed border-border px-3 py-2 text-sm text-muted-foreground",children:L.unavailableControl(Jt(o.field.label),o.field.fieldFqn??o.field.widget)}),R(Me,{diagnostics:o.diagnostics})]})};var _e=b(()=>{ke();ce();qo();qe()});var Bo;var Lo=b(()=>{Bo={noEditableFields:"This template does not expose editable fields."}});import{jsx as He,jsxs as Ho}from"react/jsx-runtime";var Dt=function(e){if(p(e))return e;if(W(e)&&!Array.isArray(e)&&"en"in e){let n=e.en;return p(n)?n:""}return""},_o=function(e){return[...e].sort((n,t)=>(n.order??0)-(t.order??0))},Rt=function(e){return _o(e).map((n)=>({...n,fields:_o(n.fields??[])}))},_=({context:o})=>{let e=Rt("editor"in o.template.contract?o.template.contract.editor?.form?.sections??[]:[]);return Ho("div",{className:"space-y-5",children:[e.map((n)=>Ho("section",{className:"space-y-3 rounded-xl border border-border p-4",children:[He("h3",{className:"text-sm font-semibold text-foreground",children:Dt(n.label)}),(n.fields??[]).filter((t)=>o.isFieldVisible?.(t)??!0).map((t)=>o.getFieldContext?He(Le,{context:o.getFieldContext(t)},t.key):null)]},n.key)),e.length?null:He("p",{className:"rounded-xl border border-dashed border-border p-4 text-sm text-muted-foreground",children:Bo.noEditableFields})]})};var we=b(()=>{_e();Lo()});var Nt,Ko=(o)=>Nt.has(o),H=(o)=>T(o)?o:void 0,ve=(o)=>{let e=o.anyOf??o.oneOf;return Array.isArray(e)?e.flatMap((n)=>{let t=H(n);return t===void 0?[]:ve(t)}):[o]},Uo=(o)=>{if(o===null)return"null";if(Array.isArray(o))return"array";if(T(o))return"object";if(p(o))return"string";if(J(o))return Number.isInteger(o)?"integer":"number";return"boolean"},Qo=(o)=>{let{type:e}=o;if(p(e))return Ko(e)?new Set([e]):void 0;if(Array.isArray(e))return new Set(e.filter(p).filter(Ko));if(o.const!==void 0)return new Set([Uo(o.const)]);if(Array.isArray(o.enum))return new Set(o.enum.map(Uo));if(o.properties!==void 0)return new Set(["object"]);if(o.items!==void 0)return new Set(["array"]);return},N=(o)=>{let e=new Set;for(let n of ve(o)){let t=Qo(n);if(t===void 0)return;for(let r of t)e.add(r)}return e},Go=(o)=>{let[e]=o;if(e===void 0)return{};return o.length===1?e:{anyOf:[...o]}},ue=(o,e)=>ve(o).filter((n)=>{let t=Qo(n);return t===void 0||t.has(e)}),he=(o)=>Go(ue(o,"array").map((e)=>H(e.items)??{})),At=(o,e)=>o.has(e)||e==="integer"&&o.has("number"),It=(o,e)=>{let[n]=ue(o,"object"),t=H(n?.properties);if(t===void 0)return!0;let r=Array.isArray(n?.required)?n.required.filter(p):[];return ue(e,"object").every((i)=>{let s=H(i.properties);if(s===void 0)return!0;return r.every((a)=>(a in s))&&Object.entries(t).every(([a,l])=>{let d=H(s[a]),c=H(l);return d===void 0||c===void 0?!0:K(c,d)})})},K=(o,e)=>{let n=N(o),t=N(e);if(n===void 0||t===void 0)return!0;for(let r of t)if(!At(n,r))return!1;if(t.has("array")&&!K(he(o),he(e)))return!1;return!t.has("object")||It(o,e)},jt=(o)=>Go(ve(o).flatMap((e)=>{let{type:n}=e;if(n==="null")return[];if(Array.isArray(n)){let t=n.filter((r)=>r!=="null");return t.length===0?[]:[{...e,type:t}]}return[e]})),$t=(o)=>{let e=N(o);if(e?.has("string")===!0)return'""';if(e?.has("number")===!0||e?.has("integer")===!0)return"0";if(e?.has("boolean")===!0)return"false";return},qt=(o)=>{let e=ue(o,"array").every((t)=>J(t.minItems)&&t.minItems>=1),n=he(o);return e||N(n)?.has("null")===!0?n:{anyOf:[n,{type:"null"}]}},Ke=(o,e)=>{if(e===void 0||N(e)===void 0||N(o)===void 0)return{status:"unknown"};if(K(e,o))return{status:"compatible"};let n=$t(e),t=(l,d)=>{if(K(e,l))return d;return n!==void 0&&K(e,jt(l))?[...d,`coalesce(${n})`]:void 0},r=t(o,[]),i=N(o),s=r===void 0&&i?.has("array")===!0?t(qt(o),["first"]):void 0,a=r??s;return a===void 0||a.length===0?{status:"incompatible"}:{pipes:a.map((l)=>`| ${l}`).join(" "),status:"fixable"}},zo=4,Mt=(o)=>{let e=ue(o,"object").flatMap((t)=>Object.keys(H(t.properties)??{}));if(e.length===0)return"object";return`{${e.slice(0,zo).join(", ")}${e.length>zo?", …":""}}`},Ue=(o)=>{let e=N(o);if(e===void 0)return"any";return["string","integer","number","boolean","object","array","null"].filter((t)=>e.has(t)).map((t)=>{if(t==="array"){let r=he(o),i=N(r);return`array of ${i?.size===1&&i.has("object")?Mt(r):Ue(r)}`}return t}).join(" | ")};var We=b(()=>{Nt=new Set(["array","boolean","integer","null","number","object","string"])});var hs=function(e){let n=e.mode==="fixed"?e.value:null;return{expression:e.mode==="expression"?e.source:"",fixed:n,mode:e.mode}},vs=function(e){return e.mode==="fixed"?{mode:"fixed",value:e.fixed}:{languageVersion:1,mode:"expression",source:e.expression}},Yo=function(e,n){return{availability:n.availability,id:n.id,label:n.label,path:n.path??[],schema:n.schema,sourceId:e}},Bt=(o,e)=>o.length===e.length&&o.every((n,t)=>n===e[t]),Lt=function(e,n,t){let r=t.path??[];if(r.length===0){e.children.push(Yo(n,t));return}let i=e;for(let[s,a]of r.entries()){let l=r.slice(0,s+1),d=i.children.findIndex((w)=>Bt(w.path,l)),c=i.children[d];if(s===r.length-1){if(!c)i.children.push(Yo(n,t));return}if(c&&"children"in c){i=c;continue}let x=c?{...c,children:[],conditional:c.availability==="conditional",selectors:[]}:{availability:t.availability,children:[],conditional:t.availability==="conditional",id:`${n}:${l.join(".")}`,label:String(a),path:l,schema:{},selectors:[],sourceId:n};if(c)i.children[d]=x;else i.children.push(x);i=x}},_t=function o(e){return e.flatMap((n)=>[n,...o(n.children??[])])},Ht=function(e){let n=e.availability??"guaranteed",t={availability:n,children:[],conditional:n==="conditional",id:e.id,label:e.label,path:[],schema:e.schema,selectors:(e.selectors??[]).map((r)=>r.kind),sourceId:e.id};if(e.nodeKey!==void 0&&e.nodeKey!==null)t.nodeKey=e.nodeKey;for(let r of _t(e.fields??[]))Lt(t,e.id,r);return t},Kt=function(e){return{compatibility:e.targetCompatibility??[],language:e.languageManifest,sources:(e.availableSources??[]).map(Ht)}},Ut=function(e){return{canonicalSource:e.canonicalSource??null,diagnostics:(e.diagnostics??[]).map((n)=>({actualSchema:n.actualSchema,code:n.code,expectedSchema:n.expectedSchema,message:n.message,remediation:n.remediation,severity:n.severity,span:n.span})),inferredSchema:e.inferredSchema,references:e.references??[]}},Ws=function(e,n){return K(n,e)},Zo=function(e,n,t){let r=Math.max(0,Math.min(n,e.length));return{cursor:r+t.length,source:`${e.slice(0,r)}${t}${e.slice(r)}`}};var Ce=b(()=>{We()});var zt=function(e){if(e.id==="trigger")return"trigger";if(e.id==="workflow_input")return"input";let[,n]=e.id.split(":port:");return`nodes[${JSON.stringify(e.nodeKey??e.label)}]${n?`.${n}`:""}`},Qt=function(e){return e.map((n)=>(()=>{if(J(n))return`[${n}]`;if(/^[A-Za-z_$][\w$]*$/u.test(n))return`.${n}`;return`[${JSON.stringify(n)}]`})()).join("")},Gt=function(e){if(e.id==="trigger")return{id:"trigger",label:"Trigger data"};if(e.id==="workflow_input")return{id:"workflow_input",label:"Workflow input"};return{id:e.id,label:e.label}},Yt=function o(e){let{source:n}=e;return e.nodes.flatMap((t)=>{let r=`${n.id}:${t.id}`,i=[...e.parentLabels,t.label],s="children"in t?t.children:[],a=`${zt(n)}${Qt(t.path)}`;return[{conditional:t.availability==="conditional",depth:e.depth,expandable:s.length>0,group:e.group,id:r,insertion:`{{ ${a} }}`,label:`${n.label} · ${i.join(".")}`,name:t.label,parentId:e.parentId,pathLabel:i.join("."),reference:a,schema:t.schema,selectors:n.selectors},...o({depth:e.depth+1,group:e.group,nodes:s,parentId:r,parentLabels:i,source:n})]})},Zt=function(e){let n=e.children.length?e.children:[{availability:e.availability,id:e.id,label:"Output",path:[],schema:e.schema,sourceId:e.id}];return Yt({depth:0,group:Gt(e),nodes:n,parentId:null,parentLabels:[],source:e})},ze=function(e){return e.sources.flatMap((n)=>Zt(n))},U=function(e){return Ue(e)};var Fe=b(()=>{We()});import{jsx as F,jsxs as en,Fragment as Xt}from"react/jsx-runtime";var V=({title:o,values:e})=>en("section",{"aria-label":o,children:[F("h3",{className:"font-medium",children:o}),e.length>0?F("ul",{className:"mt-1 list-disc pl-5 font-mono text-xs",children:e.map((n,t)=>F("li",{children:n},`${n}-${t}`))}):F("p",{className:"text-muted-foreground",children:"No entries in this language manifest."})]}),Xo=function(e){return e.map((n)=>n.example??n.name)},Qe=({manifest:o})=>en(Xt,{children:[F(V,{title:"Syntax overview",values:[o.grammar]}),F(V,{title:"Interpolation",values:[`Whole value preserves type: ${o.interpolation.wholeValuePreservesType}`,`Mixed text returns: ${o.interpolation.mixedTextReturns}`]}),F(V,{title:"References",values:[o.grammar]}),F(V,{title:"Selectors",values:o.selectors.map(({kind:e})=>e)}),F(V,{title:"Unavailable-value policies",values:o.availabilityPolicies}),F(V,{title:"Operators",values:o.operators}),F(V,{title:"Functions",values:Xo(o.functions)}),F(V,{title:"Casts and pipes",values:o.pipes}),F(V,{title:"Strings",values:o.pipes}),F(V,{title:"Collections",values:o.pipes}),F(V,{title:"Objects",values:o.pipes}),F(V,{title:"Dates",values:o.pipes}),F(V,{title:"If conditions",values:o.ifExamples}),F(V,{title:"Comparators",values:Xo(o.comparators)})]});var Ge=()=>{};var z;var on=b(()=>{z={applyPipes:(o)=>`Append ${o}`,expectedType:"Field expects",incompatibleType:"Incompatible type",insertWithPipes:"Insert with the pipes that make this value fit the field",validationFailed:(o)=>`We couldn't validate this expression: ${o}`,validationUnavailable:"We couldn't validate this expression right now. Check its syntax and referenced values, then try again."}});import{ChevronRight as er}from"@collective-intelligence/ui-react/icons";import{Badge as or,Button as G,Input as nn,Popover as nr,PopoverAnchor as tr,PopoverContent as rr,Textarea as ir}from"@collective-intelligence/ui-react/ui";import{Fragment as sr,useEffect as ar,useRef as lr,useState as Q}from"react";import{jsx as y,jsxs as S}from"react/jsx-runtime";var tn=(o)=>o!==null&&W(o)&&!Array.isArray(o),A=(o)=>o!==null&&o!==void 0&&o!=="",dr=function o(e){if(p(e))return e;if(Array.isArray(e)){let n=e.map(o).filter((t)=>A(t));return n.length?n.join("; "):void 0}if(!tn(e))return;if(p(e.msg))return e.msg;if(p(e.message))return e.message;if(p(e.detail))return e.detail;return},cr=function(e){if(e instanceof Error&&A(e.message))return e.message;if(!P(e))return;if(!tn(e))return;return[e.detail,e.body,e.error,e.message].map(dr).find((n)=>A(n))},ur=function(e){let n=cr(e);return A(n)?z.validationFailed(n):z.validationUnavailable},rn,pr,sn=function(e,n){return pr.flatMap((t)=>e.filter((r)=>n(r)===t))},fr=function(e){let n=new Map;for(let i of e){let s=n.get(i.option.parentId)??[];s.push(i),n.set(i.option.parentId,s)}let t=new Map,r=(i)=>{let s=t.get(i.option.id);if(s!==void 0)return s;let a=Math.min(rn[i.compatibility.status],...(n.get(i.option.id)??[]).map(r));return t.set(i.option.id,a),a};for(let[i,s]of n)n.set(i,sn(s,r));return n},an=({entry:o,expanded:e,onInsert:n,onToggle:t})=>{let{compatibility:r,option:i}=o,s=t===void 0,a=r.status==="incompatible";return S("div",{className:"mt-1 flex items-start gap-1",style:{paddingInlineStart:s?0:`${i.depth*1.25}rem`},children:[!s&&i.expandable?y(G,{"aria-expanded":e,"aria-label":`${e?"Collapse":"Expand"} ${i.label}`,className:"mt-1 size-7 shrink-0",onClick:t,size:"icon",type:"button",variant:"ghost",children:y(er,{"aria-hidden":!0,className:e?"size-4 rotate-90":"size-4"})}):y("span",{"aria-hidden":!0,className:"size-7 shrink-0"}),S(G,{"aria-label":`Insert ${i.label}`,className:`block h-auto min-w-0 flex-1 whitespace-normal px-2 py-1.5 text-left ${a?"opacity-60":""}`,onClick:()=>{n(i.insertion)},type:"button",variant:"ghost",children:[y("span",{className:"block text-sm",children:s?i.pathLabel:i.name}),S("span",{className:"flex flex-wrap items-center gap-1.5 font-mono text-xs text-muted-foreground",children:[U(i.schema),a?y(or,{className:"font-sans",variant:"outline",children:z.incompatibleType}):null]})]}),r.status==="fixable"?y(G,{"aria-label":`Insert ${i.label} with ${r.pipes}`,className:"mt-1 h-auto shrink-0 px-1.5 py-0.5 font-mono text-xs",onClick:()=>{n(`{{ ${i.reference} ${r.pipes} }}`)},size:"sm",title:z.insertWithPipes,type:"button",variant:"outline",children:r.pipes}):null]})},ln=({tree:o,expanded:e,onInsert:n,onToggle:t,parentId:r})=>(o.get(r)??[]).map((i)=>{let s=e.has(i.option.id);return S(sr,{children:[y(an,{entry:i,expanded:s,onInsert:n,onToggle:()=>{t(i.option.id)}}),s?y(ln,{expanded:e,onInsert:n,onToggle:t,parentId:i.option.id,tree:o}):null]},i.option.id)}),mr=({environment:o,onInsert:e,onQueryChange:n,options:t,query:r,targetSchema:i})=>{let[s,a]=Q(new Set),l=new Map(t.map(({group:u})=>[u.id,u])),d=["trigger","workflow_input"],c=[...d.flatMap((u)=>l.get(u)??[]),...[...l.values()].filter(({id:u})=>!d.includes(u))],x=t.map((u)=>({compatibility:Ke(u.schema,i),option:u})),w=r.trim()!=="",f=x.filter(({option:u})=>[u.label,u.insertion,U(u.schema)].join(" ").toLowerCase().includes(r.trim().toLowerCase())),m=(u)=>{a((h)=>{let v=new Set(h);if(v.has(u))v.delete(u);else v.add(u);return v})};return S("div",{className:"grid h-96 max-h-[calc(100dvh-3rem)] grid-cols-[minmax(0,1fr)_14rem] overflow-hidden",children:[S("div",{className:"min-h-0 touch-pan-y overflow-y-auto overscroll-y-contain border-r p-2",onWheel:(u)=>{u.stopPropagation()},children:[y(nn,{"aria-label":"Search expression suggestions",onChange:(u)=>{n(u.target.value)},placeholder:"Search available values",value:r}),c.map((u)=>{let h=(w?f:x).filter(({option:v})=>v.group.id===u.id);if(h.length===0)return null;return S("section",{"aria-label":u.label,className:"mt-3",children:[y("h3",{className:"px-2 text-xs font-semibold text-muted-foreground",children:u.label}),w?sn(h,(v)=>rn[v.compatibility.status]).map((v)=>y(an,{entry:v,expanded:!1,onInsert:e},v.option.id)):y(ln,{expanded:s,onInsert:e,onToggle:m,parentId:null,tree:fr(h)})]},u.id)}),(w?f:x).length===0?y("p",{className:"p-3 text-sm text-muted-foreground",children:"No matching workflow sources."}):null]}),S("aside",{className:"space-y-3 p-3","aria-label":"Expression helper",children:[i===void 0?null:S("p",{className:"text-xs",children:[S("span",{className:"text-muted-foreground",children:[z.expectedType," "]}),y("span",{className:"font-mono",children:U(i)})]}),y("p",{className:"text-xs text-muted-foreground",children:"Select a typed source. Expand an object to pick one of its fields, or insert the whole object."}),y("h3",{className:"text-xs font-semibold",children:"Pipes"}),o.language.pipes.map((u)=>S(G,{className:"mr-1 mb-1 h-auto px-1.5 py-0.5 font-mono text-xs",onClick:()=>{e(` | ${u}`)},size:"sm",type:"button",variant:"outline",children:["| ",u]},u))]})]})},gr,xr=function(e,n){let t=gr.exec(e)?.groups?.body;return t===void 0||t.includes("{{")?void 0:`{{ ${t.trim()} ${n} }}`},yr=({diagnostic:o,onApplyFix:e,source:n,targetSchema:t})=>{let r=o.expectedSchema??t,i=o.code==="incompatible_expression_type"&&o.actualSchema!==null?Ke(o.actualSchema,r??void 0):void 0,s=i?.status==="fixable"?xr(n,i.pipes):void 0;return S("div",{className:"space-y-1 text-sm text-destructive",role:"alert",children:[S("p",{children:[o.message," (characters ",o.span.start,"–",o.span.end,")"]}),A(o.remediation)?y("p",{className:"text-xs text-muted-foreground",children:o.remediation}):null,i?.status==="fixable"&&s!==void 0&&e!==void 0?y(G,{className:"h-auto px-1.5 py-0.5 font-mono text-xs",onClick:()=>{e(s)},size:"sm",type:"button",variant:"outline",children:z.applyPipes(i.pipes)}):null]})},Ye=({describedBy:o,environment:e,inputLabel:n="Expression",source:t,onChange:r,validate:i,multiline:s=!1,readOnly:a=!1,targetSchema:l})=>{let d=lr(null),c=(g)=>{d.current=g},[x,w]=Q(t.length),[f,m]=Q(!1),[u,h]=Q("suggestions"),[v,Y]=Q(""),[De,Re]=Q(null),[B,Z]=Q(null),ie=i===void 0||t===""?null:De,C=i===void 0||t===""?null:B,O=[o,A(C)?"expression-validation":void 0].filter(Boolean).join(" ")||void 0;ar(()=>{let g=new AbortController;if(!i||t==="");else{let Ne=async()=>{try{let Ae=await i(t,g.signal);if(!g.signal.aborted)Re(Ae),Z(null)}catch(Ae){if(!g.signal.aborted)Z(ur(Ae))}},ee=window.setTimeout(()=>{Ne()},300);return()=>{g.abort(),window.clearTimeout(ee)}}return()=>{g.abort()}},[t,i]);let j=ze(e),X=(g)=>{let Ne=d.current?.selectionStart??x,ee=Zo(t,Ne,g);w(ee.cursor),r(ee.source),queueMicrotask(()=>{d.current?.focus(),d.current?.setSelectionRange(ee.cursor,ee.cursor)})};return S("div",{className:"space-y-2",children:[S(nr,{onOpenChange:(g)=>{if(m(g),!g)Y(""),h("suggestions")},open:f,children:[y(tr,{asChild:!0,children:y("div",{children:(()=>{if(s)return y(ir,{"aria-describedby":O,"aria-invalid":A(C)||(ie?.diagnostics.length??0)>0,"aria-label":n,className:"min-h-24 text-sm",disabled:a,onChange:(g)=>{r(g.target.value),w(g.currentTarget.selectionStart??t.length)},onFocus:()=>{m(!0)},onKeyDown:(g)=>{if(g.key==="Escape")m(!1)},onSelect:(g)=>{w(g.currentTarget.selectionStart??t.length)},placeholder:"Choose a source or start typing",ref:c,value:t});return y(nn,{"aria-describedby":O,"aria-invalid":A(C)||(ie?.diagnostics.length??0)>0,"aria-label":n,className:"text-sm",disabled:a,onChange:(g)=>{r(g.target.value),w(g.currentTarget.selectionStart??t.length)},onFocus:()=>{m(!0)},onKeyDown:(g)=>{if(g.key==="Escape")m(!1)},onSelect:(g)=>{w(g.currentTarget.selectionStart??t.length)},placeholder:"Choose a source or start typing",ref:c,value:t})})()})}),S(rr,{align:"start",className:"w-[min(48rem,calc(100vw-3rem))] p-0",onOpenAutoFocus:(g)=>{g.preventDefault()},children:[S("div",{className:"flex border-b p-1",role:"tablist",children:[y(G,{"aria-selected":u==="suggestions",onClick:()=>{h("suggestions")},role:"tab",size:"sm",type:"button",variant:u==="suggestions"?"secondary":"ghost",children:"Suggestions"}),y(G,{"aria-selected":u==="syntax",onClick:()=>{h("syntax")},role:"tab",size:"sm",type:"button",variant:u==="syntax"?"secondary":"ghost",children:"Syntax reference"})]}),u==="suggestions"?y(mr,{environment:e,onInsert:X,onQueryChange:Y,options:j,query:v,targetSchema:l}):y("div",{className:"max-h-96 touch-pan-y overflow-y-auto overscroll-y-contain p-4 text-sm",onWheel:(g)=>{g.stopPropagation()},children:y(Qe,{manifest:e.language})})]})]}),A(C)?y("p",{id:"expression-validation",role:"alert",children:C}):null,ie?.diagnostics.map((g)=>y(yr,{diagnostic:g,onApplyFix:a?void 0:r,source:t,targetSchema:l},`${g.code}-${g.span.start}`))]})};var dn=b(()=>{Ce();We();Fe();Ge();on();rn={compatible:0,fixable:1,incompatible:3,unknown:2},pr=[0,1,2,3],gr=/^\s*\{\{(?<body>[\s\S]*?)\}\}\s*$/u});var Se=b(()=>{dn();Ge();Fe()});var I;var cn=b(()=>{I={expression:"Expression",expressionHelp:"Calculates a value from the data available when this step runs.",fixed:"Fixed",fixedHelp:"Uses the saved value as written.",modesHelp:"Fixed uses the saved value as written. Expression calculates a value from the data available when the step runs."}});import{Alert as br,AlertDescription as kr,Label as wr,ToggleGroup as hr,ToggleGroupItem as un}from"@collective-intelligence/ui-react/ui";import{useId as vr,useState as pn}from"react";import{jsx as E,jsxs as Ee}from"react/jsx-runtime";var Wr,fn=function(e){return e.mode==="expression"?{expression:e.source,fixed:null,mode:"expression"}:{expression:"",fixed:e.value,mode:"fixed"}},Cr=({mode:o})=>E("span",{className:"shrink-0 text-xs text-muted-foreground",title:o==="expression"?I.expressionHelp:I.fixedHelp,children:o==="expression"?I.expression:I.fixed}),pe=({allowExpression:o=!1,allowFixed:e=!0,controlId:n,diagnostics:t=Wr,expressionEditor:r,expressionMultiline:i=!1,help:s,label:a,onValueChange:l,readOnly:d=!1,renderExpression:c,renderFixed:x,required:w=!1,sensitive:f=!1,value:m})=>{let u=vr(),[h,v]=pn(()=>fn(m)),Y=JSON.stringify(m),[De,Re]=pn(Y),B=n===void 0?void 0:`${n}-label`;if(Y!==De)Re(Y),v(fn(m));let Z=(()=>{if(o&&!e)return"expression";if(e&&!o)return"fixed";return h.mode})(),ie=d;return Ee("section",{className:"space-y-2",children:[Ee("div",{className:"flex items-center justify-between gap-3",children:[E("div",{className:"min-w-0",children:Ee("div",{className:"flex items-center gap-1",children:[E(wr,{htmlFor:n,id:B,children:a}),w?E("span",{"aria-label":"Required",children:"*"}):null,f?E("span",{className:"ml-1 text-xs text-muted-foreground",children:"Sensitive"}):null]})}),o&&d?E(Cr,{mode:Z}):null,o&&e&&!d?E("div",{"aria-label":`${a} mode controls`,className:"flex shrink-0 items-center gap-1",children:Ee(hr,{"aria-label":`${a} mode`,className:"gap-0",disabled:ie,onValueChange:(C)=>{if(C==="fixed"||C==="expression")v((O)=>({...O,mode:C}))},size:"sm",type:"single",value:Z,variant:"outline",children:[E(un,{className:"h-7 px-4 text-xs",title:I.fixedHelp,value:"fixed",children:I.fixed}),E(un,{className:"h-7 px-4 text-xs",title:I.expressionHelp,value:"expression",children:I.expression})]})}):null]}),s!==void 0&&s!==""?E("p",{id:u,className:"text-xs leading-relaxed text-muted-foreground",children:s}):null,(()=>{if(Z==="expression"){if(r?.environment){let j=r.validate===void 0?{}:{validate:r.validate};return E(Ye,{...s?{describedBy:u}:{},environment:r.environment,multiline:i,onChange:(X)=>{v((g)=>({...g,expression:X})),l({languageVersion:1,mode:"expression",source:X})},readOnly:d,source:h.expression,targetSchema:r.targetSchema,...j})}if(r?.loading===!0)return E("output",{children:"Loading expression editor…"});if(r?.error!==void 0&&r.error!=="")return E("p",{role:"alert",children:r.error});let O={disabled:d,onChange:(j)=>{v((X)=>({...X,expression:j})),l({languageVersion:1,mode:"expression",source:j})},value:h.expression};if(s)O.describedBy=u;if(n!==void 0)O.controlId=`${n}-expression`;if(B!==void 0)O.labelledBy=B;return c?.(O)}let C={disabled:d,onChange:(O)=>{v((j)=>({...j,fixed:O})),l({mode:"fixed",value:O})},value:h.fixed};if(s)C.describedBy=u;if(n!==void 0)C.controlId=n;if(B!==void 0)C.labelledBy=B;return x(C)})(),t.map((C)=>E(br,{variant:"destructive",children:E(kr,{children:C.message})},`${C.code}:${C.message}`))]})};var Ze=b(()=>{Se();cn();Wr=[]});var Xe=b(()=>{Ze()});var eo;var mn=b(()=>{eo={inputBindingsDescription:"Map workflow input field names to literal or dynamic expressions.",inputBindingsTitle:"Input adapter bindings"}});var fe=function(e){return T(e)?e:{}},oo=function(e){return fe(e)},Fr=function(e,n,t){let r=e.anyOf;if(!Array.isArray(r))return;let i=r.filter((d)=>fe(d).type!=="null");if(i.length!==1||i.length===r.length)return;let s=oo(t(i[0],n)),{type:a}=s,l={...s,...Object.fromEntries(Object.entries(e).filter(([d])=>d!=="anyOf"&&d!=="$defs"))};if(p(a))l.type=[a,"null"];return l},Sr=function(e){let n=fe(e.$defs),t=(r,i=new Set)=>{if(Array.isArray(r))return r.map((c)=>t(c,i));if(!T(r))return r;let s=fe(r),a=s.$ref,l=p(a)?a:void 0;if(l!==void 0&&l.startsWith("#/$defs/")){let c=l.slice(8),x=n[c];if(x!==void 0&&!i.has(c))return t(x,new Set(i).add(c))}let d=Fr(s,i,t);if(d)return d;return Object.fromEntries(Object.entries(s).filter(([c])=>c!=="$defs").map(([c,x])=>[c,t(x,i)]))};return oo(t(e))},Er=function(e){let{type:n}=e;return n==="null"||Array.isArray(n)&&n.includes("null")},Vr=function(e){let{type:n}=e;if(p(n))return n==="null"?e:{...e,type:[n,"null"]};if(Array.isArray(n))return n.includes("null")?e:{...e,type:[...n,"null"]};return e},Tr=function o(e,n=[],t=!1){return Object.entries(fe(e.properties)).map(([r,i])=>{let s=oo(i),a=t?Vr(s):s,l=[...n,r],d=o(s,l,t||Er(s)),c={availability:"guaranteed",id:`trigger:${l.join(".")}`,label:r,path:l,schema:a,sourceId:"trigger"};return d.length?{...c,children:d,conditional:!1,selectors:[]}:c})},gn=function(e){let{triggerInput:n}=e;if(!n)return;let t=Sr(n.schema);return{compatibility:[],language:n.languageManifest,sources:[{availability:"guaranteed",children:Tr(t),conditional:!1,id:"trigger",label:"Trigger data",path:[],schema:t,selectors:[],sourceId:"trigger"}]}};var xn=()=>{};import{Input as Or,Label as Jr}from"@collective-intelligence/ui-react/ui";import{jsx as ge,jsxs as yn}from"react/jsx-runtime";var Pr=(o)=>{if(o===null||o===void 0||p(o)||J(o)||se(o))return String(o??"");return JSON.stringify(o)??""},me=function(e){return T(e)?e:{}},Dr=function(e,n){return e?.length===n.length&&e.every((t,r)=>t===n[r])},Rr=function(e,n){if(n==="number"||n==="integer"){let t=Number(e);return Number.isFinite(t)?t:e}if(n==="boolean")return e==="true";return e},Nr=function(e){if(!T(e))return{mode:"fixed",value:e??null};if(e.mode==="expression"&&p(e.source))return{languageVersion:1,mode:"expression",source:e.source};if(e.mode==="fixed"&&P(e.value))return{mode:"fixed",value:e.value};return{mode:"fixed",value:e}},bn=({context:o})=>{let e=me(o.workflowContracts?.inputContract.jsonSchema.properties),n=o.trigger?.inputBindings??{},t=gn(o.template.contract);return yn("div",{className:"space-y-5",children:[ge(_,{context:o}),yn("section",{className:"space-y-2 rounded-xl border border-border p-4",children:[ge(Jr,{htmlFor:"workflow-trigger-input-bindings",children:eo.inputBindingsTitle}),ge("p",{className:"text-xs text-muted-foreground",children:eo.inputBindingsDescription}),Object.entries(e).map(([r,i])=>{let s=me(n[r]),a=Nr(s?.value),l=o.triggerInputExpressionValidator?.(r),d=t===void 0?void 0:{environment:t,targetSchema:me(i)};if(d!==void 0&&l!==void 0)d.validate=l;return ge(pe,{allowExpression:!0,...d===void 0?{}:{expressionEditor:d},diagnostics:o.diagnostics.filter((c)=>Dr(c.path,["inputBindings",r])),label:`${r} (${U(me(i))})`,readOnly:o.readOnly,value:a,onValueChange:(c)=>o.commands.updateTriggerConfiguration?.({inputBindings:{...n,[r]:{overridePolicy:"locked",value:c}}}),renderFixed:({value:c,onChange:x})=>ge(Or,{value:Pr(c),onChange:(w)=>{x(Rr(w.target.value,me(i)?.type))}})},r)})]})]})};var kn=b(()=>{Se();Xe();we();mn();xn()});var Vn={};_n(Vn,{renderDefaultActionChart:()=>wn,renderDefaultActionDetails:()=>hn,renderDefaultInputChart:()=>Cn,renderDefaultInputDetails:()=>Fn,renderDefaultOutputChart:()=>Sn,renderDefaultOutputDetails:()=>En,renderDefaultTriggerChart:()=>vn,renderDefaultTriggerDetails:()=>Wn});import{jsx as q}from"react/jsx-runtime";var wn=(o)=>q(oe,{context:o,accent:"slate"}),hn=(o)=>q(_,{context:o}),vn=(o)=>q(oe,{context:o,accent:"violet"}),Wn=(o)=>q(bn,{context:o}),Cn=(o)=>q(oe,{context:o,accent:"sky"}),Fn=(o)=>q(_,{context:o}),Sn=(o)=>q(oe,{context:o,accent:"emerald"}),En=(o)=>q(_,{context:o});var no=b(()=>{je();we();kn()});import{declareFrontendComponent as Ar}from"@collective-intelligence/extensions-sdk-frontend";var to=(o)=>({exportName:o,load:()=>Promise.resolve().then(() => (no(),Vn)),module:import.meta.url}),Ve=(o,e,n)=>Ar({implementation:{chart:to(e),details:to(n),render:to(n)},metadata:{kind:o,mode:"default"},target:{fqn:`builtin.core.workflows.nodes.${o.replace(/_node$/u,"")}`,packageFqn:"builtin.core",role:"workflow_template_default",version:"1.0.0"}}),ro;var io=b(()=>{ro=[Ve("action_node","renderDefaultActionChart","renderDefaultActionDetails"),Ve("trigger_node","renderDefaultTriggerChart","renderDefaultTriggerDetails"),Ve("input_node","renderDefaultInputChart","renderDefaultInputDetails"),Ve("output_node","renderDefaultOutputChart","renderDefaultOutputDetails")]});import{WorkflowTemplateKinds as Ir}from"@collective-intelligence/extensions-sdk";var xe=(o)=>Ir.find((e)=>e===o);var so=()=>{};import{createFrontendCatalog as jr,declareFrontendPackage as $r}from"@collective-intelligence/extensions-sdk-frontend";var co,Te,uo=(o)=>{let{declaration:{metadata:e}}=o;if(!T(e))return{};let n=p(e.kind)?xe(e.kind):void 0,t;if(p(e.mode)){if(e.mode==="default")t="default";else if(e.mode==="override")t="override"}let r={};if(p(e.fqn))r.fqn=e.fqn;if(se(e.handlesDiagnostics))r.handlesDiagnostics=e.handlesDiagnostics;if(n!==void 0)r.kind=n;if(t!==void 0)r.mode=t;if(p(e.widget))r.widget=e.widget;return r},Oe=(o)=>{let e=o?.trim().toLowerCase();return e===void 0||e===""?void 0:e},Tn=()=>co.snapshot().entries,On=(o,e,n)=>{let t=Oe(o),r=Oe(e);if(t===void 0||r===void 0)return;return Tn().find((i)=>i.target.toLowerCase()===t&&i.version.toLowerCase()===r&&i.role===n)},ao=(o,e,n)=>{let t=Oe(e);return Tn().find((r)=>{let i=uo(r);return Oe(i[o])===t&&r.role===n})},Jn=(o)=>{Te=[...Te.filter((t)=>!o.some((r)=>r.manifest.fqn===t.manifest.fqn)),...o];let n=co.activate(Te);if(n.kind==="invalid")throw Error(n.errors.map((t)=>t.message).join("; "));if(n.kind!=="activated")throw Error(`Workflow catalog activation became stale (${n.reason}).`)},lo,qr=()=>{if(Te.some((o)=>o.manifest.fqn===lo.manifest.fqn))return;Jn([lo])},Mr=()=>co.snapshot(),de=(o)=>{let e=p(o)?{widget:o}:o,n=e.fqn??void 0,t=e.version??void 0,r=On(n,t,"workflow_field");if(r!==void 0)return{entry:r,kind:"resolved",source:"exact"};if(n!==void 0&&t!==void 0){let a=ao("widget",e.widget??"","workflow_field_fallback");if(a!==void 0&&n.toLowerCase().startsWith("builtin."))return{entry:a,kind:"resolved",source:"fallback"};let l={fqn:n,kind:"unavailable"};if(e.widget!==void 0)l.widget=e.widget;return l}let i=ao("widget",e.widget??"","workflow_field_fallback");if(i!==void 0)return{entry:i,kind:"resolved",source:"fallback"};let s={kind:"unavailable"};if(e.fqn!==void 0&&e.fqn!==null)s.fqn=e.fqn;if(e.widget!==void 0)s.widget=e.widget;return s},po=(o)=>{let e=xe(o.kind);if(e===void 0)return{fqn:o.fqn,kind:"unavailable",templateKind:o.kind};let n=On(o.fqn,o.version??"1.0.0","workflow_template_override");if(n!==void 0&&uo(n).kind===e)return{entry:n,kind:"resolved",source:"override"};let t=ao("kind",e,"workflow_template_default");if(t!==void 0)return{entry:t,kind:"resolved",source:"default"};return{fqn:o.fqn,kind:"unavailable",templateKind:o.kind}},Mo;var ce=b(()=>{io();so();so();co=jr(),Te=[],lo=$r({components:ro,manifest:{fqn:"builtin.core",name:"Dashboard Workflow UI",version:"1.0.0"}}),Mo=uo});ce();ke();ce();qe();import{jsx as Pn}from"react/jsx-runtime";var Br=({context:o})=>{let e=de(o.field);if(e.kind==="resolved"&&e.entry.declaration.implementation.configuration!==void 0)return Pn(ne,{componentProps:o,declaration:e.entry.declaration,implementationRole:"configuration",load:()=>te(e.entry.declaration,"configuration")});return Pn("div",{className:"rounded-md border border-dashed border-border p-2 text-xs text-muted-foreground",children:L.unavailableConfiguration(o.field.label)})};_e();Ce();Xe();Ze();import{Textarea as Lr}from"@collective-intelligence/ui-react/ui";import{jsx as Dn}from"react/jsx-runtime";import{createElement as Hr}from"react";var Aa=({help:o,label:e,onValueChange:n,expressionEditor:t,readOnly:r,renderFixed:i,resetKey:s,slotId:a,value:l})=>Dn("div",{"data-expression-slot":a,children:Hr(pe,{allowExpression:!0,...o===void 0?{}:{help:o},...t===void 0?{}:{expressionEditor:t},key:`${a}:${s??"current"}`,label:e,onValueChange:n,...r===void 0?{}:{readOnly:r},renderExpression:({describedBy:d,disabled:c,onChange:x,value:w})=>Dn(Lr,{"aria-describedby":d,"aria-label":`${e} expression`,disabled:c,onChange:(f)=>{x(f.target.value)},placeholder:"{{ input.value }}",value:w}),renderFixed:i,value:l})}),_r=function(e){if(!T(e))return!1;if(e.mode==="fixed")return P(e.value);return e.mode==="expression"&&J(e.languageVersion)&&e.languageVersion===1&&p(e.source)},Ia=function(e){if(_r(e))return e;return{mode:"fixed",value:e}};var fo=function(e,n){let t=[...e];for(let r=0;r<t.length;r+=1)for(let i=r+1;i<t.length;i+=1){let s=t[r],a=t[i];if(s!==void 0&&a!==void 0&&n(s,a)>0)t[r]=a,t[i]=s}return t};var Nn=function(e){return W(e)&&!Array.isArray(e)},Kr=function o(e){return e.flatMap((n)=>[...n.templates??[],...o(n.children??[])])},mo=function(e){return e.kind==="field_collection"&&"collection"in e.contract},go=function(e){return`${e.fqn}@${e.version}`},Rn=function(e){return e.kind==="literal"?e.text:e.default},Ur=function(e){return e.kind==="field"&&"field"in e.contract},zr=function(e,n){if(!e.enabled||e.state!=="available")return!1;return n==="input"?e.contract.field.availableForInput!==!1:e.contract.field.availableForOutput!==!1},Qr=function(e,n){let t=e.find((r)=>mo(r)&&go(r.contract.collection)===n);return t&&mo(t)?t.contract.collection.weight??0:0},Je=function(e){return e!==void 0&&Nn(e)?e:{}},_a=function(e,n){let t=Kr(e?.categories??[]),r=new Map;for(let s of t){if(!mo(s))continue;r.set(go(s.contract.collection),Rn(s.label))}let i=new Map;for(let s of t){if(!Ur(s)||!zr(s,n))continue;let a=s.contract.field,l=go({fqn:a.collectionFqn,version:a.collectionVersion}),d=i.get(l)??{fields:[],key:l,label:r.get(l)??a.collectionFqn,weight:Qr(t,l)};d.fields.push({catalogTemplateId:s.id,collectionKey:l,configSchema:Je(a.configSchema),fqn:a.fqn,label:Rn(s.label),schema:Je(a.valueSchema),version:a.version}),i.set(l,d)}return fo([...i.values()].map((s)=>({...s,fields:fo(s.fields,(a,l)=>a.label.localeCompare(l.label)||a.fqn.localeCompare(l.fqn))})),(s,a)=>s.weight-a.weight||s.label.localeCompare(a.label)||s.key.localeCompare(a.key))},Ha=function(e){return{key:e.key,label:e.label,options:e.fields.map((n)=>({fqn:n.fqn,label:n.label,searchTerms:[n.fqn],version:n.version}))}},Gr=function(e){let n=Je(e.$defs),t=(r,i=new Set)=>{if(Array.isArray(r))return r.map((d)=>t(d,i));if(r===null||!Nn(r))return r;let s=r,a=s.$ref,l=p(a)?a:void 0;if(l!==void 0&&l.startsWith("#/$defs/")){let d=l.slice(8),c=n[d];if(c!==void 0&&c!==null&&!i.has(d))return t(c,new Set(i).add(d))}return Object.fromEntries(Object.entries(s).filter(([d])=>d!=="$defs").map(([d,c])=>[d,t(c,i)]))};return Je(t(e))},Ka=function(e,n){let{title:t,...r}=Gr(n.schema),i={...r};if(p(e.title))i.title=e.title;return i};import{useDebouncedCallback as Yr}from"@collective-intelligence/ui-react/hooks";import{Check as Zr,ChevronsUpDown as Xr}from"@collective-intelligence/ui-react/icons";import{Button as ei,Command as oi,CommandGroup as ni,CommandInput as ti,CommandItem as ri,CommandList as ii,Popover as si,PopoverContent as ai,PopoverTrigger as li}from"@collective-intelligence/ui-react/ui";import{useMemo as di,useState as xo}from"react";import{jsx as M,jsxs as ye}from"react/jsx-runtime";var ci=250,yo=function(e){return`${e.fqn}@${e.version}`},ui=function(e,n){let t=n.trim().toLocaleLowerCase();if(!t)return e;return e.flatMap((r)=>{let i=r.options.filter((s)=>[s.label,s.fqn,...s.searchTerms??[]].join(" ").toLocaleLowerCase().includes(t));return i.length?[{...r,options:i}]:[]})},Za=({collections:o,value:e,onChange:n,ariaLabel:t="Field type"})=>{let[r,i]=xo(!1),[s,a]=xo(""),[l,d]=xo(""),c=Yr(d,ci),x=o.flatMap((m)=>m.options).find((m)=>yo(m)===e),w=di(()=>ui(o,l),[o,l]),f=w.some((m)=>m.options.length>0);return ye(si,{modal:!0,open:r,onOpenChange:(m)=>{if(i(m),!m)c.cancel(),a(""),d("")},children:[M(li,{asChild:!0,children:ye(ei,{type:"button",variant:"outline","aria-label":t,"aria-expanded":r,className:"mt-1 w-full justify-between font-normal",children:[M("span",{className:"truncate",children:x?.label??"Select a field type"}),M(Xr,{className:"ml-2 size-4 shrink-0 opacity-50"})]})}),M(ai,{align:"start",className:"w-[var(--radix-popover-trigger-width)] p-0",children:ye(oi,{shouldFilter:!1,children:[M(ti,{placeholder:"Search field types...",value:s,onValueChange:(m)=>{a(m),c(m)}}),ye(ii,{children:[f?null:M("p",{className:"py-6 text-center text-sm",children:"No field type found."}),w.map((m)=>M(ni,{heading:m.label,children:m.options.map((u)=>{let h=yo(u);return ye(ri,{value:yo(u),onSelect:()=>{n(u),i(!1)},children:[M(Zr,{className:e===h?"mr-2 size-4 opacity-100":"mr-2 size-4 opacity-0"}),u.label]},h)})},m.key))]})]})})]})};je();we();io();no();ke();ce();import{jsx as An,jsxs as fi}from"react/jsx-runtime";var pi=({context:o})=>{let e=po(o.template);if(e.kind==="resolved")return An(ne,{componentProps:o,declaration:e.entry.declaration,implementationRole:"details",load:()=>te(e.entry.declaration,"details")});return fi("div",{className:"rounded-xl border border-dashed border-border p-4 text-sm text-muted-foreground",children:["No dashboard editor is available for template kind"," ",An("code",{children:e.templateKind}),". The workflow draft has not been changed."]})};var bo=(o)=>o!==void 0&&o!==null&&W(o)&&!Array.isArray(o),In=function(e,n){return Object.fromEntries(Object.entries(e).filter(([t])=>t!==n))},jn=function(e){if(e==="input_binding")return"inputs";if(e==="setting")return"settings";if(e==="metadata")return"metadata";return"config"},re=function(e){return bo(e)?e:void 0},ko=function(e){let n=re(e);if(n===void 0||!("value"in n))return e;return n.mode==="fixed"||n.kind==="literal"?n.value:e},Pe=function(e,n){let t=e[jn(n.target)];for(let r of n.path){let i=re(ko(t));if(i===void 0)return;t=i[r]}return ko(t)},mi=function(e,n){return Pe(e,n.binding)},gi=function o(e,n,t){let[r,...i]=n;if(r===void 0)return e??{};let s=e??{};if(!i.length)return{...s,[r]:t};let a=re(s[r]),l=re(ko(a));if(a?.mode==="fixed")return{...s,[r]:{...a,value:o(l,i,t)}};return{...s,[r]:o(l,i,t)}},wo=function(e,n){return[e==="input_binding"?"inputBinding":e,...n].map((t)=>encodeURIComponent(String(t))).join("/")},xi=function(e,n,t){let r={...re(e?.fieldDisplayValues)},i=wo(n.binding.target,n.binding.path);if(t)r[i]=t;else return{...e,fieldDisplayValues:In(r,i)};return{...e,fieldDisplayValues:r}},yi=function(e,n,t,r){let i=jn(n.binding.target),s={[i]:gi(e[i],n.binding.path,t)};if(r!==void 0)s.metadata=xi(i==="metadata"?s.metadata:e.metadata,n,r);return s},$n=function(e,n,t){let r=e.metadata?.fieldDisplayValues;if(r===void 0||r===null||!bo(r))return;let i=r[wo(n.binding.target,t)];if(i===void 0||i===null||!bo(i))return;return p(i.label)&&"value"in i?{label:i.label,value:i.value}:void 0},bi=function(e,n){return $n(e,n,n.binding.path)},ki=function(e,n,t){return $n(e,n,[...n.binding.path,...t])},wi=function(e,n,t,r){let i={...re(e?.fieldDisplayValues)},s=wo(n,t);if(r)i[s]=r;else return{...e,fieldDisplayValues:In(i,s)};return{...e,fieldDisplayValues:i}},hi=function(e,n,t,r){return{metadata:wi(e.metadata,n.binding.target,[...n.binding.path,...t],r)}};var ho=function o(e,n){if(Array.isArray(e)||Array.isArray(n))return Array.isArray(e)&&Array.isArray(n)&&e.length===n.length&&e.every((t,r)=>o(t,n[r]));if(e!==null&&n!==null&&e!==void 0&&n!==void 0&&W(e)&&W(n)){let t=Object.keys(e);return t.length===Object.keys(n).length&&t.every((r)=>o(e[r],n[r]))}return e===n},qn=function(e){return e!==void 0&&e!==null&&e!==""},vi=function(e,n){if(!Array.isArray(n)||e===void 0)return!1;return(Array.isArray(e)?e:[e]).some((r)=>n.some((i)=>ho(r,i)))},Wi=function(e,n){return(e.visibleWhen??[]).every((t)=>{let r=Pe(n,t.binding);switch(t.operator){case"equals":return ho(r,t.value);case"not_equals":return!ho(r,t.value);case"is_set":return qn(r);case"is_not_set":return!qn(r);case"in":return vi(r,t.value);default:return!1}})};var Ci=function(e){if(!e)return"";return e.kind==="literal"?e.text:e.default};Ce();Se();Fe();$e();export{oe as CatalogNodeChartBlock,_ as CatalogNodeDetailsEditor,Ye as ExpressionEditor,Aa as ExpressionSlot,Qe as ExpressionSyntaxReference,Za as FieldTypeSelect,Br as WorkflowFieldConfigurationResolver,pe as WorkflowFieldFrame,Le as WorkflowFieldResolver,pi as WorkflowTemplateDetails,qr as activateDashboardWorkflowCatalog,Jn as activateWorkflowCatalog,Ia as asExpressionSlotValue,Ci as catalogText,Ui as configureWorkflowFieldOptionsProvider,hs as createExpressionDraft,lo as dashboardWorkflowPackage,ro as defaultWorkflowTemplateDeclarations,ze as expressionSourceOptions,_a as fieldCollectionsFromCatalog,yo as fieldTypeIdentity,Zo as insertExpressionAtCursor,se as isBoolean,Hn as isFunction,P as isJsonValue,J as isNumber,W as isObject,T as isRecord,Ws as isSchemaCompatible,p as isString,Si as isUndefined,Wi as isWorkflowFieldVisible,Kt as normalizeExpressionEnvironment,Ut as normalizeExpressionValidation,xe as parseWorkflowTemplateKind,hi as patchWorkflowFieldPartDisplayValue,yi as patchWorkflowFieldValue,Pe as readWorkflowBindingValue,bi as readWorkflowFieldDisplayValue,ki as readWorkflowFieldPartDisplayValue,mi as readWorkflowFieldValue,wn as renderDefaultActionChart,hn as renderDefaultActionDetails,Cn as renderDefaultInputChart,Fn as renderDefaultInputDetails,Sn as renderDefaultOutputChart,En as renderDefaultOutputDetails,vn as renderDefaultTriggerChart,Wn as renderDefaultTriggerDetails,de as resolveWorkflowField,po as resolveWorkflowTemplate,Ka as schemaForWorkflowField,U as schemaLabel,vs as serializeExpressionDraft,Ei as toDisplayString,Ha as toFieldTypeCollection,Mr as workflowCatalogSnapshot,le as workflowFieldOptions,zi as workflowFieldOptionsInfinite};
|
|
@@ -50,6 +50,16 @@ export interface WorkflowTemplateChartData {
|
|
|
50
50
|
connectedOutputPortKeys?: readonly string[];
|
|
51
51
|
}
|
|
52
52
|
export interface WorkflowFieldComponentContext {
|
|
53
|
+
/** Host-bound member picker. Emits IDs only; the Host owns authorized lookup. */
|
|
54
|
+
userSelection?: (props: {
|
|
55
|
+
multiple: boolean;
|
|
56
|
+
value: JsonValue;
|
|
57
|
+
onChange: (value: JsonValue) => void;
|
|
58
|
+
controlId?: string;
|
|
59
|
+
labelledBy?: string;
|
|
60
|
+
readOnly: boolean;
|
|
61
|
+
required: boolean;
|
|
62
|
+
}) => ReactNode;
|
|
53
63
|
field: WorkflowFormField;
|
|
54
64
|
value: JsonValue;
|
|
55
65
|
readOnly: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@collective-intelligence/extensions-sdk-frontend-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "Public hosted React contribution contracts for Collective Intelligence extensions.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -70,11 +70,11 @@
|
|
|
70
70
|
"type-check": "bun check"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@collective-intelligence/extensions-sdk": "0.1.
|
|
74
|
-
"@collective-intelligence/extensions-sdk-frontend": "0.1.
|
|
73
|
+
"@collective-intelligence/extensions-sdk": "0.1.13",
|
|
74
|
+
"@collective-intelligence/extensions-sdk-frontend": "0.1.13"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@collective-intelligence/ui-react": "0.1.
|
|
77
|
+
"@collective-intelligence/ui-react": "0.1.13",
|
|
78
78
|
"@tanstack/react-query": ">=5 <6",
|
|
79
79
|
"@xyflow/react": ">=12 <13",
|
|
80
80
|
"react": ">=18 <20",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"access": "public"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
|
-
"@collective-intelligence/ui-react": "0.1.
|
|
92
|
+
"@collective-intelligence/ui-react": "0.1.13",
|
|
93
93
|
"@hey-api/openapi-ts": "^0.96.0",
|
|
94
94
|
"@oxlint/plugins": "1.85.0",
|
|
95
95
|
"@tanstack/react-query": "5.101.4",
|