@rocketspark/domain-checker
Version:
Embeddable Domain Checker for Rocketspark
13 lines • 7.95 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([[278],{825:function(t,e,s){s.d(e,{D:function(){return m},H:function(){return v},i:function(){return f},p:function(){return d}});const{min:r,max:i,floor:o,round:n}=Math;function a(t,e,s){const r=t/360*6,i=e/100,n=s/100,a=o(r),h=r-a,l=n*(1-i),c=n*(1-h*i),u=n*(1-(1-h)*i),p=a%6;return[255*[n,c,l,l,u,n][p],255*[u,n,n,c,l,l][p],255*[l,l,u,n,n,c][p]]}function h(t,e,s){return a(t,e,s).map((t=>n(t).toString(16).padStart(2,"0")))}function l(t,e,s){let r=e/100;const i=s/100,o=(2-r)*i/2;return 0!==o&&(r=1===o?0:o<.5?r*i/(2*o):r*i/(2-2*o)),[t,100*r,100*o]}function c(t,e,s){const o=t/255,n=e/255,a=s/255,h=r(o,n,a),l=i(o,n,a),c=l-h;let u,p;if(0===c)u=0,p=0;else{p=c/l;const t=((l-o)/6+c/2)/c,e=((l-n)/6+c/2)/c,s=((l-a)/6+c/2)/c;o===l?u=s-e:n===l?u=1/3+t-s:a===l&&(u=2/3+e-t),u<0?u+=1:u>1&&(u-=1)}return[360*u,100*p,100*l]}function u(t,e,s,i){const o=e/100,n=s/100,a=i/100;return[...c(255*(1-r(1,t/100*(1-a)+a)),255*(1-r(1,o*(1-a)+a)),255*(1-r(1,n*(1-a)+a)))]}function p(t,e,s){let r=e/100;const i=s/100;r*=i<.5?i:1-i;const o=2*r/(i+r)*100,n=100*(i+r);return[t,Number.isNaN(o)?0:o,n]}function d(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:s,match:r}=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 s=e[1].exec(t);return{type:e[0],regex:e[1],match:s}}return{type:null}}(e),i=t=>t.map((t=>/^(|\d+)\.\d+|\d+$/.test(t)?Number(t):void 0));if(null===s||null===r)return{values:null,type:"hexa"};const o=t=>t>=0&&t<=1&&(t=>!!r[2]==("number"==typeof t))(t);if("cmyk"===s){const[,t,e,o,n]=i(r);if(t&&e&&o&&n&&t<=100&&e<=100&&o<=100&&n<=100)return{values:u(t,e,o,n),type:s}}if("rgba"===s){const[,,,t,e,n,a]=i(r);if(void 0!==t&&void 0!==e&&void 0!==n&&void 0!==a&&t<=255&&e<=255&&n<=255&&o(a))return{values:[...c(t,e,n),a],alpha:a,type:s}}if("hexa"===s){let[,t]=r;4!==t.length&&3!==t.length||(t=t.split("").map((t=>t+t)).join(""));const e=t.substring(0,6);let i=t.substring(6);i=i?parseInt(i,16)/255:void 0;const o=function(t){const e=t.match(/.{2}/g);if(null!==e){const[t,s,r]=e.map((t=>Number.parseInt(t,16)));return c(t,s,r)}return null}(e);if(void 0!==o)return{values:[...o,i],alpha:i,type:s}}if("hsla"===s){const[,,,t,e,n,a]=i(r);if(t&&e&&n&&a&&t<=360&&e<=100&&n<=100&&a>=0&&a<=1&&o(a))return{values:[...p(t,e,n),a],alpha:a,type:s}}if("hsva"===s){const[,,,t,e,n,a]=i(r);if(t&&e&&n&&a&&t<=360&&e<=100&&n<=100&&a>=0&&a<=1&&o(a))return{values:[t,e,n,a],alpha:a,type:s}}return{values:null,type:"hexa"}}const f=t=>void 0!==t&&t.match(/^#?[\dA-Fa-f]{6,8}$/i),m="#7CA1FF";class v{constructor(t=0,e=0,s=0,r=1){this.mapper=(t,e)=>(s=-1)=>e(s>=0?t.map((t=>Number(t.toFixed(s)))):t),this.h=t,this.s=e,this.v=s,this.a=r>1?r/100:r}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=[...l(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=l(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,s){const i=a(t,e,s),o=i[0]/255,n=i[1]/255,h=i[2]/255,l=r(1-o,1-n,1-h);return[100*(1===l?0:(1-o-l)/(1-l)),100*(1===l?0:(1-n-l)/(1-l)),100*(1===l?0:(1-h-l)/(1-l)),100*l]}(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=h(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=h(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 v(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))+"%"}}},278:function(t,e,s){s.r(e),s.d(e,{rs_color_picker:function(){return o}});var r=s(6919),i=s(825);const o=class{constructor(t){(0,r.r)(this,t),this.rsColorChange=(0,r.c)(this,"rsColorChange",7),this.rsPresetColorChoice=(0,r.c)(this,"rsPresetColorChoice",7),this.color=i.D,this.opacity=!1,this.showPicker=!1,this.position="default",this.display="default",this.transparentButton=!1,this.mode="default",this.colorSwatches=null,this.onColorChange=t=>{t.stopImmediatePropagation(),this.internalColor=t.detail,this.rsColorChange.emit({value:t.detail})},this.onPresetColorChoice=t=>{t.stopImmediatePropagation(),this.rsPresetColorChoice.emit({value:t.detail})},this.positionStyle=()=>"top"===this.position?{bottom:"37px","margin-top":"0px","padding-bottom":"0px"}:{}}async setColor(t){o.allowedColorString(t)&&await this.rsColorPicker.setColor(t)}async getColor(){return this.internalColor}async show(){this.showPicker=!0}async hide(){this.showPicker=!1}componentWillLoad(){var t;this.internalColor=new i.H(...(0,i.p)(null!==(t=this.color)&&void 0!==t?t:i.D).values)}render(){return(0,r.h)(r.H,{key:"f77ce1a1fc422ba45b6cd1ed14b0a4eb52730ed4",style:Object.assign({display:this.showPicker||"inline"===this.display?"block":"none"},this.positionStyle()),class:`rs-color-picker--${this.display}`},(0,r.h)("div",{key:"3d066e618b9069a1a8e9342087466eb9c9d91312",class:"rs-color-picker__inner"},(0,r.h)("div",{key:"93f13033ca65be2fe652ada17c0740f0c926e2c7",class:"rs-color-picker__swatch"}),(0,r.h)("div",{key:"ac1e1e46009fc42a18e95908ff887a78ea4852af",class:"rs-color-picker__popup"},(0,r.h)("color-picker",{key:"ce631924706933d920257fa525e705399617b9ec",class:"rs-color-picker__picker",color:this.color,mode:this.mode,palettes:this.palettes,opacity:this.opacity,display:this.display,transparentButton:this.transparentButton,onColorChange:this.onColorChange,onPresetColorChoice:this.onPresetColorChoice,ref:t=>this.rsColorPicker=t}))))}static allowedColorString(t){return(0,i.i)(t)||"transparent"===t.toLowerCase()}};o.style=":host{display:block;margin-top:5px;position:absolute;z-index:2;padding-bottom:20px}:host(.rs-color-picker--inline){position:unset;padding-bottom:0}:host(.rs-color-picker--inline) .rs-color-picker__picker{width:100%;max-width:500px}"}}]);
//# sourceMappingURL=278.index.js.map