PageSourceSearch

https://www.laselva.bio/theme/fc90b006d7526d0829b7d0993214b385/js/…/proxa-free-product-voucher.js?1791377238

js laselva.bio collected 2026-10-10 01:13:12 UTC 13,378 bytes, 1 lines download raw bytes

1(()=>{"use strict";var e={156:e=>{var t=function(e){var t;return!!e&&"object"==typeof e&&"[object RegExp]"!==(t=Object.prototype.toString.call(e))&&"[object Date]"!==t&&e.$$typeof!==r},r="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function i(e,t){return!1!==t.clone&&t.isMergeableObject(e)?a(Array.isArray(e)?[]:{},e,t):e}function s(e,t,r){return e.concat(t).map(function(e){return i(e,r)})}function o(e){return Object.keys(e).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[])}function n(e,t){try{return t in e}catch(e){return!1}}function a(e,r,l){(l=l||{}).arrayMerge=l.arrayMerge||s,l.isMergeableObject=l.isMergeableObject||t,l.cloneUnlessOtherwiseSpecified=i;var u,c,d=Array.isArray(r);return d!==Array.isArray(e)?i(r,l):d?l.arrayMerge(e,r,l):(c={},(u=l).isMergeableObject(e)&&o(e).forEach(function(t){c[t]=i(e[t],u)}),o(r).forEach(function(t){(!n(e,t)||Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))&&(n(e,t)&&u.isMergeableObject(r[t])?c[t]=(function(e,t){if(!t.customMerge)return a;var r=t.customMerge(e);return"function"==typeof r?r:a})(t,u)(e[t],r[t],u):c[t]=i(r[t],u))}),c)}a.all=function(e,t){if(!Array.isArray(e))throw Error("first argument should be an array");return e.reduce(function(e,r){return a(e,r,t)},{})},e.exports=a}},t={};function r(i){var s=t[i];if(void 0!==s)return s.exports;var o=t[i]={exports:{}};return e[i](o,o.exports,r),o.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var i=r(156),s=r.n(i);class o{static ucFirst(e){return e.charAt(0).toUpperCase()+e.slice(1)}static lcFirst(e){return e.charAt(0).toLowerCase()+e.slice(1)}static toDashCase(e){return e.replace(/([A-Z])/g,"-$1").replace(/^-/,"").toLowerCase()}static toLowerCamelCase(e,t){let r=o.toUpperCamelCase(e,t);return o.lcFirst(r)}static toUpperCamelCase(e,t){return t?e.split(t).map(e=>o.ucFirst(e.toLowerCase())).join(""):o.ucFirst(e.toLowerCase())}static parsePrimitive(e){try{return/^\d+(.|,)\d+$/.test(e)&&(e=e.replace(",",".")),JSON.parse(e)}catch(t){return e.toString()}}}class n{constructor(e=document){this._el=e,e.$emitter=this,this._listeners=[]}publish(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=new CustomEvent(e,{detail:t,cancelable:r});return this.el.dispatchEvent(i),i}subscribe(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=this,s=e.split("."),o=r.scope?t.bind(r.scope):t;if(r.once&&!0===r.once){let t=o;o=function(r){i.unsubscribe(e),t(r)}}return this.el.addEventListener(s[0],o),this.listeners.push({splitEventName:s,opts:r,cb:o}),!0}unsubscribe(e){let t=e.split(".");return this.listeners=this.listeners.reduce((e,r)=>([...r.splitEventName].sort().toString()===t.sort().toString()?this.el.removeEventListener(r.splitEventName[0],r.cb):e.push(r),e),[]),!0}reset(){return this.listeners.forEach(e=>{this.el.removeEventListener(e.splitEventName[0],e.cb)}),this.listeners=[],!0}get el(){return this._el}set el(e){this._el=e}get listeners(){return this._listeners}set listeners(e){this._listeners=e}}class a{constructor(e,t={},r=!1){if(!(e instanceof Node)){console.warn(`There is no valid element given while trying to create a plugin instance for "${r}".`);return}this.el=e,this.$emitter=new n(this.el),this._pluginName=this._getPluginName(r),this.options=this._mergeOptions(t),this._initialized=!1,this._registerInstance(),this._init()}init(){console.warn(`The "init" method for the plugin "${this._pluginName}" is not defined. The plugin will not be initialized.`)}update(){}_init(){this._initialized||(this.init(),this._initialized=!0)}_update(){this._initialized&&this.update()}_mergeOptions(e){let t=[this.constructor.options,this.options,e];return t.push(this._getConfigFromDataAttribute()),t.push(this._getOptionsFromDataAttribute()),s().all(t.filter(e=>e instanceof Object&&!(e instanceof Array)).map(e=>e||{}))}_getConfigFromDataAttribute(){let e={};if("function"!=typeof this.el.getAttribute)return e;let t=o.toDashCase(this._pluginName),r=this.el.getAttribute(`data-${t}-config`);return r?window.PluginConfigManager.get(this._pluginName,r):e}_getOptionsFromDataAttribute(){let e={};if("function"!=typeof this.el.getAttribute)return e;let t=o.toDashCase(this._pluginName),r=this.el.getAttribute(`data-${t}-options`);if(r)try{return JSON.parse(r)}catch(e){console.error(`The data attribute "data-${t}-options" could not be parsed to json: ${e.message}`)}return e}_registerInstance(){window.PluginManager.getPluginInstancesFromElement(this.el).set(this._pluginName,this),window.PluginManager.getPlugin(this._pluginName,!1).get("instances").push(this)}_getPluginName(e){return e||(e=this.constructor.name),e}}class l{constructor(){this._request=null,this._errorHandlingInternal=!1}get(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/json",i=this._createPreparedRequest("GET",e,r);return this._sendRequest(i,null,t)}post(e,t,r){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";i=this._getContentType(t,i);let s=this._createPreparedRequest("POST",e,i);return this._sendRequest(s,t,r)}delete(e,t,r){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";i=this._getContentType(t,i);let s=this._createPreparedRequest("DELETE",e,i);return this._sendRequest(s,t,r)}patch(e,t,r){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";i=this._getContentType(t,i);let s=this._createPreparedRequest("PATCH",e,i);return this._sendRequest(s,t,r)}
1abort(){if(this._request)return this._request.abort()}setErrorHandlingInternal(e){this._errorHandlingInternal=e}_registerOnLoaded(e,t){t&&(!0===this._errorHandlingInternal?(e.addEventListener("load",()=>{t(e.responseText,e)}),e.addEventListener("abort",()=>{console.warn(`the request to ${e.responseURL} was aborted`)}),e.addEventListener("error",()=>{console.warn(`the request to ${e.responseURL} failed with status ${e.status}`)}),e.addEventListener("timeout",()=>{console.warn(`the request to ${e.responseURL} timed out`)})):e.addEventListener("loadend",()=>{t(e.responseText,e)}))}_sendRequest(e,t,r){return this._registerOnLoaded(e,r),e.send(t),e}_getContentType(e,t){return e instanceof FormData&&(t=!1),t}_createPreparedRequest(e,t,r){return this._request=new XMLHttpRequest,this._request.open(e,t),this._request.setRequestHeader("X-Requested-With","XMLHttpRequest"),r&&this._request.setRequestHeader("Content-type",r),this._request}}class u extends a{static #e=this.options={setSelectionUrl:"/proxa/voucher/set-product-selection",deleteLineItemUrl:"/checkout/line-item/delete/__ID__",addPromotionUrl:"/checkout/promotion/add"};init(){this.client=new l,this.initAllModals(),this.registerOffcanvasObserver()}initAllModals(){document.querySelectorAll(".proxa-free-product-modal").forEach(e=>{e.dataset.proxaInitialized||(this.initModal(e),this.checkAutoShowModal(e),e.dataset.proxaInitialized="true")})}initModal(e){e.querySelectorAll(".proxa-product-card").forEach(t=>{t.addEventListener("click",t=>this.onProductCardClick(t,e)),t.addEventListener("keypress",t=>{("Enter"===t.key||" "===t.key)&&this.onProductCardClick(t,e)})}),document.querySelectorAll(".proxa-change-product-btn").forEach(e=>{e.dataset.proxaListener||(e.addEventListener("click",e=>this.onChangeButtonClick(e)),e.dataset.proxaListener="true")})}checkAutoShowModal(e){e&&"true"===e.dataset.autoShow&&(new bootstrap.Modal(e).show(),e.removeAttribute("data-auto-show"))}registerOffcanvasObserver(){let e=document.querySelector(".offcanvas");e&&new MutationObserver(()=>{this.initAllModals()}).observe(e,{childList:!0,subtree:!0})}onChangeButtonClick(e){e.preventDefault();let t=e.currentTarget.dataset.voucherId;if(t){let e=document.getElementById(`proxaFreeProductModal${t}`);e&&(e.closest(".offcanvas")&&document.body.appendChild(e),document.querySelectorAll(".offcanvas-backdrop").forEach(e=>e.remove()),new bootstrap.Modal(e).show())}}onProductCardClick(e,t){if(this._switching)return;let r=e.currentTarget.dataset.productId;if(!t)return;let i=t.querySelector(".proxa-product-card.selected");if(!i)return;if(r===i.dataset.productId){let e=bootstrap.Modal.getInstance(t);e&&e.hide();return}let s=t.dataset.lineItemId,o=t.dataset.voucherId,n=t.dataset.voucherCode;this._switching=!0,this.switchProduct(s,r,o,n,t)}switchProduct(e,t,r,i,s){if(!i){console.error("Voucher code not found"),this._switching=!1;return}this.setLoading(s,!0);let o=new FormData;o.append("voucherId",r),o.append("productId",t),this.client.post(this.options.setSelectionUrl,o,()=>{let t=this.options.deleteLineItemUrl.replace("__ID__",e);this.client.post(t,null,()=>{let e=new FormData;e.append("code",i),this.client.post(this.options.addPromotionUrl,e,()=>{this.setLoading(s,!1);let e=()=>{window.location.reload(),this._switching=!1},t=bootstrap.Modal.getInstance(s),r=!1;t&&s.classList.contains("show")?(s.addEventListener("hidden.bs.modal",()=>{r||(r=!0,e())},{once:!0}),t.hide()):e()},e=>{console.error("Error adding voucher:",e),this.setLoading(s,!1),this._switching=!1})},e=>{console.error("Error deleting line item:",e),this.setLoading(s,!1),this._switching=!1})},e=>{console.error("Error setting selection:",e),this.setLoading(s,!1),this._switching=!1})}setLoading(e,t){if(t){e.classList.add("loading");let t=document.createElement("div");t.className="proxa-loading-overlay",t.innerHTML='<div class="spinner-border text-primary" role="status"><span class="visually-hidden">Loading...</span></div>',e.querySelector(".modal-content").appendChild(t)}else{e.classList.remove("loading");let t=e.querySelector(".proxa-loading-overlay");t&&t.remove()}}}class c extends a{static #e=this.options={voucherValidateUrl:"/proxa/voucher/validate"};
1init(){this.client=new l,this.form=this.el.closest("form"),this.voucherInput=this.el.querySelector("#proxaVoucherCodeInput"),this.voucherError=this.el.querySelector(".proxa-voucher-code-inline__error"),this.submitButton=this.el.querySelector('button[type="submit"]'),this.form&&this.voucherInput&&this.submitButton&&(this.voucherValidated=!1,this.registerEvents())}registerEvents(){this.submitButton.addEventListener("click",this.onButtonClick.bind(this),!0),this.voucherInput.addEventListener("input",this.onVoucherInputChange.bind(this)),this.voucherInput.addEventListener("keypress",this.onInputKeypress.bind(this))}onInputKeypress(e){"Enter"===e.key&&(e.preventDefault(),this.onButtonClick(e))}onVoucherInputChange(){this.voucherValidated=!1,this.hideError()}onButtonClick(e){if(this.voucherValidated)return;let t=this.voucherInput.value.trim();if(!t){e.preventDefault(),e.stopPropagation(),this.showError(window.proxaVoucherTranslations?.errorEmptyCode||"Please enter a voucher code."),this.voucherInput.focus();return}e.preventDefault(),e.stopPropagation(),this.validateAndSubmit(t)}validateAndSubmit(e){this.setLoading(!0),this.hideError();let t=new FormData;t.append("code",e);let r=this.getProductId();r&&t.append("productId",r),this.client.post(this.options.voucherValidateUrl,t,e=>{this.handleValidationResponse(e)})}getProductId(){let e=this.el.querySelector("#proxaVoucherProductId");if(e&&e.value)return e.value;for(let e of this.form.querySelectorAll('input[name^="lineItems["]')){let t=e.name.match(/lineItems\[([a-f0-9]{32})\]/i);if(t&&t[1])return t[1]}let t=this.el.closest("[data-product-id]");if(t&&t.dataset.productId)return t.dataset.productId;let r=window.location.pathname.match(/detail\/([a-f0-9]{32})/i);return r&&r[1]?r[1]:null}handleValidationResponse(e){let t;try{t=JSON.parse(e)}catch(e){this.setLoading(!1),this.showError("An error occurred. Please try again.");return}if(t.success){if(this.voucherValidated=!0,this.setLoading(!1),this.addValidatedVoucherToForm(),"function"==typeof this.form.requestSubmit)this.form.requestSubmit(this.submitButton);else{let e=new Event("submit",{bubbles:!0,cancelable:!0});this.form.dispatchEvent(e)&&this.form.submit()}return}this.setLoading(!1),this.showError(t.message||"Invalid voucher code.")}addValidatedVoucherToForm(){let e=this.form.querySelector('input[name="proxaValidatedVoucherCode"]');e&&e.remove();let t=document.createElement("input");t.type="hidden",t.name="proxaValidatedVoucherCode",t.value=this.voucherInput.value.trim(),this.form.appendChild(t);let r=this.getProductId();if(r){let e=this.form.querySelector('input[name="proxaValidatedProductId"]');e&&e.remove();let t=document.createElement("input");t.type="hidden",t.name="proxaValidatedProductId",t.value=r,this.form.appendChild(t)}}setLoading(e){this.submitButton.disabled=e,e?this.submitButton.classList.add("disabled"):this.submitButton.classList.remove("disabled")}showError(e){this.voucherInput.classList.add("is-invalid"),this.voucherError&&(this.voucherError.textContent=e,this.voucherError.style.display="block")}hideError(){this.voucherInput.classList.remove("is-invalid"),this.voucherError&&(this.voucherError.textContent="",this.voucherError.style.display="none")}}let d=window.PluginManager;d.register("ProxaFreeProductSwitcher",u,"[data-proxa-free-product-switcher]"),d.register("ProxaVoucherCodeForm",c,"[data-proxa-voucher-required]")})();

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.