xel
Version:
Widget toolkit for building native-like Web, Electron and Hybrid apps
1 lines • 464 kB
JavaScript
if(!1===Object.hasOwn(MouseEvent.prototype,"pointerType")&&Object.defineProperty(MouseEvent.prototype,"pointerType",{get(){return this.sourceCapabilities.firesTouchEvents?"touch":"mouse"}}),Element.prototype.setPointerCapture){let t=Element.prototype.setPointerCapture;Element.prototype.setPointerCapture=function(e){if(t.call(this,e),!1!==this.hasPointerCapture(e)){{let t,i,s,n=!1,a=!1,r=()=>{this.removeEventListener("pointerup",t),this.removeEventListener("pointercancel",i),this.removeEventListener("lostpointercapture",s)};this.addEventListener("pointerup",t=t=>{t.pointerId===e&&(n=!0,r())}),this.addEventListener("pointercancel",i=t=>{t.pointerId===e&&(a=!0,r())}),this.addEventListener("lostpointercapture",s=t=>{if(t.pointerId===e&&(r(),!1===n&&!1===a)){let i=new PointerEvent("pointercancel",{pointerId:e,isPrimary:t.isPrimary});this.dispatchEvent(i)}})}{let t,i,s=`* {cursor: ${getComputedStyle(this).cursor} !important; user-select: none !important; -webkit-user-select: none !important;}`,n=[];for(let t=this.parentNode||this.host;t&&t!==document;t=t.parentNode||t.host)if(t.nodeType===document.DOCUMENT_FRAGMENT_NODE){let e=document.createElementNS(t.host.namespaceURI,"style");e.textContent=s,t.append(e),n.push(e)}else if(t.nodeType===document.DOCUMENT_NODE){let e=document.createElement("style");e.textContent=s,t.head.append(e),n.push(e)}this.addEventListener("lostpointercapture",t=s=>{if(s.pointerId===e){this.removeEventListener("lostpointercapture",t),window.removeEventListener("pointerup",i,!0);for(let t of n)t.remove()}}),window.addEventListener("pointerup",i=s=>{if(s.pointerId===e){this.removeEventListener("lostpointercapture",t),window.removeEventListener("pointerup",i,!0);for(let t of n)t.remove()}},!0)}}}}Object.defineProperty(Animation.prototype,"finished",{get(){return new Promise((t=>{"finished"===this.playState?t():this.addEventListener("finish",(()=>t()),{once:!0})}))}}),window.requestIdleCallback||(window.requestIdleCallback=(t,e={})=>{let i=e.timeout||1,s=performance.now();return setTimeout((()=>{t({get didTimeout(){return!e.timeout&&performance.now()-s-1>i},timeRemaining:()=>Math.max(0,performance.now()-s+1)})}),1)}),Node.prototype.append||(Node.prototype.append=function(t){this.appendChild(t)}),Node.prototype.prepend||(Node.prototype.prepend=function(t){this.insertBefore(t,this.firstElementChild)}),Node.prototype.before||(Node.prototype.before=function(t){this.parentElement.insertBefore(t,this)}),Node.prototype.after||(Node.prototype.after=function(t){this.parentElement.insertBefore(t,this.nextElementSibling)}),Node.prototype.closest||(Node.prototype.closest=function(t){return this.parentNode?this.parentNode.closest(t):null}),Node.prototype.replaceWith||(Node.prototype.replaceWith=function(t){this.parentNode.replaceChild(t,this)});let t=(t,e=null)=>{let i=t.split(":"),s=null;if(1===i.length){let[t]=i;s=null===e?document.createElement(t):document.createElement(t,e)}else if(2===i.length){let[t,e]=i;"svg"===t&&(s=document.createElementNS("http://www.w3.org/2000/svg",e))}return s},e=(t,e)=>{let i=e.getBoundingClientRect();return t.clientX>=i.x&&t.clientX<=i.x+i.width&&t.clientY>=i.y&&t.clientY<=i.y+i.height},i=(t,e,s=!0)=>{let n=t.closest(e);return s&&!n&&t.getRootNode().host?i(t.getRootNode().host,e):n},s=t=>{let e=t=>t&&t!==document.body?(t=>{let e=getComputedStyle(t,null);return/(auto|scroll)/.test(e.getPropertyValue("overflow")+e.getPropertyValue("overflow-y")+e.getPropertyValue("overflow-x"))})(t)&&"x-texteditor"!==t.localName?t:e(t.parentElement||t.parentNode.host):document.body;return e(t.parentElement||t.parentNode.host)},n=t=>{let e=null,i=[],s=t;for(;s&&""!==s.href.baseVal;){null===e&&(e=t.ownerSVGElement);let n=e.querySelector(s.href.baseVal);if(!n||"linearGradient"!==n.localName&&"radialGradient"!==n.localName||n===t||!1!==i.includes(n))break;i.push(n),s=n}return i},a=HTMLDialogElement.prototype.showModal,r=HTMLDialogElement.prototype.close,o=[],l={get open(){return this.hasAttribute("open")},showModal(){return new Promise((async t=>{if(!0!==this.open&&!1!==this.isConnected){this.o&&await this.o.finished,this.p&&await this.p.finished,a.apply(this);{let t,e={html:document.documentElement.style.overflow,body:document.body.style.overflow};document.documentElement.style.overflow="hidden",document.body.style.overflow="hidden",o.push(this),this.addEventListener("close",t=i=>{i.target===this&&(this.removeEventListener("close",t),o=o.filter((t=>t!==this)),0===o.length&&(document.documentElement.style.overflow=e.html,document.body.style.overflow=e.body))})}{let t=this.querySelector("[autofocus]");t?t.focus():this.focus()}if(!1===this.hasAttribute("hidden")){let t=getComputedStyle(this),e=1e3*Number.parseFloat(t.getPropertyValue("transition-duration")||"0s"),i=t.getPropertyValue("transition-timing-function"),s=t.getPropertyValue("--transition-type")||"stretch";this.o=this.animate({transform:"grow"===s?["scale(0.9)","scale(1)"]:["scaleY(0)","scaleY(1)"],opacity:["0","1"]},{duration:e,easing:i})}{let t,e,i;this.addEventListener("keydown",t=t=>{"Escape"===t.code&&t.preventDefault()}),document.addEventListener("keydown",e=t=>{"Escape"===t.code&&t.target===document.body&&t.preventDefault()}),this.addEventListener("close",i=s=>{s.target===this&&(this.removeEventListener("close",i),this.removeEventListener("keydown",t),document.removeEventListener("keydown",e))})}{let t,i,s,n=!0;this.addEventListener("pointerdown",t=t=>{n=!1===e(t,this)}),this.addEventListener("click",i=t=>{t.target===this&&!0===t.isTrusted&&!1===t.defaultPrevented&&!0===n&&!1===e(t,this)&&!0===this.hasAttribute("open")&&(this.close(),this.dispatchEvent(new CustomEvent("userclose")))}),this.addEventListener("close",s=e=>{e.target===this&&(this.removeEventListener("pointerdown",t),this.removeEventListener("click",i),this.removeEventListener("close",s))})}this.o&&(await this.o.finished,this.o=null),t()}else t()}))},close(t){return new Promise((async e=>{if(this.o&&await this.o.finished,this.p&&await this.p.finished,!1===this.hasAttribute("hidden")){let t=getComputedStyle(this),e=1e3*Number.parseFloat(t.getPropertyValue("transition-duration")||"0s"),i=t.getPropertyValue("transition-timing-function")||"ease",s=t.getPropertyValue("--transition-type")||"stretch";this.p=this.animate({transform:"grow"===s?["scale(1)","scale(0.9)"]:["scaleY(1)","scaleY(0)"],opacity:["1","0"]},{duration:e,easing:i})}this.p&&(await this.p.finished,this.p=null),this.hasAttribute("open")&&r.apply(this,[t]),e()}))}};for(let[t,e]of Object.entries(Object.getOwnPropertyDescriptors(l)))Object.defineProperty(HTMLDialogElement.prototype,t,e);const{entries:h,setPrototypeOf:d,isFrozen:c,getPrototypeOf:u,getOwnPropertyDescriptor:p}=Object;let{freeze:m,seal:b,create:g}=Object,{apply:f,construct:x}="undefined"!=typeof Reflect&&Reflect;m||(m=function(t){return t}),b||(b=function(t){return t}),f||(f=function(t,e){for(var i=arguments.length,s=new Array(i>2?i-2:0),n=2;n<i;n++)s[n-2]=arguments[n];return t.apply(e,s)}),x||(x=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];return new t(...i)});const w=D(Array.prototype.forEach),v=D(Array.prototype.lastIndexOf),y=D(Array.prototype.pop),k=D(Array.prototype.push),C=D(Array.prototype.splice),z=D(String.prototype.toLowerCase),E=D(String.prototype.toString),$=D(String.prototype.match),S=D(String.prototype.replace),M=D(String.prototype.indexOf),L=D(String.prototype.trim),A=D(Object.prototype.hasOwnProperty),P=D(RegExp.prototype.test),T=(R=TypeError,function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return x(R,e)});var R;function D(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var i=arguments.length,s=new Array(i>1?i-1:0),n=1;n<i;n++)s[n-1]=arguments[n];return f(t,e,s)}}function B(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:z;d&&d(t,null);let s=e.length;for(;s--;){let n=e[s];if("string"==typeof n){const t=i(n);t!==n&&(c(e)||(e[s]=t),n=t)}t[n]=!0}return t}function O(t){for(let e=0;e<t.length;e++){A(t,e)||(t[e]=null)}return t}function H(t){const e=g(null);for(const[i,s]of h(t)){A(t,i)&&(Array.isArray(s)?e[i]=O(s):s&&"object"==typeof s&&s.constructor===Object?e[i]=H(s):e[i]=s)}return e}function N(t,e){for(;null!==t;){const i=p(t,e);if(i){if(i.get)return D(i.get);if("function"==typeof i.value)return D(i.value)}t=u(t)}return function(){return null}}const I=m(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),j=m(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),G=m(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),F=m(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),X=m(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),_=m(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Z=m(["#text"]),U=m(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Y=m(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),V=m(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),W=m(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),q=b(/\{\{[\w\W]*|[\w\W]*\}\}/gm),K=b(/<%[\w\W]*|[\w\W]*%>/gm),J=b(/\$\{[\w\W]*/gm),Q=b(/^data-[\-\w.\u00B7-\uFFFF]+$/),tt=b(/^aria-[\-\w]+$/),et=b(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),it=b(/^(?:\w+script|data):/i),st=b(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),nt=b(/^html$/i),at=b(/^[a-z][.\w]*(-[.\w]+)+$/i);var rt=Object.freeze({__proto__:null,ARIA_ATTR:tt,ATTR_WHITESPACE:st,CUSTOM_ELEMENT:at,DATA_ATTR:Q,DOCTYPE_NAME:nt,ERB_EXPR:K,IS_ALLOWED_URI:et,IS_SCRIPT_OR_DATA:it,MUSTACHE_EXPR:q,TMPLIT_EXPR:J});const ot=1,lt=3,ht=7,dt=8,ct=9,ut=function(){return"undefined"==typeof window?null:window};var pt=function t(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ut();const i=e=>t(e);if(i.version="3.3.1",i.removed=[],!e||!e.document||e.document.nodeType!==ct||!e.Element)return i.isSupported=!1,i;let{document:s}=e;const n=s,a=n.currentScript,{DocumentFragment:r,HTMLTemplateElement:o,Node:l,Element:d,NodeFilter:c,NamedNodeMap:u=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:p,DOMParser:b,trustedTypes:f}=e,x=d.prototype,R=N(x,"cloneNode"),D=N(x,"remove"),O=N(x,"nextSibling"),q=N(x,"childNodes"),K=N(x,"parentNode");if("function"==typeof o){const t=s.createElement("template");t.content&&t.content.ownerDocument&&(s=t.content.ownerDocument)}let J,Q="";const{implementation:tt,createNodeIterator:it,createDocumentFragment:st,getElementsByTagName:at}=s,{importNode:pt}=n;let mt={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};i.isSupported="function"==typeof h&&"function"==typeof K&&tt&&void 0!==tt.createHTMLDocument;const{MUSTACHE_EXPR:bt,ERB_EXPR:gt,TMPLIT_EXPR:ft,DATA_ATTR:xt,ARIA_ATTR:wt,IS_SCRIPT_OR_DATA:vt,ATTR_WHITESPACE:yt,CUSTOM_ELEMENT:kt}=rt;let{IS_ALLOWED_URI:Ct}=rt,zt=null;const Et=B({},[...I,...j,...G,...X,...Z]);let $t=null;const St=B({},[...U,...Y,...V,...W]);let Mt=Object.seal(g(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Lt=null,At=null;const Pt=Object.seal(g(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Tt=!0,Rt=!0,Dt=!1,Bt=!0,Ot=!1,Ht=!0,Nt=!1,It=!1,jt=!1,Gt=!1,Ft=!1,Xt=!1,_t=!0,Zt=!1,Ut=!0,Yt=!1,Vt={},Wt=null;const qt=B({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Kt=null;const Jt=B({},["audio","video","img","source","image","track"]);let Qt=null;const te=B({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ee="http://www.w3.org/1998/Math/MathML",ie="http://www.w3.org/2000/svg",se="http://www.w3.org/1999/xhtml";let ne=se,ae=!1,re=null;const oe=B({},[ee,ie,se],E);let le=B({},["mi","mo","mn","ms","mtext"]),he=B({},["annotation-xml"]);const de=B({},["title","style","font","a","script"]);let ce=null;const ue=["application/xhtml+xml","text/html"];let pe=null,me=null;const be=s.createElement("form"),ge=function(t){return t instanceof RegExp||t instanceof Function},fe=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!me||me!==t){if(t&&"object"==typeof t||(t={}),t=H(t),ce=-1===ue.indexOf(t.PARSER_MEDIA_TYPE)?"text/html":t.PARSER_MEDIA_TYPE,pe="application/xhtml+xml"===ce?E:z,zt=A(t,"ALLOWED_TAGS")?B({},t.ALLOWED_TAGS,pe):Et,$t=A(t,"ALLOWED_ATTR")?B({},t.ALLOWED_ATTR,pe):St,re=A(t,"ALLOWED_NAMESPACES")?B({},t.ALLOWED_NAMESPACES,E):oe,Qt=A(t,"ADD_URI_SAFE_ATTR")?B(H(te),t.ADD_URI_SAFE_ATTR,pe):te,Kt=A(t,"ADD_DATA_URI_TAGS")?B(H(Jt),t.ADD_DATA_URI_TAGS,pe):Jt,Wt=A(t,"FORBID_CONTENTS")?B({},t.FORBID_CONTENTS,pe):qt,Lt=A(t,"FORBID_TAGS")?B({},t.FORBID_TAGS,pe):H({}),At=A(t,"FORBID_ATTR")?B({},t.FORBID_ATTR,pe):H({}),Vt=!!A(t,"USE_PROFILES")&&t.USE_PROFILES,Tt=!1!==t.ALLOW_ARIA_ATTR,Rt=!1!==t.ALLOW_DATA_ATTR,Dt=t.ALLOW_UNKNOWN_PROTOCOLS||!1,Bt=!1!==t.ALLOW_SELF_CLOSE_IN_ATTR,Ot=t.SAFE_FOR_TEMPLATES||!1,Ht=!1!==t.SAFE_FOR_XML,Nt=t.WHOLE_DOCUMENT||!1,Gt=t.RETURN_DOM||!1,Ft=t.RETURN_DOM_FRAGMENT||!1,Xt=t.RETURN_TRUSTED_TYPE||!1,jt=t.FORCE_BODY||!1,_t=!1!==t.SANITIZE_DOM,Zt=t.SANITIZE_NAMED_PROPS||!1,Ut=!1!==t.KEEP_CONTENT,Yt=t.IN_PLACE||!1,Ct=t.ALLOWED_URI_REGEXP||et,ne=t.NAMESPACE||se,le=t.MATHML_TEXT_INTEGRATION_POINTS||le,he=t.HTML_INTEGRATION_POINTS||he,Mt=t.CUSTOM_ELEMENT_HANDLING||{},t.CUSTOM_ELEMENT_HANDLING&&ge(t.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Mt.tagNameCheck=t.CUSTOM_ELEMENT_HANDLING.tagNameCheck),t.CUSTOM_ELEMENT_HANDLING&&ge(t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Mt.attributeNameCheck=t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),t.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Mt.allowCustomizedBuiltInElements=t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Ot&&(Rt=!1),Ft&&(Gt=!0),Vt&&(zt=B({},Z),$t=[],!0===Vt.html&&(B(zt,I),B($t,U)),!0===Vt.svg&&(B(zt,j),B($t,Y),B($t,W)),!0===Vt.svgFilters&&(B(zt,G),B($t,Y),B($t,W)),!0===Vt.mathMl&&(B(zt,X),B($t,V),B($t,W))),t.ADD_TAGS&&("function"==typeof t.ADD_TAGS?Pt.tagCheck=t.ADD_TAGS:(zt===Et&&(zt=H(zt)),B(zt,t.ADD_TAGS,pe))),t.ADD_ATTR&&("function"==typeof t.ADD_ATTR?Pt.attributeCheck=t.ADD_ATTR:($t===St&&($t=H($t)),B($t,t.ADD_ATTR,pe))),t.ADD_URI_SAFE_ATTR&&B(Qt,t.ADD_URI_SAFE_ATTR,pe),t.FORBID_CONTENTS&&(Wt===qt&&(Wt=H(Wt)),B(Wt,t.FORBID_CONTENTS,pe)),t.ADD_FORBID_CONTENTS&&(Wt===qt&&(Wt=H(Wt)),B(Wt,t.ADD_FORBID_CONTENTS,pe)),Ut&&(zt["#text"]=!0),Nt&&B(zt,["html","head","body"]),zt.table&&(B(zt,["tbody"]),delete Lt.tbody),t.TRUSTED_TYPES_POLICY){if("function"!=typeof t.TRUSTED_TYPES_POLICY.createHTML)throw T('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof t.TRUSTED_TYPES_POLICY.createScriptURL)throw T('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');J=t.TRUSTED_TYPES_POLICY,Q=J.createHTML("")}else void 0===J&&(J=function(t,e){if("object"!=typeof t||"function"!=typeof t.createPolicy)return null;let i=null;const s="data-tt-policy-suffix";e&&e.hasAttribute(s)&&(i=e.getAttribute(s));const n="dompurify"+(i?"#"+i:"");try{return t.createPolicy(n,{createHTML:t=>t,createScriptURL:t=>t})}catch(t){return console.warn("TrustedTypes policy "+n+" could not be created."),null}}(f,a)),null!==J&&"string"==typeof Q&&(Q=J.createHTML(""));m&&m(t),me=t}},xe=B({},[...j,...G,...F]),we=B({},[...X,..._]),ve=function(t){k(i.removed,{element:t});try{K(t).removeChild(t)}catch(e){D(t)}},ye=function(t,e){try{k(i.removed,{attribute:e.getAttributeNode(t),from:e})}catch(t){k(i.removed,{attribute:null,from:e})}if(e.removeAttribute(t),"is"===t)if(Gt||Ft)try{ve(e)}catch(t){}else try{e.setAttribute(t,"")}catch(t){}},ke=function(t){let e=null,i=null;if(jt)t="<remove></remove>"+t;else{const e=$(t,/^[\r\n\t ]+/);i=e&&e[0]}"application/xhtml+xml"===ce&&ne===se&&(t='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+t+"</body></html>");const n=J?J.createHTML(t):t;if(ne===se)try{e=(new b).parseFromString(n,ce)}catch(t){}if(!e||!e.documentElement){e=tt.createDocument(ne,"template",null);try{e.documentElement.innerHTML=ae?Q:n}catch(t){}}const a=e.body||e.documentElement;return t&&i&&a.insertBefore(s.createTextNode(i),a.childNodes[0]||null),ne===se?at.call(e,Nt?"html":"body")[0]:Nt?e.documentElement:a},Ce=function(t){return it.call(t.ownerDocument||t,t,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},ze=function(t){return t instanceof p&&("string"!=typeof t.nodeName||"string"!=typeof t.textContent||"function"!=typeof t.removeChild||!(t.attributes instanceof u)||"function"!=typeof t.removeAttribute||"function"!=typeof t.setAttribute||"string"!=typeof t.namespaceURI||"function"!=typeof t.insertBefore||"function"!=typeof t.hasChildNodes)},Ee=function(t){return"function"==typeof l&&t instanceof l};function $e(t,e,s){w(t,(t=>{t.call(i,e,s,me)}))}const Se=function(t){let e=null;if($e(mt.beforeSanitizeElements,t,null),ze(t))return ve(t),!0;const s=pe(t.nodeName);if($e(mt.uponSanitizeElement,t,{tagName:s,allowedTags:zt}),Ht&&t.hasChildNodes()&&!Ee(t.firstElementChild)&&P(/<[/\w!]/g,t.innerHTML)&&P(/<[/\w!]/g,t.textContent))return ve(t),!0;if(t.nodeType===ht)return ve(t),!0;if(Ht&&t.nodeType===dt&&P(/<[/\w]/g,t.data))return ve(t),!0;if(!(Pt.tagCheck instanceof Function&&Pt.tagCheck(s))&&(!zt[s]||Lt[s])){if(!Lt[s]&&Le(s)){if(Mt.tagNameCheck instanceof RegExp&&P(Mt.tagNameCheck,s))return!1;if(Mt.tagNameCheck instanceof Function&&Mt.tagNameCheck(s))return!1}if(Ut&&!Wt[s]){const e=K(t)||t.parentNode,i=q(t)||t.childNodes;if(i&&e){for(let s=i.length-1;s>=0;--s){const n=R(i[s],!0);n.k=(t.k||0)+1,e.insertBefore(n,O(t))}}}return ve(t),!0}return t instanceof d&&!function(t){let e=K(t);e&&e.tagName||(e={namespaceURI:ne,tagName:"template"});const i=z(t.tagName),s=z(e.tagName);return!!re[t.namespaceURI]&&(t.namespaceURI===ie?e.namespaceURI===se?"svg"===i:e.namespaceURI===ee?"svg"===i&&("annotation-xml"===s||le[s]):Boolean(xe[i]):t.namespaceURI===ee?e.namespaceURI===se?"math"===i:e.namespaceURI===ie?"math"===i&&he[s]:Boolean(we[i]):t.namespaceURI===se?!(e.namespaceURI===ie&&!he[s])&&!(e.namespaceURI===ee&&!le[s])&&!we[i]&&(de[i]||!xe[i]):!("application/xhtml+xml"!==ce||!re[t.namespaceURI]))}(t)?(ve(t),!0):"noscript"!==s&&"noembed"!==s&&"noframes"!==s||!P(/<\/no(script|embed|frames)/i,t.innerHTML)?(Ot&&t.nodeType===lt&&(e=t.textContent,w([bt,gt,ft],(t=>{e=S(e,t," ")})),t.textContent!==e&&(k(i.removed,{element:t.cloneNode()}),t.textContent=e)),$e(mt.afterSanitizeElements,t,null),!1):(ve(t),!0)},Me=function(t,e,i){if(_t&&("id"===e||"name"===e)&&(i in s||i in be))return!1;if(Rt&&!At[e]&&P(xt,e));else if(Tt&&P(wt,e));else if(Pt.attributeCheck instanceof Function&&Pt.attributeCheck(e,t));else if(!$t[e]||At[e]){if(!(Le(t)&&(Mt.tagNameCheck instanceof RegExp&&P(Mt.tagNameCheck,t)||Mt.tagNameCheck instanceof Function&&Mt.tagNameCheck(t))&&(Mt.attributeNameCheck instanceof RegExp&&P(Mt.attributeNameCheck,e)||Mt.attributeNameCheck instanceof Function&&Mt.attributeNameCheck(e,t))||"is"===e&&Mt.allowCustomizedBuiltInElements&&(Mt.tagNameCheck instanceof RegExp&&P(Mt.tagNameCheck,i)||Mt.tagNameCheck instanceof Function&&Mt.tagNameCheck(i))))return!1}else if(Qt[e]);else if(P(Ct,S(i,yt,"")));else if("src"!==e&&"xlink:href"!==e&&"href"!==e||"script"===t||0!==M(i,"data:")||!Kt[t]){if(Dt&&!P(vt,S(i,yt,"")));else if(i)return!1}else;return!0},Le=function(t){return"annotation-xml"!==t&&$(t,kt)},Ae=function(t){$e(mt.beforeSanitizeAttributes,t,null);const{attributes:e}=t;if(!e||ze(t))return;const s={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:$t,forceKeepAttr:void 0};let n=e.length;for(;n--;){const a=e[n],{name:r,namespaceURI:o,value:l}=a,h=pe(r),d=l;let c="value"===r?d:L(d);if(s.attrName=h,s.attrValue=c,s.keepAttr=!0,s.forceKeepAttr=void 0,$e(mt.uponSanitizeAttribute,t,s),c=s.attrValue,!Zt||"id"!==h&&"name"!==h||(ye(r,t),c="user-content-"+c),Ht&&P(/((--!?|])>)|<\/(style|title|textarea)/i,c)){ye(r,t);continue}if("attributename"===h&&$(c,"href")){ye(r,t);continue}if(s.forceKeepAttr)continue;if(!s.keepAttr){ye(r,t);continue}if(!Bt&&P(/\/>/i,c)){ye(r,t);continue}Ot&&w([bt,gt,ft],(t=>{c=S(c,t," ")}));const u=pe(t.nodeName);if(Me(u,h,c)){if(J&&"object"==typeof f&&"function"==typeof f.getAttributeType)if(o);else switch(f.getAttributeType(u,h)){case"TrustedHTML":c=J.createHTML(c);break;case"TrustedScriptURL":c=J.createScriptURL(c)}if(c!==d)try{o?t.setAttributeNS(o,r,c):t.setAttribute(r,c),ze(t)?ve(t):y(i.removed)}catch(e){ye(r,t)}}else ye(r,t)}$e(mt.afterSanitizeAttributes,t,null)},Pe=function t(e){let i=null;const s=Ce(e);for($e(mt.beforeSanitizeShadowDOM,e,null);i=s.nextNode();)$e(mt.uponSanitizeShadowNode,i,null),Se(i),Ae(i),i.content instanceof r&&t(i.content);$e(mt.afterSanitizeShadowDOM,e,null)};return i.sanitize=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=null,a=null,o=null,h=null;if(ae=!t,ae&&(t="\x3c!--\x3e"),"string"!=typeof t&&!Ee(t)){if("function"!=typeof t.toString)throw T("toString is not a function");if("string"!=typeof(t=t.toString()))throw T("dirty is not a string, aborting")}if(!i.isSupported)return t;if(It||fe(e),i.removed=[],"string"==typeof t&&(Yt=!1),Yt){if(t.nodeName){const e=pe(t.nodeName);if(!zt[e]||Lt[e])throw T("root node is forbidden and cannot be sanitized in-place")}}else if(t instanceof l)s=ke("\x3c!----\x3e"),a=s.ownerDocument.importNode(t,!0),a.nodeType===ot&&"BODY"===a.nodeName||"HTML"===a.nodeName?s=a:s.appendChild(a);else{if(!Gt&&!Ot&&!Nt&&-1===t.indexOf("<"))return J&&Xt?J.createHTML(t):t;if(s=ke(t),!s)return Gt?null:Xt?Q:""}s&&jt&&ve(s.firstChild);const d=Ce(Yt?t:s);for(;o=d.nextNode();)Se(o),Ae(o),o.content instanceof r&&Pe(o.content);if(Yt)return t;if(Gt){if(Ft)for(h=st.call(s.ownerDocument);s.firstChild;)h.appendChild(s.firstChild);else h=s;return($t.shadowroot||$t.shadowrootmode)&&(h=pt.call(n,h,!0)),h}let c=Nt?s.outerHTML:s.innerHTML;return Nt&&zt["!doctype"]&&s.ownerDocument&&s.ownerDocument.doctype&&s.ownerDocument.doctype.name&&P(nt,s.ownerDocument.doctype.name)&&(c="<!DOCTYPE "+s.ownerDocument.doctype.name+">\n"+c),Ot&&w([bt,gt,ft],(t=>{c=S(c,t," ")})),J&&Xt?J.createHTML(c):c},i.setConfig=function(){fe(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),It=!0},i.clearConfig=function(){me=null,It=!1},i.isValidAttribute=function(t,e,i){me||fe({});const s=pe(t),n=pe(e);return Me(s,n,i)},i.addHook=function(t,e){"function"==typeof e&&k(mt[t],e)},i.removeHook=function(t,e){if(void 0!==e){const i=v(mt[t],e);return-1===i?void 0:C(mt[t],i,1)[0]}return y(mt[t])},i.removeHooks=function(t){mt[t]=[]},i.removeAllHooks=function(){mt={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},i}();class mt{#t={};addEventListener(t,e){this.#t||(this.#t={});let i=this.#t[t];i||(this.#t[t]=i=[]),i.push(e),i.length>1e4&&console.warn(`Potential EventEmitter memory leak: ${i.length} listeners subscribed to event "${t}"`)}removeEventListener(t,e){if(!this.#t||!this.#t[t])return;let i=[];for(let s=0;s<this.#t[t].length;s+=1)this.#t[t][s]!==e&&i.push(this.#t[t][s]);this.#t[t]=i}dispatchEvent(t){if(!this.#t)return;let e=this.#t[t.type];if(!e)return;let i=null;for(let s=e.length-1;s>=0;s-=1){let n,a=e[s];try{n=a.call(window,t)}catch(t){null===i&&(i=t)}if(!1===n)break}if(i)throw i}}let bt=(t,e,i=!1)=>{if(t.length!==e.length)return!1;if(i)for(let i=0;i<t.length;i+=1){if(t[i]!==e[i])return!1}else{for(let i=0;i<t.length;i+=1)if(!e.includes(t[i]))return!1;for(let i=0;i<e.length;i+=1)if(!t.includes(e[i]))return!1}return!0};function gt(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function ft(t,e,i=[0,0,0]){const s=gt(t,e[0]),n=gt(t,e[1]),a=gt(t,e[2]);return i[0]=s,i[1]=n,i[2]=a,i}function xt(t){return"string"===wt(t)}function wt(t){return(Object.prototype.toString.call(t).match(/^\[object\s+(.*?)\]$/)[1]||"").toLowerCase()}function vt(t,{precision:e=16,unit:i}){return yt(t)?"none":(t=+Ct(t,e))+(i??"")}function yt(t){return null===t}function kt(t){return yt(t)?0:t}function Ct(t,e){if(0===t)return 0;let i=~~t,s=0;i&&e&&(s=1+~~Math.log10(Math.abs(i)));const n=10**(e-s);return Math.floor(t*n+.5)/n}function zt(t,e,i){return isNaN(t)?e:isNaN(e)?t:t+(e-t)*i}function Et(t,e,i){return!t||!e||t===e||t[0]===e[0]&&t[1]===e[1]||isNaN(i)||null===i?i:zt(e[0],e[1],function(t,e,i){return(i-t)/(e-t)}(t[0],t[1],i))}function $t(t,e,i){return Math.max(Math.min(i,e),t)}function St(t,e){return Math.sign(t)===Math.sign(e)?t:-t}function Mt(t,e){return St(Math.abs(t)**e,t)}function Lt(t,e){return 0===e?0:t/e}function At(t,e){if(t instanceof e)return!0;const i=e.name;for(;t;){const e=Object.getPrototypeOf(t),s=e?.constructor?.name;if(s===i)return!0;if(!s||"Object"===s)return!1;t=e}return!1}class Pt{type;coordMeta;coordRange;range;constructor(t,e){if("object"==typeof t&&(this.coordMeta=t),e&&(this.coordMeta=e,this.coordRange=e.range??e.refRange),"string"==typeof t){let e=t.trim().match(/^(?<type><[a-z]+>)(\[(?<min>-?[.\d]+),\s*(?<max>-?[.\d]+)\])?$/);if(!e)throw new TypeError(`Cannot parse ${t} as a type definition.`);this.type=e.groups.type;let{min:i,max:s}=e.groups;(i||s)&&(this.range=[+i,+s])}}get computedRange(){return this.range?this.range:"<percentage>"===this.type?this.percentageRange():"<angle>"===this.type?[0,360]:null}get unit(){return"<percentage>"===this.type?"%":"<angle>"===this.type?"deg":""}resolve(t){if("<angle>"===this.type)return t;let e=this.computedRange,i=this.coordRange;return"<percentage>"===this.type&&(i??=this.percentageRange()),Et(e,i,t)}serialize(t,e){let i="<percentage>"===this.type?this.percentageRange(100):this.computedRange,s=this.unit;return vt(t=Et(this.coordRange,i,t),{unit:s,precision:e})}toString(){let t=this.type;if(this.range){let[e="",i=""]=this.range;t+=`[${e},${i}]`}return t}percentageRange(t=1){let e;return e=this.coordMeta&&this.coordMeta.range||this.coordRange&&this.coordRange[0]>=0?[0,1]:[-1,1],[e[0]*t,e[1]*t]}static get(t,e){return At(t,this)?t:new this(t,e)}}const Tt=Symbol("instance");class Rt{type;name;spaceCoords;coords;id;alpha;constructor(t,e=t.space){t[Tt]=this,this.type="function",this.name="color",Object.assign(this,t),this.space=e,"custom"!==this.type&&(this.spaceCoords=Object.values(e.coords),this.coords||(this.coords=this.spaceCoords.map((t=>{let e=["<number>","<percentage>"];return"angle"===t.type&&e.push("<angle>"),e}))),this.coords=this.coords.map(((t,e)=>{let i=this.spaceCoords[e];return"string"==typeof t&&(t=t.trim().split(/\s*\|\s*/)),t.map((t=>Pt.get(t,i)))})))}serializeCoords(t,e,i){return i=t.map(((t,e)=>Pt.get(i?.[e]??this.coords[e][0],this.spaceCoords[e]))),t.map(((t,s)=>i[s].serialize(t,e)))}coerceCoords(t,e){return Object.entries(this.space.coords).map((([i,s],n)=>{let a=t[n];if(yt(a)||isNaN(a))return a;let r=e[n],o=this.coords[n].find((t=>t.type==r));if(!o){let t=s.name||i;throw new TypeError(`${r??a?.raw??a} not allowed for ${t} in ${this.name}()`)}return a=o.resolve(a),o.range&&(e[n]=o.toString()),a}))}canSerialize(){return"function"===this.type||this.serialize}parse(t){return null}static get(t,...e){return!t||At(t,this)?t:t[Tt]?t[Tt]:new Rt(t,...e)}}const Dt=new class{add(t,e,i){if("string"==typeof arguments[0])(Array.isArray(t)?t:[t]).forEach((function(t){this[t]=this[t]||[],e&&this[t][i?"unshift":"push"](e)}),this);else for(var t in arguments[0])this.add(t,arguments[0][t],arguments[1])}run(t,e){this[t]=this[t]||[],this[t].forEach((function(t){t.call(e&&e.context?e.context:e,e)}))}},Bt={D50:[.3457/.3585,1,.2958/.3585],D65:[.3127/.329,1,.3583/.329]};function Ot(t){return Array.isArray(t)?t:Bt[t]}function Ht(t,e,i,s={}){if(t=Ot(t),e=Ot(e),!t||!e)throw new TypeError(`Missing white point to convert ${t?"":"from"}${t||e?"":"/"}${e?"":"to"}`);if(t===e)return i;let n={W1:t,W2:e,XYZ:i,options:s};if(Dt.run("chromatic-adaptation-start",n),n.M||(n.W1===Bt.D65&&n.W2===Bt.D50?n.M=[[1.0479297925449969,.022946870601609652,-.05019226628920524],[.02962780877005599,.9904344267538799,-.017073799063418826],[-.009243040646204504,.015055191490298152,.7518742814281371]]:n.W1===Bt.D50&&n.W2===Bt.D65&&(n.M=[[.955473421488075,-.02309845494876471,.06325924320057072],[-.0283697093338637,1.0099953980813041,.021041441191917323],[.012314014864481998,-.020507649298898964,1.330365926242124]])),Dt.run("chromatic-adaptation-end",n),n.M)return ft(n.XYZ,n.M);throw new TypeError("Only Bradford CAT with white points D50 and D65 supported for now.")}var Nt={gamut_mapping:"css",precision:5,deltaE:"76",verbose:"test"!==globalThis?.process?.env?.NODE_ENV?.toLowerCase(),warn:function(t){this.verbose&&globalThis?.console?.warn?.(t)}};function It(t,e){let i,s={str:String(t)?.trim(),options:e};if(Dt.run("parse-start",s),s.color)return s.color;s.parsed=function(t){if(!t)return;t=t.trim();let e=t.match(Gt.function);if(e){let t=[],i=[],s=!1,n=e[1].toLowerCase(),a=e[2].replace(Gt.singleArgument,((e,a)=>{let{value:r,meta:o}=function(t){let e={},i=t.match(Gt.unitValue)?.[0],s=e.raw=t;i?(e.type="%"===i?"<percentage>":"<angle>",e.unit=i,e.unitless=Number(s.slice(0,-i.length)),s=e.unitless*jt[i]):Gt.number.test(s)?(s=Number(s),e.type="<number>"):"none"===s?s=null:"NaN"===s||"calc(NaN)"===s?(s=NaN,e.type="<number>"):e.type="<ident>";return{value:s,meta:e}}(a);return(e.startsWith("/")||"color"!==n&&3===t.length)&&(s=!0),t.push(r),i.push(o),""}));return{name:n,args:t,argMeta:i,lastAlpha:s,commas:a.includes(","),rawName:e[1],rawArgs:e[2]}}}(s.str);let n=s.options?s.options.parseMeta??s.options.meta:null;if(s.parsed){let e,a,r=s.parsed.name,o=s.parsed.args,l=o.map(((t,e)=>s.parsed.argMeta[e]?.type));if("color"===r){let i=o.shift();l.shift();let n=i.startsWith("--")?i.substring(2):`--${i}`,h=[i,n];if(e=Xt.findFormat({name:r,id:h,type:"function"}),!e){let e,a=i in Xt.registry?i:n;if(a in Xt.registry){let s=Xt.registry[a].formats?.color?.id;if(s){e=`Did you mean ${t.replace("color("+i,"color("+s)}?`}}throw new TypeError(`Cannot parse ${s.str}. `+(e??"Missing a plugin?"))}a=e.space,e.id.startsWith("--")&&!i.startsWith("--")&&Nt.warn(`${a.name} is a non-standard space and not currently supported in the CSS spec. Use prefixed color(${e.id}) instead of color(${i}).`),i.startsWith("--")&&!e.id.startsWith("--")&&Nt.warn(`${a.name} is a standard space and supported in the CSS spec. Use color(${e.id}) instead of prefixed color(${i}).`)}else e=Xt.findFormat({name:r,type:"function"}),a=e.space;n&&Object.assign(n,{format:e,formatId:e.name,types:l,commas:s.parsed.commas});let h=1;s.parsed.lastAlpha&&(h=s.parsed.args.pop(),n&&(n.alphaType=l.pop()));let d=e.coords.length;if(o.length!==d)throw new TypeError(`Expected ${d} coordinates for ${a.id} in ${s.str}), got ${o.length}`);o=e.coerceCoords(o,l),i={spaceId:a.id,coords:o,alpha:h}}else t:for(let t of Xt.all)for(let e in t.formats){let a=t.formats[e];if("custom"!==a.type)continue;if(a.test&&!a.test(s.str))continue;let r=t.getFormat(a),o=r.parse(s.str);if(o){n&&Object.assign(n,{format:r,formatId:e}),i=o;break t}}if(!i)throw new TypeError(`Could not parse ${t} as a color. Missing a plugin?`);return i.alpha=yt(i.alpha)?i.alpha:void 0===i.alpha?1:$t(0,i.alpha,1),i}const jt={"%":.01,deg:1,grad:.9,rad:180/Math.PI,turn:360},Gt={function:/^([a-z]+)\(((?:calc\(NaN\)|.)+?)\)$/i,number:/^([-+]?(?:[0-9]*\.)?[0-9]+(e[-+]?[0-9]+)?)$/i,unitValue:RegExp(`(${Object.keys(jt).join("|")})$`),singleArgument:/\/?\s*(none|NaN|calc\(NaN\)|[-+\w.]+(?:%|deg|g?rad|turn)?)/g};function Ft(t,e){if(Array.isArray(t))return t.map((t=>Ft(t,e)));if(!t)throw new TypeError("Empty color reference");xt(t)&&(t=It(t,e));let i=t.space||t.spaceId;return"string"==typeof i&&(t.space=Xt.get(i)),void 0===t.alpha&&(t.alpha=1),t}class Xt{constructor(t){this.id=t.id,this.name=t.name,this.base=t.base?Xt.get(t.base):null,this.aliases=t.aliases,this.base&&(this.fromBase=t.fromBase,this.toBase=t.toBase);let e=t.coords??this.base.coords;for(let t in e)"name"in e[t]||(e[t].name=t);this.coords=e;let i=t.white??this.base.white??"D65";this.white=Ot(i),this.formats=t.formats??{};for(let t in this.formats){let e=this.formats[t];e.type||="function",e.name||=t}this.formats.color?.id||(this.formats.color={...this.formats.color??{},id:t.cssId||this.id}),t.gamutSpace?this.gamutSpace="self"===t.gamutSpace?this:Xt.get(t.gamutSpace):this.isPolar?this.gamutSpace=this.base:this.gamutSpace=this,this.gamutSpace.isUnbounded&&(this.inGamut=(t,e)=>!0),this.referred=t.referred,Object.defineProperty(this,"path",{value:_t(this).reverse(),writable:!1,enumerable:!0,configurable:!0}),Dt.run("colorspace-init-end",this)}inGamut(t,{epsilon:e=75e-6}={}){if(!this.equals(this.gamutSpace))return t=this.to(this.gamutSpace,t),this.gamutSpace.inGamut(t,{epsilon:e});let i=Object.values(this.coords);return t.every(((t,s)=>{let n=i[s];if("angle"!==n.type&&n.range){if(yt(t))return!0;let[i,s]=n.range;return(void 0===i||t>=i-e)&&(void 0===s||t<=s+e)}return!0}))}get isUnbounded(){return Object.values(this.coords).every((t=>!("range"in t)))}get cssId(){return this.formats?.color?.id||this.id}get isPolar(){for(let t in this.coords)if("angle"===this.coords[t].type)return!0;return!1}getFormat(t){if(!t)return null;"default"===t?t=Object.values(this.formats)[0]:"string"==typeof t&&(t=this.formats[t]);let e=Rt.get(t,this);return e!==t&&t.name in this.formats&&(this.formats[t.name]=e),e}equals(t){return!!t&&(this===t||this.id===t||this.id===t.id)}to(t,e){if(1===arguments.length){const i=Ft(t);[t,e]=[i.space,i.coords]}if(t=Xt.get(t),this.equals(t))return e;e=e.map((t=>yt(t)?0:t));let i,s,n=this.path,a=t.path;for(let t=0;t<n.length&&n[t].equals(a[t]);t++)i=n[t],s=t;if(!i)throw new Error(`Cannot convert between color spaces ${this} and ${t}: no connection space was found`);for(let t=n.length-1;t>s;t--)e=n[t].toBase(e);for(let t=s+1;t<a.length;t++)e=a[t].fromBase(e);return e}from(t,e){if(1===arguments.length){const i=Ft(t);[t,e]=[i.space,i.coords]}return(t=Xt.get(t)).to(this,e)}toString(){return`${this.name} (${this.id})`}getMinCoords(){let t=[];for(let e in this.coords){let i=this.coords[e],s=i.range||i.refRange;t.push(s?.min??0)}return t}static registry={};static get all(){return[...new Set(Object.values(Xt.registry))]}static register(t,e){if(1===arguments.length&&(t=(e=arguments[0]).id),e=this.get(e),this.registry[t]&&this.registry[t]!==e)throw new Error(`Duplicate color space registration: '${t}'`);if(this.registry[t]=e,1===arguments.length&&e.aliases)for(let t of e.aliases)this.register(t,e);return e}static get(t,...e){if(!t||At(t,this))return t;if("string"===wt(t)){let e=Xt.registry[t.toLowerCase()];if(!e)throw new TypeError(`No color space found with id = "${t}"`);return e}if(e.length)return Xt.get(...e);throw new TypeError(`${t} is not a valid color space`)}static findFormat(t,e=Xt.all){if(!t)return null;"string"==typeof t&&(t={name:t});for(let i of e)for(let[e,s]of Object.entries(i.formats)){s.name??=e,s.type??="function";let n=!(t.name&&s.name!==t.name||t.type&&s.type!==t.type);if(t.id){let e=s.ids||[s.id],i=Array.isArray(t.id)?t.id:[t.id];n&&=i.some((t=>e.includes(t)))}if(n){let t=Rt.get(s,i);return t!==s&&(i.formats[s.name]=t),t}}return null}static resolveCoord(t,e){let i,s,n=wt(t);if("string"===n?t.includes(".")?[i,s]=t.split("."):[i,s]=[,t]:Array.isArray(t)?[i,s]=t:(i=t.space,s=t.coordId),i=Xt.get(i),i||(i=e),!i)throw new TypeError(`Cannot resolve coordinate reference ${t}: No color space specified and relative references are not allowed here`);if(n=wt(s),"number"===n||"string"===n&&s>=0){let t=Object.entries(i.coords)[s];if(t)return{space:i,id:t[0],index:s,...t[1]}}i=Xt.get(i);let a=s.toLowerCase(),r=0;for(let t in i.coords){let e=i.coords[t];if(t.toLowerCase()===a||e.name?.toLowerCase()===a)return{space:i,id:t,index:r,...e};r++}throw new TypeError(`No "${s}" coordinate found in ${i.name}. Its coordinates are: ${Object.keys(i.coords).join(", ")}`)}static DEFAULT_FORMAT={type:"functions",name:"color"}}function _t(t){let e=[t];for(let i=t;i=i.base;)e.push(i);return e}var Zt=new Xt({id:"xyz-d65",name:"XYZ D65",coords:{x:{refRange:[0,1],name:"X"},y:{refRange:[0,1],name:"Y"},z:{refRange:[0,1],name:"Z"}},white:"D65",formats:{color:{ids:["xyz-d65","xyz"]}},aliases:["xyz"]}),Ut=new Xt({id:"xyz-d50",name:"XYZ D50",white:"D50",base:Zt,fromBase:t=>Ht(Zt.white,"D50",t),toBase:t=>Ht("D50",Zt.white,t)});const Yt=216/24389,Vt=24/116,Wt=24389/27;let qt=Bt.D50;var Kt=new Xt({id:"lab",name:"Lab",coords:{l:{refRange:[0,100],name:"Lightness"},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:qt,base:Ut,fromBase(t){let e=t.map(((t,e)=>t/qt[e])).map((t=>t>Yt?Math.cbrt(t):(Wt*t+16)/116));return[116*e[1]-16,500*(e[0]-e[1]),200*(e[1]-e[2])]},toBase(t){let[e,i,s]=t,n=[];return n[1]=(e+16)/116,n[0]=i/500+n[1],n[2]=n[1]-s/200,[n[0]>Vt?Math.pow(n[0],3):(116*n[0]-16)/Wt,t[0]>8?Math.pow((t[0]+16)/116,3):t[0]/Wt,n[2]>Vt?Math.pow(n[2],3):(116*n[2]-16)/Wt].map(((t,e)=>t*qt[e]))},formats:{lab:{coords:["<percentage> | <number>","<number> | <percentage>","<number> | <percentage>"]}}});function Jt(t){return"number"!=typeof t?t:(t%360+360)%360}var Qt=new Xt({id:"lch",name:"LCH",coords:{l:{refRange:[0,100],name:"Lightness"},c:{refRange:[0,150],name:"Chroma"},h:{refRange:[0,360],type:"angle",name:"Hue"}},base:Kt,fromBase(t){if(void 0===this.ε){let t=Object.values(this.base.coords)[1].refRange,e=t[1]-t[0];this.ε=e/1e5}let[e,i,s]=t,n=Math.abs(i)<this.ε&&Math.abs(s)<this.ε,a=n?null:Jt(180*Math.atan2(s,i)/Math.PI);return[e,n?0:Math.sqrt(i**2+s**2),a]},toBase(t){let[e,i,s]=t,n=null,a=null;return yt(s)||(i=i<0?0:i,n=i*Math.cos(s*Math.PI/180),a=i*Math.sin(s*Math.PI/180)),[e,n,a]},formats:{lch:{coords:["<percentage> | <number>","<number> | <percentage>","<number> | <angle>"]}}});const te=25**7,ee=Math.PI,ie=180/ee,se=ee/180;function ne(t){const e=t*t;return e*e*e*t}function ae(t,e,{kL:i=1,kC:s=1,kH:n=1}={}){[t,e]=Ft([t,e]);let[a,r,o]=Kt.from(t),l=Qt.from(Kt,[a,r,o])[1],[h,d,c]=Kt.from(e),u=Qt.from(Kt,[h,d,c])[1];l<0&&(l=0),u<0&&(u=0);let p=ne((l+u)/2),m=.5*(1-Math.sqrt(p/(p+te))),b=(1+m)*r,g=(1+m)*d,f=Math.sqrt(b**2+o**2),x=Math.sqrt(g**2+c**2),w=0===b&&0===o?0:Math.atan2(o,b),v=0===g&&0===c?0:Math.atan2(c,g);w<0&&(w+=2*ee),v<0&&(v+=2*ee),w*=ie,v*=ie;let y,k=h-a,C=x-f,z=v-w,E=w+v,$=Math.abs(z);f*x==0?y=0:$<=180?y=z:z>180?y=z-360:z<-180?y=z+360:Nt.warn("the unthinkable has happened");let S,M=2*Math.sqrt(x*f)*Math.sin(y*se/2),L=(a+h)/2,A=(f+x)/2,P=ne(A);S=f*x==0?E:$<=180?E/2:E<360?(E+360)/2:(E-360)/2;let T=(L-50)**2,R=1+.015*T/Math.sqrt(20+T),D=1+.045*A,B=1;B-=.17*Math.cos((S-30)*se),B+=.24*Math.cos(2*S*se),B+=.32*Math.cos((3*S+6)*se),B-=.2*Math.cos((4*S-63)*se);let O=1+.015*A*B,H=30*Math.exp(-1*((S-275)/25)**2),N=2*Math.sqrt(P/(P+te)),I=(k/(i*R))**2;return I+=(C/(s*D))**2,I+=(M/(n*O))**2,I+=-1*Math.sin(2*H*se)*N*(C/(s*D))*(M/(n*O)),Math.sqrt(I)}const re=[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],oe=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],le=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],he=[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]];var de=new Xt({id:"oklab",name:"Oklab",coords:{l:{refRange:[0,1],name:"Lightness"},a:{refRange:[-.4,.4]},b:{refRange:[-.4,.4]}},white:"D65",base:Zt,fromBase(t){let e=ft(t,re);return e[0]=Math.cbrt(e[0]),e[1]=Math.cbrt(e[1]),e[2]=Math.cbrt(e[2]),ft(e,le,e)},toBase(t){let e=ft(t,he);return e[0]=e[0]**3,e[1]=e[1]**3,e[2]=e[2]**3,ft(e,oe,e)},formats:{oklab:{coords:["<percentage> | <number>","<number> | <percentage>","<number> | <percentage>"]}}});function ce(t,e){[t,e]=Ft([t,e]);let[i,s,n]=de.from(t),[a,r,o]=de.from(e),l=i-a,h=s-r,d=n-o;return Math.sqrt(l**2+h**2+d**2)}function ue(t,e,{epsilon:i=75e-6}={}){t=Ft(t),e||(e=t.space),e=Xt.get(e);let s=t.coords;return e!==t.space&&(s=e.from(t)),e.inGamut(s,{epsilon:i})}function pe(t,e){t=Ft(t);let i,s=Xt.get(e,e?.space),n=e?.precision;return i=!s||t.space.equals(s)?t.coords.slice():s.from(t),void 0===n?i:i.map((t=>Ct(t,n)))}function me(t,e){if(t=Ft(t),"alpha"===e)return t.alpha??1;let{space:i,index:s}=Xt.resolveCoord(e,t.space);return pe(t,i)[s]}function be(t,e,i,s){return t=Ft(t),Array.isArray(e)&&([e,i,s]=[t.space,e,i]),e=Xt.get(e),t.coords=e===t.space?i.slice():e.to(t.space,i),void 0!==s&&(t.alpha=s),t}function ge(t,e,i){if(t=Ft(t),2===arguments.length&&"object"===wt(arguments[1])){let e=arguments[1];for(let i in e)ge(t,i,e[i])}else if("function"==typeof i&&(i=i(me(t,e))),"alpha"===e)t.alpha=i;else{let{space:s,index:n}=Xt.resolveCoord(e,t.space),a=pe(t,s);a[n]=i,be(t,s,a)}return t}function fe(t){return{space:t.space,coords:t.coords.slice(),alpha:t.alpha}}be.returns="color",ge.returns="color";const xe=Math.PI/180;var we=new Xt({id:"xyz-abs-d65",cssId:"--xyz-abs-d65",name:"Absolute XYZ D65",coords:{x:{refRange:[0,9504.7],name:"Xa"},y:{refRange:[0,1e4],name:"Ya"},z:{refRange:[0,10888.3],name:"Za"}},base:Zt,fromBase:t=>t.map((t=>203*t)),toBase:t=>t.map((t=>t/203))});const ve=1.15,ye=.66,ke=2610/16384,Ce=16384/2610,ze=.8359375,Ee=2413/128,$e=18.6875,Se=1.7*2523/32,Me=32/(1.7*2523),Le=-.56,Ae=16295499532821565e-27,Pe=[[.41478972,.579999,.014648],[-.20151,1.120649,.0531008],[-.0166008,.2648,.6684799]],Te=[[1.9242264357876067,-1.0047923125953657,.037651404030618],[.35031676209499907,.7264811939316552,-.06538442294808501],[-.09098281098284752,-.3127282905230739,1.5227665613052603]],Re=[[.5,.5,0],[3.524,-4.066708,.542708],[.199076,1.096799,-1.295875]],De=[[1,.13860504327153927,.05804731615611883],[1,-.1386050432715393,-.058047316156118904],[1,-.09601924202631895,-.811891896056039]];var Be=new Xt({id:"jzazbz",name:"Jzazbz",coords:{jz:{refRange:[0,1],name:"Jz"},az:{refRange:[-.21,.21]},bz:{refRange:[-.21,.21]}},base:we,fromBase(t){let[e,i,s]=t,n=ft([ve*e-(ve-1)*s,ye*i-(ye-1)*e,s],Pe).map((function(t){let e=ze+Ee*Mt(t/1e4,ke),i=1+$e*Mt(t/1e4,ke);return Mt(e/i,Se)})),[a,r,o]=ft(n,Re);return[(1+Le)*a/(1+Le*a)-Ae,r,o]},toBase(t){let[e,i,s]=t,n=ft([(e+Ae)/(1+Le-Le*(e+Ae)),i,s],De).map((function(t){let e=ze-Mt(t,Me),i=$e*Mt(t,Me)-Ee;return 1e4*Mt(e/i,Ce)})),[a,r,o]=ft(n,Te),l=(a+(ve-1)*o)/ve;return[l,(r+(ye-1)*l)/ye,o]},formats:{jzazbz:{coords:["<percentage> | <number>","<number> | <percentage>","<number> | <percentage>"]}}}),Oe=new Xt({id:"jzczhz",name:"JzCzHz",coords:{jz:{refRange:[0,1],name:"Jz"},cz:{refRange:[0,.26],name:"Chroma"},hz:{refRange:[0,360],type:"angle",name:"Hue"}},base:Be,fromBase:Qt.fromBase,toBase:Qt.toBase,formats:{jzczhz:{coords:["<percentage> | <number>","<number> | <percentage>","<number> | <angle>"]}}});const He=.8359375,Ne=2413/128,Ie=18.6875,je=2610/16384,Ge=2523/32,Fe=16384/2610,Xe=32/2523,_e=[[.3592832590121217,.6976051147779502,-.035891593232029],[-.1920808463704993,1.100476797037432,.0753748658519118],[.0070797844607479,.0748396662186362,.8433265453898765]],Ze=[[.5,.5,0],[6610/4096,-13613/4096,7003/4096],[17933/4096,-17390/4096,-543/4096]],Ue=[[.9999999999999998,.0086090370379328,.111029625003026],[.9999999999999998,-.0086090370379328,-.1110296250030259],[.9999999999999998,.5600313357106791,-.3206271749873188]],Ye=[[2.0701522183894223,-1.3263473389671563,.2066510476294053],[.3647385209748072,.6805660249472273,-.0453045459220347],[-.0497472075358123,-.0492609666966131,1.1880659249923042]];var Ve=new Xt({id:"ictcp",name:"ICTCP",coords:{i:{refRange:[0,1],name:"I"},ct: