@khipu/design-system 0.1.0-alpha.49 → 0.1.0-alpha.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1644,6 +1644,7 @@ function H(e){return e<0?-1:e===0?0:1}function nt(e,t,r){return(1-r)*e+r*t}funct
|
|
|
1644
1644
|
* - Clipboard copy rows
|
|
1645
1645
|
* - Countdown timers
|
|
1646
1646
|
* - Segmented tabs
|
|
1647
|
+
* - Bank modal (search and selection)
|
|
1647
1648
|
* - Sticky invoice card (collapse on scroll)
|
|
1648
1649
|
*/
|
|
1649
1650
|
|
|
@@ -1683,6 +1684,7 @@ function H(e){return e<0?-1:e===0?0:1}function nt(e,t,r){return(1-r)*e+r*t}funct
|
|
|
1683
1684
|
initCountdown();
|
|
1684
1685
|
initSegmentedTabs();
|
|
1685
1686
|
initStickyInvoice();
|
|
1687
|
+
initBankModal();
|
|
1686
1688
|
|
|
1687
1689
|
console.log('Material Design initialization complete!');
|
|
1688
1690
|
}
|
|
@@ -1897,6 +1899,105 @@ function H(e){return e<0?-1:e===0?0:1}function nt(e,t,r){return(1-r)*e+r*t}funct
|
|
|
1897
1899
|
});
|
|
1898
1900
|
}
|
|
1899
1901
|
|
|
1902
|
+
/**
|
|
1903
|
+
* Initialize bank modal
|
|
1904
|
+
* Handles opening, closing, search, and selection of banks
|
|
1905
|
+
* Delegated events for [data-open-bank-modal], [data-close-bank-modal], and bank selection
|
|
1906
|
+
* @param {Element} root - Root element to scope listeners (default: document)
|
|
1907
|
+
*/
|
|
1908
|
+
function initBankModal(root) {
|
|
1909
|
+
root = root || document;
|
|
1910
|
+
|
|
1911
|
+
var modal = root.querySelector('#bankModal');
|
|
1912
|
+
var searchInput = root.querySelector('#bankSearch');
|
|
1913
|
+
var bankList = root.querySelector('#bankModalList');
|
|
1914
|
+
var noResults = root.querySelector('#bankNoResults');
|
|
1915
|
+
|
|
1916
|
+
if (!modal) return;
|
|
1917
|
+
|
|
1918
|
+
/**
|
|
1919
|
+
* Filter banks by search query
|
|
1920
|
+
* @param {string} query - Search term
|
|
1921
|
+
*/
|
|
1922
|
+
function filterBanks(query) {
|
|
1923
|
+
if (!bankList) return;
|
|
1924
|
+
|
|
1925
|
+
var q = query.toLowerCase().trim();
|
|
1926
|
+
var rows = bankList.querySelectorAll('.kds-bank-row');
|
|
1927
|
+
var visible = 0;
|
|
1928
|
+
|
|
1929
|
+
rows.forEach(function(row) {
|
|
1930
|
+
var nameEl = row.querySelector('.kds-bank-row-name');
|
|
1931
|
+
if (!nameEl) return;
|
|
1932
|
+
|
|
1933
|
+
var name = nameEl.textContent.toLowerCase();
|
|
1934
|
+
var match = !q || name.indexOf(q) !== -1;
|
|
1935
|
+
row.style.display = match ? '' : 'none';
|
|
1936
|
+
if (match) visible++;
|
|
1937
|
+
});
|
|
1938
|
+
|
|
1939
|
+
if (noResults) {
|
|
1940
|
+
noResults.classList.toggle('visible', visible === 0);
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1944
|
+
// Open modal
|
|
1945
|
+
root.addEventListener('click', function(e) {
|
|
1946
|
+
var opener = e.target.closest('[data-open-bank-modal]');
|
|
1947
|
+
if (opener) {
|
|
1948
|
+
modal.classList.add('open');
|
|
1949
|
+
if (searchInput) {
|
|
1950
|
+
searchInput.value = '';
|
|
1951
|
+
searchInput.focus();
|
|
1952
|
+
}
|
|
1953
|
+
filterBanks('');
|
|
1954
|
+
}
|
|
1955
|
+
});
|
|
1956
|
+
|
|
1957
|
+
// Close modal
|
|
1958
|
+
root.addEventListener('click', function(e) {
|
|
1959
|
+
var closer = e.target.closest('[data-close-bank-modal]');
|
|
1960
|
+
if (closer) {
|
|
1961
|
+
modal.classList.remove('open');
|
|
1962
|
+
}
|
|
1963
|
+
});
|
|
1964
|
+
|
|
1965
|
+
// Select bank (closes modal and dispatches event)
|
|
1966
|
+
if (bankList) {
|
|
1967
|
+
bankList.addEventListener('click', function(e) {
|
|
1968
|
+
var bankRow = e.target.closest('.kds-bank-row');
|
|
1969
|
+
if (bankRow) {
|
|
1970
|
+
var bankId = bankRow.dataset.bankId || bankRow.dataset.bank || '';
|
|
1971
|
+
var bankName = bankRow.querySelector('.kds-bank-row-name');
|
|
1972
|
+
|
|
1973
|
+
// Dispatch custom event with bank data
|
|
1974
|
+
modal.dispatchEvent(new CustomEvent('kds:bank:selected', {
|
|
1975
|
+
bubbles: true,
|
|
1976
|
+
detail: {
|
|
1977
|
+
id: bankId,
|
|
1978
|
+
name: bankName ? bankName.textContent : '',
|
|
1979
|
+
element: bankRow
|
|
1980
|
+
}
|
|
1981
|
+
}));
|
|
1982
|
+
|
|
1983
|
+
// Close modal
|
|
1984
|
+
modal.classList.remove('open');
|
|
1985
|
+
}
|
|
1986
|
+
});
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1989
|
+
// Search input
|
|
1990
|
+
if (searchInput) {
|
|
1991
|
+
searchInput.addEventListener('input', function(e) {
|
|
1992
|
+
filterBanks(e.target.value);
|
|
1993
|
+
});
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
// Export filterBanks for manual use if needed
|
|
1997
|
+
if (!window.Khipu) window.Khipu = {};
|
|
1998
|
+
window.Khipu.filterBanks = filterBanks;
|
|
1999
|
+
}
|
|
2000
|
+
|
|
1900
2001
|
/**
|
|
1901
2002
|
* Initialize sticky invoice card collapse on scroll
|
|
1902
2003
|
* Toggles .collapsed class on .kds-invoice-sticky when user scrolls past threshold
|
|
@@ -1989,6 +2090,7 @@ function H(e){return e<0?-1:e===0?0:1}function nt(e,t,r){return(1-r)*e+r*t}funct
|
|
|
1989
2090
|
window.Khipu.initCopyRow = initCopyRow;
|
|
1990
2091
|
window.Khipu.initCountdown = initCountdown;
|
|
1991
2092
|
window.Khipu.initSegmentedTabs = initSegmentedTabs;
|
|
2093
|
+
window.Khipu.initBankModal = initBankModal;
|
|
1992
2094
|
window.Khipu.initStickyInvoice = initStickyInvoice;
|
|
1993
2095
|
|
|
1994
2096
|
// Also export showSnackbar to global scope for backward compatibility
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const _emptyNodeList=[],_weakElements=new WeakSet,isChrome=navigator.userAgent.includes("Chrome");navigator.userAgent.includes("Firefox"),navigator.userAgent.includes("Safari"),navigator.userAgent.includes("Windows");const isMac=navigator.userAgent.includes("Macintosh");navigator.userAgent.includes("Linux"),navigator.userAgent.includes("Android");const isIOS=/iPad|iPhone|iPod/.test(navigator.userAgent);function isDark(){return null==window?void 0:window.matchMedia("(prefers-color-scheme: dark)").matches}async function wait(t){await new Promise(e=>setTimeout(e,t))}function guid(){return"fxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})}function query(t,e){try{return"string"==typeof t?(e??document).querySelector(t):t}catch{return null}}function queryAll(t,e){try{return"string"==typeof t?(e??document).querySelectorAll(t):t??_emptyNodeList}catch{return _emptyNodeList}}function hasClass(t,e){return(null==t?void 0:t.classList.contains(e))??!1}function hasTag(t,e){var n;return(null==(n=null==t?void 0:t.tagName)?void 0:n.toLowerCase())===e}function hasType(t,e){var n;return(null==(n=null==t?void 0:t.type)?void 0:n.toLowerCase())===e}function addClass(t,e){if(t instanceof NodeList)for(let n=0;n<t.length;n++)t[n].classList.add(e);else null==t||t.classList.add(e)}function removeClass(t,e){if(t instanceof NodeList)for(let n=0;n<t.length;n++)t[n].classList.remove(e);else null==t||t.classList.remove(e)}function on(t,e,n,r=!0){(null==t?void 0:t.addEventListener)&&t.addEventListener(e,n,r)}function onWeak(t,e,n,r=!0){addWeakElement(t),on(t,e,n,r)}function off(t,e,n,r=!0){(null==t?void 0:t.removeEventListener)&&t.removeEventListener(e,n,r)}function insertBefore(t,e){var n;null==(n=null==e?void 0:e.parentNode)||n.insertBefore(t,e)}function prev(t){return null==t?void 0:t.previousElementSibling}function next(t){return null==t?void 0:t.nextElementSibling}function parent(t){return null==t?void 0:t.parentElement}function create(t){const e=document.createElement("div");for(let n=0,r=Object.keys(t),a=r.length;n<a;n++){const a=r[n],o=t[a];e.setAttribute(a,o)}return e}function blurActiveElement(){var t;null==(t=document.activeElement)||t.blur()}function queryAllDataUi(t){return queryAll('[data-ui="#'+t+'"]')}function queryDataUi(t){return query('[data-ui="#'+t+'"]')}function updateAllClickable(t){t.id&&hasClass(t,"page")&&(t=queryDataUi(t.id)??t);const e=parent(t);if(!hasClass(e,"tabs")&&!hasClass(e,"tabbed")&&!hasTag(e,"nav"))return;const n=queryAll("a",e);for(let t=0;t<n.length;t++)removeClass(n[t],"active");hasTag(t,"button")||hasClass(t,"button")||hasClass(t,"chip")||addClass(t,"active")}function addWeakElement(t){_weakElements.has(t)||_weakElements.add(t)}function rootSizeInPixels(){const t=getComputedStyle(document.documentElement).getPropertyValue("--size")||"16px";return t.includes("%")?16*parseInt(t)/100:t.includes("em")?16*parseInt(t):parseInt(t)}function updatePlaceholder(t){t.placeholder||(t.placeholder=" ")}function onClickLabel(t){const e=query("input:not([type=file], [type=checkbox], [type=radio]), select, textarea",parent(t.currentTarget));e&&e.focus()}function onFocusInput(t){updateInput(t.currentTarget)}function onBlurInput(t){updateInput(t.currentTarget)}function onChangeFile(t){updateFile(t.currentTarget)}function onChangeColor(t){updateColor(t.currentTarget)}function onKeydownFile(t){updateFile(t.currentTarget,t)}function onKeydownColor(t){updateColor(t.currentTarget,t)}function onPasswordIconClick(t){var e;const n=t.currentTarget,r=query("input",parent(n));r&&(null==(e=n.textContent)?void 0:e.includes("visibility"))&&("password"===r.type?(r.type="text",n.textContent="visibility_off"):(r.type="password",n.textContent="visibility"))}function onInputTextarea(t){updateTextarea(t.currentTarget)}function updateAllLabels(){const t=queryAll(".field > label");for(let e=0;e<t.length;e++)onWeak(t[e],"click",onClickLabel)}function updateAllInputs(){const t=queryAll(".field > input:not([type=file], [type=color], [type=range])");for(let e=0;e<t.length;e++)onWeak(t[e],"focus",onFocusInput),onWeak(t[e],"blur",onBlurInput),updateInput(t[e])}function updateAllSelects(){const t=queryAll(".field > select");for(let e=0;e<t.length;e++)onWeak(t[e],"focus",onFocusInput),onWeak(t[e],"blur",onBlurInput)}function updateAllFiles(){const t=queryAll(".field > input[type=file]");for(let e=0;e<t.length;e++)onWeak(t[e],"change",onChangeFile),updateFile(t[e])}function updateAllColors(){const t=queryAll(".field > input[type=color]");for(let e=0;e<t.length;e++)onWeak(t[e],"change",onChangeColor),updateColor(t[e])}function updateAllTextareas(){const t=queryAll(".field > textarea");for(let e=0;e<t.length;e++)onWeak(t[e],"focus",onFocusInput),onWeak(t[e],"blur",onBlurInput),updatePlaceholder(t[e]),(!isChrome||isMac||isIOS)&&(onWeak(t[e],"input",onInputTextarea),updateTextarea(t[e]))}function updateAllPasswordIcons(){const t=queryAll(".field:has(> input[type=password]) > i, a");for(let e=0;e<t.length;e++)onWeak(t[e],"click",onPasswordIconClick)}function updateInput(t){hasType(t,"number")&&!t.value&&(t.value=""),updatePlaceholder(t)}function updateFile(t,e){if("Enter"===(null==e?void 0:e.key)){const e=prev(t);if(!hasType(e,"file"))return;return void e.click()}const n=next(t);hasType(n,"text")&&(n.value=t.files?Array.from(t.files).map(t=>t.name).join(", "):"",n.readOnly=!0,onWeak(n,"keydown",onKeydownFile,!1),updateInput(n))}function updateColor(t,e){if("Enter"===(null==e?void 0:e.key)){const e=prev(t);if(!hasType(e,"color"))return;return void e.click()}const n=next(t);hasType(n,"text")&&(n.readOnly=!0,n.value=t.value,onWeak(n,"keydown",onKeydownColor,!1),updateInput(n))}function updateTextarea(t){if(updatePlaceholder(t),t.hasAttribute("rows"))return;const e=rootSizeInPixels();t.style.blockSize="auto",t.style.blockSize=t.scrollHeight-e+"px"}function updateAllFields(){updateAllLabels(),updateAllInputs(),updateAllSelects(),updateAllFiles(),updateAllColors(),updateAllTextareas(),updateAllPasswordIcons()}function onInputDocument$1(t){const e=t.target;(hasTag(e,"input")||hasTag(e,"select"))&&("range"===e.type?(e.focus(),updateRange(e)):updateAllRanges())}function onChangeInput(t){if(!window.matchMedia("(pointer: coarse)").matches)return;t.target.blur()}function updateAllRanges(){const t=document.body,e=queryAll(".slider > input[type=range]");e.length?on(t,"input",onInputDocument$1,!1):off(t,"input",onInputDocument$1,!1);for(let t=0;t<e.length;t++)updateRange(e[t])}function updateRange(t){onWeak(t,"change",onChangeInput);const e=parent(t),n=query("span",e),r=queryAll("input",e);if(!r.length||!n)return;const a=rootSizeInPixels(),o=hasClass(e,"max")?0:.25*a*100/r[0].offsetWidth,s=[],c=[];for(let t=0,e=r.length;t<e;t++){const e=parseFloat(r[t].min)||0,n=parseFloat(r[t].max)||100,a=parseFloat(r[t].value)||0,l=100*(a-e)/(n-e),u=o/2-o*l/100;s.push(l+u),c.push(a)}let l=s[0],u=0,d=100-u-l,h=c[0],m=c[1]||0;r.length>1&&(l=Math.abs(s[1]-s[0]),u=s[1]>s[0]?s[0]:s[1],d=100-u-l,m>h&&(h=c[1]||0,m=c[0])),requestAnimationFrame(()=>e.style.cssText=`--_start: ${u}%; --_end: ${d}%; --_value1: '${h}'; --_value2: '${m}';`)}function updateAllSliders(){updateAllRanges()}const _lastTheme={light:"",dark:""};function getMode(){var t;return(null==(t=null==document?void 0:document.body)?void 0:t.classList.contains("dark"))?"dark":"light"}function lastTheme(){if(_lastTheme.light&&_lastTheme.dark)return _lastTheme;const t=document.body,e=document.createElement("body");e.className="light",t.appendChild(e);const n=document.createElement("body");n.className="dark",t.appendChild(n);const r=getComputedStyle(e),a=getComputedStyle(n),o=["--primary","--on-primary","--primary-container","--on-primary-container","--secondary","--on-secondary","--secondary-container","--on-secondary-container","--tertiary","--on-tertiary","--tertiary-container","--on-tertiary-container","--error","--on-error","--error-container","--on-error-container","--background","--on-background","--surface","--on-surface","--surface-variant","--on-surface-variant","--outline","--outline-variant","--shadow","--scrim","--inverse-surface","--inverse-on-surface","--inverse-primary","--surface-dim","--surface-bright","--surface-container-lowest","--surface-container-low","--surface-container","--surface-container-high","--surface-container-highest"];for(let t=0,e=o.length;t<e;t++)_lastTheme.light+=o[t]+":"+r.getPropertyValue(o[t])+";",_lastTheme.dark+=o[t]+":"+a.getPropertyValue(o[t])+";";return t.removeChild(e),t.removeChild(n),_lastTheme}async function updateTheme(t){const e=globalThis,n=document.body;return t&&e.materialDynamicColors?t.light&&t.dark?(_lastTheme.light=t.light,_lastTheme.dark=t.dark,n.setAttribute("style",t[getMode()]),t):e.materialDynamicColors(t).then(t=>{const e=t=>{let e="";for(let n=0,r=Object.keys(t),a=r.length;n<a;n++){const a=r[n],o=t[a];e+="--"+a.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase()+":"+o+";"}return e};return _lastTheme.light=e(t.light),_lastTheme.dark=e(t.dark),n.setAttribute("style",_lastTheme[getMode()]),_lastTheme}):lastTheme()}function updateMode(t){const e=globalThis,n=document.body;if(!n)return t;if(!t)return getMode();"auto"===t&&(t=isDark()?"dark":"light"),n.classList.remove("light","dark"),n.classList.add(t);const r="light"===t?_lastTheme.light:_lastTheme.dark;return e.materialDynamicColors&&n.setAttribute("style",r),getMode()}const _dialogs=[];function onKeydownDialog(t){if("Escape"===t.key){const e=t.currentTarget;updateDialog(e,e)}}function focusOnDialogOrElement(t){(query("[autofocus]",t)??t).focus()}function closeDialog(t,e){removeClass(queryAllDataUi(t.id),"active"),removeClass(t,"active"),removeClass(e,"active"),t.close(),_dialogs.pop();const n=_dialogs[_dialogs.length-1];n&&n.focus()}async function openDialog(t,e,n,r){hasTag(r,"button")||hasClass(r,"button")||hasClass(r,"chip")||addClass(r,"active"),addClass(e,"active"),addClass(t,"active"),n?t.showModal():t.show(),await wait(90),n||on(t,"keydown",onKeydownDialog,!1),_dialogs.push(t),focusOnDialogOrElement(t)}function onClickOverlay(t){const e=t.currentTarget,n=next(e);hasTag(n,"dialog")&&closeDialog(n,e)}async function updateDialog(t,e){blurActiveElement();let n=prev(e);const r=hasClass(e,"active")||e.open,a=hasClass(e,"modal");a||off(e,"keydown",onKeydownDialog,!1),hasClass(n,"overlay")||(n=create({class:"overlay"}),insertBefore(n,e),await wait(90)),a||onWeak(n,"click",onClickOverlay,!1),r?closeDialog(e,n):openDialog(e,n,a,t)}let _timeoutMenu,_timeoutSnackbar;function onClickDocument(t){off(document.body,"click",onClickDocument);const e=t.target,n=queryAll("menu.active");for(let r=0;r<n.length;r++)updateMenu(e,n[r],t)}function focusOnMenuOrInput(t){setTimeout(()=>{const e=query(".field > input",t);e?e.focus():t.focus()},90)}function updateMenu(t,e,n){_timeoutMenu&&clearTimeout(_timeoutMenu),_timeoutMenu=setTimeout(()=>{on(document.body,"click",onClickDocument),hasTag(document.activeElement,"input")||blurActiveElement();const r=hasClass(e,"active"),a=(null==n?void 0:n.target)===t,o=!!t.closest("menu");!r&&o||r&&a?removeClass(e,"active"):(removeClass(queryAll("menu.active"),"active"),addClass(e,"active"),focusOnMenuOrInput(e))},90)}function onClickSnackbar(t){removeClass(t.currentTarget,"active"),_timeoutSnackbar&&clearTimeout(_timeoutSnackbar)}function updateSnackbar(t,e){blurActiveElement();const n=queryAll(".snackbar.active");for(let t=0;t<n.length;t++)removeClass(n[t],"active");addClass(t,"active"),onWeak(t,"click",onClickSnackbar),_timeoutSnackbar&&clearTimeout(_timeoutSnackbar),-1!==e&&(_timeoutSnackbar=setTimeout(()=>{removeClass(t,"active")},e??6e3))}function updatePage(t){const e=parent(t);e&&removeClass(queryAll(":scope > .page",e),"active"),addClass(t,"active")}function onMousedownRipple(t){updateRipple(t)}function onKeydownRipple(t){" "===(null==t?void 0:t.key)&&updateRipple(t)}function updateRipple(t){const e=t instanceof MouseEvent,n=t.currentTarget,r=n.getBoundingClientRect(),a=Math.max(r.width,r.height),o=a/2,s=e?t.clientX-r.left-o:r.width/2-o,c=e?t.clientY-r.top-o:r.height/2-o,l=document.createElement("div");l.className="ripple-js";const u=document.createElement("div");u.style.inlineSize=u.style.blockSize=`${a}px`,u.style.left=`${s}px`,u.style.top=`${c}px`,onWeak(u,"animationend",()=>{l.remove()}),l.appendChild(u),n.appendChild(l)}function updateAllRipples(){const t=queryAll(".slow-ripple, .ripple, .fast-ripple");for(let e=0;e<t.length;e++)onWeak(t[e],"mousedown",onMousedownRipple),onWeak(t[e],"keydown",onKeydownRipple)}function onInputDocument(t){const e=t.target;hasTag(e,"progress")?updateProgress(e):updateAllProgress()}function updateProgress(t){requestAnimationFrame(()=>{if(t.hasAttribute("value")||t.hasAttribute("max"))t.style.setProperty("--_value",String(t.value));else{const e=hasClass(t,"circle")?"50":"100";t.style.setProperty("--_value",e),t.setAttribute("value",e),t.setAttribute("max","100"),t.classList.add("indeterminate")}})}function updateAllProgress(){if(isChrome&&!isMac&&!isIOS)return;const t=document.body,e=queryAll("progress");e.length?on(t,"input",onInputDocument,!1):off(t,"input",onInputDocument,!1);for(let t=0;t<e.length;t++)updateProgress(e[t])}const _context=globalThis;let _timeoutMutation,_mutation;function onMutation(){_timeoutMutation&&clearTimeout(_timeoutMutation),_timeoutMutation=setTimeout(async()=>await _ui(),180)}async function run(t,e,n,r){if(e||(e=query(t.getAttribute("data-ui"))))if(updateAllClickable(t),hasTag(e,"dialog"))requestAnimationFrame(()=>updateDialog(t,e));else if(hasTag(e,"menu"))requestAnimationFrame(()=>updateMenu(t,e,r));else if(hasClass(e,"snackbar"))requestAnimationFrame(()=>updateSnackbar(e,n));else{if(!hasClass(e,"page"))return hasClass(e,"active")?(removeClass(t,"active"),void removeClass(e,"active")):void addClass(e,"active");requestAnimationFrame(()=>updatePage(e))}else t.classList.toggle("active")}function onClickElement(t){run(t.currentTarget,null,null,t)}function onKeydownElement(t){"Enter"===t.key&&run(t.currentTarget,null,null,t)}function setup(){_context.ui||_mutation||!_context.MutationObserver||(_mutation=new MutationObserver(onMutation),_mutation.observe(document.body,{childList:!0,subtree:!0}),onMutation())}function updateAllDataUis(){const t=queryAll("[data-ui]");for(let e=0,n=t.length;e<n;e++)onWeak(t[e],"click",onClickElement),hasTag(t[e],"a")&&!t[e].getAttribute("href")&&onWeak(t[e],"keydown",onKeydownElement)}function _ui(t,e){if(t){if("setup"===t)return void setup();if("guid"===t)return guid();if("mode"===t)return updateMode(e);if("theme"===t)return updateTheme(e);const n=query(t);if(!n)return;run(n,n,e)}updateAllDataUis(),updateAllFields(),updateAllRipples(),updateAllSliders(),updateAllProgress()}function start(){var t;if(_context.ui)return;const e=null==(t=_context.document)?void 0:t.body;!e||e.classList.contains("dark")||e.classList.contains("light")||updateMode("auto"),setup(),_context.ui=_ui}start();const ui=_context.ui;function H(t){return t<0?-1:0===t?0:1}function nt(t,e,n){return(1-n)*t+n*e}function qt(t,e,n){return n<t?t:n>e?e:n}function ut(t,e,n){return n<t?t:n>e?e:n}function Ft(t){return(t%=360)<0&&(t+=360),t}function wt(t){return(t%=360)<0&&(t+=360),t}function Ht(t,e){return wt(e-t)<=180?1:-1}function Lt(t,e){return 180-Math.abs(Math.abs(t-e)-180)}function Ct(t,e){return[t[0]*e[0][0]+t[1]*e[0][1]+t[2]*e[0][2],t[0]*e[1][0]+t[1]*e[1][1]+t[2]*e[1][2],t[0]*e[2][0]+t[1]*e[2][1]+t[2]*e[2][2]]}const zt=[[.41233895,.35762064,.18051042],[.2126,.7152,.0722],[.01932141,.11916382,.95034478]],vt=[[3.2413774792388685,-1.5376652402851851,-.49885366846268053],[-.9691452513005321,1.8758853451067872,.04156585616912061],[.05562093689691305,-.20395524564742123,1.0571799111220335]],xt=[95.047,100,108.883];function ft(t,e,n){return(255<<24|(255&t)<<16|(255&e)<<8|255&n)>>>0}function Et(t){return ft(tt(t[0]),tt(t[1]),tt(t[2]))}function jt(t){return t>>24&255}function mt(t){return t>>16&255}function dt(t){return t>>8&255}function gt(t){return 255&t}function Nt(t,e,n){const r=vt,a=r[0][0]*t+r[0][1]*e+r[0][2]*n,o=r[1][0]*t+r[1][1]*e+r[1][2]*n,s=r[2][0]*t+r[2][1]*e+r[2][2]*n;return ft(tt(a),tt(o),tt(s))}function Yt(t){return Ct([$(mt(t)),$(dt(t)),$(gt(t))],zt)}function Wt(t,e,n){const r=xt,a=(t+16)/116,o=a-n/200,s=ht(e/500+a),c=ht(a),l=ht(o);return Nt(s*r[0],c*r[1],l*r[2])}function Jt(t){const e=$(mt(t)),n=$(dt(t)),r=$(gt(t)),a=zt,o=a[0][0]*e+a[0][1]*n+a[0][2]*r,s=a[1][0]*e+a[1][1]*n+a[1][2]*r,c=a[2][0]*e+a[2][1]*n+a[2][2]*r,l=s/xt[1],u=c/xt[2],d=at(o/xt[0]),h=at(l);return[116*h-16,500*(d-h),200*(h-at(u))]}function Xt(t){const e=tt(Q(t));return ft(e,e,e)}function bt(t){return 116*at(Yt(t)[1]/100)-16}function Q(t){return 100*ht((t+16)/116)}function It(t){return 116*at(t/100)-16}function $(t){const e=t/255;return e<=.040449936?e/12.92*100:100*Math.pow((e+.055)/1.055,2.4)}function tt(t){const e=t/100;let n=0;return n=e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055,qt(0,255,Math.round(255*n))}function $t(){return xt}function at(t){return t>.008856451679035631?Math.pow(t,1/3):(24389/27*t+16)/116}function ht(t){const e=t*t*t;return e>.008856451679035631?e:(116*t-16)/(24389/27)}class W{static make(t=$t(),e=200/Math.PI*Q(50)/100,n=50,r=2,a=!1){const o=t,s=.401288*o[0]+.650173*o[1]+-.051461*o[2],c=-.250268*o[0]+1.204414*o[1]+.045854*o[2],l=-.002079*o[0]+.048952*o[1]+.953127*o[2],u=.8+r/10,d=u>=.9?nt(.59,.69,10*(u-.9)):nt(.525,.59,10*(u-.8));let h=a?1:u*(1-1/3.6*Math.exp((-e-42)/92));h=h>1?1:h<0?0:h;const m=u,f=[h*(100/s)+1-h,h*(100/c)+1-h,h*(100/l)+1-h],g=1/(5*e+1),p=g*g*g*g,k=1-p,C=p*e+.1*k*k*Math.cbrt(5*e),M=Q(n)/t[1],x=1.48+Math.sqrt(M),P=.725/Math.pow(M,.2),I=P,T=[Math.pow(C*f[0]*s/100,.42),Math.pow(C*f[1]*c/100,.42),Math.pow(C*f[2]*l/100,.42)],A=[400*T[0]/(T[0]+27.13),400*T[1]/(T[1]+27.13),400*T[2]/(T[2]+27.13)];return new W(M,(2*A[0]+A[1]+.05*A[2])*P,P,I,d,m,f,C,Math.pow(C,.25),x)}constructor(t,e,n,r,a,o,s,c,l,u){this.n=t,this.aw=e,this.nbb=n,this.ncb=r,this.c=a,this.nc=o,this.rgbD=s,this.fl=c,this.fLRoot=l,this.z=u}}W.DEFAULT=W.make();class N{constructor(t,e,n,r,a,o,s,c,l){this.hue=t,this.chroma=e,this.j=n,this.q=r,this.m=a,this.s=o,this.jstar=s,this.astar=c,this.bstar=l}distance(t){const e=this.jstar-t.jstar,n=this.astar-t.astar,r=this.bstar-t.bstar,a=Math.sqrt(e*e+n*n+r*r);return 1.41*Math.pow(a,.63)}static fromInt(t){return N.fromIntInViewingConditions(t,W.DEFAULT)}static fromIntInViewingConditions(t,e){const n=(65280&t)>>8,r=255&t,a=$((16711680&t)>>16),o=$(n),s=$(r),c=.41233895*a+.35762064*o+.18051042*s,l=.2126*a+.7152*o+.0722*s,u=.01932141*a+.11916382*o+.95034478*s,d=.401288*c+.650173*l-.051461*u,h=-.250268*c+1.204414*l+.045854*u,m=-.002079*c+.048952*l+.953127*u,f=e.rgbD[0]*d,g=e.rgbD[1]*h,p=e.rgbD[2]*m,k=Math.pow(e.fl*Math.abs(f)/100,.42),C=Math.pow(e.fl*Math.abs(g)/100,.42),M=Math.pow(e.fl*Math.abs(p)/100,.42),x=400*H(f)*k/(k+27.13),P=400*H(g)*C/(C+27.13),I=400*H(p)*M/(M+27.13),T=(11*x+-12*P+I)/11,A=(x+P-2*I)/9,D=(20*x+20*P+21*I)/20,L=(40*x+20*P+I)/20,R=180*Math.atan2(A,T)/Math.PI,B=R<0?R+360:R>=360?R-360:R,q=B*Math.PI/180,G=L*e.nbb,K=100*Math.pow(G/e.aw,e.c*e.z),j=4/e.c*Math.sqrt(K/100)*(e.aw+4)*e.fLRoot,Z=B<20.14?B+360:B,it=5e4/13*(.25*(Math.cos(Z*Math.PI/180+2)+3.8))*e.nc*e.ncb*Math.sqrt(T*T+A*A)/(D+.305),st=Math.pow(it,.9)*Math.pow(1.64-Math.pow(.29,e.n),.73),ct=st*Math.sqrt(K/100),pt=ct*e.fLRoot,yt=50*Math.sqrt(st*e.c/(e.aw+4)),kt=(1+100*.007)*K/(1+.007*K),Mt=1/.0228*Math.log(1+.0228*pt),Tt=Mt*Math.cos(q),_t=Mt*Math.sin(q);return new N(B,ct,K,j,pt,yt,kt,Tt,_t)}static fromJch(t,e,n){return N.fromJchInViewingConditions(t,e,n,W.DEFAULT)}static fromJchInViewingConditions(t,e,n,r){const a=4/r.c*Math.sqrt(t/100)*(r.aw+4)*r.fLRoot,o=e*r.fLRoot,s=e/Math.sqrt(t/100),c=50*Math.sqrt(s*r.c/(r.aw+4)),l=n*Math.PI/180,u=(1+100*.007)*t/(1+.007*t),d=1/.0228*Math.log(1+.0228*o),h=d*Math.cos(l),m=d*Math.sin(l);return new N(n,e,t,a,o,c,u,h,m)}static fromUcs(t,e,n){return N.fromUcsInViewingConditions(t,e,n,W.DEFAULT)}static fromUcsInViewingConditions(t,e,n,r){const a=e,o=n,s=Math.sqrt(a*a+o*o),c=(Math.exp(.0228*s)-1)/.0228/r.fLRoot;let l=Math.atan2(o,a)*(180/Math.PI);l<0&&(l+=360);const u=t/(1-.007*(t-100));return N.fromJchInViewingConditions(u,c,l,r)}toInt(){return this.viewed(W.DEFAULT)}viewed(t){const e=0===this.chroma||0===this.j?0:this.chroma/Math.sqrt(this.j/100),n=Math.pow(e/Math.pow(1.64-Math.pow(.29,t.n),.73),1/.9),r=this.hue*Math.PI/180,a=.25*(Math.cos(r+2)+3.8),o=t.aw*Math.pow(this.j/100,1/t.c/t.z),s=a*(5e4/13)*t.nc*t.ncb,c=o/t.nbb,l=Math.sin(r),u=Math.cos(r),d=23*(c+.305)*n/(23*s+11*n*u+108*n*l),h=d*u,m=d*l,f=(460*c+451*h+288*m)/1403,g=(460*c-891*h-261*m)/1403,p=(460*c-220*h-6300*m)/1403,k=Math.max(0,27.13*Math.abs(f)/(400-Math.abs(f))),C=H(f)*(100/t.fl)*Math.pow(k,1/.42),M=Math.max(0,27.13*Math.abs(g)/(400-Math.abs(g))),x=H(g)*(100/t.fl)*Math.pow(M,1/.42),P=Math.max(0,27.13*Math.abs(p)/(400-Math.abs(p))),I=H(p)*(100/t.fl)*Math.pow(P,1/.42),T=C/t.rgbD[0],A=x/t.rgbD[1],D=I/t.rgbD[2];return Nt(1.86206786*T-1.01125463*A+.14918677*D,.38752654*T+.62144744*A-.00897398*D,-.0158415*T-.03412294*A+1.04996444*D)}static fromXyzInViewingConditions(t,e,n,r){const a=.401288*t+.650173*e-.051461*n,o=-.250268*t+1.204414*e+.045854*n,s=-.002079*t+.048952*e+.953127*n,c=r.rgbD[0]*a,l=r.rgbD[1]*o,u=r.rgbD[2]*s,d=Math.pow(r.fl*Math.abs(c)/100,.42),h=Math.pow(r.fl*Math.abs(l)/100,.42),m=Math.pow(r.fl*Math.abs(u)/100,.42),f=400*H(c)*d/(d+27.13),g=400*H(l)*h/(h+27.13),p=400*H(u)*m/(m+27.13),k=(11*f+-12*g+p)/11,C=(f+g-2*p)/9,M=(20*f+20*g+21*p)/20,x=(40*f+20*g+p)/20,P=180*Math.atan2(C,k)/Math.PI,I=P<0?P+360:P>=360?P-360:P,T=I*Math.PI/180,A=x*r.nbb,D=100*Math.pow(A/r.aw,r.c*r.z),L=4/r.c*Math.sqrt(D/100)*(r.aw+4)*r.fLRoot,R=I<20.14?I+360:I,B=5e4/13*(1/4*(Math.cos(R*Math.PI/180+2)+3.8))*r.nc*r.ncb*Math.sqrt(k*k+C*C)/(M+.305),q=Math.pow(B,.9)*Math.pow(1.64-Math.pow(.29,r.n),.73),G=q*Math.sqrt(D/100),K=G*r.fLRoot,j=50*Math.sqrt(q*r.c/(r.aw+4)),Z=(1+100*.007)*D/(1+.007*D),it=Math.log(1+.0228*K)/.0228,st=it*Math.cos(T),ct=it*Math.sin(T);return new N(I,G,D,L,K,j,Z,st,ct)}xyzInViewingConditions(t){const e=0===this.chroma||0===this.j?0:this.chroma/Math.sqrt(this.j/100),n=Math.pow(e/Math.pow(1.64-Math.pow(.29,t.n),.73),1/.9),r=this.hue*Math.PI/180,a=.25*(Math.cos(r+2)+3.8),o=t.aw*Math.pow(this.j/100,1/t.c/t.z),s=a*(5e4/13)*t.nc*t.ncb,c=o/t.nbb,l=Math.sin(r),u=Math.cos(r),d=23*(c+.305)*n/(23*s+11*n*u+108*n*l),h=d*u,m=d*l,f=(460*c+451*h+288*m)/1403,g=(460*c-891*h-261*m)/1403,p=(460*c-220*h-6300*m)/1403,k=Math.max(0,27.13*Math.abs(f)/(400-Math.abs(f))),C=H(f)*(100/t.fl)*Math.pow(k,1/.42),M=Math.max(0,27.13*Math.abs(g)/(400-Math.abs(g))),x=H(g)*(100/t.fl)*Math.pow(M,1/.42),P=Math.max(0,27.13*Math.abs(p)/(400-Math.abs(p))),I=H(p)*(100/t.fl)*Math.pow(P,1/.42),T=C/t.rgbD[0],A=x/t.rgbD[1],D=I/t.rgbD[2];return[1.86206786*T-1.01125463*A+.14918677*D,.38752654*T+.62144744*A-.00897398*D,-.0158415*T-.03412294*A+1.04996444*D]}}class b{static sanitizeRadians(t){return(t+8*Math.PI)%(2*Math.PI)}static trueDelinearized(t){const e=t/100;let n=0;return n=e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055,255*n}static chromaticAdaptation(t){const e=Math.pow(Math.abs(t),.42);return 400*H(t)*e/(e+27.13)}static hueOf(t){const e=Ct(t,b.SCALED_DISCOUNT_FROM_LINRGB),n=b.chromaticAdaptation(e[0]),r=b.chromaticAdaptation(e[1]),a=b.chromaticAdaptation(e[2]),o=(11*n+-12*r+a)/11,s=(n+r-2*a)/9;return Math.atan2(s,o)}static areInCyclicOrder(t,e,n){return b.sanitizeRadians(e-t)<b.sanitizeRadians(n-t)}static intercept(t,e,n){return(e-t)/(n-t)}static lerpPoint(t,e,n){return[t[0]+(n[0]-t[0])*e,t[1]+(n[1]-t[1])*e,t[2]+(n[2]-t[2])*e]}static setCoordinate(t,e,n,r){const a=b.intercept(t[r],e,n[r]);return b.lerpPoint(t,a,n)}static isBounded(t){return 0<=t&&t<=100}static nthVertex(t,e){const n=b.Y_FROM_LINRGB[0],r=b.Y_FROM_LINRGB[1],a=b.Y_FROM_LINRGB[2],o=e%4<=1?0:100,s=e%2==0?0:100;if(e<4){const e=o,c=s,l=(t-e*r-c*a)/n;return b.isBounded(l)?[l,e,c]:[-1,-1,-1]}if(e<8){const e=o,c=s,l=(t-c*n-e*a)/r;return b.isBounded(l)?[c,l,e]:[-1,-1,-1]}{const e=o,c=s,l=(t-e*n-c*r)/a;return b.isBounded(l)?[e,c,l]:[-1,-1,-1]}}static bisectToSegment(t,e){let n=[-1,-1,-1],r=n,a=0,o=0,s=!1,c=!0;for(let l=0;l<12;l++){const u=b.nthVertex(t,l);if(u[0]<0)continue;const d=b.hueOf(u);s?(c||b.areInCyclicOrder(a,d,o))&&(c=!1,b.areInCyclicOrder(a,e,d)?(r=u,o=d):(n=u,a=d)):(n=u,r=u,a=d,o=d,s=!0)}return[n,r]}static midpoint(t,e){return[(t[0]+e[0])/2,(t[1]+e[1])/2,(t[2]+e[2])/2]}static criticalPlaneBelow(t){return Math.floor(t-.5)}static criticalPlaneAbove(t){return Math.ceil(t-.5)}static bisectToLimit(t,e){const n=b.bisectToSegment(t,e);let r=n[0],a=b.hueOf(r),o=n[1];for(let t=0;t<3;t++)if(r[t]!==o[t]){let n=-1,s=255;r[t]<o[t]?(n=b.criticalPlaneBelow(b.trueDelinearized(r[t])),s=b.criticalPlaneAbove(b.trueDelinearized(o[t]))):(n=b.criticalPlaneAbove(b.trueDelinearized(r[t])),s=b.criticalPlaneBelow(b.trueDelinearized(o[t])));for(let c=0;c<8&&!(Math.abs(s-n)<=1);c++){const c=Math.floor((n+s)/2),l=b.CRITICAL_PLANES[c],u=b.setCoordinate(r,l,o,t),d=b.hueOf(u);b.areInCyclicOrder(a,e,d)?(o=u,s=c):(r=u,a=d,n=c)}}return b.midpoint(r,o)}static inverseChromaticAdaptation(t){const e=Math.abs(t),n=Math.max(0,27.13*e/(400-e));return H(t)*Math.pow(n,1/.42)}static findResultByJ(t,e,n){let r=11*Math.sqrt(n);const a=W.DEFAULT,o=1/Math.pow(1.64-Math.pow(.29,a.n),.73),s=.25*(Math.cos(t+2)+3.8)*(5e4/13)*a.nc*a.ncb,c=Math.sin(t),l=Math.cos(t);for(let t=0;t<5;t++){const u=r/100,d=0===e||0===r?0:e/Math.sqrt(u),h=Math.pow(d*o,1/.9),m=a.aw*Math.pow(u,1/a.c/a.z)/a.nbb,f=23*(m+.305)*h/(23*s+11*h*l+108*h*c),g=f*l,p=f*c,k=(460*m+451*g+288*p)/1403,C=(460*m-891*g-261*p)/1403,M=(460*m-220*g-6300*p)/1403,x=Ct([b.inverseChromaticAdaptation(k),b.inverseChromaticAdaptation(C),b.inverseChromaticAdaptation(M)],b.LINRGB_FROM_SCALED_DISCOUNT);if(x[0]<0||x[1]<0||x[2]<0)return 0;const P=b.Y_FROM_LINRGB[0],I=b.Y_FROM_LINRGB[1],T=b.Y_FROM_LINRGB[2],A=P*x[0]+I*x[1]+T*x[2];if(A<=0)return 0;if(4===t||Math.abs(A-n)<.002)return x[0]>100.01||x[1]>100.01||x[2]>100.01?0:Et(x);r-=(A-n)*r/(2*A)}return 0}static solveToInt(t,e,n){if(e<1e-4||n<1e-4||n>99.9999)return Xt(n);const r=(t=wt(t))/180*Math.PI,a=Q(n),o=b.findResultByJ(r,e,a);if(0!==o)return o;return Et(b.bisectToLimit(a,r))}static solveToCam(t,e,n){return N.fromInt(b.solveToInt(t,e,n))}}b.SCALED_DISCOUNT_FROM_LINRGB=[[.001200833568784504,.002389694492170889,.0002795742885861124],[.0005891086651375999,.0029785502573438758,.0003270666104008398],[.00010146692491640572,.0005364214359186694,.0032979401770712076]],b.LINRGB_FROM_SCALED_DISCOUNT=[[1373.2198709594231,-1100.4251190754821,-7.278681089101213],[-271.815969077903,559.6580465940733,-32.46047482791194],[1.9622899599665666,-57.173814538844006,308.7233197812385]],b.Y_FROM_LINRGB=[.2126,.7152,.0722],b.CRITICAL_PLANES=[.015176349177441876,.045529047532325624,.07588174588720938,.10623444424209313,.13658714259697685,.16693984095186062,.19729253930674434,.2276452376616281,.2579979360165119,.28835063437139563,.3188300904430532,.350925934958123,.3848314933096426,.42057480301049466,.458183274052838,.4976837250274023,.5391024159806381,.5824650784040898,.6277969426914107,.6751227633498623,.7244668422128921,.775853049866786,.829304845476233,.8848452951698498,.942497089126609,1.0022825574869039,1.0642236851973577,1.1283421258858297,1.1946592148522128,1.2631959812511864,1.3339731595349034,1.407011200216447,1.4823302800086415,1.5599503113873272,1.6398909516233677,1.7221716113234105,1.8068114625156377,1.8938294463134073,1.9832442801866852,2.075074464868551,2.1693382909216234,2.2660538449872063,2.36523901573795,2.4669114995532007,2.5710888059345764,2.6777882626779785,2.7870270208169257,2.898822059350997,3.0131901897720907,3.1301480604002863,3.2497121605402226,3.3718988244681087,3.4967242352587946,3.624204428461639,3.754355295633311,3.887192587735158,4.022731918402185,4.160988767090289,4.301978482107941,4.445716283538092,4.592217266055746,4.741496401646282,4.893568542229298,5.048448422192488,5.20615066083972,5.3666897647573375,5.5300801301023865,5.696336044816294,5.865471690767354,6.037501145825082,6.212438385869475,6.390297286737924,6.571091626112461,6.7548350853498045,6.941541251256611,7.131223617812143,7.323895587840543,7.5195704746346665,7.7182615035334345,7.919981813454504,8.124744458384042,8.332562408825165,8.543448553206703,8.757415699253682,8.974476575321063,9.194643831691977,9.417930041841839,9.644347703669503,9.873909240696694,10.106627003236781,10.342513269534024,10.58158024687427,10.8238400726681,11.069304815507364,11.317986476196008,11.569896988756009,11.825048221409341,12.083451977536606,12.345119996613247,12.610063955123938,12.878295467455942,13.149826086772048,13.42466730586372,13.702830557985108,13.984327217668513,14.269168601521828,14.55736596900856,14.848930523210871,15.143873411576273,15.44220572664832,15.743938506781891,16.04908273684337,16.35764934889634,16.66964922287304,16.985093187232053,17.30399201960269,17.62635644741625,17.95219714852476,18.281524751807332,18.614349837764564,18.95068293910138,19.290534541298456,19.633915083172692,19.98083495742689,20.331304511189067,20.685334046541502,21.042933821039977,21.404114048223256,21.76888489811322,22.137256497705877,22.50923893145328,22.884842241736916,23.264076429332462,23.6469514538663,24.033477234264016,24.42366364919083,24.817520537484558,25.21505769858089,25.61628489293138,26.021211842414342,26.429848230738664,26.842203703840827,27.258287870275353,27.678110301598522,28.10168053274597,28.529008062403893,28.96010235337422,29.39497283293396,29.83362889318845,30.276079891419332,30.722335150426627,31.172403958865512,31.62629557157785,32.08401920991837,32.54558406207592,33.010999283389665,33.4802739966603,33.953417292456834,34.430438229418264,34.911345834551085,35.39614910352207,35.88485700094671,36.37747846067349,36.87402238606382,37.37449765026789,37.87891309649659,38.38727753828926,38.89959975977785,39.41588851594697,39.93615253289054,40.460400508064545,40.98864111053629,41.520882981230194,42.05713473317016,42.597404951718396,43.141702194811224,43.6900349931913,44.24241185063697,44.798841244188324,45.35933162437017,45.92389141541209,46.49252901546552,47.065252796817916,47.64207110610409,48.22299226451468,48.808024568002054,49.3971762874833,49.9904556690408,50.587870934119984,51.189430279724725,51.79514187861014,52.40501387947288,53.0190544071392,53.637271562750364,54.259673423945976,54.88626804504493,55.517063457223934,56.15206766869424,56.79128866487574,57.43473440856916,58.08241284012621,58.734331877617365,59.39049941699807,60.05092333227251,60.715611475655585,61.38457167773311,62.057811747619894,62.7353394731159,63.417162620860914,64.10328893648692,64.79372614476921,65.48848194977529,66.18756403501224,66.89098006357258,67.59873767827808,68.31084450182222,69.02730813691093,69.74813616640164,70.47333615344107,71.20291564160104,71.93688215501312,72.67524319850172,73.41800625771542,74.16517879925733,74.9167682708136,75.67278210128072,76.43322770089146,77.1981124613393,77.96744375590167,78.74122893956174,79.51947534912904,80.30219030335869,81.08938110306934,81.88105503125999,82.67721935322541,83.4778813166706,84.28304815182372,85.09272707154808,85.90692527145302,86.72564993000343,87.54890820862819,88.3767072518277,89.2090541872801,90.04595612594655,90.88742016217518,91.73345337380438,92.58406282226491,93.43925555268066,94.29903859396902,95.16341895893969,96.03240364439274,96.9059996312159,97.78421388448044,98.6670533535366,99.55452497210776];class O{static from(t,e,n){return new O(b.solveToInt(t,e,n))}static fromInt(t){return new O(t)}toInt(){return this.argb}get hue(){return this.internalHue}set hue(t){this.setInternalState(b.solveToInt(t,this.internalChroma,this.internalTone))}get chroma(){return this.internalChroma}set chroma(t){this.setInternalState(b.solveToInt(this.internalHue,t,this.internalTone))}get tone(){return this.internalTone}set tone(t){this.setInternalState(b.solveToInt(this.internalHue,this.internalChroma,t))}constructor(t){this.argb=t;const e=N.fromInt(t);this.internalHue=e.hue,this.internalChroma=e.chroma,this.internalTone=bt(t),this.argb=t}setInternalState(t){const e=N.fromInt(t);this.internalHue=e.hue,this.internalChroma=e.chroma,this.internalTone=bt(t),this.argb=t}inViewingConditions(t){const e=N.fromInt(this.toInt()).xyzInViewingConditions(t),n=N.fromXyzInViewingConditions(e[0],e[1],e[2],W.make());return O.from(n.hue,n.chroma,It(e[1]))}}class Dt{static harmonize(t,e){const n=O.fromInt(t),r=O.fromInt(e),a=Lt(n.hue,r.hue),o=Math.min(.5*a,15),s=wt(n.hue+o*Ht(n.hue,r.hue));return O.from(s,n.chroma,n.tone).toInt()}static hctHue(t,e,n){const r=Dt.cam16Ucs(t,e,n),a=N.fromInt(r),o=N.fromInt(t);return O.from(a.hue,o.chroma,bt(t)).toInt()}static cam16Ucs(t,e,n){const r=N.fromInt(t),a=N.fromInt(e),o=r.jstar,s=r.astar,c=r.bstar,l=o+(a.jstar-o)*n,u=s+(a.astar-s)*n,d=c+(a.bstar-c)*n;return N.fromUcs(l,u,d).toInt()}}class z{static ratioOfTones(t,e){return t=ut(0,100,t),e=ut(0,100,e),z.ratioOfYs(Q(t),Q(e))}static ratioOfYs(t,e){const n=t>e?t:e;return(n+5)/((n===e?t:e)+5)}static lighter(t,e){if(t<0||t>100)return-1;const n=Q(t),r=e*(n+5)-5,a=z.ratioOfYs(r,n),o=Math.abs(a-e);if(a<e&&o>.04)return-1;const s=It(r)+.4;return s<0||s>100?-1:s}static darker(t,e){if(t<0||t>100)return-1;const n=Q(t),r=(n+5)/e-5,a=z.ratioOfYs(n,r),o=Math.abs(a-e);if(a<e&&o>.04)return-1;const s=It(r)-.4;return s<0||s>100?-1:s}static lighterUnsafe(t,e){const n=z.lighter(t,e);return n<0?100:n}static darkerUnsafe(t,e){const n=z.darker(t,e);return n<0?0:n}}class At{static isDisliked(t){const e=Math.round(t.hue)>=90&&Math.round(t.hue)<=111,n=Math.round(t.chroma)>16,r=Math.round(t.tone)<65;return e&&n&&r}static fixIfDisliked(t){return At.isDisliked(t)?O.from(t.hue,t.chroma,70):t}}class y{static fromPalette(t){return new y(t.name??"",t.palette,t.tone,t.isBackground??!1,t.background,t.secondBackground,t.contrastCurve,t.toneDeltaPair)}constructor(t,e,n,r,a,o,s,c){if(this.name=t,this.palette=e,this.tone=n,this.isBackground=r,this.background=a,this.secondBackground=o,this.contrastCurve=s,this.toneDeltaPair=c,this.hctCache=new Map,!a&&o)throw new Error(`Color ${t} has secondBackgrounddefined, but background is not defined.`);if(!a&&s)throw new Error(`Color ${t} has contrastCurvedefined, but background is not defined.`);if(a&&!s)throw new Error(`Color ${t} has backgrounddefined, but contrastCurve is not defined.`)}getArgb(t){return this.getHct(t).toInt()}getHct(t){const e=this.hctCache.get(t);if(null!=e)return e;const n=this.getTone(t),r=this.palette(t).getHct(n);return this.hctCache.size>4&&this.hctCache.clear(),this.hctCache.set(t,r),r}getTone(t){const e=t.contrastLevel<0;if(this.toneDeltaPair){const n=this.toneDeltaPair(t),r=n.roleA,a=n.roleB,o=n.delta,s=n.polarity,c=n.stayTogether,l=this.background(t).getTone(t),u="nearer"===s||"lighter"===s&&!t.isDark||"darker"===s&&t.isDark,d=u?r:a,h=u?a:r,m=this.name===d.name,f=t.isDark?1:-1,g=d.contrastCurve.get(t.contrastLevel),p=h.contrastCurve.get(t.contrastLevel),k=d.tone(t);let C=z.ratioOfTones(l,k)>=g?k:y.foregroundTone(l,g);const M=h.tone(t);let x=z.ratioOfTones(l,M)>=p?M:y.foregroundTone(l,p);return e&&(C=y.foregroundTone(l,g),x=y.foregroundTone(l,p)),(x-C)*f>=o||(x=ut(0,100,C+o*f),(x-C)*f>=o||(C=ut(0,100,x-o*f))),50<=C&&C<60?f>0?(C=60,x=Math.max(x,C+o*f)):(C=49,x=Math.min(x,C+o*f)):50<=x&&x<60&&(c?f>0?(C=60,x=Math.max(x,C+o*f)):(C=49,x=Math.min(x,C+o*f)):x=f>0?60:49),m?C:x}{let n=this.tone(t);if(null==this.background)return n;const r=this.background(t).getTone(t),a=this.contrastCurve.get(t.contrastLevel);if(z.ratioOfTones(r,n)>=a||(n=y.foregroundTone(r,a)),e&&(n=y.foregroundTone(r,a)),this.isBackground&&50<=n&&n<60&&(n=z.ratioOfTones(49,r)>=a?49:60),this.secondBackground){const[e,r]=[this.background,this.secondBackground],[o,s]=[e(t).getTone(t),r(t).getTone(t)],[c,l]=[Math.max(o,s),Math.min(o,s)];if(z.ratioOfTones(c,n)>=a&&z.ratioOfTones(l,n)>=a)return n;const u=z.lighter(c,a),d=z.darker(l,a),h=[];return-1!==u&&h.push(u),-1!==d&&h.push(d),y.tonePrefersLightForeground(o)||y.tonePrefersLightForeground(s)?u<0?100:u:1===h.length?h[0]:d<0?0:d}return n}}static foregroundTone(t,e){const n=z.lighterUnsafe(t,e),r=z.darkerUnsafe(t,e),a=z.ratioOfTones(n,t),o=z.ratioOfTones(r,t);if(y.tonePrefersLightForeground(t)){const t=Math.abs(a-o)<.1&&a<e&&o<e;return a>=e||a>=o||t?n:r}return o>=e||o>=a?r:n}static tonePrefersLightForeground(t){return Math.round(t)<60}static toneAllowsLightForeground(t){return Math.round(t)<=49}static enableLightForeground(t){return y.tonePrefersLightForeground(t)&&!y.toneAllowsLightForeground(t)?49:t}}class _{static fromInt(t){const e=O.fromInt(t);return _.fromHct(e)}static fromHct(t){return new _(t.hue,t.chroma,t)}static fromHueAndChroma(t,e){const n=new Kt(t,e).create();return new _(t,e,n)}constructor(t,e,n){this.hue=t,this.chroma=e,this.keyColor=n,this.cache=new Map}tone(t){let e=this.cache.get(t);return void 0===e&&(e=O.from(this.hue,this.chroma,t).toInt(),this.cache.set(t,e)),e}getHct(t){return O.fromInt(this.tone(t))}}class Kt{constructor(t,e){this.hue=t,this.requestedChroma=e,this.chromaCache=new Map,this.maxChromaValue=200}create(){let t=0,e=100;for(;t<e;){const n=Math.floor((t+e)/2),r=this.maxChroma(n)<this.maxChroma(n+1);if(this.maxChroma(n)>=this.requestedChroma-.01)if(Math.abs(t-50)<Math.abs(e-50))e=n;else{if(t===n)return O.from(this.hue,this.requestedChroma,t);t=n}else r?t=n+1:e=n}return O.from(this.hue,this.requestedChroma,t)}maxChroma(t){if(this.chromaCache.has(t))return this.chromaCache.get(t);const e=O.from(this.hue,this.maxChromaValue,t).chroma;return this.chromaCache.set(t,e),e}}class w{constructor(t,e,n,r){this.low=t,this.normal=e,this.medium=n,this.high=r}get(t){return t<=-1?this.low:t<0?nt(this.low,this.normal,(t- -1)/1):t<.5?nt(this.normal,this.medium,(t-0)/.5):t<1?nt(this.medium,this.high,(t-.5)/.5):this.high}}class v{constructor(t,e,n,r,a){this.roleA=t,this.roleB=e,this.delta=n,this.polarity=r,this.stayTogether=a}}var ot;function et(t){return t.variant===ot.FIDELITY||t.variant===ot.CONTENT}function E(t){return t.variant===ot.MONOCHROME}function Qt(t,e,n,r){let a=n,o=O.from(t,e,n);if(o.chroma<e){let n=o.chroma;for(;o.chroma<e;){a+=r?-1:1;const s=O.from(t,e,a);if(n>s.chroma||Math.abs(s.chroma-e)<.4)break;Math.abs(s.chroma-e)<Math.abs(o.chroma-e)&&(o=s),n=Math.max(n,s.chroma)}}return a}!function(t){t[t.MONOCHROME=0]="MONOCHROME",t[t.NEUTRAL=1]="NEUTRAL",t[t.TONAL_SPOT=2]="TONAL_SPOT",t[t.VIBRANT=3]="VIBRANT",t[t.EXPRESSIVE=4]="EXPRESSIVE",t[t.FIDELITY=5]="FIDELITY",t[t.CONTENT=6]="CONTENT",t[t.RAINBOW=7]="RAINBOW",t[t.FRUIT_SALAD=8]="FRUIT_SALAD"}(ot||(ot={}));class i{static highestSurface(t){return t.isDark?i.surfaceBright:i.surfaceDim}}i.contentAccentToneDelta=15,i.primaryPaletteKeyColor=y.fromPalette({name:"primary_palette_key_color",palette:t=>t.primaryPalette,tone:t=>t.primaryPalette.keyColor.tone}),i.secondaryPaletteKeyColor=y.fromPalette({name:"secondary_palette_key_color",palette:t=>t.secondaryPalette,tone:t=>t.secondaryPalette.keyColor.tone}),i.tertiaryPaletteKeyColor=y.fromPalette({name:"tertiary_palette_key_color",palette:t=>t.tertiaryPalette,tone:t=>t.tertiaryPalette.keyColor.tone}),i.neutralPaletteKeyColor=y.fromPalette({name:"neutral_palette_key_color",palette:t=>t.neutralPalette,tone:t=>t.neutralPalette.keyColor.tone}),i.neutralVariantPaletteKeyColor=y.fromPalette({name:"neutral_variant_palette_key_color",palette:t=>t.neutralVariantPalette,tone:t=>t.neutralVariantPalette.keyColor.tone}),i.background=y.fromPalette({name:"background",palette:t=>t.neutralPalette,tone:t=>t.isDark?6:98,isBackground:!0}),i.onBackground=y.fromPalette({name:"on_background",palette:t=>t.neutralPalette,tone:t=>t.isDark?90:10,background:t=>i.background,contrastCurve:new w(3,3,4.5,7)}),i.surface=y.fromPalette({name:"surface",palette:t=>t.neutralPalette,tone:t=>t.isDark?6:98,isBackground:!0}),i.surfaceDim=y.fromPalette({name:"surface_dim",palette:t=>t.neutralPalette,tone:t=>t.isDark?6:new w(87,87,80,75).get(t.contrastLevel),isBackground:!0}),i.surfaceBright=y.fromPalette({name:"surface_bright",palette:t=>t.neutralPalette,tone:t=>t.isDark?new w(24,24,29,34).get(t.contrastLevel):98,isBackground:!0}),i.surfaceContainerLowest=y.fromPalette({name:"surface_container_lowest",palette:t=>t.neutralPalette,tone:t=>t.isDark?new w(4,4,2,0).get(t.contrastLevel):100,isBackground:!0}),i.surfaceContainerLow=y.fromPalette({name:"surface_container_low",palette:t=>t.neutralPalette,tone:t=>t.isDark?new w(10,10,11,12).get(t.contrastLevel):new w(96,96,96,95).get(t.contrastLevel),isBackground:!0}),i.surfaceContainer=y.fromPalette({name:"surface_container",palette:t=>t.neutralPalette,tone:t=>t.isDark?new w(12,12,16,20).get(t.contrastLevel):new w(94,94,92,90).get(t.contrastLevel),isBackground:!0}),i.surfaceContainerHigh=y.fromPalette({name:"surface_container_high",palette:t=>t.neutralPalette,tone:t=>t.isDark?new w(17,17,21,25).get(t.contrastLevel):new w(92,92,88,85).get(t.contrastLevel),isBackground:!0}),i.surfaceContainerHighest=y.fromPalette({name:"surface_container_highest",palette:t=>t.neutralPalette,tone:t=>t.isDark?new w(22,22,26,30).get(t.contrastLevel):new w(90,90,84,80).get(t.contrastLevel),isBackground:!0}),i.onSurface=y.fromPalette({name:"on_surface",palette:t=>t.neutralPalette,tone:t=>t.isDark?90:10,background:t=>i.highestSurface(t),contrastCurve:new w(4.5,7,11,21)}),i.surfaceVariant=y.fromPalette({name:"surface_variant",palette:t=>t.neutralVariantPalette,tone:t=>t.isDark?30:90,isBackground:!0}),i.onSurfaceVariant=y.fromPalette({name:"on_surface_variant",palette:t=>t.neutralVariantPalette,tone:t=>t.isDark?80:30,background:t=>i.highestSurface(t),contrastCurve:new w(3,4.5,7,11)}),i.inverseSurface=y.fromPalette({name:"inverse_surface",palette:t=>t.neutralPalette,tone:t=>t.isDark?90:20}),i.inverseOnSurface=y.fromPalette({name:"inverse_on_surface",palette:t=>t.neutralPalette,tone:t=>t.isDark?20:95,background:t=>i.inverseSurface,contrastCurve:new w(4.5,7,11,21)}),i.outline=y.fromPalette({name:"outline",palette:t=>t.neutralVariantPalette,tone:t=>t.isDark?60:50,background:t=>i.highestSurface(t),contrastCurve:new w(1.5,3,4.5,7)}),i.outlineVariant=y.fromPalette({name:"outline_variant",palette:t=>t.neutralVariantPalette,tone:t=>t.isDark?30:80,background:t=>i.highestSurface(t),contrastCurve:new w(1,1,3,4.5)}),i.shadow=y.fromPalette({name:"shadow",palette:t=>t.neutralPalette,tone:t=>0}),i.scrim=y.fromPalette({name:"scrim",palette:t=>t.neutralPalette,tone:t=>0}),i.surfaceTint=y.fromPalette({name:"surface_tint",palette:t=>t.primaryPalette,tone:t=>t.isDark?80:40,isBackground:!0}),i.primary=y.fromPalette({name:"primary",palette:t=>t.primaryPalette,tone:t=>E(t)?t.isDark?100:0:t.isDark?80:40,isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(3,4.5,7,7),toneDeltaPair:t=>new v(i.primaryContainer,i.primary,10,"nearer",!1)}),i.onPrimary=y.fromPalette({name:"on_primary",palette:t=>t.primaryPalette,tone:t=>E(t)?t.isDark?10:90:t.isDark?20:100,background:t=>i.primary,contrastCurve:new w(4.5,7,11,21)}),i.primaryContainer=y.fromPalette({name:"primary_container",palette:t=>t.primaryPalette,tone:t=>et(t)?t.sourceColorHct.tone:E(t)?t.isDark?85:25:t.isDark?30:90,isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(1,1,3,4.5),toneDeltaPair:t=>new v(i.primaryContainer,i.primary,10,"nearer",!1)}),i.onPrimaryContainer=y.fromPalette({name:"on_primary_container",palette:t=>t.primaryPalette,tone:t=>et(t)?y.foregroundTone(i.primaryContainer.tone(t),4.5):E(t)?t.isDark?0:100:t.isDark?90:30,background:t=>i.primaryContainer,contrastCurve:new w(3,4.5,7,11)}),i.inversePrimary=y.fromPalette({name:"inverse_primary",palette:t=>t.primaryPalette,tone:t=>t.isDark?40:80,background:t=>i.inverseSurface,contrastCurve:new w(3,4.5,7,7)}),i.secondary=y.fromPalette({name:"secondary",palette:t=>t.secondaryPalette,tone:t=>t.isDark?80:40,isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(3,4.5,7,7),toneDeltaPair:t=>new v(i.secondaryContainer,i.secondary,10,"nearer",!1)}),i.onSecondary=y.fromPalette({name:"on_secondary",palette:t=>t.secondaryPalette,tone:t=>E(t)?t.isDark?10:100:t.isDark?20:100,background:t=>i.secondary,contrastCurve:new w(4.5,7,11,21)}),i.secondaryContainer=y.fromPalette({name:"secondary_container",palette:t=>t.secondaryPalette,tone:t=>{const e=t.isDark?30:90;return E(t)?t.isDark?30:85:et(t)?Qt(t.secondaryPalette.hue,t.secondaryPalette.chroma,e,!t.isDark):e},isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(1,1,3,4.5),toneDeltaPair:t=>new v(i.secondaryContainer,i.secondary,10,"nearer",!1)}),i.onSecondaryContainer=y.fromPalette({name:"on_secondary_container",palette:t=>t.secondaryPalette,tone:t=>E(t)?t.isDark?90:10:et(t)?y.foregroundTone(i.secondaryContainer.tone(t),4.5):t.isDark?90:30,background:t=>i.secondaryContainer,contrastCurve:new w(3,4.5,7,11)}),i.tertiary=y.fromPalette({name:"tertiary",palette:t=>t.tertiaryPalette,tone:t=>E(t)?t.isDark?90:25:t.isDark?80:40,isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(3,4.5,7,7),toneDeltaPair:t=>new v(i.tertiaryContainer,i.tertiary,10,"nearer",!1)}),i.onTertiary=y.fromPalette({name:"on_tertiary",palette:t=>t.tertiaryPalette,tone:t=>E(t)?t.isDark?10:90:t.isDark?20:100,background:t=>i.tertiary,contrastCurve:new w(4.5,7,11,21)}),i.tertiaryContainer=y.fromPalette({name:"tertiary_container",palette:t=>t.tertiaryPalette,tone:t=>{if(E(t))return t.isDark?60:49;if(!et(t))return t.isDark?30:90;const e=t.tertiaryPalette.getHct(t.sourceColorHct.tone);return At.fixIfDisliked(e).tone},isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(1,1,3,4.5),toneDeltaPair:t=>new v(i.tertiaryContainer,i.tertiary,10,"nearer",!1)}),i.onTertiaryContainer=y.fromPalette({name:"on_tertiary_container",palette:t=>t.tertiaryPalette,tone:t=>E(t)?t.isDark?0:100:et(t)?y.foregroundTone(i.tertiaryContainer.tone(t),4.5):t.isDark?90:30,background:t=>i.tertiaryContainer,contrastCurve:new w(3,4.5,7,11)}),i.error=y.fromPalette({name:"error",palette:t=>t.errorPalette,tone:t=>t.isDark?80:40,isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(3,4.5,7,7),toneDeltaPair:t=>new v(i.errorContainer,i.error,10,"nearer",!1)}),i.onError=y.fromPalette({name:"on_error",palette:t=>t.errorPalette,tone:t=>t.isDark?20:100,background:t=>i.error,contrastCurve:new w(4.5,7,11,21)}),i.errorContainer=y.fromPalette({name:"error_container",palette:t=>t.errorPalette,tone:t=>t.isDark?30:90,isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(1,1,3,4.5),toneDeltaPair:t=>new v(i.errorContainer,i.error,10,"nearer",!1)}),i.onErrorContainer=y.fromPalette({name:"on_error_container",palette:t=>t.errorPalette,tone:t=>E(t)?t.isDark?90:10:t.isDark?90:30,background:t=>i.errorContainer,contrastCurve:new w(3,4.5,7,11)}),i.primaryFixed=y.fromPalette({name:"primary_fixed",palette:t=>t.primaryPalette,tone:t=>E(t)?40:90,isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(1,1,3,4.5),toneDeltaPair:t=>new v(i.primaryFixed,i.primaryFixedDim,10,"lighter",!0)}),i.primaryFixedDim=y.fromPalette({name:"primary_fixed_dim",palette:t=>t.primaryPalette,tone:t=>E(t)?30:80,isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(1,1,3,4.5),toneDeltaPair:t=>new v(i.primaryFixed,i.primaryFixedDim,10,"lighter",!0)}),i.onPrimaryFixed=y.fromPalette({name:"on_primary_fixed",palette:t=>t.primaryPalette,tone:t=>E(t)?100:10,background:t=>i.primaryFixedDim,secondBackground:t=>i.primaryFixed,contrastCurve:new w(4.5,7,11,21)}),i.onPrimaryFixedVariant=y.fromPalette({name:"on_primary_fixed_variant",palette:t=>t.primaryPalette,tone:t=>E(t)?90:30,background:t=>i.primaryFixedDim,secondBackground:t=>i.primaryFixed,contrastCurve:new w(3,4.5,7,11)}),i.secondaryFixed=y.fromPalette({name:"secondary_fixed",palette:t=>t.secondaryPalette,tone:t=>E(t)?80:90,isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(1,1,3,4.5),toneDeltaPair:t=>new v(i.secondaryFixed,i.secondaryFixedDim,10,"lighter",!0)}),i.secondaryFixedDim=y.fromPalette({name:"secondary_fixed_dim",palette:t=>t.secondaryPalette,tone:t=>E(t)?70:80,isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(1,1,3,4.5),toneDeltaPair:t=>new v(i.secondaryFixed,i.secondaryFixedDim,10,"lighter",!0)}),i.onSecondaryFixed=y.fromPalette({name:"on_secondary_fixed",palette:t=>t.secondaryPalette,tone:t=>10,background:t=>i.secondaryFixedDim,secondBackground:t=>i.secondaryFixed,contrastCurve:new w(4.5,7,11,21)}),i.onSecondaryFixedVariant=y.fromPalette({name:"on_secondary_fixed_variant",palette:t=>t.secondaryPalette,tone:t=>E(t)?25:30,background:t=>i.secondaryFixedDim,secondBackground:t=>i.secondaryFixed,contrastCurve:new w(3,4.5,7,11)}),i.tertiaryFixed=y.fromPalette({name:"tertiary_fixed",palette:t=>t.tertiaryPalette,tone:t=>E(t)?40:90,isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(1,1,3,4.5),toneDeltaPair:t=>new v(i.tertiaryFixed,i.tertiaryFixedDim,10,"lighter",!0)}),i.tertiaryFixedDim=y.fromPalette({name:"tertiary_fixed_dim",palette:t=>t.tertiaryPalette,tone:t=>E(t)?30:80,isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(1,1,3,4.5),toneDeltaPair:t=>new v(i.tertiaryFixed,i.tertiaryFixedDim,10,"lighter",!0)}),i.onTertiaryFixed=y.fromPalette({name:"on_tertiary_fixed",palette:t=>t.tertiaryPalette,tone:t=>E(t)?100:10,background:t=>i.tertiaryFixedDim,secondBackground:t=>i.tertiaryFixed,contrastCurve:new w(4.5,7,11,21)}),i.onTertiaryFixedVariant=y.fromPalette({name:"on_tertiary_fixed_variant",palette:t=>t.tertiaryPalette,tone:t=>E(t)?90:30,background:t=>i.tertiaryFixedDim,secondBackground:t=>i.tertiaryFixed,contrastCurve:new w(3,4.5,7,11)});class S{static of(t){return new S(t,!1)}static contentOf(t){return new S(t,!0)}static fromColors(t){return S.createPaletteFromColors(!1,t)}static contentFromColors(t){return S.createPaletteFromColors(!0,t)}static createPaletteFromColors(t,e){const n=new S(e.primary,t);if(e.secondary){const r=new S(e.secondary,t);n.a2=r.a1}if(e.tertiary){const r=new S(e.tertiary,t);n.a3=r.a1}if(e.error){const r=new S(e.error,t);n.error=r.a1}if(e.neutral){const r=new S(e.neutral,t);n.n1=r.n1}if(e.neutralVariant){const r=new S(e.neutralVariant,t);n.n2=r.n2}return n}constructor(t,e){const n=O.fromInt(t),r=n.hue,a=n.chroma;e?(this.a1=_.fromHueAndChroma(r,a),this.a2=_.fromHueAndChroma(r,a/3),this.a3=_.fromHueAndChroma(r+60,a/2),this.n1=_.fromHueAndChroma(r,Math.min(a/12,4)),this.n2=_.fromHueAndChroma(r,Math.min(a/6,8))):(this.a1=_.fromHueAndChroma(r,Math.max(48,a)),this.a2=_.fromHueAndChroma(r,16),this.a3=_.fromHueAndChroma(r+60,24),this.n1=_.fromHueAndChroma(r,4),this.n2=_.fromHueAndChroma(r,8)),this.error=_.fromHueAndChroma(25,84)}}class Zt{fromInt(t){return Jt(t)}toInt(t){return Wt(t[0],t[1],t[2])}distance(t,e){const n=t[0]-e[0],r=t[1]-e[1],a=t[2]-e[2];return n*n+r*r+a*a}}const te=10,ee=3;class re{static quantize(t,e,n){const r=new Map,a=new Array,o=new Array,s=new Zt;let c=0;for(let e=0;e<t.length;e++){const n=t[e],l=r.get(n);void 0===l?(c++,a.push(s.fromInt(n)),o.push(n),r.set(n,1)):r.set(n,l+1)}const l=new Array;for(let t=0;t<c;t++){const e=o[t],n=r.get(e);void 0!==n&&(l[t]=n)}let u=Math.min(n,c);e.length>0&&(u=Math.min(u,e.length));const d=new Array;for(let t=0;t<e.length;t++)d.push(s.fromInt(e[t]));const h=u-d.length;if(0===e.length&&h>0)for(let t=0;t<h;t++){const t=100*Math.random(),e=201*Math.random()-100,n=201*Math.random()-100;d.push(new Array(t,e,n))}const m=new Array;for(let t=0;t<c;t++)m.push(Math.floor(Math.random()*u));const f=new Array;for(let t=0;t<u;t++){f.push(new Array);for(let e=0;e<u;e++)f[t].push(0)}const g=new Array;for(let t=0;t<u;t++){g.push(new Array);for(let e=0;e<u;e++)g[t].push(new ne)}const p=new Array;for(let t=0;t<u;t++)p.push(0);for(let t=0;t<10;t++){for(let t=0;t<u;t++){for(let e=t+1;e<u;e++){const n=s.distance(d[t],d[e]);g[e][t].distance=n,g[e][t].index=t,g[t][e].distance=n,g[t][e].index=e}g[t].sort();for(let e=0;e<u;e++)f[t][e]=g[t][e].index}let e=0;for(let t=0;t<c;t++){const n=a[t],r=m[t],o=d[r],c=s.distance(n,o);let l=c,h=-1;for(let t=0;t<u;t++){if(g[r][t].distance>=4*c)continue;const e=s.distance(n,d[t]);e<l&&(l=e,h=t)}-1!==h&&Math.abs(Math.sqrt(l)-Math.sqrt(c))>3&&(e++,m[t]=h)}if(0===e&&0!==t)break;const n=new Array(u).fill(0),r=new Array(u).fill(0),o=new Array(u).fill(0);for(let t=0;t<u;t++)p[t]=0;for(let t=0;t<c;t++){const e=m[t],s=a[t],c=l[t];p[e]+=c,n[e]+=s[0]*c,r[e]+=s[1]*c,o[e]+=s[2]*c}for(let t=0;t<u;t++){const e=p[t];if(0===e){d[t]=[0,0,0];continue}const a=n[t]/e,s=r[t]/e,c=o[t]/e;d[t]=[a,s,c]}}const k=new Map;for(let t=0;t<u;t++){const e=p[t];if(0===e)continue;const n=s.toInt(d[t]);k.has(n)||k.set(n,e)}return k}}class ne{constructor(){this.distance=-1,this.index=-1}}class ae{static quantize(t){const e=new Map;for(let n=0;n<t.length;n++){const r=t[n];jt(r)<255||e.set(r,(e.get(r)??0)+1)}return e}}const lt=5,Y=33,rt=35937,V={RED:"red",GREEN:"green",BLUE:"blue"};class oe{constructor(t=[],e=[],n=[],r=[],a=[],o=[]){this.weights=t,this.momentsR=e,this.momentsG=n,this.momentsB=r,this.moments=a,this.cubes=o}quantize(t,e){this.constructHistogram(t),this.computeMoments();const n=this.createBoxes(e);return this.createResult(n.resultCount)}constructHistogram(t){this.weights=Array.from({length:rt}).fill(0),this.momentsR=Array.from({length:rt}).fill(0),this.momentsG=Array.from({length:rt}).fill(0),this.momentsB=Array.from({length:rt}).fill(0),this.moments=Array.from({length:rt}).fill(0);const e=ae.quantize(t);for(const[t,n]of e.entries()){const e=mt(t),r=dt(t),a=gt(t),o=3,s=1+(e>>o),c=1+(r>>o),l=1+(a>>o),u=this.getIndex(s,c,l);this.weights[u]=(this.weights[u]??0)+n,this.momentsR[u]+=n*e,this.momentsG[u]+=n*r,this.momentsB[u]+=n*a,this.moments[u]+=n*(e*e+r*r+a*a)}}computeMoments(){for(let t=1;t<Y;t++){const e=Array.from({length:Y}).fill(0),n=Array.from({length:Y}).fill(0),r=Array.from({length:Y}).fill(0),a=Array.from({length:Y}).fill(0),o=Array.from({length:Y}).fill(0);for(let s=1;s<Y;s++){let c=0,l=0,u=0,d=0,h=0;for(let m=1;m<Y;m++){const f=this.getIndex(t,s,m);c+=this.weights[f],l+=this.momentsR[f],u+=this.momentsG[f],d+=this.momentsB[f],h+=this.moments[f],e[m]+=c,n[m]+=l,r[m]+=u,a[m]+=d,o[m]+=h;const g=this.getIndex(t-1,s,m);this.weights[f]=this.weights[g]+e[m],this.momentsR[f]=this.momentsR[g]+n[m],this.momentsG[f]=this.momentsG[g]+r[m],this.momentsB[f]=this.momentsB[g]+a[m],this.moments[f]=this.moments[g]+o[m]}}}}createBoxes(t){this.cubes=Array.from({length:t}).fill(0).map(()=>new se);const e=Array.from({length:t}).fill(0);this.cubes[0].r0=0,this.cubes[0].g0=0,this.cubes[0].b0=0,this.cubes[0].r1=32,this.cubes[0].g1=32,this.cubes[0].b1=32;let n=t,r=0;for(let a=1;a<t;a++){this.cut(this.cubes[r],this.cubes[a])?(e[r]=this.cubes[r].vol>1?this.variance(this.cubes[r]):0,e[a]=this.cubes[a].vol>1?this.variance(this.cubes[a]):0):(e[r]=0,a--),r=0;let t=e[0];for(let n=1;n<=a;n++)e[n]>t&&(t=e[n],r=n);if(t<=0){n=a+1;break}}return new ie(t,n)}createResult(t){const e=[];for(let n=0;n<t;++n){const t=this.cubes[n],r=this.volume(t,this.weights);if(r>0){const n=255<<24|(255&Math.round(this.volume(t,this.momentsR)/r))<<16|(255&Math.round(this.volume(t,this.momentsG)/r))<<8|255&Math.round(this.volume(t,this.momentsB)/r);e.push(n)}}return e}variance(t){const e=this.volume(t,this.momentsR),n=this.volume(t,this.momentsG),r=this.volume(t,this.momentsB);return this.moments[this.getIndex(t.r1,t.g1,t.b1)]-this.moments[this.getIndex(t.r1,t.g1,t.b0)]-this.moments[this.getIndex(t.r1,t.g0,t.b1)]+this.moments[this.getIndex(t.r1,t.g0,t.b0)]-this.moments[this.getIndex(t.r0,t.g1,t.b1)]+this.moments[this.getIndex(t.r0,t.g1,t.b0)]+this.moments[this.getIndex(t.r0,t.g0,t.b1)]-this.moments[this.getIndex(t.r0,t.g0,t.b0)]-(e*e+n*n+r*r)/this.volume(t,this.weights)}cut(t,e){const n=this.volume(t,this.momentsR),r=this.volume(t,this.momentsG),a=this.volume(t,this.momentsB),o=this.volume(t,this.weights),s=this.maximize(t,V.RED,t.r0+1,t.r1,n,r,a,o),c=this.maximize(t,V.GREEN,t.g0+1,t.g1,n,r,a,o),l=this.maximize(t,V.BLUE,t.b0+1,t.b1,n,r,a,o);let u;const d=s.maximum,h=c.maximum,m=l.maximum;if(d>=h&&d>=m){if(s.cutLocation<0)return!1;u=V.RED}else u=h>=d&&h>=m?V.GREEN:V.BLUE;switch(e.r1=t.r1,e.g1=t.g1,e.b1=t.b1,u){case V.RED:t.r1=s.cutLocation,e.r0=t.r1,e.g0=t.g0,e.b0=t.b0;break;case V.GREEN:t.g1=c.cutLocation,e.r0=t.r0,e.g0=t.g1,e.b0=t.b0;break;case V.BLUE:t.b1=l.cutLocation,e.r0=t.r0,e.g0=t.g0,e.b0=t.b1;break;default:throw new Error("unexpected direction "+u)}return t.vol=(t.r1-t.r0)*(t.g1-t.g0)*(t.b1-t.b0),e.vol=(e.r1-e.r0)*(e.g1-e.g0)*(e.b1-e.b0),!0}maximize(t,e,n,r,a,o,s,c){const l=this.bottom(t,e,this.momentsR),u=this.bottom(t,e,this.momentsG),d=this.bottom(t,e,this.momentsB),h=this.bottom(t,e,this.weights);let m=0,f=-1,g=0,p=0,k=0,C=0;for(let M=n;M<r;M++){if(g=l+this.top(t,e,M,this.momentsR),p=u+this.top(t,e,M,this.momentsG),k=d+this.top(t,e,M,this.momentsB),C=h+this.top(t,e,M,this.weights),0===C)continue;let n=1*(g*g+p*p+k*k),r=1*C,x=n/r;g=a-g,p=o-p,k=s-k,C=c-C,0!==C&&(n=1*(g*g+p*p+k*k),r=1*C,x+=n/r,x>m&&(m=x,f=M))}return new ce(f,m)}volume(t,e){return e[this.getIndex(t.r1,t.g1,t.b1)]-e[this.getIndex(t.r1,t.g1,t.b0)]-e[this.getIndex(t.r1,t.g0,t.b1)]+e[this.getIndex(t.r1,t.g0,t.b0)]-e[this.getIndex(t.r0,t.g1,t.b1)]+e[this.getIndex(t.r0,t.g1,t.b0)]+e[this.getIndex(t.r0,t.g0,t.b1)]-e[this.getIndex(t.r0,t.g0,t.b0)]}bottom(t,e,n){switch(e){case V.RED:return-n[this.getIndex(t.r0,t.g1,t.b1)]+n[this.getIndex(t.r0,t.g1,t.b0)]+n[this.getIndex(t.r0,t.g0,t.b1)]-n[this.getIndex(t.r0,t.g0,t.b0)];case V.GREEN:return-n[this.getIndex(t.r1,t.g0,t.b1)]+n[this.getIndex(t.r1,t.g0,t.b0)]+n[this.getIndex(t.r0,t.g0,t.b1)]-n[this.getIndex(t.r0,t.g0,t.b0)];case V.BLUE:return-n[this.getIndex(t.r1,t.g1,t.b0)]+n[this.getIndex(t.r1,t.g0,t.b0)]+n[this.getIndex(t.r0,t.g1,t.b0)]-n[this.getIndex(t.r0,t.g0,t.b0)];default:throw new Error("unexpected direction $direction")}}top(t,e,n,r){switch(e){case V.RED:return r[this.getIndex(n,t.g1,t.b1)]-r[this.getIndex(n,t.g1,t.b0)]-r[this.getIndex(n,t.g0,t.b1)]+r[this.getIndex(n,t.g0,t.b0)];case V.GREEN:return r[this.getIndex(t.r1,n,t.b1)]-r[this.getIndex(t.r1,n,t.b0)]-r[this.getIndex(t.r0,n,t.b1)]+r[this.getIndex(t.r0,n,t.b0)];case V.BLUE:return r[this.getIndex(t.r1,t.g1,n)]-r[this.getIndex(t.r1,t.g0,n)]-r[this.getIndex(t.r0,t.g1,n)]+r[this.getIndex(t.r0,t.g0,n)];default:throw new Error("unexpected direction $direction")}}getIndex(t,e,n){return(t<<10)+(t<<6)+t+(e<<5)+e+n}}class se{constructor(t=0,e=0,n=0,r=0,a=0,o=0,s=0){this.r0=t,this.r1=e,this.g0=n,this.g1=r,this.b0=a,this.b1=o,this.vol=s}}class ie{constructor(t,e){this.requestedCount=t,this.resultCount=e}}class ce{constructor(t,e){this.cutLocation=t,this.maximum=e}}class le{static quantize(t,e){const n=(new oe).quantize(t,e);return re.quantize(t,n,e)}}class X{get primary(){return this.props.primary}get onPrimary(){return this.props.onPrimary}get primaryContainer(){return this.props.primaryContainer}get onPrimaryContainer(){return this.props.onPrimaryContainer}get secondary(){return this.props.secondary}get onSecondary(){return this.props.onSecondary}get secondaryContainer(){return this.props.secondaryContainer}get onSecondaryContainer(){return this.props.onSecondaryContainer}get tertiary(){return this.props.tertiary}get onTertiary(){return this.props.onTertiary}get tertiaryContainer(){return this.props.tertiaryContainer}get onTertiaryContainer(){return this.props.onTertiaryContainer}get error(){return this.props.error}get onError(){return this.props.onError}get errorContainer(){return this.props.errorContainer}get onErrorContainer(){return this.props.onErrorContainer}get background(){return this.props.background}get onBackground(){return this.props.onBackground}get surface(){return this.props.surface}get onSurface(){return this.props.onSurface}get surfaceVariant(){return this.props.surfaceVariant}get onSurfaceVariant(){return this.props.onSurfaceVariant}get outline(){return this.props.outline}get outlineVariant(){return this.props.outlineVariant}get shadow(){return this.props.shadow}get scrim(){return this.props.scrim}get inverseSurface(){return this.props.inverseSurface}get inverseOnSurface(){return this.props.inverseOnSurface}get inversePrimary(){return this.props.inversePrimary}static light(t){return X.lightFromCorePalette(S.of(t))}static dark(t){return X.darkFromCorePalette(S.of(t))}static lightContent(t){return X.lightFromCorePalette(S.contentOf(t))}static darkContent(t){return X.darkFromCorePalette(S.contentOf(t))}static lightFromCorePalette(t){return new X({primary:t.a1.tone(40),onPrimary:t.a1.tone(100),primaryContainer:t.a1.tone(90),onPrimaryContainer:t.a1.tone(10),secondary:t.a2.tone(40),onSecondary:t.a2.tone(100),secondaryContainer:t.a2.tone(90),onSecondaryContainer:t.a2.tone(10),tertiary:t.a3.tone(40),onTertiary:t.a3.tone(100),tertiaryContainer:t.a3.tone(90),onTertiaryContainer:t.a3.tone(10),error:t.error.tone(40),onError:t.error.tone(100),errorContainer:t.error.tone(90),onErrorContainer:t.error.tone(10),background:t.n1.tone(99),onBackground:t.n1.tone(10),surface:t.n1.tone(99),onSurface:t.n1.tone(10),surfaceVariant:t.n2.tone(90),onSurfaceVariant:t.n2.tone(30),outline:t.n2.tone(50),outlineVariant:t.n2.tone(80),shadow:t.n1.tone(0),scrim:t.n1.tone(0),inverseSurface:t.n1.tone(20),inverseOnSurface:t.n1.tone(95),inversePrimary:t.a1.tone(80)})}static darkFromCorePalette(t){return new X({primary:t.a1.tone(80),onPrimary:t.a1.tone(20),primaryContainer:t.a1.tone(30),onPrimaryContainer:t.a1.tone(90),secondary:t.a2.tone(80),onSecondary:t.a2.tone(20),secondaryContainer:t.a2.tone(30),onSecondaryContainer:t.a2.tone(90),tertiary:t.a3.tone(80),onTertiary:t.a3.tone(20),tertiaryContainer:t.a3.tone(30),onTertiaryContainer:t.a3.tone(90),error:t.error.tone(80),onError:t.error.tone(20),errorContainer:t.error.tone(30),onErrorContainer:t.error.tone(80),background:t.n1.tone(10),onBackground:t.n1.tone(90),surface:t.n1.tone(10),onSurface:t.n1.tone(90),surfaceVariant:t.n2.tone(30),onSurfaceVariant:t.n2.tone(80),outline:t.n2.tone(60),outlineVariant:t.n2.tone(30),shadow:t.n1.tone(0),scrim:t.n1.tone(0),inverseSurface:t.n1.tone(90),inverseOnSurface:t.n1.tone(20),inversePrimary:t.a1.tone(40)})}constructor(t){this.props=t}toJSON(){return{...this.props}}}const he={desired:4,fallbackColorARGB:4282549748,filter:!0};function ue(t,e){return t.score>e.score?-1:t.score<e.score?1:0}class U{constructor(){}static score(t,e){const{desired:n,fallbackColorARGB:r,filter:a}={...he,...e},o=[],s=new Array(360).fill(0);let c=0;for(const[e,n]of t.entries()){const t=O.fromInt(e);o.push(t);s[Math.floor(t.hue)]+=n,c+=n}const l=new Array(360).fill(0);for(let t=0;t<360;t++){const e=s[t]/c;for(let n=t-14;n<t+16;n++){l[Ft(n)]+=e}}const u=new Array;for(const t of o){const e=l[Ft(Math.round(t.hue))];if(a&&(t.chroma<U.CUTOFF_CHROMA||e<=U.CUTOFF_EXCITED_PROPORTION))continue;const n=100*e*U.WEIGHT_PROPORTION,r=t.chroma<U.TARGET_CHROMA?U.WEIGHT_CHROMA_BELOW:U.WEIGHT_CHROMA_ABOVE,o=n+(t.chroma-U.TARGET_CHROMA)*r;u.push({hct:t,score:o})}u.sort(ue);const d=[];for(let t=90;t>=15;t--){d.length=0;for(const{hct:e}of u)if(d.find(n=>Lt(e.hue,n.hue)<t)||d.push(e),d.length>=n)break;if(d.length>=n)break}const h=[];0===d.length&&h.push(r);for(const t of d)h.push(t.toInt());return h}}function F(t){const e=mt(t),n=dt(t),r=gt(t),a=[e.toString(16),n.toString(16),r.toString(16)];for(const[t,e]of a.entries())1===e.length&&(a[t]="0"+e);return"#"+a.join("")}function fe(t){const e=3===(t=t.replace("#","")).length,n=6===t.length,r=8===t.length;if(!e&&!n&&!r)throw new Error("unexpected hex "+t);let a=0,o=0,s=0;return e?(a=J(t.slice(0,1).repeat(2)),o=J(t.slice(1,2).repeat(2)),s=J(t.slice(2,3).repeat(2))):n?(a=J(t.slice(0,2)),o=J(t.slice(2,4)),s=J(t.slice(4,6))):r&&(a=J(t.slice(2,4)),o=J(t.slice(4,6)),s=J(t.slice(6,8))),(255<<24|(255&a)<<16|(255&o)<<8|255&s)>>>0}function J(t){return parseInt(t,16)}async function me(t){const e=await new Promise((e,n)=>{const r=document.createElement("canvas"),a=r.getContext("2d");if(!a)return void n(new Error("Could not get canvas context"));const o=()=>{r.width=t.width,r.height=t.height,a.drawImage(t,0,0);let n=[0,0,t.width,t.height];const o=t.dataset.area;o&&/^\d+(\s*,\s*\d+){3}$/.test(o)&&(n=o.split(/\s*,\s*/).map(t=>parseInt(t,10)));const[s,c,l,u]=n;e(a.getImageData(s,c,l,u).data)};t.complete?o():(t.onload=o,t.onerror=()=>{n(new Error("Image load failed"))})}),n=[];for(let t=0;t<e.length;t+=4){const r=e[t],a=e[t+1],o=e[t+2];if(e[t+3]<255)continue;const s=ft(r,a,o);n.push(s)}const r=le.quantize(n,128);return U.score(r)[0]}function St(t,e=[]){const n=S.of(t);return{source:t,schemes:{light:X.light(t),dark:X.dark(t)},palettes:{primary:n.a1,secondary:n.a2,tertiary:n.a3,neutral:n.n1,neutralVariant:n.n2,error:n.error},customColors:e.map(e=>de(t,e))}}async function Ot(t,e=[]){return St(await me(t),e)}function de(t,e){let n=e.value;const r=n,a=t;e.blend&&(n=Dt.harmonize(r,a));const o=S.of(n).a1;return{color:e,value:n,light:{color:o.tone(40),onColor:o.tone(100),colorContainer:o.tone(90),onColorContainer:o.tone(10)},dark:{color:o.tone(80),onColor:o.tone(20),colorContainer:o.tone(30),onColorContainer:o.tone(90)}}}function Pt(t){let e=JSON.parse(JSON.stringify(t.schemes));for(let t in e)for(let n in e[t])e[t][n]=F(e[t][n]);return e.dark.surfaceDim=F(t.palettes.neutral.tone(6)),e.dark.surface=F(t.palettes.neutral.tone(6)),e.dark.surfaceBright=F(t.palettes.neutral.tone(24)),e.dark.surfaceContainerLowest=F(t.palettes.neutral.tone(4)),e.dark.surfaceContainerLow=F(t.palettes.neutral.tone(10)),e.dark.surfaceContainer=F(t.palettes.neutral.tone(12)),e.dark.surfaceContainerHigh=F(t.palettes.neutral.tone(17)),e.dark.surfaceContainerHighest=F(t.palettes.neutral.tone(22)),e.dark.onSurface=F(t.palettes.neutral.tone(90)),e.dark.onSurfaceVariant=F(t.palettes.neutralVariant.tone(80)),e.dark.outline=F(t.palettes.neutralVariant.tone(60)),e.dark.outlineVariant=F(t.palettes.neutralVariant.tone(30)),e.light.surfaceDim=F(t.palettes.neutral.tone(87)),e.light.surface=F(t.palettes.neutral.tone(98)),e.light.surfaceBright=F(t.palettes.neutral.tone(98)),e.light.surfaceContainerLowest=F(t.palettes.neutral.tone(100)),e.light.surfaceContainerLow=F(t.palettes.neutral.tone(96)),e.light.surfaceContainer=F(t.palettes.neutral.tone(94)),e.light.surfaceContainerHigh=F(t.palettes.neutral.tone(92)),e.light.surfaceContainerHighest=F(t.palettes.neutral.tone(90)),e.light.onSurface=F(t.palettes.neutral.tone(10)),e.light.onSurfaceVariant=F(t.palettes.neutralVariant.tone(30)),e.light.outline=F(t.palettes.neutralVariant.tone(50)),e.light.outlineVariant=F(t.palettes.neutralVariant.tone(80)),e}async function ge(t){const e=t,n={light:{},dark:{}};try{if("string"==typeof e&&/^\#[0-9a-f]+$/i.test(e)){return Pt(St(fe(e)))}if(e.src){return Pt(await Ot(e))}let t=new Blob;if("string"==typeof e&&(t=await fetch(e).then(t=>t.blob())),e.size&&(t=e),e.files&&e.files[0]&&(t=e.files[0]),e.target&&e.target.files&&e.target.files[0]&&(t=e.target.files[0]),!t.size)return n;let r=new Image(64);return r.src=URL.createObjectURL(t),Pt(await Ot(r))}catch{return n}}U.TARGET_CHROMA=48,U.WEIGHT_PROPORTION=.7,U.WEIGHT_CHROMA_ABOVE=.3,U.WEIGHT_CHROMA_BELOW=.1,U.CUTOFF_CHROMA=5,U.CUTOFF_EXCITED_PROPORTION=.01,globalThis.materialDynamicColors=ge,function(t){"use strict";const e={init:function(t={}){const e={sidebarSelector:t.sidebarSelector||".kds-sidebar"},n=document.querySelector(e.sidebarSelector);n?(!function(t){if(!t)return;const e=t.querySelector(".kds-sidebar-header"),n=t.querySelector(".kds-sidebar-header-dropdown");if(!e||!n)return;e.addEventListener("click",function(t){t.stopPropagation(),n.classList.toggle("kds-dropdown-open");const r=e.querySelector(".kds-sidebar-dropdown-icon");r&&(r.style.transform=n.classList.contains("kds-dropdown-open")?"rotate(180deg)":"rotate(0deg)")}),document.addEventListener("click",function(r){if(!t.contains(r.target)){n.classList.remove("kds-dropdown-open");const t=e.querySelector(".kds-sidebar-dropdown-icon");t&&(t.style.transform="rotate(0deg)")}}),n.querySelectorAll("a").forEach(t=>{t.addEventListener("click",function(){n.classList.remove("kds-dropdown-open");const t=e.querySelector(".kds-sidebar-dropdown-icon");t&&(t.style.transform="rotate(0deg)")})})}(n),function(t){if(!t)return;const e=t.querySelectorAll(".kds-sidebar-nav-item");e.forEach(n=>{n.addEventListener("click",function(n){"#"===this.getAttribute("href")&&n.preventDefault(),e.forEach(t=>{t.classList.remove("active")}),this.classList.add("active");const r=new CustomEvent("kds-sidebar-nav-change",{detail:{item:this,text:this.querySelector("span")?.textContent||""},bubbles:!0});t.dispatchEvent(r)})})}(n),function(){const t=document.querySelector(".kds-hamburger-btn"),e=document.querySelector(".kds-sidebar-close-btn"),n=document.querySelector(".kds-sidebar");t&&n&&(t.addEventListener("click",function(){n.classList.toggle("kds-sidebar-open")}),e&&e.addEventListener("click",function(){n.classList.remove("kds-sidebar-open")}),document.addEventListener("keydown",function(t){"Escape"===t.key&&n.classList.contains("kds-sidebar-open")&&n.classList.remove("kds-sidebar-open")}))}(),console.log("[Khipu Sidebar] Initialized successfully")):console.warn("[Khipu Sidebar] Sidebar not found with selector:",e.sidebarSelector)}};"function"==typeof define&&define.amd?define(function(){return e}):"object"==typeof module&&module.exports?module.exports=e:t.KhipuSidebar=e}("undefined"!=typeof window?window:this),function(t){"use strict";class KhipuOnboarding{constructor(t={}){this.currentStage=0,this.totalStages=t.totalStages||8,this.personType=t.personType||null,this.locale=t.locale||"es-CL",this.apiEndpoint=t.apiEndpoint||"/api/onboarding",this.enableLocalStorage=!1!==t.enableLocalStorage,this.formData={},this.completedStages=new Set,this.errors={},this.listeners={stageChange:[],dataChange:[],error:[]},this.init()}init(){this.enableLocalStorage&&this.loadState(),this.setupEventListeners(),this.updateStepper()}setupEventListeners(){document.addEventListener("click",t=>{if(t.target.matches("[data-onboarding-next]")&&(t.preventDefault(),this.nextStage()),t.target.matches("[data-onboarding-prev]")&&(t.preventDefault(),this.prevStage()),t.target.matches("[data-onboarding-goto]")){t.preventDefault();const e=parseInt(t.target.dataset.onboardingGoto,10);this.goToStage(e)}}),document.addEventListener("input",t=>{t.target.matches("[data-onboarding-field]")&&this.handleFieldChange(t.target)}),document.addEventListener("submit",t=>{t.target.matches("[data-onboarding-form]")&&(t.preventDefault(),this.handleFormSubmit(t.target))}),document.addEventListener("keydown",t=>{"Enter"===t.key&&t.target.matches("button")&&t.target.click(),"Escape"===t.key&&this.closeAllModals()})}goToStage(e){if(e<0||e>=this.totalStages)return void console.warn(`Invalid stage index: ${e}`);if(e>this.currentStage&&!this.validateStage())return;const n=this.currentStage;this.currentStage=e,this.emit("stageChange",{from:n,to:e}),this.updateStepper(),this.saveState(),t.scrollTo({top:0,behavior:"smooth"})}nextStage(){this.validateStage()&&(this.completedStages.add(this.currentStage),this.currentStage<this.totalStages-1?this.goToStage(this.currentStage+1):this.submitOnboarding())}prevStage(){this.currentStage>0&&this.goToStage(this.currentStage-1)}validateStage(){const t=document.querySelector(`[data-stage="${this.currentStage}"]`);if(!t)return!0;const e=t.querySelector("form");if(!e)return!0;if(!e.checkValidity())return e.reportValidity(),!1;const n=e.querySelectorAll("[data-onboarding-field]");let r=!0;return n.forEach(t=>{this.validateField(t)||(r=!1)}),r}validateField(t){t.name||t.dataset.onboardingField;const n=t.value.trim(),r=t.dataset.validation;if(this.clearFieldError(t),t.hasAttribute("required")&&!n)return this.setFieldError(t,"Este campo es obligatorio"),!1;if(r&&n){const a=e[r];if(a&&!a.test(n))return this.setFieldError(t,a.message),!1}const a=t.closest(".field");return a&&(a.classList.remove("invalid"),a.classList.add("valid")),!0}handleFieldChange(t){const e=t.name||t.dataset.onboardingField,n="checkbox"===t.type?t.checked:t.value;this.setFormData(e,n),"false"!==t.dataset.validateOnChange&&this.validateField(t)}handleFormSubmit(t){if(!this.validateStage())return;new FormData(t).forEach((t,e)=>{this.setFormData(e,t)}),this.nextStage()}setFormData(t,e){this.formData[t]=e,this.emit("dataChange",{key:t,value:e}),this.enableLocalStorage&&this.saveState()}getFormData(t){return this.formData[t]}setFieldError(t,e){const n=t.closest(".field");if(!n)return;n.classList.add("invalid"),n.classList.remove("valid");let r=n.querySelector(".error");r||(r=document.createElement("span"),r.className="error",n.appendChild(r)),r.textContent=e;const a=t.name||t.dataset.onboardingField;this.errors[a]=e}clearFieldError(t){const e=t.closest(".field");if(!e)return;e.classList.remove("invalid");const n=e.querySelector(".error");n&&n.remove();const r=t.name||t.dataset.onboardingField;delete this.errors[r]}updateStepper(){document.querySelectorAll(".kds-step").forEach((t,e)=>{t.classList.remove("current","completed"),e<this.currentStage||this.completedStages.has(e)?t.classList.add("completed"):e===this.currentStage&&t.classList.add("current")});document.querySelectorAll("[data-stage]").forEach((t,e)=>{t.style.display=e===this.currentStage?"block":"none"})}saveState(){if(this.enableLocalStorage)try{const t={currentStage:this.currentStage,personType:this.personType,formData:this.formData,completedStages:Array.from(this.completedStages),timestamp:Date.now()};localStorage.setItem("khipu_onboarding_state",JSON.stringify(t))}catch(t){console.error("Error saving state:",t)}}loadState(){try{const t=localStorage.getItem("khipu_onboarding_state");if(!t)return;const e=JSON.parse(t);if(Date.now()-e.timestamp>864e5)return void this.clearState();this.currentStage=e.currentStage||0,this.personType=e.personType||null,this.formData=e.formData||{},this.completedStages=new Set(e.completedStages||[])}catch(t){console.error("Error loading state:",t),this.clearState()}}clearState(){try{localStorage.removeItem("khipu_onboarding_state")}catch(t){console.error("Error clearing state:",t)}this.currentStage=0,this.formData={},this.completedStages.clear(),this.errors={}}async submitOnboarding(){try{const t=await fetch(this.apiEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(this.formData)});if(!t.ok)throw new Error("Network response was not ok");const e=await t.json();this.clearState(),this.emit("success",e),this.showSnackbar("¡Activación completada exitosamente!","success")}catch(t){console.error("Error submitting onboarding:",t),this.emit("error",t),this.showSnackbar("Error al enviar datos. Por favor intenta nuevamente.","error")}}showSnackbar(t,e="info"){const n=document.createElement("div");n.className=`snackbar ${e}`,n.textContent=t,document.body.appendChild(n),setTimeout(()=>{n.remove()},3e3)}closeAllModals(){document.querySelectorAll("dialog[open]").forEach(t=>t.close())}emit(t,e){this.listeners[t]&&this.listeners[t].forEach(t=>t(e))}on(t,e){this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e)}off(t,e){this.listeners[t]&&(this.listeners[t]=this.listeners[t].filter(t=>t!==e))}}const e={rut:{test:function(t){if((t=t.replace(/[^0-9kK]/g,"")).length<2)return!1;const e=t.slice(0,-1),n=t.slice(-1).toUpperCase();let r=0,a=2;for(let t=e.length-1;t>=0;t--)r+=parseInt(e[t])*a,a=7===a?2:a+1;const o=11-r%11;return n===(11===o?"0":10===o?"K":o.toString())},message:"RUT inválido"},email:{test:function(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)},message:"Email inválido"},phone:{test:function(t){return/^(\+?56)?9\d{8}$/.test(t.replace(/\s/g,""))},message:"Teléfono inválido (ej: +56912345678)"},url:{test:function(t){try{return new URL(t),!0}catch{return!1}},message:"URL inválida"}};t.KhipuOnboarding=KhipuOnboarding,t.FileUploadHandler=class FileUploadHandler{constructor(t){this.uploadZone=t,this.fileInput=t.querySelector('input[type="file"]'),this.preview=t.nextElementSibling,this.files=[],this.maxSize=5242880,this.acceptedTypes=["application/pdf","image/jpeg","image/png"],this.init()}init(){this.uploadZone.addEventListener("click",()=>{this.fileInput.click()}),this.fileInput.addEventListener("change",t=>{this.handleFiles(Array.from(t.target.files))}),this.uploadZone.addEventListener("dragover",t=>{t.preventDefault(),this.uploadZone.classList.add("dragover")}),this.uploadZone.addEventListener("dragleave",()=>{this.uploadZone.classList.remove("dragover")}),this.uploadZone.addEventListener("drop",t=>{t.preventDefault(),this.uploadZone.classList.remove("dragover"),this.handleFiles(Array.from(t.dataTransfer.files))})}handleFiles(t){t.forEach(t=>{this.acceptedTypes.includes(t.type)?t.size>this.maxSize?alert(`Archivo muy grande: ${t.name} (máx 5MB)`):(this.files.push(t),this.addFileToPreview(t)):alert(`Tipo de archivo no permitido: ${t.name}`)}),this.uploadZone.classList.add("success")}addFileToPreview(t){const e=document.createElement("div");e.className="kds-file-upload-item",e.innerHTML=`\n <div class="kds-file-upload-item-icon">\n <i class="material-symbols-outlined">description</i>\n </div>\n <div class="kds-file-upload-item-info">\n <div class="kds-file-upload-item-name">${t.name}</div>\n <div class="kds-file-upload-item-meta">${this.formatFileSize(t.size)}</div>\n </div>\n <div class="kds-file-upload-item-status success">\n <i class="material-symbols-outlined">check_circle</i>\n </div>\n <button type="button" class="kds-file-upload-item-remove">\n <i class="material-symbols-outlined">close</i>\n </button>\n `,e.querySelector(".kds-file-upload-item-remove").addEventListener("click",n=>{n.stopPropagation(),this.removeFile(t,e)}),this.preview.appendChild(e)}removeFile(t,e){this.files=this.files.filter(e=>e!==t),e.remove(),0===this.files.length&&this.uploadZone.classList.remove("success")}formatFileSize(t){return t<1024?t+" B":t<1048576?(t/1024).toFixed(1)+" KB":(t/1048576).toFixed(1)+" MB"}getFiles(){return this.files}},t.OTPInputHandler=class OTPInputHandler{constructor(t){this.container=t,this.inputs=Array.from(t.querySelectorAll(".kds-otp-digit")),this.length=this.inputs.length,this.init()}init(){this.inputs.forEach((t,e)=>{t.addEventListener("input",t=>{const n=t.target.value.replace(/[^0-9]/g,"");t.target.value=n.slice(0,1),n&&e<this.length-1&&this.inputs[e+1].focus()}),t.addEventListener("keydown",t=>{"Backspace"===t.key&&!t.target.value&&e>0&&this.inputs[e-1].focus()}),t.addEventListener("paste",t=>{t.preventDefault();const n=t.clipboardData.getData("text").replace(/[^0-9]/g,"");n.split("").forEach((t,n)=>{e+n<this.length&&(this.inputs[e+n].value=t)});const r=Math.min(e+n.length,this.length-1);this.inputs[r].focus()})})}getValue(){return this.inputs.map(t=>t.value).join("")}clear(){this.inputs.forEach(t=>{t.value=""}),this.inputs[0].focus()}isComplete(){return this.inputs.every(t=>t.value)}},t.KHIPU_ONBOARDING_CONFIG&&(t.khipuOnboarding=new KhipuOnboarding(t.KHIPU_ONBOARDING_CONFIG))}(window),function(){"use strict";function t(){console.log("Initializing Khipu Material Design components..."),void 0!==window.KhipuSidebar&&window.KhipuSidebar.init(),function(){const t=document.getElementById("menu-toggle"),e=document.getElementById("material-sidenav");t&&e&&(t.addEventListener("click",function(){e.classList.toggle("active")}),document.addEventListener("click",function(n){if(e.classList.contains("active")){e.contains(n.target)||t.contains(n.target)||e.classList.remove("active")}}))}(),document.querySelectorAll('.snackbar[data-auto-dismiss="true"]').forEach(function(t){setTimeout(function(){t.classList.remove("active")},5e3)}),window.closeModal=function(t){const e=document.getElementById(t);e&&e.classList.remove("active")},e(),n(),r(),a(),o(),console.log("Material Design initialization complete!")}function e(t){(t=t||document).addEventListener("click",function(t){var e=t.target.closest("[data-expand-toggle]");if(e){var n="true"===e.getAttribute("aria-expanded");e.setAttribute("aria-expanded",String(!n));var r=e.getAttribute("aria-controls"),a=r?document.getElementById(r):e.parentElement.querySelector("[data-expand-panel]");a&&(n?a.classList.remove("open"):a.classList.add("open"))}})}function n(t){(t=t||document).addEventListener("click",function(t){var e=t.target.closest(".kds-copy-row[data-copy]");if(e)navigator.clipboard.writeText(e.dataset.copy).then(function(){e.classList.add("copied"),setTimeout(function(){e.classList.remove("copied")},1200)});else{var n=t.target.closest(".kds-copy-all[data-copy-all]");if(n){var r=n.dataset.copyAll,a=r?document.querySelector(r):n.closest(".kds-copy-header").nextElementSibling;if(!a)return;var o=a.querySelectorAll("[data-copy]"),s=[];o.forEach(function(t){s.push(t.dataset.copy)}),navigator.clipboard.writeText(s.join("\n")).then(function(){o.forEach(function(t){t.classList.add("copied"),setTimeout(function(){t.classList.remove("copied")},1200)})})}}})}function r(t){(t=t||document).querySelectorAll(".kds-countdown[data-deadline]").forEach(function(t){var e=new Date(t.dataset.deadline).getTime(),n=t.dataset.serverNow?new Date(t.dataset.serverNow).getTime():Date.now(),r=Date.now()-n,a=t.querySelector("[data-h]"),o=t.querySelector("[data-m]"),s=t.querySelector("[data-s]");function c(t){return t<10?"0"+t:String(t)}function l(){var n=Date.now()-r,l=Math.max(0,e-n),d=Math.floor(l/1e3),h=Math.floor(d/3600),m=Math.floor(d%3600/60),f=d%60;a&&(a.textContent=c(h)),o&&(o.textContent=c(m)),s&&(s.textContent=c(f)),l<3e5&&t.classList.add("urgent"),l<=0&&(clearInterval(u),t.dispatchEvent(new CustomEvent("kds:countdown:expired",{bubbles:!0})))}l();var u=setInterval(l,1e3)})}function a(t){(t=t||document).addEventListener("click",function(t){var e=t.target.closest(".kds-segmented-tabs button");if(e){var n=e.closest(".kds-segmented-tabs"),r=n.querySelectorAll("button");r.forEach(function(t){t.classList.remove("active"),t.setAttribute("aria-selected","false")}),e.classList.add("active"),e.setAttribute("aria-selected","true");var a=Array.prototype.indexOf.call(r,e);n.dispatchEvent(new CustomEvent("kds:tab:change",{bubbles:!0,detail:{index:a,button:e}}))}})}function o(t){t=t||document;var e={};window.addEventListener("scroll",function(){var n=t.querySelector(".kds-screen.active");if(n){var r=n.querySelector(".kds-invoice-sticky");if(r){var a=n.id||"default",o=e[a]||!1,s=window.scrollY||window.pageYOffset;!o&&s>60?(r.classList.add("collapsed"),e[a]=!0):o&&s<20&&(r.classList.remove("collapsed"),e[a]=!1)}}},{passive:!0})}function s(t,e,n){e=e||"info",n=n||5e3;const r=document.createElement("div");r.className="snackbar active "+e;const a=document.createElement("i");a.className="material-symbols-outlined",a.textContent="success"===e?"check_circle":"error"===e?"error":"info";const o=document.createElement("span");o.textContent=t;const s=document.createElement("button");s.className="transparent circle",s.innerHTML='<i class="material-symbols-outlined">close</i>',s.onclick=function(){r.classList.remove("active"),setTimeout(function(){r.remove()},300)},r.appendChild(a),r.appendChild(o),r.appendChild(s),document.body.appendChild(r),setTimeout(function(){r.classList.remove("active"),setTimeout(function(){r.remove()},300)},n)}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t):t(),window.Khipu||(window.Khipu={}),window.Khipu.showSnackbar=s,window.Khipu.closeModal=window.closeModal,window.Khipu.initExpandToggle=e,window.Khipu.initCopyRow=n,window.Khipu.initCountdown=r,window.Khipu.initSegmentedTabs=a,window.Khipu.initStickyInvoice=o,window.showSnackbar=s}();
|
|
1
|
+
const _emptyNodeList=[],_weakElements=new WeakSet,isChrome=navigator.userAgent.includes("Chrome");navigator.userAgent.includes("Firefox"),navigator.userAgent.includes("Safari"),navigator.userAgent.includes("Windows");const isMac=navigator.userAgent.includes("Macintosh");navigator.userAgent.includes("Linux"),navigator.userAgent.includes("Android");const isIOS=/iPad|iPhone|iPod/.test(navigator.userAgent);function isDark(){return null==window?void 0:window.matchMedia("(prefers-color-scheme: dark)").matches}async function wait(t){await new Promise(e=>setTimeout(e,t))}function guid(){return"fxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})}function query(t,e){try{return"string"==typeof t?(e??document).querySelector(t):t}catch{return null}}function queryAll(t,e){try{return"string"==typeof t?(e??document).querySelectorAll(t):t??_emptyNodeList}catch{return _emptyNodeList}}function hasClass(t,e){return(null==t?void 0:t.classList.contains(e))??!1}function hasTag(t,e){var n;return(null==(n=null==t?void 0:t.tagName)?void 0:n.toLowerCase())===e}function hasType(t,e){var n;return(null==(n=null==t?void 0:t.type)?void 0:n.toLowerCase())===e}function addClass(t,e){if(t instanceof NodeList)for(let n=0;n<t.length;n++)t[n].classList.add(e);else null==t||t.classList.add(e)}function removeClass(t,e){if(t instanceof NodeList)for(let n=0;n<t.length;n++)t[n].classList.remove(e);else null==t||t.classList.remove(e)}function on(t,e,n,r=!0){(null==t?void 0:t.addEventListener)&&t.addEventListener(e,n,r)}function onWeak(t,e,n,r=!0){addWeakElement(t),on(t,e,n,r)}function off(t,e,n,r=!0){(null==t?void 0:t.removeEventListener)&&t.removeEventListener(e,n,r)}function insertBefore(t,e){var n;null==(n=null==e?void 0:e.parentNode)||n.insertBefore(t,e)}function prev(t){return null==t?void 0:t.previousElementSibling}function next(t){return null==t?void 0:t.nextElementSibling}function parent(t){return null==t?void 0:t.parentElement}function create(t){const e=document.createElement("div");for(let n=0,r=Object.keys(t),a=r.length;n<a;n++){const a=r[n],o=t[a];e.setAttribute(a,o)}return e}function blurActiveElement(){var t;null==(t=document.activeElement)||t.blur()}function queryAllDataUi(t){return queryAll('[data-ui="#'+t+'"]')}function queryDataUi(t){return query('[data-ui="#'+t+'"]')}function updateAllClickable(t){t.id&&hasClass(t,"page")&&(t=queryDataUi(t.id)??t);const e=parent(t);if(!hasClass(e,"tabs")&&!hasClass(e,"tabbed")&&!hasTag(e,"nav"))return;const n=queryAll("a",e);for(let t=0;t<n.length;t++)removeClass(n[t],"active");hasTag(t,"button")||hasClass(t,"button")||hasClass(t,"chip")||addClass(t,"active")}function addWeakElement(t){_weakElements.has(t)||_weakElements.add(t)}function rootSizeInPixels(){const t=getComputedStyle(document.documentElement).getPropertyValue("--size")||"16px";return t.includes("%")?16*parseInt(t)/100:t.includes("em")?16*parseInt(t):parseInt(t)}function updatePlaceholder(t){t.placeholder||(t.placeholder=" ")}function onClickLabel(t){const e=query("input:not([type=file], [type=checkbox], [type=radio]), select, textarea",parent(t.currentTarget));e&&e.focus()}function onFocusInput(t){updateInput(t.currentTarget)}function onBlurInput(t){updateInput(t.currentTarget)}function onChangeFile(t){updateFile(t.currentTarget)}function onChangeColor(t){updateColor(t.currentTarget)}function onKeydownFile(t){updateFile(t.currentTarget,t)}function onKeydownColor(t){updateColor(t.currentTarget,t)}function onPasswordIconClick(t){var e;const n=t.currentTarget,r=query("input",parent(n));r&&(null==(e=n.textContent)?void 0:e.includes("visibility"))&&("password"===r.type?(r.type="text",n.textContent="visibility_off"):(r.type="password",n.textContent="visibility"))}function onInputTextarea(t){updateTextarea(t.currentTarget)}function updateAllLabels(){const t=queryAll(".field > label");for(let e=0;e<t.length;e++)onWeak(t[e],"click",onClickLabel)}function updateAllInputs(){const t=queryAll(".field > input:not([type=file], [type=color], [type=range])");for(let e=0;e<t.length;e++)onWeak(t[e],"focus",onFocusInput),onWeak(t[e],"blur",onBlurInput),updateInput(t[e])}function updateAllSelects(){const t=queryAll(".field > select");for(let e=0;e<t.length;e++)onWeak(t[e],"focus",onFocusInput),onWeak(t[e],"blur",onBlurInput)}function updateAllFiles(){const t=queryAll(".field > input[type=file]");for(let e=0;e<t.length;e++)onWeak(t[e],"change",onChangeFile),updateFile(t[e])}function updateAllColors(){const t=queryAll(".field > input[type=color]");for(let e=0;e<t.length;e++)onWeak(t[e],"change",onChangeColor),updateColor(t[e])}function updateAllTextareas(){const t=queryAll(".field > textarea");for(let e=0;e<t.length;e++)onWeak(t[e],"focus",onFocusInput),onWeak(t[e],"blur",onBlurInput),updatePlaceholder(t[e]),(!isChrome||isMac||isIOS)&&(onWeak(t[e],"input",onInputTextarea),updateTextarea(t[e]))}function updateAllPasswordIcons(){const t=queryAll(".field:has(> input[type=password]) > i, a");for(let e=0;e<t.length;e++)onWeak(t[e],"click",onPasswordIconClick)}function updateInput(t){hasType(t,"number")&&!t.value&&(t.value=""),updatePlaceholder(t)}function updateFile(t,e){if("Enter"===(null==e?void 0:e.key)){const e=prev(t);if(!hasType(e,"file"))return;return void e.click()}const n=next(t);hasType(n,"text")&&(n.value=t.files?Array.from(t.files).map(t=>t.name).join(", "):"",n.readOnly=!0,onWeak(n,"keydown",onKeydownFile,!1),updateInput(n))}function updateColor(t,e){if("Enter"===(null==e?void 0:e.key)){const e=prev(t);if(!hasType(e,"color"))return;return void e.click()}const n=next(t);hasType(n,"text")&&(n.readOnly=!0,n.value=t.value,onWeak(n,"keydown",onKeydownColor,!1),updateInput(n))}function updateTextarea(t){if(updatePlaceholder(t),t.hasAttribute("rows"))return;const e=rootSizeInPixels();t.style.blockSize="auto",t.style.blockSize=t.scrollHeight-e+"px"}function updateAllFields(){updateAllLabels(),updateAllInputs(),updateAllSelects(),updateAllFiles(),updateAllColors(),updateAllTextareas(),updateAllPasswordIcons()}function onInputDocument$1(t){const e=t.target;(hasTag(e,"input")||hasTag(e,"select"))&&("range"===e.type?(e.focus(),updateRange(e)):updateAllRanges())}function onChangeInput(t){if(!window.matchMedia("(pointer: coarse)").matches)return;t.target.blur()}function updateAllRanges(){const t=document.body,e=queryAll(".slider > input[type=range]");e.length?on(t,"input",onInputDocument$1,!1):off(t,"input",onInputDocument$1,!1);for(let t=0;t<e.length;t++)updateRange(e[t])}function updateRange(t){onWeak(t,"change",onChangeInput);const e=parent(t),n=query("span",e),r=queryAll("input",e);if(!r.length||!n)return;const a=rootSizeInPixels(),o=hasClass(e,"max")?0:.25*a*100/r[0].offsetWidth,s=[],c=[];for(let t=0,e=r.length;t<e;t++){const e=parseFloat(r[t].min)||0,n=parseFloat(r[t].max)||100,a=parseFloat(r[t].value)||0,l=100*(a-e)/(n-e),u=o/2-o*l/100;s.push(l+u),c.push(a)}let l=s[0],u=0,d=100-u-l,h=c[0],m=c[1]||0;r.length>1&&(l=Math.abs(s[1]-s[0]),u=s[1]>s[0]?s[0]:s[1],d=100-u-l,m>h&&(h=c[1]||0,m=c[0])),requestAnimationFrame(()=>e.style.cssText=`--_start: ${u}%; --_end: ${d}%; --_value1: '${h}'; --_value2: '${m}';`)}function updateAllSliders(){updateAllRanges()}const _lastTheme={light:"",dark:""};function getMode(){var t;return(null==(t=null==document?void 0:document.body)?void 0:t.classList.contains("dark"))?"dark":"light"}function lastTheme(){if(_lastTheme.light&&_lastTheme.dark)return _lastTheme;const t=document.body,e=document.createElement("body");e.className="light",t.appendChild(e);const n=document.createElement("body");n.className="dark",t.appendChild(n);const r=getComputedStyle(e),a=getComputedStyle(n),o=["--primary","--on-primary","--primary-container","--on-primary-container","--secondary","--on-secondary","--secondary-container","--on-secondary-container","--tertiary","--on-tertiary","--tertiary-container","--on-tertiary-container","--error","--on-error","--error-container","--on-error-container","--background","--on-background","--surface","--on-surface","--surface-variant","--on-surface-variant","--outline","--outline-variant","--shadow","--scrim","--inverse-surface","--inverse-on-surface","--inverse-primary","--surface-dim","--surface-bright","--surface-container-lowest","--surface-container-low","--surface-container","--surface-container-high","--surface-container-highest"];for(let t=0,e=o.length;t<e;t++)_lastTheme.light+=o[t]+":"+r.getPropertyValue(o[t])+";",_lastTheme.dark+=o[t]+":"+a.getPropertyValue(o[t])+";";return t.removeChild(e),t.removeChild(n),_lastTheme}async function updateTheme(t){const e=globalThis,n=document.body;return t&&e.materialDynamicColors?t.light&&t.dark?(_lastTheme.light=t.light,_lastTheme.dark=t.dark,n.setAttribute("style",t[getMode()]),t):e.materialDynamicColors(t).then(t=>{const e=t=>{let e="";for(let n=0,r=Object.keys(t),a=r.length;n<a;n++){const a=r[n],o=t[a];e+="--"+a.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase()+":"+o+";"}return e};return _lastTheme.light=e(t.light),_lastTheme.dark=e(t.dark),n.setAttribute("style",_lastTheme[getMode()]),_lastTheme}):lastTheme()}function updateMode(t){const e=globalThis,n=document.body;if(!n)return t;if(!t)return getMode();"auto"===t&&(t=isDark()?"dark":"light"),n.classList.remove("light","dark"),n.classList.add(t);const r="light"===t?_lastTheme.light:_lastTheme.dark;return e.materialDynamicColors&&n.setAttribute("style",r),getMode()}const _dialogs=[];function onKeydownDialog(t){if("Escape"===t.key){const e=t.currentTarget;updateDialog(e,e)}}function focusOnDialogOrElement(t){(query("[autofocus]",t)??t).focus()}function closeDialog(t,e){removeClass(queryAllDataUi(t.id),"active"),removeClass(t,"active"),removeClass(e,"active"),t.close(),_dialogs.pop();const n=_dialogs[_dialogs.length-1];n&&n.focus()}async function openDialog(t,e,n,r){hasTag(r,"button")||hasClass(r,"button")||hasClass(r,"chip")||addClass(r,"active"),addClass(e,"active"),addClass(t,"active"),n?t.showModal():t.show(),await wait(90),n||on(t,"keydown",onKeydownDialog,!1),_dialogs.push(t),focusOnDialogOrElement(t)}function onClickOverlay(t){const e=t.currentTarget,n=next(e);hasTag(n,"dialog")&&closeDialog(n,e)}async function updateDialog(t,e){blurActiveElement();let n=prev(e);const r=hasClass(e,"active")||e.open,a=hasClass(e,"modal");a||off(e,"keydown",onKeydownDialog,!1),hasClass(n,"overlay")||(n=create({class:"overlay"}),insertBefore(n,e),await wait(90)),a||onWeak(n,"click",onClickOverlay,!1),r?closeDialog(e,n):openDialog(e,n,a,t)}let _timeoutMenu,_timeoutSnackbar;function onClickDocument(t){off(document.body,"click",onClickDocument);const e=t.target,n=queryAll("menu.active");for(let r=0;r<n.length;r++)updateMenu(e,n[r],t)}function focusOnMenuOrInput(t){setTimeout(()=>{const e=query(".field > input",t);e?e.focus():t.focus()},90)}function updateMenu(t,e,n){_timeoutMenu&&clearTimeout(_timeoutMenu),_timeoutMenu=setTimeout(()=>{on(document.body,"click",onClickDocument),hasTag(document.activeElement,"input")||blurActiveElement();const r=hasClass(e,"active"),a=(null==n?void 0:n.target)===t,o=!!t.closest("menu");!r&&o||r&&a?removeClass(e,"active"):(removeClass(queryAll("menu.active"),"active"),addClass(e,"active"),focusOnMenuOrInput(e))},90)}function onClickSnackbar(t){removeClass(t.currentTarget,"active"),_timeoutSnackbar&&clearTimeout(_timeoutSnackbar)}function updateSnackbar(t,e){blurActiveElement();const n=queryAll(".snackbar.active");for(let t=0;t<n.length;t++)removeClass(n[t],"active");addClass(t,"active"),onWeak(t,"click",onClickSnackbar),_timeoutSnackbar&&clearTimeout(_timeoutSnackbar),-1!==e&&(_timeoutSnackbar=setTimeout(()=>{removeClass(t,"active")},e??6e3))}function updatePage(t){const e=parent(t);e&&removeClass(queryAll(":scope > .page",e),"active"),addClass(t,"active")}function onMousedownRipple(t){updateRipple(t)}function onKeydownRipple(t){" "===(null==t?void 0:t.key)&&updateRipple(t)}function updateRipple(t){const e=t instanceof MouseEvent,n=t.currentTarget,r=n.getBoundingClientRect(),a=Math.max(r.width,r.height),o=a/2,s=e?t.clientX-r.left-o:r.width/2-o,c=e?t.clientY-r.top-o:r.height/2-o,l=document.createElement("div");l.className="ripple-js";const u=document.createElement("div");u.style.inlineSize=u.style.blockSize=`${a}px`,u.style.left=`${s}px`,u.style.top=`${c}px`,onWeak(u,"animationend",()=>{l.remove()}),l.appendChild(u),n.appendChild(l)}function updateAllRipples(){const t=queryAll(".slow-ripple, .ripple, .fast-ripple");for(let e=0;e<t.length;e++)onWeak(t[e],"mousedown",onMousedownRipple),onWeak(t[e],"keydown",onKeydownRipple)}function onInputDocument(t){const e=t.target;hasTag(e,"progress")?updateProgress(e):updateAllProgress()}function updateProgress(t){requestAnimationFrame(()=>{if(t.hasAttribute("value")||t.hasAttribute("max"))t.style.setProperty("--_value",String(t.value));else{const e=hasClass(t,"circle")?"50":"100";t.style.setProperty("--_value",e),t.setAttribute("value",e),t.setAttribute("max","100"),t.classList.add("indeterminate")}})}function updateAllProgress(){if(isChrome&&!isMac&&!isIOS)return;const t=document.body,e=queryAll("progress");e.length?on(t,"input",onInputDocument,!1):off(t,"input",onInputDocument,!1);for(let t=0;t<e.length;t++)updateProgress(e[t])}const _context=globalThis;let _timeoutMutation,_mutation;function onMutation(){_timeoutMutation&&clearTimeout(_timeoutMutation),_timeoutMutation=setTimeout(async()=>await _ui(),180)}async function run(t,e,n,r){if(e||(e=query(t.getAttribute("data-ui"))))if(updateAllClickable(t),hasTag(e,"dialog"))requestAnimationFrame(()=>updateDialog(t,e));else if(hasTag(e,"menu"))requestAnimationFrame(()=>updateMenu(t,e,r));else if(hasClass(e,"snackbar"))requestAnimationFrame(()=>updateSnackbar(e,n));else{if(!hasClass(e,"page"))return hasClass(e,"active")?(removeClass(t,"active"),void removeClass(e,"active")):void addClass(e,"active");requestAnimationFrame(()=>updatePage(e))}else t.classList.toggle("active")}function onClickElement(t){run(t.currentTarget,null,null,t)}function onKeydownElement(t){"Enter"===t.key&&run(t.currentTarget,null,null,t)}function setup(){_context.ui||_mutation||!_context.MutationObserver||(_mutation=new MutationObserver(onMutation),_mutation.observe(document.body,{childList:!0,subtree:!0}),onMutation())}function updateAllDataUis(){const t=queryAll("[data-ui]");for(let e=0,n=t.length;e<n;e++)onWeak(t[e],"click",onClickElement),hasTag(t[e],"a")&&!t[e].getAttribute("href")&&onWeak(t[e],"keydown",onKeydownElement)}function _ui(t,e){if(t){if("setup"===t)return void setup();if("guid"===t)return guid();if("mode"===t)return updateMode(e);if("theme"===t)return updateTheme(e);const n=query(t);if(!n)return;run(n,n,e)}updateAllDataUis(),updateAllFields(),updateAllRipples(),updateAllSliders(),updateAllProgress()}function start(){var t;if(_context.ui)return;const e=null==(t=_context.document)?void 0:t.body;!e||e.classList.contains("dark")||e.classList.contains("light")||updateMode("auto"),setup(),_context.ui=_ui}start();const ui=_context.ui;function H(t){return t<0?-1:0===t?0:1}function nt(t,e,n){return(1-n)*t+n*e}function qt(t,e,n){return n<t?t:n>e?e:n}function ut(t,e,n){return n<t?t:n>e?e:n}function Ft(t){return(t%=360)<0&&(t+=360),t}function wt(t){return(t%=360)<0&&(t+=360),t}function Ht(t,e){return wt(e-t)<=180?1:-1}function Lt(t,e){return 180-Math.abs(Math.abs(t-e)-180)}function Ct(t,e){return[t[0]*e[0][0]+t[1]*e[0][1]+t[2]*e[0][2],t[0]*e[1][0]+t[1]*e[1][1]+t[2]*e[1][2],t[0]*e[2][0]+t[1]*e[2][1]+t[2]*e[2][2]]}const zt=[[.41233895,.35762064,.18051042],[.2126,.7152,.0722],[.01932141,.11916382,.95034478]],vt=[[3.2413774792388685,-1.5376652402851851,-.49885366846268053],[-.9691452513005321,1.8758853451067872,.04156585616912061],[.05562093689691305,-.20395524564742123,1.0571799111220335]],xt=[95.047,100,108.883];function ft(t,e,n){return(255<<24|(255&t)<<16|(255&e)<<8|255&n)>>>0}function Et(t){return ft(tt(t[0]),tt(t[1]),tt(t[2]))}function jt(t){return t>>24&255}function mt(t){return t>>16&255}function dt(t){return t>>8&255}function gt(t){return 255&t}function Nt(t,e,n){const r=vt,a=r[0][0]*t+r[0][1]*e+r[0][2]*n,o=r[1][0]*t+r[1][1]*e+r[1][2]*n,s=r[2][0]*t+r[2][1]*e+r[2][2]*n;return ft(tt(a),tt(o),tt(s))}function Yt(t){return Ct([$(mt(t)),$(dt(t)),$(gt(t))],zt)}function Wt(t,e,n){const r=xt,a=(t+16)/116,o=a-n/200,s=ht(e/500+a),c=ht(a),l=ht(o);return Nt(s*r[0],c*r[1],l*r[2])}function Jt(t){const e=$(mt(t)),n=$(dt(t)),r=$(gt(t)),a=zt,o=a[0][0]*e+a[0][1]*n+a[0][2]*r,s=a[1][0]*e+a[1][1]*n+a[1][2]*r,c=a[2][0]*e+a[2][1]*n+a[2][2]*r,l=s/xt[1],u=c/xt[2],d=at(o/xt[0]),h=at(l);return[116*h-16,500*(d-h),200*(h-at(u))]}function Xt(t){const e=tt(Q(t));return ft(e,e,e)}function bt(t){return 116*at(Yt(t)[1]/100)-16}function Q(t){return 100*ht((t+16)/116)}function It(t){return 116*at(t/100)-16}function $(t){const e=t/255;return e<=.040449936?e/12.92*100:100*Math.pow((e+.055)/1.055,2.4)}function tt(t){const e=t/100;let n=0;return n=e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055,qt(0,255,Math.round(255*n))}function $t(){return xt}function at(t){return t>.008856451679035631?Math.pow(t,1/3):(24389/27*t+16)/116}function ht(t){const e=t*t*t;return e>.008856451679035631?e:(116*t-16)/(24389/27)}class W{static make(t=$t(),e=200/Math.PI*Q(50)/100,n=50,r=2,a=!1){const o=t,s=.401288*o[0]+.650173*o[1]+-.051461*o[2],c=-.250268*o[0]+1.204414*o[1]+.045854*o[2],l=-.002079*o[0]+.048952*o[1]+.953127*o[2],u=.8+r/10,d=u>=.9?nt(.59,.69,10*(u-.9)):nt(.525,.59,10*(u-.8));let h=a?1:u*(1-1/3.6*Math.exp((-e-42)/92));h=h>1?1:h<0?0:h;const m=u,f=[h*(100/s)+1-h,h*(100/c)+1-h,h*(100/l)+1-h],g=1/(5*e+1),p=g*g*g*g,k=1-p,C=p*e+.1*k*k*Math.cbrt(5*e),M=Q(n)/t[1],x=1.48+Math.sqrt(M),P=.725/Math.pow(M,.2),I=P,T=[Math.pow(C*f[0]*s/100,.42),Math.pow(C*f[1]*c/100,.42),Math.pow(C*f[2]*l/100,.42)],A=[400*T[0]/(T[0]+27.13),400*T[1]/(T[1]+27.13),400*T[2]/(T[2]+27.13)];return new W(M,(2*A[0]+A[1]+.05*A[2])*P,P,I,d,m,f,C,Math.pow(C,.25),x)}constructor(t,e,n,r,a,o,s,c,l,u){this.n=t,this.aw=e,this.nbb=n,this.ncb=r,this.c=a,this.nc=o,this.rgbD=s,this.fl=c,this.fLRoot=l,this.z=u}}W.DEFAULT=W.make();class N{constructor(t,e,n,r,a,o,s,c,l){this.hue=t,this.chroma=e,this.j=n,this.q=r,this.m=a,this.s=o,this.jstar=s,this.astar=c,this.bstar=l}distance(t){const e=this.jstar-t.jstar,n=this.astar-t.astar,r=this.bstar-t.bstar,a=Math.sqrt(e*e+n*n+r*r);return 1.41*Math.pow(a,.63)}static fromInt(t){return N.fromIntInViewingConditions(t,W.DEFAULT)}static fromIntInViewingConditions(t,e){const n=(65280&t)>>8,r=255&t,a=$((16711680&t)>>16),o=$(n),s=$(r),c=.41233895*a+.35762064*o+.18051042*s,l=.2126*a+.7152*o+.0722*s,u=.01932141*a+.11916382*o+.95034478*s,d=.401288*c+.650173*l-.051461*u,h=-.250268*c+1.204414*l+.045854*u,m=-.002079*c+.048952*l+.953127*u,f=e.rgbD[0]*d,g=e.rgbD[1]*h,p=e.rgbD[2]*m,k=Math.pow(e.fl*Math.abs(f)/100,.42),C=Math.pow(e.fl*Math.abs(g)/100,.42),M=Math.pow(e.fl*Math.abs(p)/100,.42),x=400*H(f)*k/(k+27.13),P=400*H(g)*C/(C+27.13),I=400*H(p)*M/(M+27.13),T=(11*x+-12*P+I)/11,A=(x+P-2*I)/9,D=(20*x+20*P+21*I)/20,L=(40*x+20*P+I)/20,R=180*Math.atan2(A,T)/Math.PI,B=R<0?R+360:R>=360?R-360:R,q=B*Math.PI/180,K=L*e.nbb,G=100*Math.pow(K/e.aw,e.c*e.z),j=4/e.c*Math.sqrt(G/100)*(e.aw+4)*e.fLRoot,Z=B<20.14?B+360:B,it=5e4/13*(.25*(Math.cos(Z*Math.PI/180+2)+3.8))*e.nc*e.ncb*Math.sqrt(T*T+A*A)/(D+.305),st=Math.pow(it,.9)*Math.pow(1.64-Math.pow(.29,e.n),.73),ct=st*Math.sqrt(G/100),pt=ct*e.fLRoot,yt=50*Math.sqrt(st*e.c/(e.aw+4)),kt=(1+100*.007)*G/(1+.007*G),Mt=1/.0228*Math.log(1+.0228*pt),Tt=Mt*Math.cos(q),_t=Mt*Math.sin(q);return new N(B,ct,G,j,pt,yt,kt,Tt,_t)}static fromJch(t,e,n){return N.fromJchInViewingConditions(t,e,n,W.DEFAULT)}static fromJchInViewingConditions(t,e,n,r){const a=4/r.c*Math.sqrt(t/100)*(r.aw+4)*r.fLRoot,o=e*r.fLRoot,s=e/Math.sqrt(t/100),c=50*Math.sqrt(s*r.c/(r.aw+4)),l=n*Math.PI/180,u=(1+100*.007)*t/(1+.007*t),d=1/.0228*Math.log(1+.0228*o),h=d*Math.cos(l),m=d*Math.sin(l);return new N(n,e,t,a,o,c,u,h,m)}static fromUcs(t,e,n){return N.fromUcsInViewingConditions(t,e,n,W.DEFAULT)}static fromUcsInViewingConditions(t,e,n,r){const a=e,o=n,s=Math.sqrt(a*a+o*o),c=(Math.exp(.0228*s)-1)/.0228/r.fLRoot;let l=Math.atan2(o,a)*(180/Math.PI);l<0&&(l+=360);const u=t/(1-.007*(t-100));return N.fromJchInViewingConditions(u,c,l,r)}toInt(){return this.viewed(W.DEFAULT)}viewed(t){const e=0===this.chroma||0===this.j?0:this.chroma/Math.sqrt(this.j/100),n=Math.pow(e/Math.pow(1.64-Math.pow(.29,t.n),.73),1/.9),r=this.hue*Math.PI/180,a=.25*(Math.cos(r+2)+3.8),o=t.aw*Math.pow(this.j/100,1/t.c/t.z),s=a*(5e4/13)*t.nc*t.ncb,c=o/t.nbb,l=Math.sin(r),u=Math.cos(r),d=23*(c+.305)*n/(23*s+11*n*u+108*n*l),h=d*u,m=d*l,f=(460*c+451*h+288*m)/1403,g=(460*c-891*h-261*m)/1403,p=(460*c-220*h-6300*m)/1403,k=Math.max(0,27.13*Math.abs(f)/(400-Math.abs(f))),C=H(f)*(100/t.fl)*Math.pow(k,1/.42),M=Math.max(0,27.13*Math.abs(g)/(400-Math.abs(g))),x=H(g)*(100/t.fl)*Math.pow(M,1/.42),P=Math.max(0,27.13*Math.abs(p)/(400-Math.abs(p))),I=H(p)*(100/t.fl)*Math.pow(P,1/.42),T=C/t.rgbD[0],A=x/t.rgbD[1],D=I/t.rgbD[2];return Nt(1.86206786*T-1.01125463*A+.14918677*D,.38752654*T+.62144744*A-.00897398*D,-.0158415*T-.03412294*A+1.04996444*D)}static fromXyzInViewingConditions(t,e,n,r){const a=.401288*t+.650173*e-.051461*n,o=-.250268*t+1.204414*e+.045854*n,s=-.002079*t+.048952*e+.953127*n,c=r.rgbD[0]*a,l=r.rgbD[1]*o,u=r.rgbD[2]*s,d=Math.pow(r.fl*Math.abs(c)/100,.42),h=Math.pow(r.fl*Math.abs(l)/100,.42),m=Math.pow(r.fl*Math.abs(u)/100,.42),f=400*H(c)*d/(d+27.13),g=400*H(l)*h/(h+27.13),p=400*H(u)*m/(m+27.13),k=(11*f+-12*g+p)/11,C=(f+g-2*p)/9,M=(20*f+20*g+21*p)/20,x=(40*f+20*g+p)/20,P=180*Math.atan2(C,k)/Math.PI,I=P<0?P+360:P>=360?P-360:P,T=I*Math.PI/180,A=x*r.nbb,D=100*Math.pow(A/r.aw,r.c*r.z),L=4/r.c*Math.sqrt(D/100)*(r.aw+4)*r.fLRoot,R=I<20.14?I+360:I,B=5e4/13*(1/4*(Math.cos(R*Math.PI/180+2)+3.8))*r.nc*r.ncb*Math.sqrt(k*k+C*C)/(M+.305),q=Math.pow(B,.9)*Math.pow(1.64-Math.pow(.29,r.n),.73),K=q*Math.sqrt(D/100),G=K*r.fLRoot,j=50*Math.sqrt(q*r.c/(r.aw+4)),Z=(1+100*.007)*D/(1+.007*D),it=Math.log(1+.0228*G)/.0228,st=it*Math.cos(T),ct=it*Math.sin(T);return new N(I,K,D,L,G,j,Z,st,ct)}xyzInViewingConditions(t){const e=0===this.chroma||0===this.j?0:this.chroma/Math.sqrt(this.j/100),n=Math.pow(e/Math.pow(1.64-Math.pow(.29,t.n),.73),1/.9),r=this.hue*Math.PI/180,a=.25*(Math.cos(r+2)+3.8),o=t.aw*Math.pow(this.j/100,1/t.c/t.z),s=a*(5e4/13)*t.nc*t.ncb,c=o/t.nbb,l=Math.sin(r),u=Math.cos(r),d=23*(c+.305)*n/(23*s+11*n*u+108*n*l),h=d*u,m=d*l,f=(460*c+451*h+288*m)/1403,g=(460*c-891*h-261*m)/1403,p=(460*c-220*h-6300*m)/1403,k=Math.max(0,27.13*Math.abs(f)/(400-Math.abs(f))),C=H(f)*(100/t.fl)*Math.pow(k,1/.42),M=Math.max(0,27.13*Math.abs(g)/(400-Math.abs(g))),x=H(g)*(100/t.fl)*Math.pow(M,1/.42),P=Math.max(0,27.13*Math.abs(p)/(400-Math.abs(p))),I=H(p)*(100/t.fl)*Math.pow(P,1/.42),T=C/t.rgbD[0],A=x/t.rgbD[1],D=I/t.rgbD[2];return[1.86206786*T-1.01125463*A+.14918677*D,.38752654*T+.62144744*A-.00897398*D,-.0158415*T-.03412294*A+1.04996444*D]}}class b{static sanitizeRadians(t){return(t+8*Math.PI)%(2*Math.PI)}static trueDelinearized(t){const e=t/100;let n=0;return n=e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055,255*n}static chromaticAdaptation(t){const e=Math.pow(Math.abs(t),.42);return 400*H(t)*e/(e+27.13)}static hueOf(t){const e=Ct(t,b.SCALED_DISCOUNT_FROM_LINRGB),n=b.chromaticAdaptation(e[0]),r=b.chromaticAdaptation(e[1]),a=b.chromaticAdaptation(e[2]),o=(11*n+-12*r+a)/11,s=(n+r-2*a)/9;return Math.atan2(s,o)}static areInCyclicOrder(t,e,n){return b.sanitizeRadians(e-t)<b.sanitizeRadians(n-t)}static intercept(t,e,n){return(e-t)/(n-t)}static lerpPoint(t,e,n){return[t[0]+(n[0]-t[0])*e,t[1]+(n[1]-t[1])*e,t[2]+(n[2]-t[2])*e]}static setCoordinate(t,e,n,r){const a=b.intercept(t[r],e,n[r]);return b.lerpPoint(t,a,n)}static isBounded(t){return 0<=t&&t<=100}static nthVertex(t,e){const n=b.Y_FROM_LINRGB[0],r=b.Y_FROM_LINRGB[1],a=b.Y_FROM_LINRGB[2],o=e%4<=1?0:100,s=e%2==0?0:100;if(e<4){const e=o,c=s,l=(t-e*r-c*a)/n;return b.isBounded(l)?[l,e,c]:[-1,-1,-1]}if(e<8){const e=o,c=s,l=(t-c*n-e*a)/r;return b.isBounded(l)?[c,l,e]:[-1,-1,-1]}{const e=o,c=s,l=(t-e*n-c*r)/a;return b.isBounded(l)?[e,c,l]:[-1,-1,-1]}}static bisectToSegment(t,e){let n=[-1,-1,-1],r=n,a=0,o=0,s=!1,c=!0;for(let l=0;l<12;l++){const u=b.nthVertex(t,l);if(u[0]<0)continue;const d=b.hueOf(u);s?(c||b.areInCyclicOrder(a,d,o))&&(c=!1,b.areInCyclicOrder(a,e,d)?(r=u,o=d):(n=u,a=d)):(n=u,r=u,a=d,o=d,s=!0)}return[n,r]}static midpoint(t,e){return[(t[0]+e[0])/2,(t[1]+e[1])/2,(t[2]+e[2])/2]}static criticalPlaneBelow(t){return Math.floor(t-.5)}static criticalPlaneAbove(t){return Math.ceil(t-.5)}static bisectToLimit(t,e){const n=b.bisectToSegment(t,e);let r=n[0],a=b.hueOf(r),o=n[1];for(let t=0;t<3;t++)if(r[t]!==o[t]){let n=-1,s=255;r[t]<o[t]?(n=b.criticalPlaneBelow(b.trueDelinearized(r[t])),s=b.criticalPlaneAbove(b.trueDelinearized(o[t]))):(n=b.criticalPlaneAbove(b.trueDelinearized(r[t])),s=b.criticalPlaneBelow(b.trueDelinearized(o[t])));for(let c=0;c<8&&!(Math.abs(s-n)<=1);c++){const c=Math.floor((n+s)/2),l=b.CRITICAL_PLANES[c],u=b.setCoordinate(r,l,o,t),d=b.hueOf(u);b.areInCyclicOrder(a,e,d)?(o=u,s=c):(r=u,a=d,n=c)}}return b.midpoint(r,o)}static inverseChromaticAdaptation(t){const e=Math.abs(t),n=Math.max(0,27.13*e/(400-e));return H(t)*Math.pow(n,1/.42)}static findResultByJ(t,e,n){let r=11*Math.sqrt(n);const a=W.DEFAULT,o=1/Math.pow(1.64-Math.pow(.29,a.n),.73),s=.25*(Math.cos(t+2)+3.8)*(5e4/13)*a.nc*a.ncb,c=Math.sin(t),l=Math.cos(t);for(let t=0;t<5;t++){const u=r/100,d=0===e||0===r?0:e/Math.sqrt(u),h=Math.pow(d*o,1/.9),m=a.aw*Math.pow(u,1/a.c/a.z)/a.nbb,f=23*(m+.305)*h/(23*s+11*h*l+108*h*c),g=f*l,p=f*c,k=(460*m+451*g+288*p)/1403,C=(460*m-891*g-261*p)/1403,M=(460*m-220*g-6300*p)/1403,x=Ct([b.inverseChromaticAdaptation(k),b.inverseChromaticAdaptation(C),b.inverseChromaticAdaptation(M)],b.LINRGB_FROM_SCALED_DISCOUNT);if(x[0]<0||x[1]<0||x[2]<0)return 0;const P=b.Y_FROM_LINRGB[0],I=b.Y_FROM_LINRGB[1],T=b.Y_FROM_LINRGB[2],A=P*x[0]+I*x[1]+T*x[2];if(A<=0)return 0;if(4===t||Math.abs(A-n)<.002)return x[0]>100.01||x[1]>100.01||x[2]>100.01?0:Et(x);r-=(A-n)*r/(2*A)}return 0}static solveToInt(t,e,n){if(e<1e-4||n<1e-4||n>99.9999)return Xt(n);const r=(t=wt(t))/180*Math.PI,a=Q(n),o=b.findResultByJ(r,e,a);if(0!==o)return o;return Et(b.bisectToLimit(a,r))}static solveToCam(t,e,n){return N.fromInt(b.solveToInt(t,e,n))}}b.SCALED_DISCOUNT_FROM_LINRGB=[[.001200833568784504,.002389694492170889,.0002795742885861124],[.0005891086651375999,.0029785502573438758,.0003270666104008398],[.00010146692491640572,.0005364214359186694,.0032979401770712076]],b.LINRGB_FROM_SCALED_DISCOUNT=[[1373.2198709594231,-1100.4251190754821,-7.278681089101213],[-271.815969077903,559.6580465940733,-32.46047482791194],[1.9622899599665666,-57.173814538844006,308.7233197812385]],b.Y_FROM_LINRGB=[.2126,.7152,.0722],b.CRITICAL_PLANES=[.015176349177441876,.045529047532325624,.07588174588720938,.10623444424209313,.13658714259697685,.16693984095186062,.19729253930674434,.2276452376616281,.2579979360165119,.28835063437139563,.3188300904430532,.350925934958123,.3848314933096426,.42057480301049466,.458183274052838,.4976837250274023,.5391024159806381,.5824650784040898,.6277969426914107,.6751227633498623,.7244668422128921,.775853049866786,.829304845476233,.8848452951698498,.942497089126609,1.0022825574869039,1.0642236851973577,1.1283421258858297,1.1946592148522128,1.2631959812511864,1.3339731595349034,1.407011200216447,1.4823302800086415,1.5599503113873272,1.6398909516233677,1.7221716113234105,1.8068114625156377,1.8938294463134073,1.9832442801866852,2.075074464868551,2.1693382909216234,2.2660538449872063,2.36523901573795,2.4669114995532007,2.5710888059345764,2.6777882626779785,2.7870270208169257,2.898822059350997,3.0131901897720907,3.1301480604002863,3.2497121605402226,3.3718988244681087,3.4967242352587946,3.624204428461639,3.754355295633311,3.887192587735158,4.022731918402185,4.160988767090289,4.301978482107941,4.445716283538092,4.592217266055746,4.741496401646282,4.893568542229298,5.048448422192488,5.20615066083972,5.3666897647573375,5.5300801301023865,5.696336044816294,5.865471690767354,6.037501145825082,6.212438385869475,6.390297286737924,6.571091626112461,6.7548350853498045,6.941541251256611,7.131223617812143,7.323895587840543,7.5195704746346665,7.7182615035334345,7.919981813454504,8.124744458384042,8.332562408825165,8.543448553206703,8.757415699253682,8.974476575321063,9.194643831691977,9.417930041841839,9.644347703669503,9.873909240696694,10.106627003236781,10.342513269534024,10.58158024687427,10.8238400726681,11.069304815507364,11.317986476196008,11.569896988756009,11.825048221409341,12.083451977536606,12.345119996613247,12.610063955123938,12.878295467455942,13.149826086772048,13.42466730586372,13.702830557985108,13.984327217668513,14.269168601521828,14.55736596900856,14.848930523210871,15.143873411576273,15.44220572664832,15.743938506781891,16.04908273684337,16.35764934889634,16.66964922287304,16.985093187232053,17.30399201960269,17.62635644741625,17.95219714852476,18.281524751807332,18.614349837764564,18.95068293910138,19.290534541298456,19.633915083172692,19.98083495742689,20.331304511189067,20.685334046541502,21.042933821039977,21.404114048223256,21.76888489811322,22.137256497705877,22.50923893145328,22.884842241736916,23.264076429332462,23.6469514538663,24.033477234264016,24.42366364919083,24.817520537484558,25.21505769858089,25.61628489293138,26.021211842414342,26.429848230738664,26.842203703840827,27.258287870275353,27.678110301598522,28.10168053274597,28.529008062403893,28.96010235337422,29.39497283293396,29.83362889318845,30.276079891419332,30.722335150426627,31.172403958865512,31.62629557157785,32.08401920991837,32.54558406207592,33.010999283389665,33.4802739966603,33.953417292456834,34.430438229418264,34.911345834551085,35.39614910352207,35.88485700094671,36.37747846067349,36.87402238606382,37.37449765026789,37.87891309649659,38.38727753828926,38.89959975977785,39.41588851594697,39.93615253289054,40.460400508064545,40.98864111053629,41.520882981230194,42.05713473317016,42.597404951718396,43.141702194811224,43.6900349931913,44.24241185063697,44.798841244188324,45.35933162437017,45.92389141541209,46.49252901546552,47.065252796817916,47.64207110610409,48.22299226451468,48.808024568002054,49.3971762874833,49.9904556690408,50.587870934119984,51.189430279724725,51.79514187861014,52.40501387947288,53.0190544071392,53.637271562750364,54.259673423945976,54.88626804504493,55.517063457223934,56.15206766869424,56.79128866487574,57.43473440856916,58.08241284012621,58.734331877617365,59.39049941699807,60.05092333227251,60.715611475655585,61.38457167773311,62.057811747619894,62.7353394731159,63.417162620860914,64.10328893648692,64.79372614476921,65.48848194977529,66.18756403501224,66.89098006357258,67.59873767827808,68.31084450182222,69.02730813691093,69.74813616640164,70.47333615344107,71.20291564160104,71.93688215501312,72.67524319850172,73.41800625771542,74.16517879925733,74.9167682708136,75.67278210128072,76.43322770089146,77.1981124613393,77.96744375590167,78.74122893956174,79.51947534912904,80.30219030335869,81.08938110306934,81.88105503125999,82.67721935322541,83.4778813166706,84.28304815182372,85.09272707154808,85.90692527145302,86.72564993000343,87.54890820862819,88.3767072518277,89.2090541872801,90.04595612594655,90.88742016217518,91.73345337380438,92.58406282226491,93.43925555268066,94.29903859396902,95.16341895893969,96.03240364439274,96.9059996312159,97.78421388448044,98.6670533535366,99.55452497210776];class O{static from(t,e,n){return new O(b.solveToInt(t,e,n))}static fromInt(t){return new O(t)}toInt(){return this.argb}get hue(){return this.internalHue}set hue(t){this.setInternalState(b.solveToInt(t,this.internalChroma,this.internalTone))}get chroma(){return this.internalChroma}set chroma(t){this.setInternalState(b.solveToInt(this.internalHue,t,this.internalTone))}get tone(){return this.internalTone}set tone(t){this.setInternalState(b.solveToInt(this.internalHue,this.internalChroma,t))}constructor(t){this.argb=t;const e=N.fromInt(t);this.internalHue=e.hue,this.internalChroma=e.chroma,this.internalTone=bt(t),this.argb=t}setInternalState(t){const e=N.fromInt(t);this.internalHue=e.hue,this.internalChroma=e.chroma,this.internalTone=bt(t),this.argb=t}inViewingConditions(t){const e=N.fromInt(this.toInt()).xyzInViewingConditions(t),n=N.fromXyzInViewingConditions(e[0],e[1],e[2],W.make());return O.from(n.hue,n.chroma,It(e[1]))}}class Dt{static harmonize(t,e){const n=O.fromInt(t),r=O.fromInt(e),a=Lt(n.hue,r.hue),o=Math.min(.5*a,15),s=wt(n.hue+o*Ht(n.hue,r.hue));return O.from(s,n.chroma,n.tone).toInt()}static hctHue(t,e,n){const r=Dt.cam16Ucs(t,e,n),a=N.fromInt(r),o=N.fromInt(t);return O.from(a.hue,o.chroma,bt(t)).toInt()}static cam16Ucs(t,e,n){const r=N.fromInt(t),a=N.fromInt(e),o=r.jstar,s=r.astar,c=r.bstar,l=o+(a.jstar-o)*n,u=s+(a.astar-s)*n,d=c+(a.bstar-c)*n;return N.fromUcs(l,u,d).toInt()}}class z{static ratioOfTones(t,e){return t=ut(0,100,t),e=ut(0,100,e),z.ratioOfYs(Q(t),Q(e))}static ratioOfYs(t,e){const n=t>e?t:e;return(n+5)/((n===e?t:e)+5)}static lighter(t,e){if(t<0||t>100)return-1;const n=Q(t),r=e*(n+5)-5,a=z.ratioOfYs(r,n),o=Math.abs(a-e);if(a<e&&o>.04)return-1;const s=It(r)+.4;return s<0||s>100?-1:s}static darker(t,e){if(t<0||t>100)return-1;const n=Q(t),r=(n+5)/e-5,a=z.ratioOfYs(n,r),o=Math.abs(a-e);if(a<e&&o>.04)return-1;const s=It(r)-.4;return s<0||s>100?-1:s}static lighterUnsafe(t,e){const n=z.lighter(t,e);return n<0?100:n}static darkerUnsafe(t,e){const n=z.darker(t,e);return n<0?0:n}}class At{static isDisliked(t){const e=Math.round(t.hue)>=90&&Math.round(t.hue)<=111,n=Math.round(t.chroma)>16,r=Math.round(t.tone)<65;return e&&n&&r}static fixIfDisliked(t){return At.isDisliked(t)?O.from(t.hue,t.chroma,70):t}}class y{static fromPalette(t){return new y(t.name??"",t.palette,t.tone,t.isBackground??!1,t.background,t.secondBackground,t.contrastCurve,t.toneDeltaPair)}constructor(t,e,n,r,a,o,s,c){if(this.name=t,this.palette=e,this.tone=n,this.isBackground=r,this.background=a,this.secondBackground=o,this.contrastCurve=s,this.toneDeltaPair=c,this.hctCache=new Map,!a&&o)throw new Error(`Color ${t} has secondBackgrounddefined, but background is not defined.`);if(!a&&s)throw new Error(`Color ${t} has contrastCurvedefined, but background is not defined.`);if(a&&!s)throw new Error(`Color ${t} has backgrounddefined, but contrastCurve is not defined.`)}getArgb(t){return this.getHct(t).toInt()}getHct(t){const e=this.hctCache.get(t);if(null!=e)return e;const n=this.getTone(t),r=this.palette(t).getHct(n);return this.hctCache.size>4&&this.hctCache.clear(),this.hctCache.set(t,r),r}getTone(t){const e=t.contrastLevel<0;if(this.toneDeltaPair){const n=this.toneDeltaPair(t),r=n.roleA,a=n.roleB,o=n.delta,s=n.polarity,c=n.stayTogether,l=this.background(t).getTone(t),u="nearer"===s||"lighter"===s&&!t.isDark||"darker"===s&&t.isDark,d=u?r:a,h=u?a:r,m=this.name===d.name,f=t.isDark?1:-1,g=d.contrastCurve.get(t.contrastLevel),p=h.contrastCurve.get(t.contrastLevel),k=d.tone(t);let C=z.ratioOfTones(l,k)>=g?k:y.foregroundTone(l,g);const M=h.tone(t);let x=z.ratioOfTones(l,M)>=p?M:y.foregroundTone(l,p);return e&&(C=y.foregroundTone(l,g),x=y.foregroundTone(l,p)),(x-C)*f>=o||(x=ut(0,100,C+o*f),(x-C)*f>=o||(C=ut(0,100,x-o*f))),50<=C&&C<60?f>0?(C=60,x=Math.max(x,C+o*f)):(C=49,x=Math.min(x,C+o*f)):50<=x&&x<60&&(c?f>0?(C=60,x=Math.max(x,C+o*f)):(C=49,x=Math.min(x,C+o*f)):x=f>0?60:49),m?C:x}{let n=this.tone(t);if(null==this.background)return n;const r=this.background(t).getTone(t),a=this.contrastCurve.get(t.contrastLevel);if(z.ratioOfTones(r,n)>=a||(n=y.foregroundTone(r,a)),e&&(n=y.foregroundTone(r,a)),this.isBackground&&50<=n&&n<60&&(n=z.ratioOfTones(49,r)>=a?49:60),this.secondBackground){const[e,r]=[this.background,this.secondBackground],[o,s]=[e(t).getTone(t),r(t).getTone(t)],[c,l]=[Math.max(o,s),Math.min(o,s)];if(z.ratioOfTones(c,n)>=a&&z.ratioOfTones(l,n)>=a)return n;const u=z.lighter(c,a),d=z.darker(l,a),h=[];return-1!==u&&h.push(u),-1!==d&&h.push(d),y.tonePrefersLightForeground(o)||y.tonePrefersLightForeground(s)?u<0?100:u:1===h.length?h[0]:d<0?0:d}return n}}static foregroundTone(t,e){const n=z.lighterUnsafe(t,e),r=z.darkerUnsafe(t,e),a=z.ratioOfTones(n,t),o=z.ratioOfTones(r,t);if(y.tonePrefersLightForeground(t)){const t=Math.abs(a-o)<.1&&a<e&&o<e;return a>=e||a>=o||t?n:r}return o>=e||o>=a?r:n}static tonePrefersLightForeground(t){return Math.round(t)<60}static toneAllowsLightForeground(t){return Math.round(t)<=49}static enableLightForeground(t){return y.tonePrefersLightForeground(t)&&!y.toneAllowsLightForeground(t)?49:t}}class _{static fromInt(t){const e=O.fromInt(t);return _.fromHct(e)}static fromHct(t){return new _(t.hue,t.chroma,t)}static fromHueAndChroma(t,e){const n=new Kt(t,e).create();return new _(t,e,n)}constructor(t,e,n){this.hue=t,this.chroma=e,this.keyColor=n,this.cache=new Map}tone(t){let e=this.cache.get(t);return void 0===e&&(e=O.from(this.hue,this.chroma,t).toInt(),this.cache.set(t,e)),e}getHct(t){return O.fromInt(this.tone(t))}}class Kt{constructor(t,e){this.hue=t,this.requestedChroma=e,this.chromaCache=new Map,this.maxChromaValue=200}create(){let t=0,e=100;for(;t<e;){const n=Math.floor((t+e)/2),r=this.maxChroma(n)<this.maxChroma(n+1);if(this.maxChroma(n)>=this.requestedChroma-.01)if(Math.abs(t-50)<Math.abs(e-50))e=n;else{if(t===n)return O.from(this.hue,this.requestedChroma,t);t=n}else r?t=n+1:e=n}return O.from(this.hue,this.requestedChroma,t)}maxChroma(t){if(this.chromaCache.has(t))return this.chromaCache.get(t);const e=O.from(this.hue,this.maxChromaValue,t).chroma;return this.chromaCache.set(t,e),e}}class w{constructor(t,e,n,r){this.low=t,this.normal=e,this.medium=n,this.high=r}get(t){return t<=-1?this.low:t<0?nt(this.low,this.normal,(t- -1)/1):t<.5?nt(this.normal,this.medium,(t-0)/.5):t<1?nt(this.medium,this.high,(t-.5)/.5):this.high}}class v{constructor(t,e,n,r,a){this.roleA=t,this.roleB=e,this.delta=n,this.polarity=r,this.stayTogether=a}}var ot;function et(t){return t.variant===ot.FIDELITY||t.variant===ot.CONTENT}function E(t){return t.variant===ot.MONOCHROME}function Qt(t,e,n,r){let a=n,o=O.from(t,e,n);if(o.chroma<e){let n=o.chroma;for(;o.chroma<e;){a+=r?-1:1;const s=O.from(t,e,a);if(n>s.chroma||Math.abs(s.chroma-e)<.4)break;Math.abs(s.chroma-e)<Math.abs(o.chroma-e)&&(o=s),n=Math.max(n,s.chroma)}}return a}!function(t){t[t.MONOCHROME=0]="MONOCHROME",t[t.NEUTRAL=1]="NEUTRAL",t[t.TONAL_SPOT=2]="TONAL_SPOT",t[t.VIBRANT=3]="VIBRANT",t[t.EXPRESSIVE=4]="EXPRESSIVE",t[t.FIDELITY=5]="FIDELITY",t[t.CONTENT=6]="CONTENT",t[t.RAINBOW=7]="RAINBOW",t[t.FRUIT_SALAD=8]="FRUIT_SALAD"}(ot||(ot={}));class i{static highestSurface(t){return t.isDark?i.surfaceBright:i.surfaceDim}}i.contentAccentToneDelta=15,i.primaryPaletteKeyColor=y.fromPalette({name:"primary_palette_key_color",palette:t=>t.primaryPalette,tone:t=>t.primaryPalette.keyColor.tone}),i.secondaryPaletteKeyColor=y.fromPalette({name:"secondary_palette_key_color",palette:t=>t.secondaryPalette,tone:t=>t.secondaryPalette.keyColor.tone}),i.tertiaryPaletteKeyColor=y.fromPalette({name:"tertiary_palette_key_color",palette:t=>t.tertiaryPalette,tone:t=>t.tertiaryPalette.keyColor.tone}),i.neutralPaletteKeyColor=y.fromPalette({name:"neutral_palette_key_color",palette:t=>t.neutralPalette,tone:t=>t.neutralPalette.keyColor.tone}),i.neutralVariantPaletteKeyColor=y.fromPalette({name:"neutral_variant_palette_key_color",palette:t=>t.neutralVariantPalette,tone:t=>t.neutralVariantPalette.keyColor.tone}),i.background=y.fromPalette({name:"background",palette:t=>t.neutralPalette,tone:t=>t.isDark?6:98,isBackground:!0}),i.onBackground=y.fromPalette({name:"on_background",palette:t=>t.neutralPalette,tone:t=>t.isDark?90:10,background:t=>i.background,contrastCurve:new w(3,3,4.5,7)}),i.surface=y.fromPalette({name:"surface",palette:t=>t.neutralPalette,tone:t=>t.isDark?6:98,isBackground:!0}),i.surfaceDim=y.fromPalette({name:"surface_dim",palette:t=>t.neutralPalette,tone:t=>t.isDark?6:new w(87,87,80,75).get(t.contrastLevel),isBackground:!0}),i.surfaceBright=y.fromPalette({name:"surface_bright",palette:t=>t.neutralPalette,tone:t=>t.isDark?new w(24,24,29,34).get(t.contrastLevel):98,isBackground:!0}),i.surfaceContainerLowest=y.fromPalette({name:"surface_container_lowest",palette:t=>t.neutralPalette,tone:t=>t.isDark?new w(4,4,2,0).get(t.contrastLevel):100,isBackground:!0}),i.surfaceContainerLow=y.fromPalette({name:"surface_container_low",palette:t=>t.neutralPalette,tone:t=>t.isDark?new w(10,10,11,12).get(t.contrastLevel):new w(96,96,96,95).get(t.contrastLevel),isBackground:!0}),i.surfaceContainer=y.fromPalette({name:"surface_container",palette:t=>t.neutralPalette,tone:t=>t.isDark?new w(12,12,16,20).get(t.contrastLevel):new w(94,94,92,90).get(t.contrastLevel),isBackground:!0}),i.surfaceContainerHigh=y.fromPalette({name:"surface_container_high",palette:t=>t.neutralPalette,tone:t=>t.isDark?new w(17,17,21,25).get(t.contrastLevel):new w(92,92,88,85).get(t.contrastLevel),isBackground:!0}),i.surfaceContainerHighest=y.fromPalette({name:"surface_container_highest",palette:t=>t.neutralPalette,tone:t=>t.isDark?new w(22,22,26,30).get(t.contrastLevel):new w(90,90,84,80).get(t.contrastLevel),isBackground:!0}),i.onSurface=y.fromPalette({name:"on_surface",palette:t=>t.neutralPalette,tone:t=>t.isDark?90:10,background:t=>i.highestSurface(t),contrastCurve:new w(4.5,7,11,21)}),i.surfaceVariant=y.fromPalette({name:"surface_variant",palette:t=>t.neutralVariantPalette,tone:t=>t.isDark?30:90,isBackground:!0}),i.onSurfaceVariant=y.fromPalette({name:"on_surface_variant",palette:t=>t.neutralVariantPalette,tone:t=>t.isDark?80:30,background:t=>i.highestSurface(t),contrastCurve:new w(3,4.5,7,11)}),i.inverseSurface=y.fromPalette({name:"inverse_surface",palette:t=>t.neutralPalette,tone:t=>t.isDark?90:20}),i.inverseOnSurface=y.fromPalette({name:"inverse_on_surface",palette:t=>t.neutralPalette,tone:t=>t.isDark?20:95,background:t=>i.inverseSurface,contrastCurve:new w(4.5,7,11,21)}),i.outline=y.fromPalette({name:"outline",palette:t=>t.neutralVariantPalette,tone:t=>t.isDark?60:50,background:t=>i.highestSurface(t),contrastCurve:new w(1.5,3,4.5,7)}),i.outlineVariant=y.fromPalette({name:"outline_variant",palette:t=>t.neutralVariantPalette,tone:t=>t.isDark?30:80,background:t=>i.highestSurface(t),contrastCurve:new w(1,1,3,4.5)}),i.shadow=y.fromPalette({name:"shadow",palette:t=>t.neutralPalette,tone:t=>0}),i.scrim=y.fromPalette({name:"scrim",palette:t=>t.neutralPalette,tone:t=>0}),i.surfaceTint=y.fromPalette({name:"surface_tint",palette:t=>t.primaryPalette,tone:t=>t.isDark?80:40,isBackground:!0}),i.primary=y.fromPalette({name:"primary",palette:t=>t.primaryPalette,tone:t=>E(t)?t.isDark?100:0:t.isDark?80:40,isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(3,4.5,7,7),toneDeltaPair:t=>new v(i.primaryContainer,i.primary,10,"nearer",!1)}),i.onPrimary=y.fromPalette({name:"on_primary",palette:t=>t.primaryPalette,tone:t=>E(t)?t.isDark?10:90:t.isDark?20:100,background:t=>i.primary,contrastCurve:new w(4.5,7,11,21)}),i.primaryContainer=y.fromPalette({name:"primary_container",palette:t=>t.primaryPalette,tone:t=>et(t)?t.sourceColorHct.tone:E(t)?t.isDark?85:25:t.isDark?30:90,isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(1,1,3,4.5),toneDeltaPair:t=>new v(i.primaryContainer,i.primary,10,"nearer",!1)}),i.onPrimaryContainer=y.fromPalette({name:"on_primary_container",palette:t=>t.primaryPalette,tone:t=>et(t)?y.foregroundTone(i.primaryContainer.tone(t),4.5):E(t)?t.isDark?0:100:t.isDark?90:30,background:t=>i.primaryContainer,contrastCurve:new w(3,4.5,7,11)}),i.inversePrimary=y.fromPalette({name:"inverse_primary",palette:t=>t.primaryPalette,tone:t=>t.isDark?40:80,background:t=>i.inverseSurface,contrastCurve:new w(3,4.5,7,7)}),i.secondary=y.fromPalette({name:"secondary",palette:t=>t.secondaryPalette,tone:t=>t.isDark?80:40,isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(3,4.5,7,7),toneDeltaPair:t=>new v(i.secondaryContainer,i.secondary,10,"nearer",!1)}),i.onSecondary=y.fromPalette({name:"on_secondary",palette:t=>t.secondaryPalette,tone:t=>E(t)?t.isDark?10:100:t.isDark?20:100,background:t=>i.secondary,contrastCurve:new w(4.5,7,11,21)}),i.secondaryContainer=y.fromPalette({name:"secondary_container",palette:t=>t.secondaryPalette,tone:t=>{const e=t.isDark?30:90;return E(t)?t.isDark?30:85:et(t)?Qt(t.secondaryPalette.hue,t.secondaryPalette.chroma,e,!t.isDark):e},isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(1,1,3,4.5),toneDeltaPair:t=>new v(i.secondaryContainer,i.secondary,10,"nearer",!1)}),i.onSecondaryContainer=y.fromPalette({name:"on_secondary_container",palette:t=>t.secondaryPalette,tone:t=>E(t)?t.isDark?90:10:et(t)?y.foregroundTone(i.secondaryContainer.tone(t),4.5):t.isDark?90:30,background:t=>i.secondaryContainer,contrastCurve:new w(3,4.5,7,11)}),i.tertiary=y.fromPalette({name:"tertiary",palette:t=>t.tertiaryPalette,tone:t=>E(t)?t.isDark?90:25:t.isDark?80:40,isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(3,4.5,7,7),toneDeltaPair:t=>new v(i.tertiaryContainer,i.tertiary,10,"nearer",!1)}),i.onTertiary=y.fromPalette({name:"on_tertiary",palette:t=>t.tertiaryPalette,tone:t=>E(t)?t.isDark?10:90:t.isDark?20:100,background:t=>i.tertiary,contrastCurve:new w(4.5,7,11,21)}),i.tertiaryContainer=y.fromPalette({name:"tertiary_container",palette:t=>t.tertiaryPalette,tone:t=>{if(E(t))return t.isDark?60:49;if(!et(t))return t.isDark?30:90;const e=t.tertiaryPalette.getHct(t.sourceColorHct.tone);return At.fixIfDisliked(e).tone},isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(1,1,3,4.5),toneDeltaPair:t=>new v(i.tertiaryContainer,i.tertiary,10,"nearer",!1)}),i.onTertiaryContainer=y.fromPalette({name:"on_tertiary_container",palette:t=>t.tertiaryPalette,tone:t=>E(t)?t.isDark?0:100:et(t)?y.foregroundTone(i.tertiaryContainer.tone(t),4.5):t.isDark?90:30,background:t=>i.tertiaryContainer,contrastCurve:new w(3,4.5,7,11)}),i.error=y.fromPalette({name:"error",palette:t=>t.errorPalette,tone:t=>t.isDark?80:40,isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(3,4.5,7,7),toneDeltaPair:t=>new v(i.errorContainer,i.error,10,"nearer",!1)}),i.onError=y.fromPalette({name:"on_error",palette:t=>t.errorPalette,tone:t=>t.isDark?20:100,background:t=>i.error,contrastCurve:new w(4.5,7,11,21)}),i.errorContainer=y.fromPalette({name:"error_container",palette:t=>t.errorPalette,tone:t=>t.isDark?30:90,isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(1,1,3,4.5),toneDeltaPair:t=>new v(i.errorContainer,i.error,10,"nearer",!1)}),i.onErrorContainer=y.fromPalette({name:"on_error_container",palette:t=>t.errorPalette,tone:t=>E(t)?t.isDark?90:10:t.isDark?90:30,background:t=>i.errorContainer,contrastCurve:new w(3,4.5,7,11)}),i.primaryFixed=y.fromPalette({name:"primary_fixed",palette:t=>t.primaryPalette,tone:t=>E(t)?40:90,isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(1,1,3,4.5),toneDeltaPair:t=>new v(i.primaryFixed,i.primaryFixedDim,10,"lighter",!0)}),i.primaryFixedDim=y.fromPalette({name:"primary_fixed_dim",palette:t=>t.primaryPalette,tone:t=>E(t)?30:80,isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(1,1,3,4.5),toneDeltaPair:t=>new v(i.primaryFixed,i.primaryFixedDim,10,"lighter",!0)}),i.onPrimaryFixed=y.fromPalette({name:"on_primary_fixed",palette:t=>t.primaryPalette,tone:t=>E(t)?100:10,background:t=>i.primaryFixedDim,secondBackground:t=>i.primaryFixed,contrastCurve:new w(4.5,7,11,21)}),i.onPrimaryFixedVariant=y.fromPalette({name:"on_primary_fixed_variant",palette:t=>t.primaryPalette,tone:t=>E(t)?90:30,background:t=>i.primaryFixedDim,secondBackground:t=>i.primaryFixed,contrastCurve:new w(3,4.5,7,11)}),i.secondaryFixed=y.fromPalette({name:"secondary_fixed",palette:t=>t.secondaryPalette,tone:t=>E(t)?80:90,isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(1,1,3,4.5),toneDeltaPair:t=>new v(i.secondaryFixed,i.secondaryFixedDim,10,"lighter",!0)}),i.secondaryFixedDim=y.fromPalette({name:"secondary_fixed_dim",palette:t=>t.secondaryPalette,tone:t=>E(t)?70:80,isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(1,1,3,4.5),toneDeltaPair:t=>new v(i.secondaryFixed,i.secondaryFixedDim,10,"lighter",!0)}),i.onSecondaryFixed=y.fromPalette({name:"on_secondary_fixed",palette:t=>t.secondaryPalette,tone:t=>10,background:t=>i.secondaryFixedDim,secondBackground:t=>i.secondaryFixed,contrastCurve:new w(4.5,7,11,21)}),i.onSecondaryFixedVariant=y.fromPalette({name:"on_secondary_fixed_variant",palette:t=>t.secondaryPalette,tone:t=>E(t)?25:30,background:t=>i.secondaryFixedDim,secondBackground:t=>i.secondaryFixed,contrastCurve:new w(3,4.5,7,11)}),i.tertiaryFixed=y.fromPalette({name:"tertiary_fixed",palette:t=>t.tertiaryPalette,tone:t=>E(t)?40:90,isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(1,1,3,4.5),toneDeltaPair:t=>new v(i.tertiaryFixed,i.tertiaryFixedDim,10,"lighter",!0)}),i.tertiaryFixedDim=y.fromPalette({name:"tertiary_fixed_dim",palette:t=>t.tertiaryPalette,tone:t=>E(t)?30:80,isBackground:!0,background:t=>i.highestSurface(t),contrastCurve:new w(1,1,3,4.5),toneDeltaPair:t=>new v(i.tertiaryFixed,i.tertiaryFixedDim,10,"lighter",!0)}),i.onTertiaryFixed=y.fromPalette({name:"on_tertiary_fixed",palette:t=>t.tertiaryPalette,tone:t=>E(t)?100:10,background:t=>i.tertiaryFixedDim,secondBackground:t=>i.tertiaryFixed,contrastCurve:new w(4.5,7,11,21)}),i.onTertiaryFixedVariant=y.fromPalette({name:"on_tertiary_fixed_variant",palette:t=>t.tertiaryPalette,tone:t=>E(t)?90:30,background:t=>i.tertiaryFixedDim,secondBackground:t=>i.tertiaryFixed,contrastCurve:new w(3,4.5,7,11)});class S{static of(t){return new S(t,!1)}static contentOf(t){return new S(t,!0)}static fromColors(t){return S.createPaletteFromColors(!1,t)}static contentFromColors(t){return S.createPaletteFromColors(!0,t)}static createPaletteFromColors(t,e){const n=new S(e.primary,t);if(e.secondary){const r=new S(e.secondary,t);n.a2=r.a1}if(e.tertiary){const r=new S(e.tertiary,t);n.a3=r.a1}if(e.error){const r=new S(e.error,t);n.error=r.a1}if(e.neutral){const r=new S(e.neutral,t);n.n1=r.n1}if(e.neutralVariant){const r=new S(e.neutralVariant,t);n.n2=r.n2}return n}constructor(t,e){const n=O.fromInt(t),r=n.hue,a=n.chroma;e?(this.a1=_.fromHueAndChroma(r,a),this.a2=_.fromHueAndChroma(r,a/3),this.a3=_.fromHueAndChroma(r+60,a/2),this.n1=_.fromHueAndChroma(r,Math.min(a/12,4)),this.n2=_.fromHueAndChroma(r,Math.min(a/6,8))):(this.a1=_.fromHueAndChroma(r,Math.max(48,a)),this.a2=_.fromHueAndChroma(r,16),this.a3=_.fromHueAndChroma(r+60,24),this.n1=_.fromHueAndChroma(r,4),this.n2=_.fromHueAndChroma(r,8)),this.error=_.fromHueAndChroma(25,84)}}class Zt{fromInt(t){return Jt(t)}toInt(t){return Wt(t[0],t[1],t[2])}distance(t,e){const n=t[0]-e[0],r=t[1]-e[1],a=t[2]-e[2];return n*n+r*r+a*a}}const te=10,ee=3;class re{static quantize(t,e,n){const r=new Map,a=new Array,o=new Array,s=new Zt;let c=0;for(let e=0;e<t.length;e++){const n=t[e],l=r.get(n);void 0===l?(c++,a.push(s.fromInt(n)),o.push(n),r.set(n,1)):r.set(n,l+1)}const l=new Array;for(let t=0;t<c;t++){const e=o[t],n=r.get(e);void 0!==n&&(l[t]=n)}let u=Math.min(n,c);e.length>0&&(u=Math.min(u,e.length));const d=new Array;for(let t=0;t<e.length;t++)d.push(s.fromInt(e[t]));const h=u-d.length;if(0===e.length&&h>0)for(let t=0;t<h;t++){const t=100*Math.random(),e=201*Math.random()-100,n=201*Math.random()-100;d.push(new Array(t,e,n))}const m=new Array;for(let t=0;t<c;t++)m.push(Math.floor(Math.random()*u));const f=new Array;for(let t=0;t<u;t++){f.push(new Array);for(let e=0;e<u;e++)f[t].push(0)}const g=new Array;for(let t=0;t<u;t++){g.push(new Array);for(let e=0;e<u;e++)g[t].push(new ne)}const p=new Array;for(let t=0;t<u;t++)p.push(0);for(let t=0;t<10;t++){for(let t=0;t<u;t++){for(let e=t+1;e<u;e++){const n=s.distance(d[t],d[e]);g[e][t].distance=n,g[e][t].index=t,g[t][e].distance=n,g[t][e].index=e}g[t].sort();for(let e=0;e<u;e++)f[t][e]=g[t][e].index}let e=0;for(let t=0;t<c;t++){const n=a[t],r=m[t],o=d[r],c=s.distance(n,o);let l=c,h=-1;for(let t=0;t<u;t++){if(g[r][t].distance>=4*c)continue;const e=s.distance(n,d[t]);e<l&&(l=e,h=t)}-1!==h&&Math.abs(Math.sqrt(l)-Math.sqrt(c))>3&&(e++,m[t]=h)}if(0===e&&0!==t)break;const n=new Array(u).fill(0),r=new Array(u).fill(0),o=new Array(u).fill(0);for(let t=0;t<u;t++)p[t]=0;for(let t=0;t<c;t++){const e=m[t],s=a[t],c=l[t];p[e]+=c,n[e]+=s[0]*c,r[e]+=s[1]*c,o[e]+=s[2]*c}for(let t=0;t<u;t++){const e=p[t];if(0===e){d[t]=[0,0,0];continue}const a=n[t]/e,s=r[t]/e,c=o[t]/e;d[t]=[a,s,c]}}const k=new Map;for(let t=0;t<u;t++){const e=p[t];if(0===e)continue;const n=s.toInt(d[t]);k.has(n)||k.set(n,e)}return k}}class ne{constructor(){this.distance=-1,this.index=-1}}class ae{static quantize(t){const e=new Map;for(let n=0;n<t.length;n++){const r=t[n];jt(r)<255||e.set(r,(e.get(r)??0)+1)}return e}}const lt=5,Y=33,rt=35937,V={RED:"red",GREEN:"green",BLUE:"blue"};class oe{constructor(t=[],e=[],n=[],r=[],a=[],o=[]){this.weights=t,this.momentsR=e,this.momentsG=n,this.momentsB=r,this.moments=a,this.cubes=o}quantize(t,e){this.constructHistogram(t),this.computeMoments();const n=this.createBoxes(e);return this.createResult(n.resultCount)}constructHistogram(t){this.weights=Array.from({length:rt}).fill(0),this.momentsR=Array.from({length:rt}).fill(0),this.momentsG=Array.from({length:rt}).fill(0),this.momentsB=Array.from({length:rt}).fill(0),this.moments=Array.from({length:rt}).fill(0);const e=ae.quantize(t);for(const[t,n]of e.entries()){const e=mt(t),r=dt(t),a=gt(t),o=3,s=1+(e>>o),c=1+(r>>o),l=1+(a>>o),u=this.getIndex(s,c,l);this.weights[u]=(this.weights[u]??0)+n,this.momentsR[u]+=n*e,this.momentsG[u]+=n*r,this.momentsB[u]+=n*a,this.moments[u]+=n*(e*e+r*r+a*a)}}computeMoments(){for(let t=1;t<Y;t++){const e=Array.from({length:Y}).fill(0),n=Array.from({length:Y}).fill(0),r=Array.from({length:Y}).fill(0),a=Array.from({length:Y}).fill(0),o=Array.from({length:Y}).fill(0);for(let s=1;s<Y;s++){let c=0,l=0,u=0,d=0,h=0;for(let m=1;m<Y;m++){const f=this.getIndex(t,s,m);c+=this.weights[f],l+=this.momentsR[f],u+=this.momentsG[f],d+=this.momentsB[f],h+=this.moments[f],e[m]+=c,n[m]+=l,r[m]+=u,a[m]+=d,o[m]+=h;const g=this.getIndex(t-1,s,m);this.weights[f]=this.weights[g]+e[m],this.momentsR[f]=this.momentsR[g]+n[m],this.momentsG[f]=this.momentsG[g]+r[m],this.momentsB[f]=this.momentsB[g]+a[m],this.moments[f]=this.moments[g]+o[m]}}}}createBoxes(t){this.cubes=Array.from({length:t}).fill(0).map(()=>new se);const e=Array.from({length:t}).fill(0);this.cubes[0].r0=0,this.cubes[0].g0=0,this.cubes[0].b0=0,this.cubes[0].r1=32,this.cubes[0].g1=32,this.cubes[0].b1=32;let n=t,r=0;for(let a=1;a<t;a++){this.cut(this.cubes[r],this.cubes[a])?(e[r]=this.cubes[r].vol>1?this.variance(this.cubes[r]):0,e[a]=this.cubes[a].vol>1?this.variance(this.cubes[a]):0):(e[r]=0,a--),r=0;let t=e[0];for(let n=1;n<=a;n++)e[n]>t&&(t=e[n],r=n);if(t<=0){n=a+1;break}}return new ie(t,n)}createResult(t){const e=[];for(let n=0;n<t;++n){const t=this.cubes[n],r=this.volume(t,this.weights);if(r>0){const n=255<<24|(255&Math.round(this.volume(t,this.momentsR)/r))<<16|(255&Math.round(this.volume(t,this.momentsG)/r))<<8|255&Math.round(this.volume(t,this.momentsB)/r);e.push(n)}}return e}variance(t){const e=this.volume(t,this.momentsR),n=this.volume(t,this.momentsG),r=this.volume(t,this.momentsB);return this.moments[this.getIndex(t.r1,t.g1,t.b1)]-this.moments[this.getIndex(t.r1,t.g1,t.b0)]-this.moments[this.getIndex(t.r1,t.g0,t.b1)]+this.moments[this.getIndex(t.r1,t.g0,t.b0)]-this.moments[this.getIndex(t.r0,t.g1,t.b1)]+this.moments[this.getIndex(t.r0,t.g1,t.b0)]+this.moments[this.getIndex(t.r0,t.g0,t.b1)]-this.moments[this.getIndex(t.r0,t.g0,t.b0)]-(e*e+n*n+r*r)/this.volume(t,this.weights)}cut(t,e){const n=this.volume(t,this.momentsR),r=this.volume(t,this.momentsG),a=this.volume(t,this.momentsB),o=this.volume(t,this.weights),s=this.maximize(t,V.RED,t.r0+1,t.r1,n,r,a,o),c=this.maximize(t,V.GREEN,t.g0+1,t.g1,n,r,a,o),l=this.maximize(t,V.BLUE,t.b0+1,t.b1,n,r,a,o);let u;const d=s.maximum,h=c.maximum,m=l.maximum;if(d>=h&&d>=m){if(s.cutLocation<0)return!1;u=V.RED}else u=h>=d&&h>=m?V.GREEN:V.BLUE;switch(e.r1=t.r1,e.g1=t.g1,e.b1=t.b1,u){case V.RED:t.r1=s.cutLocation,e.r0=t.r1,e.g0=t.g0,e.b0=t.b0;break;case V.GREEN:t.g1=c.cutLocation,e.r0=t.r0,e.g0=t.g1,e.b0=t.b0;break;case V.BLUE:t.b1=l.cutLocation,e.r0=t.r0,e.g0=t.g0,e.b0=t.b1;break;default:throw new Error("unexpected direction "+u)}return t.vol=(t.r1-t.r0)*(t.g1-t.g0)*(t.b1-t.b0),e.vol=(e.r1-e.r0)*(e.g1-e.g0)*(e.b1-e.b0),!0}maximize(t,e,n,r,a,o,s,c){const l=this.bottom(t,e,this.momentsR),u=this.bottom(t,e,this.momentsG),d=this.bottom(t,e,this.momentsB),h=this.bottom(t,e,this.weights);let m=0,f=-1,g=0,p=0,k=0,C=0;for(let M=n;M<r;M++){if(g=l+this.top(t,e,M,this.momentsR),p=u+this.top(t,e,M,this.momentsG),k=d+this.top(t,e,M,this.momentsB),C=h+this.top(t,e,M,this.weights),0===C)continue;let n=1*(g*g+p*p+k*k),r=1*C,x=n/r;g=a-g,p=o-p,k=s-k,C=c-C,0!==C&&(n=1*(g*g+p*p+k*k),r=1*C,x+=n/r,x>m&&(m=x,f=M))}return new ce(f,m)}volume(t,e){return e[this.getIndex(t.r1,t.g1,t.b1)]-e[this.getIndex(t.r1,t.g1,t.b0)]-e[this.getIndex(t.r1,t.g0,t.b1)]+e[this.getIndex(t.r1,t.g0,t.b0)]-e[this.getIndex(t.r0,t.g1,t.b1)]+e[this.getIndex(t.r0,t.g1,t.b0)]+e[this.getIndex(t.r0,t.g0,t.b1)]-e[this.getIndex(t.r0,t.g0,t.b0)]}bottom(t,e,n){switch(e){case V.RED:return-n[this.getIndex(t.r0,t.g1,t.b1)]+n[this.getIndex(t.r0,t.g1,t.b0)]+n[this.getIndex(t.r0,t.g0,t.b1)]-n[this.getIndex(t.r0,t.g0,t.b0)];case V.GREEN:return-n[this.getIndex(t.r1,t.g0,t.b1)]+n[this.getIndex(t.r1,t.g0,t.b0)]+n[this.getIndex(t.r0,t.g0,t.b1)]-n[this.getIndex(t.r0,t.g0,t.b0)];case V.BLUE:return-n[this.getIndex(t.r1,t.g1,t.b0)]+n[this.getIndex(t.r1,t.g0,t.b0)]+n[this.getIndex(t.r0,t.g1,t.b0)]-n[this.getIndex(t.r0,t.g0,t.b0)];default:throw new Error("unexpected direction $direction")}}top(t,e,n,r){switch(e){case V.RED:return r[this.getIndex(n,t.g1,t.b1)]-r[this.getIndex(n,t.g1,t.b0)]-r[this.getIndex(n,t.g0,t.b1)]+r[this.getIndex(n,t.g0,t.b0)];case V.GREEN:return r[this.getIndex(t.r1,n,t.b1)]-r[this.getIndex(t.r1,n,t.b0)]-r[this.getIndex(t.r0,n,t.b1)]+r[this.getIndex(t.r0,n,t.b0)];case V.BLUE:return r[this.getIndex(t.r1,t.g1,n)]-r[this.getIndex(t.r1,t.g0,n)]-r[this.getIndex(t.r0,t.g1,n)]+r[this.getIndex(t.r0,t.g0,n)];default:throw new Error("unexpected direction $direction")}}getIndex(t,e,n){return(t<<10)+(t<<6)+t+(e<<5)+e+n}}class se{constructor(t=0,e=0,n=0,r=0,a=0,o=0,s=0){this.r0=t,this.r1=e,this.g0=n,this.g1=r,this.b0=a,this.b1=o,this.vol=s}}class ie{constructor(t,e){this.requestedCount=t,this.resultCount=e}}class ce{constructor(t,e){this.cutLocation=t,this.maximum=e}}class le{static quantize(t,e){const n=(new oe).quantize(t,e);return re.quantize(t,n,e)}}class X{get primary(){return this.props.primary}get onPrimary(){return this.props.onPrimary}get primaryContainer(){return this.props.primaryContainer}get onPrimaryContainer(){return this.props.onPrimaryContainer}get secondary(){return this.props.secondary}get onSecondary(){return this.props.onSecondary}get secondaryContainer(){return this.props.secondaryContainer}get onSecondaryContainer(){return this.props.onSecondaryContainer}get tertiary(){return this.props.tertiary}get onTertiary(){return this.props.onTertiary}get tertiaryContainer(){return this.props.tertiaryContainer}get onTertiaryContainer(){return this.props.onTertiaryContainer}get error(){return this.props.error}get onError(){return this.props.onError}get errorContainer(){return this.props.errorContainer}get onErrorContainer(){return this.props.onErrorContainer}get background(){return this.props.background}get onBackground(){return this.props.onBackground}get surface(){return this.props.surface}get onSurface(){return this.props.onSurface}get surfaceVariant(){return this.props.surfaceVariant}get onSurfaceVariant(){return this.props.onSurfaceVariant}get outline(){return this.props.outline}get outlineVariant(){return this.props.outlineVariant}get shadow(){return this.props.shadow}get scrim(){return this.props.scrim}get inverseSurface(){return this.props.inverseSurface}get inverseOnSurface(){return this.props.inverseOnSurface}get inversePrimary(){return this.props.inversePrimary}static light(t){return X.lightFromCorePalette(S.of(t))}static dark(t){return X.darkFromCorePalette(S.of(t))}static lightContent(t){return X.lightFromCorePalette(S.contentOf(t))}static darkContent(t){return X.darkFromCorePalette(S.contentOf(t))}static lightFromCorePalette(t){return new X({primary:t.a1.tone(40),onPrimary:t.a1.tone(100),primaryContainer:t.a1.tone(90),onPrimaryContainer:t.a1.tone(10),secondary:t.a2.tone(40),onSecondary:t.a2.tone(100),secondaryContainer:t.a2.tone(90),onSecondaryContainer:t.a2.tone(10),tertiary:t.a3.tone(40),onTertiary:t.a3.tone(100),tertiaryContainer:t.a3.tone(90),onTertiaryContainer:t.a3.tone(10),error:t.error.tone(40),onError:t.error.tone(100),errorContainer:t.error.tone(90),onErrorContainer:t.error.tone(10),background:t.n1.tone(99),onBackground:t.n1.tone(10),surface:t.n1.tone(99),onSurface:t.n1.tone(10),surfaceVariant:t.n2.tone(90),onSurfaceVariant:t.n2.tone(30),outline:t.n2.tone(50),outlineVariant:t.n2.tone(80),shadow:t.n1.tone(0),scrim:t.n1.tone(0),inverseSurface:t.n1.tone(20),inverseOnSurface:t.n1.tone(95),inversePrimary:t.a1.tone(80)})}static darkFromCorePalette(t){return new X({primary:t.a1.tone(80),onPrimary:t.a1.tone(20),primaryContainer:t.a1.tone(30),onPrimaryContainer:t.a1.tone(90),secondary:t.a2.tone(80),onSecondary:t.a2.tone(20),secondaryContainer:t.a2.tone(30),onSecondaryContainer:t.a2.tone(90),tertiary:t.a3.tone(80),onTertiary:t.a3.tone(20),tertiaryContainer:t.a3.tone(30),onTertiaryContainer:t.a3.tone(90),error:t.error.tone(80),onError:t.error.tone(20),errorContainer:t.error.tone(30),onErrorContainer:t.error.tone(80),background:t.n1.tone(10),onBackground:t.n1.tone(90),surface:t.n1.tone(10),onSurface:t.n1.tone(90),surfaceVariant:t.n2.tone(30),onSurfaceVariant:t.n2.tone(80),outline:t.n2.tone(60),outlineVariant:t.n2.tone(30),shadow:t.n1.tone(0),scrim:t.n1.tone(0),inverseSurface:t.n1.tone(90),inverseOnSurface:t.n1.tone(20),inversePrimary:t.a1.tone(40)})}constructor(t){this.props=t}toJSON(){return{...this.props}}}const he={desired:4,fallbackColorARGB:4282549748,filter:!0};function ue(t,e){return t.score>e.score?-1:t.score<e.score?1:0}class U{constructor(){}static score(t,e){const{desired:n,fallbackColorARGB:r,filter:a}={...he,...e},o=[],s=new Array(360).fill(0);let c=0;for(const[e,n]of t.entries()){const t=O.fromInt(e);o.push(t);s[Math.floor(t.hue)]+=n,c+=n}const l=new Array(360).fill(0);for(let t=0;t<360;t++){const e=s[t]/c;for(let n=t-14;n<t+16;n++){l[Ft(n)]+=e}}const u=new Array;for(const t of o){const e=l[Ft(Math.round(t.hue))];if(a&&(t.chroma<U.CUTOFF_CHROMA||e<=U.CUTOFF_EXCITED_PROPORTION))continue;const n=100*e*U.WEIGHT_PROPORTION,r=t.chroma<U.TARGET_CHROMA?U.WEIGHT_CHROMA_BELOW:U.WEIGHT_CHROMA_ABOVE,o=n+(t.chroma-U.TARGET_CHROMA)*r;u.push({hct:t,score:o})}u.sort(ue);const d=[];for(let t=90;t>=15;t--){d.length=0;for(const{hct:e}of u)if(d.find(n=>Lt(e.hue,n.hue)<t)||d.push(e),d.length>=n)break;if(d.length>=n)break}const h=[];0===d.length&&h.push(r);for(const t of d)h.push(t.toInt());return h}}function F(t){const e=mt(t),n=dt(t),r=gt(t),a=[e.toString(16),n.toString(16),r.toString(16)];for(const[t,e]of a.entries())1===e.length&&(a[t]="0"+e);return"#"+a.join("")}function fe(t){const e=3===(t=t.replace("#","")).length,n=6===t.length,r=8===t.length;if(!e&&!n&&!r)throw new Error("unexpected hex "+t);let a=0,o=0,s=0;return e?(a=J(t.slice(0,1).repeat(2)),o=J(t.slice(1,2).repeat(2)),s=J(t.slice(2,3).repeat(2))):n?(a=J(t.slice(0,2)),o=J(t.slice(2,4)),s=J(t.slice(4,6))):r&&(a=J(t.slice(2,4)),o=J(t.slice(4,6)),s=J(t.slice(6,8))),(255<<24|(255&a)<<16|(255&o)<<8|255&s)>>>0}function J(t){return parseInt(t,16)}async function me(t){const e=await new Promise((e,n)=>{const r=document.createElement("canvas"),a=r.getContext("2d");if(!a)return void n(new Error("Could not get canvas context"));const o=()=>{r.width=t.width,r.height=t.height,a.drawImage(t,0,0);let n=[0,0,t.width,t.height];const o=t.dataset.area;o&&/^\d+(\s*,\s*\d+){3}$/.test(o)&&(n=o.split(/\s*,\s*/).map(t=>parseInt(t,10)));const[s,c,l,u]=n;e(a.getImageData(s,c,l,u).data)};t.complete?o():(t.onload=o,t.onerror=()=>{n(new Error("Image load failed"))})}),n=[];for(let t=0;t<e.length;t+=4){const r=e[t],a=e[t+1],o=e[t+2];if(e[t+3]<255)continue;const s=ft(r,a,o);n.push(s)}const r=le.quantize(n,128);return U.score(r)[0]}function St(t,e=[]){const n=S.of(t);return{source:t,schemes:{light:X.light(t),dark:X.dark(t)},palettes:{primary:n.a1,secondary:n.a2,tertiary:n.a3,neutral:n.n1,neutralVariant:n.n2,error:n.error},customColors:e.map(e=>de(t,e))}}async function Ot(t,e=[]){return St(await me(t),e)}function de(t,e){let n=e.value;const r=n,a=t;e.blend&&(n=Dt.harmonize(r,a));const o=S.of(n).a1;return{color:e,value:n,light:{color:o.tone(40),onColor:o.tone(100),colorContainer:o.tone(90),onColorContainer:o.tone(10)},dark:{color:o.tone(80),onColor:o.tone(20),colorContainer:o.tone(30),onColorContainer:o.tone(90)}}}function Pt(t){let e=JSON.parse(JSON.stringify(t.schemes));for(let t in e)for(let n in e[t])e[t][n]=F(e[t][n]);return e.dark.surfaceDim=F(t.palettes.neutral.tone(6)),e.dark.surface=F(t.palettes.neutral.tone(6)),e.dark.surfaceBright=F(t.palettes.neutral.tone(24)),e.dark.surfaceContainerLowest=F(t.palettes.neutral.tone(4)),e.dark.surfaceContainerLow=F(t.palettes.neutral.tone(10)),e.dark.surfaceContainer=F(t.palettes.neutral.tone(12)),e.dark.surfaceContainerHigh=F(t.palettes.neutral.tone(17)),e.dark.surfaceContainerHighest=F(t.palettes.neutral.tone(22)),e.dark.onSurface=F(t.palettes.neutral.tone(90)),e.dark.onSurfaceVariant=F(t.palettes.neutralVariant.tone(80)),e.dark.outline=F(t.palettes.neutralVariant.tone(60)),e.dark.outlineVariant=F(t.palettes.neutralVariant.tone(30)),e.light.surfaceDim=F(t.palettes.neutral.tone(87)),e.light.surface=F(t.palettes.neutral.tone(98)),e.light.surfaceBright=F(t.palettes.neutral.tone(98)),e.light.surfaceContainerLowest=F(t.palettes.neutral.tone(100)),e.light.surfaceContainerLow=F(t.palettes.neutral.tone(96)),e.light.surfaceContainer=F(t.palettes.neutral.tone(94)),e.light.surfaceContainerHigh=F(t.palettes.neutral.tone(92)),e.light.surfaceContainerHighest=F(t.palettes.neutral.tone(90)),e.light.onSurface=F(t.palettes.neutral.tone(10)),e.light.onSurfaceVariant=F(t.palettes.neutralVariant.tone(30)),e.light.outline=F(t.palettes.neutralVariant.tone(50)),e.light.outlineVariant=F(t.palettes.neutralVariant.tone(80)),e}async function ge(t){const e=t,n={light:{},dark:{}};try{if("string"==typeof e&&/^\#[0-9a-f]+$/i.test(e)){return Pt(St(fe(e)))}if(e.src){return Pt(await Ot(e))}let t=new Blob;if("string"==typeof e&&(t=await fetch(e).then(t=>t.blob())),e.size&&(t=e),e.files&&e.files[0]&&(t=e.files[0]),e.target&&e.target.files&&e.target.files[0]&&(t=e.target.files[0]),!t.size)return n;let r=new Image(64);return r.src=URL.createObjectURL(t),Pt(await Ot(r))}catch{return n}}U.TARGET_CHROMA=48,U.WEIGHT_PROPORTION=.7,U.WEIGHT_CHROMA_ABOVE=.3,U.WEIGHT_CHROMA_BELOW=.1,U.CUTOFF_CHROMA=5,U.CUTOFF_EXCITED_PROPORTION=.01,globalThis.materialDynamicColors=ge,function(t){"use strict";const e={init:function(t={}){const e={sidebarSelector:t.sidebarSelector||".kds-sidebar"},n=document.querySelector(e.sidebarSelector);n?(!function(t){if(!t)return;const e=t.querySelector(".kds-sidebar-header"),n=t.querySelector(".kds-sidebar-header-dropdown");if(!e||!n)return;e.addEventListener("click",function(t){t.stopPropagation(),n.classList.toggle("kds-dropdown-open");const r=e.querySelector(".kds-sidebar-dropdown-icon");r&&(r.style.transform=n.classList.contains("kds-dropdown-open")?"rotate(180deg)":"rotate(0deg)")}),document.addEventListener("click",function(r){if(!t.contains(r.target)){n.classList.remove("kds-dropdown-open");const t=e.querySelector(".kds-sidebar-dropdown-icon");t&&(t.style.transform="rotate(0deg)")}}),n.querySelectorAll("a").forEach(t=>{t.addEventListener("click",function(){n.classList.remove("kds-dropdown-open");const t=e.querySelector(".kds-sidebar-dropdown-icon");t&&(t.style.transform="rotate(0deg)")})})}(n),function(t){if(!t)return;const e=t.querySelectorAll(".kds-sidebar-nav-item");e.forEach(n=>{n.addEventListener("click",function(n){"#"===this.getAttribute("href")&&n.preventDefault(),e.forEach(t=>{t.classList.remove("active")}),this.classList.add("active");const r=new CustomEvent("kds-sidebar-nav-change",{detail:{item:this,text:this.querySelector("span")?.textContent||""},bubbles:!0});t.dispatchEvent(r)})})}(n),function(){const t=document.querySelector(".kds-hamburger-btn"),e=document.querySelector(".kds-sidebar-close-btn"),n=document.querySelector(".kds-sidebar");t&&n&&(t.addEventListener("click",function(){n.classList.toggle("kds-sidebar-open")}),e&&e.addEventListener("click",function(){n.classList.remove("kds-sidebar-open")}),document.addEventListener("keydown",function(t){"Escape"===t.key&&n.classList.contains("kds-sidebar-open")&&n.classList.remove("kds-sidebar-open")}))}(),console.log("[Khipu Sidebar] Initialized successfully")):console.warn("[Khipu Sidebar] Sidebar not found with selector:",e.sidebarSelector)}};"function"==typeof define&&define.amd?define(function(){return e}):"object"==typeof module&&module.exports?module.exports=e:t.KhipuSidebar=e}("undefined"!=typeof window?window:this),function(t){"use strict";class KhipuOnboarding{constructor(t={}){this.currentStage=0,this.totalStages=t.totalStages||8,this.personType=t.personType||null,this.locale=t.locale||"es-CL",this.apiEndpoint=t.apiEndpoint||"/api/onboarding",this.enableLocalStorage=!1!==t.enableLocalStorage,this.formData={},this.completedStages=new Set,this.errors={},this.listeners={stageChange:[],dataChange:[],error:[]},this.init()}init(){this.enableLocalStorage&&this.loadState(),this.setupEventListeners(),this.updateStepper()}setupEventListeners(){document.addEventListener("click",t=>{if(t.target.matches("[data-onboarding-next]")&&(t.preventDefault(),this.nextStage()),t.target.matches("[data-onboarding-prev]")&&(t.preventDefault(),this.prevStage()),t.target.matches("[data-onboarding-goto]")){t.preventDefault();const e=parseInt(t.target.dataset.onboardingGoto,10);this.goToStage(e)}}),document.addEventListener("input",t=>{t.target.matches("[data-onboarding-field]")&&this.handleFieldChange(t.target)}),document.addEventListener("submit",t=>{t.target.matches("[data-onboarding-form]")&&(t.preventDefault(),this.handleFormSubmit(t.target))}),document.addEventListener("keydown",t=>{"Enter"===t.key&&t.target.matches("button")&&t.target.click(),"Escape"===t.key&&this.closeAllModals()})}goToStage(e){if(e<0||e>=this.totalStages)return void console.warn(`Invalid stage index: ${e}`);if(e>this.currentStage&&!this.validateStage())return;const n=this.currentStage;this.currentStage=e,this.emit("stageChange",{from:n,to:e}),this.updateStepper(),this.saveState(),t.scrollTo({top:0,behavior:"smooth"})}nextStage(){this.validateStage()&&(this.completedStages.add(this.currentStage),this.currentStage<this.totalStages-1?this.goToStage(this.currentStage+1):this.submitOnboarding())}prevStage(){this.currentStage>0&&this.goToStage(this.currentStage-1)}validateStage(){const t=document.querySelector(`[data-stage="${this.currentStage}"]`);if(!t)return!0;const e=t.querySelector("form");if(!e)return!0;if(!e.checkValidity())return e.reportValidity(),!1;const n=e.querySelectorAll("[data-onboarding-field]");let r=!0;return n.forEach(t=>{this.validateField(t)||(r=!1)}),r}validateField(t){t.name||t.dataset.onboardingField;const n=t.value.trim(),r=t.dataset.validation;if(this.clearFieldError(t),t.hasAttribute("required")&&!n)return this.setFieldError(t,"Este campo es obligatorio"),!1;if(r&&n){const a=e[r];if(a&&!a.test(n))return this.setFieldError(t,a.message),!1}const a=t.closest(".field");return a&&(a.classList.remove("invalid"),a.classList.add("valid")),!0}handleFieldChange(t){const e=t.name||t.dataset.onboardingField,n="checkbox"===t.type?t.checked:t.value;this.setFormData(e,n),"false"!==t.dataset.validateOnChange&&this.validateField(t)}handleFormSubmit(t){if(!this.validateStage())return;new FormData(t).forEach((t,e)=>{this.setFormData(e,t)}),this.nextStage()}setFormData(t,e){this.formData[t]=e,this.emit("dataChange",{key:t,value:e}),this.enableLocalStorage&&this.saveState()}getFormData(t){return this.formData[t]}setFieldError(t,e){const n=t.closest(".field");if(!n)return;n.classList.add("invalid"),n.classList.remove("valid");let r=n.querySelector(".error");r||(r=document.createElement("span"),r.className="error",n.appendChild(r)),r.textContent=e;const a=t.name||t.dataset.onboardingField;this.errors[a]=e}clearFieldError(t){const e=t.closest(".field");if(!e)return;e.classList.remove("invalid");const n=e.querySelector(".error");n&&n.remove();const r=t.name||t.dataset.onboardingField;delete this.errors[r]}updateStepper(){document.querySelectorAll(".kds-step").forEach((t,e)=>{t.classList.remove("current","completed"),e<this.currentStage||this.completedStages.has(e)?t.classList.add("completed"):e===this.currentStage&&t.classList.add("current")});document.querySelectorAll("[data-stage]").forEach((t,e)=>{t.style.display=e===this.currentStage?"block":"none"})}saveState(){if(this.enableLocalStorage)try{const t={currentStage:this.currentStage,personType:this.personType,formData:this.formData,completedStages:Array.from(this.completedStages),timestamp:Date.now()};localStorage.setItem("khipu_onboarding_state",JSON.stringify(t))}catch(t){console.error("Error saving state:",t)}}loadState(){try{const t=localStorage.getItem("khipu_onboarding_state");if(!t)return;const e=JSON.parse(t);if(Date.now()-e.timestamp>864e5)return void this.clearState();this.currentStage=e.currentStage||0,this.personType=e.personType||null,this.formData=e.formData||{},this.completedStages=new Set(e.completedStages||[])}catch(t){console.error("Error loading state:",t),this.clearState()}}clearState(){try{localStorage.removeItem("khipu_onboarding_state")}catch(t){console.error("Error clearing state:",t)}this.currentStage=0,this.formData={},this.completedStages.clear(),this.errors={}}async submitOnboarding(){try{const t=await fetch(this.apiEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(this.formData)});if(!t.ok)throw new Error("Network response was not ok");const e=await t.json();this.clearState(),this.emit("success",e),this.showSnackbar("¡Activación completada exitosamente!","success")}catch(t){console.error("Error submitting onboarding:",t),this.emit("error",t),this.showSnackbar("Error al enviar datos. Por favor intenta nuevamente.","error")}}showSnackbar(t,e="info"){const n=document.createElement("div");n.className=`snackbar ${e}`,n.textContent=t,document.body.appendChild(n),setTimeout(()=>{n.remove()},3e3)}closeAllModals(){document.querySelectorAll("dialog[open]").forEach(t=>t.close())}emit(t,e){this.listeners[t]&&this.listeners[t].forEach(t=>t(e))}on(t,e){this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e)}off(t,e){this.listeners[t]&&(this.listeners[t]=this.listeners[t].filter(t=>t!==e))}}const e={rut:{test:function(t){if((t=t.replace(/[^0-9kK]/g,"")).length<2)return!1;const e=t.slice(0,-1),n=t.slice(-1).toUpperCase();let r=0,a=2;for(let t=e.length-1;t>=0;t--)r+=parseInt(e[t])*a,a=7===a?2:a+1;const o=11-r%11;return n===(11===o?"0":10===o?"K":o.toString())},message:"RUT inválido"},email:{test:function(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)},message:"Email inválido"},phone:{test:function(t){return/^(\+?56)?9\d{8}$/.test(t.replace(/\s/g,""))},message:"Teléfono inválido (ej: +56912345678)"},url:{test:function(t){try{return new URL(t),!0}catch{return!1}},message:"URL inválida"}};t.KhipuOnboarding=KhipuOnboarding,t.FileUploadHandler=class FileUploadHandler{constructor(t){this.uploadZone=t,this.fileInput=t.querySelector('input[type="file"]'),this.preview=t.nextElementSibling,this.files=[],this.maxSize=5242880,this.acceptedTypes=["application/pdf","image/jpeg","image/png"],this.init()}init(){this.uploadZone.addEventListener("click",()=>{this.fileInput.click()}),this.fileInput.addEventListener("change",t=>{this.handleFiles(Array.from(t.target.files))}),this.uploadZone.addEventListener("dragover",t=>{t.preventDefault(),this.uploadZone.classList.add("dragover")}),this.uploadZone.addEventListener("dragleave",()=>{this.uploadZone.classList.remove("dragover")}),this.uploadZone.addEventListener("drop",t=>{t.preventDefault(),this.uploadZone.classList.remove("dragover"),this.handleFiles(Array.from(t.dataTransfer.files))})}handleFiles(t){t.forEach(t=>{this.acceptedTypes.includes(t.type)?t.size>this.maxSize?alert(`Archivo muy grande: ${t.name} (máx 5MB)`):(this.files.push(t),this.addFileToPreview(t)):alert(`Tipo de archivo no permitido: ${t.name}`)}),this.uploadZone.classList.add("success")}addFileToPreview(t){const e=document.createElement("div");e.className="kds-file-upload-item",e.innerHTML=`\n <div class="kds-file-upload-item-icon">\n <i class="material-symbols-outlined">description</i>\n </div>\n <div class="kds-file-upload-item-info">\n <div class="kds-file-upload-item-name">${t.name}</div>\n <div class="kds-file-upload-item-meta">${this.formatFileSize(t.size)}</div>\n </div>\n <div class="kds-file-upload-item-status success">\n <i class="material-symbols-outlined">check_circle</i>\n </div>\n <button type="button" class="kds-file-upload-item-remove">\n <i class="material-symbols-outlined">close</i>\n </button>\n `,e.querySelector(".kds-file-upload-item-remove").addEventListener("click",n=>{n.stopPropagation(),this.removeFile(t,e)}),this.preview.appendChild(e)}removeFile(t,e){this.files=this.files.filter(e=>e!==t),e.remove(),0===this.files.length&&this.uploadZone.classList.remove("success")}formatFileSize(t){return t<1024?t+" B":t<1048576?(t/1024).toFixed(1)+" KB":(t/1048576).toFixed(1)+" MB"}getFiles(){return this.files}},t.OTPInputHandler=class OTPInputHandler{constructor(t){this.container=t,this.inputs=Array.from(t.querySelectorAll(".kds-otp-digit")),this.length=this.inputs.length,this.init()}init(){this.inputs.forEach((t,e)=>{t.addEventListener("input",t=>{const n=t.target.value.replace(/[^0-9]/g,"");t.target.value=n.slice(0,1),n&&e<this.length-1&&this.inputs[e+1].focus()}),t.addEventListener("keydown",t=>{"Backspace"===t.key&&!t.target.value&&e>0&&this.inputs[e-1].focus()}),t.addEventListener("paste",t=>{t.preventDefault();const n=t.clipboardData.getData("text").replace(/[^0-9]/g,"");n.split("").forEach((t,n)=>{e+n<this.length&&(this.inputs[e+n].value=t)});const r=Math.min(e+n.length,this.length-1);this.inputs[r].focus()})})}getValue(){return this.inputs.map(t=>t.value).join("")}clear(){this.inputs.forEach(t=>{t.value=""}),this.inputs[0].focus()}isComplete(){return this.inputs.every(t=>t.value)}},t.KHIPU_ONBOARDING_CONFIG&&(t.khipuOnboarding=new KhipuOnboarding(t.KHIPU_ONBOARDING_CONFIG))}(window),function(){"use strict";function t(){console.log("Initializing Khipu Material Design components..."),void 0!==window.KhipuSidebar&&window.KhipuSidebar.init(),function(){const t=document.getElementById("menu-toggle"),e=document.getElementById("material-sidenav");t&&e&&(t.addEventListener("click",function(){e.classList.toggle("active")}),document.addEventListener("click",function(n){if(e.classList.contains("active")){e.contains(n.target)||t.contains(n.target)||e.classList.remove("active")}}))}(),document.querySelectorAll('.snackbar[data-auto-dismiss="true"]').forEach(function(t){setTimeout(function(){t.classList.remove("active")},5e3)}),window.closeModal=function(t){const e=document.getElementById(t);e&&e.classList.remove("active")},e(),n(),r(),a(),s(),o(),console.log("Material Design initialization complete!")}function e(t){(t=t||document).addEventListener("click",function(t){var e=t.target.closest("[data-expand-toggle]");if(e){var n="true"===e.getAttribute("aria-expanded");e.setAttribute("aria-expanded",String(!n));var r=e.getAttribute("aria-controls"),a=r?document.getElementById(r):e.parentElement.querySelector("[data-expand-panel]");a&&(n?a.classList.remove("open"):a.classList.add("open"))}})}function n(t){(t=t||document).addEventListener("click",function(t){var e=t.target.closest(".kds-copy-row[data-copy]");if(e)navigator.clipboard.writeText(e.dataset.copy).then(function(){e.classList.add("copied"),setTimeout(function(){e.classList.remove("copied")},1200)});else{var n=t.target.closest(".kds-copy-all[data-copy-all]");if(n){var r=n.dataset.copyAll,a=r?document.querySelector(r):n.closest(".kds-copy-header").nextElementSibling;if(!a)return;var o=a.querySelectorAll("[data-copy]"),s=[];o.forEach(function(t){s.push(t.dataset.copy)}),navigator.clipboard.writeText(s.join("\n")).then(function(){o.forEach(function(t){t.classList.add("copied"),setTimeout(function(){t.classList.remove("copied")},1200)})})}}})}function r(t){(t=t||document).querySelectorAll(".kds-countdown[data-deadline]").forEach(function(t){var e=new Date(t.dataset.deadline).getTime(),n=t.dataset.serverNow?new Date(t.dataset.serverNow).getTime():Date.now(),r=Date.now()-n,a=t.querySelector("[data-h]"),o=t.querySelector("[data-m]"),s=t.querySelector("[data-s]");function c(t){return t<10?"0"+t:String(t)}function l(){var n=Date.now()-r,l=Math.max(0,e-n),d=Math.floor(l/1e3),h=Math.floor(d/3600),m=Math.floor(d%3600/60),f=d%60;a&&(a.textContent=c(h)),o&&(o.textContent=c(m)),s&&(s.textContent=c(f)),l<3e5&&t.classList.add("urgent"),l<=0&&(clearInterval(u),t.dispatchEvent(new CustomEvent("kds:countdown:expired",{bubbles:!0})))}l();var u=setInterval(l,1e3)})}function a(t){(t=t||document).addEventListener("click",function(t){var e=t.target.closest(".kds-segmented-tabs button");if(e){var n=e.closest(".kds-segmented-tabs"),r=n.querySelectorAll("button");r.forEach(function(t){t.classList.remove("active"),t.setAttribute("aria-selected","false")}),e.classList.add("active"),e.setAttribute("aria-selected","true");var a=Array.prototype.indexOf.call(r,e);n.dispatchEvent(new CustomEvent("kds:tab:change",{bubbles:!0,detail:{index:a,button:e}}))}})}function o(t){var e=(t=t||document).querySelector("#bankModal"),n=t.querySelector("#bankSearch"),r=t.querySelector("#bankModalList"),a=t.querySelector("#bankNoResults");function o(t){if(r){var e=t.toLowerCase().trim(),n=r.querySelectorAll(".kds-bank-row"),o=0;n.forEach(function(t){var n=t.querySelector(".kds-bank-row-name");if(n){var r=n.textContent.toLowerCase(),a=!e||-1!==r.indexOf(e);t.style.display=a?"":"none",a&&o++}}),a&&a.classList.toggle("visible",0===o)}}e&&(t.addEventListener("click",function(t){t.target.closest("[data-open-bank-modal]")&&(e.classList.add("open"),n&&(n.value="",n.focus()),o(""))}),t.addEventListener("click",function(t){t.target.closest("[data-close-bank-modal]")&&e.classList.remove("open")}),r&&r.addEventListener("click",function(t){var n=t.target.closest(".kds-bank-row");if(n){var r=n.dataset.bankId||n.dataset.bank||"",a=n.querySelector(".kds-bank-row-name");e.dispatchEvent(new CustomEvent("kds:bank:selected",{bubbles:!0,detail:{id:r,name:a?a.textContent:"",element:n}})),e.classList.remove("open")}}),n&&n.addEventListener("input",function(t){o(t.target.value)}),window.Khipu||(window.Khipu={}),window.Khipu.filterBanks=o)}function s(t){t=t||document;var e={};window.addEventListener("scroll",function(){var n=t.querySelector(".kds-screen.active");if(n){var r=n.querySelector(".kds-invoice-sticky");if(r){var a=n.id||"default",o=e[a]||!1,s=window.scrollY||window.pageYOffset;!o&&s>60?(r.classList.add("collapsed"),e[a]=!0):o&&s<20&&(r.classList.remove("collapsed"),e[a]=!1)}}},{passive:!0})}function c(t,e,n){e=e||"info",n=n||5e3;const r=document.createElement("div");r.className="snackbar active "+e;const a=document.createElement("i");a.className="material-symbols-outlined",a.textContent="success"===e?"check_circle":"error"===e?"error":"info";const o=document.createElement("span");o.textContent=t;const s=document.createElement("button");s.className="transparent circle",s.innerHTML='<i class="material-symbols-outlined">close</i>',s.onclick=function(){r.classList.remove("active"),setTimeout(function(){r.remove()},300)},r.appendChild(a),r.appendChild(o),r.appendChild(s),document.body.appendChild(r),setTimeout(function(){r.classList.remove("active"),setTimeout(function(){r.remove()},300)},n)}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t):t(),window.Khipu||(window.Khipu={}),window.Khipu.showSnackbar=c,window.Khipu.closeModal=window.closeModal,window.Khipu.initExpandToggle=e,window.Khipu.initCopyRow=n,window.Khipu.initCountdown=r,window.Khipu.initSegmentedTabs=a,window.Khipu.initBankModal=o,window.Khipu.initStickyInvoice=s,window.showSnackbar=c}();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khipu/design-system/beercss",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.50",
|
|
4
4
|
"description": "Khipu BeerCSS bundle with Material Design 3 and Khipu customizations",
|
|
5
|
-
"buildDate": "2026-04-27T13:
|
|
5
|
+
"buildDate": "2026-04-27T13:24:39.524Z",
|
|
6
6
|
"includes": {
|
|
7
7
|
"beercss": "4.0.1",
|
|
8
8
|
"material-dynamic-colors": "1.1.2",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"jsUnminified": "khipu-beercss.js"
|
|
18
18
|
},
|
|
19
19
|
"cdn": {
|
|
20
|
-
"css": "https://cdn.jsdelivr.net/npm/@khipu/design-system@0.1.0-alpha.
|
|
21
|
-
"js": "https://cdn.jsdelivr.net/npm/@khipu/design-system@0.1.0-alpha.
|
|
20
|
+
"css": "https://cdn.jsdelivr.net/npm/@khipu/design-system@0.1.0-alpha.50/dist/beercss/khipu-beercss.min.css",
|
|
21
|
+
"js": "https://cdn.jsdelivr.net/npm/@khipu/design-system@0.1.0-alpha.50/dist/beercss/khipu-beercss.min.js"
|
|
22
22
|
}
|
|
23
23
|
}
|
package/package.json
CHANGED