@rocketspark/domain-checker
Version:
Embeddable Domain Checker for Rocketspark
13 lines • 7.73 kB
JavaScript
/*!
*
* @rocketspark/domain-checker v0.0.34
* 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],{4902:function(t,s,r){r.d(s,{D:function(){return f},H:function(){return v},i:function(){return m},p:function(){return d}});const{min:i,max:o,floor:e,round:n}=Math;function a(t,s,r){const i=t/360*6,o=s/100,n=r/100,a=e(i),h=i-a,l=n*(1-o),c=n*(1-h*o),u=n*(1-(1-h)*o),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,s,r){return a(t,s,r).map((t=>n(t).toString(16).padStart(2,"0")))}function l(t,s,r){let i=s/100;const o=r/100,e=(2-i)*o/2;return 0!==e&&(i=1===e?0:e<.5?i*o/(2*e):i*o/(2-2*e)),[t,100*i,100*e]}function c(t,s,r){const e=t/255,n=s/255,a=r/255,h=i(e,n,a),l=o(e,n,a),c=l-h;let u,p;if(0===c)u=0,p=0;else{p=c/l;const t=((l-e)/6+c/2)/c,s=((l-n)/6+c/2)/c,r=((l-a)/6+c/2)/c;e===l?u=r-s:n===l?u=1/3+t-r:a===l&&(u=2/3+s-t),u<0?u+=1:u>1&&(u-=1)}return[360*u,100*p,100*l]}function u(t,s,r,o){const e=s/100,n=r/100,a=o/100;return[...c(255*(1-i(1,t/100*(1-a)+a)),255*(1-i(1,e*(1-a)+a)),255*(1-i(1,n*(1-a)+a)))]}function p(t,s,r){let i=s/100;const o=r/100;i*=o<.5?o:1-o;const e=2*i/(o+i)*100,n=100*(o+i);return[t,Number.isNaN(e)?0:e,n]}function d(t="#000"){"transparent"===t.toLowerCase()&&(t="#00000000");const s=null!==t.match(/^[a-zA-Z]+$/)?function(t){if(void 0===t)return"#000";if("black"===t.toLowerCase())return"#000";const s=document.createElement("canvas").getContext("2d");return null===s?null:(s.fillStyle=t,"#000"===s.fillStyle?null:s.fillStyle)}(t):t,{type:r,match:i}=function(t){const s=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((([,s])=>s.exec(t)));if(void 0!==s){const r=s[1].exec(t);return{type:s[0],regex:s[1],match:r}}return{type:null}}(s),o=t=>t.map((t=>/^(|\d+)\.\d+|\d+$/.test(t)?Number(t):void 0));if(null===r||null===i)return{values:null,type:"hexa"};const e=t=>t>=0&&t<=1&&(t=>!!i[2]==("number"==typeof t))(t);if("cmyk"===r){const[,t,s,e,n]=o(i);if(t&&s&&e&&n&&t<=100&&s<=100&&e<=100&&n<=100)return{values:u(t,s,e,n),type:r}}if("rgba"===r){const[,,,t,s,n,a]=o(i);if(void 0!==t&&void 0!==s&&void 0!==n&&void 0!==a&&t<=255&&s<=255&&n<=255&&e(a))return{values:[...c(t,s,n),a],alpha:a,type:r}}if("hexa"===r){let[,t]=i;4!==t.length&&3!==t.length||(t=t.split("").map((t=>t+t)).join(""));const s=t.substring(0,6);let o=t.substring(6);o=o?parseInt(o,16)/255:void 0;const e=function(t){const s=t.match(/.{2}/g);if(null!==s){const[t,r,i]=s.map((t=>Number.parseInt(t,16)));return c(t,r,i)}return null}(s);if(void 0!==e)return{values:[...e,o],alpha:o,type:r}}if("hsla"===r){const[,,,t,s,n,a]=o(i);if(t&&s&&n&&a&&t<=360&&s<=100&&n<=100&&a>=0&&a<=1&&e(a))return{values:[...p(t,s,n),a],alpha:a,type:r}}if("hsva"===r){const[,,,t,s,n,a]=o(i);if(t&&s&&n&&a&&t<=360&&s<=100&&n<=100&&a>=0&&a<=1&&e(a))return{values:[t,s,n,a],alpha:a,type:r}}return{values:null,type:"hexa"}}const m=t=>void 0!==t&&t.match(/^#?[\dA-Fa-f]{6,8}$/i),f="#7CA1FF";class v{constructor(t=0,s=0,r=0,i=1){this.mapper=(t,s)=>(r=-1)=>s(r>=0?t.map((t=>Number(t.toFixed(r)))):t),this.h=t,this.s=s,this.v=r,this.a=i>1?i/100:i}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,s,r){const o=a(t,s,r),e=o[0]/255,n=o[1]/255,h=o[2]/255,l=i(1-e,1-n,1-h);return[100*(1===l?0:(1-e-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),s=this.a>=1?"":Number((255*this.a).toFixed(0)).toString(16).toUpperCase().padStart(2,"0");return s&&t.push(s),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,s,r){r.r(s),r.d(s,{rs_color_picker:function(){return e}});var i=r(7915),o=r(4902);const e=class{constructor(t){(0,i.r)(this,t),this.rsColorChange=(0,i.c)(this,"rsColorChange",7),this.rsPresetColorChoice=(0,i.c)(this,"rsPresetColorChoice",7),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"}:{},this.color=o.D,this.palettes=void 0,this.opacity=!1,this.showPicker=!1,this.position="default",this.display="default",this.transparentButton=!1,this.mode="default",this.colorSwatches=null}async setColor(t){e.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 o.H(...(0,o.p)(null!==(t=this.color)&&void 0!==t?t:o.D).values)}render(){return(0,i.h)(i.H,{style:Object.assign({display:this.showPicker||"inline"===this.display?"block":"none"},this.positionStyle()),class:`rs-color-picker--${this.display}`},(0,i.h)("div",{class:"rs-color-picker__inner"},(0,i.h)("div",{class:"rs-color-picker__swatch"}),(0,i.h)("div",{class:"rs-color-picker__popup"},(0,i.h)("color-picker",{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,o.i)(t)||"transparent"===t.toLowerCase()}};e.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