(function(R,et){typeof exports=="object"&&typeof module<"u"?et(exports):typeof define=="function"&&define.amd?define(["exports"],et):(R=typeof globalThis<"u"?globalThis:R||self,et(R.Scalebar={}))})(this,function(R){"use strict";/** * @license * https://raw.githubusercontent.com/indus/dv-scalebar/refs/heads/main/dist/dv-scalebar.lit.licence.txt *//** * @license * Copyright 2019 Google LLC * SPDX-License-Identifier: BSD-3-Clause */var zr;const et=globalThis,Zt=et.ShadowRoot&&(et.ShadyCSS===void 0||et.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Se=Symbol(),Ce=new WeakMap;let jr=class{constructor(t,r,n){if(this._$cssResult$=!0,n!==Se)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=r}get styleSheet(){let t=this.o;const r=this.t;if(Zt&&t===void 0){const n=r!==void 0&&r.length===1;n&&(t=Ce.get(r)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),n&&Ce.set(r,t))}return t}toString(){return this.cssText}};const Pe=e=>new jr(typeof e=="string"?e:e+"",void 0,Se),Ur=(e,t)=>{if(Zt)e.adoptedStyleSheets=t.map(r=>r instanceof CSSStyleSheet?r:r.styleSheet);else for(const r of t){const n=document.createElement("style"),s=et.litNonce;s!==void 0&&n.setAttribute("nonce",s),n.textContent=r.cssText,e.appendChild(n)}},Ne=Zt?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let r="";for(const n of t.cssRules)r+=n.cssText;return Pe(r)})(e):e;/** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */const{is:Yr,defineProperty:Hr,getOwnPropertyDescriptor:Br,getOwnPropertyNames:Dr,getOwnPropertySymbols:Gr,getPrototypeOf:Xr}=Object,rt=globalThis,Re=rt.trustedTypes,Ir=Re?Re.emptyScript:"",Wt=rt.reactiveElementPolyfillSupport,At=(e,t)=>e,Ot={toAttribute(e,t){switch(t){case Boolean:e=e?Ir:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let r=e;switch(t){case Boolean:r=e!==null;break;case Number:r=e===null?null:Number(e);break;case Object:case Array:try{r=JSON.parse(e)}catch{r=null}}return r}},Kt=(e,t)=>!Yr(e,t),Le={attribute:!0,type:String,converter:Ot,reflect:!1,hasChanged:Kt};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),rt.litPropertyMetadata??(rt.litPropertyMetadata=new WeakMap);let ft=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,r=Le){if(r.state&&(r.attribute=!1),this._$Ei(),this.elementProperties.set(t,r),!r.noAccessor){const n=Symbol(),s=this.getPropertyDescriptor(t,n,r);s!==void 0&&Hr(this.prototype,t,s)}}static getPropertyDescriptor(t,r,n){const{get:s,set:o}=Br(this.prototype,t)??{get(){return this[r]},set(a){this[r]=a}};return{get(){return s==null?void 0:s.call(this)},set(a){const i=s==null?void 0:s.call(this);o.call(this,a),this.requestUpdate(t,i,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Le}static _$Ei(){if(this.hasOwnProperty(At("elementProperties")))return;const t=Xr(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(At("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(At("properties"))){const r=this.properties,n=[...Dr(r),...Gr(r)];for(const s of n)this.createProperty(s,r[s])}const t=this[Symbol.metadata];if(t!==null){const r=litPropertyMetadata.get(t);if(r!==void 0)for(const[n,s]of r)this.elementProperties.set(n,s)}this._$Eh=new Map;for(const[r,n]of this.elementProperties){const s=this._$Eu(r,n);s!==void 0&&this._$Eh.set(s,r)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const r=[];if(Array.isArray(t)){const n=new Set(t.flat(1/0).reverse());for(const s of n)r.unshift(Ne(s))}else t!==void 0&&r.push(Ne(t));return r}static _$Eu(t,r){const n=r.attribute;return n===!1?void 0:typeof n=="string"?n:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise(r=>this.enableUpdating=r),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(r=>r(this))}addController(t){var r;(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((r=t.hostConnected)==null||r.call(t))}removeController(t){var r;(r=this._$EO)==null||r.delete(t)}_$E_(){const t=new Map,r=this.constructor.elementProperties;for(const n of r.keys())this.hasOwnProperty(n)&&(t.set(n,this[n]),delete this[n]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Ur(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$EO)==null||t.forEach(r=>{var n;return(n=r.hostConnected)==null?void 0:n.call(r)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(r=>{var n;return(n=r.hostDisconnected)==null?void 0:n.call(r)})}attributeChangedCallback(t,r,n){this._$AK(t,n)}_$EC(t,r){var o;const n=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,n);if(s!==void 0&&n.reflect===!0){const a=(((o=n.converter)==null?void 0:o.toAttribute)!==void 0?n.converter:Ot).toAttribute(r,n.type);this._$Em=t,a==null?this.removeAttribute(s):this.setAttribute(s,a),this._$Em=null}}_$AK(t,r){var o;const n=this.constructor,s=n._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const a=n.getPropertyOptions(s),i=typeof a.converter=="function"?{fromAttribute:a.converter}:((o=a.converter)==null?void 0:o.fromAttribute)!==void 0?a.converter:Ot;this._$Em=s,this[s]=i.fromAttribute(r,a.type),this._$Em=null}}requestUpdate(t,r,n){if(t!==void 0){if(n??(n=this.constructor.getPropertyOptions(t)),!(n.hasChanged??Kt)(this[t],r))return;this.P(t,r,n)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(t,r,n){this._$AL.has(t)||this._$AL.set(t,r),n.reflect===!0&&this._$Em!==t&&(this._$Ej??(this._$Ej=new Set)).add(t)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(r){Promise.reject(r)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var n;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[o,a]of this._$Ep)this[o]=a;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[o,a]of s)a.wrapped!==!0||this._$AL.has(o)||this[o]===void 0||this.P(o,this[o],a)}let t=!1;const r=this._$AL;try{t=this.shouldUpdate(r),t?(this.willUpdate(r),(n=this._$EO)==null||n.forEach(s=>{var o;return(o=s.hostUpdate)==null?void 0:o.call(s)}),this.update(r)):this._$EU()}catch(s){throw t=!1,this._$EU(),s}t&&this._$AE(r)}willUpdate(t){}_$AE(t){var r;(r=this._$EO)==null||r.forEach(n=>{var s;return(s=n.hostUpdated)==null?void 0:s.call(n)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&(this._$Ej=this._$Ej.forEach(r=>this._$EC(r,this[r]))),this._$EU()}updated(t){}firstUpdated(t){}};ft.elementStyles=[],ft.shadowRootOptions={mode:"open"},ft[At("elementProperties")]=new Map,ft[At("finalized")]=new Map,Wt==null||Wt({ReactiveElement:ft}),(rt.reactiveElementVersions??(rt.reactiveElementVersions=[])).push("2.0.4");/** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */const kt=globalThis,zt=kt.trustedTypes,Oe=zt?zt.createPolicy("lit-html",{createHTML:e=>e}):void 0,ze="$lit$",nt=`lit$${Math.random().toFixed(9).slice(2)}$`,Te="?"+nt,Vr=`<${Te}>`,at=document,xt=()=>at.createComment(""),Et=e=>e===null||typeof e!="object"&&typeof e!="function",Ft=Array.isArray,qr=e=>Ft(e)||typeof(e==null?void 0:e[Symbol.iterator])=="function",Jt=`[ \f\r]`,Mt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,je=/-->/g,Ue=/>/g,it=RegExp(`>|${Jt}(?:([^\\s"'>=/]+)(${Jt}*=${Jt}*(?:[^ \f\r"'\`<>=]|("|')|))|$)`,"g"),Ye=/'/g,He=/"/g,Be=/^(?:script|style|textarea|title)$/i,De=e=>(t,...r)=>({_$litType$:e,strings:t,values:r}),Zr=De(1),St=De(2),ht=Symbol.for("lit-noChange"),U=Symbol.for("lit-nothing"),Ge=new WeakMap,ct=at.createTreeWalker(at,129);function Xe(e,t){if(!Ft(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return Oe!==void 0?Oe.createHTML(t):t}const Wr=(e,t)=>{const r=e.length-1,n=[];let s,o=t===2?"":t===3?"":"",a=Mt;for(let i=0;i"?(a=s??Mt,u=-1):h[1]===void 0?u=-2:(u=a.lastIndex-h[2].length,l=h[1],a=h[3]===void 0?it:h[3]==='"'?He:Ye):a===He||a===Ye?a=it:a===je||a===Ue?a=Mt:(a=it,s=void 0);const m=a===it&&e[i+1].startsWith("/>")?" ":"";o+=a===Mt?c+Vr:u>=0?(n.push(l),c.slice(0,u)+ze+c.slice(u)+nt+m):c+nt+(u===-2?i:m)}return[Xe(e,o+(e[r]||"")+(t===2?"":t===3?"":"")),n]};class Ct{constructor({strings:t,_$litType$:r},n){let s;this.parts=[];let o=0,a=0;const i=t.length-1,c=this.parts,[l,h]=Wr(t,r);if(this.el=Ct.createElement(l,n),ct.currentNode=this.el.content,r===2||r===3){const u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(s=ct.nextNode())!==null&&c.length0){s.textContent=zt?zt.emptyScript:"";for(let m=0;m2||n[0]!==""||n[1]!==""?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=U}_$AI(t,r=this,n,s){const o=this.strings;let a=!1;if(o===void 0)t=ut(this,t,r,0),a=!Et(t)||t!==this._$AH&&t!==ht,a&&(this._$AH=t);else{const i=t;let c,l;for(t=o[0],c=0;c{const n=(r==null?void 0:r.renderBefore)??t;let s=n._$litPart$;if(s===void 0){const o=(r==null?void 0:r.renderBefore)??null;n._$litPart$=s=new Pt(t.insertBefore(xt(),o),o,void 0,r??{})}return s._$AI(e),s};/** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */let Nt=class extends ft{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var r;const t=super.createRenderRoot();return(r=this.renderOptions).renderBefore??(r.renderBefore=t.firstChild),t}update(t){const r=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=en(r,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)==null||t.setConnected(!1)}render(){return ht}};Nt._$litElement$=!0,Nt.finalized=!0,(zr=globalThis.litElementHydrateSupport)==null||zr.call(globalThis,{LitElement:Nt});const te=globalThis.litElementPolyfillSupport;te==null||te({LitElement:Nt}),(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.1.1");/** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */const rn=e=>(t,r)=>{r!==void 0?r.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};/** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */const nn={attribute:!0,type:String,converter:Ot,reflect:!1,hasChanged:Kt},sn=(e=nn,t,r)=>{const{kind:n,metadata:s}=r;let o=globalThis.litPropertyMetadata.get(s);if(o===void 0&&globalThis.litPropertyMetadata.set(s,o=new Map),o.set(r.name,e),n==="accessor"){const{name:a}=r;return{set(i){const c=t.get.call(this);t.set.call(this,i),this.requestUpdate(a,c,e)},init(i){return i!==void 0&&this.P(a,void 0,e),i}}}if(n==="setter"){const{name:a}=r;return function(i){const c=this[a];t.call(this,i),this.requestUpdate(a,c,e)}}throw Error("Unsupported decorator location: "+n)};function H(e){return(t,r)=>typeof r=="object"?sn(e,t,r):((n,s,o)=>{const a=s.hasOwnProperty(o);return s.constructor.createProperty(o,a?{...n,wrapped:!0}:n),a?Object.getOwnPropertyDescriptor(s,o):void 0})(e,t,r)}const{min:on,max:an}=Math,lt=(e,t=0,r=1)=>on(an(t,e),r),ee=e=>{e._clipped=!1,e._unclipped=e.slice(0);for(let t=0;t<=3;t++)t<3?((e[t]<0||e[t]>255)&&(e._clipped=!0),e[t]=lt(e[t],0,255)):t===3&&(e[t]=lt(e[t],0,1));return e},Ie={};for(let e of["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"])Ie[`[object ${e}]`]=e.toLowerCase();function x(e){return Ie[Object.prototype.toString.call(e)]||"object"}const A=(e,t=null)=>e.length>=3?Array.prototype.slice.call(e):x(e[0])=="object"&&t?t.split("").filter(r=>e[0][r]!==void 0).map(r=>e[0][r]):e[0].slice(0),dt=e=>{if(e.length<2)return null;const t=e.length-1;return x(e[t])=="string"?e[t].toLowerCase():null},{PI:jt,min:Ve,max:qe}=Math,G=e=>Math.round(e*100)/100,re=e=>Math.round(e*100)/100,K=jt*2,ne=jt/3,cn=jt/180,ln=180/jt;function Ze(e){return[...e.slice(0,3).reverse(),...e.slice(3)]}const w={format:{},autodetect:[]};class d{constructor(...t){const r=this;if(x(t[0])==="object"&&t[0].constructor&&t[0].constructor===this.constructor)return t[0];let n=dt(t),s=!1;if(!n){s=!0,w.sorted||(w.autodetect=w.autodetect.sort((o,a)=>a.p-o.p),w.sorted=!0);for(let o of w.autodetect)if(n=o.test(...t),n)break}if(w.format[n]){const o=w.format[n].apply(null,s?t:t.slice(0,-1));r._rgb=ee(o)}else throw new Error("unknown format: "+t);r._rgb.length===3&&r._rgb.push(1)}toString(){return x(this.hex)=="function"?this.hex():`[${this._rgb.join(",")}]`}}const fn="3.1.2",E=(...e)=>new d(...e);E.version=fn;const bt={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",laserlemon:"#ffff54",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrod:"#fafad2",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",maroon2:"#7f0000",maroon3:"#b03060",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",purple2:"#7f007f",purple3:"#a020f0",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},hn=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,un=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,We=e=>{if(e.match(hn)){(e.length===4||e.length===7)&&(e=e.substr(1)),e.length===3&&(e=e.split(""),e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]);const t=parseInt(e,16),r=t>>16,n=t>>8&255,s=t&255;return[r,n,s,1]}if(e.match(un)){(e.length===5||e.length===9)&&(e=e.substr(1)),e.length===4&&(e=e.split(""),e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]);const t=parseInt(e,16),r=t>>24&255,n=t>>16&255,s=t>>8&255,o=Math.round((t&255)/255*100)/100;return[r,n,s,o]}throw new Error(`unknown hex color: ${e}`)},{round:Ut}=Math,Ke=(...e)=>{let[t,r,n,s]=A(e,"rgba"),o=dt(e)||"auto";s===void 0&&(s=1),o==="auto"&&(o=s<1?"rgba":"rgb"),t=Ut(t),r=Ut(r),n=Ut(n);let i="000000"+(t<<16|r<<8|n).toString(16);i=i.substr(i.length-6);let c="0"+Ut(s*255).toString(16);switch(c=c.substr(c.length-2),o.toLowerCase()){case"rgba":return`#${i}${c}`;case"argb":return`#${c}${i}`;default:return`#${i}`}};d.prototype.name=function(){const e=Ke(this._rgb,"rgb");for(let t of Object.keys(bt))if(bt[t]===e)return t.toLowerCase();return e},w.format.named=e=>{if(e=e.toLowerCase(),bt[e])return We(bt[e]);throw new Error("unknown color name: "+e)},w.autodetect.push({p:5,test:(e,...t)=>{if(!t.length&&x(e)==="string"&&bt[e.toLowerCase()])return"named"}}),d.prototype.alpha=function(e,t=!1){return e!==void 0&&x(e)==="number"?t?(this._rgb[3]=e,this):new d([this._rgb[0],this._rgb[1],this._rgb[2],e],"rgb"):this._rgb[3]},d.prototype.clipped=function(){return this._rgb._clipped||!1};const q={Kn:18,labWhitePoint:"d65",Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452,kE:216/24389,kKE:8,kK:24389/27,RefWhiteRGB:{X:.95047,Y:1,Z:1.08883},MtxRGB2XYZ:{m00:.4124564390896922,m01:.21267285140562253,m02:.0193338955823293,m10:.357576077643909,m11:.715152155287818,m12:.11919202588130297,m20:.18043748326639894,m21:.07217499330655958,m22:.9503040785363679},MtxXYZ2RGB:{m00:3.2404541621141045,m01:-.9692660305051868,m02:.055643430959114726,m10:-1.5371385127977166,m11:1.8760108454466942,m12:-.2040259135167538,m20:-.498531409556016,m21:.041556017530349834,m22:1.0572251882231791},As:.9414285350000001,Bs:1.040417467,Cs:1.089532651,MtxAdaptMa:{m00:.8951,m01:-.7502,m02:.0389,m10:.2664,m11:1.7135,m12:-.0685,m20:-.1614,m21:.0367,m22:1.0296},MtxAdaptMaI:{m00:.9869929054667123,m01:.43230526972339456,m02:-.008528664575177328,m10:-.14705425642099013,m11:.5183602715367776,m12:.04004282165408487,m20:.15996265166373125,m21:.0492912282128556,m22:.9684866957875502}},dn=new Map([["a",[1.0985,.35585]],["b",[1.0985,.35585]],["c",[.98074,1.18232]],["d50",[.96422,.82521]],["d55",[.95682,.92149]],["d65",[.95047,1.08883]],["e",[1,1,1]],["f2",[.99186,.67393]],["f7",[.95041,1.08747]],["f11",[1.00962,.6435]],["icc",[.96422,.82521]]]);function F(e){const t=dn.get(String(e).toLowerCase());if(!t)throw new Error("unknown Lab illuminant "+e);q.labWhitePoint=e,q.Xn=t[0],q.Zn=t[1]}function Rt(){return q.labWhitePoint}const se=(...e)=>{e=A(e,"lab");const[t,r,n]=e,[s,o,a]=bn(t,r,n),[i,c,l]=Fe(s,o,a);return[i,c,l,e.length>3?e[3]:1]},bn=(e,t,r)=>{const{kE:n,kK:s,kKE:o,Xn:a,Yn:i,Zn:c}=q,l=(e+16)/116,h=.002*t+l,u=l-.005*r,b=h*h*h,m=u*u*u,v=b>n?b:(116*h-16)/s,P=e>o?Math.pow((e+16)/116,3):e/s,g=m>n?m:(116*u-16)/s,y=v*a,z=P*i,O=g*c;return[y,z,O]},oe=e=>{const t=Math.sign(e);return e=Math.abs(e),(e<=.0031308?e*12.92:1.055*Math.pow(e,1/2.4)-.055)*t},Fe=(e,t,r)=>{const{MtxAdaptMa:n,MtxAdaptMaI:s,MtxXYZ2RGB:o,RefWhiteRGB:a,Xn:i,Yn:c,Zn:l}=q,h=i*n.m00+c*n.m10+l*n.m20,u=i*n.m01+c*n.m11+l*n.m21,b=i*n.m02+c*n.m12+l*n.m22,m=a.X*n.m00+a.Y*n.m10+a.Z*n.m20,v=a.X*n.m01+a.Y*n.m11+a.Z*n.m21,P=a.X*n.m02+a.Y*n.m12+a.Z*n.m22,g=(e*n.m00+t*n.m10+r*n.m20)*(m/h),y=(e*n.m01+t*n.m11+r*n.m21)*(v/u),z=(e*n.m02+t*n.m12+r*n.m22)*(P/b),O=g*s.m00+y*s.m10+z*s.m20,L=g*s.m01+y*s.m11+z*s.m21,k=g*s.m02+y*s.m12+z*s.m22,M=oe(O*o.m00+L*o.m10+k*o.m20),f=oe(O*o.m01+L*o.m11+k*o.m21),p=oe(O*o.m02+L*o.m12+k*o.m22);return[M*255,f*255,p*255]},ae=(...e)=>{const[t,r,n,...s]=A(e,"rgb"),[o,a,i]=Je(t,r,n),[c,l,h]=pn(o,a,i);return[c,l,h,...s.length>0&&s[0]<1?[s[0]]:[]]};function pn(e,t,r){const{Xn:n,Yn:s,Zn:o,kE:a,kK:i}=q,c=e/n,l=t/s,h=r/o,u=c>a?Math.pow(c,1/3):(i*c+16)/116,b=l>a?Math.pow(l,1/3):(i*l+16)/116,m=h>a?Math.pow(h,1/3):(i*h+16)/116;return[116*b-16,500*(u-b),200*(b-m)]}function ie(e){const t=Math.sign(e);return e=Math.abs(e),(e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4))*t}const Je=(e,t,r)=>{e=ie(e/255),t=ie(t/255),r=ie(r/255);const{MtxRGB2XYZ:n,MtxAdaptMa:s,MtxAdaptMaI:o,Xn:a,Yn:i,Zn:c,As:l,Bs:h,Cs:u}=q;let b=e*n.m00+t*n.m10+r*n.m20,m=e*n.m01+t*n.m11+r*n.m21,v=e*n.m02+t*n.m12+r*n.m22;const P=a*s.m00+i*s.m10+c*s.m20,g=a*s.m01+i*s.m11+c*s.m21,y=a*s.m02+i*s.m12+c*s.m22;let z=b*s.m00+m*s.m10+v*s.m20,O=b*s.m01+m*s.m11+v*s.m21,L=b*s.m02+m*s.m12+v*s.m22;return z*=P/l,O*=g/h,L*=y/u,b=z*o.m00+O*o.m10+L*o.m20,m=z*o.m01+O*o.m11+L*o.m21,v=z*o.m02+O*o.m12+L*o.m22,[b,m,v]};d.prototype.lab=function(){return ae(this._rgb)},Object.assign(E,{lab:(...e)=>new d(...e,"lab"),getLabWhitePoint:Rt,setLabWhitePoint:F}),w.format.lab=se,w.autodetect.push({p:2,test:(...e)=>{if(e=A(e,"lab"),x(e)==="array"&&e.length===3)return"lab"}}),d.prototype.darken=function(e=1){const t=this,r=t.lab();return r[0]-=q.Kn*e,new d(r,"lab").alpha(t.alpha(),!0)},d.prototype.brighten=function(e=1){return this.darken(-e)},d.prototype.darker=d.prototype.darken,d.prototype.brighter=d.prototype.brighten,d.prototype.get=function(e){const[t,r]=e.split("."),n=this[t]();if(r){const s=t.indexOf(r)-(t.substr(0,2)==="ok"?2:0);if(s>-1)return n[s];throw new Error(`unknown channel ${r} in mode ${t}`)}else return n};const{pow:mn}=Math,gn=1e-7,yn=20;d.prototype.luminance=function(e,t="rgb"){if(e!==void 0&&x(e)==="number"){if(e===0)return new d([0,0,0,this._rgb[3]],"rgb");if(e===1)return new d([255,255,255,this._rgb[3]],"rgb");let r=this.luminance(),n=yn;const s=(a,i)=>{const c=a.interpolate(i,.5,t),l=c.luminance();return Math.abs(e-l)e?s(a,c):s(c,i)},o=(r>e?s(new d([0,0,0]),this):s(this,new d([255,255,255]))).rgb();return new d([...o,this._rgb[3]])}return vn(...this._rgb.slice(0,3))};const vn=(e,t,r)=>(e=ce(e),t=ce(t),r=ce(r),.2126*e+.7152*t+.0722*r),ce=e=>(e/=255,e<=.03928?e/12.92:mn((e+.055)/1.055,2.4)),B={},pt=(e,t,r=.5,...n)=>{let s=n[0]||"lrgb";if(!B[s]&&!n.length&&(s=Object.keys(B)[0]),!B[s])throw new Error(`interpolation mode ${s} is not defined`);return x(e)!=="object"&&(e=new d(e)),x(t)!=="object"&&(t=new d(t)),B[s](e,t,r).alpha(e.alpha()+r*(t.alpha()-e.alpha()))};d.prototype.mix=d.prototype.interpolate=function(e,t=.5,...r){return pt(this,e,t,...r)},d.prototype.premultiply=function(e=!1){const t=this._rgb,r=t[3];return e?(this._rgb=[t[0]*r,t[1]*r,t[2]*r,r],this):new d([t[0]*r,t[1]*r,t[2]*r,r],"rgb")};const{sin:_n,cos:$n}=Math,Qe=(...e)=>{let[t,r,n]=A(e,"lch");return isNaN(n)&&(n=0),n=n*cn,[t,$n(n)*r,_n(n)*r]},le=(...e)=>{e=A(e,"lch");const[t,r,n]=e,[s,o,a]=Qe(t,r,n),[i,c,l]=se(s,o,a);return[i,c,l,e.length>3?e[3]:1]},wn=(...e)=>{const t=Ze(A(e,"hcl"));return le(...t)},{sqrt:An,atan2:kn,round:xn}=Math,tr=(...e)=>{const[t,r,n]=A(e,"lab"),s=An(r*r+n*n);let o=(kn(n,r)*ln+360)%360;return xn(s*1e4)===0&&(o=Number.NaN),[t,s,o]},fe=(...e)=>{const[t,r,n,...s]=A(e,"rgb"),[o,a,i]=ae(t,r,n),[c,l,h]=tr(o,a,i);return[c,l,h,...s.length>0&&s[0]<1?[s[0]]:[]]};d.prototype.lch=function(){return fe(this._rgb)},d.prototype.hcl=function(){return Ze(fe(this._rgb))},Object.assign(E,{lch:(...e)=>new d(...e,"lch"),hcl:(...e)=>new d(...e,"hcl")}),w.format.lch=le,w.format.hcl=wn,["lch","hcl"].forEach(e=>w.autodetect.push({p:2,test:(...t)=>{if(t=A(t,e),x(t)==="array"&&t.length===3)return e}})),d.prototype.saturate=function(e=1){const t=this,r=t.lch();return r[1]+=q.Kn*e,r[1]<0&&(r[1]=0),new d(r,"lch").alpha(t.alpha(),!0)},d.prototype.desaturate=function(e=1){return this.saturate(-e)},d.prototype.set=function(e,t,r=!1){const[n,s]=e.split("."),o=this[n]();if(s){const a=n.indexOf(s)-(n.substr(0,2)==="ok"?2:0);if(a>-1){if(x(t)=="string")switch(t.charAt(0)){case"+":o[a]+=+t;break;case"-":o[a]+=+t;break;case"*":o[a]*=+t.substr(1);break;case"/":o[a]/=+t.substr(1);break;default:o[a]=+t}else if(x(t)==="number")o[a]=t;else throw new Error("unsupported value for Color.set");const i=new d(o,n);return r?(this._rgb=i._rgb,this):i}throw new Error(`unknown channel ${s} in mode ${n}`)}else return o},d.prototype.tint=function(e=.5,...t){return pt(this,"white",e,...t)},d.prototype.shade=function(e=.5,...t){return pt(this,"black",e,...t)};const En=(e,t,r)=>{const n=e._rgb,s=t._rgb;return new d(n[0]+r*(s[0]-n[0]),n[1]+r*(s[1]-n[1]),n[2]+r*(s[2]-n[2]),"rgb")};B.rgb=En;const{sqrt:he,pow:mt}=Math,Mn=(e,t,r)=>{const[n,s,o]=e._rgb,[a,i,c]=t._rgb;return new d(he(mt(n,2)*(1-r)+mt(a,2)*r),he(mt(s,2)*(1-r)+mt(i,2)*r),he(mt(o,2)*(1-r)+mt(c,2)*r),"rgb")};B.lrgb=Mn;const Sn=(e,t,r)=>{const n=e.lab(),s=t.lab();return new d(n[0]+r*(s[0]-n[0]),n[1]+r*(s[1]-n[1]),n[2]+r*(s[2]-n[2]),"lab")};B.lab=Sn;const gt=(e,t,r,n)=>{let s,o;n==="hsl"?(s=e.hsl(),o=t.hsl()):n==="hsv"?(s=e.hsv(),o=t.hsv()):n==="hcg"?(s=e.hcg(),o=t.hcg()):n==="hsi"?(s=e.hsi(),o=t.hsi()):n==="lch"||n==="hcl"?(n="hcl",s=e.hcl(),o=t.hcl()):n==="oklch"&&(s=e.oklch().reverse(),o=t.oklch().reverse());let a,i,c,l,h,u;(n.substr(0,1)==="h"||n==="oklch")&&([a,c,h]=s,[i,l,u]=o);let b,m,v,P;return!isNaN(a)&&!isNaN(i)?(i>a&&i-a>180?P=i-(a+360):i180?P=i+360-a:P=i-a,m=a+r*P):isNaN(a)?isNaN(i)?m=Number.NaN:(m=i,(h==1||h==0)&&n!="hsv"&&(b=l)):(m=a,(u==1||u==0)&&n!="hsv"&&(b=c)),b===void 0&&(b=c+r*(l-c)),v=h+r*(u-h),n==="oklch"?new d([v,b,m],n):new d([m,b,v],n)},er=(e,t,r)=>gt(e,t,r,"lch");B.lch=er,B.hcl=er;const Cn=e=>{if(x(e)=="number"&&e>=0&&e<=16777215){const t=e>>16,r=e>>8&255,n=e&255;return[t,r,n,1]}throw new Error("unknown num color: "+e)},Pn=(...e)=>{const[t,r,n]=A(e,"rgb");return(t<<16)+(r<<8)+n};d.prototype.num=function(){return Pn(this._rgb)},Object.assign(E,{num:(...e)=>new d(...e,"num")}),w.format.num=Cn,w.autodetect.push({p:5,test:(...e)=>{if(e.length===1&&x(e[0])==="number"&&e[0]>=0&&e[0]<=16777215)return"num"}});const Nn=(e,t,r)=>{const n=e.num(),s=t.num();return new d(n+r*(s-n),"num")};B.num=Nn;const{floor:Rn}=Math,Ln=(...e)=>{e=A(e,"hcg");let[t,r,n]=e,s,o,a;n=n*255;const i=r*255;if(r===0)s=o=a=n;else{t===360&&(t=0),t>360&&(t-=360),t<0&&(t+=360),t/=60;const c=Rn(t),l=t-c,h=n*(1-r),u=h+i*(1-l),b=h+i*l,m=h+i;switch(c){case 0:[s,o,a]=[m,b,h];break;case 1:[s,o,a]=[u,m,h];break;case 2:[s,o,a]=[h,m,b];break;case 3:[s,o,a]=[h,u,m];break;case 4:[s,o,a]=[b,h,m];break;case 5:[s,o,a]=[m,h,u];break}}return[s,o,a,e.length>3?e[3]:1]},On=(...e)=>{const[t,r,n]=A(e,"rgb"),s=Ve(t,r,n),o=qe(t,r,n),a=o-s,i=a*100/255,c=s/(255-a)*100;let l;return a===0?l=Number.NaN:(t===o&&(l=(r-n)/a),r===o&&(l=2+(n-t)/a),n===o&&(l=4+(t-r)/a),l*=60,l<0&&(l+=360)),[l,i,c]};d.prototype.hcg=function(){return On(this._rgb)};const zn=(...e)=>new d(...e,"hcg");E.hcg=zn,w.format.hcg=Ln,w.autodetect.push({p:1,test:(...e)=>{if(e=A(e,"hcg"),x(e)==="array"&&e.length===3)return"hcg"}});const Tn=(e,t,r)=>gt(e,t,r,"hcg");B.hcg=Tn;const{cos:yt}=Math,jn=(...e)=>{e=A(e,"hsi");let[t,r,n]=e,s,o,a;return isNaN(t)&&(t=0),isNaN(r)&&(r=0),t>360&&(t-=360),t<0&&(t+=360),t/=360,t<1/3?(a=(1-r)/3,s=(1+r*yt(K*t)/yt(ne-K*t))/3,o=1-(a+s)):t<2/3?(t-=1/3,s=(1-r)/3,o=(1+r*yt(K*t)/yt(ne-K*t))/3,a=1-(s+o)):(t-=2/3,o=(1-r)/3,a=(1+r*yt(K*t)/yt(ne-K*t))/3,s=1-(o+a)),s=lt(n*s*3),o=lt(n*o*3),a=lt(n*a*3),[s*255,o*255,a*255,e.length>3?e[3]:1]},{min:Un,sqrt:Yn,acos:Hn}=Math,Bn=(...e)=>{let[t,r,n]=A(e,"rgb");t/=255,r/=255,n/=255;let s;const o=Un(t,r,n),a=(t+r+n)/3,i=a>0?1-o/a:0;return i===0?s=NaN:(s=(t-r+(t-n))/2,s/=Yn((t-r)*(t-r)+(t-n)*(r-n)),s=Hn(s),n>r&&(s=K-s),s/=K),[s*360,i,a]};d.prototype.hsi=function(){return Bn(this._rgb)};const Dn=(...e)=>new d(...e,"hsi");E.hsi=Dn,w.format.hsi=jn,w.autodetect.push({p:2,test:(...e)=>{if(e=A(e,"hsi"),x(e)==="array"&&e.length===3)return"hsi"}});const Gn=(e,t,r)=>gt(e,t,r,"hsi");B.hsi=Gn;const ue=(...e)=>{e=A(e,"hsl");const[t,r,n]=e;let s,o,a;if(r===0)s=o=a=n*255;else{const i=[0,0,0],c=[0,0,0],l=n<.5?n*(1+r):n+r-n*r,h=2*n-l,u=t/360;i[0]=u+1/3,i[1]=u,i[2]=u-1/3;for(let b=0;b<3;b++)i[b]<0&&(i[b]+=1),i[b]>1&&(i[b]-=1),6*i[b]<1?c[b]=h+(l-h)*6*i[b]:2*i[b]<1?c[b]=l:3*i[b]<2?c[b]=h+(l-h)*(2/3-i[b])*6:c[b]=h;[s,o,a]=[c[0]*255,c[1]*255,c[2]*255]}return e.length>3?[s,o,a,e[3]]:[s,o,a,1]},rr=(...e)=>{e=A(e,"rgba");let[t,r,n]=e;t/=255,r/=255,n/=255;const s=Ve(t,r,n),o=qe(t,r,n),a=(o+s)/2;let i,c;return o===s?(i=0,c=Number.NaN):i=a<.5?(o-s)/(o+s):(o-s)/(2-o-s),t==o?c=(r-n)/(o-s):r==o?c=2+(n-t)/(o-s):n==o&&(c=4+(t-r)/(o-s)),c*=60,c<0&&(c+=360),e.length>3&&e[3]!==void 0?[c,i,a,e[3]]:[c,i,a]};d.prototype.hsl=function(){return rr(this._rgb)};const Xn=(...e)=>new d(...e,"hsl");E.hsl=Xn,w.format.hsl=ue,w.autodetect.push({p:2,test:(...e)=>{if(e=A(e,"hsl"),x(e)==="array"&&e.length===3)return"hsl"}});const In=(e,t,r)=>gt(e,t,r,"hsl");B.hsl=In;const{floor:Vn}=Math,qn=(...e)=>{e=A(e,"hsv");let[t,r,n]=e,s,o,a;if(n*=255,r===0)s=o=a=n;else{t===360&&(t=0),t>360&&(t-=360),t<0&&(t+=360),t/=60;const i=Vn(t),c=t-i,l=n*(1-r),h=n*(1-r*c),u=n*(1-r*(1-c));switch(i){case 0:[s,o,a]=[n,u,l];break;case 1:[s,o,a]=[h,n,l];break;case 2:[s,o,a]=[l,n,u];break;case 3:[s,o,a]=[l,h,n];break;case 4:[s,o,a]=[u,l,n];break;case 5:[s,o,a]=[n,l,h];break}}return[s,o,a,e.length>3?e[3]:1]},{min:Zn,max:Wn}=Math,Kn=(...e)=>{e=A(e,"rgb");let[t,r,n]=e;const s=Zn(t,r,n),o=Wn(t,r,n),a=o-s;let i,c,l;return l=o/255,o===0?(i=Number.NaN,c=0):(c=a/o,t===o&&(i=(r-n)/a),r===o&&(i=2+(n-t)/a),n===o&&(i=4+(t-r)/a),i*=60,i<0&&(i+=360)),[i,c,l]};d.prototype.hsv=function(){return Kn(this._rgb)};const Fn=(...e)=>new d(...e,"hsv");E.hsv=Fn,w.format.hsv=qn,w.autodetect.push({p:2,test:(...e)=>{if(e=A(e,"hsv"),x(e)==="array"&&e.length===3)return"hsv"}});const Jn=(e,t,r)=>gt(e,t,r,"hsv");B.hsv=Jn;function Yt(e,t){let r=e.length;Array.isArray(e[0])||(e=[e]),Array.isArray(t[0])||(t=t.map(a=>[a]));let n=t[0].length,s=t[0].map((a,i)=>t.map(c=>c[i])),o=e.map(a=>s.map(i=>Array.isArray(a)?a.reduce((c,l,h)=>c+l*(i[h]||0),0):i.reduce((c,l)=>c+l*a,0)));return r===1&&(o=o[0]),n===1?o.map(a=>a[0]):o}const de=(...e)=>{e=A(e,"lab");const[t,r,n,...s]=e,[o,a,i]=Qn([t,r,n]),[c,l,h]=Fe(o,a,i);return[c,l,h,...s.length>0&&s[0]<1?[s[0]]:[]]};function Qn(e){var t=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],r=[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]],n=Yt(r,e);return Yt(t,n.map(s=>s**3))}const be=(...e)=>{const[t,r,n,...s]=A(e,"rgb"),o=Je(t,r,n);return[...ts(o),...s.length>0&&s[0]<1?[s[0]]:[]]};function ts(e){const t=[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],r=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],n=Yt(t,e);return Yt(r,n.map(s=>Math.cbrt(s)))}d.prototype.oklab=function(){return be(this._rgb)},Object.assign(E,{oklab:(...e)=>new d(...e,"oklab")}),w.format.oklab=de,w.autodetect.push({p:2,test:(...e)=>{if(e=A(e,"oklab"),x(e)==="array"&&e.length===3)return"oklab"}});const es=(e,t,r)=>{const n=e.oklab(),s=t.oklab();return new d(n[0]+r*(s[0]-n[0]),n[1]+r*(s[1]-n[1]),n[2]+r*(s[2]-n[2]),"oklab")};B.oklab=es;const rs=(e,t,r)=>gt(e,t,r,"oklch");B.oklch=rs;const{pow:pe,sqrt:me,PI:ge,cos:nr,sin:sr,atan2:ns}=Math,ss=(e,t="lrgb",r=null)=>{const n=e.length;r||(r=Array.from(new Array(n)).map(()=>1));const s=n/r.reduce(function(u,b){return u+b});if(r.forEach((u,b)=>{r[b]*=s}),e=e.map(u=>new d(u)),t==="lrgb")return os(e,r);const o=e.shift(),a=o.get(t),i=[];let c=0,l=0;for(let u=0;u{const m=u.get(t);h+=u.alpha()*r[b+1];for(let v=0;v=360;)b-=360;a[u]=b}else a[u]=a[u]/i[u];return h/=n,new d(a,t).alpha(h>.99999?1:h,!0)},os=(e,t)=>{const r=e.length,n=[0,0,0,0];for(let s=0;s.9999999&&(n[3]=1),new d(ee(n))},{pow:as}=Math;function Ht(e){let t="rgb",r=E("#ccc"),n=0,s=[0,1],o=[],a=[0,0],i=!1,c=[],l=!1,h=0,u=1,b=!1,m={},v=!0,P=1;const g=function(f){if(f=f||["#fff","#000"],f&&x(f)==="string"&&E.brewer&&E.brewer[f.toLowerCase()]&&(f=E.brewer[f.toLowerCase()]),x(f)==="array"){f.length===1&&(f=[f[0],f[0]]),f=f.slice(0);for(let p=0;p=i[$];)$++;return $-1}return 0};let z=f=>f,O=f=>f;const L=function(f,p){let $,_;if(p==null&&(p=!1),isNaN(f)||f===null)return r;p?_=f:i&&i.length>2?_=y(f)/(i.length-2):u!==h?_=(f-h)/(u-h):_=1,_=O(_),p||(_=z(_)),P!==1&&(_=as(_,P)),_=a[0]+_*(1-a[0]-a[1]),_=lt(_,0,1);const S=Math.floor(_*1e4);if(v&&m[S])$=m[S];else{if(x(c)==="array")for(let C=0;C=N&&C===o.length-1){$=c[C];break}if(_>N&&_m={};g(e);const M=function(f){const p=E(L(f));return l&&p[l]?p[l]():p};return M.classes=function(f){if(f!=null){if(x(f)==="array")i=f,s=[f[0],f[f.length-1]];else{const p=E.analyze(s);f===0?i=[p.min,p.max]:i=E.limits(p,"e",f)}return M}return i},M.domain=function(f){if(!arguments.length)return s;h=f[0],u=f[f.length-1],o=[];const p=c.length;if(f.length===p&&h!==u)for(let $ of Array.from(f))o.push(($-h)/(u-h));else{for(let $=0;$2){const $=f.map((S,C)=>C/(f.length-1)),_=f.map(S=>(S-h)/(u-h));_.every((S,C)=>$[C]===S)||(O=S=>{if(S<=0||S>=1)return S;let C=0;for(;S>=_[C+1];)C++;const N=(S-_[C])/(_[C+1]-_[C]);return $[C]+N*($[C+1]-$[C])})}}return s=[h,u],M},M.mode=function(f){return arguments.length?(t=f,k(),M):t},M.range=function(f,p){return g(f),M},M.out=function(f){return l=f,M},M.spread=function(f){return arguments.length?(n=f,M):n},M.correctLightness=function(f){return f==null&&(f=!0),b=f,k(),b?z=function(p){const $=L(0,!0).lab()[0],_=L(1,!0).lab()[0],S=$>_;let C=L(p,!0).lab()[0];const N=$+(_-$)*p;let W=C-N,Lt=0,Vt=1,qt=20;for(;Math.abs(W)>.01&&qt-- >0;)(function(){return S&&(W*=-1),W<0?(Lt=p,p+=(Vt-p)*.5):(Vt=p,p+=(Lt-p)*.5),C=L(p,!0).lab()[0],W=C-N})();return p}:z=p=>p,M},M.padding=function(f){return f!=null?(x(f)==="number"&&(f=[f,f]),a=f,M):a},M.colors=function(f,p){arguments.length<2&&(p="hex");let $=[];if(arguments.length===0)$=c.slice(0);else if(f===1)$=[M(.5)];else if(f>1){const _=s[0],S=s[1]-_;$=is(0,f).map(C=>M(_+C/(f-1)*S))}else{e=[];let _=[];if(i&&i.length>2)for(let S=1,C=i.length,N=1<=C;N?SC;N?S++:S--)_.push((i[S-1]+i[S])*.5);else _=s;$=_.map(S=>M(S))}return E[p]&&($=$.map(_=>_[p]())),$},M.cache=function(f){return f!=null?(v=f,M):v},M.gamma=function(f){return f!=null?(P=f,M):P},M.nodata=function(f){return f!=null?(r=E(f),M):r},M}function is(e,t,r){let n=[],s=eo;s?a++:a--)n.push(a);return n}const cs=function(e){let t=[1,1];for(let r=1;rnew d(o)),e.length===2)[r,n]=e.map(o=>o.lab()),t=function(o){const a=[0,1,2].map(i=>r[i]+o*(n[i]-r[i]));return new d(a,"lab")};else if(e.length===3)[r,n,s]=e.map(o=>o.lab()),t=function(o){const a=[0,1,2].map(i=>(1-o)*(1-o)*r[i]+2*(1-o)*o*n[i]+o*o*s[i]);return new d(a,"lab")};else if(e.length===4){let o;[r,n,s,o]=e.map(a=>a.lab()),t=function(a){const i=[0,1,2].map(c=>(1-a)*(1-a)*(1-a)*r[c]+3*(1-a)*(1-a)*a*n[c]+3*(1-a)*a*a*s[c]+a*a*a*o[c]);return new d(i,"lab")}}else if(e.length>=5){let o,a,i;o=e.map(c=>c.lab()),i=e.length-1,a=cs(i),t=function(c){const l=1-c,h=[0,1,2].map(u=>o.reduce((b,m,v)=>b+a[v]*l**(i-v)*c**v*m[u],0));return new d(h,"lab")}}else throw new RangeError("No point in running bezier with only one color.");return t},fs=e=>{const t=ls(e);return t.scale=()=>Ht(t),t},{round:or}=Math;d.prototype.rgb=function(e=!0){return e===!1?this._rgb.slice(0,3):this._rgb.slice(0,3).map(or)},d.prototype.rgba=function(e=!0){return this._rgb.slice(0,4).map((t,r)=>r<3?e===!1?t:or(t):t)},Object.assign(E,{rgb:(...e)=>new d(...e,"rgb")}),w.format.rgb=(...e)=>{const t=A(e,"rgba");return t[3]===void 0&&(t[3]=1),t},w.autodetect.push({p:3,test:(...e)=>{if(e=A(e,"rgba"),x(e)==="array"&&(e.length===3||e.length===4&&x(e[3])=="number"&&e[3]>=0&&e[3]<=1))return"rgb"}});const I=(e,t,r)=>{if(!I[r])throw new Error("unknown blend mode "+r);return I[r](e,t)},st=e=>(t,r)=>{const n=E(r).rgb(),s=E(t).rgb();return E.rgb(e(n,s))},ot=e=>(t,r)=>{const n=[];return n[0]=e(t[0],r[0]),n[1]=e(t[1],r[1]),n[2]=e(t[2],r[2]),n},hs=e=>e,us=(e,t)=>e*t/255,ds=(e,t)=>e>t?t:e,bs=(e,t)=>e>t?e:t,ps=(e,t)=>255*(1-(1-e/255)*(1-t/255)),ms=(e,t)=>t<128?2*e*t/255:255*(1-2*(1-e/255)*(1-t/255)),gs=(e,t)=>255*(1-(1-t/255)/(e/255)),ys=(e,t)=>e===255?255:(e=255*(t/255)/(1-e/255),e>255?255:e);I.normal=st(ot(hs)),I.multiply=st(ot(us)),I.screen=st(ot(ps)),I.overlay=st(ot(ms)),I.darken=st(ot(ds)),I.lighten=st(ot(bs)),I.dodge=st(ot(ys)),I.burn=st(ot(gs));const{pow:vs,sin:_s,cos:$s}=Math;function ws(e=300,t=-1.5,r=1,n=1,s=[0,1]){let o=0,a;x(s)==="array"?a=s[1]-s[0]:(a=0,s=[s,s]);const i=function(c){const l=K*((e+120)/360+t*c),h=vs(s[0]+a*c,n),b=(o!==0?r[0]+c*o:r)*h*(1-h)/2,m=$s(l),v=_s(l),P=h+b*(-.14861*m+1.78277*v),g=h+b*(-.29227*m-.90649*v),y=h+b*(1.97294*m);return E(ee([P*255,g*255,y*255,1]))};return i.start=function(c){return c==null?e:(e=c,i)},i.rotations=function(c){return c==null?t:(t=c,i)},i.gamma=function(c){return c==null?n:(n=c,i)},i.hue=function(c){return c==null?r:(r=c,x(r)==="array"?(o=r[1]-r[0],o===0&&(r=r[1])):o=0,i)},i.lightness=function(c){return c==null?s:(x(c)==="array"?(s=c,a=c[1]-c[0]):(s=[c,c],a=0),i)},i.scale=()=>E.scale(i),i.hue(r),i}const As="0123456789abcdef",{floor:ks,random:xs}=Math,Es=()=>{let e="#";for(let t=0;t<6;t++)e+=As.charAt(ks(xs()*16));return new d(e,"hex")},{log:ar,pow:Ms,floor:Ss,abs:Cs}=Math;function ir(e,t=null){const r={min:Number.MAX_VALUE,max:Number.MAX_VALUE*-1,sum:0,values:[],count:0};return x(e)==="object"&&(e=Object.values(e)),e.forEach(n=>{t&&x(n)==="object"&&(n=n[t]),n!=null&&!isNaN(n)&&(r.values.push(n),r.sum+=n,nr.max&&(r.max=n),r.count+=1)}),r.domain=[r.min,r.max],r.limits=(n,s)=>cr(r,n,s),r}function cr(e,t="equal",r=7){x(e)=="array"&&(e=ir(e));const{min:n,max:s}=e,o=e.values.sort((i,c)=>i-c);if(r===1)return[n,s];const a=[];if(t.substr(0,1)==="c"&&(a.push(n),a.push(s)),t.substr(0,1)==="e"){a.push(n);for(let i=1;i 0");const i=Math.LOG10E*ar(n),c=Math.LOG10E*ar(s);a.push(n);for(let l=1;l200&&(u=!1)}const v={};for(let g=0;gg-y),a.push(P[0]);for(let g=1;g{e=new d(e),t=new d(t);const r=e.luminance(),n=t.luminance();return r>n?(r+.05)/(n+.05):(n+.05)/(r+.05)};/** * @license * * The APCA contrast prediction algorithm is based of the formulas published * in the APCA-1.0.98G specification by Myndex. The specification is available at: * https://raw.githubusercontent.com/Myndex/apca-w3/master/images/APCAw3_0.1.17_APCA0.0.98G.svg * * Note that the APCA implementation is still beta, so please update to * future versions of chroma.js when they become available. * * You can read more about the APCA Readability Criterion at * https://readtech.org/ARC/ */const lr=.027,Ns=5e-4,Rs=.1,fr=1.14,Bt=.022,hr=1.414,Ls=(e,t)=>{e=new d(e),t=new d(t),e.alpha()<1&&(e=pt(t,e,e.alpha(),"rgb"));const r=ur(...e.rgb()),n=ur(...t.rgb()),s=r>=Bt?r:r+Math.pow(Bt-r,hr),o=n>=Bt?n:n+Math.pow(Bt-n,hr),a=Math.pow(o,.56)-Math.pow(s,.57),i=Math.pow(o,.65)-Math.pow(s,.62),c=Math.abs(o-s)0?c-lr:c+lr)*100};function ur(e,t,r){return .2126729*Math.pow(e/255,2.4)+.7151522*Math.pow(t/255,2.4)+.072175*Math.pow(r/255,2.4)}const{sqrt:J,pow:T,min:Os,max:zs,atan2:dr,abs:br,cos:Dt,sin:pr,exp:Ts,PI:mr}=Math;function js(e,t,r=1,n=1,s=1){var o=function(Me){return 360*Me/(2*mr)},a=function(Me){return 2*mr*Me/360};e=new d(e),t=new d(t);const[i,c,l]=Array.from(e.lab()),[h,u,b]=Array.from(t.lab()),m=(i+h)/2,v=J(T(c,2)+T(l,2)),P=J(T(u,2)+T(b,2)),g=(v+P)/2,y=.5*(1-J(T(g,7)/(T(g,7)+T(25,7)))),z=c*(1+y),O=u*(1+y),L=J(T(z,2)+T(l,2)),k=J(T(O,2)+T(b,2)),M=(L+k)/2,f=o(dr(l,z)),p=o(dr(b,O)),$=f>=0?f:f+360,_=p>=0?p:p+360,S=br($-_)>180?($+_+360)/2:($+_)/2,C=1-.17*Dt(a(S-30))+.24*Dt(a(2*S))+.32*Dt(a(3*S+6))-.2*Dt(a(4*S-63));let N=_-$;N=br(N)<=180?N:_<=$?N+360:N-360,N=2*J(L*k)*pr(a(N)/2);const W=h-i,Lt=k-L,Vt=1+.015*T(m-50,2)/J(20+T(m-50,2)),qt=1+.045*M,Tr=1+.015*M*C,co=30*Ts(-T((S-275)/25,2)),lo=-(2*J(T(M,7)/(T(M,7)+T(25,7))))*pr(2*a(co)),fo=J(T(W/(r*Vt),2)+T(Lt/(n*qt),2)+T(N/(s*Tr),2)+lo*(Lt/(n*qt))*(N/(s*Tr)));return zs(0,Os(100,fo))}function Us(e,t,r="lab"){e=new d(e),t=new d(t);const n=e.get(r),s=t.get(r);let o=0;for(let a in n){const i=(n[a]||0)-(s[a]||0);o+=i*i}return Math.sqrt(o)}const Ys=(...e)=>{try{return new d(...e),!0}catch{return!1}},Hs={cool(){return Ht([E.hsl(180,1,.9),E.hsl(250,.7,.4)])},hot(){return Ht(["#000","#f00","#ff0","#fff"]).mode("rgb")}},ye={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Viridis:["#440154","#482777","#3f4a8a","#31678e","#26838f","#1f9d8a","#6cce5a","#b6de2b","#fee825"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},gr=Object.keys(ye),yr=new Map(gr.map(e=>[e.toLowerCase(),e])),Bs=typeof Proxy=="function"?new Proxy(ye,{get(e,t){const r=t.toLowerCase();if(yr.has(r))return e[yr.get(r)]},getOwnPropertyNames(){return Object.getOwnPropertyNames(gr)}}):ye,Ds=(...e)=>{e=A(e,"cmyk");const[t,r,n,s]=e,o=e.length>4?e[4]:1;return s===1?[0,0,0,o]:[t>=1?0:255*(1-t)*(1-s),r>=1?0:255*(1-r)*(1-s),n>=1?0:255*(1-n)*(1-s),o]},{max:vr}=Math,Gs=(...e)=>{let[t,r,n]=A(e,"rgb");t=t/255,r=r/255,n=n/255;const s=1-vr(t,vr(r,n)),o=s<1?1/(1-s):0,a=(1-t-s)*o,i=(1-r-s)*o,c=(1-n-s)*o;return[a,i,c,s]};d.prototype.cmyk=function(){return Gs(this._rgb)},Object.assign(E,{cmyk:(...e)=>new d(...e,"cmyk")}),w.format.cmyk=Ds,w.autodetect.push({p:2,test:(...e)=>{if(e=A(e,"cmyk"),x(e)==="array"&&e.length===4)return"cmyk"}});const Xs=(...e)=>{const t=A(e,"hsla");let r=dt(e)||"lsa";return t[0]=G(t[0]||0)+"deg",t[1]=G(t[1]*100)+"%",t[2]=G(t[2]*100)+"%",r==="hsla"||t.length>3&&t[3]<1?(t[3]="/ "+(t.length>3?t[3]:1),r="hsla"):t.length=3,`${r.substr(0,3)}(${t.join(" ")})`},Is=(...e)=>{const t=A(e,"lab");let r=dt(e)||"lab";return t[0]=G(t[0])+"%",t[1]=G(t[1]),t[2]=G(t[2]),r==="laba"||t.length>3&&t[3]<1?t[3]="/ "+(t.length>3?t[3]:1):t.length=3,`lab(${t.join(" ")})`},Vs=(...e)=>{const t=A(e,"lch");let r=dt(e)||"lab";return t[0]=G(t[0])+"%",t[1]=G(t[1]),t[2]=isNaN(t[2])?"none":G(t[2])+"deg",r==="lcha"||t.length>3&&t[3]<1?t[3]="/ "+(t.length>3?t[3]:1):t.length=3,`lch(${t.join(" ")})`},qs=(...e)=>{const t=A(e,"lab");return t[0]=G(t[0]*100)+"%",t[1]=re(t[1]),t[2]=re(t[2]),t.length>3&&t[3]<1?t[3]="/ "+(t.length>3?t[3]:1):t.length=3,`oklab(${t.join(" ")})`},_r=(...e)=>{const[t,r,n,...s]=A(e,"rgb"),[o,a,i]=be(t,r,n),[c,l,h]=tr(o,a,i);return[c,l,h,...s.length>0&&s[0]<1?[s[0]]:[]]},Zs=(...e)=>{const t=A(e,"lch");return t[0]=G(t[0]*100)+"%",t[1]=re(t[1]),t[2]=isNaN(t[2])?"none":G(t[2])+"deg",t.length>3&&t[3]<1?t[3]="/ "+(t.length>3?t[3]:1):t.length=3,`oklch(${t.join(" ")})`},{round:ve}=Math,Ws=(...e)=>{const t=A(e,"rgba");let r=dt(e)||"rgb";if(r.substr(0,3)==="hsl")return Xs(rr(t),r);if(r.substr(0,3)==="lab"){const n=Rt();F("d50");const s=Is(ae(t),r);return F(n),s}if(r.substr(0,3)==="lch"){const n=Rt();F("d50");const s=Vs(fe(t),r);return F(n),s}return r.substr(0,5)==="oklab"?qs(be(t)):r.substr(0,5)==="oklch"?Zs(_r(t)):(t[0]=ve(t[0]),t[1]=ve(t[1]),t[2]=ve(t[2]),(r==="rgba"||t.length>3&&t[3]<1)&&(t[3]="/ "+(t.length>3?t[3]:1),r="rgba"),`${r.substr(0,3)}(${t.slice(0,r==="rgb"?3:4).join(" ")})`)},$r=(...e)=>{e=A(e,"lch");const[t,r,n,...s]=e,[o,a,i]=Qe(t,r,n),[c,l,h]=de(o,a,i);return[c,l,h,...s.length>0&&s[0]<1?[s[0]]:[]]},Q=/((?:-?\d+)|(?:-?\d+(?:\.\d+)?)%|none)/.source,V=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)%?)|none)/.source,Gt=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)%)|none)/.source,X=/\s*/.source,vt=/\s+/.source,_e=/\s*,\s*/.source,Xt=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)(?:deg)?)|none)/.source,_t=/\s*(?:\/\s*((?:[01]|[01]?\.\d+)|\d+(?:\.\d+)?%))?/.source,wr=new RegExp("^rgba?\\("+X+[Q,Q,Q].join(vt)+_t+"\\)$"),Ar=new RegExp("^rgb\\("+X+[Q,Q,Q].join(_e)+X+"\\)$"),kr=new RegExp("^rgba\\("+X+[Q,Q,Q,V].join(_e)+X+"\\)$"),xr=new RegExp("^hsla?\\("+X+[Xt,Gt,Gt].join(vt)+_t+"\\)$"),Er=new RegExp("^hsl?\\("+X+[Xt,Gt,Gt].join(_e)+X+"\\)$"),Mr=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,Sr=new RegExp("^lab\\("+X+[V,V,V].join(vt)+_t+"\\)$"),Cr=new RegExp("^lch\\("+X+[V,V,Xt].join(vt)+_t+"\\)$"),Pr=new RegExp("^oklab\\("+X+[V,V,V].join(vt)+_t+"\\)$"),Nr=new RegExp("^oklch\\("+X+[V,V,Xt].join(vt)+_t+"\\)$"),{round:Rr}=Math,$t=e=>e.map((t,r)=>r<=2?lt(Rr(t),0,255):t),j=(e,t=0,r=100,n=!1)=>(typeof e=="string"&&e.endsWith("%")&&(e=parseFloat(e.substring(0,e.length-1))/100,n?e=t+(e+1)*.5*(r-t):e=t+e*(r-t)),+e),D=(e,t)=>e==="none"?t:e,$e=e=>{if(e=e.toLowerCase().trim(),e==="transparent")return[0,0,0,0];let t;if(w.format.named)try{return w.format.named(e)}catch{}if((t=e.match(wr))||(t=e.match(Ar))){let r=t.slice(1,4);for(let s=0;s<3;s++)r[s]=+j(D(r[s],0),0,255);r=$t(r);const n=t[4]!==void 0?+j(t[4],0,1):1;return r[3]=n,r}if(t=e.match(kr)){const r=t.slice(1,5);for(let n=0;n<4;n++)r[n]=+j(r[n],0,255);return r}if((t=e.match(xr))||(t=e.match(Er))){const r=t.slice(1,4);r[0]=+D(r[0].replace("deg",""),0),r[1]=+j(D(r[1],0),0,100)*.01,r[2]=+j(D(r[2],0),0,100)*.01;const n=$t(ue(r)),s=t[4]!==void 0?+j(t[4],0,1):1;return n[3]=s,n}if(t=e.match(Mr)){const r=t.slice(1,4);r[1]*=.01,r[2]*=.01;const n=ue(r);for(let s=0;s<3;s++)n[s]=Rr(n[s]);return n[3]=+t[4],n}if(t=e.match(Sr)){const r=t.slice(1,4);r[0]=j(D(r[0],0),0,100),r[1]=j(D(r[1],0),-125,125,!0),r[2]=j(D(r[2],0),-125,125,!0);const n=Rt();F("d50");const s=$t(se(r));F(n);const o=t[4]!==void 0?+j(t[4],0,1):1;return s[3]=o,s}if(t=e.match(Cr)){const r=t.slice(1,4);r[0]=j(r[0],0,100),r[1]=j(D(r[1],0),0,150,!1),r[2]=+D(r[2].replace("deg",""),0);const n=Rt();F("d50");const s=$t(le(r));F(n);const o=t[4]!==void 0?+j(t[4],0,1):1;return s[3]=o,s}if(t=e.match(Pr)){const r=t.slice(1,4);r[0]=j(D(r[0],0),0,1),r[1]=j(D(r[1],0),-.4,.4,!0),r[2]=j(D(r[2],0),-.4,.4,!0);const n=$t(de(r)),s=t[4]!==void 0?+j(t[4],0,1):1;return n[3]=s,n}if(t=e.match(Nr)){const r=t.slice(1,4);r[0]=j(D(r[0],0),0,1),r[1]=j(D(r[1],0),0,.4,!1),r[2]=+D(r[2].replace("deg",""),0);const n=$t($r(r)),s=t[4]!==void 0?+j(t[4],0,1):1;return n[3]=s,n}};$e.test=e=>wr.test(e)||xr.test(e)||Sr.test(e)||Cr.test(e)||Pr.test(e)||Nr.test(e)||Ar.test(e)||kr.test(e)||Er.test(e)||Mr.test(e)||e==="transparent",d.prototype.css=function(e){return Ws(this._rgb,e)};const Ks=(...e)=>new d(...e,"css");E.css=Ks,w.format.css=$e,w.autodetect.push({p:5,test:(e,...t)=>{if(!t.length&&x(e)==="string"&&$e.test(e))return"css"}}),w.format.gl=(...e)=>{const t=A(e,"rgba");return t[0]*=255,t[1]*=255,t[2]*=255,t};const Fs=(...e)=>new d(...e,"gl");E.gl=Fs,d.prototype.gl=function(){const e=this._rgb;return[e[0]/255,e[1]/255,e[2]/255,e[3]]},d.prototype.hex=function(e){return Ke(this._rgb,e)};const Js=(...e)=>new d(...e,"hex");E.hex=Js,w.format.hex=We,w.autodetect.push({p:4,test:(e,...t)=>{if(!t.length&&x(e)==="string"&&[3,4,5,6,7,8,9].indexOf(e.length)>=0)return"hex"}});const{log:It}=Math,Lr=e=>{const t=e/100;let r,n,s;return t<66?(r=255,n=t<6?0:-155.25485562709179-.44596950469579133*(n=t-2)+104.49216199393888*It(n),s=t<20?0:-254.76935184120902+.8274096064007395*(s=t-10)+115.67994401066147*It(s)):(r=351.97690566805693+.114206453784165*(r=t-55)-40.25366309332127*It(r),n=325.4494125711974+.07943456536662342*(n=t-50)-28.0852963507957*It(n),s=255),[r,n,s,1]},{round:Qs}=Math,to=(...e)=>{const t=A(e,"rgb"),r=t[0],n=t[2];let s=1e3,o=4e4;const a=.4;let i;for(;o-s>a;){i=(o+s)*.5;const c=Lr(i);c[2]/c[0]>=n/r?o=i:s=i}return Qs(i)};d.prototype.temp=d.prototype.kelvin=d.prototype.temperature=function(){return to(this._rgb)};const we=(...e)=>new d(...e,"temp");Object.assign(E,{temp:we,kelvin:we,temperature:we}),w.format.temp=w.format.kelvin=w.format.temperature=Lr,d.prototype.oklch=function(){return _r(this._rgb)},Object.assign(E,{oklch:(...e)=>new d(...e,"oklch")}),w.format.oklch=$r,w.autodetect.push({p:2,test:(...e)=>{if(e=A(e,"oklch"),x(e)==="array"&&e.length===3)return"oklch"}}),Object.assign(E,{analyze:ir,average:ss,bezier:fs,blend:I,brewer:Bs,Color:d,colors:bt,contrast:Ps,contrastAPCA:Ls,cubehelix:ws,deltaE:js,distance:Us,input:w,interpolate:pt,limits:cr,mix:pt,random:Es,scale:Ht,scales:Hs,valid:Ys});const Or=42,eo=["#30123b","#4145ab","#4675ed","#39a2fc","#1bcfd4","#24eca6","#61fc6c","#a4fc3b","#d1e834","#f3c63a","#fe9b2d","#f36315","#d93806","#b11901","#7a0402"],ro=[0,.071,.143,.214,.286,.357,.429,.5,.571,.643,.714,.786,.857,.929,1],Ae=(e,t=0)=>Array.isArray(e)?e:Number.isInteger(e)?Array(e+t).fill(e+t-1).map((r,n)=>n/Math.max(r,1)):(console.warn("expected prop to be 'number[]' or 'int'",e),[]),ke=(e,t)=>((t?1-e:e)*100).toFixed(2)+"%",xe=(e,t,r=t,n=!1)=>[ke(t),e(n?1-r:r).hex()],Z=(e,t=!1)=>{if(e===""||e===!0)return!0;if(!e)return;let r=typeof e=="string"||e instanceof String?e.startsWith("[")?JSON.parse(e):e.split(","):Array.isArray(e)?[...e]:[e];return t&&(r=r==null?void 0:r.map(n=>n==""||isNaN(n)?n:+n)),r.length>1?r:r[0]},no=e=>{let{colors:t,labels:r,ticks:n,classes:s,vertical:o,reverse:a,flip:i,before:c,after:l,colorReverse:h,colorMode:u,colorGamma:b,colorCorrectLightness:m,colorPadding:v,colorClass:P,centeredEdgeLabels:g}=e;t=Z(t),r=Z(r),n=Z(n,!0),s=Z(s,!0),v=Z(v,!0),o=Z(o),a=Z(a),i=Z(i),h=Z(h),m=Z(m),r===!0&&(Array.isArray(n)?r=[...n]:Array.isArray(s)&&(r=[...s])),a^o&&(Array.isArray(n)&&(n=n.reverse().map(f=>1-f)),Array.isArray(s)&&(s=s.reverse().map(f=>1-f)));let y=null,z=null,O=null,L=null;s===!0&&(n?s=Array.isArray(n)?n:n-1:Array.isArray(r)?s=r==null?void 0:r.length:Array.isArray(t)&&(s=t==null?void 0:t.length));let k;if(t===!0?k=E.scale(eo).domain(ro):t===void 0?t=["#fff","#000"]:Array.isArray(t)||(t=E.brewer[t]||["#fff",t]),t!==!0&&a^o&&(t=[...t].reverse()),k=k||E.scale(t),u&&(k=k.mode(u)),b&&(k=k.gamma(b)),m&&(k=k.correctLightness()),v&&(k=k.padding(v)),s)switch(P){case"average":k=k.domain([0,1]);break;case"equal":Array.isArray(s)||(s=Ae(s,1)),k=k.classes([0,...s,1]);break;default:k=k.classes(s);break}if(c===""&&(c=k(o?1:0).hex()),l===""&&(l=k(o?0:1).hex()),!s||Number(s)<=1)z=Array(Or).fill(Or-1).map((f,p)=>xe(k,p/f,p/f,h));else{let f=Ae(s,1);if(Array.isArray(f)){let p=f.length-1;z=f.reduce(($,_,S,C)=>{let N=C[S+1],W=(_+N)/2;return Ske(p,o)),y=y||f,a^o&&(O=O.reverse()))}if(r!==void 0){if(r===!0)if(y){let p=y.length-(s?1:0);r=Array(p).fill(Math.max(p-1,1)).map(($,_)=>`${parseFloat((_/$).toFixed(2))}`)}else r=["0","1"];Array.isArray(r)||(r=["0",r]),a^o&&Array.isArray(r)&&(r=r.reverse());let f;switch(y&&r.length-y.length){case 0:f=p=>y[p],g=!1;break;case-1:f=p=>(y[p]+y[p+1])/2,g=!0;break;default:r.length>1?(f=p=>p/(r.length-1),g=!1):(f=()=>.5,g=!0);break}L=r.map((p,$)=>[ke(o?1-f($):f($)),p])}return{stops$:z,ticks$:O,labels$:L,before:c,after:l,vertical:o,klass:`dv-sb${c?" b":""}${l?" a":""}${i?" f":""}${o?" v":" h"}${g?" c":""}`}},so=".dv-sb{--s: var(--scalebar-size, 14);--f: var(--label-font, calc(var(--bz) * .9) monospace);--f0: var(--label-font0, var(--f));--f1: var(--label-font1, var(--f0));--sz: var(--container-size, calc(var(--s) * 2px));--bz: var(--bar-size, calc(var(--sz) / 2));--bo: var(--bar-offset);--tc: var(--tick-color, currentColor);--tc0: var(--tick-color0, var(--tc));--tc1: var(--tick-color1, var(--tc0));--tw: var(--tick-width, 2px);--tw0: var(--tick-width0, var(--tw));--tw1: var(--tick-width1, var(--tw0));--ts: var(--tick-size, var(--s));--ts0: var(--tick-size0, calc(var(--ts) * 1.7));--ts1: var(--tick-size1, var(--ts0));--to: var(--tick-offset, 0px);--to0: var(--tick-offset0, var(--to));--to1: var(--tick-offset1, var(--to0));--tb: var(--tick-blend, normal);--tb0: var(--tick-blend0, var(--tb));--tb1: var(--tick-blend1, var(--tb0));--lc: var(--label-color, currentColor);--lc0: var(--label-color0, var(--lc));--lc1: var(--label-color1, var(--lc0));--lo: var(--label-offset, var(--bz));--lo0: var(--label-offset0, var(--lo));--lo1: var(--label-offset1, var(--lo0));--li: var(--label-indent, 0px);--li0: var(--label-indent0, var(--li));--li1: var(--label-indent1, calc(var(--li0) * -1));--lb: var(--label-blend, normal);--lb0: var(--label-blend0, var(--lb));--lb1: var(--label-blend1, var(--lb0));--_: calc(var(--sz) - var(--bz));--_to: calc((var(--to)*-1) + (var(--sz) - var(--ts)*1px));--_to0: calc((var(--to0)*-1) + (var(--sz) - var(--ts0)*1px));--_to1: calc((var(--to1)*-1) + (var(--_to0)))}svg{display:block;overflow:visible;width:100%;height:var(--sz)}svg rect{width:100%;height:var(--bz);transform:translateY(var(--bo))}svg rect.b{transform:translate(calc(var(--bz)*-1))}svg.f rect{transform:translateY(var(--bo, var(--_)))}svg.v{width:var(--sz);height:100%}svg.v rect{width:var(--bz);height:100%;transform:translate(var(--bo))}svg.v rect.b{transform:translateY(calc(var(--bz)*-1))}svg.f.v rect{transform:translate(var(--bo, var(--_)))}svg rect.b,svg rect.a{height:var(--bz);width:var(--bz)}svg use{stroke:var(--tc);stroke-width:var(--tw);mix-blend-mode:var(--tb);transform:translateY(var(--to)) scaleY(var(--ts))}svg use:first-of-type{stroke:var(--tc0);stroke-width:var(--tw0);mix-blend-mode:var(--tb0)}svg use:last-of-type{stroke:var(--tc1);stroke-width:var(--tw1);mix-blend-mode:var(--tb1)}svg use:last-of-type{transform:translateY(var(--to1)) scaleY(var(--ts1))}svg use:first-of-type{transform:translateY(var(--to0)) scaleY(var(--ts0))}svg.f use{transform:translateY(var(--_to)) scaleY(var(--ts))}svg.f use:last-of-type{transform:translateY(var(--_to1)) scaleY(var(--ts1))}svg.f use:first-of-type{transform:translateY(var(--_to0)) scaleY(var(--ts0))}svg.v use{transform:translate(var(--to)) scaleX(var(--ts))}svg.v use:last-of-type{transform:translate(var(--to1)) scaleX(var(--ts1))}svg.v use:first-of-type{transform:translate(var(--to0)) scaleX(var(--ts0))}svg.v.f use{transform:translate(var(--_to)) scaleX(var(--ts))}svg.v.f use:last-of-type{transform:translate(var(--_to1)) scaleX(var(--ts1))}svg.v.f use:first-of-type{transform:translate(var(--_to0)) scaleX(var(--ts0))}svg text{font:var(--f);fill:var(--lc);mix-blend-mode:var(--lb)}svg text:last-of-type{font:var(--f1);fill:var(--lc1);mix-blend-mode:var(--lb1)}svg text:first-of-type{font:var(--f0);fill:var(--lc0);mix-blend-mode:var(--lb0)}svg.h text{text-anchor:middle;dominant-baseline:text-before-edge;transform:translate(var(--li),var(--lo))}svg.h text:last-of-type{transform:translate(calc(var(--li1) - .3em),var(--lo1))}svg.h text:first-of-type{transform:translate(calc(var(--li0) + .3em),var(--lo0))}svg.h:not(.c) text:last-of-type{text-anchor:end}svg.h:not(.c) text:first-of-type{text-anchor:start}svg.h.f text{dominant-baseline:text-after-edge}svg.v text{text-anchor:start;dominant-baseline:central;transform:translate(calc(var(--lo) + .3em),var(--li))}svg.v text:last-of-type{transform:translate(calc(var(--lo) + .3em),calc(-1*var(--li1)))}svg.v text:first-of-type{transform:translate(calc(var(--lo) + .3em),calc(-1*var(--li0)))}svg.v:not(.c) text:last-of-type{dominant-baseline:text-before-edge}svg.v:not(.c) text:first-of-type{dominant-baseline:text-after-edge}svg.v:not(.c).f text:last-of-type{transform:translate(calc(var(--lo) - .3em),calc(-1*var(--li1)))}svg.v:not(.c).f text:first-of-type{transform:translate(calc(var(--lo) - .3em),calc(-1*var(--li0)))}svg.v.f text{text-anchor:end;transform:translate(calc(var(--lo) - .3em),var(--li))}";var oo=Object.defineProperty,ao=Object.getOwnPropertyDescriptor,Y=(e,t,r,n)=>{for(var s=n>1?void 0:n?ao(t,r):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(s=(n?a(t,r,s):a(s))||s);return n&&s&&oo(t,r,s),s};const Ee={attribute:!0,reflect:!0},wt={type:Boolean,...Ee},tt={type:String,...Ee},io={type:Number,...Ee};R.DVscalebar=class extends Nt{render(){let{stops$:t,ticks$:r,labels$:n,before:s,after:o,vertical:a,klass:i}=no(this),c=a?1:0,l=a?0:1,h=a?"translate(-1,1) rotate(-90)":"",u=a?"100%":0,b=a?0:"100%",m=t==null?void 0:t.map(g=>St``),v=r==null?void 0:r.map(g=>St``),P=n==null?void 0:n.map(g=>St`${g[1]}`);return Zr` ${m} ${s?St``:null} ${o?St``:null} ${v} ${P} `}},R.DVscalebar.styles=Pe(` :host { display: block; } :host([hidden]) { display: none; } ${so}`),Y([H(tt)],R.DVscalebar.prototype,"colors",2),Y([H(tt)],R.DVscalebar.prototype,"labels",2),Y([H(tt)],R.DVscalebar.prototype,"ticks",2),Y([H(tt)],R.DVscalebar.prototype,"classes",2),Y([H(wt)],R.DVscalebar.prototype,"vertical",2),Y([H(wt)],R.DVscalebar.prototype,"reverse",2),Y([H(wt)],R.DVscalebar.prototype,"flip",2),Y([H(tt)],R.DVscalebar.prototype,"before",2),Y([H(tt)],R.DVscalebar.prototype,"after",2),Y([H(wt)],R.DVscalebar.prototype,"colorReverse",2),Y([H(tt)],R.DVscalebar.prototype,"colorMode",2),Y([H(io)],R.DVscalebar.prototype,"colorGamma",2),Y([H(wt)],R.DVscalebar.prototype,"colorCorrectLightness",2),Y([H(tt)],R.DVscalebar.prototype,"colorPadding",2),Y([H(tt)],R.DVscalebar.prototype,"colorClass",2),Y([H(wt)],R.DVscalebar.prototype,"centeredEdgeLabels",2),R.DVscalebar=Y([rn("dv-scalebar")],R.DVscalebar),Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})});