PageSourceSearch

https://static.vecteezy.com/vite/assets/collections-modal-controller-BO7rZG4u-2.js

js vecteezy.com collected 2026-10-01 07:02:40 UTC 5,169 bytes, 1 lines download raw bytes

1import{s as P,t as O}from"./chunk-BkyDbNN--2.js";import{n as V}from"./stimulus-helpers-De2POZIB-2.js";import{H as E,q as J}from"./helpers-qziEORor-2.js";import Z from"./dialog-modal-controller-M4m9uWIP-2.js";import{t as M}from"./events-DS-yPW69-2.js";import{n as S}from"./search-helpers-COOeExXv-2.js";var $=O(((h,a)=>{(function(){var g=function(v,D,b,A){var n={};v=v||[],n.gramSizeLower=b||2,n.gramSizeUpper=A||3,n.useLevenshtein=typeof D!="boolean"?!0:D,n.exactSet={},n.matchDict={},n.items={};var B=function(e,t){for(var i=[],s,r,o=0;o<=t.length;o++)for(var l=0;l<=e.length;l++)o&&l?e.charAt(l-1)===t.charAt(o-1)?r=s:r=Math.min(i[l],i[l-1],s)+1:r=o+l,s=i[l],i[l]=r;return i.pop()},G=function(e,t){if(e===null&&t===null)throw"Trying to compare two null values";if(e===null||t===null)return 0;e=String(e),t=String(t);var i=B(e,t);return e.length>t.length?1-i/e.length:1-i/t.length},U=/[^a-zA-Z0-9\u00C0-\u00FF, ]+/g,N=function(e,t){t=t||2;var i="-"+e.toLowerCase().replace(U,"")+"-",s=t-i.length,r=[];if(s>0)for(var o=0;o<s;++o)i+="-";for(var o=0;o<i.length-t+1;++o)r.push(i.slice(o,o+t));return r},q=function(e,t){t=t||2;for(var i={},s=N(e,t),r=0;r<s.length;++r)s[r]in i?i[s[r]]+=1:i[s[r]]=1;return i};n.get=function(e,t,i){i===void 0&&(i=.33);var s=this._get(e,i);return!s&&typeof t<"u"?t:s},n._get=function(e,t){var i=this._normalizeStr(e),s=this.exactSet[i];if(s)return[[1,s]];for(var r=[],o=this.gramSizeUpper;o>=this.gramSizeLower;--o)if(r=this.__get(e,o,t),r&&r.length>0)return r;return null},n.__get=function(e,t,i){var s=this._normalizeStr(e),r={},o=q(s,t),l=this.items[t],m=0,c,z,u,L,y;for(c in o)if(z=o[c],m+=Math.pow(z,2),c in this.matchDict)for(u=0;u<this.matchDict[c].length;++u)L=this.matchDict[c][u][0],y=this.matchDict[c][u][1],L in r?r[L]+=z*y:r[L]=z*y;function R(f){for(var w in f)if(f.hasOwnProperty(w))return!1;return!0}if(R(r))return null;var H=Math.sqrt(m),p=[],F;for(var x in r)F=r[x],p.push([F/(H*l[x][0]),l[x][1]]);var T=function(f,w){return f[0]<w[0]?1:f[0]>w[0]?-1:0};if(p.sort(T),this.useLevenshtein){for(var _=[],I=Math.min(50,p.length),u=0;u<I;++u)_.push([G(p[u][1],s),p[u][1]]);p=_,p.sort(T)}var _=[];return p.forEach(function(f){f[0]>=i&&_.push([f[0],this.exactSet[f[1]]])}.bind(this)),_},n.add=function(e){if(this._normalizeStr(e)in this.exactSet)return!1;for(var t=this.gramSizeLower;t<this.gramSizeUpper+1;++t)this._add(e,t)},n._add=function(e,t){var i=this._normalizeStr(e),s=this.items[t]||[],r=s.length;s.push(0);var o=q(i,t),l=0,m,c;for(m in o)c=o[m],l+=Math.pow(c,2),m in this.matchDict?this.matchDict[m].push([r,c]):this.matchDict[m]=[[r,c]];s[r]=[Math.sqrt(l),i],this.items[t]=s,this.exactSet[i]=e},n._normalizeStr=function(e){if(Object.prototype.toString.call(e)!=="[object String]")throw"Must use a string as argument to FuzzySet functions";return e.toLowerCase()},n.length=function(){var e=0,t;for(t in this.exactSet)this.exactSet.hasOwnProperty(t)&&(e+=1);return e},n.isEmpty=function(){for(var e in this.exactSet)if(this.exactSet.hasOwnProperty(e))return!1;return!0},n.values=function(){var e=[],t;for(t in this.exactSet)this.exactSet.hasOwnProperty(t)&&e.push(this.exactSet[t]);return e};for(var d=n.gramSizeLower;d<n.gramSizeUpper+1;++d)n.items[d]=[];for(d=0;d<v.length;++d)n.add(v[d]);return n},C=this;typeof a<"u"&&a.exports?(a.exports=g,C&&(C.FuzzySet=g)):C.FuzzySet=g})()})),k=O(((h,a)=>{a.exports=$()})),K=P(k(),1),Q=class extends Z{constructor(...h){super(...h),this.closeCollectionsModal=a=>{this.close(a,null,this.element)},this.searchCollections=a=>{S(a.target.value).length?this.saveButtonTarget.classList.remove("is-disabled"):this.saveButtonTarget.classList.add("is-disabled"),this.filterCollections(S(a.target.value))},this.updateCollections=a=>{this.compileCollectionsList(),J(M.collections.search_collections,{},document.querySelector(".collections-search-form"))}}static{this.targets=["collectionsList","collectionsListItem","saveButton","searchForm"]}connect(){super.connect(),this.compileCollectionsList(),window.addEventListener("turbo:frame-load",this.updateCollections),this.searchFormTarget.addEventListener(M.collections.search_collections,this.searchCollections),document.documentElement.addEventListener("CloseCollectionModal",this.closeCollectionsModal)}disconnect(){this.searchFormTarget.removeEventListener(M.collections.search_collections,this.searchCollections),window.removeEventListener("turbo:frame-load",this.updateCollections),document.documentElement.removeEventListener("CloseCollectionModal",this.closeCollectionsModal),super.disconnect()}compileCollectionsList(){requestAnimationFrame(()=>{this.collections=document.getElementsByClassName("collections-list__item__name"),this.collectionsListArr=[...this.collections].map(h=>S(h.textContent)||S(h.innerText)),this.fuzzySearch=(0,K.default)(this.collectionsListArr,!1)})}filterCollections(h){const a=this.fuzzySearch.get(h,null,.2);E(this.collectionsListItemTargets,"show","flex"),h&&E(this.collectionsListItemTargets,"hide"),a&&a.forEach(g=>{const C=S(g[1]),v=[...this.collectionsListTarget.querySelectorAll(`[data-collection-name*="${C}"]`)];v&&E(v,"show","flex")})}};V({name:"collections-modal",import:Q});
1export{Q 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.