File manager - Edit - /home/web/vm-3fadc827.na4u.ru/www/bitrix/modules/landing/install/js/landing/ui/field/color/dist/color_field.bundle.min.js
Back
this.BX=this.BX||{};this.BX.Landing=this.BX.Landing||{};this.BX.Landing.UI=this.BX.Landing.UI||{};(function(e,t,s,i,a,r,n){"use strict";const o=/^rgba? ?\((\d{1,3})[, ]+(\d{1,3})[, ]+(\d{1,3})([, ]+([\d\.]{1,5}))?\)$/i;function l(e){return!!e.match(o)}const c=/^#([\da-f]{3}){1,2}$/i;function h(e){return!!e.trim().match(c)}const u=/^hsla?\((\d{1,3}), ?(\d{1,3})%, ?(\d{1,3})%(, ?([\d .]+))?\)/i;function g(e){return!!e.trim().match(u)}function d(e){if(e.length===4){const t=parseInt(`0x${e[1]}${e[1]}`,16);const s=parseInt(`0x${e[2]}${e[2]}`,16);const i=parseInt(`0x${e[3]}${e[3]}`,16);return{r:t,g:s,b:i}}if(e.length===7){const t=parseInt(`0x${e[1]}${e[2]}`,16);const s=parseInt(`0x${e[3]}${e[4]}`,16);const i=parseInt(`0x${e[5]}${e[6]}`,16);return{r:t,g:s,b:i}}return{r:255,g:255,b:255}}function p(e){const t=e.r/255;const s=e.g/255;const i=e.b/255;const a=Math.max(t,s,i);const r=Math.min(t,s,i);let n,o,l=(a+r)/2;if(a===r){n=o=0}else{const e=a-r;o=l>.5?e/(2-a-r):e/(a+r);switch(a){case t:n=(s-i)/e+(s<i?6:0);break;case s:n=(i-t)/e+2;break;case i:n=(t-s)/e+4;break}n*=.6}return{h:Math.round(n*100),s:Math.round(o*100),l:Math.round(l*100),a:"a"in e?e.a:1}}function m(e){const t=d(e.trim());return p(t)}function v(e){let t=e.r.toString(16);let s=e.g.toString(16);let i=e.b.toString(16);if(t.length===1){t="0"+t}if(s.length===1){s="0"+s}if(i.length===1){i="0"+i}return"#"+t+s+i}function f(e){const t=e.h;const s=e.s/100;const i=e.l/100;let a=(1-Math.abs(2*i-1))*s;let r=a*(1-Math.abs(t/60%2-1));let n=i-a/2;let o=0;let l=0;let c=0;if(0<=t&&t<60){o=a;l=r;c=0}else if(60<=t&&t<120){o=r;l=a;c=0}else if(120<=t&&t<180){o=0;l=a;c=r}else if(180<=t&&t<240){o=0;l=r;c=a}else if(240<=t&&t<300){o=r;l=0;c=a}else if(300<=t&&t<360){o=a;l=0;c=r}o=Math.round((o+n)*255);l=Math.round((l+n)*255);c=Math.round((c+n)*255);return{r:o,g:l,b:c}}function b(e){const t=f(e);return v(t)}function C(e){let t=e.trim().match(o);if(t.length>0){return p({r:n.Text.toNumber(t[1]),g:n.Text.toNumber(t[2]),b:n.Text.toNumber(t[3]),a:t[5]?n.Text.toNumber(t[5]):1})}}function y(e){let t=e.trim().match(u);if(t&&t.length>0){return{h:n.Text.toNumber(t[1]),s:n.Text.toNumber(t[2]),l:n.Text.toNumber(t[3]),a:t[5]?n.Text.toNumber(t[5]):1}}}const A=/^(var\()?((--[\w\d-]*?)(-opacity_([\d_]+)?)?)\)?$/i;function L(e){return!!e.trim().match(A)}function T(e){const t=e.trim().match(A);if(!!t){const e={full:t[2],name:t[3]};if(t[3]){const s="--primary-opacity-0_";const i="--primary-opacity-0";if(t[3].startsWith(i)&&!t[3].startsWith(s)){e.opacity=0}if(t[3].startsWith(s)){let i=t[3].substr(s.length);if(i.length===1&&i!==0){i=i/10}if(i.length===2){i=i/100}e.opacity=i}}if(t[5]){e.opacity=+parseFloat(t[5].replace("_",".")).toFixed(1)}return e}return null}const E={h:205,s:1,l:50,a:1};const I="cover";const V="scroll";const _=null;const S={url:null,size:I,attachment:V,overlay:_};class P{constructor(e){this.value=E;this.hex=null;this.cssVar=null;this.setValue(e)}getName(){if(this.hex){return this.getHex()+"_"+this.getOpacity()}const{h:e,s:t,l:s}=this.getHsl();return`${e}-${t}-${s}-${this.getOpacity()}`}setValue(e){if(n.Type.isObject(e)){if(e instanceof P){this.value=e.getHsla();this.cssVar=e.getCssVar();this.hex=e.getHexOriginal()}else{this.value={...this.value,...e}}}if(n.Type.isString(e)){if(g(e)){this.value=y(e)}else if(h(e)){this.value={...m(e),a:E.a};this.hex=e}else if(l(e)){this.value=C(e)}else if(L(e)){const t=T(e);const s="--primary";if(t!==null){this.cssVar=t.name;if("opacity"in t){this.cssVar=s;this.setValue(n.Dom.style(document.documentElement,this.cssVar));this.setOpacity(t.opacity)}else{this.setValue(n.Dom.style(document.documentElement,this.cssVar))}}}}this.value.h=Math.round(this.value.h);this.value.s=Math.round(this.value.s);this.value.l=Math.round(this.value.l);this.value.a=this.value.a.toFixed(2);const t=Math.round(this.value.a*100%5);if(t<3){this.value.a=(this.value.a*100-t)/100}else{this.value.a=(this.value.a*100-t+5)/100}return this}setOpacity(e){this.setValue({a:e});return this}lighten(e){this.value.l=Math.min(this.value.l+e,100);this.hex=null;return this}darken(e){this.value.l=Math.max(this.value.l-e,0);this.hex=null;return this}saturate(e){this.value.s=Math.min(this.value.s+e,100);this.hex=null;return this}desaturate(e){this.value.s=Math.max(this.value.s-e,0);this.hex=null;return this}adjustHue(e){this.value.h=(this.value.h+e)%360;return this}getHsl(){return{h:this.value.h,s:this.value.s,l:this.value.l}}getHsla(){return{h:this.value.h,s:this.value.s,l:this.value.l,a:this.value.a}}getHex(){return this.hex||b(this.value)}getHexOriginal(){return this.hex}getOpacity(){var e;return(e=this.value.a)!=null?e:E.a}getCssVar(){return this.cssVar}getStyleString(){if(this.cssVar===null){if(this.hex&&this.getOpacity()===E.a){return this.hex}const{h:e,s:t,l:s,a:i}=this.value;return`hsla(${e}, ${t}%, ${s}%, ${i})`}else{let e=this.cssVar;if(this.value.a!==E.a){e=e+"-opacity-"+String(this.value.a).replace(".","_")}return`var(${e})`}}getStyleStringForOpacity(){const{h:e,s:t,l:s}=this.value;return`linear-gradient(to right, hsla(${e}, ${t}%, ${s}%, 0) 0%, hsla(${e}, ${t}%, ${s}%, 1) 100%)`}static compare(e,t){return e.getHsla().h===t.getHsla().h&&e.getHsla().s===t.getHsla().s&&e.getHsla().l===t.getHsla().l&&e.getHsla().a===t.getHsla().a&&e.cssVar===t.cssVar}static getMedian(e,t){return new P({h:(e.getHsla().h+t.getHsla().h)/2,s:(e.getHsla().s+t.getHsla().s)/2,l:(e.getHsla().l+t.getHsla().l)/2,a:(e.getHsla().a+t.getHsla().a)/2})}getContrast(){let e=60;let t=this.getHsl().h*Math.PI/180;e+=Math.sin(t)*10+5;let s=e-45*this.getHsl().l/100;return new P(this.value).setValue({l:(this.getHsl().l+s)%100})}getLighten(){let{h:e,s:t,l:s}=this.getHsl();if(t>0){t+=(s-50)/100*60;t=Math.min(100,Math.max(0,s))}s+=10+20*s/100;s=Math.min(100,s);return new P({h:e,s:t,l:s})}}let w=e=>e,N;class O extends i.EventEmitter{constructor(e){super();this.cache=new n.Cache.MemoryCache;this.property="color";this.options=e;this.pseudoClass=null;this.setEventNamespace("BX.Landing.UI.Field.Processor.BaseProcessor")}getProperty(){return n.Type.isArray(this.property)?this.property:[this.property]}getVariableName(){return n.Type.isArray(this.variableName)?this.variableName:[this.variableName]}isNullValue(e){return n.Type.isNull(e)}getNullValue(){return new P}getPseudoClass(){return this.pseudoClass}getLayout(){return this.cache.remember("layout",(()=>this.buildLayout()))}buildLayout(){return n.Tag.render(N||(N=w`<div>Base processor</div>`))}getClassName(){return[this.className]}getValue(){}getStyle(){if(n.Type.isNull(this.getValue())){return{[this.getVariableName()]:null}}return{[this.getVariableName()]:this.getValue().getStyleString()}}setProcessorValue(e){const t=this.getVariableName()[this.getVariableName().length-1];this.cache.delete("value");this.setValue(e[t])}setDefaultValue(e){if(!n.Type.isNull(e)){const t=this.getProperty()[this.getProperty().length-1];if(t in e){this.setValue(e[t]);this.cache.delete("value");this.unsetActive();return}}this.setValue(null);this.cache.set("value",null)}setValue(e){}onReset(){this.emit("onReset")}unsetActive(){}onChange(){this.cache.delete("value");this.emit("onChange")}defineActiveControl(e,t){}setActiveControl(e){}}let R=e=>e,k;class D extends i.EventEmitter{constructor(e){super();this.cache=new n.Cache.MemoryCache}getLayout(){return this.cache.remember("layout",(()=>this.buildLayout()))}buildLayout(){return n.Tag.render(k||(k=R` <div class="landing-ui-field-base-control"> Base control </div> `))}getValue(){return this.cache.remember("value",(()=>new P))}isNeedSetValue(e){return e!==this.getValue()}setValue(e){this.cache.set("value",e)}onChange(e){this.cache.delete("value");this.emit("onChange",{color:this.getValue()})}setActive(){n.Dom.addClass(this.getLayout(),D.ACTIVE_CLASS)}unsetActive(){n.Dom.removeClass(this.getLayout(),D.ACTIVE_CLASS)}isActive(){return n.Dom.hasClass(this.getLayout(),D.ACTIVE_CLASS)}}D.ACTIVE_CLASS="active";let B=e=>e,x,F,H,M,U;class G extends D{constructor(){super();this.setEventNamespace("BX.Landing.UI.Field.Color.Hex");this.previewMode=false;this.onInput=n.Runtime.debounce(this.onInput.bind(this),300);this.onButtonClick=this.onButtonClick.bind(this)}setPreviewMode(e){this.previewMode=!!e}buildLayout(){if(!this.previewMode){n.Event.bind(this.getInput(),"input",this.onInput);n.Event.bind(this.getButton(),"click",this.onButtonClick)}this.adjustColors(G.DEFAULT_COLOR,G.DEFAULT_BG);return n.Tag.render(x||(x=B` <div class="landing-ui-field-color-hex"> ${0} ${0} </div> `),this.getInput(),this.getButton())}getInput(){return this.cache.remember("input",(()=>this.previewMode?n.Tag.render(F||(F=B`<div class="landing-ui-field-color-hex-preview">${0}</div>`),G.DEFAULT_TEXT):n.Tag.render(H||(H=B`<input type="text" name="hexInput" value="${0}" class="landing-ui-field-color-hex-input">`),G.DEFAULT_TEXT)))}getButton(){return this.cache.remember("editButton",(()=>this.previewMode?n.Tag.render(M||(M=B` <svg class="landing-ui-field-color-hex-preview-btn" width="9" height="9" xmlns="http://www.w3.org/2000/svg"> <path d="M7.108 0l1.588 1.604L2.486 7.8.896 6.194 7.108 0zM.006 8.49a.166.166 0 00.041.158.161.161 0 00.16.042l1.774-.478L.484 6.715.006 8.49z" fill="#525C69" fill-rule="evenodd"/> </svg>`)):n.Tag.render(U||(U=B` <svg class="landing-ui-field-color-hex-preview-btn" width="12" height="9" xmlns="http://www.w3.org/2000/svg"> <path d="M4.27 8.551L.763 5.304 2.2 3.902l2.07 1.846L9.836.533l1.439 1.402z" fill="#525C69" fill-rule="evenodd"/> </svg>`))))}onInput(){let e=this.getInput().value.replace(/[^\da-f]/gi,"");e=e.substring(0,6);this.getInput().value="#"+e.toLowerCase();this.onChange()}onButtonClick(){this.onChange();this.emit("onButtonClick",{color:this.getValue()})}onChange(e){const t=this.getInput().value.length===7&&h(this.getInput().value)?new P(this.getInput().value):null;this.setValue(t);this.cache.delete("value");this.emit("onChange",{color:t})}adjustColors(e,t){n.Dom.style(this.getInput(),"background-color",t);n.Dom.style(this.getInput(),"color",e);n.Dom.style(this.getButton().querySelector("path"),"fill",e)}focus(){if(!this.previewMode){if(this.getValue()===null){this.getInput().value="#"}this.getInput().focus()}}unFocus(){if(!this.previewMode){this.getInput().blur()}}getValue(){return this.cache.remember("value",(()=>this.getInput().value===G.DEFAULT_TEXT?null:new P(this.getInput().value)))}setValue(e){if(this.isNeedSetValue(e)){super.setValue(e);if(e!==null){this.adjustColors(e.getContrast().getHex(),e.getHex());this.setActive()}else{this.adjustColors(G.DEFAULT_COLOR,G.DEFAULT_BG);this.unsetActive()}if(this.previewMode){this.getInput().innerText=e!==null?e.getHex():G.DEFAULT_TEXT}else if(r.PageObject.getRootWindow().document.activeElement!==this.getInput()){this.getInput().value=e!==null?e.getHex():G.DEFAULT_TEXT}}}setActive(){n.Dom.addClass(this.getInput(),G.ACTIVE_CLASS)}unsetActive(){n.Dom.removeClass(this.getInput(),G.ACTIVE_CLASS)}isActive(){return n.Dom.hasClass(this.getInput(),G.ACTIVE_CLASS)}}G.DEFAULT_TEXT="#HEX";G.DEFAULT_COLOR="#000000";G.DEFAULT_BG="#eeeeee";let $=e=>e,X,z;class j extends D{static getDefaultSaturation(){const e=window.top.document.location.saturation;const t=new URL(window.top.document.location).searchParams.get("saturation");const s=e||t||j.DEFAULT_SATURATION;window.top.document.body.style.setProperty("--saturation",s+"%");return parseInt(s)}constructor(e){super();this.setEventNamespace("BX.Landing.UI.Field.Color.Spectrum");this.onPickerDragStart=this.onPickerDragStart.bind(this);this.onPickerDragMove=this.onPickerDragMove.bind(this);this.onPickerDragEnd=this.onPickerDragEnd.bind(this);this.onScroll=this.onScroll.bind(this);this.document=r.PageObject.getRootWindow().document;this.scrollContext=e.contentRoot;n.Event.bind(this.getLayout(),"mousedown",this.onPickerDragStart)}buildLayout(){return n.Tag.render(X||(X=$` <div class="landing-ui-field-color-spectrum"> ${0} </div> `),this.getPicker())}getPicker(){return this.cache.remember("picker",(()=>n.Tag.render(z||(z=$`<div class="landing-ui-field-color-spectrum-picker"></div>`))))}getPickerPos(){return{x:n.Text.toNumber(n.Dom.style(this.getPicker(),"left")),y:n.Text.toNumber(n.Dom.style(this.getPicker(),"top"))}}onPickerDragStart(e){if(e.ctrlKey||e.metaKey||e.button){return}n.Event.bind(this.scrollContext,"scroll",this.onScroll);n.Event.bind(this.document,"mousemove",this.onPickerDragMove);n.Event.bind(this.document,"mouseup",this.onPickerDragEnd);n.Dom.addClass(this.document.body,"landing-ui-field-color-draggable");this.onScroll();this.showPicker();this.onPickerDragMove(e)}onPickerDragMove(e){if(e.target===this.getPicker()){return}this.setPickerPos(e.pageX,e.pageY);this.onChange()}onPickerDragEnd(){n.Event.unbind(this.scrollContext,"scroll",this.onScroll);n.Event.unbind(this.document,"mousemove",this.onPickerDragMove);n.Event.unbind(this.document,"mouseup",this.onPickerDragEnd);n.Dom.removeClass(this.document.body,"landing-ui-field-color-draggable")}onScroll(){this.cache.delete("layoutSize")}getLayoutRect(){return this.cache.remember("layoutSize",(()=>{const e=this.getLayout().getBoundingClientRect();return{width:e.width,height:e.height,top:e.top,left:e.left}}))}setPickerPos(e,t){const{width:s,height:i,top:a,left:r}=this.getLayoutRect();let o=Math.min(Math.max(e-r,0),s);o=o>s/j.HUE_RANGE*j.HUE_RANGE_GRAY_THRESHOLD?s/j.HUE_RANGE*j.HUE_RANGE_GRAY_MIDDLE:o;n.Dom.style(this.getPicker(),{left:`${o}px`,top:`${Math.min(Math.max(t-a,0),i)}px`})}getValue(){return this.cache.remember("value",(()=>{if(n.Dom.hasClass(this.getPicker(),j.HIDE_CLASS)){return null}const e=this.getLayout().getBoundingClientRect().width;const t=this.getPickerPos().x/e*j.HUE_RANGE;const s=this.getLayout().getBoundingClientRect().height;const i=(1-this.getPickerPos().y/s)*100;if(isNaN(t)||isNaN(i)){return null}return new P({h:Math.min(t,j.HUE_RANGE_GRAY_THRESHOLD),s:t>=j.HUE_RANGE_GRAY_THRESHOLD?0:j.getDefaultSaturation(),l:i})}))}setValue(e){super.setValue(e);if(e!==null&&j.isSpectrumValue(e)){const{h:t,s:s,l:i}=e.getHsl();const a=s===0?j.HUE_RANGE_GRAY_MIDDLE/j.HUE_RANGE*100:t/j.HUE_RANGE*100;n.Dom.style(this.getPicker(),"left",`${a}%`);const r=100-i;n.Dom.style(this.getPicker(),"top",`${r}%`);this.showPicker()}else{this.hidePicker()}}hidePicker(){n.Dom.addClass(this.getPicker(),j.HIDE_CLASS)}showPicker(){n.Dom.removeClass(this.getPicker(),j.HIDE_CLASS)}isActive(){return this.getValue()!==null&&j.isSpectrumValue(this.getValue())}static isSpectrumValue(e){return e!==null&&(e.getHsl().s===j.getDefaultSaturation()||e.getHsl().s===0)}}j.DEFAULT_SATURATION=100;j.HUE_RANGE=375;j.HUE_RANGE_GRAY_THRESHOLD=360;j.HUE_RANGE_GRAY_MIDDLE=367;j.HIDE_CLASS="hidden";let Y=e=>e,W,Z;class q extends i.EventEmitter{constructor(){super();this.cache=new n.Cache.MemoryCache;this.setEventNamespace("BX.Landing.UI.Field.Color.Recent")}getLayout(){this.initItems();return this.getLayoutContainer()}getLayoutContainer(){return this.cache.remember("layout",(()=>n.Tag.render(W||(W=Y`<div class="landing-ui-field-color-recent"></div>`))))}initItems(){if(q.itemsLoaded){this.buildItemsLayout()}else{a.Backend.getInstance().action("Utils::getUserOption",{name:q.USER_OPTION_NAME}).then((e=>{if(e&&n.Type.isString(e.items)){q.items=[];e.items.split(",").forEach((e=>{if(h(e)&&q.items.length<q.MAX_ITEMS){q.items.push(e)}}));q.itemsLoaded=true;this.buildItemsLayout()}}))}}buildItemsLayout(){n.Dom.clean(this.getLayoutContainer());q.items.forEach((e=>{if(h(e)){let t=n.Tag.render(Z||(Z=Y`<div class="landing-ui-field-color-recent-item" style="background:${0}" data-value="${0}" ></div>`),e,e);n.Event.bind(t,"click",(()=>this.onItemClick(event)));n.Dom.append(t,this.getLayoutContainer())}}));return this}onItemClick(e){this.emit("onChange",{hex:e.currentTarget.dataset.value})}addItem(e){if(h(e)){let t=q.items.indexOf(e);if(t!==-1){q.items.splice(t,1)}q.items.unshift(e);if(q.items.length>q.MAX_ITEMS){q.items.splice(q.MAX_ITEMS)}this.buildItemsLayout();this.saveItems()}return this}saveItems(){if(q.items.length>0){BX.userOptions.save("landing",q.USER_OPTION_NAME,"items",q.items)}return this}}q.USER_OPTION_NAME="color_field_recent_colors";q.MAX_ITEMS=6;q.items=[];q.itemsLoaded=false;let K=e=>e,J,Q,ee,te;class se extends D{constructor(e){super();this.setEventNamespace("BX.Landing.UI.Field.Color.Colorpicker");this.popupId="colorpicker_popup_"+n.Text.getRandom();this.popupTargetContainer=e.contentRoot;this.hexPreview=new G;this.hexPreview.setPreviewMode(true);n.Event.bind(this.hexPreview.getLayout(),"click",this.onPopupOpenClick.bind(this));this.hex=new G;this.hex.subscribe("onChange",this.onHexChange.bind(this));this.hex.subscribe("onButtonClick",this.onSelectClick.bind(this));this.spectrum=new j(e);this.spectrum.subscribe("onChange",this.onSpectrumChange.bind(this));this.recent=new q;this.recent.subscribe("onChange",this.onRecentChange.bind(this));n.Event.bind(this.getCancelButton(),"click",this.onCancelClick.bind(this));n.Event.bind(this.getSelectButton(),"click",this.onSelectClick.bind(this));this.previously=this.getValue()}onSelectClick(e){const t=e instanceof i.BaseEvent?e.getData().color:this.getValue();if(t!==null){this.recent.addItem(this.getValue().getHex())}this.getPopup().close()}buildLayout(){return n.Tag.render(J||(J=K` <div class="landing-ui-field-color-colorpicker"> ${0} </div> `),this.hexPreview.getLayout())}getPopupContent(){return n.Tag.render(Q||(Q=K` <div class="landing-ui-field-color-popup-container"> <div class="landing-ui-field-color-popup-head"> ${0} ${0} </div> ${0} <div class="landing-ui-field-color-popup-footer"> ${0} ${0} </div> </div> `),this.recent.getLayout(),this.hex.getLayout(),this.spectrum.getLayout(),this.getSelectButton(),this.getCancelButton())}getSelectButton(){return this.cache.remember("selectButton",(()=>n.Tag.render(ee||(ee=K` <button class="ui-btn ui-btn-xs ui-btn-primary"> ${0} </button> `),n.Loc.getMessage("LANDING_FIELD_COLOR-BUTTON_SELECT"))))}getCancelButton(){return this.cache.remember("cancelButton",(()=>n.Tag.render(te||(te=K` <button class="ui-btn ui-btn-xs ui-btn-light-border"> ${0} </button> `),n.Loc.getMessage("LANDING_FIELD_COLOR-BUTTON_CANCEL"))))}getHexPreviewObject(){return this.hexPreview}getPopup(){return this.cache.remember("popup",(()=>s.PopupManager.create({id:this.popupId,className:"landing-ui-field-color-spectrum-popup",autoHide:true,bindElement:this.hexPreview.getLayout(),bindOptions:{forceTop:true,forceLeft:true},padding:0,contentPadding:14,width:260,offsetTop:-37,offsetLeft:-180,content:this.getPopupContent(),closeByEsc:true,targetContainer:this.popupTargetContainer})))}getValue(){return this.cache.remember("value",(()=>this.spectrum.getValue()))}onHexChange(e){this.setValue(e.getData().color);this.onChange(e)}onSpectrumChange(e){this.hex.unFocus();this.setValue(e.getData().color);this.onChange(e)}onRecentChange(e){const t=new P(e.getData().hex);this.setValue(t);this.onChange(new i.BaseEvent({data:{color:t}}))}onCancelClick(){this.setValue(this.previously);this.getPopup().close();this.onChange(new i.BaseEvent({data:{color:this.getValue()}}))}onPopupOpenClick(){this.recent.buildItemsLayout();this.previously=this.getValue();this.getPopup().show();if(this.getPopup().isShown()){this.hex.focus()}}setValue(e){if(this.isNeedSetValue(e)){super.setValue(e);this.spectrum.setValue(e);this.hex.setValue(e);this.hexPreview.setValue(e)}this.setActivity(e)}setActivity(e){if(e!==null){if(this.spectrum.isActive()){this.hex.unsetActive()}else{this.hex.setActive()}this.hexPreview.setActive()}}unsetActive(){this.hex.unsetActive();this.hexPreview.unsetActive()}isActive(){return this.hex.isActive()||this.hexPreview.isActive()}}let ie=e=>e,ae;class re extends i.EventEmitter{constructor(){super();this.cache=new n.Cache.MemoryCache;this.setEventNamespace("BX.Landing.UI.Field.Color.Primary");n.Event.bind(this.getLayout(),"click",(()=>this.onClick()))}getLayout(){return this.cache.remember("layout",(()=>n.Tag.render(ae||(ae=ie` <div class="landing-ui-field-color-primary"> <i class="landing-ui-field-color-primary-preview"></i> <span class="landing-ui-field-color-primary-text"> ${0} </span> </div> `),n.Loc.getMessage("LANDING_FIELD_COLOR-PRIMARY_TITLE"))))}getValue(){return this.cache.remember("value",(()=>new P(re.CSS_VAR)))}onClick(){this.setActive();this.emit("onChange",{color:this.getValue()})}setActive(){n.Dom.addClass(this.getLayout(),re.ACTIVE_CLASS)}unsetActive(){n.Dom.removeClass(this.getLayout(),re.ACTIVE_CLASS)}isActive(){return n.Dom.hasClass(this.getLayout(),re.ACTIVE_CLASS)}isPrimaryValue(e){return e!==null&&this.getValue().getCssVar()===e.getCssVar()}}re.ACTIVE_CLASS="active";re.CSS_VAR="--primary";function ne(e){return new RegExp(oe(e))}function oe(e){return e.source.replace(/(^\^)|(\$$)/g,"")}const le=/^(linear|radial)-gradient\(.*\)$/i;const ce=/^(linear|radial)-gradient\(.*?((\d)+deg).*?\)$/gi;const he=oe(c);const ue=new RegExp("((rgba|hsla)?\\([\\d% .,]+\\)|transparent|"+he+")+","ig");function ge(e){return!!e.trim().match(le)}class de{constructor(e){this.value={from:new P("#ffffff"),to:new P(re.CSS_VAR),angle:de.DEFAULT_ANGLE,type:de.DEFAULT_TYPE};this.setValue(e)}getName(){return this.value.from.getName()+"_"+this.value.to.getName()+"_"+this.getAngle()+"_"+this.getType()}setValue(e){if(n.Type.isObject(e)){if(e instanceof de){this.value.from=new P(e.getFrom());this.value.to=new P(e.getTo());this.value.angle=e.getAngle();this.value.type=e.getType()}else{if("from"in e){this.value.from=new P(e.from)}if("to"in e){this.value.to=new P(e.to)}if("angle"in e){this.value.angle=n.Text.toNumber(e.angle)}if("type"in e){this.value.type=e.type}}}else if(n.Type.isString(e)&&ge(e)){this.parseGradientString(e)}return this}setOpacity(e){this.value.from.setOpacity(e);this.value.to.setOpacity(e);return this}parseGradientString(e){const t=e.trim().match(le);if(!!t){this.setValue({type:t[1]})}const s=e.trim().match(ce);if(!!s){this.setValue({angle:s[2]})}const i=e.trim().match(ue);if(i&&i.length>0){this.setValue({from:new P(i[0])});this.setValue({to:new P(i[i.length-1])})}}getFrom(){return this.value.from}getTo(){return this.value.to}getAngle(){return this.value.angle}setAngle(e){if(n.Type.isNumber(e)){this.value.angle=Math.min(Math.max(e,0),360)}return this}getType(){return this.value.type}setType(e){if(e===de.TYPE_RADIAL||e===de.TYPE_LINEAR){this.value.type=e}return this}getOpacity(){var e;return(e=(this.value.from.getOpacity()+this.value.to.getOpacity())/2)!=null?e:E.a}getStyleString(){const e=this.value.angle;const t=this.value.type;const s=this.value.from.getStyleString();const i=this.value.to.getStyleString();return t==="linear"?`linear-gradient(${e}deg, ${s} 0%, ${i} 100%)`:`radial-gradient(circle farthest-side at 50% 50%, ${s} 0%, ${i} 100%)`}getStyleStringForOpacity(){return`radial-gradient(at top left, ${this.value.from.getHex()}, transparent)`+`, radial-gradient(at bottom left, ${this.value.to.getHex()}, transparent)`}static compare(e,t,s=true){const i=P.compare(e.getFrom(),t.getFrom())&&P.compare(e.getTo(),t.getTo())||P.compare(e.getTo(),t.getFrom())&&P.compare(e.getFrom(),t.getTo());const a=s?e.getAngle()===t.getAngle()&&e.getType()===t.getType():true;return i&&a}}de.TYPE_RADIAL="radial";de.TYPE_LINEAR="linear";de.DEFAULT_ANGLE=180;de.DEFAULT_TYPE="linear";const pe="color";const me="gradient";class ve{static getDefaultPresets(){return ve.cache.remember("default",(()=>{const e=[];ve.defaultPresets.forEach((t=>{e.push({id:t.id,type:"color",items:t.items.map((e=>new P(m(e))))})}));return e}))}static getPrimaryColorPreset(){return this.cache.remember("primary",(()=>{const e={id:"defaultPrimary",items:[]};const t=new P(n.Dom.style(document.documentElement,"--primary").trim());e.items.push(new P(t));if(t.getHsl().s<=10){const s=t.getHsl().l>50?Math.ceil(t.getHsl().l/100*5):Math.floor(t.getHsl().l/100*5);const i=5-s;const a=t.getHsl().l/(s+1);const r=(100-t.getHsl().l)/(i+1);for(let i=1;i<=s;i++){e.items.push(new P(t).darken(a*i))}for(let s=1;s<=i;s++){e.items.push(new P(t).lighten(r*s))}const n=15;const o=15;const l=new P(ve.BITRIX_COLOR);e.items[6]=new P(l);e.items[7]=new P(l.darken(n).saturate(o));e.items[8]=new P(l.darken(n).saturate(o));l.lighten(n*2).desaturate(o*2);e.items[9]=new P(l.lighten(n).desaturate(o));e.items[10]=new P(l.lighten(n).desaturate(o));l.darken(n*2).saturate(o*2);e.items[11]=new P(l).adjustHue(180)}else{const s=(90-t.getHsl().l)/3;const i=(t.getHsl().l-10)/3;const a=(90-t.getHsl().s)/3;const r=(t.getHsl().s-10)/3;e.items[1]=new P(t.darken(i).saturate(a));e.items[2]=new P(t.darken(i).saturate(a));e.items[3]=new P(t.darken(i).saturate(a));t.lighten(i*3).desaturate(a*3);e.items[4]=new P(t.desaturate(r).lighten(s));e.items[5]=new P(t.desaturate(r).lighten(s));e.items[11]=new P(t.desaturate(r).lighten(s));t.saturate(r*3).darken(s*3);e.items[7]=new P(t.adjustHue(40));e.items[8]=new P(t.adjustHue(-80));e.items[9]=new P(t.adjustHue(180));e.items[6]=new P(t.adjustHue(40));e.items[10]=new P(t.adjustHue(40))}return e}))}static getBlackAndWhitePreset(){return this.cache.remember("blackAndWhite",(()=>{const e={id:"blackAndWhite",items:[]};const t=new P("#ffffff");e.items.push(new P(t));e.items.push(new P(t.darken(14.28)));e.items.push(new P(t.darken(14.28)));e.items.push(new P(t.darken(14.28)));e.items.push(new P(t.darken(14.28)));e.items.push(new P(t.darken(14.28)));e.items.push(new P(t.darken(14.28)));e.items.push(new P(t.darken(14.32)));return e}))}static getGradientByColorOptions(e){const t=[];const s=[[1,2],[1,4],[5,12],[1,8],[8,9],[1,9],[10,7],[7,11]];s.forEach((s=>{t.push(new de({from:new P(e.items[s[0]-1]),to:new P(e.items[s[1]-1]),angle:de.DEFAULT_ANGLE,type:de.DEFAULT_TYPE}))}));return{type:me,items:t}}}ve.BITRIX_COLOR="#2fc6f6";ve.cache=new n.Cache.MemoryCache;ve.defaultPresets=[{id:"agency",items:["#ff6366","#40191a","#803233","#bf4b4d","#e65a5c","#ffc1c2","#363643","#57dca3","#ee76ba","#ffa864","#eaeaec","#fadbdc"]},{id:"accounting",items:["#a5c33c","#384215","#6f8228","#8fa834","#b0cf40","#dae6ae","#4c4c4c","#5d84e6","#cd506b","#fe6466","#dfdfdf","#e9f0cf"]},{id:"app",items:["#4fd2c2","#1f524c","#379187","#46b8aa","#54dece","#c8f1ec","#6639b6","#e81c62","#9a69ca","#6279d8","#ffc337","#e9faf8"]},{id:"architecture",items:["#c94645","#4a1919","#8a2f2f","#b03c3c","#d64949","#eec3c3","#363643","#446d90","#a13773","#c98145","#eaeaec","#f9e8e7"]},{id:"business",items:["#3949a0","#232c61","#313e87","#3e4fad","#556ced","#d8d7dc","#14122c","#1d1937","#a03949","#2f295a","#c87014","#f4f4f5"]},{id:"charity",items:["#f5f219","#f58419","#f5cc19","#a8e32a","#f9f76a","#fcfbb6","#000000","#262e37","#74797f","#e569b1","#edeef0","#fefedf"]},{id:"construction",items:["#f7b70b","#382a02","#785905","#b88907","#dea509","#fdf1d1","#111111","#a3a3a3","#f7410b","#f70b4b","#d6dde9","#fef9ea"]},{id:"consulting",items:["#21a79b","#38afa5","#14665f","#1c8c83","#30f2e2","#a9ddd9","#ec4672","#58d400","#f0ac00","#2d6faf","#2da721","#e6f5f4"]},{id:"corporate",items:["#6ab8ee","#31556e","#4e86ad","#5fa3d4","#70c1fa","#d2e9f8","#36e2c0","#ffaa3c","#ee6a76","#ffa468","#5feb99","#ebf4fb"]},{id:"courses",items:["#6bda95","#2c593d","#4b9969","#5ebf83","#70e69d","#c2f0d3","#31556e","#ff947d","#738ed3","#f791ab","#ffb67d","#e2f8eb"]},{id:"event",items:["#f73859","#380d14","#781c2b","#b82a42","#de334f","#fdbbc6","#151726","#ffb553","#30d59b","#b265e0","#edeef0","#ffeaed"]},{id:"gym",items:["#6b7de0","#2f3661","#4d5aa1","#5f6fc7","#7284ed","#e4e8fa","#333333","#ffd367","#a37fe8","#e06b7d","#6dc1e0","#f4f6fd"]},{id:"lawyer",items:["#e74c3c","#69231b","#a8382c","#cf4536","#f55240","#f9d0cb","#4e4353","#5a505e","#e7863c","#38a27f","#e2e1e3","#fdeeec"]},{id:"photography",items:["#f7a700","#382600","#785200","#b87d00","#de9800","#fde8ba","#333333","#0b5aa0","#e93d18","#06c4ed","#3672a8","#fff6e3"]},{id:"restaurant",items:["#e6125d","#660829","#a60d43","#cc1052","#f21361","#facfde","#0eb88e","#00946f","#e04292","#9b12e6","#bfde00","#fef2f6"]},{id:"shipping",items:["#ff0000","#400000","#800000","#bf0000","#e60000","#ffb4b4","#333333","#ff822a","#d63986","#00ac6b","#ffb800","#fff3f3"]},{id:"spa",items:["#9dba04","#313b01","#667a02","#86a103","#a6c704","#e4ecb9","#ba7c04","#cf54bb","#049dba","#1d7094","#eead2f","#f2f6dd"]},{id:"travel",items:["#ee4136","#6e1f19","#ad3128","#d43c31","#fa4639","#fef1f0","#31353e","#3e434d","#ee8036","#428abc","#eaebec","#c3c4c7"]},{id:"wedding",items:["#d65779","#572431","#963e55","#bd4d6b","#e35d81","#f7dfe5","#af58a7","#6bc34b","#ec8c60","#50a098","#57b9d6","#fdf4f6"]}];let fe=e=>e,be,Ce;class ye extends i.EventEmitter{constructor(e){super();this.cache=new n.Cache.MemoryCache;this.setEventNamespace("BX.Landing.UI.Field.Color.Preset");this.id=e.id;this.type=e.type||pe;this.items=e.items;this.activeItem=null}getId(){return this.id}getGradientPreset(){const e=this.type===me?{type:me,items:this.items}:ve.getGradientByColorOptions({items:this.items});return new ye(e)}getLayout(){return this.cache.remember("layout",(()=>n.Tag.render(be||(be=fe` <div class="landing-ui-field-color-preset"> ${0} </div> `),this.items.map((e=>this.getItemLayout(e.getName()))))))}getItemLayout(e){return this.cache.remember(e,(()=>{const t=this.getItemByName(e);const s=n.Type.isString(t)?t:t.getStyleString();const i=n.Tag.render(Ce||(Ce=fe` <div class="landing-ui-field-color-preset-item" style="background: ${0}" data-name="${0}" ></div> `),s,e);n.Event.bind(i,"click",this.onItemClick.bind(this));return i}))}getItemByName(e){return this.items.find((t=>e===t.getName()))||null}isPresetValue(e){if(e===null){return false}return this.items.some((t=>{if(t instanceof P&&e instanceof P){return P.compare(t,new P(e).setOpacity(1))}else if(t instanceof de&&e instanceof de){return de.compare(t,e,false)}return false}))}onItemClick(e){this.setActiveItem(e.currentTarget.dataset.name);let t=null;if(this.activeItem!==null){t=this.activeItem instanceof de?new de(this.activeItem):new P(this.activeItem)}this.emit("onChange",{color:t})}setActiveItem(e){this.activeItem=this.getItemByName(e);this.items.forEach((t=>{const s=t.getName();if(e===s){n.Dom.addClass(this.getItemLayout(s),ye.ACTIVE_CLASS)}else{n.Dom.removeClass(this.getItemLayout(s),ye.ACTIVE_CLASS)}}))}setActiveValue(e){if(e!==null){if(e instanceof de){this.setActiveItem(new de(e).setAngle(de.DEFAULT_ANGLE).setType(de.DEFAULT_TYPE).getName())}else{this.setActiveItem(new P(e).setOpacity(1).getName())}}}unsetActive(){this.items.forEach((e=>{n.Dom.removeClass(this.getItemLayout(e.getName()),ye.ACTIVE_CLASS)}))}isActive(){return this.items.some((e=>n.Dom.hasClass(this.getItemLayout(e.getName()),ye.ACTIVE_CLASS)))}}ye.ACTIVE_CLASS="active";let Ae=e=>e,Le,Te,Ee,Ie,Ve;class _e extends i.EventEmitter{constructor(e){super();this.presets={};this.activeId=null;this.cache=new n.Cache.MemoryCache;this.setEventNamespace("BX.Landing.UI.Field.Color.PresetCollection");this.popupId="presets-popup_"+n.Text.getRandom();this.popupTargetContainer=e.contentRoot;this.onPresetClick=this.onPresetClick.bind(this);n.Event.bind(this.getOpenButton(),"click",(()=>{this.getPopup().toggle()}));this.onPresetChangeGlobal=this.onPresetChangeGlobal.bind(this);i.EventEmitter.subscribe("BX.Landing.UI.Field.Color.PresetCollection:onChange",this.onPresetChangeGlobal)}addDefaultPresets(){this.addPreset(ve.getPrimaryColorPreset());ve.getDefaultPresets().map((e=>{this.addPreset(e)}))}addPreset(e){this.cache.delete("popupLayout");if(!Object.keys(this.presets).length||!(e.id in this.presets)){this.presets[e.id]=e}}getGlobalActiveId(){return _e.globalActiveId}getActiveId(){return this.getGlobalActiveId()||this.getDefaultPreset().getId()}getActivePreset(){return this.getPresetById(this.getActiveId())}getDefaultPreset(){return Object.keys(this.presets).length?this.getPresetById(Object.keys(this.presets)[0]):null}getPresetById(e){if(e in this.presets){return this.cache.remember(e,(()=>new ye(this.presets[e])))}else{return null}}getPresetByItemValue(e){if(e===null){return null}for(let t in this.presets){const s=this.getPresetById(t);if(s&&e instanceof P){if(s.isPresetValue(e)){return s}}else if(s&&e instanceof de){if(s.getGradientPreset().isPresetValue(e)){return s}}}return null}getLayout(){return this.cache.remember("value",(()=>n.Tag.render(Le||(Le=Ae` <div class="landing-ui-field-color-presets"> <div class="landing-ui-field-color-presets-left"> <span class="landing-ui-field-color-presets-title"> ${0} </span> </div> <div class="landing-ui-field-color-presets-right">${0}</div> </div> `),n.Loc.getMessage("LANDING_FIELD_COLOR-PRESETS_TITLE"),this.getOpenButton())))}getOpenButton(){return this.cache.remember("openButton",(()=>n.Tag.render(Te||(Te=Ae`<span class="landing-ui-field-color-presets-open"> ${0} </span>`),n.Loc.getMessage("LANDING_FIELD_COLOR-PRESETS_MORE"))))}getTitleContainer(){return this.cache.remember("titleContainer",(()=>this.getLayout().querySelector(".landing-ui-field-color-presets-left")))}getPopup(){return this.cache.remember("popup",(()=>s.PopupManager.create({id:this.popupId,className:"presets-popup",autoHide:true,bindElement:this.getOpenButton(),bindOptions:{forceTop:true,forceLeft:true},width:280,offsetLeft:-200,content:this.getPopupLayout(),closeByEsc:true,targetContainer:this.popupTargetContainer})))}getPopupLayout(){return this.cache.remember("popupLayout",(()=>{const e=n.Tag.render(Ee||(Ee=Ae`<div class="landing-ui-field-color-presets-popup"> <div class="landing-ui-field-color-presets-popup-title"> ${0} </div> <div class="landing-ui-field-color-presets-popup-inner"></div> </div>`),n.Loc.getMessage("LANDING_FIELD_COLOR-PRESETS_MORE_COLORS"));const t=e.querySelector(".landing-ui-field-color-presets-popup-inner");for(const e in this.presets){const s=this.getPresetLayout(e);if(e===this.getActiveId()){n.Dom.addClass(s,_e.ACTIVE_CLASS);this.activeId=e}n.Event.bind(s,"click",this.onPresetClick);n.Dom.append(s,t)}return e}))}getPresetLayout(e){return this.cache.remember(e+"layout",(()=>n.Tag.render(Ie||(Ie=Ae` <div class="landing-ui-field-color-presets-preset" data-id="${0}"> ${0} </div> `),e,this.presets[e].items.map((e=>n.Tag.render(Ve||(Ve=Ae`<div class="landing-ui-field-color-presets-preset-item" style="background: ${0}" ></div>`),n.Type.isString(e)?e:e.getStyleString()))))))}onPresetClick(e){this.getPopup().close();this.setActiveItem(e.currentTarget.dataset.id);this.emit("onChange",{presetId:this.getActiveId()})}onPresetChangeGlobal(e){if(e.getData().presetId!==this.activeId){this.setActiveItem(e.getData().presetId);this.emit("onChange",e)}}setActiveItem(e){if(e!==null&&e!==this.activeId){_e.globalActiveId=e;this.activeId=e;for(const t in this.presets){n.Dom.removeClass(this.getPresetLayout(t),_e.ACTIVE_CLASS);if(t===e){n.Dom.addClass(this.getPresetLayout(t),_e.ACTIVE_CLASS)}}}}unsetActive(){for(const e in this.presets){n.Dom.removeClass(this.getPresetLayout(e),_e.ACTIVE_CLASS)}}}_e.globalActiveId=null;_e.ACTIVE_CLASS="active";let Se=e=>e,Pe;class we extends i.EventEmitter{constructor(e){super();this.cache=new n.Cache.MemoryCache;this.setEventNamespace("BX.Landing.UI.Field.Color.Reset");n.Event.bind(this.getLayout(),"click",(()=>this.onClick()));const t=BX.UI.Hint.createInstance({popupParameters:{targetContainer:e.contentRoot,padding:0}});t.init(this.getLayout())}getLayout(){return this.cache.remember("layout",(()=>n.Tag.render(Pe||(Pe=Se` <div class="landing-ui-field-color-reset-container"> <div class="landing-ui-field-color-reset" data-hint="${0}" data-hint-no-icon > </div> </div> `),n.Loc.getMessage("LANDING_FIELD_COLOR-RESET_HINT_2"))))}onClick(){this.emit("onReset")}}let Ne=e=>e,Oe,Re;class ke extends D{constructor(e){super();this.setEventNamespace("BX.Landing.UI.Field.Color.ColorSet");this.reset=new we(e);this.reset.subscribe("onReset",(()=>{this.emit("onReset")}));this.blackAndWhitePreset=new ye(ve.getBlackAndWhitePreset());this.blackAndWhitePreset.subscribe("onChange",(e=>{this.preset.unsetActive();this.onPresetItemChange(e)}));this.colorpicker=new se(e);this.colorpicker.subscribe("onChange",(e=>{this.preset.unsetActive();this.blackAndWhitePreset.unsetActive();const t=e.getData().color;if(this.preset.isPresetValue(t)){this.preset.setActiveValue(t);this.colorpicker.unsetActive()}else if(this.blackAndWhitePreset.isPresetValue(t)){this.blackAndWhitePreset.setActiveValue(t);this.colorpicker.unsetActive()}this.onChange(e)}));this.presets=new _e(e);this.presets.subscribe("onChange",(e=>{this.setPreset(this.presets.getPresetById(e.getData().presetId))}));this.presets.addDefaultPresets();const t=this.presets.getActivePreset();if(t){this.setPreset(t)}}buildLayout(){n.Dom.append(this.reset.getLayout(),this.presets.getTitleContainer());return n.Tag.render(Oe||(Oe=Ne` <div class="landing-ui-field-color-colorset"> <div class="landing-ui-field-color-colorset-top"> ${0} </div> ${0} <div class="landing-ui-field-color-colorset-bottom"> ${0} ${0} </div> </div> `),this.presets.getLayout(),this.getPresetContainer(),this.blackAndWhitePreset.getLayout(),this.colorpicker.getLayout())}getTitleLayout(){return this.cache.remember("titleLayout",(()=>this.getLayout().querySelector(".landing-ui-field-color-colorset-title")))}getPresetContainer(){return this.cache.remember("presetContainer",(()=>n.Tag.render(Re||(Re=Ne`<div class="landing-ui-field-color-colorset-preset-container"></div>`))))}setPreset(e){this.preset=e;this.preset.unsetActive();if(this.getValue()!==null&&this.preset.isPresetValue(this.getValue())){this.unsetActive();this.preset.setActiveValue(this.getValue())}else{this.unsetActive();this.colorpicker.setValue(this.getValue())}this.preset.subscribe("onChange",(e=>{this.blackAndWhitePreset.unsetActive();this.onPresetItemChange(e)}));n.Dom.clean(this.getPresetContainer());n.Dom.append(e.getLayout(),this.getPresetContainer());this.emit("onPresetChange",{preset:e})}getPreset(){return this.preset}getPresetsCollection(){return this.presets}onPresetItemChange(e){this.colorpicker.setValue(e.getData().color);this.colorpicker.unsetActive();this.onChange(e)}onChange(e){this.cache.set("value",e.getData().color);this.emit("onChange",e)}getValue(){return this.cache.remember("value",(()=>this.colorpicker.getValue()))}setValue(e){if(this.isNeedSetValue(e)){super.setValue(e);this.colorpicker.setValue(e);const t=this.presets.getGlobalActiveId()?this.presets.getPresetById(this.presets.getGlobalActiveId()):this.presets.getPresetByItemValue(e);if(t!==null){this.setPreset(t);this.presets.setActiveItem(t.getId())}if(e!==null&&this.blackAndWhitePreset.isPresetValue(e)){this.unsetActive();this.blackAndWhitePreset.setActiveValue(e)}}}unsetActive(){this.preset.unsetActive();this.blackAndWhitePreset.unsetActive();this.colorpicker.unsetActive()}isActive(){return this.preset.isActive()||this.blackAndWhitePreset.isActive()||this.colorpicker.isActive()}}let De=e=>e,Be,xe,Fe;class He extends D{constructor(e){super();this.setEventNamespace("BX.Landing.UI.Field.Color.Opacity");this.defaultOpacity=n.Type.isObject(e)&&Reflect.has(e,"defaultOpacity")?e.defaultOpacity:He.DEFAULT_OPACITY;this.document=r.PageObject.getRootWindow().document;this.onPickerDragStart=this.onPickerDragStart.bind(this);this.onPickerDragMove=this.onPickerDragMove.bind(this);this.onPickerDragEnd=this.onPickerDragEnd.bind(this);this.layout=this.getLayout();this.pickerControl=this.layout.querySelector(".landing-ui-field-color-opacity");this.rangeControl=this.layout.querySelector(".landing-ui-field-color-opacity-range-output");this.arrowsUp=this.rangeControl.querySelector(".landing-ui-field-color-opacity-range-output-arrows-up");this.arrowsDown=this.rangeControl.querySelector(".landing-ui-field-color-opacity-range-output-arrows-down");this.rangeInput=this.rangeControl.querySelector(".landing-ui-field-color-opacity-range-output-input");n.Event.bind(this.arrowsUp,"click",this.onArrowClick.bind(this,"up"));n.Event.bind(this.arrowsDown,"click",this.onArrowClick.bind(this,"down"));n.Event.bind(this.pickerControl,"mousedown",this.onPickerDragStart)}buildLayout(){const e=this.defaultOpacity*100;const t=n.Tag.render(Be||(Be=De` <div class="landing-ui-field-color-opacity-container"> <div class="landing-ui-field-color-opacity"> ${0} ${0} </div> <div class="landing-ui-field-color-opacity-range-output"> <div class="landing-ui-field-color-opacity-range-output-input" title="${0}"> ${0} </div> <div class="landing-ui-field-color-opacity-range-output-arrows"> <div class="landing-ui-field-color-opacity-range-output-arrows-up"></div> <div class="landing-ui-field-color-opacity-range-output-arrows-down"></div> </div> </div> </div> `),this.getPicker(),this.getColorLayout(),e,e);this.setPickerPosByOpacity(this.defaultOpacity);return t}onPickerDragStart(e){if(e.ctrlKey||e.metaKey||e.button){return}n.Event.bind(this.document,"mousemove",this.onPickerDragMove);n.Event.bind(this.document,"mouseup",this.onPickerDragEnd);n.Dom.addClass(this.document.body,"landing-ui-field-color-draggable");this.onPickerDragMove(e)}onPickerDragMove(e){if(e.target===this.getPicker()){return}this.setPickerPos(e.pageX);this.onChange();this.onRangeControlChange()}onPickerDragEnd(){n.Event.unbind(this.document,"mousemove",this.onPickerDragMove);n.Event.unbind(this.document,"mouseup",this.onPickerDragEnd);n.Dom.removeClass(this.document.body,"landing-ui-field-color-draggable")}setPickerPos(e){const t=Math.max(Math.min(e-this.getLayoutRect().left,this.getLayoutRect().width),0);n.Dom.style(this.getPicker(),{left:`${t}px`})}setPickerPosByOpacity(e){e=Math.min(1,Math.max(0,e));n.Dom.style(this.getPicker(),{left:`${e*100}%`})}getLayoutRect(){return this.cache.remember("layoutSize",(()=>{const e=this.pickerControl.getBoundingClientRect();return{width:e.width,left:e.left}}))}getColorLayout(){return this.cache.remember("colorLayout",(()=>n.Tag.render(xe||(xe=De` <div class="landing-ui-field-color-opacity-color"></div> `))))}getPicker(){return this.cache.remember("picker",(()=>n.Tag.render(Fe||(Fe=De` <div class="landing-ui-field-color-opacity-picker"> <div class="landing-ui-field-color-opacity-picker-item"> <div class="landing-ui-field-color-opacity-picker-item-circle"></div> </div> </div>`))))}getDefaultValue(){return this.cache.remember("default",(()=>new P(He.DEFAULT_COLOR).setOpacity(this.defaultOpacity)))}getValue(){return this.cache.remember("value",(()=>{const e=n.Text.toNumber(n.Dom.style(this.getPicker(),"left"));const t=n.Text.toNumber(this.pickerControl.getBoundingClientRect().width);return this.getDefaultValue().setOpacity(e/t)}))}setValue(e){const t=!n.Type.isNull(e)?e:this.getDefaultValue();super.setValue(t);if(!n.Type.isNull(e)){n.Dom.style(this.getColorLayout(),{background:t.getStyleStringForOpacity()});this.setPickerPosByOpacity(t.getOpacity());this.onRangeControlChange()}else{n.Dom.style(this.getColorLayout(),{background:"none"})}}onRangeControlChange(){const e=parseInt(this.getValue().getOpacity()*100);this.rangeInput.title=e;this.rangeInput.innerHTML=e}onArrowClick(e){let t;const s=this.getValue().getOpacity();const i=parseInt(s*100);if(e==="up"){if(i<100){t=(i+5)/100}else{t=i/100}}if(e==="down"){if(i>0){t=(i-5)/100}else{t=i/100}}this.rangeInput.title=parseInt(t*100);this.rangeInput.innerHTML=parseInt(t*100);const a=this.pickerControl.getBoundingClientRect().width;const r=a-a*(1-t);n.Dom.style(this.getPicker(),{left:`${r}px`});this.onChange()}}He.DEFAULT_COLOR="#cccccc";He.DEFAULT_OPACITY=1;let Me=e=>e,Ue,Ge,$e,Xe,ze,je;class Ye extends i.EventEmitter{constructor(){super();this.setEventNamespace("BX.Landing.UI.Field.Color.Tabs");this.tabs=[];this.cache=new n.Cache.MemoryCache;this.multiple=true;this.isBig=false;this.onToggle=this.onToggle.bind(this)}setMultiple(e){this.multiple=e;return this}setBig(e){this.isBig=e;this.multiple=false;return this}appendTab(e,t,s){const i=new We({id:e,title:t,items:n.Type.isArray(s)?s:[s]});this.tabs.push(i);this.bindEvents(i);this.cache.delete("layout");return this}prependTab(e,t,s){const i=new We({id:e,title:t,items:n.Type.isArray(s)||[s]});this.tabs.unshift(i);this.bindEvents(i);this.cache.delete("layout");return this}bindEvents(e){e.subscribe("onToggle",this.onToggle);e.subscribe("onShow",this.onToggle);e.subscribe("onHide",this.onToggle)}onToggle(e){this.emit("onToggle",e)}showTab(e){if(!this.multiple){this.tabs.forEach((e=>{e.hide()}))}const t=this.getTabById(e);if(t){t.show()}return this}getTabById(e){return this.tabs.find((t=>t.id===e))}getLayout(){return this.cache.remember("layout",(()=>{const e=this.isBig?" landing-ui-field-color-tabs--big":"";const t=n.Tag.render(Ue||(Ue=Me`<div class="landing-ui-field-color-tabs${0}"></div>`),e);if(this.isBig){const e=n.Tag.render(Ge||(Ge=Me` <div class="landing-ui-field-color-tabs-head landing-ui-field-color-tabs-head--big"></div> `));const s=n.Tag.render($e||($e=Me` <div class="landing-ui-field-color-tabs-content landing-ui-field-color-tabs-content--big"></div> `));this.tabs.forEach((t=>{n.Dom.append(t.getTitle(),e);n.Dom.append(t.getLayout(),s)}));n.Dom.append(e,t);n.Dom.append(s,t)}else{this.tabs.forEach((e=>{const s=n.Tag.render(Xe||(Xe=Me`<div class="landing-ui-field-color-tabs-tab"> ${0}${0} </div>`),e.getTitle(),e.getLayout());n.Dom.append(s,t)}))}this.tabs.forEach((e=>{n.Event.bind(e.getTitle(),"click",(()=>{if(!this.multiple){this.tabs.forEach((e=>{e.hide()}))}e.toggle()}))}));return t}))}}class We extends i.EventEmitter{constructor(e){super();this.id=e.id;this.title=e.title;this.items=e.items;this.cache=new n.Cache.MemoryCache}getId(){return this.id}getTitle(){return this.cache.remember("title",(()=>n.Tag.render(ze||(ze=Me` <span class="landing-ui-field-color-tabs-tab-toggler"> <span class="landing-ui-field-color-tabs-tab-toggler-icon"></span> <span class="landing-ui-field-color-tabs-tab-toggler-name">${0}</span> </span> `),this.title)))}getLayout(){return this.cache.remember("layout",(()=>n.Tag.render(je||(je=Me` <div class="landing-ui-field-color-tabs-tab-content"> ${0} </div> `),this.items.map((e=>e.getLayout())))))}toggle(){n.Dom.toggleClass(this.getLayout(),We.SHOW_CLASS);n.Dom.toggleClass(this.getTitle(),We.SHOW_CLASS);this.emit("onToggle",{tab:this.title});return this}show(){n.Dom.addClass(this.getLayout(),We.SHOW_CLASS);n.Dom.addClass(this.getTitle(),We.SHOW_CLASS);this.emit("onShow",{tab:this.title});return this}hide(){n.Dom.removeClass(this.getLayout(),We.SHOW_CLASS);n.Dom.removeClass(this.getTitle(),We.SHOW_CLASS);this.emit("onHide",{tab:this.title});return this}}We.SHOW_CLASS="show";let Ze=e=>e,qe;class Ke extends i.EventEmitter{constructor(){super();this.cache=new n.Cache.MemoryCache;this.setEventNamespace("BX.Landing.UI.Field.Color.Zeroing");n.Event.bind(this.getLayout(),"click",(()=>this.onClick()))}getLayout(){return this.cache.remember("layout",(()=>n.Tag.render(qe||(qe=Ze`<div class="landing-ui-field-color-zeroing"> <div class="landing-ui-field-color-zeroing-preview"> <div class="landing-ui-field-color-zeroing-state"></div> </div> <span class="landing-ui-field-color-primary-text"> ${0} </span> </div>`),n.Loc.getMessage("LANDING_FIELD_COLOR-ZEROING_TITLE_2"))))}onClick(){this.emit("onChange",{color:null})}setActive(){n.Dom.addClass(this.getLayout(),Ke.ACTIVE_CLASS)}unsetActive(){n.Dom.removeClass(this.getLayout(),Ke.ACTIVE_CLASS)}}Ke.ACTIVE_CLASS="active";let Je=e=>e,Qe;class et extends O{constructor(e){super(e);this.setEventNamespace("BX.Landing.UI.Field.Processor.Color");this.property="color";this.variableName="--color";this.className="g-color";this.colorSet=new ke(e);this.colorSet.subscribe("onChange",this.onColorSetChange.bind(this));this.colorSet.subscribe("onReset",this.onReset.bind(this));this.opacity=new He;this.opacity.subscribe("onChange",this.onOpacityChange.bind(this));this.zeroing=new Ke;this.zeroing.subscribe("onChange",this.onZeroingChange.bind(this));this.primary=new re;this.primary.subscribe("onChange",this.onPrimaryChange.bind(this));this.tabs=(new Ye).appendTab("Opacity",n.Loc.getMessage("LANDING_FIELD_COLOR-TAB_OPACITY"),this.opacity)}isNullValue(e){return e===null||e==="none"||e==="rgba(0, 0, 0, 0)"}getNullValue(){return new P("rgba(0, 0, 0, 0)")}buildLayout(){return n.Tag.render(Qe||(Qe=Je` <div class="landing-ui-field-color-color"> ${0} ${0} ${0} ${0} </div> `),this.colorSet.getLayout(),this.primary.getLayout(),this.zeroing.getLayout(),this.tabs.getLayout())}onColorSetChange(e){this.primary.unsetActive();this.zeroing.unsetActive();const t=e.getData().color;if(t!==null){t.setOpacity(this.opacity.getValue().getOpacity())}this.opacity.setValue(t);this.onChange()}onOpacityChange(){this.onChange()}onPrimaryChange(e){this.colorSet.setValue(e.getData().color);this.onColorSetChange(e);this.colorSet.unsetActive();this.zeroing.unsetActive();this.primary.setActive()}onZeroingChange(e){this.colorSet.unsetActive();this.primary.unsetActive();this.zeroing.setActive();this.setValue(e.getData().color);this.onChange(e)}unsetActive(){this.colorSet.unsetActive();this.primary.unsetActive()}setValue(e){const t=e!==null?new P(e):null;this.colorSet.setValue(t);this.opacity.setValue(t);if(this.primary.isPrimaryValue(t)){this.primary.setActive();this.colorSet.unsetActive()}if(e!==null&&t.getOpacity()<1){this.tabs.showTab("Opacity")}}getValue(){return this.cache.remember("value",(()=>{const e=this.primary.isActive()?this.primary.getValue():this.colorSet.getValue();return e===null?null:e.setOpacity(this.opacity.getValue().getOpacity())}))}setDefaultValue(e){this.zeroing.setActive();if(!n.Type.isNull(e)){this.colorSet.colorpicker.hex.setActive()}super.setDefaultValue(e)}onReset(){this.zeroing.unsetActive();super.onReset()}setActiveControl(e){if(e==="primary"){this.primary.setActive()}if(e==="hex"){this.colorSet.colorpicker.hexPreview.setActive()}}defineActiveControl(e,t){if(!n.Type.isUndefined(t)){let s;let i;if(t.hasOwnProperty("currentTarget")){e.forEach((e=>{if(n.Dom.hasClass(t.currentTarget,e.value)){s=e.value}}));if(s){const e=/g-[a-z]+-[a-z0-9-]+/i;const t=s.match(e);if(t){const e=/primary/i;const t=s.match(e);this.zeroing.unsetActive();if(t){i="primary"}else{i="hex"}}}if(i){this.setActiveControl(i)}}}}}et.PRIMARY_VAR="var(--primary)";class tt extends et{constructor(e){super(e);this.setEventNamespace("BX.Landing.UI.Field.Processor.ColorHover");this.property="color";this.variableName="--color-hover";this.className="g-color--hover";this.pseudoClass=":hover"}}let st=e=>e,it,at,rt,nt,ot,lt,ct;class ht extends D{constructor(e){super();this.ROTATE_STEP=45;this.setEventNamespace("BX.Landing.UI.Field.Color.Gradient");this.popupId="gradient_popup_"+n.Text.getRandom();this.popupTargetContainer=e.contentRoot;this.colorpickerFrom=new se(e);this.colorpickerFrom.subscribe("onChange",(e=>{this.onColorChange(e.getData().color,null)}));this.colorpickerTo=new se(e);this.colorpickerTo.subscribe("onChange",(e=>{this.onColorChange(null,e.getData().color)}));n.Event.bind(this.getPopupButton(),"click",this.onPopupOpen.bind(this));n.Event.bind(this.getRotateButton(),"click",this.onRotate.bind(this));n.Event.bind(this.getSwitchTypeButton(),"click",this.onSwitchType.bind(this));n.Event.bind(this.getSwapButton(),"click",this.onSwap.bind(this));this.preset=null}onColorChange(e,t){if(e===null&&t===null){return}const s=this.getValue()||new de;const i=e||s.getFrom()||(new de).getFrom();const a=t||s.getTo()||(new de).getTo();s.setValue({from:i,to:a});this.setValue(s);this.preset.unsetActive();this.onChange()}onPopupOpen(){this.getPopup().toggle()}onRotate(e){if(!ht.isButtonEnable(e.target)){return}const t=this.getValue();if(t!==null){t.setValue({angle:(t.getAngle()+this.ROTATE_STEP)%360});this.setValue(t);this.onChange()}this.getPopup().close()}onSwitchType(e){if(!ht.isButtonEnable(e.target)){return}const t=this.getValue();if(t!==null){if(t.getType()===de.TYPE_LINEAR){t.setValue({type:de.TYPE_RADIAL});ht.disableButton(this.getRotateButton())}else{t.setValue({type:de.TYPE_LINEAR});ht.enableButton(this.getRotateButton())}this.setValue(t);this.onChange()}this.getPopup().close()}onSwap(e){if(!ht.isButtonEnable(e.target)){return}const t=this.getValue();if(t!==null){t.setValue({to:t.getFrom(),from:t.getTo()});this.setValue(t);this.onChange()}this.getPopup().close()}static disableButton(e){n.Dom.addClass(e,ht.DISABLE_CLASS)}static enableButton(e){n.Dom.removeClass(e,ht.DISABLE_CLASS)}static isButtonEnable(e){return!n.Dom.hasClass(e,ht.DISABLE_CLASS)}correctColorpickerColors(){const e=this.getValue();if(e!==null){const t=e.getAngle();const s=this.colorpickerFrom.getHexPreviewObject();const i=this.colorpickerTo.getHexPreviewObject();const a=e.getFrom();const r=e.getTo();if(e.getType()===de.TYPE_LINEAR){if(t===270||t===90){const e=P.getMedian(a,r).getContrast().getHex();s.adjustColors(e,"transparent");i.adjustColors(e,"transparent")}else if(t>=135&&t<=225){s.adjustColors(a.getContrast().getHex(),"transparent");i.adjustColors(r.getContrast().getHex(),"transparent")}else{s.adjustColors(r.getContrast().getHex(),"transparent");i.adjustColors(a.getContrast().getHex(),"transparent")}}else if(e.getType()===de.TYPE_RADIAL){s.adjustColors(r.getContrast().getHex(),"transparent");i.adjustColors(r.getContrast().getHex(),"transparent")}}}getPopup(){return this.cache.remember("popup",(()=>s.PopupManager.create({id:this.popupId,className:"landing-ui-field-color-gradient-preset-popup",autoHide:true,bindElement:this.getPopupButton(),bindOptions:{forceTop:true,forceLeft:true},offsetLeft:15,angle:{offset:-5},padding:0,contentPadding:7,content:this.getPopupContent(),closeByEsc:true,targetContainer:this.popupTargetContainer})))}getPopupContent(){return this.cache.remember("popupContainer",(()=>n.Tag.render(it||(it=st` <div class="landing-ui-field-color-gradient-preset-popup-container"> ${0} ${0} </div> `),this.getRotateButton(),this.getSwapButton())))}buildLayout(){if(this.preset){n.Dom.clean(this.getPresetContainer());n.Dom.append(this.preset.getLayout(),this.getPresetContainer())}return n.Tag.render(at||(at=st` <div class="landing-ui-field-color-gradient"> ${0} <div class="landing-ui-field-color-gradient-container"> <div class="landing-ui-field-color-gradient-from">${0}</div> ${0} <div class="landing-ui-field-color-gradient-to">${0}</div> </div> <div class="landing-ui-field-color-gradient-switch-type-container"> ${0} </div> </div> `),this.getPresetContainer(),this.colorpickerFrom.getLayout(),this.getPopupButton(),this.colorpickerTo.getLayout(),this.getSwitchTypeButton())}getContainerLayout(){return this.getLayout().querySelector(".landing-ui-field-color-gradient-container")}getPresetContainer(){return this.cache.remember("presetContainer",(()=>n.Tag.render(rt||(rt=st`<div class="landing-ui-field-color-gradient-preset-container"></div>`))))}getPopupButton(){return this.cache.remember("popupButton",(()=>n.Tag.render(nt||(nt=st`<span class="landing-ui-field-color-gradient-open-popup"></span>`))))}getSwitchTypeButton(){return this.cache.remember("switchTypeButton",(()=>n.Tag.render(ot||(ot=st` <span class="landing-ui-field-color-gradient-switch-type" title="${0}" ></span>`),n.Loc.getMessage("LANDING_FIELD_COLOR-GRADIENT_SWITCH_TYPE"))))}getRotateButton(){return this.cache.remember("rotateButton",(()=>n.Tag.render(lt||(lt=st` <span class="landing-ui-field-color-gradient-rotate" title="${0}" ></span>`),n.Loc.getMessage("LANDING_FIELD_COLOR-GRADIENT_ROTATE"))))}getSwapButton(){return this.cache.remember("swapButton",(()=>n.Tag.render(ct||(ct=st` <span class="landing-ui-field-color-gradient-swap" title="${0}" ></span>`),n.Loc.getMessage("LANDING_FIELD_COLOR-GRADIENT_SWAP"))))}setPreset(e){this.preset=e;this.preset.unsetActive();this.preset.subscribe("onChange",(e=>{this.setValue(e.getData().color);this.unsetColorpickerActive();this.onChange(e)}));n.Dom.clean(this.getPresetContainer());n.Dom.append(e.getLayout(),this.getPresetContainer())}getPreset(){return this.preset}getValue(){return this.cache.remember("value",(()=>{if(this.colorpickerFrom.getValue()===null||this.colorpickerTo.getValue()===null){return null}let e=this.getRotateButton().dataset.rotate;e=e?n.Text.toNumber(e):0;const t=this.getSwitchTypeButton().dataset.type||de.TYPE_LINEAR;return new de({from:this.colorpickerFrom.getValue(),to:this.colorpickerTo.getValue(),angle:e,type:t})}))}setValue(e){super.setValue(e);if(e===null){this.colorpickerFrom.setValue(null);this.colorpickerTo.setValue(null);this.unsetActive();n.Dom.style(this.getContainerLayout(),"background",(new de).getStyleString());ht.disableButton(this.getRotateButton());ht.disableButton(this.getSwitchTypeButton());ht.disableButton(this.getSwapButton())}else{this.colorpickerFrom.setValue(e.getFrom());this.colorpickerTo.setValue(e.getTo());this.correctColorpickerColors();this.getRotateButton().dataset.rotate=e.getAngle();this.getSwitchTypeButton().dataset.type=e.getType();n.Dom.style(this.getRotateButton(),"transform",`rotate(${e.getAngle()}deg)`);n.Dom.style(this.getContainerLayout(),"background",this.getValue().getStyleString());ht.enableButton(this.getSwitchTypeButton());ht.enableButton(this.getSwapButton());if(e.getType()===de.TYPE_RADIAL){ht.disableButton(this.getRotateButton());this.getSwitchTypeButton().innerText=n.Loc.getMessage("LANDING_FIELD_COLOR-GRADIENT_DO_LINEAR")}else{ht.enableButton(this.getRotateButton());this.getSwitchTypeButton().innerText=n.Loc.getMessage("LANDING_FIELD_COLOR-GRADIENT_DO_RADIAL")}this.setActive()}}onChange(e){this.cache.delete("value");this.emit("onChange",{gradient:this.getValue()})}setActive(){const e=this.getValue();if(this.preset.isPresetValue(e)){this.preset.setActiveValue(e);this.unsetColorpickerActive()}else{this.preset.unsetActive();this.setColorpickerActive()}}unsetActive(){this.preset.unsetActive();this.unsetColorpickerActive()}setColorpickerActive(){n.Dom.addClass(this.getContainerLayout(),ht.ACTIVE_CLASS)}unsetColorpickerActive(){this.colorpickerFrom.unsetActive();this.colorpickerTo.unsetActive();n.Dom.removeClass(this.getContainerLayout(),ht.ACTIVE_CLASS)}}ht.DISABLE_CLASS="disable";class ut extends et{constructor(e){super(e);this.setEventNamespace("BX.Landing.UI.Field.Processor.BgColor");this.property=["background-image","background-color"];this.variableName="--bg";this.className="g-bg";this.activeControl=null;this.gradient=new ht(e);this.gradient.subscribe("onChange",this.onGradientChange.bind(this));this.tabs.prependTab("Gradient",n.Loc.getMessage("LANDING_FIELD_COLOR-TAB_GRADIENT"),this.gradient);this.setGradientPreset(this.colorSet.getPreset());this.colorSet.subscribe("onPresetChange",(e=>{this.setGradientPreset(e.getData().preset)}));this.tabs.subscribe("onToggle",this.onTabsToggle.bind(this))}setGradientPreset(e){const t=e.getGradientPreset();this.gradient.setPreset(t);t.subscribe("onChange",(()=>{this.activeControl=this.gradient;this.onChange()}));const s=this.getValue();if(s!==null&&s instanceof de){if(this.gradient.getPreset().isPresetValue(s)){this.colorSet.getPreset().unsetActive();this.gradient.getPreset().setActiveValue(s);this.gradient.unsetColorpickerActive()}}}onColorSetChange(e){this.activeControl=this.colorSet;this.gradient.unsetActive();super.onColorSetChange(e)}onGradientChange(e){this.activeControl=this.gradient;this.colorSet.unsetActive();const t=e.getData().gradient;if(t!==null){this.opacity.setValue(t.setOpacity(this.opacity.getValue().getOpacity()))}this.onChange()}onOverlayOpacityChange(){this.onChange()}onTabsToggle(){this.gradient.getPopup().close()}unsetActive(){this.colorSet.unsetActive();this.gradient.unsetActive();this.primary.unsetActive()}setValue(e){this.colorSet.setValue(null);this.gradient.setValue(null);this.unsetActive();this.activeControl=null;if(n.Type.isNull(e));else if(l(e)||h(e)||g(e)||L(e)){super.setValue(e);this.activeControl=this.colorSet}else if(ge(e)){this.activeControl=this.gradient;const t=new de(e);this.gradient.setValue(t);this.opacity.setValue(t);const s=this.colorSet.getPresetsCollection();const i=s.getGlobalActiveId()?s.getPresetById(s.getGlobalActiveId()):s.getPresetByItemValue(t);if(i!==null&&i!==this.colorSet.getPreset()){this.colorSet.setPreset(i);this.setGradientPreset(i)}this.tabs.showTab("Gradient");if(t.getOpacity()<1){this.tabs.showTab("Opacity")}}}getValue(){return this.cache.remember("value",(()=>{if(this.activeControl===null){return null}else if(this.activeControl===this.gradient){const e=this.gradient.getValue();return e===null?e:e.setOpacity(this.opacity.getValue().getOpacity())}else{return super.getValue()}}))}}const gt=/url\(['"]?([^ '"]*)['"]?\)([\w \/]*)/i;function dt(e){if(!!e.trim().match(gt)){return true}return!!e.trim().match(pt())}function pt(){const e=oe(gt);const t=oe(le);return new RegExp(`^${t},${e}`)}class mt{constructor(e){this.value=S;this.setValue(e)}getName(){return`\n\t\t\t${this.value.url.replace(/[^\w\d]/g,"")}_${this.value.size}_${this.value.attachment}\n\t\t`}setValue(e){if(n.Type.isObject(e)){if(e instanceof mt){this.value.url=e.getUrl();this.value.url2x=e.getUrl2x();this.value.fileId=e.getFileId();this.value.fileId2x=e.getFileId2x();this.value.size=e.getSize();this.value.attachment=e.getAttachment()}else{this.value={...this.value,...e}}}if(n.Type.isString(e)&&dt(e)){this.parseBgString(e)}return this}parseBgString(e){const t=S;const s=e.trim().match(ne(gt));if(!!s){t.url=s[1];t.size=s[2].indexOf("auto")===-1?I:"auto";t.attachment=s[2].indexOf("fixed")===-1?V:"fixed"}const i=e.trim().match(ne(ue));if(!!e.trim().match(ne(le))&&!!i){t.overlay=new P(i[0])}this.setValue(t)}setOpacity(e){return this}setUrl(e){this.setValue({url:e});return this}setUrl2x(e){this.setValue({url2x:e});return this}setFileId(e){this.setValue({fileId:e});return this}setFileId2x(e){this.setValue({fileId2x:e});return this}setSize(e){this.setValue({size:e});return this}setAttachment(e){this.setValue({attachment:e});return this}setOverlay(e){this.setValue({overlay:e});return this}getUrl(){return this.value.url}getUrl2x(){return this.value.url2x}getFileId(){return this.value.fileId}getFileId2x(){return this.value.fileId2x}getSize(){return this.value.size}getAttachment(e=false){return e?this.value.attachment==="fixed":this.value.attachment}getOverlay(){return this.value.overlay}getOpacity(){return 1}getStyleString(){let e="";if(this.value.overlay!==null){e=`linear-gradient(${this.value.overlay.getStyleString()},${this.value.overlay.getStyleString()})`}const{url:t,url2x:s,size:i,attachment:a}=this.value;const r=`center / ${i} ${a}`;if(t!==null){e=e.length?e+",":"";if(s!==null){e+=`-webkit-image-set(url('${t}') 1x, url('${s}') 2x) ${r},`;e+=`image-set(url('${t}') 1x, url('${s}') 2x) ${r},`}e+=`url('${t}') ${r}`}return e}getStyleStringForOpacity(){return""}static getSizeItemsForButtons(){return[{name:n.Loc.getMessage("LANDING_FIELD_COLOR-BG_COVER"),value:"cover"},{name:n.Loc.getMessage("LANDING_FIELD_COLOR-BG_MOSAIC"),value:"auto"}]}static getAttachmentValueByBool(e){return e?"fixed":"scroll"}}let vt=e=>e,ft;class bt extends D{constructor(e){super();this.setEventNamespace("BX.Landing.UI.Field.Color.Image");this.options=e;const t=r.PageObject.getRootWindow();this.imgField=new t.BX.Landing.UI.Field.Image({id:"landing_ui_color_image_"+n.Text.getRandom().toLowerCase(),className:"landing-ui-field-color-image-image",compactMode:true,disableLink:true,disableAltField:true,allowClear:true,dimensions:{width:1920},uploadParams:{action:"Block::uploadFile",block:this.options.block.id},contentRoot:this.options.contentRoot});this.imgField.subscribe("change",this.onImageChange.bind(this));this.sizeField=new BX.Landing.UI.Field.Dropdown({id:"landing_ui_color_image_size_"+n.Text.getRandom().toLowerCase(),title:n.Loc.getMessage("LANDING_FIELD_COLOR-BG_SIZE_TITLE"),className:"landing-ui-field-color-image-size",items:mt.getSizeItemsForButtons(),onChange:this.onSizeChange.bind(this),contentRoot:this.options.contentRoot});this.attachmentField=new BX.Landing.UI.Field.Checkbox({id:"landing_ui_color_image_attach_"+n.Text.getRandom().toLowerCase(),className:"landing-ui-field-color-image-attachment",multiple:false,compact:true,items:[{name:n.Loc.getMessage("LANDING_FIELD_COLOR-BG_FIXED"),value:true}],onChange:this.onAttachmentChange.bind(this)})}buildLayout(){return n.Tag.render(ft||(ft=vt` <div class="landing-ui-field-color-image"> ${0} ${0} ${0} </div> `),this.imgField.getLayout(),this.sizeField.getLayout(),this.attachmentField.getLayout())}onImageChange(e){const t=this.getValue()||new mt;if(e.getData().value.src){t.setUrl(e.getData().value.src);t.setFileId(e.getData().value.id);if(e.getData().value.src2x){t.setUrl2x(e.getData().value.src2x);t.setFileId2x(e.getData().value.id2x)}}else{t.setUrl(null);t.setFileId(null);t.setUrl2x(null);t.setFileId2x(null)}this.setValue(t);this.onChange();this.saveNode(t)}saveNode(e){const t=this.options.styleNode;const s=this.options.block;let i;if(t.selector===s.selector||t.selector===s.makeAbsoluteSelector(s.selector)){i="#wrapper"}else if(!t.isSelectGroup()){i=BX.Landing.Utils.join(t.selector.split("@")[0],"@",t.getElementIndex(t.getNode()[0]))}else{i=t.selector.split("@")[0]}const r={[i]:{}};r[i].id=e.getFileId()||-1;r[i].id2x=e.getFileId2x()||-1;a.Backend.getInstance().action("Landing\\Block::updateNodes",{block:this.options.block.id,data:r})}onSizeChange(e){if(n.Type.isString(e)){const t=this.getValue()||new mt;t.setSize(e);this.setValue(t);this.onChange()}}onAttachmentChange(e){if(e instanceof i.BaseEvent){const e=this.getValue()||new mt;e.setAttachment(mt.getAttachmentValueByBool(this.attachmentField.getValue()));this.setValue(e);this.onChange()}}onChange(e){this.cache.delete("value");this.emit("onChange",{data:{image:this.getValue()}})}getValue(){return this.cache.remember("value",(()=>{const e=this.imgField.getValue();const t=e.src;if(t===null){return null}else{const s=new mt({url:t,fileId:e.id});if(e.src2x){s.setUrl2x(e.src2x);s.setFileId2x(e.fileId2x)}const i=this.sizeField.getValue();if(i!==null){s.setSize(i)}s.setAttachment(mt.getAttachmentValueByBool(this.attachmentField.getValue()));return s}}))}setValue(e){if(this.isNeedSetValue(e)){super.setValue(e);if(e===null){this.imgField.setValue({src:""},true)}else{if(e.getUrl()!==null){this.setActive()}const t={type:"image",src:e.getUrl(),id:e.getFileId()};if(e.getUrl2x()){t.src2x=e.getUrl2x();t.id2x=e.getFileId2x()}this.imgField.setValue(t,true);this.sizeField.setValue(e.getSize(),true);this.attachmentField.setValue([e.getAttachment(true)])}}}setActive(){n.Dom.addClass(this.imgField.getLayout(),bt.ACTIVE_CLASS)}unsetActive(){n.Dom.removeClass(this.imgField.getLayout(),bt.ACTIVE_CLASS)}}let Ct=e=>e,yt;class At extends ut{constructor(e){super(e);this.setEventNamespace("BX.Landing.UI.Field.Processor.Bg");this.parentVariableName=this.variableName;this.variableName=[this.parentVariableName,At.BG_URL_VAR,At.BG_URL_2X_VAR,At.BG_OVERLAY_VAR,At.BG_SIZE_VAR,At.BG_ATTACHMENT_VAR];this.parentClassName=this.className;this.className="g-bg-image";this.image=new bt(e);this.image.subscribe("onChange",this.onImageChange.bind(this));this.overlay=new ke(e);this.overlay.subscribe("onChange",this.onOverlayChange.bind(this));this.overlayOpacity=new He({defaultOpacity:.5});this.overlayOpacity.subscribe("onChange",this.onOverlayOpacityChange.bind(this));this.imageTabs=(new Ye).appendTab("Overlay",n.Loc.getMessage("LANDING_FIELD_COLOR-BG_OVERLAY"),[this.overlay,this.overlayOpacity]);this.bigTabs=(new Ye).setBig(true).appendTab("Color",n.Loc.getMessage("LANDING_FIELD_COLOR-BG_COLOR"),[this.colorSet,this.primary,this.zeroing,this.tabs]).appendTab("Image",n.Loc.getMessage("LANDING_FIELD_COLOR-BG_IMAGE"),[this.image,this.imageTabs])}buildLayout(){return n.Tag.render(yt||(yt=Ct` <div class="landing-ui-field-color-color"> ${0} </div> `),this.bigTabs.getLayout())}onColorSetChange(e){this.image.unsetActive();this.overlay.unsetActive();super.onColorSetChange(e)}onGradientChange(e){this.image.unsetActive();this.overlay.unsetActive();super.onGradientChange(e)}onImageChange(){this.unsetActive();this.activeControl=this.image;this.image.setActive();this.onChange()}onOverlayChange(e){const t=e.getData().color;if(t!==null){t.setOpacity(this.overlayOpacity.getValue().getOpacity())}this.overlayOpacity.setValue(t);const s=this.image.getValue();if(s!==null){this.image.setValue(s.setOverlay(t));this.activeControl=this.image;this.image.setActive();this.colorSet.unsetActive();this.gradient.unsetActive()}this.onChange()}onOverlayOpacityChange(){this.onChange()}unsetActive(){super.unsetActive();this.image.unsetActive()}setProcessorValue(e){this.cache.delete("value");this.setValue(e)}setValue(e){this.image.setValue(null);this.bigTabs.showTab("Color");if(n.Type.isNull(e)){super.setValue(e)}else if(n.Type.isString(e)){super.setValue(e)}else if(this.parentVariableName in e&&n.Type.isString(e[this.parentVariableName])){super.setValue(e[this.parentVariableName])}else if(n.Type.isObject(e)){const t=new mt;if(At.BG_URL_VAR in e){t.setUrl(e[At.BG_URL_VAR].replace(/url\(["']/i,"").replace(/['"]\)/i,""))}if(At.BG_URL_2X_VAR in e){t.setUrl2x(e[At.BG_URL_2X_VAR].replace(/url\(["']/i,"").replace(/['"]\)/i,""))}if(At.BG_SIZE_VAR in e){t.setSize(e[At.BG_SIZE_VAR])}if(At.BG_ATTACHMENT_VAR in e){t.setAttachment(e[At.BG_ATTACHMENT_VAR])}if(At.BG_OVERLAY_VAR in e){t.setOverlay(new P(e[At.BG_OVERLAY_VAR]))}this.image.setValue(t);this.bigTabs.showTab("Image");this.activeControl=this.image;if(At.BG_OVERLAY_VAR in e){const t=new P(e[At.BG_OVERLAY_VAR]);this.overlay.setValue(t);this.overlayOpacity.setValue(t);this.imageTabs.showTab("Overlay")}}}getValue(){return this.cache.remember("value",(()=>{if(this.activeControl===this.image){const e=this.image.getValue();const t=this.overlay.getValue();if(e!==null&&this.overlay.isActive()&&t!==null){t.setOpacity(this.overlayOpacity.getValue().getOpacity());e.setOverlay(t)}return e}else{return super.getValue()}}))}getClassName(){const e=this.getValue();if(e===null||e instanceof P||e instanceof de){return[this.parentClassName]}return[this.className]}getStyle(){if(this.getValue()===null){return{[this.parentVariableName]:null,[At.BG_URL_VAR]:null,[At.BG_URL_2X_VAR]:null,[At.BG_OVERLAY_VAR]:null,[At.BG_SIZE_VAR]:null,[At.BG_ATTACHMENT_VAR]:null}}const e=this.getValue();let t=null;let s=null;let i=null;let a=null;let r=null;let n=null;if(e instanceof P||e instanceof de){t=e.getStyleString()}else{s=e.getUrl()?`url('${e.getUrl()}')`:"";i=e.getUrl2x()?`url('${e.getUrl2x()}')`:"";a=e.getOverlay()?e.getOverlay().getStyleString():"rgba(0, 0, 0, 0)";r=e.getSize();n=e.getAttachment()}return{[this.parentVariableName]:t,[At.BG_URL_VAR]:s,[At.BG_URL_2X_VAR]:i,[At.BG_OVERLAY_VAR]:a,[At.BG_SIZE_VAR]:r,[At.BG_ATTACHMENT_VAR]:n}}}At.BG_URL_VAR="--bg-url";At.BG_URL_2X_VAR="--bg-url-2x";At.BG_OVERLAY_VAR="--bg-overlay";At.BG_SIZE_VAR="--bg-size";At.BG_ATTACHMENT_VAR="--bg-attachment";class Lt extends et{constructor(e){super(e);this.setEventNamespace("BX.Landing.UI.Field.Processor.BorderColor");this.property="border-color";this.variableName="--border-color";this.className="g-border-color"}}class Tt extends et{constructor(e){super(e);this.setEventNamespace("BX.Landing.UI.Field.Processor.BorderColorHover");this.property="border-color";this.variableName="--border-color--hover";this.className="g-border-color--hover";this.pseudoClass=":hover"}}class Et extends ut{constructor(e){super(e);this.setEventNamespace("BX.Landing.UI.Field.Processor.BgColorHover");this.property=["background-image","background-color"];this.variableName="--bg-hover";this.className="g-bg--hover";this.pseudoClass=":hover"}}class It extends ut{constructor(e){super(e);this.setEventNamespace("BX.Landing.UI.Field.Processor.BgColorAfter");this.property=["background-image","background-color"];this.variableName="--bg--after";this.className="g-bg--after";this.pseudoClass=":after";const t=this.getValue()||new P;this.opacity.setValue(t.setOpacity(.5));this.tabs.showTab("Opacity")}}class Vt extends ut{constructor(e){super(e);this.setEventNamespace("BX.Landing.UI.Field.Processor.BgColorBefore");this.property=["background-image","background-color"];this.variableName="--bg--before";this.className="g-bg--before";this.pseudoClass=":before";const t=this.getValue()||new P;this.opacity.setValue(t.setOpacity(.5));this.tabs.showTab("Opacity")}}class _t extends et{constructor(e){super(e);this.setEventNamespace("BX.Landing.UI.Field.Processor.NavbarColor");this.property="color";this.variableName="--navbar-color";this.className="u-navbar-color"}}class St extends et{constructor(e){super(e);this.setEventNamespace("BX.Landing.UI.Field.Processor.NavbarColorHover");this.property="color";this.variableName="--navbar-color--hover";this.className="u-navbar-color--hover";this.pseudoClass=":hover"}}class Pt extends et{constructor(e){super(e);this.setEventNamespace("BX.Landing.UI.Field.Processor.NavbarColorFixMoment");this.property="color";this.variableName="--navbar-color--fix-moment";this.className="u-navbar-color--fix-moment"}}class wt extends et{constructor(e){super(e);this.setEventNamespace("BX.Landing.UI.Field.Processor.NavbarColorFixMomentHover");this.property="color";this.variableName="--navbar-color--fix-moment--hover";this.className="u-navbar-color--fix-moment--hover";this.pseudoClass=":hover"}}class Nt extends et{constructor(e){super(e);this.setEventNamespace("BX.Landing.UI.Field.Processor.NavbarBgColor");this.property="background-color";this.variableName="--navbar-bg-color";this.className="u-navbar-bg"}}class Ot extends et{constructor(e){super(e);this.setEventNamespace("BX.Landing.UI.Field.Processor.NavbarBgColorHover");this.property="background-color";this.variableName="--navbar-bg-color--hover";this.className="u-navbar-bg--hover";this.pseudoClass=":hover"}}class Rt extends et{constructor(e){super(e);this.setEventNamespace("BX.Landing.UI.Field.Processor.BorderColorTop");this.property="border-top-color";this.variableName="--border-color-top";this.className="g-border-color-top"}}class kt extends et{constructor(e){super(e);this.setEventNamespace("BX.Landing.UI.Field.Processor.FillColor");this.property="fill";this.pseudoClass=":before";this.variableName="--fill-first";this.className="g-fill-first"}}class Dt extends et{constructor(e){super(e);this.setEventNamespace("BX.Landing.UI.Field.Processor.FillColorSecond");this.property="fill";this.pseudoClass=":after";this.variableName="--fill-second";this.className="g-fill-second"}}class Bt extends et{constructor(e){super(e);this.setEventNamespace("BX.Landing.UI.Field.Processor.ButtonColor");this.property="background-color";this.variableName=[Bt.COLOR_CONTRAST_VAR,Bt.COLOR_HOVER_VAR,Bt.COLOR_LIGHT_VAR,Bt.COLOR_VAR];this.className="g-button-color"}getStyle(){if(this.getValue()===null){return{[Bt.COLOR_CONTRAST_VAR]:null,[Bt.COLOR_HOVER_VAR]:null,[Bt.COLOR_LIGHT_VAR]:null,[Bt.COLOR_VAR]:null}}const e=this.getValue();const t=e.getContrast().lighten(10);const s=new P(e).lighten(10);const i=e.getLighten();return{[Bt.COLOR_CONTRAST_VAR]:t.getStyleString(),[Bt.COLOR_HOVER_VAR]:s.getStyleString(),[Bt.COLOR_LIGHT_VAR]:i.getStyleString(),[Bt.COLOR_VAR]:e.getStyleString()}}}Bt.COLOR_CONTRAST_VAR="--button-color-contrast";Bt.COLOR_HOVER_VAR="--button-color-hover";Bt.COLOR_LIGHT_VAR="--button-color-light";Bt.COLOR_VAR="--button-color";class xt extends et{constructor(e){super(e);this.setEventNamespace("BX.Landing.UI.Field.Processor.NavbarCollapseBgColor");this.property="background-color";this.variableName="--navbar-collapse-bg-color";this.className="u-navbar-collapse-bg"}}class Ft extends t.BaseField{constructor(e){super(e);this.items="items"in e&&e.items?e.items:[];this.postfix=typeof e.postfix==="string"?e.postfix:"";this.frame=typeof e.frame==="object"?e.frame:null;const t={block:e.block,styleNode:e.styleNode,selector:e.selector,contentRoot:this.contentRoot};this.changeHandler=typeof e.onChange==="function"?e.onChange:()=>{};this.resetHandler=typeof e.onReset==="function"?e.onReset:function(){};switch(e.subtype){case"color":this.processor=new et(t);break;case"color-hover":this.processor=new tt(t);break;case"bg":this.processor=new At(t);break;case"bg-color":this.processor=new ut(t);break;case"bg-color-hover":this.processor=new Et(t);break;case"bg-color-after":this.processor=new It(t);break;case"bg-color-before":this.processor=new Vt(t);break;case"border-color":this.processor=new Lt(t);break;case"border-color-hover":this.processor=new Tt(t);break;case"border-color-top":this.processor=new Rt(t);break;case"navbar-color":this.processor=new _t(t);break;case"navbar-color-hover":this.processor=new St(t);break;case"navbar-color-fix-moment":this.processor=new Pt(t);break;case"navbar-color-fix-moment-hover":this.processor=new wt(t);break;case"navbar-bg-color":this.processor=new Nt(t);break;case"navbar-bg-color-hover":this.processor=new Ot(t);break;case"navbar-collapse-bg-color":this.processor=new xt(t);break;case"fill-color":this.processor=new kt(t);break;case"fill-color-second":this.processor=new Dt(t);break;case"button-color":this.processor=new Bt(t);break;default:break}this.property=this.processor.getProperty()[this.processor.getProperty().length-1];this.processor.getClassName().forEach((e=>this.items.push({name:e,value:e})));n.Dom.remove(this.input);this.layout.classList.add("landing-ui-field-color");n.Dom.append(this.processor.getLayout(),this.layout);this.processor.subscribe("onChange",this.onChange.bind(this));this.processor.subscribe("onReset",this.onReset.bind(this))}getInlineProperties(){return this.processor.getVariableName()}getComputedProperties(){return this.processor.getProperty()}getPseudoElement(){return this.processor.getPseudoClass()}onChange(){this.changeHandler({className:this.processor.getClassName(),style:this.processor.getStyle()},this.items,this.postfix,this.property);this.emit("onChange")}onReset(){this.resetHandler(this.items,this.postfix,this.property)}getValue(){return this.processor.getValue()||this.processor.getNullValue()}setValue(e){let t=null;this.getInlineProperties().forEach((s=>{if(s in e&&!this.processor.isNullValue(e[s])){if(!n.Type.isObject(t)){t={}}t[s]=e[s]}}));let s=null;this.getComputedProperties().forEach((t=>{if(t in e&&!this.processor.isNullValue(e[t])){if(!n.Type.isObject(s)){s={}}s[t]=e[t]}}));if(t!==null){this.processor.setProcessorValue(t)}else{this.processor.setDefaultValue(s);this.processor.defineActiveControl(this.items,this.data.styleNode)}}onFrameLoad(){const e=this.data.styleNode.getValue(true);this.setValue(e.style)}}e.ColorField=Ft})(this.BX.Landing.UI.Field=this.BX.Landing.UI.Field||{},BX.Landing.UI.Field,BX.Main,BX.Event,BX.Landing,BX.Landing,BX); //# sourceMappingURL=color_field.bundle.map.js
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.26 |
proxy
|
phpinfo
|
Settings