UNPKG

@public-ui/components

Version:

Contains all web components that belong to KoliBri - The accessible HTML-Standard.

4 lines 28.9 kB
/*! * KoliBri - The accessible HTML-Standard */ var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t={exports:{}};!function(t){!function(e,o){t.exports?t.exports=o():e.log=o()}(e,(function(){var e=function(){},t="undefined",o=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),n=["trace","debug","info","warn","error"],r={},a=null;function s(e,t){var o=e[t];if("function"==typeof o.bind)return o.bind(e);try{return Function.prototype.bind.call(o,e)}catch(t){return function(){return Function.prototype.apply.apply(o,[e,arguments])}}}function i(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function l(n){return"debug"===n&&(n="log"),typeof console!==t&&("trace"===n&&o?i:void 0!==console[n]?s(console,n):void 0!==console.log?s(console,"log"):e)}function c(){for(var o=this.getLevel(),r=0;r<n.length;r++){var a=n[r];this[a]=r<o?e:this.methodFactory(a,o,this.name)}if(this.log=this.debug,typeof console===t&&o<this.levels.SILENT)return"No console available for logging"}function u(e){return function(){typeof console!==t&&(c.call(this),this[e].apply(this,arguments))}}function d(e,t,o){return l(e)||u.apply(this,arguments)}function f(e,o){var s,i,l,u=this,f="loglevel";function h(e){var o=(n[e]||"silent").toUpperCase();if(typeof window!==t&&f){try{return void(window.localStorage[f]=o)}catch(e){}try{window.document.cookie=encodeURIComponent(f)+"="+o+";"}catch(e){}}}function p(){var e;if(typeof window!==t&&f){try{e=window.localStorage[f]}catch(e){}if(typeof e===t)try{var o=window.document.cookie,n=encodeURIComponent(f),r=o.indexOf(n+"=");-1!==r&&(e=/^([^;]+)/.exec(o.slice(r+n.length+1))[1])}catch(e){}return void 0===u.levels[e]&&(e=void 0),e}}function g(e){var t=e;if("string"==typeof t&&void 0!==u.levels[t.toUpperCase()]&&(t=u.levels[t.toUpperCase()]),"number"==typeof t&&t>=0&&t<=u.levels.SILENT)return t;throw new TypeError("log.setLevel() called with invalid level: "+e)}"string"==typeof e?f+=":"+e:"symbol"==typeof e&&(f=void 0),u.name=e,u.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},u.methodFactory=o||d,u.getLevel=function(){return null!=l?l:null!=i?i:s},u.setLevel=function(e,t){return l=g(e),!1!==t&&h(l),c.call(u)},u.setDefaultLevel=function(e){i=g(e),p()||u.setLevel(e,!1)},u.resetLevel=function(){l=null,function(){if(typeof window!==t&&f){try{window.localStorage.removeItem(f)}catch(e){}try{window.document.cookie=encodeURIComponent(f)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(e){}}}(),c.call(u)},u.enableAll=function(e){u.setLevel(u.levels.TRACE,e)},u.disableAll=function(e){u.setLevel(u.levels.SILENT,e)},u.rebuild=function(){if(a!==u&&(s=g(a.getLevel())),c.call(u),a===u)for(var e in r)r[e].rebuild()},s=g(a?a.getLevel():"WARN");var m=p();null!=m&&(l=g(m)),c.call(u)}(a=new f).getLogger=function(e){if("symbol"!=typeof e&&"string"!=typeof e||""===e)throw new TypeError("You must supply a name when creating a logger.");var t=r[e];return t||(t=r[e]=new f(e,a.methodFactory)),t};var h=typeof window!==t?window.log:void 0;return a.noConflict=function(){return typeof window!==t&&window.log===a&&(window.log=h),a},a.getLoggers=function(){return r},a.default=a,a}))}(t);const n=t.exports,o=(e,t)=>o=>o(e,t),r=(e,t)=>o=>o(e,t,{append:!1}),i=()=>{const e=typeof process<"u"&&process.env?process.env:{},t="test"===e.NODE_ENV,o="VITEST"in e,n="JEST_WORKER_ID"in e,r="PLAYWRIGHT_TEST_BASE_URL"in e,a="true"===e.CI,s="true"===e.TEST||"true"===e.IS_TEST,i=typeof navigator<"u"&&!0===navigator.webdriver,l=typeof navigator<"u"&&/playwright|puppeteer|webdriver|selenium|testcafe/i.test(navigator.userAgent);return t||o||n||r||a||s||i||l},s={A11yUi:{CSS_STYLE_CACHE:new Map,IS_TEST_ENVIRONMENT:i(),PERFORMANCE_MEASURES:new Map,STYLING_TASK_QUEUE:new Map,THEMES:new Map,showAverageTimes:()=>{const e={};for(const[t,o]of s.A11yUi.PERFORMANCE_MEASURES.entries())e[t]=[o.totalTime/o.count,o.count];const t=Object.entries(e).sort(((e,t)=>t[1][0]-e[1][0]));return console.table(Object.fromEntries(t.map((([e,[t,o]])=>[e,{"avg (ms)":parseFloat(t.toFixed(2)),count:o}])))),e}}};let a=!0,l=!1;const c=/^[a-z][a-z0-9]{1,}(-[a-z0-9]+)?$/,f=e=>"string"==typeof e&&c.test(e),u=e=>{if(!f(e))throw new Error(`[Theming] The theme identifier "${"string"==typeof e?e:""}" (Type: ${typeof e}) is not valid. Please use only follow this pattern: /^[a-z][a-z0-9]{1,}(-[a-z0-9]+)?$/`)},d=e=>e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s*([{}:;,])\s*/g,"$1").replace(/\s+/g," ").replace(/;\}/g,"}").trim(),v=(e,t,o,n)=>p(e,t,o,n),p=(e,t,o,r)=>{(r=r??{}).append=r.append??!1,u(e),a&&!l&&(l=!0,n.warn(`[Theming] The theme process is locked. This means that the theme "${e}" should not be patched.\n\n import { register } from 'adopted-style-sheets';\n import { defineCustomElements } from '...';\n import { THEME } from '...';\n\n register(THEME, defineCustomElements)\n .then(() => {\n // run your app or website\n })\n .catch(console.warn);`));let i=s.A11yUi.THEMES.get(e);if(i||(i=new Map,s.A11yUi.THEMES.set(e,i)),r.append&&i.has(t)){const e=i.get(t);i.set(t,d(`${e}${o}`))}else i.set(t,d(o))},y=(e,t,o,n)=>h(e,t,o,n),h=(e,t,o,n)=>(u(e),"object"==typeof t&&null!==t&&Object.getOwnPropertyNames(t).forEach((r=>{const a=t[r],s=r.toLowerCase(),i="function"!=typeof n?.transformTagName||["GLOBAL","PROPERTIES"].includes(r)?r:n.transformTagName(s);"string"==typeof a&&a.length>0&&p(e,i.toUpperCase(),a,o)})),e),b=e=>{if(e instanceof HTMLElement){if("string"==typeof e.dataset.theme)return e;{let t=e.parentNode;for(;t instanceof ShadowRoot;)t=t.host;return b(t)}}return null},g=(e={})=>"false"!==e.themeEncroachCss&&"true"!==e.themeReset&&{mode:"after"===e.themeEncroachCssMode||"before"===e.themeEncroachCssMode?e.themeEncroachCssMode:"before"},w=()=>"object"==typeof s.A11yUi.Theme&&null!==s.A11yUi.Theme&&"boolean"==typeof s.A11yUi.Theme.cache&&"object"==typeof s.A11yUi.Theme.encroachCss&&null!==s.A11yUi.Theme.encroachCss&&"string"==typeof s.A11yUi.Theme.encroachCss.mode&&"string"==typeof s.A11yUi.Theme.name,m=()=>!("object"==typeof s.A11yUi.Theme&&null!==s.A11yUi.Theme)||"default"!==s.A11yUi.Theme.name,S=e=>{if(w())return s.A11yUi.Theme;{const t={cache:!0,encroachCss:g(),loglevel:"silent",mode:"csr",name:null},o=b(e);return o instanceof HTMLElement&&(t.cache="false"!==o.dataset.themeCache,t.encroachCss=g(o.dataset),t.loglevel="debug"===o.dataset.themeLoglevel?o.dataset.themeLoglevel:"silent",t.mode="ssr"===o.dataset.themeMode?o.dataset.themeMode:"csr",t.name=o.dataset.theme||null),t}},T=(e,t)=>({cache:!1!==t.cache,detect:"auto"===t.detect?"auto":"fixed",encroachCss:!1!==t.encroachCss&&("object"!=typeof t.encroachCss||null==t.encroachCss||"after"!==t.encroachCss.mode&&"before"!==t.encroachCss.mode?{mode:"before"}:t.encroachCss),loglevel:"debug"===t.loglevel?t.loglevel:"silent",mode:"ssr"===t.mode?t.mode:"csr",name:"string"==typeof t.name?t.name:e}),E=(e,t)=>{!1===w()&&m()&&"object"==typeof t&&null!==t&&("fixed"===(t=T(e,t)).detect?(null===t.name&&"string"==typeof e&&(t.name=e),e===t.name&&(s.A11yUi.Theme=t,n.info(`[Theming] Theme "${e}" was set as default theme.`))):l||(l=!0,n.warn("[Theming] The presetting of theme options is only relevant by using 'fixed' detection mode.")))};let M=!1;const A=(e,t,o={})=>{M||(M=!0,a=!1,typeof window<"u"&&(window.A11yUi=s.A11yUi)),"function"==typeof e?e=new Set([e]):Array.isArray(e)&&(e=new Set(e)),e instanceof Set&&e.forEach((e=>{"function"==typeof e&&1===e.length?E(e(((e,t,n)=>h(e,t,n,o))),{cache:o.theme?.cache,detect:o.theme?.detect,encroachCss:o.theme?.encroachCss,mode:o.theme?.mode,name:o.theme?.name}):n.error("[Theming] An attempt was made to load an incompatible theme.")})),a=!0,"function"==typeof t?t=new Set([t]):Array.isArray(t)&&(t=new Set(t));const r=[];return t.forEach((e=>{const t=e();t instanceof Promise&&r.push(t)})),Promise.all(r)},k=new Set,N=/--[^;]+/g,R=/:/,L=typeof MutationObserver<"u";let O=25,C=()=>{O=Math.min(25+20*Math.log2(s.A11yUi.STYLING_TASK_QUEUE.size+1),250)};const j=(e,t)=>{let o=t.match(N);if(Array.isArray(o)){o=o.filter((e=>R.test(e)));const t=document.createElement("style");t.innerHTML=`.${e} {${o.join(";")}}`,document.querySelector("head")?.appendChild(t)}k.add(e)},_=(e,t)=>{const o=s.A11yUi.THEMES.get(e);return o instanceof Map&&o.has(t)?o.get(t):""},I=e=>{for(const t of Array.from(e.childNodes)){if(!(t instanceof HTMLStyleElement&&"STYLE"===t.tagName&&void 0===t.dataset.themingFallback))break;e.removeChild(t)}},$=(e,t)=>{try{if("ssr"===s.A11yUi.Theme?.mode)throw new Error("SSR");const o=[];t.forEach((e=>{const t=new CSSStyleSheet;t.replaceSync(e),o.push(t)})),e.adoptedStyleSheets=o}catch{[...t].reverse().forEach(((t,o)=>{if("string"!=typeof t||0===t.length)return;const n=document.createElement("style");switch(n.dataset.themingFallback="",o){case 4:n.dataset.themingBaseA11y="";break;case 3:n.dataset.themingBaseGlobal="";break;case 2:n.dataset.themingBaseComponent="";break;case 1:n.dataset.themingCustomGlobal="";break;case 0:n.dataset.themingCustomComponent="";break;default:n.dataset.themingUnknown=""}n.innerHTML=t,e.insertBefore(n,e.firstChild)}))}},x=(e,t,o)=>{if(!1!==o){const n=[...Array.from(e.childNodes).filter((e=>e instanceof HTMLStyleElement&&"STYLE"===e.tagName))];let r;try{r=[...Array.from(e.adoptedStyleSheets)]}catch{r=[]}"before"===o?.mode?(n.reverse().forEach((e=>t.unshift(e.innerHTML))),r.reverse().forEach((e=>t.unshift(Array.from(e.cssRules).map((e=>e.cssText)).join(""))))):"after"===o?.mode&&(n.forEach((e=>t.push(e.innerHTML))),r.forEach((e=>t.push(Array.from(e.cssRules).map((e=>e.cssText)).join("")))))}},H=(e,t,o)=>{const n=t.name||"default";let r;try{if(null===e.shadowRoot)throw new Error("ShadowRoot is null");r=e.shadowRoot}catch{r=e}if(s.A11yUi.CSS_STYLE_CACHE.get(n)?.has(e.tagName))P(e,r,s.A11yUi.CSS_STYLE_CACHE.get(n)?.get(e.tagName),o);else{const a=_(n,"PROPERTIES"),i=_(n,"GLOBAL"),l=_(n,e.tagName);!1===k.has(n)&&j(n,i);const c=[a,i,l];x(r,c,t.encroachCss),!0===t.cache&&(!1===s.A11yUi.CSS_STYLE_CACHE.has(n)&&s.A11yUi.CSS_STYLE_CACHE.set(n,new Map),s.A11yUi.CSS_STYLE_CACHE.get(n)?.set(e.tagName,c)),P(e,r,c,o)}},P=(e,t,o,n)=>{const r=performance.now();if(I(t),$(t,o),Y(e),n(),s.A11yUi.PERFORMANCE_MEASURES.has(e.tagName)){const t=s.A11yUi.PERFORMANCE_MEASURES.get(e.tagName);t.count+=1,t.totalTime+=performance.now()-r}else s.A11yUi.PERFORMANCE_MEASURES.set(e.tagName,{count:1,totalTime:performance.now()-r})},F=e=>{const t=s.A11yUi.STYLING_TASK_QUEUE.get(e);if(t){const{resetCss:o,themeDetails:n}=t;H(e,n,o),Y(e)}};let U=e=>{const t=setTimeout((()=>{clearTimeout(t),e.classList.contains("hydrated")?F(e):U(e)}),O)};const B={attributes:!0,attributeFilter:["class"],childList:!1,subtree:!1},D={attributes:!0,attributeFilter:[],childList:!1,subtree:!1},J=L?new MutationObserver(((e,t)=>{for(const o of e){const e=o.target;e.classList.contains("hydrated")&&(F(e),t.observe(e,D))}})):null;J&&(U=e=>J.observe(e,B),C=()=>{});let z=e=>{const t=getComputedStyle(e).getPropertyValue("--theme-visibility-delay").trim();if(t.endsWith("ms"))return parseFloat(t);if(t.endsWith("s"))return 1e3*parseFloat(t);{const e=parseFloat(t);return isNaN(e)?0:e}};s.A11yUi.IS_TEST_ENVIRONMENT&&(z=()=>0,console.log("Test-Runner detected, disabling theme visibility delay."));const K=(e,t)=>{e.style.setProperty("visibility",t),e.dataset.themed=""},W=(e,t)=>{const o=e.style.visibility||null;s.A11yUi.STYLING_TASK_QUEUE.set(e,{resetCss:()=>{const t=z(e);t>0?setTimeout((()=>{K(e,o)}),t):K(e,o)},themeDetails:t}),e.style.setProperty("visibility","hidden","important"),U(e)},Y=e=>{s.A11yUi.STYLING_TASK_QUEUE.delete(e),C()},G=(e,t)=>{W(e,{...s.A11yUi.Theme,...t})};class q{Prefix;Key;Tag;createTheme=(e,t)=>r(e,t);createTranslation=(e,t)=>o(e,t);constructor(e,t,o){this.Prefix=e,this.Key=Object.getOwnPropertyNames(t),this.Tag=Object.getOwnPropertyNames(o)}}var Q,V;!function(e){e[e.error=0]="error",e[e.warning=1]="warning",e[e.info=2]="info",e[e.success=3]="success",e[e.message=4]="message",e[e.close=5]="close",e[e["form-description"]=6]="form-description",e[e.of=7]="of",e[e.characters=8]="characters",e[e.new=9]="new",e[e["no-entries"]=10]="no-entries",e[e["change-order"]=11]="change-order",e[e["action-running"]=12]="action-running",e[e["action-done"]=13]="action-done",e[e["page-first"]=14]="page-first",e[e["page-back"]=15]="page-back",e[e["page-next"]=16]="page-next",e[e["page-last"]=17]="page-last",e[e["entries-per-site"]=18]="entries-per-site",e[e["page-current"]=19]="page-current",e[e["page-selected"]=20]="page-selected",e[e["page-per-site"]=21]="page-per-site",e[e["logo-description"]=22]="logo-description",e[e["open-link-in-tab"]=23]="open-link-in-tab",e[e["kolibri-logo"]=24]="kolibri-logo"}(Q||(Q={})),function(e){e[e.abbr=0]="abbr",e[e.accordion=1]="accordion",e[e["accordion-group"]=2]="accordion-group",e[e.alert=3]="alert",e[e.avatar=4]="avatar",e[e.badge=5]="badge",e[e.breadcrumb=6]="breadcrumb",e[e.button=7]="button",e[e["button-link"]=8]="button-link",e[e.card=9]="card",e[e.combobox=10]="combobox",e[e.details=11]="details",e[e.drawer=12]="drawer",e[e.form=13]="form",e[e.heading=14]="heading",e[e.icon=15]="icon",e[e.image=16]="image",e[e["input-checkbox"]=17]="input-checkbox",e[e["input-color"]=18]="input-color",e[e["input-date"]=19]="input-date",e[e["input-email"]=20]="input-email",e[e["input-file"]=21]="input-file",e[e["input-number"]=22]="input-number",e[e["input-password"]=23]="input-password",e[e["input-radio"]=24]="input-radio",e[e["input-range"]=25]="input-range",e[e["input-text"]=26]="input-text",e[e.kolibri=27]="kolibri",e[e.link=28]="link",e[e["link-button"]=29]="link-button",e[e.logo=30]="logo",e[e.modal=31]="modal",e[e.nav=32]="nav",e[e.pagination=33]="pagination",e[e["popover-button"]=34]="popover-button",e[e.progress=35]="progress",e[e.select=36]="select",e[e.separator=37]="separator",e[e["single-select"]=38]="single-select",e[e["skip-nav"]=39]="skip-nav",e[e.spin=40]="spin",e[e["split-button"]=41]="split-button",e[e.symbol=42]="symbol",e[e.table=43]="table",e[e["table-stateful"]=44]="table-stateful",e[e["table-stateless"]=45]="table-stateless",e[e.tabs=46]="tabs",e[e.textarea=47]="textarea",e[e["toast-container"]=48]="toast-container",e[e.toolbar=49]="toolbar",e[e.tooltip=50]="tooltip",e[e.tree=51]="tree",e[e["tree-item"]=52]="tree-item"}(V||(V={}));const X=()=>"undefined"==typeof window?null:window,Z=()=>void 0===X().document?null:X().document;let ee=!1,te=!1,ne=!1;const oe=()=>!0===ee,re=e=>{ee=!0===e},ie=()=>!0===te,se=e=>{te=!0===e},ae=()=>!0===ne,le=e=>{ne=!0===e},ce="color: white; background: #666; font-weight: bold; padding: .25em .5em; border-radius: 3px; border: 1px solid #000",fe=e=>Array.isArray(e)?e:[e],ue=e=>`%c${e}`,de=(e,t)=>"string"==typeof t&&t.length>0?`${ue(e)} | ${t}`:ue(e),ve=(e,t)=>[de(e,null==t?void 0:t.classifier),`${ce};${(null==t?void 0:t.overwriteStyle)||""}`],pe=(e,t)=>e()||!0===t;class ye{constructor(e,t){this.label=e,this.devMode=t}debug(e,t){pe(this.devMode,null==t?void 0:t.forceLog)&&console.debug(...ve(this.label,t),...fe(e))}info(e,t){pe(this.devMode,null==t?void 0:t.forceLog)&&console.info(...ve(this.label,t),...fe(e))}trace(e,t){pe(this.devMode,null==t?void 0:t.forceLog)&&console.trace(...ve(this.label,t),...fe(e))}warn(e,t){pe(this.devMode,null==t?void 0:t.forceLog)&&console.warn(...ve(this.label,t),...fe(e))}error(e,t){console.error(...ve(this.label,t),...fe(e))}throw(e,t){if(pe(this.devMode,null==t?void 0:t.forceLog))throw new Error(...ve(this.label,t),...fe(e))}}const he=new ye("KoliBri",oe),be=new Set,ge=(e,t)=>{(!1===be.has(e)||(null==t?void 0:t.force))&&(be.add(e),he.debug([e].concat((null==t?void 0:t.details)||[]),{classifier:"✋ a11y",forceLog:!!(null==t?void 0:t.force),overwriteStyle:"; background-color: #09f"}))},we=new Set,me=(e,t)=>{(!1===we.has(e)||(null==t?void 0:t.force))&&(we.add(e),he.warn([e].concat((null==t?void 0:t.details)||[]),{classifier:"🔥 deprecated",forceLog:!!(null==t?void 0:t.force),overwriteStyle:"; background-color: #f00"}))},Se=new Set,Te=(e,t)=>{(!1===Se.has(e)||(null==t?void 0:t.force))&&(Se.add(e),he.debug([e].concat((null==t?void 0:t.details)||[]),{classifier:"💻 dev",forceLog:!!(null==t?void 0:t.force),overwriteStyle:"; background-color: #f09"}))},Ee=(e,t)=>{(!1===Se.has(e)||(null==t?void 0:t.force))&&(Se.add(e),he.warn([e].concat((null==t?void 0:t.details)||[]),{classifier:"⚠️ dev",forceLog:!!(null==t?void 0:t.force),overwriteStyle:"; background-color: #f09"}))},Me=new Set,Ae=(e,t=!1,o)=>{(!1===Me.has(e)||(null==o?void 0:o.force))&&(Me.add(e),e+=!0===t?" ✅":"",he.debug([e].concat((null==o?void 0:o.details)||[]),{classifier:"🌟 feature",forceLog:!!(null==o?void 0:o.force),overwriteStyle:"; background-color: #309"}))};Te("We appreciate any feedback, comments, screenshots, or demo links of an application based on KoliBri (kolibri@itzbund.de). Thank you!");const ke=new Set,Ne=(e,t)=>{(!1===ke.has(e)||(null==t?void 0:t.force))&&(ke.add(e),he.debug([e].concat((null==t?void 0:t.details)||[]),{classifier:"📑 ui/ux",forceLog:!!(null==t?void 0:t.force),overwriteStyle:"; background-color: #060;"}))},Re=()=>{ge('"Disabled" limits accessibility and visibility. From an accessibility perspective, we recommend using the readonly attribute instead of disabled.\n- https://uxdesign.cc/is-it-ok-to-grey-out-disabled-buttons-8afa74a0fae')},Le=e=>{"string"==typeof e&&""!==e||ge("Some structural elements, such as the nav tag, can be used multiple times on a webpage. To distinguish between similarly named structural elements, it is necessary to set an ARIA label.\n- https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Navigation_Role#accessibility_concerns")},Oe=(e,t=8)=>{t>7&&Ne(`[${e}] Within navigation structures, it is recommended to use no more than 7 menu items.\n\nLink:\n- https://en.wikipedia.org/wiki/The_Magical_Number_Seven,_Plus_or_Minus_Two`)};var Ce=.2126,je=.7152,_e=.0722,Ie=1/12.92;function $e(e){return Math.pow((e+.055)/1.055,2.4)}function xe(e){var t=e[0]/255,o=e[1]/255,n=e[2]/255,r=t<=.03928?t*Ie:$e(t),a=o<=.03928?o*Ie:$e(o),s=n<=.03928?n*Ie:$e(n);return r*Ce+a*je+s*_e}function He(e){var t=255;8===(e=e.replace(/^#/,"")).length&&(t=parseInt(e.slice(6,8),16),e=e.substring(0,6)),4===e.length&&(t=parseInt(e.slice(3,4).repeat(2),16),e=e.substring(0,3)),3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]);var o=parseInt(e,16);return[o>>16,o>>8&255,255&o,t]}function Pe(e,t){return(Math.max(e,t)+.05)/(Math.min(e,t)+.05)}function Fe(e,t){return Pe(xe(e),xe(t))}function Ue(e,t){return Fe(He(e),He(t))}function Be(e){return e>=7?"AAA":e>=4.5?"AA":e>=3?"AA Large":"Fail"}var De={exports:{}};function Je(e){var t=Ge(e);return 3==t.length?t.concat(255):(t[3]=Math.round(t[3]),t)}function ze(e){var t=Ge(e);return{r:t[0],g:t[1],b:t[2],a:3==t.length?255:Math.round(t[3])}}function Ke(e){var t=Ge(e);return 3==t.length&&t.push(255),255==t[3]?"rgb("+t[0]+", "+t[1]+", "+t[2]+")":0==t[3]?"rgba("+t[0]+", "+t[1]+", "+t[2]+", 0)":"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+String(t[3]/255).substr(1)+")"}function We(e){3==(t=Ge(e)).length&&t.push(255);var t,o=255==t[3],n=qe(t[0]),r=qe(t[1]),a=qe(t[2]),s=Qe(n,r,a,t=qe(Math.round(t[3])));return o?s?"#"+n.charAt(0)+r.charAt(0)+a.charAt(0):"#"+n+r+a:s?"#"+n.charAt(0)+r.charAt(0)+a.charAt(0)+t.charAt(0):"#"+n+r+a+t}function Ye(e){var t=Ge(e);return 3==t.length?t.push(255):t[3]=Math.round(t[3]),(t[3]<<24>>>0|t[0]<<16|t[1]<<8|t[2])>>>0}function Ge(e){return"string"==typeof e?Ve(e=e.toLowerCase())||Ze(e)||et(e)||it(e)||st(e)||[0,0,0,255]:nt(e)||ot(e)||rt(e)||[0,0,0,255]}function qe(e){var t=e.toString(16);return 1==t.length?"0"+t:t}function Qe(e,t,o,n){var r=["ff","00","11","22","33","44","55","66","77","88","99","aa","bb","cc","dd","ee"];return-1!=r.indexOf(e)&&-1!=r.indexOf(t)&&-1!=r.indexOf(o)&&-1!=r.indexOf(n)}function Ve(e){return"red"==e?[255,0,0]:"green"==e?[0,255,0]:"blue"==e?[0,0,255]:"black"==e?[0,0,0]:"white"==e?[255,255,255]:"cyan"==e?[0,255,255]:"gray"==e||"grey"==e?[128,128,128]:"magenta"==e||"pink"==e?[255,0,255]:"yellow"==e?[255,255,0]:void 0}function Xe(e){return 1==e.length?parseInt(e+e,16):parseInt(e,16)}function Ze(e){var t=e.replace(/^#/,""),o=t.length;if(3==o||4==o){var n=Xe(t[0]),r=Xe(t[1]),a=Xe(t[2]),s=3==o?255:Xe(t[3]);if(isNaN(n)||isNaN(r)||isNaN(a)||isNaN(s))return;return[n,r,a,s]}}function et(e){var t=e.replace(/^#/,""),o=t.length;if(6==o||8==o){var n=Xe(t.slice(0,2)),r=Xe(t.slice(2,4)),a=Xe(t.slice(4,6)),s=6==o?255:Xe(t.slice(6,8));if(isNaN(n)||isNaN(r)||isNaN(a)||isNaN(s))return;return[n,r,a,s]}}function tt(e,t){return"number"!=typeof e||!0===t&&Math.floor(e)!==e?-1:e>=0&&e<=255?e:-1}function nt(e){if("[object Object]"===Object.prototype.toString.call(e)&&Object.getPrototypeOf(e)===Object.getPrototypeOf({})){var t=tt(null!=e.r?e.r:null!=e.red?e.red:0,!0),o=tt(null!=e.g?e.g:null!=e.green?e.green:0,!0),n=tt(null!=e.b?e.b:null!=e.blue?e.blue:0,!0),r=tt(null!=e.a?e.a:null!=e.alpha?e.alpha:255,!0);if(-1!=t&&-1!=o&&-1!=n&&-1!=r)return[t,o,n,r]}}function ot(e){if(Array.isArray(e)&&(3==e.length||4==e.length)){var t=tt(e[0],!0),o=tt(e[1],!0),n=tt(e[2],!0),r=tt(null!=e[3]?e[3]:255,!0);if(-1!=t&&-1!=o&&-1!=n&&-1!=r)return[t,o,n,r]}}function rt(e){if("number"==typeof e&&Math.floor(e)==e&&e<=4294967295&&e>=0)return[e>>16&255,e>>8&255,255&e,e>>24&255]}function it(e){if("rgb("==e.substr(0,4)){var t=(e=e.match(/^rgb\(([^)]+)\)/)[1]).split(/ *, */).map(Number),o=tt(t[0],!0),n=tt(t[1],!0),r=tt(t[2],!0);if(-1!=o&&-1!=n&&-1!=r)return[o,n,r,255]}}function st(e){if("rgba("==e.substr(0,5)){var t=(e=e.match(/^rgba\(([^)]+)\)/)[1]).split(/ *, */).map(Number),o=tt(t[0],!0),n=tt(t[1],!0),r=tt(t[2],!0),a=tt(255*t[3]);if(-1!=o&&-1!=n&&-1!=r&&-1!=a)return[o,n,r,a]}}De.exports=Je,De.exports.arr=Je,De.exports.obj=ze,De.exports.css=Ke,De.exports.hex=We,De.exports.num=Ye;const at=De.exports,lt=(e,t)=>{t.forEach((t=>{!1===e.has(t)&&e.add(t)}))},ct=(e,t=document)=>{if(t instanceof Document||t instanceof HTMLElement||t instanceof ShadowRoot){const o=new Set;lt(o,t.querySelectorAll(e));const n=t.querySelectorAll('[class*="hydrated"]');for(let t=0;t<n.length;t++){const r=n[t].shadowRoot;lt(o,ct(e,"object"==typeof r&&null!==r?r:n[t]))}return Array.from(o)}throw new Error("The parameter document for the method querySelectorAll is not type of Document, HTMLElement or ShadowRoot.")},ft=(e,t=document)=>{if(t instanceof Document||t instanceof HTMLElement||t instanceof ShadowRoot){let o=t.querySelector(e);if(null===o){const n=t.querySelectorAll('[class*="hydrated"]');for(let t=0;t<n.length;t++){const r=n[t].shadowRoot;if(o=ft(e,"object"==typeof r&&null!==r?r:n[t]),null!==o)break}}return o}throw new Error("The parameter document for the method querySelector is not type of Document, HTMLElement or ShadowRoot.")},ut=/\[object Object\]/,dt=(e,t)=>{"string"==typeof e&&ut.test(e)||t()},vt=(e,t)=>{"string"==typeof e&&""===e||t()},pt=(e,t)=>{ie()&&(he.debug([e,t]),he.debug("↑ We propagate the (submit) event to this target.")),Object.defineProperty(e,"target",{value:t,writable:!1})},yt=e=>{var t,o,n;null===(t=e.nextHooks)||void 0===t||t.forEach(((t,o)=>{var n;const r=t.get("beforePatch");"function"==typeof r&&r(null===(n=e.nextState)||void 0===n?void 0:n.get(o),e.nextState,e,o)})),(null===(o=e.nextState)||void 0===o?void 0:o.size)>0&&(e.state=Object.assign(Object.assign({},e.state),Object.fromEntries(e.nextState)),delete e.nextState,null===(n=e.nextHooks)||void 0===n||n.forEach(((t,o)=>{const n=t.get("afterPatch");"function"==typeof n&&n(e.state[o],e.state,e,o)}))),delete e.nextHooks},ht=(e,t,o,n={})=>{var r,a;void 0===e.nextHooks&&(e.nextHooks=new Map),void 0===e.nextState&&(e.nextState=new Map);e.nextHooks.get(t)instanceof Map==!1&&e.nextHooks.set(t,new Map),"function"==typeof n.afterPatch&&(null===(r=e.nextHooks.get(t))||void 0===r||r.set("afterPatch",n.afterPatch)),"function"==typeof n.beforePatch&&(null===(a=e.nextHooks.get(t))||void 0===a||a.set("beforePatch",n.beforePatch)),e.nextState.set(t,o),yt(e)},bt=(e,t,o,n)=>{Te(`[${e.constructor.name}] The property value: (${o}) for '${t}' is not valid. Allowed values are: ${Array.from(n).join(", ")}`)};function gt(e,t,o,n,r,a={}){o(r)?ht(e,t,r,a.hooks):void 0===r&&!0!==a.required&&o(a.defaultValue)?ht(e,t,a.defaultValue,a.hooks):(a.required||n.add(null),bt(e,t,r,n))}const wt=(e,t,o,n)=>{gt(e,t,(e=>"boolean"==typeof e),new Set(["Boolean {true, false}"]),o,n)},mt=(e,t,o,n={})=>{const r="number"==typeof n.minLength?null==n?void 0:n.minLength:0;gt(e,t,(e=>"string"==typeof e&&e.length>=r&&(void 0===(null==n?void 0:n.maxLength)||e.length<=n.maxLength)),new Set(["String"]),o,n)},St=(e,t,o,n)=>{gt(e,t,(e=>"number"==typeof e&&(void 0===(null==n?void 0:n.min)||"number"==typeof(null==n?void 0:n.min)&&e>=n.min)&&(void 0===(null==n?void 0:n.max)||"number"==typeof(null==n?void 0:n.max)&&e<=n.max)),new Set(["Number"]),o,n)},Tt=(e,t,o,n,r=e=>e==e,a={})=>{vt(n,(()=>{dt(n,(()=>{void 0===n&&(n=[]);try{try{n=At(n)}catch(e){}if(Array.isArray(n)){const s=n.find((e=>!o(e)));void 0===s&&r(n)?ht(e,t,n,a.hooks):dt(s,(()=>{throw he.debug(s),new Error("↑ The schema for the property (_options) is not valid. The value will not be changed.")}))}else dt(n,(()=>{throw he.debug(n),new Error("↑ The schema for the property (_options) is not valid. The value will not be changed.")}))}catch(e){he.debug(e)}}))}))},Et=e=>{try{return JSON.stringify(e).replace(/"/g,"'")}catch(t){throw he.warn(["stringifyJson",e]),he.error("↑ The JSON could not be converted to a string. A stringifiable JSON is expected."),new Error}},Mt=/^[{[]/,At=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(t){if(Mt.test(e))try{return JSON.parse(e.replace(/'/g,'"'))}catch(t){he.warn(["parseJson",e]),he.error("↑ The JSON string could not be parsed. Make sure that single quotes in the text are escaped (&#8216;).")}}throw new Error},kt=e=>"boolean"==typeof e?!0===e?"true":"false":void 0,Nt=e=>"string"==typeof e?e:kt(e),Rt=(e,t)=>ft(e,t||Z()),Lt=(e,t)=>ct(e,t||Z());let Ot=null;const Ct=()=>(Ot=Ot||{backgroundColor:"#00000000",color:"#00000000",domNode:Z().body,level:"Fail",score:1},Ot),jt=/(\d+, ){3}0\)/,_t=(e,t=Ct())=>{const o=getComputedStyle(e),n=jt.test(o.backgroundColor)?t.backgroundColor:at.hex(o.backgroundColor),r=jt.test(o.color)?t.color:at.hex(o.color),a=Ue(n,r),s={backgroundColor:n,color:r,domNode:e,level:Be(a),score:a};return a<4.5&&he.error(["Color-Contrast-Error",{backgroundColor:s.backgroundColor,color:s.color,level:s.level,score:s.score},s.domNode]),s},It=(e,t=Ct())=>{t.domNode instanceof HTMLElement&&(t=_t(t.domNode,t));const o=t.domNode.querySelector(e);if(null===o){const o=t.domNode.querySelectorAll('[class="hydrated"]');for(let n=0;n<o.length&&(t.domNode=o[n],null===(t=It(e,t)).domNode);n++);return t}return _t(o,t)};class $t{static queryHtmlElementColors(e,t,o=!1,n=!0){let r=null;if(!0===o||!1===$t.executionLock)if(!1===o&&($t.cache.clear(),$t.cache.set(t.domNode,t),$t.executionLock=!0,!0===n&&he.debug("[KoliBriUtils] Color contrast analysis started...")),e===t.domNode)r=t;else{const o=new Set;if(t.domNode.shadowRoot){const e=t.domNode.shadowRoot.children;for(let t=0;t<e.length;t++)o.add(e[t])}const n=t.domNode;if("function"==typeof n.assignedNodes){const e=n.assignedNodes();for(let t=0;t<e.length;t++)e[t]instanceof HTMLElement&&o.add(e[t])}const a=t.domNode.children;for(let e=0;e<a.length;e++)o.add(a[e]);const s=Array.from(o);for(let o=0;o<s.length;o++){let n=$t.cache.get(s[o]);void 0===n&&(n=_t(s[o],t)),$t.cache.set(s[o],n);const a=$t.queryHtmlElementColors(e,n,!0,!1);if(null!==a){r=a;break}}}else he.debug("[KoliBriUtils] Call aborted because a color contrast analysis is currently being executed.");return!1===o&&(!0===n&&he.debug(`[KoliBriUtils] Color contrast analysis finished (${$t.cache.size} DOM elements are analysed).`),$t.executionLock=!1,$t.cache.clear()),r}}$t.executionLock=!1,$t.cache=new Map;class xt{}xt.getCssStyle=_,xt.patchTheme=y,xt.patchThemeTag=v,xt.querySelector=Rt,xt.querySelectorAll=Lt,xt.stringifyJson=Et;let Ht="development";try{Ht="production"}catch(Ie){Ht="production"}const Pt=e=>""===e,Ft=(e,t)=>e||t||"",Ut=e=>"object"==typeof e&&null!==e,Bt=(e,t=0)=>"string"==typeof e&&e.length>=t,Dt=e=>{if("object"!=typeof e||null===e)return Bt(e,1);for(const t in e)if(!1===Bt(t,1))return!1;return!0},Jt=new Event("StateChange");var zt;!function(e){e.bar="bar",e.cycle="cycle"}(zt||(zt={}));const Kt=new q("kol",Q,V);export{mt as A,Ft as B,S as C,Te as D,St as E,ie as F,Ee as G,me as H,pt as I,zt as J,Kt as K,he as L,vt as M,Rt as N,kt as O,Nt as P,oe as Q,ae as R,Jt as S,_t as T,Lt as U,A as V,It as W,$t as X,Et as Y,xt as a,ge as b,se as c,le as d,X as e,Ae as f,Z as g,wt as h,Re as i,At as j,ht as k,Pt as l,Ue as m,G as n,dt as o,Ht as p,Bt as q,at as r,re as s,Dt as t,Ne as u,Ut as v,gt as w,Le as x,Tt as y,Oe as z};