File manager - Edit - /home/c14075/dragmet-ural.ru/www/bitrix/modules/catalog/install/js/catalog/product-selector/dist/product-selector.bundle.min.js
Back
this.BX=this.BX||{};(function(e,t,i,s,o,r,n,a,l,c,d,h,g,u,I,E,m){"use strict";let p=e=>e,C,T,b,S,_,f,A,L;class P extends a.DefaultFooter{constructor(e,t){super(e,t);this.loader=null;this.errorAdminHint=t.errorAdminHint||"";this.getDialog().subscribe("onSearch",this.handleOnSearch.bind(this))}getContent(){let e="";const t=this.options.allowCreateItem===true||this.options.allowEditItem===false;if(this.isViewEditButton()&&t){e=g.Tag.render(C||(C=p` <div>${0}</div> `),g.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_FOOTER_1"));const t=e.querySelector("create-button");g.Dom.replace(t,this.getLabelContainer());const i=e.querySelector("change-button");g.Dom.replace(i,this.getSaveContainer())}else if(this.isViewEditButton()){e=this.getSaveContainer()}else{e=this.getLabelContainer()}return g.Tag.render(T||(T=p` <div class="ui-selector-search-footer-box"> ${0} ${0} ${0} </div> `),e,this.getHintContainer(),this.getLoaderContainer())}isViewEditButton(){return this.options.allowEditItem===true}getLoader(){if(g.Type.isNil(this.loader)){this.loader=new r.Loader({target:this.getLoaderContainer(),size:17,color:"rgba(82, 92, 105, 0.9)"})}return this.loader}showLoader(){void this.getLoader().show()}hideLoader(){void this.getLoader().hide()}setLabel(e){if(g.Type.isString(e)){this.getLabelContainer().textContent=e}}getLabelContainer(){return this.cache.remember("label",(()=>g.Tag.render(b||(b=p` <span> <span onclick="${0}" class="ui-selector-footer-link ui-selector-footer-link-add"> ${0} </span> ${0} </span> `),this.handleClick.bind(this),this.getOption("creationLabel",g.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_FOOTER_CREATE")),this.getQueryContainer())))}getQueryContainer(){return this.cache.remember("name-container",(()=>g.Tag.render(S||(S=p` <span class="ui-selector-search-footer-query"></span> `))))}getSaveContainer(){return this.cache.remember("save-container",(()=>{const e=`ui-selector-footer-link`;const t=this.options.inputName===c.ProductSelector.INPUT_FIELD_BARCODE?"CATALOG_SELECTOR_SEARCH_POPUP_FOOTER_BARCODE_CHANGE":"CATALOG_SELECTOR_SEARCH_POPUP_FOOTER_CHANGE";return g.Tag.render(_||(_=p` <span class="${0}" onclick="${0}"> ${0} </span> `),e,this.onClickSaveChanges.bind(this),g.Loc.getMessage(t))}))}getLoaderContainer(){return this.cache.remember("loader",(()=>g.Tag.render(f||(f=p` <div class="ui-selector-search-footer-loader"></div> `))))}getHintContainer(){return this.cache.remember("hint",(()=>{let e=null;if(!this.options.allowEditItem&&!this.options.allowCreateItem){e=g.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_DISABLED_FOOTER_ALL_HINT",{"#ADMIN_HINT#":this.errorAdminHint})}else if(!this.options.allowEditItem){e=g.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_DISABLED_FOOTER_EDIT_HINT",{"#ADMIN_HINT#":this.errorAdminHint})}else if(!this.options.allowCreateItem){e=g.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_DISABLED_FOOTER_ADD_HINT",{"#ADMIN_HINT#":this.errorAdminHint})}if(!e){return null}const t=g.Tag.render(A||(A=p`<span class="ui-btn ui-btn-icon-lock ui-btn-link"></span>`));t.dataset.hint=e;t.dataset.hintNoIcon=true;BX.UI.Hint.initNode(t);return g.Tag.render(L||(L=p`<div class="product-search-selector-disabled-footer-hint">${0}</div>`),t)}))}onClickSaveChanges(){if(!this.options.allowEditItem){return}const e=this.getDialog().getActiveTab().getLastSearchQuery();this.getDialog().emit("ChangeItem:onClick",{query:e.query});this.getDialog().clearSearch();this.getDialog().hide()}createItem(){if(!this.options.allowCreateItem){return}const e=this.getDialog().getTagSelector();if(e&&e.isLocked()){return}const t=()=>{this.hideLoader();if(this.getDialog().getTagSelector()){this.getDialog().getTagSelector().unlock();this.getDialog().focusSearch()}};event.preventDefault();this.showLoader();if(e){e.lock()}this.getDialog().emitAsync("Search:onItemCreateAsync",{searchQuery:this.getDialog().getActiveTab().getLastSearchQuery()}).then((()=>{this.getTab().clearResults();this.getDialog().clearSearch();if(this.getDialog().getActiveTab()===this.getTab()){this.getDialog().selectFirstTab()}t()})).catch((()=>{t()}))}handleClick(){this.createItem()}handleOnSearch(e){const{query:t}=e.getData();if(this.options.currentValue===t||t===""){this.hide()}else{this.show()}this.getQueryContainer().textContent=" "+t}}let N=e=>e,O,v,D;class M extends a.DefaultFooter{getContent(){const e=g.Tag.render(O||(O=N` <div>${0}</div> `),g.Loc.getMessage("CATALOG_SELECTOR_LIMITED_PRODUCT_CREATION"));const t=g.Tag.render(v||(v=N` <a class="ui-btn ui-btn-sm ui-btn-primary ui-btn-hover ui-btn-round"> ${0} </a> `),g.Loc.getMessage("CATALOG_SELECTOR_LICENSE_EXPLODE"));g.Event.bind(t,"click",(()=>{BX.UI.InfoHelper.show("limit_shop_products")}));return g.Tag.render(D||(D=N` <div class="ui-selector-search-footer-box"> <div class="ui-selector-search-footer-box"> <div class="tariff-lock"></div> ${0} </div> <div> ${0} </div> </div> `),e,t)}}class y{static getCodes(){return[y.NOT_SELECTED_PRODUCT,y.FAILED_PRODUCT]}}y.NOT_SELECTED_PRODUCT="NOT_SELECTED_PRODUCT";y.FAILED_PRODUCT="FAILED_PRODUCT";let R=e=>e,w,F,k,B,H,U,V,x,G,$,X,j,Q;class W{}W.SEARCHING="SEARCHING";W.SHOW_PRODUCT_ITEM="SHOW_PRODUCT_ITEM";W.SHOW_RECENT="SHOW_RECENT";var q=babelHelpers.classPrivateFieldLooseKey("showSelectedItem");var Y=babelHelpers.classPrivateFieldLooseKey("loadPreselectedItems");var K=babelHelpers.classPrivateFieldLooseKey("showPreselectedItems");var z=babelHelpers.classPrivateFieldLooseKey("searchItem");class J{constructor(e,t={}){Object.defineProperty(this,z,{value:ie});Object.defineProperty(this,K,{value:te});Object.defineProperty(this,Y,{value:ee});Object.defineProperty(this,q,{value:Z});this.cache=new g.Cache.MemoryCache;this.id=e||g.Text.getRandom();this.selector=t.selector;if(!(this.selector instanceof c.ProductSelector)){throw new Error("Product selector instance not found.")}this.model=t.model||{};this.isEnabledSearch=t.isSearchEnabled;this.isEnabledDetailLink=t.isEnabledDetailLink;this.inputName=t.inputName||c.ProductSelector.INPUT_FIELD_NAME;this.immutableFieldNames=[c.ProductSelector.INPUT_FIELD_BARCODE,c.ProductSelector.INPUT_FIELD_NAME];if(!this.immutableFieldNames.includes(this.inputName)){this.immutableFieldNames.push(this.inputName)}this.ajaxInProcess=false;this.loadedSelectedItem=null;this.handleSearchInput=g.Runtime.debounce(this.searchInDialog,500,this)}destroy(){}getId(){return this.id}getSelectorType(){return c.ProductSelector.INPUT_FIELD_NAME}getField(e){return this.model.getField(e)}getValue(){return this.getField(this.inputName)}getFilledValue(){return this.getNameInput().value||""}isSearchEnabled(){return this.isEnabledSearch}toggleIcon(e,t){if(g.Type.isDomNode(e)){g.Dom.style(e,"display",t)}}getNameBlock(){return this.cache.remember("nameBlock",(()=>g.Tag.render(w||(w=R` <div class="ui-ctl ui-ctl-textbox ui-ctl-w100"> ${0} ${0} ${0} </div> `),this.getNameTag(),this.getNameInput(),this.getHiddenNameInput())))}getNameTag(){if(!this.model.isNew()){return""}return g.Tag.render(F||(F=R` <div class="ui-ctl-tag">${0}</div> `),g.Loc.getMessage("CATALOG_SELECTOR_NEW_TAG_TITLE"))}getNameInput(){return this.cache.remember("nameInput",(()=>{const e=g.Tag.render(k||(k=R` <input type="text" class="ui-ctl-element ui-ctl-textbox" autocomplete="off" data-name="${0}" value="${0}" placeholder="${0}" title="${0}" onchange="${0}" > `),g.Text.encode(this.inputName),g.Text.encode(this.getValue()),g.Text.encode(this.getPlaceholder()),g.Text.encode(this.getValue()),this.handleNameInputHiddenChange.bind(this));if(this.selector.getConfig("SELECTOR_INPUT_DISABLED",false)){g.Dom.addClass(e,"ui-ctl-disabled");e.setAttribute("disabled",true)}return e}))}getHiddenNameInput(){return this.cache.remember("hiddenNameInput",(()=>g.Tag.render(B||(B=R` <input type="hidden" name="${0}" value="${0}" > `),g.Text.encode(this.inputName),g.Text.encode(this.getValue()))))}handleNameInputHiddenChange(e){this.getHiddenNameInput().value=e.target.value}getClearIcon(){return this.cache.remember("closeIcon",(()=>g.Tag.render(H||(H=R` <button class="ui-ctl-after ui-ctl-icon-clear" onclick="${0}" ></button> `),this.handleClearIconClick.bind(this))))}getArrowIcon(){return this.cache.remember("arrowIcon",(()=>g.Tag.render(U||(U=R` <a href="${0}" target="_blank" class="ui-ctl-after ui-ctl-icon-forward" > `),g.Text.encode(this.model.getDetailPath()))))}getSearchIcon(){return this.cache.remember("searchIcon",(()=>g.Tag.render(V||(V=R` <button class="ui-ctl-after ui-ctl-icon-search" onclick="${0}" ></button> `),this.handleSearchIconClick.bind(this))))}layout(){this.clearInputCache();const e=g.Tag.render(x||(x=R`<div class="ui-ctl ui-ctl-w100 ui-ctl-after-icon"></div>`));this.toggleIcon(this.getClearIcon(),"none");g.Dom.append(this.getClearIcon(),e);if(this.isSearchEnabled()){if(this.selector.isProductSearchEnabled()){this.initHasDialogItems()}this.toggleIcon(this.getSearchIcon(),g.Type.isStringFilled(this.getFilledValue())?"none":"block");g.Dom.append(this.getSearchIcon(),e);g.Event.bind(this.getNameInput(),"click",this.handleClickNameInput.bind(this));g.Event.bind(this.getNameInput(),"input",this.handleSearchInput);g.Event.bind(this.getNameInput(),"blur",this.handleNameInputBlur.bind(this));g.Event.bind(this.getNameInput(),"keydown",this.handleNameInputKeyDown.bind(this));this.dialogMode=this.model.isCatalogExisted()?W.SHOW_PRODUCT_ITEM:W.SHOW_RECENT}if(this.showDetailLink()&&g.Type.isStringFilled(this.getValue())){this.toggleIcon(this.getClearIcon(),"none");this.toggleIcon(this.getSearchIcon(),"none");this.toggleIcon(this.getArrowIcon(),"block");g.Dom.append(this.getArrowIcon(),e)}g.Event.bind(this.getNameInput(),"click",this.handleIconsSwitchingOnNameInput.bind(this));g.Event.bind(this.getNameInput(),"input",this.handleIconsSwitchingOnNameInput.bind(this));g.Event.bind(this.getNameInput(),"change",this.handleNameInputChange.bind(this));g.Dom.append(this.getNameBlock(),e);return e}showDetailLink(){return this.isEnabledDetailLink}getDialog(){return this.cache.remember("dialog",(()=>{var e;const t=J.SEARCH_TYPE_ID;const i={id:t,options:{iblockId:this.model.getIblockId(),basePriceId:this.model.getBasePriceId(),currency:this.model.getCurrency()},dynamicLoad:true,dynamicSearch:true};const s=this.selector.getConfig("RESTRICTED_PRODUCT_TYPES",null);if(!g.Type.isNil(s)){i.options.restrictedProductTypes=s}const o={id:this.id+"_"+t,height:300,width:Math.max((e=this.getNameInput())==null?void 0:e.offsetWidth,565),context:"catalog-products",targetNode:this.getNameInput(),enableSearch:false,multiple:false,dropdownMode:true,searchTabOptions:{stub:true,stubOptions:{title:g.Tag.message(G||(G=R`${0}`),"CATALOG_SELECTOR_IS_EMPTY_TITLE"),subtitle:this.isAllowedCreateProduct()?g.Tag.message($||($=R`${0}`),"CATALOG_SELECTOR_IS_EMPTY_SUBTITLE"):"",arrow:true}},events:{"Item:onSelect":this.onProductSelect.bind(this),"Search:onItemCreateAsync":this.createProduct.bind(this),"ChangeItem:onClick":this.showChangeNotification.bind(this)},entities:[i]};const r=g.Extension.getSettings("catalog.product-selector");if(g.Type.isObject(r.get("limitInfo"))){o.footer=M}else if(this.model&&this.model.isCatalogExisted()){o.footer=P;o.footerOptions={inputName:this.inputName,allowEditItem:this.isAllowedEditProduct(),allowCreateItem:this.isAllowedCreateProduct(),errorAdminHint:r.get("errorAdminHint"),creationLabel:g.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_FOOTER_CREATE"),currentValue:this.getValue()}}else{o.searchOptions={allowCreateItem:this.isAllowedCreateProduct()}}return new a.Dialog(o)}))}initHasDialogItems(){if(!g.Type.isNil(this.selector.getConfig("EXIST_DIALOG_ITEMS"))){return}if(!this.selector.getModel().isEmpty()){this.selector.setConfig("EXIST_DIALOG_ITEMS",true);return}this.selector.setConfig("EXIST_DIALOG_ITEMS",false);const e=this.getDialog();if(e.hasDynamicLoad()){babelHelpers.classPrivateFieldLooseBase(this,Y)[Y]();e.subscribeOnce("onLoad",(()=>{if(e.getPreselectedItems().length>1){this.selector.setConfig("EXIST_DIALOG_ITEMS",true)}}))}else{this.selector.setConfig("EXIST_DIALOG_ITEMS",true)}}isAllowedCreateProduct(){return this.selector.getConfig("IS_ALLOWED_CREATION_PRODUCT",true)&&this.selector.checkProductAddRights()}isAllowedEditProduct(){return this.selector.checkProductEditRights()}handleNameInputKeyDown(e){const t=this.getDialog();if(e.key==="Enter"&&t.getActiveTab()===t.getSearchTab()){e.stopPropagation();e.preventDefault();if(g.Browser.isMac()&&e.metaKey||e.ctrlKey){t.getSearchTab().getFooter().createItem()}}}handleIconsSwitchingOnNameInput(e){this.toggleIcon(this.getArrowIcon(),"none");if(g.Type.isStringFilled(e.target.value)){this.toggleIcon(this.getClearIcon(),"block");this.toggleIcon(this.getSearchIcon(),"none")}else{this.toggleIcon(this.getClearIcon(),"none");if(this.isSearchEnabled()){this.toggleIcon(this.getSearchIcon(),"block")}}}clearInputCache(){this.cache.delete("dialog");this.cache.delete("nameBlock");this.cache.delete("nameInput");this.cache.delete("hiddenNameInput")}handleClearIconClick(e){this.selector.emit("onBeforeClear",{selectorId:this.selector.getId(),rowId:this.selector.getRowId()});this.loadedSelectedItem=null;if(this.selector.isProductSearchEnabled()&&!this.model.isEmpty()){this.selector.clearState();this.selector.clearLayout();this.selector.layout()}else{const e="";this.toggleIcon(this.getClearIcon(),"none");this.onChangeValue(e)}this.selector.focusName();this.selector.emit("onClear",{selectorId:this.selector.getId(),rowId:this.selector.getRowId()});e.stopPropagation();e.preventDefault()}handleNameInputChange(e){const t=e.target.value;this.onChangeValue(t)}onChangeValue(e){const t={};this.getNameInput().title=e;this.getNameInput().value=e;t[this.inputName]=e;u.EventEmitter.emit("ProductSelector::onNameChange",{rowId:this.selector.getRowId(),fields:t});if(!this.selector.isEnabledAutosave()){return}this.selector.getModel().setFields(t);this.selector.getModel().save().then((()=>{BX.UI.Notification.Center.notify({id:"saving_field_notify_name",closeButton:false,content:g.Tag.render(X||(X=R`<div>${0}</div>`),g.Loc.getMessage("CATALOG_SELECTOR_SAVING_NOTIFICATION_NAME")),autoHide:true})}))}focusName(){requestAnimationFrame((()=>this.getNameInput().focus()))}searchInDialog(){const e=this.getFilledValue().trim();if(e===""){if(this.isHasDialogItems===false){this.getDialog().hide();return}this.loadedSelectedItem=null;babelHelpers.classPrivateFieldLooseBase(this,K)[K]();return}this.dialogMode=W.SEARCHING;babelHelpers.classPrivateFieldLooseBase(this,z)[z](e);this.isSearchingInProcess=true}handleClickNameInput(){const e=this.getDialog();if(e.isOpen()||this.getFilledValue()===""&&this.isHasDialogItems===false){e.hide();return}this.showItems()}showItems(){if(this.getFilledValue()===""){babelHelpers.classPrivateFieldLooseBase(this,K)[K]();return}if(!this.model.isCatalogExisted()||this.dialogMode!==W.SHOW_PRODUCT_ITEM){this.searchInDialog();return}babelHelpers.classPrivateFieldLooseBase(this,q)[q]()}handleNameInputBlur(e){setTimeout((()=>{this.toggleIcon(this.getClearIcon(),"none");if(this.showDetailLink()&&g.Type.isStringFilled(this.getValue())){if(this.isSearchEnabled()){this.toggleIcon(this.getSearchIcon(),"none")}this.toggleIcon(this.getArrowIcon(),"block")}else{this.toggleIcon(this.getArrowIcon(),"none");if(this.isSearchEnabled()){this.toggleIcon(this.getSearchIcon(),g.Type.isStringFilled(this.getFilledValue())?"none":"block")}}}),200);if(this.isSearchEnabled()&&this.selector.isEnabledEmptyProductError()){setTimeout((()=>{if(!this.selector.inProcess()&&(this.model.isEmpty()||!g.Type.isStringFilled(this.getFilledValue()))){this.model.getErrorCollection().setError(y.NOT_SELECTED_PRODUCT,this.selector.getEmptySelectErrorMessage());this.selector.layoutErrors()}}),200)}}handleSearchIconClick(e){this.searchInDialog();this.focusName();e.stopPropagation();e.preventDefault()}getImmutableFieldNames(){return this.immutableFieldNames}setInputValueOnProductSelect(e){e.getDialog().getTargetNode().value=e.getTitle()}onProductSelect(e){const t=e.getData().item;this.setInputValueOnProductSelect(t);this.toggleIcon(this.getSearchIcon(),"none");this.clearErrors();if(this.selector){const e=t.getCustomData().get("isNew");const i=[];this.getImmutableFieldNames().forEach((e=>{if(!g.Type.isNil(t.getCustomData().get(e))){this.model.setField(e,t.getCustomData().get(e));i.push(e)}}));this.selector.onProductSelect(t.getId(),{isNew:e,immutableFields:i});this.selector.clearLayout();this.selector.layout()}this.dialogMode=W.SHOW_PRODUCT_ITEM;this.loadedSelectedItem=t;this.cache.delete("dialog")}clearErrors(){const e=this.model.getErrorCollection().getErrors();for(const t in e){if(c.ProductSelector.ErrorCodes.getCodes().includes(t)){this.model.getErrorCollection().removeError(t)}}}createProductModelFromSearchQuery(e){const t={...this.selector.getModel().getFields()};t[this.inputName]=e;return new l.ProductModel({isSimpleModel:true,isNew:true,currency:this.selector.options.currency,iblockId:this.selector.getModel().getIblockId(),basePriceId:this.selector.getModel().getBasePriceId(),fields:t})}createProduct(e){if(this.ajaxInProcess){return}this.ajaxInProcess=true;const t=e.getTarget();const{searchQuery:i}=e.getData();const s=this.createProductModelFromSearchQuery(i.getQuery());u.EventEmitter.emit(this.selector,"onBeforeCreate",{model:s});return new Promise(((e,o)=>{if(!this.checkCreationModel(s)){this.ajaxInProcess=false;t.hide();o();return}t.showLoader();s.save().then((o=>{t.hideLoader();const r=g.Text.toInteger(o.data.id);const n=t.addItem({id:r,entityId:J.SEARCH_TYPE_ID,title:i.getQuery(),tabs:t.getRecentTab().getId(),customData:{isNew:true}});this.selector.getModel().setOption("isSimpleModel",false);this.selector.getModel().setOption("isNew",true);this.getImmutableFieldNames().forEach((e=>{this.selector.getModel().setField(e,s.getField(e));this.selector.getModel().setOption(e,s.getField(e))}));if(n){n.select()}t.hide();this.cache.delete("dialog");this.ajaxInProcess=false;this.isHasDialogItems=true;e()})).catch((e=>{t.hideLoader();e.errors.forEach((e=>{BX.UI.Notification.Center.notify({closeButton:true,content:g.Tag.render(j||(j=R`<div>${0}</div>`),e.message),autoHide:true})}));this.ajaxInProcess=false;o()}))}))}checkCreationModel(e){return true}showChangeNotification(e){const{query:t}=e.getData();const i={title:g.Loc.getMessage("CATALOG_SELECTOR_SAVING_NOTIFICATION_"+this.selector.getType()),events:{onSave:()=>{if(this.selector){this.selector.getModel().setField(this.inputName,t);this.selector.getModel().save([this.inputName]).catch((e=>{e.errors.forEach((e=>{BX.UI.Notification.Center.notify({closeButton:true,content:g.Tag.render(Q||(Q=R`<div>${0}</div>`),e.message),autoHide:true})}))}))}}}};if(this.selector.getConfig("ROLLBACK_INPUT_AFTER_CANCEL",false)){i.declineCancelTitle=g.Loc.getMessage("CATALOG_SELECTOR_SAVING_NOTIFICATION_CANCEL_TITLE");i.events.onCancel=()=>{this.selector.clearLayout();this.selector.layout()}}this.selector.getModel().showSaveNotifier("nameChanger_"+this.selector.getId(),i)}getPlaceholder(){return this.isSearchEnabled()&&this.model.isEmpty()?g.Loc.getMessage("CATALOG_SELECTOR_BEFORE_SEARCH_TITLE"):g.Loc.getMessage("CATALOG_SELECTOR_VIEW_NAME_TITLE")}removeSpotlight(){}removeQrAuth(){}}function Z(){var e;if(!this.selector.isProductSearchEnabled()){return}const t=this.getDialog();t.removeItems();new Promise((e=>{if(!g.Type.isNil(this.loadedSelectedItem)){e();return}t.showLoader();g.ajax.runAction("catalog.productSelector.getSkuSelectorItem",{json:{id:this.selector.getModel().getSkuId(),options:{iblockId:this.model.getIblockId(),basePriceId:this.model.getBasePriceId(),currency:this.model.getCurrency()}}}).then((i=>{t.hideLoader();this.loadedSelectedItem=null;if(g.Type.isObject(i.data)&&!t.isLoading()){this.loadedSelectedItem=t.addItem(i.data)}e()}))})).then((()=>{if(!g.Type.isNil(this.loadedSelectedItem)){var e;t.setPreselectedItems([this.selector.getModel().getSkuId()]);t.getRecentTab().getRootNode().addItem(this.loadedSelectedItem);t.selectFirstTab();(e=t.getFooter())==null?void 0:e.hide()}else{this.searchInDialog()}}));t.getPopup().show();(e=t.getFooter())==null?void 0:e.hide()}function ee(){const e=this.getDialog();if(e.isLoading()){return}if(this.loadedSelectedItem){e.removeItems();e.loadState="UNSENT";this.loadedSelectedItem=null}e.load()}function te(){var e;if(!this.selector.isProductSearchEnabled()){return}this.dialogMode=W.SHOW_RECENT;const t=this.getDialog();babelHelpers.classPrivateFieldLooseBase(this,Y)[Y]();t.selectFirstTab();(e=t.getFooter())==null?void 0:e.hide();t.show()}function ie(e=""){if(!this.selector.isProductSearchEnabled()){return}const t=this.getDialog();t.getPopup().show();t.search(e)}J.SEARCH_TYPE_ID="product";let se=e=>e,oe;class re{constructor(e,t={}){var i;this.id=e||g.Text.getRandom();this.selector=t.selector||null;if(!(this.selector instanceof c.ProductSelector)){throw new Error("Product selector instance not found.")}this.config=t.config||{};if(!g.Type.isStringFilled((i=this.selector.getModel())==null?void 0:i.getImageCollection().getEditInput())){this.restoreDefaultInputHtml()}this.enableSaving=t.enableSaving;this.uploaderFieldMap={}}getId(){return this.id}setId(e){this.id=e}setView(e){var t;(t=this.selector.getModel())==null?void 0:t.getImageCollection().setPreview(e)}setInputHtml(e){var t;(t=this.selector.getModel())==null?void 0:t.getImageCollection().setEditInput(e)}restoreDefaultInputHtml(){var e,t;const i=`\n\t\t\t<div class='ui-image-input-container ui-image-input-img--disabled'>\n\t\t\t\t<div class='adm-fileinput-wrapper '>\n\t\t\t\t\t<div class='adm-fileinput-area mode-pict adm-fileinput-drag-area'></div>\n\t\t\t\t</div>\n\t\t\t</div>\n`;(e=this.selector.getModel())==null?void 0:e.getImageCollection().setEditInput(i);(t=this.selector.getModel())==null?void 0:t.getImageCollection().setPreview(i)}isViewMode(){return this.selector&&(this.selector.isViewMode()||!this.selector.model.isSaveable())}isEnabledLiveSaving(){return this.enableSaving}layout(){var e,t,i,s;const o=g.Tag.render(oe||(oe=se`<div></div>`));const r=this.isViewMode()?(e=this.selector.getModel())==null?void 0:(t=e.getImageCollection())==null?void 0:t.getPreview():(i=this.selector.getModel())==null?void 0:(s=i.getImageCollection())==null?void 0:s.getEditInput();g.Runtime.html(o,r);return o}}let ne=e=>e,ae,le,ce,de,he;class ge extends P{constructor(e,t={}){super(e,t);this.isEmptyBarcode=t.isEmptyBarcode;this.getDialog().subscribe("SearchTab:onLoad",this.handleOnSearchLoad.bind(this))}getContent(){this.barcodeContent=super.getContent();this.scannerContent=this.getScannerContent();g.Dom.style(this.barcodeContent,"display","none");return g.Tag.render(ae||(ae=ne` <div class="catalog-footers-container"> ${0} ${0} </div> `),this.barcodeContent,this.scannerContent)}isViewEditButton(){return!this.isEmptyBarcode&&super.isViewEditButton()}getScannerContent(){const e=g.Tag.render(le||(le=ne` <div>${0}</div> `),g.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_FOOTER_BARCODE"));const t=e.querySelector("create-button");g.Dom.replace(t,this.getScannerLabelContainer());return g.Tag.render(ce||(ce=ne` <div class="ui-selector-search-footer-box"> ${0} ${0} </div> `),e,this.getLoaderContainer())}getScannerLabelContainer(){return this.cache.remember("scannerLabel",(()=>g.Tag.render(de||(de=ne` <span onclick="${0}"> <span class="ui-selector-footer-link ui-selector-footer-link-add footer-link--warehouse-barcode-icon"> ${0} </span> ${0} </span> `),this.handleScannerClick.bind(this),g.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_FOOTER_BARCODE_START_SCAN_LABEL"),this.getScannerQueryContainer())))}getScannerQueryContainer(){return this.cache.remember("scanner_name-container",(()=>g.Tag.render(he||(he=ne` <span class="ui-selector-search-footer-query"></span> `))))}handleScannerClick(){var e;const t=(e=this.options)==null?void 0:e.inputEntity;if(t){t.startMobileScanner()}}handleOnSearch(e){const{query:t}=e.getData();if(!g.Type.isStringFilled(t)){this.show();g.Dom.style(this.scannerContent,"display","");g.Dom.style(this.barcodeContent,"display","none")}else if(this.options.currentValue===t){this.hide()}else{this.show();g.Dom.style(this.barcodeContent,"display","");g.Dom.style(this.scannerContent,"display","none")}this.getQueryContainer().textContent=" "+t;this.getScannerQueryContainer().textContent=" "+t}handleOnSearchLoad(e){const{searchTab:t}=e.getData();this.getDialog().getItems().forEach((e=>{if(e.getCustomData().get("BARCODE")===t.getLastSearchQuery().getQuery()){this.hide()}}))}}let ue=e=>e,Ie,Ee,me,pe,Ce,Te,be,Se,_e,fe;class Ae extends J{constructor(e,t={}){super(e,t);this.onFocusHandler=this.handleFocusEvent.bind(this);this.onBlurHandler=this.handleBlurEvent.bind(this);this.focused=false;this.settingsCollection=g.Extension.getSettings("catalog.product-selector");this.isInstalledMobileApp=this.selector.getConfig("IS_INSTALLED_MOBILE_APP")||this.settingsCollection.get("isInstallMobileApp");if(!this.settingsCollection.get("isEnabledQrAuth")&&this.selector.getConfig("ENABLE_BARCODE_QR_AUTH",true)){this.qrAuth=new I.QrAuthorization;this.qrAuth.createQrCodeImage()}}destroy(){g.Event.unbind(this.getNameInput(),"focus",this.onFocusHandler);g.Event.unbind(this.getNameInput(),"blur",this.onBlurHandler)}handleFocusEvent(){this.focused=true}handleBlurEvent(){this.focused=false}isSearchEnabled(){return true}showDetailLink(){return false}getNameBlock(){return this.cache.remember("nameBlock",(()=>g.Tag.render(Ie||(Ie=ue` <div class="ui-ctl ui-ctl-textbox ui-ctl-w100"> ${0} ${0} </div> `),this.getNameInput(),this.getHiddenNameInput())))}getDialog(){return this.cache.remember("dialog",(()=>{var e;const t={id:Ae.SEARCH_TYPE_ID,options:{iblockId:this.model.getIblockId(),basePriceId:this.model.getBasePriceId(),currency:this.model.getCurrency()},dynamicLoad:true,dynamicSearch:true,searchFields:[{name:"title",type:"string",system:true,searchable:false}]};const i=this.selector.getConfig("RESTRICTED_PRODUCT_TYPES",null);if(!g.Type.isNil(i)){t.options.restrictedProductTypes=i}const s={id:this.id+"_"+Ae.SEARCH_TYPE_ID,height:300,width:Math.max((e=this.getNameInput())==null?void 0:e.offsetWidth,565),context:null,targetNode:this.getNameInput(),enableSearch:false,multiple:false,dropdownMode:true,searchTabOptions:{stub:true,stubOptions:{title:g.Tag.message(Ee||(Ee=ue`${0}`),"CATALOG_SELECTOR_IS_EMPTY_TITLE"),subtitle:this.isAllowedCreateProduct()?g.Tag.message(me||(me=ue`${0}`),"CATALOG_SELECTOR_IS_EMPTY_SUBTITLE"):"",arrow:true}},events:{"Item:onSelect":this.onProductSelect.bind(this),"Search:onItemCreateAsync":this.createProduct.bind(this),"ChangeItem:onClick":this.showChangeNotification.bind(this)},entities:[t]};if(this.model.getSkuId()&&!g.Type.isStringFilled(this.model.getField(this.inputName))){s.preselectedItems=[[Ae.SEARCH_TYPE_ID,this.model.getSkuId()]]}if(g.Type.isObject(this.settingsCollection.get("limitInfo"))){s.footer=M}else{s.footer=ge;s.footerOptions={inputEntity:this,isEmptyBarcode:!this.model||!this.model.isCatalogExisted(),inputName:this.inputName,errorAdminHint:this.settingsCollection.get("errorAdminHint"),allowEditItem:this.isAllowedEditProduct(),allowCreateItem:this.isAllowedCreateProduct(),creationLabel:g.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_FOOTER_CREATE_WITH_BARCODE"),currentValue:this.getValue(),searchOptions:{allowCreateItem:this.isAllowedCreateProduct(),footerOptions:{label:g.Loc.getMessage("CATALOG_SELECTOR_SEARCH_POPUP_FOOTER_CREATE_WITH_BARCODE")}}}}return new a.Dialog(s)}))}layoutMobileQrPopup(){return this.cache.remember("qrMobilePopup",(()=>{const e=g.Tag.render(pe||(pe=ue`<span class="popup-window-close-icon"></span>`));g.Event.bind(e,"click",this.closeMobilePopup.bind(this));let t="";let i="";if(top.BX.Helper){i=g.Tag.render(Ce||(Ce=ue` <a class="product-selector-mobile-popup-link ui-btn ui-btn-light-border ui-btn-round"> ${0} </a> `),g.Loc.getMessage("CATALOG_SELECTOR_MOBILE_POPUP_HELP_BUTTON"));g.Event.bind(i,"click",(()=>{top.BX.Helper.show("redirect=detail&code=14956818")}));t=g.Tag.render(Te||(Te=ue` <a class="product-selector-mobile-popup-link ui-btn ui-btn-link"> ${0} </a> `),g.Loc.getMessage("CATALOG_SELECTOR_MOBILE_POPUP_SEND_PUSH_BUTTON"));g.Event.bind(t,"click",(()=>{top.BX.Helper.show("redirect=detail&code=15042444")}))}return g.Tag.render(be||(be=ue` <div data-role="mobile-popup"> <div class="product-selector-mobile-popup-overlay"></div> <div class="product-selector-mobile-popup-content"> <div class="product-selector-mobile-popup-title">${0}</div> <div class="product-selector-mobile-popup-text">${0}</div> <div class="product-selector-mobile-popup-qr"> ${0} </div> <div class="product-selector-mobile-popup-link-container"> ${0} ${0} </div> ${0} </div> </div> `),g.Loc.getMessage("CATALOG_SELECTOR_MOBILE_POPUP_TITLE"),g.Loc.getMessage("CATALOG_SELECTOR_MOBILE_POPUP_INSTRUCTION"),this.qrAuth.getQrNode(),i,t,e)}))}closeMobilePopup(){this.removeQrAuth();g.ajax.runAction("catalog.ProductSelector.isInstalledMobileApp",{json:{}}).then((e=>{this.selector.emit("onBarcodeQrClose",{});if(e.data===true){this.selector.emit("onBarcodeScannerInstallChecked",{});this.isInstalledMobileApp=true}}));g.userOptions.save("product-selector","barcodeQrAuth","showed","Y")}handleClickNameInput(e){if(this.qrAuth&&this.getDialog().getContainer()){if(!g.Dom.hasClass(this.getDialog().getContainer(),"qr-barcode-info")){g.Dom.addClass(this.getDialog().getContainer(),"qr-barcode-info")}if(this.getDialog().getContainer()){g.Dom.append(this.layoutMobileQrPopup(),this.getDialog().getContainer())}}super.handleClickNameInput(e)}showItems(){this.searchInDialog()}onChangeValue(e){const t={};this.getNameInput().title=e;this.getNameInput().value=e;t[this.inputName]=e;u.EventEmitter.emit("ProductSelector::onBarcodeChange",{rowId:this.selector.getRowId(),fields:t});this.selector.emit("onBarcodeChange",{value:e});if(this.selector.isEnabledAutosave()){this.selector.getModel().setField(this.inputName,e);this.selector.getModel().showSaveNotifier("barcodeChanger_"+this.selector.getId(),{title:g.Loc.getMessage("CATALOG_SELECTOR_SAVING_NOTIFICATION_BARCODE"),disableCancel:true,events:{onSave:()=>{if(this.selector){this.selector.getModel().save([this.inputName])}}}})}}searchInDialog(){const e=this.getFilledValue().trim();this.searchByBarcode(e)}searchByBarcode(e=""){if(!this.selector.isProductSearchEnabled()){return}const t=this.getDialog();if(!t){return}t.removeItems();if(!g.Type.isStringFilled(e)){if(this.model&&this.model.isCatalogExisted()){t.setPreselectedItems([[Ae.SEARCH_TYPE_ID,this.model.getSkuId()]]);t.loadState="UNSENT";t.load()}}t.show();t.search(e)}handleNameInputBlur(e){setTimeout((()=>{this.toggleIcon(this.getClearIcon(),"none");if(this.showDetailLink()&&g.Type.isStringFilled(this.getValue())){this.toggleIcon(this.getSearchIcon(),"none");this.toggleIcon(this.getArrowIcon(),"block")}else{this.toggleIcon(this.getArrowIcon(),"none");this.toggleIcon(this.getSearchIcon(),g.Type.isStringFilled(this.getFilledValue())?"none":"block")}}),200)}setInputValueOnProductSelect(e){e.getDialog().getTargetNode().value=e.getSubtitle()}getCreationProduct(e){const t={...this.selector.getModel().getFields()};t[c.ProductSelector.INPUT_FIELD_NAME]=e;return new l.ProductModel({isSimpleModel:true,isNew:true,currency:this.selector.options.currency,iblockId:this.selector.getModel().getIblockId(),basePriceId:this.selector.getModel().getBasePriceId(),fields:t})}createProductModelFromSearchQuery(e){const t=super.createProductModelFromSearchQuery(e);t.setField(c.ProductSelector.INPUT_FIELD_NAME,g.Loc.getMessage("CATALOG_SELECTOR_NEW_BARCODE_PRODUCT_NAME"));t.setField(this.inputName,e);return t}checkCreationModel(e){if(!g.Type.isStringFilled(e.getField(c.ProductSelector.INPUT_FIELD_NAME))){this.model.getErrorCollection().setError(y.NOT_SELECTED_PRODUCT,g.Loc.getMessage("CATALOG_SELECTOR_EMPTY_TITLE"));return false}return true}getPlaceholder(){return this.isSearchEnabled()&&this.model.isEmpty()?g.Loc.getMessage("CATALOG_SELECTOR_BEFORE_SEARCH_BARCODE_TITLE"):g.Loc.getMessage("CATALOG_SELECTOR_VIEW_BARCODE_TITLE")}handleClearIconClick(e){this.toggleIcon(this.getClearIcon(),"none");this.onChangeValue("");this.selector.focusName();e.stopPropagation();e.preventDefault()}startMobileScanner(e){if(this.isInstalledMobileApp){this.sendMobilePush(e);return}if(!this.qrAuth){this.qrAuth=new I.QrAuthorization;this.qrAuth.createQrCodeImage()}if(this.getDialog().isOpen()){this.getDialog().hide();this.getDialog().subscribeOnce("onHide",this.handleClickNameInput.bind(this))}else{this.handleClickNameInput(e)}}sendMobilePush(e){e==null?void 0:e.preventDefault();this.getDialog().hide();this.getNameInput().focus();if(!this.selector.isEnabledMobileScanning()){return}const t=this.selector.getMobileScannerToken();d.BarcodeScanner.open(t);const i=g.Tag.render(Se||(Se=ue`<span class='ui-notification-balloon-action'>${0}</span>`),g.Loc.getMessage("CATALOG_SELECTOR_SEND_PUSH_ON_SCANNER_NOTIFICATION_REPEAT"));g.Event.bind(i,"click",this.sendMobilePush.bind(this));const s=g.Tag.render(_e||(_e=ue` <div> <span>${0}</span> ${0} </div> `),g.Loc.getMessage("CATALOG_SELECTOR_SEND_PUSH_ON_SCANNER_NOTIFICATION"),i);BX.UI.Notification.Center.notify({content:s,category:"sending_push_barcode_scanner_notification",autoHideDelay:5e3})}getProductIdByBarcode(e){return g.ajax.runAction("catalog.ProductSelector.getProductIdByBarcode",{json:{barcode:e}})}applyScannerData(e){this.getProductIdByBarcode(e).then((t=>{const i=t==null?void 0:t.data;if(i){this.selectScannedBarcodeProduct(i)}else{this.searchByBarcode(e)}this.getNameInput().value=g.Text.encode(e)}))}selectScannedBarcodeProduct(e){this.toggleIcon(this.getSearchIcon(),"none");this.clearErrors();if(this.selector){this.selector.onProductSelect(e,{isNew:false,immutableFields:[]});this.selector.clearLayout();this.selector.layout()}this.cache.delete("dialog")}getBarcodeIcon(){return this.cache.remember("barcodeIcon",(()=>{const e=g.Tag.render(fe||(fe=ue` <button class="ui-ctl-before warehouse-barcode-icon" title="${0}"></button> `),g.Loc.getMessage("CATALOG_SELECTOR_BARCODE_ICON_TITLE"));if(!this.settingsCollection.get("isShowedBarcodeSpotlightInfo")&&this.settingsCollection.get("isAllowedShowBarcodeSpotlightInfo")&&this.selector.getConfig("ENABLE_INFO_SPOTLIGHT",true)){this.spotlight=new BX.SpotLight({id:"selector_barcode_scanner_info",targetElement:e,autoSave:true,targetVertex:"middle-center",zIndex:200});this.spotlight.show();u.EventEmitter.subscribe(this.spotlight,"BX.SpotLight:onTargetEnter",(()=>{const t=new m.Guide({steps:[{target:e,title:g.Loc.getMessage("CATALOG_SELECTOR_BARCODE_SCANNER_FIRST_TIME_HINT_TITLE"),text:g.Loc.getMessage("CATALOG_SELECTOR_BARCODE_SCANNER_FIRST_TIME_HINT_TEXT")}],onEvents:true});t.getPopup().setAutoHide(true);t.showNextStep();this.selector.setConfig("ENABLE_INFO_SPOTLIGHT",false);this.selector.emit("onSpotlightClose",{})}))}g.Event.bind(e,"click",(e=>{e.preventDefault();if(this.qrAuth){this.handleClickNameInput(e)}else{this.startMobileScanner(e)}}));return e}))}layout(){const e=super.layout();g.Dom.append(this.getBarcodeIcon(),e);this.getNameInput().className+=" catalog-product-field-input-barcode";g.Event.bind(this.getNameInput(),"focus",this.onFocusHandler);g.Event.bind(this.getNameInput(),"blur",this.onBlurHandler);return e}removeSpotlight(){if(this.spotlight){this.spotlight.close()}}removeQrAuth(){var e;const t=(e=this.getDialog().getContainer())==null?void 0:e.querySelector('[data-role="mobile-popup"]');if(t){g.Dom.remove(t);if(g.Dom.hasClass(this.getDialog().getContainer(),"qr-barcode-info")){g.Dom.removeClass(this.getDialog().getContainer(),"qr-barcode-info")}}this.qrAuth=null}}Ae.SEARCH_TYPE_ID="barcode";let Le=e=>e,Pe,Ne,Oe,ve,De,Me,ye,Re;const we=new Map;const Fe=new Map;var ke=babelHelpers.classPrivateFieldLooseKey("inAjaxProcess");class Be extends u.EventEmitter{static getById(e){return we.get(e)||null}constructor(e,t={}){super();Object.defineProperty(this,ke,{writable:true,value:false});this.mode=Be.MODE_EDIT;this.cache=new g.Cache.MemoryCache;this.type=Be.INPUT_FIELD_NAME;this.mobileScannerToken=null;this.variationChangeHandler=this.handleVariationChange.bind(this);this.onSaveImageHandler=this.onSaveImage.bind(this);this.onChangeFieldsHandler=g.Runtime.debounce(this.onChangeFields,500,this);this.onUploaderIsInitedHandler=this.onUploaderIsInited.bind(this);this.onNameChangeFieldHandler=g.Runtime.debounce(this.onNameChange,500,this);this.setEventNamespace("BX.Catalog.ProductSelector");this.id=e||g.Text.getRandom();t.inputFieldName=t.inputFieldName||Be.INPUT_FIELD_NAME;this.options=t||{};this.settings=g.Extension.getSettings("catalog.product-selector");this.type=this.options.type||Be.INPUT_FIELD_NAME;this.setMode(t.mode);if(t.model&&t.model instanceof l.ProductModel){this.model=t.model}else{this.model=l.ProductModel.getById(this.id)}if(!(this.model instanceof l.ProductModel)){this.model=new l.ProductModel({currency:t.currency,iblockId:g.Text.toNumber(t.iblockId),basePriceId:g.Text.toNumber(t.basePriceId),fields:t.fields,skuTree:t.skuTree,storeMap:t.storeMap})}this.model.getImageCollection().setMorePhotoValues(t.morePhotoValues);if(!g.Type.isNil(this.getConfig("DETAIL_PATH"))){this.model.setDetailPath(this.getConfig("DETAIL_PATH"))}if(t.failedProduct){this.model.getErrorCollection().setError(y.FAILED_PRODUCT,"")}if(this.isShowableEmptyProductError()){this.model.getErrorCollection().setError(y.NOT_SELECTED_PRODUCT,this.getEmptySelectErrorMessage())}if(t.fileView){this.model.getImageCollection().setPreview(t.fileView)}if(t.fileInput){this.model.getImageCollection().setEditInput(t.fileInput)}this.layout();if(t.skuTree){this.updateSkuTree(t.skuTree)}if(t.scannerToken){this.setMobileScannerToken(t.scannerToken)}this.subscribeEvents();we.set(this.id,this)}setModel(e){this.model=e}getModel(){return this.model}setMode(e){if(!g.Type.isNil(e)){this.mode=e===Be.MODE_VIEW?Be.MODE_VIEW:Be.MODE_EDIT}}isViewMode(){return this.mode===Be.MODE_VIEW}isShortViewFormat(){return this.getConfig("VIEW_FORMAT",Be.FULL_VIEW_FORMAT)===Be.SHORT_VIEW_FORMAT}isSaveable(){return!this.isViewMode()&&this.model.isSaveable()}isEnabledAutosave(){return this.isSaveable()&&this.getConfig("ENABLE_AUTO_SAVE",false)}isEnabledMobileScanning(){return!this.isViewMode()&&this.getConfig("ENABLE_MOBILE_SCANNING",true)}getEmptySelectErrorMessage(){return this.checkProductAddRights()?g.Loc.getMessage("CATALOG_SELECTOR_SELECTED_PRODUCT_TITLE"):g.Loc.getMessage("CATALOG_SELECTOR_SELECT_PRODUCT_TITLE")}getMobileScannerToken(){return this.mobileScannerToken||g.Text.getRandom(16)}checkProductViewRights(){var e;return(e=this.model.checkAccess(l.RightActionDictionary.ACTION_PRODUCT_VIEW))!=null?e:true}checkProductEditRights(){var e;return(e=this.model.checkAccess(l.RightActionDictionary.ACTION_PRODUCT_EDIT))!=null?e:false}checkProductAddRights(){var e;return(e=this.model.checkAccess(l.RightActionDictionary.ACTION_PRODUCT_ADD))!=null?e:false}setMobileScannerToken(e){this.mobileScannerToken=e}removeMobileScannerToken(){this.mobileScannerToken=null}getId(){return this.id}getType(){return this.type}getConfig(e,t){return BX.prop.get(this.options.config,e,t)}setConfig(e,t){this.options.config[e]=t;return this}getRowId(){return this.getConfig("ROW_ID")}getFileInput(){if(!this.fileInput){this.fileInput=new re(this.options.fileInputId,{selector:this,enableSaving:this.getConfig("ENABLE_IMAGE_CHANGE_SAVING",false)})}return this.fileInput}isProductSearchEnabled(){return this.getConfig("ENABLE_SEARCH",false)&&this.model.getIblockId()>0&&this.checkProductViewRights()}isSkuTreeEnabled(){return this.getConfig("ENABLE_SKU_TREE",true)!==false}isImageFieldEnabled(){return this.getConfig("ENABLE_IMAGE_INPUT",true)!==false}isShowableEmptyProductError(){return this.isEnabledEmptyProductError()&&(this.model.isEmpty()&&this.model.isChanged()||this.model.isSimple())}isShowableErrors(){return this.isEnabledEmptyProductError()||this.isEnabledEmptyImagesError()}isEnabledEmptyProductError(){return this.getConfig("ENABLE_EMPTY_PRODUCT_ERROR",false)}isEnabledEmptyImagesError(){return this.getConfig("ENABLE_EMPTY_IMAGES_ERROR",false)}isEnabledChangesRendering(){return this.getConfig("ENABLE_CHANGES_RENDERING",true)}isInputDetailLinkEnabled(){return this.getConfig("ENABLE_INPUT_DETAIL_LINK",false)&&g.Type.isStringFilled(this.model.getDetailPath())&&this.checkProductViewRights()}getWrapper(){if(!this.wrapper){this.wrapper=document.getElementById(this.id)}return this.wrapper}renderTo(e){this.clearLayout();this.wrapper=e;this.layout()}layout(){const e=this.getWrapper();if(!e){return}this.defineWrapperClass(e);e.innerHTML="";const t=g.Tag.render(Pe||(Pe=Le`<div class="catalog-product-field-inner"></div>`));g.Dom.append(this.layoutNameBlock(),t);if(this.getSkuTreeInstance()){g.Dom.append(this.getSkuTreeInstance().layout(),t)}g.Dom.append(this.getErrorContainer(),t);if(!this.isViewMode()){g.Dom.append(t,e)}if(this.isImageFieldEnabled()){if(!g.Reflection.getClass("BX.UI.ImageInput")){g.ajax.runAction("catalog.productSelector.getFileInput",{json:{iblockId:this.getModel().getIblockId()}}).then((()=>{this.layoutImage()}))}else{this.layoutImage()}g.Dom.append(this.getImageContainer(),e)}if(this.isViewMode()){g.Dom.append(t,e)}if(this.isViewMode()){g.Dom.append(t,e)}if(this.isShowableErrors){this.layoutErrors()}this.subscribeToVariationChange()}focusName(){if(this.searchInput){this.searchInput.focusName()}return this}getImageContainer(){return this.cache.remember("imageContainer",(()=>g.Tag.render(Ne||(Ne=Le`<div class="catalog-product-img"></div>`))))}getErrorContainer(){return this.cache.remember("errorContainer",(()=>g.Tag.render(Oe||(Oe=Le`<div class="catalog-product-error"></div>`))))}layoutErrors(){this.getErrorContainer().innerHTML="";this.clearImageErrorBorder();if(!this.model.getErrorCollection().hasErrors()){return}const e=this.model.getErrorCollection().getErrors();for(const t in e){if(!Be.ErrorCodes.getCodes().includes(t)){continue}if(t==="EMPTY_IMAGE"){this.setImageErrorBorder()}else{g.Dom.append(g.Tag.render(ve||(ve=Le`<div class="catalog-product-error-item">${0}</div>`),e[t].text),this.getErrorContainer());if(this.searchInput){g.Dom.addClass(this.searchInput.getNameBlock(),"ui-ctl-danger")}}}}setImageErrorBorder(){g.Dom.addClass(this.getImageContainer().querySelector(".adm-fileinput-area"),"adm-fileinput-drag-area-error")}clearImageErrorBorder(){g.Dom.removeClass(this.getImageContainer().querySelector(".adm-fileinput-area"),"adm-fileinput-drag-area-error")}onUploaderIsInited(){if(this.isEnabledEmptyImagesError()){requestAnimationFrame(this.layoutErrors.bind(this))}}layoutImage(){this.getImageContainer().innerHTML="";g.Dom.append(this.getFileInput().layout(),this.getImageContainer());this.refreshImageSelectorId=null}clearState(){this.getModel().initFields({ID:"",NAME:"",BARCODE:"",PRODUCT_ID:null,SKU_ID:null}).setOption("isNew",false);this.getFileInput().restoreDefaultInputHtml();this.getModel().clearSkuTree();this.skuTreeInstance=null;this.getModel().getStoreCollection().clear()}clearLayout(){const e=this.getWrapper();if(e){e.innerHTML=""}this.unsubscribeToVariationChange()}subscribeEvents(){u.EventEmitter.subscribe("ProductList::onChangeFields",this.onChangeFieldsHandler);u.EventEmitter.subscribe("ProductSelector::onNameChange",this.onNameChangeFieldHandler);u.EventEmitter.subscribe("Catalog.ImageInput::save",this.onSaveImageHandler);u.EventEmitter.subscribe("onUploaderIsInited",this.onUploaderIsInitedHandler)}unsubscribeEvents(){this.unsubscribeToVariationChange();u.EventEmitter.unsubscribe("Catalog.ImageInput::save",this.onSaveImageHandler);u.EventEmitter.unsubscribe("ProductList::onChangeFields",this.onChangeFieldsHandler);u.EventEmitter.unsubscribe("onUploaderIsInited",this.onUploaderIsInitedHandler);u.EventEmitter.unsubscribe("onUploaderIsInited",this.onUploaderIsInitedHandler);u.EventEmitter.unsubscribe("ProductSelector::onNameChange",this.onNameChangeFieldHandler)}defineWrapperClass(e){if(this.isViewMode()){g.Dom.addClass(e,"catalog-product-view");g.Dom.removeClass(e,"catalog-product-edit");if(this.isShortViewFormat()){g.Dom.addClass(e,"--short-format")}}else{g.Dom.addClass(e,"catalog-product-edit");g.Dom.removeClass(e,"catalog-product-view")}}getNameBlockView(){const e=g.Text.encode(this.model.getField("NAME"));const t=g.Loc.getMessage("CATALOG_SELECTOR_VIEW_NAME_TITLE");if(this.getModel().getDetailPath()){return g.Tag.render(De||(De=Le` <a href="${0}" title="${0}">${0}</a> `),this.getModel().getDetailPath(),t,e)}return g.Tag.render(Me||(Me=Le`<span title="${0}">${0}</span>`),t,e)}getNameInputFilledValue(){if(this.searchInput){return this.searchInput.getFilledValue()}return""}layoutNameBlock(){const e=g.Tag.render(ye||(ye=Le`<div class="catalog-product-field-input"></div>`));if(this.isViewMode()){g.Dom.append(this.getNameBlockView(),e)}else{if(this.getType()===Be.INPUT_FIELD_BARCODE){if(!this.searchInput){this.searchInput=new Ae(this.id,{selector:this,model:this.getModel(),inputName:this.options.inputFieldName})}}else{this.searchInput=new J(this.id,{selector:this,model:this.getModel(),inputName:this.options.inputFieldName,isSearchEnabled:this.isProductSearchEnabled(),isEnabledEmptyProductError:this.isEnabledEmptyProductError(),isEnabledDetailLink:this.isInputDetailLinkEnabled()})}g.Dom.append(this.searchInput.layout(),e)}return e}searchInDialog(){this.searchInput.searchInDialog();return this}updateSkuTree(e){this.getModel().setSkuTree(e);this.skuTreeInstance=null;return this}getIblockSkuTreeProperties(){return new Promise((e=>{if(Fe.has(this.getModel().getIblockId())){e(Fe.get(this.getModel().getIblockId()))}else{g.ajax.runAction("catalog.productSelector.getSkuTreeProperties",{json:{iblockId:this.getModel().getIblockId()}}).then((t=>{Fe.set(this.getModel().getIblockId(),t);e(t)}))}}))}getSkuTreeInstance(){var e;if(this.isSkuTreeEnabled()&&(e=this.getModel())!=null&&e.getSkuTree()&&!this.skuTreeInstance){this.skuTreeInstance=new o.SkuTree({skuTree:this.getModel().getSkuTree(),selectable:this.getConfig("ENABLE_SKU_SELECTION",true),hideUnselected:this.getConfig("HIDE_UNSELECTED_ITEMS",false),isShortView:this.isViewMode()&&this.isShortViewFormat()})}return this.skuTreeInstance}subscribeToVariationChange(){const e=this.getSkuTreeInstance();if(e){this.unsubscribeToVariationChange();e.subscribe("SkuProperty::onChange",this.variationChangeHandler)}}unsubscribeToVariationChange(){const e=this.getSkuTreeInstance();if(e){e.unsubscribe("SkuProperty::onChange",this.variationChangeHandler)}}handleVariationChange(e){const[t]=e.getData();const i=g.Text.toNumber(t.PARENT_PRODUCT_ID);const s=g.Text.toNumber(t.ID);if(i<=0||s<=0){return}this.emit("onBeforeChange",{selectorId:this.getId(),rowId:this.getRowId()});babelHelpers.classPrivateFieldLooseBase(this,ke)[ke]=true;g.ajax.runAction("catalog.productSelector.getSelectedSku",{json:{variationId:s,options:{priceId:this.basePriceId,currency:this.model.getCurrency(),urlBuilder:this.getConfig("URL_BUILDER_CONTEXT")}}}).then((e=>this.processResponse(e,{...this.options.config})))}onChangeFields(e){const t=e.getData();if(t.rowId!==this.getRowId()){return}const i=t.fields;this.getModel().setFields(i)}reloadFileInput(){var e;g.ajax.runAction("catalog.productSelector.getFileInput",{json:{iblockId:this.getModel().getIblockId(),skuId:(e=this.getModel())==null?void 0:e.getSkuId()}}).then((e=>{this.getModel().getImageCollection().setEditInput(e.data.html);if(this.isImageFieldEnabled()){this.layoutImage()}}))}onNameChange(e){const t=e.getData();if(t.rowId!==this.getRowId()||!this.isEnabledAutosave()){return}const i=t.fields;this.getModel().setFields(i);this.getModel().save().then((()=>{BX.UI.Notification.Center.notify({id:"saving_field_notify_name",closeButton:false,content:g.Tag.render(Re||(Re=Le`<div>${0}</div>`),g.Loc.getMessage("CATALOG_SELECTOR_SAVING_NOTIFICATION_NAME_CHANGED")),autoHide:true})}))}onSaveImage(e){const[,t,i]=e.getData();if(t!==this.getFileInput().getId()){return}this.getFileInput().setId(i.data.id);this.getFileInput().setInputHtml(i.data.input);this.getFileInput().setView(i.data.preview);this.getModel().getImageCollection().setMorePhotoValues(i.data.values);if(this.isImageFieldEnabled()){this.layoutImage()}this.emit("onChange",{selectorId:this.id,rowId:this.getRowId(),fields:this.getModel().getFields(),morePhoto:this.getModel().getImageCollection().getMorePhotoValues()})}inProcess(){return babelHelpers.classPrivateFieldLooseBase(this,ke)[ke]}onProductSelect(e,t){this.emit("onProductSelect",{selectorId:this.getId(),rowId:this.getRowId()});this.emit("onBeforeChange",{selectorId:this.getId(),rowId:this.getRowId()});this.productSelectAjaxAction(e,t)}productSelectAjaxAction(e,t={isNew:false,immutableFields:[]}){babelHelpers.classPrivateFieldLooseBase(this,ke)[ke]=true;g.ajax.runAction("catalog.productSelector.getProduct",{json:{productId:e,options:{priceId:this.basePriceId,currency:this.model.getCurrency(),urlBuilder:this.getConfig("URL_BUILDER_CONTEXT")}}}).then((e=>this.processResponse(e,{...this.options.config,...t},true)))}processResponse(e,t={},i=false){const s=(e==null?void 0:e.data)||null;babelHelpers.classPrivateFieldLooseBase(this,ke)[ke]=false;const o=(s==null?void 0:s.fields)||[];if(g.Type.isArray(t.immutableFields)){t.immutableFields.forEach((e=>{o[e]=this.getModel().getField(e)}));s.fields=o}if(i){this.clearState()}if(s){this.changeSelectedElement(s,t)}else if(!i){this.productSelectAjaxAction(this.getModel().getProductId())}this.unsubscribeToVariationChange();if(this.isEnabledChangesRendering()){this.clearLayout();this.layout()}this.emit("onChange",{selectorId:this.id,rowId:this.getRowId(),isNew:t.isNew||false,fields:o,morePhoto:this.getModel().getImageCollection().getMorePhotoValues()})}changeSelectedElement(e,t){const i=g.Text.toInteger(e.productId);const s=this.getModel().getProductId()!==i;if(s){this.getModel().setOption("productId",i);this.getModel().setOption("skuId",g.Text.toInteger(e.skuId));this.getModel().setOption("isSimpleModel",false);this.getModel().setOption("isNew",t.isNew)}this.getModel().initFields(e.fields);const o={id:"",input:"",preview:"",values:[]};if(g.Type.isObject(e.image)){o.id=e.image.id;o.input=e.image.input;o.preview=e.image.preview;o.values=e.image.values}this.getFileInput().setId(o.id);this.getFileInput().setInputHtml(o.input);this.getFileInput().setView(o.preview);this.getModel().getImageCollection().setMorePhotoValues(o.values);this.checkEmptyImageError();if(e.detailUrl){this.getModel().setDetailPath(e.detailUrl)}if(g.Type.isObject(e.skuTree)){this.updateSkuTree(e.skuTree)}}checkEmptyImageError(){if(!g.Type.isArrayFilled(this.getModel().getImageCollection().getMorePhotoValues())&&this.isEnabledEmptyImagesError()){this.getModel().getErrorCollection().setError("EMPTY_IMAGE",g.Loc.getMessage("CATALOG_SELECTOR_EMPTY_IMAGE_ERROR"))}else{this.getModel().getErrorCollection().removeError("EMPTY_IMAGE")}}removeSpotlight(){var e;(e=this.searchInput)==null?void 0:e.removeSpotlight();this.setConfig("ENABLE_INFO_SPOTLIGHT",false)}removeQrAuth(){var e;(e=this.searchInput)==null?void 0:e.removeQrAuth();this.setConfig("ENABLE_BARCODE_QR_AUTH",false)}}Be.MODE_VIEW="view";Be.MODE_EDIT="edit";Be.SHORT_VIEW_FORMAT="short";Be.FULL_VIEW_FORMAT="full";Be.INPUT_FIELD_NAME="NAME";Be.INPUT_FIELD_BARCODE="BARCODE";Be.ErrorCodes=y;e.ProductSelector=Be})(this.BX.Catalog=this.BX.Catalog||{},BX,BX,BX,BX.Catalog.SkuTree,BX,BX,BX.UI.EntitySelector,BX.Catalog,BX.Catalog,BX.Catalog,BX,BX,BX.Event,BX.UI,BX,BX.UI.Tour); //# sourceMappingURL=product-selector.bundle.map.js
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.26 |
proxy
|
phpinfo
|
Settings