shafafiyat/static/assets/vendor/libs/bloodhound/bloodhound.js
2025-08-10 07:44:23 +03:30

2 lines
No EOL
14 KiB
JavaScript

/*! For license information please see bloodhound.js.LICENSE.txt */
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("jQuery"));else if("function"==typeof define&&define.amd)define(["jQuery"],e);else{var r="object"==typeof exports?e(require("jQuery")):e(t.jQuery);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(self,(function(t){return function(){var e={5469:function(t,e,r){var n,i,o;o=this,n=[r(1145)],i=function(t){return o.Bloodhound=(e=t,r=function(){"use strict";return{isMsie:function(){return!!/(msie|trident)/i.test(navigator.userAgent)&&navigator.userAgent.match(/(msie |rv:)(\d+(.\d+)?)/i)[2]},isBlankString:function(t){return!t||/^\s*$/.test(t)},escapeRegExChars:function(t){return t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isArray:e.isArray,isFunction:e.isFunction,isObject:e.isPlainObject,isUndefined:function(t){return void 0===t},isElement:function(t){return!(!t||1!==t.nodeType)},isJQuery:function(t){return t instanceof e},toStr:function(t){return r.isUndefined(t)||null===t?"":t+""},bind:e.proxy,each:function(t,r){e.each(t,(function(t,e){return r(e,t)}))},map:e.map,filter:e.grep,every:function(t,r){var n=!0;return t?(e.each(t,(function(e,i){if(!(n=r.call(null,i,e,t)))return!1})),!!n):n},some:function(t,r){var n=!1;return t?(e.each(t,(function(e,i){if(n=r.call(null,i,e,t))return!1})),!!n):n},mixin:e.extend,identity:function(t){return t},clone:function(t){return e.extend(!0,{},t)},getIdGenerator:function(){var t=0;return function(){return t++}},templatify:function(t){return e.isFunction(t)?t:function(){return String(t)}},defer:function(t){setTimeout(t,0)},debounce:function(t,e,r){var n,i;return function(){var o,s,u=this,c=arguments;return o=function(){n=null,r||(i=t.apply(u,c))},s=r&&!n,clearTimeout(n),n=setTimeout(o,e),s&&(i=t.apply(u,c)),i}},throttle:function(t,e){var r,n,i,o,s,u;return s=0,u=function(){s=new Date,i=null,o=t.apply(r,n)},function(){var c=new Date,a=e-(c-s);return r=this,n=arguments,a<=0?(clearTimeout(i),i=null,s=c,o=t.apply(r,n)):i||(i=setTimeout(u,a)),o}},stringify:function(t){return r.isString(t)?t:JSON.stringify(t)},noop:function(){}}}(),n="0.11.1",i=function(){"use strict";return{nonword:e,whitespace:t,obj:{nonword:n(e),whitespace:n(t)}};function t(t){return(t=r.toStr(t))?t.split(/\s+/):[]}function e(t){return(t=r.toStr(t))?t.split(/\W+/):[]}function n(t){return function(e){return e=r.isArray(e)?e:[].slice.call(arguments,0),function(n){var i=[];return r.each(e,(function(e){i=i.concat(t(r.toStr(n[e])))})),i}}}}(),s=function(){"use strict";function t(t){this.maxSize=r.isNumber(t)?t:100,this.reset(),this.maxSize<=0&&(this.set=this.get=e.noop)}function n(){this.head=this.tail=null}function i(t,e){this.key=t,this.val=e,this.prev=this.next=null}return r.mixin(t.prototype,{set:function(t,e){var r,n=this.list.tail;this.size>=this.maxSize&&(this.list.remove(n),delete this.hash[n.key],this.size--),(r=this.hash[t])?(r.val=e,this.list.moveToFront(r)):(r=new i(t,e),this.list.add(r),this.hash[t]=r,this.size++)},get:function(t){var e=this.hash[t];if(e)return this.list.moveToFront(e),e.val},reset:function(){this.size=0,this.hash={},this.list=new n}}),r.mixin(n.prototype,{add:function(t){this.head&&(t.next=this.head,this.head.prev=t),this.head=t,this.tail=this.tail||t},remove:function(t){t.prev?t.prev.next=t.next:this.head=t.next,t.next?t.next.prev=t.prev:this.tail=t.prev},moveToFront:function(t){this.remove(t),this.add(t)}}),t}(),u=function(){"use strict";var t;try{(t=window.localStorage).setItem("~~~","!"),t.removeItem("~~~")}catch(e){t=null}function n(e,n){this.prefix=["__",e,"__"].join(""),this.ttlKey="__ttl__",this.keyMatcher=new RegExp("^"+r.escapeRegExChars(this.prefix)),this.ls=n||t,!this.ls&&this._noop()}return r.mixin(n.prototype,{_prefix:function(t){return this.prefix+t},_ttlKey:function(t){return this._prefix(t)+this.ttlKey},_noop:function(){this.get=this.set=this.remove=this.clear=this.isExpired=r.noop},_safeSet:function(t,e){try{this.ls.setItem(t,e)}catch(t){"QuotaExceededError"===t.name&&(this.clear(),this._noop())}},get:function(t){return this.isExpired(t)&&this.remove(t),s(this.ls.getItem(this._prefix(t)))},set:function(t,e,n){return r.isNumber(n)?this._safeSet(this._ttlKey(t),o(i()+n)):this.ls.removeItem(this._ttlKey(t)),this._safeSet(this._prefix(t),o(e))},remove:function(t){return this.ls.removeItem(this._ttlKey(t)),this.ls.removeItem(this._prefix(t)),this},clear:function(){var e,r=function(e){var r,n,i=[],o=t.length;for(r=0;r<o;r++)(n=t.key(r)).match(e)&&i.push(n.replace(e,""));return i}(this.keyMatcher);for(e=r.length;e--;)this.remove(r[e]);return this},isExpired:function(t){var e=s(this.ls.getItem(this._ttlKey(t)));return!!(r.isNumber(e)&&i()>e)}}),n;function i(){return(new Date).getTime()}function o(t){return JSON.stringify(r.isUndefined(t)?null:t)}function s(t){return e.parseJSON(t)}}(),c=function(){"use strict";var t=0,n={},i=6,o=new s(10);function u(t){t=t||{},this.cancelled=!1,this.lastReq=null,this._send=t.transport,this._get=t.limiter?t.limiter(this._get):this._get,this._cache=!1===t.cache?new s(0):o}return u.setMaxPendingRequests=function(t){i=t},u.resetCache=function(){o.reset()},r.mixin(u.prototype,{_fingerprint:function(t){return(t=t||{}).url+t.type+e.param(t.data||{})},_get:function(e,r){var o,s,u=this;function c(t){r(null,t),u._cache.set(o,t)}function a(){r(!0)}o=this._fingerprint(e),this.cancelled||o!==this.lastReq||((s=n[o])?s.done(c).fail(a):t<i?(t++,n[o]=this._send(e).done(c).fail(a).always((function(){t--,delete n[o],u.onDeckRequestArgs&&(u._get.apply(u,u.onDeckRequestArgs),u.onDeckRequestArgs=null)}))):this.onDeckRequestArgs=[].slice.call(arguments,0))},get:function(t,n){var i,o;n=n||e.noop,t=r.isString(t)?{url:t}:t||{},o=this._fingerprint(t),this.cancelled=!1,this.lastReq=o,(i=this._cache.get(o))?n(null,i):this._get(t,n)},cancel:function(){this.cancelled=!0}}),u}(),a=window.SearchIndex=function(){"use strict";var t="c";function n(t){(t=t||{}).datumTokenizer&&t.queryTokenizer||e.error("datumTokenizer and queryTokenizer are both required"),this.identify=t.identify||r.stringify,this.datumTokenizer=t.datumTokenizer,this.queryTokenizer=t.queryTokenizer,this.reset()}return r.mixin(n.prototype,{bootstrap:function(t){this.datums=t.datums,this.trie=t.trie},add:function(e){var n=this;e=r.isArray(e)?e:[e],r.each(e,(function(e){var s,u;n.datums[s=n.identify(e)]=e,u=i(n.datumTokenizer(e)),r.each(u,(function(e){var r,i,u;for(r=n.trie,i=e.split("");u=i.shift();)(r=r[t][u]||(r[t][u]=o())).i.push(s)}))}))},get:function(t){var e=this;return r.map(t,(function(t){return e.datums[t]}))},search:function(e){var n,o,s=this;return n=i(this.queryTokenizer(e)),r.each(n,(function(e){var r,n,i,u;if(o&&0===o.length)return!1;for(r=s.trie,n=e.split("");r&&(i=n.shift());)r=r[t][i];if(!r||0!==n.length)return o=[],!1;u=r.i.slice(0),o=o?function(t,e){var r=0,n=0,i=[];t=t.sort(),e=e.sort();for(var o=t.length,s=e.length;r<o&&n<s;)t[r]<e[n]?r++:(t[r]>e[n]||(i.push(t[r]),r++),n++);return i}(o,u):u})),o?r.map(function(t){for(var e={},r=[],n=0,i=t.length;n<i;n++)e[t[n]]||(e[t[n]]=!0,r.push(t[n]));return r}(o),(function(t){return s.datums[t]})):[]},all:function(){var t=[];for(var e in this.datums)t.push(this.datums[e]);return t},reset:function(){this.datums={},this.trie=o()},serialize:function(){return{datums:this.datums,trie:this.trie}}}),n;function i(t){return t=r.filter(t,(function(t){return!!t})),r.map(t,(function(t){return t.toLowerCase()}))}function o(){var e={i:[]};return e[t]={},e}}(),h=function(){"use strict";var t;function e(t){this.url=t.url,this.ttl=t.ttl,this.cache=t.cache,this.prepare=t.prepare,this.transform=t.transform,this.transport=t.transport,this.thumbprint=t.thumbprint,this.storage=new u(t.cacheKey)}return t={data:"data",protocol:"protocol",thumbprint:"thumbprint"},r.mixin(e.prototype,{_settings:function(){return{url:this.url,type:"GET",dataType:"json"}},store:function(e){this.cache&&(this.storage.set(t.data,e,this.ttl),this.storage.set(t.protocol,location.protocol,this.ttl),this.storage.set(t.thumbprint,this.thumbprint,this.ttl))},fromCache:function(){var e,r={};return this.cache?(r.data=this.storage.get(t.data),r.protocol=this.storage.get(t.protocol),r.thumbprint=this.storage.get(t.thumbprint),e=r.thumbprint!==this.thumbprint||r.protocol!==location.protocol,r.data&&!e?r.data:null):null},fromNetwork:function(t){var e,r=this;t&&(e=this.prepare(this._settings()),this.transport(e).fail((function(){t(!0)})).done((function(e){t(null,r.transform(e))})))},clear:function(){return this.storage.clear(),this}}),e}(),l=function(){"use strict";function t(t){this.url=t.url,this.prepare=t.prepare,this.transform=t.transform,this.transport=new c({cache:t.cache,limiter:t.limiter,transport:t.transport})}return r.mixin(t.prototype,{_settings:function(){return{url:this.url,type:"GET",dataType:"json"}},get:function(t,e){var r,n=this;if(e)return t=t||"",r=this.prepare(t,this._settings()),this.transport.get(r,(function(t,r){e(t?[]:n.transform(r))}))},cancelLastRequest:function(){this.transport.cancel()}}),t}(),f=function(){"use strict";return function(i){var o,s;return o={initialize:!0,identify:r.stringify,datumTokenizer:null,queryTokenizer:null,sufficient:5,sorter:null,local:[],prefetch:null,remote:null},!(i=r.mixin(o,i||{})).datumTokenizer&&e.error("datumTokenizer is required"),!i.queryTokenizer&&e.error("queryTokenizer is required"),s=i.sorter,i.sorter=s?function(t){return t.sort(s)}:r.identity,i.local=r.isFunction(i.local)?i.local():i.local,i.prefetch=function(i){var o;return i?(o={url:null,ttl:864e5,cache:!0,cacheKey:null,thumbprint:"",prepare:r.identity,transform:r.identity,transport:null},i=r.isString(i)?{url:i}:i,!(i=r.mixin(o,i)).url&&e.error("prefetch requires url to be set"),i.transform=i.filter||i.transform,i.cacheKey=i.cacheKey||i.url,i.thumbprint=n+i.thumbprint,i.transport=i.transport?t(i.transport):e.ajax,i):null}(i.prefetch),i.remote=function(n){var i;if(n)return i={url:null,cache:!0,prepare:null,replace:null,wildcard:null,limiter:null,rateLimitBy:"debounce",rateLimitWait:300,transform:r.identity,transport:null},n=r.isString(n)?{url:n}:n,!(n=r.mixin(i,n)).url&&e.error("remote requires url to be set"),n.transform=n.filter||n.transform,n.prepare=function(t){var e,r,n;return e=t.prepare,r=t.replace,n=t.wildcard,e||(r?i:t.wildcard?o:s);function i(t,e){return e.url=r(e.url,t),e}function o(t,e){return e.url=e.url.replace(n,encodeURIComponent(t)),e}function s(t,e){return e}}(n),n.limiter=function(t){var e,n,i;return e=t.limiter,n=t.rateLimitBy,i=t.rateLimitWait,e||(e=/^throttle$/i.test(n)?s(i):o(i)),e;function o(t){return function(e){return r.debounce(e,t)}}function s(t){return function(e){return r.throttle(e,t)}}}(n),n.transport=n.transport?t(n.transport):e.ajax,delete n.replace,delete n.wildcard,delete n.rateLimitBy,delete n.rateLimitWait,n}(i.remote),i};function t(t){return function(n){var i=e.Deferred();return t(n,(function(t){r.defer((function(){i.resolve(t)}))}),(function(t){r.defer((function(){i.reject(t)}))})),i}}}(),p=function(){"use strict";var t;function n(t){t=f(t),this.sorter=t.sorter,this.identify=t.identify,this.sufficient=t.sufficient,this.local=t.local,this.remote=t.remote?new l(t.remote):null,this.prefetch=t.prefetch?new h(t.prefetch):null,this.index=new a({identify:this.identify,datumTokenizer:t.datumTokenizer,queryTokenizer:t.queryTokenizer}),!1!==t.initialize&&this.initialize()}return t=window&&window.Bloodhound,n.noConflict=function(){return window&&(window.Bloodhound=t),n},n.tokenizers=i,r.mixin(n.prototype,{__ttAdapter:function(){var t=this;return this.remote?function(e,r,n){return t.search(e,r,n)}:function(e,r){return t.search(e,r)}},_loadPrefetch:function(){var t,r,n=this;return t=e.Deferred(),this.prefetch?(r=this.prefetch.fromCache())?(this.index.bootstrap(r),t.resolve()):this.prefetch.fromNetwork((function(e,r){if(e)return t.reject();n.add(r),n.prefetch.store(n.index.serialize()),t.resolve()})):t.resolve(),t.promise()},_initialize:function(){var t=this;return this.clear(),(this.initPromise=this._loadPrefetch()).done((function(){t.add(t.local)})),this.initPromise},initialize:function(t){return!this.initPromise||t?this._initialize():this.initPromise},add:function(t){return this.index.add(t),this},get:function(t){return t=r.isArray(t)?t:[].slice.call(arguments),this.index.get(t)},search:function(t,e,n){var i,o=this;return i=this.sorter(this.index.search(t)),e(this.remote?i.slice():i),this.remote&&i.length<this.sufficient?this.remote.get(t,(function(t){var e=[];r.each(t,(function(t){!r.some(i,(function(e){return o.identify(t)===o.identify(e)}))&&e.push(t)})),n&&n(e)})):this.remote&&this.remote.cancelLastRequest(),this},all:function(){return this.index.all()},clear:function(){return this.index.reset(),this},clearPrefetchCache:function(){return this.prefetch&&this.prefetch.clear(),this},clearRemoteCache:function(){return c.resetCache(),this},ttAdapter:function(){return this.__ttAdapter()}}),n}(),p);var e,r,n,i,s,u,c,a,h,l,f,p}.apply(e,n),void 0===i||(t.exports=i)},1145:function(e){"use strict";e.exports=t}},r={};function n(t){var i=r[t];if(void 0!==i)return i.exports;var o=r[t]={exports:{}};return e[t].call(o.exports,o,o.exports,n),o.exports}n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,{a:e}),e},n.d=function(t,e){for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return function(){"use strict";n.r(i),n.d(i,{Bloodhound:function(){return e.a}});var t=n(5469),e=n.n(t);try{window.Bloodhound=e()}catch(t){}}(),i}()}));