1import{a as I,b as h,c as L,f as C,g as y,h as g,i as E,j as d}from"./chunk-22FG46JR.js";import"./chunk-GOH7Q6D5.js";import{e as f,l as v}from"./chunk-UIWAPUFS.js";import"./chunk-YCV2IU6X.js";import"./chunk-TEDFW2F3.js";import"./chunk-Y6SLVHK3.js";var m=class{constructor(){this.activeCategoriesCache=new Set;this.lastFilterState={categories:"",search:""};this.fuseInstance=null;this.debouncedFilterUpdate=null;this.urlParams=new URLSearchParams(window.location.search),this.searchQuery=this.urlParams.get("search")||"",this.isInit=!0,this.itemsPerPage=12,this.cache={data:L(solaApp.ajaxurl,"POST",{action:"fetch_integrations_posts",security:solaApp.nonce})},this.handleIntegrationsFilter()}getFuseInstance(i){return this.fuseInstance||(this.fuseInstance=new I(i,{threshold:.4,keys:["name","tags","slug","description","categories","seoTitle"]})),this.fuseInstance}updateActiveCategoriesCache(){return this.activeCategoriesCache.clear(),this.component.querySelectorAll("[data-category].active").forEach(r=>{let a=r.getAttribute("data-category");a&&this.activeCategoriesCache.add(a)}),this.activeCategoriesCache}showHideIntegrationItems(i,r){if(i.length===0){this.noResultsContainer.classList.remove("hidden"),Array.from(r.children).forEach(t=>t.classList.add("hidden"));let n=this.component.querySelector(".pagination");n&&n.classList.add("hidden");return}else this.noResultsContainer.classList.add("hidden");this.setupPaginationWithUtils(i,r)}setupPaginationWithUtils(i,r){let a=this.component.querySelector(".pagination");if(!a||!this.itemsPerPage){let n=Array.from(r.children),t=[],s=[];n.forEach(e=>{let l=e.dataset.integrationSlug,o=i.some(u=>u.slug===l),c=!e.classList.contains("hidden");o&&!c?t.push(e):!o&&c&&s.push(e)}),s.length>0?h.exit(s,()=>{s.forEach(e=>e.classList.add("hidden")),t.length>0&&(t.forEach(e=>e.classList.remove("hidden")),h.enter(t))}):t.length>0&&(t.forEach(e=>e.classList.remove("hidden")),h.enter(t));return}if(i.length<=this.itemsPerPage){a.classList.add("hidden");let n=Array.from(r.children),t=[],s=[];n.forEach(e=>{let l=e.dataset.integrationSlug,o=i.some(u=>u.slug===l),c=!e.classList.contains("hidden");o&&!c?t.push(e):!o&&c&&s.push(e)}),s.length>0?h.exit(s,()=>{s.forEach(e=>e.classList.add("hidden")),t.length>0&&(t.forEach(e=>e.classList.remove("hidden")),h.enter(t))}):t.length>0&&(t.forEach(e=>e.classList.remove("hidden")),h.enter(t));return}a.classList.remove("hidden"),E(a,i.length,this.itemsPerPage,1,n=>{g(i,r,this.itemsPerPage,Number(n),!0)}),g(i,r,this.itemsPerPage,1,!0)}performUnifiedFiltering(i,r="",a){let n=a||this.activeCategoriesCache,t=i;return n.size>0&&(t=i.filter(s=>s.categories.some(e=>n.has(e.slug.toLowerCase().replace(/\s+/g,"-"))))),r.length>=2?this.getFuseInstance(t).search(r).map(e=>e.item):t}setupOptimizedSearch(i,r){if(!this.searchInput)return;let a=this.searchInput.parentElement?.querySelector(".filter-search-reset"),n=s=>{this.updateActiveCategoriesCache();let e={categories:Array.from(this.activeCategoriesCache).sort().join(","),search:s};if(e.categories===this.lastFilterState.categories&&e.search===this.lastFilterState.search)return;let l=this.performUnifiedFiltering(i,s);i.forEach(o=>{o.isActive=l.includes(o)}),this.showHideIntegrationItems(l,r),this.lastFilterState=e},t=()=>{this.searchInput.value="",n("")};this.debouncedFilterUpdate||(this.debouncedFilterUpdate=v(n,300)),a?.addEventListener("click",t),this.searchInput.addEventListener("input",s=>{let e=s.target.value.trim();this.debouncedFilterUpdate(e)})}renderIntegrationItems(i,r){let a=document.createDocumentFragment();if(r.innerHTML="",!i||i.length===0){this.noResultsContainer.classList.remove("hidden");let t=this.component.querySelector(".pagination");t&&t.classList.add("hidden");return}else this.noResultsContainer.classList.add("hidden");i?.forEach(t=>{let s=document.createElement("article");s.className=h.getItemClasses("relative h-full filter-item hidden");let e=t,l=e.isPublished?`href="./${encodeURIComponent(e.slug??"")}"`:"",o=e.isDraft?'<span class="absolute text-xs p-1 tracking-widest bg-blue-ice text-center text-muted z-10 top-0 left-0 w-full uppercase border border-b-0 border-edge-light">coming soon</span>':"",c=e.isRealtime?'<span class="absolute top-2 right-2 z-20 rounded-full bg-azure text-white text-[10px] leading-none px-2 py-1
1whitespace-nowrap">Real Time Data Source</span>':"";s.dataset.integrationSlug=t.slug,s.dataset.integrationTags=t.tags?.join(",").toLowerCase()||"",s.dataset.integrationTitle=t.name?.toLowerCase()||"",s.innerHTML=` 2 <a ${l} class="flex flex-col text-center justify-center items-center h-full group relative ${e.isPublished?"":" cursor-default pointer-events-none relative"}"> 3 <div class="relative z-10 flex flex-col items-center justify-center w-full h-full py-4 transition-all duration-300 ease-out overflow-hidden bg-brand-white border rounded-lg border-edge-light group-hover:shadow-dim group-active:translate-x-0.5 group-active:translate-y-0.5"> 4 ${o} 5 ${e.image?`<div class="flex items-center justify-center py-8 max-w-20 aspect-square max-h-8"><img src="${d(e.image)}" alt="${d(e.name)}" class="w-8 h-auto max-h-8 object-fit" loading="lazy" /></div>`:""} 6 <span class="pb-1 ${e.image?"text-xs":"text-xl"} text-blue-midnight">${d(e.name)}</span> 7 </div> 8 <span class="absolute z-0 h-5/6 w-5/6 right-0 bottom-0 group-hover:w-full group-hover:h-full transition-all duration-200 ease-out delay-75 rounded-lg opacity-50 bg-azure group-hover:translate-x-1.5 group-hover:translate-y-1.5"></span> 9 ${c}</a>`,a.appendChild(s)}),r.appendChild(a);let n=r.querySelectorAll(".filter-item");h.init(n)}async handleIntegrationsFilter(){this.component=document.querySelector(".sola-filter"),this.searchInput=this.component.querySelector("#filter-search"),this.noResultsContainer=this.component.querySelector(".no-results");let i=this.component.querySelector(".filter-items-grid");try{let a=(await this.cache.data).data;this.renderIntegrationItems(a,i),this.component.addEventListener("click",e=>{let l=e.target;if(l.classList.contains("category-button")){f(l,["active"]),this.updateActiveCategoriesCache();let o=this.searchInput.value.trim(),c={categories:Array.from(this.activeCategoriesCache).sort().join(","),search:o};if(c.categories===this.lastFilterState.categories&&c.search===this.lastFilterState.search)return;let u=this.performUnifiedFiltering(a,o);a.forEach(p=>{p.isActive=u.includes(p)}),this.showHideIntegrationItems(u,i),this.lastFilterState=c;let S=Array.from(this.activeCategoriesCache).join(",");C(S)}}),this.searchInput&&(this.setupOptimizedSearch(a,i),this.isInit&&this.searchQuery&&(this.searchInput.value=this.searchQuery)),y(this.component,a);let t=new URLSearchParams(window.location.search).get("filter"),s=a;if(t&&(t.split(",").map(l=>l.trim().replace(/[^a-zA-Z0-9-_]/g,"")).forEach(l=>{let o=this.component.querySelector(`[data-category="${l}"]`);o&&o.classList.add("active")}),this.updateActiveCategoriesCache(),s=this.performUnifiedFiltering(a,"",this.activeCategoriesCache)),this.isInit&&this.searchQuery){this.updateActiveCategoriesCache(),s=this.performUnifiedFiltering(a,this.searchQuery,this.activeCategoriesCache);let e=new Event("input",{bubbles:!0});this.searchInput.dispatchEvent(e),this.isInit=!1}s.forEach(e=>{e.isActive=!0}),a.forEach(e=>{s.includes(e)||(e.isActive=!1)}),this.showHideIntegrationItems(s,i),this.lastFilterState={categories:Array.from(this.activeCategoriesCache).sort().join(","),search:this.searchInput?.value.trim()||""}}catch(r){console.error("Error handling integrations filter:",r)}}},U=m;export{U 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.