searxng/searx/static/themes/simple/js/searxng.min.js
Markus Heiser 7a6ea56565 [web-client] simple theme: vite build -- CSS sourcemaps still missing!!!
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2025-02-28 12:27:41 +01:00

7 lines
26 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* @license
* (C) Copyright Contributors to the SearXNG project.
* (C) Copyright Contributors to the searx project (2014 - 2021).
* SPDX-License-Identifier: AGPL-3.0-or-later
*/window.searxng=function(p,d){p.Element&&function(i){i.matches=i.matches||i.matchesSelector||i.webkitMatchesSelector||i.msMatchesSelector||function(s){for(var l=this,n=(l.parentNode||l.document).querySelectorAll(s),e=-1;n[++e]&&n[e]!=l;);return!!n[e]}}(Element.prototype);function a(i,s,l){try{i.call(s,l)}catch(n){console.log(n)}}var h=window.searxng||{};h.on=function(i,s,l,n){n=n||!1,typeof i!="string"?i.addEventListener(s,l,n):d.addEventListener(s,function(e){for(var t=e.target||e.srcElement,o=!1;t&&t.matches&&t!==d&&!(o=t.matches(i));)t=t.parentElement;o&&a(l,t,e)},n)},h.ready=function(i){document.readyState!="loading"?i.call(p):p.addEventListener("DOMContentLoaded",i.bind(p))},h.http=function(i,s,l=null){return new Promise(function(n,e){try{var t=new XMLHttpRequest;t.open(i,s,!0),t.timeout=2e4,t.onload=function(){t.status==200?n(t.response,t.responseType):e(Error(t.statusText))},t.onerror=function(){e(Error("Network Error"))},t.onabort=function(){e(Error("Transaction is aborted"))},t.ontimeout=function(){e(Error("Timeout"))},l?t.send(l):t.send()}catch(o){e(o)}})},h.loadStyle=function(i){var s=h.settings.theme_static_path+"/"+i,l="style_"+i.replace(".","_"),n=d.getElementById(l);n===null&&(n=d.createElement("link"),n.setAttribute("id",l),n.setAttribute("rel","stylesheet"),n.setAttribute("type","text/css"),n.setAttribute("href",s),d.body.appendChild(n))},h.loadScript=function(i,s){var l=h.settings.theme_static_path+"/"+i,n="script_"+i.replace(".","_"),e=d.getElementById(n);if(e===null)e=d.createElement("script"),e.setAttribute("id",n),e.setAttribute("src",l),e.onload=s,e.onerror=function(){e.setAttribute("error","1")},d.body.appendChild(e);else if(e.hasAttribute("error"))console.log("callback not executed : script '"+l+"' not loaded.");else try{s.apply(e,[])}catch(t){console.log(t)}},h.insertBefore=function(i,s){s.parentNode.insertBefore(i,s)},h.insertAfter=function(i,s){s.parentNode.insertAfter(i,s.nextSibling)},h.on(".close","click",function(){this.parentNode.classList.add("invisible")});function m(){for(var i of d.getElementsByTagName("body")[0].classList.values())if(i.endsWith("_endpoint"))return i.split("_")[0];return""}return h.endpoint=m(),h}(window,document);searxng.ready(function(){if(searxng.infinite_scroll_supported="IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype,searxng.endpoint!=="results")return;if(!searxng.infinite_scroll_supported){console.log("IntersectionObserver not supported");return}let p=document;var d=p.getElementById("results").classList.contains("only_template_images");function a(){var i=p.createElement("div");return i.classList.add("loader"),i}function h(i,s){i.textContent="",s.forEach(l=>i.appendChild(l))}function m(i){var s=p.querySelector("#pagination form.next_page");if(s){h(p.querySelector("#pagination"),[a()]);var l=new FormData(s);searxng.http("POST",p.querySelector("#search").getAttribute("action"),l).then(function(n){var e=new DOMParser().parseFromString(n,"text/html"),t=e.querySelectorAll("#urls article"),o=e.querySelector("#pagination");p.querySelector("#pagination").remove(),t.length>0&&!d&&p.querySelector("#urls").appendChild(p.createElement("hr")),t.forEach(u=>{p.querySelector("#urls").appendChild(u)}),o&&(p.querySelector("#results").appendChild(o),i())}).catch(function(n){console.log(n);var e=p.createElement("div");e.textContent=searxng.settings.translations.error_loading_next_page,e.classList.add("dialog-error"),e.setAttribute("role","alert"),h(p.querySelector("#pagination"),[e])})}}if(searxng.settings.infinite_scroll&&searxng.infinite_scroll_supported){const i={rootMargin:"20rem"},s="article.result:last-child",l=new IntersectionObserver(n=>{const e=n[0];e.isIntersecting&&(l.unobserve(e.target),m(()=>l.observe(p.querySelector(s),i)))});l.observe(p.querySelector(s),i)}});searxng.ready(function(){function p(r){for(;r!==void 0;){if(r.classList.contains("detail"))return!0;if(r.classList.contains("result"))return!1;r=r.parentNode}return!1}function d(r){for(;r!==void 0;){if(r.classList.contains("result"))return r;r=r.parentNode}}function a(r){return r&&r.classList.contains("result-images")}searxng.on(".result","click",function(r){if(!p(r.target)){s(this)(!0,!0);let f=d(r.target);a(f)&&(r.preventDefault(),searxng.selectImage(f))}}),searxng.on(".result a","focus",function(r){if(!p(r.target)){let f=d(r.target);f&&f.getAttribute("data-vim-selected")===null&&s(f)(!0),a(f)&&searxng.selectImage(f)}},!0);var h={Escape:{key:"ESC",fun:n,des:"remove focus from the focused input",cat:"Control"},c:{key:"c",fun:T,des:"copy url of the selected result to the clipboard",cat:"Results"},h:{key:"h",fun:k,des:"toggle help window",cat:"Other"},i:{key:"i",fun:v,des:"focus on the search input",cat:"Control"},n:{key:"n",fun:t(),des:"go to next page",cat:"Results"},o:{key:"o",fun:b(!1),des:"open search result",cat:"Results"},p:{key:"p",fun:o(),des:"go to previous page",cat:"Results"},r:{key:"r",fun:l,des:"reload page from the server",cat:"Control"},t:{key:"t",fun:b(!0),des:"open the result in a new tab",cat:"Results"}},m={default:Object.assign({ArrowLeft:{key:"←",fun:s("up"),des:"select previous search result",cat:"Results"},ArrowRight:{key:"→",fun:s("down"),des:"select next search result",cat:"Results"}},h),vim:Object.assign({b:{key:"b",fun:c(-window.innerHeight),des:"scroll one page up",cat:"Navigation"},f:{key:"f",fun:c(window.innerHeight),des:"scroll one page down",cat:"Navigation"},u:{key:"u",fun:c(-window.innerHeight/2),des:"scroll half a page up",cat:"Navigation"},d:{key:"d",fun:c(window.innerHeight/2),des:"scroll half a page down",cat:"Navigation"},g:{key:"g",fun:y(-document.body.scrollHeight,"top"),des:"scroll to the top of the page",cat:"Navigation"},v:{key:"v",fun:y(document.body.scrollHeight,"bottom"),des:"scroll to the bottom of the page",cat:"Navigation"},k:{key:"k",fun:s("up"),des:"select previous search result",cat:"Results"},j:{key:"j",fun:s("down"),des:"select next search result",cat:"Results"},y:{key:"y",fun:T,des:"copy url of the selected result to the clipboard",cat:"Results"}},h)},i=m[searxng.settings.hotkeys]||m.default;searxng.on(document,"keydown",function(r){if(Object.prototype.hasOwnProperty.call(i,r.key)&&!r.ctrlKey&&!r.altKey&&!r.shiftKey&&!r.metaKey){var f=r.target.tagName.toLowerCase();r.key==="Escape"?i[r.key].fun(r):(r.target===document.body||f==="a"||f==="button")&&(r.preventDefault(),i[r.key].fun())}});function s(r){return function(f,S){var _=document.querySelector(".result[data-vim-selected]"),E=r;if(_===null){if(_=document.querySelector(".result"),_===null)return;(r==="down"||r==="up")&&(E=_)}var g,w=document.querySelectorAll(".result");if(w=Array.from(w),typeof E!="string")g=E;else switch(E){case"visible":for(var O=document.documentElement.scrollTop||document.body.scrollTop,x=O+document.documentElement.clientHeight,R=0;R<w.length;R++){g=w[R];var I=g.offsetTop,q=I+g.clientHeight;if(q<=x&&I>O)break}break;case"down":g=w[w.indexOf(_)+1]||_;break;case"up":g=w[w.indexOf(_)-1]||_;break;case"bottom":g=w[w.length-1];break;case"top":default:g=w[0]}if(g){if(_.removeAttribute("data-vim-selected"),g.setAttribute("data-vim-selected","true"),!S){var D=g.querySelector("h3 a")||g.querySelector("a");D!==null&&D.focus()}f||u()}}}function l(){document.location.reload(!0)}function n(r){const f=r.target.tagName.toLowerCase();document.activeElement&&(f==="input"||f==="select"||f==="textarea")?document.activeElement.blur():searxng.closeDetail()}function e(r){return function(){var f=document.querySelector(r);f&&f.click()}}function t(){return e('nav#pagination .next_page button[type="submit"]')}function o(){return e('nav#pagination .previous_page button[type="submit"]')}function u(){var r=document.querySelector(".result[data-vim-selected]");if(r!==null){var f=document.documentElement.scrollTop||document.body.scrollTop,S=document.documentElement.clientHeight,_=r.offsetTop,E=_+r.clientHeight,g=120;if(r.previousElementSibling===null&&E<S){window.scroll(window.scrollX,0);return}if(f>_-g)window.scroll(window.scrollX,_-g);else{var w=f+S;w<E+g&&window.scroll(window.scrollX,E-S+g)}}}function c(r){return function(){window.scrollBy(0,r),s("visible")()}}function y(r,f){return function(){window.scrollTo(0,r),s(f)()}}function v(){window.scrollTo(0,0);var r=document.querySelector("#q");if(r.focus(),r.setSelectionRange){var f=r.value.length;r.setSelectionRange(f,f)}}function b(r){return function(){var f=document.querySelector(".result[data-vim-selected] h3 a");if(f===null&&(f=document.querySelector(".result[data-vim-selected] > a")),f!==null){var S=f.getAttribute("href");r?window.open(S):window.location.href=S}}}function M(r){var f={};for(var S in i){var _=i[S];f[_.cat]=f[_.cat]||[],f[_.cat].push(_)}var E=Object.keys(f).sort(function(q,D){return f[D].length-f[q].length});if(E.length!==0){var g='<a href="#" class="close" aria-label="close" title="close">×</a>';g+="<h3>How to navigate SearXNG with hotkeys</h3>",g+="<table>";for(var w=0;w<E.length;w++){var O=f[E[w]],x=w===E.length-1,R=w%2===0;R&&(g+="<tr>"),g+="<td>",g+="<h4>"+O[0].cat+"</h4>",g+='<ul class="list-unstyled">';for(var I in O)g+="<li><kbd>"+O[I].key+"</kbd> "+O[I].des+"</li>";g+="</ul>",g+="</td>",(!R||x)&&(g+="</tr>")}g+="</table>",r.innerHTML=g}}function k(){var r=document.querySelector("#vim-hotkeys-help");if(r==null){r=document.createElement("div"),r.id="vim-hotkeys-help",r.className="dialog-modal",M(r);var f=document.getElementsByTagName("body")[0];f.appendChild(r)}else{r.classList.toggle("invisible");return}}function T(){var r=document.querySelector(".result[data-vim-selected] h3 a");if(r===null)return;const f=r.getAttribute("href");navigator.clipboard.writeText(f)}searxng.scrollPageToSelected=u,searxng.selectNext=s("down"),searxng.selectPrevious=s("up")});(function(p,d,a){a.ready(function(){a.on(".searxng_init_map","click",function(h){this.classList.remove("searxng_init_map");var m=this.dataset.leafletTarget,i=parseFloat(this.dataset.mapLon),s=parseFloat(this.dataset.mapLat),l=parseFloat(this.dataset.mapZoom),n=JSON.parse(this.dataset.mapBoundingbox),e=JSON.parse(this.dataset.mapGeojson);a.loadStyle("css/leaflet.css"),a.loadScript("js/leaflet.js",function(){var t=null;if(n){var o=L.latLng(n[0],n[2]),u=L.latLng(n[1],n[3]);t=L.latLngBounds(o,u)}var c=L.map(m),y="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",v='Map data © <a href="https://openstreetmap.org">OpenStreetMap</a> contributors',b=new L.TileLayer(y,{minZoom:1,maxZoom:19,attribution:v}),M="https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png",k='Wikimedia maps | Maps data © <a href="https://openstreetmap.org">OpenStreetMap contributors</a>',T=new L.TileLayer(M,{minZoom:1,maxZoom:19,attribution:k});t?setTimeout(function(){c.fitBounds(t,{maxZoom:17})},0):i&&s&&(l?c.setView(new L.latLng(s,i),l):c.setView(new L.latLng(s,i),8)),c.addLayer(b);var r={"OSM Mapnik":b,"OSM Wikimedia":T};L.control.layers(r).addTo(c),e&&L.geoJson(e).addTo(c)}),h.preventDefault()})})})(window,document,window.searxng);(function(p,d,a){a.endpoint==="preferences"&&a.ready(function(){let h=null;function m(){h==null&&a.http("GET","engine_descriptions.json").then(function(t){h=JSON.parse(t);for(const[o,u]of Object.entries(h)){let c=d.querySelectorAll('[data-engine-name="'+o+'"] .engine-description');for(const y of c){let v=" (<i>"+a.settings.translations.Source+":&nbsp;"+u[1]+"</i>)";y.innerHTML=u[0]+v}}})}for(const t of d.querySelectorAll("[data-engine-name]"))a.on(t,"mouseenter",m);const i=d.querySelectorAll(".enable-all-engines"),s=d.querySelectorAll(".disable-all-engines"),l=d.querySelectorAll("tbody input[type=checkbox][class~=checkbox-onoff]"),n=t=>{for(const o of l)o.offsetParent!==null&&(o.checked=!t)};for(const t of i)a.on(t,"click",()=>n(!0));for(const t of s)a.on(t,"click",()=>n(!1));const e=d.querySelector("#copy-hash");a.on(e,"click",t=>{t.preventDefault(),navigator.clipboard.writeText(e.dataset.hash),e.innerText=e.dataset.copiedText})})})(window,document,window.searxng);(function(p,d,a){a.endpoint==="results"&&a.ready(function(){d.querySelectorAll("#urls img").forEach(l=>l.addEventListener("error",()=>{l.src=window.searxng.settings.theme_static_path+"/img/img_load_error.svg"},{once:!0})),d.querySelector("#search_url button#copy_url")&&(d.querySelector("#search_url button#copy_url").style.display="block"),a.on(".btn-collapse","click",function(){var l=this.getAttribute("data-btn-text-collapsed"),n=this.getAttribute("data-btn-text-not-collapsed"),e=this.getAttribute("data-target"),t=d.querySelector(e),o=this.innerHTML;this.classList.contains("collapsed")?o=o.replace(l,n):o=o.replace(n,l),this.innerHTML=o,this.classList.toggle("collapsed"),t.classList.toggle("invisible")}),a.on(".media-loader","click",function(){var l=this.getAttribute("data-target"),n=d.querySelector(l+" > iframe"),e=n.getAttribute("src");(e==null||e===!1)&&n.setAttribute("src",n.getAttribute("data-src"))}),a.on("#copy_url","click",function(){var l=this.parentElement.querySelector("pre");navigator.clipboard.writeText(l.innerText),this.innerText=this.dataset.copiedText});let h;const m=d.createElement("div");m.classList.add("loader");const i=new Image,s=(l,n)=>{h&&clearTimeout(h),h=setTimeout(()=>{i.src=l},1e3),i.onload=()=>{n(),m.remove()},i.onerror=()=>{m.remove()}};a.selectImage=l=>{if(d.getElementById("results").classList.add("image-detail-open"),window.location.hash="#image-viewer",a.scrollPageToSelected(),!l)return;const n=l.querySelector(".result-images-source img");if(!n)return;const e=n.getAttribute("data-src");if(!e)return;const t=l.querySelector(".image_thumbnail");n.src=t.src,l.querySelector(".detail").appendChild(m),s(e,()=>{n.src=e,n.removeAttribute("data-src")})},a.closeDetail=function(){d.getElementById("results").classList.remove("image-detail-open"),window.location.hash=="#image-viewer"&&window.history.back(),a.scrollPageToSelected()},a.on(".result-detail-close","click",l=>{l.preventDefault(),a.closeDetail()}),a.on(".result-detail-previous","click",l=>{l.preventDefault(),a.selectPrevious(!1)}),a.on(".result-detail-next","click",l=>{l.preventDefault(),a.selectNext(!1)}),window.addEventListener("hashchange",()=>{window.location.hash!="#image-viewer"&&a.closeDetail()}),d.querySelectorAll(".swipe-horizontal").forEach(l=>{l.addEventListener("swiped-left",function(){a.selectNext(!1)}),l.addEventListener("swiped-right",function(){a.selectPrevious(!1)})}),p.addEventListener("scroll",function(){var l=d.getElementById("backToTop"),n=document.documentElement.scrollTop||document.body.scrollTop,e=d.getElementById("results");l!==null&&(n>=100?e.classList.add("scrolling"):e.classList.remove("scrolling"))},!0)})})(window,document,window.searxng);function P(p){return p&&p.__esModule&&Object.prototype.hasOwnProperty.call(p,"default")?p.default:p}function C(p){throw new Error('Could not dynamically require "'+p+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var N={exports:{}},H;function B(){return H||(H=1,function(p,d){(function(a){p.exports=a()})(function(){return function(){function a(h,m,i){function s(e,t){if(!m[e]){if(!h[e]){var o=typeof C=="function"&&C;if(!t&&o)return o(e,!0);if(l)return l(e,!0);var u=new Error("Cannot find module '"+e+"'");throw u.code="MODULE_NOT_FOUND",u}var c=m[e]={exports:{}};h[e][0].call(c.exports,function(y){var v=h[e][1][y];return s(v||y)},c,c.exports,a,h,m,i)}return m[e].exports}for(var l=typeof C=="function"&&C,n=0;n<i.length;n++)s(i[n]);return s}return a}()({1:[function(a,h,m){var i;(function(n){n[n.AND=0]="AND",n[n.OR=1]="OR"})(i||(i={}));var s;(function(n){n[n.KEYDOWN=0]="KEYDOWN",n[n.KEYUP=1]="KEYUP"})(s||(s={}));var l=function(){function n(e,t){if(e===void 0&&(e={}),t===void 0&&(t="[data-autocomplete]"),Array.isArray(t))t.forEach(function(c){new n(e,c)});else if(typeof t=="string"){var o=document.querySelectorAll(t);Array.prototype.forEach.call(o,function(c){new n(e,c)})}else{var u=n.merge(n.defaults,e,{DOMResults:document.createElement("div")});return n.prototype.create(u,t),u}}return n.prototype.create=function(e,t){if(e.Input=t,e.Input.nodeName.match(/^INPUT$/i)&&(e.Input.hasAttribute("type")===!1||e.Input.getAttribute("type").match(/^TEXT|SEARCH$/i))){e.Input.setAttribute("autocomplete","off"),e._Position(e),e.Input.parentNode.appendChild(e.DOMResults),e.$Listeners={blur:e._Blur.bind(e),destroy:n.prototype.destroy.bind(null,e),focus:e._Focus.bind(e),keyup:n.prototype.event.bind(null,e,s.KEYUP),keydown:n.prototype.event.bind(null,e,s.KEYDOWN),position:e._Position.bind(e)};for(var o in e.$Listeners)e.Input.addEventListener(o,e.$Listeners[o])}},n.prototype.getEventsByType=function(e,t){var o={};for(var u in e.KeyboardMappings){var c=s.KEYUP;e.KeyboardMappings[u].Event!==void 0&&(c=e.KeyboardMappings[u].Event),c==t&&(o[u]=e.KeyboardMappings[u])}return o},n.prototype.event=function(e,t,o){var u=function(b){(v===!0&&y.Operator==i.AND||v===!1&&y.Operator==i.OR)&&(b=n.merge({Not:!1},b),b.hasOwnProperty("Is")?b.Is==o.keyCode?v=!b.Not:v=b.Not:b.hasOwnProperty("From")&&b.hasOwnProperty("To")&&(o.keyCode>=b.From&&o.keyCode<=b.To?v=!b.Not:v=b.Not))};for(var c in n.prototype.getEventsByType(e,t)){var y=n.merge({Operator:i.AND},e.KeyboardMappings[c]),v=i.AND==y.Operator;y.Conditions.forEach(u),v===!0&&y.Callback.call(e,o)}},n.prototype.makeRequest=function(e,t,o){var u=Object.getOwnPropertyNames(e.HttpHeaders),c=new XMLHttpRequest,y=e._HttpMethod(),v=e._Url(),b=e._Pre(),M=encodeURIComponent(e._QueryArg())+"="+encodeURIComponent(b);y.match(/^GET$/i)&&(v.indexOf("?")!==-1?v+="&"+M:v+="?"+M),c.open(y,v,!0);for(var k=u.length-1;k>=0;k--)c.setRequestHeader(u[k],e.HttpHeaders[u[k]]);return c.onreadystatechange=function(){c.readyState==4&&c.status==200?(e.$Cache[b]=c.response,t(c.response)):c.status>=400&&o()},c},n.prototype.ajax=function(e,t,o){o===void 0&&(o=!0),e.$AjaxTimer&&window.clearTimeout(e.$AjaxTimer),o===!0?e.$AjaxTimer=window.setTimeout(n.prototype.ajax.bind(null,e,t,!1),e.Delay):(e.Request&&e.Request.abort(),e.Request=t,e.Request.send(e._QueryArg()+"="+e._Pre()))},n.prototype.cache=function(e,t,o){var u=e._Cache(e._Pre());if(u===void 0){var c=n.prototype.makeRequest(e,t,o);n.prototype.ajax(e,c)}else t(u)},n.prototype.destroy=function(e){for(var t in e.$Listeners)e.Input.removeEventListener(t,e.$Listeners[t]);e.DOMResults.parentNode.removeChild(e.DOMResults)},n.merge=function(){for(var e={},t,o=0;o<arguments.length;o++)for(t in arguments[o])e[t]=arguments[o][t];return e},n.defaults={Delay:150,EmptyMessage:"No result here",Highlight:{getRegex:function(e){return new RegExp(e,"ig")},transform:function(e){return"<strong>"+e+"</strong>"}},HttpHeaders:{"Content-type":"application/x-www-form-urlencoded"},Limit:0,MinChars:0,HttpMethod:"GET",QueryArg:"q",Url:null,KeyboardMappings:{Enter:{Conditions:[{Is:13,Not:!1}],Callback:function(e){if(this.DOMResults.getAttribute("class").indexOf("open")!=-1){var t=this.DOMResults.querySelector("li.active");t!==null&&(e.preventDefault(),this._Select(t),this.DOMResults.setAttribute("class","autocomplete"))}},Operator:i.AND,Event:s.KEYDOWN},KeyUpAndDown_down:{Conditions:[{Is:38,Not:!1},{Is:40,Not:!1}],Callback:function(e){e.preventDefault()},Operator:i.OR,Event:s.KEYDOWN},KeyUpAndDown_up:{Conditions:[{Is:38,Not:!1},{Is:40,Not:!1}],Callback:function(e){e.preventDefault();var t=this.DOMResults.querySelector("li:first-child:not(.locked)"),o=this.DOMResults.querySelector("li:last-child:not(.locked)"),u=this.DOMResults.querySelector("li.active");if(u){var c=Array.prototype.indexOf.call(u.parentNode.children,u),y=c+(e.keyCode-39),v=this.DOMResults.getElementsByTagName("li").length;y<0?y=v-1:y>=v&&(y=0),u.classList.remove("active"),u.parentElement.children.item(y).classList.add("active")}else o&&e.keyCode==38?o.classList.add("active"):t&&t.classList.add("active")},Operator:i.OR,Event:s.KEYUP},AlphaNum:{Conditions:[{Is:13,Not:!0},{From:35,To:40,Not:!0}],Callback:function(){var e=this.Input.getAttribute("data-autocomplete-old-value"),t=this._Pre();t!==""&&t.length>=this._MinChars()?((!e||t!=e)&&this.DOMResults.setAttribute("class","autocomplete open"),n.prototype.cache(this,(function(o){this._Render(this._Post(o)),this._Open()}).bind(this),this._Error)):this._Close()},Operator:i.AND,Event:s.KEYUP}},DOMResults:null,Request:null,Input:null,_EmptyMessage:function(){var e="";return this.Input.hasAttribute("data-autocomplete-empty-message")?e=this.Input.getAttribute("data-autocomplete-empty-message"):this.EmptyMessage!==!1?e=this.EmptyMessage:e="",e},_Limit:function(){var e=this.Input.getAttribute("data-autocomplete-limit");return isNaN(e)||e===null?this.Limit:parseInt(e,10)},_MinChars:function(){var e=this.Input.getAttribute("data-autocomplete-minchars");return isNaN(e)||e===null?this.MinChars:parseInt(e,10)},_Highlight:function(e){return e.replace(this.Highlight.getRegex(this._Pre()),this.Highlight.transform)},_HttpMethod:function(){return this.Input.hasAttribute("data-autocomplete-method")?this.Input.getAttribute("data-autocomplete-method"):this.HttpMethod},_QueryArg:function(){return this.Input.hasAttribute("data-autocomplete-param-name")?this.Input.getAttribute("data-autocomplete-param-name"):this.QueryArg},_Url:function(){return this.Input.hasAttribute("data-autocomplete")?this.Input.getAttribute("data-autocomplete"):this.Url},_Blur:function(e){if(e===void 0&&(e=!1),e)this._Close();else{var t=this;setTimeout(function(){t._Blur(!0)},150)}},_Cache:function(e){return this.$Cache[e]},_Focus:function(){var e=this.Input.getAttribute("data-autocomplete-old-value");(!e||this.Input.value!=e)&&this._MinChars()<=this.Input.value.length&&this.DOMResults.setAttribute("class","autocomplete open")},_Open:function(){var e=this;Array.prototype.forEach.call(this.DOMResults.getElementsByTagName("li"),function(t){t.getAttribute("class")!="locked"&&(t.onclick=function(){e._Select(t)})})},_Close:function(){this.DOMResults.setAttribute("class","autocomplete")},_Position:function(){this.DOMResults.setAttribute("class","autocomplete"),this.DOMResults.setAttribute("style","top:"+(this.Input.offsetTop+this.Input.offsetHeight)+"px;left:"+this.Input.offsetLeft+"px;width:"+this.Input.clientWidth+"px;")},_Render:function(e){var t;typeof e=="string"?t=this._RenderRaw(e):t=this._RenderResponseItems(e),this.DOMResults.hasChildNodes()&&this.DOMResults.removeChild(this.DOMResults.childNodes[0]),this.DOMResults.appendChild(t)},_RenderResponseItems:function(e){var t=document.createElement("ul"),o=document.createElement("li"),u=this._Limit();u<0?e=e.reverse():u===0&&(u=e.length);for(var c=0;c<Math.min(Math.abs(u),e.length);c++)o.innerHTML=e[c].Label,o.setAttribute("data-autocomplete-value",e[c].Value),t.appendChild(o),o=document.createElement("li");return t},_RenderRaw:function(e){var t=document.createElement("ul"),o=document.createElement("li");if(e.length>0)this.DOMResults.innerHTML=e;else{var u=this._EmptyMessage();u!==""&&(o.innerHTML=u,o.setAttribute("class","locked"),t.appendChild(o))}return t},_Post:function(e){try{var t=[],o=JSON.parse(e);if(Object.keys(o).length===0)return"";if(Array.isArray(o))for(var u=0;u<Object.keys(o).length;u++)t[t.length]={Value:o[u],Label:this._Highlight(o[u])};else for(var c in o)t.push({Value:c,Label:this._Highlight(o[c])});return t}catch{return e}},_Pre:function(){return this.Input.value},_Select:function(e){e.hasAttribute("data-autocomplete-value")?this.Input.value=e.getAttribute("data-autocomplete-value"):this.Input.value=e.innerHTML,this.Input.setAttribute("data-autocomplete-old-value",this.Input.value)},_Error:function(){},$AjaxTimer:null,$Cache:{},$Listeners:{}},n}();h.exports=l},{}]},{},[1])(1)})}(N)),N.exports}var K=B();const A=P(K);(function(p,d,a){var h="q",m;const i=window.matchMedia("only screen and (max-width: 50em)").matches;function s(){if(m.value.length>0){var n=document.getElementById("search");setTimeout(n.submit.bind(n),0)}}function l(n){var e=document.getElementById("clear_search"),t=function(){n.value.length===0?e.classList.add("empty"):e.classList.remove("empty")};t(),e.addEventListener("click",function(o){n.value="",n.focus(),t(),o.preventDefault()}),n.addEventListener("input",t,!1)}a.ready(function(){m=d.getElementById(h),m!==null&&(l(m),a.settings.autocomplete&&(a.autocomplete=A.call(p,{Url:"./autocompleter",EmptyMessage:a.settings.translations.no_item_found,HttpMethod:a.settings.method,HttpHeaders:{"Content-type":"application/x-www-form-urlencoded","X-Requested-With":"XMLHttpRequest"},MinChars:a.settings.autocomplete_min,Delay:300,_Position:function(){},_Open:function(){var t=this;Array.prototype.forEach.call(this.DOMResults.getElementsByTagName("li"),function(o){o.getAttribute("class")!="locked"&&(o.onmousedown=function(){t._Select(o)})})},_Select:function(t){A.defaults._Select.call(this,t);var o=t.closest("form");o&&o.submit()},_MinChars:function(){return this.Input.value.indexOf("!")>-1?0:A.defaults._MinChars.call(this)},KeyboardMappings:Object.assign({},A.defaults.KeyboardMappings,{KeyUpAndDown_up:Object.assign({},A.defaults.KeyboardMappings.KeyUpAndDown_up,{Callback:function(t){A.defaults.KeyboardMappings.KeyUpAndDown_up.Callback.call(this,t);var o=this.DOMResults.querySelector("li.active");o&&A.defaults._Select.call(this,o)}}),Tab:Object.assign({},A.defaults.KeyboardMappings.Enter,{Conditions:[{Is:9,Not:!1}],Callback:function(t){if(this.DOMResults.getAttribute("class").indexOf("open")!=-1){var o=this.DOMResults.querySelector("li.active");o!==null&&(A.defaults._Select.call(this,o),t.preventDefault())}}})})},"#"+h)),A.prototype.ajax=function(t,o,u){u===void 0&&(u=!0),t.$AjaxTimer&&window.clearTimeout(t.$AjaxTimer),u===!0?t.$AjaxTimer=window.setTimeout(A.prototype.ajax.bind(null,t,o,!1),t.Delay):(t.Request&&t.Request.abort(),t.Request=o,t.Request.send(encodeURIComponent(t._QueryArg())+"="+encodeURIComponent(t._Pre())))},!i&&document.querySelector(".index_endpoint")&&m.focus()),m!==null&&a.settings.search_on_category_select&&d.querySelector(".search_filters")!=null&&(a.on(d.getElementById("safesearch"),"change",s),a.on(d.getElementById("time_range"),"change",s),a.on(d.getElementById("language"),"change",s));const n=d.querySelectorAll("button.category_button");for(let t of n)a.on(t,"click",o=>{if(o.shiftKey){o.preventDefault(),t.classList.toggle("selected");return}const u=d.querySelectorAll("button.category_button.selected");for(let c of u)c.classList.remove("selected");t.classList.add("selected")});const e=d.querySelector("#search");e!=null&&a.on(e,"submit",t=>{t.preventDefault();const o=d.querySelector("#selected-categories");if(o){let u=[];for(let c of n)c.classList.contains("selected")&&u.push(c.name.replace("category_",""));o.value=u.join(",")}e.submit()})})})(window,document,window.searxng);
//# sourceMappingURL=searxng.min.js.map