(()=>{"use strict";var e={n:n=>{var o=n&&n.__esModule?()=>n.default:()=>n;return e.d(o,{a:o}),o},d:(n,o)=>{for(var r in o)e.o(o,r)&&!e.o(n,r)&&Object.defineProperty(n,r,{enumerable:!0,get:o[r]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n)};const n=window.wp.url,o=window.wp.i18n,r=window.jQuery;var d=e.n(r);const i=window.wp.apiFetch;var t=e.n(i);d()(document).ready((()=>{d()(`.${window.cdek.prefix}-show_uin`).on("click",(function(e){e.preventDefault();const n=d()(this).next(".hidden");n.length>0&&(d()(this).addClass("hidden"),n.removeClass("hidden"))})),d()(`.${window.cdek.prefix}-save_uin`).on("click",(function(e){e.preventDefault(),e.stopPropagation();const r=d()(this).parent(),i=r.find(`.${window.cdek.prefix}-jewel-uin`);if(0===i.length)return void console.error("Input not found");r.find(`.${window.cdek.prefix}-notice`).remove();const a=d()("<div></div>").addClass(`${window.cdek.prefix}-notice`);t()({method:"POST",url:(0,n.addQueryArgs)(ajaxurl,{action:`${window.cdek.prefix}-jewel-uin`,_wpnonce:window.cdek.nonce}),data:{item_id:r.data("id"),jewel_uin:i.val()}}).then((e=>{console.debug("[CDEK-ORDER-ITEM] Save UIN response",e),e.success?a.addClass("notice-success"):a.addClass("notice-error"),i.before(a.text(e.data.message))})).catch((e=>{console.error("Error catch:",e),i.before(a.addClass("notice-error").text((0,o.__)("Error saving UIN","cdekdelivery")))})).finally((()=>setTimeout((()=>a.remove()),5e3)))}))}))})();