UNPKG

n8n-editor-ui

Version:

Workflow Editor UI for n8n

6 lines 6.72 kB
(function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`n8n@2.16.1`}}catch{}})();try{(function(){var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`147ba636-013d-413d-969d-fa2080f6d273`,e._sentryDebugIdIdentifier=`sentry-dbid-147ba636-013d-413d-969d-fa2080f6d273`)})()}catch{}import{Qr as e}from"./constants-DuQbSl-q.js";import{c as t}from"./constants-BVzsnVB6.js";function n(e,t){let n=new Date(t),r=new Date(e.getFullYear(),e.getMonth(),e.getDate()),i=new Date(r);i.setDate(i.getDate()-1);let a=new Date(r);a.setDate(a.getDate()-7);let o=new Date(n.getFullYear(),n.getMonth(),n.getDate());return o.getTime()===r.getTime()?`Today`:o.getTime()===i.getTime()?`Yesterday`:o>=a?`This week`:`Older`}function r(e){let t=new Date,r=new Map;for(let i of e){let e=n(t,i.lastMessageAt??i.updatedAt);r.has(e)||r.set(e,[]),r.get(e).push(i)}return[`Today`,`Yesterday`,`This week`,`Older`].flatMap(e=>{let t=r.get(e)??[];return t.length>0?[{group:e,sessions:t.sort((e,t)=>Date.parse(t.lastMessageAt??t.updatedAt)-Date.parse(e.lastMessageAt??e.updatedAt))}]:[]})}function i(e){return e.provider===`n8n`?{name:t,query:{workflowId:e.workflowId}}:e.provider===`custom-agent`?{name:t,query:{agentId:e.agentId}}:{name:t,query:{provider:e.provider,model:e.model}}}function a(e){return{provider:e.provider,model:e?.provider===`n8n`||e?.provider===`custom-agent`?null:e?.model??null,workflowId:e?.provider===`n8n`?e.workflowId:null,agentId:e?.provider===`custom-agent`?e.agentId:null}}function o(e){if(e.provider===null)return null;switch(e.provider){case`custom-agent`:return e.agentId?{provider:`custom-agent`,agentId:e.agentId}:null;case`n8n`:return e.workflowId?{provider:`n8n`,workflowId:e.workflowId}:null;default:return e.model===null?null:{provider:e.provider,model:e.model}}}function s(e,t){let n=e;if(t.search.trim()){let e=t.search.toLowerCase();n=n.filter(t=>t.name.toLowerCase().includes(e))}return n=[...n].sort((e,n)=>{let r=e[t.sortBy],i=n[t.sortBy],a=r?Date.parse(r):void 0,o=i?Date.parse(i):void 0;return a&&o?o-a:a&&!o?-1:!a&&o?1:0}),n}function c(e){return`${e.provider}::${e.provider===`custom-agent`?e.agentId:e.provider===`n8n`?e.workflowId:e.model}`}function l(t){let[n,r]=t.split(`::`),i=e.safeParse(n).data;if(i)return i===`n8n`?{provider:`n8n`,workflowId:r}:i===`custom-agent`?{provider:`custom-agent`,agentId:r}:{provider:i,model:r}}function u(e,t){return t.provider===`n8n`?e.model.provider===`n8n`&&e.model.workflowId===t.workflowId:t.provider===`custom-agent`?e.model.provider===`custom-agent`&&e.model.agentId===t.agentId:e.model.provider===t.provider&&e.model.model===t.model}function d(e,t,n){return{id:t,sessionId:e,type:`ai`,name:`AI`,content:[],executionId:n?.executionId??null,status:`running`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),previousMessageId:n?.previousMessageId??null,retryOfMessageId:n?.retryOfMessageId??null,revisionOfMessageId:null,responses:[],alternatives:[],attachments:[],...n?.agent?a(n.agent.model):{provider:null,model:null,workflowId:null,agentId:null}}}function f(e,t,n){let r=[],i=!1;for(let o=0;o<t.activeMessageChain.length;o++){let s=t.activeMessageChain[o],c=t.messages[s];if(c){if(i||=c.status===`running`,i||n?.sessionId!==e||c.type!==`ai`){r.push(c);continue}if(n.retryOfMessageId===s&&!n.messageId){r.push({...c,content:[],status:`running`,...a(n.agent.model)}),i=!0;continue}if(n.messageId&&o===t.activeMessageChain.length-1){r.push({...c,status:`running`}),i=!0;continue}r.push(c)}}return r}function p(e){return e!==`n8n`&&e!==`custom-agent`}function m(e){return p(e?.provider)}function h({enabled:e=!0,allowedModels:t},n){return e&&(t.length===0||t.some(e=>`model`in n&&e.model===n.model))}function g(t,n){for(let r of e.options){let e,i=-1/0,a=p(r)?n[r]:void 0,o=t[r].models.filter(e=>!a||h(a,e.model));for(let t of o){let n=t.metadata.priority??0;n>i&&(i=n,e=t)}if(e)return e}}function _(e,t,n=!1){return{id:e.sessionId,title:`New Chat`,ownerId:``,lastMessageAt:new Date().toISOString(),credentialId:null,agentName:e.agent.name,agentIcon:e.agent.icon,type:n?`manual`:`production`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),toolIds:t,...a(e.agent.model)}}var v={type:`icon`,value:`message-square`},y={type:`icon`,value:`bot`};function b(e,t){return{model:e,name:t?.name||``,description:null,icon:t?.icon??null,createdAt:null,updatedAt:null,metadata:{allowFileUploads:!1,allowedFilesMimeTypes:``,capabilities:{functionCalling:e.provider!==`n8n`},available:!0},groupName:null,groupIcon:null}}function x(e){return e&&(e.includes(`text/*`)||e.includes(`text/markdown`))?`${e},.md`:e}var S=e=>e.status===`success`&&e.type!==`ai`,C=e=>e.type===`ai`;function w(e){if(!e)return[];let t=[],n=``,r={type:`normal`},i=e.split(` `),a=()=>{n.trim()&&(t.push(n.trimEnd()),n=``)};for(let e=0;e<i.length;e++){let t=i[e],o=e<i.length-1?i[e+1]:``,s=t.trim(),c=/^( {4}|\t)/.test(t),l=/^( {0,3})(`{3,}|~{3,})/.test(t);if(r.type===`backtick-fence`){if(l&&s.startsWith("```")){let e=s.match(/^(`+)/);if((e?e[1].length:0)>=r.count){n+=t+` `,r={type:`normal`},a();continue}}}else if(r.type===`tilde-fence`){if(l&&s.startsWith(`~~~`)){let e=s.match(/^(~+)/);if((e?e[1].length:0)>=r.count){n+=t+` `,r={type:`normal`},a();continue}}}else if(r.type===`indented`)!c&&s!==``&&(r={type:`normal`},a());else if(l&&s.startsWith("```")){let e=s.match(/^(`+)/);r={type:`backtick-fence`,count:e?e[1].length:0}}else if(l&&s.startsWith(`~~~`)){let e=s.match(/^(~+)/);r={type:`tilde-fence`,count:e?e[1].length:0}}else c&&s!==``&&(a(),r={type:`indented`});if(n+=t+` `,r.type===`normal`){let e=s===``,t=o.trim()===``,n=o.trim().startsWith(`#`);(e&&t||e&&n)&&a()}}return a(),t}function T(e){return!e||e.status!==`waiting`?!1:e.content.some(e=>e.type===`with-buttons`&&e.blockUserInput)}function E(e,t){let n=[],r=[],i=0;for(let a of e)i+a.size>t&&r.length>0&&(n.push(r),r=[],i=0),r.push(a),i+=a.size;return r.length>0&&n.push(r),n}async function D(e){let t=new FileReader;return await new Promise((n,r)=>{t.onload=()=>{n({data:t.result.split(`base64,`)?.[1]??``,mimeType:e.type,fileName:e.name,fileSize:`${e.size} bytes`,fileExtension:e.name.split(`.`).pop()??``,fileType:e.type.split(`/`)[0]})},t.onerror=()=>{r(Error(`Failed to convert file to binary data`))},t.readAsDataURL(e)})}export{w as C,y as E,v as S,o as T,p as _,b as a,C as b,s as c,l as d,i as f,S as g,h,d as i,g as l,r as m,f as n,_ as o,n as p,E as r,x as s,D as t,a as u,m as v,c as w,T as x,u as y}; //# sourceMappingURL=fileUtils-D6dhtxVJ.js.map