1import{h as u,s as l,j as g,au as w,av as f,o as m,r as S,ad as h,N as T}from"./app-BLFWTgAp.js";import"./vendor-CRPCMX9G.js";function p(e,a,t="",i=""){let n=$("#rowsContainer").attr("data-source");if(n=="specification"){$.ajax({method:"POST",url:route("catalog.ajax.specification.add_line_to_specification",{id:e}),data:$("form[name='exportToSpecificationForm']").serializeArray(),dataType:"json",beforeSend:()=>l(),success:function(o){o.status=="success"?Swal.fire({title:o.title,text:"ÐеÑейÑи в гоÑовое ÑеÑение?",showCancelButton:!0,confirmButtonText:"ÐеÑейÑи",cancelButtonText:"ÐÑÑаÑÑÑÑ"}).then(c=>{c.isConfirmed?($("#exportToSpecificationModal").modal("hide"),location.href=route("catalog.specification.show",{id:o.targetSpecificationId})):location.reload()}):Swal.fire({title:o.title,text:o.message,icon:o.status}).then(()=>location.reload())},complete:()=>u()});return}$.ajax({url:route("catalog.ajax.get_recommended_sections",{specificationid:e}),success:function(o){o.indexOf("<div")>-1?($("#selectedSpecName").html(a),$("#selectedSpecDesc").html(t),$("#selectedSpecPath").html(i),$("#specificationSectionsContainer").html(o),n=="ss-basket"?($("form[name='addBasketToSpecificationForm']").attr("data-id",e),$("#addToSpecificationStep1Container").fadeOut(500),$("#addBasketToSpecificationStep2Container").fadeIn(500)):($("form[name='addItemToSpecificationForm'] input[name='specificationId']").val(e),$("#addToSpecificationStep1Container").fadeOut(500),$("#addToSpecificationStep2Container").fadeIn(500)),g()):(Swal.fire({title:"ÐÑибка Ð´Ð¾Ð±Ð°Ð²Ð»ÐµÐ½Ð¸Ñ ÑоваÑа в гоÑовое ÑеÑение",text:o,icon:"error"}),n=="ss-basket"?$("#addBasketToSpecificationModal").modal("hide"):n=="addItemToSpec"&&$("#addItemToSpecificationModal").modal("hide"))}})}function C(e,a){let t=0,i=0;for(window.specificationsArr=[];t<e.length;)(w(a,e[t].name)||a==e[t].id)&&(window.specificationsArr[i]={id:e[t].id,specification_type:e[t].specification_type,name:e[t].name,description:e[t].description,path:e[t].path,updated_at:e[t].updated_at,picture_link:e[t].picture_link,picture_link_default:e[t].picture_link_default},i++),t++}function v(){const e=document.querySelector("#addToSpecificationStep1Container #spec-modal-page-data");if(!e)return;const a=JSON.parse(e.textContent);window.specificationsOnPage=a.specificationsOnPage,window.specificationsArr=a.specifications,window.specificationsOriginalArr=a.specifications.slice(),f(1,window.specificationsArr,window.specificationsOnPage,"rowsContainer")}function r(e="addItemToSpec"){e=="ss-basket"&&$("#addBasketToSpecificationModal").modal("show"),e=="specification"&&$("#exportToSpecificationModal").modal("show"),$.ajax({url:route("catalog.ajax.get_users_specifications",{source:e}),success:function(a){$("#addToSpecificationStep1Container").html(a),v()}})}function x(){let e=$("#rowsContainer").attr("data-source");e=="ss-basket"?($("#addBasketToSpecificationStep2Container").fadeOut(500),r("ss-basket")):e=="addItemToSpec"&&($("#addToSpecificationStep2Container").fadeOut(500),$("form[name='addItemToSpecificationForm'] input[name='quantity']").val("").removeClass("is-invalid is-valid"),r()),$("#addToSpecificationStep1Container").fadeIn(500)}function b(e){$("#addToSpecSupplementaryText10").html($(e).data("supplementarytext10")),$("#addToSpecItemText1").html($(e).data("itemtext1")),$("#addToSpecImage").attr("src",$("img[data-itemnumber='"+$(e).data("itemnumber")+"']").attr("src")),$("input[name='itemnumber']").val($(e).data("itemnumber")),r()}function I(){$(document).off(".specSharedModal"),$(document).on("click.specSharedModal",'[data-action="spec:return-to-select"]',function(e){e.preventDefault(),x()}),$(document).on("click.specSharedModal",'[data-action="spec:add-item-to-spec-modal"]',function(){b(this)}),$(document).on("click.specSharedModal",'[data-action="spec:confirm-select"]',function(e){e.preventDefault(),p(Number(this.dataset.specificationId),String(this.dataset.specificationName??""),String(this.dataset.specificationDesc??""),String(this.dataset.specificationPath??""))}),$(document).on("click.specSharedModal",".make-specification-private",function(){return Swal.fire({title:"ÐÑ Ð´ÐµÐ¹ÑÑвиÑелÑно Ñ
оÑиÑе ÑделаÑÑ Ð³Ð¾Ñовое ÑеÑение ÑаÑÑнÑм?",showCancelButton:!0,confirmButtonText:"Ðа",cancelButtonText:"ÐеÑ"}).then(e=>{if(e.isConfirmed){let a=$(this).attr("data-id");$.ajax({type:"POST",url:route("catalog.ajax.change_specification_type",{id:a}),dataType:"json",success:function(){$("#addToSpecificationStep1Container").fadeOut(600),setTimeout(function(){let t=$("#rowsContainer").attr("data-source");r(t),document.getElementById("addToSpecificationStep1Container").scrollTop=0,$("#addToSpecificationStep1Container").fadeIn(600)},500)}})}}),!1}),$(document).on("click.specSharedModal",'[data-action="spec:show-new-section"]',function(e){e.preventDefault(),$("#newSection").prop("disabled",!1),$("#createNewSection").fadeIn(500),$(".radio-sections").remove()})}m(()=>{I()});let s;function k(e){[{name:"specificationSuperGroup",placeholder:"ÐÑбеÑиÑе Ñип обÑекÑа"},{name:"specificationGroup",placeholder:"ÐÑбеÑиÑе Ñаздел пÑоекÑа"},{name:"specificationClass",placeholder:"ÐÑбеÑиÑе вид гоÑового ÑеÑениÑ"}
1].forEach(({name:t,placeholder:i})=>{const n=e.find(`select[name='${t}']`);!n.length||n.data("select2")||n.select2({theme:"bootstrap4",placeholder:i,dropdownParent:n.closest("div"),matcher:T})})}function M(){let e=$("form[name='createSpecificationForm']");if(!e.length)return;const a=$("#createSpecificationModal"),t=".catalogSpecCreate";a.off(t),e.find("select[name='specificationSuperGroup']").off(t),e.find("select[name='specificationGroup']").off(t),a.on("show.bs.modal"+t,function(i){s==null&&$.ajax({type:"POST",url:route("catalog.specification.get_specification_structure"),data:"data",async:!1,dataType:"json",success:function(n){s=n}}),e=$("form[name='createSpecificationForm']"),k(e),e.find("select[name='specificationSuperGroup'], select[name='specificationGroup'], select[name='specificationClass']").find("option").remove().end(),e.find("select[name='specificationSuperGroup']").append($("<option>")),$.each(s,function(n,o){e.find("select[name='specificationSuperGroup']").append($("<option>",{value:n,text:o.superGroupName}))}),$("input[name='supergroupId']").length!=0&&e.find("select[name='specificationSuperGroup']").val($("input[name='supergroupId']").val()).trigger("change"),$("input[name='groupId']").length!=0&&e.find("select[name='specificationGroup']").val($("input[name='groupId']").val()).trigger("change"),$("input[name='classId']").length!=0&&e.find("select[name='specificationClass']").val($("input[name='classId']").val()).trigger("change"),$("input[name='source']").val(i.relatedTarget.dataset.source)}).on("hidden.bs.modal"+t,function(){S(e)}),e.find("select[name='specificationSuperGroup']").on("change"+t,function(){e.find("select[name='specificationGroup'], select[name='specificationClass']").find("option").remove().end(),$(this).val()&&$.each(s[$(this).val()].groups,function(i,n){e.find("select[name='specificationGroup']").append($("<option>",{value:i,text:n.groupName}))}),e.find("select[name='specificationGroup']").val("-1")}),e.find("select[name='specificationGroup']").on("change"+t,function(){e.find("select[name='specificationClass']").find("option").remove().end(),$(this).val()&&$.each(s[e.find("select[name='specificationSuperGroup']").val()].groups[$(this).val()].classes,function(i,n){e.find("select[name='specificationClass']").append($("<option>",{value:n.classId,text:n.className}))}),e.find("select[name='specificationClass']").val("-1")}),h(e,{validClass:"is-valid",errorClass:"is-invalid",rules:{specificationSuperGroup:{required:!1,number:!0},specificationGroup:{required:!1,number:!0},specificationClass:{required:!1,number:!0},specificationName:{required:!0,NoSpecialChars:!0,normalizer:function(i){return $.trim(i)}},specificationDescription:{NoSpecialChars:!0},specificationYoutubeLink:{UrlRegex:!0},specificationLink:{UrlRegex:!0}},messages:{specificationName:{required:"ÐожалÑйÑÑа, введиÑе название"}},errorElement:"div",errorPlacement:function(i,n){i.addClass("invalid-feedback"),i.insertAfter(n)},highlight:function(i,n,o){$(i).addClass(n).removeClass(o)},unhighlight:function(i,n,o){$(i).addClass(o).removeClass(n)},submitHandler:function(){$.ajax({method:"POST",url:route("catalog.ajax.Ñreate_specification"),dataType:"json",data:e.serialize(),beforeSend:()=>l(),success:function(i){if(i.status=="error"){Swal.fire({title:i.title,text:i.message,icon:i.status});return}let n=e.find("input[name='source']").val();if(n=="addItemToSpec")$("#createSpecificationModal").modal("hide"),$("#addItemToSpecificationModal").modal("show"),p(i.specificationId,i.specificationName,i.specificationDesc);else if(n=="ss-basket"){let o=[];if($(".basketLineCheckBox:checked").parents("tr").each(function(c,d){$(d).attr("data-isqntnull")!=1&&$(d).attr("data-isMP")!=1&&o.push($(d).attr("data-linenumber"))}),o.length==0){Swal.fire({title:"ÐÑибка пÑи добавлении ÑоваÑов в гоÑовое ÑеÑение",text:"ÐÑбеÑиÑе ÑоваÑÑ Ð² коÑзине (ÑÑÑоки Ñ Ð½ÑлевÑм колиÑеÑÑвом и ÑÑоÑонниÑ
поÑÑавÑиков игноÑиÑÑÑÑÑÑ)",icon:"error"});return}e=$("form[name='addBasketToSpecificationForm']"),e.find("input[name='basketLines']").val(o),$.ajax({method:"POST",url:route("basket.export_to_specification",{id:i.specificationId}),data:e.serialize(),dataType:"json",beforeSend:()=>l(),success:function(c){Swal.fire(c.title,c.message,c.status).then(()=>{c.status=="success"?window.location.href=route("catalog.specification.show",{id:i.specificationId}):location.reload()})}})}else n=="specification"?($("#createSpecificationModal").modal("hide"),p(i.specificationId,i.specificationName,i.specificationDesc)):Swal.fire(i.title,i.message,i.status).then(()=>{i.status=="success"&&(window.location.href=route("catalog.specification.show",{id:i.specificationId}))})},complete:()=>u()})}})}function y(){$("#addItemToSpecificationModal").off("show.bs.modal.catalogSpecModals hidden.bs.modal.catalogSpecModals").on("show.bs.modal.catalogSpecModals",function(){$("#addToSpecificationStep1Container").attr("style",""),$("#addToSpecificationStep2Container").attr("style","display: none")}).on("hidden.bs.modal.catalogSpecModals",function(){let e=$("form[name='addItemToSpecificationForm']");S(e)}),h($("form[name='addItemToSpecificationForm']"),{validClass:"is-valid",errorClass:"is-invalid",rules:{quantity:{required:!0,number:!0,min:1e-4},itemnumber:{required:!0},specificationId:{required:!0}},messages:{quantity:{required:"ÐожалÑйÑÑа, введиÑе колиÑеÑÑво",number:"ÐожалÑйÑÑа, введиÑе ÑиÑло",min:"ÐожалÑйÑÑа, введиÑе положиÑелÑное ÑиÑло"}},errorElement:"div",errorPlacement:function(e,a){e.addClass("invalid-feedback"),e.insertAfter(a)},highlight:function(e,a,t){$(e).addClass(a).removeClass(t)},unhighlight:function(e,a,t){$(e).addClass(t).removeClass(a)},submitHandler:function(e){e=$("form[name='addItemToSpecificationForm']"),$.ajax({method:"POST",url:route("catalog.ajax.add_item_to_specification"),dataType:"json",data:e.serialize(),beforeSend:function(){e.find("button[type='submit']").blockButton()},success:function(a){$("#addItemToSpecificationModal").modal("hide"),a.status=="success"?Swal.fire({title:a.title,text:a.message,icon:a.status,showCancelButton:!0,confirmButtonText:"ÐоÑовое ÑеÑение",cancelButtonText:"ÐаÑалог",reverseButtons:!0}).then(t=>{t.isConfirmed&&location.replace(route("catalog.specification.show",{id:e.find("input[name='specificationId']").val()}))}):Swal.fire({title:a.title,text:a.message,icon:a.status}).then(()=>location.reload())},complete:function(){e.find("button[type='submit']").unblockButton()}})}}),$(document).off("input.catalogSpecModals click.catalogSpecModals").on("input.catalogSpecModals",'input[name="specificationText"]',function(){let e=$(this).val();e!==""?$(".context-filter-clear-button").show():$(".context-filter-clear-button").hide(),C(window.specificationsOriginalArr,e),f(1,window.specificationsArr,window.specificationsOnPage,"rowsContainer")}).on("click.catalogSpecModals",".context-filter-clear-button",function(){$("#specificationText").val(""),$(this).hide(),window.specificationsArr=window.specificationsOriginalArr,f(1,window.specificationsArr,window.specificationsOnPage,"rowsContainer")})}function _(){M(),y()}m(()=>{_()});export{y as addItemToSpecificationBlock,r as getUsersSpecifications,_ as rebindSpecificationModals,M as specificationCreateBlock};
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.