@rocketspark/domain-checker
Version:
Embeddable Domain Checker for Rocketspark
13 lines • 11 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([[208],{825:function(t,r,e){e.d(r,{D:function(){return b},H:function(){return f},i:function(){return g},p:function(){return p}});const{min:o,max:i,floor:s,round:n}=Math;function a(t,r,e){const o=t/360*6,i=r/100,n=e/100,a=s(o),l=o-a,h=n*(1-i),c=n*(1-l*i),d=n*(1-(1-l)*i),u=a%6;return[255*[n,c,h,h,d,n][u],255*[d,n,n,c,h,h][u],255*[h,h,d,n,n,c][u]]}function l(t,r,e){return a(t,r,e).map((t=>n(t).toString(16).padStart(2,"0")))}function h(t,r,e){let o=r/100;const i=e/100,s=(2-o)*i/2;return 0!==s&&(o=1===s?0:s<.5?o*i/(2*s):o*i/(2-2*s)),[t,100*o,100*s]}function c(t,r,e){const s=t/255,n=r/255,a=e/255,l=o(s,n,a),h=i(s,n,a),c=h-l;let d,u;if(0===c)d=0,u=0;else{u=c/h;const t=((h-s)/6+c/2)/c,r=((h-n)/6+c/2)/c,e=((h-a)/6+c/2)/c;s===h?d=e-r:n===h?d=1/3+t-e:a===h&&(d=2/3+r-t),d<0?d+=1:d>1&&(d-=1)}return[360*d,100*u,100*h]}function d(t,r,e,i){const s=r/100,n=e/100,a=i/100;return[...c(255*(1-o(1,t/100*(1-a)+a)),255*(1-o(1,s*(1-a)+a)),255*(1-o(1,n*(1-a)+a)))]}function u(t,r,e){let o=r/100;const i=e/100;o*=i<.5?i:1-i;const s=2*o/(i+o)*100,n=100*(i+o);return[t,Number.isNaN(s)?0:s,n]}function p(t="#000"){"transparent"===t.toLowerCase()&&(t="#00000000");const r=null!==t.match(/^[a-zA-Z]+$/)?function(t){if(void 0===t)return"#000";if("black"===t.toLowerCase())return"#000";const r=document.createElement("canvas").getContext("2d");return null===r?null:(r.fillStyle=t,"#000"===r.fillStyle?null:r.fillStyle)}(t):t,{type:e,match:o}=function(t){const r=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((([,r])=>r.exec(t)));if(void 0!==r){const e=r[1].exec(t);return{type:r[0],regex:r[1],match:e}}return{type:null}}(r),i=t=>t.map((t=>/^(|\d+)\.\d+|\d+$/.test(t)?Number(t):void 0));if(null===e||null===o)return{values:null,type:"hexa"};const s=t=>t>=0&&t<=1&&(t=>!!o[2]==("number"==typeof t))(t);if("cmyk"===e){const[,t,r,s,n]=i(o);if(t&&r&&s&&n&&t<=100&&r<=100&&s<=100&&n<=100)return{values:d(t,r,s,n),type:e}}if("rgba"===e){const[,,,t,r,n,a]=i(o);if(void 0!==t&&void 0!==r&&void 0!==n&&void 0!==a&&t<=255&&r<=255&&n<=255&&s(a))return{values:[...c(t,r,n),a],alpha:a,type:e}}if("hexa"===e){let[,t]=o;4!==t.length&&3!==t.length||(t=t.split("").map((t=>t+t)).join(""));const r=t.substring(0,6);let i=t.substring(6);i=i?parseInt(i,16)/255:void 0;const s=function(t){const r=t.match(/.{2}/g);if(null!==r){const[t,e,o]=r.map((t=>Number.parseInt(t,16)));return c(t,e,o)}return null}(r);if(void 0!==s)return{values:[...s,i],alpha:i,type:e}}if("hsla"===e){const[,,,t,r,n,a]=i(o);if(t&&r&&n&&a&&t<=360&&r<=100&&n<=100&&a>=0&&a<=1&&s(a))return{values:[...u(t,r,n),a],alpha:a,type:e}}if("hsva"===e){const[,,,t,r,n,a]=i(o);if(t&&r&&n&&a&&t<=360&&r<=100&&n<=100&&a>=0&&a<=1&&s(a))return{values:[t,r,n,a],alpha:a,type:e}}return{values:null,type:"hexa"}}const g=t=>void 0!==t&&t.match(/^#?[\dA-Fa-f]{6,8}$/i),b="#7CA1FF";class f{constructor(t=0,r=0,e=0,o=1){this.mapper=(t,r)=>(e=-1)=>r(e>=0?t.map((t=>Number(t.toFixed(e)))):t),this.h=t,this.s=r,this.v=e,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,r,e){const i=a(t,r,e),s=i[0]/255,n=i[1]/255,l=i[2]/255,h=o(1-s,1-n,1-l);return[100*(1===h?0:(1-s-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),r=this.a>=1?"":Number((255*this.a).toFixed(0)).toString(16).toUpperCase().padStart(2,"0");return r&&t.push(r),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 f(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))+"%"}}},3208:function(t,r,e){e.r(r),e.d(r,{rs_color_swatch:function(){return s}});var o=e(6919),i=e(825);const s=class{constructor(t){(0,o.r)(this,t),this.close=(0,o.c)(this,"close",7),this.rsClose=(0,o.c)(this,"rsClose",7),this.isDirty=!1,this.label="",this.color=i.D,this.opacity=!1,this.alignment="center",this.transparentButton=!1,this.mode="default",this.isNearBottomOfViewport=()=>window.innerHeight-this.el.getBoundingClientRect().bottom<200,this.isTopSpaceEnoughForColorPicker=()=>600<this.el.getBoundingClientRect().y,this.updateColorPickerPosition=()=>{this.isNearBottomOfViewport()&&this.isTopSpaceEnoughForColorPicker()?this.colorPicker.position="top":this.colorPicker.position="default"},this.toggleColorPicker=()=>{this.updateColorPickerPosition(),this.colorPicker.showPicker?(this.sendCloseEvent(),this.sendCloseEventWithObject(),this.closeColorPicker(),document.removeEventListener("click",this.listenToBody.bind(this))):(this.colorPicker.show(),document.addEventListener("click",this.listenToBody.bind(this)))},this.alignmentClass=()=>"center"===this.alignment?{left:"50%",transform:"translateX(-50%)"}:{}}updateColor(t){s.allowedColorString(t)&&(this.setInternalColor(t),this.colorPicker.setColor(this.internalColor.toHEXA().toString()))}async setColor(t){s.allowedColorString(t)&&(this.setInternalColor(t),await this.colorPicker.setColor(this.internalColor.toHEXA().toString()))}async getColor(){return this.internalColor}listenToBody(t){!t.composedPath().includes(this.el)&&this.colorPicker.showPicker&&(this.sendCloseEvent(),this.sendCloseEventWithObject(),this.closeColorPicker())}sendCloseEvent(){this.close.emit({color:this.color,isDirty:this.isDirty})}sendCloseEventWithObject(){this.rsClose.emit({color:this.internalColor,isDirty:this.isDirty})}closeColorPicker(){this.colorPicker.hide(),this.isDirty=!1}rsColorChangeHandler(t){this.setInternalColor(t.detail.value),this.isDirty=!0}swatchBackgroundColor(){return`linear-gradient(135deg, ${this.internalColor.toRGB().toString()} 50%, ${this.internalColor.toRGBModern().toString()} 50%)`}componentWillLoad(){this.setInternalColor(""===this.color?i.D:this.color)}setInternalColor(t){if("string"==typeof t)t=s.allowedColorString(t)?t:i.D,this.internalColor=new i.H(...(0,i.p)(t).values);else{if(!(t instanceof i.H))throw new Error("A valid color string or HSVaColor object is required");this.internalColor=t}this.internalOpacity=this.internalColor.alpha}render(){return(0,o.h)(o.H,{key:"9e3114a27c6e7a5cfdf4b4aac570cdda7850124a",style:{display:""===this.label?"inline-block":null,width:this.getWidth()}},(0,o.h)("div",{key:"bd9886f20f83081b56e10bc06ce682b82ede5966",class:"rs-color-swatch__inner",onClick:this.toggleColorPicker},(0,o.h)("div",{key:"0ae14294486d071743d208afeef4d55b6d625933",class:{"rs-color-swatch__container":!0,"rs-color-swatch__container--transparent":0===this.internalOpacity}},(0,o.h)("div",{key:"68dfecc74d02e467fbf0e479db4a43cd58d17949",class:{"rs-color-swatch__swatch":!0,"rs-color-swatch__swatch--solid-half":!0},style:{background:this.swatchBackgroundColor()}})),""!==this.label?(0,o.h)("rs-caption",{style:{display:""!==this.label?"block":null},class:"rs-color-swatch__label",color:"secondary"},""!==this.label?this.label:""):""),(0,o.h)("rs-color-picker",{key:"55ac5efe377d3ecbbc716eb69e220b7ee112214b",class:"rs-color-swatch__color-picker",mode:this.mode,style:this.alignmentClass(),color:this.internalColor.toHEXA().toString().toLowerCase(),palettes:this.palettes,opacity:this.opacity,transparentButton:this.transparentButton,ref:t=>this.colorPicker=t}))}getWidth(){return void 0!==this.width?this.width:""!==this.label?"100%":null}static allowedColorString(t){return(0,i.i)(t)||"transparent"===t.toLowerCase()}get el(){return(0,o.g)(this)}static get watchers(){return{color:["updateColor"]}}};s.style=':host{display:block}.rs-color-swatch__inner{background:var(--rs-color-white);box-shadow:inset 0 0 0 1px var(--rs-color-select-border);border-radius:4px;padding:6px;cursor:pointer;min-width:32px;box-sizing:border-box;display:flex;align-items:center;justify-content:start}.rs-color-swatch__container{width:20px;height:20px;box-sizing:border-box;position:relative;overflow:hidden;border-radius:50%}.rs-color-swatch__container::before{content:"";position:absolute;width:18px;height:18px;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;border-radius:50%;top:1px;left:1px}.rs-color-swatch__container::after{content:"";position:absolute;border-top:2px solid red;width:18px;transform:rotate(-45deg);transform-origin:center;top:9px;left:1px;opacity:0}.rs-color-swatch__container--transparent::after{opacity:1}.rs-color-swatch__swatch{display:block;width:20px;height:20px;min-width:10px;box-sizing:border-box;position:relative;overflow:hidden;border-radius:50%;border:1px solid rgb(223 223 224)}.rs-color-swatch__container--transparent .rs-color-swatch__swatch{background:#fff !important}.rs-color-swatch__label{display:none;margin-left:7px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}'}}]);
//# sourceMappingURL=208.index.js.map