(()=>{var e={3482:()=>{}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};(()=>{"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function t(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(t,n){if(t){if("string"==typeof t)return e(t,n);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(t,n):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}n.r(r);n(3482);var o,i=window.ddwcposAdminObj||{},c=(i.ajax,i.i18n||{}),a=i.ddwcpos_configuration||{},d=/<\s?[^>]*\/?\s?>/i,u=function(e){return window.wp&&wp.template&&e?wp.template(e):null},l=function(e,n){var r=!1;t(e.elements).forEach((function(e){!function(e){e.style.borderColor=""}(e),function(e){return e&&!e.disabled&&!["hidden","submit","button"].includes(e.type)&&!e.classList.contains("ddwcpos-hide")}(e)&&function(e){var t=String(e.value||"").trim();return!t||"-1"===t||d.test(t)}(e)&&(n.preventDefault(),function(e){e.style.borderColor="red"}(e),r=!0)})),r&&function(e){var t=u("ddwcpos_form_data_error");t&&e.insertAdjacentHTML("beforeBegin",t())}(e)},s=function(){var e=document.querySelectorAll("form#ddwcpos-payments-container, form#ddwcpos-tables-container");e.length&&e.forEach((function(e){e.addEventListener("submit",(function(n){t(document.querySelectorAll(".notice")).forEach((function(e){return e.remove()})),l(e,n)}))}))},f=function(e){var t=e.closest(".ddwcpos-invoice-card");return t||e.closest("tr")},p=function(){document.addEventListener("click",(function(e){var t,n=e.target.closest(".ddwcpos-add-row"),r=e.target.closest(".ddwcpos-remove-row");if(n)return e.preventDefault(),void function(e){var t=e.closest("form"),n=e.getAttribute("data-template"),r=u(n),o=t?t.querySelector("#ddwcpos-max-index"):null,i=f(e);if(r&&o&&i){var c=(Number.parseInt(o.value,10)||0)+1;o.value=c,i.insertAdjacentHTML("beforeBegin",r({key:c}))}}(n);r&&(e.preventDefault(),(t=f(r))&&t.remove())}))},m=function(e){var t=e.querySelector(".ddwcpos-barcode-quantity"),n=t?Number.parseInt(t.value,10):0;if(n){t.value="";var r="<html><head><title>Barcode</title>".concat('<style type="text/css">\n    @page {\n        size: '.concat(a.barcode_printer_width," ").concat(a.barcode_printer_height,";\n        margin: ").concat(a.barcode_printer_margin,";\n        text-align: center;\n    }\n</style>"),"</head><body>").concat(function(e,t){var n=e.querySelector(".ddwcpos-barcode-print-content"),r=n?n.innerHTML:"";return Array.from({length:t},(function(){return r})).join("")}(e,n),"</body></html>");/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)?function(e){var t=window.open("","PRINT","height=400,width=600");t&&(t.document.open(),t.document.clear(),t.document.writeln(e),t.document.close(),t.addEventListener("load",(function(){setTimeout((function(){t.focus(),t.print()}),700)}),!0))}(r):function(e){var t=document.createElement("iframe");t.name="ddwcpos-barcode-print-frame",document.body.appendChild(t);var n=t.contentWindow?t.contentWindow.document:t.contentDocument;n.open(),n.write(e),n.close(),setTimeout((function(){t.contentWindow.focus(),t.contentWindow.print(),document.body.removeChild(t)}),700)}(r)}else alert(c.barcodeQuantityError)};o=function(){s(),p(),document.addEventListener("click",(function(e){var t=e.target.closest(".ddwcpos-product-action");if(t){e.preventDefault();var n=t.closest("tr"),r=t.getAttribute("data-action");n&&("print_barcode"!==r||m(n))}})),document.addEventListener("keydown",(function(e){if(e.target.matches(".ddwcpos-barcode, .ddwcpos-barcode-quantity, .ddwcpos-custom-stock")&&("Enter"===e.key||13===e.keyCode)){var t=e.target.nextElementSibling;e.preventDefault(),t&&t.click()}}))},"loading"!==document.readyState?o():document.addEventListener("DOMContentLoaded",o)})();for(var o in r)this[o]=r[o];r.__esModule&&Object.defineProperty(this,"__esModule",{value:!0})})();