2 lines
56 KiB
JavaScript
Raw Permalink Normal View History

2025-01-12 00:52:51 +08:00
(function(d,k){typeof define=="function"&&define.amd?define(["jquery"],k):typeof module=="object"&&typeof module.exports=="object"?module.exports=k(require("jquery")):d.Selectize=k(d.jQuery)})(this,function(d){"use strict";var k=function(e,t){if(!(typeof t=="string"&&!t.length)){var i=typeof t=="string"?new RegExp(t,"i"):t,n=function(r){var s=0;if(r.nodeType===3){var o=r.data.search(i);if(o>=0&&r.data.length>0){var a=r.data.match(i),l=document.createElement("span");l.className="highlight";var c=r.splitText(o),u=c.splitText(a[0].length),f=c.cloneNode(!0);l.appendChild(f),c.parentNode.replaceChild(l,c),s=1}}else if(r.nodeType===1&&r.childNodes&&!/(script|style)/i.test(r.tagName)&&(r.className!=="highlight"||r.tagName!=="SPAN"))for(var h=0;h<r.childNodes.length;++h)h+=n(r.childNodes[h]);return s};return e.each(function(){n(this)})}};d.fn.removeHighlight=function(){return this.find("span.highlight").each(function(){this.parentNode.firstChild.nodeName;var e=this.parentNode;e.replaceChild(this.firstChild,this),e.normalize()}).end()};var N=function(){};N.prototype={on:function(e,t){this._events=this._events||{},this._events[e]=this._events[e]||[],this._events[e].push(t)},off:function(e,t){var i=arguments.length;if(i===0)return delete this._events;if(i===1)return delete this._events[e];this._events=this._events||{},e in this._events&&this._events[e].splice(this._events[e].indexOf(t),1)},trigger:function(e){const t=this._events=this._events||{};if(e in t)for(var i=0;i<t[e].length;i++)t[e][i].apply(this,Array.prototype.slice.call(arguments,1))}},N.mixin=function(e){for(var t=["on","off","trigger"],i=0;i<t.length;i++)e.prototype[t[i]]=N.prototype[t[i]]};var Y={};Y.mixin=function(e){e.plugins={},e.prototype.initializePlugins=function(t){var i,n,r,s=this,o=[];if(s.plugins={names:[],settings:{},requested:{},loaded:{}},we(t))for(i=0,n=t.length;i<n;i++)typeof t[i]=="string"?o.push(t[i]):(s.plugins.settings[t[i].name]=t[i].options,o.push(t[i].name));else if(t)for(r in t)t.hasOwnProperty(r)&&(s.plugins.settings[r]=t[r],o.push(r));for(;o.length;)s.require(o.shift())},e.prototype.loadPlugin=function(t){var i=this,n=i.plugins,r=e.plugins[t];if(!e.plugins.hasOwnProperty(t))throw new Error('Unable to find "'+t+'" plugin');n.requested[t]=!0,n.loaded[t]=r.fn.apply(i,[i.plugins.settings[t]||{}]),n.names.push(t)},e.prototype.require=function(t){var i=this,n=i.plugins;if(!i.plugins.loaded.hasOwnProperty(t)){if(n.requested[t])throw new Error('Plugin has circular dependency ("'+t+'")');i.loadPlugin(t)}return n.loaded[t]},e.define=function(t,i){e.plugins[t]={name:t,fn:i}}};const G=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,i)=>t+=(i&=63)<36?i.toString(36):i<62?(i-26).toString(36).toUpperCase():i>62?"-":"_","");var A=function(e,t){this.items=e,this.settings=t||{diacritics:!0}};A.prototype.tokenize=function(e,t){if(e=se(String(e||"").toLowerCase()),!e||!e.length)return[];var i,n,r,s,o=[],a=e.split(/ +/);for(i=0,n=a.length;i<n;i++){if(r=oe(a[i]),this.settings.diacritics)for(s in D)D.hasOwnProperty(s)&&(r=r.replace(new RegExp(s,"g"),D[s]));t&&(r="\\b"+r),o.push({string:a[i],regex:new RegExp(r,"i")})}return o},A.prototype.iterator=function(e,t){var i;H(e)?i=Array.prototype.forEach||function(n){for(var r=0,s=this.length;r<s;r++)n(this[r],r,this)}:i=function(n){for(var r in this)this.hasOwnProperty(r)&&n(this[r],r,this)},i.apply(e,[t])},A.prototype.getScoreFunction=function(e,t){var i,n,r,s,o;i=this,e=i.prepareSearch(e,t),r=e.tokens,n=e.options.fields,s=r.length,o=e.options.nesting;var a=function(c,u){var f,h;return!c||(c=String(c||""),h=c.search(u.regex),h===-1)?0:(f=u.string.length/c.length,h===0&&(f+=.5),f)},l=function(){var c=n.length;return c?c===1?function(u,f){return a(W(f,n[0],o),u)}:function(u,f){for(var h=0,g=0;h<c;h++)g+=a(W(f,n[h],o),u);return g/c}:function(){return 0}}();return s?s===1?function(c){return l(r[0],c)}:e.options.conjunction==="and"?function(c){for(var u,f=0,h=0;f<s;f++){if(u=l(r[f],c),u<=0)return 0;h+=u}return h/s}:function(c){for(var u=0,f=0;u<s;u++)f+=l(r[u],c);return f/s}:function(){return 0}},A.prototype.getSor