PageSourceSearch

https://ultimatenexus.ai/assets/view-workflow-templates-CtuW2BEV.js

js ultimatenexus.ai collected 2026-10-05 13:11:23 UTC 25,419 bytes, 1 lines download raw bytes

1import{R as Ne,j as e,r as a,c as F,aE as we,aU as ve,al as T,af as ye,U as de,F as Ce,e as ke,aX as Se,aY as y,aZ as Ee,a_ as Te,Z as ne,l as ze,Y as Ae,am as Re,X as ie,a8 as oe,N as Le,Q as We}from"./vendor-DG5Dz7Ik.js";import{l as Ie,g as Ve,A as o,i as _e}from"./view-workflow-builder-CDc7AhbV.js";import{V as $e}from"./shared-components-CRZb49ua.js";import"./view-analytics-BkPD6vG9.js";import"./pdf-vendor-BQyayL6K.js";import"./socket-vendor-DENoLIvz.js";import"./auth-vendor-CeReGQmr.js";const G={content:{icon:Ce,color:"from-blue-500 to-cyan-500",label:"Content"},social_media:{icon:de,color:"from-pink-500 to-purple-500",label:"Social Media"},lead_nurture:{icon:ye,color:"from-green-500 to-emerald-500",label:"Lead Nurture"},crisis_response:{icon:T,color:"from-red-500 to-orange-500",label:"Crisis Response"},analytics:{icon:ve,color:"from-yellow-500 to-amber-500",label:"Analytics"},competitive:{icon:we,color:"from-purple-500 to-indigo-500",label:"Competitive"},custom:{icon:F,color:"from-slate-500 to-slate-600",label:"Custom"}},Oe=({orgId:x,projectId:z,onTemplateInstantiated:C})=>{var le,ae,re;
1const[p,H]=a.useState([]),[M,q]=a.useState(!0),[U,D]=a.useState(null),[k,h]=a.useState(null),j=a.useRef(0),A=a.useRef(!0);a.useEffect(()=>(A.current=!0,()=>{A.current=!1,j.current++}),[]);const[b,Y]=a.useState(""),[m,R]=a.useState(null),[u,L]=a.useState([]),[S,B]=a.useState(!1),[d,g]=a.useState(null),[ce,Q]=a.useState(!1),[c,N]=a.useState(null),[W,Z]=a.useState(""),[I,J]=a.useState({}),[w,V]=a.useState({}),[v,K]=a.useState(!1),[_,X]=a.useState(null),[xe,me]=a.useState(3),$=a.useRef(null),[ue,he]=a.useState(600);a.useEffect(()=>{const s=()=>{const t=window.innerWidth;me(t>=1024?3:t>=768?2:1)};return s(),window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[]),a.useEffect(()=>{const s=()=>{if($.current){const t=$.current.getBoundingClientRect(),r=window.innerHeight-t.top-24;he(Math.max(400,r))}};return s(),window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[M]);const O=a.useCallback(async()=>{const s=++j.current;q(!0),D(null);try{const t=await Promise.race([Ie({orgId:x,category:m||void 0,tags:u.length>0?u:void 0,isPublic:S||void 0,limit:100}),new Promise((r,l)=>setTimeout(()=>l(new Error("Request timeout - templates API may be unavailable")),1e4))]);s===j.current&&H(t.templates)}catch(t){s===j.current&&(D(t instanceof Error?t.message:"Unable to load templates."),H([]))}finally{s===j.current&&q(!1)}},[x,m,u,S]);a.useEffect(()=>{O()},[O]);const ee=a.useMemo(()=>{const s=new Set;return p.forEach(t=>{var r;(r=t.tags)==null||r.forEach(l=>s.add(l))}),Array.from(s).sort()},[p]),E=a.useMemo(()=>{if(!b.trim())return p;const s=b.toLowerCase();return p.filter(t=>{var r;return t.name.toLowerCase().includes(s)||t.description.toLowerCase().includes(s)||((r=t.tags)==null?void 0:r.some(l=>l.toLowerCase().includes(s)))})},[p,b]),be=a.useCallback(async s=>{g(s),Q(!0),h(null);try{const t=await Ve({orgId:x,templateId:s.id});g(t.template)}catch(t){h(t instanceof Error?t.message:"Unable to load template details."),g(null)}finally{Q(!1)}},[x]),se=a.useCallback(s=>{var r;h(null),N(s),Z(`${s.name} - ${new Date().toLocaleDateString()}`);const t={};(r=s.variables)==null||r.forEach(l=>{l.defaultValue!==void 0&&(t[l.name]=l.defaultValue)}),J(t),V({}),X(null),g(null)},[]),ge=()=>{var r;const s={};let t=!0;return(r=c==null?void 0:c.variables)==null||r.forEach(l=>{const i=I[l.name];if(l.required&&(i==null||i==="")){s[l.name]=`${l.label||l.name} is required`,t=!1;return}if(i!=null&&i!==""&&(l.type==="number"&&isNaN(Number(i))&&(s[l.name]=`${l.label||l.name} must be a valid number`,t=!1),l.type==="select"&&l.options)){const n=l.options.map(je=>je.value),P=typeof i=="boolean"?String(i):typeof i=="string"||typeof i=="number"?i:String(i);n.includes(P)||(s[l.name]=`${l.label||l.name} must be one of the available options`,t=!1)}}),V(s),t},fe=async()=>{if(c){if(!z){h("Choose a business before creating a workflow.");return}if(ge()){K(!0),h(null);try{const s=await _e({orgId:x,templateId:c.id,projectId:z,name:W,variables:I});if(!A.current)return;X(s.workflow.id),C&&C(s.workflow.id)}catch(s){h(s instanceof Error?s.message:"Failed to create workflow from template")}finally{K(!1)}}}},f=(s,t)=>{J(r=>({...r,[s]:t})),w[s]&&V(r=>{const l={...r};return delete l[s],l})},pe=s=>{var i;const t=I[s.name]??s.defaultValue??"",r=!!w[s.name],l=`w-full px-3 py-2 bg-slate-800 border ${r?"border-red-500":"border-slate-700"} rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 ${r?"focus:ring-red-500":"focus:ring-nexus-500"} transition-all`;switch(s.type){case"string":return e.jsx("input",{type:"text",value:String(t),onChange:n=>f(s.name,n.target.value),placeholder:s.description||`Enter ${s.label}`,className:l});case"number":return e.jsx("input",{type:"number",value:typeof t=="number"?t:String(t),onChange:n=>{const P=n.target.value===""?"":parseFloat(n.target.value);f(s.name,P)},placeholder:s.description||`Enter ${s.label}`,className:l});case"boolean":return e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"checkbox",checked:!!t,onChange:n=>
1f(s.name,n.target.checked?1:0),className:"sr-only peer"}),e.jsx("div",{className:"w-11 h-6 bg-slate-700 rounded-full peer peer-checked:bg-nexus-500 transition-all"}),e.jsx("div",{className:"absolute left-1 top-1 w-4 h-4 bg-white rounded-full transition-all peer-checked:translate-x-5"})]}),e.jsx("span",{className:"text-sm text-slate-300",children:s.description||"Enable this option"})]});case"select":return e.jsxs("select",{value:String(t),onChange:n=>f(s.name,n.target.value),className:l,children:[e.jsxs("option",{value:"",children:["Select ",s.label]}),(i=s.options)==null?void 0:i.map(n=>e.jsx("option",{value:String(n.value),children:n.label},String(n.value)))]});case"agent_role":return e.jsxs("select",{value:String(t),onChange:n=>f(s.name,n.target.value),className:l,children:[e.jsx("option",{value:"",children:"Select agent role"}),e.jsx("option",{value:o.PROJECT_MANAGER,children:o.PROJECT_MANAGER}),e.jsx("option",{value:o.STRATEGIST,children:o.STRATEGIST}),e.jsx("option",{value:o.CONTENT_CREATOR,children:o.CONTENT_CREATOR}),e.jsx("option",{value:o.ANALYST,children:o.ANALYST}),e.jsx("option",{value:o.SOCIAL_MANAGER,children:o.SOCIAL_MANAGER}),e.jsx("option",{value:o.PR_SPECIALIST,children:o.PR_SPECIALIST}),e.jsx("option",{value:o.LEGAL_ADVISOR,children:o.LEGAL_ADVISOR}),e.jsx("option",{value:o.GROWTH_HACKER,children:o.GROWTH_HACKER})]});default:return e.jsx("input",{type:"text",value:String(t),onChange:n=>f(s.name,n.target.value),placeholder:s.description||`Enter ${s.label}`,className:l})}},te=a.useCallback(s=>G[s]||G.custom,[]);return e.jsxs("div",{className:"h-full flex flex-col bg-slate-950 text-slate-100",children:[k&&!c&&e.jsx("p",{role:"alert",className:"m-4 rounded-lg border border-red-500/30 p-3 text-red-300",children:k}),e.jsxs("div",{className:"p-6 border-b border-slate-800 bg-gradient-to-br from-slate-900 to-slate-950",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-3xl font-bold text-white flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-gradient-to-br from-nexus-500 to-blue-600 flex items-center justify-center",children:e.jsx(F,{size:24,className:"text-white"})}),"Workflow Templates"]}),e.jsx("p",{className:"text-slate-300 mt-2",children:"Workspace template library · create a disabled draft for the selected business, then review it before activation."})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("span",{className:"text-sm text-slate-300",children:[E.length," template",E.length!==1?"s":""]})})]}),e.jsxs("div",{className:"flex flex-col lg:flex-row gap-4",children:[e.jsxs("div",{className:"flex-1 relative",role:"search","aria-label":"Search workflow templates",children:[e.jsx(ke,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-300",size:20}),e.jsx("input",{type:"text",value:b,onChange:s=>Y(s.target.value),placeholder:"Search templates...","aria-label":"Search workflow templates",className:"w-full pl-10 pr-4 py-2.5 bg-slate-900 border border-slate-700 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-nexus-500 transition-all"})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{onClick:()=>R(null),"aria-pressed":m===null,"aria-label":"Filter by all categories",className:`px-4 py-2 rounded-lg text-sm font-semibold transition-all ${m===null?"bg-gradient-to-br from-nexus-500 to-blue-600 text-white":"bg-slate-800 text-slate-300 hover:bg-slate-700"}`,children:"All"}),Object.entries(G).map(([s,t])=>{const r=t.icon;return e.jsxs("button",{onClick:()=>R(s),"aria-pressed":m===s,"aria-label":`Filter by ${t.label} category`,className:`px-4 py-2 rounded-lg text-sm font-semibold transition-all flex items-center gap-2 ${m===s?`bg-gradient-to-br ${t.color} text-white`:"bg-slate-800 text-slate-300 hover:bg-slate-700"}`,children:[e.jsx(r,{size:16}),t.label]},s)})]}),e.jsxs("label",{className:"flex items-center gap-3 px-4 py-2 bg-slate-900 border border-slate-700 rounded-lg cursor-pointer hover:bg-slate-800 transition-all",children:[e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"checkbox",checked:S,onChange:s=>B(s.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-11 h-6 bg-slate-700 rounded-full peer peer-checked:bg-nexus-500 transition-all"}),e.jsx("div",{className:"absolute left-1 top-1 w-4 h-4 bg-white rounded-full transition-all peer-checked:translate-x-5"})]}),e.jsx("span",{className:"text-sm text-slate-300 whitespace-nowrap",children:"Public Only"})]})]}),ee.length>0&&e.jsxs("div",{className:"mt-4 flex items-center gap-2 flex-wrap",children:[e.jsx(Se,{size:16,className:"text-slate-300"}),e.jsx("span",{className:"text-xs text-slate-300",children:"Tags:"}),ee.map(s=>e.jsx("button",{onClick:()=>{L(t=>t.includes(s)?t.filter(r=>r!==s):[...t,s])},"aria-pressed":u.includes(s),"aria-label":`Filter by tag: ${s}`,className:`px-2 py-1 rounded-md text-xs font-medium transition-all ${u.includes(s)?"bg-nexus-600 text-white":"bg-slate-800 text-slate-300 hover:bg-slate-700"}`,children:s},s)),u.length>0&&e.jsx("button",{onClick:()=>L([]),"aria-label":"Clear all tag filters",className:"px-2 py-1 text-xs text-red-400 hover:text-red-300 transition-colors",children:"Clear"})]})]}),e.jsx("div",{ref:$,className:"flex-1 min-h-0 p-6",children:M?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[...Array(6)].map((s,t)=>e.jsxs("div",{className:"bg-slate-900 border border-slate-800 rounded-xl overflow-hidden animate-pulse",children:[e.jsx("div",{className:"h-32 bg-slate-800"}),e.jsxs("div",{className:"p-4",children:[e.jsx("div",{className:"h-6 bg-slate-800 rounded w-3/4 mb-2"}),e.jsx("div",{className:"h-4 bg-slate-800 rounded w-full mb-1"}),e.jsx("div",{className:"h-4 bg-slate-800 rounded w-2/3 mb-4"}),e.jsxs("div",{className:"flex gap-1.5 mb-4",children:[e.jsx("div",{className:"h-6 w-16 bg-slate-800 rounded-md"}),e.jsx("div",{className:"h-6 w-20 bg-slate-800 rounded-md"}),e.jsx("div",{className:"h-6 w-14 bg-slate-800 rounded-md"})]}),e.jsxs("div",{className:"flex gap-4 mb-4",children:[e.jsx("div",{className:"h-4 w-16 bg-slate-800 rounded"}),e.jsx("div",{className:"h-4 w-20 bg-slate-800 rounded"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"flex-1 h-10 bg-slate-800 rounded-lg"}),e.jsx("div",{className:"flex-1 h-10 bg-slate-800 rounded-lg"})]})]})]},t))}):U?e.jsx("div",{className:"p-6 bg-red-500/10 border border-red-500/30 rounded-xl",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(T,{size:20,className:"text-red-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-red-300 mb-1",children:"Failed to Load Templates"}),e.jsx("p",{className:"text-sm text-red-400/80",children:U}),e.jsx("button",{onClick:O,className:"mt-3 px-4 py-2 bg-red-600 hover:bg-red-500 text-white rounded-lg text-sm font-semibold transition-all",children:"Try Again"})]})]})}):E.length===0?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsxs("div",{className:"text-center",children:[e.jsx(F,{size:48,className:"text-slate-600 mx-auto mb-4"}),e.jsx("h3",{className:"text-xl font-bold text-slate-300 mb-2",children:"No templates found"}),e.jsx("p",{className:"text-slate-400 mb-4",children:b||m||u.length>0?"Try adjusting your filters or search query":"No workflow templates are available yet"}),(b||m||u.length>0||S)&&e.jsx("button",{onClick:()=>{Y(""),R(null),L([]),B(!1)},className:"mr-3 rounded-lg border border-slate-700 px-4 py-2 text-slate-200",children:"Clear filters"}),e.jsxs("a",{href:"/workflows/builder",className:"inline-flex items-center gap-2 px-4 py-2 bg-gradient-to-br from-nexus-500 to-blue-600 hover:from-nexus-600 hover:to-blue-700 text-white rounded-lg text-sm font-semibold transition-all",children:[e.jsx(y,{size:16}),"Build a Workflow"]})]})}):e.jsx($e,{items:E,itemHeight:340,containerHeight:ue,columns:xe,gap:24,overscan:2,emptyMessage:"No templates available",renderItem:s=>{var l,i;const t=te(s.category),r=t.icon;return e.jsxs("div",{className:"group relative bg-slate-900 border border-slate-800 rounded-xl overflow-hidden hover:border-nexus-500/50 transition-all hover:shadow-lg hover:shadow-nexus-500/10 h-full",children:[e.jsxs("div",{className:`h-32 bg-gradient-to-br ${t.color} relative`,children:[e.jsx("div",{className:"absolute inset-0 bg-black/20"}),e.jsxs("div",{className:"absolute bottom-3 left-3 flex items-center gap-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-white/20 backdrop-blur-sm flex items-center justify-center",children:e.jsx(r,{size:20,className:"text-white"})}),e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-2",children:[s.isSystemTemplate&&e.jsx("span",{className:"text-xs px-2 py-0.5 bg-white/20 backdrop-blur-sm rounded-full text-white font-medium",children:"Official"}),s.isPublic?e.jsx(Ee,{size:12,className:"text-white/80"}):e.jsx(Te,{size:12,className:"text-white/80"})]})})]})]}),e.jsxs("div",{className:"p-4",children:[e.jsx("h3",{className:"text-lg font-bold text-white mb-2 line-clamp-1",children:s.name}),e.jsx("p",{className:"text-sm text-slate-300 mb-4 line-clamp-2",children:s.description}),s.tags&&s.tags.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-4",children:[s.tags.slice(0,3).map(n=>e.jsx("span",{className:"px-2 py-0.5 bg-slate-800 text-slate-300 text-xs rounded-md",children:n},n)),s.tags.length>3&&e.jsxs("span",{className:"px-2 py-0.5 bg-slate-800 text-slate-300 text-xs rounded-md",children:["+",s.tags.length-3]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-slate-400 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ne,{size:12}),((l=s.steps)==null?void 0:l.length)||0," steps"]}),((i=s.trigger)==null?void 0:i.type)&&e.jsxs("div",{className:"flex items-center gap-1",children:[s.trigger.type==="scheduled"?e.jsx(ze,{size:12}):s.trigger.type==="event"?e.jsx(ne,{size:12}):e.jsx(Ae,{size:12}),s.trigger.type]}),s.usageCount!==void 0&&s.usageCount>0&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(de,{size:12}),s.usageCount," uses"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:()=>be(s),className:"flex-1 flex items-center justify-center gap-2 px-3 py-2 bg-slate-800 hover:bg-slate-700 text-slate-300 hover:text-white rounded-lg text-sm font-semibold transition-all",children:[e.jsx(Re,{size:16}),"Preview"]}),e.jsxs("button",{onClick:()=>se(s),className:"flex-1 flex items-center justify-center gap-2 px-3 py-2 bg-gradient-to-br from-nexus-500 to-blue-600 hover:from-nexus-600 hover:to-blue-700 text-white rounded-lg text-sm font-semibold transition-all shadow-lg shadow-nexus-500/20 hover:shadow-nexus-500/30",children:[e.jsx(y,{size:16}),"Use Template"]})]})]})]},s.id)}})}),d&&e.jsx("div",{className:"fixed inset-0 z-[70] flex items-center justify-center p-4 bg-black/90 backdrop-blur-md",children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"preview-modal-title",className:"bg-slate-900 rounded-2xl border border-slate-800 w-full max-w-4xl overflow-hidden shadow-2xl flex flex-col max-h-[90vh]",children:[e.jsx("div",{className:"p-6 border-b border-slate-800 bg-gradient-to-br from-slate-900 to-slate-950",children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{id:"preview-modal-title",className:"text-2xl font-bold text-white mb-2",children:d.name}),e.jsx("p",{className:"text-slate-300",children:d.description})]}),e.jsx("button",{onClick:()=>g(null),"aria-label":"Close template preview",className:"text-slate-300 hover:text-white transition-colors p-2 hover:bg-slate-800 rounded-lg",children:e.jsx(ie,{size:24})})]})}),e.jsx("div",{className:"p-6 overflow-y-auto flex-1 bg-slate-950",children:ce?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(oe,{size:32,className:"text-nexus-500 animate-spin"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-white mb-3",children:"Details"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[(()=>{const s=te(d.category),t=s.icon;return e.jsxs("div",{className:`px-3 py-1.5 rounded-lg bg-gradient-to-br ${s.color} text-white text-sm font-medium flex items-center gap-2`,children:[e.jsx(t,{size:14}),s.label]})})(),(le=d.tags)==null?void 0:le.map(s=>e.jsx("span",{className:"px-3 py-1.5 bg-slate-800 text-slate-300 text-sm rounded-lg",children:s},s))]})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-semibold text-white mb-3",children:["Workflow Steps (",((ae=d.steps)==null?void 0:ae.length)||0,")"]}),e.jsx("div",{className:"space-y-2",children:(re=d.steps)==null?void 0:re.map((s,t)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 bg-slate-900 rounded-lg border border-slate-800",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-nexus-600 flex items-center justify-center flex-shrink-0 text-white text-sm font-bold",children:t+1}),e.jsx("div",{className:"flex-1",children:e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h4",{className:"text-sm font-semibold text-white",children:s.label}),e.jsx("span",{className:"px-2 py-0.5 bg-slate-800 text-slate-300 text-xs rounded",children:s.type})]})})]},s.id))})]}),d.variables&&d.variables.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-semibold text-white mb-3",children:["Customization Options (",d.variables.length,")"]}),e.jsx("div",{className:"space-y-2",children:d.variables.map(s=>e.jsx("div",{className:"flex items-start gap-3 p-3 bg-slate-900 rounded-lg border border-slate-800",children:e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h4",{className:"text-sm font-semibold text-white",children:s.label}),s.required&&e.jsx("span",{className:"text-red-400 text-xs",children:"*"}),e.jsx("span",{className:"px-2 py-0.5 bg-slate-800 text-slate-300 text-xs rounded",children:s.type})]}),s.description&&e.jsx("p",{className:"text-xs text-slate-300",children:s.description})]})},s.name))})]})]})}),e.jsxs("div",{className:"p-6 border-t border-slate-800 flex justify-end gap-3 bg-slate-900/50",children:[e.jsx("button",{onClick:()=>g(null),className:"px-4 py-2 bg-slate-800 hover:bg-slate-700 text-white rounded-lg text-sm font-semibold transition-all border border-slate-700 hover:border-slate-600",children:"Close"}),e.jsxs("button",{onClick:()=>se(d),className:"flex items-center gap-2 px-4 py-2 bg-gradient-to-br from-nexus-500 to-blue-600 hover:from-nexus-600 hover:to-blue-700 text-white rounded-lg text-sm font-semibold transition-all shadow-lg shadow-nexus-500/20 hover:shadow-nexus-500/30",children:[e.jsx(y,{size:16}),"Use This Template"]})]})]})}),c&&e.jsx("div",{className:"fixed inset-0 z-[70] flex items-center justify-center p-4 bg-black/90 backdrop-blur-md",children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"instantiate-modal-title",className:"bg-slate-900 rounded-2xl border border-slate-800 w-full max-w-3xl overflow-hidden shadow-2xl flex flex-col max-h-[90vh]",children:[e.jsx("div",{className:"p-6 border-b border-slate-800 bg-gradient-to-br from-slate-900 to-slate-950",children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("h2",{id:"instantiate-modal-title",className:"text-2xl font-bold text-white mb-2 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-gradient-to-br from-nexus-500 to-blue-600 flex items-center justify-center",children:e.jsx(y,{size:20,className:"text-white"})}),"Create Workflow from Template"]}),e.jsx("p",{className:"text-slate-300",children:c.name}),e.jsx("p",{className:"mt-2 text-sm text-amber-200",children:"Creates a draft for this business. It will not run until you explicitly activate or run it."})]}),e.jsx("button",{onClick:()=>!v&&N(null),disabled:v,"aria-label":"Close workflow creation dialog",className:"text-slate-300 hover:text-white transition-colors p-2 hover:bg-slate-800 rounded-lg disabled:opacity-50 disabled:cursor-not-allowed",children:e.jsx(ie,{size:24})})]})}),e.jsx("div",{className
1:"p-6 overflow-y-auto flex-1 bg-slate-950",children:_?e.jsx("div",{className:"p-6 bg-green-500/10 border border-green-500/30 rounded-xl",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-lg bg-gradient-to-br from-green-500 to-green-600 flex items-center justify-center flex-shrink-0",children:e.jsx(Le,{size:24,className:"text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-xl font-bold text-green-300 mb-2",children:"Workflow Created Successfully!"}),e.jsx("p",{className:"text-sm text-green-400/80 mb-4",children:"Your workflow has been created from the template and is ready to use."}),e.jsxs("button",{onClick:()=>{C&&C(_),N(null)},className:"flex items-center gap-2 px-4 py-2 bg-green-600 hover:bg-green-500 text-white rounded-lg text-sm font-semibold transition-all",children:["Go to Workflow",e.jsx(We,{size:16})]})]})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-semibold text-white mb-2",children:["Workflow Name ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{type:"text",value:W,onChange:s=>Z(s.target.value),placeholder:"Enter workflow name",className:"w-full px-3 py-2 bg-slate-800 border border-slate-700 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-nexus-500 transition-all"})]}),c.variables&&c.variables.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-white mb-4",children:"Customize Template Variables"}),e.jsx("div",{className:"space-y-4",children:c.variables.map(s=>e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:[s.label,s.required&&e.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),pe(s),w[s.name]&&e.jsxs("p",{className:"mt-1 text-xs text-red-400 flex items-center gap-1",children:[e.jsx(T,{size:12}),w[s.name]]}),s.description&&!w[s.name]&&e.jsx("p",{className:"mt-1 text-xs text-slate-400",children:s.description})]},s.name))})]}),k&&e.jsx("div",{className:"p-4 bg-red-500/10 border border-red-500/30 rounded-xl",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(T,{size:20,className:"text-red-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-red-300 mb-1",children:"Failed to Create Workflow"}),e.jsx("p",{className:"text-sm text-red-400/80",children:k})]})]})})]})}),e.jsx("div",{className:"p-6 border-t border-slate-800 flex justify-end gap-3 bg-slate-900/50",children:_?e.jsx("button",{onClick:()=>N(null),className:"px-4 py-2 bg-gradient-to-br from-nexus-500 to-blue-600 hover:from-nexus-600 hover:to-blue-700 text-white rounded-lg text-sm font-semibold transition-all",children:"Close"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>N(null),disabled:v,className:"px-4 py-2 bg-slate-800 hover:bg-slate-700 disabled:bg-slate-900 disabled:cursor-not-allowed text-white rounded-lg text-sm font-semibold transition-all border border-slate-700 hover:border-slate-600",children:"Cancel"}),e.jsx("button",{onClick:fe,disabled:v||!W.trim()||!z,className:"flex items-center gap-2 px-4 py-2 bg-gradient-to-br from-nexus-500 to-blue-600 hover:from-nexus-600 hover:to-blue-700 disabled:from-slate-700 disabled:to-slate-800 disabled:cursor-not-allowed text-white rounded-lg text-sm font-semibold transition-all shadow-lg shadow-nexus-500/20 hover:shadow-nexus-500/30",children:v?e.jsxs(e.Fragment,{children:[e.jsx(oe,{size:16,className:"animate-spin"}),"Creating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(y,{size:16}),"Create Workflow"]})})]})})]})})]})},Pe=x=>e.jsx(Oe,{...x},`${x.orgId}:${x.projectId??"workspace"}`),Ye=Ne.memo(Pe);export{Ye as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.