n8n-editor-ui
Version:
Workflow Editor UI for n8n
2 lines • 29.3 kB
JavaScript
!function(){try{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{}).SENTRY_RELEASE={id:"n8n@2.13.4"}}catch(e){}}(),System.register(["./chunk-legacy-TXBRODOR.js","./vue.runtime.esm-bundler-legacy-IafOlCW8.js","./_MapCache-legacy-DwgdC8YO.js","./src-legacy-Dwzr7bD0.js","./_plugin-vue_export-helper-legacy-DEZAmQqp.js","./sanitize-html-legacy-ChR3ikxn.js","./users.store-legacy-OKuN0qAC.js","./constants-legacy-DNCca_FT.js","./merge-legacy-uu1aGqHK.js","./_baseOrderBy-legacy-PsQY_Pvh.js","./dateformat-legacy-BxdD_OP7.js","./useDebounce-legacy-CT3oYGrC.js","./nodeIcon-legacy-CU0X8703.js","./NodeIcon-legacy-B4uktMo3.js","./TimeAgo-legacy-DuWY6_ss.js","./orderBy-legacy-B1QhOZ6M.js","./TemplatesView-legacy--TC0rG3N.js","./TemplateList-legacy-BaK3bf8O.js"],(function(e,t){var i,s,l,a,n,o,r,d,u,c,h,g,p,f,v,_,m,y,w,b,x,S,k,T,C,$,B,M,A,P,E,W,D,L,N,O,I,j,z,X,U,R,F,Y,q,G,H,V,K,J,Q,Z,ee,te,ie,se,le,ae,ne,oe,re,de,ue,ce,he,ge,pe,fe,ve,_e,me,ye,we,be,xe,Se,ke,Te,Ce,$e,Be,Me,Ae,Pe,Ee,We,De,Le,Ne,Oe,Ie,je,ze;function Xe(e,t,i,s,r,d){return l(),o("div",{class:w([{"agile--ssr":r.isSSR,"agile--auto-play":e.settings.autoplay,"agile--disabled":e.settings.unagile,"agile--fade":e.settings.fade&&!e.settings.unagile,"agile--rtl":e.settings.rtl,"agile--no-nav-buttons":!e.settings.navButtons},"agile"]),onTouchstart:()=>{}},[n("div",xe,[n("div",{ref:"track",style:M({transform:`translate(${r.translateX+d.marginX}px)`,transition:`transform ${e.settings.timing} ${r.transitionDelay}ms`}),class:"agile__track",onMouseout:t[0]||(t[0]=t=>e.handleMouseOut("track")),onMouseover:t[1]||(t[1]=t=>e.handleMouseOver("track"))},[b(n("div",Se,[S(e.$slots,"default")],512),[[C,d.slidesCloned]]),n("div",ke,[S(e.$slots,"default")],512),b(n("div",Te,[S(e.$slots,"default")],512),[[C,d.slidesCloned]])],36)],512),e.$slots.caption?(l(),o("div",Ce,[S(e.$slots,"caption")])):p("",!0),e.settings.unagile||!e.settings.navButtons&&!e.settings.dots?p("",!0):(l(),o("div",$e,[e.settings.navButtons&&!e.settings.unagile?(l(),o("button",{key:0,ref:"prevButton",disabled:!d.canGoToPrev,"aria-label":"Previous",class:"agile__nav-button agile__nav-button--prev",type:"button",onClick:t[2]||(t[2]=t=>(d.goToPrev(),e.restartAutoPlay()))},[S(e.$slots,"prevButton",{},(()=>[t[6]||(t[6]=a(" ← ",-1))]))],8,Be)):p("",!0),e.settings.dots&&!e.settings.unagile?(l(),o("ul",Me,[(l(!0),o(y,null,$(d.countSlides,(i=>(l(),o("li",{key:i,class:w([{"agile__dot--current":i-1===r.currentSlide},"agile__dot"]),onMouseout:t[3]||(t[3]=t=>e.handleMouseOut("dot")),onMouseover:t[4]||(t[4]=t=>e.handleMouseOver("dot"))},[n("button",{type:"button",onClick:t=>(d.goTo(i-1),e.restartAutoPlay())},g(i),9,Ae)],34)))),128))],512)):p("",!0),e.settings.navButtons&&!e.settings.unagile?(l(),o("button",{key:2,ref:"nextButton",disabled:!d.canGoToNext,"aria-label":"Next",class:"agile__nav-button agile__nav-button--next",type:"button",onClick:t[5]||(t[5]=t=>(d.goToNext(),e.restartAutoPlay()))},[S(e.$slots,"nextButton",{},(()=>[t[7]||(t[7]=a(" → ",-1))]))],8,Pe)):p("",!0)]))],34)}return{setters:[function(e){i=e.o,s=e.t},function(e){l=e.$,a=e.A,n=e.C,o=e.E,r=e.Ft,d=e.K,u=e.N,c=e.O,h=e.S,g=e.Sn,p=e.T,f=e.U,v=e.W,_=e.Wt,m=e.X,y=e._,w=e._n,b=e.bt,x=e.gt,S=e.it,k=e.j,T=e.ot,C=e.p,$=e.rt,B=e.w,M=e.yn,A=e.yt},function(e){P=e.bt,E=e.c},function(e){W=e.$i,D=e.Fi,L=e.Nt,N=e.Qi,O=e.Yi,I=e.Zi,j=e._t,z=e.gt,X=e.ht,U=e.yt,R=e.zt},function(e){F=e.t},function(e){},function(e){Y=e.As,q=e.Dn,G=e.Tr,H=e.en,V=e.t,K=e.vn},function(e){J=e.ms,Q=e.u},function(e){},function(e){},function(e){},function(e){Z=e.n,ee=e.t},function(e){},function(e){},function(e){},function(e){te=e.t},function(e){ie=e.t},function(e){se=e.n,le=e.t}],execute:function(){(ae=document.createElement("style")).textContent='._card_pxgdc_125{min-width:235px;height:140px;margin-right:var(--spacing--2xs);cursor:pointer}._card_pxgdc_125:last-child{margin-right:var(--spacing--5xs)}._card_pxgdc_125:hover{box-shadow:0 2px 4px rgba(68,28,23,.07)}._card_pxgdc_125>div{height:100%}._title_pxgdc_141{-webkit-line-clamp:4;font-size:var(--font-size--sm);line-height:var(--line-height--md);font-weight:var(--font-weight--bold);white-space:normal;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.agile{position:relative}.agile--ssr .agile__slides--cloned{display:none}.agile--ssr .agile__slides>*{width:0;overflow:hidden}.agile--ssr .agile__slides>:first-child{width:100%}.agile--rtl .agile__track,.agile--rtl .agile__slides,.agile--rtl .agile__actions,.agile--rtl .agile__dots{flex-direction:row-reverse}.agile:focus,.agile:active,.agile :focus,.agile :active{outline:none}.agile__list{width:100%;display:block;position:relative;overflow:hidden}.agile__track{flex-flow:row;display:flex}.agile__actions{justify-content:space-between;display:flex}.agile--no-nav-buttons .agile__actions{justify-content:center}.agile__slides{flex-direction:row;flex-grow:1;flex-shrink:unset;flex-wrap:nowrap;justify-content:flex-start;align-items:center;display:flex}.agile--disabled .agile__slides{width:100%;display:block}.agile__slide{flex-grow:1;flex-shrink:0;display:block}.agile__slide,.agile__slide *{-webkit-user-drag:none}.agile--fade .agile__slide{opacity:0;z-index:0;position:relative}.agile--fade .agile__slide--active{opacity:1;z-index:2}.agile--fade .agile__slide--expiring{opacity:1;z-index:1;transition-duration:0s}.agile__nav-button[disabled]{cursor:default}.agile__dots{white-space:nowrap;align-items:center;padding:0;list-style:none;display:flex}.agile__dot button{cursor:pointer;font-size:0;line-height:0;display:block}._container_1m7ae_125{position:relative}._button_1m7ae_129{border-radius:var(--radius--lg);border:var(--border);cursor:pointer;background-color:#fbfcfe;width:28px;height:37px;position:absolute;top:35%}._button_1m7ae_129:after{content:"";width:40px;height:140px;position:absolute;top:-55px}._button_1m7ae_129 svg{color:var(--color--foreground--shade-2)}._leftButton_1m7ae_150{left:-30px}._leftButton_1m7ae_150:after{background:linear-gradient(270deg,color-mix(in srgb,transparent 50%,var(--color--background--light-2)),var(--color--background--light-2));left:27px}._rightButton_1m7ae_159{right:-30px}._rightButton_1m7ae_159:after{background:linear-gradient(90deg,color-mix(in srgb,transparent 50%,var(--color--background--light-2)),var(--color--background--light-2));right:27px}.agile__list{width:100%;padding-bottom:var(--spacing--2xs);transition:all 1s ease-in-out;overflow-x:auto}.agile__track{width:50px}._title_hd29n_125{font-size:var(--font-size--2xs);color:var(--color--text)}._categories_hd29n_130{padding-top:var(--spacing--xs);list-style-type:none}._item_hd29n_135{margin-top:var(--spacing--xs)}._item_hd29n_135:first-child{margin-top:0}._button_hd29n_142{padding-top:var(--spacing--2xs);cursor:pointer}.template-filters .el-checkbox{white-space:unset;display:flex}.template-filters .el-checkbox__label{font-size:var(--font-size--xs);line-height:var(--line-height--lg);color:var(--color--text--shade-1);padding-left:var(--spacing--2xs);position:relative;top:-2px}._wrapper_n14ka_125,._contentWrapper_n14ka_130{justify-content:space-between;display:flex}@media (max-width:768px){._contentWrapper_n14ka_130{flex-direction:column}}._filters_n14ka_140{width:200px;margin-bottom:var(--spacing--xl);margin-right:var(--spacing--2xl)}._search_n14ka_146{width:100%}._search_n14ka_146>*{margin-bottom:var(--spacing--lg)}@media (max-width:768px){._search_n14ka_146{padding-left:0}}._header_n14ka_158{margin-bottom:var(--spacing--2xs)}\n/*$vite$:1*/',document.head.appendChild(ae);try{t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},(Ue=(new t.Error).stack)&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[Ue]="ed80ee38-2393-4f12-b146-f685254954ba",t._sentryDebugIdIdentifier="sentry-dbid-ed80ee38-2393-4f12-b146-f685254954ba")}catch(t){}var t,Ue;ne=["textContent"],oe=u({__name:"CollectionWorkflowCard",props:{loading:{type:Boolean},title:{}},setup:e=>(t,i)=>(l(),B(_(L),f({class:t.$style.card},t.$attrs),c({default:A((()=>[k(_(R),{loading:e.loading,rows:3,variant:"p"},null,8,["loading"])])),_:2},[!e.loading&&e.title?{name:"header",fn:A((()=>[n("span",{class:w(t.$style.title),textContent:g(e.title)},null,10,ne)])),key:"0"}:void 0,e.loading?void 0:{name:"footer",fn:A((()=>[S(t.$slots,"footer")])),key:"1"}]),1040,["class"]))}),re=F(oe,[["__cssModules",{$style:{card:"_card_pxgdc_125",title:"_title_pxgdc_141"}}]]),de=u({__name:"TemplatesInfoCard",props:{collection:{},loading:{type:Boolean,default:!1},showItemCount:{type:Boolean,default:!0},width:{}},setup(e){const t=P();return(i,s)=>(l(),B(re,{loading:e.loading,title:e.collection.name,style:M({width:e.width})},{footer:A((()=>[n("span",null,[b(k(_(I),{size:"small",color:"text-light"},{default:A((()=>[a(g(e.collection.workflows.length)+" "+g(_(t).baseText("templates.workflows")),1)])),_:1},512),[[C,e.showItemCount]])]),k(se,{nodes:e.collection.nodes,"show-more":!1},null,8,["nodes"])])),_:1},8,["loading","title","style"]))}}),ue=de,ce={methods:{handleMouseDown(e){this.isMouseDown=!0,-1!==e.type.indexOf("touch")&&(this.dragStartX=e.touches[0].clientX,this.dragStartY=e.touches[0].clientY),-1!==e.type.indexOf("mouse")&&(this.dragStartX=e.clientX,this.dragStartY=e.clientY)},handleMouseMove(e){let t,i;-1!==e.type.indexOf("touch")&&(t=e.touches[0].clientX,i=e.touches[0].clientY),-1!==e.type.indexOf("mouse")&&(t=e.clientX,i=e.clientY),Math.abs(t-this.dragStartX)>3*Math.abs(i-this.dragStartY)&&(this.disableScroll(),this.dragDistance=t-this.dragStartX)},handleMouseUp(){this.isMouseDown=!1,this.enableScroll()},handleMouseOver(e){this.settings.autoplay&&("dot"===e&&this.settings.pauseOnDotsHover||"track"===e&&this.settings.pauseOnHover)&&(this.isAutoplayPaused=!0)},handleMouseOut(e){this.settings.autoplay&&("dot"===e&&this.settings.pauseOnDotsHover||"track"===e&&this.settings.pauseOnHover)&&(this.isAutoplayPaused=!1)}}},he=ce,ge={methods:{getWidth(){if(this.isSSR)return!1;this.widthWindow=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,this.widthContainer=this.$refs.list.clientWidth},htmlCollectionToArray:e=>Array.prototype.slice.call(e,0)}},pe={methods:{clearAutoPlayPause(){clearTimeout(this.autoplayTimeout),this.autoplayRemaining=null},disableAutoPlay(){clearInterval(this.autoplayInterval),this.autoplayInterval=null},disableScroll(){document.ontouchmove=e=>e.preventDefault()},enableScroll(){document.ontouchmove=()=>!0},restartAutoPlay(){this.disableAutoPlay(),this.toggleAutoPlay()},toggleAutoPlay(){const e=!this.settings.unagile&&this.settings.autoplay;!this.autoplayInterval&&e?this.autoplayInterval=setInterval((()=>{document.hidden||(this.canGoToNext?this.goToNext():this.disableAutoPlay())}),this.settings.autoplaySpeed):this.disableAutoPlay()},toggleFade(){const e=!this.settings.unagile&&this.settings.fade;for(let t=0;t<this.countSlides;t++)this.slides[t].style.transition=e?"opacity "+this.settings.timing+" "+this.settings.speed+"ms":"none",this.slides[t].style.transform=e?`translate(-${t*this.widthSlide}px)`:"none"}}},fe=pe,ve={methods:{prepareSlides(){this.slides=this.htmlCollectionToArray(this.$refs.slides.children),this.slidesCloned&&(this.slidesClonedBefore=this.htmlCollectionToArray(this.$refs.slidesClonedBefore.children),this.slidesClonedAfter=this.htmlCollectionToArray(this.$refs.slidesClonedAfter.children));for(const e of this.slidesAll)e.classList.add("agile__slide")},prepareSlidesClasses(){if(null===this.currentSlide)return!1;for(let t=0;t<this.countSlides;t++)this.slides[t].classList.remove("agile__slide--active"),this.slides[t].classList.remove("agile__slide--current");setTimeout((()=>this.slides[this.currentSlide].classList.add("agile__slide--active")),this.changeDelay);let e=this.slidesCloned?this.countSlides+this.currentSlide:this.currentSlide;this.centerMode&&(e-=Math.floor(this.settings.slidesToShow/2)-+(this.settings.slidesToShow%2==0));for(let t=Math.max(e,0);t<Math.min(e+this.settings.slidesToShow,this.countSlides);t++)this.slidesAll[t].classList.add("agile__slide--current")},prepareCarousel(){this.settings.unagile?this.translateX=0:(null===this.currentSlide&&this.countSlides&&(this.currentSlide=this.settings.initialSlide),this.currentSlide>this.countSlides&&(this.currentSlide=this.countSlides-1),this.goTo(this.currentSlide,!1,!1))}}},_e=i(te()),me={props:{asNavFor:{type:Array,default:function(){return[]}},autoplay:{type:Boolean,default:!1},autoplaySpeed:{type:Number,default:3e3},centerMode:{type:Boolean,default:!1},centerPadding:{type:String,default:"15%"},changeDelay:{type:Number,default:0},dots:{type:Boolean,default:!0},fade:{type:Boolean,default:!1},infinite:{type:Boolean,default:!0},initialSlide:{type:Number,default:0},mobileFirst:{type:Boolean,default:!0},navButtons:{type:Boolean,default:!0},options:{type:Object,default:()=>null},pauseOnDotsHover:{type:Boolean,default:!1},pauseOnHover:{type:Boolean,default:!0},responsive:{type:Array,default:()=>null},rtl:{type:Boolean,default:!1},slidesToScroll:{type:Number,default:1},slidesToShow:{type:Number,default:1},speed:{type:Number,default:300},swipeDistance:{type:Number,default:50},throttleDelay:{type:Number,default:500},timing:{type:String,default:"ease",validator:e=>-1!==["ease","linear","ease-in","ease-out","ease-in-out"].indexOf(e)},unagile:{type:Boolean,default:!1}},computed:{initialSettings:function(){let{options:e,...t}=this.$props;return e&&(t={...t,...e}),t.responsive&&(t.responsive=(0,_e.default)(t.responsive,"breakpoint")),t},settings:function(){const{responsive:e,...t}=this.initialSettings;return e&&e.forEach((e=>{if(t.mobileFirst?e.breakpoint<this.widthWindow:e.breakpoint>this.widthWindow)for(const i in e.settings)t[i]=e.settings[i]})),t}}},ye=me,we=i(s(((e,t)=>{var i=Z(),s=E();t.exports=function(e,t,l){var a=!0,n=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return s(l)&&(a="leading"in l?!!l.leading:a,n="trailing"in l?!!l.trailing:n),i(e,t,{leading:a,maxWait:t,trailing:n})}}))()),be={name:"agile",mixins:[he,ge,fe,ve,ye,{created(){this.goTo=(0,we.default)(this.goTo,this.throttleDelay),this.getWidth=(0,we.default)(this.getWidth,500)}},{watch:{currentBreakpoint(){this.$emit("breakpoint",{breakpoint:this.currentBreakpoint})},currentSlide(){this.prepareSlidesClasses(),this.autoplayStartTimestamp=this.settings.autoplay?+new Date:null,this.$emit("after-change",{currentSlide:this.currentSlide})},dragDistance(){if(this.isMouseDown){const{rtl:e}=this.settings,t=this.dragDistance*(e?-1:1);t>this.swipeDistance&&this.canGoToPrev&&(this.goToPrev(),this.handleMouseUp()),t<-1*this.swipeDistance&&this.canGoToNext&&(this.goToNext(),this.handleMouseUp())}},isAutoplayPaused(e){e?(this.remaining=this.settings.autoplaySpeed-(+new Date-this.autoplayStartTimestamp),this.disableAutoPlay(),this.clearAutoPlayPause()):this.autoplayTimeout=setTimeout((()=>{this.clearAutoPlayPause(),this.goToNext(),this.toggleAutoPlay()}),this.remaining)},"settings.autoplay"(){this.toggleAutoPlay()},"settings.fade"(){this.toggleFade()},"settings.unagile"(){},widthSlide(){for(let e=0;e<this.countSlidesAll;e++)this.slidesAll[e].style.width=`${this.widthSlide}${"auto"!==this.widthSlide?"px":""}`},widthWindow(e,t){t&&(this.prepareCarousel(),this.toggleFade())}}}],emits:["before-change","after-change","breakpoint"],data:()=>({autoplayInterval:null,autoplayRemaining:null,autoplayStartTimestamp:null,autoplayTimeout:null,currentSlide:null,dragDistance:0,dragStartX:0,dragStartY:0,isAutoplayPaused:!1,isMouseDown:!1,slides:[],slidesClonedAfter:[],slidesClonedBefore:[],isSSR:"undefined"==typeof window,transitionDelay:0,translateX:0,widthWindow:0,widthContainer:0}),computed:{breakpoints:function(){return this.initialSettings.responsive?this.initialSettings.responsive.map((e=>e.breakpoint)):[]},canGoToPrev:function(){return this.settings.infinite||this.currentSlide>0},canGoToNext:function(){return this.settings.infinite||this.currentSlide<this.countSlides-1},countSlides:function(){return this.isSSR?this.htmlCollectionToArray(this.$slots.default).length:this.slides.length},countSlidesAll:function(){return this.slidesAll.length},currentBreakpoint:function(){const e=this.breakpoints.map((e=>e)).reverse();return this.initialSettings.mobileFirst?e.find((e=>e<this.widthWindow))||0:e.find((e=>e>this.widthWindow))||null},marginX:function(){if(this.settings.unagile)return 0;let e=this.slidesCloned?this.countSlides*this.widthSlide:0;return this.settings.centerMode&&(e-=(Math.floor(this.settings.slidesToShow/2)-+(this.settings.slidesToShow%2==0))*this.widthSlide),this.settings.rtl?e:-1*e},slidesCloned:function(){return!this.settings.unagile&&!this.settings.fade&&this.settings.infinite},slidesAll:function(){return this.slidesCloned?[...this.slidesClonedBefore,...this.slides,...this.slidesClonedAfter]:this.slides},widthSlide:function(){return this.settings.unagile?"auto":this.widthContainer/this.settings.slidesToShow}},mounted(){window.addEventListener("resize",this.getWidth),this.$refs.track.addEventListener("touchstart",this.handleMouseDown),this.$refs.track.addEventListener("touchend",this.handleMouseUp),this.$refs.track.addEventListener("touchmove",this.handleMouseMove),this.$refs.track.addEventListener("mousedown",this.handleMouseDown),this.$refs.track.addEventListener("mouseup",this.handleMouseUp),this.$refs.track.addEventListener("mousemove",this.handleMouseMove),this.isSSR=!1,this.reload()},beforeUnmount(){this.destroy()},methods:{destroy(){window.removeEventListener("resize",this.getWidth),this.$refs.track.removeEventListener("touchstart",this.handleMouseDown),this.$refs.track.removeEventListener("touchend",this.handleMouseUp),this.$refs.track.removeEventListener("touchmove",this.handleMouseMove),this.$refs.track.removeEventListener("mousedown",this.handleMouseDown),this.$refs.track.removeEventListener("mouseup",this.handleMouseUp),this.$refs.track.removeEventListener("mousemove",this.handleMouseMove),this.disableAutoPlay()},getCurrentBreakpoint(){return this.currentBreakpoint},getCurrentSettings(){return this.settings},getCurrentSlide(){return this.currentSlide},getInitialSettings(){return this.initialSettings},goTo(e,t=!0,i=!1){if(this.settings.unagile)return!1;i||this.settings.asNavFor.forEach((i=>{i&&i.goTo(e,t,!0)}));let s=e;t&&(this.settings.infinite&&e<0?s=this.countSlides-1:e>=this.countSlides&&(s=0),this.$emit("before-change",{currentSlide:this.currentSlide,nextSlide:s}),this.currentSlide=s,e!==s&&setTimeout((()=>{this.goTo(s,!1)}),this.settings.speed));const l=this.settings.fade?0:e*this.widthSlide*this.settings.slidesToScroll;this.transitionDelay=t?this.speed:0,(this.infinite||this.currentSlide+this.slidesToShow<=this.countSlides)&&(this.translateX=this.settings.rtl?l:-1*l)},goToNext(){this.canGoToNext&&this.goTo(this.currentSlide+1)},goToPrev(){this.canGoToPrev&&this.goTo(this.currentSlide-1)},reload(){this.getWidth(),this.prepareSlides(),this.prepareCarousel(),this.toggleFade(),this.toggleAutoPlay()}}},xe={ref:"list",class:"agile__list"},Se={ref:"slidesClonedBefore",class:"agile__slides agile__slides--cloned"},ke={ref:"slides",class:"agile__slides agile__slides--regular"},Te={ref:"slidesClonedAfter",class:"agile__slides agile__slides--cloned"},Ce={key:0,class:"agile__caption"},$e={key:1,class:"agile__actions"},Be=["disabled"],Me={key:1,ref:"dots",class:"agile__dots"},Ae=["onClick"],Pe=["disabled"],Ee=F(be,[["render",Xe]]),We=u({__name:"TemplatesInfoCarousel",props:{collections:{},loading:{type:Boolean,default:!1},showItemCount:{type:Boolean,default:!0},showNavigation:{type:Boolean,default:!0},cardsWidth:{default:"240px"}},emits:["openCollection"],setup(e,{emit:t}){const i=e,s=t,a=r(0),u=r(parseInt(i.cardsWidth,10)),c=r(!1),h=r(null),g=r(null),p=()=>{if(h.value){a.value=Number(h.value.scrollLeft.toFixed());const e=h.value.clientWidth,t=h.value.scrollWidth,i=a.value;c.value=t-e<=i+7}},f=()=>{h.value&&h.value.scrollBy({left:-2*u.value,top:0,behavior:"smooth"})},S=()=>{h.value&&h.value.scrollBy({left:2*u.value,top:0,behavior:"smooth"})};return x((()=>i.collections),(()=>{setTimeout((()=>{p()}),0)})),x((()=>i.loading),(()=>{setTimeout((()=>{p()}),0)})),m((async()=>{await v(),g.value&&(h.value=g.value.$el.querySelector(".agile__list"),h.value&&h.value.addEventListener("scroll",p))})),d((()=>{g.value&&g.value.destroy(),window.addEventListener("scroll",p)})),(t,i)=>b((l(),o("div",{class:w(t.$style.container)},[k(_(Ee),{ref_key:"sliderRef",ref:g,dots:!1,"nav-buttons":!1,infinite:!1,"slides-to-show":4,onAfterChange:p},{default:A((()=>[(l(!0),o(y,null,$(e.loading?4:0,(t=>(l(),B(re,{key:`loading-${t}`,loading:e.loading},null,8,["loading"])))),128)),(l(!0),o(y,null,$(e.loading?[]:e.collections,(t=>(l(),B(ue,{key:t.id,"data-test-id":"templates-info-card",collection:t,"show-item-count":e.showItemCount,width:e.cardsWidth,onClick:e=>{return i=e,l=t.id,void s("openCollection",{event:i,id:l});var i,l}},null,8,["collection","show-item-count","width","onClick"])))),128))])),_:1},512),b(n("button",{class:w({[t.$style.leftButton]:!0}),onClick:f},[k(_(W),{icon:"chevron-left"})],2),[[C,e.showNavigation&&a.value>0]]),b(n("button",{class:w({[t.$style.rightButton]:!0}),onClick:S},[k(_(W),{icon:"chevron-right"})],2),[[C,e.showNavigation&&!c.value]])],2)),[[C,e.loading||e.collections.length]])}}),De=F(We,[["__cssModules",{$style:{container:"_container_1m7ae_125",button:"_button_1m7ae_129",leftButton:"_leftButton_1m7ae_150 _button_1m7ae_129",rightButton:"_rightButton_1m7ae_159 _button_1m7ae_129"}}]]),Le=["textContent"],Ne=["data-test-id"],Oe=u({__name:"TemplateFilters",props:{categories:{default:()=>[]},sortOnPopulate:{type:Boolean,default:!1},expandLimit:{default:12},loading:{type:Boolean,default:!1},selected:{default:()=>[]}},emits:["clearAll","select","clear"],setup(e,{emit:t}){const i=e,s=t,d=P(),u=r(!0),c=r([]),f=h((()=>0===i.selected.length));function v(){if(i.sortOnPopulate){const e=i.selected||[],t=i.categories.filter((t=>e.includes(t))),s=i.categories.filter((t=>!e.includes(t)));c.value=t.concat(s)}else c.value=i.categories}function m(){u.value=!1}function b(e){return i.selected.includes(e)}return x((()=>i.sortOnPopulate),(e=>{e&&v()}),{immediate:!0}),x((()=>i.categories),(e=>{e.length>0&&v()}),{immediate:!0}),(t,i)=>(l(),o("div",{class:w([t.$style.filters,"template-filters"]),"data-test-id":"templates-filter-container"},[n("div",{class:w(t.$style.title),textContent:g(_(d).baseText("templates.categoriesHeading"))},null,10,Le),e.loading?(l(),o("div",{key:0,class:w(t.$style.list)},[k(_(R),{loading:e.loading,rows:e.expandLimit},null,8,["loading","rows"])],2)):p("",!0),e.loading?p("",!0):(l(),o("ul",{key:1,class:w(t.$style.categories)},[n("li",{class:w(t.$style.item),"data-test-id":"template-filter-all-categories"},[k(_(U),{"model-value":f.value,label:_(d).baseText("templates.allCategories"),"onUpdate:modelValue":i[0]||(i[0]=()=>{s("clearAll")})},null,8,["model-value","label"])],2),(l(!0),o(y,null,$(u.value?c.value.slice(0,e.expandLimit):c.value,((e,i)=>(l(),o("li",{key:i,class:w(t.$style.item),"data-test-id":`template-filter-${e.name.toLowerCase().replaceAll(" ","-")}`},[k(_(U),{"model-value":b(e),label:e.name,"onUpdate:modelValue":t=>function(e,t){s(e?"select":"clear",t)}(t,e)},null,8,["model-value","label","onUpdate:modelValue"])],10,Ne)))),128))],2)),c.value.length>e.expandLimit&&u.value&&!e.loading?(l(),o("div",{key:2,class:w(t.$style.button),"data-test-id":"expand-categories-button",onClick:m},[k(_(I),{size:"small",color:"primary"},{default:A((()=>[a(" + "+g(c.value.length-e.expandLimit+" more"),1)])),_:1})],2)):p("",!0)],2))}}),Ie=F(Oe,[["__cssModules",{$style:{title:"_title_hd29n_125",categories:"_categories_hd29n_130",item:"_item_hd29n_135",button:"_button_hd29n_142"}}]]),je=["textContent"],ze=u({__name:"TemplatesSearchView",setup(e){const i=r(!1),s=r([]),d=r(!0),u=r(!0),c=r(!0),f=r(""),v=r(null),y=r(!1),{callDebounced:S}=ee(),$=G(),M=K(),E=Y(),L=q(),U=V(),R=P(),F=z(),Z=j(),te=H(),se=e=>({categories:s.value.map((t=>"name"===e?t.name:String(t.id))),search:f.value}),ae=h((()=>L.getSearchedWorkflowsTotal(se("name")))),ne=h((()=>L.getSearchedWorkflows(se("name"))??[])),oe=h((()=>L.getSearchedCollections(se("id"))??[])),re=h((()=>c.value||u.value||0!==ne.value.length||0!==oe.value.length?null:!E.isTemplatesEndpointReachable&&y.value?R.baseText("templates.connectionWarning"):R.baseText("templates.noSearchResults"))),de=()=>{((e,t)=>{const i=Object.assign({},F.query);t.length?i.categories=t:delete i.categories,e.length?i.search=e:delete i.search,Z.replace({query:i})})(f.value,s.value.map((e=>e.id)).join(",")),ge(!1)},ue=async()=>{try{c.value=!0,await L.getWorkflows({search:f.value,categories:s.value.map((e=>e.name))}),y.value=!1}catch(t){y.value=!0}c.value=!1},ce=async()=>{try{u.value=!0,await L.getCollections({categories:s.value.map((e=>String(e.id))),search:f.value})}catch(t){}u.value=!1},he=()=>{s.value.length&&te.track("User changed template filters",{search_string:f.value,categories_applied:s.value,wf_template_repo_session_id:L.currentSessionId})},ge=async e=>{const t=[...s.value],i=f.value;var l,a;await Promise.all([ue(),ce()]),e||(l=i,a=t.map((e=>e.id)),l&&(v.value&&v.value.search_string.length>l.length||(v.value={search_string:l,workflow_results_count:ne.value.length,collection_results_count:oe.value.length,categories_applied:a.map((e=>L.getCategoryById(e.toString()))),wf_template_repo_session_id:L.currentSessionId})))},pe=(e,t,i)=>{if(e.metaKey||e.ctrlKey){const e=Z.resolve({name:t,params:{id:i}});window.open(e.href,"_blank")}else Z.push({name:t,params:{id:i}})},fe=({event:e,id:t})=>{pe(e,J.COLLECTION,t)},ve=({event:e,id:t})=>{pe(e,J.TEMPLATE,t)},_e=()=>{v.value&&(te.track("User searched workflow templates",v.value),v.value=null)},me=e=>{c.value=!0,u.value=!0,f.value=e,S(de,{debounceTime:500,trailing:!0}),0===e.length&&_e()},ye=e=>{s.value=s.value.concat(e),de(),he()},we=e=>{s.value=s.value.filter((t=>t.id!==e.id)),de(),he()},be=()=>{s.value=[],de()},xe=async()=>{if(!(ne.value.length>=ae.value))try{c.value=!0,await L.getMoreWorkflows({categories:s.value.map((e=>e.name)),search:f.value})}catch(t){$.showMessage({title:"Error",message:"Could not load more workflows",type:"error"})}finally{c.value=!1}};return m((async()=>{M.set("Templates"),await(async()=>{try{await L.getCategories()}catch(t){}d.value=!1})(),ge(!0),U.showPersonalizationSurvey(),(()=>{let e=!1;if(F.query.search&&"string"==typeof F.query.search&&(f.value=F.query.search,e=!0),"string"==typeof F.query.categories&&F.query.categories.length){const t=F.query.categories.split(",");s.value=L.allCategories.filter((e=>t.includes(e.id.toString()))),e=!0}e&&(de(),he(),i.value=!0)})(),E.isTemplatesEnabled&&E.testTemplatesEndpoint().catch((()=>{})),setTimeout((()=>{const e=F.meta?.scrollOffset;"number"==typeof e&&e>0&&((e,t="smooth")=>{setTimeout((()=>{const i=document.getElementById("content");i&&i.scrollTo({top:e,behavior:t})}),0)})(e,"auto")}),100)})),X(((e,t,i)=>{const s=document.getElementById("content");s&&F.meta?.setScrollPosition?.(s.scrollTop),_e(),i()})),x(ne,(e=>{0===e.length&&window.scrollTo(0,0)})),(e,t)=>{const r=T("n8n-html");return l(),B(ie,null,{header:A((()=>[n("div",{class:w(e.$style.wrapper)},[n("div",{class:w(e.$style.title)},[k(_(O),{tag:"h1",size:"2xlarge"},{default:A((()=>[a(g(_(R).baseText("templates.heading")),1)])),_:1})],2),n("div",{class:w(e.$style.button)},[k(_(N),{variant:"subtle",size:"large",href:_(Q),label:_(R).baseText("templates.shareWorkflow"),target:"_blank"},null,8,["href","label"])],2)],2)])),content:A((()=>[n("div",{class:w(e.$style.contentWrapper)},[n("div",{class:w(e.$style.filters)},[k(Ie,{categories:_(L).allCategories,"sort-on-populate":i.value,selected:s.value,loading:d.value,onClear:we,onClearAll:be,onSelect:ye},null,8,["categories","sort-on-populate","selected","loading"])],2),n("div",{class:w(e.$style.search)},[k(_(D),{"model-value":f.value,placeholder:_(R).baseText("templates.searchPlaceholder"),clearable:"","data-test-id":"template-search-input","onUpdate:modelValue":me,onBlur:_e},{prefix:A((()=>[k(_(W),{icon:"search"})])),_:1},8,["model-value","placeholder"]),b(n("div",{class:w(e.$style.carouselContainer)},[n("div",{class:w(e.$style.header)},[k(_(O),{bold:!0,size:"medium",color:"text-light"},{default:A((()=>[a(g(_(R).baseText("templates.collections"))+" ",1),u.value?p("",!0):(l(),o("span",{key:0,"data-test-id":"collection-count-label",textContent:g(`(${oe.value.length})`)},null,8,je))])),_:1})],2),k(De,{collections:oe.value,loading:u.value,onOpenCollection:fe},null,8,["collections","loading"])],2),[[C,oe.value.length||u.value]]),k(le,{"infinite-scroll-enabled":!0,loading:c.value,workflows:ne.value,"total-count":ae.value,onLoadMore:xe,onOpenTemplate:ve},null,8,["loading","workflows","total-count"]),re.value?(l(),o("div",{key:0,class:w(e.$style.endText)},[k(_(I),{size:"medium",color:"text-base"},{default:A((()=>[b(n("span",null,null,512),[[r,re.value]])])),_:1})],2)):p("",!0)],2)],2)])),_:1})}}}),e("default",F(ze,[["__cssModules",{$style:{wrapper:"_wrapper_n14ka_125",contentWrapper:"_contentWrapper_n14ka_130",filters:"_filters_n14ka_140",search:"_search_n14ka_146",header:"_header_n14ka_158"}}]]))}}}));
//# sourceMappingURL=TemplatesSearchView-legacy-hIK96bf9.js.map