js-sniper
Version:
A lightweight JavaScript library that lets you code smarter and build faster
12 lines (8 loc) • 31.8 kB
JavaScript
(function(){function t(e,n,o){function r(s,l){if(!n[s]){if(!e[s]){var a="function"==typeof require&&require;if(!l&&a)return a(s,!0);if(i)return i(s,!0);var u=Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var h=n[s]={exports:{}};e[s][0].call(h.exports,function(t){return r(e[s][1][t]||t)},h,h.exports,t,e,n,o)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<o.length;s++)r(o[s]);return r}return t})()({1:[function(t,e,n){/*! *****************************************************************************
Name:SniperJs 2.2.1
documentation: https://sniperjs.gitbook.io/docs
ISC License
Copyright (c) 2024 jubbytech Inc.
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */ t("./plugins/ssp.js"),t("./modules/dom.js"),t("./modules/xhr.js");let o=t("./modules/utils.js");for(let r in o)if(Object.prototype.hasOwnProperty.call(o,r)){let i=o[r];window[r]=i}},{"./modules/dom.js":2,"./modules/utils.js":3,"./modules/xhr.js":4,"./plugins/ssp.js":5}],2:[function(t,e,n){let{isObject:o}=t("./utils");Object.defineProperty(Object.prototype,"isEmpty",{value:function(){let t=[];for(key in this)Object.hasOwnProperty.apply(this,[key])&&t.push(key);return 0===t.length},enumerable:!1,writable:!0,configurable:!0}),String.prototype.capitalizeFirstLetters=function(){return this.replace(/\w\S*/g,t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase())},String.prototype.capitalizeFirstLetter=function(){return this.charAt(0).toUpperCase()+this.slice(1)},Array.prototype.shuffle=function(){let t=this.length,e;for(;0!=t;)e=Math.floor(Math.random()*t),t--,[this[t],this[e]]=[this[e],this[t]];return this},Array.prototype.moveBackward=function(){return this.push(this.shift()),this},Array.prototype.moveForward=function(){return this.unshift(this.pop()),this},window.$=window.$niper=function(t="",e=!1){try{if(t instanceof HTMLElement)return t;if((t=t.trim()).endsWith("*")){if((t=t.substring(0,t.length-1).trim()).startsWith("#"))return document.getElementById(t.substring(1));e=!0}return e?document.querySelectorAll(t):document.querySelector(t)}catch(n){console.error(n)}},String.prototype.truncate=function(t=200){return this.length>t?this.substring(0,t)+"...":this.toString()},HTMLElement.prototype.addClass=function(t){return this.classList.add(t),this},HTMLElement.prototype.setClass=function(t){return this.className=t,this},NodeList.prototype.setClass=HTMLCollection.prototype.setClass=function(t){return Array.from(this).forEach(e=>e.className=t),this},NodeList.prototype.addClass=HTMLCollection.prototype.addClass=function(t){return Array.from(this).forEach(e=>e.classList.add(t)),this},NodeList.prototype.replaceClass=HTMLCollection.prototype.replaceClass=function(t,e){return Array.from(this).forEach(n=>n.classList.replace(t,e)),this},HTMLElement.prototype.replaceClass=function(t,e){return this.classList.replace(t,e),this},NodeList.prototype.removeClass=HTMLCollection.prototype.removeClass=function(t){return Array.from(this).forEach(e=>e.classList.remove(t)),this},HTMLElement.prototype.removeClass=function(t){return this.classList.remove(t),this},HTMLElement.prototype.toggleClass=function t(e){return this.classList.toggle(e),this},NodeList.prototype.toggleClass=HTMLCollection.prototype.toggleClass=function t(e){return Array.from(this).forEach(t=>t.classList.toggle(e)),this},HTMLElement.prototype.html=function(){return 1===arguments.length&&"function"==typeof arguments[0]?(this.innerHTML=arguments[0].call(this,this.innerHTML),this):1===arguments.length?(this.innerHTML=arguments[0],this):this.innerHTML},NodeList.prototype.html=HTMLCollection.prototype.html=function(){if(1===arguments.length){for(let t of this)t.html(...arguments);return this}return Array.from(this).map(t=>t.innerHTML)},HTMLElement.prototype.text=function(){return 1===arguments.length&&"function"==typeof arguments[0]?(this.textContent=arguments[0].call(this,this.textContent),this):1===arguments.length?(this.textContent=arguments[0],this):this.textContent},NodeList.prototype.text=HTMLCollection.prototype.text=function(){if(1===arguments.length){for(let t of this)t.text(...arguments);return this}return Array.from(this).map(t=>t.textContent)},Object.defineProperty(HTMLAnchorElement.prototype,"text",{value:function(){return 1===arguments.length&&"function"==typeof arguments[0]?(this.textContent=arguments[0].call(this,this.textContent),this):1===arguments.length?(this.textContent=arguments[0],this):this.textContent},enumerable:!1}),HTMLElement.prototype.val=function(){return 1===arguments.length&&"function"==typeof arguments[0]?(this.value=arguments[0].call(this,this.value),this):1===arguments.length?(this.value=arguments[0],this):this.value},NodeList.prototype.val=HTMLCollection.prototype.val=function(){if(1===arguments.length){for(let t of this)t.val(...arguments);return this}return Array.from(this).map(t=>t.value)},HTMLElement.prototype.hasClass=function(t){return this.classList.contains(t)},NodeList.prototype.hasClass=HTMLCollection.prototype.hasClass=function(t){return Array.from(this).every(e=>e.classList.contains(t))},NodeList.prototype.addEventListener=HTMLCollection.prototype.addEventListener=function(t,e,n){return Array.from(this).forEach(o=>o.addEventListener(t,e,n)),this},HTMLElement.prototype.on=function(t,e,n){return this.addEventListener(t,e,n),this},HTMLElement.prototype.click=function(t,e){return this.addEventListener("click",t,e),this},NodeList.prototype.on=HTMLCollection.prototype.on=function(t,e,n){return Array.from(this).forEach(o=>o.addEventListener(t,e,n)),this},NodeList.prototype.click=HTMLCollection.prototype.click=function(t,e){return Array.from(this).forEach(n=>n.addEventListener("click",t,e)),this},String.prototype.trimStart=function(t=" "){let e=this.toString();return e.startsWith(t)?e.slice(t.length,e.length):e},String.prototype.trimEnd=function(t=" "){let e=this.toString();return e.endsWith(t)?e.slice(0,`-${t.length}`):e},Location.prototype.queryObject=function(){let t=this.search.trimStart("?"),e=t=>/^(-?(0|[1-9]\d*)(\.\d+)?)$/.test(t)?Number(t):/true|false/.test(t)?"true"===t:t,n=(t,e,n)=>{let o=e.split("."),r=t;for(;o.length>1;){let i=o.shift();if(i.endsWith("[]")){let s=i.slice(0,-2);r[s]=r[s]||[],r=r[s]}else r[i]=r[i]||{},r=r[i]}let l=o[0];if(l.endsWith("[]")){let a=l.slice(0,-2);r[a]=r[a]||[],r[a].push(n)}else r[l]=n};return""===t?null:t.split("&").reduce((t,o)=>{let[r,i=""]=o.split("=");try{r=decodeURIComponent(r),i=e(decodeURIComponent(i))}catch(s){return console.warn(`Malformed query string pair detected: "${o}". It has been skipped.`),t}return r.length>0&&n(t,r,i),t},{})},NodeList.prototype.remove=HTMLCollection.prototype.remove=function(){return Array.from(this).forEach(t=>t.remove()),this},HTMLElement.prototype.css=function(){if(1===arguments.length&&"string"==typeof arguments[0]){let t=window.getComputedStyle(this).getPropertyValue(arguments[0]);if(!t)return t;if(1===t.split(" ").length){let e=t.trimEnd("px");return isNaN(e)?t:parseFloat(e)}return t}if(isIterable(arguments)){if(o(arguments[0])){if(Object.entries(arguments[0]).length>=5){let n=`${new Date().getMilliseconds()}${Math.ceil(999*Math.random())}`,r=`sniper-${this.tagName.toLowerCase()}-${n}`,i=`.${r} {`;Object.entries(arguments[0]).forEach(([t,e])=>{i+=`${camelToKebab(t)}:${Boolean(+e)?e+"px":e};`}),i+="}",document.head.getElementsByTagName("style")[0]?document.head.getElementsByTagName("style")[0].textContent+=i:createElement({nodeName:"style",type:"text/css",textContent:i},document.head),this.addClass(r)}else Object.entries(arguments[0]).forEach(([t,e])=>{this.style[t]=Boolean(+e)?e+"px":e})}else for(let s=0;s<arguments.length;s+=2){let l=arguments[s+1];this.style[arguments[s]]=Boolean(+l)?l+"px":l}return this}throw Error("Arguments must be an array of key-value pairs")},NodeList.prototype.css=HTMLCollection.prototype.css=function(){let t=arguments;if(isIterable(t)){if(o(t[0])){if(Object.entries(t[0]).length>=3){let e=`${new Date().getMilliseconds()}${Math.ceil(999*Math.random())}`,n=`sniper-${e}`,r=`.${n} {`;Object.entries(t[0]).forEach(([t,e])=>{r+=`${camelToKebab(t)}:${Boolean(+e)?e+"px":e};`}),r+="}",document.head.getElementsByTagName("style")[0]?document.head.getElementsByTagName("style")[0].textContent+=r:createElement({nodeName:"style",type:"text/css",textContent:r},document.head),Array.from(this).forEach(function(t){t.addClass(n)})}else Array.from(this).forEach(function(e){Object.entries(t[0]).forEach(([t,n])=>{e.style[t]=Boolean(+n)?n+"px":n})})}else Array.from(this).forEach(function(e){for(let n=0;n<t.length;n+=2){let o=t[n+1];e.style[t[n]]=Boolean(+o)?o+"px":o}});return this}throw Error("Arguments must be an array of key-value pairs")},HTMLElement.prototype.width=function(){return 1===arguments.length&&"function"==typeof arguments[0]?this.css("width",arguments[0].call(this,this.offsetWidth)):1===arguments.length&&("string"==typeof arguments[0]||"number"==typeof arguments[0])?this.css("width",arguments[0]):this.offsetWidth},Object.defineProperty(HTMLInputElement.prototype,"width",{value:function(){return 1===arguments.length&&"function"==typeof arguments[0]?this.css("width",arguments[0].call(this,this.offsetWidth)):1===arguments.length&&("string"==typeof arguments[0]||"number"==typeof arguments[0])?this.css("width",arguments[0]):this.offsetWidth},enumerable:!1}),HTMLCollection.prototype.width=NodeList.prototype.width=function(){if(1===arguments.length){for(let t of this)t.width(...arguments);return this}if(0===arguments.length)return Array.from(this).reduce((t,e)=>t+=e.offsetWidth,0)},HTMLElement.prototype.height=function(){return 1===arguments.length&&"function"==typeof arguments[0]?this.css("height",arguments[0].call(this,this.offsetHeight)):1===arguments.length&&("string"==typeof arguments[0]||"number"==typeof arguments[0])?this.css("height",arguments[0]):this.offsetHeight},Object.defineProperty(HTMLInputElement.prototype,"height",{value:function(){return 1===arguments.length&&"function"==typeof arguments[0]?this.css("height",arguments[0].call(this,this.offsetHeight)):1===arguments.length&&("string"==typeof arguments[0]||"number"==typeof arguments[0])?this.css("height",arguments[0]):this.offsetHeight},enumerable:!1}),NodeList.prototype.height=HTMLCollection.prototype.height=function(){if(1===arguments.length){for(let t of this)t.height(...arguments);return this}if(0===arguments.length)return Array.from(this).reduce((t,e)=>t+=e.offsetHeight,0)},HTMLElement.prototype.find=function(t=""){let e=!1;return"*"===t.at(-1)&&(e=!0,t=t.substring(0,t.length-1)),e?this.querySelectorAll(t):this.querySelector(t)},NodeList.prototype.find=HTMLCollection.prototype.find=function(t=""){let e=!1;t.endsWith("*")&&(e=!0,t=t.slice(0,-1));let n=[];for(let o of this)if(e)n=[...n,...o.querySelectorAll(t)];else{let r=o.querySelector(t);if(r)return r}return e?n:null},HTMLElement.prototype.toggleAction=function(t,e){return void 0===this.ACTION_TOGGLE&&(this.ACTION_TOGGLE=!1),this.onclick=function(n){this.ACTION_TOGGLE?e&&e.call(this,n):t&&t.call(this,n),this.ACTION_TOGGLE=!this.ACTION_TOGGLE},this},HTMLCollection.prototype.toggleAction=NodeList.prototype.toggleAction=function(t,e){return Array.from(this).forEach(function(n){void 0===n.ACTION_TOGGLE&&(n.ACTION_TOGGLE=!1),n.onclick=function(o){n.ACTION_TOGGLE?e&&e.call(this,o):t&&t.call(this,o),n.ACTION_TOGGLE=!n.ACTION_TOGGLE}}),this},HTMLElement.prototype.parent=function(t=""){let e=this.parentElement;if(!t)return e;for(;e;){if(t.startsWith("#")&&e.id===t.slice(1)||t.startsWith(".")&&e.classList.contains(t.slice(1))||e.tagName.toLowerCase()===t.toLowerCase())return e;e=e.parentElement}return null},HTMLElement.prototype.hide=function(t,e){t=t||0;let n=this;return t<=0?n.css("display","none"):(setTimeout(function(){n.css("display","none")&&e&&e.call(n)},+t),n)},HTMLElement.prototype.show=function(t,e){t=t||0;let n=this;return t<=0?n.css("display",""):(setTimeout(function(){n.css("display","")&&e&&e.call(n)},+t),n)},HTMLCollection.prototype.hide=NodeList.prototype.hide=function(t,e){t=t||0;let n=this;return t<=0?n.css("display","none"):(setTimeout(function(){n.css("display","none")&&e&&e.call(n)},+t),n)},HTMLCollection.prototype.show=NodeList.prototype.show=function(t,e){t=t||0;let n=this;return t<=0?n.css("display",""):(setTimeout(function(){n.css("display","")&&e&&e.call(n)},+t),n)},HTMLCollection.prototype.parent=NodeList.prototype.parent=function(t=null){if(0===this.length)return null;let e=this[0].parentElement;if(!t)return e;for(;e;){if(t.startsWith("#")&&e.id===t.slice(1)||t.startsWith(".")&&e.classList.contains(t.slice(1))||e.tagName.toLowerCase()===t.toLowerCase())return e;e=e.parentElement}return null},HTMLElement.prototype.onScroll=function t(e=0,n=null,o=null){this.addEventListener("scroll",function(t){let r=this.scrollTop;null!==o?n&&n.call(this,Boolean(r>=e&&o),r,t):n&&n.call(this,Boolean(r>=e),r,t)})},NodeList.prototype.onScroll=HTMLCollection.prototype.onScroll=function(t=0,e=null,n=null){Array.from(this).forEach(o=>o.onScroll(t,e,n))},HTMLElement.prototype.load=function(t,e){let n=this,[o,r]=t.split(" "),i=new XMLHttpRequest;return i.onload=function(){if(4==this.readyState&&200==this.status){if(r){let t=new DOMParser,o=t.parseFromString(this.responseText,"text/html"),s=o.querySelector(r)?.innerHTML;n.html(s),e&&e.call(this,s,"success",i)}else n.html(this.responseText),e&&e.call(this,this.responseText,"success",i)}else e&&e.call(this,null,"error",i)},i.onerror=t=>{throw Error("Couldn't load "+o)},i.open("GET",o,!0),i.send(),n},Element.prototype.clone=function(){return this.cloneNode(!0)},HTMLElement.prototype.append=function(t,e=!1){let n=document.createDocumentFragment();if("function"==typeof t&&(t=t(this,this.innerHTML)),"string"==typeof t){let o=document.createElement("div");for(o.innerHTML=t;o.firstChild;)n.appendChild(o.firstChild)}else if(t instanceof Node)n.appendChild(t);else if(t instanceof NodeList||Array.isArray(t))t.forEach(t=>{t instanceof Node&&n.appendChild(t)});else throw TypeError("Content must be a string, Node, NodeList, or Array of Nodes.");return e?this.insertBefore(n,this.firstChild):this.appendChild(n),this},NodeList.prototype.append=HTMLCollection.prototype.append=function(t,e=!1){return Array.from(this).forEach(n=>{n instanceof HTMLElement&&n.append(t,e)}),this},HTMLElement.prototype.createElement=function(t,e=!1){let n=null;if(o(t)){let{nodeName:r="div",...i}=t;for(let[s,l]of(n=document.createElement(r),Object.entries(i)))n[s]=l}else if("string"==typeof t)n=document.createElement(t);else throw Error("Invalid argument: parameter 1 must be type of an object or string.");return e?this.prepend(n):this.append(n),n},HTMLCollection.prototype.createElement=NodeList.prototype.createElement=function(t,e=!1){let n=(()=>{if(o(t)){let{nodeName:e="div",...n}=t,r=document.createElement(e);for(let[i,s]of Object.entries(n))r[i]=s;return r}if("string"==typeof t)return document.createElement(t);throw Error("Invalid argument passed to createElement")})();return this.forEach(t=>{e?t.prepend(n.cloneNode(!0)):t.append(n.cloneNode(!0))}),this},HTMLElement.prototype.toFirst=function(){return this.parentElement&&this.parentElement.insertAdjacentElement("afterbegin",this),this},HTMLElement.prototype.toLast=function(){return this.parentElement&&this.parentElement.insertAdjacentElement("beforeend",this),this},HTMLCollection.prototype.toLast=NodeList.prototype.toLast=function(){for(let t of this)t.toLast();return this},HTMLCollection.prototype.toLast=NodeList.prototype.toFirst=function(){for(let t of this)t.toFirst();return this},HTMLCollection.prototype.src=NodeList.prototype.src=function(t){let e=[];for(let n of this)n instanceof HTMLImageElement&&(void 0===t||!1===t?e.push(n.src(t)):n.src(t));return 0===e.length?this:e},Object.defineProperty(HTMLImageElement.prototype,"src",{value:function(t){return void 0===t?this.currentSrc:!1===t?this.getAttribute("src"):"function"==typeof t?(this.setAttribute("src",t(this,{fullSrc:this.currentSrc,src:this.getAttribute("src")})),this):(this.setAttribute("src",t),this)},enumerable:!1}),HTMLCollection.prototype.attr=NodeList.prototype.attr=function(){let t=[];for(let e of this)1===arguments.length&&"string"==typeof arguments[0]?t.push(e.attr(...arguments)):e.attr(...arguments);return 0===t.length?this:t},HTMLElement.prototype.attr=function(){if(1===arguments.length&&"string"==typeof arguments[0])return this.getAttribute(arguments[0]);if(isIterable(arguments)){if(o(arguments[0])){for(let[t,e]of Object.entries(arguments[0]))this.setAttribute(t,e);return this}if(2===arguments.length&&"function"==typeof arguments[1])return this.setAttribute(arguments[0],arguments[1].call(this,this.getAttribute(arguments[0]))),this;for(let n=0;n<arguments.length;n+=2){let r=arguments[n+1];this.setAttribute(arguments[n],r)}return this}},HTMLCollection.prototype.removeAttr=NodeList.prototype.removeAttr=function(){for(let t of this)t.removeAttr(...arguments);return this},HTMLElement.prototype.removeAttr=function(){if(arguments.length>0)for(let t of arguments)"string"==typeof t&&this.removeAttribute(t);return this},HTMLElement.prototype.hasAttr=function t(){if(!arguments[0])return!1;let e=[];for(let n of arguments)e.push(this.hasAttribute(n));return e.every(t=>!0===t)},HTMLCollection.prototype.hasAttr=NodeList.prototype.hasAttr=function(){let t=[];for(let e of this)t.push(e.hasAttr(...arguments));return!t.some(t=>!1===t)},HTMLElement.prototype.hasValue=function t(){let e=this.val?.();if(null==e)return!1;if(this.type){let n=this.type.toLowerCase();if("radio"===n||"checkbox"===n)return!!this.checked}return"string"==typeof e?""!==e.trim()&&"0"!==e:"number"==typeof e&&0!==e},HTMLCollection.prototype.hasValue=NodeList.prototype.hasValue=function(){let t=[];for(let e of this)t.push(e.hasValue());return!t.some(t=>!1===t)},HTMLElement.prototype.scrollTo=function(t={}){let e={behavior:"smooth",block:"start",inline:"nearest",...t},n=this.getBoundingClientRect(),o=n.top>=0&&n.bottom<=window.innerHeight;if(!o)return this.scrollIntoView(e),this},NodeList.prototype.scrollTo=HTMLCollection.prototype.scrollTo=function(t={}){return this.length>0&&this[0].scrollTo(t),this},HTMLElement.prototype.hover=function(t,e){return"function"==typeof t&&this.addEventListener("mouseenter",function(e){t.call(this,e)}),"function"==typeof e&&this.addEventListener("mouseleave",function(t){e.call(this,t)}),this},NodeList.prototype.hover=function(t,e){return this.forEach(n=>n.hover(t,e)),this},HTMLElement.prototype.scrollToBottom=function(){return this.scrollTop=this.scrollHeight,this},HTMLElement.prototype.scrollToTop=function(){return this.scrollTop=0,this},NodeList.prototype.scrollToBottom=HTMLCollection.prototype.scrollToBottom=function(){for(let t of this)t.scrollToBottom();return this},NodeList.prototype.scrollToTop=HTMLCollection.prototype.scrollToTop=function(){for(let t of this)t.scrollToTop();return this},HTMLFormElement.prototype.serialize=function(){let t=new FormData(this),e={};for(let[n,o]of t.entries())Array.isArray(e[n])?e[n].push(o):e[n]?e[n]=[e[n],o]:e[n]=o;return e},HTMLElement.prototype.replaceText=function t(e,n){if(0===e.toString().trim().length)return;let o="object"==typeof e&&e.flags?e.flags:"i";this.childNodes.forEach(t=>{if(t.nodeType===Node.TEXT_NODE){let r=t.textContent.match(RegExp(e,o));if("string"==typeof e&&r&&r[0].trim().length>0){"function"==typeof n&&(n=n(r[0]));let i=t.textContent.replace(RegExp(e,"gi"),n);t.parentElement.html(i)}else if("object"==typeof e&&r&&r[0].trim().length>0){"function"==typeof n&&(n=n(r[0]));let s=t.textContent.replace(e,n);t.parentElement.html(s)}}else t.nodeType===Node.ELEMENT_NODE&&t.replaceText(e,n)})},HTMLInputElement.prototype.onEnterKey=function(t,e){return"function"==typeof t&&this.addEventListener("keyup",function(e){(e?.keyCode===13||e?.code==="Enter"||e?.key==="Enter")&&t.call(this,e)},e),this}},{"./utils":3}],3:[function(t,e,n){e.exports={getYears(t=1850,e=new Date().getFullYear()){if(t>e)throw Error("End date cannot be less than start date");let n=[];for(;t!==e+1;)n.push(t),t++;return n},getMonths:(t=!1)=>t?["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]:["January","February","March","April","May","June","July","August","September","October","November","December"],getWeekDays:(t=!1)=>t?["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]:["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],commarize(t){let e="";e=t.toString().search(/\./)>0?"."+t.split(".").at(-1):"",t=0>t.toString().search(/\./)?t.toString().split(""):t.toString().split(".")[0];let n=[],o=1;for(let r=t.length-1;r>=0;r--)n.unshift(t[r]),o%3==0&&0!=r&&n.unshift(","),o++;return e.length<1?n.join(""):n.join("")+e},createElement(t,e,n=!1){let{nodeName:o="div",...r}=t,i=document.createElement(o);return Object.entries(r).forEach(([t,e])=>{i[t]=e}),n?e.prepend(i):e.append(i),i},isJsonString(t){try{JSON.parse(t)}catch(e){return!1}return!0},objIsEmpty:t=>!!t&&0===Object.keys(t).length&&Object.getPrototypeOf(t)===Object.prototype,isObject:t=>!("object"!=typeof t||Array.isArray(t))&&null!==t,charFormatter(t,e=4,n=""){let o=[...t],r=0,i="";for(;r<o.length;)0!==r&&r%e==0&&(i+=n),i+=o[r],r++;return i},insertTextSeparator(t){let e=arguments[1]??" ",n=arguments[2]??4,o="object"==typeof t&&void 0!==t.target,r=t;if(o){if(t.inputType&&"deleteContentBackward"===t.inputType||t?.nativeEvent?.inputType&&"deleteContentBackward"===t.nativeEvent.inputType)return t.target.value;r=t.target.value}let i=[...r.replaceAll(RegExp("[^a-zA-Z0-9 ]|"+e,"g"),"")],s=0,l="";for(;s<i.length;)s%n==0&&0!==s&&(l+=e),l+=i[s],s++;return l},onScroll(t=0,e=null,n=null){window.onscroll=function(o){let r=document.body.scrollTop||document.documentElement.scrollTop;null!==n?e&&e.call(this,Boolean(r>=t&&n),r,o):e&&e.call(this,Boolean(r>=t),r,o)}},isIterable:t=>t&&"function"==typeof t[Symbol.iterator],getRandomInt:(t=1,e=9999)=>Math.floor(Math.random()*(e-t+1))+t,inWords(t,e=""){let n="",o={once:["zero","one","two","three","four","five","six","seven","eight","nine"],tens:["","ten","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"],teens:["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],units:[e,"thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","decillion","undecillion","duodecillion","tredecillion","quattuordecillion","quindecillion","sexdecillion","septemdecillion","octodecillion","novemdecillion","vigintillion","unvigintillion","duovigintillion","trevigintillion","quattuorvigintillion","quinvigintillion","sexvigintillion","septvigintillion","octovigintillion","nonvigintillion","trigintillion","untrigintillion","duotrigintillion"]},r=commarize(`${t}`).split(","),i,s;if(r.length>1)console.log(r),r.forEach((t,e,r)=>{switch(i=o.units[r.length-e-1],t.length){case 3:a(t)||(u(t)?c(t)?(s=0===e?i:o.units[o.units.indexOf(i)],n+=o.once[t[0]]+" hundred "+s+" "):p(t[1]+t[2])?(s=0===e?i:o.units[o.units.indexOf(i)],n+="0"==t[2]?o.once[t[0]]+" hundred and "+o.teens[t[2]]:o.once[t[0]]+" hundred and "+o.teens[t[2]]+" "+s+" "):(s=0===e?i:o.units[o.units.indexOf(i)],n+=o.once[t[0]]+" hundred and "+o.tens[t[1]]+" "+s+" "):h(t)?(s=0===e?i:o.units[o.units.indexOf(i)],n+=o.once[t[0]]+" hundred and "+o.once[t[2]]+" "+s+" "):p(t[1]+t[2])?(s=0===e?i:o.units[o.units.indexOf(i)],n+="0"==t[2]?o.once[t[0]]+" hundred and "+o.teens[t[2]]:o.once[t[0]]+" hundred and "+o.teens[t[2]]+" "+s+" "):(s=0===e?i:o.units[o.units.indexOf(i)],n+=o.once[t[0]]+" hundred and "+o.tens[t[1]]+"-"+o.once[t[2]]+" "+s+" ")),n+=o.once[t[0]]+" "+o.once[t[1]]+" "+o.once[t[2]]+" ";break;case 2:a(t)?n+=o.once[t[0]]+" "+o.once[t[1]]+" ":p(t)?(s=0===e?i:o.units[o.units.indexOf(i)],n+="0"==t[0]?o.teens[t[1]]:o.teens[t[1]]+" "+s+" "):(s=0===e?i:o.units[o.units.indexOf(i)],n+=o.tens[t[0]]+"-"+o.once[t[1]]+" "+s+" ");break;case 1:s=0===e?i:o.units[o.units.indexOf(i)],n+=o.once[t[0]]+" "+s+" "}});else{let l=r.at(-1).split("");switch(l.length){case 3:n=a(l.join(""))?o.once[l[0]]+" "+o.once[l[1]]+" "+o.once[l[2]]:u(l.join(""))?c(l.join(""))?o.once[l[0]]+" hundred":p(l[1]+l[2])?(l[2],o.once[l[0]]+" hundred and "+o.teens[l[2]]):o.once[l[0]]+" hundred and "+o.tens[l[1]]:h(l.join(""))?o.once[l[0]]+" hundred and "+o.once[l[2]]:p(l[1]+l[2])?(l[2],o.once[l[0]]+" hundred and "+o.teens[l[2]]):o.once[l[0]]+" hundred and "+o.tens[l[1]]+"-"+o.once[l[2]];break;case 2:n=a(l.join(""))?o.once[l[0]]+" "+o.once[l[1]]:p(l.join(""))?(l[0],o.teens[l[1]]):o.tens[l[0]]+"-"+o.once[l[1]];break;case 1:n=o.once[l[0]]}}function a(t){return"0"==t.toString()[0]}function u(t){return"0"==(t=t.toString())[t.length-1]}function h(t){return"0"==t.toString().slice(1,-1)}function p(t){return 2==(t=t.toString()).length&&"1"==t[0]}function c(t){return 3==(t=t.toString()).length&&"00"==t.slice(1)}return n},isValidEmail:t=>/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(t),camelToKebab:t=>t.replace(/([A-Z])/g,"-$1").toLowerCase(),camelToSnake:t=>t.replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase(),camelToPascal:t=>t.charAt(0).toUpperCase()+t.slice(1),snakeToCamel:t=>t.replace(/(_[a-z])/g,t=>t[1].toUpperCase()),snakeToKebab:t=>t.replace(/_/g,"-"),snakeToPascal:t=>t.split("_").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(""),kebabToCamel:t=>t.replace(/(-[a-z])/g,t=>t[1].toUpperCase()),kebabToPascal:t=>t.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(""),kebabToSnake:t=>t.replace(/-/g,"_"),pascalToCamel:t=>t.charAt(0).toLowerCase()+t.slice(1),pascalToSnake:t=>t.replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase(),pascalToKebab:t=>t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),onPageLoad(){let t=window.location.pathname;if(!arguments[0])throw Error("No page route provided");let e=arguments[0],n=!1,o=e=>{if("/"===e)return"/"===t||/^\/index\.(html|php|asp)$/.test(t);let n=t.split(e);return!!/^(?!\/)index\.(html|php|asp)$/.test(e)&&2===n.length||2===n.length&&(!!/^(?!\/)index\.(html|php|asp)$/.test(n.at(-1))||n.at(-1).length<2)},r=(e,r)=>{if(!e)return!1;(n=e.endsWith("*"))&&(e=e.slice(0,-1));let i=()=>{if(r){if("function"!=typeof r)throw TypeError("Second argument must be a function");document.addEventListener("DOMContentLoaded",()=>r({route:t.split("/").filter(Boolean),query:window.location.queryObject(),title:document.title,...window.location}))}};o(e)?i(...arguments):n&&2===t.split(e).length&&i(...arguments)};if(Array.isArray(e))for(let i of e)r(i,arguments[1]);else"string"==typeof e&&r(e,arguments[1])},die(t=""){throw Error(t)},swapElements(t,e){let n=t.parentNode,o=t.nextSibling;e.parentNode.insertBefore(t,e),n.insertBefore(e,o)},debounce(t,e){let n;return function(...o){clearTimeout(n),n=setTimeout(()=>t.apply(this,o),e)}},stringify:t=>"object"==typeof t?JSON.stringify(t):t,setLocalItem(t,e){"function"==typeof e&&(e=e(this.getLocalItem(t))),localStorage.setItem(t,this.stringify(e))},getLocalItem(t){let e=localStorage.getItem(t);try{return JSON.parse(e)}catch{return e}},removeLocalItem(t){localStorage.removeItem(t)},clearLocalItems(){localStorage.clear()},setSessionItem(t,e){"function"==typeof e&&(e=e(this.getSessionItem(t))),sessionStorage.setItem(t,this.stringify(e))},getSessionItem(t){let e=sessionStorage.getItem(t);try{return JSON.parse(e)}catch{return e}},removeSessionItem(t){sessionStorage.removeItem(t)},clearSessionItems(){sessionStorage.clear()},mediaQuery(t,e){if("string"!=typeof t||"function"!=typeof e)throw TypeError('Usage: mediaQuery("(max-width: 768px)", callbackFunction)');let n=window.matchMedia(t),o=t=>e(t.matches);return o(n),n.addEventListener("change",o),()=>n.removeEventListener("change",o)}}},{}],4:[function(t,e,n){(function(e){(function(){let{isJsonString:n}=t("./utils");e.nexus={create:function({baseURL:t,headers:e={},cacheEnabled:o=!0,retryConfig:r={retries:0,delay:0}}){let i=new Map,s="",l=arguments[0],a="";for(let u in l)if(Object.prototype.hasOwnProperty.call(l,u)){let h=l[u];"baseurl"===u.toLowerCase()&&(s=h)}async function p(t,e,n={},r=null){let l=function t(e,n){a=e;let o=new URLSearchParams(n).toString();return`${s}${e}${o?`?${o}`:""}`}(e,n);return o&&"GET"===t&&i.has(l)?(console.log("Serving from cache"),Promise.resolve(i.get(l))):c(t,l,r)}function c(t,s,u=null,h=r.retries){return new Promise((r,p)=>{var c;let d=new XMLHttpRequest;d.open(t,s),c=d,Object.entries(e).forEach(([t,e])=>{c.setRequestHeader(t,e)}),e["Content-Type"]||c.setRequestHeader("Content-Type","application/json"),d.onload=()=>{if(d.status>=200&&d.status<300){let e=n(d.responseText)?JSON.parse(d.responseText):d.responseText;o&&"GET"===t&&i.set(s,e);let c={config:{...l,headers:d.getAllResponseHeaders(),url:a},request:d,status:d.status,statusText:d.statusText,data:e};r(c)}else f(d,s,p,r,t,h,u)},d.onerror=()=>{f(d,s,p,r,t,h,u)},d.send(u?JSON.stringify(u):null)})}function f(t,e,o,i,s,u,h){if(u>0)console.warn(`Retrying ${s} request to ${e}, remaining retries: ${u-1}`),setTimeout(()=>{c(s,e,h,u-1).then(i).catch(o)},r.delay);else{let p={config:{...l,headers:t.getAllResponseHeaders(),url:a},request:t,status:t.status,statusText:t.statusText,data:n(t.responseText)?JSON.parse(t.responseText):t.responseText},f=Error(`Request failed with status ${t.status}: ${t.statusText}`);Object.defineProperty(f,"response",{value:p,enumerable:!1}),o(f)}}return{get:(t,e={})=>p("GET",t,e),post:(t,e={},n={})=>p("POST",t,n,e),put:(t,e={},n={})=>p("PUT",t,n,e),patch:(t,e={},n={})=>p("PATCH",t,n,e),delete:(t,e={})=>p("DELETE",t,e)}}}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./utils":3}],5:[function(t,e,n){(function(t){(function(){t.ssp={handleInputs(t){let e=t.target;if(!/^[0-9]*$/.test(e.value))return e.value="";if(1===e.value.length){if(!e.nextElementSibling)return;e.nextElementSibling.focus()}},handlePaste(t){t.stopPropagation(),t.preventDefault();let e=(t.clipboardData||window.clipboardData).getData("Text");if(Number.isInteger(+e)){let n=e.toString();if(n.length>0){let o=n.split(""),r=t.target.parentElement.children;for(let i=0;i<o.length&&(r[i].value=o[i],r[i].focus(),i!==r.length-1);i++);}}},handleArrowMovement(t){let e=t.target;if(37===t.keyCode){if(!e.previousElementSibling)return;e.previousElementSibling.focus(),e.selectionStart=e.selectionEnd=e.value.length}else if(39===t.keyCode){if(!e.nextElementSibling)return;e.nextElementSibling.focus()}if(8===t.keyCode){if(t.preventDefault(),!e.previousElementSibling)return e.value="";e.value="",e.previousElementSibling.focus()}else if(46===t.keyCode){if(t.preventDefault(),!e.nextElementSibling)return e.value="";e.value="",e.nextElementSibling.focus()}}};let e=document.querySelectorAll("[sniper-secure-pin] input");if(e){Array.from(e).forEach(t=>{t.setAttribute("maxlength",1),t.oninput=t=>{ssp.handleInputs(t),n()},t.onpaste=t=>{ssp.handlePaste(t),n()},t.onkeydown=t=>{ssp.handleArrowMovement(t),n()}});let n=t=>{let n=[...e].map(t=>t.value).join("");e.parent().setAttribute("data-value",n)}}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1]);