@rocketspark/domain-checker
Version:
Embeddable Domain Checker for Rocketspark
13 lines • 33.4 kB
JavaScript
/*!
*
* @rocketspark/domain-checker v1.0.12
* git+https://github.com/rocketspark/domain-checker.git
*
* Copyright (c) Lee Reichardt and project contributors.
*
* This source code is licensed under the no license license found in the
* LICENSE file in the root directory of this source tree.
*
*/
"use strict";(self.webpackChunkDomainChecker=self.webpackChunkDomainChecker||[]).push([[245],{825:function(t,e,i){i.d(e,{D:function(){return f},H:function(){return m},i:function(){return g},p:function(){return u}});const{min:o,max:s,floor:r,round:n}=Math;function a(t,e,i){const o=t/360*6,s=e/100,n=i/100,a=r(o),l=o-a,h=n*(1-s),c=n*(1-l*s),p=n*(1-(1-l)*s),d=a%6;return[255*[n,c,h,h,p,n][d],255*[p,n,n,c,h,h][d],255*[h,h,p,n,n,c][d]]}function l(t,e,i){return a(t,e,i).map((t=>n(t).toString(16).padStart(2,"0")))}function h(t,e,i){let o=e/100;const s=i/100,r=(2-o)*s/2;return 0!==r&&(o=1===r?0:r<.5?o*s/(2*r):o*s/(2-2*r)),[t,100*o,100*r]}function c(t,e,i){const r=t/255,n=e/255,a=i/255,l=o(r,n,a),h=s(r,n,a),c=h-l;let p,d;if(0===c)p=0,d=0;else{d=c/h;const t=((h-r)/6+c/2)/c,e=((h-n)/6+c/2)/c,i=((h-a)/6+c/2)/c;r===h?p=i-e:n===h?p=1/3+t-i:a===h&&(p=2/3+e-t),p<0?p+=1:p>1&&(p-=1)}return[360*p,100*d,100*h]}function p(t,e,i,s){const r=e/100,n=i/100,a=s/100;return[...c(255*(1-o(1,t/100*(1-a)+a)),255*(1-o(1,r*(1-a)+a)),255*(1-o(1,n*(1-a)+a)))]}function d(t,e,i){let o=e/100;const s=i/100;o*=s<.5?s:1-s;const r=2*o/(s+o)*100,n=100*(s+o);return[t,Number.isNaN(r)?0:r,n]}function u(t="#000"){"transparent"===t.toLowerCase()&&(t="#00000000");const e=null!==t.match(/^[a-zA-Z]+$/)?function(t){if(void 0===t)return"#000";if("black"===t.toLowerCase())return"#000";const e=document.createElement("canvas").getContext("2d");return null===e?null:(e.fillStyle=t,"#000"===e.fillStyle?null:e.fillStyle)}(t):t,{type:i,match:o}=function(t){const e=Object.entries({cmyk:/^cmyk[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)/i,rgba:/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsla:/^((hsla)|hsl)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsva:/^((hsva)|hsv)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hexa:/^#?(([\dA-Fa-f]{3,4})|([\dA-Fa-f]{6})|([\dA-Fa-f]{8}))$/i}).find((([,e])=>e.exec(t)));if(void 0!==e){const i=e[1].exec(t);return{type:e[0],regex:e[1],match:i}}return{type:null}}(e),s=t=>t.map((t=>/^(|\d+)\.\d+|\d+$/.test(t)?Number(t):void 0));if(null===i||null===o)return{values:null,type:"hexa"};const r=t=>t>=0&&t<=1&&(t=>!!o[2]==("number"==typeof t))(t);if("cmyk"===i){const[,t,e,r,n]=s(o);if(t&&e&&r&&n&&t<=100&&e<=100&&r<=100&&n<=100)return{values:p(t,e,r,n),type:i}}if("rgba"===i){const[,,,t,e,n,a]=s(o);if(void 0!==t&&void 0!==e&&void 0!==n&&void 0!==a&&t<=255&&e<=255&&n<=255&&r(a))return{values:[...c(t,e,n),a],alpha:a,type:i}}if("hexa"===i){let[,t]=o;4!==t.length&&3!==t.length||(t=t.split("").map((t=>t+t)).join(""));const e=t.substring(0,6);let s=t.substring(6);s=s?parseInt(s,16)/255:void 0;const r=function(t){const e=t.match(/.{2}/g);if(null!==e){const[t,i,o]=e.map((t=>Number.parseInt(t,16)));return c(t,i,o)}return null}(e);if(void 0!==r)return{values:[...r,s],alpha:s,type:i}}if("hsla"===i){const[,,,t,e,n,a]=s(o);if(t&&e&&n&&a&&t<=360&&e<=100&&n<=100&&a>=0&&a<=1&&r(a))return{values:[...d(t,e,n),a],alpha:a,type:i}}if("hsva"===i){const[,,,t,e,n,a]=s(o);if(t&&e&&n&&a&&t<=360&&e<=100&&n<=100&&a>=0&&a<=1&&r(a))return{values:[t,e,n,a],alpha:a,type:i}}return{values:null,type:"hexa"}}const g=t=>void 0!==t&&t.match(/^#?[\dA-Fa-f]{6,8}$/i),f="#7CA1FF";class m{constructor(t=0,e=0,i=0,o=1){this.mapper=(t,e)=>(i=-1)=>e(i>=0?t.map((t=>Number(t.toFixed(i)))):t),this.h=t,this.s=e,this.v=i,this.a=o>1?o/100:o}toHSVA(){const t=[this.h,this.s,this.v,this.a];return t.toString=this.mapper(t,(t=>`hsva(${t[0]}, ${t[1]}%, ${t[2]}%, ${this.readableAlpha()})`)),t}toHSLA(){const t=[...h(this.h,this.s,this.v),this.a];return t.toString=this.mapper(t,(t=>`hsla(${t[0]}, ${t[1]}%, ${t[2]}%, ${this.readableAlpha()})`)),t}toHSL(){const t=h(this.h,this.s,this.v);return t.toString=this.mapper(t,(t=>`hsl(${t[0]}, ${t[1]}%, ${t[2]}%)`)),t}toRGBA(){const t=[...a(this.h,this.s,this.v),this.a];return t.toString=this.mapper(t,(t=>`rgba(${Math.round(t[0])}, ${Math.round(t[1])}, ${Math.round(t[2])}, ${this.readableAlpha()})`)),t}toRGB(){const t=a(this.h,this.s,this.v);return t.toString=this.mapper(t,(t=>`rgb(${Math.round(t[0])}, ${Math.round(t[1])}, ${Math.round(t[2])})`)),t}toRGBModern(){const t=[...a(this.h,this.s,this.v),this.a];return t.toString=this.mapper(t,(t=>`rgb(${Math.round(t[0])} ${Math.round(t[1])} ${Math.round(t[2])} / ${this.alphaAsPercent()})`)),t}toCMYK(){const t=function(t,e,i){const s=a(t,e,i),r=s[0]/255,n=s[1]/255,l=s[2]/255,h=o(1-r,1-n,1-l);return[100*(1===h?0:(1-r-h)/(1-h)),100*(1===h?0:(1-n-h)/(1-h)),100*(1===h?0:(1-l-h)/(1-h)),100*h]}(this.h,this.s,this.v);return t.toString=this.mapper(t,(t=>`cmyk(${t[0]}%, ${t[1]}%, ${t[2]}%, ${t[3]}%)`)),t}toHEXA(){const t=l(this.h,this.s,this.v),e=this.a>=1?"":Number((255*this.a).toFixed(0)).toString(16).toUpperCase().padStart(2,"0");return e&&t.push(e),t.toString=()=>`#${t.join("").toUpperCase()}`,t}toHEX(){const t=l(this.h,this.s,this.v);return t.toString=()=>`#${t.join("").toLowerCase()}`,t}set alpha(t){this.a=t>1?t/100:t}get alpha(){return this.a}set hue(t){this.h=Math.round(t)}get hue(){return this.h}set saturation(t){this.s=Math.round(t)}get saturation(){return this.s}set value(t){this.v=Math.round(t)}get value(){return this.v}clone(){return new m(this.h,this.s,this.v,this.a)}readableAlpha(){return Math.round(100*(this.a+Number.EPSILON))/100}alphaAsPercent(){return Math.round(100*(this.a+Number.EPSILON))+"%"}}},7245:function(t,e,i){i.r(e),i.d(e,{color_picker:function(){return h},color_picker_color_palette:function(){return p},color_picker_hue_slider:function(){return d},color_picker_opacity_slider:function(){return u}});var o=i(6919),s=i(825),r=i(9041);const n=t=>t<=1?Math.round(100*t):Math.round(t);const a=new class{constructor(){this.storage=new WeakMap}set(t,e,i){this.has(t,e)&&console.warn("Overwriting existing key:",e),this.storage.get(t)||this.storage.set(t,new Map),this.storage.get(t).set(e,i)}get(t,e){var i;return void 0!==this.storage.get(t)?this.storage.get(t).get(e):null!==(i=this.storage[e])&&void 0!==i?i:null}has(t,e){return void 0!==this.storage.get(t)&&this.storage.get(t).has(e)}delete(t,e){this.has(t,e)&&(this.storage.get(t).delete(e),0===this.storage.get(t).size&&this.storage.delete(t))}};class l{constructor(t,e={}){if(this.arrowOffset=10,this.isScrolling=!1,this.positionClasses=[],this.defaults={position:"horizontal",delayShow:1e3,delayHide:500,horizontalOffset:-5,verticalOffset:0},this.classNames={tooltip:"rs-tooltip",horizontal:"rs-tooltip--horizontal",vertical:"rs-tooltip--vertical",arrowBottom:"rs-tooltip--bottom",arrowLeft:"rs-tooltip--left",arrowRight:"rs-tooltip-right",arrowTop:"rs-tooltip--top",active:"rs-tooltip--active"},void 0!==t.dataset.tip&&""!==t.dataset.tip&&!a.has(t,"tooltip-loaded")){if(a.set(t,"tooltip-loaded",!0),"object"==typeof e&&(this.options=Object.assign(this.defaults,e)),"string"==typeof t&&(t=document.querySelector(t)),!(t instanceof Element||t instanceof Element||null===t))throw new Error(`You haven't passed through a DOM element, or the element can't be found: ${t}`);this.element=t,this.createStructure(),this.element.addEventListener("mouseenter",(()=>{let t=this.isVisible()?0:this.options.delayShow;const e=a.get(this.tooltipContainer,"tooltipHideTimeout");void 0!==e&&(clearTimeout(e),a.delete(this.tooltipContainer,"tooltipHideTimeout"));const i=a.get(this.tooltipContainer,"tooltipShowTimeout");void 0!==i&&(clearTimeout(i),a.delete(this.tooltipContainer,"tooltipShowTimeout"));const o=setTimeout((()=>{this.show()}),t);a.set(this.tooltipContainer,"showTimeout",o)})),this.element.addEventListener("mouseleave",(()=>{const t=setTimeout((()=>{this.hide(),a.delete(this.tooltipContainer,"tooltipHideTimeout")}),this.options.delayHide);a.set(this.tooltipContainer,"tooltipHideTimeout",t);const e=a.get(this.tooltipContainer,"showTimeout");void 0!==e&&(clearTimeout(e),a.delete(this.tooltipContainer,"showTimeout"))})),window.addEventListener("scroll",(()=>{this.isScrolling=!0,this.hide(!0),(0,r.S)((()=>{this.isScrolling=!1,window.addEventListener("scroll",(()=>{this.isScrolling=!0,this.hide(!0)}),{once:!0})}))}),{once:!0})}}createStructure(){null===document.querySelector("rs-tool-tip")?(this.tooltipContainer=document.createElement("rs-tool-tip"),this.tooltipContainer.classList.add(this.classNames.tooltip),document.body.append(this.tooltipContainer)):this.tooltipContainer=document.querySelector("rs-tool-tip")}show(){if(this.isScrolling)return;this.hide(),setTimeout((()=>{this.tooltipContainer.innerHTML=this.element.dataset.tip,this.setPosition(),this.tooltipContainer.classList.add(this.classNames.active)}),150)}setPosition(){let t,e;this.tooltipContainer.style.width=null,this.tooltipContainer.style.height=null;const i=this.element.getBoundingClientRect(),o=i.left,s=i.top,r=i.width,n=i.height,a=this.tooltipContainer.offsetWidth,l=this.tooltipContainer.offsetHeight,h=window.scrollY||document.documentElement.scrollTop;let c="left";"horizontal"===this.options.position?(c="right",window.innerWidth-o+r>a+20?c="right":o>a+20&&(c="left")):"vertical"===this.options.position&&(c="top",window.innerHeight-s+n>l+20?c="bottom":s>a+20&&(c="top")),this.positionClasses.push(this.classNames[`arrow${c.charAt(0).toUpperCase()+c.slice(1)}`]),"top"===c?(this.positionClasses.push(this.classNames.vertical),e=r/2+o-a/2+this.options.horizontalOffset,t=s+h-l-this.arrowOffset+this.options.verticalOffset):"bottom"===c?(this.positionClasses.push(this.classNames.vertical),e=r/2+o-a/2+this.options.horizontalOffset,t=s+h+n+this.arrowOffset+this.options.verticalOffset):"left"===c?(this.positionClasses.push(this.classNames.horizontal),e=o-a-this.arrowOffset+this.options.horizontalOffset,t=s+h+n/2-l/2+this.options.verticalOffset):"right"===c&&(this.positionClasses.push(this.classNames.horizontal),e=r+o+this.arrowOffset+this.options.horizontalOffset,t=s+h+n/2-l/2+this.options.verticalOffset);const{left:p}=window.getComputedStyle(document.body),d=void 0!==e?e-Number.parseInt(p):"auto";this.tooltipContainer.style.top=`${null!=t?t:"auto"}px`,this.tooltipContainer.style.right="autopx",this.tooltipContainer.style.bottom="autopx",this.tooltipContainer.style.left=`${d}px`,this.tooltipContainer.classList.add(...this.positionClasses),this.tooltipContainer.setAttribute("arrow",c)}hide(t=!1){const e=t?0:150;this.tooltipContainer.classList.remove(this.classNames.active),setTimeout((()=>{this.tooltipContainer.classList.remove(this.classNames.arrowBottom,this.classNames.arrowTop,this.classNames.arrowLeft,this.classNames.arrowRight),this.tooltipContainer.style.top=null,this.tooltipContainer.style.right=null,this.tooltipContainer.style.bottom=null,this.tooltipContainer.style.left=null}),e)}isVisible(){const t=window.getComputedStyle(this.tooltipContainer);return!(null===this.tooltipContainer.offsetParent||"0"===t.opacity)}}const h=class{constructor(t){(0,o.r)(this,t),this.colorChange=(0,o.c)(this,"colorChange",7),this.presetColorChoice=(0,o.c)(this,"presetColorChoice",7),this.hasRecentColors=!1,this.palettesToDisplay=[],this.opacity=!1,this.maxPresetDisplay=12,this.recentColorsLabel="Recent Colors",this.transparentButton=!1,this.display="default",this.mode="default",this.hueChangeHandler=t=>{this.hasTransparentButton()&&(this.currentOpacity=100,this.currentColor.alpha=this.currentOpacity),this.currentColor.hue=t.detail,this.setHue(t.detail),this.setColorAndEmit(this.currentColor.toHEXA().toString())},this.colorPaletteChangeHandler=t=>{var e;!this.hasTransparentButton()&&this.supportsOpacity()||(this.currentOpacity=100),null===(e=this.opacitySlider)||void 0===e||e.setColor(t.detail.toHEXA().toString()),t.detail.alpha=this.currentOpacity,this.setColorAndEmit(t.detail.toHEXA().toString())},this.handleOpacityInput=t=>{const e=isNaN(t.target.value)?0:t.target.value;this.currentOpacity=Math.max(Math.min(e,100),0),this.setColorAndEmit(this.currentColor.toHEXA().toString())},this.setPresetPalette=t=>{var e,i,o;const s=null!==(i=(null!==(e=this.palettesToDisplay.filter((e=>e.label===t.target.dataset.category))[0])&&void 0!==e?e:{palettes:[]}).palettes.filter((e=>e.index===Number.parseInt(t.target.dataset.index)))[0])&&void 0!==i?i:{};this.setColorFromPalette(t.target.dataset.color),this.presetColorChoice.emit({color:this.currentColor,data:null!==(o=s.data)&&void 0!==o?o:null})},this.handleHexInput=t=>{const e=t.target.value,i=e.startsWith("#")?e:`#${e}`;(0,s.i)(i)&&(this.setColorAndEmit(i),this.setHue(this.currentColor.hue))},this.handleHexFocus=t=>{t.target.select()},this.hasOpacity=t=>t.length>7,this.setTransparentButton=()=>{this.currentOpacity=0,this.currentColor.alpha=this.currentOpacity,this.setColorAndEmit(this.currentColor.toHEXA().toString())}}watchPalettes(){this.buildPresetPalettes()}componentWillLoad(){var t;this.setColorValue(null!==(t=this.color)&&void 0!==t?t:s.D),this.buildPresetPalettes()}componentDidRender(){this.createToolTips()}opacityChangeHandler(t){this.currentOpacity=n(t.detail),this.currentColor.alpha=this.currentOpacity,this.setColorAndEmit(this.currentColor.toHEXA().toString())}colorPickerAddRecentHandler(t){if(!this.hasRecentColors)return;const e=this.getPresetPaletteGroup(this.recentColorsLabel);this.paletteExists(t.detail.hex,e.palettes)||this.addToPreset(t.detail.hex,this.recentColorsLabel)}async setColor(t){this.setColorValue(t),await this.updateColorPickerControls()}async getColor(){return this.currentColor}async addToPreset(t,e){if(this.renderPresetPalette(t)){const i=JSON.parse(JSON.stringify(this.palettesToDisplay)),o=i.findIndex((t=>t.label===e));-1!==o?this.paletteExists(t,i[o].palettes)||i[o].palettes.unshift(t):i.push({label:e,palettes:[t]}),this.palettesToDisplay=i}}async updateColorPickerControls(){await this.colorPalette.setColor(this.currentColor.toHEXA().toString()),await this.hueSlider.setHue(this.currentColor.hue),this.setOpacitySlider()}getPresetPaletteGroup(t){const e=JSON.parse(JSON.stringify(this.palettesToDisplay)),i=e.findIndex((e=>e.label===t));return e[i]}setColorAndEmit(t){this.setColorValue(t),this.colorChange.emit(this.currentColor)}setColorValue(t){this.currentColor=new s.H(...(0,s.p)(t).values),this.hasTransparentButton()&&!this.showOpacity()&&this.currentColor.alpha<1?this.currentColor.alpha=0:(this.showOpacity()||(this.currentColor.alpha=100),this.currentOpacity=n(this.currentColor.alpha))}setOpacitySlider(){this.showOpacity()&&(this.opacitySlider.setColor(this.currentColor.toHEX().toString()),this.opacitySlider.setOpacity(this.currentColor.alpha))}supportsOpacity(){return this.showOpacity()||this.hasTransparentButton()}hasTransparentButton(){return void 0!==this.transparentButton&&!0===this.transparentButton&&!this.showOpacity()}showOpacity(){return void 0!==this.opacity&&!0===this.opacity}renderPresetPalette(t){return(0,s.i)(t)&&!this.showOpacity()&&!this.hasOpacity(t)||(0,s.i)(t)&&this.showOpacity()}paletteExists(t,e){return-1!==e.findIndex((e=>e.toLowerCase()===t.toLowerCase()))}renderOpacityInput(){if(this.showOpacity())return(0,o.h)("div",{class:"input-container",style:{flexBasis:"70px"}},(0,o.h)("input",{type:"text",value:`${this.currentOpacity}`,onInput:this.handleOpacityInput}),(0,o.h)("div",{class:"input-label"},"%"))}buildPresetPalettes(){let t=this.palettes;if("string"==typeof this.palettes)try{t=JSON.parse(this.palettes)}catch(e){t=[]}void 0===t&&(t=[]),Array.isArray(t)||(t=[t]),this.palettesToDisplay=t.map((({label:t,palettes:e,count:i})=>({label:t,count:i,palettes:e.reduce(((t,e,i)=>{var o,r,n;const a="string"==typeof e&&(0,s.i)(e)?e:"string"==typeof e.color&&(0,s.i)(e.color)?e.color:null;return null!==a&&t.push({index:i,color:a,title:null!==(o=e.title)&&void 0!==o?o:null,description:null!==(r=e.description)&&void 0!==r?r:null,data:null!==(n=e.data)&&void 0!==n?n:null}),t}),[])})))}setColorFromPalette(t){this.setColorAndEmit(t),this.currentOpacity=n(this.currentColor.alpha),"preset"!==this.mode&&(this.colorPalette.setColor(this.currentColor.toHEXA().toString()),this.hueSlider.setHue(this.currentColor.hue),this.setOpacitySlider())}setHue(t){var e,i;null===(e=this.hueSlider)||void 0===e||e.setHue(t),null===(i=this.colorPalette)||void 0===i||i.setHue(t)}render(){return(0,o.h)(o.H,{key:"43937d9520976b79be1f7a5154dd233d55ec76ae",class:`color-picker--${this.display}`},(0,o.h)("div",{key:"9824de5c98c9d6d59c3f993bf7340d9857078378",class:"container"},"default"===this.mode?(0,o.h)("div",null,(0,o.h)("color-picker-color-palette",{display:this.display,color:this.currentColor.toHEX().toString(),onColorPaletteChange:this.colorPaletteChangeHandler,ref:t=>this.colorPalette=t}),(0,o.h)("color-picker-hue-slider",{display:this.display,hue:this.currentColor.hue,onHueChange:this.hueChangeHandler,ref:t=>this.hueSlider=t}),this.showOpacity()?(0,o.h)("color-picker-opacity-slider",{display:this.display,color:this.currentColor.toHEX().toString(),opacity:this.currentOpacity,ref:t=>this.opacitySlider=t}):"",(0,o.h)("div",{style:{width:"100%",maxWidth:"inline"===this.display?"100%":"200px",display:"flex",gap:"12px",marginTop:"16px"}},(0,o.h)("div",{class:"input-container"},(0,o.h)("input",{type:"text",maxlength:7,value:this.currentColor.toHEX().toString(),onInput:this.handleHexInput,onFocus:this.handleHexFocus}),(0,o.h)("div",{class:"input-label"},"Hex")),this.renderOpacityInput())):"",(0,o.h)("div",{key:"d641498f69ddc3d1ec259303a9014824c476741c",ref:t=>this.palettesContainer=t},this.palettesToDisplay.map((({label:t,palettes:e,count:i},s)=>{let r=0;return t===this.recentColorsLabel&&(this.hasRecentColors=!0),(0,o.h)("div",null,(0,o.h)("h3",{class:"palettes-header",style:{marginTop:0===s&&"preset"===this.mode?"0":""}},t),(0,o.h)("div",{class:"palettes-container"},e.map((s=>{if(this.renderPresetPalette(s.color)&&r<this.getMaxPalettesToDisplay(i,e.length))return r++,(0,o.h)("div",{class:{palette__container:!0,"palette__container--active":this.currentColor.toHEX().toString().toLowerCase()===s.color.toLowerCase()}},(0,o.h)("span",{class:"checkerboard"}),(0,o.h)("span",{class:"palette","data-category":t,"data-index":s.index,"data-tip":h.buildToolTip(s),"data-color":s.color,style:{backgroundColor:s.color},onClick:this.setPresetPalette}))}))),(0,o.h)("div",null,e.length<=0&&"Brand Colours"===t?(0,o.h)("div",{class:"palettes-message"},(0,o.h)("rs-content",{style:{fontSize:"12px"}},"No brand colours have been added to your website yet"),(0,o.h)("a",{href:"https://support.rocketspark.com/hc/en-us/articles/6551728489881-Want-to-add-your-Brand-Colours-to-your-site-",target:"_blank",class:"help-guide-link"},"View help guide")):""))}))),this.hasTransparentButton()?(0,o.h)("button",{class:"transparent-button",onClick:this.setTransparentButton},"Transparent",(0,o.h)("span",{class:"transparent-button__swatch"}," ")):""))}static buildToolTip(t){let e;return null!==t.title&&""!==t.title&&(e=`<h5 class="rs-tooltip__heading">${t.title}</h5>`),null!==t.description&&""!==t.description&&(e+=`<p class="rs-tooltip__caption">${t.description}</p>`),e}createToolTips(){var t,e;null===(e=null===(t=this.palettesContainer)||void 0===t?void 0:t.querySelectorAll(".palette"))||void 0===e||e.forEach((t=>{new l(t,{position:"horizontal",horizontalOffset:10})}))}getMaxPalettesToDisplay(t,e){return void 0===t?this.maxPresetDisplay:0===t?e:t}static get watchers(){return{palettes:["watchPalettes"]}}};h.style=':host{display:inline-block;font-family:arial, sans-serif;-webkit-font-smoothing:antialiased}.container{padding:16px;border-radius:8px;background:#fff;box-shadow:0 5px 15px rgb(70 74 83 / 0.25);font-family:soleil, sans-serif}:host(.color-picker--inline) .container{padding:0;box-shadow:none;background:none}.input-container{position:relative;flex-grow:1;flex-shrink:1}.input-label{font-size:12px;color:#95a8bd;position:absolute;right:15px;top:50%;transform:translateY(-50%)}.palettes-header{color:#748393;font-size:12px;font-weight:normal}.palettes-container{display:grid;gap:10px;grid-template-columns:repeat(6, 24px);grid-auto-rows:minmax(24px, auto)}.palettes-message{background:var(--rs-color-light);padding:16px;font-size:12px;width:162px;text-align:center;display:flex;flex-direction:column;gap:10px;border-radius:8px}.help-guide-link{color:var(--rs-color-primary);font-weight:700;cursor:pointer}:host(.color-picker--inline) .palettes-container{grid-template-columns:repeat(auto-fit, 24px)}.palette__container{border-radius:30px;overflow:hidden;position:relative}.palette__container--active{box-shadow:0 0 0 2px rgb(116 131 147 / 0.5);border:2px solid #fff}.palette{border-radius:30px;width:100%;height:100%;display:block;box-sizing:border-box;cursor:pointer;position:absolute;top:0;left:0;bottom:0;right:0;border:1px solid rgb(44 48 53 / 0.15)}.checkerboard{position:absolute;top:0;left:0;bottom:0;right:0;opacity:0.5;background-image:linear-gradient(45deg, #808080 25%, transparent 25%), linear-gradient(-45deg, #808080 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #808080 75%), linear-gradient(-45deg, transparent 75%, #808080 75%);background-size:6px 6px;background-position:0 0, 0 3px, 3px -3px, -3px 0}input,.transparent-button{font-family:soleil, arial, sans-serif;font-size:14px;text-transform:uppercase;color:#748393;height:28px;text-indent:8px;border-radius:4px;background:#fff;border:1px solid #ddd;box-sizing:border-box;min-width:0;width:100%}.transparent-button{margin-top:16px;text-transform:unset;text-align:left;display:flex;align-items:center;cursor:pointer;justify-content:space-between;padding:0 4px}.transparent-button__swatch{width:20px;height:20px;display:block;opacity:0.5;box-shadow:inset 0 0 1px 1px var(--rs-color-secondary);border-radius:20px;transition:box-shadow 0.15s cubic-bezier(0, 0.55, 0.45, 1);position:relative;overflow:hidden}.transparent-button:hover .transparent-button__swatch{box-shadow:inset 0 0 3px 1px var(--rs-color-secondary)}.transparent-button__swatch::after{content:"";position:absolute;border-top:2px solid red;width:21px;transform:rotate(-45deg);transform-origin:center;top:8px;z-index:1;left:0}';class c{constructor(t){this.cache={x:0,y:0},this.clamp=t=>Math.max(Math.min(t,1),0),this.options=Object.assign(Object.assign({},c.DEFAULT_OPTIONS),t),this.tapStartBinding=this.tapstart.bind(this),this.tapStopBinding=this.tapstop.bind(this),this.tapMoveBinding=this.tapmove.bind(this),(0,r.o)([this.options.wrapper,this.options.element],"mousedown",this.tapStartBinding),(0,r.o)([this.options.wrapper,this.options.element],"touchstart",this.tapStartBinding,{passive:!1}),(0,r.o)(document,["keydown","keyup"],this.keyboard.bind(this))}keyboard(t){const{type:e,key:i}=t;if(document.activeElement===this.options.wrapper){const{lock:o}=this.options,s="ArrowUp"===i,r="ArrowRight"===i,n="ArrowDown"===i,a="ArrowLeft"===i;if("keydown"===e&&(s||r||n||a)){let e,i=0;"v"===o?e=s||r?1:-1:"h"===o?e=s||r?-1:1:(i=0,s?i=-1:n&&(i=1),e=0,a?e=-1:r&&(e=1)),this.update(this.clamp(this.cache.x+.01*e),this.clamp(this.cache.y+.01*i)),t.preventDefault()}else i.startsWith("Arrow")&&(this.options.onstop(),t.preventDefault())}}tapstart(t){this.wrapperBoundingClient=this.options.wrapper.getBoundingClientRect(),(0,r.o)(document,["mouseup","touchend","touchcancel"],this.tapStopBinding),(0,r.o)(document,["mousemove","touchmove"],this.tapMoveBinding),t.cancelable&&t.preventDefault();const e=new CustomEvent("start");this.options.element.dispatchEvent(e),this.tapmove(t)}tapmove(t){let e,i;if(t){const o=t&&t.touches&&t.touches[0];e=t?(o||t).clientX:0,i=t?(o||t).clientY:0,c.outsideLeftBounds(e,this.wrapperBoundingClient)?e=this.wrapperBoundingClient.left:c.outsideRightBounds(e,this.wrapperBoundingClient)&&(e=this.wrapperBoundingClient.left+this.wrapperBoundingClient.width),c.outsideTopBounds(i,this.wrapperBoundingClient)?i=this.wrapperBoundingClient.top:c.outsideBottomBounds(i,this.wrapperBoundingClient)&&(i=this.wrapperBoundingClient.top+this.wrapperBoundingClient.height),e-=this.wrapperBoundingClient.left,i-=this.wrapperBoundingClient.top}else e=this.cache.x*this.wrapperBoundingClient.width,i=this.cache.y*this.wrapperBoundingClient.height;"h"!==this.options.lock&&(this.options.element.style.left=e/this.wrapperBoundingClient.width*100+"%"),"v"!==this.options.lock&&(this.options.element.style.top=i/this.wrapperBoundingClient.height*100+"%"),this.cache={x:e/this.wrapperBoundingClient.width,y:i/this.wrapperBoundingClient.height};const o=this.clamp(this.cache.x),s=this.clamp(this.cache.y),r=new CustomEvent("change",{detail:{x:o,y:s}});this.options.element.dispatchEvent(r)}tapstop(){this.options.onstop(),(0,r.a)(document,["mouseup","touchend","touchcancel"],this.tapStopBinding),(0,r.a)(document,["mousemove","touchmove"],this.tapMoveBinding);const t=new CustomEvent("stop");this.options.element.dispatchEvent(t)}trigger(){this.tapmove(null)}update(t=0,e=0){const i=t;let o="h"===this.options.lock?i:e;const{left:s,top:r,width:n,height:a}=this.options.wrapper.getBoundingClientRect();this.tapmove({clientX:s+n*i,clientY:r+a*o})}destroy(){(0,r.a)(document,["keydown","keyup"],this.keyboard.bind(this)),(0,r.a)([this.options.wrapper,this.options.element],"mousedown",this.tapstart.bind(this)),(0,r.a)([this.options.wrapper,this.options.element],"touchstart",this.tapstart.bind(this),{passive:!1})}}c.DEFAULT_OPTIONS={lock:null,onchange:()=>0,onstop:()=>0},c.outsideBottomBounds=(t,e)=>t>e.top+e.height,c.outsideTopBounds=(t,e)=>t<e.top,c.outsideRightBounds=(t,e)=>t>e.left+e.width,c.outsideLeftBounds=(t,e)=>t<e.left;const p=class{constructor(t){(0,o.r)(this,t),this.colorPaletteChange=(0,o.c)(this,"colorPaletteChange",7),this.sliderOffsetWidth=8,this.sliderOffsetHeight=8,this.sliderLeft=50,this.sliderTop=50,this.hue=0,this.display="default",this.getPaletteBackgroundColor=()=>`\n linear-gradient(to top, rgba(0, 0, 0, 1), transparent),\n linear-gradient(to left, hsla(${this.hue}, 100%, 50%, 1),\n rgba(255, 255, 255, 1))\n `,this.handleChange=t=>{const{x:e,y:i}=t.detail,o=100*e;let s=100-100*i;s<0&&(s=0),this.currentColor.saturation=o,this.currentColor.value=s,this.slider.style.background=this.currentColor.toRGB().toString(),this.colorPaletteChange.emit(this.currentColor)}}componentWillLoad(){return this.setInternalColor(this.color),new Promise((t=>{if(null!==this.slider&&void 0!==this.slider){const t=this.slider.offsetWidth,e=this.slider.offsetHeight;isNaN(t)||(this.sliderOffsetWidth=t/2),isNaN(e)||(this.sliderOffsetHeight=this.slider.offsetHeight/2)}t()}))}componentDidLoad(){new c({element:this.slider,wrapper:this.palette})}async setHue(t){this.currentColor.hue=t,this.hue=t}async setColor(t){this.setInternalColor(t)}setInternalColor(t){this.currentColor=new s.H(...(0,s.p)(t).values),this.hue=this.currentColor.hue,this.sliderLeft=this.currentColor.saturation,this.sliderTop=100-this.currentColor.value}render(){return(0,o.h)("div",{key:"f5728b33ac7593a22cbdee208e337e2cb087e7a5",class:{"color-selector":!0,[`color-selector--${this.display}`]:!0},ref:t=>this.palette=t,style:{background:this.getPaletteBackgroundColor()}},(0,o.h)("div",{key:"84f243bd113623ba09520d73617ae1e98a4e3a7e",class:"selector__pickr",style:{left:`${this.sliderLeft}%`,top:`${this.sliderTop}%`,background:this.currentColor.toRGB().toString()},onChange:this.handleChange,ref:t=>this.slider=t}))}};p.style=":host{display:block}.selector__pickr{position:absolute;height:16px;width:16px;border-radius:16px;border:2px solid #fff;box-sizing:border-box;box-shadow:0 5px 15px rgb(70 74 83 / 0.25);cursor:pointer;transition:top 150ms linear, left 150ms linear;transform:translate(-50%, -50%)}.selector__pickr:active,.color-selector:active .selector__pickr{transition:none;cursor:none}.color-selector{height:155px;width:200px;border-radius:6px;position:relative}.color-selector--inline{width:100%}";const d=class{constructor(t){(0,o.r)(this,t),this.hueChange=(0,o.c)(this,"hueChange",7),this.display="default",this.handleChange=t=>{const e=360*t.detail.x;this.hueChange.emit(e),this.slider.style.backgroundColor=`hsl(${e}, 100%, 50%)`}}async setHue(t){this._hue=t}componentWillLoad(){this._hue=this.hue}componentDidLoad(){new c({lock:"v",element:this.slider,wrapper:this.container})}render(){return(0,o.h)("div",{key:"aae99fa8a86c2544569e0c6caf9f3f23c46ab8d1",class:{"component-outer":!0,[`component-outer--${this.display}`]:!0},style:{"margin-top":"16px"},ref:t=>this.container=t},(0,o.h)("div",{key:"dce858da0afe98d2244a75f649313c0f77b26ba3",class:"hue-selector component-selector"}),(0,o.h)("div",{key:"16f08a19d0ff39ac5f3d186f4e25784f138d0f50",class:"selector__pickr",style:{"margin-top":"-4px",left:this._hue/360*100+"%",background:`hsl(${this._hue}, 100%, 50%)`},onChange:this.handleChange,ref:t=>this.slider=t}))}};d.style=":host{display:block}.selector__pickr{position:absolute;height:16px;width:16px;border-radius:16px;border:2px solid #fff;box-sizing:border-box;box-shadow:0 5px 15px rgb(70 74 83 / 0.25);cursor:pointer;transition:left 150ms linear;transform:translateX(-50%)}.selector__pickr:active,.color-selector:active .selector__pickr{transition:none;cursor:none}.component-outer{position:relative;height:8px;width:100%;max-width:200px;cursor:pointer}.component-outer--inline{max-width:100%}.component-selector{position:absolute;top:0;left:0;right:0;bottom:0;border-radius:10px;overflow:hidden}.hue-selector{background:linear-gradient(90deg, #f00 0%, #f57a20 12.78%, #ffd708 25.28%, #61ff00 37.78%, #0ff 50.28%, #0f4ded 62.26%, #640fed 73.72%, #ed0fe4 85.7%, #ed0f87 97.68%)}";const u=class{constructor(t){(0,o.r)(this,t),this.opacityChange=(0,o.c)(this,"opacityChange",7),this.color="#000000",this.display="default",this.handleOpacityChange=t=>{this.currentColor.alpha=this.currentOpacity=t.detail.x,this.slider.style.background=this.currentColor.toRGBA().toString(),this.opacityChange.emit(this.currentOpacity)}}watchOpacity(t){this.setInternalOpacity(t)}getOpacityAsPercent(){return this.currentOpacity<=1?100*this.currentOpacity:this.currentOpacity}async setColor(t){this.setInternalColor(t)}async setOpacity(t){this.setInternalOpacity(t)}componentDidLoad(){new c({lock:"v",element:this.slider,wrapper:this.container})}componentWillLoad(){this.setInternalOpacity(this.opacity),this.setInternalColor(this.color)}setInternalOpacity(t){const e=null!=t?t:100;this.currentOpacity=e>1?e/100:e}setInternalColor(t){this.currentColor=new s.H(...(0,s.p)(t).values),this.currentColor.alpha=this.currentOpacity,this.currentRgb=this.currentColor.toRGB()}render(){return(0,o.h)("div",{key:"8b5daccc6b2b77ddcd15dca8632f8f68be57fc0a",class:{"component-outer":!0,[`component-outer--${this.display}`]:!0},style:{"margin-top":"16px"},ref:t=>this.container=t},(0,o.h)("div",{key:"5399198da6828d72cc5b9af4ac0a064891ac9864",class:"checker-board component-selector"}),(0,o.h)("div",{key:"31e20b5c45c2bf2537d93d199620056b12c68085",class:"component-selector",style:{background:`linear-gradient(90deg, rgba(${this.currentRgb[0]},${this.currentRgb[1]},${this.currentRgb[2]}, 0) 0%, rgba(${this.currentRgb[0]},${this.currentRgb[1]},${this.currentRgb[2]}, 1) 100%)`}}),(0,o.h)("div",{key:"bff7d5f16d7cb26f9657b6e716f0ebb40ecf990c",class:"selector__pickr",style:{"margin-top":"-4px",left:`${this.getOpacityAsPercent()}%`,background:`rgba(${this.currentRgb[0]},${this.currentRgb[1]},${this.currentRgb[2]}, ${this.currentOpacity})`},onChange:this.handleOpacityChange,ref:t=>this.slider=t}))}static get watchers(){return{opacity:["watchOpacity"]}}};u.style=":host{display:block}.component-outer{position:relative;cursor:pointer;height:8px;width:100%;max-width:200px}.component-outer--inline{max-width:100%}.component-selector{position:absolute;top:0;left:0;right:0;bottom:0;border-radius:10px;overflow:hidden}.checker-board{background-image:linear-gradient(45deg, #808080 25%, transparent 25%), linear-gradient(-45deg, #808080 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #808080 75%), linear-gradient(-45deg, transparent 75%, #808080 75%);background-size:6px 6px;background-position:0 0, 0 3px, 3px -3px, -3px 0}.selector__pickr{transform:translateX(-50%);position:absolute;height:16px;width:16px;border-radius:16px;border:2px solid #fff;box-sizing:border-box;box-shadow:0 5px 15px rgb(70 74 83 / 0.25);cursor:pointer;transition:left 150ms linear}.selector__pickr:active,.color-selector:active .selector__pickr{transition:none;cursor:none}"},9041:function(t,e,i){i.d(e,{S:function(){return a},a:function(){return n},f:function(){return o},o:function(){return r}});const o=()=>{const t=document.createElement("div");t.style.display="flex",t.style.flexDirection="column",t.style.rowGap="1px",t.appendChild(document.createElement("div")),t.appendChild(document.createElement("div")),document.body.appendChild(t);const e=1===t.scrollHeight;return t.parentNode.removeChild(t),e};function s(t,e,i,o,s={}){let r=e;Array.isArray(e)?r=Array.from(e):Array.isArray(e)||(r=[e]);let n=i;return Array.isArray(i)||(n=[i]),r.forEach((e=>{n.forEach((i=>{e[t](i,o,Object.assign({capture:!1},s))}))})),[e,i,o,s]}const r=s.bind(null,"addEventListener"),n=s.bind(null,"removeEventListener"),a=t=>{if(!t||"[object Function]"!==Object.prototype.toString.call(t))return;let e;window.addEventListener("scroll",(function(){window.clearTimeout(e),e=setTimeout((function(){t()}),66)}),!1)}}}]);
//# sourceMappingURL=245.index.js.map