diff --git a/CLAUDE.md b/CLAUDE.md index f4f5bb2..82c43be 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -38,8 +38,10 @@ tailwindcss -i ./assets/css/input.css -o ./assets/css/output.css --watch # watc - `internal/repository/` — data access with sqlx, interface-based - `internal/model/` — data structs with `db:` tags - `internal/middleware/` — ordered chain: Config → Logging → NoCache → CSRF → Auth → URLPath +- `internal/router/` - custom router to group routes together and chain middleware. - `internal/routes/routes.go` — all route definitions with middleware wrapping - `internal/ui/` — templ templates organized as pages/, components/, layouts/, blocks/ +- `internal/misc/` - miscellanous packages such as timezones - `assets/` — static files (CSS, JS, fonts) embedded in binary via `go:embed` ## Key Patterns @@ -67,3 +69,78 @@ App reads from `.env` file via `godotenv`. Key vars: `APP_ENV`, `APP_URL`, `DB_D ## Database PostgreSQL (pgx driver) or SQLite. Migrations auto-run on startup from `internal/db/migrations/` (Goose SQL format, embedded via `go:embed`). 8 migration files covering users, tokens, profiles, spaces, shopping lists, tags, expenses, invitations. + +# templui Components + +> templ-based UI components for Go. Open source. Customizable. Accessible. + +## Overview + +templui is a collection of beautifully designed, accessible UI components built with templ and Go. +Components are designed to be composable, customizable, and easy to integrate into your Go projects. + +- [Introduction](https://templui.io/docs/introduction): Core principles and getting started guide +- [How to Use](https://templui.io/docs/how-to-use): CLI installation and usage guide +- [Components](https://templui.io/docs/components): Component overview and catalog +- [Themes](https://templui.io/docs/themes): Theme customization and styling +- [GitHub](https://github.com/templui/templui): Source code and issue tracker + +## Form & Input + +- [Button](https://templui.io/docs/components/button): Button component with multiple variants. +- [Calendar](https://templui.io/docs/components/calendar): Calendar component for date selection. +- [Checkbox](https://templui.io/docs/components/checkbox): Checkbox input component. +- [Date Picker](https://templui.io/docs/components/date-picker): Date picker component combining input and calendar. +- [Form](https://templui.io/docs/components/form): Form container with validation support. +- [Input](https://templui.io/docs/components/input): Text input component. +- [Input OTP](https://templui.io/docs/components/input-otp): One-time password input component. +- [Label](https://templui.io/docs/components/label): Form label component. +- [Radio](https://templui.io/docs/components/radio): Radio button group component. +- [Rating](https://templui.io/docs/components/rating): Star rating input component. +- [Select Box](https://templui.io/docs/components/select-box): Searchable select component. +- [Slider](https://templui.io/docs/components/slider): Slider input component. +- [Switch](https://templui.io/docs/components/switch): Toggle switch component. +- [Tags Input](https://templui.io/docs/components/tags-input): Tags input component. +- [Textarea](https://templui.io/docs/components/textarea): Multi-line text input component. +- [Time Picker](https://templui.io/docs/components/time-picker): Time picker component. + +## Layout & Navigation + +- [Accordion](https://templui.io/docs/components/accordion): Collapsible accordion component. +- [Breadcrumb](https://templui.io/docs/components/breadcrumb): Breadcrumb navigation component. +- [Pagination](https://templui.io/docs/components/pagination): Pagination component for lists and tables. +- [Separator](https://templui.io/docs/components/separator): Visual divider between content sections. +- [Sidebar](https://templui.io/docs/components/sidebar): Collapsible sidebar component for app layouts. +- [Tabs](https://templui.io/docs/components/tabs): Tabbed interface component. + +## Overlays & Dialogs + +- [Dialog](https://templui.io/docs/components/dialog): Modal dialog component. +- [Dropdown](https://templui.io/docs/components/dropdown): Dropdown menu component. +- [Popover](https://templui.io/docs/components/popover): Floating popover component. +- [Sheet](https://templui.io/docs/components/sheet): Slide-out panel component (drawer). +- [Tooltip](https://templui.io/docs/components/tooltip): Tooltip component for additional context. + +## Feedback & Status + +- [Alert](https://templui.io/docs/components/alert): Alert component for messages and notifications. +- [Badge](https://templui.io/docs/components/badge): Badge component for labels and status indicators. +- [Progress](https://templui.io/docs/components/progress): Progress bar component. +- [Skeleton](https://templui.io/docs/components/skeleton): Skeleton loading placeholder. +- [Toast](https://templui.io/docs/components/toast): Toast notification component. + +## Display & Media + +- [Aspect Ratio](https://templui.io/docs/components/aspect-ratio): Container that maintains aspect ratio. +- [Avatar](https://templui.io/docs/components/avatar): Avatar component for user profiles. +- [Card](https://templui.io/docs/components/card): Card container component. +- [Carousel](https://templui.io/docs/components/carousel): Carousel component with navigation controls. +- [Charts](https://templui.io/docs/components/charts): Chart components for data visualization. +- [Table](https://templui.io/docs/components/table): Table component for displaying data. + +## Misc + +- [Collapsible](https://templui.io/docs/components/collapsible): Collapsible container component. +- [Copy Button](https://templui.io/docs/components/copy-button): Copy to clipboard button component. +- [Icon](https://templui.io/docs/components/icon): SVG icon component library. + diff --git a/assets/js/avatar.js b/assets/js/avatar.js new file mode 100644 index 0000000..0e8f410 --- /dev/null +++ b/assets/js/avatar.js @@ -0,0 +1,63 @@ +(function () { + "use strict"; + + // Handle image load events + document.addEventListener( + "load", + function (e) { + if (e.target.matches("[data-tui-avatar-image]")) { + const fallback = e.target.parentElement.querySelector( + "[data-tui-avatar-fallback]", + ); + if (fallback) { + fallback.style.display = "none"; + } + } + }, + true, + ); + + // Handle image error events + document.addEventListener( + "error", + function (e) { + if (e.target.matches("[data-tui-avatar-image]")) { + e.target.style.display = "none"; + const fallback = e.target.parentElement.querySelector( + "[data-tui-avatar-fallback]", + ); + if (fallback) { + fallback.style.display = "flex"; + } + } + }, + true, + ); + + // Check already loaded/broken images on DOM ready + function checkImages() { + document + .querySelectorAll("[data-tui-avatar-image]") + .forEach(function (img) { + const fallback = img.parentElement.querySelector( + "[data-tui-avatar-fallback]", + ); + + // Image already successfully loaded + if (img.complete && img.naturalWidth > 0) { + if (fallback) fallback.style.display = "none"; + } + // Image already failed + else if (img.complete && img.naturalWidth === 0) { + img.style.display = "none"; + if (fallback) fallback.style.display = "flex"; + } + }); + } + + if (document.readyState === "loading") { + document.addEventListener("DOMContentLoaded", checkImages); + } else { + checkImages(); + } +})(); diff --git a/assets/js/calendar.js b/assets/js/calendar.js new file mode 100644 index 0000000..0035792 --- /dev/null +++ b/assets/js/calendar.js @@ -0,0 +1,414 @@ +(function () { + "use strict"; + + // Utility functions + function parseISODate(isoStr) { + if (!isoStr) return null; + const parts = isoStr.split("-"); + if (parts.length !== 3) return null; + + const year = parseInt(parts[0], 10); + const month = parseInt(parts[1], 10) - 1; + const day = parseInt(parts[2], 10); + const date = new Date(Date.UTC(year, month, day)); + + if ( + date.getUTCFullYear() === year && + date.getUTCMonth() === month && + date.getUTCDate() === day + ) { + return date; + } + return null; + } + + function getMonthNames(locale) { + try { + return Array.from({ length: 12 }, (_, i) => + new Intl.DateTimeFormat(locale, { + month: "short", + timeZone: "UTC", + }).format(new Date(Date.UTC(2000, i, 1))), + ); + } catch { + return [ + "Jan", + "Feb", + "Mar", + "Apr", + "May", + "Jun", + "Jul", + "Aug", + "Sep", + "Oct", + "Nov", + "Dec", + ]; + } + } + + function getDayNames(locale, startOfWeek) { + try { + return Array.from({ length: 7 }, (_, i) => + new Intl.DateTimeFormat(locale, { + weekday: "short", + timeZone: "UTC", + }).format(new Date(Date.UTC(2000, 0, i + 2 + startOfWeek))), + ); + } catch { + return ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]; + } + } + + function findHiddenInput(container) { + const wrapper = container.closest("[data-tui-calendar-wrapper]"); + return wrapper?.querySelector("[data-tui-calendar-hidden-input]") || null; + } + + function renderCalendar(container) { + const weekdaysContainer = container.querySelector( + "[data-tui-calendar-weekdays]", + ); + const daysContainer = container.querySelector("[data-tui-calendar-days]"); + + if (!weekdaysContainer || !daysContainer) return; + + // Get current viewing month/year (or use initial/defaults) + let currentMonth = parseInt(container.dataset.tuiCalendarCurrentMonth); + let currentYear = parseInt(container.dataset.tuiCalendarCurrentYear); + + // If not set, use initial values or current date + if (isNaN(currentMonth) || isNaN(currentYear)) { + const initialMonth = parseInt( + container.getAttribute("data-tui-calendar-initial-month"), + ); + const initialYear = parseInt( + container.getAttribute("data-tui-calendar-initial-year"), + ); + const selectedDate = container.getAttribute( + "data-tui-calendar-selected-date", + ); + + if (selectedDate) { + const parsed = parseISODate(selectedDate); + if (parsed) { + currentMonth = parsed.getUTCMonth(); + currentYear = parsed.getUTCFullYear(); + } + } + + if (isNaN(currentMonth)) { + currentMonth = !isNaN(initialMonth) + ? initialMonth + : new Date().getMonth(); + } + if (isNaN(currentYear)) { + currentYear = + !isNaN(initialYear) && initialYear > 0 + ? initialYear + : new Date().getFullYear(); + } + + // Store for navigation + container.dataset.tuiCalendarCurrentMonth = currentMonth; + container.dataset.tuiCalendarCurrentYear = currentYear; + } + + // Get other settings + const locale = + container.getAttribute("data-tui-calendar-locale-tag") || "en-US"; + let startOfWeek = parseInt( + container.getAttribute("data-tui-calendar-start-of-week"), + 10, + ); + if (isNaN(startOfWeek)) startOfWeek = 1; + const selectedDateStr = container.getAttribute( + "data-tui-calendar-selected-date", + ); + const selectedDate = selectedDateStr ? parseISODate(selectedDateStr) : null; + + // Update SelectBox values + const monthNames = getMonthNames(locale); + const monthValue = container.querySelector(`#${container.id}-month-value`); + const yearValue = container.querySelector(`#${container.id}-year-value`); + + if (monthValue) monthValue.textContent = monthNames[currentMonth]; + if (yearValue) yearValue.textContent = currentYear; + + // Render weekdays if empty + if (!weekdaysContainer.children.length) { + const dayNames = getDayNames(locale, startOfWeek); + weekdaysContainer.innerHTML = dayNames + .map( + (day) => + `
${day}
`, + ) + .join(""); + } + + // Render days + daysContainer.innerHTML = ""; + + const firstDay = new Date(Date.UTC(currentYear, currentMonth, 1)); + const startOffset = (((firstDay.getUTCDay() - startOfWeek) % 7) + 7) % 7; + const daysInMonth = new Date( + Date.UTC(currentYear, currentMonth + 1, 0), + ).getUTCDate(); + + const today = new Date(); + const todayUTC = new Date( + Date.UTC(today.getFullYear(), today.getMonth(), today.getDate()), + ); + + // Add empty cells for offset + for (let i = 0; i < startOffset; i++) { + daysContainer.innerHTML += + '
'; + } + + // Add day buttons + for (let day = 1; day <= daysInMonth; day++) { + const currentDate = new Date(Date.UTC(currentYear, currentMonth, day)); + const isSelected = + selectedDate && currentDate.getTime() === selectedDate.getTime(); + const isToday = currentDate.getTime() === todayUTC.getTime(); + + let classes = + "inline-flex h-[var(--cell-size)] w-[var(--cell-size)] items-center justify-center rounded-md text-sm font-medium focus:outline-none focus:ring-1 focus:ring-ring"; + + if (isSelected) { + classes += " bg-primary text-primary-foreground hover:bg-primary/90"; + } else if (isToday) { + classes += " bg-accent text-accent-foreground"; + } else { + classes += " hover:bg-accent hover:text-accent-foreground"; + } + + const attrs = [ + `data-tui-calendar-day="${day}"`, + isToday ? 'data-tui-calendar-today="true"' : "", + isSelected ? 'data-tui-calendar-selected="true"' : "", + ] + .filter(Boolean) + .join(" "); + + daysContainer.innerHTML += ``; + } + } + + // Handle month/year selection from native selects + document.addEventListener("change", (e) => { + // Month select + if (e.target.matches("[data-tui-calendar-month-select]")) { + const container = e.target.closest("[data-tui-calendar-container]"); + if (!container) return; + + const newMonth = parseInt(e.target.value, 10); + if (isNaN(newMonth)) return; + + container.dataset.tuiCalendarCurrentMonth = newMonth; + renderCalendar(container); + return; + } + + // Year select + if (e.target.matches("[data-tui-calendar-year-select]")) { + const container = e.target.closest("[data-tui-calendar-container]"); + if (!container) return; + + const newYear = parseInt(e.target.value, 10); + if (isNaN(newYear)) return; + + container.dataset.tuiCalendarCurrentYear = newYear; + renderCalendar(container); + return; + } + }); + + // Event delegation for calendar navigation and selection + document.addEventListener("click", (e) => { + // Previous month + const prevBtn = e.target.closest("[data-tui-calendar-prev]"); + if (prevBtn) { + const container = prevBtn.closest("[data-tui-calendar-container]"); + if (!container) return; + + let month = parseInt(container.dataset.tuiCalendarCurrentMonth, 10); + let year = parseInt(container.dataset.tuiCalendarCurrentYear, 10); + + // Only use fallback if truly not initialized (should not happen after init) + if (isNaN(month)) month = new Date().getMonth(); + if (isNaN(year)) year = new Date().getFullYear(); + + month--; + if (month < 0) { + month = 11; + year--; + } + + container.dataset.tuiCalendarCurrentMonth = month; + container.dataset.tuiCalendarCurrentYear = year; + renderCalendar(container); + updateNativeSelects(container); + return; + } + + // Next month + const nextBtn = e.target.closest("[data-tui-calendar-next]"); + if (nextBtn) { + const container = nextBtn.closest("[data-tui-calendar-container]"); + if (!container) return; + + let month = parseInt(container.dataset.tuiCalendarCurrentMonth, 10); + let year = parseInt(container.dataset.tuiCalendarCurrentYear, 10); + + // Only use fallback if truly not initialized (should not happen after init) + if (isNaN(month)) month = new Date().getMonth(); + if (isNaN(year)) year = new Date().getFullYear(); + + month++; + if (month > 11) { + month = 0; + year++; + } + + container.dataset.tuiCalendarCurrentMonth = month; + container.dataset.tuiCalendarCurrentYear = year; + renderCalendar(container); + updateNativeSelects(container); + return; + } + + // Day selection + if (e.target.matches("[data-tui-calendar-day]")) { + const container = e.target.closest("[data-tui-calendar-container]"); + if (!container) return; + + const day = parseInt(e.target.dataset.tuiCalendarDay); + let month = parseInt(container.dataset.tuiCalendarCurrentMonth, 10); + let year = parseInt(container.dataset.tuiCalendarCurrentYear, 10); + + // Only use fallback if truly not initialized (should not happen after init) + if (isNaN(month)) month = new Date().getMonth(); + if (isNaN(year)) year = new Date().getFullYear(); + const selectedDate = new Date(Date.UTC(year, month, day)); + + // Update selected date attribute + container.setAttribute( + "data-tui-calendar-selected-date", + selectedDate.toISOString().split("T")[0], + ); + + // Update hidden input + const hiddenInput = findHiddenInput(container); + if (hiddenInput) { + hiddenInput.value = selectedDate.toISOString().split("T")[0]; + } + + // Dispatch custom event + container.dispatchEvent( + new CustomEvent("calendar-date-selected", { + bubbles: true, + detail: { date: selectedDate }, + }), + ); + + renderCalendar(container); + } + }); + + // Update native selects when month/year changes via arrows + function updateNativeSelects(container) { + const month = parseInt(container.dataset.tuiCalendarCurrentMonth, 10); + const year = parseInt(container.dataset.tuiCalendarCurrentYear, 10); + + if (isNaN(month) || isNaN(year)) return; + + // Update month select + const monthSelect = container.querySelector( + "[data-tui-calendar-month-select]", + ); + if (monthSelect) { + monthSelect.value = month.toString(); + } + + // Update year select + const yearSelect = container.querySelector( + "[data-tui-calendar-year-select]", + ); + if (yearSelect) { + yearSelect.value = year.toString(); + } + } + + // Form reset handling + document.addEventListener("reset", (e) => { + if (!e.target.matches("form")) return; + + e.target + .querySelectorAll("[data-tui-calendar-container]") + .forEach((container) => { + const hiddenInput = findHiddenInput(container); + if (hiddenInput) { + hiddenInput.value = ""; + } + + // Clear selected date and reset to current month + container.removeAttribute("data-tui-calendar-selected-date"); + const today = new Date(); + container.dataset.tuiCalendarCurrentMonth = today.getMonth(); + container.dataset.tuiCalendarCurrentYear = today.getFullYear(); + renderCalendar(container); + }); + }); + + // MutationObserver for dynamic content (framework-agnostic) + const observer = new MutationObserver(() => { + document + .querySelectorAll("[data-tui-calendar-container]") + .forEach((container) => { + const daysContainer = container.querySelector( + "[data-tui-calendar-days]", + ); + // Only render if not already rendered + if (daysContainer && !daysContainer.children.length) { + renderCalendar(container); + } + }); + }); + + observer.observe(document.body, { childList: true, subtree: true }); + + // Initialize calendars on page load + function initCalendars() { + document + .querySelectorAll("[data-tui-calendar-container]") + .forEach((container) => { + // Localize month names in native select options + const locale = + container.getAttribute("data-tui-calendar-locale-tag") || "en-US"; + const monthNames = getMonthNames(locale); + const monthSelect = container.querySelector( + "[data-tui-calendar-month-select]", + ); + + if (monthSelect) { + const options = monthSelect.querySelectorAll("option"); + options.forEach((option, index) => { + if (monthNames[index]) { + option.textContent = monthNames[index]; + } + }); + } + + renderCalendar(container); + }); + } + + if (document.readyState === "loading") { + document.addEventListener("DOMContentLoaded", initCalendars); + } else { + initCalendars(); + } +})(); diff --git a/assets/js/calendar.min.js b/assets/js/calendar.min.js index 1338784..6ae0288 100644 --- a/assets/js/calendar.min.js +++ b/assets/js/calendar.min.js @@ -1 +1 @@ -(()=>{(function(){"use strict";function m(t){if(!t)return null;let a=t.split("-");if(a.length!==3)return null;let n=parseInt(a[0],10),e=parseInt(a[1],10)-1,r=parseInt(a[2],10),s=new Date(Date.UTC(n,e,r));return s.getUTCFullYear()===n&&s.getUTCMonth()===e&&s.getUTCDate()===r?s:null}function y(t){try{return Array.from({length:12},(a,n)=>new Intl.DateTimeFormat(t,{month:"short",timeZone:"UTC"}).format(new Date(Date.UTC(2e3,n,1))))}catch{return["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}}function v(t,a){try{return Array.from({length:7},(n,e)=>new Intl.DateTimeFormat(t,{weekday:"short",timeZone:"UTC"}).format(new Date(Date.UTC(2e3,0,e+2+a))))}catch{return["Su","Mo","Tu","We","Th","Fr","Sa"]}}function p(t){let n=t.closest("[data-tui-calendar-wrapper]")?.querySelector("[data-tui-calendar-hidden-input]");if(!n&&t.id){let e=t.id.replace("-calendar-instance","");n=document.getElementById(e+"-hidden")}return n}function u(t){let a=t.querySelector("[data-tui-calendar-weekdays]"),n=t.querySelector("[data-tui-calendar-days]");if(!a||!n)return;let e=parseInt(t.dataset.tuiCalendarCurrentMonth),r=parseInt(t.dataset.tuiCalendarCurrentYear);if(isNaN(e)||isNaN(r)){let d=parseInt(t.getAttribute("data-tui-calendar-initial-month")),l=parseInt(t.getAttribute("data-tui-calendar-initial-year")),h=t.getAttribute("data-tui-calendar-selected-date");if(h){let f=m(h);f&&(e=f.getUTCMonth(),r=f.getUTCFullYear())}isNaN(e)&&(e=isNaN(d)?new Date().getMonth():d),isNaN(r)&&(r=!isNaN(l)&&l>0?l:new Date().getFullYear()),t.dataset.tuiCalendarCurrentMonth=e,t.dataset.tuiCalendarCurrentYear=r}let s=t.getAttribute("data-tui-calendar-locale-tag")||"en-US",i=parseInt(t.getAttribute("data-tui-calendar-start-of-week"))||1,o=t.getAttribute("data-tui-calendar-selected-date"),c=o?m(o):null,M=y(s),w=t.querySelector(`#${t.id}-month-value`),T=t.querySelector(`#${t.id}-year-value`);if(w&&(w.textContent=M[e]),T&&(T.textContent=r),!a.children.length){let d=v(s,i);a.innerHTML=d.map(l=>`
${l}
`).join("")}n.innerHTML="";let I=((new Date(Date.UTC(r,e,1)).getUTCDay()-i)%7+7)%7,S=new Date(Date.UTC(r,e+1,0)).getUTCDate(),C=new Date,b=new Date(Date.UTC(C.getFullYear(),C.getMonth(),C.getDate()));for(let d=0;d';for(let d=1;d<=S;d++){let l=new Date(Date.UTC(r,e,d)),h=c&&l.getTime()===c.getTime(),f=l.getTime()===b.getTime(),g="inline-flex h-8 w-8 items-center justify-center rounded-md text-sm font-medium focus:outline-none focus:ring-1 focus:ring-ring";h?g+=" bg-primary text-primary-foreground hover:bg-primary/90":f?g+=" bg-accent text-accent-foreground":g+=" hover:bg-accent hover:text-accent-foreground";let Y=[`data-tui-calendar-day="${d}"`,f?'data-tui-calendar-today="true"':"",h?'data-tui-calendar-selected="true"':""].filter(Boolean).join(" ");n.innerHTML+=``}}document.addEventListener("change",t=>{if(t.target.matches("[data-tui-calendar-month-select]")){let a=t.target.closest("[data-tui-calendar-container]");if(!a)return;let n=parseInt(t.target.value,10);if(isNaN(n))return;a.dataset.tuiCalendarCurrentMonth=n,u(a);return}if(t.target.matches("[data-tui-calendar-year-select]")){let a=t.target.closest("[data-tui-calendar-container]");if(!a)return;let n=parseInt(t.target.value,10);if(isNaN(n))return;a.dataset.tuiCalendarCurrentYear=n,u(a);return}}),document.addEventListener("click",t=>{let a=t.target.closest("[data-tui-calendar-prev]");if(a){let e=a.closest("[data-tui-calendar-container]");if(!e)return;let r=parseInt(e.dataset.tuiCalendarCurrentMonth,10),s=parseInt(e.dataset.tuiCalendarCurrentYear,10);isNaN(r)&&(r=new Date().getMonth()),isNaN(s)&&(s=new Date().getFullYear()),r--,r<0&&(r=11,s--),e.dataset.tuiCalendarCurrentMonth=r,e.dataset.tuiCalendarCurrentYear=s,u(e),D(e);return}let n=t.target.closest("[data-tui-calendar-next]");if(n){let e=n.closest("[data-tui-calendar-container]");if(!e)return;let r=parseInt(e.dataset.tuiCalendarCurrentMonth,10),s=parseInt(e.dataset.tuiCalendarCurrentYear,10);isNaN(r)&&(r=new Date().getMonth()),isNaN(s)&&(s=new Date().getFullYear()),r++,r>11&&(r=0,s++),e.dataset.tuiCalendarCurrentMonth=r,e.dataset.tuiCalendarCurrentYear=s,u(e),D(e);return}if(t.target.matches("[data-tui-calendar-day]")){let e=t.target.closest("[data-tui-calendar-container]");if(!e)return;let r=parseInt(t.target.dataset.tuiCalendarDay),s=parseInt(e.dataset.tuiCalendarCurrentMonth,10),i=parseInt(e.dataset.tuiCalendarCurrentYear,10);isNaN(s)&&(s=new Date().getMonth()),isNaN(i)&&(i=new Date().getFullYear());let o=new Date(Date.UTC(i,s,r));e.setAttribute("data-tui-calendar-selected-date",o.toISOString().split("T")[0]);let c=p(e);c&&(c.value=o.toISOString().split("T")[0],c.dispatchEvent(new Event("change",{bubbles:!0}))),e.dispatchEvent(new CustomEvent("calendar-date-selected",{bubbles:!0,detail:{date:o}})),u(e)}});function D(t){let a=parseInt(t.dataset.tuiCalendarCurrentMonth,10),n=parseInt(t.dataset.tuiCalendarCurrentYear,10);if(isNaN(a)||isNaN(n))return;let e=t.querySelector("[data-tui-calendar-month-select]");e&&(e.value=a.toString());let r=t.querySelector("[data-tui-calendar-year-select]");r&&(r.value=n.toString())}document.addEventListener("reset",t=>{t.target.matches("form")&&t.target.querySelectorAll("[data-tui-calendar-container]").forEach(a=>{let n=p(a);n&&(n.value=""),a.removeAttribute("data-tui-calendar-selected-date");let e=new Date;a.dataset.tuiCalendarCurrentMonth=e.getMonth(),a.dataset.tuiCalendarCurrentYear=e.getFullYear(),u(a)})}),new MutationObserver(()=>{document.querySelectorAll("[data-tui-calendar-container]").forEach(t=>{let a=t.querySelector("[data-tui-calendar-days]");a&&!a.children.length&&u(t)})}).observe(document.body,{childList:!0,subtree:!0});function N(){document.querySelectorAll("[data-tui-calendar-container]").forEach(t=>{let a=t.getAttribute("data-tui-calendar-locale-tag")||"en-US",n=y(a),e=t.querySelector("[data-tui-calendar-month-select]");e&&e.querySelectorAll("option").forEach((s,i)=>{n[i]&&(s.textContent=n[i])}),u(t)})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",N):N()})();})(); +(()=>{(function(){"use strict";function m(t){if(!t)return null;let a=t.split("-");if(a.length!==3)return null;let r=parseInt(a[0],10),e=parseInt(a[1],10)-1,n=parseInt(a[2],10),s=new Date(Date.UTC(r,e,n));return s.getUTCFullYear()===r&&s.getUTCMonth()===e&&s.getUTCDate()===n?s:null}function y(t){try{return Array.from({length:12},(a,r)=>new Intl.DateTimeFormat(t,{month:"short",timeZone:"UTC"}).format(new Date(Date.UTC(2e3,r,1))))}catch{return["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}}function T(t,a){try{return Array.from({length:7},(r,e)=>new Intl.DateTimeFormat(t,{weekday:"short",timeZone:"UTC"}).format(new Date(Date.UTC(2e3,0,e+2+a))))}catch{return["Su","Mo","Tu","We","Th","Fr","Sa"]}}function p(t){return t.closest("[data-tui-calendar-wrapper]")?.querySelector("[data-tui-calendar-hidden-input]")||null}function d(t){let a=t.querySelector("[data-tui-calendar-weekdays]"),r=t.querySelector("[data-tui-calendar-days]");if(!a||!r)return;let e=parseInt(t.dataset.tuiCalendarCurrentMonth),n=parseInt(t.dataset.tuiCalendarCurrentYear);if(isNaN(e)||isNaN(n)){let i=parseInt(t.getAttribute("data-tui-calendar-initial-month")),u=parseInt(t.getAttribute("data-tui-calendar-initial-year")),g=t.getAttribute("data-tui-calendar-selected-date");if(g){let c=m(g);c&&(e=c.getUTCMonth(),n=c.getUTCFullYear())}isNaN(e)&&(e=isNaN(i)?new Date().getMonth():i),isNaN(n)&&(n=!isNaN(u)&&u>0?u:new Date().getFullYear()),t.dataset.tuiCalendarCurrentMonth=e,t.dataset.tuiCalendarCurrentYear=n}let s=t.getAttribute("data-tui-calendar-locale-tag")||"en-US",l=parseInt(t.getAttribute("data-tui-calendar-start-of-week"),10);isNaN(l)&&(l=1);let o=t.getAttribute("data-tui-calendar-selected-date"),f=o?m(o):null,M=y(s),v=t.querySelector(`#${t.id}-month-value`),w=t.querySelector(`#${t.id}-year-value`);if(v&&(v.textContent=M[e]),w&&(w.textContent=n),!a.children.length){let i=T(s,l);a.innerHTML=i.map(u=>`
${u}
`).join("")}r.innerHTML="";let S=((new Date(Date.UTC(n,e,1)).getUTCDay()-l)%7+7)%7,I=new Date(Date.UTC(n,e+1,0)).getUTCDate(),C=new Date,b=new Date(Date.UTC(C.getFullYear(),C.getMonth(),C.getDate()));for(let i=0;i';for(let i=1;i<=I;i++){let u=new Date(Date.UTC(n,e,i)),g=f&&u.getTime()===f.getTime(),c=u.getTime()===b.getTime(),h="inline-flex h-[var(--cell-size)] w-[var(--cell-size)] items-center justify-center rounded-md text-sm font-medium focus:outline-none focus:ring-1 focus:ring-ring";g?h+=" bg-primary text-primary-foreground hover:bg-primary/90":c?h+=" bg-accent text-accent-foreground":h+=" hover:bg-accent hover:text-accent-foreground";let Y=[`data-tui-calendar-day="${i}"`,c?'data-tui-calendar-today="true"':"",g?'data-tui-calendar-selected="true"':""].filter(Boolean).join(" ");r.innerHTML+=``}}document.addEventListener("change",t=>{if(t.target.matches("[data-tui-calendar-month-select]")){let a=t.target.closest("[data-tui-calendar-container]");if(!a)return;let r=parseInt(t.target.value,10);if(isNaN(r))return;a.dataset.tuiCalendarCurrentMonth=r,d(a);return}if(t.target.matches("[data-tui-calendar-year-select]")){let a=t.target.closest("[data-tui-calendar-container]");if(!a)return;let r=parseInt(t.target.value,10);if(isNaN(r))return;a.dataset.tuiCalendarCurrentYear=r,d(a);return}}),document.addEventListener("click",t=>{let a=t.target.closest("[data-tui-calendar-prev]");if(a){let e=a.closest("[data-tui-calendar-container]");if(!e)return;let n=parseInt(e.dataset.tuiCalendarCurrentMonth,10),s=parseInt(e.dataset.tuiCalendarCurrentYear,10);isNaN(n)&&(n=new Date().getMonth()),isNaN(s)&&(s=new Date().getFullYear()),n--,n<0&&(n=11,s--),e.dataset.tuiCalendarCurrentMonth=n,e.dataset.tuiCalendarCurrentYear=s,d(e),D(e);return}let r=t.target.closest("[data-tui-calendar-next]");if(r){let e=r.closest("[data-tui-calendar-container]");if(!e)return;let n=parseInt(e.dataset.tuiCalendarCurrentMonth,10),s=parseInt(e.dataset.tuiCalendarCurrentYear,10);isNaN(n)&&(n=new Date().getMonth()),isNaN(s)&&(s=new Date().getFullYear()),n++,n>11&&(n=0,s++),e.dataset.tuiCalendarCurrentMonth=n,e.dataset.tuiCalendarCurrentYear=s,d(e),D(e);return}if(t.target.matches("[data-tui-calendar-day]")){let e=t.target.closest("[data-tui-calendar-container]");if(!e)return;let n=parseInt(t.target.dataset.tuiCalendarDay),s=parseInt(e.dataset.tuiCalendarCurrentMonth,10),l=parseInt(e.dataset.tuiCalendarCurrentYear,10);isNaN(s)&&(s=new Date().getMonth()),isNaN(l)&&(l=new Date().getFullYear());let o=new Date(Date.UTC(l,s,n));e.setAttribute("data-tui-calendar-selected-date",o.toISOString().split("T")[0]);let f=p(e);f&&(f.value=o.toISOString().split("T")[0]),e.dispatchEvent(new CustomEvent("calendar-date-selected",{bubbles:!0,detail:{date:o}})),d(e)}});function D(t){let a=parseInt(t.dataset.tuiCalendarCurrentMonth,10),r=parseInt(t.dataset.tuiCalendarCurrentYear,10);if(isNaN(a)||isNaN(r))return;let e=t.querySelector("[data-tui-calendar-month-select]");e&&(e.value=a.toString());let n=t.querySelector("[data-tui-calendar-year-select]");n&&(n.value=r.toString())}document.addEventListener("reset",t=>{t.target.matches("form")&&t.target.querySelectorAll("[data-tui-calendar-container]").forEach(a=>{let r=p(a);r&&(r.value=""),a.removeAttribute("data-tui-calendar-selected-date");let e=new Date;a.dataset.tuiCalendarCurrentMonth=e.getMonth(),a.dataset.tuiCalendarCurrentYear=e.getFullYear(),d(a)})}),new MutationObserver(()=>{document.querySelectorAll("[data-tui-calendar-container]").forEach(t=>{let a=t.querySelector("[data-tui-calendar-days]");a&&!a.children.length&&d(t)})}).observe(document.body,{childList:!0,subtree:!0});function N(){document.querySelectorAll("[data-tui-calendar-container]").forEach(t=>{let a=t.getAttribute("data-tui-calendar-locale-tag")||"en-US",r=y(a),e=t.querySelector("[data-tui-calendar-month-select]");e&&e.querySelectorAll("option").forEach((s,l)=>{r[l]&&(s.textContent=r[l])}),d(t)})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",N):N()})();})(); diff --git a/assets/js/carousel.js b/assets/js/carousel.js new file mode 100644 index 0000000..c622930 --- /dev/null +++ b/assets/js/carousel.js @@ -0,0 +1,236 @@ +(function() { + 'use strict'; + + const autoplays = new Map(); + let dragState = null; + + // Click handling for navigation + document.addEventListener('click', (e) => { + const prevBtn = e.target.closest('[data-tui-carousel-prev]'); + if (prevBtn) { + const carousel = prevBtn.closest('[data-tui-carousel]'); + if (carousel) navigate(carousel, -1); + return; + } + + const nextBtn = e.target.closest('[data-tui-carousel-next]'); + if (nextBtn) { + const carousel = nextBtn.closest('[data-tui-carousel]'); + if (carousel) navigate(carousel, 1); + return; + } + + const indicator = e.target.closest('[data-tui-carousel-indicator]'); + if (indicator) { + const carousel = indicator.closest('[data-tui-carousel]'); + const index = parseInt(indicator.dataset.tuiCarouselIndicator); + if (carousel && !isNaN(index)) { + updateCarousel(carousel, index); + } + } + }); + + // Drag/swipe handling + function startDrag(e) { + const track = e.target.closest('[data-tui-carousel-track]'); + if (!track) return; + + const carousel = track.closest('[data-tui-carousel]'); + if (!carousel) return; + + e.preventDefault(); + const clientX = e.touches ? e.touches[0].clientX : e.clientX; + + dragState = { + carousel, + track, + startX: clientX, + currentX: clientX, + startTime: Date.now() + }; + + track.style.cursor = 'grabbing'; + track.style.transition = 'none'; + stopAutoplay(carousel); + } + + function doDrag(e) { + if (!dragState) return; + + const clientX = e.touches ? e.touches[0].clientX : e.clientX; + dragState.currentX = clientX; + + const diff = clientX - dragState.startX; + const currentIndex = parseInt(dragState.carousel.dataset.tuiCarouselCurrent || '0'); + const offset = -currentIndex * 100 + (diff / dragState.track.offsetWidth) * 100; + + dragState.track.style.transform = `translateX(${offset}%)`; + } + + function endDrag(e) { + if (!dragState) return; + + const { carousel, track, startX, startTime } = dragState; + const clientX = e.changedTouches ? e.changedTouches[0].clientX : (e.clientX || dragState.currentX); + + track.style.cursor = ''; + track.style.transition = ''; + + const diff = startX - clientX; + const velocity = Math.abs(diff) / (Date.now() - startTime); + + if (Math.abs(diff) > 50 || velocity > 0.5) { + navigate(carousel, diff > 0 ? 1 : -1); + } else { + const currentIndex = parseInt(carousel.dataset.tuiCarouselCurrent || '0'); + updateCarousel(carousel, currentIndex); + } + + dragState = null; + + if (carousel.dataset.tuiCarouselAutoplay === 'true' && !carousel.matches(':hover')) { + startAutoplay(carousel); + } + } + + document.addEventListener('mousedown', startDrag); + document.addEventListener('mousemove', doDrag); + document.addEventListener('mouseup', endDrag); + document.addEventListener('mouseleave', (e) => { + if (e.target === document.documentElement) endDrag(e); + }); + + document.addEventListener('touchstart', startDrag, { passive: false }); + document.addEventListener('touchmove', doDrag, { passive: false }); + document.addEventListener('touchend', endDrag, { passive: false }); + + // Navigation logic + function navigate(carousel, direction) { + const current = parseInt(carousel.dataset.tuiCarouselCurrent || '0'); + const items = carousel.querySelectorAll('[data-tui-carousel-item]'); + const count = items.length; + + if (count === 0) return; + + let next = current + direction; + + if (carousel.dataset.tuiCarouselLoop === 'true') { + next = ((next % count) + count) % count; + } else { + next = Math.max(0, Math.min(next, count - 1)); + } + + updateCarousel(carousel, next); + } + + function updateCarousel(carousel, index) { + const track = carousel.querySelector('[data-tui-carousel-track]'); + const indicators = carousel.querySelectorAll('[data-tui-carousel-indicator]'); + const prevBtn = carousel.querySelector('[data-tui-carousel-prev]'); + const nextBtn = carousel.querySelector('[data-tui-carousel-next]'); + const items = carousel.querySelectorAll('[data-tui-carousel-item]'); + const count = items.length; + + carousel.dataset.tuiCarouselCurrent = index; + + if (track) { + track.style.transform = `translateX(-${index * 100}%)`; + } + + indicators.forEach((ind, i) => { + ind.dataset.tuiCarouselActive = (i === index) ? 'true' : 'false'; + ind.classList.toggle('bg-primary', i === index); + ind.classList.toggle('bg-foreground/30', i !== index); + }); + + const isLoop = carousel.dataset.tuiCarouselLoop === 'true'; + + if (prevBtn) { + prevBtn.disabled = !isLoop && index === 0; + prevBtn.classList.toggle('opacity-50', prevBtn.disabled); + } + + if (nextBtn) { + nextBtn.disabled = !isLoop && index === count - 1; + nextBtn.classList.toggle('opacity-50', nextBtn.disabled); + } + } + + // Autoplay functionality + function startAutoplay(carousel) { + if (carousel.dataset.tuiCarouselAutoplay !== 'true') return; + + stopAutoplay(carousel); + + const interval = parseInt(carousel.dataset.tuiCarouselInterval || '5000'); + const id = setInterval(() => { + if (!document.contains(carousel)) { + stopAutoplay(carousel); + return; + } + + if (carousel.matches(':hover') || dragState?.carousel === carousel) { + return; + } + + navigate(carousel, 1); + }, interval); + + autoplays.set(carousel, id); + } + + function stopAutoplay(carousel) { + const id = autoplays.get(carousel); + if (id) { + clearInterval(id); + autoplays.delete(carousel); + } + } + + // Intersection Observer for visibility management + const observedCarousels = new WeakSet(); + const carouselObserver = new IntersectionObserver((entries) => { + entries.forEach(entry => { + const carousel = entry.target; + + // Initialize display on first observation + if (!carousel.hasAttribute('data-tui-carousel-initialized')) { + carousel.setAttribute('data-tui-carousel-initialized', 'true'); + const index = parseInt(carousel.dataset.tuiCarouselCurrent || '0'); + updateCarousel(carousel, index); + } + + // Handle autoplay if enabled + if (carousel.dataset.tuiCarouselAutoplay === 'true') { + if (entry.isIntersecting) { + startAutoplay(carousel); + } else { + stopAutoplay(carousel); + } + } + }); + }); + + // Observe all carousels for visibility and initialization + function observeCarousels() { + document.querySelectorAll('[data-tui-carousel]').forEach(carousel => { + if (!observedCarousels.has(carousel)) { + observedCarousels.add(carousel); + carouselObserver.observe(carousel); + } + }); + } + + // Start observing + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', observeCarousels); + } else { + observeCarousels(); + } + + // Watch for dynamically added carousels + new MutationObserver(observeCarousels).observe(document.body, { + childList: true, + subtree: true + }); +})(); \ No newline at end of file diff --git a/assets/js/chart.js b/assets/js/chart.js new file mode 100644 index 0000000..8b6e3b5 --- /dev/null +++ b/assets/js/chart.js @@ -0,0 +1,214 @@ +import "./chartjs.js"; + +(function () { + "use strict"; + + const chartInstances = new Map(); + function getThemeColors() { + const style = getComputedStyle(document.documentElement); + return { + foreground: style.getPropertyValue("--foreground").trim() || "#000", + background: style.getPropertyValue("--background").trim() || "#fff", + mutedForeground: + style.getPropertyValue("--muted-foreground").trim() || "#666", + border: style.getPropertyValue("--border").trim() || "#ccc", + }; + } + + function buildGeneratedChartConfig(chartConfig, colors) { + const isComplexChart = ["pie", "doughnut", "bar", "radar"].includes( + chartConfig.type, + ); + + const legendOptions = { + display: chartConfig.showLegend || false, + labels: { color: colors.foreground }, + }; + + const tooltipOptions = { + backgroundColor: colors.background, + bodyColor: colors.mutedForeground, + titleColor: colors.foreground, + borderColor: colors.border, + borderWidth: 1, + }; + + const scalesOptions = + chartConfig.type === "radar" + ? { + r: { + grid: { + color: colors.border, + display: chartConfig.showYGrid !== false, + }, + ticks: { + color: colors.mutedForeground, + backdropColor: "transparent", + display: chartConfig.showYLabels !== false, + }, + angleLines: { + color: colors.border, + display: chartConfig.showXGrid !== false, + }, + pointLabels: { + color: colors.foreground, + font: { size: 12 }, + }, + border: { + display: chartConfig.showYAxis !== false, + color: colors.border, + }, + beginAtZero: true, + }, + } + : { + x: { + beginAtZero: true, + display: + chartConfig.showXLabels !== false || + chartConfig.showXGrid !== false || + chartConfig.showXAxis !== false, + border: { + display: chartConfig.showXAxis !== false, + color: colors.border, + }, + ticks: { + display: chartConfig.showXLabels !== false, + color: colors.mutedForeground, + }, + grid: { + display: chartConfig.showXGrid !== false, + color: colors.border, + }, + stacked: chartConfig.stacked || false, + }, + y: { + offset: true, + beginAtZero: chartConfig.beginAtZero !== false, + min: chartConfig.yMin, + max: chartConfig.yMax, + display: + chartConfig.showYLabels !== false || + chartConfig.showYGrid !== false || + chartConfig.showYAxis !== false, + border: { + display: chartConfig.showYAxis !== false, + color: colors.border, + }, + ticks: { + display: chartConfig.showYLabels !== false, + color: colors.mutedForeground, + }, + grid: { + display: chartConfig.showYGrid !== false, + color: colors.border, + }, + stacked: chartConfig.stacked || false, + }, + }; + + return { + ...chartConfig, + options: { + responsive: true, + maintainAspectRatio: false, + interaction: { + intersect: isComplexChart, + axis: "xy", + mode: isComplexChart ? "nearest" : "index", + }, + indexAxis: chartConfig.horizontal ? "y" : "x", + plugins: { + legend: legendOptions, + tooltip: tooltipOptions, + }, + scales: scalesOptions, + }, + }; + } + + function initChart(canvas) { + if (!canvas || !canvas.id || !canvas.hasAttribute("data-tui-chart-id")) + return; + + if (chartInstances.has(canvas.id)) { + cleanupChart(canvas); + } + + const dataId = canvas.getAttribute("data-tui-chart-id"); + const dataElement = document.getElementById(dataId); + if (!dataElement) return; + + try { + const chartPayload = JSON.parse(dataElement.textContent); + const colors = getThemeColors(); + + // eslint-disable-next-line no-undef + Chart.defaults.elements.point.radius = 0; + // eslint-disable-next-line no-undef + Chart.defaults.elements.point.hoverRadius = 5; + + const finalChartConfig = chartPayload.rawConfig + ? chartPayload.rawConfig + : buildGeneratedChartConfig( + chartPayload.generatedConfig || chartPayload, + colors, + ); + + // eslint-disable-next-line no-undef + chartInstances.set(canvas.id, new Chart(canvas, finalChartConfig)); + } catch {} + } + + function cleanupChart(canvas) { + if (!canvas || !canvas.id || !chartInstances.has(canvas.id)) return; + try { + chartInstances.get(canvas.id).destroy(); + } finally { + chartInstances.delete(canvas.id); + } + } + + function waitForChartAndInit() { + if (typeof Chart !== "undefined") { + document.querySelectorAll("canvas[data-tui-chart-id]").forEach(initChart); + setupObservers(); + } else { + setTimeout(waitForChartAndInit, 100); + } + } + + document.addEventListener("DOMContentLoaded", waitForChartAndInit); + + function setupObservers() { + // Observe theme changes + let themeTimeout; + new MutationObserver(() => { + clearTimeout(themeTimeout); + themeTimeout = setTimeout(() => { + document + .querySelectorAll("canvas[data-tui-chart-id]") + .forEach((canvas) => { + if (chartInstances.has(canvas.id)) { + cleanupChart(canvas); + initChart(canvas); + } + }); + }, 50); + }).observe(document.documentElement, { + attributes: true, + attributeFilter: ["class", "style"], + }); + + // Observe for new charts + new MutationObserver(() => { + document + .querySelectorAll("canvas[data-tui-chart-id]") + .forEach((canvas) => { + if (!chartInstances.has(canvas.id)) { + initChart(canvas); + } + }); + }).observe(document.body, { childList: true, subtree: true }); + } +})(); diff --git a/assets/js/chart.min.js b/assets/js/chart.min.js index 857f840..6c7a014 100644 --- a/assets/js/chart.min.js +++ b/assets/js/chart.min.js @@ -1,6 +1,6 @@ -(()=>{var Er=Object.create;var qo=Object.defineProperty;var Rr=Object.getOwnPropertyDescriptor;var Ir=Object.getOwnPropertyNames;var zr=Object.getPrototypeOf,Fr=Object.prototype.hasOwnProperty;var Vr=($,W)=>()=>(W||$((W={exports:{}}).exports,W),W.exports);var Br=($,W,ht,I)=>{if(W&&typeof W=="object"||typeof W=="function")for(let F of Ir(W))!Fr.call($,F)&&F!==ht&&qo($,F,{get:()=>W[F],enumerable:!(I=Rr(W,F))||I.enumerable});return $};var Wr=($,W,ht)=>(ht=$!=null?Er(zr($)):{},Br(W||!$||!$.__esModule?qo(ht,"default",{value:$,enumerable:!0}):ht,$));var Ko=Vr((fs,gs)=>{(function($,W){typeof fs=="object"&&typeof gs<"u"?gs.exports=W():typeof define=="function"&&define.amd?define(W):($=typeof globalThis<"u"?globalThis:$||self).Chart=W()})(fs,function(){"use strict";var $=Object.freeze({__proto__:null,get Colors(){return xr},get Decimation(){return _r},get Filler(){return Pr},get Legend(){return Dr},get SubTitle(){return Or},get Title(){return Cr},get Tooltip(){return Lr}});function W(){}let ht=(()=>{let i=0;return()=>i++})();function I(i){return i==null}function F(i){if(Array.isArray&&Array.isArray(i))return!0;let t=Object.prototype.toString.call(i);return t.slice(0,7)==="[object"&&t.slice(-6)==="Array]"}function z(i){return i!==null&&Object.prototype.toString.call(i)==="[object Object]"}function L(i){return(typeof i=="number"||i instanceof Number)&&isFinite(+i)}function q(i,t){return L(i)?i:t}function E(i,t){return i===void 0?t:i}let j=(i,t)=>typeof i=="string"&&i.endsWith("%")?parseFloat(i)/100:+i/t,Z=(i,t)=>typeof i=="string"&&i.endsWith("%")?parseFloat(i)/100*t:+i;function N(i,t,e){if(i&&typeof i.call=="function")return i.apply(e,t)}function B(i,t,e,s){let n,o,a;if(F(i))if(o=i.length,s)for(n=o-1;n>=0;n--)t.call(e,i[n],n);else for(n=0;ni,x:i=>i.x,y:i=>i.y};function xs(i){let t=i.split("."),e=[],s="";for(let n of t)s+=n,s.endsWith("\\")?s=s.slice(0,-1)+".":(e.push(s),s="");return e}function St(i,t){return(bs[t]||(bs[t]=(function(s){let n=xs(s);return o=>{for(let a of n){if(a==="")break;o=o&&o[a]}return o}})(t)))(i)}function Oe(i){return i.charAt(0).toUpperCase()+i.slice(1)}let Qt=i=>i!==void 0,Pt=i=>typeof i=="function",ci=(i,t)=>{if(i.size!==t.size)return!1;for(let e of i)if(!t.has(e))return!1;return!0};function _s(i){return i.type==="mouseup"||i.type==="click"||i.type==="contextmenu"}let Y=Math.PI,U=2*Y,ys=U+Y,he=Number.POSITIVE_INFINITY,vs=Y/180,K=Y/2,Lt=Y/4,di=2*Y/3,Dt=Math.log10,ft=Math.sign;function te(i,t,e){return Math.abs(i-t)n-o).pop(),t}function $t(i){return!(function(t){return typeof t=="symbol"||typeof t=="object"&&t!==null&&!(Symbol.toPrimitive in t||"toString"in t||"valueOf"in t)})(i)&&!isNaN(parseFloat(i))&&isFinite(i)}function ws(i,t){let e=Math.round(i);return e-t<=i&&e+t>=i}function fi(i,t,e){let s,n,o;for(s=0,n=i.length;sl&&h=Math.min(t,e)-s&&i<=Math.max(t,e)+s}function Le(i,t,e){e=e||(a=>i[a]1;)s=o+n>>1,e(s)?o=s:n=s;return{lo:o,hi:n}}let yt=(i,t,e,s)=>Le(i,e,s?n=>{let o=i[n][t];return oi[n][t]Le(i,e,s=>i[s][t]>=e);function Ds(i,t,e){let s=0,n=i.length;for(;ss&&i[n-1]>e;)n--;return s>0||n{let s="_onData"+Oe(e),n=i[e];Object.defineProperty(i,e,{configurable:!0,enumerable:!1,value(...o){let a=n.apply(this,o);return i._chartjs.listeners.forEach(r=>{typeof r[s]=="function"&&r[s](...o)}),a}})}))}function mi(i,t){let e=i._chartjs;if(!e)return;let s=e.listeners,n=s.indexOf(t);n!==-1&&s.splice(n,1),s.length>0||(Cs.forEach(o=>{delete i[o]}),delete i._chartjs)}function bi(i){let t=new Set(i);return t.size===i.length?i:Array.from(t)}let xi=typeof window>"u"?function(i){return i()}:window.requestAnimationFrame;function _i(i,t){let e=[],s=!1;return function(...n){e=n,s||(s=!0,xi.call(window,()=>{s=!1,i.apply(t,e)}))}}function As(i,t){let e;return function(...s){return t?(clearTimeout(e),e=setTimeout(i,t,s)):i.apply(this,s),t}}let Ee=i=>i==="start"?"left":i==="end"?"right":"center",tt=(i,t,e)=>i==="start"?t:i==="end"?e:(t+e)/2,Ts=(i,t,e,s)=>i===(s?"left":"right")?e:i==="center"?(t+e)/2:t;function yi(i,t,e){let s=t.length,n=0,o=s;if(i._sorted){let{iScale:a,vScale:r,_parsed:l}=i,h=i.dataset&&i.dataset.options?i.dataset.options.spanGaps:null,d=a.axis,{min:c,max:u,minDefined:f,maxDefined:p}=a.getUserBounds();if(f){if(n=Math.min(yt(l,d,c).lo,e?s:yt(t,d,a.getPixelForValue(c)).lo),h){let g=l.slice(0,n+1).reverse().findIndex(m=>!I(m[r.axis]));n-=Math.max(0,g)}n=Q(n,0,s-1)}if(p){let g=Math.max(yt(l,a.axis,u,!0).hi+1,e?0:yt(t,d,a.getPixelForValue(u),!0).hi+1);if(h){let m=l.slice(g-1).findIndex(b=>!I(b[r.axis]));g+=Math.max(0,m)}o=Q(g,n,s)-n}else o=s-n}return{start:n,count:o}}function vi(i){let{xScale:t,yScale:e,_scaleRanges:s}=i,n={xmin:t.min,xmax:t.max,ymin:e.min,ymax:e.max};if(!s)return i._scaleRanges=n,!0;let o=s.xmin!==t.min||s.xmax!==t.max||s.ymin!==e.min||s.ymax!==e.max;return Object.assign(s,n),o}class Go{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,s,n){let o=e.listeners[n],a=e.duration;o.forEach(r=>r({chart:t,initial:e.initial,numSteps:a,currentStep:Math.min(s-e.start,a)}))}_refresh(){this._request||(this._running=!0,this._request=xi.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let e=0;this._charts.forEach((s,n)=>{if(!s.running||!s.items.length)return;let o=s.items,a,r=o.length-1,l=!1;for(;r>=0;--r)a=o[r],a._active?(a._total>s.duration&&(s.duration=a._total),a.tick(t),l=!0):(o[r]=o[o.length-1],o.pop());l&&(n.draw(),this._notify(n,s,t,"progress")),o.length||(s.running=!1,this._notify(n,s,t,"complete"),s.initial=!1),e+=o.length}),this._lastDate=t,e===0&&(this._running=!1)}_getAnims(t){let e=this._charts,s=e.get(t);return s||(s={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,s)),s}listen(t,e,s){this._getAnims(t).listeners[e].push(s)}add(t,e){e&&e.length&&this._getAnims(t).items.push(...e)}has(t){return this._getAnims(t).items.length>0}start(t){let e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce((s,n)=>Math.max(s,n._duration),0),this._refresh())}running(t){if(!this._running)return!1;let e=this._charts.get(t);return!!(e&&e.running&&e.items.length)}stop(t){let e=this._charts.get(t);if(!e||!e.items.length)return;let s=e.items,n=s.length-1;for(;n>=0;--n)s[n].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var vt=new Go;function ce(i){return i+.5|0}let Et=(i,t,e)=>Math.max(Math.min(i,e),t);function de(i){return Et(ce(2.55*i),0,255)}function Rt(i){return Et(ce(255*i),0,255)}function Ct(i){return Et(ce(i/2.55)/100,0,1)}function Ls(i){return Et(ce(100*i),0,100)}let dt={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},Mi=[..."0123456789ABCDEF"],Zo=i=>Mi[15&i],Jo=i=>Mi[(240&i)>>4]+Mi[15&i],Re=i=>(240&i)>>4==(15&i);function Qo(i){var t=(e=>Re(e.r)&&Re(e.g)&&Re(e.b)&&Re(e.a))(i)?Zo:Jo;return i?"#"+t(i.r)+t(i.g)+t(i.b)+((e,s)=>e<255?s(e):"")(i.a,t):void 0}let ta=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function Es(i,t,e){let s=t*Math.min(e,1-e),n=(o,a=(o+i/30)%12)=>e-s*Math.max(Math.min(a-3,9-a,1),-1);return[n(0),n(8),n(4)]}function ea(i,t,e){let s=(n,o=(n+i/60)%6)=>e-e*t*Math.max(Math.min(o,4-o,1),0);return[s(5),s(3),s(1)]}function ia(i,t,e){let s=Es(i,1,.5),n;for(t+e>1&&(n=1/(t+e),t*=n,e*=n),n=0;n<3;n++)s[n]*=1-t-e,s[n]+=t;return s}function wi(i){let t=i.r/255,e=i.g/255,s=i.b/255,n=Math.max(t,e,s),o=Math.min(t,e,s),a=(n+o)/2,r,l,h;return n!==o&&(h=n-o,l=a>.5?h/(2-n-o):h/(n+o),r=(function(d,c,u,f,p){return d===p?(c-u)/f+(c>16&255,r>>8&255,255&r]}return e})(),Ie.transparent=[0,0,0,0]);let t=Ie[i.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}let oa=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/,Pi=i=>i<=.0031308?12.92*i:1.055*Math.pow(i,1/2.4)-.055,ie=i=>i<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4);function ze(i,t,e){if(i){let s=wi(i);s[t]=Math.max(0,Math.min(s[t]+s[t]*e,t===0?360:1)),s=Si(s),i.r=s[0],i.g=s[1],i.b=s[2]}}function Fs(i,t){return i&&Object.assign(t||{},i)}function Vs(i){var t={r:0,g:0,b:0,a:255};return Array.isArray(i)?i.length>=3&&(t={r:i[0],g:i[1],b:i[2],a:255},i.length>3&&(t.a=Rt(i[3]))):(t=Fs(i,{r:0,g:0,b:0,a:1})).a=Rt(t.a),t}function aa(i){return i.charAt(0)==="r"?(function(t){let e=oa.exec(t),s,n,o,a=255;if(e){if(e[7]!==s){let r=+e[7];a=e[8]?de(r):Et(255*r,0,255)}return s=+e[1],n=+e[3],o=+e[5],s=255&(e[2]?de(s):Et(s,0,255)),n=255&(e[4]?de(n):Et(n,0,255)),o=255&(e[6]?de(o):Et(o,0,255)),{r:s,g:n,b:o,a}}})(i):sa(i)}class ue{constructor(t){if(t instanceof ue)return t;let e=typeof t,s;var n,o,a;e==="object"?s=Vs(t):e==="string"&&(a=(n=t).length,n[0]==="#"&&(a===4||a===5?o={r:255&17*dt[n[1]],g:255&17*dt[n[2]],b:255&17*dt[n[3]],a:a===5?17*dt[n[4]]:255}:a!==7&&a!==9||(o={r:dt[n[1]]<<4|dt[n[2]],g:dt[n[3]]<<4|dt[n[4]],b:dt[n[5]]<<4|dt[n[6]],a:a===9?dt[n[7]]<<4|dt[n[8]]:255})),s=o||na(t)||aa(t)),this._rgb=s,this._valid=!!s}get valid(){return this._valid}get rgb(){var t=Fs(this._rgb);return t&&(t.a=Ct(t.a)),t}set rgb(t){this._rgb=Vs(t)}rgbString(){return this._valid?(t=this._rgb)&&(t.a<255?`rgba(${t.r}, ${t.g}, ${t.b}, ${Ct(t.a)})`:`rgb(${t.r}, ${t.g}, ${t.b})`):void 0;var t}hexString(){return this._valid?Qo(this._rgb):void 0}hslString(){return this._valid?(function(t){if(!t)return;let e=wi(t),s=e[0],n=Ls(e[1]),o=Ls(e[2]);return t.a<255?`hsla(${s}, ${n}%, ${o}%, ${Ct(t.a)})`:`hsl(${s}, ${n}%, ${o}%)`})(this._rgb):void 0}mix(t,e){if(t){let s=this.rgb,n=t.rgb,o,a=e===o?.5:e,r=2*a-1,l=s.a-n.a,h=((r*l==-1?r:(r+l)/(1+r*l))+1)/2;o=1-h,s.r=255&h*s.r+o*n.r+.5,s.g=255&h*s.g+o*n.g+.5,s.b=255&h*s.b+o*n.b+.5,s.a=a*s.a+(1-a)*n.a,this.rgb=s}return this}interpolate(t,e){return t&&(this._rgb=(function(s,n,o){let a=ie(Ct(s.r)),r=ie(Ct(s.g)),l=ie(Ct(s.b));return{r:Rt(Pi(a+o*(ie(Ct(n.r))-a))),g:Rt(Pi(r+o*(ie(Ct(n.g))-r))),b:Rt(Pi(l+o*(ie(Ct(n.b))-l))),a:s.a+o*(n.a-s.a)}})(this._rgb,t._rgb,e)),this}clone(){return new ue(this.rgb)}alpha(t){return this._rgb.a=Rt(t),this}clearer(t){return this._rgb.a*=1-t,this}greyscale(){let t=this._rgb,e=ce(.3*t.r+.59*t.g+.11*t.b);return t.r=t.g=t.b=e,this}opaquer(t){return this._rgb.a*=1+t,this}negate(){let t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return ze(this._rgb,2,t),this}darken(t){return ze(this._rgb,2,-t),this}saturate(t){return ze(this._rgb,1,t),this}desaturate(t){return ze(this._rgb,1,-t),this}rotate(t){return(function(e,s){var n=wi(e);n[0]=Rs(n[0]+s),n=Si(n),e.r=n[0],e.g=n[1],e.b=n[2]})(this._rgb,t),this}}function Fe(i){if(i&&typeof i=="object"){let t=i.toString();return t==="[object CanvasPattern]"||t==="[object CanvasGradient]"}return!1}function Di(i){return Fe(i)?i:new ue(i)}function Ve(i){return Fe(i)?i:new ue(i).saturate(.5).darken(.1).hexString()}let ra=["x","y","borderWidth","radius","tension"],la=["color","borderColor","backgroundColor"],Bs=new Map;function se(i,t,e){return(function(s,n){n=n||{};let o=s+JSON.stringify(n),a=Bs.get(o);return a||(a=new Intl.NumberFormat(s,n),Bs.set(o,a)),a})(t,e).format(i)}let Ws={values:i=>F(i)?i:""+i,numeric(i,t,e){if(i===0)return"0";let s=this.chart.options.locale,n,o=i;if(e.length>1){let h=Math.max(Math.abs(e[0].value),Math.abs(e[e.length-1].value));(h<1e-4||h>1e15)&&(n="scientific"),o=(function(d,c){let u=c.length>3?c[2].value-c[1].value:c[1].value-c[0].value;return Math.abs(u)>=1&&d!==Math.floor(d)&&(u=d-Math.floor(d)),u})(i,e)}let a=Dt(Math.abs(o)),r=isNaN(a)?1:Math.max(Math.min(-1*Math.floor(a),20),0),l={notation:n,minimumFractionDigits:r,maximumFractionDigits:r};return Object.assign(l,this.options.ticks.format),se(i,s,l)},logarithmic(i,t,e){if(i===0)return"0";let s=e[t].significand||i/Math.pow(10,Math.floor(Dt(i)));return[1,2,3,5,10,15].includes(s)||t>.8*e.length?Ws.numeric.call(this,i,t,e):""}};var fe={formatters:Ws};let Yt=Object.create(null),Ci=Object.create(null);function ge(i,t){if(!t)return i;let e=t.split(".");for(let s=0,n=e.length;ss.chart.platform.getDevicePixelRatio(),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(s,n)=>Ve(n.backgroundColor),this.hoverBorderColor=(s,n)=>Ve(n.borderColor),this.hoverColor=(s,n)=>Ve(n.color),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(t),this.apply(e)}set(t,e){return Oi(this,t,e)}get(t){return ge(this,t)}describe(t,e){return Oi(Ci,t,e)}override(t,e){return Oi(Yt,t,e)}route(t,e,s,n){let o=ge(this,t),a=ge(this,s),r="_"+e;Object.defineProperties(o,{[r]:{value:o[e],writable:!0},[e]:{enumerable:!0,get(){let l=this[r],h=a[n];return z(l)?Object.assign({},h,l):E(l,h)},set(l){this[r]=l}}})}apply(t){t.forEach(e=>e(this))}}var X=new ha({_scriptable:i=>!i.startsWith("on"),_indexable:i=>i!=="events",hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[function(i){i.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),i.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:t=>t!=="onProgress"&&t!=="onComplete"&&t!=="fn"}),i.set("animations",{colors:{type:"color",properties:la},numbers:{type:"number",properties:ra}}),i.describe("animations",{_fallback:"animation"}),i.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>0|t}}}})},function(i){i.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})},function(i){i.set("scale",{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:"ticks",clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(t,e)=>e.lineWidth,tickColor:(t,e)=>e.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:fe.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),i.route("scale.ticks","color","","color"),i.route("scale.grid","color","","borderColor"),i.route("scale.border","color","","borderColor"),i.route("scale.title","color","","color"),i.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&t!=="callback"&&t!=="parser",_indexable:t=>t!=="borderDash"&&t!=="tickBorderDash"&&t!=="dash"}),i.describe("scales",{_fallback:"scale"}),i.describe("scale.ticks",{_scriptable:t=>t!=="backdropPadding"&&t!=="callback",_indexable:t=>t!=="backdropPadding"})}]);function Be(){return typeof window<"u"&&typeof document<"u"}function We(i){let t=i.parentNode;return t&&t.toString()==="[object ShadowRoot]"&&(t=t.host),t}function Ne(i,t,e){let s;return typeof i=="string"?(s=parseInt(i,10),i.indexOf("%")!==-1&&(s=s/100*t.parentNode[e])):s=i,s}let He=i=>i.ownerDocument.defaultView.getComputedStyle(i,null);function Ns(i,t){return He(i).getPropertyValue(t)}let ca=["top","right","bottom","left"];function Ut(i,t,e){let s={};e=e?"-"+e:"";for(let n=0;n<4;n++){let o=ca[n];s[o]=parseFloat(i[t+"-"+o+e])||0}return s.width=s.left+s.right,s.height=s.top+s.bottom,s}let da=(i,t,e)=>(i>0||t>0)&&(!e||!e.shadowRoot);function It(i,t){if("native"in i)return i;let{canvas:e,currentDevicePixelRatio:s}=t,n=He(e),o=n.boxSizing==="border-box",a=Ut(n,"padding"),r=Ut(n,"border","width"),{x:l,y:h,box:d}=(function(g,m){let b=g.touches,y=b&&b.length?b[0]:g,{offsetX:_,offsetY:x}=y,v,M,w=!1;if(da(_,x,g.target))v=_,M=x;else{let k=m.getBoundingClientRect();v=y.clientX-k.left,M=y.clientY-k.top,w=!0}return{x:v,y:M,box:w}})(i,e),c=a.left+(d&&r.left),u=a.top+(d&&r.top),{width:f,height:p}=t;return o&&(f-=a.width+r.width,p-=a.height+r.height),{x:Math.round((l-c)/f*e.width/s),y:Math.round((h-u)/p*e.height/s)}}let je=i=>Math.round(10*i)/10;function Hs(i,t,e,s){let n=He(i),o=Ut(n,"margin"),a=Ne(n.maxWidth,i,"clientWidth")||he,r=Ne(n.maxHeight,i,"clientHeight")||he,l=(function(c,u,f){let p,g;if(u===void 0||f===void 0){let m=c&&We(c);if(m){let b=m.getBoundingClientRect(),y=He(m),_=Ut(y,"border","width"),x=Ut(y,"padding");u=b.width-x.width-_.width,f=b.height-x.height-_.height,p=Ne(y.maxWidth,m,"clientWidth"),g=Ne(y.maxHeight,m,"clientHeight")}else u=c.clientWidth,f=c.clientHeight}return{width:u,height:f,maxWidth:p||he,maxHeight:g||he}})(i,t,e),{width:h,height:d}=l;if(n.boxSizing==="content-box"){let c=Ut(n,"border","width"),u=Ut(n,"padding");h-=u.width+c.width,d-=u.height+c.height}return h=Math.max(0,h-o.width),d=Math.max(0,s?h/s:d-o.height),h=je(Math.min(h,a,l.maxWidth)),d=je(Math.min(d,r,l.maxHeight)),h&&!d&&(d=je(h/2)),(t!==void 0||e!==void 0)&&s&&l.height&&d>l.height&&(d=l.height,h=je(Math.floor(d*s))),{width:h,height:d}}function Ai(i,t,e){let s=t||1,n=Math.floor(i.height*s),o=Math.floor(i.width*s);i.height=Math.floor(i.height),i.width=Math.floor(i.width);let a=i.canvas;return a.style&&(e||!a.style.height&&!a.style.width)&&(a.style.height=`${i.height}px`,a.style.width=`${i.width}px`),(i.currentDevicePixelRatio!==s||a.height!==n||a.width!==o)&&(i.currentDevicePixelRatio=s,a.height=n,a.width=o,i.ctx.setTransform(s,0,0,s,0,0),!0)}let js=(function(){let i=!1;try{let t={get passive(){return i=!0,!1}};Be()&&(window.addEventListener("test",null,t),window.removeEventListener("test",null,t))}catch{}return i})();function Ti(i,t){let e=Ns(i,t),s=e&&e.match(/^(\d+)(\.\d+)?px$/);return s?+s[1]:void 0}function $s(i){return!i||I(i.size)||I(i.family)?null:(i.style?i.style+" ":"")+(i.weight?i.weight+" ":"")+i.size+"px "+i.family}function pe(i,t,e,s,n){let o=t[n];return o||(o=t[n]=i.measureText(n).width,e.push(n)),o>s&&(s=o),s}function Ys(i,t,e,s){let n=(s=s||{}).data=s.data||{},o=s.garbageCollect=s.garbageCollect||[];s.font!==t&&(n=s.data={},o=s.garbageCollect=[],s.font=t),i.save(),i.font=t;let a=0,r=e.length,l,h,d,c,u;for(l=0;le.length){for(l=0;l0&&i.stroke()}}function Mt(i,t,e){return e=e||.5,!t||i&&i.x>t.left-e&&i.xt.top-e&&i.y0&&o.strokeColor!=="",l,h;for(i.save(),i.font=n.string,(function(d,c){c.translation&&d.translate(c.translation[0],c.translation[1]),I(c.rotation)||d.rotate(c.rotation),c.color&&(d.fillStyle=c.color),c.textAlign&&(d.textAlign=c.textAlign),c.textBaseline&&(d.textBaseline=c.textBaseline)})(i,o),l=0;li[0]){let o=e||i;s===void 0&&(s=Zs("_fallback",i));let a={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:i,_rootScopes:o,_fallback:s,_getTarget:n,override:r=>Ye([r,...i],t,o,s)};return new Proxy(a,{deleteProperty:(r,l)=>(delete r[l],delete r._keys,delete i[0][l],!0),get:(r,l)=>qs(r,l,()=>(function(h,d,c,u){let f;for(let p of d)if(f=Zs(ga(p,h),c),f!==void 0)return Ii(h,f)?zi(c,u,h,f):f})(l,t,i,r)),getOwnPropertyDescriptor:(r,l)=>Reflect.getOwnPropertyDescriptor(r._scopes[0],l),getPrototypeOf:()=>Reflect.getPrototypeOf(i[0]),has:(r,l)=>Js(r).includes(l),ownKeys:r=>Js(r),set(r,l,h){let d=r._storage||(r._storage=n());return r[l]=d[l]=h,delete r._keys,!0}})}function Xt(i,t,e,s){let n={_cacheable:!1,_proxy:i,_context:t,_subProxy:e,_stack:new Set,_descriptors:Ri(i,s),setContext:o=>Xt(i,o,e,s),override:o=>Xt(i.override(o),t,e,s)};return new Proxy(n,{deleteProperty:(o,a)=>(delete o[a],delete i[a],!0),get:(o,a,r)=>qs(o,a,()=>(function(l,h,d){let{_proxy:c,_context:u,_subProxy:f,_descriptors:p}=l,g=c[h];return Pt(g)&&p.isScriptable(h)&&(g=(function(m,b,y,_){let{_proxy:x,_context:v,_subProxy:M,_stack:w}=y;if(w.has(m))throw new Error("Recursion detected: "+Array.from(w).join("->")+"->"+m);w.add(m);let k=b(v,M||_);return w.delete(m),Ii(m,k)&&(k=zi(x._scopes,x,m,k)),k})(h,g,l,d)),F(g)&&g.length&&(g=(function(m,b,y,_){let{_proxy:x,_context:v,_subProxy:M,_descriptors:w}=y;if(v.index!==void 0&&_(m))return b[v.index%b.length];if(z(b[0])){let k=b,D=x._scopes.filter(S=>S!==k);b=[];for(let S of k){let T=zi(D,x,m,S);b.push(Xt(T,v,M&&M[m],w))}}return b})(h,g,l,p.isIndexable)),Ii(h,g)&&(g=Xt(g,u,f&&f[h],p)),g})(o,a,r)),getOwnPropertyDescriptor:(o,a)=>o._descriptors.allKeys?Reflect.has(i,a)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(i,a),getPrototypeOf:()=>Reflect.getPrototypeOf(i),has:(o,a)=>Reflect.has(i,a),ownKeys:()=>Reflect.ownKeys(i),set:(o,a,r)=>(i[a]=r,delete o[a],!0)})}function Ri(i,t={scriptable:!0,indexable:!0}){let{_scriptable:e=t.scriptable,_indexable:s=t.indexable,_allKeys:n=t.allKeys}=i;return{allKeys:n,scriptable:e,indexable:s,isScriptable:Pt(e)?e:()=>e,isIndexable:Pt(s)?s:()=>s}}let ga=(i,t)=>i?i+Oe(t):t,Ii=(i,t)=>z(t)&&i!=="adapters"&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function qs(i,t,e){if(Object.prototype.hasOwnProperty.call(i,t)||t==="constructor")return i[t];let s=e();return i[t]=s,s}function Ks(i,t,e){return Pt(i)?i(t,e):i}let pa=(i,t)=>i===!0?t:typeof i=="string"?St(t,i):void 0;function ma(i,t,e,s,n){for(let o of t){let a=pa(e,o);if(a){i.add(a);let r=Ks(a._fallback,e,n);if(r!==void 0&&r!==e&&r!==s)return r}else if(a===!1&&s!==void 0&&e!==s)return null}return!1}function zi(i,t,e,s){let n=t._rootScopes,o=Ks(t._fallback,e,s),a=[...i,...n],r=new Set;r.add(s);let l=Gs(r,a,e,o||e,s);return l!==null&&(o===void 0||o===e||(l=Gs(r,a,o,l,s),l!==null))&&Ye(Array.from(r),[""],n,o,()=>(function(h,d,c){let u=h._getTarget();d in u||(u[d]={});let f=u[d];return F(f)&&z(c)?c:f||{}})(t,e,s))}function Gs(i,t,e,s,n){for(;e;)e=ma(i,t,e,s,n);return e}function Zs(i,t){for(let e of t){if(!e)continue;let s=e[i];if(s!==void 0)return s}}function Js(i){let t=i._keys;return t||(t=i._keys=(function(e){let s=new Set;for(let n of e)for(let o of Object.keys(n).filter(a=>!a.startsWith("_")))s.add(o);return Array.from(s)})(i._scopes)),t}function Fi(i,t,e,s){let{iScale:n}=i,{key:o="r"}=this._parsing,a=new Array(s),r,l,h,d;for(r=0,l=s;rti==="x"?"y":"x";function tn(i,t,e,s){let n=i.skip?t:i,o=t,a=e.skip?t:e,r=Te(o,n),l=Te(a,o),h=r/(r+l),d=l/(r+l);h=isNaN(h)?0:h,d=isNaN(d)?0:d;let c=s*h,u=s*d;return{previous:{x:o.x-c*(a.x-n.x),y:o.y-c*(a.y-n.y)},next:{x:o.x+u*(a.x-n.x),y:o.y+u*(a.y-n.y)}}}function en(i,t="x"){let e=Qs(t),s=i.length,n=Array(s).fill(0),o=Array(s),a,r,l,h=oe(i,0);for(a=0;a!h.skip)),t.cubicInterpolationMode==="monotone")en(i,n);else{let h=s?i[i.length-1]:i[0];for(o=0,a=i.length;oi===0||i===1,nn=(i,t,e)=>-Math.pow(2,10*(i-=1))*Math.sin((i-t)*U/e),on=(i,t,e)=>Math.pow(2,-10*i)*Math.sin((i-t)*U/e)+1,ae={linear:i=>i,easeInQuad:i=>i*i,easeOutQuad:i=>-i*(i-2),easeInOutQuad:i=>(i/=.5)<1?.5*i*i:-.5*(--i*(i-2)-1),easeInCubic:i=>i*i*i,easeOutCubic:i=>(i-=1)*i*i+1,easeInOutCubic:i=>(i/=.5)<1?.5*i*i*i:.5*((i-=2)*i*i+2),easeInQuart:i=>i*i*i*i,easeOutQuart:i=>-((i-=1)*i*i*i-1),easeInOutQuart:i=>(i/=.5)<1?.5*i*i*i*i:-.5*((i-=2)*i*i*i-2),easeInQuint:i=>i*i*i*i*i,easeOutQuint:i=>(i-=1)*i*i*i*i+1,easeInOutQuint:i=>(i/=.5)<1?.5*i*i*i*i*i:.5*((i-=2)*i*i*i*i+2),easeInSine:i=>1-Math.cos(i*K),easeOutSine:i=>Math.sin(i*K),easeInOutSine:i=>-.5*(Math.cos(Y*i)-1),easeInExpo:i=>i===0?0:Math.pow(2,10*(i-1)),easeOutExpo:i=>i===1?1:1-Math.pow(2,-10*i),easeInOutExpo:i=>Xe(i)?i:i<.5?.5*Math.pow(2,10*(2*i-1)):.5*(2-Math.pow(2,-10*(2*i-1))),easeInCirc:i=>i>=1?i:-(Math.sqrt(1-i*i)-1),easeOutCirc:i=>Math.sqrt(1-(i-=1)*i),easeInOutCirc:i=>(i/=.5)<1?-.5*(Math.sqrt(1-i*i)-1):.5*(Math.sqrt(1-(i-=2)*i)+1),easeInElastic:i=>Xe(i)?i:nn(i,.075,.3),easeOutElastic:i=>Xe(i)?i:on(i,.075,.3),easeInOutElastic(i){return Xe(i)?i:i<.5?.5*nn(2*i,.1125,.45):.5+.5*on(2*i-1,.1125,.45)},easeInBack(i){return i*i*((1.70158+1)*i-1.70158)},easeOutBack(i){return(i-=1)*i*((1.70158+1)*i+1.70158)+1},easeInOutBack(i){let t=1.70158;return(i/=.5)<1?i*i*((1+(t*=1.525))*i-t)*.5:.5*((i-=2)*i*((1+(t*=1.525))*i+t)+2)},easeInBounce:i=>1-ae.easeOutBounce(1-i),easeOutBounce(i){return i<1/2.75?7.5625*i*i:i<2/2.75?7.5625*(i-=1.5/2.75)*i+.75:i<2.5/2.75?7.5625*(i-=2.25/2.75)*i+.9375:7.5625*(i-=2.625/2.75)*i+.984375},easeInOutBounce:i=>i<.5?.5*ae.easeInBounce(2*i):.5*ae.easeOutBounce(2*i-1)+.5};function Vt(i,t,e,s){return{x:i.x+e*(t.x-i.x),y:i.y+e*(t.y-i.y)}}function an(i,t,e,s){return{x:i.x+e*(t.x-i.x),y:s==="middle"?e<.5?i.y:t.y:s==="after"?e<1?i.y:t.y:e>0?t.y:i.y}}function rn(i,t,e,s){let n={x:i.cp2x,y:i.cp2y},o={x:t.cp1x,y:t.cp1y},a=Vt(i,n,e),r=Vt(n,o,e),l=Vt(o,t,e),h=Vt(a,r,e),d=Vt(r,l,e);return Vt(h,d,e)}let xa=/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/,_a=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;function ln(i,t){let e=(""+i).match(xa);if(!e||e[1]==="normal")return 1.2*t;switch(i=+e[2],e[3]){case"px":return i;case"%":i/=100}return t*i}let ya=i=>+i||0;function qe(i,t){let e={},s=z(t),n=s?Object.keys(t):t,o=z(i)?s?a=>E(i[a],i[t[a]]):a=>i[a]:()=>i;for(let a of n)e[a]=ya(o(a));return e}function Vi(i){return qe(i,{top:"y",right:"x",bottom:"y",left:"x"})}function Bt(i){return qe(i,["topLeft","topRight","bottomLeft","bottomRight"])}function et(i){let t=Vi(i);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function J(i,t){i=i||{},t=t||X.font;let e=E(i.size,t.size);typeof e=="string"&&(e=parseInt(e,10));let s=E(i.style,t.style);s&&!(""+s).match(_a)&&(console.warn('Invalid font style specified: "'+s+'"'),s=void 0);let n={family:E(i.family,t.family),lineHeight:ln(E(i.lineHeight,t.lineHeight),e),size:e,style:s,weight:E(i.weight,t.weight),string:""};return n.string=$s(n),n}function re(i,t,e,s){let n,o,a,r=!0;for(n=0,o=i.length;ne&&r===0?0:r+l;return{min:a(s,-Math.abs(o)),max:a(n,o)}}function Ot(i,t){return Object.assign(Object.create(i),t)}function qt(i,t,e){return i?(function(s,n){return{x:o=>s+s+n-o,setWidth(o){n=o},textAlign:o=>o==="center"?o:o==="right"?"left":"right",xPlus:(o,a)=>o-a,leftForLtr:(o,a)=>o-a}})(t,e):{x:s=>s,setWidth(s){},textAlign:s=>s,xPlus:(s,n)=>s+n,leftForLtr:(s,n)=>s}}function Bi(i,t){let e,s;t!=="ltr"&&t!=="rtl"||(e=i.canvas.style,s=[e.getPropertyValue("direction"),e.getPropertyPriority("direction")],e.setProperty("direction",t,"important"),i.prevTextDirection=s)}function Wi(i,t){t!==void 0&&(delete i.prevTextDirection,i.canvas.style.setProperty("direction",t[0],t[1]))}function cn(i){return i==="angle"?{between:ee,compare:ks,normalize:nt}:{between:_t,compare:(t,e)=>t-e,normalize:t=>t}}function dn({start:i,end:t,count:e,loop:s,style:n}){return{start:i%e,end:t%e,loop:s&&(t-i+1)%e==0,style:n}}function Ni(i,t,e){if(!e)return[i];let{property:s,start:n,end:o}=e,a=t.length,{compare:r,between:l,normalize:h}=cn(s),{start:d,end:c,loop:u,style:f}=(function(M,w,k){let{property:D,start:S,end:T}=k,{between:A,normalize:P}=cn(D),O=w.length,C,R,{start:H,end:V,loop:st}=M;if(st){for(H+=O,V+=O,C=0,R=O;Cy||l(n,b,g)&&r(n,b)!==0,v=()=>!y||r(o,g)===0||l(o,b,g);for(let M=d,w=d;M<=c;++M)m=t[M%a],m.skip||(g=h(m[s]),g!==b&&(y=l(g,n,o),_===null&&x()&&(_=r(g,n)===0?M:w),_!==null&&v()&&(p.push(dn({start:_,end:M,loop:u,count:a,style:f})),_=null),w=M,b=g));return _!==null&&p.push(dn({start:_,end:c,loop:u,count:a,style:f})),p}function Hi(i,t){let e=[],s=i.segments;for(let n=0;nu&&l[f%h].skip;)f--;return f%=h,{start:u,end:f}})(e,n,o,s);return s===!0?fn(i,[{start:a,end:r,loop:o}],e,t):fn(i,(function(l,h,d,c){let u=l.length,f=[],p,g=h,m=l[h];for(p=h+1;p<=d;++p){let b=l[p%u];b.skip||b.stop?m.skip||(c=!1,f.push({start:h%u,end:(p-1)%u,loop:c}),h=g=b.stop?p:null):(g=p,m.skip&&(h=p)),m=b}return g!==null&&f.push({start:h%u,end:g%u,loop:c}),f})(e,a,r!I(g[c.axis]));d.lo-=Math.max(0,f);let p=u.slice(d.hi).findIndex(g=>!I(g[c.axis]));d.hi+=Math.max(0,p)}return d}if(n._sharedOptions){let d=o[0],c=typeof d.getRange=="function"&&d.getRange(t);if(c){let u=h(o,t,e-c),f=h(o,t,e+c);return{lo:u.lo,hi:f.hi}}}}return{lo:0,hi:o.length-1}}function xe(i,t,e,s,n){let o=i.getSortedVisibleDatasetMetas(),a=e[t];for(let r=0,l=o.length;r{l[a]&&l[a](t[e],n)&&(o.push({element:l,datasetIndex:h,index:d}),r=r||l.inRange(t.x,t.y,n))}),s&&!r?[]:o}var mn={evaluateInteractionItems:xe,modes:{index(i,t,e,s){let n=It(t,i),o=e.axis||"x",a=e.includeInvisible||!1,r=e.intersect?ji(i,n,o,s,a):$i(i,n,o,!1,s,a),l=[];return r.length?(i.getSortedVisibleDatasetMetas().forEach(h=>{let d=r[0].index,c=h.data[d];c&&!c.skip&&l.push({element:c,datasetIndex:h.index,index:d})}),l):[]},dataset(i,t,e,s){let n=It(t,i),o=e.axis||"xy",a=e.includeInvisible||!1,r=e.intersect?ji(i,n,o,s,a):$i(i,n,o,!1,s,a);if(r.length>0){let l=r[0].datasetIndex,h=i.getDatasetMeta(l).data;r=[];for(let d=0;dji(i,It(t,i),e.axis||"xy",s,e.includeInvisible||!1),nearest(i,t,e,s){let n=It(t,i),o=e.axis||"xy",a=e.includeInvisible||!1;return $i(i,n,o,e.intersect,s,a)},x:(i,t,e,s)=>pn(i,It(t,i),"x",e.intersect,s),y:(i,t,e,s)=>pn(i,It(t,i),"y",e.intersect,s)}};let bn=["left","top","right","bottom"];function _e(i,t){return i.filter(e=>e.pos===t)}function xn(i,t){return i.filter(e=>bn.indexOf(e.pos)===-1&&e.box.axis===t)}function ye(i,t){return i.sort((e,s)=>{let n=t?s:e,o=t?e:s;return n.weight===o.weight?n.index-o.index:n.weight-o.weight})}function Sa(i,t){let e=(function(l){let h={};for(let d of l){let{stack:c,pos:u,stackWeight:f}=d;if(!c||!bn.includes(u))continue;let p=h[c]||(h[c]={count:0,placed:0,weight:0,size:0});p.count++,p.weight+=f}return h})(i),{vBoxMaxWidth:s,hBoxMaxHeight:n}=t,o,a,r;for(o=0,a=i.length;o{o[a]=Math.max(t[a],e[a])}),o}return s(i?["left","right"]:["top","bottom"])}function ve(i,t,e,s){let n=[],o,a,r,l,h,d;for(o=0,a=i.length,h=0;ok.box.fullSize),!0),y=ye(_e(m,"left"),!0),_=ye(_e(m,"right")),x=ye(_e(m,"top"),!0),v=ye(_e(m,"bottom")),M=xn(m,"x"),w=xn(m,"y");return{fullSize:b,leftAndTop:y.concat(x),rightAndBottom:_.concat(w).concat(v).concat(M),chartArea:_e(m,"chartArea"),vertical:y.concat(_).concat(w),horizontal:x.concat(v).concat(M)}})(i.boxes),l=r.vertical,h=r.horizontal;B(i.boxes,g=>{typeof g.beforeLayout=="function"&&g.beforeLayout()});let d=l.reduce((g,m)=>m.box.options&&m.box.options.display===!1?g:g+1,0)||1,c=Object.freeze({outerWidth:t,outerHeight:e,padding:n,availableWidth:o,availableHeight:a,vBoxMaxWidth:o/2/d,hBoxMaxHeight:a/2}),u=Object.assign({},n);yn(u,et(s));let f=Object.assign({maxPadding:u,w:o,h:a,x:n.left,y:n.top},n),p=Sa(l.concat(h),c);ve(r.fullSize,f,c,p),ve(l,f,c,p),ve(h,f,c,p)&&ve(l,f,c,p),(function(g){let m=g.maxPadding;function b(y){let _=Math.max(m[y]-g[y],0);return g[y]+=_,_}g.y+=b("top"),g.x+=b("left"),b("right"),b("bottom")})(f),vn(r.leftAndTop,f,c,p),f.x+=f.w,f.y+=f.h,vn(r.rightAndBottom,f,c,p),i.chartArea={left:f.left,top:f.top,right:f.left+f.w,bottom:f.top+f.h,height:f.h,width:f.w},B(r.chartArea,g=>{let m=g.box;Object.assign(m,i.chartArea),m.update(f.w,f.h,{left:0,top:0,right:0,bottom:0})})}};class Yi{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,s){}removeEventListener(t,e,s){}getDevicePixelRatio(){return 1}getMaximumSize(t,e,s,n){return e=Math.max(0,e||t.width),s=s||t.height,{width:e,height:Math.max(0,n?Math.floor(e/n):s)}}isAttached(t){return!0}updateConfig(t){}}class Mn extends Yi{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}let Ge="$chartjs",Ca={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},wn=i=>i===null||i==="",kn=!!js&&{passive:!0};function Oa(i,t,e){i&&i.canvas&&i.canvas.removeEventListener(t,e,kn)}function Ze(i,t){for(let e of i)if(e===t||e.contains(t))return!0}function Aa(i,t,e){let s=i.canvas,n=new MutationObserver(o=>{let a=!1;for(let r of o)a=a||Ze(r.addedNodes,s),a=a&&!Ze(r.removedNodes,s);a&&e()});return n.observe(document,{childList:!0,subtree:!0}),n}function Ta(i,t,e){let s=i.canvas,n=new MutationObserver(o=>{let a=!1;for(let r of o)a=a||Ze(r.removedNodes,s),a=a&&!Ze(r.addedNodes,s);a&&e()});return n.observe(document,{childList:!0,subtree:!0}),n}let Me=new Map,Sn=0;function Pn(){let i=window.devicePixelRatio;i!==Sn&&(Sn=i,Me.forEach((t,e)=>{e.currentDevicePixelRatio!==i&&t()}))}function La(i,t,e){let s=i.canvas,n=s&&We(s);if(!n)return;let o=_i((r,l)=>{let h=n.clientWidth;e(r,l),h{let l=r[0],h=l.contentRect.width,d=l.contentRect.height;h===0&&d===0||o(h,d)});return a.observe(n),(function(r,l){Me.size||window.addEventListener("resize",Pn),Me.set(r,l)})(i,o),a}function Ui(i,t,e){e&&e.disconnect(),t==="resize"&&(function(s){Me.delete(s),Me.size||window.removeEventListener("resize",Pn)})(i)}function Ea(i,t,e){let s=i.canvas,n=_i(o=>{i.ctx!==null&&e((function(a,r){let l=Ca[a.type]||a.type,{x:h,y:d}=It(a,r);return{type:l,chart:r,native:a,x:h!==void 0?h:null,y:d!==void 0?d:null}})(o,i))},i);return(function(o,a,r){o&&o.addEventListener(a,r,kn)})(s,t,n),n}class Dn extends Yi{acquireContext(t,e){let s=t&&t.getContext&&t.getContext("2d");return s&&s.canvas===t?((function(n,o){let a=n.style,r=n.getAttribute("height"),l=n.getAttribute("width");if(n[Ge]={initial:{height:r,width:l,style:{display:a.display,height:a.height,width:a.width}}},a.display=a.display||"block",a.boxSizing=a.boxSizing||"border-box",wn(l)){let h=Ti(n,"width");h!==void 0&&(n.width=h)}if(wn(r))if(n.style.height==="")n.height=n.width/(o||2);else{let h=Ti(n,"height");h!==void 0&&(n.height=h)}})(t,e),s):null}releaseContext(t){let e=t.canvas;if(!e[Ge])return!1;let s=e[Ge].initial;["height","width"].forEach(o=>{let a=s[o];I(a)?e.removeAttribute(o):e.setAttribute(o,a)});let n=s.style||{};return Object.keys(n).forEach(o=>{e.style[o]=n[o]}),e.width=e.width,delete e[Ge],!0}addEventListener(t,e,s){this.removeEventListener(t,e);let n=t.$proxies||(t.$proxies={}),o={attach:Aa,detach:Ta,resize:La}[e]||Ea;n[e]=o(t,e,s)}removeEventListener(t,e){let s=t.$proxies||(t.$proxies={}),n=s[e];n&&(({attach:Ui,detach:Ui,resize:Ui}[e]||Oa)(t,e,n),s[e]=void 0)}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,s,n){return Hs(t,e,s,n)}isAttached(t){let e=t&&We(t);return!(!e||!e.isConnected)}}function Cn(i){return!Be()||typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas?Mn:Dn}var On=Object.freeze({__proto__:null,BasePlatform:Yi,BasicPlatform:Mn,DomPlatform:Dn,_detectPlatform:Cn});let An="transparent",Ra={boolean:(i,t,e)=>e>.5?t:i,color(i,t,e){let s=Di(i||An),n=s.valid&&Di(t||An);return n&&n.valid?n.mix(s,e).hexString():t},number:(i,t,e)=>i+(t-i)*e};class Tn{constructor(t,e,s,n){let o=e[s];n=re([t.to,n,o,t.from]);let a=re([t.from,o,n]);this._active=!0,this._fn=t.fn||Ra[t.type||typeof a],this._easing=ae[t.easing]||ae.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=s,this._from=a,this._to=n,this._promises=void 0}active(){return this._active}update(t,e,s){if(this._active){this._notify(!1);let n=this._target[this._prop],o=s-this._start,a=this._duration-o;this._start=s,this._duration=Math.floor(Math.max(a,t.duration)),this._total+=o,this._loop=!!t.loop,this._to=re([t.to,e,n,t.from]),this._from=re([t.from,n,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){let e=t-this._start,s=this._duration,n=this._prop,o=this._from,a=this._loop,r=this._to,l;if(this._active=o!==r&&(a||e1?2-l:l,l=this._easing(Math.min(1,Math.max(0,l))),this._target[n]=this._fn(o,r,l))}wait(){let t=this._promises||(this._promises=[]);return new Promise((e,s)=>{t.push({res:e,rej:s})})}_notify(t){let e=t?"res":"rej",s=this._promises||[];for(let n=0;n{let o=t[n];if(!z(o))return;let a={};for(let r of e)a[r]=o[r];(F(o.properties)&&o.properties||[n]).forEach(r=>{r!==n&&s.has(r)||s.set(r,a)})})}_animateOptions(t,e){let s=e.options,n=(function(a,r){if(!r)return;let l=a.options;return l?(l.$shared&&(a.options=l=Object.assign({},l,{$shared:!1,$animations:{}})),l):void(a.options=r)})(t,s);if(!n)return[];let o=this._createAnimations(n,s);return s.$shared&&(function(a,r){let l=[],h=Object.keys(r);for(let d=0;d{t.options=s},()=>{}),o}_createAnimations(t,e){let s=this._properties,n=[],o=t.$animations||(t.$animations={}),a=Object.keys(e),r=Date.now(),l;for(l=a.length-1;l>=0;--l){let h=a[l];if(h.charAt(0)==="$")continue;if(h==="options"){n.push(...this._animateOptions(t,e));continue}let d=e[h],c=o[h],u=s.get(h);if(c){if(u&&c.active()){c.update(u,d,r);continue}c.cancel()}u&&u.duration?(o[h]=c=new Tn(u,t,h,d),n.push(c)):t[h]=d}return n}update(t,e){if(this._properties.size===0)return void Object.assign(t,e);let s=this._createAnimations(t,e);return s.length?(vt.add(this._chart,s),!0):void 0}}function Ln(i,t){let e=i&&i.options||{},s=e.reverse,n=e.min===void 0?t:0,o=e.max===void 0?t:0;return{start:s?o:n,end:s?n:o}}function En(i,t){let e=[],s=i._getSortedDatasetMetas(t),n,o;for(n=0,o=s.length;n0||!e&&o<0)return n.index}return null}function zn(i,t){let{chart:e,_cachedMeta:s}=i,n=e._stacks||(e._stacks={}),{iScale:o,vScale:a,index:r}=s,l=o.axis,h=a.axis,d=(function(f,p,g){return`${f.id}.${p.id}.${g.stack||g.type}`})(o,a,s),c=t.length,u;for(let f=0;fe[s].axis===t).shift()}function we(i,t){let e=i.controller.index,s=i.vScale&&i.vScale.axis;if(s){t=t||i._parsed;for(let n of t){let o=n._stacks;if(!o||o[s]===void 0||o[s][e]===void 0)return;delete o[s][e],o[s]._visualValues!==void 0&&o[s]._visualValues[e]!==void 0&&delete o[s]._visualValues[e]}}}let Gi=i=>i==="reset"||i==="none",Fn=(i,t)=>t?i:Object.assign({},i);class At{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(t,e){this.chart=t,this._ctx=t.ctx,this.index=e,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){let t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=qi(t.vScale,t),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled("filler")&&console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options")}updateIndex(t){this.index!==t&&we(this._cachedMeta),this.index=t}linkScales(){let t=this.chart,e=this._cachedMeta,s=this.getDataset(),n=(c,u,f,p)=>c==="x"?u:c==="r"?p:f,o=e.xAxisID=E(s.xAxisID,Ki(t,"x")),a=e.yAxisID=E(s.yAxisID,Ki(t,"y")),r=e.rAxisID=E(s.rAxisID,Ki(t,"r")),l=e.indexAxis,h=e.iAxisID=n(l,o,a,r),d=e.vAxisID=n(l,a,o,r);e.xScale=this.getScaleForId(o),e.yScale=this.getScaleForId(a),e.rScale=this.getScaleForId(r),e.iScale=this.getScaleForId(h),e.vScale=this.getScaleForId(d)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){let e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){let t=this._cachedMeta;this._data&&mi(this._data,this),t._stacked&&we(t)}_dataCheck(){let t=this.getDataset(),e=t.data||(t.data=[]),s=this._data;if(z(e)){let n=this._cachedMeta;this._data=(function(o,a){let{iScale:r,vScale:l}=a,h=r.axis==="x"?"x":"y",d=l.axis==="x"?"x":"y",c=Object.keys(o),u=new Array(c.length),f,p,g;for(f=0,p=c.length;f0&&s._parsed[t-1];if(this._parsing===!1)s._parsed=n,s._sorted=!0,d=n;else{d=F(n[t])?this.parseArrayData(s,n,t,e):z(n[t])?this.parseObjectData(s,n,t,e):this.parsePrimitiveData(s,n,t,e);let f=()=>h[r]===null||u&&h[r]g&&!m.hidden&&m._stacked&&{keys:En(b,!0),values:null})(e,s,this.chart),h={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:d,max:c}=(function(g){let{min:m,max:b,minDefined:y,maxDefined:_}=g.getUserBounds();return{min:y?m:Number.NEGATIVE_INFINITY,max:_?b:Number.POSITIVE_INFINITY}})(r),u,f;function p(){f=n[u];let g=f[r.axis];return!L(f[t.axis])||d>g||c=0;--u)if(!p()){this.updateRangeFromParsed(h,t,f,l);break}}return h}getAllParsedValues(t){let e=this._cachedMeta._parsed,s=[],n,o,a;for(n=0,o=e.length;n=0&&tthis.getContext(s,n,e),c);return p.$shared&&(p.$shared=l,o[a]=Object.freeze(Fn(p,l))),p}_resolveAnimations(t,e,s){let n=this.chart,o=this._cachedDataOpts,a=`animation-${e}`,r=o[a];if(r)return r;let l;if(n.options.animation!==!1){let d=this.chart.config,c=d.datasetAnimationScopeKeys(this._type,e),u=d.getOptionScopes(this.getDataset(),c);l=d.createResolver(u,this.getContext(t,s,e))}let h=new Xi(n,l&&l.animations);return l&&l._cacheable&&(o[a]=Object.freeze(h)),h}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||Gi(t)||this.chart._animationsDisabled}_getSharedOptions(t,e){let s=this.resolveDataElementOptions(t,e),n=this._sharedOptions,o=this.getSharedOptions(s),a=this.includeOptions(e,o)||o!==n;return this.updateSharedOptions(o,e,s),{sharedOptions:o,includeOptions:a}}updateElement(t,e,s,n){Gi(n)?Object.assign(t,s):this._resolveAnimations(e,n).update(t,s)}updateSharedOptions(t,e,s){t&&!Gi(e)&&this._resolveAnimations(void 0,e).update(t,s)}_setStyle(t,e,s,n){t.active=n;let o=this.getStyle(e,n);this._resolveAnimations(e,s,n).update(t,{options:!n&&this.getSharedOptions(o)||o})}removeHoverStyle(t,e,s){this._setStyle(t,s,"active",!1)}setHoverStyle(t,e,s){this._setStyle(t,s,"active",!0)}_removeDatasetHoverStyle(){let t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){let t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){let e=this._data,s=this._cachedMeta.data;for(let[r,l,h]of this._syncList)this[r](l,h);this._syncList=[];let n=s.length,o=e.length,a=Math.min(o,n);a&&this.parse(0,a),o>n?this._insertElements(n,o-n,t):o{for(h.length+=e,r=h.length-1;r>=a;r--)h[r]=h[r-e]};for(l(o),r=t;r{n[o]=s[o]&&s[o].active()?s[o]._to:this[o]}),n}}function za(i,t){let e=i.options.ticks,s=(function(c){let u=c.options.offset,f=c._tickSize(),p=c._length/f+(u?0:1),g=c._maxLength/f;return Math.floor(Math.min(p,g))})(i),n=Math.min(e.maxTicksLimit||s,s),o=e.major.enabled?(function(c){let u=[],f,p;for(f=0,p=c.length;fn)return(function(c,u,f,p){let g,m=0,b=f[0];for(p=Math.ceil(p),g=0;gg)return _}return Math.max(g,1)})(o,t,n);if(a>0){let c,u,f=a>1?Math.round((l-r)/(a-1)):null;for(Je(t,h,d,I(f)?0:r-f,r),c=0,u=a-1;ct==="top"||t==="left"?i[t]+e:i[t]-e,Bn=(i,t)=>Math.min(t||i,i);function Wn(i,t){let e=[],s=i.length/t,n=i.length,o=0;for(;oa+r)))return h}function ke(i){return i.drawTicks?i.tickLength:0}function Nn(i,t){if(!i.display)return 0;let e=J(i.font,t),s=et(i.padding);return(F(i.text)?i.text.length:1)*e.lineHeight+s.height}function Va(i,t,e){let s=Ee(i);return(e&&t!=="right"||!e&&t==="right")&&(s=(n=>n==="left"?"right":n==="right"?"left":n)(s)),s}class Wt extends wt{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,e){return t}getUserBounds(){let{_userMin:t,_userMax:e,_suggestedMin:s,_suggestedMax:n}=this;return t=q(t,Number.POSITIVE_INFINITY),e=q(e,Number.NEGATIVE_INFINITY),s=q(s,Number.POSITIVE_INFINITY),n=q(n,Number.NEGATIVE_INFINITY),{min:q(t,s),max:q(e,n),minDefined:L(t),maxDefined:L(e)}}getMinMax(t){let e,{min:s,max:n,minDefined:o,maxDefined:a}=this.getUserBounds();if(o&&a)return{min:s,max:n};let r=this.getMatchingVisibleMetas();for(let l=0,h=r.length;ln?n:s,n=o&&s>n?s:n,{min:q(s,q(n,s)),max:q(n,q(s,n))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){let t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}getLabelItems(t=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(t))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){N(this.options.beforeUpdate,[this])}update(t,e,s){let{beginAtZero:n,grace:o,ticks:a}=this.options,r=a.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=s=Object.assign({left:0,right:0,top:0,bottom:0},s),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+s.left+s.right:this.height+s.top+s.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=hn(this,o,n),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();let l=r=o||s<=1||!this.isHorizontal())return void(this.labelRotation=n);let d=this._getLabelSizes(),c=d.widest.width,u=d.highest.height,f=Q(this.chart.width-c,0,this.maxWidth);a=t.offset?this.maxWidth/s:f/(s-1),c+6>a&&(a=f/(s-(t.offset?.5:1)),r=this.maxHeight-ke(t.grid)-e.padding-Nn(t.title,this.chart.options.font),l=Math.sqrt(c*c+u*u),h=Ae(Math.min(Math.asin(Q((d.highest.height+6)/a,-1,1)),Math.asin(Q(r/l,-1,1))-Math.asin(Q(u/l,-1,1)))),h=Math.max(n,Math.min(o,h))),this.labelRotation=h}afterCalculateLabelRotation(){N(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){N(this.options.beforeFit,[this])}fit(){let t={width:0,height:0},{chart:e,options:{ticks:s,title:n,grid:o}}=this,a=this._isVisible(),r=this.isHorizontal();if(a){let l=Nn(n,e.options.font);if(r?(t.width=this.maxWidth,t.height=ke(o)+l):(t.height=this.maxHeight,t.width=ke(o)+l),s.display&&this.ticks.length){let{first:h,last:d,widest:c,highest:u}=this._getLabelSizes(),f=2*s.padding,p=ct(this.labelRotation),g=Math.cos(p),m=Math.sin(p);if(r){let b=s.mirror?0:m*c.width+g*u.height;t.height=Math.min(this.maxHeight,t.height+b+f)}else{let b=s.mirror?0:g*c.width+m*u.height;t.width=Math.min(this.maxWidth,t.width+b+f)}this._calculatePadding(h,d,m,g)}}this._handleMargins(),r?(this.width=this._length=e.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=e.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,e,s,n){let{ticks:{align:o,padding:a},position:r}=this.options,l=this.labelRotation!==0,h=r!=="top"&&this.axis==="x";if(this.isHorizontal()){let d=this.getPixelForTick(0)-this.left,c=this.right-this.getPixelForTick(this.ticks.length-1),u=0,f=0;l?h?(u=n*t.width,f=s*e.height):(u=s*t.height,f=n*e.width):o==="start"?f=e.width:o==="end"?u=t.width:o!=="inner"&&(u=t.width/2,f=e.width/2),this.paddingLeft=Math.max((u-d+a)*this.width/(this.width-d),0),this.paddingRight=Math.max((f-c+a)*this.width/(this.width-c),0)}else{let d=e.height/2,c=t.height/2;o==="start"?(d=0,c=t.height):o==="end"&&(d=e.height,c=0),this.paddingTop=d+a,this.paddingBottom=c+a}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){N(this.options.afterFit,[this])}isHorizontal(){let{axis:t,position:e}=this.options;return e==="top"||e==="bottom"||t==="x"}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){let e,s;for(this.beforeTickToLabelConversion(),this.generateTickLabels(t),e=0,s=t.length;e{let A=T.gc,P=A.length/2,O;if(P>S){for(O=0;O({width:a[D]||0,height:r[D]||0});return{first:k(0),last:k(e-1),widest:k(M),highest:k(w),widths:a,heights:r}}getLabelForValue(t){return t}getPixelForValue(t,e){return NaN}getValueForPixel(t){}getPixelForTick(t){let e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);let e=this._startPixel+t*this._length;return Ss(this._alignToPixels?zt(this.chart,e,0):e)}getDecimalForPixel(t){let e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){let{min:t,max:e}=this;return t<0&&e<0?e:t>0&&e>0?t:0}getContext(t){let e=this.ticks||[];if(t>=0&&tr*n?r/s:l/n:l*n0}_computeGridLineItems(t){let e=this.axis,s=this.chart,n=this.options,{grid:o,position:a,border:r}=n,l=o.offset,h=this.isHorizontal(),d=this.ticks.length+(l?1:0),c=ke(o),u=[],f=r.setContext(this.getContext()),p=f.display?f.width:0,g=p/2,m=function(C){return zt(s,C,p)},b,y,_,x,v,M,w,k,D,S,T,A;if(a==="top")b=m(this.bottom),M=this.bottom-c,k=b-g,S=m(t.top)+g,A=t.bottom;else if(a==="bottom")b=m(this.top),S=t.top,A=m(t.bottom)-g,M=b+g,k=this.top+c;else if(a==="left")b=m(this.right),v=this.right-c,w=b-g,D=m(t.left)+g,T=t.right;else if(a==="right")b=m(this.left),D=t.left,T=m(t.right)-g,v=b+g,w=this.left+c;else if(e==="x"){if(a==="center")b=m((t.top+t.bottom)/2+.5);else if(z(a)){let C=Object.keys(a)[0],R=a[C];b=m(this.chart.scales[C].getPixelForValue(R))}S=t.top,A=t.bottom,M=b+g,k=M+c}else if(e==="y"){if(a==="center")b=m((t.left+t.right)/2);else if(z(a)){let C=Object.keys(a)[0],R=a[C];b=m(this.chart.scales[C].getPixelForValue(R))}v=b-g,w=v-c,D=t.left,T=t.right}let P=E(n.ticks.maxTicksLimit,d),O=Math.max(1,Math.ceil(d/P));for(y=0;y0&&(xt-=mt/2)}rt={left:xt,top:bt,width:mt+ut.width,height:pt+ut.height,color:C.backdropColor}}m.push({label:x,font:D,textOffset:A,options:{rotation:g,color:H,strokeColor:V,strokeWidth:st,textAlign:lt,textBaseline:P,translation:[v,M],backdrop:rt}})}return m}_getXAxisLabelAlignment(){let{position:t,ticks:e}=this.options;if(-ct(this.labelRotation))return t==="top"?"left":"right";let s="center";return e.align==="start"?s="left":e.align==="end"?s="right":e.align==="inner"&&(s="inner"),s}_getYAxisLabelAlignment(t){let{position:e,ticks:{crossAlign:s,mirror:n,padding:o}}=this.options,a=t+o,r=this._getLabelSizes().widest.width,l,h;return e==="left"?n?(h=this.right+o,s==="near"?l="left":s==="center"?(l="center",h+=r/2):(l="right",h+=r)):(h=this.right-a,s==="near"?l="right":s==="center"?(l="center",h-=r/2):(l="left",h=this.left)):e==="right"?n?(h=this.left+o,s==="near"?l="right":s==="center"?(l="center",h-=r/2):(l="left",h-=r)):(h=this.left+a,s==="near"?l="left":s==="center"?(l="center",h+=r/2):(l="right",h=this.right)):l="right",{textAlign:l,x:h}}_computeLabelArea(){if(this.options.ticks.mirror)return;let t=this.chart,e=this.options.position;return e==="left"||e==="right"?{top:0,left:this.left,bottom:t.height,right:this.right}:e==="top"||e==="bottom"?{top:this.top,left:0,bottom:this.bottom,right:t.width}:void 0}drawBackground(){let{ctx:t,options:{backgroundColor:e},left:s,top:n,width:o,height:a}=this;e&&(t.save(),t.fillStyle=e,t.fillRect(s,n,o,a),t.restore())}getLineWidthForValue(t){let e=this.options.grid;if(!this._isVisible()||!e.display)return 0;let s=this.ticks.findIndex(n=>n.value===t);return s>=0?e.setContext(this.getContext(s)).lineWidth:0}drawGrid(t){let e=this.options.grid,s=this.ctx,n=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t)),o,a,r=(l,h,d)=>{d.width&&d.color&&(s.save(),s.lineWidth=d.width,s.strokeStyle=d.color,s.setLineDash(d.borderDash||[]),s.lineDashOffset=d.borderDashOffset,s.beginPath(),s.moveTo(l.x,l.y),s.lineTo(h.x,h.y),s.stroke(),s.restore())};if(e.display)for(o=0,a=n.length;o{this.drawBackground(),this.drawGrid(o),this.drawTitle()}},{z:n,draw:()=>{this.drawBorder()}},{z:e,draw:o=>{this.drawLabels(o)}}]:[{z:e,draw:o=>{this.draw(o)}}]}getMatchingVisibleMetas(t){let e=this.chart.getSortedVisibleDatasetMetas(),s=this.axis+"AxisID",n=[],o,a;for(o=0,a=e.length;o{let p=f.split("."),g=p.pop(),m=[c].concat(p).join("."),b=u[f].split("."),y=b.pop(),_=b.join(".");X.route(m,g,_,y)})})(l,r.defaultRoutes),r.descriptors&&X.describe(l,r.descriptors)})(t,a,s),this.override&&X.override(t.id,t.overrides)),a}get(t){return this.items[t]}unregister(t){let e=this.items,s=t.id,n=this.scope;s in e&&delete e[s],n&&s in X[n]&&(delete X[n][s],this.override&&delete Yt[s])}}class Ba{constructor(){this.controllers=new Qe(At,"datasets",!0),this.elements=new Qe(wt,"elements"),this.plugins=new Qe(Object,"plugins"),this.scales=new Qe(Wt,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,e,s){[...e].forEach(n=>{let o=s||this._getRegistryForType(n);s||o.isForType(n)||o===this.plugins&&n.id?this._exec(t,o,n):B(n,a=>{let r=s||this._getRegistryForType(a);this._exec(t,r,a)})})}_exec(t,e,s){let n=Oe(t);N(s["before"+n],[],s),e[t](s),N(s["after"+n],[],s)}_getRegistryForType(t){for(let e=0;eo.filter(r=>!a.some(l=>r.plugin.id===l.plugin.id));this._notify(n(e,s),t,"stop"),this._notify(n(s,e),t,"start")}}function Na(i,t){return t||i!==!1?i===!0?{}:i:null}function Ha(i,{plugin:t,local:e},s,n){let o=i.pluginScopeKeys(t),a=i.getOptionScopes(s,o);return e&&t.defaults&&a.push(t.defaults),i.createResolver(a,n,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function Zi(i,t){let e=X.datasets[i]||{};return((t.datasets||{})[i]||{}).indexAxis||t.indexAxis||e.indexAxis||"x"}function Hn(i){if(i==="x"||i==="y"||i==="r")return i}function Ji(i,...t){if(Hn(i))return i;for(let s of t){let n=s.axis||((e=s.position)==="top"||e==="bottom"?"x":e==="left"||e==="right"?"y":void 0)||i.length>1&&Hn(i[0].toLowerCase());if(n)return n}var e;throw new Error(`Cannot determine type of '${i}' axis. Please provide 'axis' or 'position' option.`)}function jn(i,t,e){if(e[t+"AxisID"]===i)return{axis:t}}function ja(i,t){let e=Yt[i.type]||{scales:{}},s=t.scales||{},n=Zi(i.type,t),o=Object.create(null);return Object.keys(s).forEach(a=>{let r=s[a];if(!z(r))return console.error(`Invalid scale configuration for scale: ${a}`);if(r._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${a}`);let l=Ji(a,r,(function(c,u){if(u.data&&u.data.datasets){let f=u.data.datasets.filter(p=>p.xAxisID===c||p.yAxisID===c);if(f.length)return jn(c,"x",f[0])||jn(c,"y",f[0])}return{}})(a,i),X.scales[r.type]),h=(function(c,u){return c===u?"_index_":"_value_"})(l,n),d=e.scales||{};o[a]=Jt(Object.create(null),[{axis:l},r,d[l],d[h]])}),i.data.datasets.forEach(a=>{let r=a.type||i.type,l=a.indexAxis||Zi(r,t),h=(Yt[r]||{}).scales||{};Object.keys(h).forEach(d=>{let c=(function(f,p){let g=f;return f==="_index_"?g=p:f==="_value_"&&(g=p==="x"?"y":"x"),g})(d,l),u=a[c+"AxisID"]||c;o[u]=o[u]||Object.create(null),Jt(o[u],[{axis:c},s[u],h[d]])})}),Object.keys(o).forEach(a=>{let r=o[a];Jt(r,[X.scales[r.type],X.scale])}),o}function $n(i){let t=i.options||(i.options={});t.plugins=E(t.plugins,{}),t.scales=ja(i,t)}function Yn(i){return(i=i||{}).datasets=i.datasets||[],i.labels=i.labels||[],i}let Un=new Map,Xn=new Set;function ti(i,t){let e=Un.get(i);return e||(e=t(),Un.set(i,e),Xn.add(e)),e}let Se=(i,t,e)=>{let s=St(t,e);s!==void 0&&i.add(s)};class $a{constructor(t){this._config=(function(e){return(e=e||{}).data=Yn(e.data),$n(e),e})(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=Yn(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){let t=this._config;this.clearCache(),$n(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return ti(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,e){return ti(`${t}.transition.${e}`,()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,e){return ti(`${t}-${e}`,()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]])}pluginScopeKeys(t){let e=t.id;return ti(`${this.type}-plugin-${e}`,()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,e){let s=this._scopeCache,n=s.get(t);return n&&!e||(n=new Map,s.set(t,n)),n}getOptionScopes(t,e,s){let{options:n,type:o}=this,a=this._cachedScopes(t,s),r=a.get(e);if(r)return r;let l=new Set;e.forEach(d=>{t&&(l.add(t),d.forEach(c=>Se(l,t,c))),d.forEach(c=>Se(l,n,c)),d.forEach(c=>Se(l,Yt[o]||{},c)),d.forEach(c=>Se(l,X,c)),d.forEach(c=>Se(l,Ci,c))});let h=Array.from(l);return h.length===0&&h.push(Object.create(null)),Xn.has(e)&&a.set(e,h),h}chartOptionScopes(){let{options:t,type:e}=this;return[t,Yt[e]||{},X.datasets[e]||{},{type:e},X,Ci]}resolveNamedOptions(t,e,s,n=[""]){let o={$shared:!0},{resolver:a,subPrefixes:r}=qn(this._resolverCache,t,n),l=a;(function(h,d){let{isScriptable:c,isIndexable:u}=Ri(h);for(let f of d){let p=c(f),g=u(f),m=(g||p)&&h[f];if(p&&(Pt(m)||Ya(m))||g&&F(m))return!0}return!1})(a,e)&&(o.$shared=!1,l=Xt(a,s=Pt(s)?s():s,this.createResolver(t,s,r)));for(let h of e)o[h]=l[h];return o}createResolver(t,e,s=[""],n){let{resolver:o}=qn(this._resolverCache,t,s);return z(e)?Xt(o,e,void 0,n):o}}function qn(i,t,e){let s=i.get(t);s||(s=new Map,i.set(t,s));let n=e.join(),o=s.get(n);return o||(o={resolver:Ye(t,e),subPrefixes:e.filter(a=>!a.toLowerCase().includes("hover"))},s.set(n,o)),o}let Ya=i=>z(i)&&Object.getOwnPropertyNames(i).some(t=>Pt(i[t])),Ua=["top","bottom","left","right","chartArea"];function Kn(i,t){return i==="top"||i==="bottom"||Ua.indexOf(i)===-1&&t==="x"}function Gn(i,t){return function(e,s){return e[i]===s[i]?e[t]-s[t]:e[i]-s[i]}}function Zn(i){let t=i.chart,e=t.options.animation;t.notifyPlugins("afterRender"),N(e&&e.onComplete,[i],t)}function Xa(i){let t=i.chart,e=t.options.animation;N(e&&e.onProgress,[i],t)}function Jn(i){return Be()&&typeof i=="string"?i=document.getElementById(i):i&&i.length&&(i=i[0]),i&&i.canvas&&(i=i.canvas),i}let ei={},Qn=i=>{let t=Jn(i);return Object.values(ei).filter(e=>e.canvas===t).pop()};function qa(i,t,e){let s=Object.keys(i);for(let n of s){let o=+n;if(o>=t){let a=i[n];delete i[n],(e>0||o>t)&&(i[o+e]=a)}}}function ii(i,t,e){return i.options.clip?i[e]:t[e]}class G{static defaults=X;static instances=ei;static overrides=Yt;static registry=gt;static version="4.4.8";static getChart=Qn;static register(...t){gt.add(...t),to()}static unregister(...t){gt.remove(...t),to()}constructor(t,e){let s=this.config=new $a(e),n=Jn(t),o=Qn(n);if(o)throw new Error("Canvas is already in use. Chart with ID '"+o.id+"' must be destroyed before the canvas with ID '"+o.canvas.id+"' can be reused.");let a=s.createResolver(s.chartOptionScopes(),this.getContext());this.platform=new(s.platform||Cn(n)),this.platform.updateConfig(s);let r=this.platform.acquireContext(n,a.aspectRatio),l=r&&r.canvas,h=l&&l.height,d=l&&l.width;this.id=ht(),this.ctx=r,this.canvas=l,this.width=d,this.height=h,this._options=a,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new Wa,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=As(c=>this.update(c),a.resizeDelay||0),this._dataChanges=[],ei[this.id]=this,r&&l?(vt.listen(this,"complete",Zn),vt.listen(this,"progress",Xa),this._initialize(),this.attached&&this.update()):console.error("Failed to create chart: can't acquire context from the given item")}get aspectRatio(){let{options:{aspectRatio:t,maintainAspectRatio:e},width:s,height:n,_aspectRatio:o}=this;return I(t)?e&&o?o:n?s/n:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}get registry(){return gt}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():Ai(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return Li(this.canvas,this.ctx),this}stop(){return vt.stop(this),this}resize(t,e){vt.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){let s=this.options,n=this.canvas,o=s.maintainAspectRatio&&this.aspectRatio,a=this.platform.getMaximumSize(n,t,e,o),r=s.devicePixelRatio||this.platform.getDevicePixelRatio(),l=this.width?"resize":"attach";this.width=a.width,this.height=a.height,this._aspectRatio=this.aspectRatio,Ai(this,r,!0)&&(this.notifyPlugins("resize",{size:a}),N(s.onResize,[this,a],this),this.attached&&this._doResize(l)&&this.render())}ensureScalesHaveIDs(){B(this.options.scales||{},(t,e)=>{t.id=e})}buildOrUpdateScales(){let t=this.options,e=t.scales,s=this.scales,n=Object.keys(s).reduce((a,r)=>(a[r]=!1,a),{}),o=[];e&&(o=o.concat(Object.keys(e).map(a=>{let r=e[a],l=Ji(a,r),h=l==="r",d=l==="x";return{options:r,dposition:h?"chartArea":d?"bottom":"left",dtype:h?"radialLinear":d?"category":"linear"}}))),B(o,a=>{let r=a.options,l=r.id,h=Ji(l,r),d=E(r.type,a.dtype);r.position!==void 0&&Kn(r.position,h)===Kn(a.dposition)||(r.position=a.dposition),n[l]=!0;let c=null;l in s&&s[l].type===d?c=s[l]:(c=new(gt.getScale(d))({id:l,type:d,ctx:this.ctx,chart:this}),s[c.id]=c),c.init(r,t)}),B(n,(a,r)=>{a||delete s[r]}),B(s,a=>{it.configure(this,a,a.options),it.addBox(this,a)})}_updateMetasets(){let t=this._metasets,e=this.data.datasets.length,s=t.length;if(t.sort((n,o)=>n.index-o.index),s>e){for(let n=e;ne.length&&delete this._stacks,t.forEach((s,n)=>{e.filter(o=>o===s._dataset).length===0&&this._destroyDatasetMeta(n)})}buildOrUpdateControllers(){let t=[],e=this.data.datasets,s,n;for(this._removeUnreferencedMetasets(),s=0,n=e.length;s{this.getDatasetMeta(e).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){let e=this.config;e.update();let s=this._options=e.createResolver(e.chartOptionScopes(),this.getContext()),n=this._animationsDisabled=!s.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0})===!1)return;let o=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let a=0;for(let h=0,d=this.data.datasets.length;h{h.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(Gn("z","_idx"));let{_active:r,_lastEvent:l}=this;l?this._eventHandler(l,!0):r.length&&this._updateHoverStyles(r,r,!0),this.render()}_updateScales(){B(this.scales,t=>{it.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){let t=this.options,e=new Set(Object.keys(this._listeners)),s=new Set(t.events);ci(e,s)&&!!this._responsiveListeners===t.responsive||(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){let{_hiddenIndices:t}=this,e=this._getUniformDataChanges()||[];for(let{method:s,start:n,count:o}of e)qa(t,n,s==="_removeElements"?-o:o)}_getUniformDataChanges(){let t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];let e=this.data.datasets.length,s=o=>new Set(t.filter(a=>a[0]===o).map((a,r)=>r+","+a.splice(1).join(","))),n=s(0);for(let o=1;oo.split(",")).map(o=>({method:o[1],start:+o[2],count:+o[3]}))}_updateLayout(t){if(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;it.update(this,this.width,this.height,t);let e=this.chartArea,s=e.width<=0||e.height<=0;this._layers=[],B(this.boxes,n=>{s&&n.position==="chartArea"||(n.configure&&n.configure(),this._layers.push(...n._layers()))},this),this._layers.forEach((n,o)=>{n._idx=o}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})!==!1){for(let e=0,s=this.data.datasets.length;e=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){let e=this.ctx,s=t._clip,n=!s.disabled,o=(function(r,l){let{xScale:h,yScale:d}=r;return h&&d?{left:ii(h,l,"left"),right:ii(h,l,"right"),top:ii(d,l,"top"),bottom:ii(d,l,"bottom")}:l})(t,this.chartArea),a={meta:t,index:t.index,cancelable:!0};this.notifyPlugins("beforeDatasetDraw",a)!==!1&&(n&&me(e,{left:s.left===!1?0:o.left-s.left,right:s.right===!1?this.width:o.right+s.right,top:s.top===!1?0:o.top-s.top,bottom:s.bottom===!1?this.height:o.bottom+s.bottom}),t.controller.draw(),n&&be(e),a.cancelable=!1,this.notifyPlugins("afterDatasetDraw",a))}isPointInArea(t){return Mt(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,e,s,n){let o=mn.modes[e];return typeof o=="function"?o(this,t,s,n):[]}getDatasetMeta(t){let e=this.data.datasets[t],s=this._metasets,n=s.filter(o=>o&&o._dataset===e).pop();return n||(n={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e&&e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1},s.push(n)),n}getContext(){return this.$context||(this.$context=Ot(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){let e=this.data.datasets[t];if(!e)return!1;let s=this.getDatasetMeta(t);return typeof s.hidden=="boolean"?!s.hidden:!e.hidden}setDatasetVisibility(t,e){this.getDatasetMeta(t).hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,s){let n=s?"show":"hide",o=this.getDatasetMeta(t),a=o.controller._resolveAnimations(void 0,n);Qt(e)?(o.data[e].hidden=!s,this.update()):(this.setDatasetVisibility(t,s),a.update(o,{visible:s}),this.update(r=>r.datasetIndex===t?n:void 0))}hide(t,e){this._updateVisibility(t,e,!1)}show(t,e){this._updateVisibility(t,e,!0)}_destroyDatasetMeta(t){let e=this._metasets[t];e&&e.controller&&e.controller._destroy(),delete this._metasets[t]}_stop(){let t,e;for(this.stop(),vt.remove(this),t=0,e=this.data.datasets.length;t{e.addEventListener(this,o,a),t[o]=a},n=(o,a,r)=>{o.offsetX=a,o.offsetY=r,this._eventHandler(o)};B(this.options.events,o=>s(o,n))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});let t=this._responsiveListeners,e=this.platform,s=(l,h)=>{e.addEventListener(this,l,h),t[l]=h},n=(l,h)=>{t[l]&&(e.removeEventListener(this,l,h),delete t[l])},o=(l,h)=>{this.canvas&&this.resize(l,h)},a,r=()=>{n("attach",r),this.attached=!0,this.resize(),s("resize",o),s("detach",a)};a=()=>{this.attached=!1,n("resize",o),this._stop(),this._resize(0,0),s("attach",r)},e.isAttached(this.canvas)?r():a()}unbindEvents(){B(this._listeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._listeners={},B(this._responsiveListeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,e,s){let n=s?"set":"remove",o,a,r,l;for(e==="dataset"&&(o=this.getDatasetMeta(t[0].datasetIndex),o.controller["_"+n+"DatasetHoverStyle"]()),r=0,l=t.length;r{let a=this.getDatasetMeta(n);if(!a)throw new Error("No dataset found at index "+n);return{datasetIndex:n,element:a.data[o],index:o}});!Ht(s,e)&&(this._active=s,this._lastEvent=null,this._updateHoverStyles(s,e))}notifyPlugins(t,e,s){return this._plugins.notify(this,t,e,s)}isPluginEnabled(t){return this._plugins._cache.filter(e=>e.plugin.id===t).length===1}_updateHoverStyles(t,e,s){let n=this.options.hover,o=(l,h)=>l.filter(d=>!h.some(c=>d.datasetIndex===c.datasetIndex&&d.index===c.index)),a=o(e,t),r=s?t:o(t,e);a.length&&this.updateHoverStyle(a,n.mode,!1),r.length&&n.mode&&this.updateHoverStyle(r,n.mode,!0)}_eventHandler(t,e){let s={event:t,replay:e,cancelable:!0,inChartArea:this.isPointInArea(t)},n=a=>(a.options.events||this.options.events).includes(t.native.type);if(this.notifyPlugins("beforeEvent",s,n)===!1)return;let o=this._handleEvent(t,e,s.inChartArea);return s.cancelable=!1,this.notifyPlugins("afterEvent",s,n),(o||s.changed)&&this.render(),this}_handleEvent(t,e,s){let{_active:n=[],options:o}=this,a=e,r=this._getActiveElements(t,n,s,a),l=_s(t),h=(function(c,u,f,p){return f&&c.type!=="mouseout"?p?u:c:null})(t,this._lastEvent,s,l);s&&(this._lastEvent=null,N(o.onHover,[t,r,this],this),l&&N(o.onClick,[t,r,this],this));let d=!Ht(r,n);return(d||e)&&(this._active=r,this._updateHoverStyles(r,n,e)),this._lastEvent=h,d}_getActiveElements(t,e,s,n){if(t.type==="mouseout")return[];if(!s)return e;let o=this.options.hover;return this.getElementsAtEventForMode(t,o.mode,o,n)}}function to(){return B(G.instances,i=>i._plugins.invalidate())}function Kt(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class Qi{static override(t){Object.assign(Qi.prototype,t)}options;constructor(t){this.options=t||{}}init(){}formats(){return Kt()}parse(){return Kt()}format(){return Kt()}add(){return Kt()}diff(){return Kt()}startOf(){return Kt()}endOf(){return Kt()}}var eo={_date:Qi};function Ka(i){let t=i.iScale,e=(function(h,d){if(!h._cache.$bar){let c=h.getMatchingVisibleMetas(d),u=[];for(let f=0,p=c.length;ff-p))}return h._cache.$bar})(t,i.type),s,n,o,a,r=t._length,l=()=>{o!==32767&&o!==-32768&&(Qt(a)&&(r=Math.min(r,Math.abs(o-a)||r)),a=o)};for(s=0,n=e.length;sMath.abs(c)&&(u=c,f=d),o[a.axis]=f,o._custom={barStart:u,barEnd:f,start:l,end:h,min:d,max:c}})(i,t,e,s):t[e.axis]=e.parse(i,s),t}function so(i,t,e,s){let n=i.iScale,o=i.vScale,a=n.getLabels(),r=n===o,l=[],h,d,c,u;for(h=e,d=e+s;hc.x,f="left",p="right"):(u=c.baset!=="spacing",_indexable:t=>t!=="spacing"&&!t.startsWith("borderDash")&&!t.startsWith("hoverBorderDash")};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){let e=t.data;if(e.labels.length&&e.datasets.length){let{labels:{pointStyle:s,color:n}}=t.legend.options;return e.labels.map((o,a)=>{let r=t.getDatasetMeta(0).controller.getStyle(a);return{text:o,fillStyle:r.backgroundColor,strokeStyle:r.borderColor,fontColor:n,lineWidth:r.borderWidth,pointStyle:s,hidden:!t.getDataVisibility(a),index:a}})}return[]}},onClick(t,e,s){s.chart.toggleDataVisibility(e.index),s.chart.update()}}}};constructor(t,e){super(t,e),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,e){let s=this.getDataset().data,n=this._cachedMeta;if(this._parsing===!1)n._parsed=s;else{let o,a,r=l=>+s[l];if(z(s[t])){let{key:l="value"}=this._parsing;r=h=>+St(s[h],l)}for(o=t,a=t+e;oee(mt,A,P,!0)?1:Math.max(bt,bt*w,xt,xt*w),st=(mt,bt,xt)=>ee(mt,A,P,!0)?-1:Math.min(bt,bt*w,xt,xt*w),rt=V(0,O,R),lt=V(K,C,H),ut=st(Y,O,R),pt=st(Y+K,C,H);k=(rt-ut)/2,D=(lt-pt)/2,S=-(rt+ut)/2,T=-(lt+pt)/2}return{ratioX:k,ratioY:D,offsetX:S,offsetY:T}})(c,d,l),m=(s.width-a)/u,b=(s.height-a)/f,y=Math.max(Math.min(m,b)/2,0),_=Z(this.options.radius,y),x=(_-Math.max(_*l,0))/this._getVisibleDatasetWeightTotal();this.offsetX=p*_,this.offsetY=g*_,n.total=this.calculateTotal(),this.outerRadius=_-x*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-x*h,0),this.updateElements(o,0,o.length,t)}_circumference(t,e){let s=this.options,n=this._cachedMeta,o=this._getCircumference();return e&&s.animation.animateRotate||!this.chart.getDataVisibility(t)||n._parsed[t]===null||n.data[t].hidden?0:this.calculateCircumference(n._parsed[t]*o/U)}updateElements(t,e,s,n){let o=n==="reset",a=this.chart,r=a.chartArea,l=a.options.animation,h=(r.left+r.right)/2,d=(r.top+r.bottom)/2,c=o&&l.animateScale,u=c?0:this.innerRadius,f=c?0:this.outerRadius,{sharedOptions:p,includeOptions:g}=this._getSharedOptions(e,n),m,b=this._getRotation();for(m=0;m0&&!isNaN(t)?U*(Math.abs(t)/e):0}getLabelAndValue(t){let e=this._cachedMeta,s=this.chart,n=s.data.labels||[],o=se(e._parsed[t],s.options.locale);return{label:n[t]||"",value:o}}getMaxBorderWidth(t){let e=0,s=this.chart,n,o,a,r,l;if(!t){for(n=0,o=s.data.datasets.length;n{let r=t.getDatasetMeta(0).controller.getStyle(a);return{text:o,fillStyle:r.backgroundColor,strokeStyle:r.borderColor,fontColor:n,lineWidth:r.borderWidth,pointStyle:s,hidden:!t.getDataVisibility(a),index:a}})}return[]}},onClick(t,e,s){s.chart.toggleDataVisibility(e.index),s.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){let e=this._cachedMeta,s=this.chart,n=s.data.labels||[],o=se(e._parsed[t].r,s.options.locale);return{label:n[t]||"",value:o}}parseObjectData(t,e,s,n){return Fi.bind(this)(t,e,s,n)}update(t){let e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,e.length,t)}getMinMax(){let t=this._cachedMeta,e={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return t.data.forEach((s,n)=>{let o=this.getParsed(n).r;!isNaN(o)&&this.chart.getDataVisibility(n)&&(oe.max&&(e.max=o))}),e}_updateRadius(){let t=this.chart,e=t.chartArea,s=t.options,n=Math.min(e.right-e.left,e.bottom-e.top),o=Math.max(n/2,0),a=(o-Math.max(s.cutoutPercentage?o/100*s.cutoutPercentage:1,0))/t.getVisibleDatasetCount();this.outerRadius=o-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(t,e,s,n){let o=n==="reset",a=this.chart,r=a.options.animation,l=this._cachedMeta.rScale,h=l.xCenter,d=l.yCenter,c=l.getIndexAngle(0)-.5*Y,u,f=c,p=360/this.countVisibleElements();for(u=0;u{!isNaN(this.getParsed(n).r)&&this.chart.getDataVisibility(n)&&e++}),e}_computeAngle(t,e,s){return this.chart.getDataVisibility(t)?ct(this.resolveDataElementOptions(t,e).angle||s):0}}var ro=Object.freeze({__proto__:null,BarController:class extends At{static id="bar";static defaults={datasetElementType:!1,dataElementType:"bar",categoryPercentage:.8,barPercentage:.9,grouped:!0,animations:{numbers:{type:"number",properties:["x","y","base","width","height"]}}};static overrides={scales:{_index_:{type:"category",offset:!0,grid:{offset:!0}},_value_:{type:"linear",beginAtZero:!0}}};parsePrimitiveData(i,t,e,s){return so(i,t,e,s)}parseArrayData(i,t,e,s){return so(i,t,e,s)}parseObjectData(i,t,e,s){let{iScale:n,vScale:o}=i,{xAxisKey:a="x",yAxisKey:r="y"}=this._parsing,l=n.axis==="x"?a:r,h=o.axis==="x"?a:r,d=[],c,u,f,p;for(c=e,u=e+s;ch.controller.options.grouped),n=e.options.stacked,o=[],a=this._cachedMeta.controller.getParsed(t),r=a&&a[e.axis],l=h=>{let d=h._parsed.find(u=>u[e.axis]===r),c=d&&d[h.vScale.axis];if(I(c)||isNaN(c))return!0};for(let h of s)if((t===void 0||!l(h))&&((n===!1||o.indexOf(h.stack)===-1||n===void 0&&h.stack===void 0)&&o.push(h.stack),h.index===i))break;return o.length||o.push(void 0),o}_getStackCount(i){return this._getStacks(void 0,i).length}_getStackIndex(i,t,e){let s=this._getStacks(i,e),n=t!==void 0?s.indexOf(t):-1;return n===-1?s.length-1:n}_getRuler(){let i=this.options,t=this._cachedMeta,e=t.iScale,s=[],n,o;for(n=0,o=t.data.length;n=w?1:-1)})(c,t,a)*o,u===a&&(m-=c/2);let b=t.getPixelForDecimal(0),y=t.getPixelForDecimal(1),_=Math.min(b,y),x=Math.max(b,y);m=Math.max(Math.min(m,x),_),d=m+c,e&&!h&&(r._stacks[t.axis]._visualValues[s]=t.getValueForPixel(d)-t.getValueForPixel(m))}if(m===t.getPixelForValue(a)){let b=ft(c)*t.getLineWidthForValue(a)/2;m+=b,c-=b}return{size:c,base:m,head:d,center:d+c/2}}_calculateBarIndexPixels(i,t){let e=t.scale,s=this.options,n=s.skipNull,o=E(s.maxBarThickness,1/0),a,r;if(t.grouped){let l=n?this._getStackCount(i):t.stackCount,h=s.barThickness==="flex"?(function(c,u,f,p){let g=u.pixels,m=g[c],b=c>0?g[c-1]:null,y=c=0;--e)t=Math.max(t,i[e].size(this.resolveDataElementOptions(e))/2);return t>0&&t}getLabelAndValue(i){let t=this._cachedMeta,e=this.chart.data.labels||[],{xScale:s,yScale:n}=t,o=this.getParsed(i),a=s.getLabelForValue(o.x),r=n.getLabelForValue(o.y),l=o._custom;return{label:e[i]||"",value:"("+a+", "+r+(l?", "+l:"")+")"}}update(i){let t=this._cachedMeta.data;this.updateElements(t,0,t.length,i)}updateElements(i,t,e,s){let n=s==="reset",{iScale:o,vScale:a}=this._cachedMeta,{sharedOptions:r,includeOptions:l}=this._getSharedOptions(t,s),h=o.axis,d=a.axis;for(let c=t;c0&&this.getParsed(t-1);for(let x=0;x=b){M.skip=!0;continue}let w=this.getParsed(x),k=I(w[u]),D=M[c]=o.getPixelForValue(w[c],x),S=M[u]=n||k?a.getBasePixel():a.getPixelForValue(r?this.applyStack(a,w,r):w[u],x);M.skip=isNaN(D)||isNaN(S)||k,M.stop=x>0&&Math.abs(w[c]-_[c])>g,p&&(M.parsed=w,M.raw=l.data[x]),d&&(M.options=h||this.resolveDataElementOptions(x,v.active?"active":s)),m||this.updateElement(v,x,M,s),_=w}}getMaxOverflow(){let i=this._cachedMeta,t=i.dataset,e=t.options&&t.options.borderWidth||0,s=i.data||[];if(!s.length)return e;let n=s[0].size(this.resolveDataElementOptions(0)),o=s[s.length-1].size(this.resolveDataElementOptions(s.length-1));return Math.max(e,n,o)/2}draw(){let i=this._cachedMeta;i.dataset.updateControlPoints(this.chart.chartArea,i.iScale.axis),super.draw()}},PieController:class extends es{static id="pie";static defaults={cutout:0,rotation:0,circumference:360,radius:"100%"}},PolarAreaController:ao,RadarController:class extends At{static id="radar";static defaults={datasetElementType:"line",dataElementType:"point",indexAxis:"r",showLine:!0,elements:{line:{fill:"start"}}};static overrides={aspectRatio:1,scales:{r:{type:"radialLinear"}}};getLabelAndValue(i){let t=this._cachedMeta.vScale,e=this.getParsed(i);return{label:t.getLabels()[i],value:""+t.getLabelForValue(e[t.axis])}}parseObjectData(i,t,e,s){return Fi.bind(this)(i,t,e,s)}update(i){let t=this._cachedMeta,e=t.dataset,s=t.data||[],n=t.iScale.getLabels();if(e.points=s,i!=="resize"){let o=this.resolveDatasetElementOptions(i);this.options.showLine||(o.borderWidth=0);let a={_loop:!0,_fullLoop:n.length===s.length,options:o};this.updateElement(e,void 0,a,i)}this.updateElements(s,0,s.length,i)}updateElements(i,t,e,s){let n=this._cachedMeta.rScale,o=s==="reset";for(let a=t;a0&&this.getParsed(t-1);for(let _=t;_0&&Math.abs(v[u]-y[u])>m,g&&(M.parsed=v,M.raw=l.data[_]),c&&(M.options=d||this.resolveDataElementOptions(_,x.active?"active":s)),b||this.updateElement(x,_,M,s),y=v}this.updateSharedOptions(d,s,h)}getMaxOverflow(){let i=this._cachedMeta,t=i.data||[];if(!this.options.showLine){let a=0;for(let r=t.length-1;r>=0;--r)a=Math.max(a,t[r].size(this.resolveDataElementOptions(r))/2);return a>0&&a}let e=i.dataset,s=e.options&&e.options.borderWidth||0;if(!t.length)return s;let n=t[0].size(this.resolveDataElementOptions(0)),o=t[t.length-1].size(this.resolveDataElementOptions(t.length-1));return Math.max(s,n,o)/2}}});function Ja(i,t,e,s){let n=qe(i.options.borderRadius,["outerStart","outerEnd","innerStart","innerEnd"]),o=(e-t)/2,a=Math.min(o,s*t/2),r=l=>{let h=(e-Math.min(o,l))*s/2;return Q(l,0,Math.min(o,h))};return{outerStart:r(n.outerStart),outerEnd:r(n.outerEnd),innerStart:Q(n.innerStart,0,a),innerEnd:Q(n.innerEnd,0,a)}}function le(i,t,e,s){return{x:e+i*Math.cos(t),y:s+i*Math.sin(t)}}function si(i,t,e,s,n,o){let{x:a,y:r,startAngle:l,pixelMargin:h,innerRadius:d}=t,c=Math.max(t.outerRadius+s+e-h,0),u=d>0?d+s+e+h:0,f=0,p=n-l;if(s){let O=((d>0?d-s:0)+(c>0?c-s:0))/2;f=(p-(O!==0?p*O/(O+s):p))/2}let g=(p-Math.max(.001,p*c-e/Y)/c)/2,m=l+g+f,b=n-g-f,{outerStart:y,outerEnd:_,innerStart:x,innerEnd:v}=Ja(t,u,c,b-m),M=c-y,w=c-_,k=m+y/M,D=b-_/w,S=u+x,T=u+v,A=m+x/S,P=b-v/T;if(i.beginPath(),o){let O=(k+D)/2;if(i.arc(a,r,c,k,O),i.arc(a,r,c,O,D),_>0){let V=le(w,D,a,r);i.arc(V.x,V.y,_,D,b+K)}let C=le(T,b,a,r);if(i.lineTo(C.x,C.y),v>0){let V=le(T,P,a,r);i.arc(V.x,V.y,v,b+K,P+Math.PI)}let R=(b-v/u+(m+x/u))/2;if(i.arc(a,r,u,b-v/u,R,!0),i.arc(a,r,u,R,m+x/u,!0),x>0){let V=le(S,A,a,r);i.arc(V.x,V.y,x,A+Math.PI,m-K)}let H=le(M,m,a,r);if(i.lineTo(H.x,H.y),y>0){let V=le(M,k,a,r);i.arc(V.x,V.y,y,m-K,k)}}else{i.moveTo(a,r);let O=Math.cos(k)*c+a,C=Math.sin(k)*c+r;i.lineTo(O,C);let R=Math.cos(D)*c+a,H=Math.sin(D)*c+r;i.lineTo(R,H)}i.closePath()}function Qa(i,t,e,s,n){let{fullCircles:o,startAngle:a,circumference:r,options:l}=t,{borderWidth:h,borderJoinStyle:d,borderDash:c,borderDashOffset:u}=l,f=l.borderAlign==="inner";if(!h)return;i.setLineDash(c||[]),i.lineDashOffset=u,f?(i.lineWidth=2*h,i.lineJoin=d||"round"):(i.lineWidth=h,i.lineJoin=d||"bevel");let p=t.endAngle;if(o){si(i,t,e,s,p,n);for(let g=0;g_?(k=_/w,g.arc(x,v,w,b+k,y-k,!0)):g.arc(x,v,_,b+K,y-K),g.closePath(),g.clip()})(i,t,p),o||(si(i,t,e,s,p,n),i.stroke())}function lo(i,t,e=t){i.lineCap=E(e.borderCapStyle,t.borderCapStyle),i.setLineDash(E(e.borderDash,t.borderDash)),i.lineDashOffset=E(e.borderDashOffset,t.borderDashOffset),i.lineJoin=E(e.borderJoinStyle,t.borderJoinStyle),i.lineWidth=E(e.borderWidth,t.borderWidth),i.strokeStyle=E(e.borderColor,t.borderColor)}function tr(i,t,e){i.lineTo(e.x,e.y)}function ho(i,t,e={}){let s=i.length,{start:n=0,end:o=s-1}=e,{start:a,end:r}=t,l=Math.max(n,a),h=Math.min(o,r),d=nr&&o>r;return{count:s,start:l,loop:t.loop,ilen:h(a+(h?r-x:x))%o,_=()=>{f!==p&&(i.lineTo(m,p),i.lineTo(m,f),i.lineTo(m,g))};for(l&&(c=n[y(0)],i.moveTo(c.x,c.y)),d=0;d<=r;++d){if(c=n[y(d)],c.skip)continue;let x=c.x,v=c.y,M=0|x;M===u?(vp&&(p=v),m=(b*m+x)/++b):(_(),i.lineTo(x,v),u=M,b=0,f=p=v),g=v}_()}function is(i){let t=i.options,e=t.borderDash&&t.borderDash.length;return i._decimated||i._loop||t.tension||t.cubicInterpolationMode==="monotone"||t.stepped||e?er:ir}let sr=typeof Path2D=="function";function nr(i,t,e,s){sr&&!t.options.segment?(function(n,o,a,r){let l=o._path;l||(l=o._path=new Path2D,o.path(l,a,r)&&l.closePath()),lo(n,o.options),n.stroke(l)})(i,t,e,s):(function(n,o,a,r){let{segments:l,options:h}=o,d=is(o);for(let c of l)lo(n,h,c.style),n.beginPath(),d(n,o,c,{start:a,end:a+r-1})&&n.closePath(),n.stroke()})(i,t,e,s)}class ni extends wt{static id="line";static defaults={borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:"default",fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};static descriptors={_scriptable:!0,_indexable:t=>t!=="borderDash"&&t!=="fill"};constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,e){let s=this.options;if((s.tension||s.cubicInterpolationMode==="monotone")&&!s.stepped&&!this._pointsUpdated){let n=s.spanGaps?this._loop:this._fullLoop;sn(this._points,s,t,n,e),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=un(this,this.options.segment))}first(){let t=this.segments,e=this.points;return t.length&&e[t[0].start]}last(){let t=this.segments,e=this.points,s=t.length;return s&&e[t[s-1].end]}interpolate(t,e){let s=this.options,n=t[e],o=this.points,a=Hi(this,{property:e,start:n,end:n});if(!a.length)return;let r=[],l=(function(c){return c.stepped?an:c.tension||c.cubicInterpolationMode==="monotone"?rn:Vt})(s),h,d;for(h=0,d=a.length;hi!=="borderDash"};circumference;endAngle;fullCircles;innerRadius;outerRadius;pixelMargin;startAngle;constructor(i){super(),this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,i&&Object.assign(this,i)}inRange(i,t,e){let s=this.getProps(["x","y"],e),{angle:n,distance:o}=pi(s,{x:i,y:t}),{startAngle:a,endAngle:r,innerRadius:l,outerRadius:h,circumference:d}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],e),c=(this.options.spacing+this.options.borderWidth)/2,u=E(d,r-a),f=ee(n,a,r)&&a!==r,p=u>=U||f,g=_t(o,l+c,h+c);return p&&g}getCenterPoint(i){let{x:t,y:e,startAngle:s,endAngle:n,innerRadius:o,outerRadius:a}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],i),{offset:r,spacing:l}=this.options,h=(s+n)/2,d=(o+a+l+r)/2;return{x:t+Math.cos(h)*d,y:e+Math.sin(h)*d}}tooltipPosition(i){return this.getCenterPoint(i)}draw(i){let{options:t,circumference:e}=this,s=(t.offset||0)/4,n=(t.spacing||0)/2,o=t.circular;if(this.pixelMargin=t.borderAlign==="inner"?.33:0,this.fullCircles=e>U?Math.floor(e/U):0,e===0||this.innerRadius<0||this.outerRadius<0)return;i.save();let a=(this.startAngle+this.endAngle)/2;i.translate(Math.cos(a)*s,Math.sin(a)*s);let r=s*(1-Math.sin(Math.min(Y,e||0)));i.fillStyle=t.backgroundColor,i.strokeStyle=t.borderColor,(function(l,h,d,c,u){let{fullCircles:f,startAngle:p,circumference:g}=h,m=h.endAngle;if(f){si(l,h,d,c,m,u);for(let b=0;b(typeof a=="string"?(r=o.push(a)-1,l.unshift({index:r,label:a})):isNaN(a)&&(r=null),r))(i,t,e,s):n!==i.lastIndexOf(t)?e:n}function fo(i){let t=this.getLabels();return i>=0&&in=e?n:l,r=l=>o=s?o:l;if(t){let l=ft(n),h=ft(o);l<0&&h<0?r(0):l>0&&h>0&&a(0)}if(n===o){let l=o===0?1:Math.abs(.05*o);r(o+l),t||a(n-l)}this.min=n,this.max=o}getTickLimit(){let t=this.options.ticks,e,{maxTicksLimit:s,stepSize:n}=t;return n?(e=Math.ceil(this.max/n)-Math.floor(this.min/n)+1,e>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${n} would result generating up to ${e} ticks. Limiting to 1000.`),e=1e3)):(e=this.computeTickLimit(),s=s||11),s&&(e=Math.min(s,e)),e}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){let t=this.options,e=t.ticks,s=this.getTickLimit();s=Math.max(2,s);let n=(function(o,a){let r=[],{bounds:l,step:h,min:d,max:c,precision:u,count:f,maxTicks:p,maxDigits:g,includeBounds:m}=o,b=h||1,y=p-1,{min:_,max:x}=a,v=!I(d),M=!I(c),w=!I(f),k=(x-_)/(g+1),D,S,T,A,P=ui((x-_)/y/b)*b;if(P<1e-14&&!v&&!M)return[{value:_},{value:x}];A=Math.ceil(x/P)-Math.floor(_/P),A>y&&(P=ui(A*P/y/b)*b),I(u)||(D=Math.pow(10,u),P=Math.ceil(P*D)/D),l==="ticks"?(S=Math.floor(_/P)*P,T=Math.ceil(x/P)*P):(S=_,T=x),v&&M&&h&&ws((c-d)/h,P/1e3)?(A=Math.round(Math.min((c-d)/P,p)),P=(c-d)/A,S=d,T=c):w?(S=v?d:S,T=M?c:T,A=f-1,P=(T-S)/A):(A=(T-S)/P,A=te(A,Math.round(A),P/1e3)?Math.round(A):Math.ceil(A));let O=Math.max(gi(P),gi(S));D=Math.pow(10,I(u)?O:u),S=Math.round(S*D)/D,T=Math.round(T*D)/D;let C=0;for(v&&(m&&S!==d?(r.push({value:d}),Sc)break;r.push({value:R})}return M&&m&&T!==c?r.length&&te(r[r.length-1].value,c,go(c,k,o))?r[r.length-1].value=c:r.push({value:c}):M&&T!==c||r.push({value:T}),r})({maxTicks:s,bounds:t.bounds,min:t.min,max:t.max,precision:e.precision,step:e.stepSize,count:e.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:e.minRotation||0,includeBounds:e.includeBounds!==!1},this._range||this);return t.bounds==="ticks"&&fi(n,this,"value"),t.reverse?(n.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),n}configure(){let t=this.ticks,e=this.min,s=this.max;if(super.configure(),this.options.offset&&t.length){let n=(s-e)/Math.max(t.length-1,1)/2;e-=n,s+=n}this._startValue=e,this._endValue=s,this._valueRange=s-e}getLabelForValue(t){return se(t,this.chart.options.locale,this.options.ticks.format)}}class lr extends oi{static id="linear";static defaults={ticks:{callback:fe.formatters.numeric}};determineDataLimits(){let{min:t,max:e}=this.getMinMax(!0);this.min=L(t)?t:0,this.max=L(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){let t=this.isHorizontal(),e=t?this.width:this.height,s=ct(this.options.ticks.minRotation),n=(t?Math.sin(s):Math.cos(s))||.001,o=this._resolveTickFontOptions(0);return Math.ceil(e/Math.min(40,o.lineHeight/n))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}let Pe=i=>Math.floor(Dt(i)),Gt=(i,t)=>Math.pow(10,Pe(i)+t);function po(i){return i/Math.pow(10,Pe(i))===1}function mo(i,t,e){let s=Math.pow(10,e),n=Math.floor(i/s);return Math.ceil(t/s)-n}function hr(i,{min:t,max:e}){t=q(i.min,t);let s=[],n=Pe(t),o=(function(p,g){let m=Pe(g-p);for(;mo(p,g,m)>10;)m++;for(;mo(p,g,m)<10;)m--;return Math.min(m,Pe(p))})(t,e),a=o<0?Math.pow(10,Math.abs(o)):1,r=Math.pow(10,o),l=n>o?Math.pow(10,n):0,h=Math.round((t-l)*a)/a,d=Math.floor((t-l)/r/10)*r*10,c=Math.floor((h-d)/Math.pow(10,o)),u=q(i.min,Math.round((l+d+c*Math.pow(10,o))*a)/a);for(;u=10?c=c<15?15:20:c++,c>=20&&(o++,c=2,a=o>=0?1:a),u=Math.round((l+d+c*Math.pow(10,o))*a)/a;let f=q(i.max,u);return s.push({value:f,major:po(f),significand:c}),s}class cr extends Wt{static id="logarithmic";static defaults={ticks:{callback:fe.formatters.logarithmic,major:{enabled:!0}}};constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,e){let s=oi.prototype.parse.apply(this,[t,e]);if(s!==0)return L(s)&&s>0?s:null;this._zero=!0}determineDataLimits(){let{min:t,max:e}=this.getMinMax(!0);this.min=L(t)?Math.max(0,t):null,this.max=L(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!L(this._userMin)&&(this.min=t===Gt(this.min,0)?Gt(this.min,-1):Gt(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){let{minDefined:t,maxDefined:e}=this.getUserBounds(),s=this.min,n=this.max,o=r=>s=t?s:r,a=r=>n=e?n:r;s===n&&(s<=0?(o(1),a(10)):(o(Gt(s,-1)),a(Gt(n,1)))),s<=0&&o(Gt(n,-1)),n<=0&&a(Gt(s,1)),this.min=s,this.max=n}buildTicks(){let t=this.options,e=hr({min:this._userMin,max:this._userMax},this);return t.bounds==="ticks"&&fi(e,this,"value"),t.reverse?(e.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),e}getLabelForValue(t){return t===void 0?"0":se(t,this.chart.options.locale,this.options.ticks.format)}configure(){let t=this.min;super.configure(),this._startValue=Dt(t),this._valueRange=Dt(this.max)-Dt(t)}getPixelForValue(t){return t!==void 0&&t!==0||(t=this.min),t===null||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(Dt(t)-this._startValue)/this._valueRange)}getValueForPixel(t){let e=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+e*this._valueRange)}}function as(i){let t=i.ticks;if(t.display&&i.display){let e=et(t.backdropPadding);return E(t.font&&t.font.size,X.font.size)+e.height}return 0}function bo(i,t,e,s,n){return i===s||i===n?{start:t-e/2,end:t+e/2}:in?{start:t-e,end:t}:{start:t,end:t+e}}function dr(i){let t={l:i.left+i._padding.left,r:i.right-i._padding.right,t:i.top+i._padding.top,b:i.bottom-i._padding.bottom},e=Object.assign({},t),s=[],n=[],o=i._pointLabels.length,a=i.options.pointLabels,r=a.centerPointLabels?Y/o:0;for(let c=0;ct.r&&(r=(s.end-t.r)/o,i.r=Math.max(i.r,t.r+r)),n.startt.b&&(l=(n.end-t.b)/a,i.b=Math.max(i.b,t.b+l))}function fr(i,t,e){let s=i.drawingArea,{extra:n,additionalAngle:o,padding:a,size:r}=e,l=i.getPointPosition(t,s+n+a,o),h=Math.round(Ae(nt(l.angle+K))),d=(function(f,p,g){return g===90||g===270?f-=p/2:(g>270||g<90)&&(f-=p),f})(l.y,r.h,h),c=(function(f){return f===0||f===180?"center":f<180?"left":"right"})(h),u=(function(f,p,g){return g==="right"?f-=p:g==="center"&&(f-=p/2),f})(l.x,r.w,c);return{visible:!0,x:l.x,y:d,textAlign:c,left:u,top:d,right:u+r.w,bottom:d+r.h}}function gr(i,t){if(!t)return!0;let{left:e,top:s,right:n,bottom:o}=i;return!(Mt({x:e,y:s},t)||Mt({x:e,y:o},t)||Mt({x:n,y:s},t)||Mt({x:n,y:o},t))}function pr(i,t,e){let{left:s,top:n,right:o,bottom:a}=e,{backdropColor:r}=t;if(!I(r)){let l=Bt(t.borderRadius),h=et(t.backdropPadding);i.fillStyle=r;let d=s-h.left,c=n-h.top,u=o-s+h.width,f=a-n+h.height;Object.values(l).some(p=>p!==0)?(i.beginPath(),ne(i,{x:d,y:c,w:u,h:f,radius:l}),i.fill()):i.fillRect(d,c,u,f)}}function xo(i,t,e,s){let{ctx:n}=i;if(e)n.arc(i.xCenter,i.yCenter,t,0,U);else{let o=i.getPointPosition(0,t);n.moveTo(o.x,o.y);for(let a=1;at,padding:5,centerPointLabels:!1}};static defaultRoutes={"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"};static descriptors={angleLines:{_fallback:"grid"}};constructor(t){super(t),this.xCenter=void 0,this.yCenter=void 0,this.drawingArea=void 0,this._pointLabels=[],this._pointLabelItems=[]}setDimensions(){let t=this._padding=et(as(this.options)/2),e=this.width=this.maxWidth-t.width,s=this.height=this.maxHeight-t.height;this.xCenter=Math.floor(this.left+e/2+t.left),this.yCenter=Math.floor(this.top+s/2+t.top),this.drawingArea=Math.floor(Math.min(e,s)/2)}determineDataLimits(){let{min:t,max:e}=this.getMinMax(!1);this.min=L(t)&&!isNaN(t)?t:0,this.max=L(e)&&!isNaN(e)?e:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/as(this.options))}generateTickLabels(t){oi.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map((e,s)=>{let n=N(this.options.pointLabels.callback,[e,s],this);return n||n===0?n:""}).filter((e,s)=>this.chart.getDataVisibility(s))}fit(){let t=this.options;t.display&&t.pointLabels.display?dr(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,e,s,n){this.xCenter+=Math.floor((t-e)/2),this.yCenter+=Math.floor((s-n)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,e,s,n))}getIndexAngle(t){return nt(t*(U/(this._pointLabels.length||1))+ct(this.options.startAngle||0))}getDistanceFromCenterForValue(t){if(I(t))return NaN;let e=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*e:(t-this.min)*e}getValueForDistanceFromCenter(t){if(I(t))return NaN;let e=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-e:this.min+e}getPointLabelContext(t){let e=this._pointLabels||[];if(t>=0&&t=0;p--){let g=d._pointLabelItems[p];if(!g.visible)continue;let m=f.setContext(d.getPointLabelContext(p));pr(u,m,g);let b=J(m.font),{x:y,y:_,textAlign:x}=g;Ft(u,d._pointLabels[p],y,_+b.lineHeight/2,b,{color:m.color,textAlign:x,textBaseline:"middle"})}})(this,a),n.display&&this.ticks.forEach((d,c)=>{if(c!==0||c===0&&this.min<0){l=this.getDistanceFromCenterForValue(d.value);let u=this.getContext(c),f=n.setContext(u),p=o.setContext(u);(function(g,m,b,y,_){let x=g.ctx,v=m.circular,{color:M,lineWidth:w}=m;!v&&!y||!M||!w||b<0||(x.save(),x.strokeStyle=M,x.lineWidth=w,x.setLineDash(_.dash||[]),x.lineDashOffset=_.dashOffset,x.beginPath(),xo(g,b,v,y),x.closePath(),x.stroke(),x.restore())})(this,f,l,a,p)}}),s.display){for(t.save(),r=a-1;r>=0;r--){let d=s.setContext(this.getPointLabelContext(r)),{color:c,lineWidth:u}=d;u&&c&&(t.lineWidth=u,t.strokeStyle=c,t.setLineDash(d.borderDash),t.lineDashOffset=d.borderDashOffset,l=this.getDistanceFromCenterForValue(e.reverse?this.min:this.max),h=this.getPointPosition(r,l),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(h.x,h.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){let t=this.ctx,e=this.options,s=e.ticks;if(!s.display)return;let n=this.getIndexAngle(0),o,a;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(n),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((r,l)=>{if(l===0&&this.min>=0&&!e.reverse)return;let h=s.setContext(this.getContext(l)),d=J(h.font);if(o=this.getDistanceFromCenterForValue(this.ticks[l].value),h.showLabelBackdrop){t.font=d.string,a=t.measureText(r.label).width,t.fillStyle=h.backdropColor;let c=et(h.backdropPadding);t.fillRect(-a/2-c.left,-o-d.size/2-c.top,a+c.width,d.size+c.height)}Ft(t,r.label,0,-o,d,{color:h.color,strokeColor:h.textStrokeColor,strokeWidth:h.textStrokeWidth})}),t.restore()}drawTitle(){}}let ai={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},ot=Object.keys(ai);function _o(i,t){return i-t}function yo(i,t){if(I(t))return null;let e=i._adapter,{parser:s,round:n,isoWeekday:o}=i._parseOpts,a=t;return typeof s=="function"&&(a=s(a)),L(a)||(a=typeof s=="string"?e.parse(a,s):e.parse(a)),a===null?null:(n&&(a=n!=="week"||!$t(o)&&o!==!0?e.startOf(a,n):e.startOf(a,"isoWeek",o)),+a)}function vo(i,t,e,s){let n=ot.length;for(let o=ot.indexOf(i);o=t?e[s]:e[n]]=!0}}else i[t]=!0}function wo(i,t,e){let s=[],n={},o=t.length,a,r;for(a=0;a=0&&(h[m].major=!0);return h})(i,s,n,e):s}class rs extends Wt{static id="time";static defaults={bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",callback:!1,major:{enabled:!1}}};constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,e={}){let s=t.time||(t.time={}),n=this._adapter=new eo._date(t.adapters.date);n.init(e),Jt(s.displayFormats,n.formats()),this._parseOpts={parser:s.parser,round:s.round,isoWeekday:s.isoWeekday},super.init(t),this._normalized=e.normalized}parse(t,e){return t===void 0?null:yo(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){let t=this.options,e=this._adapter,s=t.time.unit||"day",{min:n,max:o,minDefined:a,maxDefined:r}=this.getUserBounds();function l(h){a||isNaN(h.min)||(n=Math.min(n,h.min)),r||isNaN(h.max)||(o=Math.max(o,h.max))}a&&r||(l(this._getLabelBounds()),t.bounds==="ticks"&&t.ticks.source==="labels"||l(this.getMinMax(!1))),n=L(n)&&!isNaN(n)?n:+e.startOf(Date.now(),s),o=L(o)&&!isNaN(o)?o:+e.endOf(Date.now(),s)+1,this.min=Math.min(n,o-1),this.max=Math.max(n+1,o)}_getLabelBounds(){let t=this.getLabelTimestamps(),e=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],s=t[t.length-1]),{min:e,max:s}}buildTicks(){let t=this.options,e=t.time,s=t.ticks,n=s.source==="labels"?this.getLabelTimestamps():this._generate();t.bounds==="ticks"&&n.length&&(this.min=this._userMin||n[0],this.max=this._userMax||n[n.length-1]);let o=this.min,a=Ds(n,o,this.max);return this._unit=e.unit||(s.autoSkip?vo(e.minUnit,this.min,this.max,this._getLabelCapacity(o)):(function(r,l,h,d,c){for(let u=ot.length-1;u>=ot.indexOf(h);u--){let f=ot[u];if(ai[f].common&&r._adapter.diff(c,d,f)>=l-1)return f}return ot[h?ot.indexOf(h):0]})(this,a.length,e.minUnit,this.min,this.max)),this._majorUnit=s.major.enabled&&this._unit!=="year"?(function(r){for(let l=ot.indexOf(r)+1,h=ot.length;l+t.value))}initOffsets(t=[]){let e,s,n=0,o=0;this.options.offset&&t.length&&(e=this.getDecimalForValue(t[0]),n=t.length===1?1-e:(this.getDecimalForValue(t[1])-e)/2,s=this.getDecimalForValue(t[t.length-1]),o=t.length===1?s:(s-this.getDecimalForValue(t[t.length-2]))/2);let a=t.length<3?.5:.25;n=Q(n,0,a),o=Q(o,0,a),this._offsets={start:n,end:o,factor:1/(n+1+o)}}_generate(){let t=this._adapter,e=this.min,s=this.max,n=this.options,o=n.time,a=o.unit||vo(o.minUnit,e,s,this._getLabelCapacity(e)),r=E(n.ticks.stepSize,1),l=a==="week"&&o.isoWeekday,h=$t(l)||l===!0,d={},c,u,f=e;if(h&&(f=+t.startOf(f,"isoWeek",l)),f=+t.startOf(f,h?"day":a),t.diff(s,e,a)>1e5*r)throw new Error(e+" and "+s+" are too far apart with stepSize of "+r+" "+a);let p=n.ticks.source==="data"&&this.getDataTimestamps();for(c=f,u=0;c+g)}getLabelForValue(t){let e=this._adapter,s=this.options.time;return s.tooltipFormat?e.format(t,s.tooltipFormat):e.format(t,s.displayFormats.datetime)}format(t,e){let s=this.options.time.displayFormats,n=this._unit,o=e||s[n];return this._adapter.format(t,o)}_tickFormatFunction(t,e,s,n){let o=this.options,a=o.ticks.callback;if(a)return N(a,[t,e,s],this);let r=o.time.displayFormats,l=this._unit,h=this._majorUnit,d=l&&r[l],c=h&&r[h],u=s[e],f=h&&c&&u&&u.major;return this._adapter.format(t,n||(f?c:d))}generateTickLabels(t){let e,s,n;for(e=0,s=t.length;e0?r:1}getDataTimestamps(){let t,e,s=this._cache.data||[];if(s.length)return s;let n=this.getMatchingVisibleMetas();if(this._normalized&&n.length)return this._cache.data=n[0].controller.getAllParsedValues(this);for(t=0,e=n.length;t=i[r].pos&&t<=i[l].pos&&({lo:r,hi:l}=yt(i,"pos",t)),{pos:s,time:o}=i[r],{pos:n,time:a}=i[l]):(t>=i[r].time&&t<=i[l].time&&({lo:r,hi:l}=yt(i,"time",t)),{time:s,pos:o}=i[r],{time:n,pos:a}=i[l]);let h=n-s;return h?o+(a-o)*(t-s)/h:o}var ko=Object.freeze({__proto__:null,CategoryScale:class extends Wt{static id="category";static defaults={ticks:{callback:fo}};constructor(i){super(i),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(i){let t=this._addedLabels;if(t.length){let e=this.getLabels();for(let{index:s,label:n}of t)e[s]===n&&e.splice(s,1);this._addedLabels=[]}super.init(i)}parse(i,t){if(I(i))return null;let e=this.getLabels();return((s,n)=>s===null?null:Q(Math.round(s),0,n))(t=isFinite(t)&&e[t]===i?t:rr(e,i,E(t,i),this._addedLabels),e.length-1)}determineDataLimits(){let{minDefined:i,maxDefined:t}=this.getUserBounds(),{min:e,max:s}=this.getMinMax(!0);this.options.bounds==="ticks"&&(i||(e=0),t||(s=this.getLabels().length-1)),this.min=e,this.max=s}buildTicks(){let i=this.min,t=this.max,e=this.options.offset,s=[],n=this.getLabels();n=i===0&&t===n.length-1?n:n.slice(i,t+1),this._valueRange=Math.max(n.length-(e?0:1),1),this._startValue=this.min-(e?.5:0);for(let o=i;o<=t;o++)s.push({value:o});return s}getLabelForValue(i){return fo.call(this,i)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(i){return typeof i!="number"&&(i=this.parse(i)),i===null?NaN:this.getPixelForDecimal((i-this._startValue)/this._valueRange)}getPixelForTick(i){let t=this.ticks;return i<0||i>t.length-1?null:this.getPixelForValue(t[i].value)}getValueForPixel(i){return Math.round(this._startValue+this.getDecimalForPixel(i)*this._valueRange)}getBasePixel(){return this.bottom}},LinearScale:lr,LogarithmicScale:cr,RadialLinearScale:mr,TimeScale:rs,TimeSeriesScale:class extends rs{static id="timeseries";static defaults=rs.defaults;constructor(i){super(i),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){let i=this._getTimestampsForTable(),t=this._table=this.buildLookupTable(i);this._minPos=ri(t,this.min),this._tableRange=ri(t,this.max)-this._minPos,super.initOffsets(i)}buildLookupTable(i){let{min:t,max:e}=this,s=[],n=[],o,a,r,l,h;for(o=0,a=i.length;o=t&&l<=e&&s.push(l);if(s.length<2)return[{time:t,pos:0},{time:e,pos:1}];for(o=0,a=s.length;os-n)}_getTimestampsForTable(){let i=this._cache.all||[];if(i.length)return i;let t=this.getDataTimestamps(),e=this.getLabelTimestamps();return i=t.length&&e.length?this.normalize(t.concat(e)):t.length?t:e,i=this._cache.all=i,i}getDecimalForValue(i){return(ri(this._table,i)-this._minPos)/this._tableRange}getValueForPixel(i){let t=this._offsets,e=this.getDecimalForPixel(i)/t.factor-t.end;return ri(this._table,e*this._tableRange+this._minPos,!0)}}});let ls=["rgb(54, 162, 235)","rgb(255, 99, 132)","rgb(255, 159, 64)","rgb(255, 205, 86)","rgb(75, 192, 192)","rgb(153, 102, 255)","rgb(201, 203, 207)"],So=ls.map(i=>i.replace("rgb(","rgba(").replace(")",", 0.5)"));function Po(i){return ls[i%ls.length]}function Do(i){return So[i%So.length]}function br(i){let t=0;return(e,s)=>{let n=i.getDatasetMeta(s).controller;n instanceof es?t=(function(o,a){return o.backgroundColor=o.data.map(()=>Po(a++)),a})(e,t):n instanceof ao?t=(function(o,a){return o.backgroundColor=o.data.map(()=>Do(a++)),a})(e,t):n&&(t=(function(o,a){return o.borderColor=Po(a),o.backgroundColor=Do(a),++a})(e,t))}}function Co(i){let t;for(t in i)if(i[t].borderColor||i[t].backgroundColor)return!0;return!1}var xr={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(i,t,e){if(!e.enabled)return;let{data:{datasets:s},options:n}=i.config,{elements:o}=n,a=Co(s)||(r=n)&&(r.borderColor||r.backgroundColor)||o&&Co(o)||X.borderColor!=="rgba(0,0,0,0.1)"||X.backgroundColor!=="rgba(0,0,0,0.1)";var r;if(!e.forceOverride&&a)return;let l=br(i);s.forEach(l)}};function Oo(i){if(i._decimated){let t=i._data;delete i._decimated,delete i._data,Object.defineProperty(i,"data",{configurable:!0,enumerable:!0,writable:!0,value:t})}}function Ao(i){i.data.datasets.forEach(t=>{Oo(t)})}var _r={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(i,t,e)=>{if(!e.enabled)return void Ao(i);let s=i.width;i.data.datasets.forEach((n,o)=>{let{_data:a,indexAxis:r}=n,l=i.getDatasetMeta(o),h=a||n.data;if(re([r,i.options.indexAxis])==="y"||!l.controller.supportsDecimation)return;let d=i.scales[l.xAxisID];if(d.type!=="linear"&&d.type!=="time"||i.options.parsing)return;let{start:c,count:u}=(function(p,g){let m=g.length,b,y=0,{iScale:_}=p,{min:x,max:v,minDefined:M,maxDefined:w}=_.getUserBounds();return M&&(y=Q(yt(g,_.axis,x).lo,0,m-1)),b=w?Q(yt(g,_.axis,v).hi+1,y,m)-y:m-y,{start:y,count:b}})(l,h);if(u<=(e.threshold||4*s))return void Oo(n);let f;switch(I(a)&&(n._data=h,delete n.data,Object.defineProperty(n,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(p){this._data=p}})),e.algorithm){case"lttb":f=(function(p,g,m,b,y){let _=y.samples||b;if(_>=m)return p.slice(g,g+m);let x=[],v=(m-2)/(_-2),M=0,w=g+m-1,k,D,S,T,A,P=g;for(x[M++]=p[P],k=0;k<_-2;k++){let O,C=0,R=0,H=Math.floor((k+1)*v)+1+g,V=Math.min(Math.floor((k+2)*v)+1,m)+g,st=V-H;for(O=H;OS&&(S=T,D=p[O],A=O);x[M++]=D,P=A}return x[M++]=p[w],x})(h,c,u,s,e);break;case"min-max":f=(function(p,g,m,b){let y,_,x,v,M,w,k,D,S,T,A=0,P=0,O=[],C=g+m-1,R=p[g].x,H=p[C].x-R;for(y=g;yT&&(T=v,k=y),A=(P*A+_.x)/++P;else{let st=y-1;if(!I(w)&&!I(k)){let rt=Math.min(w,k),lt=Math.max(w,k);rt!==D&&rt!==st&&O.push({...p[rt],x:A}),lt!==D&<!==st&&O.push({...p[lt],x:A})}y>0&&st!==D&&O.push(p[st]),O.push(_),M=V,P=0,S=T=v,w=k=D=y}}return O})(h,c,u,s);break;default:throw new Error(`Unsupported decimation algorithm '${e.algorithm}'`)}n._decimated=f})},destroy(i){Ao(i)}};function hs(i,t,e,s){if(s)return;let n=t[i],o=e[i];return i==="angle"&&(n=nt(n),o=nt(o)),{property:i,start:n,end:o}}function cs(i,t,e){for(;t>i;t--){let s=e[t];if(!isNaN(s.x)&&!isNaN(s.y))break}return t}function To(i,t,e,s){return i&&t?s(i[e],t[e]):i?i[e]:t?t[e]:0}function Lo(i,t){let e=[],s=!1;return F(i)?(s=!0,e=i):e=(function(n,o){let{x:a=null,y:r=null}=n||{},l=o.points,h=[];return o.segments.forEach(({start:d,end:c})=>{c=cs(d,c,l);let u=l[d],f=l[c];r!==null?(h.push({x:u.x,y:r}),h.push({x:f.x,y:r})):a!==null&&(h.push({x:a,y:u.y}),h.push({x:a,y:f.y}))}),h})(i,t),e.length?new ni({points:e,options:{tension:0},_loop:s,_fullLoop:s}):null}function Eo(i){return i&&i.fill!==!1}function yr(i,t,e){let s=i[t].fill,n=[t],o;if(!e)return s;for(;s!==!1&&n.indexOf(s)===-1;){if(!L(s))return s;if(o=i[s],!o)return!1;if(o.visible)return s;n.push(s),s=o.fill}return!1}function vr(i,t,e){let s=(function(o){let a=o.options,r=a.fill,l=E(r&&r.target,r);return l===void 0&&(l=!!a.backgroundColor),l===!1||l===null?!1:l===!0?"origin":l})(i);if(z(s))return!isNaN(s.value)&&s;let n=parseFloat(s);return L(n)&&Math.floor(n)===n?(function(o,a,r,l){return o!=="-"&&o!=="+"||(r=a+r),r===a||r<0||r>=l?!1:r})(s[0],t,n,e):["origin","start","end","stack","shape"].indexOf(s)>=0&&s}function Mr(i,t,e){let s=[];for(let n=0;n=0;--a){let r=n[a].$filler;r&&(r.line.updateControlPoints(o,r.axis),s&&r.fill&&ds(i.ctx,r,o))}},beforeDatasetsDraw(i,t,e){if(e.drawTime!=="beforeDatasetsDraw")return;let s=i.getSortedVisibleDatasetMetas();for(let n=s.length-1;n>=0;--n){let o=s[n].$filler;Eo(o)&&ds(i.ctx,o,i.chartArea)}},beforeDatasetDraw(i,t,e){let s=t.meta.$filler;Eo(s)&&e.drawTime==="beforeDatasetDraw"&&ds(i.ctx,s,i.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};let Vo=(i,t)=>{let{boxHeight:e=t,boxWidth:s=t}=i;return i.usePointStyle&&(e=Math.min(e,t),s=i.pointStyleWidth||Math.min(s,t)),{boxWidth:s,boxHeight:e,itemHeight:Math.max(t,e)}};class Bo extends wt{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e,s){this.maxWidth=t,this.maxHeight=e,this._margins=s,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){let t=this.options.labels||{},e=N(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter(s=>t.filter(s,this.chart.data))),t.sort&&(e=e.sort((s,n)=>t.sort(s,n,this.chart.data))),this.options.reverse&&e.reverse(),this.legendItems=e}fit(){let{options:t,ctx:e}=this;if(!t.display)return void(this.width=this.height=0);let s=t.labels,n=J(s.font),o=n.size,a=this._computeTitleHeight(),{boxWidth:r,itemHeight:l}=Vo(s,o),h,d;e.font=n.string,this.isHorizontal()?(h=this.maxWidth,d=this._fitRows(a,o,r,l)+10):(d=this.maxHeight,h=this._fitCols(a,n,r,l)+10),this.width=Math.min(h,t.maxWidth||this.maxWidth),this.height=Math.min(d,t.maxHeight||this.maxHeight)}_fitRows(t,e,s,n){let{ctx:o,maxWidth:a,options:{labels:{padding:r}}}=this,l=this.legendHitBoxes=[],h=this.lineWidths=[0],d=n+r,c=t;o.textAlign="left",o.textBaseline="middle";let u=-1,f=-d;return this.legendItems.forEach((p,g)=>{let m=s+e/2+o.measureText(p.text).width;(g===0||h[h.length-1]+m+2*r>a)&&(c+=d,h[h.length-(g>0?0:1)]=0,f+=d,u++),l[g]={left:0,top:f,row:u,width:m,height:n},h[h.length-1]+=m+r}),c}_fitCols(t,e,s,n){let{ctx:o,maxHeight:a,options:{labels:{padding:r}}}=this,l=this.legendHitBoxes=[],h=this.columnSizes=[],d=a-t,c=r,u=0,f=0,p=0,g=0;return this.legendItems.forEach((m,b)=>{let{itemWidth:y,itemHeight:_}=(function(x,v,M,w,k){let D=(function(T,A,P,O){let C=T.text;return C&&typeof C!="string"&&(C=C.reduce((R,H)=>R.length>H.length?R:H)),A+P.size/2+O.measureText(C).width})(w,x,v,M),S=(function(T,A,P){let O=T;return typeof A.text!="string"&&(O=Wo(A,P)),O})(k,w,v.lineHeight);return{itemWidth:D,itemHeight:S}})(s,e,o,m,n);b>0&&f+_+2*r>d&&(c+=u+r,h.push({width:u,height:f}),p+=u+r,g++,u=f=0),l[b]={left:p,top:f,col:g,width:y,height:_},u=Math.max(u,y),f+=_+r}),c+=u,h.push({width:u,height:f}),c}adjustHitBoxes(){if(!this.options.display)return;let t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:s,labels:{padding:n},rtl:o}}=this,a=qt(o,this.left,this.width);if(this.isHorizontal()){let r=0,l=tt(s,this.left+n,this.right-this.lineWidths[r]);for(let h of e)r!==h.row&&(r=h.row,l=tt(s,this.left+n,this.right-this.lineWidths[r])),h.top+=this.top+t+n,h.left=a.leftForLtr(a.x(l),h.width),l+=h.width+n}else{let r=0,l=tt(s,this.top+t+n,this.bottom-this.columnSizes[r].height);for(let h of e)h.col!==r&&(r=h.col,l=tt(s,this.top+t+n,this.bottom-this.columnSizes[r].height)),h.top=l,h.left+=this.left+n,h.left=a.leftForLtr(a.x(h.left),h.width),l+=h.height+n}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){let t=this.ctx;me(t,this),this._draw(),be(t)}}_draw(){let{options:t,columnSizes:e,lineWidths:s,ctx:n}=this,{align:o,labels:a}=t,r=X.color,l=qt(t.rtl,this.left,this.width),h=J(a.font),{padding:d}=a,c=h.size,u=c/2,f;this.drawTitle(),n.textAlign=l.textAlign("left"),n.textBaseline="middle",n.lineWidth=.5,n.font=h.string;let{boxWidth:p,boxHeight:g,itemHeight:m}=Vo(a,c),b=this.isHorizontal(),y=this._computeTitleHeight();f=b?{x:tt(o,this.left+d,this.right-s[0]),y:this.top+d+y,line:0}:{x:this.left+d,y:tt(o,this.top+y+d,this.bottom-e[0].height),line:0},Bi(this.ctx,t.textDirection);let _=m+d;this.legendItems.forEach((x,v)=>{n.strokeStyle=x.fontColor,n.fillStyle=x.fontColor;let M=n.measureText(x.text).width,w=l.textAlign(x.textAlign||(x.textAlign=a.textAlign)),k=p+u+M,D=f.x,S=f.y;if(l.setWidth(this.width),b?v>0&&D+k+d>this.right&&(S=f.y+=_,f.line++,D=f.x=tt(o,this.left+d,this.right-s[f.line])):v>0&&S+_>this.bottom&&(D=f.x=D+e[f.line].width+d,f.line++,S=f.y=tt(o,this.top+y+d,this.bottom-e[f.line].height)),(function(T,A,P){if(isNaN(p)||p<=0||isNaN(g)||g<0)return;n.save();let O=E(P.lineWidth,1);if(n.fillStyle=E(P.fillStyle,r),n.lineCap=E(P.lineCap,"butt"),n.lineDashOffset=E(P.lineDashOffset,0),n.lineJoin=E(P.lineJoin,"miter"),n.lineWidth=O,n.strokeStyle=E(P.strokeStyle,r),n.setLineDash(E(P.lineDash,[])),a.usePointStyle){let C={radius:g*Math.SQRT2/2,pointStyle:P.pointStyle,rotation:P.rotation,borderWidth:O},R=l.xPlus(T,p/2);Ei(n,C,R,A+u,a.pointStyleWidth&&p)}else{let C=A+Math.max((c-g)/2,0),R=l.leftForLtr(T,p),H=Bt(P.borderRadius);n.beginPath(),Object.values(H).some(V=>V!==0)?ne(n,{x:R,y:C,w:p,h:g,radius:H}):n.rect(R,C,p,g),n.fill(),O!==0&&n.stroke()}n.restore()})(l.x(D),S,x),D=Ts(w,D+p+u,b?D+k:this.right,t.rtl),(function(T,A,P){Ft(n,P.text,T,A+m/2,h,{strikethrough:P.hidden,textAlign:l.textAlign(P.textAlign)})})(l.x(D),S,x),b)f.x+=k+d;else if(typeof x.text!="string"){let T=h.lineHeight;f.y+=Wo(x,T)+d}else f.y+=_}),Wi(this.ctx,t.textDirection)}drawTitle(){let t=this.options,e=t.title,s=J(e.font),n=et(e.padding);if(!e.display)return;let o=qt(t.rtl,this.left,this.width),a=this.ctx,r=e.position,l=s.size/2,h=n.top+l,d,c=this.left,u=this.width;if(this.isHorizontal())u=Math.max(...this.lineWidths),d=this.top+h,c=tt(t.align,c,this.right-u);else{let p=this.columnSizes.reduce((g,m)=>Math.max(g,m.height),0);d=h+tt(t.align,this.top,this.bottom-p-t.labels.padding-this._computeTitleHeight())}let f=tt(r,c,c+u);a.textAlign=o.textAlign(Ee(r)),a.textBaseline="middle",a.strokeStyle=e.color,a.fillStyle=e.color,a.font=s.string,Ft(a,e.text,f,d,s)}_computeTitleHeight(){let t=this.options.title,e=J(t.font),s=et(t.padding);return t.display?e.lineHeight+s.height:0}_getLegendItemAt(t,e){let s,n,o;if(_t(t,this.left,this.right)&&_t(e,this.top,this.bottom)){for(o=this.legendHitBoxes,s=0;si.chart.options.color,boxWidth:40,padding:10,generateLabels(i){let t=i.data.datasets,{labels:{usePointStyle:e,pointStyle:s,textAlign:n,color:o,useBorderRadius:a,borderRadius:r}}=i.legend.options;return i._getSortedDatasetMetas().map(l=>{let h=l.controller.getStyle(e?0:void 0),d=et(h.borderWidth);return{text:t[l.index].label,fillStyle:h.backgroundColor,fontColor:o,hidden:!l.visible,lineCap:h.borderCapStyle,lineDash:h.borderDash,lineDashOffset:h.borderDashOffset,lineJoin:h.borderJoinStyle,lineWidth:(d.width+d.height)/4,strokeStyle:h.borderColor,pointStyle:s||h.pointStyle,rotation:h.rotation,textAlign:n||h.textAlign,borderRadius:a&&(r||h.borderRadius),datasetIndex:l.index}},this)}},title:{color:i=>i.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:i=>!i.startsWith("on"),labels:{_scriptable:i=>!["generateLabels","filter","sort"].includes(i)}}};class us extends wt{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e){let s=this.options;if(this.left=0,this.top=0,!s.display)return void(this.width=this.height=this.right=this.bottom=0);this.width=this.right=t,this.height=this.bottom=e;let n=F(s.text)?s.text.length:1;this._padding=et(s.padding);let o=n*J(s.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=o:this.width=o}isHorizontal(){let t=this.options.position;return t==="top"||t==="bottom"}_drawArgs(t){let{top:e,left:s,bottom:n,right:o,options:a}=this,r=a.align,l,h,d,c=0;return this.isHorizontal()?(h=tt(r,s,o),d=e+t,l=o-s):(a.position==="left"?(h=s+t,d=tt(r,n,e),c=-.5*Y):(h=o-t,d=tt(r,e,n),c=.5*Y),l=n-e),{titleX:h,titleY:d,maxWidth:l,rotation:c}}draw(){let t=this.ctx,e=this.options;if(!e.display)return;let s=J(e.font),n=s.lineHeight/2+this._padding.top,{titleX:o,titleY:a,maxWidth:r,rotation:l}=this._drawArgs(n);Ft(t,e.text,0,0,s,{color:e.color,maxWidth:r,rotation:l,textAlign:Ee(e.align),textBaseline:"middle",translation:[o,a]})}}var Cr={id:"title",_element:us,start(i,t,e){(function(s,n){let o=new us({ctx:s.ctx,options:n,chart:s});it.configure(s,o,n),it.addBox(s,o),s.titleBlock=o})(i,e)},stop(i){let t=i.titleBlock;it.removeBox(i,t),delete i.titleBlock},beforeUpdate(i,t,e){let s=i.titleBlock;it.configure(i,s,e),s.options=e},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};let li=new WeakMap;var Or={id:"subtitle",start(i,t,e){let s=new us({ctx:i.ctx,options:e,chart:i});it.configure(i,s,e),it.addBox(i,s),li.set(i,s)},stop(i){it.removeBox(i,li.get(i)),li.delete(i)},beforeUpdate(i,t,e){let s=li.get(i);it.configure(i,s,e),s.options=e},defaults:{align:"center",display:!1,font:{weight:"normal"},fullSize:!0,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};let De={average(i){if(!i.length)return!1;let t,e,s=new Set,n=0,o=0;for(t=0,e=i.length;ta+r)/s.size,y:n/o}},nearest(i,t){if(!i.length)return!1;let e,s,n,o=t.x,a=t.y,r=Number.POSITIVE_INFINITY;for(e=0,s=i.length;e{var Er=Object.create;var qo=Object.defineProperty;var Rr=Object.getOwnPropertyDescriptor;var Ir=Object.getOwnPropertyNames;var zr=Object.getPrototypeOf,Fr=Object.prototype.hasOwnProperty;var Vr=(j,N)=>()=>(N||j((N={exports:{}}).exports,N),N.exports);var Br=(j,N,mt,I)=>{if(N&&typeof N=="object"||typeof N=="function")for(let F of Ir(N))!Fr.call(j,F)&&F!==mt&&qo(j,F,{get:()=>N[F],enumerable:!(I=Rr(N,F))||I.enumerable});return j};var Wr=(j,N,mt)=>(mt=j!=null?Er(zr(j)):{},Br(N||!j||!j.__esModule?qo(mt,"default",{value:j,enumerable:!0}):mt,j));var Ko=Vr((us,fs)=>{(function(j,N){typeof us=="object"&&typeof fs<"u"?fs.exports=N():typeof define=="function"&&define.amd?define(N):(j=typeof globalThis<"u"?globalThis:j||self).Chart=N()})(us,function(){"use strict";var j=Object.freeze({__proto__:null,get Colors(){return xr},get Decimation(){return _r},get Filler(){return Pr},get Legend(){return Dr},get SubTitle(){return Cr},get Title(){return Or},get Tooltip(){return Lr}});function N(){}let mt=(()=>{let i=0;return()=>i++})();function I(i){return i==null}function F(i){if(Array.isArray&&Array.isArray(i))return!0;let t=Object.prototype.toString.call(i);return t.slice(0,7)==="[object"&&t.slice(-6)==="Array]"}function z(i){return i!==null&&Object.prototype.toString.call(i)==="[object Object]"}function U(i){return(typeof i=="number"||i instanceof Number)&&isFinite(+i)}function L(i,t){return U(i)?i:t}function A(i,t){return i===void 0?t:i}let Tt=(i,t)=>typeof i=="string"&&i.endsWith("%")?parseFloat(i)/100:+i/t,bt=(i,t)=>typeof i=="string"&&i.endsWith("%")?parseFloat(i)/100*t:+i;function W(i,t,e){if(i&&typeof i.call=="function")return i.apply(e,t)}function V(i,t,e,s){let n,o,a;if(F(i))if(o=i.length,s)for(n=o-1;n>=0;n--)t.call(e,i[n],n);else for(n=0;ni,x:i=>i.x,y:i=>i.y};function xs(i){let t=i.split("."),e=[],s="";for(let n of t)s+=n,s.endsWith("\\")?s=s.slice(0,-1)+".":(e.push(s),s="");return e}function kt(i,t){return(bs[t]||(bs[t]=(function(s){let n=xs(s);return o=>{for(let a of n){if(a==="")break;o=o&&o[a]}return o}})(t)))(i)}function Oe(i){return i.charAt(0).toUpperCase()+i.slice(1)}let Zt=i=>i!==void 0,St=i=>typeof i=="function",hi=(i,t)=>{if(i.size!==t.size)return!1;for(let e of i)if(!t.has(e))return!1;return!0};function _s(i){return i.type==="mouseup"||i.type==="click"||i.type==="contextmenu"}let $=Math.PI,Y=2*$,ys=Y+$,he=Number.POSITIVE_INFINITY,vs=$/180,q=$/2,Lt=$/4,ci=2*$/3,Pt=Math.log10,ct=Math.sign;function Jt(i,t,e){return Math.abs(i-t)n-o).pop(),t}function Ht(i){return!(function(t){return typeof t=="symbol"||typeof t=="object"&&t!==null&&!(Symbol.toPrimitive in t||"toString"in t||"valueOf"in t)})(i)&&!isNaN(parseFloat(i))&&isFinite(i)}function ws(i,t){let e=Math.round(i);return e-t<=i&&e+t>=i}function ui(i,t,e){let s,n,o;for(s=0,n=i.length;sl&&h=Math.min(t,e)-s&&i<=Math.max(t,e)+s}function Te(i,t,e){e=e||(a=>i[a]1;)s=o+n>>1,e(s)?o=s:n=s;return{lo:o,hi:n}}let _t=(i,t,e,s)=>Te(i,e,s?n=>{let o=i[n][t];return oi[n][t]Te(i,e,s=>i[s][t]>=e);function Ds(i,t,e){let s=0,n=i.length;for(;ss&&i[n-1]>e;)n--;return s>0||n{let s="_onData"+Oe(e),n=i[e];Object.defineProperty(i,e,{configurable:!0,enumerable:!1,value(...o){let a=n.apply(this,o);return i._chartjs.listeners.forEach(r=>{typeof r[s]=="function"&&r[s](...o)}),a}})}))}function pi(i,t){let e=i._chartjs;if(!e)return;let s=e.listeners,n=s.indexOf(t);n!==-1&&s.splice(n,1),s.length>0||(Os.forEach(o=>{delete i[o]}),delete i._chartjs)}function mi(i){let t=new Set(i);return t.size===i.length?i:Array.from(t)}let bi=typeof window>"u"?function(i){return i()}:window.requestAnimationFrame;function xi(i,t){let e=[],s=!1;return function(...n){e=n,s||(s=!0,bi.call(window,()=>{s=!1,i.apply(t,e)}))}}function As(i,t){let e;return function(...s){return t?(clearTimeout(e),e=setTimeout(i,t,s)):i.apply(this,s),t}}let Le=i=>i==="start"?"left":i==="end"?"right":"center",J=(i,t,e)=>i==="start"?t:i==="end"?e:(t+e)/2,Ts=(i,t,e,s)=>i===(s?"left":"right")?e:i==="center"?(t+e)/2:t;function _i(i,t,e){let s=t.length,n=0,o=s;if(i._sorted){let{iScale:a,vScale:r,_parsed:l}=i,h=i.dataset&&i.dataset.options?i.dataset.options.spanGaps:null,d=a.axis,{min:c,max:u,minDefined:f,maxDefined:p}=a.getUserBounds();if(f){if(n=Math.min(_t(l,d,c).lo,e?s:_t(t,d,a.getPixelForValue(c)).lo),h){let g=l.slice(0,n+1).reverse().findIndex(m=>!I(m[r.axis]));n-=Math.max(0,g)}n=Z(n,0,s-1)}if(p){let g=Math.max(_t(l,a.axis,u,!0).hi+1,e?0:_t(t,d,a.getPixelForValue(u),!0).hi+1);if(h){let m=l.slice(g-1).findIndex(b=>!I(b[r.axis]));g+=Math.max(0,m)}o=Z(g,n,s)-n}else o=s-n}return{start:n,count:o}}function yi(i){let{xScale:t,yScale:e,_scaleRanges:s}=i,n={xmin:t.min,xmax:t.max,ymin:e.min,ymax:e.max};if(!s)return i._scaleRanges=n,!0;let o=s.xmin!==t.min||s.xmax!==t.max||s.ymin!==e.min||s.ymax!==e.max;return Object.assign(s,n),o}class Go{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,s,n){let o=e.listeners[n],a=e.duration;o.forEach(r=>r({chart:t,initial:e.initial,numSteps:a,currentStep:Math.min(s-e.start,a)}))}_refresh(){this._request||(this._running=!0,this._request=bi.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let e=0;this._charts.forEach((s,n)=>{if(!s.running||!s.items.length)return;let o=s.items,a,r=o.length-1,l=!1;for(;r>=0;--r)a=o[r],a._active?(a._total>s.duration&&(s.duration=a._total),a.tick(t),l=!0):(o[r]=o[o.length-1],o.pop());l&&(n.draw(),this._notify(n,s,t,"progress")),o.length||(s.running=!1,this._notify(n,s,t,"complete"),s.initial=!1),e+=o.length}),this._lastDate=t,e===0&&(this._running=!1)}_getAnims(t){let e=this._charts,s=e.get(t);return s||(s={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,s)),s}listen(t,e,s){this._getAnims(t).listeners[e].push(s)}add(t,e){e&&e.length&&this._getAnims(t).items.push(...e)}has(t){return this._getAnims(t).items.length>0}start(t){let e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce((s,n)=>Math.max(s,n._duration),0),this._refresh())}running(t){if(!this._running)return!1;let e=this._charts.get(t);return!!(e&&e.running&&e.items.length)}stop(t){let e=this._charts.get(t);if(!e||!e.items.length)return;let s=e.items,n=s.length-1;for(;n>=0;--n)s[n].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var yt=new Go;function ce(i){return i+.5|0}let Et=(i,t,e)=>Math.max(Math.min(i,e),t);function de(i){return Et(ce(2.55*i),0,255)}function Rt(i){return Et(ce(255*i),0,255)}function Dt(i){return Et(ce(i/2.55)/100,0,1)}function Ls(i){return Et(ce(100*i),0,100)}let lt={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},vi=[..."0123456789ABCDEF"],Zo=i=>vi[15&i],Jo=i=>vi[(240&i)>>4]+vi[15&i],Ee=i=>(240&i)>>4==(15&i);function Qo(i){var t=(e=>Ee(e.r)&&Ee(e.g)&&Ee(e.b)&&Ee(e.a))(i)?Zo:Jo;return i?"#"+t(i.r)+t(i.g)+t(i.b)+((e,s)=>e<255?s(e):"")(i.a,t):void 0}let ta=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function Es(i,t,e){let s=t*Math.min(e,1-e),n=(o,a=(o+i/30)%12)=>e-s*Math.max(Math.min(a-3,9-a,1),-1);return[n(0),n(8),n(4)]}function ea(i,t,e){let s=(n,o=(n+i/60)%6)=>e-e*t*Math.max(Math.min(o,4-o,1),0);return[s(5),s(3),s(1)]}function ia(i,t,e){let s=Es(i,1,.5),n;for(t+e>1&&(n=1/(t+e),t*=n,e*=n),n=0;n<3;n++)s[n]*=1-t-e,s[n]+=t;return s}function Mi(i){let t=i.r/255,e=i.g/255,s=i.b/255,n=Math.max(t,e,s),o=Math.min(t,e,s),a=(n+o)/2,r,l,h;return n!==o&&(h=n-o,l=a>.5?h/(2-n-o):h/(n+o),r=(function(d,c,u,f,p){return d===p?(c-u)/f+(c>16&255,r>>8&255,255&r]}return e})(),Re.transparent=[0,0,0,0]);let t=Re[i.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}let oa=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/,Si=i=>i<=.0031308?12.92*i:1.055*Math.pow(i,1/2.4)-.055,te=i=>i<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4);function Ie(i,t,e){if(i){let s=Mi(i);s[t]=Math.max(0,Math.min(s[t]+s[t]*e,t===0?360:1)),s=ki(s),i.r=s[0],i.g=s[1],i.b=s[2]}}function Fs(i,t){return i&&Object.assign(t||{},i)}function Vs(i){var t={r:0,g:0,b:0,a:255};return Array.isArray(i)?i.length>=3&&(t={r:i[0],g:i[1],b:i[2],a:255},i.length>3&&(t.a=Rt(i[3]))):(t=Fs(i,{r:0,g:0,b:0,a:1})).a=Rt(t.a),t}function aa(i){return i.charAt(0)==="r"?(function(t){let e=oa.exec(t),s,n,o,a=255;if(e){if(e[7]!==s){let r=+e[7];a=e[8]?de(r):Et(255*r,0,255)}return s=+e[1],n=+e[3],o=+e[5],s=255&(e[2]?de(s):Et(s,0,255)),n=255&(e[4]?de(n):Et(n,0,255)),o=255&(e[6]?de(o):Et(o,0,255)),{r:s,g:n,b:o,a}}})(i):sa(i)}class ue{constructor(t){if(t instanceof ue)return t;let e=typeof t,s;var n,o,a;e==="object"?s=Vs(t):e==="string"&&(a=(n=t).length,n[0]==="#"&&(a===4||a===5?o={r:255&17*lt[n[1]],g:255&17*lt[n[2]],b:255&17*lt[n[3]],a:a===5?17*lt[n[4]]:255}:a!==7&&a!==9||(o={r:lt[n[1]]<<4|lt[n[2]],g:lt[n[3]]<<4|lt[n[4]],b:lt[n[5]]<<4|lt[n[6]],a:a===9?lt[n[7]]<<4|lt[n[8]]:255})),s=o||na(t)||aa(t)),this._rgb=s,this._valid=!!s}get valid(){return this._valid}get rgb(){var t=Fs(this._rgb);return t&&(t.a=Dt(t.a)),t}set rgb(t){this._rgb=Vs(t)}rgbString(){return this._valid?(t=this._rgb)&&(t.a<255?`rgba(${t.r}, ${t.g}, ${t.b}, ${Dt(t.a)})`:`rgb(${t.r}, ${t.g}, ${t.b})`):void 0;var t}hexString(){return this._valid?Qo(this._rgb):void 0}hslString(){return this._valid?(function(t){if(!t)return;let e=Mi(t),s=e[0],n=Ls(e[1]),o=Ls(e[2]);return t.a<255?`hsla(${s}, ${n}%, ${o}%, ${Dt(t.a)})`:`hsl(${s}, ${n}%, ${o}%)`})(this._rgb):void 0}mix(t,e){if(t){let s=this.rgb,n=t.rgb,o,a=e===o?.5:e,r=2*a-1,l=s.a-n.a,h=((r*l==-1?r:(r+l)/(1+r*l))+1)/2;o=1-h,s.r=255&h*s.r+o*n.r+.5,s.g=255&h*s.g+o*n.g+.5,s.b=255&h*s.b+o*n.b+.5,s.a=a*s.a+(1-a)*n.a,this.rgb=s}return this}interpolate(t,e){return t&&(this._rgb=(function(s,n,o){let a=te(Dt(s.r)),r=te(Dt(s.g)),l=te(Dt(s.b));return{r:Rt(Si(a+o*(te(Dt(n.r))-a))),g:Rt(Si(r+o*(te(Dt(n.g))-r))),b:Rt(Si(l+o*(te(Dt(n.b))-l))),a:s.a+o*(n.a-s.a)}})(this._rgb,t._rgb,e)),this}clone(){return new ue(this.rgb)}alpha(t){return this._rgb.a=Rt(t),this}clearer(t){return this._rgb.a*=1-t,this}greyscale(){let t=this._rgb,e=ce(.3*t.r+.59*t.g+.11*t.b);return t.r=t.g=t.b=e,this}opaquer(t){return this._rgb.a*=1+t,this}negate(){let t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return Ie(this._rgb,2,t),this}darken(t){return Ie(this._rgb,2,-t),this}saturate(t){return Ie(this._rgb,1,t),this}desaturate(t){return Ie(this._rgb,1,-t),this}rotate(t){return(function(e,s){var n=Mi(e);n[0]=Rs(n[0]+s),n=ki(n),e.r=n[0],e.g=n[1],e.b=n[2]})(this._rgb,t),this}}function ze(i){if(i&&typeof i=="object"){let t=i.toString();return t==="[object CanvasPattern]"||t==="[object CanvasGradient]"}return!1}function Pi(i){return ze(i)?i:new ue(i)}function Fe(i){return ze(i)?i:new ue(i).saturate(.5).darken(.1).hexString()}let ra=["x","y","borderWidth","radius","tension"],la=["color","borderColor","backgroundColor"],Bs=new Map;function ee(i,t,e){return(function(s,n){n=n||{};let o=s+JSON.stringify(n),a=Bs.get(o);return a||(a=new Intl.NumberFormat(s,n),Bs.set(o,a)),a})(t,e).format(i)}let Ws={values:i=>F(i)?i:""+i,numeric(i,t,e){if(i===0)return"0";let s=this.chart.options.locale,n,o=i;if(e.length>1){let h=Math.max(Math.abs(e[0].value),Math.abs(e[e.length-1].value));(h<1e-4||h>1e15)&&(n="scientific"),o=(function(d,c){let u=c.length>3?c[2].value-c[1].value:c[1].value-c[0].value;return Math.abs(u)>=1&&d!==Math.floor(d)&&(u=d-Math.floor(d)),u})(i,e)}let a=Pt(Math.abs(o)),r=isNaN(a)?1:Math.max(Math.min(-1*Math.floor(a),20),0),l={notation:n,minimumFractionDigits:r,maximumFractionDigits:r};return Object.assign(l,this.options.ticks.format),ee(i,s,l)},logarithmic(i,t,e){if(i===0)return"0";let s=e[t].significand||i/Math.pow(10,Math.floor(Pt(i)));return[1,2,3,5,10,15].includes(s)||t>.8*e.length?Ws.numeric.call(this,i,t,e):""}};var fe={formatters:Ws};let jt=Object.create(null),Di=Object.create(null);function ge(i,t){if(!t)return i;let e=t.split(".");for(let s=0,n=e.length;ss.chart.platform.getDevicePixelRatio(),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(s,n)=>Fe(n.backgroundColor),this.hoverBorderColor=(s,n)=>Fe(n.borderColor),this.hoverColor=(s,n)=>Fe(n.color),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(t),this.apply(e)}set(t,e){return Oi(this,t,e)}get(t){return ge(this,t)}describe(t,e){return Oi(Di,t,e)}override(t,e){return Oi(jt,t,e)}route(t,e,s,n){let o=ge(this,t),a=ge(this,s),r="_"+e;Object.defineProperties(o,{[r]:{value:o[e],writable:!0},[e]:{enumerable:!0,get(){let l=this[r],h=a[n];return z(l)?Object.assign({},h,l):A(l,h)},set(l){this[r]=l}}})}apply(t){t.forEach(e=>e(this))}}var X=new ha({_scriptable:i=>!i.startsWith("on"),_indexable:i=>i!=="events",hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[function(i){i.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),i.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:t=>t!=="onProgress"&&t!=="onComplete"&&t!=="fn"}),i.set("animations",{colors:{type:"color",properties:la},numbers:{type:"number",properties:ra}}),i.describe("animations",{_fallback:"animation"}),i.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>0|t}}}})},function(i){i.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})},function(i){i.set("scale",{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:"ticks",clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(t,e)=>e.lineWidth,tickColor:(t,e)=>e.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:fe.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),i.route("scale.ticks","color","","color"),i.route("scale.grid","color","","borderColor"),i.route("scale.border","color","","borderColor"),i.route("scale.title","color","","color"),i.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&t!=="callback"&&t!=="parser",_indexable:t=>t!=="borderDash"&&t!=="tickBorderDash"&&t!=="dash"}),i.describe("scales",{_fallback:"scale"}),i.describe("scale.ticks",{_scriptable:t=>t!=="backdropPadding"&&t!=="callback",_indexable:t=>t!=="backdropPadding"})}]);function Ve(){return typeof window<"u"&&typeof document<"u"}function Be(i){let t=i.parentNode;return t&&t.toString()==="[object ShadowRoot]"&&(t=t.host),t}function We(i,t,e){let s;return typeof i=="string"?(s=parseInt(i,10),i.indexOf("%")!==-1&&(s=s/100*t.parentNode[e])):s=i,s}let Ne=i=>i.ownerDocument.defaultView.getComputedStyle(i,null);function Ns(i,t){return Ne(i).getPropertyValue(t)}let ca=["top","right","bottom","left"];function $t(i,t,e){let s={};e=e?"-"+e:"";for(let n=0;n<4;n++){let o=ca[n];s[o]=parseFloat(i[t+"-"+o+e])||0}return s.width=s.left+s.right,s.height=s.top+s.bottom,s}let da=(i,t,e)=>(i>0||t>0)&&(!e||!e.shadowRoot);function It(i,t){if("native"in i)return i;let{canvas:e,currentDevicePixelRatio:s}=t,n=Ne(e),o=n.boxSizing==="border-box",a=$t(n,"padding"),r=$t(n,"border","width"),{x:l,y:h,box:d}=(function(g,m){let b=g.touches,y=b&&b.length?b[0]:g,{offsetX:_,offsetY:x}=y,v,M,w=!1;if(da(_,x,g.target))v=_,M=x;else{let k=m.getBoundingClientRect();v=y.clientX-k.left,M=y.clientY-k.top,w=!0}return{x:v,y:M,box:w}})(i,e),c=a.left+(d&&r.left),u=a.top+(d&&r.top),{width:f,height:p}=t;return o&&(f-=a.width+r.width,p-=a.height+r.height),{x:Math.round((l-c)/f*e.width/s),y:Math.round((h-u)/p*e.height/s)}}let He=i=>Math.round(10*i)/10;function Hs(i,t,e,s){let n=Ne(i),o=$t(n,"margin"),a=We(n.maxWidth,i,"clientWidth")||he,r=We(n.maxHeight,i,"clientHeight")||he,l=(function(c,u,f){let p,g;if(u===void 0||f===void 0){let m=c&&Be(c);if(m){let b=m.getBoundingClientRect(),y=Ne(m),_=$t(y,"border","width"),x=$t(y,"padding");u=b.width-x.width-_.width,f=b.height-x.height-_.height,p=We(y.maxWidth,m,"clientWidth"),g=We(y.maxHeight,m,"clientHeight")}else u=c.clientWidth,f=c.clientHeight}return{width:u,height:f,maxWidth:p||he,maxHeight:g||he}})(i,t,e),{width:h,height:d}=l;if(n.boxSizing==="content-box"){let c=$t(n,"border","width"),u=$t(n,"padding");h-=u.width+c.width,d-=u.height+c.height}return h=Math.max(0,h-o.width),d=Math.max(0,s?h/s:d-o.height),h=He(Math.min(h,a,l.maxWidth)),d=He(Math.min(d,r,l.maxHeight)),h&&!d&&(d=He(h/2)),(t!==void 0||e!==void 0)&&s&&l.height&&d>l.height&&(d=l.height,h=He(Math.floor(d*s))),{width:h,height:d}}function Ci(i,t,e){let s=t||1,n=Math.floor(i.height*s),o=Math.floor(i.width*s);i.height=Math.floor(i.height),i.width=Math.floor(i.width);let a=i.canvas;return a.style&&(e||!a.style.height&&!a.style.width)&&(a.style.height=`${i.height}px`,a.style.width=`${i.width}px`),(i.currentDevicePixelRatio!==s||a.height!==n||a.width!==o)&&(i.currentDevicePixelRatio=s,a.height=n,a.width=o,i.ctx.setTransform(s,0,0,s,0,0),!0)}let js=(function(){let i=!1;try{let t={get passive(){return i=!0,!1}};Ve()&&(window.addEventListener("test",null,t),window.removeEventListener("test",null,t))}catch{}return i})();function Ai(i,t){let e=Ns(i,t),s=e&&e.match(/^(\d+)(\.\d+)?px$/);return s?+s[1]:void 0}function $s(i){return!i||I(i.size)||I(i.family)?null:(i.style?i.style+" ":"")+(i.weight?i.weight+" ":"")+i.size+"px "+i.family}function pe(i,t,e,s,n){let o=t[n];return o||(o=t[n]=i.measureText(n).width,e.push(n)),o>s&&(s=o),s}function Ys(i,t,e,s){let n=(s=s||{}).data=s.data||{},o=s.garbageCollect=s.garbageCollect||[];s.font!==t&&(n=s.data={},o=s.garbageCollect=[],s.font=t),i.save(),i.font=t;let a=0,r=e.length,l,h,d,c,u;for(l=0;le.length){for(l=0;l0&&i.stroke()}}function vt(i,t,e){return e=e||.5,!t||i&&i.x>t.left-e&&i.xt.top-e&&i.y0&&o.strokeColor!=="",l,h;for(i.save(),i.font=n.string,(function(d,c){c.translation&&d.translate(c.translation[0],c.translation[1]),I(c.rotation)||d.rotate(c.rotation),c.color&&(d.fillStyle=c.color),c.textAlign&&(d.textAlign=c.textAlign),c.textBaseline&&(d.textBaseline=c.textBaseline)})(i,o),l=0;li[0]){let o=e||i;s===void 0&&(s=Zs("_fallback",i));let a={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:i,_rootScopes:o,_fallback:s,_getTarget:n,override:r=>$e([r,...i],t,o,s)};return new Proxy(a,{deleteProperty:(r,l)=>(delete r[l],delete r._keys,delete i[0][l],!0),get:(r,l)=>qs(r,l,()=>(function(h,d,c,u){let f;for(let p of d)if(f=Zs(ga(p,h),c),f!==void 0)return Ri(h,f)?Ii(c,u,h,f):f})(l,t,i,r)),getOwnPropertyDescriptor:(r,l)=>Reflect.getOwnPropertyDescriptor(r._scopes[0],l),getPrototypeOf:()=>Reflect.getPrototypeOf(i[0]),has:(r,l)=>Js(r).includes(l),ownKeys:r=>Js(r),set(r,l,h){let d=r._storage||(r._storage=n());return r[l]=d[l]=h,delete r._keys,!0}})}function Yt(i,t,e,s){let n={_cacheable:!1,_proxy:i,_context:t,_subProxy:e,_stack:new Set,_descriptors:Ei(i,s),setContext:o=>Yt(i,o,e,s),override:o=>Yt(i.override(o),t,e,s)};return new Proxy(n,{deleteProperty:(o,a)=>(delete o[a],delete i[a],!0),get:(o,a,r)=>qs(o,a,()=>(function(l,h,d){let{_proxy:c,_context:u,_subProxy:f,_descriptors:p}=l,g=c[h];return St(g)&&p.isScriptable(h)&&(g=(function(m,b,y,_){let{_proxy:x,_context:v,_subProxy:M,_stack:w}=y;if(w.has(m))throw new Error("Recursion detected: "+Array.from(w).join("->")+"->"+m);w.add(m);let k=b(v,M||_);return w.delete(m),Ri(m,k)&&(k=Ii(x._scopes,x,m,k)),k})(h,g,l,d)),F(g)&&g.length&&(g=(function(m,b,y,_){let{_proxy:x,_context:v,_subProxy:M,_descriptors:w}=y;if(v.index!==void 0&&_(m))return b[v.index%b.length];if(z(b[0])){let k=b,D=x._scopes.filter(S=>S!==k);b=[];for(let S of k){let E=Ii(D,x,m,S);b.push(Yt(E,v,M&&M[m],w))}}return b})(h,g,l,p.isIndexable)),Ri(h,g)&&(g=Yt(g,u,f&&f[h],p)),g})(o,a,r)),getOwnPropertyDescriptor:(o,a)=>o._descriptors.allKeys?Reflect.has(i,a)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(i,a),getPrototypeOf:()=>Reflect.getPrototypeOf(i),has:(o,a)=>Reflect.has(i,a),ownKeys:()=>Reflect.ownKeys(i),set:(o,a,r)=>(i[a]=r,delete o[a],!0)})}function Ei(i,t={scriptable:!0,indexable:!0}){let{_scriptable:e=t.scriptable,_indexable:s=t.indexable,_allKeys:n=t.allKeys}=i;return{allKeys:n,scriptable:e,indexable:s,isScriptable:St(e)?e:()=>e,isIndexable:St(s)?s:()=>s}}let ga=(i,t)=>i?i+Oe(t):t,Ri=(i,t)=>z(t)&&i!=="adapters"&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function qs(i,t,e){if(Object.prototype.hasOwnProperty.call(i,t)||t==="constructor")return i[t];let s=e();return i[t]=s,s}function Ks(i,t,e){return St(i)?i(t,e):i}let pa=(i,t)=>i===!0?t:typeof i=="string"?kt(t,i):void 0;function ma(i,t,e,s,n){for(let o of t){let a=pa(e,o);if(a){i.add(a);let r=Ks(a._fallback,e,n);if(r!==void 0&&r!==e&&r!==s)return r}else if(a===!1&&s!==void 0&&e!==s)return null}return!1}function Ii(i,t,e,s){let n=t._rootScopes,o=Ks(t._fallback,e,s),a=[...i,...n],r=new Set;r.add(s);let l=Gs(r,a,e,o||e,s);return l!==null&&(o===void 0||o===e||(l=Gs(r,a,o,l,s),l!==null))&&$e(Array.from(r),[""],n,o,()=>(function(h,d,c){let u=h._getTarget();d in u||(u[d]={});let f=u[d];return F(f)&&z(c)?c:f||{}})(t,e,s))}function Gs(i,t,e,s,n){for(;e;)e=ma(i,t,e,s,n);return e}function Zs(i,t){for(let e of t){if(!e)continue;let s=e[i];if(s!==void 0)return s}}function Js(i){let t=i._keys;return t||(t=i._keys=(function(e){let s=new Set;for(let n of e)for(let o of Object.keys(n).filter(a=>!a.startsWith("_")))s.add(o);return Array.from(s)})(i._scopes)),t}function zi(i,t,e,s){let{iScale:n}=i,{key:o="r"}=this._parsing,a=new Array(s),r,l,h,d;for(r=0,l=s;rti==="x"?"y":"x";function tn(i,t,e,s){let n=i.skip?t:i,o=t,a=e.skip?t:e,r=Ae(o,n),l=Ae(a,o),h=r/(r+l),d=l/(r+l);h=isNaN(h)?0:h,d=isNaN(d)?0:d;let c=s*h,u=s*d;return{previous:{x:o.x-c*(a.x-n.x),y:o.y-c*(a.y-n.y)},next:{x:o.x+u*(a.x-n.x),y:o.y+u*(a.y-n.y)}}}function en(i,t="x"){let e=Qs(t),s=i.length,n=Array(s).fill(0),o=Array(s),a,r,l,h=se(i,0);for(a=0;a!h.skip)),t.cubicInterpolationMode==="monotone")en(i,n);else{let h=s?i[i.length-1]:i[0];for(o=0,a=i.length;oi===0||i===1,nn=(i,t,e)=>-Math.pow(2,10*(i-=1))*Math.sin((i-t)*Y/e),on=(i,t,e)=>Math.pow(2,-10*i)*Math.sin((i-t)*Y/e)+1,ne={linear:i=>i,easeInQuad:i=>i*i,easeOutQuad:i=>-i*(i-2),easeInOutQuad:i=>(i/=.5)<1?.5*i*i:-.5*(--i*(i-2)-1),easeInCubic:i=>i*i*i,easeOutCubic:i=>(i-=1)*i*i+1,easeInOutCubic:i=>(i/=.5)<1?.5*i*i*i:.5*((i-=2)*i*i+2),easeInQuart:i=>i*i*i*i,easeOutQuart:i=>-((i-=1)*i*i*i-1),easeInOutQuart:i=>(i/=.5)<1?.5*i*i*i*i:-.5*((i-=2)*i*i*i-2),easeInQuint:i=>i*i*i*i*i,easeOutQuint:i=>(i-=1)*i*i*i*i+1,easeInOutQuint:i=>(i/=.5)<1?.5*i*i*i*i*i:.5*((i-=2)*i*i*i*i+2),easeInSine:i=>1-Math.cos(i*q),easeOutSine:i=>Math.sin(i*q),easeInOutSine:i=>-.5*(Math.cos($*i)-1),easeInExpo:i=>i===0?0:Math.pow(2,10*(i-1)),easeOutExpo:i=>i===1?1:1-Math.pow(2,-10*i),easeInOutExpo:i=>Ue(i)?i:i<.5?.5*Math.pow(2,10*(2*i-1)):.5*(2-Math.pow(2,-10*(2*i-1))),easeInCirc:i=>i>=1?i:-(Math.sqrt(1-i*i)-1),easeOutCirc:i=>Math.sqrt(1-(i-=1)*i),easeInOutCirc:i=>(i/=.5)<1?-.5*(Math.sqrt(1-i*i)-1):.5*(Math.sqrt(1-(i-=2)*i)+1),easeInElastic:i=>Ue(i)?i:nn(i,.075,.3),easeOutElastic:i=>Ue(i)?i:on(i,.075,.3),easeInOutElastic(i){return Ue(i)?i:i<.5?.5*nn(2*i,.1125,.45):.5+.5*on(2*i-1,.1125,.45)},easeInBack(i){return i*i*((1.70158+1)*i-1.70158)},easeOutBack(i){return(i-=1)*i*((1.70158+1)*i+1.70158)+1},easeInOutBack(i){let t=1.70158;return(i/=.5)<1?i*i*((1+(t*=1.525))*i-t)*.5:.5*((i-=2)*i*((1+(t*=1.525))*i+t)+2)},easeInBounce:i=>1-ne.easeOutBounce(1-i),easeOutBounce(i){return i<1/2.75?7.5625*i*i:i<2/2.75?7.5625*(i-=1.5/2.75)*i+.75:i<2.5/2.75?7.5625*(i-=2.25/2.75)*i+.9375:7.5625*(i-=2.625/2.75)*i+.984375},easeInOutBounce:i=>i<.5?.5*ne.easeInBounce(2*i):.5*ne.easeOutBounce(2*i-1)+.5};function Vt(i,t,e,s){return{x:i.x+e*(t.x-i.x),y:i.y+e*(t.y-i.y)}}function an(i,t,e,s){return{x:i.x+e*(t.x-i.x),y:s==="middle"?e<.5?i.y:t.y:s==="after"?e<1?i.y:t.y:e>0?t.y:i.y}}function rn(i,t,e,s){let n={x:i.cp2x,y:i.cp2y},o={x:t.cp1x,y:t.cp1y},a=Vt(i,n,e),r=Vt(n,o,e),l=Vt(o,t,e),h=Vt(a,r,e),d=Vt(r,l,e);return Vt(h,d,e)}let xa=/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/,_a=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;function ln(i,t){let e=(""+i).match(xa);if(!e||e[1]==="normal")return 1.2*t;switch(i=+e[2],e[3]){case"px":return i;case"%":i/=100}return t*i}let ya=i=>+i||0;function Xe(i,t){let e={},s=z(t),n=s?Object.keys(t):t,o=z(i)?s?a=>A(i[a],i[t[a]]):a=>i[a]:()=>i;for(let a of n)e[a]=ya(o(a));return e}function Fi(i){return Xe(i,{top:"y",right:"x",bottom:"y",left:"x"})}function Bt(i){return Xe(i,["topLeft","topRight","bottomLeft","bottomRight"])}function Q(i){let t=Fi(i);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function G(i,t){i=i||{},t=t||X.font;let e=A(i.size,t.size);typeof e=="string"&&(e=parseInt(e,10));let s=A(i.style,t.style);s&&!(""+s).match(_a)&&(console.warn('Invalid font style specified: "'+s+'"'),s=void 0);let n={family:A(i.family,t.family),lineHeight:ln(A(i.lineHeight,t.lineHeight),e),size:e,style:s,weight:A(i.weight,t.weight),string:""};return n.string=$s(n),n}function oe(i,t,e,s){let n,o,a,r=!0;for(n=0,o=i.length;ne&&r===0?0:r+l;return{min:a(s,-Math.abs(o)),max:a(n,o)}}function Ot(i,t){return Object.assign(Object.create(i),t)}function Ut(i,t,e){return i?(function(s,n){return{x:o=>s+s+n-o,setWidth(o){n=o},textAlign:o=>o==="center"?o:o==="right"?"left":"right",xPlus:(o,a)=>o-a,leftForLtr:(o,a)=>o-a}})(t,e):{x:s=>s,setWidth(s){},textAlign:s=>s,xPlus:(s,n)=>s+n,leftForLtr:(s,n)=>s}}function Vi(i,t){let e,s;t!=="ltr"&&t!=="rtl"||(e=i.canvas.style,s=[e.getPropertyValue("direction"),e.getPropertyPriority("direction")],e.setProperty("direction",t,"important"),i.prevTextDirection=s)}function Bi(i,t){t!==void 0&&(delete i.prevTextDirection,i.canvas.style.setProperty("direction",t[0],t[1]))}function cn(i){return i==="angle"?{between:Qt,compare:ks,normalize:it}:{between:xt,compare:(t,e)=>t-e,normalize:t=>t}}function dn({start:i,end:t,count:e,loop:s,style:n}){return{start:i%e,end:t%e,loop:s&&(t-i+1)%e==0,style:n}}function Wi(i,t,e){if(!e)return[i];let{property:s,start:n,end:o}=e,a=t.length,{compare:r,between:l,normalize:h}=cn(s),{start:d,end:c,loop:u,style:f}=(function(M,w,k){let{property:D,start:S,end:E}=k,{between:T,normalize:P}=cn(D),C=w.length,O,R,{start:H,end:B,loop:et}=M;if(et){for(H+=C,B+=C,O=0,R=C;Oy||l(n,b,g)&&r(n,b)!==0,v=()=>!y||r(o,g)===0||l(o,b,g);for(let M=d,w=d;M<=c;++M)m=t[M%a],m.skip||(g=h(m[s]),g!==b&&(y=l(g,n,o),_===null&&x()&&(_=r(g,n)===0?M:w),_!==null&&v()&&(p.push(dn({start:_,end:M,loop:u,count:a,style:f})),_=null),w=M,b=g));return _!==null&&p.push(dn({start:_,end:c,loop:u,count:a,style:f})),p}function Ni(i,t){let e=[],s=i.segments;for(let n=0;nu&&l[f%h].skip;)f--;return f%=h,{start:u,end:f}})(e,n,o,s);return s===!0?fn(i,[{start:a,end:r,loop:o}],e,t):fn(i,(function(l,h,d,c){let u=l.length,f=[],p,g=h,m=l[h];for(p=h+1;p<=d;++p){let b=l[p%u];b.skip||b.stop?m.skip||(c=!1,f.push({start:h%u,end:(p-1)%u,loop:c}),h=g=b.stop?p:null):(g=p,m.skip&&(h=p)),m=b}return g!==null&&f.push({start:h%u,end:g%u,loop:c}),f})(e,a,r!I(g[c.axis]));d.lo-=Math.max(0,f);let p=u.slice(d.hi).findIndex(g=>!I(g[c.axis]));d.hi+=Math.max(0,p)}return d}if(n._sharedOptions){let d=o[0],c=typeof d.getRange=="function"&&d.getRange(t);if(c){let u=h(o,t,e-c),f=h(o,t,e+c);return{lo:u.lo,hi:f.hi}}}}return{lo:0,hi:o.length-1}}function xe(i,t,e,s,n){let o=i.getSortedVisibleDatasetMetas(),a=e[t];for(let r=0,l=o.length;r{l[a]&&l[a](t[e],n)&&(o.push({element:l,datasetIndex:h,index:d}),r=r||l.inRange(t.x,t.y,n))}),s&&!r?[]:o}var mn={evaluateInteractionItems:xe,modes:{index(i,t,e,s){let n=It(t,i),o=e.axis||"x",a=e.includeInvisible||!1,r=e.intersect?Hi(i,n,o,s,a):ji(i,n,o,!1,s,a),l=[];return r.length?(i.getSortedVisibleDatasetMetas().forEach(h=>{let d=r[0].index,c=h.data[d];c&&!c.skip&&l.push({element:c,datasetIndex:h.index,index:d})}),l):[]},dataset(i,t,e,s){let n=It(t,i),o=e.axis||"xy",a=e.includeInvisible||!1,r=e.intersect?Hi(i,n,o,s,a):ji(i,n,o,!1,s,a);if(r.length>0){let l=r[0].datasetIndex,h=i.getDatasetMeta(l).data;r=[];for(let d=0;dHi(i,It(t,i),e.axis||"xy",s,e.includeInvisible||!1),nearest(i,t,e,s){let n=It(t,i),o=e.axis||"xy",a=e.includeInvisible||!1;return ji(i,n,o,e.intersect,s,a)},x:(i,t,e,s)=>pn(i,It(t,i),"x",e.intersect,s),y:(i,t,e,s)=>pn(i,It(t,i),"y",e.intersect,s)}};let bn=["left","top","right","bottom"];function _e(i,t){return i.filter(e=>e.pos===t)}function xn(i,t){return i.filter(e=>bn.indexOf(e.pos)===-1&&e.box.axis===t)}function ye(i,t){return i.sort((e,s)=>{let n=t?s:e,o=t?e:s;return n.weight===o.weight?n.index-o.index:n.weight-o.weight})}function Sa(i,t){let e=(function(l){let h={};for(let d of l){let{stack:c,pos:u,stackWeight:f}=d;if(!c||!bn.includes(u))continue;let p=h[c]||(h[c]={count:0,placed:0,weight:0,size:0});p.count++,p.weight+=f}return h})(i),{vBoxMaxWidth:s,hBoxMaxHeight:n}=t,o,a,r;for(o=0,a=i.length;o{o[a]=Math.max(t[a],e[a])}),o}return s(i?["left","right"]:["top","bottom"])}function ve(i,t,e,s){let n=[],o,a,r,l,h,d;for(o=0,a=i.length,h=0;ok.box.fullSize),!0),y=ye(_e(m,"left"),!0),_=ye(_e(m,"right")),x=ye(_e(m,"top"),!0),v=ye(_e(m,"bottom")),M=xn(m,"x"),w=xn(m,"y");return{fullSize:b,leftAndTop:y.concat(x),rightAndBottom:_.concat(w).concat(v).concat(M),chartArea:_e(m,"chartArea"),vertical:y.concat(_).concat(w),horizontal:x.concat(v).concat(M)}})(i.boxes),l=r.vertical,h=r.horizontal;V(i.boxes,g=>{typeof g.beforeLayout=="function"&&g.beforeLayout()});let d=l.reduce((g,m)=>m.box.options&&m.box.options.display===!1?g:g+1,0)||1,c=Object.freeze({outerWidth:t,outerHeight:e,padding:n,availableWidth:o,availableHeight:a,vBoxMaxWidth:o/2/d,hBoxMaxHeight:a/2}),u=Object.assign({},n);yn(u,Q(s));let f=Object.assign({maxPadding:u,w:o,h:a,x:n.left,y:n.top},n),p=Sa(l.concat(h),c);ve(r.fullSize,f,c,p),ve(l,f,c,p),ve(h,f,c,p)&&ve(l,f,c,p),(function(g){let m=g.maxPadding;function b(y){let _=Math.max(m[y]-g[y],0);return g[y]+=_,_}g.y+=b("top"),g.x+=b("left"),b("right"),b("bottom")})(f),vn(r.leftAndTop,f,c,p),f.x+=f.w,f.y+=f.h,vn(r.rightAndBottom,f,c,p),i.chartArea={left:f.left,top:f.top,right:f.left+f.w,bottom:f.top+f.h,height:f.h,width:f.w},V(r.chartArea,g=>{let m=g.box;Object.assign(m,i.chartArea),m.update(f.w,f.h,{left:0,top:0,right:0,bottom:0})})}};class $i{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,s){}removeEventListener(t,e,s){}getDevicePixelRatio(){return 1}getMaximumSize(t,e,s,n){return e=Math.max(0,e||t.width),s=s||t.height,{width:e,height:Math.max(0,n?Math.floor(e/n):s)}}isAttached(t){return!0}updateConfig(t){}}class Mn extends $i{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}let Ke="$chartjs",Oa={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},wn=i=>i===null||i==="",kn=!!js&&{passive:!0};function Ca(i,t,e){i&&i.canvas&&i.canvas.removeEventListener(t,e,kn)}function Ge(i,t){for(let e of i)if(e===t||e.contains(t))return!0}function Aa(i,t,e){let s=i.canvas,n=new MutationObserver(o=>{let a=!1;for(let r of o)a=a||Ge(r.addedNodes,s),a=a&&!Ge(r.removedNodes,s);a&&e()});return n.observe(document,{childList:!0,subtree:!0}),n}function Ta(i,t,e){let s=i.canvas,n=new MutationObserver(o=>{let a=!1;for(let r of o)a=a||Ge(r.removedNodes,s),a=a&&!Ge(r.addedNodes,s);a&&e()});return n.observe(document,{childList:!0,subtree:!0}),n}let Me=new Map,Sn=0;function Pn(){let i=window.devicePixelRatio;i!==Sn&&(Sn=i,Me.forEach((t,e)=>{e.currentDevicePixelRatio!==i&&t()}))}function La(i,t,e){let s=i.canvas,n=s&&Be(s);if(!n)return;let o=xi((r,l)=>{let h=n.clientWidth;e(r,l),h{let l=r[0],h=l.contentRect.width,d=l.contentRect.height;h===0&&d===0||o(h,d)});return a.observe(n),(function(r,l){Me.size||window.addEventListener("resize",Pn),Me.set(r,l)})(i,o),a}function Yi(i,t,e){e&&e.disconnect(),t==="resize"&&(function(s){Me.delete(s),Me.size||window.removeEventListener("resize",Pn)})(i)}function Ea(i,t,e){let s=i.canvas,n=xi(o=>{i.ctx!==null&&e((function(a,r){let l=Oa[a.type]||a.type,{x:h,y:d}=It(a,r);return{type:l,chart:r,native:a,x:h!==void 0?h:null,y:d!==void 0?d:null}})(o,i))},i);return(function(o,a,r){o&&o.addEventListener(a,r,kn)})(s,t,n),n}class Dn extends $i{acquireContext(t,e){let s=t&&t.getContext&&t.getContext("2d");return s&&s.canvas===t?((function(n,o){let a=n.style,r=n.getAttribute("height"),l=n.getAttribute("width");if(n[Ke]={initial:{height:r,width:l,style:{display:a.display,height:a.height,width:a.width}}},a.display=a.display||"block",a.boxSizing=a.boxSizing||"border-box",wn(l)){let h=Ai(n,"width");h!==void 0&&(n.width=h)}if(wn(r))if(n.style.height==="")n.height=n.width/(o||2);else{let h=Ai(n,"height");h!==void 0&&(n.height=h)}})(t,e),s):null}releaseContext(t){let e=t.canvas;if(!e[Ke])return!1;let s=e[Ke].initial;["height","width"].forEach(o=>{let a=s[o];I(a)?e.removeAttribute(o):e.setAttribute(o,a)});let n=s.style||{};return Object.keys(n).forEach(o=>{e.style[o]=n[o]}),e.width=e.width,delete e[Ke],!0}addEventListener(t,e,s){this.removeEventListener(t,e);let n=t.$proxies||(t.$proxies={}),o={attach:Aa,detach:Ta,resize:La}[e]||Ea;n[e]=o(t,e,s)}removeEventListener(t,e){let s=t.$proxies||(t.$proxies={}),n=s[e];n&&(({attach:Yi,detach:Yi,resize:Yi}[e]||Ca)(t,e,n),s[e]=void 0)}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,s,n){return Hs(t,e,s,n)}isAttached(t){let e=t&&Be(t);return!(!e||!e.isConnected)}}function On(i){return!Ve()||typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas?Mn:Dn}var Cn=Object.freeze({__proto__:null,BasePlatform:$i,BasicPlatform:Mn,DomPlatform:Dn,_detectPlatform:On});let An="transparent",Ra={boolean:(i,t,e)=>e>.5?t:i,color(i,t,e){let s=Pi(i||An),n=s.valid&&Pi(t||An);return n&&n.valid?n.mix(s,e).hexString():t},number:(i,t,e)=>i+(t-i)*e};class Tn{constructor(t,e,s,n){let o=e[s];n=oe([t.to,n,o,t.from]);let a=oe([t.from,o,n]);this._active=!0,this._fn=t.fn||Ra[t.type||typeof a],this._easing=ne[t.easing]||ne.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=s,this._from=a,this._to=n,this._promises=void 0}active(){return this._active}update(t,e,s){if(this._active){this._notify(!1);let n=this._target[this._prop],o=s-this._start,a=this._duration-o;this._start=s,this._duration=Math.floor(Math.max(a,t.duration)),this._total+=o,this._loop=!!t.loop,this._to=oe([t.to,e,n,t.from]),this._from=oe([t.from,n,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){let e=t-this._start,s=this._duration,n=this._prop,o=this._from,a=this._loop,r=this._to,l;if(this._active=o!==r&&(a||e1?2-l:l,l=this._easing(Math.min(1,Math.max(0,l))),this._target[n]=this._fn(o,r,l))}wait(){let t=this._promises||(this._promises=[]);return new Promise((e,s)=>{t.push({res:e,rej:s})})}_notify(t){let e=t?"res":"rej",s=this._promises||[];for(let n=0;n{let o=t[n];if(!z(o))return;let a={};for(let r of e)a[r]=o[r];(F(o.properties)&&o.properties||[n]).forEach(r=>{r!==n&&s.has(r)||s.set(r,a)})})}_animateOptions(t,e){let s=e.options,n=(function(a,r){if(!r)return;let l=a.options;return l?(l.$shared&&(a.options=l=Object.assign({},l,{$shared:!1,$animations:{}})),l):void(a.options=r)})(t,s);if(!n)return[];let o=this._createAnimations(n,s);return s.$shared&&(function(a,r){let l=[],h=Object.keys(r);for(let d=0;d{t.options=s},()=>{}),o}_createAnimations(t,e){let s=this._properties,n=[],o=t.$animations||(t.$animations={}),a=Object.keys(e),r=Date.now(),l;for(l=a.length-1;l>=0;--l){let h=a[l];if(h.charAt(0)==="$")continue;if(h==="options"){n.push(...this._animateOptions(t,e));continue}let d=e[h],c=o[h],u=s.get(h);if(c){if(u&&c.active()){c.update(u,d,r);continue}c.cancel()}u&&u.duration?(o[h]=c=new Tn(u,t,h,d),n.push(c)):t[h]=d}return n}update(t,e){if(this._properties.size===0)return void Object.assign(t,e);let s=this._createAnimations(t,e);return s.length?(yt.add(this._chart,s),!0):void 0}}function Ln(i,t){let e=i&&i.options||{},s=e.reverse,n=e.min===void 0?t:0,o=e.max===void 0?t:0;return{start:s?o:n,end:s?n:o}}function En(i,t){let e=[],s=i._getSortedDatasetMetas(t),n,o;for(n=0,o=s.length;n0||!e&&o<0)return n.index}return null}function zn(i,t){let{chart:e,_cachedMeta:s}=i,n=e._stacks||(e._stacks={}),{iScale:o,vScale:a,index:r}=s,l=o.axis,h=a.axis,d=(function(f,p,g){return`${f.id}.${p.id}.${g.stack||g.type}`})(o,a,s),c=t.length,u;for(let f=0;fe[s].axis===t).shift()}function we(i,t){let e=i.controller.index,s=i.vScale&&i.vScale.axis;if(s){t=t||i._parsed;for(let n of t){let o=n._stacks;if(!o||o[s]===void 0||o[s][e]===void 0)return;delete o[s][e],o[s]._visualValues!==void 0&&o[s]._visualValues[e]!==void 0&&delete o[s]._visualValues[e]}}}let Ki=i=>i==="reset"||i==="none",Fn=(i,t)=>t?i:Object.assign({},i);class Ct{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(t,e){this.chart=t,this._ctx=t.ctx,this.index=e,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){let t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=Xi(t.vScale,t),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled("filler")&&console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options")}updateIndex(t){this.index!==t&&we(this._cachedMeta),this.index=t}linkScales(){let t=this.chart,e=this._cachedMeta,s=this.getDataset(),n=(c,u,f,p)=>c==="x"?u:c==="r"?p:f,o=e.xAxisID=A(s.xAxisID,qi(t,"x")),a=e.yAxisID=A(s.yAxisID,qi(t,"y")),r=e.rAxisID=A(s.rAxisID,qi(t,"r")),l=e.indexAxis,h=e.iAxisID=n(l,o,a,r),d=e.vAxisID=n(l,a,o,r);e.xScale=this.getScaleForId(o),e.yScale=this.getScaleForId(a),e.rScale=this.getScaleForId(r),e.iScale=this.getScaleForId(h),e.vScale=this.getScaleForId(d)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){let e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){let t=this._cachedMeta;this._data&&pi(this._data,this),t._stacked&&we(t)}_dataCheck(){let t=this.getDataset(),e=t.data||(t.data=[]),s=this._data;if(z(e)){let n=this._cachedMeta;this._data=(function(o,a){let{iScale:r,vScale:l}=a,h=r.axis==="x"?"x":"y",d=l.axis==="x"?"x":"y",c=Object.keys(o),u=new Array(c.length),f,p,g;for(f=0,p=c.length;f0&&s._parsed[t-1];if(this._parsing===!1)s._parsed=n,s._sorted=!0,d=n;else{d=F(n[t])?this.parseArrayData(s,n,t,e):z(n[t])?this.parseObjectData(s,n,t,e):this.parsePrimitiveData(s,n,t,e);let f=()=>h[r]===null||u&&h[r]g&&!m.hidden&&m._stacked&&{keys:En(b,!0),values:null})(e,s,this.chart),h={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:d,max:c}=(function(g){let{min:m,max:b,minDefined:y,maxDefined:_}=g.getUserBounds();return{min:y?m:Number.NEGATIVE_INFINITY,max:_?b:Number.POSITIVE_INFINITY}})(r),u,f;function p(){f=n[u];let g=f[r.axis];return!U(f[t.axis])||d>g||c=0;--u)if(!p()){this.updateRangeFromParsed(h,t,f,l);break}}return h}getAllParsedValues(t){let e=this._cachedMeta._parsed,s=[],n,o,a;for(n=0,o=e.length;n=0&&tthis.getContext(s,n,e),c);return p.$shared&&(p.$shared=l,o[a]=Object.freeze(Fn(p,l))),p}_resolveAnimations(t,e,s){let n=this.chart,o=this._cachedDataOpts,a=`animation-${e}`,r=o[a];if(r)return r;let l;if(n.options.animation!==!1){let d=this.chart.config,c=d.datasetAnimationScopeKeys(this._type,e),u=d.getOptionScopes(this.getDataset(),c);l=d.createResolver(u,this.getContext(t,s,e))}let h=new Ui(n,l&&l.animations);return l&&l._cacheable&&(o[a]=Object.freeze(h)),h}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||Ki(t)||this.chart._animationsDisabled}_getSharedOptions(t,e){let s=this.resolveDataElementOptions(t,e),n=this._sharedOptions,o=this.getSharedOptions(s),a=this.includeOptions(e,o)||o!==n;return this.updateSharedOptions(o,e,s),{sharedOptions:o,includeOptions:a}}updateElement(t,e,s,n){Ki(n)?Object.assign(t,s):this._resolveAnimations(e,n).update(t,s)}updateSharedOptions(t,e,s){t&&!Ki(e)&&this._resolveAnimations(void 0,e).update(t,s)}_setStyle(t,e,s,n){t.active=n;let o=this.getStyle(e,n);this._resolveAnimations(e,s,n).update(t,{options:!n&&this.getSharedOptions(o)||o})}removeHoverStyle(t,e,s){this._setStyle(t,s,"active",!1)}setHoverStyle(t,e,s){this._setStyle(t,s,"active",!0)}_removeDatasetHoverStyle(){let t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){let t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){let e=this._data,s=this._cachedMeta.data;for(let[r,l,h]of this._syncList)this[r](l,h);this._syncList=[];let n=s.length,o=e.length,a=Math.min(o,n);a&&this.parse(0,a),o>n?this._insertElements(n,o-n,t):o{for(h.length+=e,r=h.length-1;r>=a;r--)h[r]=h[r-e]};for(l(o),r=t;r{n[o]=s[o]&&s[o].active()?s[o]._to:this[o]}),n}}function za(i,t){let e=i.options.ticks,s=(function(c){let u=c.options.offset,f=c._tickSize(),p=c._length/f+(u?0:1),g=c._maxLength/f;return Math.floor(Math.min(p,g))})(i),n=Math.min(e.maxTicksLimit||s,s),o=e.major.enabled?(function(c){let u=[],f,p;for(f=0,p=c.length;fn)return(function(c,u,f,p){let g,m=0,b=f[0];for(p=Math.ceil(p),g=0;gg)return _}return Math.max(g,1)})(o,t,n);if(a>0){let c,u,f=a>1?Math.round((l-r)/(a-1)):null;for(Ze(t,h,d,I(f)?0:r-f,r),c=0,u=a-1;ct==="top"||t==="left"?i[t]+e:i[t]-e,Bn=(i,t)=>Math.min(t||i,i);function Wn(i,t){let e=[],s=i.length/t,n=i.length,o=0;for(;oa+r)))return h}function ke(i){return i.drawTicks?i.tickLength:0}function Nn(i,t){if(!i.display)return 0;let e=G(i.font,t),s=Q(i.padding);return(F(i.text)?i.text.length:1)*e.lineHeight+s.height}function Va(i,t,e){let s=Le(i);return(e&&t!=="right"||!e&&t==="right")&&(s=(n=>n==="left"?"right":n==="right"?"left":n)(s)),s}class Wt extends Mt{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,e){return t}getUserBounds(){let{_userMin:t,_userMax:e,_suggestedMin:s,_suggestedMax:n}=this;return t=L(t,Number.POSITIVE_INFINITY),e=L(e,Number.NEGATIVE_INFINITY),s=L(s,Number.POSITIVE_INFINITY),n=L(n,Number.NEGATIVE_INFINITY),{min:L(t,s),max:L(e,n),minDefined:U(t),maxDefined:U(e)}}getMinMax(t){let e,{min:s,max:n,minDefined:o,maxDefined:a}=this.getUserBounds();if(o&&a)return{min:s,max:n};let r=this.getMatchingVisibleMetas();for(let l=0,h=r.length;ln?n:s,n=o&&s>n?s:n,{min:L(s,L(n,s)),max:L(n,L(s,n))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){let t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}getLabelItems(t=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(t))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){W(this.options.beforeUpdate,[this])}update(t,e,s){let{beginAtZero:n,grace:o,ticks:a}=this.options,r=a.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=s=Object.assign({left:0,right:0,top:0,bottom:0},s),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+s.left+s.right:this.height+s.top+s.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=hn(this,o,n),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();let l=r=o||s<=1||!this.isHorizontal())return void(this.labelRotation=n);let d=this._getLabelSizes(),c=d.widest.width,u=d.highest.height,f=Z(this.chart.width-c,0,this.maxWidth);a=t.offset?this.maxWidth/s:f/(s-1),c+6>a&&(a=f/(s-(t.offset?.5:1)),r=this.maxHeight-ke(t.grid)-e.padding-Nn(t.title,this.chart.options.font),l=Math.sqrt(c*c+u*u),h=Ce(Math.min(Math.asin(Z((d.highest.height+6)/a,-1,1)),Math.asin(Z(r/l,-1,1))-Math.asin(Z(u/l,-1,1)))),h=Math.max(n,Math.min(o,h))),this.labelRotation=h}afterCalculateLabelRotation(){W(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){W(this.options.beforeFit,[this])}fit(){let t={width:0,height:0},{chart:e,options:{ticks:s,title:n,grid:o}}=this,a=this._isVisible(),r=this.isHorizontal();if(a){let l=Nn(n,e.options.font);if(r?(t.width=this.maxWidth,t.height=ke(o)+l):(t.height=this.maxHeight,t.width=ke(o)+l),s.display&&this.ticks.length){let{first:h,last:d,widest:c,highest:u}=this._getLabelSizes(),f=2*s.padding,p=rt(this.labelRotation),g=Math.cos(p),m=Math.sin(p);if(r){let b=s.mirror?0:m*c.width+g*u.height;t.height=Math.min(this.maxHeight,t.height+b+f)}else{let b=s.mirror?0:g*c.width+m*u.height;t.width=Math.min(this.maxWidth,t.width+b+f)}this._calculatePadding(h,d,m,g)}}this._handleMargins(),r?(this.width=this._length=e.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=e.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,e,s,n){let{ticks:{align:o,padding:a},position:r}=this.options,l=this.labelRotation!==0,h=r!=="top"&&this.axis==="x";if(this.isHorizontal()){let d=this.getPixelForTick(0)-this.left,c=this.right-this.getPixelForTick(this.ticks.length-1),u=0,f=0;l?h?(u=n*t.width,f=s*e.height):(u=s*t.height,f=n*e.width):o==="start"?f=e.width:o==="end"?u=t.width:o!=="inner"&&(u=t.width/2,f=e.width/2),this.paddingLeft=Math.max((u-d+a)*this.width/(this.width-d),0),this.paddingRight=Math.max((f-c+a)*this.width/(this.width-c),0)}else{let d=e.height/2,c=t.height/2;o==="start"?(d=0,c=t.height):o==="end"&&(d=e.height,c=0),this.paddingTop=d+a,this.paddingBottom=c+a}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){W(this.options.afterFit,[this])}isHorizontal(){let{axis:t,position:e}=this.options;return e==="top"||e==="bottom"||t==="x"}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){let e,s;for(this.beforeTickToLabelConversion(),this.generateTickLabels(t),e=0,s=t.length;e{let T=E.gc,P=T.length/2,C;if(P>S){for(C=0;C({width:a[D]||0,height:r[D]||0});return{first:k(0),last:k(e-1),widest:k(M),highest:k(w),widths:a,heights:r}}getLabelForValue(t){return t}getPixelForValue(t,e){return NaN}getValueForPixel(t){}getPixelForTick(t){let e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);let e=this._startPixel+t*this._length;return Ss(this._alignToPixels?zt(this.chart,e,0):e)}getDecimalForPixel(t){let e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){let{min:t,max:e}=this;return t<0&&e<0?e:t>0&&e>0?t:0}getContext(t){let e=this.ticks||[];if(t>=0&&tr*n?r/s:l/n:l*n0}_computeGridLineItems(t){let e=this.axis,s=this.chart,n=this.options,{grid:o,position:a,border:r}=n,l=o.offset,h=this.isHorizontal(),d=this.ticks.length+(l?1:0),c=ke(o),u=[],f=r.setContext(this.getContext()),p=f.display?f.width:0,g=p/2,m=function(O){return zt(s,O,p)},b,y,_,x,v,M,w,k,D,S,E,T;if(a==="top")b=m(this.bottom),M=this.bottom-c,k=b-g,S=m(t.top)+g,T=t.bottom;else if(a==="bottom")b=m(this.top),S=t.top,T=m(t.bottom)-g,M=b+g,k=this.top+c;else if(a==="left")b=m(this.right),v=this.right-c,w=b-g,D=m(t.left)+g,E=t.right;else if(a==="right")b=m(this.left),D=t.left,E=m(t.right)-g,v=b+g,w=this.left+c;else if(e==="x"){if(a==="center")b=m((t.top+t.bottom)/2+.5);else if(z(a)){let O=Object.keys(a)[0],R=a[O];b=m(this.chart.scales[O].getPixelForValue(R))}S=t.top,T=t.bottom,M=b+g,k=M+c}else if(e==="y"){if(a==="center")b=m((t.left+t.right)/2);else if(z(a)){let O=Object.keys(a)[0],R=a[O];b=m(this.chart.scales[O].getPixelForValue(R))}v=b-g,w=v-c,D=t.left,E=t.right}let P=A(n.ticks.maxTicksLimit,d),C=Math.max(1,Math.ceil(d/P));for(y=0;y0&&(pt-=ft/2)}ot={left:pt,top:gt,width:ft+ht.width,height:ut+ht.height,color:O.backdropColor}}m.push({label:x,font:D,textOffset:T,options:{rotation:g,color:H,strokeColor:B,strokeWidth:et,textAlign:at,textBaseline:P,translation:[v,M],backdrop:ot}})}return m}_getXAxisLabelAlignment(){let{position:t,ticks:e}=this.options;if(-rt(this.labelRotation))return t==="top"?"left":"right";let s="center";return e.align==="start"?s="left":e.align==="end"?s="right":e.align==="inner"&&(s="inner"),s}_getYAxisLabelAlignment(t){let{position:e,ticks:{crossAlign:s,mirror:n,padding:o}}=this.options,a=t+o,r=this._getLabelSizes().widest.width,l,h;return e==="left"?n?(h=this.right+o,s==="near"?l="left":s==="center"?(l="center",h+=r/2):(l="right",h+=r)):(h=this.right-a,s==="near"?l="right":s==="center"?(l="center",h-=r/2):(l="left",h=this.left)):e==="right"?n?(h=this.left+o,s==="near"?l="right":s==="center"?(l="center",h-=r/2):(l="left",h-=r)):(h=this.left+a,s==="near"?l="left":s==="center"?(l="center",h+=r/2):(l="right",h=this.right)):l="right",{textAlign:l,x:h}}_computeLabelArea(){if(this.options.ticks.mirror)return;let t=this.chart,e=this.options.position;return e==="left"||e==="right"?{top:0,left:this.left,bottom:t.height,right:this.right}:e==="top"||e==="bottom"?{top:this.top,left:0,bottom:this.bottom,right:t.width}:void 0}drawBackground(){let{ctx:t,options:{backgroundColor:e},left:s,top:n,width:o,height:a}=this;e&&(t.save(),t.fillStyle=e,t.fillRect(s,n,o,a),t.restore())}getLineWidthForValue(t){let e=this.options.grid;if(!this._isVisible()||!e.display)return 0;let s=this.ticks.findIndex(n=>n.value===t);return s>=0?e.setContext(this.getContext(s)).lineWidth:0}drawGrid(t){let e=this.options.grid,s=this.ctx,n=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t)),o,a,r=(l,h,d)=>{d.width&&d.color&&(s.save(),s.lineWidth=d.width,s.strokeStyle=d.color,s.setLineDash(d.borderDash||[]),s.lineDashOffset=d.borderDashOffset,s.beginPath(),s.moveTo(l.x,l.y),s.lineTo(h.x,h.y),s.stroke(),s.restore())};if(e.display)for(o=0,a=n.length;o{this.drawBackground(),this.drawGrid(o),this.drawTitle()}},{z:n,draw:()=>{this.drawBorder()}},{z:e,draw:o=>{this.drawLabels(o)}}]:[{z:e,draw:o=>{this.draw(o)}}]}getMatchingVisibleMetas(t){let e=this.chart.getSortedVisibleDatasetMetas(),s=this.axis+"AxisID",n=[],o,a;for(o=0,a=e.length;o{let p=f.split("."),g=p.pop(),m=[c].concat(p).join("."),b=u[f].split("."),y=b.pop(),_=b.join(".");X.route(m,g,_,y)})})(l,r.defaultRoutes),r.descriptors&&X.describe(l,r.descriptors)})(t,a,s),this.override&&X.override(t.id,t.overrides)),a}get(t){return this.items[t]}unregister(t){let e=this.items,s=t.id,n=this.scope;s in e&&delete e[s],n&&s in X[n]&&(delete X[n][s],this.override&&delete jt[s])}}class Ba{constructor(){this.controllers=new Je(Ct,"datasets",!0),this.elements=new Je(Mt,"elements"),this.plugins=new Je(Object,"plugins"),this.scales=new Je(Wt,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,e,s){[...e].forEach(n=>{let o=s||this._getRegistryForType(n);s||o.isForType(n)||o===this.plugins&&n.id?this._exec(t,o,n):V(n,a=>{let r=s||this._getRegistryForType(a);this._exec(t,r,a)})})}_exec(t,e,s){let n=Oe(t);W(s["before"+n],[],s),e[t](s),W(s["after"+n],[],s)}_getRegistryForType(t){for(let e=0;eo.filter(r=>!a.some(l=>r.plugin.id===l.plugin.id));this._notify(n(e,s),t,"stop"),this._notify(n(s,e),t,"start")}}function Na(i,t){return t||i!==!1?i===!0?{}:i:null}function Ha(i,{plugin:t,local:e},s,n){let o=i.pluginScopeKeys(t),a=i.getOptionScopes(s,o);return e&&t.defaults&&a.push(t.defaults),i.createResolver(a,n,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function Gi(i,t){let e=X.datasets[i]||{};return((t.datasets||{})[i]||{}).indexAxis||t.indexAxis||e.indexAxis||"x"}function Hn(i){if(i==="x"||i==="y"||i==="r")return i}function Zi(i,...t){if(Hn(i))return i;for(let s of t){let n=s.axis||((e=s.position)==="top"||e==="bottom"?"x":e==="left"||e==="right"?"y":void 0)||i.length>1&&Hn(i[0].toLowerCase());if(n)return n}var e;throw new Error(`Cannot determine type of '${i}' axis. Please provide 'axis' or 'position' option.`)}function jn(i,t,e){if(e[t+"AxisID"]===i)return{axis:t}}function ja(i,t){let e=jt[i.type]||{scales:{}},s=t.scales||{},n=Gi(i.type,t),o=Object.create(null);return Object.keys(s).forEach(a=>{let r=s[a];if(!z(r))return console.error(`Invalid scale configuration for scale: ${a}`);if(r._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${a}`);let l=Zi(a,r,(function(c,u){if(u.data&&u.data.datasets){let f=u.data.datasets.filter(p=>p.xAxisID===c||p.yAxisID===c);if(f.length)return jn(c,"x",f[0])||jn(c,"y",f[0])}return{}})(a,i),X.scales[r.type]),h=(function(c,u){return c===u?"_index_":"_value_"})(l,n),d=e.scales||{};o[a]=Gt(Object.create(null),[{axis:l},r,d[l],d[h]])}),i.data.datasets.forEach(a=>{let r=a.type||i.type,l=a.indexAxis||Gi(r,t),h=(jt[r]||{}).scales||{};Object.keys(h).forEach(d=>{let c=(function(f,p){let g=f;return f==="_index_"?g=p:f==="_value_"&&(g=p==="x"?"y":"x"),g})(d,l),u=a[c+"AxisID"]||c;o[u]=o[u]||Object.create(null),Gt(o[u],[{axis:c},s[u],h[d]])})}),Object.keys(o).forEach(a=>{let r=o[a];Gt(r,[X.scales[r.type],X.scale])}),o}function $n(i){let t=i.options||(i.options={});t.plugins=A(t.plugins,{}),t.scales=ja(i,t)}function Yn(i){return(i=i||{}).datasets=i.datasets||[],i.labels=i.labels||[],i}let Un=new Map,Xn=new Set;function Qe(i,t){let e=Un.get(i);return e||(e=t(),Un.set(i,e),Xn.add(e)),e}let Se=(i,t,e)=>{let s=kt(t,e);s!==void 0&&i.add(s)};class $a{constructor(t){this._config=(function(e){return(e=e||{}).data=Yn(e.data),$n(e),e})(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=Yn(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){let t=this._config;this.clearCache(),$n(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return Qe(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,e){return Qe(`${t}.transition.${e}`,()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,e){return Qe(`${t}-${e}`,()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]])}pluginScopeKeys(t){let e=t.id;return Qe(`${this.type}-plugin-${e}`,()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,e){let s=this._scopeCache,n=s.get(t);return n&&!e||(n=new Map,s.set(t,n)),n}getOptionScopes(t,e,s){let{options:n,type:o}=this,a=this._cachedScopes(t,s),r=a.get(e);if(r)return r;let l=new Set;e.forEach(d=>{t&&(l.add(t),d.forEach(c=>Se(l,t,c))),d.forEach(c=>Se(l,n,c)),d.forEach(c=>Se(l,jt[o]||{},c)),d.forEach(c=>Se(l,X,c)),d.forEach(c=>Se(l,Di,c))});let h=Array.from(l);return h.length===0&&h.push(Object.create(null)),Xn.has(e)&&a.set(e,h),h}chartOptionScopes(){let{options:t,type:e}=this;return[t,jt[e]||{},X.datasets[e]||{},{type:e},X,Di]}resolveNamedOptions(t,e,s,n=[""]){let o={$shared:!0},{resolver:a,subPrefixes:r}=qn(this._resolverCache,t,n),l=a;(function(h,d){let{isScriptable:c,isIndexable:u}=Ei(h);for(let f of d){let p=c(f),g=u(f),m=(g||p)&&h[f];if(p&&(St(m)||Ya(m))||g&&F(m))return!0}return!1})(a,e)&&(o.$shared=!1,l=Yt(a,s=St(s)?s():s,this.createResolver(t,s,r)));for(let h of e)o[h]=l[h];return o}createResolver(t,e,s=[""],n){let{resolver:o}=qn(this._resolverCache,t,s);return z(e)?Yt(o,e,void 0,n):o}}function qn(i,t,e){let s=i.get(t);s||(s=new Map,i.set(t,s));let n=e.join(),o=s.get(n);return o||(o={resolver:$e(t,e),subPrefixes:e.filter(a=>!a.toLowerCase().includes("hover"))},s.set(n,o)),o}let Ya=i=>z(i)&&Object.getOwnPropertyNames(i).some(t=>St(i[t])),Ua=["top","bottom","left","right","chartArea"];function Kn(i,t){return i==="top"||i==="bottom"||Ua.indexOf(i)===-1&&t==="x"}function Gn(i,t){return function(e,s){return e[i]===s[i]?e[t]-s[t]:e[i]-s[i]}}function Zn(i){let t=i.chart,e=t.options.animation;t.notifyPlugins("afterRender"),W(e&&e.onComplete,[i],t)}function Xa(i){let t=i.chart,e=t.options.animation;W(e&&e.onProgress,[i],t)}function Jn(i){return Ve()&&typeof i=="string"?i=document.getElementById(i):i&&i.length&&(i=i[0]),i&&i.canvas&&(i=i.canvas),i}let ti={},Qn=i=>{let t=Jn(i);return Object.values(ti).filter(e=>e.canvas===t).pop()};function qa(i,t,e){let s=Object.keys(i);for(let n of s){let o=+n;if(o>=t){let a=i[n];delete i[n],(e>0||o>t)&&(i[o+e]=a)}}}function ei(i,t,e){return i.options.clip?i[e]:t[e]}class K{static defaults=X;static instances=ti;static overrides=jt;static registry=dt;static version="4.4.8";static getChart=Qn;static register(...t){dt.add(...t),to()}static unregister(...t){dt.remove(...t),to()}constructor(t,e){let s=this.config=new $a(e),n=Jn(t),o=Qn(n);if(o)throw new Error("Canvas is already in use. Chart with ID '"+o.id+"' must be destroyed before the canvas with ID '"+o.canvas.id+"' can be reused.");let a=s.createResolver(s.chartOptionScopes(),this.getContext());this.platform=new(s.platform||On(n)),this.platform.updateConfig(s);let r=this.platform.acquireContext(n,a.aspectRatio),l=r&&r.canvas,h=l&&l.height,d=l&&l.width;this.id=mt(),this.ctx=r,this.canvas=l,this.width=d,this.height=h,this._options=a,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new Wa,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=As(c=>this.update(c),a.resizeDelay||0),this._dataChanges=[],ti[this.id]=this,r&&l?(yt.listen(this,"complete",Zn),yt.listen(this,"progress",Xa),this._initialize(),this.attached&&this.update()):console.error("Failed to create chart: can't acquire context from the given item")}get aspectRatio(){let{options:{aspectRatio:t,maintainAspectRatio:e},width:s,height:n,_aspectRatio:o}=this;return I(t)?e&&o?o:n?s/n:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}get registry(){return dt}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():Ci(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return Ti(this.canvas,this.ctx),this}stop(){return yt.stop(this),this}resize(t,e){yt.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){let s=this.options,n=this.canvas,o=s.maintainAspectRatio&&this.aspectRatio,a=this.platform.getMaximumSize(n,t,e,o),r=s.devicePixelRatio||this.platform.getDevicePixelRatio(),l=this.width?"resize":"attach";this.width=a.width,this.height=a.height,this._aspectRatio=this.aspectRatio,Ci(this,r,!0)&&(this.notifyPlugins("resize",{size:a}),W(s.onResize,[this,a],this),this.attached&&this._doResize(l)&&this.render())}ensureScalesHaveIDs(){V(this.options.scales||{},(t,e)=>{t.id=e})}buildOrUpdateScales(){let t=this.options,e=t.scales,s=this.scales,n=Object.keys(s).reduce((a,r)=>(a[r]=!1,a),{}),o=[];e&&(o=o.concat(Object.keys(e).map(a=>{let r=e[a],l=Zi(a,r),h=l==="r",d=l==="x";return{options:r,dposition:h?"chartArea":d?"bottom":"left",dtype:h?"radialLinear":d?"category":"linear"}}))),V(o,a=>{let r=a.options,l=r.id,h=Zi(l,r),d=A(r.type,a.dtype);r.position!==void 0&&Kn(r.position,h)===Kn(a.dposition)||(r.position=a.dposition),n[l]=!0;let c=null;l in s&&s[l].type===d?c=s[l]:(c=new(dt.getScale(d))({id:l,type:d,ctx:this.ctx,chart:this}),s[c.id]=c),c.init(r,t)}),V(n,(a,r)=>{a||delete s[r]}),V(s,a=>{tt.configure(this,a,a.options),tt.addBox(this,a)})}_updateMetasets(){let t=this._metasets,e=this.data.datasets.length,s=t.length;if(t.sort((n,o)=>n.index-o.index),s>e){for(let n=e;ne.length&&delete this._stacks,t.forEach((s,n)=>{e.filter(o=>o===s._dataset).length===0&&this._destroyDatasetMeta(n)})}buildOrUpdateControllers(){let t=[],e=this.data.datasets,s,n;for(this._removeUnreferencedMetasets(),s=0,n=e.length;s{this.getDatasetMeta(e).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){let e=this.config;e.update();let s=this._options=e.createResolver(e.chartOptionScopes(),this.getContext()),n=this._animationsDisabled=!s.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0})===!1)return;let o=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let a=0;for(let h=0,d=this.data.datasets.length;h{h.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(Gn("z","_idx"));let{_active:r,_lastEvent:l}=this;l?this._eventHandler(l,!0):r.length&&this._updateHoverStyles(r,r,!0),this.render()}_updateScales(){V(this.scales,t=>{tt.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){let t=this.options,e=new Set(Object.keys(this._listeners)),s=new Set(t.events);hi(e,s)&&!!this._responsiveListeners===t.responsive||(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){let{_hiddenIndices:t}=this,e=this._getUniformDataChanges()||[];for(let{method:s,start:n,count:o}of e)qa(t,n,s==="_removeElements"?-o:o)}_getUniformDataChanges(){let t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];let e=this.data.datasets.length,s=o=>new Set(t.filter(a=>a[0]===o).map((a,r)=>r+","+a.splice(1).join(","))),n=s(0);for(let o=1;oo.split(",")).map(o=>({method:o[1],start:+o[2],count:+o[3]}))}_updateLayout(t){if(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;tt.update(this,this.width,this.height,t);let e=this.chartArea,s=e.width<=0||e.height<=0;this._layers=[],V(this.boxes,n=>{s&&n.position==="chartArea"||(n.configure&&n.configure(),this._layers.push(...n._layers()))},this),this._layers.forEach((n,o)=>{n._idx=o}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})!==!1){for(let e=0,s=this.data.datasets.length;e=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){let e=this.ctx,s=t._clip,n=!s.disabled,o=(function(r,l){let{xScale:h,yScale:d}=r;return h&&d?{left:ei(h,l,"left"),right:ei(h,l,"right"),top:ei(d,l,"top"),bottom:ei(d,l,"bottom")}:l})(t,this.chartArea),a={meta:t,index:t.index,cancelable:!0};this.notifyPlugins("beforeDatasetDraw",a)!==!1&&(n&&me(e,{left:s.left===!1?0:o.left-s.left,right:s.right===!1?this.width:o.right+s.right,top:s.top===!1?0:o.top-s.top,bottom:s.bottom===!1?this.height:o.bottom+s.bottom}),t.controller.draw(),n&&be(e),a.cancelable=!1,this.notifyPlugins("afterDatasetDraw",a))}isPointInArea(t){return vt(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,e,s,n){let o=mn.modes[e];return typeof o=="function"?o(this,t,s,n):[]}getDatasetMeta(t){let e=this.data.datasets[t],s=this._metasets,n=s.filter(o=>o&&o._dataset===e).pop();return n||(n={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e&&e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1},s.push(n)),n}getContext(){return this.$context||(this.$context=Ot(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){let e=this.data.datasets[t];if(!e)return!1;let s=this.getDatasetMeta(t);return typeof s.hidden=="boolean"?!s.hidden:!e.hidden}setDatasetVisibility(t,e){this.getDatasetMeta(t).hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,s){let n=s?"show":"hide",o=this.getDatasetMeta(t),a=o.controller._resolveAnimations(void 0,n);Zt(e)?(o.data[e].hidden=!s,this.update()):(this.setDatasetVisibility(t,s),a.update(o,{visible:s}),this.update(r=>r.datasetIndex===t?n:void 0))}hide(t,e){this._updateVisibility(t,e,!1)}show(t,e){this._updateVisibility(t,e,!0)}_destroyDatasetMeta(t){let e=this._metasets[t];e&&e.controller&&e.controller._destroy(),delete this._metasets[t]}_stop(){let t,e;for(this.stop(),yt.remove(this),t=0,e=this.data.datasets.length;t{e.addEventListener(this,o,a),t[o]=a},n=(o,a,r)=>{o.offsetX=a,o.offsetY=r,this._eventHandler(o)};V(this.options.events,o=>s(o,n))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});let t=this._responsiveListeners,e=this.platform,s=(l,h)=>{e.addEventListener(this,l,h),t[l]=h},n=(l,h)=>{t[l]&&(e.removeEventListener(this,l,h),delete t[l])},o=(l,h)=>{this.canvas&&this.resize(l,h)},a,r=()=>{n("attach",r),this.attached=!0,this.resize(),s("resize",o),s("detach",a)};a=()=>{this.attached=!1,n("resize",o),this._stop(),this._resize(0,0),s("attach",r)},e.isAttached(this.canvas)?r():a()}unbindEvents(){V(this._listeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._listeners={},V(this._responsiveListeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,e,s){let n=s?"set":"remove",o,a,r,l;for(e==="dataset"&&(o=this.getDatasetMeta(t[0].datasetIndex),o.controller["_"+n+"DatasetHoverStyle"]()),r=0,l=t.length;r{let a=this.getDatasetMeta(n);if(!a)throw new Error("No dataset found at index "+n);return{datasetIndex:n,element:a.data[o],index:o}});!re(s,e)&&(this._active=s,this._lastEvent=null,this._updateHoverStyles(s,e))}notifyPlugins(t,e,s){return this._plugins.notify(this,t,e,s)}isPluginEnabled(t){return this._plugins._cache.filter(e=>e.plugin.id===t).length===1}_updateHoverStyles(t,e,s){let n=this.options.hover,o=(l,h)=>l.filter(d=>!h.some(c=>d.datasetIndex===c.datasetIndex&&d.index===c.index)),a=o(e,t),r=s?t:o(t,e);a.length&&this.updateHoverStyle(a,n.mode,!1),r.length&&n.mode&&this.updateHoverStyle(r,n.mode,!0)}_eventHandler(t,e){let s={event:t,replay:e,cancelable:!0,inChartArea:this.isPointInArea(t)},n=a=>(a.options.events||this.options.events).includes(t.native.type);if(this.notifyPlugins("beforeEvent",s,n)===!1)return;let o=this._handleEvent(t,e,s.inChartArea);return s.cancelable=!1,this.notifyPlugins("afterEvent",s,n),(o||s.changed)&&this.render(),this}_handleEvent(t,e,s){let{_active:n=[],options:o}=this,a=e,r=this._getActiveElements(t,n,s,a),l=_s(t),h=(function(c,u,f,p){return f&&c.type!=="mouseout"?p?u:c:null})(t,this._lastEvent,s,l);s&&(this._lastEvent=null,W(o.onHover,[t,r,this],this),l&&W(o.onClick,[t,r,this],this));let d=!re(r,n);return(d||e)&&(this._active=r,this._updateHoverStyles(r,n,e)),this._lastEvent=h,d}_getActiveElements(t,e,s,n){if(t.type==="mouseout")return[];if(!s)return e;let o=this.options.hover;return this.getElementsAtEventForMode(t,o.mode,o,n)}}function to(){return V(K.instances,i=>i._plugins.invalidate())}function Xt(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class Ji{static override(t){Object.assign(Ji.prototype,t)}options;constructor(t){this.options=t||{}}init(){}formats(){return Xt()}parse(){return Xt()}format(){return Xt()}add(){return Xt()}diff(){return Xt()}startOf(){return Xt()}endOf(){return Xt()}}var eo={_date:Ji};function Ka(i){let t=i.iScale,e=(function(h,d){if(!h._cache.$bar){let c=h.getMatchingVisibleMetas(d),u=[];for(let f=0,p=c.length;ff-p))}return h._cache.$bar})(t,i.type),s,n,o,a,r=t._length,l=()=>{o!==32767&&o!==-32768&&(Zt(a)&&(r=Math.min(r,Math.abs(o-a)||r)),a=o)};for(s=0,n=e.length;sMath.abs(c)&&(u=c,f=d),o[a.axis]=f,o._custom={barStart:u,barEnd:f,start:l,end:h,min:d,max:c}})(i,t,e,s):t[e.axis]=e.parse(i,s),t}function so(i,t,e,s){let n=i.iScale,o=i.vScale,a=n.getLabels(),r=n===o,l=[],h,d,c,u;for(h=e,d=e+s;hc.x,f="left",p="right"):(u=c.baset!=="spacing",_indexable:t=>t!=="spacing"&&!t.startsWith("borderDash")&&!t.startsWith("hoverBorderDash")};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){let e=t.data;if(e.labels.length&&e.datasets.length){let{labels:{pointStyle:s,color:n}}=t.legend.options;return e.labels.map((o,a)=>{let r=t.getDatasetMeta(0).controller.getStyle(a);return{text:o,fillStyle:r.backgroundColor,strokeStyle:r.borderColor,fontColor:n,lineWidth:r.borderWidth,pointStyle:s,hidden:!t.getDataVisibility(a),index:a}})}return[]}},onClick(t,e,s){s.chart.toggleDataVisibility(e.index),s.chart.update()}}}};constructor(t,e){super(t,e),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,e){let s=this.getDataset().data,n=this._cachedMeta;if(this._parsing===!1)n._parsed=s;else{let o,a,r=l=>+s[l];if(z(s[t])){let{key:l="value"}=this._parsing;r=h=>+kt(s[h],l)}for(o=t,a=t+e;oQt(ft,T,P,!0)?1:Math.max(gt,gt*w,pt,pt*w),et=(ft,gt,pt)=>Qt(ft,T,P,!0)?-1:Math.min(gt,gt*w,pt,pt*w),ot=B(0,C,R),at=B(q,O,H),ht=et($,C,R),ut=et($+q,O,H);k=(ot-ht)/2,D=(at-ut)/2,S=-(ot+ht)/2,E=-(at+ut)/2}return{ratioX:k,ratioY:D,offsetX:S,offsetY:E}})(c,d,l),m=(s.width-a)/u,b=(s.height-a)/f,y=Math.max(Math.min(m,b)/2,0),_=bt(this.options.radius,y),x=(_-Math.max(_*l,0))/this._getVisibleDatasetWeightTotal();this.offsetX=p*_,this.offsetY=g*_,n.total=this.calculateTotal(),this.outerRadius=_-x*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-x*h,0),this.updateElements(o,0,o.length,t)}_circumference(t,e){let s=this.options,n=this._cachedMeta,o=this._getCircumference();return e&&s.animation.animateRotate||!this.chart.getDataVisibility(t)||n._parsed[t]===null||n.data[t].hidden?0:this.calculateCircumference(n._parsed[t]*o/Y)}updateElements(t,e,s,n){let o=n==="reset",a=this.chart,r=a.chartArea,l=a.options.animation,h=(r.left+r.right)/2,d=(r.top+r.bottom)/2,c=o&&l.animateScale,u=c?0:this.innerRadius,f=c?0:this.outerRadius,{sharedOptions:p,includeOptions:g}=this._getSharedOptions(e,n),m,b=this._getRotation();for(m=0;m0&&!isNaN(t)?Y*(Math.abs(t)/e):0}getLabelAndValue(t){let e=this._cachedMeta,s=this.chart,n=s.data.labels||[],o=ee(e._parsed[t],s.options.locale);return{label:n[t]||"",value:o}}getMaxBorderWidth(t){let e=0,s=this.chart,n,o,a,r,l;if(!t){for(n=0,o=s.data.datasets.length;n{let r=t.getDatasetMeta(0).controller.getStyle(a);return{text:o,fillStyle:r.backgroundColor,strokeStyle:r.borderColor,fontColor:n,lineWidth:r.borderWidth,pointStyle:s,hidden:!t.getDataVisibility(a),index:a}})}return[]}},onClick(t,e,s){s.chart.toggleDataVisibility(e.index),s.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){let e=this._cachedMeta,s=this.chart,n=s.data.labels||[],o=ee(e._parsed[t].r,s.options.locale);return{label:n[t]||"",value:o}}parseObjectData(t,e,s,n){return zi.bind(this)(t,e,s,n)}update(t){let e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,e.length,t)}getMinMax(){let t=this._cachedMeta,e={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return t.data.forEach((s,n)=>{let o=this.getParsed(n).r;!isNaN(o)&&this.chart.getDataVisibility(n)&&(oe.max&&(e.max=o))}),e}_updateRadius(){let t=this.chart,e=t.chartArea,s=t.options,n=Math.min(e.right-e.left,e.bottom-e.top),o=Math.max(n/2,0),a=(o-Math.max(s.cutoutPercentage?o/100*s.cutoutPercentage:1,0))/t.getVisibleDatasetCount();this.outerRadius=o-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(t,e,s,n){let o=n==="reset",a=this.chart,r=a.options.animation,l=this._cachedMeta.rScale,h=l.xCenter,d=l.yCenter,c=l.getIndexAngle(0)-.5*$,u,f=c,p=360/this.countVisibleElements();for(u=0;u{!isNaN(this.getParsed(n).r)&&this.chart.getDataVisibility(n)&&e++}),e}_computeAngle(t,e,s){return this.chart.getDataVisibility(t)?rt(this.resolveDataElementOptions(t,e).angle||s):0}}var ro=Object.freeze({__proto__:null,BarController:class extends Ct{static id="bar";static defaults={datasetElementType:!1,dataElementType:"bar",categoryPercentage:.8,barPercentage:.9,grouped:!0,animations:{numbers:{type:"number",properties:["x","y","base","width","height"]}}};static overrides={scales:{_index_:{type:"category",offset:!0,grid:{offset:!0}},_value_:{type:"linear",beginAtZero:!0}}};parsePrimitiveData(i,t,e,s){return so(i,t,e,s)}parseArrayData(i,t,e,s){return so(i,t,e,s)}parseObjectData(i,t,e,s){let{iScale:n,vScale:o}=i,{xAxisKey:a="x",yAxisKey:r="y"}=this._parsing,l=n.axis==="x"?a:r,h=o.axis==="x"?a:r,d=[],c,u,f,p;for(c=e,u=e+s;ch.controller.options.grouped),n=e.options.stacked,o=[],a=this._cachedMeta.controller.getParsed(t),r=a&&a[e.axis],l=h=>{let d=h._parsed.find(u=>u[e.axis]===r),c=d&&d[h.vScale.axis];if(I(c)||isNaN(c))return!0};for(let h of s)if((t===void 0||!l(h))&&((n===!1||o.indexOf(h.stack)===-1||n===void 0&&h.stack===void 0)&&o.push(h.stack),h.index===i))break;return o.length||o.push(void 0),o}_getStackCount(i){return this._getStacks(void 0,i).length}_getStackIndex(i,t,e){let s=this._getStacks(i,e),n=t!==void 0?s.indexOf(t):-1;return n===-1?s.length-1:n}_getRuler(){let i=this.options,t=this._cachedMeta,e=t.iScale,s=[],n,o;for(n=0,o=t.data.length;n=w?1:-1)})(c,t,a)*o,u===a&&(m-=c/2);let b=t.getPixelForDecimal(0),y=t.getPixelForDecimal(1),_=Math.min(b,y),x=Math.max(b,y);m=Math.max(Math.min(m,x),_),d=m+c,e&&!h&&(r._stacks[t.axis]._visualValues[s]=t.getValueForPixel(d)-t.getValueForPixel(m))}if(m===t.getPixelForValue(a)){let b=ct(c)*t.getLineWidthForValue(a)/2;m+=b,c-=b}return{size:c,base:m,head:d,center:d+c/2}}_calculateBarIndexPixels(i,t){let e=t.scale,s=this.options,n=s.skipNull,o=A(s.maxBarThickness,1/0),a,r;if(t.grouped){let l=n?this._getStackCount(i):t.stackCount,h=s.barThickness==="flex"?(function(c,u,f,p){let g=u.pixels,m=g[c],b=c>0?g[c-1]:null,y=c=0;--e)t=Math.max(t,i[e].size(this.resolveDataElementOptions(e))/2);return t>0&&t}getLabelAndValue(i){let t=this._cachedMeta,e=this.chart.data.labels||[],{xScale:s,yScale:n}=t,o=this.getParsed(i),a=s.getLabelForValue(o.x),r=n.getLabelForValue(o.y),l=o._custom;return{label:e[i]||"",value:"("+a+", "+r+(l?", "+l:"")+")"}}update(i){let t=this._cachedMeta.data;this.updateElements(t,0,t.length,i)}updateElements(i,t,e,s){let n=s==="reset",{iScale:o,vScale:a}=this._cachedMeta,{sharedOptions:r,includeOptions:l}=this._getSharedOptions(t,s),h=o.axis,d=a.axis;for(let c=t;c0&&this.getParsed(t-1);for(let x=0;x=b){M.skip=!0;continue}let w=this.getParsed(x),k=I(w[u]),D=M[c]=o.getPixelForValue(w[c],x),S=M[u]=n||k?a.getBasePixel():a.getPixelForValue(r?this.applyStack(a,w,r):w[u],x);M.skip=isNaN(D)||isNaN(S)||k,M.stop=x>0&&Math.abs(w[c]-_[c])>g,p&&(M.parsed=w,M.raw=l.data[x]),d&&(M.options=h||this.resolveDataElementOptions(x,v.active?"active":s)),m||this.updateElement(v,x,M,s),_=w}}getMaxOverflow(){let i=this._cachedMeta,t=i.dataset,e=t.options&&t.options.borderWidth||0,s=i.data||[];if(!s.length)return e;let n=s[0].size(this.resolveDataElementOptions(0)),o=s[s.length-1].size(this.resolveDataElementOptions(s.length-1));return Math.max(e,n,o)/2}draw(){let i=this._cachedMeta;i.dataset.updateControlPoints(this.chart.chartArea,i.iScale.axis),super.draw()}},PieController:class extends ts{static id="pie";static defaults={cutout:0,rotation:0,circumference:360,radius:"100%"}},PolarAreaController:ao,RadarController:class extends Ct{static id="radar";static defaults={datasetElementType:"line",dataElementType:"point",indexAxis:"r",showLine:!0,elements:{line:{fill:"start"}}};static overrides={aspectRatio:1,scales:{r:{type:"radialLinear"}}};getLabelAndValue(i){let t=this._cachedMeta.vScale,e=this.getParsed(i);return{label:t.getLabels()[i],value:""+t.getLabelForValue(e[t.axis])}}parseObjectData(i,t,e,s){return zi.bind(this)(i,t,e,s)}update(i){let t=this._cachedMeta,e=t.dataset,s=t.data||[],n=t.iScale.getLabels();if(e.points=s,i!=="resize"){let o=this.resolveDatasetElementOptions(i);this.options.showLine||(o.borderWidth=0);let a={_loop:!0,_fullLoop:n.length===s.length,options:o};this.updateElement(e,void 0,a,i)}this.updateElements(s,0,s.length,i)}updateElements(i,t,e,s){let n=this._cachedMeta.rScale,o=s==="reset";for(let a=t;a0&&this.getParsed(t-1);for(let _=t;_0&&Math.abs(v[u]-y[u])>m,g&&(M.parsed=v,M.raw=l.data[_]),c&&(M.options=d||this.resolveDataElementOptions(_,x.active?"active":s)),b||this.updateElement(x,_,M,s),y=v}this.updateSharedOptions(d,s,h)}getMaxOverflow(){let i=this._cachedMeta,t=i.data||[];if(!this.options.showLine){let a=0;for(let r=t.length-1;r>=0;--r)a=Math.max(a,t[r].size(this.resolveDataElementOptions(r))/2);return a>0&&a}let e=i.dataset,s=e.options&&e.options.borderWidth||0;if(!t.length)return s;let n=t[0].size(this.resolveDataElementOptions(0)),o=t[t.length-1].size(this.resolveDataElementOptions(t.length-1));return Math.max(s,n,o)/2}}});function Ja(i,t,e,s){let n=Xe(i.options.borderRadius,["outerStart","outerEnd","innerStart","innerEnd"]),o=(e-t)/2,a=Math.min(o,s*t/2),r=l=>{let h=(e-Math.min(o,l))*s/2;return Z(l,0,Math.min(o,h))};return{outerStart:r(n.outerStart),outerEnd:r(n.outerEnd),innerStart:Z(n.innerStart,0,a),innerEnd:Z(n.innerEnd,0,a)}}function ae(i,t,e,s){return{x:e+i*Math.cos(t),y:s+i*Math.sin(t)}}function ii(i,t,e,s,n,o){let{x:a,y:r,startAngle:l,pixelMargin:h,innerRadius:d}=t,c=Math.max(t.outerRadius+s+e-h,0),u=d>0?d+s+e+h:0,f=0,p=n-l;if(s){let C=((d>0?d-s:0)+(c>0?c-s:0))/2;f=(p-(C!==0?p*C/(C+s):p))/2}let g=(p-Math.max(.001,p*c-e/$)/c)/2,m=l+g+f,b=n-g-f,{outerStart:y,outerEnd:_,innerStart:x,innerEnd:v}=Ja(t,u,c,b-m),M=c-y,w=c-_,k=m+y/M,D=b-_/w,S=u+x,E=u+v,T=m+x/S,P=b-v/E;if(i.beginPath(),o){let C=(k+D)/2;if(i.arc(a,r,c,k,C),i.arc(a,r,c,C,D),_>0){let B=ae(w,D,a,r);i.arc(B.x,B.y,_,D,b+q)}let O=ae(E,b,a,r);if(i.lineTo(O.x,O.y),v>0){let B=ae(E,P,a,r);i.arc(B.x,B.y,v,b+q,P+Math.PI)}let R=(b-v/u+(m+x/u))/2;if(i.arc(a,r,u,b-v/u,R,!0),i.arc(a,r,u,R,m+x/u,!0),x>0){let B=ae(S,T,a,r);i.arc(B.x,B.y,x,T+Math.PI,m-q)}let H=ae(M,m,a,r);if(i.lineTo(H.x,H.y),y>0){let B=ae(M,k,a,r);i.arc(B.x,B.y,y,m-q,k)}}else{i.moveTo(a,r);let C=Math.cos(k)*c+a,O=Math.sin(k)*c+r;i.lineTo(C,O);let R=Math.cos(D)*c+a,H=Math.sin(D)*c+r;i.lineTo(R,H)}i.closePath()}function Qa(i,t,e,s,n){let{fullCircles:o,startAngle:a,circumference:r,options:l}=t,{borderWidth:h,borderJoinStyle:d,borderDash:c,borderDashOffset:u}=l,f=l.borderAlign==="inner";if(!h)return;i.setLineDash(c||[]),i.lineDashOffset=u,f?(i.lineWidth=2*h,i.lineJoin=d||"round"):(i.lineWidth=h,i.lineJoin=d||"bevel");let p=t.endAngle;if(o){ii(i,t,e,s,p,n);for(let g=0;g_?(k=_/w,g.arc(x,v,w,b+k,y-k,!0)):g.arc(x,v,_,b+q,y-q),g.closePath(),g.clip()})(i,t,p),o||(ii(i,t,e,s,p,n),i.stroke())}function lo(i,t,e=t){i.lineCap=A(e.borderCapStyle,t.borderCapStyle),i.setLineDash(A(e.borderDash,t.borderDash)),i.lineDashOffset=A(e.borderDashOffset,t.borderDashOffset),i.lineJoin=A(e.borderJoinStyle,t.borderJoinStyle),i.lineWidth=A(e.borderWidth,t.borderWidth),i.strokeStyle=A(e.borderColor,t.borderColor)}function tr(i,t,e){i.lineTo(e.x,e.y)}function ho(i,t,e={}){let s=i.length,{start:n=0,end:o=s-1}=e,{start:a,end:r}=t,l=Math.max(n,a),h=Math.min(o,r),d=nr&&o>r;return{count:s,start:l,loop:t.loop,ilen:h(a+(h?r-x:x))%o,_=()=>{f!==p&&(i.lineTo(m,p),i.lineTo(m,f),i.lineTo(m,g))};for(l&&(c=n[y(0)],i.moveTo(c.x,c.y)),d=0;d<=r;++d){if(c=n[y(d)],c.skip)continue;let x=c.x,v=c.y,M=0|x;M===u?(vp&&(p=v),m=(b*m+x)/++b):(_(),i.lineTo(x,v),u=M,b=0,f=p=v),g=v}_()}function es(i){let t=i.options,e=t.borderDash&&t.borderDash.length;return i._decimated||i._loop||t.tension||t.cubicInterpolationMode==="monotone"||t.stepped||e?er:ir}let sr=typeof Path2D=="function";function nr(i,t,e,s){sr&&!t.options.segment?(function(n,o,a,r){let l=o._path;l||(l=o._path=new Path2D,o.path(l,a,r)&&l.closePath()),lo(n,o.options),n.stroke(l)})(i,t,e,s):(function(n,o,a,r){let{segments:l,options:h}=o,d=es(o);for(let c of l)lo(n,h,c.style),n.beginPath(),d(n,o,c,{start:a,end:a+r-1})&&n.closePath(),n.stroke()})(i,t,e,s)}class si extends Mt{static id="line";static defaults={borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:"default",fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};static descriptors={_scriptable:!0,_indexable:t=>t!=="borderDash"&&t!=="fill"};constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,e){let s=this.options;if((s.tension||s.cubicInterpolationMode==="monotone")&&!s.stepped&&!this._pointsUpdated){let n=s.spanGaps?this._loop:this._fullLoop;sn(this._points,s,t,n,e),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=un(this,this.options.segment))}first(){let t=this.segments,e=this.points;return t.length&&e[t[0].start]}last(){let t=this.segments,e=this.points,s=t.length;return s&&e[t[s-1].end]}interpolate(t,e){let s=this.options,n=t[e],o=this.points,a=Ni(this,{property:e,start:n,end:n});if(!a.length)return;let r=[],l=(function(c){return c.stepped?an:c.tension||c.cubicInterpolationMode==="monotone"?rn:Vt})(s),h,d;for(h=0,d=a.length;hi!=="borderDash"};circumference;endAngle;fullCircles;innerRadius;outerRadius;pixelMargin;startAngle;constructor(i){super(),this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,i&&Object.assign(this,i)}inRange(i,t,e){let s=this.getProps(["x","y"],e),{angle:n,distance:o}=gi(s,{x:i,y:t}),{startAngle:a,endAngle:r,innerRadius:l,outerRadius:h,circumference:d}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],e),c=(this.options.spacing+this.options.borderWidth)/2,u=A(d,r-a),f=Qt(n,a,r)&&a!==r,p=u>=Y||f,g=xt(o,l+c,h+c);return p&&g}getCenterPoint(i){let{x:t,y:e,startAngle:s,endAngle:n,innerRadius:o,outerRadius:a}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],i),{offset:r,spacing:l}=this.options,h=(s+n)/2,d=(o+a+l+r)/2;return{x:t+Math.cos(h)*d,y:e+Math.sin(h)*d}}tooltipPosition(i){return this.getCenterPoint(i)}draw(i){let{options:t,circumference:e}=this,s=(t.offset||0)/4,n=(t.spacing||0)/2,o=t.circular;if(this.pixelMargin=t.borderAlign==="inner"?.33:0,this.fullCircles=e>Y?Math.floor(e/Y):0,e===0||this.innerRadius<0||this.outerRadius<0)return;i.save();let a=(this.startAngle+this.endAngle)/2;i.translate(Math.cos(a)*s,Math.sin(a)*s);let r=s*(1-Math.sin(Math.min($,e||0)));i.fillStyle=t.backgroundColor,i.strokeStyle=t.borderColor,(function(l,h,d,c,u){let{fullCircles:f,startAngle:p,circumference:g}=h,m=h.endAngle;if(f){ii(l,h,d,c,m,u);for(let b=0;b(typeof a=="string"?(r=o.push(a)-1,l.unshift({index:r,label:a})):isNaN(a)&&(r=null),r))(i,t,e,s):n!==i.lastIndexOf(t)?e:n}function fo(i){let t=this.getLabels();return i>=0&&in=e?n:l,r=l=>o=s?o:l;if(t){let l=ct(n),h=ct(o);l<0&&h<0?r(0):l>0&&h>0&&a(0)}if(n===o){let l=o===0?1:Math.abs(.05*o);r(o+l),t||a(n-l)}this.min=n,this.max=o}getTickLimit(){let t=this.options.ticks,e,{maxTicksLimit:s,stepSize:n}=t;return n?(e=Math.ceil(this.max/n)-Math.floor(this.min/n)+1,e>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${n} would result generating up to ${e} ticks. Limiting to 1000.`),e=1e3)):(e=this.computeTickLimit(),s=s||11),s&&(e=Math.min(s,e)),e}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){let t=this.options,e=t.ticks,s=this.getTickLimit();s=Math.max(2,s);let n=(function(o,a){let r=[],{bounds:l,step:h,min:d,max:c,precision:u,count:f,maxTicks:p,maxDigits:g,includeBounds:m}=o,b=h||1,y=p-1,{min:_,max:x}=a,v=!I(d),M=!I(c),w=!I(f),k=(x-_)/(g+1),D,S,E,T,P=di((x-_)/y/b)*b;if(P<1e-14&&!v&&!M)return[{value:_},{value:x}];T=Math.ceil(x/P)-Math.floor(_/P),T>y&&(P=di(T*P/y/b)*b),I(u)||(D=Math.pow(10,u),P=Math.ceil(P*D)/D),l==="ticks"?(S=Math.floor(_/P)*P,E=Math.ceil(x/P)*P):(S=_,E=x),v&&M&&h&&ws((c-d)/h,P/1e3)?(T=Math.round(Math.min((c-d)/P,p)),P=(c-d)/T,S=d,E=c):w?(S=v?d:S,E=M?c:E,T=f-1,P=(E-S)/T):(T=(E-S)/P,T=Jt(T,Math.round(T),P/1e3)?Math.round(T):Math.ceil(T));let C=Math.max(fi(P),fi(S));D=Math.pow(10,I(u)?C:u),S=Math.round(S*D)/D,E=Math.round(E*D)/D;let O=0;for(v&&(m&&S!==d?(r.push({value:d}),Sc)break;r.push({value:R})}return M&&m&&E!==c?r.length&&Jt(r[r.length-1].value,c,go(c,k,o))?r[r.length-1].value=c:r.push({value:c}):M&&E!==c||r.push({value:E}),r})({maxTicks:s,bounds:t.bounds,min:t.min,max:t.max,precision:e.precision,step:e.stepSize,count:e.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:e.minRotation||0,includeBounds:e.includeBounds!==!1},this._range||this);return t.bounds==="ticks"&&ui(n,this,"value"),t.reverse?(n.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),n}configure(){let t=this.ticks,e=this.min,s=this.max;if(super.configure(),this.options.offset&&t.length){let n=(s-e)/Math.max(t.length-1,1)/2;e-=n,s+=n}this._startValue=e,this._endValue=s,this._valueRange=s-e}getLabelForValue(t){return ee(t,this.chart.options.locale,this.options.ticks.format)}}class lr extends ni{static id="linear";static defaults={ticks:{callback:fe.formatters.numeric}};determineDataLimits(){let{min:t,max:e}=this.getMinMax(!0);this.min=U(t)?t:0,this.max=U(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){let t=this.isHorizontal(),e=t?this.width:this.height,s=rt(this.options.ticks.minRotation),n=(t?Math.sin(s):Math.cos(s))||.001,o=this._resolveTickFontOptions(0);return Math.ceil(e/Math.min(40,o.lineHeight/n))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}let Pe=i=>Math.floor(Pt(i)),qt=(i,t)=>Math.pow(10,Pe(i)+t);function po(i){return i/Math.pow(10,Pe(i))===1}function mo(i,t,e){let s=Math.pow(10,e),n=Math.floor(i/s);return Math.ceil(t/s)-n}function hr(i,{min:t,max:e}){t=L(i.min,t);let s=[],n=Pe(t),o=(function(p,g){let m=Pe(g-p);for(;mo(p,g,m)>10;)m++;for(;mo(p,g,m)<10;)m--;return Math.min(m,Pe(p))})(t,e),a=o<0?Math.pow(10,Math.abs(o)):1,r=Math.pow(10,o),l=n>o?Math.pow(10,n):0,h=Math.round((t-l)*a)/a,d=Math.floor((t-l)/r/10)*r*10,c=Math.floor((h-d)/Math.pow(10,o)),u=L(i.min,Math.round((l+d+c*Math.pow(10,o))*a)/a);for(;u=10?c=c<15?15:20:c++,c>=20&&(o++,c=2,a=o>=0?1:a),u=Math.round((l+d+c*Math.pow(10,o))*a)/a;let f=L(i.max,u);return s.push({value:f,major:po(f),significand:c}),s}class cr extends Wt{static id="logarithmic";static defaults={ticks:{callback:fe.formatters.logarithmic,major:{enabled:!0}}};constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,e){let s=ni.prototype.parse.apply(this,[t,e]);if(s!==0)return U(s)&&s>0?s:null;this._zero=!0}determineDataLimits(){let{min:t,max:e}=this.getMinMax(!0);this.min=U(t)?Math.max(0,t):null,this.max=U(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!U(this._userMin)&&(this.min=t===qt(this.min,0)?qt(this.min,-1):qt(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){let{minDefined:t,maxDefined:e}=this.getUserBounds(),s=this.min,n=this.max,o=r=>s=t?s:r,a=r=>n=e?n:r;s===n&&(s<=0?(o(1),a(10)):(o(qt(s,-1)),a(qt(n,1)))),s<=0&&o(qt(n,-1)),n<=0&&a(qt(s,1)),this.min=s,this.max=n}buildTicks(){let t=this.options,e=hr({min:this._userMin,max:this._userMax},this);return t.bounds==="ticks"&&ui(e,this,"value"),t.reverse?(e.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),e}getLabelForValue(t){return t===void 0?"0":ee(t,this.chart.options.locale,this.options.ticks.format)}configure(){let t=this.min;super.configure(),this._startValue=Pt(t),this._valueRange=Pt(this.max)-Pt(t)}getPixelForValue(t){return t!==void 0&&t!==0||(t=this.min),t===null||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(Pt(t)-this._startValue)/this._valueRange)}getValueForPixel(t){let e=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+e*this._valueRange)}}function os(i){let t=i.ticks;if(t.display&&i.display){let e=Q(t.backdropPadding);return A(t.font&&t.font.size,X.font.size)+e.height}return 0}function bo(i,t,e,s,n){return i===s||i===n?{start:t-e/2,end:t+e/2}:in?{start:t-e,end:t}:{start:t,end:t+e}}function dr(i){let t={l:i.left+i._padding.left,r:i.right-i._padding.right,t:i.top+i._padding.top,b:i.bottom-i._padding.bottom},e=Object.assign({},t),s=[],n=[],o=i._pointLabels.length,a=i.options.pointLabels,r=a.centerPointLabels?$/o:0;for(let c=0;ct.r&&(r=(s.end-t.r)/o,i.r=Math.max(i.r,t.r+r)),n.startt.b&&(l=(n.end-t.b)/a,i.b=Math.max(i.b,t.b+l))}function fr(i,t,e){let s=i.drawingArea,{extra:n,additionalAngle:o,padding:a,size:r}=e,l=i.getPointPosition(t,s+n+a,o),h=Math.round(Ce(it(l.angle+q))),d=(function(f,p,g){return g===90||g===270?f-=p/2:(g>270||g<90)&&(f-=p),f})(l.y,r.h,h),c=(function(f){return f===0||f===180?"center":f<180?"left":"right"})(h),u=(function(f,p,g){return g==="right"?f-=p:g==="center"&&(f-=p/2),f})(l.x,r.w,c);return{visible:!0,x:l.x,y:d,textAlign:c,left:u,top:d,right:u+r.w,bottom:d+r.h}}function gr(i,t){if(!t)return!0;let{left:e,top:s,right:n,bottom:o}=i;return!(vt({x:e,y:s},t)||vt({x:e,y:o},t)||vt({x:n,y:s},t)||vt({x:n,y:o},t))}function pr(i,t,e){let{left:s,top:n,right:o,bottom:a}=e,{backdropColor:r}=t;if(!I(r)){let l=Bt(t.borderRadius),h=Q(t.backdropPadding);i.fillStyle=r;let d=s-h.left,c=n-h.top,u=o-s+h.width,f=a-n+h.height;Object.values(l).some(p=>p!==0)?(i.beginPath(),ie(i,{x:d,y:c,w:u,h:f,radius:l}),i.fill()):i.fillRect(d,c,u,f)}}function xo(i,t,e,s){let{ctx:n}=i;if(e)n.arc(i.xCenter,i.yCenter,t,0,Y);else{let o=i.getPointPosition(0,t);n.moveTo(o.x,o.y);for(let a=1;at,padding:5,centerPointLabels:!1}};static defaultRoutes={"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"};static descriptors={angleLines:{_fallback:"grid"}};constructor(t){super(t),this.xCenter=void 0,this.yCenter=void 0,this.drawingArea=void 0,this._pointLabels=[],this._pointLabelItems=[]}setDimensions(){let t=this._padding=Q(os(this.options)/2),e=this.width=this.maxWidth-t.width,s=this.height=this.maxHeight-t.height;this.xCenter=Math.floor(this.left+e/2+t.left),this.yCenter=Math.floor(this.top+s/2+t.top),this.drawingArea=Math.floor(Math.min(e,s)/2)}determineDataLimits(){let{min:t,max:e}=this.getMinMax(!1);this.min=U(t)&&!isNaN(t)?t:0,this.max=U(e)&&!isNaN(e)?e:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/os(this.options))}generateTickLabels(t){ni.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map((e,s)=>{let n=W(this.options.pointLabels.callback,[e,s],this);return n||n===0?n:""}).filter((e,s)=>this.chart.getDataVisibility(s))}fit(){let t=this.options;t.display&&t.pointLabels.display?dr(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,e,s,n){this.xCenter+=Math.floor((t-e)/2),this.yCenter+=Math.floor((s-n)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,e,s,n))}getIndexAngle(t){return it(t*(Y/(this._pointLabels.length||1))+rt(this.options.startAngle||0))}getDistanceFromCenterForValue(t){if(I(t))return NaN;let e=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*e:(t-this.min)*e}getValueForDistanceFromCenter(t){if(I(t))return NaN;let e=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-e:this.min+e}getPointLabelContext(t){let e=this._pointLabels||[];if(t>=0&&t=0;p--){let g=d._pointLabelItems[p];if(!g.visible)continue;let m=f.setContext(d.getPointLabelContext(p));pr(u,m,g);let b=G(m.font),{x:y,y:_,textAlign:x}=g;Ft(u,d._pointLabels[p],y,_+b.lineHeight/2,b,{color:m.color,textAlign:x,textBaseline:"middle"})}})(this,a),n.display&&this.ticks.forEach((d,c)=>{if(c!==0||c===0&&this.min<0){l=this.getDistanceFromCenterForValue(d.value);let u=this.getContext(c),f=n.setContext(u),p=o.setContext(u);(function(g,m,b,y,_){let x=g.ctx,v=m.circular,{color:M,lineWidth:w}=m;!v&&!y||!M||!w||b<0||(x.save(),x.strokeStyle=M,x.lineWidth=w,x.setLineDash(_.dash||[]),x.lineDashOffset=_.dashOffset,x.beginPath(),xo(g,b,v,y),x.closePath(),x.stroke(),x.restore())})(this,f,l,a,p)}}),s.display){for(t.save(),r=a-1;r>=0;r--){let d=s.setContext(this.getPointLabelContext(r)),{color:c,lineWidth:u}=d;u&&c&&(t.lineWidth=u,t.strokeStyle=c,t.setLineDash(d.borderDash),t.lineDashOffset=d.borderDashOffset,l=this.getDistanceFromCenterForValue(e.reverse?this.min:this.max),h=this.getPointPosition(r,l),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(h.x,h.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){let t=this.ctx,e=this.options,s=e.ticks;if(!s.display)return;let n=this.getIndexAngle(0),o,a;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(n),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((r,l)=>{if(l===0&&this.min>=0&&!e.reverse)return;let h=s.setContext(this.getContext(l)),d=G(h.font);if(o=this.getDistanceFromCenterForValue(this.ticks[l].value),h.showLabelBackdrop){t.font=d.string,a=t.measureText(r.label).width,t.fillStyle=h.backdropColor;let c=Q(h.backdropPadding);t.fillRect(-a/2-c.left,-o-d.size/2-c.top,a+c.width,d.size+c.height)}Ft(t,r.label,0,-o,d,{color:h.color,strokeColor:h.textStrokeColor,strokeWidth:h.textStrokeWidth})}),t.restore()}drawTitle(){}}let oi={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},st=Object.keys(oi);function _o(i,t){return i-t}function yo(i,t){if(I(t))return null;let e=i._adapter,{parser:s,round:n,isoWeekday:o}=i._parseOpts,a=t;return typeof s=="function"&&(a=s(a)),U(a)||(a=typeof s=="string"?e.parse(a,s):e.parse(a)),a===null?null:(n&&(a=n!=="week"||!Ht(o)&&o!==!0?e.startOf(a,n):e.startOf(a,"isoWeek",o)),+a)}function vo(i,t,e,s){let n=st.length;for(let o=st.indexOf(i);o=t?e[s]:e[n]]=!0}}else i[t]=!0}function wo(i,t,e){let s=[],n={},o=t.length,a,r;for(a=0;a=0&&(h[m].major=!0);return h})(i,s,n,e):s}class as extends Wt{static id="time";static defaults={bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",callback:!1,major:{enabled:!1}}};constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,e={}){let s=t.time||(t.time={}),n=this._adapter=new eo._date(t.adapters.date);n.init(e),Gt(s.displayFormats,n.formats()),this._parseOpts={parser:s.parser,round:s.round,isoWeekday:s.isoWeekday},super.init(t),this._normalized=e.normalized}parse(t,e){return t===void 0?null:yo(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){let t=this.options,e=this._adapter,s=t.time.unit||"day",{min:n,max:o,minDefined:a,maxDefined:r}=this.getUserBounds();function l(h){a||isNaN(h.min)||(n=Math.min(n,h.min)),r||isNaN(h.max)||(o=Math.max(o,h.max))}a&&r||(l(this._getLabelBounds()),t.bounds==="ticks"&&t.ticks.source==="labels"||l(this.getMinMax(!1))),n=U(n)&&!isNaN(n)?n:+e.startOf(Date.now(),s),o=U(o)&&!isNaN(o)?o:+e.endOf(Date.now(),s)+1,this.min=Math.min(n,o-1),this.max=Math.max(n+1,o)}_getLabelBounds(){let t=this.getLabelTimestamps(),e=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],s=t[t.length-1]),{min:e,max:s}}buildTicks(){let t=this.options,e=t.time,s=t.ticks,n=s.source==="labels"?this.getLabelTimestamps():this._generate();t.bounds==="ticks"&&n.length&&(this.min=this._userMin||n[0],this.max=this._userMax||n[n.length-1]);let o=this.min,a=Ds(n,o,this.max);return this._unit=e.unit||(s.autoSkip?vo(e.minUnit,this.min,this.max,this._getLabelCapacity(o)):(function(r,l,h,d,c){for(let u=st.length-1;u>=st.indexOf(h);u--){let f=st[u];if(oi[f].common&&r._adapter.diff(c,d,f)>=l-1)return f}return st[h?st.indexOf(h):0]})(this,a.length,e.minUnit,this.min,this.max)),this._majorUnit=s.major.enabled&&this._unit!=="year"?(function(r){for(let l=st.indexOf(r)+1,h=st.length;l+t.value))}initOffsets(t=[]){let e,s,n=0,o=0;this.options.offset&&t.length&&(e=this.getDecimalForValue(t[0]),n=t.length===1?1-e:(this.getDecimalForValue(t[1])-e)/2,s=this.getDecimalForValue(t[t.length-1]),o=t.length===1?s:(s-this.getDecimalForValue(t[t.length-2]))/2);let a=t.length<3?.5:.25;n=Z(n,0,a),o=Z(o,0,a),this._offsets={start:n,end:o,factor:1/(n+1+o)}}_generate(){let t=this._adapter,e=this.min,s=this.max,n=this.options,o=n.time,a=o.unit||vo(o.minUnit,e,s,this._getLabelCapacity(e)),r=A(n.ticks.stepSize,1),l=a==="week"&&o.isoWeekday,h=Ht(l)||l===!0,d={},c,u,f=e;if(h&&(f=+t.startOf(f,"isoWeek",l)),f=+t.startOf(f,h?"day":a),t.diff(s,e,a)>1e5*r)throw new Error(e+" and "+s+" are too far apart with stepSize of "+r+" "+a);let p=n.ticks.source==="data"&&this.getDataTimestamps();for(c=f,u=0;c+g)}getLabelForValue(t){let e=this._adapter,s=this.options.time;return s.tooltipFormat?e.format(t,s.tooltipFormat):e.format(t,s.displayFormats.datetime)}format(t,e){let s=this.options.time.displayFormats,n=this._unit,o=e||s[n];return this._adapter.format(t,o)}_tickFormatFunction(t,e,s,n){let o=this.options,a=o.ticks.callback;if(a)return W(a,[t,e,s],this);let r=o.time.displayFormats,l=this._unit,h=this._majorUnit,d=l&&r[l],c=h&&r[h],u=s[e],f=h&&c&&u&&u.major;return this._adapter.format(t,n||(f?c:d))}generateTickLabels(t){let e,s,n;for(e=0,s=t.length;e0?r:1}getDataTimestamps(){let t,e,s=this._cache.data||[];if(s.length)return s;let n=this.getMatchingVisibleMetas();if(this._normalized&&n.length)return this._cache.data=n[0].controller.getAllParsedValues(this);for(t=0,e=n.length;t=i[r].pos&&t<=i[l].pos&&({lo:r,hi:l}=_t(i,"pos",t)),{pos:s,time:o}=i[r],{pos:n,time:a}=i[l]):(t>=i[r].time&&t<=i[l].time&&({lo:r,hi:l}=_t(i,"time",t)),{time:s,pos:o}=i[r],{time:n,pos:a}=i[l]);let h=n-s;return h?o+(a-o)*(t-s)/h:o}var ko=Object.freeze({__proto__:null,CategoryScale:class extends Wt{static id="category";static defaults={ticks:{callback:fo}};constructor(i){super(i),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(i){let t=this._addedLabels;if(t.length){let e=this.getLabels();for(let{index:s,label:n}of t)e[s]===n&&e.splice(s,1);this._addedLabels=[]}super.init(i)}parse(i,t){if(I(i))return null;let e=this.getLabels();return((s,n)=>s===null?null:Z(Math.round(s),0,n))(t=isFinite(t)&&e[t]===i?t:rr(e,i,A(t,i),this._addedLabels),e.length-1)}determineDataLimits(){let{minDefined:i,maxDefined:t}=this.getUserBounds(),{min:e,max:s}=this.getMinMax(!0);this.options.bounds==="ticks"&&(i||(e=0),t||(s=this.getLabels().length-1)),this.min=e,this.max=s}buildTicks(){let i=this.min,t=this.max,e=this.options.offset,s=[],n=this.getLabels();n=i===0&&t===n.length-1?n:n.slice(i,t+1),this._valueRange=Math.max(n.length-(e?0:1),1),this._startValue=this.min-(e?.5:0);for(let o=i;o<=t;o++)s.push({value:o});return s}getLabelForValue(i){return fo.call(this,i)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(i){return typeof i!="number"&&(i=this.parse(i)),i===null?NaN:this.getPixelForDecimal((i-this._startValue)/this._valueRange)}getPixelForTick(i){let t=this.ticks;return i<0||i>t.length-1?null:this.getPixelForValue(t[i].value)}getValueForPixel(i){return Math.round(this._startValue+this.getDecimalForPixel(i)*this._valueRange)}getBasePixel(){return this.bottom}},LinearScale:lr,LogarithmicScale:cr,RadialLinearScale:mr,TimeScale:as,TimeSeriesScale:class extends as{static id="timeseries";static defaults=as.defaults;constructor(i){super(i),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){let i=this._getTimestampsForTable(),t=this._table=this.buildLookupTable(i);this._minPos=ai(t,this.min),this._tableRange=ai(t,this.max)-this._minPos,super.initOffsets(i)}buildLookupTable(i){let{min:t,max:e}=this,s=[],n=[],o,a,r,l,h;for(o=0,a=i.length;o=t&&l<=e&&s.push(l);if(s.length<2)return[{time:t,pos:0},{time:e,pos:1}];for(o=0,a=s.length;os-n)}_getTimestampsForTable(){let i=this._cache.all||[];if(i.length)return i;let t=this.getDataTimestamps(),e=this.getLabelTimestamps();return i=t.length&&e.length?this.normalize(t.concat(e)):t.length?t:e,i=this._cache.all=i,i}getDecimalForValue(i){return(ai(this._table,i)-this._minPos)/this._tableRange}getValueForPixel(i){let t=this._offsets,e=this.getDecimalForPixel(i)/t.factor-t.end;return ai(this._table,e*this._tableRange+this._minPos,!0)}}});let rs=["rgb(54, 162, 235)","rgb(255, 99, 132)","rgb(255, 159, 64)","rgb(255, 205, 86)","rgb(75, 192, 192)","rgb(153, 102, 255)","rgb(201, 203, 207)"],So=rs.map(i=>i.replace("rgb(","rgba(").replace(")",", 0.5)"));function Po(i){return rs[i%rs.length]}function Do(i){return So[i%So.length]}function br(i){let t=0;return(e,s)=>{let n=i.getDatasetMeta(s).controller;n instanceof ts?t=(function(o,a){return o.backgroundColor=o.data.map(()=>Po(a++)),a})(e,t):n instanceof ao?t=(function(o,a){return o.backgroundColor=o.data.map(()=>Do(a++)),a})(e,t):n&&(t=(function(o,a){return o.borderColor=Po(a),o.backgroundColor=Do(a),++a})(e,t))}}function Oo(i){let t;for(t in i)if(i[t].borderColor||i[t].backgroundColor)return!0;return!1}var xr={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(i,t,e){if(!e.enabled)return;let{data:{datasets:s},options:n}=i.config,{elements:o}=n,a=Oo(s)||(r=n)&&(r.borderColor||r.backgroundColor)||o&&Oo(o)||X.borderColor!=="rgba(0,0,0,0.1)"||X.backgroundColor!=="rgba(0,0,0,0.1)";var r;if(!e.forceOverride&&a)return;let l=br(i);s.forEach(l)}};function Co(i){if(i._decimated){let t=i._data;delete i._decimated,delete i._data,Object.defineProperty(i,"data",{configurable:!0,enumerable:!0,writable:!0,value:t})}}function Ao(i){i.data.datasets.forEach(t=>{Co(t)})}var _r={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(i,t,e)=>{if(!e.enabled)return void Ao(i);let s=i.width;i.data.datasets.forEach((n,o)=>{let{_data:a,indexAxis:r}=n,l=i.getDatasetMeta(o),h=a||n.data;if(oe([r,i.options.indexAxis])==="y"||!l.controller.supportsDecimation)return;let d=i.scales[l.xAxisID];if(d.type!=="linear"&&d.type!=="time"||i.options.parsing)return;let{start:c,count:u}=(function(p,g){let m=g.length,b,y=0,{iScale:_}=p,{min:x,max:v,minDefined:M,maxDefined:w}=_.getUserBounds();return M&&(y=Z(_t(g,_.axis,x).lo,0,m-1)),b=w?Z(_t(g,_.axis,v).hi+1,y,m)-y:m-y,{start:y,count:b}})(l,h);if(u<=(e.threshold||4*s))return void Co(n);let f;switch(I(a)&&(n._data=h,delete n.data,Object.defineProperty(n,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(p){this._data=p}})),e.algorithm){case"lttb":f=(function(p,g,m,b,y){let _=y.samples||b;if(_>=m)return p.slice(g,g+m);let x=[],v=(m-2)/(_-2),M=0,w=g+m-1,k,D,S,E,T,P=g;for(x[M++]=p[P],k=0;k<_-2;k++){let C,O=0,R=0,H=Math.floor((k+1)*v)+1+g,B=Math.min(Math.floor((k+2)*v)+1,m)+g,et=B-H;for(C=H;CS&&(S=E,D=p[C],T=C);x[M++]=D,P=T}return x[M++]=p[w],x})(h,c,u,s,e);break;case"min-max":f=(function(p,g,m,b){let y,_,x,v,M,w,k,D,S,E,T=0,P=0,C=[],O=g+m-1,R=p[g].x,H=p[O].x-R;for(y=g;yE&&(E=v,k=y),T=(P*T+_.x)/++P;else{let et=y-1;if(!I(w)&&!I(k)){let ot=Math.min(w,k),at=Math.max(w,k);ot!==D&&ot!==et&&C.push({...p[ot],x:T}),at!==D&&at!==et&&C.push({...p[at],x:T})}y>0&&et!==D&&C.push(p[et]),C.push(_),M=B,P=0,S=E=v,w=k=D=y}}return C})(h,c,u,s);break;default:throw new Error(`Unsupported decimation algorithm '${e.algorithm}'`)}n._decimated=f})},destroy(i){Ao(i)}};function ls(i,t,e,s){if(s)return;let n=t[i],o=e[i];return i==="angle"&&(n=it(n),o=it(o)),{property:i,start:n,end:o}}function hs(i,t,e){for(;t>i;t--){let s=e[t];if(!isNaN(s.x)&&!isNaN(s.y))break}return t}function To(i,t,e,s){return i&&t?s(i[e],t[e]):i?i[e]:t?t[e]:0}function Lo(i,t){let e=[],s=!1;return F(i)?(s=!0,e=i):e=(function(n,o){let{x:a=null,y:r=null}=n||{},l=o.points,h=[];return o.segments.forEach(({start:d,end:c})=>{c=hs(d,c,l);let u=l[d],f=l[c];r!==null?(h.push({x:u.x,y:r}),h.push({x:f.x,y:r})):a!==null&&(h.push({x:a,y:u.y}),h.push({x:a,y:f.y}))}),h})(i,t),e.length?new si({points:e,options:{tension:0},_loop:s,_fullLoop:s}):null}function Eo(i){return i&&i.fill!==!1}function yr(i,t,e){let s=i[t].fill,n=[t],o;if(!e)return s;for(;s!==!1&&n.indexOf(s)===-1;){if(!U(s))return s;if(o=i[s],!o)return!1;if(o.visible)return s;n.push(s),s=o.fill}return!1}function vr(i,t,e){let s=(function(o){let a=o.options,r=a.fill,l=A(r&&r.target,r);return l===void 0&&(l=!!a.backgroundColor),l===!1||l===null?!1:l===!0?"origin":l})(i);if(z(s))return!isNaN(s.value)&&s;let n=parseFloat(s);return U(n)&&Math.floor(n)===n?(function(o,a,r,l){return o!=="-"&&o!=="+"||(r=a+r),r===a||r<0||r>=l?!1:r})(s[0],t,n,e):["origin","start","end","stack","shape"].indexOf(s)>=0&&s}function Mr(i,t,e){let s=[];for(let n=0;n=0;--a){let r=n[a].$filler;r&&(r.line.updateControlPoints(o,r.axis),s&&r.fill&&cs(i.ctx,r,o))}},beforeDatasetsDraw(i,t,e){if(e.drawTime!=="beforeDatasetsDraw")return;let s=i.getSortedVisibleDatasetMetas();for(let n=s.length-1;n>=0;--n){let o=s[n].$filler;Eo(o)&&cs(i.ctx,o,i.chartArea)}},beforeDatasetDraw(i,t,e){let s=t.meta.$filler;Eo(s)&&e.drawTime==="beforeDatasetDraw"&&cs(i.ctx,s,i.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};let Vo=(i,t)=>{let{boxHeight:e=t,boxWidth:s=t}=i;return i.usePointStyle&&(e=Math.min(e,t),s=i.pointStyleWidth||Math.min(s,t)),{boxWidth:s,boxHeight:e,itemHeight:Math.max(t,e)}};class Bo extends Mt{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e,s){this.maxWidth=t,this.maxHeight=e,this._margins=s,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){let t=this.options.labels||{},e=W(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter(s=>t.filter(s,this.chart.data))),t.sort&&(e=e.sort((s,n)=>t.sort(s,n,this.chart.data))),this.options.reverse&&e.reverse(),this.legendItems=e}fit(){let{options:t,ctx:e}=this;if(!t.display)return void(this.width=this.height=0);let s=t.labels,n=G(s.font),o=n.size,a=this._computeTitleHeight(),{boxWidth:r,itemHeight:l}=Vo(s,o),h,d;e.font=n.string,this.isHorizontal()?(h=this.maxWidth,d=this._fitRows(a,o,r,l)+10):(d=this.maxHeight,h=this._fitCols(a,n,r,l)+10),this.width=Math.min(h,t.maxWidth||this.maxWidth),this.height=Math.min(d,t.maxHeight||this.maxHeight)}_fitRows(t,e,s,n){let{ctx:o,maxWidth:a,options:{labels:{padding:r}}}=this,l=this.legendHitBoxes=[],h=this.lineWidths=[0],d=n+r,c=t;o.textAlign="left",o.textBaseline="middle";let u=-1,f=-d;return this.legendItems.forEach((p,g)=>{let m=s+e/2+o.measureText(p.text).width;(g===0||h[h.length-1]+m+2*r>a)&&(c+=d,h[h.length-(g>0?0:1)]=0,f+=d,u++),l[g]={left:0,top:f,row:u,width:m,height:n},h[h.length-1]+=m+r}),c}_fitCols(t,e,s,n){let{ctx:o,maxHeight:a,options:{labels:{padding:r}}}=this,l=this.legendHitBoxes=[],h=this.columnSizes=[],d=a-t,c=r,u=0,f=0,p=0,g=0;return this.legendItems.forEach((m,b)=>{let{itemWidth:y,itemHeight:_}=(function(x,v,M,w,k){let D=(function(E,T,P,C){let O=E.text;return O&&typeof O!="string"&&(O=O.reduce((R,H)=>R.length>H.length?R:H)),T+P.size/2+C.measureText(O).width})(w,x,v,M),S=(function(E,T,P){let C=E;return typeof T.text!="string"&&(C=Wo(T,P)),C})(k,w,v.lineHeight);return{itemWidth:D,itemHeight:S}})(s,e,o,m,n);b>0&&f+_+2*r>d&&(c+=u+r,h.push({width:u,height:f}),p+=u+r,g++,u=f=0),l[b]={left:p,top:f,col:g,width:y,height:_},u=Math.max(u,y),f+=_+r}),c+=u,h.push({width:u,height:f}),c}adjustHitBoxes(){if(!this.options.display)return;let t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:s,labels:{padding:n},rtl:o}}=this,a=Ut(o,this.left,this.width);if(this.isHorizontal()){let r=0,l=J(s,this.left+n,this.right-this.lineWidths[r]);for(let h of e)r!==h.row&&(r=h.row,l=J(s,this.left+n,this.right-this.lineWidths[r])),h.top+=this.top+t+n,h.left=a.leftForLtr(a.x(l),h.width),l+=h.width+n}else{let r=0,l=J(s,this.top+t+n,this.bottom-this.columnSizes[r].height);for(let h of e)h.col!==r&&(r=h.col,l=J(s,this.top+t+n,this.bottom-this.columnSizes[r].height)),h.top=l,h.left+=this.left+n,h.left=a.leftForLtr(a.x(h.left),h.width),l+=h.height+n}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){let t=this.ctx;me(t,this),this._draw(),be(t)}}_draw(){let{options:t,columnSizes:e,lineWidths:s,ctx:n}=this,{align:o,labels:a}=t,r=X.color,l=Ut(t.rtl,this.left,this.width),h=G(a.font),{padding:d}=a,c=h.size,u=c/2,f;this.drawTitle(),n.textAlign=l.textAlign("left"),n.textBaseline="middle",n.lineWidth=.5,n.font=h.string;let{boxWidth:p,boxHeight:g,itemHeight:m}=Vo(a,c),b=this.isHorizontal(),y=this._computeTitleHeight();f=b?{x:J(o,this.left+d,this.right-s[0]),y:this.top+d+y,line:0}:{x:this.left+d,y:J(o,this.top+y+d,this.bottom-e[0].height),line:0},Vi(this.ctx,t.textDirection);let _=m+d;this.legendItems.forEach((x,v)=>{n.strokeStyle=x.fontColor,n.fillStyle=x.fontColor;let M=n.measureText(x.text).width,w=l.textAlign(x.textAlign||(x.textAlign=a.textAlign)),k=p+u+M,D=f.x,S=f.y;if(l.setWidth(this.width),b?v>0&&D+k+d>this.right&&(S=f.y+=_,f.line++,D=f.x=J(o,this.left+d,this.right-s[f.line])):v>0&&S+_>this.bottom&&(D=f.x=D+e[f.line].width+d,f.line++,S=f.y=J(o,this.top+y+d,this.bottom-e[f.line].height)),(function(E,T,P){if(isNaN(p)||p<=0||isNaN(g)||g<0)return;n.save();let C=A(P.lineWidth,1);if(n.fillStyle=A(P.fillStyle,r),n.lineCap=A(P.lineCap,"butt"),n.lineDashOffset=A(P.lineDashOffset,0),n.lineJoin=A(P.lineJoin,"miter"),n.lineWidth=C,n.strokeStyle=A(P.strokeStyle,r),n.setLineDash(A(P.lineDash,[])),a.usePointStyle){let O={radius:g*Math.SQRT2/2,pointStyle:P.pointStyle,rotation:P.rotation,borderWidth:C},R=l.xPlus(E,p/2);Li(n,O,R,T+u,a.pointStyleWidth&&p)}else{let O=T+Math.max((c-g)/2,0),R=l.leftForLtr(E,p),H=Bt(P.borderRadius);n.beginPath(),Object.values(H).some(B=>B!==0)?ie(n,{x:R,y:O,w:p,h:g,radius:H}):n.rect(R,O,p,g),n.fill(),C!==0&&n.stroke()}n.restore()})(l.x(D),S,x),D=Ts(w,D+p+u,b?D+k:this.right,t.rtl),(function(E,T,P){Ft(n,P.text,E,T+m/2,h,{strikethrough:P.hidden,textAlign:l.textAlign(P.textAlign)})})(l.x(D),S,x),b)f.x+=k+d;else if(typeof x.text!="string"){let E=h.lineHeight;f.y+=Wo(x,E)+d}else f.y+=_}),Bi(this.ctx,t.textDirection)}drawTitle(){let t=this.options,e=t.title,s=G(e.font),n=Q(e.padding);if(!e.display)return;let o=Ut(t.rtl,this.left,this.width),a=this.ctx,r=e.position,l=s.size/2,h=n.top+l,d,c=this.left,u=this.width;if(this.isHorizontal())u=Math.max(...this.lineWidths),d=this.top+h,c=J(t.align,c,this.right-u);else{let p=this.columnSizes.reduce((g,m)=>Math.max(g,m.height),0);d=h+J(t.align,this.top,this.bottom-p-t.labels.padding-this._computeTitleHeight())}let f=J(r,c,c+u);a.textAlign=o.textAlign(Le(r)),a.textBaseline="middle",a.strokeStyle=e.color,a.fillStyle=e.color,a.font=s.string,Ft(a,e.text,f,d,s)}_computeTitleHeight(){let t=this.options.title,e=G(t.font),s=Q(t.padding);return t.display?e.lineHeight+s.height:0}_getLegendItemAt(t,e){let s,n,o;if(xt(t,this.left,this.right)&&xt(e,this.top,this.bottom)){for(o=this.legendHitBoxes,s=0;si.chart.options.color,boxWidth:40,padding:10,generateLabels(i){let t=i.data.datasets,{labels:{usePointStyle:e,pointStyle:s,textAlign:n,color:o,useBorderRadius:a,borderRadius:r}}=i.legend.options;return i._getSortedDatasetMetas().map(l=>{let h=l.controller.getStyle(e?0:void 0),d=Q(h.borderWidth);return{text:t[l.index].label,fillStyle:h.backgroundColor,fontColor:o,hidden:!l.visible,lineCap:h.borderCapStyle,lineDash:h.borderDash,lineDashOffset:h.borderDashOffset,lineJoin:h.borderJoinStyle,lineWidth:(d.width+d.height)/4,strokeStyle:h.borderColor,pointStyle:s||h.pointStyle,rotation:h.rotation,textAlign:n||h.textAlign,borderRadius:a&&(r||h.borderRadius),datasetIndex:l.index}},this)}},title:{color:i=>i.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:i=>!i.startsWith("on"),labels:{_scriptable:i=>!["generateLabels","filter","sort"].includes(i)}}};class ds extends Mt{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e){let s=this.options;if(this.left=0,this.top=0,!s.display)return void(this.width=this.height=this.right=this.bottom=0);this.width=this.right=t,this.height=this.bottom=e;let n=F(s.text)?s.text.length:1;this._padding=Q(s.padding);let o=n*G(s.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=o:this.width=o}isHorizontal(){let t=this.options.position;return t==="top"||t==="bottom"}_drawArgs(t){let{top:e,left:s,bottom:n,right:o,options:a}=this,r=a.align,l,h,d,c=0;return this.isHorizontal()?(h=J(r,s,o),d=e+t,l=o-s):(a.position==="left"?(h=s+t,d=J(r,n,e),c=-.5*$):(h=o-t,d=J(r,e,n),c=.5*$),l=n-e),{titleX:h,titleY:d,maxWidth:l,rotation:c}}draw(){let t=this.ctx,e=this.options;if(!e.display)return;let s=G(e.font),n=s.lineHeight/2+this._padding.top,{titleX:o,titleY:a,maxWidth:r,rotation:l}=this._drawArgs(n);Ft(t,e.text,0,0,s,{color:e.color,maxWidth:r,rotation:l,textAlign:Le(e.align),textBaseline:"middle",translation:[o,a]})}}var Or={id:"title",_element:ds,start(i,t,e){(function(s,n){let o=new ds({ctx:s.ctx,options:n,chart:s});tt.configure(s,o,n),tt.addBox(s,o),s.titleBlock=o})(i,e)},stop(i){let t=i.titleBlock;tt.removeBox(i,t),delete i.titleBlock},beforeUpdate(i,t,e){let s=i.titleBlock;tt.configure(i,s,e),s.options=e},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};let ri=new WeakMap;var Cr={id:"subtitle",start(i,t,e){let s=new ds({ctx:i.ctx,options:e,chart:i});tt.configure(i,s,e),tt.addBox(i,s),ri.set(i,s)},stop(i){tt.removeBox(i,ri.get(i)),ri.delete(i)},beforeUpdate(i,t,e){let s=ri.get(i);tt.configure(i,s,e),s.options=e},defaults:{align:"center",display:!1,font:{weight:"normal"},fullSize:!0,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};let De={average(i){if(!i.length)return!1;let t,e,s=new Set,n=0,o=0;for(t=0,e=i.length;ta+r)/s.size,y:n/o}},nearest(i,t){if(!i.length)return!1;let e,s,n,o=t.x,a=t.y,r=Number.POSITIVE_INFINITY;for(e=0,s=i.length;e-1?i.split(` -`):i}function Ar(i,t){let{element:e,datasetIndex:s,index:n}=t,o=i.getDatasetMeta(s).controller,{label:a,value:r}=o.getLabelAndValue(n);return{chart:i,label:a,parsed:o.getParsed(n),raw:i.data.datasets[s].data[n],formattedValue:r,dataset:o.getDataset(),dataIndex:n,datasetIndex:s,element:e}}function No(i,t){let e=i.chart.ctx,{body:s,footer:n,title:o}=i,{boxWidth:a,boxHeight:r}=t,l=J(t.bodyFont),h=J(t.titleFont),d=J(t.footerFont),c=o.length,u=n.length,f=s.length,p=et(t.padding),g=p.height,m=0,b=s.reduce((x,v)=>x+v.before.length+v.lines.length+v.after.length,0);b+=i.beforeBody.length+i.afterBody.length,c&&(g+=c*h.lineHeight+(c-1)*t.titleSpacing+t.titleMarginBottom),b&&(g+=f*(t.displayColors?Math.max(r,l.lineHeight):l.lineHeight)+(b-f)*l.lineHeight+(b-1)*t.bodySpacing),u&&(g+=t.footerMarginTop+u*d.lineHeight+(u-1)*t.footerSpacing);let y=0,_=function(x){m=Math.max(m,e.measureText(x).width+y)};return e.save(),e.font=h.string,B(i.title,_),e.font=l.string,B(i.beforeBody.concat(i.afterBody),_),y=t.displayColors?a+2+t.boxPadding:0,B(s,x=>{B(x.before,_),B(x.lines,_),B(x.after,_)}),y=0,e.font=d.string,B(i.footer,_),e.restore(),m+=p.width,{width:m,height:g}}function Tr(i,t,e,s){let{x:n,width:o}=e,{width:a,chartArea:{left:r,right:l}}=i,h="center";return s==="center"?h=n<=(r+l)/2?"left":"right":n<=o/2?h="left":n>=a-o/2&&(h="right"),(function(d,c,u,f){let{x:p,width:g}=f,m=u.caretSize+u.caretPadding;return d==="left"&&p+g+m>c.width||d==="right"&&p-g-m<0||void 0})(h,i,t,e)&&(h="center"),h}function Ho(i,t,e){let s=e.yAlign||t.yAlign||(function(n,o){let{y:a,height:r}=o;return an.height-r/2?"bottom":"center"})(i,e);return{xAlign:e.xAlign||t.xAlign||Tr(i,t,e,s),yAlign:s}}function jo(i,t,e,s){let{caretSize:n,caretPadding:o,cornerRadius:a}=i,{xAlign:r,yAlign:l}=e,h=n+o,{topLeft:d,topRight:c,bottomLeft:u,bottomRight:f}=Bt(a),p=(function(m,b){let{x:y,width:_}=m;return b==="right"?y-=_:b==="center"&&(y-=_/2),y})(t,r),g=(function(m,b,y){let{y:_,height:x}=m;return b==="top"?_+=y:_-=b==="bottom"?x+y:x/2,_})(t,l,h);return l==="center"?r==="left"?p+=h:r==="right"&&(p-=h):r==="left"?p-=Math.max(d,u)+n:r==="right"&&(p+=Math.max(c,f)+n),{x:Q(p,0,s.width-t.width),y:Q(g,0,s.height-t.height)}}function hi(i,t,e){let s=et(e.padding);return t==="center"?i.x+i.width/2:t==="right"?i.x+i.width-s.right:i.x+s.left}function $o(i){return kt([],Tt(i))}function Yo(i,t){let e=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return e?i.override(e):i}let Uo={beforeTitle:W,title(i){if(i.length>0){let t=i[0],e=t.chart.data.labels,s=e?e.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(s>0&&t.dataIndex{let a={before:[],lines:[],after:[]},r=Yo(s,o);kt(a.before,Tt(at(r,"beforeLabel",this,o))),kt(a.lines,at(r,"label",this,o)),kt(a.after,Tt(at(r,"afterLabel",this,o))),n.push(a)}),n}getAfterBody(t,e){return $o(at(e.callbacks,"afterBody",this,t))}getFooter(t,e){let{callbacks:s}=e,n=at(s,"beforeFooter",this,t),o=at(s,"footer",this,t),a=at(s,"afterFooter",this,t),r=[];return r=kt(r,Tt(n)),r=kt(r,Tt(o)),r=kt(r,Tt(a)),r}_createItems(t){let e=this._active,s=this.chart.data,n=[],o=[],a=[],r,l,h=[];for(r=0,l=e.length;rt.filter(d,c,u,s))),t.itemSort&&(h=h.sort((d,c)=>t.itemSort(d,c,s))),B(h,d=>{let c=Yo(t.callbacks,d);n.push(at(c,"labelColor",this,d)),o.push(at(c,"labelPointStyle",this,d)),a.push(at(c,"labelTextColor",this,d))}),this.labelColors=n,this.labelPointStyles=o,this.labelTextColors=a,this.dataPoints=h,h}update(t,e){let s=this.options.setContext(this.getContext()),n=this._active,o,a=[];if(n.length){let r=De[s.position].call(this,n,this._eventPosition);a=this._createItems(s),this.title=this.getTitle(a,s),this.beforeBody=this.getBeforeBody(a,s),this.body=this.getBody(a,s),this.afterBody=this.getAfterBody(a,s),this.footer=this.getFooter(a,s);let l=this._size=No(this,s),h=Object.assign({},r,l),d=Ho(this.chart,s,h),c=jo(s,h,d,this.chart);this.xAlign=d.xAlign,this.yAlign=d.yAlign,o={opacity:1,x:c.x,y:c.y,width:l.width,height:l.height,caretX:r.x,caretY:r.y}}else this.opacity!==0&&(o={opacity:0});this._tooltipItems=a,this.$context=void 0,o&&this._resolveAnimations().update(this,o),t&&s.external&&s.external.call(this,{chart:this.chart,tooltip:this,replay:e})}drawCaret(t,e,s,n){let o=this.getCaretPosition(t,s,n);e.lineTo(o.x1,o.y1),e.lineTo(o.x2,o.y2),e.lineTo(o.x3,o.y3)}getCaretPosition(t,e,s){let{xAlign:n,yAlign:o}=this,{caretSize:a,cornerRadius:r}=s,{topLeft:l,topRight:h,bottomLeft:d,bottomRight:c}=Bt(r),{x:u,y:f}=t,{width:p,height:g}=e,m,b,y,_,x,v;return o==="center"?(x=f+g/2,n==="left"?(m=u,b=m-a,_=x+a,v=x-a):(m=u+p,b=m+a,_=x-a,v=x+a),y=m):(b=n==="left"?u+Math.max(l,d)+a:n==="right"?u+p-Math.max(h,c)-a:this.caretX,o==="top"?(_=f,x=_-a,m=b-a,y=b+a):(_=f+g,x=_+a,m=b+a,y=b-a),v=_),{x1:m,x2:b,x3:y,y1:_,y2:x,y3:v}}drawTitle(t,e,s){let n=this.title,o=n.length,a,r,l;if(o){let h=qt(s.rtl,this.x,this.width);for(t.x=hi(this,s.titleAlign,s),e.textAlign=h.textAlign(s.titleAlign),e.textBaseline="middle",a=J(s.titleFont),r=s.titleSpacing,e.fillStyle=s.titleColor,e.font=a.string,l=0;ly!==0)?(t.beginPath(),t.fillStyle=o.multiKeyBackground,ne(t,{x:g,y:p,w:h,h:l,radius:b}),t.fill(),t.stroke(),t.fillStyle=a.backgroundColor,t.beginPath(),ne(t,{x:m,y:p+1,w:h-2,h:l-2,radius:b}),t.fill()):(t.fillStyle=o.multiKeyBackground,t.fillRect(g,p,h,l),t.strokeRect(g,p,h,l),t.fillStyle=a.backgroundColor,t.fillRect(m,p+1,h-2,l-2))}t.fillStyle=this.labelTextColors[s]}drawBody(t,e,s){let{body:n}=this,{bodySpacing:o,bodyAlign:a,displayColors:r,boxHeight:l,boxWidth:h,boxPadding:d}=s,c=J(s.bodyFont),u=c.lineHeight,f=0,p=qt(s.rtl,this.x,this.width),g=function(k){e.fillText(k,p.x(t.x+f),t.y+u/2),t.y+=u+o},m=p.textAlign(a),b,y,_,x,v,M,w;for(e.textAlign=a,e.textBaseline="middle",e.font=c.string,t.x=hi(this,m,s),e.fillStyle=s.bodyColor,B(this.beforeBody,g),f=r&&m!=="right"?a==="center"?h/2+d:h+2+d:0,x=0,M=n.length;x0&&e.stroke()}_updateAnimationTarget(t){let e=this.chart,s=this.$animations,n=s&&s.x,o=s&&s.y;if(n||o){let a=De[t.position].call(this,this._active,this._eventPosition);if(!a)return;let r=this._size=No(this,t),l=Object.assign({},a,this._size),h=Ho(e,t,l),d=jo(t,l,h,e);n._to===d.x&&o._to===d.y||(this.xAlign=h.xAlign,this.yAlign=h.yAlign,this.width=r.width,this.height=r.height,this.caretX=a.x,this.caretY=a.y,this._resolveAnimations().update(this,d))}}_willRender(){return!!this.opacity}draw(t){let e=this.options.setContext(this.getContext()),s=this.opacity;if(!s)return;this._updateAnimationTarget(e);let n={width:this.width,height:this.height},o={x:this.x,y:this.y};s=Math.abs(s)<.001?0:s;let a=et(e.padding),r=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&r&&(t.save(),t.globalAlpha=s,this.drawBackground(o,t,n,e),Bi(t,e.textDirection),o.y+=a.top,this.drawTitle(o,t,e),this.drawBody(o,t,e),this.drawFooter(o,t,e),Wi(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){let s=this._active,n=t.map(({datasetIndex:r,index:l})=>{let h=this.chart.getDatasetMeta(r);if(!h)throw new Error("Cannot find a dataset at index "+r);return{datasetIndex:r,element:h.data[l],index:l}}),o=!Ht(s,n),a=this._positionChanged(n,e);(o||a)&&(this._active=n,this._eventPosition=e,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,e,s=!0){if(e&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;let n=this.options,o=this._active||[],a=this._getActiveElements(t,o,e,s),r=this._positionChanged(a,t),l=e||!Ht(a,o)||r;return l&&(this._active=a,(n.enabled||n.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),l}_getActiveElements(t,e,s,n){let o=this.options;if(t.type==="mouseout")return[];if(!n)return e.filter(r=>this.chart.data.datasets[r.datasetIndex]&&this.chart.getDatasetMeta(r.datasetIndex).controller.getParsed(r.index)!==void 0);let a=this.chart.getElementsAtEventForMode(t,o.mode,o,s);return o.reverse&&a.reverse(),a}_positionChanged(t,e){let{caretX:s,caretY:n,options:o}=this,a=De[o.position].call(this,t,e);return a!==!1&&(s!==a.x||n!==a.y)}}var Lr={id:"tooltip",_element:Xo,positioners:De,afterInit(i,t,e){e&&(i.tooltip=new Xo({chart:i,options:e}))},beforeUpdate(i,t,e){i.tooltip&&i.tooltip.initialize(e)},reset(i,t,e){i.tooltip&&i.tooltip.initialize(e)},afterDraw(i){let t=i.tooltip;if(t&&t._willRender()){let e={tooltip:t};if(i.notifyPlugins("beforeTooltipDraw",{...e,cancelable:!0})===!1)return;t.draw(i.ctx),i.notifyPlugins("afterTooltipDraw",e)}},afterEvent(i,t){if(i.tooltip){let e=t.replay;i.tooltip.handleEvent(t.event,e,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(i,t)=>t.bodyFont.size,boxWidth:(i,t)=>t.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:Uo},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:i=>i!=="filter"&&i!=="itemSort"&&i!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]};return G.register(ro,ko,os,$),G.helpers={...Ma},G._adapters=eo,G.Animation=Tn,G.Animations=Xi,G.animator=vt,G.controllers=gt.controllers.items,G.DatasetController=At,G.Element=wt,G.elements=os,G.Interaction=mn,G.layouts=it,G.platforms=On,G.Scale=Wt,G.Ticks=fe,Object.assign(G,ro,ko,os,$,On),G.Chart=G,typeof window<"u"&&(window.Chart=G),G})});var Qr=Wr(Ko());(function(){"use strict";let $=new Map;function W(){let L=getComputedStyle(document.documentElement);return{foreground:L.getPropertyValue("--foreground").trim()||"#000",background:L.getPropertyValue("--background").trim()||"#fff",mutedForeground:L.getPropertyValue("--muted-foreground").trim()||"#666",border:L.getPropertyValue("--border").trim()||"#ccc"}}function ht(L){if(!L||!L.id||!L.hasAttribute("data-tui-chart-id"))return;$.has(L.id)&&I(L);let q=L.getAttribute("data-tui-chart-id"),E=document.getElementById(q);if(E)try{let j=JSON.parse(E.textContent),Z=W();Chart.defaults.elements.point.radius=0,Chart.defaults.elements.point.hoverRadius=5;let N=["pie","doughnut","bar","radar"].includes(j.type),B={display:j.showLegend||!1,labels:{color:Z.foreground}},Ht={backgroundColor:Z.background,bodyColor:Z.mutedForeground,titleColor:Z.foreground,borderColor:Z.border,borderWidth:1},jt=j.type==="radar"?{r:{grid:{color:Z.border,display:j.showYGrid!==!1},ticks:{color:Z.mutedForeground,backdropColor:"transparent",display:j.showYLabels!==!1},angleLines:{color:Z.border,display:j.showXGrid!==!1},pointLabels:{color:Z.foreground,font:{size:12}},border:{display:j.showYAxis!==!1,color:Z.border},beginAtZero:!0}}:{x:{beginAtZero:!0,display:j.showXLabels!==!1||j.showXGrid!==!1||j.showXAxis!==!1,border:{display:j.showXAxis!==!1,color:Z.border},ticks:{display:j.showXLabels!==!1,color:Z.mutedForeground},grid:{display:j.showXGrid!==!1,color:Z.border},stacked:j.stacked||!1},y:{offset:!0,beginAtZero:j.beginAtZero!==!1,min:j.yMin,max:j.yMax,display:j.showYLabels!==!1||j.showYGrid!==!1||j.showYAxis!==!1,border:{display:j.showYAxis!==!1,color:Z.border},ticks:{display:j.showYLabels!==!1,color:Z.mutedForeground},grid:{display:j.showYGrid!==!1,color:Z.border},stacked:j.stacked||!1}},Ce={...j,options:{responsive:!0,maintainAspectRatio:!1,interaction:{intersect:!!N,axis:"xy",mode:N?"nearest":"index"},indexAxis:j.horizontal?"y":"x",plugins:{legend:B,tooltip:Ht},scales:jt}};$.set(L.id,new Chart(L,Ce))}catch{}}function I(L){if(!(!L||!L.id||!$.has(L.id)))try{$.get(L.id).destroy()}finally{$.delete(L.id)}}function F(){typeof Chart<"u"?(document.querySelectorAll("canvas[data-tui-chart-id]").forEach(ht),z()):setTimeout(F,100)}document.addEventListener("DOMContentLoaded",F);function z(){let L;new MutationObserver(()=>{clearTimeout(L),L=setTimeout(()=>{document.querySelectorAll("canvas[data-tui-chart-id]").forEach(q=>{$.has(q.id)&&(I(q),ht(q))})},50)}).observe(document.documentElement,{attributes:!0,attributeFilter:["class","style"]}),new MutationObserver(()=>{document.querySelectorAll("canvas[data-tui-chart-id]").forEach(q=>{$.has(q.id)||ht(q)})}).observe(document.body,{childList:!0,subtree:!0})}})();})(); +`):i}function Ar(i,t){let{element:e,datasetIndex:s,index:n}=t,o=i.getDatasetMeta(s).controller,{label:a,value:r}=o.getLabelAndValue(n);return{chart:i,label:a,parsed:o.getParsed(n),raw:i.data.datasets[s].data[n],formattedValue:r,dataset:o.getDataset(),dataIndex:n,datasetIndex:s,element:e}}function No(i,t){let e=i.chart.ctx,{body:s,footer:n,title:o}=i,{boxWidth:a,boxHeight:r}=t,l=G(t.bodyFont),h=G(t.titleFont),d=G(t.footerFont),c=o.length,u=n.length,f=s.length,p=Q(t.padding),g=p.height,m=0,b=s.reduce((x,v)=>x+v.before.length+v.lines.length+v.after.length,0);b+=i.beforeBody.length+i.afterBody.length,c&&(g+=c*h.lineHeight+(c-1)*t.titleSpacing+t.titleMarginBottom),b&&(g+=f*(t.displayColors?Math.max(r,l.lineHeight):l.lineHeight)+(b-f)*l.lineHeight+(b-1)*t.bodySpacing),u&&(g+=t.footerMarginTop+u*d.lineHeight+(u-1)*t.footerSpacing);let y=0,_=function(x){m=Math.max(m,e.measureText(x).width+y)};return e.save(),e.font=h.string,V(i.title,_),e.font=l.string,V(i.beforeBody.concat(i.afterBody),_),y=t.displayColors?a+2+t.boxPadding:0,V(s,x=>{V(x.before,_),V(x.lines,_),V(x.after,_)}),y=0,e.font=d.string,V(i.footer,_),e.restore(),m+=p.width,{width:m,height:g}}function Tr(i,t,e,s){let{x:n,width:o}=e,{width:a,chartArea:{left:r,right:l}}=i,h="center";return s==="center"?h=n<=(r+l)/2?"left":"right":n<=o/2?h="left":n>=a-o/2&&(h="right"),(function(d,c,u,f){let{x:p,width:g}=f,m=u.caretSize+u.caretPadding;return d==="left"&&p+g+m>c.width||d==="right"&&p-g-m<0||void 0})(h,i,t,e)&&(h="center"),h}function Ho(i,t,e){let s=e.yAlign||t.yAlign||(function(n,o){let{y:a,height:r}=o;return an.height-r/2?"bottom":"center"})(i,e);return{xAlign:e.xAlign||t.xAlign||Tr(i,t,e,s),yAlign:s}}function jo(i,t,e,s){let{caretSize:n,caretPadding:o,cornerRadius:a}=i,{xAlign:r,yAlign:l}=e,h=n+o,{topLeft:d,topRight:c,bottomLeft:u,bottomRight:f}=Bt(a),p=(function(m,b){let{x:y,width:_}=m;return b==="right"?y-=_:b==="center"&&(y-=_/2),y})(t,r),g=(function(m,b,y){let{y:_,height:x}=m;return b==="top"?_+=y:_-=b==="bottom"?x+y:x/2,_})(t,l,h);return l==="center"?r==="left"?p+=h:r==="right"&&(p-=h):r==="left"?p-=Math.max(d,u)+n:r==="right"&&(p+=Math.max(c,f)+n),{x:Z(p,0,s.width-t.width),y:Z(g,0,s.height-t.height)}}function li(i,t,e){let s=Q(e.padding);return t==="center"?i.x+i.width/2:t==="right"?i.x+i.width-s.right:i.x+s.left}function $o(i){return wt([],At(i))}function Yo(i,t){let e=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return e?i.override(e):i}let Uo={beforeTitle:N,title(i){if(i.length>0){let t=i[0],e=t.chart.data.labels,s=e?e.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(s>0&&t.dataIndex{let a={before:[],lines:[],after:[]},r=Yo(s,o);wt(a.before,At(nt(r,"beforeLabel",this,o))),wt(a.lines,nt(r,"label",this,o)),wt(a.after,At(nt(r,"afterLabel",this,o))),n.push(a)}),n}getAfterBody(t,e){return $o(nt(e.callbacks,"afterBody",this,t))}getFooter(t,e){let{callbacks:s}=e,n=nt(s,"beforeFooter",this,t),o=nt(s,"footer",this,t),a=nt(s,"afterFooter",this,t),r=[];return r=wt(r,At(n)),r=wt(r,At(o)),r=wt(r,At(a)),r}_createItems(t){let e=this._active,s=this.chart.data,n=[],o=[],a=[],r,l,h=[];for(r=0,l=e.length;rt.filter(d,c,u,s))),t.itemSort&&(h=h.sort((d,c)=>t.itemSort(d,c,s))),V(h,d=>{let c=Yo(t.callbacks,d);n.push(nt(c,"labelColor",this,d)),o.push(nt(c,"labelPointStyle",this,d)),a.push(nt(c,"labelTextColor",this,d))}),this.labelColors=n,this.labelPointStyles=o,this.labelTextColors=a,this.dataPoints=h,h}update(t,e){let s=this.options.setContext(this.getContext()),n=this._active,o,a=[];if(n.length){let r=De[s.position].call(this,n,this._eventPosition);a=this._createItems(s),this.title=this.getTitle(a,s),this.beforeBody=this.getBeforeBody(a,s),this.body=this.getBody(a,s),this.afterBody=this.getAfterBody(a,s),this.footer=this.getFooter(a,s);let l=this._size=No(this,s),h=Object.assign({},r,l),d=Ho(this.chart,s,h),c=jo(s,h,d,this.chart);this.xAlign=d.xAlign,this.yAlign=d.yAlign,o={opacity:1,x:c.x,y:c.y,width:l.width,height:l.height,caretX:r.x,caretY:r.y}}else this.opacity!==0&&(o={opacity:0});this._tooltipItems=a,this.$context=void 0,o&&this._resolveAnimations().update(this,o),t&&s.external&&s.external.call(this,{chart:this.chart,tooltip:this,replay:e})}drawCaret(t,e,s,n){let o=this.getCaretPosition(t,s,n);e.lineTo(o.x1,o.y1),e.lineTo(o.x2,o.y2),e.lineTo(o.x3,o.y3)}getCaretPosition(t,e,s){let{xAlign:n,yAlign:o}=this,{caretSize:a,cornerRadius:r}=s,{topLeft:l,topRight:h,bottomLeft:d,bottomRight:c}=Bt(r),{x:u,y:f}=t,{width:p,height:g}=e,m,b,y,_,x,v;return o==="center"?(x=f+g/2,n==="left"?(m=u,b=m-a,_=x+a,v=x-a):(m=u+p,b=m+a,_=x-a,v=x+a),y=m):(b=n==="left"?u+Math.max(l,d)+a:n==="right"?u+p-Math.max(h,c)-a:this.caretX,o==="top"?(_=f,x=_-a,m=b-a,y=b+a):(_=f+g,x=_+a,m=b+a,y=b-a),v=_),{x1:m,x2:b,x3:y,y1:_,y2:x,y3:v}}drawTitle(t,e,s){let n=this.title,o=n.length,a,r,l;if(o){let h=Ut(s.rtl,this.x,this.width);for(t.x=li(this,s.titleAlign,s),e.textAlign=h.textAlign(s.titleAlign),e.textBaseline="middle",a=G(s.titleFont),r=s.titleSpacing,e.fillStyle=s.titleColor,e.font=a.string,l=0;ly!==0)?(t.beginPath(),t.fillStyle=o.multiKeyBackground,ie(t,{x:g,y:p,w:h,h:l,radius:b}),t.fill(),t.stroke(),t.fillStyle=a.backgroundColor,t.beginPath(),ie(t,{x:m,y:p+1,w:h-2,h:l-2,radius:b}),t.fill()):(t.fillStyle=o.multiKeyBackground,t.fillRect(g,p,h,l),t.strokeRect(g,p,h,l),t.fillStyle=a.backgroundColor,t.fillRect(m,p+1,h-2,l-2))}t.fillStyle=this.labelTextColors[s]}drawBody(t,e,s){let{body:n}=this,{bodySpacing:o,bodyAlign:a,displayColors:r,boxHeight:l,boxWidth:h,boxPadding:d}=s,c=G(s.bodyFont),u=c.lineHeight,f=0,p=Ut(s.rtl,this.x,this.width),g=function(k){e.fillText(k,p.x(t.x+f),t.y+u/2),t.y+=u+o},m=p.textAlign(a),b,y,_,x,v,M,w;for(e.textAlign=a,e.textBaseline="middle",e.font=c.string,t.x=li(this,m,s),e.fillStyle=s.bodyColor,V(this.beforeBody,g),f=r&&m!=="right"?a==="center"?h/2+d:h+2+d:0,x=0,M=n.length;x0&&e.stroke()}_updateAnimationTarget(t){let e=this.chart,s=this.$animations,n=s&&s.x,o=s&&s.y;if(n||o){let a=De[t.position].call(this,this._active,this._eventPosition);if(!a)return;let r=this._size=No(this,t),l=Object.assign({},a,this._size),h=Ho(e,t,l),d=jo(t,l,h,e);n._to===d.x&&o._to===d.y||(this.xAlign=h.xAlign,this.yAlign=h.yAlign,this.width=r.width,this.height=r.height,this.caretX=a.x,this.caretY=a.y,this._resolveAnimations().update(this,d))}}_willRender(){return!!this.opacity}draw(t){let e=this.options.setContext(this.getContext()),s=this.opacity;if(!s)return;this._updateAnimationTarget(e);let n={width:this.width,height:this.height},o={x:this.x,y:this.y};s=Math.abs(s)<.001?0:s;let a=Q(e.padding),r=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&r&&(t.save(),t.globalAlpha=s,this.drawBackground(o,t,n,e),Vi(t,e.textDirection),o.y+=a.top,this.drawTitle(o,t,e),this.drawBody(o,t,e),this.drawFooter(o,t,e),Bi(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){let s=this._active,n=t.map(({datasetIndex:r,index:l})=>{let h=this.chart.getDatasetMeta(r);if(!h)throw new Error("Cannot find a dataset at index "+r);return{datasetIndex:r,element:h.data[l],index:l}}),o=!re(s,n),a=this._positionChanged(n,e);(o||a)&&(this._active=n,this._eventPosition=e,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,e,s=!0){if(e&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;let n=this.options,o=this._active||[],a=this._getActiveElements(t,o,e,s),r=this._positionChanged(a,t),l=e||!re(a,o)||r;return l&&(this._active=a,(n.enabled||n.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),l}_getActiveElements(t,e,s,n){let o=this.options;if(t.type==="mouseout")return[];if(!n)return e.filter(r=>this.chart.data.datasets[r.datasetIndex]&&this.chart.getDatasetMeta(r.datasetIndex).controller.getParsed(r.index)!==void 0);let a=this.chart.getElementsAtEventForMode(t,o.mode,o,s);return o.reverse&&a.reverse(),a}_positionChanged(t,e){let{caretX:s,caretY:n,options:o}=this,a=De[o.position].call(this,t,e);return a!==!1&&(s!==a.x||n!==a.y)}}var Lr={id:"tooltip",_element:Xo,positioners:De,afterInit(i,t,e){e&&(i.tooltip=new Xo({chart:i,options:e}))},beforeUpdate(i,t,e){i.tooltip&&i.tooltip.initialize(e)},reset(i,t,e){i.tooltip&&i.tooltip.initialize(e)},afterDraw(i){let t=i.tooltip;if(t&&t._willRender()){let e={tooltip:t};if(i.notifyPlugins("beforeTooltipDraw",{...e,cancelable:!0})===!1)return;t.draw(i.ctx),i.notifyPlugins("afterTooltipDraw",e)}},afterEvent(i,t){if(i.tooltip){let e=t.replay;i.tooltip.handleEvent(t.event,e,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(i,t)=>t.bodyFont.size,boxWidth:(i,t)=>t.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:Uo},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:i=>i!=="filter"&&i!=="itemSort"&&i!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]};return K.register(ro,ko,ns,j),K.helpers={...Ma},K._adapters=eo,K.Animation=Tn,K.Animations=Ui,K.animator=yt,K.controllers=dt.controllers.items,K.DatasetController=Ct,K.Element=Mt,K.elements=ns,K.Interaction=mn,K.layouts=tt,K.platforms=Cn,K.Scale=Wt,K.Ticks=fe,Object.assign(K,ro,ko,ns,j,Cn),K.Chart=K,typeof window<"u"&&(window.Chart=K),K})});var Qr=Wr(Ko());(function(){"use strict";let j=new Map;function N(){let L=getComputedStyle(document.documentElement);return{foreground:L.getPropertyValue("--foreground").trim()||"#000",background:L.getPropertyValue("--background").trim()||"#fff",mutedForeground:L.getPropertyValue("--muted-foreground").trim()||"#666",border:L.getPropertyValue("--border").trim()||"#ccc"}}function mt(L,A){let Tt=["pie","doughnut","bar","radar"].includes(L.type),bt={display:L.showLegend||!1,labels:{color:A.foreground}},W={backgroundColor:A.background,bodyColor:A.mutedForeground,titleColor:A.foreground,borderColor:A.border,borderWidth:1},V=L.type==="radar"?{r:{grid:{color:A.border,display:L.showYGrid!==!1},ticks:{color:A.mutedForeground,backdropColor:"transparent",display:L.showYLabels!==!1},angleLines:{color:A.border,display:L.showXGrid!==!1},pointLabels:{color:A.foreground,font:{size:12}},border:{display:L.showYAxis!==!1,color:A.border},beginAtZero:!0}}:{x:{beginAtZero:!0,display:L.showXLabels!==!1||L.showXGrid!==!1||L.showXAxis!==!1,border:{display:L.showXAxis!==!1,color:A.border},ticks:{display:L.showXLabels!==!1,color:A.mutedForeground},grid:{display:L.showXGrid!==!1,color:A.border},stacked:L.stacked||!1},y:{offset:!0,beginAtZero:L.beginAtZero!==!1,min:L.yMin,max:L.yMax,display:L.showYLabels!==!1||L.showYGrid!==!1||L.showYAxis!==!1,border:{display:L.showYAxis!==!1,color:A.border},ticks:{display:L.showYLabels!==!1,color:A.mutedForeground},grid:{display:L.showYGrid!==!1,color:A.border},stacked:L.stacked||!1}};return{...L,options:{responsive:!0,maintainAspectRatio:!1,interaction:{intersect:Tt,axis:"xy",mode:Tt?"nearest":"index"},indexAxis:L.horizontal?"y":"x",plugins:{legend:bt,tooltip:W},scales:V}}}function I(L){if(!L||!L.id||!L.hasAttribute("data-tui-chart-id"))return;j.has(L.id)&&F(L);let A=L.getAttribute("data-tui-chart-id"),Tt=document.getElementById(A);if(Tt)try{let bt=JSON.parse(Tt.textContent),W=N();Chart.defaults.elements.point.radius=0,Chart.defaults.elements.point.hoverRadius=5;let V=bt.rawConfig?bt.rawConfig:mt(bt.generatedConfig||bt,W);j.set(L.id,new Chart(L,V))}catch{}}function F(L){if(!(!L||!L.id||!j.has(L.id)))try{j.get(L.id).destroy()}finally{j.delete(L.id)}}function z(){typeof Chart<"u"?(document.querySelectorAll("canvas[data-tui-chart-id]").forEach(I),U()):setTimeout(z,100)}document.addEventListener("DOMContentLoaded",z);function U(){let L;new MutationObserver(()=>{clearTimeout(L),L=setTimeout(()=>{document.querySelectorAll("canvas[data-tui-chart-id]").forEach(A=>{j.has(A.id)&&(F(A),I(A))})},50)}).observe(document.documentElement,{attributes:!0,attributeFilter:["class","style"]}),new MutationObserver(()=>{document.querySelectorAll("canvas[data-tui-chart-id]").forEach(A=>{j.has(A.id)||I(A)})}).observe(document.body,{childList:!0,subtree:!0})}})();})(); /*! * Chart.js v4.4.8 * https://www.chartjs.org diff --git a/assets/js/chartjs.js b/assets/js/chartjs.js new file mode 100644 index 0000000..5a5f471 --- /dev/null +++ b/assets/js/chartjs.js @@ -0,0 +1,11735 @@ +/** + * Skipped minification because the original files appears to be already minified. + * Original file: /npm/chart.js@4.4.8/dist/chart.umd.js + * + * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files + */ +/*! + * Chart.js v4.4.8 + * https://www.chartjs.org + * (c) 2025 Chart.js Contributors + * Released under the MIT License + */ +!(function (t, e) { + "object" == typeof exports && "undefined" != typeof module + ? (module.exports = e()) + : "function" == typeof define && define.amd + ? define(e) + : ((t = "undefined" != typeof globalThis ? globalThis : t || self).Chart = + e()); +})(this, function () { + "use strict"; + var t = Object.freeze({ + __proto__: null, + get Colors() { + return Go; + }, + get Decimation() { + return Qo; + }, + get Filler() { + return ma; + }, + get Legend() { + return ya; + }, + get SubTitle() { + return ka; + }, + get Title() { + return Ma; + }, + get Tooltip() { + return Ba; + }, + }); + function e() {} + const i = (() => { + let t = 0; + return () => t++; + })(); + function s(t) { + return null == t; + } + function n(t) { + if (Array.isArray && Array.isArray(t)) return !0; + const e = Object.prototype.toString.call(t); + return "[object" === e.slice(0, 7) && "Array]" === e.slice(-6); + } + function o(t) { + return ( + null !== t && "[object Object]" === Object.prototype.toString.call(t) + ); + } + function a(t) { + return ("number" == typeof t || t instanceof Number) && isFinite(+t); + } + function r(t, e) { + return a(t) ? t : e; + } + function l(t, e) { + return void 0 === t ? e : t; + } + const h = (t, e) => + "string" == typeof t && t.endsWith("%") ? parseFloat(t) / 100 : +t / e, + c = (t, e) => + "string" == typeof t && t.endsWith("%") ? (parseFloat(t) / 100) * e : +t; + function d(t, e, i) { + if (t && "function" == typeof t.call) return t.apply(i, e); + } + function u(t, e, i, s) { + let a, r, l; + if (n(t)) + if (((r = t.length), s)) for (a = r - 1; a >= 0; a--) e.call(i, t[a], a); + else for (a = 0; a < r; a++) e.call(i, t[a], a); + else if (o(t)) + for (l = Object.keys(t), r = l.length, a = 0; a < r; a++) + e.call(i, t[l[a]], l[a]); + } + function f(t, e) { + let i, s, n, o; + if (!t || !e || t.length !== e.length) return !1; + for (i = 0, s = t.length; i < s; ++i) + if ( + ((n = t[i]), + (o = e[i]), + n.datasetIndex !== o.datasetIndex || n.index !== o.index) + ) + return !1; + return !0; + } + function g(t) { + if (n(t)) return t.map(g); + if (o(t)) { + const e = Object.create(null), + i = Object.keys(t), + s = i.length; + let n = 0; + for (; n < s; ++n) e[i[n]] = g(t[i[n]]); + return e; + } + return t; + } + function p(t) { + return -1 === ["__proto__", "prototype", "constructor"].indexOf(t); + } + function m(t, e, i, s) { + if (!p(t)) return; + const n = e[t], + a = i[t]; + o(n) && o(a) ? x(n, a, s) : (e[t] = g(a)); + } + function x(t, e, i) { + const s = n(e) ? e : [e], + a = s.length; + if (!o(t)) return t; + const r = (i = i || {}).merger || m; + let l; + for (let e = 0; e < a; ++e) { + if (((l = s[e]), !o(l))) continue; + const n = Object.keys(l); + for (let e = 0, s = n.length; e < s; ++e) r(n[e], t, l, i); + } + return t; + } + function b(t, e) { + return x(t, e, { merger: _ }); + } + function _(t, e, i) { + if (!p(t)) return; + const s = e[t], + n = i[t]; + o(s) && o(n) + ? b(s, n) + : Object.prototype.hasOwnProperty.call(e, t) || (e[t] = g(n)); + } + const y = { "": (t) => t, x: (t) => t.x, y: (t) => t.y }; + function v(t) { + const e = t.split("."), + i = []; + let s = ""; + for (const t of e) + (s += t), + s.endsWith("\\") ? (s = s.slice(0, -1) + ".") : (i.push(s), (s = "")); + return i; + } + function M(t, e) { + const i = + y[e] || + (y[e] = (function (t) { + const e = v(t); + return (t) => { + for (const i of e) { + if ("" === i) break; + t = t && t[i]; + } + return t; + }; + })(e)); + return i(t); + } + function w(t) { + return t.charAt(0).toUpperCase() + t.slice(1); + } + const k = (t) => void 0 !== t, + S = (t) => "function" == typeof t, + P = (t, e) => { + if (t.size !== e.size) return !1; + for (const i of t) if (!e.has(i)) return !1; + return !0; + }; + function D(t) { + return ( + "mouseup" === t.type || "click" === t.type || "contextmenu" === t.type + ); + } + const C = Math.PI, + O = 2 * C, + A = O + C, + T = Number.POSITIVE_INFINITY, + L = C / 180, + E = C / 2, + R = C / 4, + I = (2 * C) / 3, + z = Math.log10, + F = Math.sign; + function V(t, e, i) { + return Math.abs(t - e) < i; + } + function B(t) { + const e = Math.round(t); + t = V(t, e, t / 1e3) ? e : t; + const i = Math.pow(10, Math.floor(z(t))), + s = t / i; + return (s <= 1 ? 1 : s <= 2 ? 2 : s <= 5 ? 5 : 10) * i; + } + function W(t) { + const e = [], + i = Math.sqrt(t); + let s; + for (s = 1; s < i; s++) t % s == 0 && (e.push(s), e.push(t / s)); + return i === (0 | i) && e.push(i), e.sort((t, e) => t - e).pop(), e; + } + function N(t) { + return ( + !(function (t) { + return ( + "symbol" == typeof t || + ("object" == typeof t && + null !== t && + !(Symbol.toPrimitive in t || "toString" in t || "valueOf" in t)) + ); + })(t) && + !isNaN(parseFloat(t)) && + isFinite(t) + ); + } + function H(t, e) { + const i = Math.round(t); + return i - e <= t && i + e >= t; + } + function j(t, e, i) { + let s, n, o; + for (s = 0, n = t.length; s < n; s++) + (o = t[s][i]), + isNaN(o) || + ((e.min = Math.min(e.min, o)), (e.max = Math.max(e.max, o))); + } + function $(t) { + return t * (C / 180); + } + function Y(t) { + return t * (180 / C); + } + function U(t) { + if (!a(t)) return; + let e = 1, + i = 0; + for (; Math.round(t * e) / e !== t; ) (e *= 10), i++; + return i; + } + function X(t, e) { + const i = e.x - t.x, + s = e.y - t.y, + n = Math.sqrt(i * i + s * s); + let o = Math.atan2(s, i); + return o < -0.5 * C && (o += O), { angle: o, distance: n }; + } + function q(t, e) { + return Math.sqrt(Math.pow(e.x - t.x, 2) + Math.pow(e.y - t.y, 2)); + } + function K(t, e) { + return ((t - e + A) % O) - C; + } + function G(t) { + return ((t % O) + O) % O; + } + function Z(t, e, i, s) { + const n = G(t), + o = G(e), + a = G(i), + r = G(o - n), + l = G(a - n), + h = G(n - o), + c = G(n - a); + return n === o || n === a || (s && o === a) || (r > l && h < c); + } + function J(t, e, i) { + return Math.max(e, Math.min(i, t)); + } + function Q(t) { + return J(t, -32768, 32767); + } + function tt(t, e, i, s = 1e-6) { + return t >= Math.min(e, i) - s && t <= Math.max(e, i) + s; + } + function et(t, e, i) { + i = i || ((i) => t[i] < e); + let s, + n = t.length - 1, + o = 0; + for (; n - o > 1; ) (s = (o + n) >> 1), i(s) ? (o = s) : (n = s); + return { lo: o, hi: n }; + } + const it = (t, e, i, s) => + et( + t, + i, + s + ? (s) => { + const n = t[s][e]; + return n < i || (n === i && t[s + 1][e] === i); + } + : (s) => t[s][e] < i + ), + st = (t, e, i) => et(t, i, (s) => t[s][e] >= i); + function nt(t, e, i) { + let s = 0, + n = t.length; + for (; s < n && t[s] < e; ) s++; + for (; n > s && t[n - 1] > i; ) n--; + return s > 0 || n < t.length ? t.slice(s, n) : t; + } + const ot = ["push", "pop", "shift", "splice", "unshift"]; + function at(t, e) { + t._chartjs + ? t._chartjs.listeners.push(e) + : (Object.defineProperty(t, "_chartjs", { + configurable: !0, + enumerable: !1, + value: { listeners: [e] }, + }), + ot.forEach((e) => { + const i = "_onData" + w(e), + s = t[e]; + Object.defineProperty(t, e, { + configurable: !0, + enumerable: !1, + value(...e) { + const n = s.apply(this, e); + return ( + t._chartjs.listeners.forEach((t) => { + "function" == typeof t[i] && t[i](...e); + }), + n + ); + }, + }); + })); + } + function rt(t, e) { + const i = t._chartjs; + if (!i) return; + const s = i.listeners, + n = s.indexOf(e); + -1 !== n && s.splice(n, 1), + s.length > 0 || + (ot.forEach((e) => { + delete t[e]; + }), + delete t._chartjs); + } + function lt(t) { + const e = new Set(t); + return e.size === t.length ? t : Array.from(e); + } + const ht = + "undefined" == typeof window + ? function (t) { + return t(); + } + : window.requestAnimationFrame; + function ct(t, e) { + let i = [], + s = !1; + return function (...n) { + (i = n), + s || + ((s = !0), + ht.call(window, () => { + (s = !1), t.apply(e, i); + })); + }; + } + function dt(t, e) { + let i; + return function (...s) { + return ( + e ? (clearTimeout(i), (i = setTimeout(t, e, s))) : t.apply(this, s), e + ); + }; + } + const ut = (t) => ("start" === t ? "left" : "end" === t ? "right" : "center"), + ft = (t, e, i) => ("start" === t ? e : "end" === t ? i : (e + i) / 2), + gt = (t, e, i, s) => + t === (s ? "left" : "right") ? i : "center" === t ? (e + i) / 2 : e; + function pt(t, e, i) { + const n = e.length; + let o = 0, + a = n; + if (t._sorted) { + const { iScale: r, vScale: l, _parsed: h } = t, + c = t.dataset && t.dataset.options ? t.dataset.options.spanGaps : null, + d = r.axis, + { min: u, max: f, minDefined: g, maxDefined: p } = r.getUserBounds(); + if (g) { + if ( + ((o = Math.min( + it(h, d, u).lo, + i ? n : it(e, d, r.getPixelForValue(u)).lo + )), + c) + ) { + const t = h + .slice(0, o + 1) + .reverse() + .findIndex((t) => !s(t[l.axis])); + o -= Math.max(0, t); + } + o = J(o, 0, n - 1); + } + if (p) { + let t = Math.max( + it(h, r.axis, f, !0).hi + 1, + i ? 0 : it(e, d, r.getPixelForValue(f), !0).hi + 1 + ); + if (c) { + const e = h.slice(t - 1).findIndex((t) => !s(t[l.axis])); + t += Math.max(0, e); + } + a = J(t, o, n) - o; + } else a = n - o; + } + return { start: o, count: a }; + } + function mt(t) { + const { xScale: e, yScale: i, _scaleRanges: s } = t, + n = { xmin: e.min, xmax: e.max, ymin: i.min, ymax: i.max }; + if (!s) return (t._scaleRanges = n), !0; + const o = + s.xmin !== e.min || + s.xmax !== e.max || + s.ymin !== i.min || + s.ymax !== i.max; + return Object.assign(s, n), o; + } + class xt { + constructor() { + (this._request = null), + (this._charts = new Map()), + (this._running = !1), + (this._lastDate = void 0); + } + _notify(t, e, i, s) { + const n = e.listeners[s], + o = e.duration; + n.forEach((s) => + s({ + chart: t, + initial: e.initial, + numSteps: o, + currentStep: Math.min(i - e.start, o), + }) + ); + } + _refresh() { + this._request || + ((this._running = !0), + (this._request = ht.call(window, () => { + this._update(), + (this._request = null), + this._running && this._refresh(); + }))); + } + _update(t = Date.now()) { + let e = 0; + this._charts.forEach((i, s) => { + if (!i.running || !i.items.length) return; + const n = i.items; + let o, + a = n.length - 1, + r = !1; + for (; a >= 0; --a) + (o = n[a]), + o._active + ? (o._total > i.duration && (i.duration = o._total), + o.tick(t), + (r = !0)) + : ((n[a] = n[n.length - 1]), n.pop()); + r && (s.draw(), this._notify(s, i, t, "progress")), + n.length || + ((i.running = !1), + this._notify(s, i, t, "complete"), + (i.initial = !1)), + (e += n.length); + }), + (this._lastDate = t), + 0 === e && (this._running = !1); + } + _getAnims(t) { + const e = this._charts; + let i = e.get(t); + return ( + i || + ((i = { + running: !1, + initial: !0, + items: [], + listeners: { complete: [], progress: [] }, + }), + e.set(t, i)), + i + ); + } + listen(t, e, i) { + this._getAnims(t).listeners[e].push(i); + } + add(t, e) { + e && e.length && this._getAnims(t).items.push(...e); + } + has(t) { + return this._getAnims(t).items.length > 0; + } + start(t) { + const e = this._charts.get(t); + e && + ((e.running = !0), + (e.start = Date.now()), + (e.duration = e.items.reduce((t, e) => Math.max(t, e._duration), 0)), + this._refresh()); + } + running(t) { + if (!this._running) return !1; + const e = this._charts.get(t); + return !!(e && e.running && e.items.length); + } + stop(t) { + const e = this._charts.get(t); + if (!e || !e.items.length) return; + const i = e.items; + let s = i.length - 1; + for (; s >= 0; --s) i[s].cancel(); + (e.items = []), this._notify(t, e, Date.now(), "complete"); + } + remove(t) { + return this._charts.delete(t); + } + } + var bt = new xt(); + /*! + * @kurkle/color v0.3.2 + * https://github.com/kurkle/color#readme + * (c) 2023 Jukka Kurkela + * Released under the MIT License + */ function _t(t) { + return (t + 0.5) | 0; + } + const yt = (t, e, i) => Math.max(Math.min(t, i), e); + function vt(t) { + return yt(_t(2.55 * t), 0, 255); + } + function Mt(t) { + return yt(_t(255 * t), 0, 255); + } + function wt(t) { + return yt(_t(t / 2.55) / 100, 0, 1); + } + function kt(t) { + return yt(_t(100 * t), 0, 100); + } + const St = { + 0: 0, + 1: 1, + 2: 2, + 3: 3, + 4: 4, + 5: 5, + 6: 6, + 7: 7, + 8: 8, + 9: 9, + A: 10, + B: 11, + C: 12, + D: 13, + E: 14, + F: 15, + a: 10, + b: 11, + c: 12, + d: 13, + e: 14, + f: 15, + }, + Pt = [..."0123456789ABCDEF"], + Dt = (t) => Pt[15 & t], + Ct = (t) => Pt[(240 & t) >> 4] + Pt[15 & t], + Ot = (t) => (240 & t) >> 4 == (15 & t); + function At(t) { + var e = ((t) => Ot(t.r) && Ot(t.g) && Ot(t.b) && Ot(t.a))(t) ? Dt : Ct; + return t + ? "#" + + e(t.r) + + e(t.g) + + e(t.b) + + ((t, e) => (t < 255 ? e(t) : ""))(t.a, e) + : void 0; + } + const Tt = + /^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/; + function Lt(t, e, i) { + const s = e * Math.min(i, 1 - i), + n = (e, n = (e + t / 30) % 12) => + i - s * Math.max(Math.min(n - 3, 9 - n, 1), -1); + return [n(0), n(8), n(4)]; + } + function Et(t, e, i) { + const s = (s, n = (s + t / 60) % 6) => + i - i * e * Math.max(Math.min(n, 4 - n, 1), 0); + return [s(5), s(3), s(1)]; + } + function Rt(t, e, i) { + const s = Lt(t, 1, 0.5); + let n; + for ( + e + i > 1 && ((n = 1 / (e + i)), (e *= n), (i *= n)), n = 0; + n < 3; + n++ + ) + (s[n] *= 1 - e - i), (s[n] += e); + return s; + } + function It(t) { + const e = t.r / 255, + i = t.g / 255, + s = t.b / 255, + n = Math.max(e, i, s), + o = Math.min(e, i, s), + a = (n + o) / 2; + let r, l, h; + return ( + n !== o && + ((h = n - o), + (l = a > 0.5 ? h / (2 - n - o) : h / (n + o)), + (r = (function (t, e, i, s, n) { + return t === n + ? (e - i) / s + (e < i ? 6 : 0) + : e === n + ? (i - t) / s + 2 + : (t - e) / s + 4; + })(e, i, s, h, n)), + (r = 60 * r + 0.5)), + [0 | r, l || 0, a] + ); + } + function zt(t, e, i, s) { + return (Array.isArray(e) ? t(e[0], e[1], e[2]) : t(e, i, s)).map(Mt); + } + function Ft(t, e, i) { + return zt(Lt, t, e, i); + } + function Vt(t) { + return ((t % 360) + 360) % 360; + } + function Bt(t) { + const e = Tt.exec(t); + let i, + s = 255; + if (!e) return; + e[5] !== i && (s = e[6] ? vt(+e[5]) : Mt(+e[5])); + const n = Vt(+e[2]), + o = +e[3] / 100, + a = +e[4] / 100; + return ( + (i = + "hwb" === e[1] + ? (function (t, e, i) { + return zt(Rt, t, e, i); + })(n, o, a) + : "hsv" === e[1] + ? (function (t, e, i) { + return zt(Et, t, e, i); + })(n, o, a) + : Ft(n, o, a)), + { r: i[0], g: i[1], b: i[2], a: s } + ); + } + const Wt = { + x: "dark", + Z: "light", + Y: "re", + X: "blu", + W: "gr", + V: "medium", + U: "slate", + A: "ee", + T: "ol", + S: "or", + B: "ra", + C: "lateg", + D: "ights", + R: "in", + Q: "turquois", + E: "hi", + P: "ro", + O: "al", + N: "le", + M: "de", + L: "yello", + F: "en", + K: "ch", + G: "arks", + H: "ea", + I: "ightg", + J: "wh", + }, + Nt = { + OiceXe: "f0f8ff", + antiquewEte: "faebd7", + aqua: "ffff", + aquamarRe: "7fffd4", + azuY: "f0ffff", + beige: "f5f5dc", + bisque: "ffe4c4", + black: "0", + blanKedOmond: "ffebcd", + Xe: "ff", + XeviTet: "8a2be2", + bPwn: "a52a2a", + burlywood: "deb887", + caMtXe: "5f9ea0", + KartYuse: "7fff00", + KocTate: "d2691e", + cSO: "ff7f50", + cSnflowerXe: "6495ed", + cSnsilk: "fff8dc", + crimson: "dc143c", + cyan: "ffff", + xXe: "8b", + xcyan: "8b8b", + xgTMnPd: "b8860b", + xWay: "a9a9a9", + xgYF: "6400", + xgYy: "a9a9a9", + xkhaki: "bdb76b", + xmagFta: "8b008b", + xTivegYF: "556b2f", + xSange: "ff8c00", + xScEd: "9932cc", + xYd: "8b0000", + xsOmon: "e9967a", + xsHgYF: "8fbc8f", + xUXe: "483d8b", + xUWay: "2f4f4f", + xUgYy: "2f4f4f", + xQe: "ced1", + xviTet: "9400d3", + dAppRk: "ff1493", + dApskyXe: "bfff", + dimWay: "696969", + dimgYy: "696969", + dodgerXe: "1e90ff", + fiYbrick: "b22222", + flSOwEte: "fffaf0", + foYstWAn: "228b22", + fuKsia: "ff00ff", + gaRsbSo: "dcdcdc", + ghostwEte: "f8f8ff", + gTd: "ffd700", + gTMnPd: "daa520", + Way: "808080", + gYF: "8000", + gYFLw: "adff2f", + gYy: "808080", + honeyMw: "f0fff0", + hotpRk: "ff69b4", + RdianYd: "cd5c5c", + Rdigo: "4b0082", + ivSy: "fffff0", + khaki: "f0e68c", + lavFMr: "e6e6fa", + lavFMrXsh: "fff0f5", + lawngYF: "7cfc00", + NmoncEffon: "fffacd", + ZXe: "add8e6", + ZcSO: "f08080", + Zcyan: "e0ffff", + ZgTMnPdLw: "fafad2", + ZWay: "d3d3d3", + ZgYF: "90ee90", + ZgYy: "d3d3d3", + ZpRk: "ffb6c1", + ZsOmon: "ffa07a", + ZsHgYF: "20b2aa", + ZskyXe: "87cefa", + ZUWay: "778899", + ZUgYy: "778899", + ZstAlXe: "b0c4de", + ZLw: "ffffe0", + lime: "ff00", + limegYF: "32cd32", + lRF: "faf0e6", + magFta: "ff00ff", + maPon: "800000", + VaquamarRe: "66cdaa", + VXe: "cd", + VScEd: "ba55d3", + VpurpN: "9370db", + VsHgYF: "3cb371", + VUXe: "7b68ee", + VsprRggYF: "fa9a", + VQe: "48d1cc", + VviTetYd: "c71585", + midnightXe: "191970", + mRtcYam: "f5fffa", + mistyPse: "ffe4e1", + moccasR: "ffe4b5", + navajowEte: "ffdead", + navy: "80", + Tdlace: "fdf5e6", + Tive: "808000", + TivedBb: "6b8e23", + Sange: "ffa500", + SangeYd: "ff4500", + ScEd: "da70d6", + pOegTMnPd: "eee8aa", + pOegYF: "98fb98", + pOeQe: "afeeee", + pOeviTetYd: "db7093", + papayawEp: "ffefd5", + pHKpuff: "ffdab9", + peru: "cd853f", + pRk: "ffc0cb", + plum: "dda0dd", + powMrXe: "b0e0e6", + purpN: "800080", + YbeccapurpN: "663399", + Yd: "ff0000", + Psybrown: "bc8f8f", + PyOXe: "4169e1", + saddNbPwn: "8b4513", + sOmon: "fa8072", + sandybPwn: "f4a460", + sHgYF: "2e8b57", + sHshell: "fff5ee", + siFna: "a0522d", + silver: "c0c0c0", + skyXe: "87ceeb", + UXe: "6a5acd", + UWay: "708090", + UgYy: "708090", + snow: "fffafa", + sprRggYF: "ff7f", + stAlXe: "4682b4", + tan: "d2b48c", + teO: "8080", + tEstN: "d8bfd8", + tomato: "ff6347", + Qe: "40e0d0", + viTet: "ee82ee", + JHt: "f5deb3", + wEte: "ffffff", + wEtesmoke: "f5f5f5", + Lw: "ffff00", + LwgYF: "9acd32", + }; + let Ht; + function jt(t) { + Ht || + ((Ht = (function () { + const t = {}, + e = Object.keys(Nt), + i = Object.keys(Wt); + let s, n, o, a, r; + for (s = 0; s < e.length; s++) { + for (a = r = e[s], n = 0; n < i.length; n++) + (o = i[n]), (r = r.replace(o, Wt[o])); + (o = parseInt(Nt[a], 16)), + (t[r] = [(o >> 16) & 255, (o >> 8) & 255, 255 & o]); + } + return t; + })()), + (Ht.transparent = [0, 0, 0, 0])); + const e = Ht[t.toLowerCase()]; + return e && { r: e[0], g: e[1], b: e[2], a: 4 === e.length ? e[3] : 255 }; + } + const $t = + /^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/; + const Yt = (t) => + t <= 0.0031308 ? 12.92 * t : 1.055 * Math.pow(t, 1 / 2.4) - 0.055, + Ut = (t) => (t <= 0.04045 ? t / 12.92 : Math.pow((t + 0.055) / 1.055, 2.4)); + function Xt(t, e, i) { + if (t) { + let s = It(t); + (s[e] = Math.max(0, Math.min(s[e] + s[e] * i, 0 === e ? 360 : 1))), + (s = Ft(s)), + (t.r = s[0]), + (t.g = s[1]), + (t.b = s[2]); + } + } + function qt(t, e) { + return t ? Object.assign(e || {}, t) : t; + } + function Kt(t) { + var e = { r: 0, g: 0, b: 0, a: 255 }; + return ( + Array.isArray(t) + ? t.length >= 3 && + ((e = { r: t[0], g: t[1], b: t[2], a: 255 }), + t.length > 3 && (e.a = Mt(t[3]))) + : ((e = qt(t, { r: 0, g: 0, b: 0, a: 1 })).a = Mt(e.a)), + e + ); + } + function Gt(t) { + return "r" === t.charAt(0) + ? (function (t) { + const e = $t.exec(t); + let i, + s, + n, + o = 255; + if (e) { + if (e[7] !== i) { + const t = +e[7]; + o = e[8] ? vt(t) : yt(255 * t, 0, 255); + } + return ( + (i = +e[1]), + (s = +e[3]), + (n = +e[5]), + (i = 255 & (e[2] ? vt(i) : yt(i, 0, 255))), + (s = 255 & (e[4] ? vt(s) : yt(s, 0, 255))), + (n = 255 & (e[6] ? vt(n) : yt(n, 0, 255))), + { r: i, g: s, b: n, a: o } + ); + } + })(t) + : Bt(t); + } + class Zt { + constructor(t) { + if (t instanceof Zt) return t; + const e = typeof t; + let i; + var s, n, o; + "object" === e + ? (i = Kt(t)) + : "string" === e && + ((o = (s = t).length), + "#" === s[0] && + (4 === o || 5 === o + ? (n = { + r: 255 & (17 * St[s[1]]), + g: 255 & (17 * St[s[2]]), + b: 255 & (17 * St[s[3]]), + a: 5 === o ? 17 * St[s[4]] : 255, + }) + : (7 !== o && 9 !== o) || + (n = { + r: (St[s[1]] << 4) | St[s[2]], + g: (St[s[3]] << 4) | St[s[4]], + b: (St[s[5]] << 4) | St[s[6]], + a: 9 === o ? (St[s[7]] << 4) | St[s[8]] : 255, + })), + (i = n || jt(t) || Gt(t))), + (this._rgb = i), + (this._valid = !!i); + } + get valid() { + return this._valid; + } + get rgb() { + var t = qt(this._rgb); + return t && (t.a = wt(t.a)), t; + } + set rgb(t) { + this._rgb = Kt(t); + } + rgbString() { + return this._valid + ? (t = this._rgb) && + (t.a < 255 + ? `rgba(${t.r}, ${t.g}, ${t.b}, ${wt(t.a)})` + : `rgb(${t.r}, ${t.g}, ${t.b})`) + : void 0; + var t; + } + hexString() { + return this._valid ? At(this._rgb) : void 0; + } + hslString() { + return this._valid + ? (function (t) { + if (!t) return; + const e = It(t), + i = e[0], + s = kt(e[1]), + n = kt(e[2]); + return t.a < 255 + ? `hsla(${i}, ${s}%, ${n}%, ${wt(t.a)})` + : `hsl(${i}, ${s}%, ${n}%)`; + })(this._rgb) + : void 0; + } + mix(t, e) { + if (t) { + const i = this.rgb, + s = t.rgb; + let n; + const o = e === n ? 0.5 : e, + a = 2 * o - 1, + r = i.a - s.a, + l = ((a * r == -1 ? a : (a + r) / (1 + a * r)) + 1) / 2; + (n = 1 - l), + (i.r = 255 & (l * i.r + n * s.r + 0.5)), + (i.g = 255 & (l * i.g + n * s.g + 0.5)), + (i.b = 255 & (l * i.b + n * s.b + 0.5)), + (i.a = o * i.a + (1 - o) * s.a), + (this.rgb = i); + } + return this; + } + interpolate(t, e) { + return ( + t && + (this._rgb = (function (t, e, i) { + const s = Ut(wt(t.r)), + n = Ut(wt(t.g)), + o = Ut(wt(t.b)); + return { + r: Mt(Yt(s + i * (Ut(wt(e.r)) - s))), + g: Mt(Yt(n + i * (Ut(wt(e.g)) - n))), + b: Mt(Yt(o + i * (Ut(wt(e.b)) - o))), + a: t.a + i * (e.a - t.a), + }; + })(this._rgb, t._rgb, e)), + this + ); + } + clone() { + return new Zt(this.rgb); + } + alpha(t) { + return (this._rgb.a = Mt(t)), this; + } + clearer(t) { + return (this._rgb.a *= 1 - t), this; + } + greyscale() { + const t = this._rgb, + e = _t(0.3 * t.r + 0.59 * t.g + 0.11 * t.b); + return (t.r = t.g = t.b = e), this; + } + opaquer(t) { + return (this._rgb.a *= 1 + t), this; + } + negate() { + const t = this._rgb; + return (t.r = 255 - t.r), (t.g = 255 - t.g), (t.b = 255 - t.b), this; + } + lighten(t) { + return Xt(this._rgb, 2, t), this; + } + darken(t) { + return Xt(this._rgb, 2, -t), this; + } + saturate(t) { + return Xt(this._rgb, 1, t), this; + } + desaturate(t) { + return Xt(this._rgb, 1, -t), this; + } + rotate(t) { + return ( + (function (t, e) { + var i = It(t); + (i[0] = Vt(i[0] + e)), + (i = Ft(i)), + (t.r = i[0]), + (t.g = i[1]), + (t.b = i[2]); + })(this._rgb, t), + this + ); + } + } + function Jt(t) { + if (t && "object" == typeof t) { + const e = t.toString(); + return "[object CanvasPattern]" === e || "[object CanvasGradient]" === e; + } + return !1; + } + function Qt(t) { + return Jt(t) ? t : new Zt(t); + } + function te(t) { + return Jt(t) ? t : new Zt(t).saturate(0.5).darken(0.1).hexString(); + } + const ee = ["x", "y", "borderWidth", "radius", "tension"], + ie = ["color", "borderColor", "backgroundColor"]; + const se = new Map(); + function ne(t, e, i) { + return (function (t, e) { + e = e || {}; + const i = t + JSON.stringify(e); + let s = se.get(i); + return s || ((s = new Intl.NumberFormat(t, e)), se.set(i, s)), s; + })(e, i).format(t); + } + const oe = { + values: (t) => (n(t) ? t : "" + t), + numeric(t, e, i) { + if (0 === t) return "0"; + const s = this.chart.options.locale; + let n, + o = t; + if (i.length > 1) { + const e = Math.max( + Math.abs(i[0].value), + Math.abs(i[i.length - 1].value) + ); + (e < 1e-4 || e > 1e15) && (n = "scientific"), + (o = (function (t, e) { + let i = + e.length > 3 ? e[2].value - e[1].value : e[1].value - e[0].value; + Math.abs(i) >= 1 && t !== Math.floor(t) && (i = t - Math.floor(t)); + return i; + })(t, i)); + } + const a = z(Math.abs(o)), + r = isNaN(a) ? 1 : Math.max(Math.min(-1 * Math.floor(a), 20), 0), + l = { notation: n, minimumFractionDigits: r, maximumFractionDigits: r }; + return Object.assign(l, this.options.ticks.format), ne(t, s, l); + }, + logarithmic(t, e, i) { + if (0 === t) return "0"; + const s = i[e].significand || t / Math.pow(10, Math.floor(z(t))); + return [1, 2, 3, 5, 10, 15].includes(s) || e > 0.8 * i.length + ? oe.numeric.call(this, t, e, i) + : ""; + }, + }; + var ae = { formatters: oe }; + const re = Object.create(null), + le = Object.create(null); + function he(t, e) { + if (!e) return t; + const i = e.split("."); + for (let e = 0, s = i.length; e < s; ++e) { + const s = i[e]; + t = t[s] || (t[s] = Object.create(null)); + } + return t; + } + function ce(t, e, i) { + return "string" == typeof e ? x(he(t, e), i) : x(he(t, ""), e); + } + class de { + constructor(t, e) { + (this.animation = void 0), + (this.backgroundColor = "rgba(0,0,0,0.1)"), + (this.borderColor = "rgba(0,0,0,0.1)"), + (this.color = "#666"), + (this.datasets = {}), + (this.devicePixelRatio = (t) => t.chart.platform.getDevicePixelRatio()), + (this.elements = {}), + (this.events = [ + "mousemove", + "mouseout", + "click", + "touchstart", + "touchmove", + ]), + (this.font = { + family: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", + size: 12, + style: "normal", + lineHeight: 1.2, + weight: null, + }), + (this.hover = {}), + (this.hoverBackgroundColor = (t, e) => te(e.backgroundColor)), + (this.hoverBorderColor = (t, e) => te(e.borderColor)), + (this.hoverColor = (t, e) => te(e.color)), + (this.indexAxis = "x"), + (this.interaction = { + mode: "nearest", + intersect: !0, + includeInvisible: !1, + }), + (this.maintainAspectRatio = !0), + (this.onHover = null), + (this.onClick = null), + (this.parsing = !0), + (this.plugins = {}), + (this.responsive = !0), + (this.scale = void 0), + (this.scales = {}), + (this.showLine = !0), + (this.drawActiveElementsOnTop = !0), + this.describe(t), + this.apply(e); + } + set(t, e) { + return ce(this, t, e); + } + get(t) { + return he(this, t); + } + describe(t, e) { + return ce(le, t, e); + } + override(t, e) { + return ce(re, t, e); + } + route(t, e, i, s) { + const n = he(this, t), + a = he(this, i), + r = "_" + e; + Object.defineProperties(n, { + [r]: { value: n[e], writable: !0 }, + [e]: { + enumerable: !0, + get() { + const t = this[r], + e = a[s]; + return o(t) ? Object.assign({}, e, t) : l(t, e); + }, + set(t) { + this[r] = t; + }, + }, + }); + } + apply(t) { + t.forEach((t) => t(this)); + } + } + var ue = new de( + { + _scriptable: (t) => !t.startsWith("on"), + _indexable: (t) => "events" !== t, + hover: { _fallback: "interaction" }, + interaction: { _scriptable: !1, _indexable: !1 }, + }, + [ + function (t) { + t.set("animation", { + delay: void 0, + duration: 1e3, + easing: "easeOutQuart", + fn: void 0, + from: void 0, + loop: void 0, + to: void 0, + type: void 0, + }), + t.describe("animation", { + _fallback: !1, + _indexable: !1, + _scriptable: (t) => + "onProgress" !== t && "onComplete" !== t && "fn" !== t, + }), + t.set("animations", { + colors: { type: "color", properties: ie }, + numbers: { type: "number", properties: ee }, + }), + t.describe("animations", { _fallback: "animation" }), + t.set("transitions", { + active: { animation: { duration: 400 } }, + resize: { animation: { duration: 0 } }, + show: { + animations: { + colors: { from: "transparent" }, + visible: { type: "boolean", duration: 0 }, + }, + }, + hide: { + animations: { + colors: { to: "transparent" }, + visible: { + type: "boolean", + easing: "linear", + fn: (t) => 0 | t, + }, + }, + }, + }); + }, + function (t) { + t.set("layout", { + autoPadding: !0, + padding: { top: 0, right: 0, bottom: 0, left: 0 }, + }); + }, + function (t) { + t.set("scale", { + display: !0, + offset: !1, + reverse: !1, + beginAtZero: !1, + bounds: "ticks", + clip: !0, + grace: 0, + grid: { + display: !0, + lineWidth: 1, + drawOnChartArea: !0, + drawTicks: !0, + tickLength: 8, + tickWidth: (t, e) => e.lineWidth, + tickColor: (t, e) => e.color, + offset: !1, + }, + border: { display: !0, dash: [], dashOffset: 0, width: 1 }, + title: { display: !1, text: "", padding: { top: 4, bottom: 4 } }, + ticks: { + minRotation: 0, + maxRotation: 50, + mirror: !1, + textStrokeWidth: 0, + textStrokeColor: "", + padding: 3, + display: !0, + autoSkip: !0, + autoSkipPadding: 3, + labelOffset: 0, + callback: ae.formatters.values, + minor: {}, + major: {}, + align: "center", + crossAlign: "near", + showLabelBackdrop: !1, + backdropColor: "rgba(255, 255, 255, 0.75)", + backdropPadding: 2, + }, + }), + t.route("scale.ticks", "color", "", "color"), + t.route("scale.grid", "color", "", "borderColor"), + t.route("scale.border", "color", "", "borderColor"), + t.route("scale.title", "color", "", "color"), + t.describe("scale", { + _fallback: !1, + _scriptable: (t) => + !t.startsWith("before") && + !t.startsWith("after") && + "callback" !== t && + "parser" !== t, + _indexable: (t) => + "borderDash" !== t && "tickBorderDash" !== t && "dash" !== t, + }), + t.describe("scales", { _fallback: "scale" }), + t.describe("scale.ticks", { + _scriptable: (t) => "backdropPadding" !== t && "callback" !== t, + _indexable: (t) => "backdropPadding" !== t, + }); + }, + ] + ); + function fe() { + return "undefined" != typeof window && "undefined" != typeof document; + } + function ge(t) { + let e = t.parentNode; + return e && "[object ShadowRoot]" === e.toString() && (e = e.host), e; + } + function pe(t, e, i) { + let s; + return ( + "string" == typeof t + ? ((s = parseInt(t, 10)), + -1 !== t.indexOf("%") && (s = (s / 100) * e.parentNode[i])) + : (s = t), + s + ); + } + const me = (t) => t.ownerDocument.defaultView.getComputedStyle(t, null); + function xe(t, e) { + return me(t).getPropertyValue(e); + } + const be = ["top", "right", "bottom", "left"]; + function _e(t, e, i) { + const s = {}; + i = i ? "-" + i : ""; + for (let n = 0; n < 4; n++) { + const o = be[n]; + s[o] = parseFloat(t[e + "-" + o + i]) || 0; + } + return (s.width = s.left + s.right), (s.height = s.top + s.bottom), s; + } + const ye = (t, e, i) => (t > 0 || e > 0) && (!i || !i.shadowRoot); + function ve(t, e) { + if ("native" in t) return t; + const { canvas: i, currentDevicePixelRatio: s } = e, + n = me(i), + o = "border-box" === n.boxSizing, + a = _e(n, "padding"), + r = _e(n, "border", "width"), + { + x: l, + y: h, + box: c, + } = (function (t, e) { + const i = t.touches, + s = i && i.length ? i[0] : t, + { offsetX: n, offsetY: o } = s; + let a, + r, + l = !1; + if (ye(n, o, t.target)) (a = n), (r = o); + else { + const t = e.getBoundingClientRect(); + (a = s.clientX - t.left), (r = s.clientY - t.top), (l = !0); + } + return { x: a, y: r, box: l }; + })(t, i), + d = a.left + (c && r.left), + u = a.top + (c && r.top); + let { width: f, height: g } = e; + return ( + o && ((f -= a.width + r.width), (g -= a.height + r.height)), + { + x: Math.round((((l - d) / f) * i.width) / s), + y: Math.round((((h - u) / g) * i.height) / s), + } + ); + } + const Me = (t) => Math.round(10 * t) / 10; + function we(t, e, i, s) { + const n = me(t), + o = _e(n, "margin"), + a = pe(n.maxWidth, t, "clientWidth") || T, + r = pe(n.maxHeight, t, "clientHeight") || T, + l = (function (t, e, i) { + let s, n; + if (void 0 === e || void 0 === i) { + const o = t && ge(t); + if (o) { + const t = o.getBoundingClientRect(), + a = me(o), + r = _e(a, "border", "width"), + l = _e(a, "padding"); + (e = t.width - l.width - r.width), + (i = t.height - l.height - r.height), + (s = pe(a.maxWidth, o, "clientWidth")), + (n = pe(a.maxHeight, o, "clientHeight")); + } else (e = t.clientWidth), (i = t.clientHeight); + } + return { width: e, height: i, maxWidth: s || T, maxHeight: n || T }; + })(t, e, i); + let { width: h, height: c } = l; + if ("content-box" === n.boxSizing) { + const t = _e(n, "border", "width"), + e = _e(n, "padding"); + (h -= e.width + t.width), (c -= e.height + t.height); + } + (h = Math.max(0, h - o.width)), + (c = Math.max(0, s ? h / s : c - o.height)), + (h = Me(Math.min(h, a, l.maxWidth))), + (c = Me(Math.min(c, r, l.maxHeight))), + h && !c && (c = Me(h / 2)); + return ( + (void 0 !== e || void 0 !== i) && + s && + l.height && + c > l.height && + ((c = l.height), (h = Me(Math.floor(c * s)))), + { width: h, height: c } + ); + } + function ke(t, e, i) { + const s = e || 1, + n = Math.floor(t.height * s), + o = Math.floor(t.width * s); + (t.height = Math.floor(t.height)), (t.width = Math.floor(t.width)); + const a = t.canvas; + return ( + a.style && + (i || (!a.style.height && !a.style.width)) && + ((a.style.height = `${t.height}px`), (a.style.width = `${t.width}px`)), + (t.currentDevicePixelRatio !== s || a.height !== n || a.width !== o) && + ((t.currentDevicePixelRatio = s), + (a.height = n), + (a.width = o), + t.ctx.setTransform(s, 0, 0, s, 0, 0), + !0) + ); + } + const Se = (function () { + let t = !1; + try { + const e = { + get passive() { + return (t = !0), !1; + }, + }; + fe() && + (window.addEventListener("test", null, e), + window.removeEventListener("test", null, e)); + } catch (t) {} + return t; + })(); + function Pe(t, e) { + const i = xe(t, e), + s = i && i.match(/^(\d+)(\.\d+)?px$/); + return s ? +s[1] : void 0; + } + function De(t) { + return !t || s(t.size) || s(t.family) + ? null + : (t.style ? t.style + " " : "") + + (t.weight ? t.weight + " " : "") + + t.size + + "px " + + t.family; + } + function Ce(t, e, i, s, n) { + let o = e[n]; + return ( + o || ((o = e[n] = t.measureText(n).width), i.push(n)), o > s && (s = o), s + ); + } + function Oe(t, e, i, s) { + let o = ((s = s || {}).data = s.data || {}), + a = (s.garbageCollect = s.garbageCollect || []); + s.font !== e && + ((o = s.data = {}), (a = s.garbageCollect = []), (s.font = e)), + t.save(), + (t.font = e); + let r = 0; + const l = i.length; + let h, c, d, u, f; + for (h = 0; h < l; h++) + if (((u = i[h]), null == u || n(u))) { + if (n(u)) + for (c = 0, d = u.length; c < d; c++) + (f = u[c]), null == f || n(f) || (r = Ce(t, o, a, r, f)); + } else r = Ce(t, o, a, r, u); + t.restore(); + const g = a.length / 2; + if (g > i.length) { + for (h = 0; h < g; h++) delete o[a[h]]; + a.splice(0, g); + } + return r; + } + function Ae(t, e, i) { + const s = t.currentDevicePixelRatio, + n = 0 !== i ? Math.max(i / 2, 0.5) : 0; + return Math.round((e - n) * s) / s + n; + } + function Te(t, e) { + (e || t) && + ((e = e || t.getContext("2d")).save(), + e.resetTransform(), + e.clearRect(0, 0, t.width, t.height), + e.restore()); + } + function Le(t, e, i, s) { + Ee(t, e, i, s, null); + } + function Ee(t, e, i, s, n) { + let o, a, r, l, h, c, d, u; + const f = e.pointStyle, + g = e.rotation, + p = e.radius; + let m = (g || 0) * L; + if ( + f && + "object" == typeof f && + ((o = f.toString()), + "[object HTMLImageElement]" === o || "[object HTMLCanvasElement]" === o) + ) + return ( + t.save(), + t.translate(i, s), + t.rotate(m), + t.drawImage(f, -f.width / 2, -f.height / 2, f.width, f.height), + void t.restore() + ); + if (!(isNaN(p) || p <= 0)) { + switch ((t.beginPath(), f)) { + default: + n ? t.ellipse(i, s, n / 2, p, 0, 0, O) : t.arc(i, s, p, 0, O), + t.closePath(); + break; + case "triangle": + (c = n ? n / 2 : p), + t.moveTo(i + Math.sin(m) * c, s - Math.cos(m) * p), + (m += I), + t.lineTo(i + Math.sin(m) * c, s - Math.cos(m) * p), + (m += I), + t.lineTo(i + Math.sin(m) * c, s - Math.cos(m) * p), + t.closePath(); + break; + case "rectRounded": + (h = 0.516 * p), + (l = p - h), + (a = Math.cos(m + R) * l), + (d = Math.cos(m + R) * (n ? n / 2 - h : l)), + (r = Math.sin(m + R) * l), + (u = Math.sin(m + R) * (n ? n / 2 - h : l)), + t.arc(i - d, s - r, h, m - C, m - E), + t.arc(i + u, s - a, h, m - E, m), + t.arc(i + d, s + r, h, m, m + E), + t.arc(i - u, s + a, h, m + E, m + C), + t.closePath(); + break; + case "rect": + if (!g) { + (l = Math.SQRT1_2 * p), + (c = n ? n / 2 : l), + t.rect(i - c, s - l, 2 * c, 2 * l); + break; + } + m += R; + case "rectRot": + (d = Math.cos(m) * (n ? n / 2 : p)), + (a = Math.cos(m) * p), + (r = Math.sin(m) * p), + (u = Math.sin(m) * (n ? n / 2 : p)), + t.moveTo(i - d, s - r), + t.lineTo(i + u, s - a), + t.lineTo(i + d, s + r), + t.lineTo(i - u, s + a), + t.closePath(); + break; + case "crossRot": + m += R; + case "cross": + (d = Math.cos(m) * (n ? n / 2 : p)), + (a = Math.cos(m) * p), + (r = Math.sin(m) * p), + (u = Math.sin(m) * (n ? n / 2 : p)), + t.moveTo(i - d, s - r), + t.lineTo(i + d, s + r), + t.moveTo(i + u, s - a), + t.lineTo(i - u, s + a); + break; + case "star": + (d = Math.cos(m) * (n ? n / 2 : p)), + (a = Math.cos(m) * p), + (r = Math.sin(m) * p), + (u = Math.sin(m) * (n ? n / 2 : p)), + t.moveTo(i - d, s - r), + t.lineTo(i + d, s + r), + t.moveTo(i + u, s - a), + t.lineTo(i - u, s + a), + (m += R), + (d = Math.cos(m) * (n ? n / 2 : p)), + (a = Math.cos(m) * p), + (r = Math.sin(m) * p), + (u = Math.sin(m) * (n ? n / 2 : p)), + t.moveTo(i - d, s - r), + t.lineTo(i + d, s + r), + t.moveTo(i + u, s - a), + t.lineTo(i - u, s + a); + break; + case "line": + (a = n ? n / 2 : Math.cos(m) * p), + (r = Math.sin(m) * p), + t.moveTo(i - a, s - r), + t.lineTo(i + a, s + r); + break; + case "dash": + t.moveTo(i, s), + t.lineTo(i + Math.cos(m) * (n ? n / 2 : p), s + Math.sin(m) * p); + break; + case !1: + t.closePath(); + } + t.fill(), e.borderWidth > 0 && t.stroke(); + } + } + function Re(t, e, i) { + return ( + (i = i || 0.5), + !e || + (t && + t.x > e.left - i && + t.x < e.right + i && + t.y > e.top - i && + t.y < e.bottom + i) + ); + } + function Ie(t, e) { + t.save(), + t.beginPath(), + t.rect(e.left, e.top, e.right - e.left, e.bottom - e.top), + t.clip(); + } + function ze(t) { + t.restore(); + } + function Fe(t, e, i, s, n) { + if (!e) return t.lineTo(i.x, i.y); + if ("middle" === n) { + const s = (e.x + i.x) / 2; + t.lineTo(s, e.y), t.lineTo(s, i.y); + } else ("after" === n) != !!s ? t.lineTo(e.x, i.y) : t.lineTo(i.x, e.y); + t.lineTo(i.x, i.y); + } + function Ve(t, e, i, s) { + if (!e) return t.lineTo(i.x, i.y); + t.bezierCurveTo( + s ? e.cp1x : e.cp2x, + s ? e.cp1y : e.cp2y, + s ? i.cp2x : i.cp1x, + s ? i.cp2y : i.cp1y, + i.x, + i.y + ); + } + function Be(t, e, i, s, n) { + if (n.strikethrough || n.underline) { + const o = t.measureText(s), + a = e - o.actualBoundingBoxLeft, + r = e + o.actualBoundingBoxRight, + l = i - o.actualBoundingBoxAscent, + h = i + o.actualBoundingBoxDescent, + c = n.strikethrough ? (l + h) / 2 : h; + (t.strokeStyle = t.fillStyle), + t.beginPath(), + (t.lineWidth = n.decorationWidth || 2), + t.moveTo(a, c), + t.lineTo(r, c), + t.stroke(); + } + } + function We(t, e) { + const i = t.fillStyle; + (t.fillStyle = e.color), + t.fillRect(e.left, e.top, e.width, e.height), + (t.fillStyle = i); + } + function Ne(t, e, i, o, a, r = {}) { + const l = n(e) ? e : [e], + h = r.strokeWidth > 0 && "" !== r.strokeColor; + let c, d; + for ( + t.save(), + t.font = a.string, + (function (t, e) { + e.translation && t.translate(e.translation[0], e.translation[1]), + s(e.rotation) || t.rotate(e.rotation), + e.color && (t.fillStyle = e.color), + e.textAlign && (t.textAlign = e.textAlign), + e.textBaseline && (t.textBaseline = e.textBaseline); + })(t, r), + c = 0; + c < l.length; + ++c + ) + (d = l[c]), + r.backdrop && We(t, r.backdrop), + h && + (r.strokeColor && (t.strokeStyle = r.strokeColor), + s(r.strokeWidth) || (t.lineWidth = r.strokeWidth), + t.strokeText(d, i, o, r.maxWidth)), + t.fillText(d, i, o, r.maxWidth), + Be(t, i, o, d, r), + (o += Number(a.lineHeight)); + t.restore(); + } + function He(t, e) { + const { x: i, y: s, w: n, h: o, radius: a } = e; + t.arc(i + a.topLeft, s + a.topLeft, a.topLeft, 1.5 * C, C, !0), + t.lineTo(i, s + o - a.bottomLeft), + t.arc(i + a.bottomLeft, s + o - a.bottomLeft, a.bottomLeft, C, E, !0), + t.lineTo(i + n - a.bottomRight, s + o), + t.arc( + i + n - a.bottomRight, + s + o - a.bottomRight, + a.bottomRight, + E, + 0, + !0 + ), + t.lineTo(i + n, s + a.topRight), + t.arc(i + n - a.topRight, s + a.topRight, a.topRight, 0, -E, !0), + t.lineTo(i + a.topLeft, s); + } + function je(t, e = [""], i, s, n = () => t[0]) { + const o = i || t; + void 0 === s && (s = ti("_fallback", t)); + const a = { + [Symbol.toStringTag]: "Object", + _cacheable: !0, + _scopes: t, + _rootScopes: o, + _fallback: s, + _getTarget: n, + override: (i) => je([i, ...t], e, o, s), + }; + return new Proxy(a, { + deleteProperty: (e, i) => ( + delete e[i], delete e._keys, delete t[0][i], !0 + ), + get: (i, s) => + qe(i, s, () => + (function (t, e, i, s) { + let n; + for (const o of e) + if (((n = ti(Ue(o, t), i)), void 0 !== n)) + return Xe(t, n) ? Je(i, s, t, n) : n; + })(s, e, t, i) + ), + getOwnPropertyDescriptor: (t, e) => + Reflect.getOwnPropertyDescriptor(t._scopes[0], e), + getPrototypeOf: () => Reflect.getPrototypeOf(t[0]), + has: (t, e) => ei(t).includes(e), + ownKeys: (t) => ei(t), + set(t, e, i) { + const s = t._storage || (t._storage = n()); + return (t[e] = s[e] = i), delete t._keys, !0; + }, + }); + } + function $e(t, e, i, s) { + const a = { + _cacheable: !1, + _proxy: t, + _context: e, + _subProxy: i, + _stack: new Set(), + _descriptors: Ye(t, s), + setContext: (e) => $e(t, e, i, s), + override: (n) => $e(t.override(n), e, i, s), + }; + return new Proxy(a, { + deleteProperty: (e, i) => (delete e[i], delete t[i], !0), + get: (t, e, i) => + qe(t, e, () => + (function (t, e, i) { + const { _proxy: s, _context: a, _subProxy: r, _descriptors: l } = t; + let h = s[e]; + S(h) && + l.isScriptable(e) && + (h = (function (t, e, i, s) { + const { _proxy: n, _context: o, _subProxy: a, _stack: r } = i; + if (r.has(t)) + throw new Error( + "Recursion detected: " + Array.from(r).join("->") + "->" + t + ); + r.add(t); + let l = e(o, a || s); + r.delete(t), Xe(t, l) && (l = Je(n._scopes, n, t, l)); + return l; + })(e, h, t, i)); + n(h) && + h.length && + (h = (function (t, e, i, s) { + const { + _proxy: n, + _context: a, + _subProxy: r, + _descriptors: l, + } = i; + if (void 0 !== a.index && s(t)) return e[a.index % e.length]; + if (o(e[0])) { + const i = e, + s = n._scopes.filter((t) => t !== i); + e = []; + for (const o of i) { + const i = Je(s, n, t, o); + e.push($e(i, a, r && r[t], l)); + } + } + return e; + })(e, h, t, l.isIndexable)); + Xe(e, h) && (h = $e(h, a, r && r[e], l)); + return h; + })(t, e, i) + ), + getOwnPropertyDescriptor: (e, i) => + e._descriptors.allKeys + ? Reflect.has(t, i) + ? { enumerable: !0, configurable: !0 } + : void 0 + : Reflect.getOwnPropertyDescriptor(t, i), + getPrototypeOf: () => Reflect.getPrototypeOf(t), + has: (e, i) => Reflect.has(t, i), + ownKeys: () => Reflect.ownKeys(t), + set: (e, i, s) => ((t[i] = s), delete e[i], !0), + }); + } + function Ye(t, e = { scriptable: !0, indexable: !0 }) { + const { + _scriptable: i = e.scriptable, + _indexable: s = e.indexable, + _allKeys: n = e.allKeys, + } = t; + return { + allKeys: n, + scriptable: i, + indexable: s, + isScriptable: S(i) ? i : () => i, + isIndexable: S(s) ? s : () => s, + }; + } + const Ue = (t, e) => (t ? t + w(e) : e), + Xe = (t, e) => + o(e) && + "adapters" !== t && + (null === Object.getPrototypeOf(e) || e.constructor === Object); + function qe(t, e, i) { + if (Object.prototype.hasOwnProperty.call(t, e) || "constructor" === e) + return t[e]; + const s = i(); + return (t[e] = s), s; + } + function Ke(t, e, i) { + return S(t) ? t(e, i) : t; + } + const Ge = (t, e) => (!0 === t ? e : "string" == typeof t ? M(e, t) : void 0); + function Ze(t, e, i, s, n) { + for (const o of e) { + const e = Ge(i, o); + if (e) { + t.add(e); + const o = Ke(e._fallback, i, n); + if (void 0 !== o && o !== i && o !== s) return o; + } else if (!1 === e && void 0 !== s && i !== s) return null; + } + return !1; + } + function Je(t, e, i, s) { + const a = e._rootScopes, + r = Ke(e._fallback, i, s), + l = [...t, ...a], + h = new Set(); + h.add(s); + let c = Qe(h, l, i, r || i, s); + return ( + null !== c && + (void 0 === r || r === i || ((c = Qe(h, l, r, c, s)), null !== c)) && + je(Array.from(h), [""], a, r, () => + (function (t, e, i) { + const s = t._getTarget(); + e in s || (s[e] = {}); + const a = s[e]; + if (n(a) && o(i)) return i; + return a || {}; + })(e, i, s) + ) + ); + } + function Qe(t, e, i, s, n) { + for (; i; ) i = Ze(t, e, i, s, n); + return i; + } + function ti(t, e) { + for (const i of e) { + if (!i) continue; + const e = i[t]; + if (void 0 !== e) return e; + } + } + function ei(t) { + let e = t._keys; + return ( + e || + (e = t._keys = + (function (t) { + const e = new Set(); + for (const i of t) + for (const t of Object.keys(i).filter((t) => !t.startsWith("_"))) + e.add(t); + return Array.from(e); + })(t._scopes)), + e + ); + } + function ii(t, e, i, s) { + const { iScale: n } = t, + { key: o = "r" } = this._parsing, + a = new Array(s); + let r, l, h, c; + for (r = 0, l = s; r < l; ++r) + (h = r + i), (c = e[h]), (a[r] = { r: n.parse(M(c, o), h) }); + return a; + } + const si = Number.EPSILON || 1e-14, + ni = (t, e) => e < t.length && !t[e].skip && t[e], + oi = (t) => ("x" === t ? "y" : "x"); + function ai(t, e, i, s) { + const n = t.skip ? e : t, + o = e, + a = i.skip ? e : i, + r = q(o, n), + l = q(a, o); + let h = r / (r + l), + c = l / (r + l); + (h = isNaN(h) ? 0 : h), (c = isNaN(c) ? 0 : c); + const d = s * h, + u = s * c; + return { + previous: { x: o.x - d * (a.x - n.x), y: o.y - d * (a.y - n.y) }, + next: { x: o.x + u * (a.x - n.x), y: o.y + u * (a.y - n.y) }, + }; + } + function ri(t, e = "x") { + const i = oi(e), + s = t.length, + n = Array(s).fill(0), + o = Array(s); + let a, + r, + l, + h = ni(t, 0); + for (a = 0; a < s; ++a) + if (((r = l), (l = h), (h = ni(t, a + 1)), l)) { + if (h) { + const t = h[e] - l[e]; + n[a] = 0 !== t ? (h[i] - l[i]) / t : 0; + } + o[a] = r + ? h + ? F(n[a - 1]) !== F(n[a]) + ? 0 + : (n[a - 1] + n[a]) / 2 + : n[a - 1] + : n[a]; + } + !(function (t, e, i) { + const s = t.length; + let n, + o, + a, + r, + l, + h = ni(t, 0); + for (let c = 0; c < s - 1; ++c) + (l = h), + (h = ni(t, c + 1)), + l && + h && + (V(e[c], 0, si) + ? (i[c] = i[c + 1] = 0) + : ((n = i[c] / e[c]), + (o = i[c + 1] / e[c]), + (r = Math.pow(n, 2) + Math.pow(o, 2)), + r <= 9 || + ((a = 3 / Math.sqrt(r)), + (i[c] = n * a * e[c]), + (i[c + 1] = o * a * e[c])))); + })(t, n, o), + (function (t, e, i = "x") { + const s = oi(i), + n = t.length; + let o, + a, + r, + l = ni(t, 0); + for (let h = 0; h < n; ++h) { + if (((a = r), (r = l), (l = ni(t, h + 1)), !r)) continue; + const n = r[i], + c = r[s]; + a && + ((o = (n - a[i]) / 3), + (r[`cp1${i}`] = n - o), + (r[`cp1${s}`] = c - o * e[h])), + l && + ((o = (l[i] - n) / 3), + (r[`cp2${i}`] = n + o), + (r[`cp2${s}`] = c + o * e[h])); + } + })(t, o, e); + } + function li(t, e, i) { + return Math.max(Math.min(t, i), e); + } + function hi(t, e, i, s, n) { + let o, a, r, l; + if ( + (e.spanGaps && (t = t.filter((t) => !t.skip)), + "monotone" === e.cubicInterpolationMode) + ) + ri(t, n); + else { + let i = s ? t[t.length - 1] : t[0]; + for (o = 0, a = t.length; o < a; ++o) + (r = t[o]), + (l = ai(i, r, t[Math.min(o + 1, a - (s ? 0 : 1)) % a], e.tension)), + (r.cp1x = l.previous.x), + (r.cp1y = l.previous.y), + (r.cp2x = l.next.x), + (r.cp2y = l.next.y), + (i = r); + } + e.capBezierPoints && + (function (t, e) { + let i, + s, + n, + o, + a, + r = Re(t[0], e); + for (i = 0, s = t.length; i < s; ++i) + (a = o), + (o = r), + (r = i < s - 1 && Re(t[i + 1], e)), + o && + ((n = t[i]), + a && + ((n.cp1x = li(n.cp1x, e.left, e.right)), + (n.cp1y = li(n.cp1y, e.top, e.bottom))), + r && + ((n.cp2x = li(n.cp2x, e.left, e.right)), + (n.cp2y = li(n.cp2y, e.top, e.bottom)))); + })(t, i); + } + const ci = (t) => 0 === t || 1 === t, + di = (t, e, i) => -Math.pow(2, 10 * (t -= 1)) * Math.sin(((t - e) * O) / i), + ui = (t, e, i) => Math.pow(2, -10 * t) * Math.sin(((t - e) * O) / i) + 1, + fi = { + linear: (t) => t, + easeInQuad: (t) => t * t, + easeOutQuad: (t) => -t * (t - 2), + easeInOutQuad: (t) => + (t /= 0.5) < 1 ? 0.5 * t * t : -0.5 * (--t * (t - 2) - 1), + easeInCubic: (t) => t * t * t, + easeOutCubic: (t) => (t -= 1) * t * t + 1, + easeInOutCubic: (t) => + (t /= 0.5) < 1 ? 0.5 * t * t * t : 0.5 * ((t -= 2) * t * t + 2), + easeInQuart: (t) => t * t * t * t, + easeOutQuart: (t) => -((t -= 1) * t * t * t - 1), + easeInOutQuart: (t) => + (t /= 0.5) < 1 + ? 0.5 * t * t * t * t + : -0.5 * ((t -= 2) * t * t * t - 2), + easeInQuint: (t) => t * t * t * t * t, + easeOutQuint: (t) => (t -= 1) * t * t * t * t + 1, + easeInOutQuint: (t) => + (t /= 0.5) < 1 + ? 0.5 * t * t * t * t * t + : 0.5 * ((t -= 2) * t * t * t * t + 2), + easeInSine: (t) => 1 - Math.cos(t * E), + easeOutSine: (t) => Math.sin(t * E), + easeInOutSine: (t) => -0.5 * (Math.cos(C * t) - 1), + easeInExpo: (t) => (0 === t ? 0 : Math.pow(2, 10 * (t - 1))), + easeOutExpo: (t) => (1 === t ? 1 : 1 - Math.pow(2, -10 * t)), + easeInOutExpo: (t) => + ci(t) + ? t + : t < 0.5 + ? 0.5 * Math.pow(2, 10 * (2 * t - 1)) + : 0.5 * (2 - Math.pow(2, -10 * (2 * t - 1))), + easeInCirc: (t) => (t >= 1 ? t : -(Math.sqrt(1 - t * t) - 1)), + easeOutCirc: (t) => Math.sqrt(1 - (t -= 1) * t), + easeInOutCirc: (t) => + (t /= 0.5) < 1 + ? -0.5 * (Math.sqrt(1 - t * t) - 1) + : 0.5 * (Math.sqrt(1 - (t -= 2) * t) + 1), + easeInElastic: (t) => (ci(t) ? t : di(t, 0.075, 0.3)), + easeOutElastic: (t) => (ci(t) ? t : ui(t, 0.075, 0.3)), + easeInOutElastic(t) { + const e = 0.1125; + return ci(t) + ? t + : t < 0.5 + ? 0.5 * di(2 * t, e, 0.45) + : 0.5 + 0.5 * ui(2 * t - 1, e, 0.45); + }, + easeInBack(t) { + const e = 1.70158; + return t * t * ((e + 1) * t - e); + }, + easeOutBack(t) { + const e = 1.70158; + return (t -= 1) * t * ((e + 1) * t + e) + 1; + }, + easeInOutBack(t) { + let e = 1.70158; + return (t /= 0.5) < 1 + ? t * t * ((1 + (e *= 1.525)) * t - e) * 0.5 + : 0.5 * ((t -= 2) * t * ((1 + (e *= 1.525)) * t + e) + 2); + }, + easeInBounce: (t) => 1 - fi.easeOutBounce(1 - t), + easeOutBounce(t) { + const e = 7.5625, + i = 2.75; + return t < 1 / i + ? e * t * t + : t < 2 / i + ? e * (t -= 1.5 / i) * t + 0.75 + : t < 2.5 / i + ? e * (t -= 2.25 / i) * t + 0.9375 + : e * (t -= 2.625 / i) * t + 0.984375; + }, + easeInOutBounce: (t) => + t < 0.5 + ? 0.5 * fi.easeInBounce(2 * t) + : 0.5 * fi.easeOutBounce(2 * t - 1) + 0.5, + }; + function gi(t, e, i, s) { + return { x: t.x + i * (e.x - t.x), y: t.y + i * (e.y - t.y) }; + } + function pi(t, e, i, s) { + return { + x: t.x + i * (e.x - t.x), + y: + "middle" === s + ? i < 0.5 + ? t.y + : e.y + : "after" === s + ? i < 1 + ? t.y + : e.y + : i > 0 + ? e.y + : t.y, + }; + } + function mi(t, e, i, s) { + const n = { x: t.cp2x, y: t.cp2y }, + o = { x: e.cp1x, y: e.cp1y }, + a = gi(t, n, i), + r = gi(n, o, i), + l = gi(o, e, i), + h = gi(a, r, i), + c = gi(r, l, i); + return gi(h, c, i); + } + const xi = /^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/, + bi = + /^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/; + function _i(t, e) { + const i = ("" + t).match(xi); + if (!i || "normal" === i[1]) return 1.2 * e; + switch (((t = +i[2]), i[3])) { + case "px": + return t; + case "%": + t /= 100; + } + return e * t; + } + const yi = (t) => +t || 0; + function vi(t, e) { + const i = {}, + s = o(e), + n = s ? Object.keys(e) : e, + a = o(t) ? (s ? (i) => l(t[i], t[e[i]]) : (e) => t[e]) : () => t; + for (const t of n) i[t] = yi(a(t)); + return i; + } + function Mi(t) { + return vi(t, { top: "y", right: "x", bottom: "y", left: "x" }); + } + function wi(t) { + return vi(t, ["topLeft", "topRight", "bottomLeft", "bottomRight"]); + } + function ki(t) { + const e = Mi(t); + return (e.width = e.left + e.right), (e.height = e.top + e.bottom), e; + } + function Si(t, e) { + (t = t || {}), (e = e || ue.font); + let i = l(t.size, e.size); + "string" == typeof i && (i = parseInt(i, 10)); + let s = l(t.style, e.style); + s && + !("" + s).match(bi) && + (console.warn('Invalid font style specified: "' + s + '"'), (s = void 0)); + const n = { + family: l(t.family, e.family), + lineHeight: _i(l(t.lineHeight, e.lineHeight), i), + size: i, + style: s, + weight: l(t.weight, e.weight), + string: "", + }; + return (n.string = De(n)), n; + } + function Pi(t, e, i, s) { + let o, + a, + r, + l = !0; + for (o = 0, a = t.length; o < a; ++o) + if ( + ((r = t[o]), + void 0 !== r && + (void 0 !== e && "function" == typeof r && ((r = r(e)), (l = !1)), + void 0 !== i && n(r) && ((r = r[i % r.length]), (l = !1)), + void 0 !== r)) + ) + return s && !l && (s.cacheable = !1), r; + } + function Di(t, e, i) { + const { min: s, max: n } = t, + o = c(e, (n - s) / 2), + a = (t, e) => (i && 0 === t ? 0 : t + e); + return { min: a(s, -Math.abs(o)), max: a(n, o) }; + } + function Ci(t, e) { + return Object.assign(Object.create(t), e); + } + function Oi(t, e, i) { + return t + ? (function (t, e) { + return { + x: (i) => t + t + e - i, + setWidth(t) { + e = t; + }, + textAlign: (t) => + "center" === t ? t : "right" === t ? "left" : "right", + xPlus: (t, e) => t - e, + leftForLtr: (t, e) => t - e, + }; + })(e, i) + : { + x: (t) => t, + setWidth(t) {}, + textAlign: (t) => t, + xPlus: (t, e) => t + e, + leftForLtr: (t, e) => t, + }; + } + function Ai(t, e) { + let i, s; + ("ltr" !== e && "rtl" !== e) || + ((i = t.canvas.style), + (s = [ + i.getPropertyValue("direction"), + i.getPropertyPriority("direction"), + ]), + i.setProperty("direction", e, "important"), + (t.prevTextDirection = s)); + } + function Ti(t, e) { + void 0 !== e && + (delete t.prevTextDirection, + t.canvas.style.setProperty("direction", e[0], e[1])); + } + function Li(t) { + return "angle" === t + ? { between: Z, compare: K, normalize: G } + : { between: tt, compare: (t, e) => t - e, normalize: (t) => t }; + } + function Ei({ start: t, end: e, count: i, loop: s, style: n }) { + return { + start: t % i, + end: e % i, + loop: s && (e - t + 1) % i == 0, + style: n, + }; + } + function Ri(t, e, i) { + if (!i) return [t]; + const { property: s, start: n, end: o } = i, + a = e.length, + { compare: r, between: l, normalize: h } = Li(s), + { + start: c, + end: d, + loop: u, + style: f, + } = (function (t, e, i) { + const { property: s, start: n, end: o } = i, + { between: a, normalize: r } = Li(s), + l = e.length; + let h, + c, + { start: d, end: u, loop: f } = t; + if (f) { + for ( + d += l, u += l, h = 0, c = l; + h < c && a(r(e[d % l][s]), n, o); + ++h + ) + d--, u--; + (d %= l), (u %= l); + } + return u < d && (u += l), { start: d, end: u, loop: f, style: t.style }; + })(t, e, i), + g = []; + let p, + m, + x, + b = !1, + _ = null; + const y = () => b || (l(n, x, p) && 0 !== r(n, x)), + v = () => !b || 0 === r(o, p) || l(o, x, p); + for (let t = c, i = c; t <= d; ++t) + (m = e[t % a]), + m.skip || + ((p = h(m[s])), + p !== x && + ((b = l(p, n, o)), + null === _ && y() && (_ = 0 === r(p, n) ? t : i), + null !== _ && + v() && + (g.push(Ei({ start: _, end: t, loop: u, count: a, style: f })), + (_ = null)), + (i = t), + (x = p))); + return ( + null !== _ && + g.push(Ei({ start: _, end: d, loop: u, count: a, style: f })), + g + ); + } + function Ii(t, e) { + const i = [], + s = t.segments; + for (let n = 0; n < s.length; n++) { + const o = Ri(s[n], t.points, e); + o.length && i.push(...o); + } + return i; + } + function zi(t, e) { + const i = t.points, + s = t.options.spanGaps, + n = i.length; + if (!n) return []; + const o = !!t._loop, + { start: a, end: r } = (function (t, e, i, s) { + let n = 0, + o = e - 1; + if (i && !s) for (; n < e && !t[n].skip; ) n++; + for (; n < e && t[n].skip; ) n++; + for (n %= e, i && (o += n); o > n && t[o % e].skip; ) o--; + return (o %= e), { start: n, end: o }; + })(i, n, o, s); + if (!0 === s) return Fi(t, [{ start: a, end: r, loop: o }], i, e); + return Fi( + t, + (function (t, e, i, s) { + const n = t.length, + o = []; + let a, + r = e, + l = t[e]; + for (a = e + 1; a <= i; ++a) { + const i = t[a % n]; + i.skip || i.stop + ? l.skip || + ((s = !1), + o.push({ start: e % n, end: (a - 1) % n, loop: s }), + (e = r = i.stop ? a : null)) + : ((r = a), l.skip && (e = a)), + (l = i); + } + return null !== r && o.push({ start: e % n, end: r % n, loop: s }), o; + })(i, a, r < a ? r + n : r, !!t._fullLoop && 0 === a && r === n - 1), + i, + e + ); + } + function Fi(t, e, i, s) { + return s && s.setContext && i + ? (function (t, e, i, s) { + const n = t._chart.getContext(), + o = Vi(t.options), + { + _datasetIndex: a, + options: { spanGaps: r }, + } = t, + l = i.length, + h = []; + let c = o, + d = e[0].start, + u = d; + function f(t, e, s, n) { + const o = r ? -1 : 1; + if (t !== e) { + for (t += l; i[t % l].skip; ) t -= o; + for (; i[e % l].skip; ) e += o; + t % l != e % l && + (h.push({ start: t % l, end: e % l, loop: s, style: n }), + (c = n), + (d = e % l)); + } + } + for (const t of e) { + d = r ? d : t.start; + let e, + o = i[d % l]; + for (u = d + 1; u <= t.end; u++) { + const r = i[u % l]; + (e = Vi( + s.setContext( + Ci(n, { + type: "segment", + p0: o, + p1: r, + p0DataIndex: (u - 1) % l, + p1DataIndex: u % l, + datasetIndex: a, + }) + ) + )), + Bi(e, c) && f(d, u - 1, t.loop, c), + (o = r), + (c = e); + } + d < u - 1 && f(d, u - 1, t.loop, c); + } + return h; + })(t, e, i, s) + : e; + } + function Vi(t) { + return { + backgroundColor: t.backgroundColor, + borderCapStyle: t.borderCapStyle, + borderDash: t.borderDash, + borderDashOffset: t.borderDashOffset, + borderJoinStyle: t.borderJoinStyle, + borderWidth: t.borderWidth, + borderColor: t.borderColor, + }; + } + function Bi(t, e) { + if (!e) return !1; + const i = [], + s = function (t, e) { + return Jt(e) ? (i.includes(e) || i.push(e), i.indexOf(e)) : e; + }; + return JSON.stringify(t, s) !== JSON.stringify(e, s); + } + var Wi = Object.freeze({ + __proto__: null, + HALF_PI: E, + INFINITY: T, + PI: C, + PITAU: A, + QUARTER_PI: R, + RAD_PER_DEG: L, + TAU: O, + TWO_THIRDS_PI: I, + _addGrace: Di, + _alignPixel: Ae, + _alignStartEnd: ft, + _angleBetween: Z, + _angleDiff: K, + _arrayUnique: lt, + _attachContext: $e, + _bezierCurveTo: Ve, + _bezierInterpolation: mi, + _boundSegment: Ri, + _boundSegments: Ii, + _capitalize: w, + _computeSegments: zi, + _createResolver: je, + _decimalPlaces: U, + _deprecated: function (t, e, i, s) { + void 0 !== e && + console.warn( + t + ': "' + i + '" is deprecated. Please use "' + s + '" instead' + ); + }, + _descriptors: Ye, + _elementsEqual: f, + _factorize: W, + _filterBetween: nt, + _getParentNode: ge, + _getStartAndCountOfVisiblePoints: pt, + _int16Range: Q, + _isBetween: tt, + _isClickEvent: D, + _isDomSupported: fe, + _isPointInArea: Re, + _limitValue: J, + _longestText: Oe, + _lookup: et, + _lookupByKey: it, + _measureText: Ce, + _merger: m, + _mergerIf: _, + _normalizeAngle: G, + _parseObjectDataRadialScale: ii, + _pointInLine: gi, + _readValueToProps: vi, + _rlookupByKey: st, + _scaleRangesChanged: mt, + _setMinAndMaxByKey: j, + _splitKey: v, + _steppedInterpolation: pi, + _steppedLineTo: Fe, + _textX: gt, + _toLeftRightCenter: ut, + _updateBezierControlPoints: hi, + addRoundedRectPath: He, + almostEquals: V, + almostWhole: H, + callback: d, + clearCanvas: Te, + clipArea: Ie, + clone: g, + color: Qt, + createContext: Ci, + debounce: dt, + defined: k, + distanceBetweenPoints: q, + drawPoint: Le, + drawPointLegend: Ee, + each: u, + easingEffects: fi, + finiteOrDefault: r, + fontString: function (t, e, i) { + return e + " " + t + "px " + i; + }, + formatNumber: ne, + getAngleFromPoint: X, + getHoverColor: te, + getMaximumSize: we, + getRelativePosition: ve, + getRtlAdapter: Oi, + getStyle: xe, + isArray: n, + isFinite: a, + isFunction: S, + isNullOrUndef: s, + isNumber: N, + isObject: o, + isPatternOrGradient: Jt, + listenArrayEvents: at, + log10: z, + merge: x, + mergeIf: b, + niceNum: B, + noop: e, + overrideTextDirection: Ai, + readUsedSize: Pe, + renderText: Ne, + requestAnimFrame: ht, + resolve: Pi, + resolveObjectKey: M, + restoreTextDirection: Ti, + retinaScale: ke, + setsEqual: P, + sign: F, + splineCurve: ai, + splineCurveMonotone: ri, + supportsEventListenerOptions: Se, + throttled: ct, + toDegrees: Y, + toDimension: c, + toFont: Si, + toFontString: De, + toLineHeight: _i, + toPadding: ki, + toPercentage: h, + toRadians: $, + toTRBL: Mi, + toTRBLCorners: wi, + uid: i, + unclipArea: ze, + unlistenArrayEvents: rt, + valueOrDefault: l, + }); + function Ni(t, e, i, n) { + const { controller: o, data: a, _sorted: r } = t, + l = o._cachedMeta.iScale, + h = t.dataset && t.dataset.options ? t.dataset.options.spanGaps : null; + if (l && e === l.axis && "r" !== e && r && a.length) { + const r = l._reversePixels ? st : it; + if (!n) { + const n = r(a, e, i); + if (h) { + const { vScale: e } = o._cachedMeta, + { _parsed: i } = t, + a = i + .slice(0, n.lo + 1) + .reverse() + .findIndex((t) => !s(t[e.axis])); + n.lo -= Math.max(0, a); + const r = i.slice(n.hi).findIndex((t) => !s(t[e.axis])); + n.hi += Math.max(0, r); + } + return n; + } + if (o._sharedOptions) { + const t = a[0], + s = "function" == typeof t.getRange && t.getRange(e); + if (s) { + const t = r(a, e, i - s), + n = r(a, e, i + s); + return { lo: t.lo, hi: n.hi }; + } + } + } + return { lo: 0, hi: a.length - 1 }; + } + function Hi(t, e, i, s, n) { + const o = t.getSortedVisibleDatasetMetas(), + a = i[e]; + for (let t = 0, i = o.length; t < i; ++t) { + const { index: i, data: r } = o[t], + { lo: l, hi: h } = Ni(o[t], e, a, n); + for (let t = l; t <= h; ++t) { + const e = r[t]; + e.skip || s(e, i, t); + } + } + } + function ji(t, e, i, s, n) { + const o = []; + if (!n && !t.isPointInArea(e)) return o; + return ( + Hi( + t, + i, + e, + function (i, a, r) { + (n || Re(i, t.chartArea, 0)) && + i.inRange(e.x, e.y, s) && + o.push({ element: i, datasetIndex: a, index: r }); + }, + !0 + ), + o + ); + } + function $i(t, e, i, s, n, o) { + let a = []; + const r = (function (t) { + const e = -1 !== t.indexOf("x"), + i = -1 !== t.indexOf("y"); + return function (t, s) { + const n = e ? Math.abs(t.x - s.x) : 0, + o = i ? Math.abs(t.y - s.y) : 0; + return Math.sqrt(Math.pow(n, 2) + Math.pow(o, 2)); + }; + })(i); + let l = Number.POSITIVE_INFINITY; + return ( + Hi(t, i, e, function (i, h, c) { + const d = i.inRange(e.x, e.y, n); + if (s && !d) return; + const u = i.getCenterPoint(n); + if (!(!!o || t.isPointInArea(u)) && !d) return; + const f = r(e, u); + f < l + ? ((a = [{ element: i, datasetIndex: h, index: c }]), (l = f)) + : f === l && a.push({ element: i, datasetIndex: h, index: c }); + }), + a + ); + } + function Yi(t, e, i, s, n, o) { + return o || t.isPointInArea(e) + ? "r" !== i || s + ? $i(t, e, i, s, n, o) + : (function (t, e, i, s) { + let n = []; + return ( + Hi(t, i, e, function (t, i, o) { + const { startAngle: a, endAngle: r } = t.getProps( + ["startAngle", "endAngle"], + s + ), + { angle: l } = X(t, { x: e.x, y: e.y }); + Z(l, a, r) && n.push({ element: t, datasetIndex: i, index: o }); + }), + n + ); + })(t, e, i, n) + : []; + } + function Ui(t, e, i, s, n) { + const o = [], + a = "x" === i ? "inXRange" : "inYRange"; + let r = !1; + return ( + Hi(t, i, e, (t, s, l) => { + t[a] && + t[a](e[i], n) && + (o.push({ element: t, datasetIndex: s, index: l }), + (r = r || t.inRange(e.x, e.y, n))); + }), + s && !r ? [] : o + ); + } + var Xi = { + evaluateInteractionItems: Hi, + modes: { + index(t, e, i, s) { + const n = ve(e, t), + o = i.axis || "x", + a = i.includeInvisible || !1, + r = i.intersect ? ji(t, n, o, s, a) : Yi(t, n, o, !1, s, a), + l = []; + return r.length + ? (t.getSortedVisibleDatasetMetas().forEach((t) => { + const e = r[0].index, + i = t.data[e]; + i && + !i.skip && + l.push({ element: i, datasetIndex: t.index, index: e }); + }), + l) + : []; + }, + dataset(t, e, i, s) { + const n = ve(e, t), + o = i.axis || "xy", + a = i.includeInvisible || !1; + let r = i.intersect ? ji(t, n, o, s, a) : Yi(t, n, o, !1, s, a); + if (r.length > 0) { + const e = r[0].datasetIndex, + i = t.getDatasetMeta(e).data; + r = []; + for (let t = 0; t < i.length; ++t) + r.push({ element: i[t], datasetIndex: e, index: t }); + } + return r; + }, + point: (t, e, i, s) => + ji(t, ve(e, t), i.axis || "xy", s, i.includeInvisible || !1), + nearest(t, e, i, s) { + const n = ve(e, t), + o = i.axis || "xy", + a = i.includeInvisible || !1; + return Yi(t, n, o, i.intersect, s, a); + }, + x: (t, e, i, s) => Ui(t, ve(e, t), "x", i.intersect, s), + y: (t, e, i, s) => Ui(t, ve(e, t), "y", i.intersect, s), + }, + }; + const qi = ["left", "top", "right", "bottom"]; + function Ki(t, e) { + return t.filter((t) => t.pos === e); + } + function Gi(t, e) { + return t.filter((t) => -1 === qi.indexOf(t.pos) && t.box.axis === e); + } + function Zi(t, e) { + return t.sort((t, i) => { + const s = e ? i : t, + n = e ? t : i; + return s.weight === n.weight ? s.index - n.index : s.weight - n.weight; + }); + } + function Ji(t, e) { + const i = (function (t) { + const e = {}; + for (const i of t) { + const { stack: t, pos: s, stackWeight: n } = i; + if (!t || !qi.includes(s)) continue; + const o = + e[t] || (e[t] = { count: 0, placed: 0, weight: 0, size: 0 }); + o.count++, (o.weight += n); + } + return e; + })(t), + { vBoxMaxWidth: s, hBoxMaxHeight: n } = e; + let o, a, r; + for (o = 0, a = t.length; o < a; ++o) { + r = t[o]; + const { fullSize: a } = r.box, + l = i[r.stack], + h = l && r.stackWeight / l.weight; + r.horizontal + ? ((r.width = h ? h * s : a && e.availableWidth), (r.height = n)) + : ((r.width = s), (r.height = h ? h * n : a && e.availableHeight)); + } + return i; + } + function Qi(t, e, i, s) { + return Math.max(t[i], e[i]) + Math.max(t[s], e[s]); + } + function ts(t, e) { + (t.top = Math.max(t.top, e.top)), + (t.left = Math.max(t.left, e.left)), + (t.bottom = Math.max(t.bottom, e.bottom)), + (t.right = Math.max(t.right, e.right)); + } + function es(t, e, i, s) { + const { pos: n, box: a } = i, + r = t.maxPadding; + if (!o(n)) { + i.size && (t[n] -= i.size); + const e = s[i.stack] || { size: 0, count: 1 }; + (e.size = Math.max(e.size, i.horizontal ? a.height : a.width)), + (i.size = e.size / e.count), + (t[n] += i.size); + } + a.getPadding && ts(r, a.getPadding()); + const l = Math.max(0, e.outerWidth - Qi(r, t, "left", "right")), + h = Math.max(0, e.outerHeight - Qi(r, t, "top", "bottom")), + c = l !== t.w, + d = h !== t.h; + return ( + (t.w = l), + (t.h = h), + i.horizontal ? { same: c, other: d } : { same: d, other: c } + ); + } + function is(t, e) { + const i = e.maxPadding; + function s(t) { + const s = { left: 0, top: 0, right: 0, bottom: 0 }; + return ( + t.forEach((t) => { + s[t] = Math.max(e[t], i[t]); + }), + s + ); + } + return s(t ? ["left", "right"] : ["top", "bottom"]); + } + function ss(t, e, i, s) { + const n = []; + let o, a, r, l, h, c; + for (o = 0, a = t.length, h = 0; o < a; ++o) { + (r = t[o]), + (l = r.box), + l.update(r.width || e.w, r.height || e.h, is(r.horizontal, e)); + const { same: a, other: d } = es(e, i, r, s); + (h |= a && n.length), (c = c || d), l.fullSize || n.push(r); + } + return (h && ss(n, e, i, s)) || c; + } + function ns(t, e, i, s, n) { + (t.top = i), + (t.left = e), + (t.right = e + s), + (t.bottom = i + n), + (t.width = s), + (t.height = n); + } + function os(t, e, i, s) { + const n = i.padding; + let { x: o, y: a } = e; + for (const r of t) { + const t = r.box, + l = s[r.stack] || { count: 1, placed: 0, weight: 1 }, + h = r.stackWeight / l.weight || 1; + if (r.horizontal) { + const s = e.w * h, + o = l.size || t.height; + k(l.start) && (a = l.start), + t.fullSize + ? ns(t, n.left, a, i.outerWidth - n.right - n.left, o) + : ns(t, e.left + l.placed, a, s, o), + (l.start = a), + (l.placed += s), + (a = t.bottom); + } else { + const s = e.h * h, + a = l.size || t.width; + k(l.start) && (o = l.start), + t.fullSize + ? ns(t, o, n.top, a, i.outerHeight - n.bottom - n.top) + : ns(t, o, e.top + l.placed, a, s), + (l.start = o), + (l.placed += s), + (o = t.right); + } + } + (e.x = o), (e.y = a); + } + var as = { + addBox(t, e) { + t.boxes || (t.boxes = []), + (e.fullSize = e.fullSize || !1), + (e.position = e.position || "top"), + (e.weight = e.weight || 0), + (e._layers = + e._layers || + function () { + return [ + { + z: 0, + draw(t) { + e.draw(t); + }, + }, + ]; + }), + t.boxes.push(e); + }, + removeBox(t, e) { + const i = t.boxes ? t.boxes.indexOf(e) : -1; + -1 !== i && t.boxes.splice(i, 1); + }, + configure(t, e, i) { + (e.fullSize = i.fullSize), + (e.position = i.position), + (e.weight = i.weight); + }, + update(t, e, i, s) { + if (!t) return; + const n = ki(t.options.layout.padding), + o = Math.max(e - n.width, 0), + a = Math.max(i - n.height, 0), + r = (function (t) { + const e = (function (t) { + const e = []; + let i, s, n, o, a, r; + for (i = 0, s = (t || []).length; i < s; ++i) + (n = t[i]), + ({ + position: o, + options: { stack: a, stackWeight: r = 1 }, + } = n), + e.push({ + index: i, + box: n, + pos: o, + horizontal: n.isHorizontal(), + weight: n.weight, + stack: a && o + a, + stackWeight: r, + }); + return e; + })(t), + i = Zi( + e.filter((t) => t.box.fullSize), + !0 + ), + s = Zi(Ki(e, "left"), !0), + n = Zi(Ki(e, "right")), + o = Zi(Ki(e, "top"), !0), + a = Zi(Ki(e, "bottom")), + r = Gi(e, "x"), + l = Gi(e, "y"); + return { + fullSize: i, + leftAndTop: s.concat(o), + rightAndBottom: n.concat(l).concat(a).concat(r), + chartArea: Ki(e, "chartArea"), + vertical: s.concat(n).concat(l), + horizontal: o.concat(a).concat(r), + }; + })(t.boxes), + l = r.vertical, + h = r.horizontal; + u(t.boxes, (t) => { + "function" == typeof t.beforeLayout && t.beforeLayout(); + }); + const c = + l.reduce( + (t, e) => + e.box.options && !1 === e.box.options.display ? t : t + 1, + 0 + ) || 1, + d = Object.freeze({ + outerWidth: e, + outerHeight: i, + padding: n, + availableWidth: o, + availableHeight: a, + vBoxMaxWidth: o / 2 / c, + hBoxMaxHeight: a / 2, + }), + f = Object.assign({}, n); + ts(f, ki(s)); + const g = Object.assign( + { maxPadding: f, w: o, h: a, x: n.left, y: n.top }, + n + ), + p = Ji(l.concat(h), d); + ss(r.fullSize, g, d, p), + ss(l, g, d, p), + ss(h, g, d, p) && ss(l, g, d, p), + (function (t) { + const e = t.maxPadding; + function i(i) { + const s = Math.max(e[i] - t[i], 0); + return (t[i] += s), s; + } + (t.y += i("top")), (t.x += i("left")), i("right"), i("bottom"); + })(g), + os(r.leftAndTop, g, d, p), + (g.x += g.w), + (g.y += g.h), + os(r.rightAndBottom, g, d, p), + (t.chartArea = { + left: g.left, + top: g.top, + right: g.left + g.w, + bottom: g.top + g.h, + height: g.h, + width: g.w, + }), + u(r.chartArea, (e) => { + const i = e.box; + Object.assign(i, t.chartArea), + i.update(g.w, g.h, { left: 0, top: 0, right: 0, bottom: 0 }); + }); + }, + }; + class rs { + acquireContext(t, e) {} + releaseContext(t) { + return !1; + } + addEventListener(t, e, i) {} + removeEventListener(t, e, i) {} + getDevicePixelRatio() { + return 1; + } + getMaximumSize(t, e, i, s) { + return ( + (e = Math.max(0, e || t.width)), + (i = i || t.height), + { width: e, height: Math.max(0, s ? Math.floor(e / s) : i) } + ); + } + isAttached(t) { + return !0; + } + updateConfig(t) {} + } + class ls extends rs { + acquireContext(t) { + return (t && t.getContext && t.getContext("2d")) || null; + } + updateConfig(t) { + t.options.animation = !1; + } + } + const hs = "$chartjs", + cs = { + touchstart: "mousedown", + touchmove: "mousemove", + touchend: "mouseup", + pointerenter: "mouseenter", + pointerdown: "mousedown", + pointermove: "mousemove", + pointerup: "mouseup", + pointerleave: "mouseout", + pointerout: "mouseout", + }, + ds = (t) => null === t || "" === t; + const us = !!Se && { passive: !0 }; + function fs(t, e, i) { + t && t.canvas && t.canvas.removeEventListener(e, i, us); + } + function gs(t, e) { + for (const i of t) if (i === e || i.contains(e)) return !0; + } + function ps(t, e, i) { + const s = t.canvas, + n = new MutationObserver((t) => { + let e = !1; + for (const i of t) + (e = e || gs(i.addedNodes, s)), (e = e && !gs(i.removedNodes, s)); + e && i(); + }); + return n.observe(document, { childList: !0, subtree: !0 }), n; + } + function ms(t, e, i) { + const s = t.canvas, + n = new MutationObserver((t) => { + let e = !1; + for (const i of t) + (e = e || gs(i.removedNodes, s)), (e = e && !gs(i.addedNodes, s)); + e && i(); + }); + return n.observe(document, { childList: !0, subtree: !0 }), n; + } + const xs = new Map(); + let bs = 0; + function _s() { + const t = window.devicePixelRatio; + t !== bs && + ((bs = t), + xs.forEach((e, i) => { + i.currentDevicePixelRatio !== t && e(); + })); + } + function ys(t, e, i) { + const s = t.canvas, + n = s && ge(s); + if (!n) return; + const o = ct((t, e) => { + const s = n.clientWidth; + i(t, e), s < n.clientWidth && i(); + }, window), + a = new ResizeObserver((t) => { + const e = t[0], + i = e.contentRect.width, + s = e.contentRect.height; + (0 === i && 0 === s) || o(i, s); + }); + return ( + a.observe(n), + (function (t, e) { + xs.size || window.addEventListener("resize", _s), xs.set(t, e); + })(t, o), + a + ); + } + function vs(t, e, i) { + i && i.disconnect(), + "resize" === e && + (function (t) { + xs.delete(t), xs.size || window.removeEventListener("resize", _s); + })(t); + } + function Ms(t, e, i) { + const s = t.canvas, + n = ct((e) => { + null !== t.ctx && + i( + (function (t, e) { + const i = cs[t.type] || t.type, + { x: s, y: n } = ve(t, e); + return { + type: i, + chart: e, + native: t, + x: void 0 !== s ? s : null, + y: void 0 !== n ? n : null, + }; + })(e, t) + ); + }, t); + return ( + (function (t, e, i) { + t && t.addEventListener(e, i, us); + })(s, e, n), + n + ); + } + class ws extends rs { + acquireContext(t, e) { + const i = t && t.getContext && t.getContext("2d"); + return i && i.canvas === t + ? ((function (t, e) { + const i = t.style, + s = t.getAttribute("height"), + n = t.getAttribute("width"); + if ( + ((t[hs] = { + initial: { + height: s, + width: n, + style: { + display: i.display, + height: i.height, + width: i.width, + }, + }, + }), + (i.display = i.display || "block"), + (i.boxSizing = i.boxSizing || "border-box"), + ds(n)) + ) { + const e = Pe(t, "width"); + void 0 !== e && (t.width = e); + } + if (ds(s)) + if ("" === t.style.height) t.height = t.width / (e || 2); + else { + const e = Pe(t, "height"); + void 0 !== e && (t.height = e); + } + })(t, e), + i) + : null; + } + releaseContext(t) { + const e = t.canvas; + if (!e[hs]) return !1; + const i = e[hs].initial; + ["height", "width"].forEach((t) => { + const n = i[t]; + s(n) ? e.removeAttribute(t) : e.setAttribute(t, n); + }); + const n = i.style || {}; + return ( + Object.keys(n).forEach((t) => { + e.style[t] = n[t]; + }), + (e.width = e.width), + delete e[hs], + !0 + ); + } + addEventListener(t, e, i) { + this.removeEventListener(t, e); + const s = t.$proxies || (t.$proxies = {}), + n = { attach: ps, detach: ms, resize: ys }[e] || Ms; + s[e] = n(t, e, i); + } + removeEventListener(t, e) { + const i = t.$proxies || (t.$proxies = {}), + s = i[e]; + if (!s) return; + (({ attach: vs, detach: vs, resize: vs })[e] || fs)(t, e, s), + (i[e] = void 0); + } + getDevicePixelRatio() { + return window.devicePixelRatio; + } + getMaximumSize(t, e, i, s) { + return we(t, e, i, s); + } + isAttached(t) { + const e = t && ge(t); + return !(!e || !e.isConnected); + } + } + function ks(t) { + return !fe() || + ("undefined" != typeof OffscreenCanvas && t instanceof OffscreenCanvas) + ? ls + : ws; + } + var Ss = Object.freeze({ + __proto__: null, + BasePlatform: rs, + BasicPlatform: ls, + DomPlatform: ws, + _detectPlatform: ks, + }); + const Ps = "transparent", + Ds = { + boolean: (t, e, i) => (i > 0.5 ? e : t), + color(t, e, i) { + const s = Qt(t || Ps), + n = s.valid && Qt(e || Ps); + return n && n.valid ? n.mix(s, i).hexString() : e; + }, + number: (t, e, i) => t + (e - t) * i, + }; + class Cs { + constructor(t, e, i, s) { + const n = e[i]; + s = Pi([t.to, s, n, t.from]); + const o = Pi([t.from, n, s]); + (this._active = !0), + (this._fn = t.fn || Ds[t.type || typeof o]), + (this._easing = fi[t.easing] || fi.linear), + (this._start = Math.floor(Date.now() + (t.delay || 0))), + (this._duration = this._total = Math.floor(t.duration)), + (this._loop = !!t.loop), + (this._target = e), + (this._prop = i), + (this._from = o), + (this._to = s), + (this._promises = void 0); + } + active() { + return this._active; + } + update(t, e, i) { + if (this._active) { + this._notify(!1); + const s = this._target[this._prop], + n = i - this._start, + o = this._duration - n; + (this._start = i), + (this._duration = Math.floor(Math.max(o, t.duration))), + (this._total += n), + (this._loop = !!t.loop), + (this._to = Pi([t.to, e, s, t.from])), + (this._from = Pi([t.from, s, e])); + } + } + cancel() { + this._active && + (this.tick(Date.now()), (this._active = !1), this._notify(!1)); + } + tick(t) { + const e = t - this._start, + i = this._duration, + s = this._prop, + n = this._from, + o = this._loop, + a = this._to; + let r; + if (((this._active = n !== a && (o || e < i)), !this._active)) + return (this._target[s] = a), void this._notify(!0); + e < 0 + ? (this._target[s] = n) + : ((r = (e / i) % 2), + (r = o && r > 1 ? 2 - r : r), + (r = this._easing(Math.min(1, Math.max(0, r)))), + (this._target[s] = this._fn(n, a, r))); + } + wait() { + const t = this._promises || (this._promises = []); + return new Promise((e, i) => { + t.push({ res: e, rej: i }); + }); + } + _notify(t) { + const e = t ? "res" : "rej", + i = this._promises || []; + for (let t = 0; t < i.length; t++) i[t][e](); + } + } + class Os { + constructor(t, e) { + (this._chart = t), (this._properties = new Map()), this.configure(e); + } + configure(t) { + if (!o(t)) return; + const e = Object.keys(ue.animation), + i = this._properties; + Object.getOwnPropertyNames(t).forEach((s) => { + const a = t[s]; + if (!o(a)) return; + const r = {}; + for (const t of e) r[t] = a[t]; + ((n(a.properties) && a.properties) || [s]).forEach((t) => { + (t !== s && i.has(t)) || i.set(t, r); + }); + }); + } + _animateOptions(t, e) { + const i = e.options, + s = (function (t, e) { + if (!e) return; + let i = t.options; + if (!i) return void (t.options = e); + i.$shared && + (t.options = i = + Object.assign({}, i, { $shared: !1, $animations: {} })); + return i; + })(t, i); + if (!s) return []; + const n = this._createAnimations(s, i); + return ( + i.$shared && + (function (t, e) { + const i = [], + s = Object.keys(e); + for (let e = 0; e < s.length; e++) { + const n = t[s[e]]; + n && n.active() && i.push(n.wait()); + } + return Promise.all(i); + })(t.options.$animations, i).then( + () => { + t.options = i; + }, + () => {} + ), + n + ); + } + _createAnimations(t, e) { + const i = this._properties, + s = [], + n = t.$animations || (t.$animations = {}), + o = Object.keys(e), + a = Date.now(); + let r; + for (r = o.length - 1; r >= 0; --r) { + const l = o[r]; + if ("$" === l.charAt(0)) continue; + if ("options" === l) { + s.push(...this._animateOptions(t, e)); + continue; + } + const h = e[l]; + let c = n[l]; + const d = i.get(l); + if (c) { + if (d && c.active()) { + c.update(d, h, a); + continue; + } + c.cancel(); + } + d && d.duration + ? ((n[l] = c = new Cs(d, t, l, h)), s.push(c)) + : (t[l] = h); + } + return s; + } + update(t, e) { + if (0 === this._properties.size) return void Object.assign(t, e); + const i = this._createAnimations(t, e); + return i.length ? (bt.add(this._chart, i), !0) : void 0; + } + } + function As(t, e) { + const i = (t && t.options) || {}, + s = i.reverse, + n = void 0 === i.min ? e : 0, + o = void 0 === i.max ? e : 0; + return { start: s ? o : n, end: s ? n : o }; + } + function Ts(t, e) { + const i = [], + s = t._getSortedDatasetMetas(e); + let n, o; + for (n = 0, o = s.length; n < o; ++n) i.push(s[n].index); + return i; + } + function Ls(t, e, i, s = {}) { + const n = t.keys, + o = "single" === s.mode; + let r, l, h, c; + if (null === e) return; + let d = !1; + for (r = 0, l = n.length; r < l; ++r) { + if (((h = +n[r]), h === i)) { + if (((d = !0), s.all)) continue; + break; + } + (c = t.values[h]), a(c) && (o || 0 === e || F(e) === F(c)) && (e += c); + } + return d || s.all ? e : 0; + } + function Es(t, e) { + const i = t && t.options.stacked; + return i || (void 0 === i && void 0 !== e.stack); + } + function Rs(t, e, i) { + const s = t[e] || (t[e] = {}); + return s[i] || (s[i] = {}); + } + function Is(t, e, i, s) { + for (const n of e.getMatchingVisibleMetas(s).reverse()) { + const e = t[n.index]; + if ((i && e > 0) || (!i && e < 0)) return n.index; + } + return null; + } + function zs(t, e) { + const { chart: i, _cachedMeta: s } = t, + n = i._stacks || (i._stacks = {}), + { iScale: o, vScale: a, index: r } = s, + l = o.axis, + h = a.axis, + c = (function (t, e, i) { + return `${t.id}.${e.id}.${i.stack || i.type}`; + })(o, a, s), + d = e.length; + let u; + for (let t = 0; t < d; ++t) { + const i = e[t], + { [l]: o, [h]: d } = i; + (u = (i._stacks || (i._stacks = {}))[h] = Rs(n, c, o)), + (u[r] = d), + (u._top = Is(u, a, !0, s.type)), + (u._bottom = Is(u, a, !1, s.type)); + (u._visualValues || (u._visualValues = {}))[r] = d; + } + } + function Fs(t, e) { + const i = t.scales; + return Object.keys(i) + .filter((t) => i[t].axis === e) + .shift(); + } + function Vs(t, e) { + const i = t.controller.index, + s = t.vScale && t.vScale.axis; + if (s) { + e = e || t._parsed; + for (const t of e) { + const e = t._stacks; + if (!e || void 0 === e[s] || void 0 === e[s][i]) return; + delete e[s][i], + void 0 !== e[s]._visualValues && + void 0 !== e[s]._visualValues[i] && + delete e[s]._visualValues[i]; + } + } + } + const Bs = (t) => "reset" === t || "none" === t, + Ws = (t, e) => (e ? t : Object.assign({}, t)); + class Ns { + static defaults = {}; + static datasetElementType = null; + static dataElementType = null; + constructor(t, e) { + (this.chart = t), + (this._ctx = t.ctx), + (this.index = e), + (this._cachedDataOpts = {}), + (this._cachedMeta = this.getMeta()), + (this._type = this._cachedMeta.type), + (this.options = void 0), + (this._parsing = !1), + (this._data = void 0), + (this._objectData = void 0), + (this._sharedOptions = void 0), + (this._drawStart = void 0), + (this._drawCount = void 0), + (this.enableOptionSharing = !1), + (this.supportsDecimation = !1), + (this.$context = void 0), + (this._syncList = []), + (this.datasetElementType = new.target.datasetElementType), + (this.dataElementType = new.target.dataElementType), + this.initialize(); + } + initialize() { + const t = this._cachedMeta; + this.configure(), + this.linkScales(), + (t._stacked = Es(t.vScale, t)), + this.addElements(), + this.options.fill && + !this.chart.isPluginEnabled("filler") && + console.warn( + "Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options" + ); + } + updateIndex(t) { + this.index !== t && Vs(this._cachedMeta), (this.index = t); + } + linkScales() { + const t = this.chart, + e = this._cachedMeta, + i = this.getDataset(), + s = (t, e, i, s) => ("x" === t ? e : "r" === t ? s : i), + n = (e.xAxisID = l(i.xAxisID, Fs(t, "x"))), + o = (e.yAxisID = l(i.yAxisID, Fs(t, "y"))), + a = (e.rAxisID = l(i.rAxisID, Fs(t, "r"))), + r = e.indexAxis, + h = (e.iAxisID = s(r, n, o, a)), + c = (e.vAxisID = s(r, o, n, a)); + (e.xScale = this.getScaleForId(n)), + (e.yScale = this.getScaleForId(o)), + (e.rScale = this.getScaleForId(a)), + (e.iScale = this.getScaleForId(h)), + (e.vScale = this.getScaleForId(c)); + } + getDataset() { + return this.chart.data.datasets[this.index]; + } + getMeta() { + return this.chart.getDatasetMeta(this.index); + } + getScaleForId(t) { + return this.chart.scales[t]; + } + _getOtherScale(t) { + const e = this._cachedMeta; + return t === e.iScale ? e.vScale : e.iScale; + } + reset() { + this._update("reset"); + } + _destroy() { + const t = this._cachedMeta; + this._data && rt(this._data, this), t._stacked && Vs(t); + } + _dataCheck() { + const t = this.getDataset(), + e = t.data || (t.data = []), + i = this._data; + if (o(e)) { + const t = this._cachedMeta; + this._data = (function (t, e) { + const { iScale: i, vScale: s } = e, + n = "x" === i.axis ? "x" : "y", + o = "x" === s.axis ? "x" : "y", + a = Object.keys(t), + r = new Array(a.length); + let l, h, c; + for (l = 0, h = a.length; l < h; ++l) + (c = a[l]), (r[l] = { [n]: c, [o]: t[c] }); + return r; + })(e, t); + } else if (i !== e) { + if (i) { + rt(i, this); + const t = this._cachedMeta; + Vs(t), (t._parsed = []); + } + e && Object.isExtensible(e) && at(e, this), + (this._syncList = []), + (this._data = e); + } + } + addElements() { + const t = this._cachedMeta; + this._dataCheck(), + this.datasetElementType && (t.dataset = new this.datasetElementType()); + } + buildOrUpdateElements(t) { + const e = this._cachedMeta, + i = this.getDataset(); + let s = !1; + this._dataCheck(); + const n = e._stacked; + (e._stacked = Es(e.vScale, e)), + e.stack !== i.stack && ((s = !0), Vs(e), (e.stack = i.stack)), + this._resyncElements(t), + (s || n !== e._stacked) && + (zs(this, e._parsed), (e._stacked = Es(e.vScale, e))); + } + configure() { + const t = this.chart.config, + e = t.datasetScopeKeys(this._type), + i = t.getOptionScopes(this.getDataset(), e, !0); + (this.options = t.createResolver(i, this.getContext())), + (this._parsing = this.options.parsing), + (this._cachedDataOpts = {}); + } + parse(t, e) { + const { _cachedMeta: i, _data: s } = this, + { iScale: a, _stacked: r } = i, + l = a.axis; + let h, + c, + d, + u = (0 === t && e === s.length) || i._sorted, + f = t > 0 && i._parsed[t - 1]; + if (!1 === this._parsing) (i._parsed = s), (i._sorted = !0), (d = s); + else { + d = n(s[t]) + ? this.parseArrayData(i, s, t, e) + : o(s[t]) + ? this.parseObjectData(i, s, t, e) + : this.parsePrimitiveData(i, s, t, e); + const a = () => null === c[l] || (f && c[l] < f[l]); + for (h = 0; h < e; ++h) + (i._parsed[h + t] = c = d[h]), u && (a() && (u = !1), (f = c)); + i._sorted = u; + } + r && zs(this, d); + } + parsePrimitiveData(t, e, i, s) { + const { iScale: n, vScale: o } = t, + a = n.axis, + r = o.axis, + l = n.getLabels(), + h = n === o, + c = new Array(s); + let d, u, f; + for (d = 0, u = s; d < u; ++d) + (f = d + i), + (c[d] = { [a]: h || n.parse(l[f], f), [r]: o.parse(e[f], f) }); + return c; + } + parseArrayData(t, e, i, s) { + const { xScale: n, yScale: o } = t, + a = new Array(s); + let r, l, h, c; + for (r = 0, l = s; r < l; ++r) + (h = r + i), + (c = e[h]), + (a[r] = { x: n.parse(c[0], h), y: o.parse(c[1], h) }); + return a; + } + parseObjectData(t, e, i, s) { + const { xScale: n, yScale: o } = t, + { xAxisKey: a = "x", yAxisKey: r = "y" } = this._parsing, + l = new Array(s); + let h, c, d, u; + for (h = 0, c = s; h < c; ++h) + (d = h + i), + (u = e[d]), + (l[h] = { x: n.parse(M(u, a), d), y: o.parse(M(u, r), d) }); + return l; + } + getParsed(t) { + return this._cachedMeta._parsed[t]; + } + getDataElement(t) { + return this._cachedMeta.data[t]; + } + applyStack(t, e, i) { + const s = this.chart, + n = this._cachedMeta, + o = e[t.axis]; + return Ls( + { keys: Ts(s, !0), values: e._stacks[t.axis]._visualValues }, + o, + n.index, + { mode: i } + ); + } + updateRangeFromParsed(t, e, i, s) { + const n = i[e.axis]; + let o = null === n ? NaN : n; + const a = s && i._stacks[e.axis]; + s && a && ((s.values = a), (o = Ls(s, n, this._cachedMeta.index))), + (t.min = Math.min(t.min, o)), + (t.max = Math.max(t.max, o)); + } + getMinMax(t, e) { + const i = this._cachedMeta, + s = i._parsed, + n = i._sorted && t === i.iScale, + o = s.length, + r = this._getOtherScale(t), + l = ((t, e, i) => + t && !e.hidden && e._stacked && { keys: Ts(i, !0), values: null })( + e, + i, + this.chart + ), + h = { min: Number.POSITIVE_INFINITY, max: Number.NEGATIVE_INFINITY }, + { min: c, max: d } = (function (t) { + const { + min: e, + max: i, + minDefined: s, + maxDefined: n, + } = t.getUserBounds(); + return { + min: s ? e : Number.NEGATIVE_INFINITY, + max: n ? i : Number.POSITIVE_INFINITY, + }; + })(r); + let u, f; + function g() { + f = s[u]; + const e = f[r.axis]; + return !a(f[t.axis]) || c > e || d < e; + } + for ( + u = 0; + u < o && (g() || (this.updateRangeFromParsed(h, t, f, l), !n)); + ++u + ); + if (n) + for (u = o - 1; u >= 0; --u) + if (!g()) { + this.updateRangeFromParsed(h, t, f, l); + break; + } + return h; + } + getAllParsedValues(t) { + const e = this._cachedMeta._parsed, + i = []; + let s, n, o; + for (s = 0, n = e.length; s < n; ++s) + (o = e[s][t.axis]), a(o) && i.push(o); + return i; + } + getMaxOverflow() { + return !1; + } + getLabelAndValue(t) { + const e = this._cachedMeta, + i = e.iScale, + s = e.vScale, + n = this.getParsed(t); + return { + label: i ? "" + i.getLabelForValue(n[i.axis]) : "", + value: s ? "" + s.getLabelForValue(n[s.axis]) : "", + }; + } + _update(t) { + const e = this._cachedMeta; + this.update(t || "default"), + (e._clip = (function (t) { + let e, i, s, n; + return ( + o(t) + ? ((e = t.top), (i = t.right), (s = t.bottom), (n = t.left)) + : (e = i = s = n = t), + { top: e, right: i, bottom: s, left: n, disabled: !1 === t } + ); + })( + l( + this.options.clip, + (function (t, e, i) { + if (!1 === i) return !1; + const s = As(t, i), + n = As(e, i); + return { + top: n.end, + right: s.end, + bottom: n.start, + left: s.start, + }; + })(e.xScale, e.yScale, this.getMaxOverflow()) + ) + )); + } + update(t) {} + draw() { + const t = this._ctx, + e = this.chart, + i = this._cachedMeta, + s = i.data || [], + n = e.chartArea, + o = [], + a = this._drawStart || 0, + r = this._drawCount || s.length - a, + l = this.options.drawActiveElementsOnTop; + let h; + for (i.dataset && i.dataset.draw(t, n, a, r), h = a; h < a + r; ++h) { + const e = s[h]; + e.hidden || (e.active && l ? o.push(e) : e.draw(t, n)); + } + for (h = 0; h < o.length; ++h) o[h].draw(t, n); + } + getStyle(t, e) { + const i = e ? "active" : "default"; + return void 0 === t && this._cachedMeta.dataset + ? this.resolveDatasetElementOptions(i) + : this.resolveDataElementOptions(t || 0, i); + } + getContext(t, e, i) { + const s = this.getDataset(); + let n; + if (t >= 0 && t < this._cachedMeta.data.length) { + const e = this._cachedMeta.data[t]; + (n = + e.$context || + (e.$context = (function (t, e, i) { + return Ci(t, { + active: !1, + dataIndex: e, + parsed: void 0, + raw: void 0, + element: i, + index: e, + mode: "default", + type: "data", + }); + })(this.getContext(), t, e))), + (n.parsed = this.getParsed(t)), + (n.raw = s.data[t]), + (n.index = n.dataIndex = t); + } else + (n = + this.$context || + (this.$context = (function (t, e) { + return Ci(t, { + active: !1, + dataset: void 0, + datasetIndex: e, + index: e, + mode: "default", + type: "dataset", + }); + })(this.chart.getContext(), this.index))), + (n.dataset = s), + (n.index = n.datasetIndex = this.index); + return (n.active = !!e), (n.mode = i), n; + } + resolveDatasetElementOptions(t) { + return this._resolveElementOptions(this.datasetElementType.id, t); + } + resolveDataElementOptions(t, e) { + return this._resolveElementOptions(this.dataElementType.id, e, t); + } + _resolveElementOptions(t, e = "default", i) { + const s = "active" === e, + n = this._cachedDataOpts, + o = t + "-" + e, + a = n[o], + r = this.enableOptionSharing && k(i); + if (a) return Ws(a, r); + const l = this.chart.config, + h = l.datasetElementScopeKeys(this._type, t), + c = s ? [`${t}Hover`, "hover", t, ""] : [t, ""], + d = l.getOptionScopes(this.getDataset(), h), + u = Object.keys(ue.elements[t]), + f = l.resolveNamedOptions(d, u, () => this.getContext(i, s, e), c); + return ( + f.$shared && ((f.$shared = r), (n[o] = Object.freeze(Ws(f, r)))), f + ); + } + _resolveAnimations(t, e, i) { + const s = this.chart, + n = this._cachedDataOpts, + o = `animation-${e}`, + a = n[o]; + if (a) return a; + let r; + if (!1 !== s.options.animation) { + const s = this.chart.config, + n = s.datasetAnimationScopeKeys(this._type, e), + o = s.getOptionScopes(this.getDataset(), n); + r = s.createResolver(o, this.getContext(t, i, e)); + } + const l = new Os(s, r && r.animations); + return r && r._cacheable && (n[o] = Object.freeze(l)), l; + } + getSharedOptions(t) { + if (t.$shared) + return ( + this._sharedOptions || (this._sharedOptions = Object.assign({}, t)) + ); + } + includeOptions(t, e) { + return !e || Bs(t) || this.chart._animationsDisabled; + } + _getSharedOptions(t, e) { + const i = this.resolveDataElementOptions(t, e), + s = this._sharedOptions, + n = this.getSharedOptions(i), + o = this.includeOptions(e, n) || n !== s; + return ( + this.updateSharedOptions(n, e, i), + { sharedOptions: n, includeOptions: o } + ); + } + updateElement(t, e, i, s) { + Bs(s) ? Object.assign(t, i) : this._resolveAnimations(e, s).update(t, i); + } + updateSharedOptions(t, e, i) { + t && !Bs(e) && this._resolveAnimations(void 0, e).update(t, i); + } + _setStyle(t, e, i, s) { + t.active = s; + const n = this.getStyle(e, s); + this._resolveAnimations(e, i, s).update(t, { + options: (!s && this.getSharedOptions(n)) || n, + }); + } + removeHoverStyle(t, e, i) { + this._setStyle(t, i, "active", !1); + } + setHoverStyle(t, e, i) { + this._setStyle(t, i, "active", !0); + } + _removeDatasetHoverStyle() { + const t = this._cachedMeta.dataset; + t && this._setStyle(t, void 0, "active", !1); + } + _setDatasetHoverStyle() { + const t = this._cachedMeta.dataset; + t && this._setStyle(t, void 0, "active", !0); + } + _resyncElements(t) { + const e = this._data, + i = this._cachedMeta.data; + for (const [t, e, i] of this._syncList) this[t](e, i); + this._syncList = []; + const s = i.length, + n = e.length, + o = Math.min(n, s); + o && this.parse(0, o), + n > s + ? this._insertElements(s, n - s, t) + : n < s && this._removeElements(n, s - n); + } + _insertElements(t, e, i = !0) { + const s = this._cachedMeta, + n = s.data, + o = t + e; + let a; + const r = (t) => { + for (t.length += e, a = t.length - 1; a >= o; a--) t[a] = t[a - e]; + }; + for (r(n), a = t; a < o; ++a) n[a] = new this.dataElementType(); + this._parsing && r(s._parsed), + this.parse(t, e), + i && this.updateElements(n, t, e, "reset"); + } + updateElements(t, e, i, s) {} + _removeElements(t, e) { + const i = this._cachedMeta; + if (this._parsing) { + const s = i._parsed.splice(t, e); + i._stacked && Vs(i, s); + } + i.data.splice(t, e); + } + _sync(t) { + if (this._parsing) this._syncList.push(t); + else { + const [e, i, s] = t; + this[e](i, s); + } + this.chart._dataChanges.push([this.index, ...t]); + } + _onDataPush() { + const t = arguments.length; + this._sync(["_insertElements", this.getDataset().data.length - t, t]); + } + _onDataPop() { + this._sync(["_removeElements", this._cachedMeta.data.length - 1, 1]); + } + _onDataShift() { + this._sync(["_removeElements", 0, 1]); + } + _onDataSplice(t, e) { + e && this._sync(["_removeElements", t, e]); + const i = arguments.length - 2; + i && this._sync(["_insertElements", t, i]); + } + _onDataUnshift() { + this._sync(["_insertElements", 0, arguments.length]); + } + } + class Hs { + static defaults = {}; + static defaultRoutes = void 0; + x; + y; + active = !1; + options; + $animations; + tooltipPosition(t) { + const { x: e, y: i } = this.getProps(["x", "y"], t); + return { x: e, y: i }; + } + hasValue() { + return N(this.x) && N(this.y); + } + getProps(t, e) { + const i = this.$animations; + if (!e || !i) return this; + const s = {}; + return ( + t.forEach((t) => { + s[t] = i[t] && i[t].active() ? i[t]._to : this[t]; + }), + s + ); + } + } + function js(t, e) { + const i = t.options.ticks, + n = (function (t) { + const e = t.options.offset, + i = t._tickSize(), + s = t._length / i + (e ? 0 : 1), + n = t._maxLength / i; + return Math.floor(Math.min(s, n)); + })(t), + o = Math.min(i.maxTicksLimit || n, n), + a = i.major.enabled + ? (function (t) { + const e = []; + let i, s; + for (i = 0, s = t.length; i < s; i++) t[i].major && e.push(i); + return e; + })(e) + : [], + r = a.length, + l = a[0], + h = a[r - 1], + c = []; + if (r > o) + return ( + (function (t, e, i, s) { + let n, + o = 0, + a = i[0]; + for (s = Math.ceil(s), n = 0; n < t.length; n++) + n === a && (e.push(t[n]), o++, (a = i[o * s])); + })(e, c, a, r / o), + c + ); + const d = (function (t, e, i) { + const s = (function (t) { + const e = t.length; + let i, s; + if (e < 2) return !1; + for (s = t[0], i = 1; i < e; ++i) + if (t[i] - t[i - 1] !== s) return !1; + return s; + })(t), + n = e.length / i; + if (!s) return Math.max(n, 1); + const o = W(s); + for (let t = 0, e = o.length - 1; t < e; t++) { + const e = o[t]; + if (e > n) return e; + } + return Math.max(n, 1); + })(a, e, o); + if (r > 0) { + let t, i; + const n = r > 1 ? Math.round((h - l) / (r - 1)) : null; + for ($s(e, c, d, s(n) ? 0 : l - n, l), t = 0, i = r - 1; t < i; t++) + $s(e, c, d, a[t], a[t + 1]); + return $s(e, c, d, h, s(n) ? e.length : h + n), c; + } + return $s(e, c, d), c; + } + function $s(t, e, i, s, n) { + const o = l(s, 0), + a = Math.min(l(n, t.length), t.length); + let r, + h, + c, + d = 0; + for ( + i = Math.ceil(i), n && ((r = n - s), (i = r / Math.floor(r / i))), c = o; + c < 0; + + ) + d++, (c = Math.round(o + d * i)); + for (h = Math.max(o, 0); h < a; h++) + h === c && (e.push(t[h]), d++, (c = Math.round(o + d * i))); + } + const Ys = (t, e, i) => ("top" === e || "left" === e ? t[e] + i : t[e] - i), + Us = (t, e) => Math.min(e || t, t); + function Xs(t, e) { + const i = [], + s = t.length / e, + n = t.length; + let o = 0; + for (; o < n; o += s) i.push(t[Math.floor(o)]); + return i; + } + function qs(t, e, i) { + const s = t.ticks.length, + n = Math.min(e, s - 1), + o = t._startPixel, + a = t._endPixel, + r = 1e-6; + let l, + h = t.getPixelForTick(n); + if ( + !( + i && + ((l = + 1 === s + ? Math.max(h - o, a - h) + : 0 === e + ? (t.getPixelForTick(1) - h) / 2 + : (h - t.getPixelForTick(n - 1)) / 2), + (h += n < e ? l : -l), + h < o - r || h > a + r) + ) + ) + return h; + } + function Ks(t) { + return t.drawTicks ? t.tickLength : 0; + } + function Gs(t, e) { + if (!t.display) return 0; + const i = Si(t.font, e), + s = ki(t.padding); + return (n(t.text) ? t.text.length : 1) * i.lineHeight + s.height; + } + function Zs(t, e, i) { + let s = ut(t); + return ( + ((i && "right" !== e) || (!i && "right" === e)) && + (s = ((t) => ("left" === t ? "right" : "right" === t ? "left" : t))(s)), + s + ); + } + class Js extends Hs { + constructor(t) { + super(), + (this.id = t.id), + (this.type = t.type), + (this.options = void 0), + (this.ctx = t.ctx), + (this.chart = t.chart), + (this.top = void 0), + (this.bottom = void 0), + (this.left = void 0), + (this.right = void 0), + (this.width = void 0), + (this.height = void 0), + (this._margins = { left: 0, right: 0, top: 0, bottom: 0 }), + (this.maxWidth = void 0), + (this.maxHeight = void 0), + (this.paddingTop = void 0), + (this.paddingBottom = void 0), + (this.paddingLeft = void 0), + (this.paddingRight = void 0), + (this.axis = void 0), + (this.labelRotation = void 0), + (this.min = void 0), + (this.max = void 0), + (this._range = void 0), + (this.ticks = []), + (this._gridLineItems = null), + (this._labelItems = null), + (this._labelSizes = null), + (this._length = 0), + (this._maxLength = 0), + (this._longestTextCache = {}), + (this._startPixel = void 0), + (this._endPixel = void 0), + (this._reversePixels = !1), + (this._userMax = void 0), + (this._userMin = void 0), + (this._suggestedMax = void 0), + (this._suggestedMin = void 0), + (this._ticksLength = 0), + (this._borderValue = 0), + (this._cache = {}), + (this._dataLimitsCached = !1), + (this.$context = void 0); + } + init(t) { + (this.options = t.setContext(this.getContext())), + (this.axis = t.axis), + (this._userMin = this.parse(t.min)), + (this._userMax = this.parse(t.max)), + (this._suggestedMin = this.parse(t.suggestedMin)), + (this._suggestedMax = this.parse(t.suggestedMax)); + } + parse(t, e) { + return t; + } + getUserBounds() { + let { + _userMin: t, + _userMax: e, + _suggestedMin: i, + _suggestedMax: s, + } = this; + return ( + (t = r(t, Number.POSITIVE_INFINITY)), + (e = r(e, Number.NEGATIVE_INFINITY)), + (i = r(i, Number.POSITIVE_INFINITY)), + (s = r(s, Number.NEGATIVE_INFINITY)), + { min: r(t, i), max: r(e, s), minDefined: a(t), maxDefined: a(e) } + ); + } + getMinMax(t) { + let e, + { min: i, max: s, minDefined: n, maxDefined: o } = this.getUserBounds(); + if (n && o) return { min: i, max: s }; + const a = this.getMatchingVisibleMetas(); + for (let r = 0, l = a.length; r < l; ++r) + (e = a[r].controller.getMinMax(this, t)), + n || (i = Math.min(i, e.min)), + o || (s = Math.max(s, e.max)); + return ( + (i = o && i > s ? s : i), + (s = n && i > s ? i : s), + { min: r(i, r(s, i)), max: r(s, r(i, s)) } + ); + } + getPadding() { + return { + left: this.paddingLeft || 0, + top: this.paddingTop || 0, + right: this.paddingRight || 0, + bottom: this.paddingBottom || 0, + }; + } + getTicks() { + return this.ticks; + } + getLabels() { + const t = this.chart.data; + return ( + this.options.labels || + (this.isHorizontal() ? t.xLabels : t.yLabels) || + t.labels || + [] + ); + } + getLabelItems(t = this.chart.chartArea) { + return ( + this._labelItems || (this._labelItems = this._computeLabelItems(t)) + ); + } + beforeLayout() { + (this._cache = {}), (this._dataLimitsCached = !1); + } + beforeUpdate() { + d(this.options.beforeUpdate, [this]); + } + update(t, e, i) { + const { beginAtZero: s, grace: n, ticks: o } = this.options, + a = o.sampleSize; + this.beforeUpdate(), + (this.maxWidth = t), + (this.maxHeight = e), + (this._margins = i = + Object.assign({ left: 0, right: 0, top: 0, bottom: 0 }, i)), + (this.ticks = null), + (this._labelSizes = null), + (this._gridLineItems = null), + (this._labelItems = null), + this.beforeSetDimensions(), + this.setDimensions(), + this.afterSetDimensions(), + (this._maxLength = this.isHorizontal() + ? this.width + i.left + i.right + : this.height + i.top + i.bottom), + this._dataLimitsCached || + (this.beforeDataLimits(), + this.determineDataLimits(), + this.afterDataLimits(), + (this._range = Di(this, n, s)), + (this._dataLimitsCached = !0)), + this.beforeBuildTicks(), + (this.ticks = this.buildTicks() || []), + this.afterBuildTicks(); + const r = a < this.ticks.length; + this._convertTicksToLabels(r ? Xs(this.ticks, a) : this.ticks), + this.configure(), + this.beforeCalculateLabelRotation(), + this.calculateLabelRotation(), + this.afterCalculateLabelRotation(), + o.display && + (o.autoSkip || "auto" === o.source) && + ((this.ticks = js(this, this.ticks)), + (this._labelSizes = null), + this.afterAutoSkip()), + r && this._convertTicksToLabels(this.ticks), + this.beforeFit(), + this.fit(), + this.afterFit(), + this.afterUpdate(); + } + configure() { + let t, + e, + i = this.options.reverse; + this.isHorizontal() + ? ((t = this.left), (e = this.right)) + : ((t = this.top), (e = this.bottom), (i = !i)), + (this._startPixel = t), + (this._endPixel = e), + (this._reversePixels = i), + (this._length = e - t), + (this._alignToPixels = this.options.alignToPixels); + } + afterUpdate() { + d(this.options.afterUpdate, [this]); + } + beforeSetDimensions() { + d(this.options.beforeSetDimensions, [this]); + } + setDimensions() { + this.isHorizontal() + ? ((this.width = this.maxWidth), + (this.left = 0), + (this.right = this.width)) + : ((this.height = this.maxHeight), + (this.top = 0), + (this.bottom = this.height)), + (this.paddingLeft = 0), + (this.paddingTop = 0), + (this.paddingRight = 0), + (this.paddingBottom = 0); + } + afterSetDimensions() { + d(this.options.afterSetDimensions, [this]); + } + _callHooks(t) { + this.chart.notifyPlugins(t, this.getContext()), + d(this.options[t], [this]); + } + beforeDataLimits() { + this._callHooks("beforeDataLimits"); + } + determineDataLimits() {} + afterDataLimits() { + this._callHooks("afterDataLimits"); + } + beforeBuildTicks() { + this._callHooks("beforeBuildTicks"); + } + buildTicks() { + return []; + } + afterBuildTicks() { + this._callHooks("afterBuildTicks"); + } + beforeTickToLabelConversion() { + d(this.options.beforeTickToLabelConversion, [this]); + } + generateTickLabels(t) { + const e = this.options.ticks; + let i, s, n; + for (i = 0, s = t.length; i < s; i++) + (n = t[i]), (n.label = d(e.callback, [n.value, i, t], this)); + } + afterTickToLabelConversion() { + d(this.options.afterTickToLabelConversion, [this]); + } + beforeCalculateLabelRotation() { + d(this.options.beforeCalculateLabelRotation, [this]); + } + calculateLabelRotation() { + const t = this.options, + e = t.ticks, + i = Us(this.ticks.length, t.ticks.maxTicksLimit), + s = e.minRotation || 0, + n = e.maxRotation; + let o, + a, + r, + l = s; + if ( + !this._isVisible() || + !e.display || + s >= n || + i <= 1 || + !this.isHorizontal() + ) + return void (this.labelRotation = s); + const h = this._getLabelSizes(), + c = h.widest.width, + d = h.highest.height, + u = J(this.chart.width - c, 0, this.maxWidth); + (o = t.offset ? this.maxWidth / i : u / (i - 1)), + c + 6 > o && + ((o = u / (i - (t.offset ? 0.5 : 1))), + (a = + this.maxHeight - + Ks(t.grid) - + e.padding - + Gs(t.title, this.chart.options.font)), + (r = Math.sqrt(c * c + d * d)), + (l = Y( + Math.min( + Math.asin(J((h.highest.height + 6) / o, -1, 1)), + Math.asin(J(a / r, -1, 1)) - Math.asin(J(d / r, -1, 1)) + ) + )), + (l = Math.max(s, Math.min(n, l)))), + (this.labelRotation = l); + } + afterCalculateLabelRotation() { + d(this.options.afterCalculateLabelRotation, [this]); + } + afterAutoSkip() {} + beforeFit() { + d(this.options.beforeFit, [this]); + } + fit() { + const t = { width: 0, height: 0 }, + { + chart: e, + options: { ticks: i, title: s, grid: n }, + } = this, + o = this._isVisible(), + a = this.isHorizontal(); + if (o) { + const o = Gs(s, e.options.font); + if ( + (a + ? ((t.width = this.maxWidth), (t.height = Ks(n) + o)) + : ((t.height = this.maxHeight), (t.width = Ks(n) + o)), + i.display && this.ticks.length) + ) { + const { + first: e, + last: s, + widest: n, + highest: o, + } = this._getLabelSizes(), + r = 2 * i.padding, + l = $(this.labelRotation), + h = Math.cos(l), + c = Math.sin(l); + if (a) { + const e = i.mirror ? 0 : c * n.width + h * o.height; + t.height = Math.min(this.maxHeight, t.height + e + r); + } else { + const e = i.mirror ? 0 : h * n.width + c * o.height; + t.width = Math.min(this.maxWidth, t.width + e + r); + } + this._calculatePadding(e, s, c, h); + } + } + this._handleMargins(), + a + ? ((this.width = this._length = + e.width - this._margins.left - this._margins.right), + (this.height = t.height)) + : ((this.width = t.width), + (this.height = this._length = + e.height - this._margins.top - this._margins.bottom)); + } + _calculatePadding(t, e, i, s) { + const { + ticks: { align: n, padding: o }, + position: a, + } = this.options, + r = 0 !== this.labelRotation, + l = "top" !== a && "x" === this.axis; + if (this.isHorizontal()) { + const a = this.getPixelForTick(0) - this.left, + h = this.right - this.getPixelForTick(this.ticks.length - 1); + let c = 0, + d = 0; + r + ? l + ? ((c = s * t.width), (d = i * e.height)) + : ((c = i * t.height), (d = s * e.width)) + : "start" === n + ? (d = e.width) + : "end" === n + ? (c = t.width) + : "inner" !== n && ((c = t.width / 2), (d = e.width / 2)), + (this.paddingLeft = Math.max( + ((c - a + o) * this.width) / (this.width - a), + 0 + )), + (this.paddingRight = Math.max( + ((d - h + o) * this.width) / (this.width - h), + 0 + )); + } else { + let i = e.height / 2, + s = t.height / 2; + "start" === n + ? ((i = 0), (s = t.height)) + : "end" === n && ((i = e.height), (s = 0)), + (this.paddingTop = i + o), + (this.paddingBottom = s + o); + } + } + _handleMargins() { + this._margins && + ((this._margins.left = Math.max(this.paddingLeft, this._margins.left)), + (this._margins.top = Math.max(this.paddingTop, this._margins.top)), + (this._margins.right = Math.max( + this.paddingRight, + this._margins.right + )), + (this._margins.bottom = Math.max( + this.paddingBottom, + this._margins.bottom + ))); + } + afterFit() { + d(this.options.afterFit, [this]); + } + isHorizontal() { + const { axis: t, position: e } = this.options; + return "top" === e || "bottom" === e || "x" === t; + } + isFullSize() { + return this.options.fullSize; + } + _convertTicksToLabels(t) { + let e, i; + for ( + this.beforeTickToLabelConversion(), + this.generateTickLabels(t), + e = 0, + i = t.length; + e < i; + e++ + ) + s(t[e].label) && (t.splice(e, 1), i--, e--); + this.afterTickToLabelConversion(); + } + _getLabelSizes() { + let t = this._labelSizes; + if (!t) { + const e = this.options.ticks.sampleSize; + let i = this.ticks; + e < i.length && (i = Xs(i, e)), + (this._labelSizes = t = + this._computeLabelSizes( + i, + i.length, + this.options.ticks.maxTicksLimit + )); + } + return t; + } + _computeLabelSizes(t, e, i) { + const { ctx: o, _longestTextCache: a } = this, + r = [], + l = [], + h = Math.floor(e / Us(e, i)); + let c, + d, + f, + g, + p, + m, + x, + b, + _, + y, + v, + M = 0, + w = 0; + for (c = 0; c < e; c += h) { + if ( + ((g = t[c].label), + (p = this._resolveTickFontOptions(c)), + (o.font = m = p.string), + (x = a[m] = a[m] || { data: {}, gc: [] }), + (b = p.lineHeight), + (_ = y = 0), + s(g) || n(g)) + ) { + if (n(g)) + for (d = 0, f = g.length; d < f; ++d) + (v = g[d]), + s(v) || n(v) || ((_ = Ce(o, x.data, x.gc, _, v)), (y += b)); + } else (_ = Ce(o, x.data, x.gc, _, g)), (y = b); + r.push(_), l.push(y), (M = Math.max(_, M)), (w = Math.max(y, w)); + } + !(function (t, e) { + u(t, (t) => { + const i = t.gc, + s = i.length / 2; + let n; + if (s > e) { + for (n = 0; n < s; ++n) delete t.data[i[n]]; + i.splice(0, s); + } + }); + })(a, e); + const k = r.indexOf(M), + S = l.indexOf(w), + P = (t) => ({ width: r[t] || 0, height: l[t] || 0 }); + return { + first: P(0), + last: P(e - 1), + widest: P(k), + highest: P(S), + widths: r, + heights: l, + }; + } + getLabelForValue(t) { + return t; + } + getPixelForValue(t, e) { + return NaN; + } + getValueForPixel(t) {} + getPixelForTick(t) { + const e = this.ticks; + return t < 0 || t > e.length - 1 + ? null + : this.getPixelForValue(e[t].value); + } + getPixelForDecimal(t) { + this._reversePixels && (t = 1 - t); + const e = this._startPixel + t * this._length; + return Q(this._alignToPixels ? Ae(this.chart, e, 0) : e); + } + getDecimalForPixel(t) { + const e = (t - this._startPixel) / this._length; + return this._reversePixels ? 1 - e : e; + } + getBasePixel() { + return this.getPixelForValue(this.getBaseValue()); + } + getBaseValue() { + const { min: t, max: e } = this; + return t < 0 && e < 0 ? e : t > 0 && e > 0 ? t : 0; + } + getContext(t) { + const e = this.ticks || []; + if (t >= 0 && t < e.length) { + const i = e[t]; + return ( + i.$context || + (i.$context = (function (t, e, i) { + return Ci(t, { tick: i, index: e, type: "tick" }); + })(this.getContext(), t, i)) + ); + } + return ( + this.$context || + (this.$context = Ci(this.chart.getContext(), { + scale: this, + type: "scale", + })) + ); + } + _tickSize() { + const t = this.options.ticks, + e = $(this.labelRotation), + i = Math.abs(Math.cos(e)), + s = Math.abs(Math.sin(e)), + n = this._getLabelSizes(), + o = t.autoSkipPadding || 0, + a = n ? n.widest.width + o : 0, + r = n ? n.highest.height + o : 0; + return this.isHorizontal() + ? r * i > a * s + ? a / i + : r / s + : r * s < a * i + ? r / i + : a / s; + } + _isVisible() { + const t = this.options.display; + return "auto" !== t ? !!t : this.getMatchingVisibleMetas().length > 0; + } + _computeGridLineItems(t) { + const e = this.axis, + i = this.chart, + s = this.options, + { grid: n, position: a, border: r } = s, + h = n.offset, + c = this.isHorizontal(), + d = this.ticks.length + (h ? 1 : 0), + u = Ks(n), + f = [], + g = r.setContext(this.getContext()), + p = g.display ? g.width : 0, + m = p / 2, + x = function (t) { + return Ae(i, t, p); + }; + let b, _, y, v, M, w, k, S, P, D, C, O; + if ("top" === a) + (b = x(this.bottom)), + (w = this.bottom - u), + (S = b - m), + (D = x(t.top) + m), + (O = t.bottom); + else if ("bottom" === a) + (b = x(this.top)), + (D = t.top), + (O = x(t.bottom) - m), + (w = b + m), + (S = this.top + u); + else if ("left" === a) + (b = x(this.right)), + (M = this.right - u), + (k = b - m), + (P = x(t.left) + m), + (C = t.right); + else if ("right" === a) + (b = x(this.left)), + (P = t.left), + (C = x(t.right) - m), + (M = b + m), + (k = this.left + u); + else if ("x" === e) { + if ("center" === a) b = x((t.top + t.bottom) / 2 + 0.5); + else if (o(a)) { + const t = Object.keys(a)[0], + e = a[t]; + b = x(this.chart.scales[t].getPixelForValue(e)); + } + (D = t.top), (O = t.bottom), (w = b + m), (S = w + u); + } else if ("y" === e) { + if ("center" === a) b = x((t.left + t.right) / 2); + else if (o(a)) { + const t = Object.keys(a)[0], + e = a[t]; + b = x(this.chart.scales[t].getPixelForValue(e)); + } + (M = b - m), (k = M - u), (P = t.left), (C = t.right); + } + const A = l(s.ticks.maxTicksLimit, d), + T = Math.max(1, Math.ceil(d / A)); + for (_ = 0; _ < d; _ += T) { + const t = this.getContext(_), + e = n.setContext(t), + s = r.setContext(t), + o = e.lineWidth, + a = e.color, + l = s.dash || [], + d = s.dashOffset, + u = e.tickWidth, + g = e.tickColor, + p = e.tickBorderDash || [], + m = e.tickBorderDashOffset; + (y = qs(this, _, h)), + void 0 !== y && + ((v = Ae(i, y, o)), + c ? (M = k = P = C = v) : (w = S = D = O = v), + f.push({ + tx1: M, + ty1: w, + tx2: k, + ty2: S, + x1: P, + y1: D, + x2: C, + y2: O, + width: o, + color: a, + borderDash: l, + borderDashOffset: d, + tickWidth: u, + tickColor: g, + tickBorderDash: p, + tickBorderDashOffset: m, + })); + } + return (this._ticksLength = d), (this._borderValue = b), f; + } + _computeLabelItems(t) { + const e = this.axis, + i = this.options, + { position: s, ticks: a } = i, + r = this.isHorizontal(), + l = this.ticks, + { align: h, crossAlign: c, padding: d, mirror: u } = a, + f = Ks(i.grid), + g = f + d, + p = u ? -d : g, + m = -$(this.labelRotation), + x = []; + let b, + _, + y, + v, + M, + w, + k, + S, + P, + D, + C, + O, + A = "middle"; + if ("top" === s) + (w = this.bottom - p), (k = this._getXAxisLabelAlignment()); + else if ("bottom" === s) + (w = this.top + p), (k = this._getXAxisLabelAlignment()); + else if ("left" === s) { + const t = this._getYAxisLabelAlignment(f); + (k = t.textAlign), (M = t.x); + } else if ("right" === s) { + const t = this._getYAxisLabelAlignment(f); + (k = t.textAlign), (M = t.x); + } else if ("x" === e) { + if ("center" === s) w = (t.top + t.bottom) / 2 + g; + else if (o(s)) { + const t = Object.keys(s)[0], + e = s[t]; + w = this.chart.scales[t].getPixelForValue(e) + g; + } + k = this._getXAxisLabelAlignment(); + } else if ("y" === e) { + if ("center" === s) M = (t.left + t.right) / 2 - g; + else if (o(s)) { + const t = Object.keys(s)[0], + e = s[t]; + M = this.chart.scales[t].getPixelForValue(e); + } + k = this._getYAxisLabelAlignment(f).textAlign; + } + "y" === e && + ("start" === h ? (A = "top") : "end" === h && (A = "bottom")); + const T = this._getLabelSizes(); + for (b = 0, _ = l.length; b < _; ++b) { + (y = l[b]), (v = y.label); + const t = a.setContext(this.getContext(b)); + (S = this.getPixelForTick(b) + a.labelOffset), + (P = this._resolveTickFontOptions(b)), + (D = P.lineHeight), + (C = n(v) ? v.length : 1); + const e = C / 2, + i = t.color, + o = t.textStrokeColor, + h = t.textStrokeWidth; + let d, + f = k; + if ( + (r + ? ((M = S), + "inner" === k && + (f = + b === _ - 1 + ? this.options.reverse + ? "left" + : "right" + : 0 === b + ? this.options.reverse + ? "right" + : "left" + : "center"), + (O = + "top" === s + ? "near" === c || 0 !== m + ? -C * D + D / 2 + : "center" === c + ? -T.highest.height / 2 - e * D + D + : -T.highest.height + D / 2 + : "near" === c || 0 !== m + ? D / 2 + : "center" === c + ? T.highest.height / 2 - e * D + : T.highest.height - C * D), + u && (O *= -1), + 0 === m || t.showLabelBackdrop || (M += (D / 2) * Math.sin(m))) + : ((w = S), (O = ((1 - C) * D) / 2)), + t.showLabelBackdrop) + ) { + const e = ki(t.backdropPadding), + i = T.heights[b], + s = T.widths[b]; + let n = O - e.top, + o = 0 - e.left; + switch (A) { + case "middle": + n -= i / 2; + break; + case "bottom": + n -= i; + } + switch (k) { + case "center": + o -= s / 2; + break; + case "right": + o -= s; + break; + case "inner": + b === _ - 1 ? (o -= s) : b > 0 && (o -= s / 2); + } + d = { + left: o, + top: n, + width: s + e.width, + height: i + e.height, + color: t.backdropColor, + }; + } + x.push({ + label: v, + font: P, + textOffset: O, + options: { + rotation: m, + color: i, + strokeColor: o, + strokeWidth: h, + textAlign: f, + textBaseline: A, + translation: [M, w], + backdrop: d, + }, + }); + } + return x; + } + _getXAxisLabelAlignment() { + const { position: t, ticks: e } = this.options; + if (-$(this.labelRotation)) return "top" === t ? "left" : "right"; + let i = "center"; + return ( + "start" === e.align + ? (i = "left") + : "end" === e.align + ? (i = "right") + : "inner" === e.align && (i = "inner"), + i + ); + } + _getYAxisLabelAlignment(t) { + const { + position: e, + ticks: { crossAlign: i, mirror: s, padding: n }, + } = this.options, + o = t + n, + a = this._getLabelSizes().widest.width; + let r, l; + return ( + "left" === e + ? s + ? ((l = this.right + n), + "near" === i + ? (r = "left") + : "center" === i + ? ((r = "center"), (l += a / 2)) + : ((r = "right"), (l += a))) + : ((l = this.right - o), + "near" === i + ? (r = "right") + : "center" === i + ? ((r = "center"), (l -= a / 2)) + : ((r = "left"), (l = this.left))) + : "right" === e + ? s + ? ((l = this.left + n), + "near" === i + ? (r = "right") + : "center" === i + ? ((r = "center"), (l -= a / 2)) + : ((r = "left"), (l -= a))) + : ((l = this.left + o), + "near" === i + ? (r = "left") + : "center" === i + ? ((r = "center"), (l += a / 2)) + : ((r = "right"), (l = this.right))) + : (r = "right"), + { textAlign: r, x: l } + ); + } + _computeLabelArea() { + if (this.options.ticks.mirror) return; + const t = this.chart, + e = this.options.position; + return "left" === e || "right" === e + ? { top: 0, left: this.left, bottom: t.height, right: this.right } + : "top" === e || "bottom" === e + ? { top: this.top, left: 0, bottom: this.bottom, right: t.width } + : void 0; + } + drawBackground() { + const { + ctx: t, + options: { backgroundColor: e }, + left: i, + top: s, + width: n, + height: o, + } = this; + e && (t.save(), (t.fillStyle = e), t.fillRect(i, s, n, o), t.restore()); + } + getLineWidthForValue(t) { + const e = this.options.grid; + if (!this._isVisible() || !e.display) return 0; + const i = this.ticks.findIndex((e) => e.value === t); + if (i >= 0) { + return e.setContext(this.getContext(i)).lineWidth; + } + return 0; + } + drawGrid(t) { + const e = this.options.grid, + i = this.ctx, + s = + this._gridLineItems || + (this._gridLineItems = this._computeGridLineItems(t)); + let n, o; + const a = (t, e, s) => { + s.width && + s.color && + (i.save(), + (i.lineWidth = s.width), + (i.strokeStyle = s.color), + i.setLineDash(s.borderDash || []), + (i.lineDashOffset = s.borderDashOffset), + i.beginPath(), + i.moveTo(t.x, t.y), + i.lineTo(e.x, e.y), + i.stroke(), + i.restore()); + }; + if (e.display) + for (n = 0, o = s.length; n < o; ++n) { + const t = s[n]; + e.drawOnChartArea && a({ x: t.x1, y: t.y1 }, { x: t.x2, y: t.y2 }, t), + e.drawTicks && + a( + { x: t.tx1, y: t.ty1 }, + { x: t.tx2, y: t.ty2 }, + { + color: t.tickColor, + width: t.tickWidth, + borderDash: t.tickBorderDash, + borderDashOffset: t.tickBorderDashOffset, + } + ); + } + } + drawBorder() { + const { + chart: t, + ctx: e, + options: { border: i, grid: s }, + } = this, + n = i.setContext(this.getContext()), + o = i.display ? n.width : 0; + if (!o) return; + const a = s.setContext(this.getContext(0)).lineWidth, + r = this._borderValue; + let l, h, c, d; + this.isHorizontal() + ? ((l = Ae(t, this.left, o) - o / 2), + (h = Ae(t, this.right, a) + a / 2), + (c = d = r)) + : ((c = Ae(t, this.top, o) - o / 2), + (d = Ae(t, this.bottom, a) + a / 2), + (l = h = r)), + e.save(), + (e.lineWidth = n.width), + (e.strokeStyle = n.color), + e.beginPath(), + e.moveTo(l, c), + e.lineTo(h, d), + e.stroke(), + e.restore(); + } + drawLabels(t) { + if (!this.options.ticks.display) return; + const e = this.ctx, + i = this._computeLabelArea(); + i && Ie(e, i); + const s = this.getLabelItems(t); + for (const t of s) { + const i = t.options, + s = t.font; + Ne(e, t.label, 0, t.textOffset, s, i); + } + i && ze(e); + } + drawTitle() { + const { + ctx: t, + options: { position: e, title: i, reverse: s }, + } = this; + if (!i.display) return; + const a = Si(i.font), + r = ki(i.padding), + l = i.align; + let h = a.lineHeight / 2; + "bottom" === e || "center" === e || o(e) + ? ((h += r.bottom), + n(i.text) && (h += a.lineHeight * (i.text.length - 1))) + : (h += r.top); + const { + titleX: c, + titleY: d, + maxWidth: u, + rotation: f, + } = (function (t, e, i, s) { + const { top: n, left: a, bottom: r, right: l, chart: h } = t, + { chartArea: c, scales: d } = h; + let u, + f, + g, + p = 0; + const m = r - n, + x = l - a; + if (t.isHorizontal()) { + if (((f = ft(s, a, l)), o(i))) { + const t = Object.keys(i)[0], + s = i[t]; + g = d[t].getPixelForValue(s) + m - e; + } else + g = "center" === i ? (c.bottom + c.top) / 2 + m - e : Ys(t, i, e); + u = l - a; + } else { + if (o(i)) { + const t = Object.keys(i)[0], + s = i[t]; + f = d[t].getPixelForValue(s) - x + e; + } else + f = "center" === i ? (c.left + c.right) / 2 - x + e : Ys(t, i, e); + (g = ft(s, r, n)), (p = "left" === i ? -E : E); + } + return { titleX: f, titleY: g, maxWidth: u, rotation: p }; + })(this, h, e, l); + Ne(t, i.text, 0, 0, a, { + color: i.color, + maxWidth: u, + rotation: f, + textAlign: Zs(l, e, s), + textBaseline: "middle", + translation: [c, d], + }); + } + draw(t) { + this._isVisible() && + (this.drawBackground(), + this.drawGrid(t), + this.drawBorder(), + this.drawTitle(), + this.drawLabels(t)); + } + _layers() { + const t = this.options, + e = (t.ticks && t.ticks.z) || 0, + i = l(t.grid && t.grid.z, -1), + s = l(t.border && t.border.z, 0); + return this._isVisible() && this.draw === Js.prototype.draw + ? [ + { + z: i, + draw: (t) => { + this.drawBackground(), this.drawGrid(t), this.drawTitle(); + }, + }, + { + z: s, + draw: () => { + this.drawBorder(); + }, + }, + { + z: e, + draw: (t) => { + this.drawLabels(t); + }, + }, + ] + : [ + { + z: e, + draw: (t) => { + this.draw(t); + }, + }, + ]; + } + getMatchingVisibleMetas(t) { + const e = this.chart.getSortedVisibleDatasetMetas(), + i = this.axis + "AxisID", + s = []; + let n, o; + for (n = 0, o = e.length; n < o; ++n) { + const o = e[n]; + o[i] !== this.id || (t && o.type !== t) || s.push(o); + } + return s; + } + _resolveTickFontOptions(t) { + return Si(this.options.ticks.setContext(this.getContext(t)).font); + } + _maxDigits() { + const t = this._resolveTickFontOptions(0).lineHeight; + return (this.isHorizontal() ? this.width : this.height) / t; + } + } + class Qs { + constructor(t, e, i) { + (this.type = t), + (this.scope = e), + (this.override = i), + (this.items = Object.create(null)); + } + isForType(t) { + return Object.prototype.isPrototypeOf.call( + this.type.prototype, + t.prototype + ); + } + register(t) { + const e = Object.getPrototypeOf(t); + let i; + (function (t) { + return "id" in t && "defaults" in t; + })(e) && (i = this.register(e)); + const s = this.items, + n = t.id, + o = this.scope + "." + n; + if (!n) throw new Error("class does not have id: " + t); + return ( + n in s || + ((s[n] = t), + (function (t, e, i) { + const s = x(Object.create(null), [ + i ? ue.get(i) : {}, + ue.get(e), + t.defaults, + ]); + ue.set(e, s), + t.defaultRoutes && + (function (t, e) { + Object.keys(e).forEach((i) => { + const s = i.split("."), + n = s.pop(), + o = [t].concat(s).join("."), + a = e[i].split("."), + r = a.pop(), + l = a.join("."); + ue.route(o, n, l, r); + }); + })(e, t.defaultRoutes); + t.descriptors && ue.describe(e, t.descriptors); + })(t, o, i), + this.override && ue.override(t.id, t.overrides)), + o + ); + } + get(t) { + return this.items[t]; + } + unregister(t) { + const e = this.items, + i = t.id, + s = this.scope; + i in e && delete e[i], + s && i in ue[s] && (delete ue[s][i], this.override && delete re[i]); + } + } + class tn { + constructor() { + (this.controllers = new Qs(Ns, "datasets", !0)), + (this.elements = new Qs(Hs, "elements")), + (this.plugins = new Qs(Object, "plugins")), + (this.scales = new Qs(Js, "scales")), + (this._typedRegistries = [ + this.controllers, + this.scales, + this.elements, + ]); + } + add(...t) { + this._each("register", t); + } + remove(...t) { + this._each("unregister", t); + } + addControllers(...t) { + this._each("register", t, this.controllers); + } + addElements(...t) { + this._each("register", t, this.elements); + } + addPlugins(...t) { + this._each("register", t, this.plugins); + } + addScales(...t) { + this._each("register", t, this.scales); + } + getController(t) { + return this._get(t, this.controllers, "controller"); + } + getElement(t) { + return this._get(t, this.elements, "element"); + } + getPlugin(t) { + return this._get(t, this.plugins, "plugin"); + } + getScale(t) { + return this._get(t, this.scales, "scale"); + } + removeControllers(...t) { + this._each("unregister", t, this.controllers); + } + removeElements(...t) { + this._each("unregister", t, this.elements); + } + removePlugins(...t) { + this._each("unregister", t, this.plugins); + } + removeScales(...t) { + this._each("unregister", t, this.scales); + } + _each(t, e, i) { + [...e].forEach((e) => { + const s = i || this._getRegistryForType(e); + i || s.isForType(e) || (s === this.plugins && e.id) + ? this._exec(t, s, e) + : u(e, (e) => { + const s = i || this._getRegistryForType(e); + this._exec(t, s, e); + }); + }); + } + _exec(t, e, i) { + const s = w(t); + d(i["before" + s], [], i), e[t](i), d(i["after" + s], [], i); + } + _getRegistryForType(t) { + for (let e = 0; e < this._typedRegistries.length; e++) { + const i = this._typedRegistries[e]; + if (i.isForType(t)) return i; + } + return this.plugins; + } + _get(t, e, i) { + const s = e.get(t); + if (void 0 === s) + throw new Error('"' + t + '" is not a registered ' + i + "."); + return s; + } + } + var en = new tn(); + class sn { + constructor() { + this._init = []; + } + notify(t, e, i, s) { + "beforeInit" === e && + ((this._init = this._createDescriptors(t, !0)), + this._notify(this._init, t, "install")); + const n = s ? this._descriptors(t).filter(s) : this._descriptors(t), + o = this._notify(n, t, e, i); + return ( + "afterDestroy" === e && + (this._notify(n, t, "stop"), + this._notify(this._init, t, "uninstall")), + o + ); + } + _notify(t, e, i, s) { + s = s || {}; + for (const n of t) { + const t = n.plugin; + if (!1 === d(t[i], [e, s, n.options], t) && s.cancelable) return !1; + } + return !0; + } + invalidate() { + s(this._cache) || + ((this._oldCache = this._cache), (this._cache = void 0)); + } + _descriptors(t) { + if (this._cache) return this._cache; + const e = (this._cache = this._createDescriptors(t)); + return this._notifyStateChanges(t), e; + } + _createDescriptors(t, e) { + const i = t && t.config, + s = l(i.options && i.options.plugins, {}), + n = (function (t) { + const e = {}, + i = [], + s = Object.keys(en.plugins.items); + for (let t = 0; t < s.length; t++) i.push(en.getPlugin(s[t])); + const n = t.plugins || []; + for (let t = 0; t < n.length; t++) { + const s = n[t]; + -1 === i.indexOf(s) && (i.push(s), (e[s.id] = !0)); + } + return { plugins: i, localIds: e }; + })(i); + return !1 !== s || e + ? (function (t, { plugins: e, localIds: i }, s, n) { + const o = [], + a = t.getContext(); + for (const r of e) { + const e = r.id, + l = nn(s[e], n); + null !== l && + o.push({ + plugin: r, + options: on(t.config, { plugin: r, local: i[e] }, l, a), + }); + } + return o; + })(t, n, s, e) + : []; + } + _notifyStateChanges(t) { + const e = this._oldCache || [], + i = this._cache, + s = (t, e) => + t.filter((t) => !e.some((e) => t.plugin.id === e.plugin.id)); + this._notify(s(e, i), t, "stop"), this._notify(s(i, e), t, "start"); + } + } + function nn(t, e) { + return e || !1 !== t ? (!0 === t ? {} : t) : null; + } + function on(t, { plugin: e, local: i }, s, n) { + const o = t.pluginScopeKeys(e), + a = t.getOptionScopes(s, o); + return ( + i && e.defaults && a.push(e.defaults), + t.createResolver(a, n, [""], { + scriptable: !1, + indexable: !1, + allKeys: !0, + }) + ); + } + function an(t, e) { + const i = ue.datasets[t] || {}; + return ( + ((e.datasets || {})[t] || {}).indexAxis || + e.indexAxis || + i.indexAxis || + "x" + ); + } + function rn(t) { + if ("x" === t || "y" === t || "r" === t) return t; + } + function ln(t, ...e) { + if (rn(t)) return t; + for (const s of e) { + const e = + s.axis || + ("top" === (i = s.position) || "bottom" === i + ? "x" + : "left" === i || "right" === i + ? "y" + : void 0) || + (t.length > 1 && rn(t[0].toLowerCase())); + if (e) return e; + } + var i; + throw new Error( + `Cannot determine type of '${t}' axis. Please provide 'axis' or 'position' option.` + ); + } + function hn(t, e, i) { + if (i[e + "AxisID"] === t) return { axis: e }; + } + function cn(t, e) { + const i = re[t.type] || { scales: {} }, + s = e.scales || {}, + n = an(t.type, e), + a = Object.create(null); + return ( + Object.keys(s).forEach((e) => { + const r = s[e]; + if (!o(r)) + return console.error(`Invalid scale configuration for scale: ${e}`); + if (r._proxy) + return console.warn( + `Ignoring resolver passed as options for scale: ${e}` + ); + const l = ln( + e, + r, + (function (t, e) { + if (e.data && e.data.datasets) { + const i = e.data.datasets.filter( + (e) => e.xAxisID === t || e.yAxisID === t + ); + if (i.length) return hn(t, "x", i[0]) || hn(t, "y", i[0]); + } + return {}; + })(e, t), + ue.scales[r.type] + ), + h = (function (t, e) { + return t === e ? "_index_" : "_value_"; + })(l, n), + c = i.scales || {}; + a[e] = b(Object.create(null), [{ axis: l }, r, c[l], c[h]]); + }), + t.data.datasets.forEach((i) => { + const n = i.type || t.type, + o = i.indexAxis || an(n, e), + r = (re[n] || {}).scales || {}; + Object.keys(r).forEach((t) => { + const e = (function (t, e) { + let i = t; + return ( + "_index_" === t + ? (i = e) + : "_value_" === t && (i = "x" === e ? "y" : "x"), + i + ); + })(t, o), + n = i[e + "AxisID"] || e; + (a[n] = a[n] || Object.create(null)), + b(a[n], [{ axis: e }, s[n], r[t]]); + }); + }), + Object.keys(a).forEach((t) => { + const e = a[t]; + b(e, [ue.scales[e.type], ue.scale]); + }), + a + ); + } + function dn(t) { + const e = t.options || (t.options = {}); + (e.plugins = l(e.plugins, {})), (e.scales = cn(t, e)); + } + function un(t) { + return ( + ((t = t || {}).datasets = t.datasets || []), + (t.labels = t.labels || []), + t + ); + } + const fn = new Map(), + gn = new Set(); + function pn(t, e) { + let i = fn.get(t); + return i || ((i = e()), fn.set(t, i), gn.add(i)), i; + } + const mn = (t, e, i) => { + const s = M(e, i); + void 0 !== s && t.add(s); + }; + class xn { + constructor(t) { + (this._config = (function (t) { + return ((t = t || {}).data = un(t.data)), dn(t), t; + })(t)), + (this._scopeCache = new Map()), + (this._resolverCache = new Map()); + } + get platform() { + return this._config.platform; + } + get type() { + return this._config.type; + } + set type(t) { + this._config.type = t; + } + get data() { + return this._config.data; + } + set data(t) { + this._config.data = un(t); + } + get options() { + return this._config.options; + } + set options(t) { + this._config.options = t; + } + get plugins() { + return this._config.plugins; + } + update() { + const t = this._config; + this.clearCache(), dn(t); + } + clearCache() { + this._scopeCache.clear(), this._resolverCache.clear(); + } + datasetScopeKeys(t) { + return pn(t, () => [[`datasets.${t}`, ""]]); + } + datasetAnimationScopeKeys(t, e) { + return pn(`${t}.transition.${e}`, () => [ + [`datasets.${t}.transitions.${e}`, `transitions.${e}`], + [`datasets.${t}`, ""], + ]); + } + datasetElementScopeKeys(t, e) { + return pn(`${t}-${e}`, () => [ + [`datasets.${t}.elements.${e}`, `datasets.${t}`, `elements.${e}`, ""], + ]); + } + pluginScopeKeys(t) { + const e = t.id; + return pn(`${this.type}-plugin-${e}`, () => [ + [`plugins.${e}`, ...(t.additionalOptionScopes || [])], + ]); + } + _cachedScopes(t, e) { + const i = this._scopeCache; + let s = i.get(t); + return (s && !e) || ((s = new Map()), i.set(t, s)), s; + } + getOptionScopes(t, e, i) { + const { options: s, type: n } = this, + o = this._cachedScopes(t, i), + a = o.get(e); + if (a) return a; + const r = new Set(); + e.forEach((e) => { + t && (r.add(t), e.forEach((e) => mn(r, t, e))), + e.forEach((t) => mn(r, s, t)), + e.forEach((t) => mn(r, re[n] || {}, t)), + e.forEach((t) => mn(r, ue, t)), + e.forEach((t) => mn(r, le, t)); + }); + const l = Array.from(r); + return ( + 0 === l.length && l.push(Object.create(null)), + gn.has(e) && o.set(e, l), + l + ); + } + chartOptionScopes() { + const { options: t, type: e } = this; + return [t, re[e] || {}, ue.datasets[e] || {}, { type: e }, ue, le]; + } + resolveNamedOptions(t, e, i, s = [""]) { + const o = { $shared: !0 }, + { resolver: a, subPrefixes: r } = bn(this._resolverCache, t, s); + let l = a; + if ( + (function (t, e) { + const { isScriptable: i, isIndexable: s } = Ye(t); + for (const o of e) { + const e = i(o), + a = s(o), + r = (a || e) && t[o]; + if ((e && (S(r) || _n(r))) || (a && n(r))) return !0; + } + return !1; + })(a, e) + ) { + o.$shared = !1; + l = $e(a, (i = S(i) ? i() : i), this.createResolver(t, i, r)); + } + for (const t of e) o[t] = l[t]; + return o; + } + createResolver(t, e, i = [""], s) { + const { resolver: n } = bn(this._resolverCache, t, i); + return o(e) ? $e(n, e, void 0, s) : n; + } + } + function bn(t, e, i) { + let s = t.get(e); + s || ((s = new Map()), t.set(e, s)); + const n = i.join(); + let o = s.get(n); + if (!o) { + (o = { + resolver: je(e, i), + subPrefixes: i.filter((t) => !t.toLowerCase().includes("hover")), + }), + s.set(n, o); + } + return o; + } + const _n = (t) => o(t) && Object.getOwnPropertyNames(t).some((e) => S(t[e])); + const yn = ["top", "bottom", "left", "right", "chartArea"]; + function vn(t, e) { + return "top" === t || "bottom" === t || (-1 === yn.indexOf(t) && "x" === e); + } + function Mn(t, e) { + return function (i, s) { + return i[t] === s[t] ? i[e] - s[e] : i[t] - s[t]; + }; + } + function wn(t) { + const e = t.chart, + i = e.options.animation; + e.notifyPlugins("afterRender"), d(i && i.onComplete, [t], e); + } + function kn(t) { + const e = t.chart, + i = e.options.animation; + d(i && i.onProgress, [t], e); + } + function Sn(t) { + return ( + fe() && "string" == typeof t + ? (t = document.getElementById(t)) + : t && t.length && (t = t[0]), + t && t.canvas && (t = t.canvas), + t + ); + } + const Pn = {}, + Dn = (t) => { + const e = Sn(t); + return Object.values(Pn) + .filter((t) => t.canvas === e) + .pop(); + }; + function Cn(t, e, i) { + const s = Object.keys(t); + for (const n of s) { + const s = +n; + if (s >= e) { + const o = t[n]; + delete t[n], (i > 0 || s > e) && (t[s + i] = o); + } + } + } + function On(t, e, i) { + return t.options.clip ? t[i] : e[i]; + } + class An { + static defaults = ue; + static instances = Pn; + static overrides = re; + static registry = en; + static version = "4.4.8"; + static getChart = Dn; + static register(...t) { + en.add(...t), Tn(); + } + static unregister(...t) { + en.remove(...t), Tn(); + } + constructor(t, e) { + const s = (this.config = new xn(e)), + n = Sn(t), + o = Dn(n); + if (o) + throw new Error( + "Canvas is already in use. Chart with ID '" + + o.id + + "' must be destroyed before the canvas with ID '" + + o.canvas.id + + "' can be reused." + ); + const a = s.createResolver(s.chartOptionScopes(), this.getContext()); + (this.platform = new (s.platform || ks(n))()), + this.platform.updateConfig(s); + const r = this.platform.acquireContext(n, a.aspectRatio), + l = r && r.canvas, + h = l && l.height, + c = l && l.width; + (this.id = i()), + (this.ctx = r), + (this.canvas = l), + (this.width = c), + (this.height = h), + (this._options = a), + (this._aspectRatio = this.aspectRatio), + (this._layers = []), + (this._metasets = []), + (this._stacks = void 0), + (this.boxes = []), + (this.currentDevicePixelRatio = void 0), + (this.chartArea = void 0), + (this._active = []), + (this._lastEvent = void 0), + (this._listeners = {}), + (this._responsiveListeners = void 0), + (this._sortedMetasets = []), + (this.scales = {}), + (this._plugins = new sn()), + (this.$proxies = {}), + (this._hiddenIndices = {}), + (this.attached = !1), + (this._animationsDisabled = void 0), + (this.$context = void 0), + (this._doResize = dt((t) => this.update(t), a.resizeDelay || 0)), + (this._dataChanges = []), + (Pn[this.id] = this), + r && l + ? (bt.listen(this, "complete", wn), + bt.listen(this, "progress", kn), + this._initialize(), + this.attached && this.update()) + : console.error( + "Failed to create chart: can't acquire context from the given item" + ); + } + get aspectRatio() { + const { + options: { aspectRatio: t, maintainAspectRatio: e }, + width: i, + height: n, + _aspectRatio: o, + } = this; + return s(t) ? (e && o ? o : n ? i / n : null) : t; + } + get data() { + return this.config.data; + } + set data(t) { + this.config.data = t; + } + get options() { + return this._options; + } + set options(t) { + this.config.options = t; + } + get registry() { + return en; + } + _initialize() { + return ( + this.notifyPlugins("beforeInit"), + this.options.responsive + ? this.resize() + : ke(this, this.options.devicePixelRatio), + this.bindEvents(), + this.notifyPlugins("afterInit"), + this + ); + } + clear() { + return Te(this.canvas, this.ctx), this; + } + stop() { + return bt.stop(this), this; + } + resize(t, e) { + bt.running(this) + ? (this._resizeBeforeDraw = { width: t, height: e }) + : this._resize(t, e); + } + _resize(t, e) { + const i = this.options, + s = this.canvas, + n = i.maintainAspectRatio && this.aspectRatio, + o = this.platform.getMaximumSize(s, t, e, n), + a = i.devicePixelRatio || this.platform.getDevicePixelRatio(), + r = this.width ? "resize" : "attach"; + (this.width = o.width), + (this.height = o.height), + (this._aspectRatio = this.aspectRatio), + ke(this, a, !0) && + (this.notifyPlugins("resize", { size: o }), + d(i.onResize, [this, o], this), + this.attached && this._doResize(r) && this.render()); + } + ensureScalesHaveIDs() { + u(this.options.scales || {}, (t, e) => { + t.id = e; + }); + } + buildOrUpdateScales() { + const t = this.options, + e = t.scales, + i = this.scales, + s = Object.keys(i).reduce((t, e) => ((t[e] = !1), t), {}); + let n = []; + e && + (n = n.concat( + Object.keys(e).map((t) => { + const i = e[t], + s = ln(t, i), + n = "r" === s, + o = "x" === s; + return { + options: i, + dposition: n ? "chartArea" : o ? "bottom" : "left", + dtype: n ? "radialLinear" : o ? "category" : "linear", + }; + }) + )), + u(n, (e) => { + const n = e.options, + o = n.id, + a = ln(o, n), + r = l(n.type, e.dtype); + (void 0 !== n.position && vn(n.position, a) === vn(e.dposition)) || + (n.position = e.dposition), + (s[o] = !0); + let h = null; + if (o in i && i[o].type === r) h = i[o]; + else { + (h = new (en.getScale(r))({ + id: o, + type: r, + ctx: this.ctx, + chart: this, + })), + (i[h.id] = h); + } + h.init(n, t); + }), + u(s, (t, e) => { + t || delete i[e]; + }), + u(i, (t) => { + as.configure(this, t, t.options), as.addBox(this, t); + }); + } + _updateMetasets() { + const t = this._metasets, + e = this.data.datasets.length, + i = t.length; + if ((t.sort((t, e) => t.index - e.index), i > e)) { + for (let t = e; t < i; ++t) this._destroyDatasetMeta(t); + t.splice(e, i - e); + } + this._sortedMetasets = t.slice(0).sort(Mn("order", "index")); + } + _removeUnreferencedMetasets() { + const { + _metasets: t, + data: { datasets: e }, + } = this; + t.length > e.length && delete this._stacks, + t.forEach((t, i) => { + 0 === e.filter((e) => e === t._dataset).length && + this._destroyDatasetMeta(i); + }); + } + buildOrUpdateControllers() { + const t = [], + e = this.data.datasets; + let i, s; + for ( + this._removeUnreferencedMetasets(), i = 0, s = e.length; + i < s; + i++ + ) { + const s = e[i]; + let n = this.getDatasetMeta(i); + const o = s.type || this.config.type; + if ( + (n.type && + n.type !== o && + (this._destroyDatasetMeta(i), (n = this.getDatasetMeta(i))), + (n.type = o), + (n.indexAxis = s.indexAxis || an(o, this.options)), + (n.order = s.order || 0), + (n.index = i), + (n.label = "" + s.label), + (n.visible = this.isDatasetVisible(i)), + n.controller) + ) + n.controller.updateIndex(i), n.controller.linkScales(); + else { + const e = en.getController(o), + { datasetElementType: s, dataElementType: a } = ue.datasets[o]; + Object.assign(e, { + dataElementType: en.getElement(a), + datasetElementType: s && en.getElement(s), + }), + (n.controller = new e(this, i)), + t.push(n.controller); + } + } + return this._updateMetasets(), t; + } + _resetElements() { + u( + this.data.datasets, + (t, e) => { + this.getDatasetMeta(e).controller.reset(); + }, + this + ); + } + reset() { + this._resetElements(), this.notifyPlugins("reset"); + } + update(t) { + const e = this.config; + e.update(); + const i = (this._options = e.createResolver( + e.chartOptionScopes(), + this.getContext() + )), + s = (this._animationsDisabled = !i.animation); + if ( + (this._updateScales(), + this._checkEventBindings(), + this._updateHiddenIndices(), + this._plugins.invalidate(), + !1 === this.notifyPlugins("beforeUpdate", { mode: t, cancelable: !0 })) + ) + return; + const n = this.buildOrUpdateControllers(); + this.notifyPlugins("beforeElementsUpdate"); + let o = 0; + for (let t = 0, e = this.data.datasets.length; t < e; t++) { + const { controller: e } = this.getDatasetMeta(t), + i = !s && -1 === n.indexOf(e); + e.buildOrUpdateElements(i), (o = Math.max(+e.getMaxOverflow(), o)); + } + (o = this._minPadding = i.layout.autoPadding ? o : 0), + this._updateLayout(o), + s || + u(n, (t) => { + t.reset(); + }), + this._updateDatasets(t), + this.notifyPlugins("afterUpdate", { mode: t }), + this._layers.sort(Mn("z", "_idx")); + const { _active: a, _lastEvent: r } = this; + r + ? this._eventHandler(r, !0) + : a.length && this._updateHoverStyles(a, a, !0), + this.render(); + } + _updateScales() { + u(this.scales, (t) => { + as.removeBox(this, t); + }), + this.ensureScalesHaveIDs(), + this.buildOrUpdateScales(); + } + _checkEventBindings() { + const t = this.options, + e = new Set(Object.keys(this._listeners)), + i = new Set(t.events); + (P(e, i) && !!this._responsiveListeners === t.responsive) || + (this.unbindEvents(), this.bindEvents()); + } + _updateHiddenIndices() { + const { _hiddenIndices: t } = this, + e = this._getUniformDataChanges() || []; + for (const { method: i, start: s, count: n } of e) { + Cn(t, s, "_removeElements" === i ? -n : n); + } + } + _getUniformDataChanges() { + const t = this._dataChanges; + if (!t || !t.length) return; + this._dataChanges = []; + const e = this.data.datasets.length, + i = (e) => + new Set( + t + .filter((t) => t[0] === e) + .map((t, e) => e + "," + t.splice(1).join(",")) + ), + s = i(0); + for (let t = 1; t < e; t++) if (!P(s, i(t))) return; + return Array.from(s) + .map((t) => t.split(",")) + .map((t) => ({ method: t[1], start: +t[2], count: +t[3] })); + } + _updateLayout(t) { + if (!1 === this.notifyPlugins("beforeLayout", { cancelable: !0 })) return; + as.update(this, this.width, this.height, t); + const e = this.chartArea, + i = e.width <= 0 || e.height <= 0; + (this._layers = []), + u( + this.boxes, + (t) => { + (i && "chartArea" === t.position) || + (t.configure && t.configure(), this._layers.push(...t._layers())); + }, + this + ), + this._layers.forEach((t, e) => { + t._idx = e; + }), + this.notifyPlugins("afterLayout"); + } + _updateDatasets(t) { + if ( + !1 !== + this.notifyPlugins("beforeDatasetsUpdate", { mode: t, cancelable: !0 }) + ) { + for (let t = 0, e = this.data.datasets.length; t < e; ++t) + this.getDatasetMeta(t).controller.configure(); + for (let e = 0, i = this.data.datasets.length; e < i; ++e) + this._updateDataset(e, S(t) ? t({ datasetIndex: e }) : t); + this.notifyPlugins("afterDatasetsUpdate", { mode: t }); + } + } + _updateDataset(t, e) { + const i = this.getDatasetMeta(t), + s = { meta: i, index: t, mode: e, cancelable: !0 }; + !1 !== this.notifyPlugins("beforeDatasetUpdate", s) && + (i.controller._update(e), + (s.cancelable = !1), + this.notifyPlugins("afterDatasetUpdate", s)); + } + render() { + !1 !== this.notifyPlugins("beforeRender", { cancelable: !0 }) && + (bt.has(this) + ? this.attached && !bt.running(this) && bt.start(this) + : (this.draw(), wn({ chart: this }))); + } + draw() { + let t; + if (this._resizeBeforeDraw) { + const { width: t, height: e } = this._resizeBeforeDraw; + (this._resizeBeforeDraw = null), this._resize(t, e); + } + if ((this.clear(), this.width <= 0 || this.height <= 0)) return; + if (!1 === this.notifyPlugins("beforeDraw", { cancelable: !0 })) return; + const e = this._layers; + for (t = 0; t < e.length && e[t].z <= 0; ++t) e[t].draw(this.chartArea); + for (this._drawDatasets(); t < e.length; ++t) e[t].draw(this.chartArea); + this.notifyPlugins("afterDraw"); + } + _getSortedDatasetMetas(t) { + const e = this._sortedMetasets, + i = []; + let s, n; + for (s = 0, n = e.length; s < n; ++s) { + const n = e[s]; + (t && !n.visible) || i.push(n); + } + return i; + } + getSortedVisibleDatasetMetas() { + return this._getSortedDatasetMetas(!0); + } + _drawDatasets() { + if (!1 === this.notifyPlugins("beforeDatasetsDraw", { cancelable: !0 })) + return; + const t = this.getSortedVisibleDatasetMetas(); + for (let e = t.length - 1; e >= 0; --e) this._drawDataset(t[e]); + this.notifyPlugins("afterDatasetsDraw"); + } + _drawDataset(t) { + const e = this.ctx, + i = t._clip, + s = !i.disabled, + n = (function (t, e) { + const { xScale: i, yScale: s } = t; + return i && s + ? { + left: On(i, e, "left"), + right: On(i, e, "right"), + top: On(s, e, "top"), + bottom: On(s, e, "bottom"), + } + : e; + })(t, this.chartArea), + o = { meta: t, index: t.index, cancelable: !0 }; + !1 !== this.notifyPlugins("beforeDatasetDraw", o) && + (s && + Ie(e, { + left: !1 === i.left ? 0 : n.left - i.left, + right: !1 === i.right ? this.width : n.right + i.right, + top: !1 === i.top ? 0 : n.top - i.top, + bottom: !1 === i.bottom ? this.height : n.bottom + i.bottom, + }), + t.controller.draw(), + s && ze(e), + (o.cancelable = !1), + this.notifyPlugins("afterDatasetDraw", o)); + } + isPointInArea(t) { + return Re(t, this.chartArea, this._minPadding); + } + getElementsAtEventForMode(t, e, i, s) { + const n = Xi.modes[e]; + return "function" == typeof n ? n(this, t, i, s) : []; + } + getDatasetMeta(t) { + const e = this.data.datasets[t], + i = this._metasets; + let s = i.filter((t) => t && t._dataset === e).pop(); + return ( + s || + ((s = { + type: null, + data: [], + dataset: null, + controller: null, + hidden: null, + xAxisID: null, + yAxisID: null, + order: (e && e.order) || 0, + index: t, + _dataset: e, + _parsed: [], + _sorted: !1, + }), + i.push(s)), + s + ); + } + getContext() { + return ( + this.$context || + (this.$context = Ci(null, { chart: this, type: "chart" })) + ); + } + getVisibleDatasetCount() { + return this.getSortedVisibleDatasetMetas().length; + } + isDatasetVisible(t) { + const e = this.data.datasets[t]; + if (!e) return !1; + const i = this.getDatasetMeta(t); + return "boolean" == typeof i.hidden ? !i.hidden : !e.hidden; + } + setDatasetVisibility(t, e) { + this.getDatasetMeta(t).hidden = !e; + } + toggleDataVisibility(t) { + this._hiddenIndices[t] = !this._hiddenIndices[t]; + } + getDataVisibility(t) { + return !this._hiddenIndices[t]; + } + _updateVisibility(t, e, i) { + const s = i ? "show" : "hide", + n = this.getDatasetMeta(t), + o = n.controller._resolveAnimations(void 0, s); + k(e) + ? ((n.data[e].hidden = !i), this.update()) + : (this.setDatasetVisibility(t, i), + o.update(n, { visible: i }), + this.update((e) => (e.datasetIndex === t ? s : void 0))); + } + hide(t, e) { + this._updateVisibility(t, e, !1); + } + show(t, e) { + this._updateVisibility(t, e, !0); + } + _destroyDatasetMeta(t) { + const e = this._metasets[t]; + e && e.controller && e.controller._destroy(), delete this._metasets[t]; + } + _stop() { + let t, e; + for ( + this.stop(), bt.remove(this), t = 0, e = this.data.datasets.length; + t < e; + ++t + ) + this._destroyDatasetMeta(t); + } + destroy() { + this.notifyPlugins("beforeDestroy"); + const { canvas: t, ctx: e } = this; + this._stop(), + this.config.clearCache(), + t && + (this.unbindEvents(), + Te(t, e), + this.platform.releaseContext(e), + (this.canvas = null), + (this.ctx = null)), + delete Pn[this.id], + this.notifyPlugins("afterDestroy"); + } + toBase64Image(...t) { + return this.canvas.toDataURL(...t); + } + bindEvents() { + this.bindUserEvents(), + this.options.responsive + ? this.bindResponsiveEvents() + : (this.attached = !0); + } + bindUserEvents() { + const t = this._listeners, + e = this.platform, + i = (i, s) => { + e.addEventListener(this, i, s), (t[i] = s); + }, + s = (t, e, i) => { + (t.offsetX = e), (t.offsetY = i), this._eventHandler(t); + }; + u(this.options.events, (t) => i(t, s)); + } + bindResponsiveEvents() { + this._responsiveListeners || (this._responsiveListeners = {}); + const t = this._responsiveListeners, + e = this.platform, + i = (i, s) => { + e.addEventListener(this, i, s), (t[i] = s); + }, + s = (i, s) => { + t[i] && (e.removeEventListener(this, i, s), delete t[i]); + }, + n = (t, e) => { + this.canvas && this.resize(t, e); + }; + let o; + const a = () => { + s("attach", a), + (this.attached = !0), + this.resize(), + i("resize", n), + i("detach", o); + }; + (o = () => { + (this.attached = !1), + s("resize", n), + this._stop(), + this._resize(0, 0), + i("attach", a); + }), + e.isAttached(this.canvas) ? a() : o(); + } + unbindEvents() { + u(this._listeners, (t, e) => { + this.platform.removeEventListener(this, e, t); + }), + (this._listeners = {}), + u(this._responsiveListeners, (t, e) => { + this.platform.removeEventListener(this, e, t); + }), + (this._responsiveListeners = void 0); + } + updateHoverStyle(t, e, i) { + const s = i ? "set" : "remove"; + let n, o, a, r; + for ( + "dataset" === e && + ((n = this.getDatasetMeta(t[0].datasetIndex)), + n.controller["_" + s + "DatasetHoverStyle"]()), + a = 0, + r = t.length; + a < r; + ++a + ) { + o = t[a]; + const e = o && this.getDatasetMeta(o.datasetIndex).controller; + e && e[s + "HoverStyle"](o.element, o.datasetIndex, o.index); + } + } + getActiveElements() { + return this._active || []; + } + setActiveElements(t) { + const e = this._active || [], + i = t.map(({ datasetIndex: t, index: e }) => { + const i = this.getDatasetMeta(t); + if (!i) throw new Error("No dataset found at index " + t); + return { datasetIndex: t, element: i.data[e], index: e }; + }); + !f(i, e) && + ((this._active = i), + (this._lastEvent = null), + this._updateHoverStyles(i, e)); + } + notifyPlugins(t, e, i) { + return this._plugins.notify(this, t, e, i); + } + isPluginEnabled(t) { + return 1 === this._plugins._cache.filter((e) => e.plugin.id === t).length; + } + _updateHoverStyles(t, e, i) { + const s = this.options.hover, + n = (t, e) => + t.filter( + (t) => + !e.some( + (e) => t.datasetIndex === e.datasetIndex && t.index === e.index + ) + ), + o = n(e, t), + a = i ? t : n(t, e); + o.length && this.updateHoverStyle(o, s.mode, !1), + a.length && s.mode && this.updateHoverStyle(a, s.mode, !0); + } + _eventHandler(t, e) { + const i = { + event: t, + replay: e, + cancelable: !0, + inChartArea: this.isPointInArea(t), + }, + s = (e) => + (e.options.events || this.options.events).includes(t.native.type); + if (!1 === this.notifyPlugins("beforeEvent", i, s)) return; + const n = this._handleEvent(t, e, i.inChartArea); + return ( + (i.cancelable = !1), + this.notifyPlugins("afterEvent", i, s), + (n || i.changed) && this.render(), + this + ); + } + _handleEvent(t, e, i) { + const { _active: s = [], options: n } = this, + o = e, + a = this._getActiveElements(t, s, i, o), + r = D(t), + l = (function (t, e, i, s) { + return i && "mouseout" !== t.type ? (s ? e : t) : null; + })(t, this._lastEvent, i, r); + i && + ((this._lastEvent = null), + d(n.onHover, [t, a, this], this), + r && d(n.onClick, [t, a, this], this)); + const h = !f(a, s); + return ( + (h || e) && ((this._active = a), this._updateHoverStyles(a, s, e)), + (this._lastEvent = l), + h + ); + } + _getActiveElements(t, e, i, s) { + if ("mouseout" === t.type) return []; + if (!i) return e; + const n = this.options.hover; + return this.getElementsAtEventForMode(t, n.mode, n, s); + } + } + function Tn() { + return u(An.instances, (t) => t._plugins.invalidate()); + } + function Ln() { + throw new Error( + "This method is not implemented: Check that a complete date adapter is provided." + ); + } + class En { + static override(t) { + Object.assign(En.prototype, t); + } + options; + constructor(t) { + this.options = t || {}; + } + init() {} + formats() { + return Ln(); + } + parse() { + return Ln(); + } + format() { + return Ln(); + } + add() { + return Ln(); + } + diff() { + return Ln(); + } + startOf() { + return Ln(); + } + endOf() { + return Ln(); + } + } + var Rn = { _date: En }; + function In(t) { + const e = t.iScale, + i = (function (t, e) { + if (!t._cache.$bar) { + const i = t.getMatchingVisibleMetas(e); + let s = []; + for (let e = 0, n = i.length; e < n; e++) + s = s.concat(i[e].controller.getAllParsedValues(t)); + t._cache.$bar = lt(s.sort((t, e) => t - e)); + } + return t._cache.$bar; + })(e, t.type); + let s, + n, + o, + a, + r = e._length; + const l = () => { + 32767 !== o && + -32768 !== o && + (k(a) && (r = Math.min(r, Math.abs(o - a) || r)), (a = o)); + }; + for (s = 0, n = i.length; s < n; ++s) (o = e.getPixelForValue(i[s])), l(); + for (a = void 0, s = 0, n = e.ticks.length; s < n; ++s) + (o = e.getPixelForTick(s)), l(); + return r; + } + function zn(t, e, i, s) { + return ( + n(t) + ? (function (t, e, i, s) { + const n = i.parse(t[0], s), + o = i.parse(t[1], s), + a = Math.min(n, o), + r = Math.max(n, o); + let l = a, + h = r; + Math.abs(a) > Math.abs(r) && ((l = r), (h = a)), + (e[i.axis] = h), + (e._custom = { + barStart: l, + barEnd: h, + start: n, + end: o, + min: a, + max: r, + }); + })(t, e, i, s) + : (e[i.axis] = i.parse(t, s)), + e + ); + } + function Fn(t, e, i, s) { + const n = t.iScale, + o = t.vScale, + a = n.getLabels(), + r = n === o, + l = []; + let h, c, d, u; + for (h = i, c = i + s; h < c; ++h) + (u = e[h]), + (d = {}), + (d[n.axis] = r || n.parse(a[h], h)), + l.push(zn(u, d, o, h)); + return l; + } + function Vn(t) { + return t && void 0 !== t.barStart && void 0 !== t.barEnd; + } + function Bn(t, e, i, s) { + let n = e.borderSkipped; + const o = {}; + if (!n) return void (t.borderSkipped = o); + if (!0 === n) + return void (t.borderSkipped = { + top: !0, + right: !0, + bottom: !0, + left: !0, + }); + const { + start: a, + end: r, + reverse: l, + top: h, + bottom: c, + } = (function (t) { + let e, i, s, n, o; + return ( + t.horizontal + ? ((e = t.base > t.x), (i = "left"), (s = "right")) + : ((e = t.base < t.y), (i = "bottom"), (s = "top")), + e ? ((n = "end"), (o = "start")) : ((n = "start"), (o = "end")), + { start: i, end: s, reverse: e, top: n, bottom: o } + ); + })(t); + "middle" === n && + i && + ((t.enableBorderRadius = !0), + (i._top || 0) === s + ? (n = h) + : (i._bottom || 0) === s + ? (n = c) + : ((o[Wn(c, a, r, l)] = !0), (n = h))), + (o[Wn(n, a, r, l)] = !0), + (t.borderSkipped = o); + } + function Wn(t, e, i, s) { + var n, o, a; + return ( + s + ? ((a = i), + (t = Nn((t = (n = t) === (o = e) ? a : n === a ? o : n), i, e))) + : (t = Nn(t, e, i)), + t + ); + } + function Nn(t, e, i) { + return "start" === t ? e : "end" === t ? i : t; + } + function Hn(t, { inflateAmount: e }, i) { + t.inflateAmount = "auto" === e ? (1 === i ? 0.33 : 0) : e; + } + class jn extends Ns { + static id = "doughnut"; + static defaults = { + datasetElementType: !1, + dataElementType: "arc", + animation: { animateRotate: !0, animateScale: !1 }, + animations: { + numbers: { + type: "number", + properties: [ + "circumference", + "endAngle", + "innerRadius", + "outerRadius", + "startAngle", + "x", + "y", + "offset", + "borderWidth", + "spacing", + ], + }, + }, + cutout: "50%", + rotation: 0, + circumference: 360, + radius: "100%", + spacing: 0, + indexAxis: "r", + }; + static descriptors = { + _scriptable: (t) => "spacing" !== t, + _indexable: (t) => + "spacing" !== t && + !t.startsWith("borderDash") && + !t.startsWith("hoverBorderDash"), + }; + static overrides = { + aspectRatio: 1, + plugins: { + legend: { + labels: { + generateLabels(t) { + const e = t.data; + if (e.labels.length && e.datasets.length) { + const { + labels: { pointStyle: i, color: s }, + } = t.legend.options; + return e.labels.map((e, n) => { + const o = t.getDatasetMeta(0).controller.getStyle(n); + return { + text: e, + fillStyle: o.backgroundColor, + strokeStyle: o.borderColor, + fontColor: s, + lineWidth: o.borderWidth, + pointStyle: i, + hidden: !t.getDataVisibility(n), + index: n, + }; + }); + } + return []; + }, + }, + onClick(t, e, i) { + i.chart.toggleDataVisibility(e.index), i.chart.update(); + }, + }, + }, + }; + constructor(t, e) { + super(t, e), + (this.enableOptionSharing = !0), + (this.innerRadius = void 0), + (this.outerRadius = void 0), + (this.offsetX = void 0), + (this.offsetY = void 0); + } + linkScales() {} + parse(t, e) { + const i = this.getDataset().data, + s = this._cachedMeta; + if (!1 === this._parsing) s._parsed = i; + else { + let n, + a, + r = (t) => +i[t]; + if (o(i[t])) { + const { key: t = "value" } = this._parsing; + r = (e) => +M(i[e], t); + } + for (n = t, a = t + e; n < a; ++n) s._parsed[n] = r(n); + } + } + _getRotation() { + return $(this.options.rotation - 90); + } + _getCircumference() { + return $(this.options.circumference); + } + _getRotationExtents() { + let t = O, + e = -O; + for (let i = 0; i < this.chart.data.datasets.length; ++i) + if ( + this.chart.isDatasetVisible(i) && + this.chart.getDatasetMeta(i).type === this._type + ) { + const s = this.chart.getDatasetMeta(i).controller, + n = s._getRotation(), + o = s._getCircumference(); + (t = Math.min(t, n)), (e = Math.max(e, n + o)); + } + return { rotation: t, circumference: e - t }; + } + update(t) { + const e = this.chart, + { chartArea: i } = e, + s = this._cachedMeta, + n = s.data, + o = + this.getMaxBorderWidth() + + this.getMaxOffset(n) + + this.options.spacing, + a = Math.max((Math.min(i.width, i.height) - o) / 2, 0), + r = Math.min(h(this.options.cutout, a), 1), + l = this._getRingWeight(this.index), + { circumference: d, rotation: u } = this._getRotationExtents(), + { + ratioX: f, + ratioY: g, + offsetX: p, + offsetY: m, + } = (function (t, e, i) { + let s = 1, + n = 1, + o = 0, + a = 0; + if (e < O) { + const r = t, + l = r + e, + h = Math.cos(r), + c = Math.sin(r), + d = Math.cos(l), + u = Math.sin(l), + f = (t, e, s) => + Z(t, r, l, !0) ? 1 : Math.max(e, e * i, s, s * i), + g = (t, e, s) => + Z(t, r, l, !0) ? -1 : Math.min(e, e * i, s, s * i), + p = f(0, h, d), + m = f(E, c, u), + x = g(C, h, d), + b = g(C + E, c, u); + (s = (p - x) / 2), + (n = (m - b) / 2), + (o = -(p + x) / 2), + (a = -(m + b) / 2); + } + return { ratioX: s, ratioY: n, offsetX: o, offsetY: a }; + })(u, d, r), + x = (i.width - o) / f, + b = (i.height - o) / g, + _ = Math.max(Math.min(x, b) / 2, 0), + y = c(this.options.radius, _), + v = (y - Math.max(y * r, 0)) / this._getVisibleDatasetWeightTotal(); + (this.offsetX = p * y), + (this.offsetY = m * y), + (s.total = this.calculateTotal()), + (this.outerRadius = y - v * this._getRingWeightOffset(this.index)), + (this.innerRadius = Math.max(this.outerRadius - v * l, 0)), + this.updateElements(n, 0, n.length, t); + } + _circumference(t, e) { + const i = this.options, + s = this._cachedMeta, + n = this._getCircumference(); + return (e && i.animation.animateRotate) || + !this.chart.getDataVisibility(t) || + null === s._parsed[t] || + s.data[t].hidden + ? 0 + : this.calculateCircumference((s._parsed[t] * n) / O); + } + updateElements(t, e, i, s) { + const n = "reset" === s, + o = this.chart, + a = o.chartArea, + r = o.options.animation, + l = (a.left + a.right) / 2, + h = (a.top + a.bottom) / 2, + c = n && r.animateScale, + d = c ? 0 : this.innerRadius, + u = c ? 0 : this.outerRadius, + { sharedOptions: f, includeOptions: g } = this._getSharedOptions(e, s); + let p, + m = this._getRotation(); + for (p = 0; p < e; ++p) m += this._circumference(p, n); + for (p = e; p < e + i; ++p) { + const e = this._circumference(p, n), + i = t[p], + o = { + x: l + this.offsetX, + y: h + this.offsetY, + startAngle: m, + endAngle: m + e, + circumference: e, + outerRadius: u, + innerRadius: d, + }; + g && + (o.options = + f || this.resolveDataElementOptions(p, i.active ? "active" : s)), + (m += e), + this.updateElement(i, p, o, s); + } + } + calculateTotal() { + const t = this._cachedMeta, + e = t.data; + let i, + s = 0; + for (i = 0; i < e.length; i++) { + const n = t._parsed[i]; + null === n || + isNaN(n) || + !this.chart.getDataVisibility(i) || + e[i].hidden || + (s += Math.abs(n)); + } + return s; + } + calculateCircumference(t) { + const e = this._cachedMeta.total; + return e > 0 && !isNaN(t) ? O * (Math.abs(t) / e) : 0; + } + getLabelAndValue(t) { + const e = this._cachedMeta, + i = this.chart, + s = i.data.labels || [], + n = ne(e._parsed[t], i.options.locale); + return { label: s[t] || "", value: n }; + } + getMaxBorderWidth(t) { + let e = 0; + const i = this.chart; + let s, n, o, a, r; + if (!t) + for (s = 0, n = i.data.datasets.length; s < n; ++s) + if (i.isDatasetVisible(s)) { + (o = i.getDatasetMeta(s)), (t = o.data), (a = o.controller); + break; + } + if (!t) return 0; + for (s = 0, n = t.length; s < n; ++s) + (r = a.resolveDataElementOptions(s)), + "inner" !== r.borderAlign && + (e = Math.max(e, r.borderWidth || 0, r.hoverBorderWidth || 0)); + return e; + } + getMaxOffset(t) { + let e = 0; + for (let i = 0, s = t.length; i < s; ++i) { + const t = this.resolveDataElementOptions(i); + e = Math.max(e, t.offset || 0, t.hoverOffset || 0); + } + return e; + } + _getRingWeightOffset(t) { + let e = 0; + for (let i = 0; i < t; ++i) + this.chart.isDatasetVisible(i) && (e += this._getRingWeight(i)); + return e; + } + _getRingWeight(t) { + return Math.max(l(this.chart.data.datasets[t].weight, 1), 0); + } + _getVisibleDatasetWeightTotal() { + return this._getRingWeightOffset(this.chart.data.datasets.length) || 1; + } + } + class $n extends Ns { + static id = "polarArea"; + static defaults = { + dataElementType: "arc", + animation: { animateRotate: !0, animateScale: !0 }, + animations: { + numbers: { + type: "number", + properties: [ + "x", + "y", + "startAngle", + "endAngle", + "innerRadius", + "outerRadius", + ], + }, + }, + indexAxis: "r", + startAngle: 0, + }; + static overrides = { + aspectRatio: 1, + plugins: { + legend: { + labels: { + generateLabels(t) { + const e = t.data; + if (e.labels.length && e.datasets.length) { + const { + labels: { pointStyle: i, color: s }, + } = t.legend.options; + return e.labels.map((e, n) => { + const o = t.getDatasetMeta(0).controller.getStyle(n); + return { + text: e, + fillStyle: o.backgroundColor, + strokeStyle: o.borderColor, + fontColor: s, + lineWidth: o.borderWidth, + pointStyle: i, + hidden: !t.getDataVisibility(n), + index: n, + }; + }); + } + return []; + }, + }, + onClick(t, e, i) { + i.chart.toggleDataVisibility(e.index), i.chart.update(); + }, + }, + }, + scales: { + r: { + type: "radialLinear", + angleLines: { display: !1 }, + beginAtZero: !0, + grid: { circular: !0 }, + pointLabels: { display: !1 }, + startAngle: 0, + }, + }, + }; + constructor(t, e) { + super(t, e), (this.innerRadius = void 0), (this.outerRadius = void 0); + } + getLabelAndValue(t) { + const e = this._cachedMeta, + i = this.chart, + s = i.data.labels || [], + n = ne(e._parsed[t].r, i.options.locale); + return { label: s[t] || "", value: n }; + } + parseObjectData(t, e, i, s) { + return ii.bind(this)(t, e, i, s); + } + update(t) { + const e = this._cachedMeta.data; + this._updateRadius(), this.updateElements(e, 0, e.length, t); + } + getMinMax() { + const t = this._cachedMeta, + e = { min: Number.POSITIVE_INFINITY, max: Number.NEGATIVE_INFINITY }; + return ( + t.data.forEach((t, i) => { + const s = this.getParsed(i).r; + !isNaN(s) && + this.chart.getDataVisibility(i) && + (s < e.min && (e.min = s), s > e.max && (e.max = s)); + }), + e + ); + } + _updateRadius() { + const t = this.chart, + e = t.chartArea, + i = t.options, + s = Math.min(e.right - e.left, e.bottom - e.top), + n = Math.max(s / 2, 0), + o = + (n - + Math.max( + i.cutoutPercentage ? (n / 100) * i.cutoutPercentage : 1, + 0 + )) / + t.getVisibleDatasetCount(); + (this.outerRadius = n - o * this.index), + (this.innerRadius = this.outerRadius - o); + } + updateElements(t, e, i, s) { + const n = "reset" === s, + o = this.chart, + a = o.options.animation, + r = this._cachedMeta.rScale, + l = r.xCenter, + h = r.yCenter, + c = r.getIndexAngle(0) - 0.5 * C; + let d, + u = c; + const f = 360 / this.countVisibleElements(); + for (d = 0; d < e; ++d) u += this._computeAngle(d, s, f); + for (d = e; d < e + i; d++) { + const e = t[d]; + let i = u, + g = u + this._computeAngle(d, s, f), + p = o.getDataVisibility(d) + ? r.getDistanceFromCenterForValue(this.getParsed(d).r) + : 0; + (u = g), + n && (a.animateScale && (p = 0), a.animateRotate && (i = g = c)); + const m = { + x: l, + y: h, + innerRadius: 0, + outerRadius: p, + startAngle: i, + endAngle: g, + options: this.resolveDataElementOptions(d, e.active ? "active" : s), + }; + this.updateElement(e, d, m, s); + } + } + countVisibleElements() { + const t = this._cachedMeta; + let e = 0; + return ( + t.data.forEach((t, i) => { + !isNaN(this.getParsed(i).r) && this.chart.getDataVisibility(i) && e++; + }), + e + ); + } + _computeAngle(t, e, i) { + return this.chart.getDataVisibility(t) + ? $(this.resolveDataElementOptions(t, e).angle || i) + : 0; + } + } + var Yn = Object.freeze({ + __proto__: null, + BarController: class extends Ns { + static id = "bar"; + static defaults = { + datasetElementType: !1, + dataElementType: "bar", + categoryPercentage: 0.8, + barPercentage: 0.9, + grouped: !0, + animations: { + numbers: { + type: "number", + properties: ["x", "y", "base", "width", "height"], + }, + }, + }; + static overrides = { + scales: { + _index_: { type: "category", offset: !0, grid: { offset: !0 } }, + _value_: { type: "linear", beginAtZero: !0 }, + }, + }; + parsePrimitiveData(t, e, i, s) { + return Fn(t, e, i, s); + } + parseArrayData(t, e, i, s) { + return Fn(t, e, i, s); + } + parseObjectData(t, e, i, s) { + const { iScale: n, vScale: o } = t, + { xAxisKey: a = "x", yAxisKey: r = "y" } = this._parsing, + l = "x" === n.axis ? a : r, + h = "x" === o.axis ? a : r, + c = []; + let d, u, f, g; + for (d = i, u = i + s; d < u; ++d) + (g = e[d]), + (f = {}), + (f[n.axis] = n.parse(M(g, l), d)), + c.push(zn(M(g, h), f, o, d)); + return c; + } + updateRangeFromParsed(t, e, i, s) { + super.updateRangeFromParsed(t, e, i, s); + const n = i._custom; + n && + e === this._cachedMeta.vScale && + ((t.min = Math.min(t.min, n.min)), (t.max = Math.max(t.max, n.max))); + } + getMaxOverflow() { + return 0; + } + getLabelAndValue(t) { + const e = this._cachedMeta, + { iScale: i, vScale: s } = e, + n = this.getParsed(t), + o = n._custom, + a = Vn(o) + ? "[" + o.start + ", " + o.end + "]" + : "" + s.getLabelForValue(n[s.axis]); + return { label: "" + i.getLabelForValue(n[i.axis]), value: a }; + } + initialize() { + (this.enableOptionSharing = !0), super.initialize(); + this._cachedMeta.stack = this.getDataset().stack; + } + update(t) { + const e = this._cachedMeta; + this.updateElements(e.data, 0, e.data.length, t); + } + updateElements(t, e, i, n) { + const o = "reset" === n, + { + index: a, + _cachedMeta: { vScale: r }, + } = this, + l = r.getBasePixel(), + h = r.isHorizontal(), + c = this._getRuler(), + { sharedOptions: d, includeOptions: u } = this._getSharedOptions( + e, + n + ); + for (let f = e; f < e + i; f++) { + const e = this.getParsed(f), + i = + o || s(e[r.axis]) + ? { base: l, head: l } + : this._calculateBarValuePixels(f), + g = this._calculateBarIndexPixels(f, c), + p = (e._stacks || {})[r.axis], + m = { + horizontal: h, + base: i.base, + enableBorderRadius: + !p || Vn(e._custom) || a === p._top || a === p._bottom, + x: h ? i.head : g.center, + y: h ? g.center : i.head, + height: h ? g.size : Math.abs(i.size), + width: h ? Math.abs(i.size) : g.size, + }; + u && + (m.options = + d || + this.resolveDataElementOptions(f, t[f].active ? "active" : n)); + const x = m.options || t[f].options; + Bn(m, x, p, a), Hn(m, x, c.ratio), this.updateElement(t[f], f, m, n); + } + } + _getStacks(t, e) { + const { iScale: i } = this._cachedMeta, + n = i + .getMatchingVisibleMetas(this._type) + .filter((t) => t.controller.options.grouped), + o = i.options.stacked, + a = [], + r = this._cachedMeta.controller.getParsed(e), + l = r && r[i.axis], + h = (t) => { + const e = t._parsed.find((t) => t[i.axis] === l), + n = e && e[t.vScale.axis]; + if (s(n) || isNaN(n)) return !0; + }; + for (const i of n) + if ( + (void 0 === e || !h(i)) && + ((!1 === o || + -1 === a.indexOf(i.stack) || + (void 0 === o && void 0 === i.stack)) && + a.push(i.stack), + i.index === t) + ) + break; + return a.length || a.push(void 0), a; + } + _getStackCount(t) { + return this._getStacks(void 0, t).length; + } + _getStackIndex(t, e, i) { + const s = this._getStacks(t, i), + n = void 0 !== e ? s.indexOf(e) : -1; + return -1 === n ? s.length - 1 : n; + } + _getRuler() { + const t = this.options, + e = this._cachedMeta, + i = e.iScale, + s = []; + let n, o; + for (n = 0, o = e.data.length; n < o; ++n) + s.push(i.getPixelForValue(this.getParsed(n)[i.axis], n)); + const a = t.barThickness; + return { + min: a || In(e), + pixels: s, + start: i._startPixel, + end: i._endPixel, + stackCount: this._getStackCount(), + scale: i, + grouped: t.grouped, + ratio: a ? 1 : t.categoryPercentage * t.barPercentage, + }; + } + _calculateBarValuePixels(t) { + const { + _cachedMeta: { vScale: e, _stacked: i, index: n }, + options: { base: o, minBarLength: a }, + } = this, + r = o || 0, + l = this.getParsed(t), + h = l._custom, + c = Vn(h); + let d, + u, + f = l[e.axis], + g = 0, + p = i ? this.applyStack(e, l, i) : f; + p !== f && ((g = p - f), (p = f)), + c && + ((f = h.barStart), + (p = h.barEnd - h.barStart), + 0 !== f && F(f) !== F(h.barEnd) && (g = 0), + (g += f)); + const m = s(o) || c ? g : o; + let x = e.getPixelForValue(m); + if ( + ((d = this.chart.getDataVisibility(t) + ? e.getPixelForValue(g + p) + : x), + (u = d - x), + Math.abs(u) < a) + ) { + (u = + (function (t, e, i) { + return 0 !== t + ? F(t) + : (e.isHorizontal() ? 1 : -1) * (e.min >= i ? 1 : -1); + })(u, e, r) * a), + f === r && (x -= u / 2); + const t = e.getPixelForDecimal(0), + s = e.getPixelForDecimal(1), + o = Math.min(t, s), + h = Math.max(t, s); + (x = Math.max(Math.min(x, h), o)), + (d = x + u), + i && + !c && + (l._stacks[e.axis]._visualValues[n] = + e.getValueForPixel(d) - e.getValueForPixel(x)); + } + if (x === e.getPixelForValue(r)) { + const t = (F(u) * e.getLineWidthForValue(r)) / 2; + (x += t), (u -= t); + } + return { size: u, base: x, head: d, center: d + u / 2 }; + } + _calculateBarIndexPixels(t, e) { + const i = e.scale, + n = this.options, + o = n.skipNull, + a = l(n.maxBarThickness, 1 / 0); + let r, h; + if (e.grouped) { + const i = o ? this._getStackCount(t) : e.stackCount, + l = + "flex" === n.barThickness + ? (function (t, e, i, s) { + const n = e.pixels, + o = n[t]; + let a = t > 0 ? n[t - 1] : null, + r = t < n.length - 1 ? n[t + 1] : null; + const l = i.categoryPercentage; + null === a && + (a = o - (null === r ? e.end - e.start : r - o)), + null === r && (r = o + o - a); + const h = o - ((o - Math.min(a, r)) / 2) * l; + return { + chunk: ((Math.abs(r - a) / 2) * l) / s, + ratio: i.barPercentage, + start: h, + }; + })(t, e, n, i) + : (function (t, e, i, n) { + const o = i.barThickness; + let a, r; + return ( + s(o) + ? ((a = e.min * i.categoryPercentage), + (r = i.barPercentage)) + : ((a = o * n), (r = 1)), + { chunk: a / n, ratio: r, start: e.pixels[t] - a / 2 } + ); + })(t, e, n, i), + c = this._getStackIndex( + this.index, + this._cachedMeta.stack, + o ? t : void 0 + ); + (r = l.start + l.chunk * c + l.chunk / 2), + (h = Math.min(a, l.chunk * l.ratio)); + } else + (r = i.getPixelForValue(this.getParsed(t)[i.axis], t)), + (h = Math.min(a, e.min * e.ratio)); + return { base: r - h / 2, head: r + h / 2, center: r, size: h }; + } + draw() { + const t = this._cachedMeta, + e = t.vScale, + i = t.data, + s = i.length; + let n = 0; + for (; n < s; ++n) + null === this.getParsed(n)[e.axis] || + i[n].hidden || + i[n].draw(this._ctx); + } + }, + BubbleController: class extends Ns { + static id = "bubble"; + static defaults = { + datasetElementType: !1, + dataElementType: "point", + animations: { + numbers: { + type: "number", + properties: ["x", "y", "borderWidth", "radius"], + }, + }, + }; + static overrides = { + scales: { x: { type: "linear" }, y: { type: "linear" } }, + }; + initialize() { + (this.enableOptionSharing = !0), super.initialize(); + } + parsePrimitiveData(t, e, i, s) { + const n = super.parsePrimitiveData(t, e, i, s); + for (let t = 0; t < n.length; t++) + n[t]._custom = this.resolveDataElementOptions(t + i).radius; + return n; + } + parseArrayData(t, e, i, s) { + const n = super.parseArrayData(t, e, i, s); + for (let t = 0; t < n.length; t++) { + const s = e[i + t]; + n[t]._custom = l(s[2], this.resolveDataElementOptions(t + i).radius); + } + return n; + } + parseObjectData(t, e, i, s) { + const n = super.parseObjectData(t, e, i, s); + for (let t = 0; t < n.length; t++) { + const s = e[i + t]; + n[t]._custom = l( + s && s.r && +s.r, + this.resolveDataElementOptions(t + i).radius + ); + } + return n; + } + getMaxOverflow() { + const t = this._cachedMeta.data; + let e = 0; + for (let i = t.length - 1; i >= 0; --i) + e = Math.max(e, t[i].size(this.resolveDataElementOptions(i)) / 2); + return e > 0 && e; + } + getLabelAndValue(t) { + const e = this._cachedMeta, + i = this.chart.data.labels || [], + { xScale: s, yScale: n } = e, + o = this.getParsed(t), + a = s.getLabelForValue(o.x), + r = n.getLabelForValue(o.y), + l = o._custom; + return { + label: i[t] || "", + value: "(" + a + ", " + r + (l ? ", " + l : "") + ")", + }; + } + update(t) { + const e = this._cachedMeta.data; + this.updateElements(e, 0, e.length, t); + } + updateElements(t, e, i, s) { + const n = "reset" === s, + { iScale: o, vScale: a } = this._cachedMeta, + { sharedOptions: r, includeOptions: l } = this._getSharedOptions( + e, + s + ), + h = o.axis, + c = a.axis; + for (let d = e; d < e + i; d++) { + const e = t[d], + i = !n && this.getParsed(d), + u = {}, + f = (u[h] = n + ? o.getPixelForDecimal(0.5) + : o.getPixelForValue(i[h])), + g = (u[c] = n ? a.getBasePixel() : a.getPixelForValue(i[c])); + (u.skip = isNaN(f) || isNaN(g)), + l && + ((u.options = + r || + this.resolveDataElementOptions(d, e.active ? "active" : s)), + n && (u.options.radius = 0)), + this.updateElement(e, d, u, s); + } + } + resolveDataElementOptions(t, e) { + const i = this.getParsed(t); + let s = super.resolveDataElementOptions(t, e); + s.$shared && (s = Object.assign({}, s, { $shared: !1 })); + const n = s.radius; + return ( + "active" !== e && (s.radius = 0), + (s.radius += l(i && i._custom, n)), + s + ); + } + }, + DoughnutController: jn, + LineController: class extends Ns { + static id = "line"; + static defaults = { + datasetElementType: "line", + dataElementType: "point", + showLine: !0, + spanGaps: !1, + }; + static overrides = { + scales: { _index_: { type: "category" }, _value_: { type: "linear" } }, + }; + initialize() { + (this.enableOptionSharing = !0), + (this.supportsDecimation = !0), + super.initialize(); + } + update(t) { + const e = this._cachedMeta, + { dataset: i, data: s = [], _dataset: n } = e, + o = this.chart._animationsDisabled; + let { start: a, count: r } = pt(e, s, o); + (this._drawStart = a), + (this._drawCount = r), + mt(e) && ((a = 0), (r = s.length)), + (i._chart = this.chart), + (i._datasetIndex = this.index), + (i._decimated = !!n._decimated), + (i.points = s); + const l = this.resolveDatasetElementOptions(t); + this.options.showLine || (l.borderWidth = 0), + (l.segment = this.options.segment), + this.updateElement(i, void 0, { animated: !o, options: l }, t), + this.updateElements(s, a, r, t); + } + updateElements(t, e, i, n) { + const o = "reset" === n, + { iScale: a, vScale: r, _stacked: l, _dataset: h } = this._cachedMeta, + { sharedOptions: c, includeOptions: d } = this._getSharedOptions( + e, + n + ), + u = a.axis, + f = r.axis, + { spanGaps: g, segment: p } = this.options, + m = N(g) ? g : Number.POSITIVE_INFINITY, + x = this.chart._animationsDisabled || o || "none" === n, + b = e + i, + _ = t.length; + let y = e > 0 && this.getParsed(e - 1); + for (let i = 0; i < _; ++i) { + const g = t[i], + _ = x ? g : {}; + if (i < e || i >= b) { + _.skip = !0; + continue; + } + const v = this.getParsed(i), + M = s(v[f]), + w = (_[u] = a.getPixelForValue(v[u], i)), + k = (_[f] = + o || M + ? r.getBasePixel() + : r.getPixelForValue(l ? this.applyStack(r, v, l) : v[f], i)); + (_.skip = isNaN(w) || isNaN(k) || M), + (_.stop = i > 0 && Math.abs(v[u] - y[u]) > m), + p && ((_.parsed = v), (_.raw = h.data[i])), + d && + (_.options = + c || + this.resolveDataElementOptions(i, g.active ? "active" : n)), + x || this.updateElement(g, i, _, n), + (y = v); + } + } + getMaxOverflow() { + const t = this._cachedMeta, + e = t.dataset, + i = (e.options && e.options.borderWidth) || 0, + s = t.data || []; + if (!s.length) return i; + const n = s[0].size(this.resolveDataElementOptions(0)), + o = s[s.length - 1].size( + this.resolveDataElementOptions(s.length - 1) + ); + return Math.max(i, n, o) / 2; + } + draw() { + const t = this._cachedMeta; + t.dataset.updateControlPoints(this.chart.chartArea, t.iScale.axis), + super.draw(); + } + }, + PieController: class extends jn { + static id = "pie"; + static defaults = { + cutout: 0, + rotation: 0, + circumference: 360, + radius: "100%", + }; + }, + PolarAreaController: $n, + RadarController: class extends Ns { + static id = "radar"; + static defaults = { + datasetElementType: "line", + dataElementType: "point", + indexAxis: "r", + showLine: !0, + elements: { line: { fill: "start" } }, + }; + static overrides = { + aspectRatio: 1, + scales: { r: { type: "radialLinear" } }, + }; + getLabelAndValue(t) { + const e = this._cachedMeta.vScale, + i = this.getParsed(t); + return { + label: e.getLabels()[t], + value: "" + e.getLabelForValue(i[e.axis]), + }; + } + parseObjectData(t, e, i, s) { + return ii.bind(this)(t, e, i, s); + } + update(t) { + const e = this._cachedMeta, + i = e.dataset, + s = e.data || [], + n = e.iScale.getLabels(); + if (((i.points = s), "resize" !== t)) { + const e = this.resolveDatasetElementOptions(t); + this.options.showLine || (e.borderWidth = 0); + const o = { _loop: !0, _fullLoop: n.length === s.length, options: e }; + this.updateElement(i, void 0, o, t); + } + this.updateElements(s, 0, s.length, t); + } + updateElements(t, e, i, s) { + const n = this._cachedMeta.rScale, + o = "reset" === s; + for (let a = e; a < e + i; a++) { + const e = t[a], + i = this.resolveDataElementOptions(a, e.active ? "active" : s), + r = n.getPointPositionForValue(a, this.getParsed(a).r), + l = o ? n.xCenter : r.x, + h = o ? n.yCenter : r.y, + c = { + x: l, + y: h, + angle: r.angle, + skip: isNaN(l) || isNaN(h), + options: i, + }; + this.updateElement(e, a, c, s); + } + } + }, + ScatterController: class extends Ns { + static id = "scatter"; + static defaults = { + datasetElementType: !1, + dataElementType: "point", + showLine: !1, + fill: !1, + }; + static overrides = { + interaction: { mode: "point" }, + scales: { x: { type: "linear" }, y: { type: "linear" } }, + }; + getLabelAndValue(t) { + const e = this._cachedMeta, + i = this.chart.data.labels || [], + { xScale: s, yScale: n } = e, + o = this.getParsed(t), + a = s.getLabelForValue(o.x), + r = n.getLabelForValue(o.y); + return { label: i[t] || "", value: "(" + a + ", " + r + ")" }; + } + update(t) { + const e = this._cachedMeta, + { data: i = [] } = e, + s = this.chart._animationsDisabled; + let { start: n, count: o } = pt(e, i, s); + if ( + ((this._drawStart = n), + (this._drawCount = o), + mt(e) && ((n = 0), (o = i.length)), + this.options.showLine) + ) { + this.datasetElementType || this.addElements(); + const { dataset: n, _dataset: o } = e; + (n._chart = this.chart), + (n._datasetIndex = this.index), + (n._decimated = !!o._decimated), + (n.points = i); + const a = this.resolveDatasetElementOptions(t); + (a.segment = this.options.segment), + this.updateElement(n, void 0, { animated: !s, options: a }, t); + } else + this.datasetElementType && + (delete e.dataset, (this.datasetElementType = !1)); + this.updateElements(i, n, o, t); + } + addElements() { + const { showLine: t } = this.options; + !this.datasetElementType && + t && + (this.datasetElementType = this.chart.registry.getElement("line")), + super.addElements(); + } + updateElements(t, e, i, n) { + const o = "reset" === n, + { iScale: a, vScale: r, _stacked: l, _dataset: h } = this._cachedMeta, + c = this.resolveDataElementOptions(e, n), + d = this.getSharedOptions(c), + u = this.includeOptions(n, d), + f = a.axis, + g = r.axis, + { spanGaps: p, segment: m } = this.options, + x = N(p) ? p : Number.POSITIVE_INFINITY, + b = this.chart._animationsDisabled || o || "none" === n; + let _ = e > 0 && this.getParsed(e - 1); + for (let c = e; c < e + i; ++c) { + const e = t[c], + i = this.getParsed(c), + p = b ? e : {}, + y = s(i[g]), + v = (p[f] = a.getPixelForValue(i[f], c)), + M = (p[g] = + o || y + ? r.getBasePixel() + : r.getPixelForValue(l ? this.applyStack(r, i, l) : i[g], c)); + (p.skip = isNaN(v) || isNaN(M) || y), + (p.stop = c > 0 && Math.abs(i[f] - _[f]) > x), + m && ((p.parsed = i), (p.raw = h.data[c])), + u && + (p.options = + d || + this.resolveDataElementOptions(c, e.active ? "active" : n)), + b || this.updateElement(e, c, p, n), + (_ = i); + } + this.updateSharedOptions(d, n, c); + } + getMaxOverflow() { + const t = this._cachedMeta, + e = t.data || []; + if (!this.options.showLine) { + let t = 0; + for (let i = e.length - 1; i >= 0; --i) + t = Math.max(t, e[i].size(this.resolveDataElementOptions(i)) / 2); + return t > 0 && t; + } + const i = t.dataset, + s = (i.options && i.options.borderWidth) || 0; + if (!e.length) return s; + const n = e[0].size(this.resolveDataElementOptions(0)), + o = e[e.length - 1].size( + this.resolveDataElementOptions(e.length - 1) + ); + return Math.max(s, n, o) / 2; + } + }, + }); + function Un(t, e, i, s) { + const n = vi(t.options.borderRadius, [ + "outerStart", + "outerEnd", + "innerStart", + "innerEnd", + ]); + const o = (i - e) / 2, + a = Math.min(o, (s * e) / 2), + r = (t) => { + const e = ((i - Math.min(o, t)) * s) / 2; + return J(t, 0, Math.min(o, e)); + }; + return { + outerStart: r(n.outerStart), + outerEnd: r(n.outerEnd), + innerStart: J(n.innerStart, 0, a), + innerEnd: J(n.innerEnd, 0, a), + }; + } + function Xn(t, e, i, s) { + return { x: i + t * Math.cos(e), y: s + t * Math.sin(e) }; + } + function qn(t, e, i, s, n, o) { + const { x: a, y: r, startAngle: l, pixelMargin: h, innerRadius: c } = e, + d = Math.max(e.outerRadius + s + i - h, 0), + u = c > 0 ? c + s + i + h : 0; + let f = 0; + const g = n - l; + if (s) { + const t = ((c > 0 ? c - s : 0) + (d > 0 ? d - s : 0)) / 2; + f = (g - (0 !== t ? (g * t) / (t + s) : g)) / 2; + } + const p = (g - Math.max(0.001, g * d - i / C) / d) / 2, + m = l + p + f, + x = n - p - f, + { + outerStart: b, + outerEnd: _, + innerStart: y, + innerEnd: v, + } = Un(e, u, d, x - m), + M = d - b, + w = d - _, + k = m + b / M, + S = x - _ / w, + P = u + y, + D = u + v, + O = m + y / P, + A = x - v / D; + if ((t.beginPath(), o)) { + const e = (k + S) / 2; + if ((t.arc(a, r, d, k, e), t.arc(a, r, d, e, S), _ > 0)) { + const e = Xn(w, S, a, r); + t.arc(e.x, e.y, _, S, x + E); + } + const i = Xn(D, x, a, r); + if ((t.lineTo(i.x, i.y), v > 0)) { + const e = Xn(D, A, a, r); + t.arc(e.x, e.y, v, x + E, A + Math.PI); + } + const s = (x - v / u + (m + y / u)) / 2; + if ( + (t.arc(a, r, u, x - v / u, s, !0), + t.arc(a, r, u, s, m + y / u, !0), + y > 0) + ) { + const e = Xn(P, O, a, r); + t.arc(e.x, e.y, y, O + Math.PI, m - E); + } + const n = Xn(M, m, a, r); + if ((t.lineTo(n.x, n.y), b > 0)) { + const e = Xn(M, k, a, r); + t.arc(e.x, e.y, b, m - E, k); + } + } else { + t.moveTo(a, r); + const e = Math.cos(k) * d + a, + i = Math.sin(k) * d + r; + t.lineTo(e, i); + const s = Math.cos(S) * d + a, + n = Math.sin(S) * d + r; + t.lineTo(s, n); + } + t.closePath(); + } + function Kn(t, e, i, s, n) { + const { fullCircles: o, startAngle: a, circumference: r, options: l } = e, + { + borderWidth: h, + borderJoinStyle: c, + borderDash: d, + borderDashOffset: u, + } = l, + f = "inner" === l.borderAlign; + if (!h) return; + t.setLineDash(d || []), + (t.lineDashOffset = u), + f + ? ((t.lineWidth = 2 * h), (t.lineJoin = c || "round")) + : ((t.lineWidth = h), (t.lineJoin = c || "bevel")); + let g = e.endAngle; + if (o) { + qn(t, e, i, s, g, n); + for (let e = 0; e < o; ++e) t.stroke(); + isNaN(r) || (g = a + (r % O || O)); + } + f && + (function (t, e, i) { + const { + startAngle: s, + pixelMargin: n, + x: o, + y: a, + outerRadius: r, + innerRadius: l, + } = e; + let h = n / r; + t.beginPath(), + t.arc(o, a, r, s - h, i + h), + l > n + ? ((h = n / l), t.arc(o, a, l, i + h, s - h, !0)) + : t.arc(o, a, n, i + E, s - E), + t.closePath(), + t.clip(); + })(t, e, g), + o || (qn(t, e, i, s, g, n), t.stroke()); + } + function Gn(t, e, i = e) { + (t.lineCap = l(i.borderCapStyle, e.borderCapStyle)), + t.setLineDash(l(i.borderDash, e.borderDash)), + (t.lineDashOffset = l(i.borderDashOffset, e.borderDashOffset)), + (t.lineJoin = l(i.borderJoinStyle, e.borderJoinStyle)), + (t.lineWidth = l(i.borderWidth, e.borderWidth)), + (t.strokeStyle = l(i.borderColor, e.borderColor)); + } + function Zn(t, e, i) { + t.lineTo(i.x, i.y); + } + function Jn(t, e, i = {}) { + const s = t.length, + { start: n = 0, end: o = s - 1 } = i, + { start: a, end: r } = e, + l = Math.max(n, a), + h = Math.min(o, r), + c = (n < a && o < a) || (n > r && o > r); + return { + count: s, + start: l, + loop: e.loop, + ilen: h < l && !c ? s + h - l : h - l, + }; + } + function Qn(t, e, i, s) { + const { points: n, options: o } = e, + { count: a, start: r, loop: l, ilen: h } = Jn(n, i, s), + c = (function (t) { + return t.stepped + ? Fe + : t.tension || "monotone" === t.cubicInterpolationMode + ? Ve + : Zn; + })(o); + let d, + u, + f, + { move: g = !0, reverse: p } = s || {}; + for (d = 0; d <= h; ++d) + (u = n[(r + (p ? h - d : d)) % a]), + u.skip || + (g ? (t.moveTo(u.x, u.y), (g = !1)) : c(t, f, u, p, o.stepped), + (f = u)); + return l && ((u = n[(r + (p ? h : 0)) % a]), c(t, f, u, p, o.stepped)), !!l; + } + function to(t, e, i, s) { + const n = e.points, + { count: o, start: a, ilen: r } = Jn(n, i, s), + { move: l = !0, reverse: h } = s || {}; + let c, + d, + u, + f, + g, + p, + m = 0, + x = 0; + const b = (t) => (a + (h ? r - t : t)) % o, + _ = () => { + f !== g && (t.lineTo(m, g), t.lineTo(m, f), t.lineTo(m, p)); + }; + for (l && ((d = n[b(0)]), t.moveTo(d.x, d.y)), c = 0; c <= r; ++c) { + if (((d = n[b(c)]), d.skip)) continue; + const e = d.x, + i = d.y, + s = 0 | e; + s === u + ? (i < f ? (f = i) : i > g && (g = i), (m = (x * m + e) / ++x)) + : (_(), t.lineTo(e, i), (u = s), (x = 0), (f = g = i)), + (p = i); + } + _(); + } + function eo(t) { + const e = t.options, + i = e.borderDash && e.borderDash.length; + return !( + t._decimated || + t._loop || + e.tension || + "monotone" === e.cubicInterpolationMode || + e.stepped || + i + ) + ? to + : Qn; + } + const io = "function" == typeof Path2D; + function so(t, e, i, s) { + io && !e.options.segment + ? (function (t, e, i, s) { + let n = e._path; + n || ((n = e._path = new Path2D()), e.path(n, i, s) && n.closePath()), + Gn(t, e.options), + t.stroke(n); + })(t, e, i, s) + : (function (t, e, i, s) { + const { segments: n, options: o } = e, + a = eo(e); + for (const r of n) + Gn(t, o, r.style), + t.beginPath(), + a(t, e, r, { start: i, end: i + s - 1 }) && t.closePath(), + t.stroke(); + })(t, e, i, s); + } + class no extends Hs { + static id = "line"; + static defaults = { + borderCapStyle: "butt", + borderDash: [], + borderDashOffset: 0, + borderJoinStyle: "miter", + borderWidth: 3, + capBezierPoints: !0, + cubicInterpolationMode: "default", + fill: !1, + spanGaps: !1, + stepped: !1, + tension: 0, + }; + static defaultRoutes = { + backgroundColor: "backgroundColor", + borderColor: "borderColor", + }; + static descriptors = { + _scriptable: !0, + _indexable: (t) => "borderDash" !== t && "fill" !== t, + }; + constructor(t) { + super(), + (this.animated = !0), + (this.options = void 0), + (this._chart = void 0), + (this._loop = void 0), + (this._fullLoop = void 0), + (this._path = void 0), + (this._points = void 0), + (this._segments = void 0), + (this._decimated = !1), + (this._pointsUpdated = !1), + (this._datasetIndex = void 0), + t && Object.assign(this, t); + } + updateControlPoints(t, e) { + const i = this.options; + if ( + (i.tension || "monotone" === i.cubicInterpolationMode) && + !i.stepped && + !this._pointsUpdated + ) { + const s = i.spanGaps ? this._loop : this._fullLoop; + hi(this._points, i, t, s, e), (this._pointsUpdated = !0); + } + } + set points(t) { + (this._points = t), + delete this._segments, + delete this._path, + (this._pointsUpdated = !1); + } + get points() { + return this._points; + } + get segments() { + return ( + this._segments || (this._segments = zi(this, this.options.segment)) + ); + } + first() { + const t = this.segments, + e = this.points; + return t.length && e[t[0].start]; + } + last() { + const t = this.segments, + e = this.points, + i = t.length; + return i && e[t[i - 1].end]; + } + interpolate(t, e) { + const i = this.options, + s = t[e], + n = this.points, + o = Ii(this, { property: e, start: s, end: s }); + if (!o.length) return; + const a = [], + r = (function (t) { + return t.stepped + ? pi + : t.tension || "monotone" === t.cubicInterpolationMode + ? mi + : gi; + })(i); + let l, h; + for (l = 0, h = o.length; l < h; ++l) { + const { start: h, end: c } = o[l], + d = n[h], + u = n[c]; + if (d === u) { + a.push(d); + continue; + } + const f = r(d, u, Math.abs((s - d[e]) / (u[e] - d[e])), i.stepped); + (f[e] = t[e]), a.push(f); + } + return 1 === a.length ? a[0] : a; + } + pathSegment(t, e, i) { + return eo(this)(t, this, e, i); + } + path(t, e, i) { + const s = this.segments, + n = eo(this); + let o = this._loop; + (e = e || 0), (i = i || this.points.length - e); + for (const a of s) o &= n(t, this, a, { start: e, end: e + i - 1 }); + return !!o; + } + draw(t, e, i, s) { + const n = this.options || {}; + (this.points || []).length && + n.borderWidth && + (t.save(), so(t, this, i, s), t.restore()), + this.animated && ((this._pointsUpdated = !1), (this._path = void 0)); + } + } + function oo(t, e, i, s) { + const n = t.options, + { [i]: o } = t.getProps([i], s); + return Math.abs(e - o) < n.radius + n.hitRadius; + } + function ao(t, e) { + const { + x: i, + y: s, + base: n, + width: o, + height: a, + } = t.getProps(["x", "y", "base", "width", "height"], e); + let r, l, h, c, d; + return ( + t.horizontal + ? ((d = a / 2), + (r = Math.min(i, n)), + (l = Math.max(i, n)), + (h = s - d), + (c = s + d)) + : ((d = o / 2), + (r = i - d), + (l = i + d), + (h = Math.min(s, n)), + (c = Math.max(s, n))), + { left: r, top: h, right: l, bottom: c } + ); + } + function ro(t, e, i, s) { + return t ? 0 : J(e, i, s); + } + function lo(t) { + const e = ao(t), + i = e.right - e.left, + s = e.bottom - e.top, + n = (function (t, e, i) { + const s = t.options.borderWidth, + n = t.borderSkipped, + o = Mi(s); + return { + t: ro(n.top, o.top, 0, i), + r: ro(n.right, o.right, 0, e), + b: ro(n.bottom, o.bottom, 0, i), + l: ro(n.left, o.left, 0, e), + }; + })(t, i / 2, s / 2), + a = (function (t, e, i) { + const { enableBorderRadius: s } = t.getProps(["enableBorderRadius"]), + n = t.options.borderRadius, + a = wi(n), + r = Math.min(e, i), + l = t.borderSkipped, + h = s || o(n); + return { + topLeft: ro(!h || l.top || l.left, a.topLeft, 0, r), + topRight: ro(!h || l.top || l.right, a.topRight, 0, r), + bottomLeft: ro(!h || l.bottom || l.left, a.bottomLeft, 0, r), + bottomRight: ro(!h || l.bottom || l.right, a.bottomRight, 0, r), + }; + })(t, i / 2, s / 2); + return { + outer: { x: e.left, y: e.top, w: i, h: s, radius: a }, + inner: { + x: e.left + n.l, + y: e.top + n.t, + w: i - n.l - n.r, + h: s - n.t - n.b, + radius: { + topLeft: Math.max(0, a.topLeft - Math.max(n.t, n.l)), + topRight: Math.max(0, a.topRight - Math.max(n.t, n.r)), + bottomLeft: Math.max(0, a.bottomLeft - Math.max(n.b, n.l)), + bottomRight: Math.max(0, a.bottomRight - Math.max(n.b, n.r)), + }, + }, + }; + } + function ho(t, e, i, s) { + const n = null === e, + o = null === i, + a = t && !(n && o) && ao(t, s); + return a && (n || tt(e, a.left, a.right)) && (o || tt(i, a.top, a.bottom)); + } + function co(t, e) { + t.rect(e.x, e.y, e.w, e.h); + } + function uo(t, e, i = {}) { + const s = t.x !== i.x ? -e : 0, + n = t.y !== i.y ? -e : 0, + o = (t.x + t.w !== i.x + i.w ? e : 0) - s, + a = (t.y + t.h !== i.y + i.h ? e : 0) - n; + return { x: t.x + s, y: t.y + n, w: t.w + o, h: t.h + a, radius: t.radius }; + } + var fo = Object.freeze({ + __proto__: null, + ArcElement: class extends Hs { + static id = "arc"; + static defaults = { + borderAlign: "center", + borderColor: "#fff", + borderDash: [], + borderDashOffset: 0, + borderJoinStyle: void 0, + borderRadius: 0, + borderWidth: 2, + offset: 0, + spacing: 0, + angle: void 0, + circular: !0, + }; + static defaultRoutes = { backgroundColor: "backgroundColor" }; + static descriptors = { + _scriptable: !0, + _indexable: (t) => "borderDash" !== t, + }; + circumference; + endAngle; + fullCircles; + innerRadius; + outerRadius; + pixelMargin; + startAngle; + constructor(t) { + super(), + (this.options = void 0), + (this.circumference = void 0), + (this.startAngle = void 0), + (this.endAngle = void 0), + (this.innerRadius = void 0), + (this.outerRadius = void 0), + (this.pixelMargin = 0), + (this.fullCircles = 0), + t && Object.assign(this, t); + } + inRange(t, e, i) { + const s = this.getProps(["x", "y"], i), + { angle: n, distance: o } = X(s, { x: t, y: e }), + { + startAngle: a, + endAngle: r, + innerRadius: h, + outerRadius: c, + circumference: d, + } = this.getProps( + [ + "startAngle", + "endAngle", + "innerRadius", + "outerRadius", + "circumference", + ], + i + ), + u = (this.options.spacing + this.options.borderWidth) / 2, + f = l(d, r - a), + g = Z(n, a, r) && a !== r, + p = f >= O || g, + m = tt(o, h + u, c + u); + return p && m; + } + getCenterPoint(t) { + const { + x: e, + y: i, + startAngle: s, + endAngle: n, + innerRadius: o, + outerRadius: a, + } = this.getProps( + ["x", "y", "startAngle", "endAngle", "innerRadius", "outerRadius"], + t + ), + { offset: r, spacing: l } = this.options, + h = (s + n) / 2, + c = (o + a + l + r) / 2; + return { x: e + Math.cos(h) * c, y: i + Math.sin(h) * c }; + } + tooltipPosition(t) { + return this.getCenterPoint(t); + } + draw(t) { + const { options: e, circumference: i } = this, + s = (e.offset || 0) / 4, + n = (e.spacing || 0) / 2, + o = e.circular; + if ( + ((this.pixelMargin = "inner" === e.borderAlign ? 0.33 : 0), + (this.fullCircles = i > O ? Math.floor(i / O) : 0), + 0 === i || this.innerRadius < 0 || this.outerRadius < 0) + ) + return; + t.save(); + const a = (this.startAngle + this.endAngle) / 2; + t.translate(Math.cos(a) * s, Math.sin(a) * s); + const r = s * (1 - Math.sin(Math.min(C, i || 0))); + (t.fillStyle = e.backgroundColor), + (t.strokeStyle = e.borderColor), + (function (t, e, i, s, n) { + const { fullCircles: o, startAngle: a, circumference: r } = e; + let l = e.endAngle; + if (o) { + qn(t, e, i, s, l, n); + for (let e = 0; e < o; ++e) t.fill(); + isNaN(r) || (l = a + (r % O || O)); + } + qn(t, e, i, s, l, n), t.fill(); + })(t, this, r, n, o), + Kn(t, this, r, n, o), + t.restore(); + } + }, + BarElement: class extends Hs { + static id = "bar"; + static defaults = { + borderSkipped: "start", + borderWidth: 0, + borderRadius: 0, + inflateAmount: "auto", + pointStyle: void 0, + }; + static defaultRoutes = { + backgroundColor: "backgroundColor", + borderColor: "borderColor", + }; + constructor(t) { + super(), + (this.options = void 0), + (this.horizontal = void 0), + (this.base = void 0), + (this.width = void 0), + (this.height = void 0), + (this.inflateAmount = void 0), + t && Object.assign(this, t); + } + draw(t) { + const { + inflateAmount: e, + options: { borderColor: i, backgroundColor: s }, + } = this, + { inner: n, outer: o } = lo(this), + a = + (r = o.radius).topLeft || + r.topRight || + r.bottomLeft || + r.bottomRight + ? He + : co; + var r; + t.save(), + (o.w === n.w && o.h === n.h) || + (t.beginPath(), + a(t, uo(o, e, n)), + t.clip(), + a(t, uo(n, -e, o)), + (t.fillStyle = i), + t.fill("evenodd")), + t.beginPath(), + a(t, uo(n, e)), + (t.fillStyle = s), + t.fill(), + t.restore(); + } + inRange(t, e, i) { + return ho(this, t, e, i); + } + inXRange(t, e) { + return ho(this, t, null, e); + } + inYRange(t, e) { + return ho(this, null, t, e); + } + getCenterPoint(t) { + const { + x: e, + y: i, + base: s, + horizontal: n, + } = this.getProps(["x", "y", "base", "horizontal"], t); + return { x: n ? (e + s) / 2 : e, y: n ? i : (i + s) / 2 }; + } + getRange(t) { + return "x" === t ? this.width / 2 : this.height / 2; + } + }, + LineElement: no, + PointElement: class extends Hs { + static id = "point"; + parsed; + skip; + stop; + static defaults = { + borderWidth: 1, + hitRadius: 1, + hoverBorderWidth: 1, + hoverRadius: 4, + pointStyle: "circle", + radius: 3, + rotation: 0, + }; + static defaultRoutes = { + backgroundColor: "backgroundColor", + borderColor: "borderColor", + }; + constructor(t) { + super(), + (this.options = void 0), + (this.parsed = void 0), + (this.skip = void 0), + (this.stop = void 0), + t && Object.assign(this, t); + } + inRange(t, e, i) { + const s = this.options, + { x: n, y: o } = this.getProps(["x", "y"], i); + return ( + Math.pow(t - n, 2) + Math.pow(e - o, 2) < + Math.pow(s.hitRadius + s.radius, 2) + ); + } + inXRange(t, e) { + return oo(this, t, "x", e); + } + inYRange(t, e) { + return oo(this, t, "y", e); + } + getCenterPoint(t) { + const { x: e, y: i } = this.getProps(["x", "y"], t); + return { x: e, y: i }; + } + size(t) { + let e = (t = t || this.options || {}).radius || 0; + e = Math.max(e, (e && t.hoverRadius) || 0); + return 2 * (e + ((e && t.borderWidth) || 0)); + } + draw(t, e) { + const i = this.options; + this.skip || + i.radius < 0.1 || + !Re(this, e, this.size(i) / 2) || + ((t.strokeStyle = i.borderColor), + (t.lineWidth = i.borderWidth), + (t.fillStyle = i.backgroundColor), + Le(t, i, this.x, this.y)); + } + getRange() { + const t = this.options || {}; + return t.radius + t.hitRadius; + } + }, + }); + function go(t, e, i, s) { + const n = t.indexOf(e); + if (-1 === n) + return ((t, e, i, s) => ( + "string" == typeof e + ? ((i = t.push(e) - 1), s.unshift({ index: i, label: e })) + : isNaN(e) && (i = null), + i + ))(t, e, i, s); + return n !== t.lastIndexOf(e) ? i : n; + } + function po(t) { + const e = this.getLabels(); + return t >= 0 && t < e.length ? e[t] : t; + } + function mo(t, e, { horizontal: i, minRotation: s }) { + const n = $(s), + o = (i ? Math.sin(n) : Math.cos(n)) || 0.001, + a = 0.75 * e * ("" + t).length; + return Math.min(e / o, a); + } + class xo extends Js { + constructor(t) { + super(t), + (this.start = void 0), + (this.end = void 0), + (this._startValue = void 0), + (this._endValue = void 0), + (this._valueRange = 0); + } + parse(t, e) { + return s(t) || + (("number" == typeof t || t instanceof Number) && !isFinite(+t)) + ? null + : +t; + } + handleTickRangeOptions() { + const { beginAtZero: t } = this.options, + { minDefined: e, maxDefined: i } = this.getUserBounds(); + let { min: s, max: n } = this; + const o = (t) => (s = e ? s : t), + a = (t) => (n = i ? n : t); + if (t) { + const t = F(s), + e = F(n); + t < 0 && e < 0 ? a(0) : t > 0 && e > 0 && o(0); + } + if (s === n) { + let e = 0 === n ? 1 : Math.abs(0.05 * n); + a(n + e), t || o(s - e); + } + (this.min = s), (this.max = n); + } + getTickLimit() { + const t = this.options.ticks; + let e, + { maxTicksLimit: i, stepSize: s } = t; + return ( + s + ? ((e = Math.ceil(this.max / s) - Math.floor(this.min / s) + 1), + e > 1e3 && + (console.warn( + `scales.${this.id}.ticks.stepSize: ${s} would result generating up to ${e} ticks. Limiting to 1000.` + ), + (e = 1e3))) + : ((e = this.computeTickLimit()), (i = i || 11)), + i && (e = Math.min(i, e)), + e + ); + } + computeTickLimit() { + return Number.POSITIVE_INFINITY; + } + buildTicks() { + const t = this.options, + e = t.ticks; + let i = this.getTickLimit(); + i = Math.max(2, i); + const n = (function (t, e) { + const i = [], + { + bounds: n, + step: o, + min: a, + max: r, + precision: l, + count: h, + maxTicks: c, + maxDigits: d, + includeBounds: u, + } = t, + f = o || 1, + g = c - 1, + { min: p, max: m } = e, + x = !s(a), + b = !s(r), + _ = !s(h), + y = (m - p) / (d + 1); + let v, + M, + w, + k, + S = B((m - p) / g / f) * f; + if (S < 1e-14 && !x && !b) return [{ value: p }, { value: m }]; + (k = Math.ceil(m / S) - Math.floor(p / S)), + k > g && (S = B((k * S) / g / f) * f), + s(l) || ((v = Math.pow(10, l)), (S = Math.ceil(S * v) / v)), + "ticks" === n + ? ((M = Math.floor(p / S) * S), (w = Math.ceil(m / S) * S)) + : ((M = p), (w = m)), + x && b && o && H((r - a) / o, S / 1e3) + ? ((k = Math.round(Math.min((r - a) / S, c))), + (S = (r - a) / k), + (M = a), + (w = r)) + : _ + ? ((M = x ? a : M), (w = b ? r : w), (k = h - 1), (S = (w - M) / k)) + : ((k = (w - M) / S), + (k = V(k, Math.round(k), S / 1e3) + ? Math.round(k) + : Math.ceil(k))); + const P = Math.max(U(S), U(M)); + (v = Math.pow(10, s(l) ? P : l)), + (M = Math.round(M * v) / v), + (w = Math.round(w * v) / v); + let D = 0; + for ( + x && + (u && M !== a + ? (i.push({ value: a }), + M < a && D++, + V(Math.round((M + D * S) * v) / v, a, mo(a, y, t)) && D++) + : M < a && D++); + D < k; + ++D + ) { + const t = Math.round((M + D * S) * v) / v; + if (b && t > r) break; + i.push({ value: t }); + } + return ( + b && u && w !== r + ? i.length && V(i[i.length - 1].value, r, mo(r, y, t)) + ? (i[i.length - 1].value = r) + : i.push({ value: r }) + : (b && w !== r) || i.push({ value: w }), + i + ); + })( + { + maxTicks: i, + bounds: t.bounds, + min: t.min, + max: t.max, + precision: e.precision, + step: e.stepSize, + count: e.count, + maxDigits: this._maxDigits(), + horizontal: this.isHorizontal(), + minRotation: e.minRotation || 0, + includeBounds: !1 !== e.includeBounds, + }, + this._range || this + ); + return ( + "ticks" === t.bounds && j(n, this, "value"), + t.reverse + ? (n.reverse(), (this.start = this.max), (this.end = this.min)) + : ((this.start = this.min), (this.end = this.max)), + n + ); + } + configure() { + const t = this.ticks; + let e = this.min, + i = this.max; + if ((super.configure(), this.options.offset && t.length)) { + const s = (i - e) / Math.max(t.length - 1, 1) / 2; + (e -= s), (i += s); + } + (this._startValue = e), (this._endValue = i), (this._valueRange = i - e); + } + getLabelForValue(t) { + return ne(t, this.chart.options.locale, this.options.ticks.format); + } + } + class bo extends xo { + static id = "linear"; + static defaults = { ticks: { callback: ae.formatters.numeric } }; + determineDataLimits() { + const { min: t, max: e } = this.getMinMax(!0); + (this.min = a(t) ? t : 0), + (this.max = a(e) ? e : 1), + this.handleTickRangeOptions(); + } + computeTickLimit() { + const t = this.isHorizontal(), + e = t ? this.width : this.height, + i = $(this.options.ticks.minRotation), + s = (t ? Math.sin(i) : Math.cos(i)) || 0.001, + n = this._resolveTickFontOptions(0); + return Math.ceil(e / Math.min(40, n.lineHeight / s)); + } + getPixelForValue(t) { + return null === t + ? NaN + : this.getPixelForDecimal((t - this._startValue) / this._valueRange); + } + getValueForPixel(t) { + return this._startValue + this.getDecimalForPixel(t) * this._valueRange; + } + } + const _o = (t) => Math.floor(z(t)), + yo = (t, e) => Math.pow(10, _o(t) + e); + function vo(t) { + return 1 === t / Math.pow(10, _o(t)); + } + function Mo(t, e, i) { + const s = Math.pow(10, i), + n = Math.floor(t / s); + return Math.ceil(e / s) - n; + } + function wo(t, { min: e, max: i }) { + e = r(t.min, e); + const s = [], + n = _o(e); + let o = (function (t, e) { + let i = _o(e - t); + for (; Mo(t, e, i) > 10; ) i++; + for (; Mo(t, e, i) < 10; ) i--; + return Math.min(i, _o(t)); + })(e, i), + a = o < 0 ? Math.pow(10, Math.abs(o)) : 1; + const l = Math.pow(10, o), + h = n > o ? Math.pow(10, n) : 0, + c = Math.round((e - h) * a) / a, + d = Math.floor((e - h) / l / 10) * l * 10; + let u = Math.floor((c - d) / Math.pow(10, o)), + f = r(t.min, Math.round((h + d + u * Math.pow(10, o)) * a) / a); + for (; f < i; ) + s.push({ value: f, major: vo(f), significand: u }), + u >= 10 ? (u = u < 15 ? 15 : 20) : u++, + u >= 20 && (o++, (u = 2), (a = o >= 0 ? 1 : a)), + (f = Math.round((h + d + u * Math.pow(10, o)) * a) / a); + const g = r(t.max, f); + return s.push({ value: g, major: vo(g), significand: u }), s; + } + class ko extends Js { + static id = "logarithmic"; + static defaults = { + ticks: { callback: ae.formatters.logarithmic, major: { enabled: !0 } }, + }; + constructor(t) { + super(t), + (this.start = void 0), + (this.end = void 0), + (this._startValue = void 0), + (this._valueRange = 0); + } + parse(t, e) { + const i = xo.prototype.parse.apply(this, [t, e]); + if (0 !== i) return a(i) && i > 0 ? i : null; + this._zero = !0; + } + determineDataLimits() { + const { min: t, max: e } = this.getMinMax(!0); + (this.min = a(t) ? Math.max(0, t) : null), + (this.max = a(e) ? Math.max(0, e) : null), + this.options.beginAtZero && (this._zero = !0), + this._zero && + this.min !== this._suggestedMin && + !a(this._userMin) && + (this.min = + t === yo(this.min, 0) ? yo(this.min, -1) : yo(this.min, 0)), + this.handleTickRangeOptions(); + } + handleTickRangeOptions() { + const { minDefined: t, maxDefined: e } = this.getUserBounds(); + let i = this.min, + s = this.max; + const n = (e) => (i = t ? i : e), + o = (t) => (s = e ? s : t); + i === s && (i <= 0 ? (n(1), o(10)) : (n(yo(i, -1)), o(yo(s, 1)))), + i <= 0 && n(yo(s, -1)), + s <= 0 && o(yo(i, 1)), + (this.min = i), + (this.max = s); + } + buildTicks() { + const t = this.options, + e = wo({ min: this._userMin, max: this._userMax }, this); + return ( + "ticks" === t.bounds && j(e, this, "value"), + t.reverse + ? (e.reverse(), (this.start = this.max), (this.end = this.min)) + : ((this.start = this.min), (this.end = this.max)), + e + ); + } + getLabelForValue(t) { + return void 0 === t + ? "0" + : ne(t, this.chart.options.locale, this.options.ticks.format); + } + configure() { + const t = this.min; + super.configure(), + (this._startValue = z(t)), + (this._valueRange = z(this.max) - z(t)); + } + getPixelForValue(t) { + return ( + (void 0 !== t && 0 !== t) || (t = this.min), + null === t || isNaN(t) + ? NaN + : this.getPixelForDecimal( + t === this.min ? 0 : (z(t) - this._startValue) / this._valueRange + ) + ); + } + getValueForPixel(t) { + const e = this.getDecimalForPixel(t); + return Math.pow(10, this._startValue + e * this._valueRange); + } + } + function So(t) { + const e = t.ticks; + if (e.display && t.display) { + const t = ki(e.backdropPadding); + return l(e.font && e.font.size, ue.font.size) + t.height; + } + return 0; + } + function Po(t, e, i, s, n) { + return t === s || t === n + ? { start: e - i / 2, end: e + i / 2 } + : t < s || t > n + ? { start: e - i, end: e } + : { start: e, end: e + i }; + } + function Do(t) { + const e = { + l: t.left + t._padding.left, + r: t.right - t._padding.right, + t: t.top + t._padding.top, + b: t.bottom - t._padding.bottom, + }, + i = Object.assign({}, e), + s = [], + o = [], + a = t._pointLabels.length, + r = t.options.pointLabels, + l = r.centerPointLabels ? C / a : 0; + for (let u = 0; u < a; u++) { + const a = r.setContext(t.getPointLabelContext(u)); + o[u] = a.padding; + const f = t.getPointPosition(u, t.drawingArea + o[u], l), + g = Si(a.font), + p = + ((h = t.ctx), + (c = g), + (d = n((d = t._pointLabels[u])) ? d : [d]), + { w: Oe(h, c.string, d), h: d.length * c.lineHeight }); + s[u] = p; + const m = G(t.getIndexAngle(u) + l), + x = Math.round(Y(m)); + Co(i, e, m, Po(x, f.x, p.w, 0, 180), Po(x, f.y, p.h, 90, 270)); + } + var h, c, d; + t.setCenterPoint(e.l - i.l, i.r - e.r, e.t - i.t, i.b - e.b), + (t._pointLabelItems = (function (t, e, i) { + const s = [], + n = t._pointLabels.length, + o = t.options, + { centerPointLabels: a, display: r } = o.pointLabels, + l = { extra: So(o) / 2, additionalAngle: a ? C / n : 0 }; + let h; + for (let o = 0; o < n; o++) { + (l.padding = i[o]), (l.size = e[o]); + const n = Oo(t, o, l); + s.push(n), + "auto" === r && ((n.visible = Ao(n, h)), n.visible && (h = n)); + } + return s; + })(t, s, o)); + } + function Co(t, e, i, s, n) { + const o = Math.abs(Math.sin(i)), + a = Math.abs(Math.cos(i)); + let r = 0, + l = 0; + s.start < e.l + ? ((r = (e.l - s.start) / o), (t.l = Math.min(t.l, e.l - r))) + : s.end > e.r && + ((r = (s.end - e.r) / o), (t.r = Math.max(t.r, e.r + r))), + n.start < e.t + ? ((l = (e.t - n.start) / a), (t.t = Math.min(t.t, e.t - l))) + : n.end > e.b && + ((l = (n.end - e.b) / a), (t.b = Math.max(t.b, e.b + l))); + } + function Oo(t, e, i) { + const s = t.drawingArea, + { extra: n, additionalAngle: o, padding: a, size: r } = i, + l = t.getPointPosition(e, s + n + a, o), + h = Math.round(Y(G(l.angle + E))), + c = (function (t, e, i) { + 90 === i || 270 === i ? (t -= e / 2) : (i > 270 || i < 90) && (t -= e); + return t; + })(l.y, r.h, h), + d = (function (t) { + if (0 === t || 180 === t) return "center"; + if (t < 180) return "left"; + return "right"; + })(h), + u = (function (t, e, i) { + "right" === i ? (t -= e) : "center" === i && (t -= e / 2); + return t; + })(l.x, r.w, d); + return { + visible: !0, + x: l.x, + y: c, + textAlign: d, + left: u, + top: c, + right: u + r.w, + bottom: c + r.h, + }; + } + function Ao(t, e) { + if (!e) return !0; + const { left: i, top: s, right: n, bottom: o } = t; + return !( + Re({ x: i, y: s }, e) || + Re({ x: i, y: o }, e) || + Re({ x: n, y: s }, e) || + Re({ x: n, y: o }, e) + ); + } + function To(t, e, i) { + const { left: n, top: o, right: a, bottom: r } = i, + { backdropColor: l } = e; + if (!s(l)) { + const i = wi(e.borderRadius), + s = ki(e.backdropPadding); + t.fillStyle = l; + const h = n - s.left, + c = o - s.top, + d = a - n + s.width, + u = r - o + s.height; + Object.values(i).some((t) => 0 !== t) + ? (t.beginPath(), + He(t, { x: h, y: c, w: d, h: u, radius: i }), + t.fill()) + : t.fillRect(h, c, d, u); + } + } + function Lo(t, e, i, s) { + const { ctx: n } = t; + if (i) n.arc(t.xCenter, t.yCenter, e, 0, O); + else { + let i = t.getPointPosition(0, e); + n.moveTo(i.x, i.y); + for (let o = 1; o < s; o++) + (i = t.getPointPosition(o, e)), n.lineTo(i.x, i.y); + } + } + class Eo extends xo { + static id = "radialLinear"; + static defaults = { + display: !0, + animate: !0, + position: "chartArea", + angleLines: { + display: !0, + lineWidth: 1, + borderDash: [], + borderDashOffset: 0, + }, + grid: { circular: !1 }, + startAngle: 0, + ticks: { showLabelBackdrop: !0, callback: ae.formatters.numeric }, + pointLabels: { + backdropColor: void 0, + backdropPadding: 2, + display: !0, + font: { size: 10 }, + callback: (t) => t, + padding: 5, + centerPointLabels: !1, + }, + }; + static defaultRoutes = { + "angleLines.color": "borderColor", + "pointLabels.color": "color", + "ticks.color": "color", + }; + static descriptors = { angleLines: { _fallback: "grid" } }; + constructor(t) { + super(t), + (this.xCenter = void 0), + (this.yCenter = void 0), + (this.drawingArea = void 0), + (this._pointLabels = []), + (this._pointLabelItems = []); + } + setDimensions() { + const t = (this._padding = ki(So(this.options) / 2)), + e = (this.width = this.maxWidth - t.width), + i = (this.height = this.maxHeight - t.height); + (this.xCenter = Math.floor(this.left + e / 2 + t.left)), + (this.yCenter = Math.floor(this.top + i / 2 + t.top)), + (this.drawingArea = Math.floor(Math.min(e, i) / 2)); + } + determineDataLimits() { + const { min: t, max: e } = this.getMinMax(!1); + (this.min = a(t) && !isNaN(t) ? t : 0), + (this.max = a(e) && !isNaN(e) ? e : 0), + this.handleTickRangeOptions(); + } + computeTickLimit() { + return Math.ceil(this.drawingArea / So(this.options)); + } + generateTickLabels(t) { + xo.prototype.generateTickLabels.call(this, t), + (this._pointLabels = this.getLabels() + .map((t, e) => { + const i = d(this.options.pointLabels.callback, [t, e], this); + return i || 0 === i ? i : ""; + }) + .filter((t, e) => this.chart.getDataVisibility(e))); + } + fit() { + const t = this.options; + t.display && t.pointLabels.display + ? Do(this) + : this.setCenterPoint(0, 0, 0, 0); + } + setCenterPoint(t, e, i, s) { + (this.xCenter += Math.floor((t - e) / 2)), + (this.yCenter += Math.floor((i - s) / 2)), + (this.drawingArea -= Math.min( + this.drawingArea / 2, + Math.max(t, e, i, s) + )); + } + getIndexAngle(t) { + return G( + t * (O / (this._pointLabels.length || 1)) + + $(this.options.startAngle || 0) + ); + } + getDistanceFromCenterForValue(t) { + if (s(t)) return NaN; + const e = this.drawingArea / (this.max - this.min); + return this.options.reverse ? (this.max - t) * e : (t - this.min) * e; + } + getValueForDistanceFromCenter(t) { + if (s(t)) return NaN; + const e = t / (this.drawingArea / (this.max - this.min)); + return this.options.reverse ? this.max - e : this.min + e; + } + getPointLabelContext(t) { + const e = this._pointLabels || []; + if (t >= 0 && t < e.length) { + const i = e[t]; + return (function (t, e, i) { + return Ci(t, { label: i, index: e, type: "pointLabel" }); + })(this.getContext(), t, i); + } + } + getPointPosition(t, e, i = 0) { + const s = this.getIndexAngle(t) - E + i; + return { + x: Math.cos(s) * e + this.xCenter, + y: Math.sin(s) * e + this.yCenter, + angle: s, + }; + } + getPointPositionForValue(t, e) { + return this.getPointPosition(t, this.getDistanceFromCenterForValue(e)); + } + getBasePosition(t) { + return this.getPointPositionForValue(t || 0, this.getBaseValue()); + } + getPointLabelPosition(t) { + const { left: e, top: i, right: s, bottom: n } = this._pointLabelItems[t]; + return { left: e, top: i, right: s, bottom: n }; + } + drawBackground() { + const { + backgroundColor: t, + grid: { circular: e }, + } = this.options; + if (t) { + const i = this.ctx; + i.save(), + i.beginPath(), + Lo( + this, + this.getDistanceFromCenterForValue(this._endValue), + e, + this._pointLabels.length + ), + i.closePath(), + (i.fillStyle = t), + i.fill(), + i.restore(); + } + } + drawGrid() { + const t = this.ctx, + e = this.options, + { angleLines: i, grid: s, border: n } = e, + o = this._pointLabels.length; + let a, r, l; + if ( + (e.pointLabels.display && + (function (t, e) { + const { + ctx: i, + options: { pointLabels: s }, + } = t; + for (let n = e - 1; n >= 0; n--) { + const e = t._pointLabelItems[n]; + if (!e.visible) continue; + const o = s.setContext(t.getPointLabelContext(n)); + To(i, o, e); + const a = Si(o.font), + { x: r, y: l, textAlign: h } = e; + Ne(i, t._pointLabels[n], r, l + a.lineHeight / 2, a, { + color: o.color, + textAlign: h, + textBaseline: "middle", + }); + } + })(this, o), + s.display && + this.ticks.forEach((t, e) => { + if (0 !== e || (0 === e && this.min < 0)) { + r = this.getDistanceFromCenterForValue(t.value); + const i = this.getContext(e), + a = s.setContext(i), + l = n.setContext(i); + !(function (t, e, i, s, n) { + const o = t.ctx, + a = e.circular, + { color: r, lineWidth: l } = e; + (!a && !s) || + !r || + !l || + i < 0 || + (o.save(), + (o.strokeStyle = r), + (o.lineWidth = l), + o.setLineDash(n.dash || []), + (o.lineDashOffset = n.dashOffset), + o.beginPath(), + Lo(t, i, a, s), + o.closePath(), + o.stroke(), + o.restore()); + })(this, a, r, o, l); + } + }), + i.display) + ) { + for (t.save(), a = o - 1; a >= 0; a--) { + const s = i.setContext(this.getPointLabelContext(a)), + { color: n, lineWidth: o } = s; + o && + n && + ((t.lineWidth = o), + (t.strokeStyle = n), + t.setLineDash(s.borderDash), + (t.lineDashOffset = s.borderDashOffset), + (r = this.getDistanceFromCenterForValue( + e.reverse ? this.min : this.max + )), + (l = this.getPointPosition(a, r)), + t.beginPath(), + t.moveTo(this.xCenter, this.yCenter), + t.lineTo(l.x, l.y), + t.stroke()); + } + t.restore(); + } + } + drawBorder() {} + drawLabels() { + const t = this.ctx, + e = this.options, + i = e.ticks; + if (!i.display) return; + const s = this.getIndexAngle(0); + let n, o; + t.save(), + t.translate(this.xCenter, this.yCenter), + t.rotate(s), + (t.textAlign = "center"), + (t.textBaseline = "middle"), + this.ticks.forEach((s, a) => { + if (0 === a && this.min >= 0 && !e.reverse) return; + const r = i.setContext(this.getContext(a)), + l = Si(r.font); + if ( + ((n = this.getDistanceFromCenterForValue(this.ticks[a].value)), + r.showLabelBackdrop) + ) { + (t.font = l.string), + (o = t.measureText(s.label).width), + (t.fillStyle = r.backdropColor); + const e = ki(r.backdropPadding); + t.fillRect( + -o / 2 - e.left, + -n - l.size / 2 - e.top, + o + e.width, + l.size + e.height + ); + } + Ne(t, s.label, 0, -n, l, { + color: r.color, + strokeColor: r.textStrokeColor, + strokeWidth: r.textStrokeWidth, + }); + }), + t.restore(); + } + drawTitle() {} + } + const Ro = { + millisecond: { common: !0, size: 1, steps: 1e3 }, + second: { common: !0, size: 1e3, steps: 60 }, + minute: { common: !0, size: 6e4, steps: 60 }, + hour: { common: !0, size: 36e5, steps: 24 }, + day: { common: !0, size: 864e5, steps: 30 }, + week: { common: !1, size: 6048e5, steps: 4 }, + month: { common: !0, size: 2628e6, steps: 12 }, + quarter: { common: !1, size: 7884e6, steps: 4 }, + year: { common: !0, size: 3154e7 }, + }, + Io = Object.keys(Ro); + function zo(t, e) { + return t - e; + } + function Fo(t, e) { + if (s(e)) return null; + const i = t._adapter, + { parser: n, round: o, isoWeekday: r } = t._parseOpts; + let l = e; + return ( + "function" == typeof n && (l = n(l)), + a(l) || (l = "string" == typeof n ? i.parse(l, n) : i.parse(l)), + null === l + ? null + : (o && + (l = + "week" !== o || (!N(r) && !0 !== r) + ? i.startOf(l, o) + : i.startOf(l, "isoWeek", r)), + +l) + ); + } + function Vo(t, e, i, s) { + const n = Io.length; + for (let o = Io.indexOf(t); o < n - 1; ++o) { + const t = Ro[Io[o]], + n = t.steps ? t.steps : Number.MAX_SAFE_INTEGER; + if (t.common && Math.ceil((i - e) / (n * t.size)) <= s) return Io[o]; + } + return Io[n - 1]; + } + function Bo(t, e, i) { + if (i) { + if (i.length) { + const { lo: s, hi: n } = et(i, e); + t[i[s] >= e ? i[s] : i[n]] = !0; + } + } else t[e] = !0; + } + function Wo(t, e, i) { + const s = [], + n = {}, + o = e.length; + let a, r; + for (a = 0; a < o; ++a) + (r = e[a]), (n[r] = a), s.push({ value: r, major: !1 }); + return 0 !== o && i + ? (function (t, e, i, s) { + const n = t._adapter, + o = +n.startOf(e[0].value, s), + a = e[e.length - 1].value; + let r, l; + for (r = o; r <= a; r = +n.add(r, 1, s)) + (l = i[r]), l >= 0 && (e[l].major = !0); + return e; + })(t, s, n, i) + : s; + } + class No extends Js { + static id = "time"; + static defaults = { + bounds: "data", + adapters: {}, + time: { + parser: !1, + unit: !1, + round: !1, + isoWeekday: !1, + minUnit: "millisecond", + displayFormats: {}, + }, + ticks: { source: "auto", callback: !1, major: { enabled: !1 } }, + }; + constructor(t) { + super(t), + (this._cache = { data: [], labels: [], all: [] }), + (this._unit = "day"), + (this._majorUnit = void 0), + (this._offsets = {}), + (this._normalized = !1), + (this._parseOpts = void 0); + } + init(t, e = {}) { + const i = t.time || (t.time = {}), + s = (this._adapter = new Rn._date(t.adapters.date)); + s.init(e), + b(i.displayFormats, s.formats()), + (this._parseOpts = { + parser: i.parser, + round: i.round, + isoWeekday: i.isoWeekday, + }), + super.init(t), + (this._normalized = e.normalized); + } + parse(t, e) { + return void 0 === t ? null : Fo(this, t); + } + beforeLayout() { + super.beforeLayout(), (this._cache = { data: [], labels: [], all: [] }); + } + determineDataLimits() { + const t = this.options, + e = this._adapter, + i = t.time.unit || "day"; + let { + min: s, + max: n, + minDefined: o, + maxDefined: r, + } = this.getUserBounds(); + function l(t) { + o || isNaN(t.min) || (s = Math.min(s, t.min)), + r || isNaN(t.max) || (n = Math.max(n, t.max)); + } + (o && r) || + (l(this._getLabelBounds()), + ("ticks" === t.bounds && "labels" === t.ticks.source) || + l(this.getMinMax(!1))), + (s = a(s) && !isNaN(s) ? s : +e.startOf(Date.now(), i)), + (n = a(n) && !isNaN(n) ? n : +e.endOf(Date.now(), i) + 1), + (this.min = Math.min(s, n - 1)), + (this.max = Math.max(s + 1, n)); + } + _getLabelBounds() { + const t = this.getLabelTimestamps(); + let e = Number.POSITIVE_INFINITY, + i = Number.NEGATIVE_INFINITY; + return ( + t.length && ((e = t[0]), (i = t[t.length - 1])), { min: e, max: i } + ); + } + buildTicks() { + const t = this.options, + e = t.time, + i = t.ticks, + s = + "labels" === i.source ? this.getLabelTimestamps() : this._generate(); + "ticks" === t.bounds && + s.length && + ((this.min = this._userMin || s[0]), + (this.max = this._userMax || s[s.length - 1])); + const n = this.min, + o = nt(s, n, this.max); + return ( + (this._unit = + e.unit || + (i.autoSkip + ? Vo(e.minUnit, this.min, this.max, this._getLabelCapacity(n)) + : (function (t, e, i, s, n) { + for (let o = Io.length - 1; o >= Io.indexOf(i); o--) { + const i = Io[o]; + if (Ro[i].common && t._adapter.diff(n, s, i) >= e - 1) + return i; + } + return Io[i ? Io.indexOf(i) : 0]; + })(this, o.length, e.minUnit, this.min, this.max))), + (this._majorUnit = + i.major.enabled && "year" !== this._unit + ? (function (t) { + for (let e = Io.indexOf(t) + 1, i = Io.length; e < i; ++e) + if (Ro[Io[e]].common) return Io[e]; + })(this._unit) + : void 0), + this.initOffsets(s), + t.reverse && o.reverse(), + Wo(this, o, this._majorUnit) + ); + } + afterAutoSkip() { + this.options.offsetAfterAutoskip && + this.initOffsets(this.ticks.map((t) => +t.value)); + } + initOffsets(t = []) { + let e, + i, + s = 0, + n = 0; + this.options.offset && + t.length && + ((e = this.getDecimalForValue(t[0])), + (s = 1 === t.length ? 1 - e : (this.getDecimalForValue(t[1]) - e) / 2), + (i = this.getDecimalForValue(t[t.length - 1])), + (n = + 1 === t.length + ? i + : (i - this.getDecimalForValue(t[t.length - 2])) / 2)); + const o = t.length < 3 ? 0.5 : 0.25; + (s = J(s, 0, o)), + (n = J(n, 0, o)), + (this._offsets = { start: s, end: n, factor: 1 / (s + 1 + n) }); + } + _generate() { + const t = this._adapter, + e = this.min, + i = this.max, + s = this.options, + n = s.time, + o = n.unit || Vo(n.minUnit, e, i, this._getLabelCapacity(e)), + a = l(s.ticks.stepSize, 1), + r = "week" === o && n.isoWeekday, + h = N(r) || !0 === r, + c = {}; + let d, + u, + f = e; + if ( + (h && (f = +t.startOf(f, "isoWeek", r)), + (f = +t.startOf(f, h ? "day" : o)), + t.diff(i, e, o) > 1e5 * a) + ) + throw new Error( + e + " and " + i + " are too far apart with stepSize of " + a + " " + o + ); + const g = "data" === s.ticks.source && this.getDataTimestamps(); + for (d = f, u = 0; d < i; d = +t.add(d, a, o), u++) Bo(c, d, g); + return ( + (d !== i && "ticks" !== s.bounds && 1 !== u) || Bo(c, d, g), + Object.keys(c) + .sort(zo) + .map((t) => +t) + ); + } + getLabelForValue(t) { + const e = this._adapter, + i = this.options.time; + return i.tooltipFormat + ? e.format(t, i.tooltipFormat) + : e.format(t, i.displayFormats.datetime); + } + format(t, e) { + const i = this.options.time.displayFormats, + s = this._unit, + n = e || i[s]; + return this._adapter.format(t, n); + } + _tickFormatFunction(t, e, i, s) { + const n = this.options, + o = n.ticks.callback; + if (o) return d(o, [t, e, i], this); + const a = n.time.displayFormats, + r = this._unit, + l = this._majorUnit, + h = r && a[r], + c = l && a[l], + u = i[e], + f = l && c && u && u.major; + return this._adapter.format(t, s || (f ? c : h)); + } + generateTickLabels(t) { + let e, i, s; + for (e = 0, i = t.length; e < i; ++e) + (s = t[e]), (s.label = this._tickFormatFunction(s.value, e, t)); + } + getDecimalForValue(t) { + return null === t ? NaN : (t - this.min) / (this.max - this.min); + } + getPixelForValue(t) { + const e = this._offsets, + i = this.getDecimalForValue(t); + return this.getPixelForDecimal((e.start + i) * e.factor); + } + getValueForPixel(t) { + const e = this._offsets, + i = this.getDecimalForPixel(t) / e.factor - e.end; + return this.min + i * (this.max - this.min); + } + _getLabelSize(t) { + const e = this.options.ticks, + i = this.ctx.measureText(t).width, + s = $(this.isHorizontal() ? e.maxRotation : e.minRotation), + n = Math.cos(s), + o = Math.sin(s), + a = this._resolveTickFontOptions(0).size; + return { w: i * n + a * o, h: i * o + a * n }; + } + _getLabelCapacity(t) { + const e = this.options.time, + i = e.displayFormats, + s = i[e.unit] || i.millisecond, + n = this._tickFormatFunction(t, 0, Wo(this, [t], this._majorUnit), s), + o = this._getLabelSize(n), + a = + Math.floor( + this.isHorizontal() ? this.width / o.w : this.height / o.h + ) - 1; + return a > 0 ? a : 1; + } + getDataTimestamps() { + let t, + e, + i = this._cache.data || []; + if (i.length) return i; + const s = this.getMatchingVisibleMetas(); + if (this._normalized && s.length) + return (this._cache.data = s[0].controller.getAllParsedValues(this)); + for (t = 0, e = s.length; t < e; ++t) + i = i.concat(s[t].controller.getAllParsedValues(this)); + return (this._cache.data = this.normalize(i)); + } + getLabelTimestamps() { + const t = this._cache.labels || []; + let e, i; + if (t.length) return t; + const s = this.getLabels(); + for (e = 0, i = s.length; e < i; ++e) t.push(Fo(this, s[e])); + return (this._cache.labels = this._normalized ? t : this.normalize(t)); + } + normalize(t) { + return lt(t.sort(zo)); + } + } + function Ho(t, e, i) { + let s, + n, + o, + a, + r = 0, + l = t.length - 1; + i + ? (e >= t[r].pos && e <= t[l].pos && ({ lo: r, hi: l } = it(t, "pos", e)), + ({ pos: s, time: o } = t[r]), + ({ pos: n, time: a } = t[l])) + : (e >= t[r].time && + e <= t[l].time && + ({ lo: r, hi: l } = it(t, "time", e)), + ({ time: s, pos: o } = t[r]), + ({ time: n, pos: a } = t[l])); + const h = n - s; + return h ? o + ((a - o) * (e - s)) / h : o; + } + var jo = Object.freeze({ + __proto__: null, + CategoryScale: class extends Js { + static id = "category"; + static defaults = { ticks: { callback: po } }; + constructor(t) { + super(t), + (this._startValue = void 0), + (this._valueRange = 0), + (this._addedLabels = []); + } + init(t) { + const e = this._addedLabels; + if (e.length) { + const t = this.getLabels(); + for (const { index: i, label: s } of e) t[i] === s && t.splice(i, 1); + this._addedLabels = []; + } + super.init(t); + } + parse(t, e) { + if (s(t)) return null; + const i = this.getLabels(); + return ((t, e) => (null === t ? null : J(Math.round(t), 0, e)))( + (e = + isFinite(e) && i[e] === t + ? e + : go(i, t, l(e, t), this._addedLabels)), + i.length - 1 + ); + } + determineDataLimits() { + const { minDefined: t, maxDefined: e } = this.getUserBounds(); + let { min: i, max: s } = this.getMinMax(!0); + "ticks" === this.options.bounds && + (t || (i = 0), e || (s = this.getLabels().length - 1)), + (this.min = i), + (this.max = s); + } + buildTicks() { + const t = this.min, + e = this.max, + i = this.options.offset, + s = []; + let n = this.getLabels(); + (n = 0 === t && e === n.length - 1 ? n : n.slice(t, e + 1)), + (this._valueRange = Math.max(n.length - (i ? 0 : 1), 1)), + (this._startValue = this.min - (i ? 0.5 : 0)); + for (let i = t; i <= e; i++) s.push({ value: i }); + return s; + } + getLabelForValue(t) { + return po.call(this, t); + } + configure() { + super.configure(), + this.isHorizontal() || (this._reversePixels = !this._reversePixels); + } + getPixelForValue(t) { + return ( + "number" != typeof t && (t = this.parse(t)), + null === t + ? NaN + : this.getPixelForDecimal((t - this._startValue) / this._valueRange) + ); + } + getPixelForTick(t) { + const e = this.ticks; + return t < 0 || t > e.length - 1 + ? null + : this.getPixelForValue(e[t].value); + } + getValueForPixel(t) { + return Math.round( + this._startValue + this.getDecimalForPixel(t) * this._valueRange + ); + } + getBasePixel() { + return this.bottom; + } + }, + LinearScale: bo, + LogarithmicScale: ko, + RadialLinearScale: Eo, + TimeScale: No, + TimeSeriesScale: class extends No { + static id = "timeseries"; + static defaults = No.defaults; + constructor(t) { + super(t), + (this._table = []), + (this._minPos = void 0), + (this._tableRange = void 0); + } + initOffsets() { + const t = this._getTimestampsForTable(), + e = (this._table = this.buildLookupTable(t)); + (this._minPos = Ho(e, this.min)), + (this._tableRange = Ho(e, this.max) - this._minPos), + super.initOffsets(t); + } + buildLookupTable(t) { + const { min: e, max: i } = this, + s = [], + n = []; + let o, a, r, l, h; + for (o = 0, a = t.length; o < a; ++o) + (l = t[o]), l >= e && l <= i && s.push(l); + if (s.length < 2) + return [ + { time: e, pos: 0 }, + { time: i, pos: 1 }, + ]; + for (o = 0, a = s.length; o < a; ++o) + (h = s[o + 1]), + (r = s[o - 1]), + (l = s[o]), + Math.round((h + r) / 2) !== l && + n.push({ time: l, pos: o / (a - 1) }); + return n; + } + _generate() { + const t = this.min, + e = this.max; + let i = super.getDataTimestamps(); + return ( + (i.includes(t) && i.length) || i.splice(0, 0, t), + (i.includes(e) && 1 !== i.length) || i.push(e), + i.sort((t, e) => t - e) + ); + } + _getTimestampsForTable() { + let t = this._cache.all || []; + if (t.length) return t; + const e = this.getDataTimestamps(), + i = this.getLabelTimestamps(); + return ( + (t = + e.length && i.length + ? this.normalize(e.concat(i)) + : e.length + ? e + : i), + (t = this._cache.all = t), + t + ); + } + getDecimalForValue(t) { + return (Ho(this._table, t) - this._minPos) / this._tableRange; + } + getValueForPixel(t) { + const e = this._offsets, + i = this.getDecimalForPixel(t) / e.factor - e.end; + return Ho(this._table, i * this._tableRange + this._minPos, !0); + } + }, + }); + const $o = [ + "rgb(54, 162, 235)", + "rgb(255, 99, 132)", + "rgb(255, 159, 64)", + "rgb(255, 205, 86)", + "rgb(75, 192, 192)", + "rgb(153, 102, 255)", + "rgb(201, 203, 207)", + ], + Yo = $o.map((t) => t.replace("rgb(", "rgba(").replace(")", ", 0.5)")); + function Uo(t) { + return $o[t % $o.length]; + } + function Xo(t) { + return Yo[t % Yo.length]; + } + function qo(t) { + let e = 0; + return (i, s) => { + const n = t.getDatasetMeta(s).controller; + n instanceof jn + ? (e = (function (t, e) { + return (t.backgroundColor = t.data.map(() => Uo(e++))), e; + })(i, e)) + : n instanceof $n + ? (e = (function (t, e) { + return (t.backgroundColor = t.data.map(() => Xo(e++))), e; + })(i, e)) + : n && + (e = (function (t, e) { + return (t.borderColor = Uo(e)), (t.backgroundColor = Xo(e)), ++e; + })(i, e)); + }; + } + function Ko(t) { + let e; + for (e in t) if (t[e].borderColor || t[e].backgroundColor) return !0; + return !1; + } + var Go = { + id: "colors", + defaults: { enabled: !0, forceOverride: !1 }, + beforeLayout(t, e, i) { + if (!i.enabled) return; + const { + data: { datasets: s }, + options: n, + } = t.config, + { elements: o } = n, + a = + Ko(s) || + ((r = n) && (r.borderColor || r.backgroundColor)) || + (o && Ko(o)) || + "rgba(0,0,0,0.1)" !== ue.borderColor || + "rgba(0,0,0,0.1)" !== ue.backgroundColor; + var r; + if (!i.forceOverride && a) return; + const l = qo(t); + s.forEach(l); + }, + }; + function Zo(t) { + if (t._decimated) { + const e = t._data; + delete t._decimated, + delete t._data, + Object.defineProperty(t, "data", { + configurable: !0, + enumerable: !0, + writable: !0, + value: e, + }); + } + } + function Jo(t) { + t.data.datasets.forEach((t) => { + Zo(t); + }); + } + var Qo = { + id: "decimation", + defaults: { algorithm: "min-max", enabled: !1 }, + beforeElementsUpdate: (t, e, i) => { + if (!i.enabled) return void Jo(t); + const n = t.width; + t.data.datasets.forEach((e, o) => { + const { _data: a, indexAxis: r } = e, + l = t.getDatasetMeta(o), + h = a || e.data; + if ("y" === Pi([r, t.options.indexAxis])) return; + if (!l.controller.supportsDecimation) return; + const c = t.scales[l.xAxisID]; + if ("linear" !== c.type && "time" !== c.type) return; + if (t.options.parsing) return; + let { start: d, count: u } = (function (t, e) { + const i = e.length; + let s, + n = 0; + const { iScale: o } = t, + { + min: a, + max: r, + minDefined: l, + maxDefined: h, + } = o.getUserBounds(); + return ( + l && (n = J(it(e, o.axis, a).lo, 0, i - 1)), + (s = h ? J(it(e, o.axis, r).hi + 1, n, i) - n : i - n), + { start: n, count: s } + ); + })(l, h); + if (u <= (i.threshold || 4 * n)) return void Zo(e); + let f; + switch ( + (s(a) && + ((e._data = h), + delete e.data, + Object.defineProperty(e, "data", { + configurable: !0, + enumerable: !0, + get: function () { + return this._decimated; + }, + set: function (t) { + this._data = t; + }, + })), + i.algorithm) + ) { + case "lttb": + f = (function (t, e, i, s, n) { + const o = n.samples || s; + if (o >= i) return t.slice(e, e + i); + const a = [], + r = (i - 2) / (o - 2); + let l = 0; + const h = e + i - 1; + let c, + d, + u, + f, + g, + p = e; + for (a[l++] = t[p], c = 0; c < o - 2; c++) { + let s, + n = 0, + o = 0; + const h = Math.floor((c + 1) * r) + 1 + e, + m = Math.min(Math.floor((c + 2) * r) + 1, i) + e, + x = m - h; + for (s = h; s < m; s++) (n += t[s].x), (o += t[s].y); + (n /= x), (o /= x); + const b = Math.floor(c * r) + 1 + e, + _ = Math.min(Math.floor((c + 1) * r) + 1, i) + e, + { x: y, y: v } = t[p]; + for (u = f = -1, s = b; s < _; s++) + (f = + 0.5 * + Math.abs((y - n) * (t[s].y - v) - (y - t[s].x) * (o - v))), + f > u && ((u = f), (d = t[s]), (g = s)); + (a[l++] = d), (p = g); + } + return (a[l++] = t[h]), a; + })(h, d, u, n, i); + break; + case "min-max": + f = (function (t, e, i, n) { + let o, + a, + r, + l, + h, + c, + d, + u, + f, + g, + p = 0, + m = 0; + const x = [], + b = e + i - 1, + _ = t[e].x, + y = t[b].x - _; + for (o = e; o < e + i; ++o) { + (a = t[o]), (r = ((a.x - _) / y) * n), (l = a.y); + const e = 0 | r; + if (e === h) + l < f ? ((f = l), (c = o)) : l > g && ((g = l), (d = o)), + (p = (m * p + a.x) / ++m); + else { + const i = o - 1; + if (!s(c) && !s(d)) { + const e = Math.min(c, d), + s = Math.max(c, d); + e !== u && e !== i && x.push({ ...t[e], x: p }), + s !== u && s !== i && x.push({ ...t[s], x: p }); + } + o > 0 && i !== u && x.push(t[i]), + x.push(a), + (h = e), + (m = 0), + (f = g = l), + (c = d = u = o); + } + } + return x; + })(h, d, u, n); + break; + default: + throw new Error( + `Unsupported decimation algorithm '${i.algorithm}'` + ); + } + e._decimated = f; + }); + }, + destroy(t) { + Jo(t); + }, + }; + function ta(t, e, i, s) { + if (s) return; + let n = e[t], + o = i[t]; + return ( + "angle" === t && ((n = G(n)), (o = G(o))), + { property: t, start: n, end: o } + ); + } + function ea(t, e, i) { + for (; e > t; e--) { + const t = i[e]; + if (!isNaN(t.x) && !isNaN(t.y)) break; + } + return e; + } + function ia(t, e, i, s) { + return t && e ? s(t[i], e[i]) : t ? t[i] : e ? e[i] : 0; + } + function sa(t, e) { + let i = [], + s = !1; + return ( + n(t) + ? ((s = !0), (i = t)) + : (i = (function (t, e) { + const { x: i = null, y: s = null } = t || {}, + n = e.points, + o = []; + return ( + e.segments.forEach(({ start: t, end: e }) => { + e = ea(t, e, n); + const a = n[t], + r = n[e]; + null !== s + ? (o.push({ x: a.x, y: s }), o.push({ x: r.x, y: s })) + : null !== i && + (o.push({ x: i, y: a.y }), o.push({ x: i, y: r.y })); + }), + o + ); + })(t, e)), + i.length + ? new no({ points: i, options: { tension: 0 }, _loop: s, _fullLoop: s }) + : null + ); + } + function na(t) { + return t && !1 !== t.fill; + } + function oa(t, e, i) { + let s = t[e].fill; + const n = [e]; + let o; + if (!i) return s; + for (; !1 !== s && -1 === n.indexOf(s); ) { + if (!a(s)) return s; + if (((o = t[s]), !o)) return !1; + if (o.visible) return s; + n.push(s), (s = o.fill); + } + return !1; + } + function aa(t, e, i) { + const s = (function (t) { + const e = t.options, + i = e.fill; + let s = l(i && i.target, i); + void 0 === s && (s = !!e.backgroundColor); + if (!1 === s || null === s) return !1; + if (!0 === s) return "origin"; + return s; + })(t); + if (o(s)) return !isNaN(s.value) && s; + let n = parseFloat(s); + return a(n) && Math.floor(n) === n + ? (function (t, e, i, s) { + ("-" !== t && "+" !== t) || (i = e + i); + if (i === e || i < 0 || i >= s) return !1; + return i; + })(s[0], e, n, i) + : ["origin", "start", "end", "stack", "shape"].indexOf(s) >= 0 && s; + } + function ra(t, e, i) { + const s = []; + for (let n = 0; n < i.length; n++) { + const o = i[n], + { first: a, last: r, point: l } = la(o, e, "x"); + if (!(!l || (a && r))) + if (a) s.unshift(l); + else if ((t.push(l), !r)) break; + } + t.push(...s); + } + function la(t, e, i) { + const s = t.interpolate(e, i); + if (!s) return {}; + const n = s[i], + o = t.segments, + a = t.points; + let r = !1, + l = !1; + for (let t = 0; t < o.length; t++) { + const e = o[t], + s = a[e.start][i], + h = a[e.end][i]; + if (tt(n, s, h)) { + (r = n === s), (l = n === h); + break; + } + } + return { first: r, last: l, point: s }; + } + class ha { + constructor(t) { + (this.x = t.x), (this.y = t.y), (this.radius = t.radius); + } + pathSegment(t, e, i) { + const { x: s, y: n, radius: o } = this; + return ( + (e = e || { start: 0, end: O }), + t.arc(s, n, o, e.end, e.start, !0), + !i.bounds + ); + } + interpolate(t) { + const { x: e, y: i, radius: s } = this, + n = t.angle; + return { x: e + Math.cos(n) * s, y: i + Math.sin(n) * s, angle: n }; + } + } + function ca(t) { + const { chart: e, fill: i, line: s } = t; + if (a(i)) + return (function (t, e) { + const i = t.getDatasetMeta(e), + s = i && t.isDatasetVisible(e); + return s ? i.dataset : null; + })(e, i); + if ("stack" === i) + return (function (t) { + const { scale: e, index: i, line: s } = t, + n = [], + o = s.segments, + a = s.points, + r = (function (t, e) { + const i = [], + s = t.getMatchingVisibleMetas("line"); + for (let t = 0; t < s.length; t++) { + const n = s[t]; + if (n.index === e) break; + n.hidden || i.unshift(n.dataset); + } + return i; + })(e, i); + r.push(sa({ x: null, y: e.bottom }, s)); + for (let t = 0; t < o.length; t++) { + const e = o[t]; + for (let t = e.start; t <= e.end; t++) ra(n, a[t], r); + } + return new no({ points: n, options: {} }); + })(t); + if ("shape" === i) return !0; + const n = (function (t) { + const e = t.scale || {}; + if (e.getPointPositionForValue) + return (function (t) { + const { scale: e, fill: i } = t, + s = e.options, + n = e.getLabels().length, + a = s.reverse ? e.max : e.min, + r = (function (t, e, i) { + let s; + return ( + (s = + "start" === t + ? i + : "end" === t + ? e.options.reverse + ? e.min + : e.max + : o(t) + ? t.value + : e.getBaseValue()), + s + ); + })(i, e, a), + l = []; + if (s.grid.circular) { + const t = e.getPointPositionForValue(0, a); + return new ha({ + x: t.x, + y: t.y, + radius: e.getDistanceFromCenterForValue(r), + }); + } + for (let t = 0; t < n; ++t) l.push(e.getPointPositionForValue(t, r)); + return l; + })(t); + return (function (t) { + const { scale: e = {}, fill: i } = t, + s = (function (t, e) { + let i = null; + return ( + "start" === t + ? (i = e.bottom) + : "end" === t + ? (i = e.top) + : o(t) + ? (i = e.getPixelForValue(t.value)) + : e.getBasePixel && (i = e.getBasePixel()), + i + ); + })(i, e); + if (a(s)) { + const t = e.isHorizontal(); + return { x: t ? s : null, y: t ? null : s }; + } + return null; + })(t); + })(t); + return n instanceof ha ? n : sa(n, s); + } + function da(t, e, i) { + const s = ca(e), + { line: n, scale: o, axis: a } = e, + r = n.options, + l = r.fill, + h = r.backgroundColor, + { above: c = h, below: d = h } = l || {}; + s && + n.points.length && + (Ie(t, i), + (function (t, e) { + const { line: i, target: s, above: n, below: o, area: a, scale: r } = e, + l = i._loop ? "angle" : e.axis; + t.save(), + "x" === l && + o !== n && + (ua(t, s, a.top), + fa(t, { line: i, target: s, color: n, scale: r, property: l }), + t.restore(), + t.save(), + ua(t, s, a.bottom)); + fa(t, { line: i, target: s, color: o, scale: r, property: l }), + t.restore(); + })(t, { + line: n, + target: s, + above: c, + below: d, + area: i, + scale: o, + axis: a, + }), + ze(t)); + } + function ua(t, e, i) { + const { segments: s, points: n } = e; + let o = !0, + a = !1; + t.beginPath(); + for (const r of s) { + const { start: s, end: l } = r, + h = n[s], + c = n[ea(s, l, n)]; + o + ? (t.moveTo(h.x, h.y), (o = !1)) + : (t.lineTo(h.x, i), t.lineTo(h.x, h.y)), + (a = !!e.pathSegment(t, r, { move: a })), + a ? t.closePath() : t.lineTo(c.x, i); + } + t.lineTo(e.first().x, i), t.closePath(), t.clip(); + } + function fa(t, e) { + const { line: i, target: s, property: n, color: o, scale: a } = e, + r = (function (t, e, i) { + const s = t.segments, + n = t.points, + o = e.points, + a = []; + for (const t of s) { + let { start: s, end: r } = t; + r = ea(s, r, n); + const l = ta(i, n[s], n[r], t.loop); + if (!e.segments) { + a.push({ source: t, target: l, start: n[s], end: n[r] }); + continue; + } + const h = Ii(e, l); + for (const e of h) { + const s = ta(i, o[e.start], o[e.end], e.loop), + r = Ri(t, n, s); + for (const t of r) + a.push({ + source: t, + target: e, + start: { [i]: ia(l, s, "start", Math.max) }, + end: { [i]: ia(l, s, "end", Math.min) }, + }); + } + } + return a; + })(i, s, n); + for (const { source: e, target: l, start: h, end: c } of r) { + const { style: { backgroundColor: r = o } = {} } = e, + d = !0 !== s; + t.save(), (t.fillStyle = r), ga(t, a, d && ta(n, h, c)), t.beginPath(); + const u = !!i.pathSegment(t, e); + let f; + if (d) { + u ? t.closePath() : pa(t, s, c, n); + const e = !!s.pathSegment(t, l, { move: u, reverse: !0 }); + (f = u && e), f || pa(t, s, h, n); + } + t.closePath(), t.fill(f ? "evenodd" : "nonzero"), t.restore(); + } + } + function ga(t, e, i) { + const { top: s, bottom: n } = e.chart.chartArea, + { property: o, start: a, end: r } = i || {}; + "x" === o && (t.beginPath(), t.rect(a, s, r - a, n - s), t.clip()); + } + function pa(t, e, i, s) { + const n = e.interpolate(i, s); + n && t.lineTo(n.x, n.y); + } + var ma = { + id: "filler", + afterDatasetsUpdate(t, e, i) { + const s = (t.data.datasets || []).length, + n = []; + let o, a, r, l; + for (a = 0; a < s; ++a) + (o = t.getDatasetMeta(a)), + (r = o.dataset), + (l = null), + r && + r.options && + r instanceof no && + (l = { + visible: t.isDatasetVisible(a), + index: a, + fill: aa(r, a, s), + chart: t, + axis: o.controller.options.indexAxis, + scale: o.vScale, + line: r, + }), + (o.$filler = l), + n.push(l); + for (a = 0; a < s; ++a) + (l = n[a]), l && !1 !== l.fill && (l.fill = oa(n, a, i.propagate)); + }, + beforeDraw(t, e, i) { + const s = "beforeDraw" === i.drawTime, + n = t.getSortedVisibleDatasetMetas(), + o = t.chartArea; + for (let e = n.length - 1; e >= 0; --e) { + const i = n[e].$filler; + i && + (i.line.updateControlPoints(o, i.axis), + s && i.fill && da(t.ctx, i, o)); + } + }, + beforeDatasetsDraw(t, e, i) { + if ("beforeDatasetsDraw" !== i.drawTime) return; + const s = t.getSortedVisibleDatasetMetas(); + for (let e = s.length - 1; e >= 0; --e) { + const i = s[e].$filler; + na(i) && da(t.ctx, i, t.chartArea); + } + }, + beforeDatasetDraw(t, e, i) { + const s = e.meta.$filler; + na(s) && "beforeDatasetDraw" === i.drawTime && da(t.ctx, s, t.chartArea); + }, + defaults: { propagate: !0, drawTime: "beforeDatasetDraw" }, + }; + const xa = (t, e) => { + let { boxHeight: i = e, boxWidth: s = e } = t; + return ( + t.usePointStyle && + ((i = Math.min(i, e)), (s = t.pointStyleWidth || Math.min(s, e))), + { boxWidth: s, boxHeight: i, itemHeight: Math.max(e, i) } + ); + }; + class ba extends Hs { + constructor(t) { + super(), + (this._added = !1), + (this.legendHitBoxes = []), + (this._hoveredItem = null), + (this.doughnutMode = !1), + (this.chart = t.chart), + (this.options = t.options), + (this.ctx = t.ctx), + (this.legendItems = void 0), + (this.columnSizes = void 0), + (this.lineWidths = void 0), + (this.maxHeight = void 0), + (this.maxWidth = void 0), + (this.top = void 0), + (this.bottom = void 0), + (this.left = void 0), + (this.right = void 0), + (this.height = void 0), + (this.width = void 0), + (this._margins = void 0), + (this.position = void 0), + (this.weight = void 0), + (this.fullSize = void 0); + } + update(t, e, i) { + (this.maxWidth = t), + (this.maxHeight = e), + (this._margins = i), + this.setDimensions(), + this.buildLabels(), + this.fit(); + } + setDimensions() { + this.isHorizontal() + ? ((this.width = this.maxWidth), + (this.left = this._margins.left), + (this.right = this.width)) + : ((this.height = this.maxHeight), + (this.top = this._margins.top), + (this.bottom = this.height)); + } + buildLabels() { + const t = this.options.labels || {}; + let e = d(t.generateLabels, [this.chart], this) || []; + t.filter && (e = e.filter((e) => t.filter(e, this.chart.data))), + t.sort && (e = e.sort((e, i) => t.sort(e, i, this.chart.data))), + this.options.reverse && e.reverse(), + (this.legendItems = e); + } + fit() { + const { options: t, ctx: e } = this; + if (!t.display) return void (this.width = this.height = 0); + const i = t.labels, + s = Si(i.font), + n = s.size, + o = this._computeTitleHeight(), + { boxWidth: a, itemHeight: r } = xa(i, n); + let l, h; + (e.font = s.string), + this.isHorizontal() + ? ((l = this.maxWidth), (h = this._fitRows(o, n, a, r) + 10)) + : ((h = this.maxHeight), (l = this._fitCols(o, s, a, r) + 10)), + (this.width = Math.min(l, t.maxWidth || this.maxWidth)), + (this.height = Math.min(h, t.maxHeight || this.maxHeight)); + } + _fitRows(t, e, i, s) { + const { + ctx: n, + maxWidth: o, + options: { + labels: { padding: a }, + }, + } = this, + r = (this.legendHitBoxes = []), + l = (this.lineWidths = [0]), + h = s + a; + let c = t; + (n.textAlign = "left"), (n.textBaseline = "middle"); + let d = -1, + u = -h; + return ( + this.legendItems.forEach((t, f) => { + const g = i + e / 2 + n.measureText(t.text).width; + (0 === f || l[l.length - 1] + g + 2 * a > o) && + ((c += h), (l[l.length - (f > 0 ? 0 : 1)] = 0), (u += h), d++), + (r[f] = { left: 0, top: u, row: d, width: g, height: s }), + (l[l.length - 1] += g + a); + }), + c + ); + } + _fitCols(t, e, i, s) { + const { + ctx: n, + maxHeight: o, + options: { + labels: { padding: a }, + }, + } = this, + r = (this.legendHitBoxes = []), + l = (this.columnSizes = []), + h = o - t; + let c = a, + d = 0, + u = 0, + f = 0, + g = 0; + return ( + this.legendItems.forEach((t, o) => { + const { itemWidth: p, itemHeight: m } = (function (t, e, i, s, n) { + const o = (function (t, e, i, s) { + let n = t.text; + n && + "string" != typeof n && + (n = n.reduce((t, e) => (t.length > e.length ? t : e))); + return e + i.size / 2 + s.measureText(n).width; + })(s, t, e, i), + a = (function (t, e, i) { + let s = t; + "string" != typeof e.text && (s = _a(e, i)); + return s; + })(n, s, e.lineHeight); + return { itemWidth: o, itemHeight: a }; + })(i, e, n, t, s); + o > 0 && + u + m + 2 * a > h && + ((c += d + a), + l.push({ width: d, height: u }), + (f += d + a), + g++, + (d = u = 0)), + (r[o] = { left: f, top: u, col: g, width: p, height: m }), + (d = Math.max(d, p)), + (u += m + a); + }), + (c += d), + l.push({ width: d, height: u }), + c + ); + } + adjustHitBoxes() { + if (!this.options.display) return; + const t = this._computeTitleHeight(), + { + legendHitBoxes: e, + options: { + align: i, + labels: { padding: s }, + rtl: n, + }, + } = this, + o = Oi(n, this.left, this.width); + if (this.isHorizontal()) { + let n = 0, + a = ft(i, this.left + s, this.right - this.lineWidths[n]); + for (const r of e) + n !== r.row && + ((n = r.row), + (a = ft(i, this.left + s, this.right - this.lineWidths[n]))), + (r.top += this.top + t + s), + (r.left = o.leftForLtr(o.x(a), r.width)), + (a += r.width + s); + } else { + let n = 0, + a = ft(i, this.top + t + s, this.bottom - this.columnSizes[n].height); + for (const r of e) + r.col !== n && + ((n = r.col), + (a = ft( + i, + this.top + t + s, + this.bottom - this.columnSizes[n].height + ))), + (r.top = a), + (r.left += this.left + s), + (r.left = o.leftForLtr(o.x(r.left), r.width)), + (a += r.height + s); + } + } + isHorizontal() { + return ( + "top" === this.options.position || "bottom" === this.options.position + ); + } + draw() { + if (this.options.display) { + const t = this.ctx; + Ie(t, this), this._draw(), ze(t); + } + } + _draw() { + const { options: t, columnSizes: e, lineWidths: i, ctx: s } = this, + { align: n, labels: o } = t, + a = ue.color, + r = Oi(t.rtl, this.left, this.width), + h = Si(o.font), + { padding: c } = o, + d = h.size, + u = d / 2; + let f; + this.drawTitle(), + (s.textAlign = r.textAlign("left")), + (s.textBaseline = "middle"), + (s.lineWidth = 0.5), + (s.font = h.string); + const { boxWidth: g, boxHeight: p, itemHeight: m } = xa(o, d), + x = this.isHorizontal(), + b = this._computeTitleHeight(); + (f = x + ? { + x: ft(n, this.left + c, this.right - i[0]), + y: this.top + c + b, + line: 0, + } + : { + x: this.left + c, + y: ft(n, this.top + b + c, this.bottom - e[0].height), + line: 0, + }), + Ai(this.ctx, t.textDirection); + const _ = m + c; + this.legendItems.forEach((y, v) => { + (s.strokeStyle = y.fontColor), (s.fillStyle = y.fontColor); + const M = s.measureText(y.text).width, + w = r.textAlign(y.textAlign || (y.textAlign = o.textAlign)), + k = g + u + M; + let S = f.x, + P = f.y; + r.setWidth(this.width), + x + ? v > 0 && + S + k + c > this.right && + ((P = f.y += _), + f.line++, + (S = f.x = ft(n, this.left + c, this.right - i[f.line]))) + : v > 0 && + P + _ > this.bottom && + ((S = f.x = S + e[f.line].width + c), + f.line++, + (P = f.y = + ft(n, this.top + b + c, this.bottom - e[f.line].height))); + if ( + ((function (t, e, i) { + if (isNaN(g) || g <= 0 || isNaN(p) || p < 0) return; + s.save(); + const n = l(i.lineWidth, 1); + if ( + ((s.fillStyle = l(i.fillStyle, a)), + (s.lineCap = l(i.lineCap, "butt")), + (s.lineDashOffset = l(i.lineDashOffset, 0)), + (s.lineJoin = l(i.lineJoin, "miter")), + (s.lineWidth = n), + (s.strokeStyle = l(i.strokeStyle, a)), + s.setLineDash(l(i.lineDash, [])), + o.usePointStyle) + ) { + const a = { + radius: (p * Math.SQRT2) / 2, + pointStyle: i.pointStyle, + rotation: i.rotation, + borderWidth: n, + }, + l = r.xPlus(t, g / 2); + Ee(s, a, l, e + u, o.pointStyleWidth && g); + } else { + const o = e + Math.max((d - p) / 2, 0), + a = r.leftForLtr(t, g), + l = wi(i.borderRadius); + s.beginPath(), + Object.values(l).some((t) => 0 !== t) + ? He(s, { x: a, y: o, w: g, h: p, radius: l }) + : s.rect(a, o, g, p), + s.fill(), + 0 !== n && s.stroke(); + } + s.restore(); + })(r.x(S), P, y), + (S = gt(w, S + g + u, x ? S + k : this.right, t.rtl)), + (function (t, e, i) { + Ne(s, i.text, t, e + m / 2, h, { + strikethrough: i.hidden, + textAlign: r.textAlign(i.textAlign), + }); + })(r.x(S), P, y), + x) + ) + f.x += k + c; + else if ("string" != typeof y.text) { + const t = h.lineHeight; + f.y += _a(y, t) + c; + } else f.y += _; + }), + Ti(this.ctx, t.textDirection); + } + drawTitle() { + const t = this.options, + e = t.title, + i = Si(e.font), + s = ki(e.padding); + if (!e.display) return; + const n = Oi(t.rtl, this.left, this.width), + o = this.ctx, + a = e.position, + r = i.size / 2, + l = s.top + r; + let h, + c = this.left, + d = this.width; + if (this.isHorizontal()) + (d = Math.max(...this.lineWidths)), + (h = this.top + l), + (c = ft(t.align, c, this.right - d)); + else { + const e = this.columnSizes.reduce((t, e) => Math.max(t, e.height), 0); + h = + l + + ft( + t.align, + this.top, + this.bottom - e - t.labels.padding - this._computeTitleHeight() + ); + } + const u = ft(a, c, c + d); + (o.textAlign = n.textAlign(ut(a))), + (o.textBaseline = "middle"), + (o.strokeStyle = e.color), + (o.fillStyle = e.color), + (o.font = i.string), + Ne(o, e.text, u, h, i); + } + _computeTitleHeight() { + const t = this.options.title, + e = Si(t.font), + i = ki(t.padding); + return t.display ? e.lineHeight + i.height : 0; + } + _getLegendItemAt(t, e) { + let i, s, n; + if (tt(t, this.left, this.right) && tt(e, this.top, this.bottom)) + for (n = this.legendHitBoxes, i = 0; i < n.length; ++i) + if ( + ((s = n[i]), + tt(t, s.left, s.left + s.width) && tt(e, s.top, s.top + s.height)) + ) + return this.legendItems[i]; + return null; + } + handleEvent(t) { + const e = this.options; + if ( + !(function (t, e) { + if ( + ("mousemove" === t || "mouseout" === t) && + (e.onHover || e.onLeave) + ) + return !0; + if (e.onClick && ("click" === t || "mouseup" === t)) return !0; + return !1; + })(t.type, e) + ) + return; + const i = this._getLegendItemAt(t.x, t.y); + if ("mousemove" === t.type || "mouseout" === t.type) { + const o = this._hoveredItem, + a = + ((n = i), + null !== (s = o) && + null !== n && + s.datasetIndex === n.datasetIndex && + s.index === n.index); + o && !a && d(e.onLeave, [t, o, this], this), + (this._hoveredItem = i), + i && !a && d(e.onHover, [t, i, this], this); + } else i && d(e.onClick, [t, i, this], this); + var s, n; + } + } + function _a(t, e) { + return e * (t.text ? t.text.length : 0); + } + var ya = { + id: "legend", + _element: ba, + start(t, e, i) { + const s = (t.legend = new ba({ ctx: t.ctx, options: i, chart: t })); + as.configure(t, s, i), as.addBox(t, s); + }, + stop(t) { + as.removeBox(t, t.legend), delete t.legend; + }, + beforeUpdate(t, e, i) { + const s = t.legend; + as.configure(t, s, i), (s.options = i); + }, + afterUpdate(t) { + const e = t.legend; + e.buildLabels(), e.adjustHitBoxes(); + }, + afterEvent(t, e) { + e.replay || t.legend.handleEvent(e.event); + }, + defaults: { + display: !0, + position: "top", + align: "center", + fullSize: !0, + reverse: !1, + weight: 1e3, + onClick(t, e, i) { + const s = e.datasetIndex, + n = i.chart; + n.isDatasetVisible(s) + ? (n.hide(s), (e.hidden = !0)) + : (n.show(s), (e.hidden = !1)); + }, + onHover: null, + onLeave: null, + labels: { + color: (t) => t.chart.options.color, + boxWidth: 40, + padding: 10, + generateLabels(t) { + const e = t.data.datasets, + { + labels: { + usePointStyle: i, + pointStyle: s, + textAlign: n, + color: o, + useBorderRadius: a, + borderRadius: r, + }, + } = t.legend.options; + return t._getSortedDatasetMetas().map((t) => { + const l = t.controller.getStyle(i ? 0 : void 0), + h = ki(l.borderWidth); + return { + text: e[t.index].label, + fillStyle: l.backgroundColor, + fontColor: o, + hidden: !t.visible, + lineCap: l.borderCapStyle, + lineDash: l.borderDash, + lineDashOffset: l.borderDashOffset, + lineJoin: l.borderJoinStyle, + lineWidth: (h.width + h.height) / 4, + strokeStyle: l.borderColor, + pointStyle: s || l.pointStyle, + rotation: l.rotation, + textAlign: n || l.textAlign, + borderRadius: a && (r || l.borderRadius), + datasetIndex: t.index, + }; + }, this); + }, + }, + title: { + color: (t) => t.chart.options.color, + display: !1, + position: "center", + text: "", + }, + }, + descriptors: { + _scriptable: (t) => !t.startsWith("on"), + labels: { + _scriptable: (t) => !["generateLabels", "filter", "sort"].includes(t), + }, + }, + }; + class va extends Hs { + constructor(t) { + super(), + (this.chart = t.chart), + (this.options = t.options), + (this.ctx = t.ctx), + (this._padding = void 0), + (this.top = void 0), + (this.bottom = void 0), + (this.left = void 0), + (this.right = void 0), + (this.width = void 0), + (this.height = void 0), + (this.position = void 0), + (this.weight = void 0), + (this.fullSize = void 0); + } + update(t, e) { + const i = this.options; + if (((this.left = 0), (this.top = 0), !i.display)) + return void (this.width = this.height = this.right = this.bottom = 0); + (this.width = this.right = t), (this.height = this.bottom = e); + const s = n(i.text) ? i.text.length : 1; + this._padding = ki(i.padding); + const o = s * Si(i.font).lineHeight + this._padding.height; + this.isHorizontal() ? (this.height = o) : (this.width = o); + } + isHorizontal() { + const t = this.options.position; + return "top" === t || "bottom" === t; + } + _drawArgs(t) { + const { top: e, left: i, bottom: s, right: n, options: o } = this, + a = o.align; + let r, + l, + h, + c = 0; + return ( + this.isHorizontal() + ? ((l = ft(a, i, n)), (h = e + t), (r = n - i)) + : ("left" === o.position + ? ((l = i + t), (h = ft(a, s, e)), (c = -0.5 * C)) + : ((l = n - t), (h = ft(a, e, s)), (c = 0.5 * C)), + (r = s - e)), + { titleX: l, titleY: h, maxWidth: r, rotation: c } + ); + } + draw() { + const t = this.ctx, + e = this.options; + if (!e.display) return; + const i = Si(e.font), + s = i.lineHeight / 2 + this._padding.top, + { titleX: n, titleY: o, maxWidth: a, rotation: r } = this._drawArgs(s); + Ne(t, e.text, 0, 0, i, { + color: e.color, + maxWidth: a, + rotation: r, + textAlign: ut(e.align), + textBaseline: "middle", + translation: [n, o], + }); + } + } + var Ma = { + id: "title", + _element: va, + start(t, e, i) { + !(function (t, e) { + const i = new va({ ctx: t.ctx, options: e, chart: t }); + as.configure(t, i, e), as.addBox(t, i), (t.titleBlock = i); + })(t, i); + }, + stop(t) { + const e = t.titleBlock; + as.removeBox(t, e), delete t.titleBlock; + }, + beforeUpdate(t, e, i) { + const s = t.titleBlock; + as.configure(t, s, i), (s.options = i); + }, + defaults: { + align: "center", + display: !1, + font: { weight: "bold" }, + fullSize: !0, + padding: 10, + position: "top", + text: "", + weight: 2e3, + }, + defaultRoutes: { color: "color" }, + descriptors: { _scriptable: !0, _indexable: !1 }, + }; + const wa = new WeakMap(); + var ka = { + id: "subtitle", + start(t, e, i) { + const s = new va({ ctx: t.ctx, options: i, chart: t }); + as.configure(t, s, i), as.addBox(t, s), wa.set(t, s); + }, + stop(t) { + as.removeBox(t, wa.get(t)), wa.delete(t); + }, + beforeUpdate(t, e, i) { + const s = wa.get(t); + as.configure(t, s, i), (s.options = i); + }, + defaults: { + align: "center", + display: !1, + font: { weight: "normal" }, + fullSize: !0, + padding: 0, + position: "top", + text: "", + weight: 1500, + }, + defaultRoutes: { color: "color" }, + descriptors: { _scriptable: !0, _indexable: !1 }, + }; + const Sa = { + average(t) { + if (!t.length) return !1; + let e, + i, + s = new Set(), + n = 0, + o = 0; + for (e = 0, i = t.length; e < i; ++e) { + const i = t[e].element; + if (i && i.hasValue()) { + const t = i.tooltipPosition(); + s.add(t.x), (n += t.y), ++o; + } + } + if (0 === o || 0 === s.size) return !1; + return { x: [...s].reduce((t, e) => t + e) / s.size, y: n / o }; + }, + nearest(t, e) { + if (!t.length) return !1; + let i, + s, + n, + o = e.x, + a = e.y, + r = Number.POSITIVE_INFINITY; + for (i = 0, s = t.length; i < s; ++i) { + const s = t[i].element; + if (s && s.hasValue()) { + const t = q(e, s.getCenterPoint()); + t < r && ((r = t), (n = s)); + } + } + if (n) { + const t = n.tooltipPosition(); + (o = t.x), (a = t.y); + } + return { x: o, y: a }; + }, + }; + function Pa(t, e) { + return e && (n(e) ? Array.prototype.push.apply(t, e) : t.push(e)), t; + } + function Da(t) { + return ("string" == typeof t || t instanceof String) && t.indexOf("\n") > -1 + ? t.split("\n") + : t; + } + function Ca(t, e) { + const { element: i, datasetIndex: s, index: n } = e, + o = t.getDatasetMeta(s).controller, + { label: a, value: r } = o.getLabelAndValue(n); + return { + chart: t, + label: a, + parsed: o.getParsed(n), + raw: t.data.datasets[s].data[n], + formattedValue: r, + dataset: o.getDataset(), + dataIndex: n, + datasetIndex: s, + element: i, + }; + } + function Oa(t, e) { + const i = t.chart.ctx, + { body: s, footer: n, title: o } = t, + { boxWidth: a, boxHeight: r } = e, + l = Si(e.bodyFont), + h = Si(e.titleFont), + c = Si(e.footerFont), + d = o.length, + f = n.length, + g = s.length, + p = ki(e.padding); + let m = p.height, + x = 0, + b = s.reduce( + (t, e) => t + e.before.length + e.lines.length + e.after.length, + 0 + ); + if ( + ((b += t.beforeBody.length + t.afterBody.length), + d && + (m += + d * h.lineHeight + (d - 1) * e.titleSpacing + e.titleMarginBottom), + b) + ) { + m += + g * (e.displayColors ? Math.max(r, l.lineHeight) : l.lineHeight) + + (b - g) * l.lineHeight + + (b - 1) * e.bodySpacing; + } + f && + (m += e.footerMarginTop + f * c.lineHeight + (f - 1) * e.footerSpacing); + let _ = 0; + const y = function (t) { + x = Math.max(x, i.measureText(t).width + _); + }; + return ( + i.save(), + (i.font = h.string), + u(t.title, y), + (i.font = l.string), + u(t.beforeBody.concat(t.afterBody), y), + (_ = e.displayColors ? a + 2 + e.boxPadding : 0), + u(s, (t) => { + u(t.before, y), u(t.lines, y), u(t.after, y); + }), + (_ = 0), + (i.font = c.string), + u(t.footer, y), + i.restore(), + (x += p.width), + { width: x, height: m } + ); + } + function Aa(t, e, i, s) { + const { x: n, width: o } = i, + { + width: a, + chartArea: { left: r, right: l }, + } = t; + let h = "center"; + return ( + "center" === s + ? (h = n <= (r + l) / 2 ? "left" : "right") + : n <= o / 2 + ? (h = "left") + : n >= a - o / 2 && (h = "right"), + (function (t, e, i, s) { + const { x: n, width: o } = s, + a = i.caretSize + i.caretPadding; + return ( + ("left" === t && n + o + a > e.width) || + ("right" === t && n - o - a < 0) || + void 0 + ); + })(h, t, e, i) && (h = "center"), + h + ); + } + function Ta(t, e, i) { + const s = + i.yAlign || + e.yAlign || + (function (t, e) { + const { y: i, height: s } = e; + return i < s / 2 ? "top" : i > t.height - s / 2 ? "bottom" : "center"; + })(t, i); + return { xAlign: i.xAlign || e.xAlign || Aa(t, e, i, s), yAlign: s }; + } + function La(t, e, i, s) { + const { caretSize: n, caretPadding: o, cornerRadius: a } = t, + { xAlign: r, yAlign: l } = i, + h = n + o, + { topLeft: c, topRight: d, bottomLeft: u, bottomRight: f } = wi(a); + let g = (function (t, e) { + let { x: i, width: s } = t; + return "right" === e ? (i -= s) : "center" === e && (i -= s / 2), i; + })(e, r); + const p = (function (t, e, i) { + let { y: s, height: n } = t; + return "top" === e ? (s += i) : (s -= "bottom" === e ? n + i : n / 2), s; + })(e, l, h); + return ( + "center" === l + ? "left" === r + ? (g += h) + : "right" === r && (g -= h) + : "left" === r + ? (g -= Math.max(c, u) + n) + : "right" === r && (g += Math.max(d, f) + n), + { x: J(g, 0, s.width - e.width), y: J(p, 0, s.height - e.height) } + ); + } + function Ea(t, e, i) { + const s = ki(i.padding); + return "center" === e + ? t.x + t.width / 2 + : "right" === e + ? t.x + t.width - s.right + : t.x + s.left; + } + function Ra(t) { + return Pa([], Da(t)); + } + function Ia(t, e) { + const i = + e && e.dataset && e.dataset.tooltip && e.dataset.tooltip.callbacks; + return i ? t.override(i) : t; + } + const za = { + beforeTitle: e, + title(t) { + if (t.length > 0) { + const e = t[0], + i = e.chart.data.labels, + s = i ? i.length : 0; + if (this && this.options && "dataset" === this.options.mode) + return e.dataset.label || ""; + if (e.label) return e.label; + if (s > 0 && e.dataIndex < s) return i[e.dataIndex]; + } + return ""; + }, + afterTitle: e, + beforeBody: e, + beforeLabel: e, + label(t) { + if (this && this.options && "dataset" === this.options.mode) + return t.label + ": " + t.formattedValue || t.formattedValue; + let e = t.dataset.label || ""; + e && (e += ": "); + const i = t.formattedValue; + return s(i) || (e += i), e; + }, + labelColor(t) { + const e = t.chart + .getDatasetMeta(t.datasetIndex) + .controller.getStyle(t.dataIndex); + return { + borderColor: e.borderColor, + backgroundColor: e.backgroundColor, + borderWidth: e.borderWidth, + borderDash: e.borderDash, + borderDashOffset: e.borderDashOffset, + borderRadius: 0, + }; + }, + labelTextColor() { + return this.options.bodyColor; + }, + labelPointStyle(t) { + const e = t.chart + .getDatasetMeta(t.datasetIndex) + .controller.getStyle(t.dataIndex); + return { pointStyle: e.pointStyle, rotation: e.rotation }; + }, + afterLabel: e, + afterBody: e, + beforeFooter: e, + footer: e, + afterFooter: e, + }; + function Fa(t, e, i, s) { + const n = t[e].call(i, s); + return void 0 === n ? za[e].call(i, s) : n; + } + class Va extends Hs { + static positioners = Sa; + constructor(t) { + super(), + (this.opacity = 0), + (this._active = []), + (this._eventPosition = void 0), + (this._size = void 0), + (this._cachedAnimations = void 0), + (this._tooltipItems = []), + (this.$animations = void 0), + (this.$context = void 0), + (this.chart = t.chart), + (this.options = t.options), + (this.dataPoints = void 0), + (this.title = void 0), + (this.beforeBody = void 0), + (this.body = void 0), + (this.afterBody = void 0), + (this.footer = void 0), + (this.xAlign = void 0), + (this.yAlign = void 0), + (this.x = void 0), + (this.y = void 0), + (this.height = void 0), + (this.width = void 0), + (this.caretX = void 0), + (this.caretY = void 0), + (this.labelColors = void 0), + (this.labelPointStyles = void 0), + (this.labelTextColors = void 0); + } + initialize(t) { + (this.options = t), + (this._cachedAnimations = void 0), + (this.$context = void 0); + } + _resolveAnimations() { + const t = this._cachedAnimations; + if (t) return t; + const e = this.chart, + i = this.options.setContext(this.getContext()), + s = i.enabled && e.options.animation && i.animations, + n = new Os(this.chart, s); + return s._cacheable && (this._cachedAnimations = Object.freeze(n)), n; + } + getContext() { + return ( + this.$context || + (this.$context = + ((t = this.chart.getContext()), + (e = this), + (i = this._tooltipItems), + Ci(t, { tooltip: e, tooltipItems: i, type: "tooltip" }))) + ); + var t, e, i; + } + getTitle(t, e) { + const { callbacks: i } = e, + s = Fa(i, "beforeTitle", this, t), + n = Fa(i, "title", this, t), + o = Fa(i, "afterTitle", this, t); + let a = []; + return (a = Pa(a, Da(s))), (a = Pa(a, Da(n))), (a = Pa(a, Da(o))), a; + } + getBeforeBody(t, e) { + return Ra(Fa(e.callbacks, "beforeBody", this, t)); + } + getBody(t, e) { + const { callbacks: i } = e, + s = []; + return ( + u(t, (t) => { + const e = { before: [], lines: [], after: [] }, + n = Ia(i, t); + Pa(e.before, Da(Fa(n, "beforeLabel", this, t))), + Pa(e.lines, Fa(n, "label", this, t)), + Pa(e.after, Da(Fa(n, "afterLabel", this, t))), + s.push(e); + }), + s + ); + } + getAfterBody(t, e) { + return Ra(Fa(e.callbacks, "afterBody", this, t)); + } + getFooter(t, e) { + const { callbacks: i } = e, + s = Fa(i, "beforeFooter", this, t), + n = Fa(i, "footer", this, t), + o = Fa(i, "afterFooter", this, t); + let a = []; + return (a = Pa(a, Da(s))), (a = Pa(a, Da(n))), (a = Pa(a, Da(o))), a; + } + _createItems(t) { + const e = this._active, + i = this.chart.data, + s = [], + n = [], + o = []; + let a, + r, + l = []; + for (a = 0, r = e.length; a < r; ++a) l.push(Ca(this.chart, e[a])); + return ( + t.filter && (l = l.filter((e, s, n) => t.filter(e, s, n, i))), + t.itemSort && (l = l.sort((e, s) => t.itemSort(e, s, i))), + u(l, (e) => { + const i = Ia(t.callbacks, e); + s.push(Fa(i, "labelColor", this, e)), + n.push(Fa(i, "labelPointStyle", this, e)), + o.push(Fa(i, "labelTextColor", this, e)); + }), + (this.labelColors = s), + (this.labelPointStyles = n), + (this.labelTextColors = o), + (this.dataPoints = l), + l + ); + } + update(t, e) { + const i = this.options.setContext(this.getContext()), + s = this._active; + let n, + o = []; + if (s.length) { + const t = Sa[i.position].call(this, s, this._eventPosition); + (o = this._createItems(i)), + (this.title = this.getTitle(o, i)), + (this.beforeBody = this.getBeforeBody(o, i)), + (this.body = this.getBody(o, i)), + (this.afterBody = this.getAfterBody(o, i)), + (this.footer = this.getFooter(o, i)); + const e = (this._size = Oa(this, i)), + a = Object.assign({}, t, e), + r = Ta(this.chart, i, a), + l = La(i, a, r, this.chart); + (this.xAlign = r.xAlign), + (this.yAlign = r.yAlign), + (n = { + opacity: 1, + x: l.x, + y: l.y, + width: e.width, + height: e.height, + caretX: t.x, + caretY: t.y, + }); + } else 0 !== this.opacity && (n = { opacity: 0 }); + (this._tooltipItems = o), + (this.$context = void 0), + n && this._resolveAnimations().update(this, n), + t && + i.external && + i.external.call(this, { + chart: this.chart, + tooltip: this, + replay: e, + }); + } + drawCaret(t, e, i, s) { + const n = this.getCaretPosition(t, i, s); + e.lineTo(n.x1, n.y1), e.lineTo(n.x2, n.y2), e.lineTo(n.x3, n.y3); + } + getCaretPosition(t, e, i) { + const { xAlign: s, yAlign: n } = this, + { caretSize: o, cornerRadius: a } = i, + { topLeft: r, topRight: l, bottomLeft: h, bottomRight: c } = wi(a), + { x: d, y: u } = t, + { width: f, height: g } = e; + let p, m, x, b, _, y; + return ( + "center" === n + ? ((_ = u + g / 2), + "left" === s + ? ((p = d), (m = p - o), (b = _ + o), (y = _ - o)) + : ((p = d + f), (m = p + o), (b = _ - o), (y = _ + o)), + (x = p)) + : ((m = + "left" === s + ? d + Math.max(r, h) + o + : "right" === s + ? d + f - Math.max(l, c) - o + : this.caretX), + "top" === n + ? ((b = u), (_ = b - o), (p = m - o), (x = m + o)) + : ((b = u + g), (_ = b + o), (p = m + o), (x = m - o)), + (y = b)), + { x1: p, x2: m, x3: x, y1: b, y2: _, y3: y } + ); + } + drawTitle(t, e, i) { + const s = this.title, + n = s.length; + let o, a, r; + if (n) { + const l = Oi(i.rtl, this.x, this.width); + for ( + t.x = Ea(this, i.titleAlign, i), + e.textAlign = l.textAlign(i.titleAlign), + e.textBaseline = "middle", + o = Si(i.titleFont), + a = i.titleSpacing, + e.fillStyle = i.titleColor, + e.font = o.string, + r = 0; + r < n; + ++r + ) + e.fillText(s[r], l.x(t.x), t.y + o.lineHeight / 2), + (t.y += o.lineHeight + a), + r + 1 === n && (t.y += i.titleMarginBottom - a); + } + } + _drawColorBox(t, e, i, s, n) { + const a = this.labelColors[i], + r = this.labelPointStyles[i], + { boxHeight: l, boxWidth: h } = n, + c = Si(n.bodyFont), + d = Ea(this, "left", n), + u = s.x(d), + f = l < c.lineHeight ? (c.lineHeight - l) / 2 : 0, + g = e.y + f; + if (n.usePointStyle) { + const e = { + radius: Math.min(h, l) / 2, + pointStyle: r.pointStyle, + rotation: r.rotation, + borderWidth: 1, + }, + i = s.leftForLtr(u, h) + h / 2, + o = g + l / 2; + (t.strokeStyle = n.multiKeyBackground), + (t.fillStyle = n.multiKeyBackground), + Le(t, e, i, o), + (t.strokeStyle = a.borderColor), + (t.fillStyle = a.backgroundColor), + Le(t, e, i, o); + } else { + (t.lineWidth = o(a.borderWidth) + ? Math.max(...Object.values(a.borderWidth)) + : a.borderWidth || 1), + (t.strokeStyle = a.borderColor), + t.setLineDash(a.borderDash || []), + (t.lineDashOffset = a.borderDashOffset || 0); + const e = s.leftForLtr(u, h), + i = s.leftForLtr(s.xPlus(u, 1), h - 2), + r = wi(a.borderRadius); + Object.values(r).some((t) => 0 !== t) + ? (t.beginPath(), + (t.fillStyle = n.multiKeyBackground), + He(t, { x: e, y: g, w: h, h: l, radius: r }), + t.fill(), + t.stroke(), + (t.fillStyle = a.backgroundColor), + t.beginPath(), + He(t, { x: i, y: g + 1, w: h - 2, h: l - 2, radius: r }), + t.fill()) + : ((t.fillStyle = n.multiKeyBackground), + t.fillRect(e, g, h, l), + t.strokeRect(e, g, h, l), + (t.fillStyle = a.backgroundColor), + t.fillRect(i, g + 1, h - 2, l - 2)); + } + t.fillStyle = this.labelTextColors[i]; + } + drawBody(t, e, i) { + const { body: s } = this, + { + bodySpacing: n, + bodyAlign: o, + displayColors: a, + boxHeight: r, + boxWidth: l, + boxPadding: h, + } = i, + c = Si(i.bodyFont); + let d = c.lineHeight, + f = 0; + const g = Oi(i.rtl, this.x, this.width), + p = function (i) { + e.fillText(i, g.x(t.x + f), t.y + d / 2), (t.y += d + n); + }, + m = g.textAlign(o); + let x, b, _, y, v, M, w; + for ( + e.textAlign = o, + e.textBaseline = "middle", + e.font = c.string, + t.x = Ea(this, m, i), + e.fillStyle = i.bodyColor, + u(this.beforeBody, p), + f = a && "right" !== m ? ("center" === o ? l / 2 + h : l + 2 + h) : 0, + y = 0, + M = s.length; + y < M; + ++y + ) { + for ( + x = s[y], + b = this.labelTextColors[y], + e.fillStyle = b, + u(x.before, p), + _ = x.lines, + a && + _.length && + (this._drawColorBox(e, t, y, g, i), + (d = Math.max(c.lineHeight, r))), + v = 0, + w = _.length; + v < w; + ++v + ) + p(_[v]), (d = c.lineHeight); + u(x.after, p); + } + (f = 0), (d = c.lineHeight), u(this.afterBody, p), (t.y -= n); + } + drawFooter(t, e, i) { + const s = this.footer, + n = s.length; + let o, a; + if (n) { + const r = Oi(i.rtl, this.x, this.width); + for ( + t.x = Ea(this, i.footerAlign, i), + t.y += i.footerMarginTop, + e.textAlign = r.textAlign(i.footerAlign), + e.textBaseline = "middle", + o = Si(i.footerFont), + e.fillStyle = i.footerColor, + e.font = o.string, + a = 0; + a < n; + ++a + ) + e.fillText(s[a], r.x(t.x), t.y + o.lineHeight / 2), + (t.y += o.lineHeight + i.footerSpacing); + } + } + drawBackground(t, e, i, s) { + const { xAlign: n, yAlign: o } = this, + { x: a, y: r } = t, + { width: l, height: h } = i, + { + topLeft: c, + topRight: d, + bottomLeft: u, + bottomRight: f, + } = wi(s.cornerRadius); + (e.fillStyle = s.backgroundColor), + (e.strokeStyle = s.borderColor), + (e.lineWidth = s.borderWidth), + e.beginPath(), + e.moveTo(a + c, r), + "top" === o && this.drawCaret(t, e, i, s), + e.lineTo(a + l - d, r), + e.quadraticCurveTo(a + l, r, a + l, r + d), + "center" === o && "right" === n && this.drawCaret(t, e, i, s), + e.lineTo(a + l, r + h - f), + e.quadraticCurveTo(a + l, r + h, a + l - f, r + h), + "bottom" === o && this.drawCaret(t, e, i, s), + e.lineTo(a + u, r + h), + e.quadraticCurveTo(a, r + h, a, r + h - u), + "center" === o && "left" === n && this.drawCaret(t, e, i, s), + e.lineTo(a, r + c), + e.quadraticCurveTo(a, r, a + c, r), + e.closePath(), + e.fill(), + s.borderWidth > 0 && e.stroke(); + } + _updateAnimationTarget(t) { + const e = this.chart, + i = this.$animations, + s = i && i.x, + n = i && i.y; + if (s || n) { + const i = Sa[t.position].call(this, this._active, this._eventPosition); + if (!i) return; + const o = (this._size = Oa(this, t)), + a = Object.assign({}, i, this._size), + r = Ta(e, t, a), + l = La(t, a, r, e); + (s._to === l.x && n._to === l.y) || + ((this.xAlign = r.xAlign), + (this.yAlign = r.yAlign), + (this.width = o.width), + (this.height = o.height), + (this.caretX = i.x), + (this.caretY = i.y), + this._resolveAnimations().update(this, l)); + } + } + _willRender() { + return !!this.opacity; + } + draw(t) { + const e = this.options.setContext(this.getContext()); + let i = this.opacity; + if (!i) return; + this._updateAnimationTarget(e); + const s = { width: this.width, height: this.height }, + n = { x: this.x, y: this.y }; + i = Math.abs(i) < 0.001 ? 0 : i; + const o = ki(e.padding), + a = + this.title.length || + this.beforeBody.length || + this.body.length || + this.afterBody.length || + this.footer.length; + e.enabled && + a && + (t.save(), + (t.globalAlpha = i), + this.drawBackground(n, t, s, e), + Ai(t, e.textDirection), + (n.y += o.top), + this.drawTitle(n, t, e), + this.drawBody(n, t, e), + this.drawFooter(n, t, e), + Ti(t, e.textDirection), + t.restore()); + } + getActiveElements() { + return this._active || []; + } + setActiveElements(t, e) { + const i = this._active, + s = t.map(({ datasetIndex: t, index: e }) => { + const i = this.chart.getDatasetMeta(t); + if (!i) throw new Error("Cannot find a dataset at index " + t); + return { datasetIndex: t, element: i.data[e], index: e }; + }), + n = !f(i, s), + o = this._positionChanged(s, e); + (n || o) && + ((this._active = s), + (this._eventPosition = e), + (this._ignoreReplayEvents = !0), + this.update(!0)); + } + handleEvent(t, e, i = !0) { + if (e && this._ignoreReplayEvents) return !1; + this._ignoreReplayEvents = !1; + const s = this.options, + n = this._active || [], + o = this._getActiveElements(t, n, e, i), + a = this._positionChanged(o, t), + r = e || !f(o, n) || a; + return ( + r && + ((this._active = o), + (s.enabled || s.external) && + ((this._eventPosition = { x: t.x, y: t.y }), this.update(!0, e))), + r + ); + } + _getActiveElements(t, e, i, s) { + const n = this.options; + if ("mouseout" === t.type) return []; + if (!s) + return e.filter( + (t) => + this.chart.data.datasets[t.datasetIndex] && + void 0 !== + this.chart + .getDatasetMeta(t.datasetIndex) + .controller.getParsed(t.index) + ); + const o = this.chart.getElementsAtEventForMode(t, n.mode, n, i); + return n.reverse && o.reverse(), o; + } + _positionChanged(t, e) { + const { caretX: i, caretY: s, options: n } = this, + o = Sa[n.position].call(this, t, e); + return !1 !== o && (i !== o.x || s !== o.y); + } + } + var Ba = { + id: "tooltip", + _element: Va, + positioners: Sa, + afterInit(t, e, i) { + i && (t.tooltip = new Va({ chart: t, options: i })); + }, + beforeUpdate(t, e, i) { + t.tooltip && t.tooltip.initialize(i); + }, + reset(t, e, i) { + t.tooltip && t.tooltip.initialize(i); + }, + afterDraw(t) { + const e = t.tooltip; + if (e && e._willRender()) { + const i = { tooltip: e }; + if ( + !1 === t.notifyPlugins("beforeTooltipDraw", { ...i, cancelable: !0 }) + ) + return; + e.draw(t.ctx), t.notifyPlugins("afterTooltipDraw", i); + } + }, + afterEvent(t, e) { + if (t.tooltip) { + const i = e.replay; + t.tooltip.handleEvent(e.event, i, e.inChartArea) && (e.changed = !0); + } + }, + defaults: { + enabled: !0, + external: null, + position: "average", + backgroundColor: "rgba(0,0,0,0.8)", + titleColor: "#fff", + titleFont: { weight: "bold" }, + titleSpacing: 2, + titleMarginBottom: 6, + titleAlign: "left", + bodyColor: "#fff", + bodySpacing: 2, + bodyFont: {}, + bodyAlign: "left", + footerColor: "#fff", + footerSpacing: 2, + footerMarginTop: 6, + footerFont: { weight: "bold" }, + footerAlign: "left", + padding: 6, + caretPadding: 2, + caretSize: 5, + cornerRadius: 6, + boxHeight: (t, e) => e.bodyFont.size, + boxWidth: (t, e) => e.bodyFont.size, + multiKeyBackground: "#fff", + displayColors: !0, + boxPadding: 0, + borderColor: "rgba(0,0,0,0)", + borderWidth: 0, + animation: { duration: 400, easing: "easeOutQuart" }, + animations: { + numbers: { + type: "number", + properties: ["x", "y", "width", "height", "caretX", "caretY"], + }, + opacity: { easing: "linear", duration: 200 }, + }, + callbacks: za, + }, + defaultRoutes: { bodyFont: "font", footerFont: "font", titleFont: "font" }, + descriptors: { + _scriptable: (t) => + "filter" !== t && "itemSort" !== t && "external" !== t, + _indexable: !1, + callbacks: { _scriptable: !1, _indexable: !1 }, + animation: { _fallback: !1 }, + animations: { _fallback: "animation" }, + }, + additionalOptionScopes: ["interaction"], + }; + return ( + An.register(Yn, jo, fo, t), + (An.helpers = { ...Wi }), + (An._adapters = Rn), + (An.Animation = Cs), + (An.Animations = Os), + (An.animator = bt), + (An.controllers = en.controllers.items), + (An.DatasetController = Ns), + (An.Element = Hs), + (An.elements = fo), + (An.Interaction = Xi), + (An.layouts = as), + (An.platforms = Ss), + (An.Scale = Js), + (An.Ticks = ae), + Object.assign(An, Yn, jo, fo, t, Ss), + (An.Chart = An), + "undefined" != typeof window && (window.Chart = An), + An + ); +}); +//# sourceMappingURL=chart.umd.js.map diff --git a/assets/js/checkbox.js b/assets/js/checkbox.js new file mode 100644 index 0000000..21f6cc7 --- /dev/null +++ b/assets/js/checkbox.js @@ -0,0 +1,82 @@ +(function () { + "use strict"; + + // Reactive Binding für checked property (wie bei Selectbox) + function enableReactiveBinding(input) { + if (input._tuiCheckbox) return; + input._tuiCheckbox = true; + + var desc = Object.getOwnPropertyDescriptor( + HTMLInputElement.prototype, + "checked" + ); + if (!desc || !desc.set) return; + + Object.defineProperty(input, "checked", { + get: desc.get, + set: function (v) { + var old = desc.get.call(this); + desc.set.call(this, v); + if (old !== v) { + this.dispatchEvent(new Event("change", { bubbles: true })); + } + }, + configurable: true, + }); + } + + function updateParent(group) { + var parent = document.querySelector( + '[data-tui-checkbox-group="' + group + '"][data-tui-checkbox-parent]' + ); + var children = document.querySelectorAll( + '[data-tui-checkbox-group="' + group + '"]:not([data-tui-checkbox-parent])' + ); + if (!parent || !children.length) return; + + var checked = 0; + children.forEach(function (c) { + if (c.checked) checked++; + }); + + parent.checked = checked === children.length; + parent.indeterminate = checked > 0 && checked < children.length; + } + + function toggleChildren(group, checked) { + document + .querySelectorAll( + '[data-tui-checkbox-group="' + group + '"]:not([data-tui-checkbox-parent])' + ) + .forEach(function (c) { + c.checked = checked; + }); + } + + document.addEventListener("change", function (e) { + var el = e.target; + if (!el.matches("[data-tui-checkbox-group]")) return; + + var group = el.getAttribute("data-tui-checkbox-group"); + if (el.hasAttribute("data-tui-checkbox-parent")) { + toggleChildren(group, el.checked); + } else { + updateParent(group); + } + }); + + function init() { + var groups = new Set(); + document.querySelectorAll("[data-tui-checkbox-group]").forEach(function (el) { + groups.add(el.getAttribute("data-tui-checkbox-group")); + enableReactiveBinding(el); + }); + groups.forEach(updateParent); + } + + if (document.readyState === "loading") { + document.addEventListener("DOMContentLoaded", init); + } else { + init(); + } +})(); diff --git a/assets/js/collapsible.js b/assets/js/collapsible.js new file mode 100644 index 0000000..9fbeb19 --- /dev/null +++ b/assets/js/collapsible.js @@ -0,0 +1,70 @@ +(function () { + "use strict"; + + // Find the direct content element for a root (not nested ones) + function findDirectContent(root) { + const allContents = root.querySelectorAll('[data-tui-collapsible="content"]'); + for (const content of allContents) { + if (content.closest('[data-tui-collapsible="root"]') === root) { + return content; + } + } + return null; + } + + function toggle(trigger) { + const root = trigger.closest('[data-tui-collapsible="root"]'); + if (!root) return; + + const content = findDirectContent(root); + const isOpen = root.getAttribute("data-tui-collapsible-state") === "open"; + const newState = isOpen ? "closed" : "open"; + + // Update states + root.setAttribute("data-tui-collapsible-state", newState); + trigger.setAttribute("aria-expanded", !isOpen); + + // Toggle class on content for nested collapsible support + if (content) { + content.classList.toggle("tui-collapsible-open", !isOpen); + } + } + + // Initialize collapsibles on page load + function initializeCollapsibles() { + document.querySelectorAll('[data-tui-collapsible="root"]').forEach((root) => { + const isOpen = root.getAttribute("data-tui-collapsible-state") === "open"; + const content = findDirectContent(root); + if (content) { + content.classList.toggle("tui-collapsible-open", isOpen); + } + }); + } + + // Click handler + document.addEventListener("click", (e) => { + const trigger = e.target.closest('[data-tui-collapsible="trigger"]'); + if (trigger) { + e.preventDefault(); + toggle(trigger); + } + }); + + // Keyboard handler + document.addEventListener("keydown", (e) => { + if (e.key !== " " && e.key !== "Enter") return; + const trigger = e.target.closest('[data-tui-collapsible="trigger"]'); + if (trigger) { + e.preventDefault(); + toggle(trigger); + } + }); + + // Run on DOM ready + if (document.readyState === "loading") { + document.addEventListener("DOMContentLoaded", initializeCollapsibles); + } else { + initializeCollapsibles(); + } +})(); + diff --git a/assets/js/copybutton.js b/assets/js/copybutton.js new file mode 100644 index 0000000..630667f --- /dev/null +++ b/assets/js/copybutton.js @@ -0,0 +1,101 @@ +(function () { + "use strict"; + + // Copy button click delegation + document.addEventListener("click", (e) => { + const copyButton = e.target.closest("[data-copy-button]"); + if (!copyButton) return; + + const targetId = copyButton.dataset.targetId; + if (!targetId) { + console.error("CopyButton: No target-id specified"); + return; + } + + const targetElement = document.getElementById(targetId); + if (!targetElement) { + console.error(`CopyButton: Element with id '${targetId}' not found`); + return; + } + + // Smart detection: use value for inputs/textareas, textContent for everything else + let textToCopy = ""; + if (targetElement.value !== undefined) { + textToCopy = targetElement.value; + } else { + textToCopy = targetElement.textContent || ""; + } + + // Get icon elements + const iconClipboard = copyButton.querySelector( + "[data-copy-icon-clipboard]", + ); + const iconCheck = copyButton.querySelector("[data-copy-icon-check]"); + + if (!iconClipboard || !iconCheck) return; + + const showCopied = () => { + iconClipboard.style.display = "none"; + iconCheck.style.display = "inline"; + + // Update tooltip text if it exists + const tooltipText = copyButton + .closest(".inline-block") + ?.parentElement?.parentElement?.querySelector( + "[data-copy-tooltip-text]", + ); + const originalText = tooltipText?.textContent; + if (tooltipText) { + tooltipText.textContent = "Copied!"; + } + + setTimeout(() => { + iconClipboard.style.display = "inline"; + iconCheck.style.display = "none"; + // Restore original tooltip text + if (tooltipText && originalText) { + tooltipText.textContent = originalText; + } + }, 2000); + }; + + // Try to copy using modern API first + if (navigator.clipboard && window.isSecureContext) { + navigator.clipboard + .writeText(textToCopy.trim()) + .then(showCopied) + .catch((err) => { + console.error("CopyButton: Failed to copy text", err); + fallbackCopy(textToCopy.trim(), showCopied); + }); + } else { + // Fallback for older browsers or non-secure contexts + fallbackCopy(textToCopy.trim(), showCopied); + } + }); + + // Fallback copy method for older browsers + function fallbackCopy(text, callback) { + const textArea = document.createElement("textarea"); + textArea.value = text; + textArea.style.position = "fixed"; + textArea.style.top = "-9999px"; + textArea.style.left = "-9999px"; + document.body.appendChild(textArea); + textArea.focus(); + textArea.select(); + + try { + const successful = document.execCommand("copy"); + if (successful) { + callback(); + } else { + console.error("CopyButton: Fallback copy failed"); + } + } catch (err) { + console.error("CopyButton: Fallback copy error", err); + } + + document.body.removeChild(textArea); + } +})(); diff --git a/assets/js/datepicker.js b/assets/js/datepicker.js index 70777e8..854cb08 100644 --- a/assets/js/datepicker.js +++ b/assets/js/datepicker.js @@ -1,251 +1,199 @@ (function () { - "use strict"; + "use strict"; - /** - * Reactive Binding for hidden inputs - * - * Problem: Setting input.value programmatically (e.g., via Datastar/Alpine) - * does NOT fire 'input' events - this is standard browser behavior since the 90s. - * - * Solution: Override the value setter to dispatch 'input' events on change. - * This is the same pattern used by Vue.js, MobX, and other reactive frameworks. - */ - function enableReactiveBinding(input) { - if (input._tui) return; - input._tui = true; + /** + * Reactive Binding for hidden inputs + * + * Problem: Setting input.value programmatically (e.g., via Datastar/Alpine) + * does NOT fire 'input' events - this is standard browser behavior since the 90s. + * + * Solution: Override the value setter to dispatch 'input' events on change. + * This is the same pattern used by Vue.js, MobX, and other reactive frameworks. + */ + function enableReactiveBinding(input) { + if (input._tui) return; + input._tui = true; - const desc = Object.getOwnPropertyDescriptor( - HTMLInputElement.prototype, - "value", - ); - if (!desc?.set) return; + const desc = Object.getOwnPropertyDescriptor( + HTMLInputElement.prototype, + "value", + ); + if (!desc?.set) return; - Object.defineProperty(input, "value", { - get: desc.get, - set(v) { - const old = this.value; - desc.set.call(this, v); - if (old !== v) { - this.dispatchEvent(new Event("input", { bubbles: true })); - } - }, - configurable: true, - }); - } + Object.defineProperty(input, "value", { + get: desc.get, + set(v) { + const old = this.value; + desc.set.call(this, v); + if (old !== v) { + this.dispatchEvent(new Event("input", { bubbles: true })); + } + }, + configurable: true, + }); + } - function todayISO() { - var d = new Date(); - return ( - d.getFullYear() + - "-" + - String(d.getMonth() + 1).padStart(2, "0") + - "-" + - String(d.getDate()).padStart(2, "0") - ); - } + // Utility functions + function parseISODate(isoString) { + if (!isoString) return null; + const parts = isoString.match(/^(\d{4})-(\d{2})-(\d{2})$/); + if (!parts) return null; - function setDefaultToday(input) { - if (!input.value) { - input.value = todayISO(); - } - const form = input.closest("form"); - if (form) { - form.addEventListener("reset", function () { - setTimeout(() => { - input.value = todayISO(); - }, 0); - }); - } - } + const year = parseInt(parts[1], 10); + const month = parseInt(parts[2], 10) - 1; + const day = parseInt(parts[3], 10); + const date = new Date(Date.UTC(year, month, day)); - // Utility functions - function parseISODate(isoString) { - if (!isoString) return null; - const parts = isoString.match(/^(\d{4})-(\d{2})-(\d{2})$/); - if (!parts) return null; + if ( + date.getUTCFullYear() === year && + date.getUTCMonth() === month && + date.getUTCDate() === day + ) { + return date; + } + return null; + } - const year = parseInt(parts[1], 10); - const month = parseInt(parts[2], 10) - 1; - const day = parseInt(parts[3], 10); - const date = new Date(Date.UTC(year, month, day)); + function formatDate(date, format, locale) { + if (!date || isNaN(date.getTime())) return ""; - if ( - date.getUTCFullYear() === year && - date.getUTCMonth() === month && - date.getUTCDate() === day - ) { - return date; - } - return null; - } + const options = { timeZone: "UTC" }; + const formatMap = { + "locale-short": "short", + "locale-long": "long", + "locale-full": "full", + "locale-medium": "medium", + }; - function formatDate(date, format, locale) { - if (!date || isNaN(date.getTime())) return ""; + options.dateStyle = formatMap[format] || "medium"; - const options = { timeZone: "UTC" }; - const formatMap = { - "locale-short": "short", - "locale-long": "long", - "locale-full": "full", - "locale-medium": "medium", - }; + try { + return new Intl.DateTimeFormat(locale, options).format(date); + } catch (e) { + // Fallback to ISO format + const year = date.getUTCFullYear(); + const month = (date.getUTCMonth() + 1).toString().padStart(2, "0"); + const day = date.getUTCDate().toString().padStart(2, "0"); + return `${year}-${month}-${day}`; + } + } - options.dateStyle = formatMap[format] || "medium"; + function findRoot(element) { + return element?.closest("[data-tui-datepicker-root]") || null; + } - try { - return new Intl.DateTimeFormat(locale, options).format(date); - } catch (e) { - // Fallback to ISO format - const year = date.getUTCFullYear(); - const month = (date.getUTCMonth() + 1).toString().padStart(2, "0"); - const day = date.getUTCDate().toString().padStart(2, "0"); - return `${year}-${month}-${day}`; - } - } + function findElements(root) { + const trigger = root?.querySelector("[data-tui-datepicker='true']"); + const calendar = root?.querySelector("[data-tui-calendar-container]"); + const hiddenInput = root?.querySelector( + "[data-tui-datepicker-hidden-input]", + ); + const display = trigger?.querySelector("[data-tui-datepicker-display]"); - // Find elements - function findElements(trigger) { - const calendarId = trigger.id + "-calendar-instance"; - const calendar = document.getElementById(calendarId); - const hiddenInput = - document.getElementById(trigger.id + "-hidden") || - trigger.parentElement?.querySelector( - "[data-tui-datepicker-hidden-input]", - ); - const display = trigger.querySelector("[data-tui-datepicker-display]"); + return { trigger, calendar, hiddenInput, display }; + } - return { calendar, hiddenInput, display }; - } + function closePopover(root) { + const popoverContent = root?.querySelector("[data-tui-popover-content]"); + if (!popoverContent?.matches(":popover-open")) return; - // Update display - function updateDisplay(trigger) { - const elements = findElements(trigger); - if (!elements.display || !elements.hiddenInput) return; + try { + popoverContent.hidePopover(); + } catch { + // ignore + } + } - const format = - trigger.getAttribute("data-tui-datepicker-display-format") || - "locale-medium"; - const locale = - trigger.getAttribute("data-tui-datepicker-locale-tag") || "en-US"; - const placeholder = - trigger.getAttribute("data-tui-datepicker-placeholder") || - "Select a date"; + // Update display + function updateDisplay(root) { + const elements = findElements(root); + if (!elements.trigger || !elements.display || !elements.hiddenInput) return; - if (elements.hiddenInput.value) { - const date = parseISODate(elements.hiddenInput.value); - if (date) { - elements.display.textContent = formatDate(date, format, locale); - elements.display.classList.remove("text-muted-foreground"); - return; - } - } + const format = + elements.trigger.getAttribute("data-tui-datepicker-display-format") || + "locale-medium"; + const locale = + elements.trigger.getAttribute("data-tui-datepicker-locale-tag") || + "en-US"; + const placeholder = + elements.trigger.getAttribute("data-tui-datepicker-placeholder") || + "Select a date"; - elements.display.textContent = placeholder; - elements.display.classList.add("text-muted-foreground"); - } + if (elements.hiddenInput.value) { + const date = parseISODate(elements.hiddenInput.value); + if (date) { + elements.display.textContent = formatDate(date, format, locale); + elements.display.classList.remove("text-muted-foreground"); + return; + } + } - // Handle calendar date selection - document.addEventListener("calendar-date-selected", (e) => { - // Find the datepicker trigger associated with this calendar - const calendar = e.target; - if (!calendar || !calendar.id.endsWith("-calendar-instance")) return; + elements.display.textContent = placeholder; + elements.display.classList.add("text-muted-foreground"); + } - const triggerId = calendar.id.replace("-calendar-instance", ""); - const trigger = document.getElementById(triggerId); - if (!trigger || !trigger.hasAttribute("data-tui-datepicker")) return; + function toISODate(date) { + if (!date || isNaN(date.getTime())) return ""; + return date.toISOString().split("T")[0]; + } - const elements = findElements(trigger); - if (!elements.display || !e.detail?.date) return; + // Handle calendar date selection + document.addEventListener("calendar-date-selected", (e) => { + const calendar = e.target; + const root = findRoot(calendar); + const elements = findElements(root); + if (!elements.hiddenInput || !e.detail?.date) return; - const format = - trigger.getAttribute("data-tui-datepicker-display-format") || - "locale-medium"; - const locale = - trigger.getAttribute("data-tui-datepicker-locale-tag") || "en-US"; + elements.hiddenInput.value = toISODate(e.detail.date); + updateDisplay(root); + closePopover(root); + }); - elements.display.textContent = formatDate(e.detail.date, format, locale); - elements.display.classList.remove("text-muted-foreground"); + // Handle hidden input value changes (for reactive frameworks) + document.addEventListener("input", (e) => { + if (!e.target.matches("[data-tui-datepicker-hidden-input]")) return; - // Close the popover - if (window.closePopover) { - const popoverId = - trigger.getAttribute("aria-controls") || trigger.id + "-content"; - window.closePopover(popoverId); - } - }); + const root = findRoot(e.target); + if (root) { + updateDisplay(root); + } + }); - // Handle hidden input value changes (for reactive frameworks) - document.addEventListener("input", (e) => { - if (!e.target.matches("[data-tui-datepicker-hidden-input]")) return; + // Form reset handling + document.addEventListener("reset", (e) => { + if (!e.target.matches("form")) return; - const trigger = document.getElementById(e.target.id.replace("-hidden", "")); - if (trigger) { - updateDisplay(trigger); - } - }); + e.target.querySelectorAll("[data-tui-datepicker-root]").forEach((root) => { + const elements = findElements(root); + if (elements.hiddenInput) { + elements.hiddenInput.value = ""; + } + updateDisplay(root); + }); + }); - // Form reset handling - document.addEventListener("reset", (e) => { - if (!e.target.matches("form")) return; + // Initialize datepickers + function initializeDatePickers() { + document.querySelectorAll("[data-tui-datepicker-root]").forEach((root) => { + const elements = findElements(root); + if (!elements.hiddenInput || elements.hiddenInput._tui) return; - e.target - .querySelectorAll('[data-tui-datepicker="true"]') - .forEach((trigger) => { - const elements = findElements(trigger); - if (elements.hiddenInput) { - elements.hiddenInput.value = ""; - } - updateDisplay(trigger); - }); - }); + // Enable reactive binding for hidden input + enableReactiveBinding(elements.hiddenInput); + updateDisplay(root); + }); + } - // Clear button handling - document.addEventListener("click", (e) => { - const trigger = e.target.closest('[data-tui-datepicker-clear="true"]'); - if (!trigger) return; + // Initialize on DOM ready + if (document.readyState === "loading") { + document.addEventListener("DOMContentLoaded", initializeDatePickers); + } else { + initializeDatePickers(); + } - const triggerID = trigger.id; - const baseID = triggerID.replace(new RegExp("-clear-button" + "$"), ""); - - const datepicker = document.getElementById(baseID); - if (!datepicker) return; - - const elements = findElements(datepicker); - if (elements.hiddenInput) { - elements.hiddenInput.value = ""; - } - - updateDisplay(datepicker); - }); - - // Initialize datepickers - function initializeDatePickers() { - document - .querySelectorAll('[data-tui-datepicker="true"]') - .forEach((trigger) => { - const elements = findElements(trigger); - if (!elements.hiddenInput || elements.hiddenInput._tui) return; - - // Enable reactive binding for hidden input - enableReactiveBinding(elements.hiddenInput); - // If required, set default date to today - if (trigger.dataset.tuiDatepickerRequired === "true") { - setDefaultToday(elements.hiddenInput); - } - updateDisplay(trigger); - }); - } - - // Initialize on DOM ready - if (document.readyState === "loading") { - document.addEventListener("DOMContentLoaded", initializeDatePickers); - } else { - initializeDatePickers(); - } - - // MutationObserver for dynamically added elements - new MutationObserver(initializeDatePickers).observe(document.body, { - childList: true, - subtree: true, - }); + // MutationObserver for dynamically added elements + new MutationObserver(initializeDatePickers).observe(document.body, { + childList: true, + subtree: true, + }); })(); diff --git a/assets/js/datepicker.min.js b/assets/js/datepicker.min.js index 7900572..fa1771c 100644 --- a/assets/js/datepicker.min.js +++ b/assets/js/datepicker.min.js @@ -1 +1 @@ -(()=>{(function(){"use strict";function p(t){if(t._tui)return;t._tui=!0;let e=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value");e?.set&&Object.defineProperty(t,"value",{get:e.get,set(a){let n=this.value;e.set.call(this,a),n!==a&&this.dispatchEvent(new Event("input",{bubbles:!0}))},configurable:!0})}function m(t){if(!t)return null;let e=t.match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!e)return null;let a=parseInt(e[1],10),n=parseInt(e[2],10)-1,d=parseInt(e[3],10),i=new Date(Date.UTC(a,n,d));return i.getUTCFullYear()===a&&i.getUTCMonth()===n&&i.getUTCDate()===d?i:null}function s(t,e,a){if(!t||isNaN(t.getTime()))return"";let n={timeZone:"UTC"},d={"locale-short":"short","locale-long":"long","locale-full":"full","locale-medium":"medium"};n.dateStyle=d[e]||"medium";try{return new Intl.DateTimeFormat(a,n).format(t)}catch{let u=t.getUTCFullYear(),l=(t.getUTCMonth()+1).toString().padStart(2,"0"),f=t.getUTCDate().toString().padStart(2,"0");return`${u}-${l}-${f}`}}function r(t){let e=t.id+"-calendar-instance",a=document.getElementById(e),n=document.getElementById(t.id+"-hidden")||t.parentElement?.querySelector("[data-tui-datepicker-hidden-input]"),d=t.querySelector("[data-tui-datepicker-display]");return{calendar:a,hiddenInput:n,display:d}}function o(t){let e=r(t);if(!e.display||!e.hiddenInput)return;let a=t.getAttribute("data-tui-datepicker-display-format")||"locale-medium",n=t.getAttribute("data-tui-datepicker-locale-tag")||"en-US",d=t.getAttribute("data-tui-datepicker-placeholder")||"Select a date";if(e.hiddenInput.value){let i=m(e.hiddenInput.value);if(i){e.display.textContent=s(i,a,n),e.display.classList.remove("text-muted-foreground");return}}e.display.textContent=d,e.display.classList.add("text-muted-foreground")}document.addEventListener("calendar-date-selected",t=>{let e=t.target;if(!e||!e.id.endsWith("-calendar-instance"))return;let a=e.id.replace("-calendar-instance",""),n=document.getElementById(a);if(!n||!n.hasAttribute("data-tui-datepicker"))return;let d=r(n);if(!d.display||!t.detail?.date)return;let i=n.getAttribute("data-tui-datepicker-display-format")||"locale-medium",u=n.getAttribute("data-tui-datepicker-locale-tag")||"en-US";if(d.display.textContent=s(t.detail.date,i,u),d.display.classList.remove("text-muted-foreground"),window.closePopover){let l=n.getAttribute("aria-controls")||n.id+"-content";window.closePopover(l)}}),document.addEventListener("input",t=>{if(!t.target.matches("[data-tui-datepicker-hidden-input]"))return;let e=document.getElementById(t.target.id.replace("-hidden",""));e&&o(e)}),document.addEventListener("reset",t=>{t.target.matches("form")&&t.target.querySelectorAll('[data-tui-datepicker="true"]').forEach(e=>{let a=r(e);a.hiddenInput&&(a.hiddenInput.value=""),o(e)})});function c(){document.querySelectorAll('[data-tui-datepicker="true"]').forEach(t=>{let e=r(t);!e.hiddenInput||e.hiddenInput._tui||(p(e.hiddenInput),o(t))})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",c):c(),new MutationObserver(c).observe(document.body,{childList:!0,subtree:!0})})();})(); +(()=>{(function(){"use strict";function l(e){if(e._tui)return;e._tui=!0;let t=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value");t?.set&&Object.defineProperty(e,"value",{get:t.get,set(n){let r=this.value;t.set.call(this,n),r!==n&&this.dispatchEvent(new Event("input",{bubbles:!0}))},configurable:!0})}function s(e){if(!e)return null;let t=e.match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!t)return null;let n=parseInt(t[1],10),r=parseInt(t[2],10)-1,a=parseInt(t[3],10),i=new Date(Date.UTC(n,r,a));return i.getUTCFullYear()===n&&i.getUTCMonth()===r&&i.getUTCDate()===a?i:null}function p(e,t,n){if(!e||isNaN(e.getTime()))return"";let r={timeZone:"UTC"},a={"locale-short":"short","locale-long":"long","locale-full":"full","locale-medium":"medium"};r.dateStyle=a[t]||"medium";try{return new Intl.DateTimeFormat(n,r).format(e)}catch{let g=e.getUTCFullYear(),h=(e.getUTCMonth()+1).toString().padStart(2,"0"),y=e.getUTCDate().toString().padStart(2,"0");return`${g}-${h}-${y}`}}function c(e){return e?.closest("[data-tui-datepicker-root]")||null}function o(e){let t=e?.querySelector("[data-tui-datepicker='true']"),n=e?.querySelector("[data-tui-calendar-container]"),r=e?.querySelector("[data-tui-datepicker-hidden-input]"),a=t?.querySelector("[data-tui-datepicker-display]");return{trigger:t,calendar:n,hiddenInput:r,display:a}}function f(e){let t=e?.querySelector("[data-tui-popover-content]");if(t?.matches(":popover-open"))try{t.hidePopover()}catch{}}function d(e){let t=o(e);if(!t.trigger||!t.display||!t.hiddenInput)return;let n=t.trigger.getAttribute("data-tui-datepicker-display-format")||"locale-medium",r=t.trigger.getAttribute("data-tui-datepicker-locale-tag")||"en-US",a=t.trigger.getAttribute("data-tui-datepicker-placeholder")||"Select a date";if(t.hiddenInput.value){let i=s(t.hiddenInput.value);if(i){t.display.textContent=p(i,n,r),t.display.classList.remove("text-muted-foreground");return}}t.display.textContent=a,t.display.classList.add("text-muted-foreground")}function m(e){return!e||isNaN(e.getTime())?"":e.toISOString().split("T")[0]}document.addEventListener("calendar-date-selected",e=>{let t=e.target,n=c(t),r=o(n);!r.hiddenInput||!e.detail?.date||(r.hiddenInput.value=m(e.detail.date),d(n),f(n))}),document.addEventListener("input",e=>{if(!e.target.matches("[data-tui-datepicker-hidden-input]"))return;let t=c(e.target);t&&d(t)}),document.addEventListener("reset",e=>{e.target.matches("form")&&e.target.querySelectorAll("[data-tui-datepicker-root]").forEach(t=>{let n=o(t);n.hiddenInput&&(n.hiddenInput.value=""),d(t)})});function u(){document.querySelectorAll("[data-tui-datepicker-root]").forEach(e=>{let t=o(e);!t.hiddenInput||t.hiddenInput._tui||(l(t.hiddenInput),d(e))})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",u):u(),new MutationObserver(u).observe(document.body,{childList:!0,subtree:!0})})();})(); diff --git a/assets/js/dialog.js b/assets/js/dialog.js new file mode 100644 index 0000000..8f13222 --- /dev/null +++ b/assets/js/dialog.js @@ -0,0 +1,215 @@ +(function () { + "use strict"; + + const CLOSE_DURATION_MS = 200; + + function getRoot(target) { + if (!target) return null; + + if (typeof target === "string") { + const byId = document.getElementById(target); + if (byId?.matches?.("[data-tui-dialog]")) { + return byId; + } + + try { + return document.querySelector(target)?.closest("[data-tui-dialog]") || null; + } catch { + return null; + } + } + + if (target.matches?.("[data-tui-dialog]")) { + return target; + } + + return target.closest?.("[data-tui-dialog]") || null; + } + + function getDialog(root) { + if (!root) return null; + return ensureDialog(root.querySelector("[data-tui-dialog-content]")); + } + + function getOwnedTriggers(root) { + if (!root) return []; + + return Array.from(root.querySelectorAll("[data-tui-dialog-trigger]")).filter( + (trigger) => !trigger.hasAttribute("data-tui-dialog-target"), + ); + } + + function getTargetedTriggers(targetId) { + if (!targetId) return []; + + return Array.from( + document.querySelectorAll( + `[data-tui-dialog-trigger][data-tui-dialog-target="${targetId}"]`, + ), + ); + } + + function getTargetValue(element) { + const target = element?.getAttribute("data-tui-dialog-target"); + return target && target.trim() ? target.trim() : null; + } + + function getRootForElement(element) { + return getRoot(getTargetValue(element) || element); + } + + function ensureDialog(dialog) { + if (!dialog || dialog.dataset.tuiDialogInitialized === "true") return dialog; + + dialog.dataset.tuiDialogInitialized = "true"; + + dialog.addEventListener("cancel", (event) => { + const root = getRoot(dialog); + if (root?.hasAttribute("data-tui-dialog-disable-esc")) { + event.preventDefault(); + return; + } + + event.preventDefault(); + closeDialog(root); + }); + + dialog.addEventListener("close", () => { + const root = getRoot(dialog); + window.clearTimeout(dialog._tuiDialogCloseTimer); + delete dialog._tuiDialogCloseTimer; + dialog.removeAttribute("data-tui-dialog-closing"); + root?.removeAttribute("data-tui-dialog-closing"); + updateState(getRoot(dialog), false); + }); + + dialog.addEventListener("click", (event) => { + if (event.target !== dialog) return; + + const root = getRoot(dialog); + if (root?.hasAttribute("data-tui-dialog-disable-click-away")) { + return; + } + + closeDialog(root); + }); + + return dialog; + } + + function updateState(root, isOpen) { + const dialog = getDialog(root); + dialog?.setAttribute("data-tui-dialog-open", isOpen ? "true" : "false"); + root?.setAttribute("data-tui-dialog-open", isOpen ? "true" : "false"); + + getOwnedTriggers(root).forEach((trigger) => { + trigger.setAttribute("data-tui-dialog-trigger-open", isOpen ? "true" : "false"); + }); + + if (root?.id) { + getTargetedTriggers(root.id).forEach((trigger) => { + trigger.setAttribute("data-tui-dialog-trigger-open", isOpen ? "true" : "false"); + }); + } + + } + + function openDialog(target) { + const root = getRoot(target); + const dialog = getDialog(root); + if (!dialog) return; + + window.clearTimeout(dialog._tuiDialogCloseTimer); + delete dialog._tuiDialogCloseTimer; + dialog.removeAttribute("data-tui-dialog-closing"); + root?.removeAttribute("data-tui-dialog-closing"); + + if (!dialog.open) { + try { + dialog.showModal(); + } catch { + return; + } + } + + updateState(root, true); + } + + function closeDialog(target) { + const root = getRoot(target); + const dialog = getDialog(root); + if (!dialog) return; + + if (!dialog.open) { + updateState(root, false); + return; + } + + if (dialog.dataset.tuiDialogClosing === "true") { + return; + } + + dialog.setAttribute("data-tui-dialog-closing", "true"); + root?.setAttribute("data-tui-dialog-closing", "true"); + updateState(root, false); + + dialog._tuiDialogCloseTimer = window.setTimeout(() => { + if (dialog.open) { + dialog.close(); + } else { + dialog.removeAttribute("data-tui-dialog-closing"); + root?.removeAttribute("data-tui-dialog-closing"); + } + }, CLOSE_DURATION_MS); + } + + function isDialogOpen(target) { + return getDialog(getRoot(target))?.open || false; + } + + function toggleDialog(target) { + isDialogOpen(target) ? closeDialog(target) : openDialog(target); + } + + function initDialogs(root = document) { + root.querySelectorAll("[data-tui-dialog]").forEach((dialogRoot) => { + const dialog = getDialog(dialogRoot); + if (!dialog) return; + + ensureDialog(dialog); + + if (dialog.getAttribute("data-tui-dialog-initial-open") === "true") { + openDialog(dialogRoot); + } else { + updateState(dialogRoot, dialog.open); + } + }); + } + + document.addEventListener("click", (event) => { + const trigger = event.target.closest("[data-tui-dialog-trigger]"); + if (trigger) { + toggleDialog(getRootForElement(trigger)); + return; + } + + const closeButton = event.target.closest("[data-tui-dialog-close]"); + if (closeButton) { + closeDialog(getRootForElement(closeButton)); + } + }); + + if (document.readyState === "loading") { + document.addEventListener("DOMContentLoaded", () => initDialogs()); + } else { + initDialogs(); + } + + window.tui = window.tui || {}; + window.tui.dialog = { + open: openDialog, + close: closeDialog, + toggle: toggleDialog, + isOpen: isDialogOpen, + }; +})(); diff --git a/assets/js/dialog.min.js b/assets/js/dialog.min.js index c6730a1..68d9894 100644 --- a/assets/js/dialog.min.js +++ b/assets/js/dialog.min.js @@ -1 +1 @@ -(()=>{(function(){"use strict";function u(t){let a=document.querySelector(`[data-tui-dialog-backdrop][data-dialog-instance="${t}"]`),e=document.querySelector(`[data-tui-dialog-content][data-dialog-instance="${t}"]`);!a||!e||(a.removeAttribute("data-tui-dialog-hidden"),e.removeAttribute("data-tui-dialog-hidden"),requestAnimationFrame(()=>{a.setAttribute("data-tui-dialog-open","true"),e.setAttribute("data-tui-dialog-open","true"),document.body.style.overflow="hidden",document.querySelectorAll(`[data-tui-dialog-trigger][data-dialog-instance="${t}"]`).forEach(o=>{o.setAttribute("data-tui-dialog-trigger-open","true")}),e.hasAttribute("data-tui-dialog-disable-autofocus")||setTimeout(()=>{e.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')?.focus()},50)}))}function n(t){let a=document.querySelector(`[data-tui-dialog-backdrop][data-dialog-instance="${t}"]`),e=document.querySelector(`[data-tui-dialog-content][data-dialog-instance="${t}"]`);!a||!e||(a.setAttribute("data-tui-dialog-open","false"),e.setAttribute("data-tui-dialog-open","false"),document.querySelectorAll(`[data-tui-dialog-trigger][data-dialog-instance="${t}"]`).forEach(i=>{i.setAttribute("data-tui-dialog-trigger-open","false")}),setTimeout(()=>{a.setAttribute("data-tui-dialog-hidden","true"),e.setAttribute("data-tui-dialog-hidden","true"),document.querySelector('[data-tui-dialog-content][data-tui-dialog-open="true"]')||(document.body.style.overflow="")},300))}function l(t){let a=t.getAttribute("data-dialog-instance");if(a)return a;let e=t.closest("[data-tui-dialog]");return e?e.getAttribute("data-dialog-instance"):null}function r(t){return document.querySelector(`[data-tui-dialog-content][data-dialog-instance="${t}"]`)?.getAttribute("data-tui-dialog-open")==="true"||!1}function c(t){r(t)?n(t):u(t)}document.addEventListener("click",t=>{let a=t.target.closest("[data-tui-dialog-trigger]");if(a){let o=a.getAttribute("data-dialog-instance");if(!o)return;c(o);return}let e=t.target.closest("[data-tui-dialog-close]");if(e){let d=e.getAttribute("data-tui-dialog-close")||l(e);d&&n(d);return}let i=t.target.closest("[data-tui-dialog-backdrop]");if(i){let o=i.getAttribute("data-dialog-instance");if(!o)return;let d=document.querySelector(`[data-tui-dialog][data-dialog-instance="${o}"]`),s=document.querySelector(`[data-tui-dialog-content][data-dialog-instance="${o}"]`);d?.hasAttribute("data-tui-dialog-disable-click-away")||s?.hasAttribute("data-tui-dialog-disable-click-away")||n(o)}}),document.addEventListener("keydown",t=>{if(t.key==="Escape"){let a=document.querySelectorAll('[data-tui-dialog-content][data-tui-dialog-open="true"]');if(a.length===0)return;let e=a[a.length-1],i=e.getAttribute("data-dialog-instance");if(!i)return;document.querySelector(`[data-tui-dialog][data-dialog-instance="${i}"]`)?.hasAttribute("data-tui-dialog-disable-esc")||e?.hasAttribute("data-tui-dialog-disable-esc")||n(i)}}),document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll('[data-tui-dialog-content][data-tui-dialog-open="true"]').length>0&&(document.body.style.overflow="hidden")}),new MutationObserver(()=>{document.querySelector('[data-tui-dialog-content][data-tui-dialog-open="true"]')||(document.body.style.overflow="")}).observe(document.body,{childList:!0,subtree:!0}),window.tui=window.tui||{},window.tui.dialog={open:u,close:n,toggle:c,isOpen:r}})();})(); +(()=>{(function(){"use strict";function r(t){if(!t)return null;if(typeof t=="string"){let e=document.getElementById(t);if(e?.matches?.("[data-tui-dialog]"))return e;try{return document.querySelector(t)?.closest("[data-tui-dialog]")||null}catch{return null}}return t.matches?.("[data-tui-dialog]")?t:t.closest?.("[data-tui-dialog]")||null}function a(t){return t?s(t.querySelector("[data-tui-dialog-content]")):null}function m(t){return t?Array.from(t.querySelectorAll("[data-tui-dialog-trigger]")).filter(e=>!e.hasAttribute("data-tui-dialog-target")):[]}function A(t){return t?Array.from(document.querySelectorAll(`[data-tui-dialog-trigger][data-tui-dialog-target="${t}"]`)):[]}function b(t){let e=t?.getAttribute("data-tui-dialog-target");return e&&e.trim()?e.trim():null}function d(t){return r(b(t)||t)}function s(t){return!t||t.dataset.tuiDialogInitialized==="true"||(t.dataset.tuiDialogInitialized="true",t.addEventListener("cancel",e=>{let i=r(t);if(i?.hasAttribute("data-tui-dialog-disable-esc")){e.preventDefault();return}e.preventDefault(),u(i)}),t.addEventListener("close",()=>{let e=r(t);window.clearTimeout(t._tuiDialogCloseTimer),delete t._tuiDialogCloseTimer,t.removeAttribute("data-tui-dialog-closing"),e?.removeAttribute("data-tui-dialog-closing"),o(r(t),!1)}),t.addEventListener("click",e=>{if(e.target!==t)return;let i=r(t);i?.hasAttribute("data-tui-dialog-disable-click-away")||u(i)})),t}function o(t,e){a(t)?.setAttribute("data-tui-dialog-open",e?"true":"false"),t?.setAttribute("data-tui-dialog-open",e?"true":"false"),m(t).forEach(l=>{l.setAttribute("data-tui-dialog-trigger-open",e?"true":"false")}),t?.id&&A(t.id).forEach(l=>{l.setAttribute("data-tui-dialog-trigger-open",e?"true":"false")})}function n(t){let e=r(t),i=a(e);if(i){if(window.clearTimeout(i._tuiDialogCloseTimer),delete i._tuiDialogCloseTimer,i.removeAttribute("data-tui-dialog-closing"),e?.removeAttribute("data-tui-dialog-closing"),!i.open)try{i.showModal()}catch{return}o(e,!0)}}function u(t){let e=r(t),i=a(e);if(i){if(!i.open){o(e,!1);return}i.dataset.tuiDialogClosing!=="true"&&(i.setAttribute("data-tui-dialog-closing","true"),e?.setAttribute("data-tui-dialog-closing","true"),o(e,!1),i._tuiDialogCloseTimer=window.setTimeout(()=>{i.open?i.close():(i.removeAttribute("data-tui-dialog-closing"),e?.removeAttribute("data-tui-dialog-closing"))},200))}}function c(t){return a(r(t))?.open||!1}function g(t){c(t)?u(t):n(t)}function f(t=document){t.querySelectorAll("[data-tui-dialog]").forEach(e=>{let i=a(e);i&&(s(i),i.getAttribute("data-tui-dialog-initial-open")==="true"?n(e):o(e,i.open))})}document.addEventListener("click",t=>{let e=t.target.closest("[data-tui-dialog-trigger]");if(e){g(d(e));return}let i=t.target.closest("[data-tui-dialog-close]");i&&u(d(i))}),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>f()):f(),window.tui=window.tui||{},window.tui.dialog={open:n,close:u,toggle:g,isOpen:c}})();})(); diff --git a/assets/js/dropdown.js b/assets/js/dropdown.js new file mode 100644 index 0000000..aa5f691 --- /dev/null +++ b/assets/js/dropdown.js @@ -0,0 +1,20 @@ +(function () { + 'use strict'; + + document.addEventListener('click', (e) => { + const item = e.target.closest('[data-tui-dropdown-item]'); + if (!item || + item.hasAttribute('data-tui-dropdown-submenu-trigger') || + item.getAttribute('data-tui-dropdown-prevent-close') === 'true') return; + + const popoverRoot = item.closest('[data-tui-popover-root]'); + const popoverContent = popoverRoot?.querySelector(':scope > [data-tui-popover-content]'); + if (!popoverContent?.matches(':popover-open')) return; + + try { + popoverContent.hidePopover(); + } catch { + // ignore + } + }); +})(); diff --git a/assets/js/dropdown.min.js b/assets/js/dropdown.min.js index ced54f9..d1648e0 100644 --- a/assets/js/dropdown.min.js +++ b/assets/js/dropdown.min.js @@ -1 +1 @@ -(()=>{(function(){"use strict";document.addEventListener("click",o=>{let t=o.target.closest("[data-tui-dropdown-item]");if(!t||t.hasAttribute("data-tui-dropdown-submenu-trigger")||t.getAttribute("data-tui-dropdown-prevent-close")==="true")return;let e=t.closest("[data-tui-popover-id]");if(!e)return;let i=e.getAttribute("data-tui-popover-id")||e.id;window.closePopover&&window.closePopover(i)})})();})(); +(()=>{(function(){"use strict";document.addEventListener("click",e=>{let t=e.target.closest("[data-tui-dropdown-item]");if(!t||t.hasAttribute("data-tui-dropdown-submenu-trigger")||t.getAttribute("data-tui-dropdown-prevent-close")==="true")return;let o=t.closest("[data-tui-popover-root]")?.querySelector(":scope > [data-tui-popover-content]");if(o?.matches(":popover-open"))try{o.hidePopover()}catch{}})})();})(); diff --git a/assets/js/floating_ui_core.js b/assets/js/floating_ui_core.js new file mode 100644 index 0000000..00a9122 --- /dev/null +++ b/assets/js/floating_ui_core.js @@ -0,0 +1,858 @@ +// https://cdn.jsdelivr.net/npm/@floating-ui/core@1.7.0 +!(function (t, e) { + "object" == typeof exports && "undefined" != typeof module + ? e(exports) + : "function" == typeof define && define.amd + ? define(["exports"], e) + : e( + ((t = + "undefined" != typeof globalThis + ? globalThis + : t || self).FloatingUICore = {}) + ); +})(this, function (t) { + "use strict"; + const e = ["top", "right", "bottom", "left"], + n = ["start", "end"], + i = e.reduce((t, e) => t.concat(e, e + "-" + n[0], e + "-" + n[1]), []), + o = Math.min, + r = Math.max, + a = { left: "right", right: "left", bottom: "top", top: "bottom" }, + l = { start: "end", end: "start" }; + function s(t, e, n) { + return r(t, o(e, n)); + } + function f(t, e) { + return "function" == typeof t ? t(e) : t; + } + function c(t) { + return t.split("-")[0]; + } + function u(t) { + return t.split("-")[1]; + } + function m(t) { + return "x" === t ? "y" : "x"; + } + function d(t) { + return "y" === t ? "height" : "width"; + } + function g(t) { + return ["top", "bottom"].includes(c(t)) ? "y" : "x"; + } + function p(t) { + return m(g(t)); + } + function h(t, e, n) { + void 0 === n && (n = !1); + const i = u(t), + o = p(t), + r = d(o); + let a = + "x" === o + ? i === (n ? "end" : "start") + ? "right" + : "left" + : "start" === i + ? "bottom" + : "top"; + return e.reference[r] > e.floating[r] && (a = w(a)), [a, w(a)]; + } + function y(t) { + return t.replace(/start|end/g, (t) => l[t]); + } + function w(t) { + return t.replace(/left|right|bottom|top/g, (t) => a[t]); + } + function x(t) { + return "number" != typeof t + ? (function (t) { + return { top: 0, right: 0, bottom: 0, left: 0, ...t }; + })(t) + : { top: t, right: t, bottom: t, left: t }; + } + function v(t) { + const { x: e, y: n, width: i, height: o } = t; + return { + width: i, + height: o, + top: n, + left: e, + right: e + i, + bottom: n + o, + x: e, + y: n, + }; + } + function b(t, e, n) { + let { reference: i, floating: o } = t; + const r = g(e), + a = p(e), + l = d(a), + s = c(e), + f = "y" === r, + m = i.x + i.width / 2 - o.width / 2, + h = i.y + i.height / 2 - o.height / 2, + y = i[l] / 2 - o[l] / 2; + let w; + switch (s) { + case "top": + w = { x: m, y: i.y - o.height }; + break; + case "bottom": + w = { x: m, y: i.y + i.height }; + break; + case "right": + w = { x: i.x + i.width, y: h }; + break; + case "left": + w = { x: i.x - o.width, y: h }; + break; + default: + w = { x: i.x, y: i.y }; + } + switch (u(e)) { + case "start": + w[a] -= y * (n && f ? -1 : 1); + break; + case "end": + w[a] += y * (n && f ? -1 : 1); + } + return w; + } + async function A(t, e) { + var n; + void 0 === e && (e = {}); + const { x: i, y: o, platform: r, rects: a, elements: l, strategy: s } = t, + { + boundary: c = "clippingAncestors", + rootBoundary: u = "viewport", + elementContext: m = "floating", + altBoundary: d = !1, + padding: g = 0, + } = f(e, t), + p = x(g), + h = l[d ? ("floating" === m ? "reference" : "floating") : m], + y = v( + await r.getClippingRect({ + element: + null == + (n = await (null == r.isElement ? void 0 : r.isElement(h))) || n + ? h + : h.contextElement || + (await (null == r.getDocumentElement + ? void 0 + : r.getDocumentElement(l.floating))), + boundary: c, + rootBoundary: u, + strategy: s, + }) + ), + w = + "floating" === m + ? { x: i, y: o, width: a.floating.width, height: a.floating.height } + : a.reference, + b = await (null == r.getOffsetParent + ? void 0 + : r.getOffsetParent(l.floating)), + A = ((await (null == r.isElement ? void 0 : r.isElement(b))) && + (await (null == r.getScale ? void 0 : r.getScale(b)))) || { + x: 1, + y: 1, + }, + R = v( + r.convertOffsetParentRelativeRectToViewportRelativeRect + ? await r.convertOffsetParentRelativeRectToViewportRelativeRect({ + elements: l, + rect: w, + offsetParent: b, + strategy: s, + }) + : w + ); + return { + top: (y.top - R.top + p.top) / A.y, + bottom: (R.bottom - y.bottom + p.bottom) / A.y, + left: (y.left - R.left + p.left) / A.x, + right: (R.right - y.right + p.right) / A.x, + }; + } + function R(t, e) { + return { + top: t.top - e.height, + right: t.right - e.width, + bottom: t.bottom - e.height, + left: t.left - e.width, + }; + } + function P(t) { + return e.some((e) => t[e] >= 0); + } + function D(t) { + const e = o(...t.map((t) => t.left)), + n = o(...t.map((t) => t.top)); + return { + x: e, + y: n, + width: r(...t.map((t) => t.right)) - e, + height: r(...t.map((t) => t.bottom)) - n, + }; + } + (t.arrow = (t) => ({ + name: "arrow", + options: t, + async fn(e) { + const { + x: n, + y: i, + placement: r, + rects: a, + platform: l, + elements: c, + middlewareData: m, + } = e, + { element: g, padding: h = 0 } = f(t, e) || {}; + if (null == g) return {}; + const y = x(h), + w = { x: n, y: i }, + v = p(r), + b = d(v), + A = await l.getDimensions(g), + R = "y" === v, + P = R ? "top" : "left", + D = R ? "bottom" : "right", + T = R ? "clientHeight" : "clientWidth", + O = a.reference[b] + a.reference[v] - w[v] - a.floating[b], + E = w[v] - a.reference[v], + L = await (null == l.getOffsetParent ? void 0 : l.getOffsetParent(g)); + let k = L ? L[T] : 0; + (k && (await (null == l.isElement ? void 0 : l.isElement(L)))) || + (k = c.floating[T] || a.floating[b]); + const C = O / 2 - E / 2, + B = k / 2 - A[b] / 2 - 1, + H = o(y[P], B), + S = o(y[D], B), + F = H, + j = k - A[b] - S, + z = k / 2 - A[b] / 2 + C, + M = s(F, z, j), + V = + !m.arrow && + null != u(r) && + z !== M && + a.reference[b] / 2 - (z < F ? H : S) - A[b] / 2 < 0, + W = V ? (z < F ? z - F : z - j) : 0; + return { + [v]: w[v] + W, + data: { + [v]: M, + centerOffset: z - M - W, + ...(V && { alignmentOffset: W }), + }, + reset: V, + }; + }, + })), + (t.autoPlacement = function (t) { + return ( + void 0 === t && (t = {}), + { + name: "autoPlacement", + options: t, + async fn(e) { + var n, o, r; + const { + rects: a, + middlewareData: l, + placement: s, + platform: m, + elements: d, + } = e, + { + crossAxis: g = !1, + alignment: p, + allowedPlacements: w = i, + autoAlignment: x = !0, + ...v + } = f(t, e), + b = + void 0 !== p || w === i + ? (function (t, e, n) { + return ( + t + ? [ + ...n.filter((e) => u(e) === t), + ...n.filter((e) => u(e) !== t), + ] + : n.filter((t) => c(t) === t) + ).filter((n) => !t || u(n) === t || (!!e && y(n) !== n)); + })(p || null, x, w) + : w, + R = await A(e, v), + P = (null == (n = l.autoPlacement) ? void 0 : n.index) || 0, + D = b[P]; + if (null == D) return {}; + const T = h( + D, + a, + await (null == m.isRTL ? void 0 : m.isRTL(d.floating)) + ); + if (s !== D) return { reset: { placement: b[0] } }; + const O = [R[c(D)], R[T[0]], R[T[1]]], + E = [ + ...((null == (o = l.autoPlacement) ? void 0 : o.overflows) || + []), + { placement: D, overflows: O }, + ], + L = b[P + 1]; + if (L) + return { + data: { index: P + 1, overflows: E }, + reset: { placement: L }, + }; + const k = E.map((t) => { + const e = u(t.placement); + return [ + t.placement, + e && g + ? t.overflows.slice(0, 2).reduce((t, e) => t + e, 0) + : t.overflows[0], + t.overflows, + ]; + }).sort((t, e) => t[1] - e[1]), + C = + (null == + (r = k.filter((t) => + t[2].slice(0, u(t[0]) ? 2 : 3).every((t) => t <= 0) + )[0]) + ? void 0 + : r[0]) || k[0][0]; + return C !== s + ? { + data: { index: P + 1, overflows: E }, + reset: { placement: C }, + } + : {}; + }, + } + ); + }), + (t.computePosition = async (t, e, n) => { + const { + placement: i = "bottom", + strategy: o = "absolute", + middleware: r = [], + platform: a, + } = n, + l = r.filter(Boolean), + s = await (null == a.isRTL ? void 0 : a.isRTL(e)); + let f = await a.getElementRects({ + reference: t, + floating: e, + strategy: o, + }), + { x: c, y: u } = b(f, i, s), + m = i, + d = {}, + g = 0; + for (let n = 0; n < l.length; n++) { + const { name: r, fn: p } = l[n], + { + x: h, + y: y, + data: w, + reset: x, + } = await p({ + x: c, + y: u, + initialPlacement: i, + placement: m, + strategy: o, + middlewareData: d, + rects: f, + platform: a, + elements: { reference: t, floating: e }, + }); + (c = null != h ? h : c), + (u = null != y ? y : u), + (d = { ...d, [r]: { ...d[r], ...w } }), + x && + g <= 50 && + (g++, + "object" == typeof x && + (x.placement && (m = x.placement), + x.rects && + (f = + !0 === x.rects + ? await a.getElementRects({ + reference: t, + floating: e, + strategy: o, + }) + : x.rects), + ({ x: c, y: u } = b(f, m, s))), + (n = -1)); + } + return { x: c, y: u, placement: m, strategy: o, middlewareData: d }; + }), + (t.detectOverflow = A), + (t.flip = function (t) { + return ( + void 0 === t && (t = {}), + { + name: "flip", + options: t, + async fn(e) { + var n, i; + const { + placement: o, + middlewareData: r, + rects: a, + initialPlacement: l, + platform: s, + elements: m, + } = e, + { + mainAxis: d = !0, + crossAxis: p = !0, + fallbackPlacements: x, + fallbackStrategy: v = "bestFit", + fallbackAxisSideDirection: b = "none", + flipAlignment: R = !0, + ...P + } = f(t, e); + if (null != (n = r.arrow) && n.alignmentOffset) return {}; + const D = c(o), + T = g(l), + O = c(l) === l, + E = await (null == s.isRTL ? void 0 : s.isRTL(m.floating)), + L = + x || + (O || !R + ? [w(l)] + : (function (t) { + const e = w(t); + return [y(t), e, y(e)]; + })(l)), + k = "none" !== b; + !x && + k && + L.push( + ...(function (t, e, n, i) { + const o = u(t); + let r = (function (t, e, n) { + const i = ["left", "right"], + o = ["right", "left"], + r = ["top", "bottom"], + a = ["bottom", "top"]; + switch (t) { + case "top": + case "bottom": + return n ? (e ? o : i) : e ? i : o; + case "left": + case "right": + return e ? r : a; + default: + return []; + } + })(c(t), "start" === n, i); + return ( + o && + ((r = r.map((t) => t + "-" + o)), + e && (r = r.concat(r.map(y)))), + r + ); + })(l, R, b, E) + ); + const C = [l, ...L], + B = await A(e, P), + H = []; + let S = (null == (i = r.flip) ? void 0 : i.overflows) || []; + if ((d && H.push(B[D]), p)) { + const t = h(o, a, E); + H.push(B[t[0]], B[t[1]]); + } + if ( + ((S = [...S, { placement: o, overflows: H }]), + !H.every((t) => t <= 0)) + ) { + var F, j; + const t = ((null == (F = r.flip) ? void 0 : F.index) || 0) + 1, + e = C[t]; + if (e) { + var z; + const n = "alignment" === p && T !== g(e), + i = (null == (z = S[0]) ? void 0 : z.overflows[0]) > 0; + if (!n || i) + return { + data: { index: t, overflows: S }, + reset: { placement: e }, + }; + } + let n = + null == + (j = S.filter((t) => t.overflows[0] <= 0).sort( + (t, e) => t.overflows[1] - e.overflows[1] + )[0]) + ? void 0 + : j.placement; + if (!n) + switch (v) { + case "bestFit": { + var M; + const t = + null == + (M = S.filter((t) => { + if (k) { + const e = g(t.placement); + return e === T || "y" === e; + } + return !0; + }) + .map((t) => [ + t.placement, + t.overflows + .filter((t) => t > 0) + .reduce((t, e) => t + e, 0), + ]) + .sort((t, e) => t[1] - e[1])[0]) + ? void 0 + : M[0]; + t && (n = t); + break; + } + case "initialPlacement": + n = l; + } + if (o !== n) return { reset: { placement: n } }; + } + return {}; + }, + } + ); + }), + (t.hide = function (t) { + return ( + void 0 === t && (t = {}), + { + name: "hide", + options: t, + async fn(e) { + const { rects: n } = e, + { strategy: i = "referenceHidden", ...o } = f(t, e); + switch (i) { + case "referenceHidden": { + const t = R( + await A(e, { ...o, elementContext: "reference" }), + n.reference + ); + return { + data: { referenceHiddenOffsets: t, referenceHidden: P(t) }, + }; + } + case "escaped": { + const t = R(await A(e, { ...o, altBoundary: !0 }), n.floating); + return { data: { escapedOffsets: t, escaped: P(t) } }; + } + default: + return {}; + } + }, + } + ); + }), + (t.inline = function (t) { + return ( + void 0 === t && (t = {}), + { + name: "inline", + options: t, + async fn(e) { + const { + placement: n, + elements: i, + rects: a, + platform: l, + strategy: s, + } = e, + { padding: u = 2, x: m, y: d } = f(t, e), + p = Array.from( + (await (null == l.getClientRects + ? void 0 + : l.getClientRects(i.reference))) || [] + ), + h = (function (t) { + const e = t.slice().sort((t, e) => t.y - e.y), + n = []; + let i = null; + for (let t = 0; t < e.length; t++) { + const o = e[t]; + !i || o.y - i.y > i.height / 2 + ? n.push([o]) + : n[n.length - 1].push(o), + (i = o); + } + return n.map((t) => v(D(t))); + })(p), + y = v(D(p)), + w = x(u); + const b = await l.getElementRects({ + reference: { + getBoundingClientRect: function () { + if ( + 2 === h.length && + h[0].left > h[1].right && + null != m && + null != d + ) + return ( + h.find( + (t) => + m > t.left - w.left && + m < t.right + w.right && + d > t.top - w.top && + d < t.bottom + w.bottom + ) || y + ); + if (h.length >= 2) { + if ("y" === g(n)) { + const t = h[0], + e = h[h.length - 1], + i = "top" === c(n), + o = t.top, + r = e.bottom, + a = i ? t.left : e.left, + l = i ? t.right : e.right; + return { + top: o, + bottom: r, + left: a, + right: l, + width: l - a, + height: r - o, + x: a, + y: o, + }; + } + const t = "left" === c(n), + e = r(...h.map((t) => t.right)), + i = o(...h.map((t) => t.left)), + a = h.filter((n) => (t ? n.left === i : n.right === e)), + l = a[0].top, + s = a[a.length - 1].bottom; + return { + top: l, + bottom: s, + left: i, + right: e, + width: e - i, + height: s - l, + x: i, + y: l, + }; + } + return y; + }, + }, + floating: i.floating, + strategy: s, + }); + return a.reference.x !== b.reference.x || + a.reference.y !== b.reference.y || + a.reference.width !== b.reference.width || + a.reference.height !== b.reference.height + ? { reset: { rects: b } } + : {}; + }, + } + ); + }), + (t.limitShift = function (t) { + return ( + void 0 === t && (t = {}), + { + options: t, + fn(e) { + const { x: n, y: i, placement: o, rects: r, middlewareData: a } = e, + { offset: l = 0, mainAxis: s = !0, crossAxis: u = !0 } = f(t, e), + d = { x: n, y: i }, + p = g(o), + h = m(p); + let y = d[h], + w = d[p]; + const x = f(l, e), + v = + "number" == typeof x + ? { mainAxis: x, crossAxis: 0 } + : { mainAxis: 0, crossAxis: 0, ...x }; + if (s) { + const t = "y" === h ? "height" : "width", + e = r.reference[h] - r.floating[t] + v.mainAxis, + n = r.reference[h] + r.reference[t] - v.mainAxis; + y < e ? (y = e) : y > n && (y = n); + } + if (u) { + var b, A; + const t = "y" === h ? "width" : "height", + e = ["top", "left"].includes(c(o)), + n = + r.reference[p] - + r.floating[t] + + ((e && (null == (b = a.offset) ? void 0 : b[p])) || 0) + + (e ? 0 : v.crossAxis), + i = + r.reference[p] + + r.reference[t] + + (e ? 0 : (null == (A = a.offset) ? void 0 : A[p]) || 0) - + (e ? v.crossAxis : 0); + w < n ? (w = n) : w > i && (w = i); + } + return { [h]: y, [p]: w }; + }, + } + ); + }), + (t.offset = function (t) { + return ( + void 0 === t && (t = 0), + { + name: "offset", + options: t, + async fn(e) { + var n, i; + const { x: o, y: r, placement: a, middlewareData: l } = e, + s = await (async function (t, e) { + const { placement: n, platform: i, elements: o } = t, + r = await (null == i.isRTL ? void 0 : i.isRTL(o.floating)), + a = c(n), + l = u(n), + s = "y" === g(n), + m = ["left", "top"].includes(a) ? -1 : 1, + d = r && s ? -1 : 1, + p = f(e, t); + let { + mainAxis: h, + crossAxis: y, + alignmentAxis: w, + } = "number" == typeof p + ? { mainAxis: p, crossAxis: 0, alignmentAxis: null } + : { + mainAxis: p.mainAxis || 0, + crossAxis: p.crossAxis || 0, + alignmentAxis: p.alignmentAxis, + }; + return ( + l && "number" == typeof w && (y = "end" === l ? -1 * w : w), + s ? { x: y * d, y: h * m } : { x: h * m, y: y * d } + ); + })(e, t); + return a === (null == (n = l.offset) ? void 0 : n.placement) && + null != (i = l.arrow) && + i.alignmentOffset + ? {} + : { x: o + s.x, y: r + s.y, data: { ...s, placement: a } }; + }, + } + ); + }), + (t.rectToClientRect = v), + (t.shift = function (t) { + return ( + void 0 === t && (t = {}), + { + name: "shift", + options: t, + async fn(e) { + const { x: n, y: i, placement: o } = e, + { + mainAxis: r = !0, + crossAxis: a = !1, + limiter: l = { + fn: (t) => { + let { x: e, y: n } = t; + return { x: e, y: n }; + }, + }, + ...u + } = f(t, e), + d = { x: n, y: i }, + p = await A(e, u), + h = g(c(o)), + y = m(h); + let w = d[y], + x = d[h]; + if (r) { + const t = "y" === y ? "bottom" : "right"; + w = s(w + p["y" === y ? "top" : "left"], w, w - p[t]); + } + if (a) { + const t = "y" === h ? "bottom" : "right"; + x = s(x + p["y" === h ? "top" : "left"], x, x - p[t]); + } + const v = l.fn({ ...e, [y]: w, [h]: x }); + return { + ...v, + data: { x: v.x - n, y: v.y - i, enabled: { [y]: r, [h]: a } }, + }; + }, + } + ); + }), + (t.size = function (t) { + return ( + void 0 === t && (t = {}), + { + name: "size", + options: t, + async fn(e) { + var n, i; + const { placement: a, rects: l, platform: s, elements: m } = e, + { apply: d = () => {}, ...p } = f(t, e), + h = await A(e, p), + y = c(a), + w = u(a), + x = "y" === g(a), + { width: v, height: b } = l.floating; + let R, P; + "top" === y || "bottom" === y + ? ((R = y), + (P = + w === + ((await (null == s.isRTL ? void 0 : s.isRTL(m.floating))) + ? "start" + : "end") + ? "left" + : "right")) + : ((P = y), (R = "end" === w ? "top" : "bottom")); + const D = b - h.top - h.bottom, + T = v - h.left - h.right, + O = o(b - h[R], D), + E = o(v - h[P], T), + L = !e.middlewareData.shift; + let k = O, + C = E; + if ( + (null != (n = e.middlewareData.shift) && n.enabled.x && (C = T), + null != (i = e.middlewareData.shift) && i.enabled.y && (k = D), + L && !w) + ) { + const t = r(h.left, 0), + e = r(h.right, 0), + n = r(h.top, 0), + i = r(h.bottom, 0); + x + ? (C = + v - 2 * (0 !== t || 0 !== e ? t + e : r(h.left, h.right))) + : (k = + b - 2 * (0 !== n || 0 !== i ? n + i : r(h.top, h.bottom))); + } + await d({ ...e, availableWidth: C, availableHeight: k }); + const B = await s.getDimensions(m.floating); + return v !== B.width || b !== B.height + ? { reset: { rects: !0 } } + : {}; + }, + } + ); + }); +}); diff --git a/assets/js/floating_ui_dom.js b/assets/js/floating_ui_dom.js new file mode 100644 index 0000000..aee440f --- /dev/null +++ b/assets/js/floating_ui_dom.js @@ -0,0 +1,604 @@ +// https://cdn.jsdelivr.net/npm/@floating-ui/dom@1.7.0 +!(function (t, e) { + "object" == typeof exports && "undefined" != typeof module + ? e(exports, require("./floating_ui_core")) + : "function" == typeof define && define.amd + ? define(["exports", "./floatingUICore"], e) + : e( + ((t = + "undefined" != typeof globalThis + ? globalThis + : t || self).FloatingUIDOM = {}), + t.FloatingUICore + ); +})(this, function (t, e) { + "use strict"; + const n = Math.min, + o = Math.max, + i = Math.round, + r = Math.floor, + c = (t) => ({ x: t, y: t }); + function l() { + return "undefined" != typeof window; + } + function s(t) { + return a(t) ? (t.nodeName || "").toLowerCase() : "#document"; + } + function f(t) { + var e; + return ( + (null == t || null == (e = t.ownerDocument) ? void 0 : e.defaultView) || + window + ); + } + function u(t) { + var e; + return null == + (e = (a(t) ? t.ownerDocument : t.document) || window.document) + ? void 0 + : e.documentElement; + } + function a(t) { + return !!l() && (t instanceof Node || t instanceof f(t).Node); + } + function d(t) { + return !!l() && (t instanceof Element || t instanceof f(t).Element); + } + function h(t) { + return !!l() && (t instanceof HTMLElement || t instanceof f(t).HTMLElement); + } + function p(t) { + return ( + !(!l() || "undefined" == typeof ShadowRoot) && + (t instanceof ShadowRoot || t instanceof f(t).ShadowRoot) + ); + } + function g(t) { + const { overflow: e, overflowX: n, overflowY: o, display: i } = b(t); + return ( + /auto|scroll|overlay|hidden|clip/.test(e + o + n) && + !["inline", "contents"].includes(i) + ); + } + function m(t) { + return ["table", "td", "th"].includes(s(t)); + } + function y(t) { + return [":popover-open", ":modal"].some((e) => { + try { + return t.matches(e); + } catch (t) { + return !1; + } + }); + } + function w(t) { + const e = x(), + n = d(t) ? b(t) : t; + return ( + ["transform", "translate", "scale", "rotate", "perspective"].some( + (t) => !!n[t] && "none" !== n[t] + ) || + (!!n.containerType && "normal" !== n.containerType) || + (!e && !!n.backdropFilter && "none" !== n.backdropFilter) || + (!e && !!n.filter && "none" !== n.filter) || + [ + "transform", + "translate", + "scale", + "rotate", + "perspective", + "filter", + ].some((t) => (n.willChange || "").includes(t)) || + ["paint", "layout", "strict", "content"].some((t) => + (n.contain || "").includes(t) + ) + ); + } + function x() { + return ( + !("undefined" == typeof CSS || !CSS.supports) && + CSS.supports("-webkit-backdrop-filter", "none") + ); + } + function v(t) { + return ["html", "body", "#document"].includes(s(t)); + } + function b(t) { + return f(t).getComputedStyle(t); + } + function T(t) { + return d(t) + ? { scrollLeft: t.scrollLeft, scrollTop: t.scrollTop } + : { scrollLeft: t.scrollX, scrollTop: t.scrollY }; + } + function L(t) { + if ("html" === s(t)) return t; + const e = t.assignedSlot || t.parentNode || (p(t) && t.host) || u(t); + return p(e) ? e.host : e; + } + function R(t) { + const e = L(t); + return v(e) + ? t.ownerDocument + ? t.ownerDocument.body + : t.body + : h(e) && g(e) + ? e + : R(e); + } + function C(t, e, n) { + var o; + void 0 === e && (e = []), void 0 === n && (n = !0); + const i = R(t), + r = i === (null == (o = t.ownerDocument) ? void 0 : o.body), + c = f(i); + if (r) { + const t = E(c); + return e.concat( + c, + c.visualViewport || [], + g(i) ? i : [], + t && n ? C(t) : [] + ); + } + return e.concat(i, C(i, [], n)); + } + function E(t) { + return t.parent && Object.getPrototypeOf(t.parent) ? t.frameElement : null; + } + function S(t) { + const e = b(t); + let n = parseFloat(e.width) || 0, + o = parseFloat(e.height) || 0; + const r = h(t), + c = r ? t.offsetWidth : n, + l = r ? t.offsetHeight : o, + s = i(n) !== c || i(o) !== l; + return s && ((n = c), (o = l)), { width: n, height: o, $: s }; + } + function F(t) { + return d(t) ? t : t.contextElement; + } + function O(t) { + const e = F(t); + if (!h(e)) return c(1); + const n = e.getBoundingClientRect(), + { width: o, height: r, $: l } = S(e); + let s = (l ? i(n.width) : n.width) / o, + f = (l ? i(n.height) : n.height) / r; + return ( + (s && Number.isFinite(s)) || (s = 1), + (f && Number.isFinite(f)) || (f = 1), + { x: s, y: f } + ); + } + const D = c(0); + function H(t) { + const e = f(t); + return x() && e.visualViewport + ? { x: e.visualViewport.offsetLeft, y: e.visualViewport.offsetTop } + : D; + } + function P(t, n, o, i) { + void 0 === n && (n = !1), void 0 === o && (o = !1); + const r = t.getBoundingClientRect(), + l = F(t); + let s = c(1); + n && (i ? d(i) && (s = O(i)) : (s = O(t))); + const u = (function (t, e, n) { + return void 0 === e && (e = !1), !(!n || (e && n !== f(t))) && e; + })(l, o, i) + ? H(l) + : c(0); + let a = (r.left + u.x) / s.x, + h = (r.top + u.y) / s.y, + p = r.width / s.x, + g = r.height / s.y; + if (l) { + const t = f(l), + e = i && d(i) ? f(i) : i; + let n = t, + o = E(n); + for (; o && i && e !== n; ) { + const t = O(o), + e = o.getBoundingClientRect(), + i = b(o), + r = e.left + (o.clientLeft + parseFloat(i.paddingLeft)) * t.x, + c = e.top + (o.clientTop + parseFloat(i.paddingTop)) * t.y; + (a *= t.x), + (h *= t.y), + (p *= t.x), + (g *= t.y), + (a += r), + (h += c), + (n = f(o)), + (o = E(n)); + } + } + return e.rectToClientRect({ width: p, height: g, x: a, y: h }); + } + function W(t, e) { + const n = T(t).scrollLeft; + return e ? e.left + n : P(u(t)).left + n; + } + function M(t, e, n) { + void 0 === n && (n = !1); + const o = t.getBoundingClientRect(); + return { + x: o.left + e.scrollLeft - (n ? 0 : W(t, o)), + y: o.top + e.scrollTop, + }; + } + function z(t, n, i) { + let r; + if ("viewport" === n) + r = (function (t, e) { + const n = f(t), + o = u(t), + i = n.visualViewport; + let r = o.clientWidth, + c = o.clientHeight, + l = 0, + s = 0; + if (i) { + (r = i.width), (c = i.height); + const t = x(); + (!t || (t && "fixed" === e)) && + ((l = i.offsetLeft), (s = i.offsetTop)); + } + return { width: r, height: c, x: l, y: s }; + })(t, i); + else if ("document" === n) + r = (function (t) { + const e = u(t), + n = T(t), + i = t.ownerDocument.body, + r = o(e.scrollWidth, e.clientWidth, i.scrollWidth, i.clientWidth), + c = o(e.scrollHeight, e.clientHeight, i.scrollHeight, i.clientHeight); + let l = -n.scrollLeft + W(t); + const s = -n.scrollTop; + return ( + "rtl" === b(i).direction && + (l += o(e.clientWidth, i.clientWidth) - r), + { width: r, height: c, x: l, y: s } + ); + })(u(t)); + else if (d(n)) + r = (function (t, e) { + const n = P(t, !0, "fixed" === e), + o = n.top + t.clientTop, + i = n.left + t.clientLeft, + r = h(t) ? O(t) : c(1); + return { + width: t.clientWidth * r.x, + height: t.clientHeight * r.y, + x: i * r.x, + y: o * r.y, + }; + })(n, i); + else { + const e = H(t); + r = { x: n.x - e.x, y: n.y - e.y, width: n.width, height: n.height }; + } + return e.rectToClientRect(r); + } + function A(t, e) { + const n = L(t); + return ( + !(n === e || !d(n) || v(n)) && ("fixed" === b(n).position || A(n, e)) + ); + } + function B(t, e, n) { + const o = h(e), + i = u(e), + r = "fixed" === n, + l = P(t, !0, r, e); + let f = { scrollLeft: 0, scrollTop: 0 }; + const a = c(0); + function d() { + a.x = W(i); + } + if (o || (!o && !r)) + if ((("body" !== s(e) || g(i)) && (f = T(e)), o)) { + const t = P(e, !0, r, e); + (a.x = t.x + e.clientLeft), (a.y = t.y + e.clientTop); + } else i && d(); + r && !o && i && d(); + const p = !i || o || r ? c(0) : M(i, f); + return { + x: l.left + f.scrollLeft - a.x - p.x, + y: l.top + f.scrollTop - a.y - p.y, + width: l.width, + height: l.height, + }; + } + function V(t) { + return "static" === b(t).position; + } + function N(t, e) { + if (!h(t) || "fixed" === b(t).position) return null; + if (e) return e(t); + let n = t.offsetParent; + return u(t) === n && (n = n.ownerDocument.body), n; + } + function I(t, e) { + const n = f(t); + if (y(t)) return n; + if (!h(t)) { + let e = L(t); + for (; e && !v(e); ) { + if (d(e) && !V(e)) return e; + e = L(e); + } + return n; + } + let o = N(t, e); + for (; o && m(o) && V(o); ) o = N(o, e); + return o && v(o) && V(o) && !w(o) + ? n + : o || + (function (t) { + let e = L(t); + for (; h(e) && !v(e); ) { + if (w(e)) return e; + if (y(e)) return null; + e = L(e); + } + return null; + })(t) || + n; + } + const k = { + convertOffsetParentRelativeRectToViewportRelativeRect: function (t) { + let { elements: e, rect: n, offsetParent: o, strategy: i } = t; + const r = "fixed" === i, + l = u(o), + f = !!e && y(e.floating); + if (o === l || (f && r)) return n; + let a = { scrollLeft: 0, scrollTop: 0 }, + d = c(1); + const p = c(0), + m = h(o); + if ( + (m || (!m && !r)) && + (("body" !== s(o) || g(l)) && (a = T(o)), h(o)) + ) { + const t = P(o); + (d = O(o)), (p.x = t.x + o.clientLeft), (p.y = t.y + o.clientTop); + } + const w = !l || m || r ? c(0) : M(l, a, !0); + return { + width: n.width * d.x, + height: n.height * d.y, + x: n.x * d.x - a.scrollLeft * d.x + p.x + w.x, + y: n.y * d.y - a.scrollTop * d.y + p.y + w.y, + }; + }, + getDocumentElement: u, + getClippingRect: function (t) { + let { element: e, boundary: i, rootBoundary: r, strategy: c } = t; + const l = [ + ...("clippingAncestors" === i + ? y(e) + ? [] + : (function (t, e) { + const n = e.get(t); + if (n) return n; + let o = C(t, [], !1).filter((t) => d(t) && "body" !== s(t)), + i = null; + const r = "fixed" === b(t).position; + let c = r ? L(t) : t; + for (; d(c) && !v(c); ) { + const e = b(c), + n = w(c); + n || "fixed" !== e.position || (i = null), + ( + r + ? !n && !i + : (!n && + "static" === e.position && + i && + ["absolute", "fixed"].includes(i.position)) || + (g(c) && !n && A(t, c)) + ) + ? (o = o.filter((t) => t !== c)) + : (i = e), + (c = L(c)); + } + return e.set(t, o), o; + })(e, this._c) + : [].concat(i)), + r, + ], + f = l[0], + u = l.reduce((t, i) => { + const r = z(e, i, c); + return ( + (t.top = o(r.top, t.top)), + (t.right = n(r.right, t.right)), + (t.bottom = n(r.bottom, t.bottom)), + (t.left = o(r.left, t.left)), + t + ); + }, z(e, f, c)); + return { + width: u.right - u.left, + height: u.bottom - u.top, + x: u.left, + y: u.top, + }; + }, + getOffsetParent: I, + getElementRects: async function (t) { + const e = this.getOffsetParent || I, + n = this.getDimensions, + o = await n(t.floating); + return { + reference: B(t.reference, await e(t.floating), t.strategy), + floating: { x: 0, y: 0, width: o.width, height: o.height }, + }; + }, + getClientRects: function (t) { + return Array.from(t.getClientRects()); + }, + getDimensions: function (t) { + const { width: e, height: n } = S(t); + return { width: e, height: n }; + }, + getScale: O, + isElement: d, + isRTL: function (t) { + return "rtl" === b(t).direction; + }, + }; + function q(t, e) { + return ( + t.x === e.x && t.y === e.y && t.width === e.width && t.height === e.height + ); + } + const U = e.detectOverflow, + j = e.offset, + X = e.autoPlacement, + Y = e.shift, + $ = e.flip, + _ = e.size, + G = e.hide, + J = e.arrow, + K = e.inline, + Q = e.limitShift; + (t.arrow = J), + (t.autoPlacement = X), + (t.autoUpdate = function (t, e, i, c) { + void 0 === c && (c = {}); + const { + ancestorScroll: l = !0, + ancestorResize: s = !0, + elementResize: f = "function" == typeof ResizeObserver, + layoutShift: a = "function" == typeof IntersectionObserver, + animationFrame: d = !1, + } = c, + h = F(t), + p = l || s ? [...(h ? C(h) : []), ...C(e)] : []; + p.forEach((t) => { + l && t.addEventListener("scroll", i, { passive: !0 }), + s && t.addEventListener("resize", i); + }); + const g = + h && a + ? (function (t, e) { + let i, + c = null; + const l = u(t); + function s() { + var t; + clearTimeout(i), null == (t = c) || t.disconnect(), (c = null); + } + return ( + (function f(u, a) { + void 0 === u && (u = !1), void 0 === a && (a = 1), s(); + const d = t.getBoundingClientRect(), + { left: h, top: p, width: g, height: m } = d; + if ((u || e(), !g || !m)) return; + const y = { + rootMargin: + -r(p) + + "px " + + -r(l.clientWidth - (h + g)) + + "px " + + -r(l.clientHeight - (p + m)) + + "px " + + -r(h) + + "px", + threshold: o(0, n(1, a)) || 1, + }; + let w = !0; + function x(e) { + const n = e[0].intersectionRatio; + if (n !== a) { + if (!w) return f(); + n + ? f(!1, n) + : (i = setTimeout(() => { + f(!1, 1e-7); + }, 1e3)); + } + 1 !== n || q(d, t.getBoundingClientRect()) || f(), (w = !1); + } + try { + c = new IntersectionObserver(x, { + ...y, + root: l.ownerDocument, + }); + } catch (t) { + c = new IntersectionObserver(x, y); + } + c.observe(t); + })(!0), + s + ); + })(h, i) + : null; + let m, + y = -1, + w = null; + f && + ((w = new ResizeObserver((t) => { + let [n] = t; + n && + n.target === h && + w && + (w.unobserve(e), + cancelAnimationFrame(y), + (y = requestAnimationFrame(() => { + var t; + null == (t = w) || t.observe(e); + }))), + i(); + })), + h && !d && w.observe(h), + w.observe(e)); + let x = d ? P(t) : null; + return ( + d && + (function e() { + const n = P(t); + x && !q(x, n) && i(); + (x = n), (m = requestAnimationFrame(e)); + })(), + i(), + () => { + var t; + p.forEach((t) => { + l && t.removeEventListener("scroll", i), + s && t.removeEventListener("resize", i); + }), + null == g || g(), + null == (t = w) || t.disconnect(), + (w = null), + d && cancelAnimationFrame(m); + } + ); + }), + (t.computePosition = (t, n, o) => { + const i = new Map(), + r = { platform: k, ...o }, + c = { ...r.platform, _c: i }; + return e.computePosition(t, n, { ...r, platform: c }); + }), + (t.detectOverflow = U), + (t.flip = $), + (t.getOverflowAncestors = C), + (t.hide = G), + (t.inline = K), + (t.limitShift = Q), + (t.offset = j), + (t.platform = k), + (t.shift = Y), + (t.size = _); + + // We put this manually here because we need to make sure it's available + // before the popover component is initialized. + window.FloatingUIDOM = t; + return t; +}); diff --git a/assets/js/input.js b/assets/js/input.js new file mode 100644 index 0000000..9709875 --- /dev/null +++ b/assets/js/input.js @@ -0,0 +1,25 @@ +(function () { + 'use strict'; + + document.addEventListener('click', (e) => { + const button = e.target.closest('[data-tui-input-toggle-password]'); + if (!button) return; + + const inputId = button.getAttribute('data-tui-input-toggle-password'); + const input = document.getElementById(inputId); + if (!input) return; + + const iconOpen = button.querySelector('.icon-open'); + const iconClosed = button.querySelector('.icon-closed'); + + if (input.type === 'password') { + input.type = 'text'; + if (iconOpen) iconOpen.classList.add('hidden'); + if (iconClosed) iconClosed.classList.remove('hidden'); + } else { + input.type = 'password'; + if (iconOpen) iconOpen.classList.remove('hidden'); + if (iconClosed) iconClosed.classList.add('hidden'); + } + }); +})(); diff --git a/assets/js/inputotp.js b/assets/js/inputotp.js new file mode 100644 index 0000000..701452f --- /dev/null +++ b/assets/js/inputotp.js @@ -0,0 +1,207 @@ +(function () { + 'use strict'; + + function getEventTargetElement(event) { + return event.target instanceof Element ? event.target : null; + } + + // Utility functions + function getSlots(container) { + return Array.from(container.querySelectorAll('[data-tui-inputotp-slot]')).sort( + (a, b) => parseInt(a.getAttribute('data-tui-inputotp-index')) - parseInt(b.getAttribute('data-tui-inputotp-index')) + ); + } + + function focusSlot(slot) { + if (!slot) return; + slot.focus(); + setTimeout(() => slot.select(), 0); + } + + function updateHiddenValue(container) { + const hiddenInput = container.querySelector('[data-tui-inputotp-value-target]'); + const slots = getSlots(container); + if (hiddenInput && slots.length) { + hiddenInput.value = slots.map(s => s.value).join(''); + } + } + + function findFirstEmptySlot(container) { + const slots = getSlots(container); + for (const slot of slots) { + if (!slot.value) return slot; + } + return null; + } + + function getNextSlot(container, currentSlot) { + const slots = getSlots(container); + const index = slots.indexOf(currentSlot); + return index >= 0 && index < slots.length - 1 ? slots[index + 1] : null; + } + + function getPrevSlot(container, currentSlot) { + const slots = getSlots(container); + const index = slots.indexOf(currentSlot); + return index > 0 ? slots[index - 1] : null; + } + + // Event handlers + document.addEventListener('input', (e) => { + const target = getEventTargetElement(e); + if (!target?.matches('[data-tui-inputotp-slot]')) return; + + const slot = target; + const container = slot.closest('[data-tui-inputotp]'); + if (!container) return; + + // Handle space as empty + if (slot.value === ' ') { + slot.value = ''; + return; + } + + // Keep only last character + if (slot.value.length > 1) { + slot.value = slot.value.slice(-1); + } + + // Move to next slot if filled + if (slot.value) { + const nextSlot = getNextSlot(container, slot); + if (nextSlot) focusSlot(nextSlot); + } + + updateHiddenValue(container); + }); + + document.addEventListener('keydown', (e) => { + const target = getEventTargetElement(e); + if (!target?.matches('[data-tui-inputotp-slot]')) return; + + const slot = target; + const container = slot.closest('[data-tui-inputotp]'); + if (!container) return; + + if (e.key === 'Backspace') { + e.preventDefault(); + + if (slot.value) { + slot.value = ''; + updateHiddenValue(container); + } else { + const prevSlot = getPrevSlot(container, slot); + if (prevSlot) { + prevSlot.value = ''; + updateHiddenValue(container); + focusSlot(prevSlot); + } + } + } else if (e.key === 'ArrowLeft') { + e.preventDefault(); + const prevSlot = getPrevSlot(container, slot); + if (prevSlot) focusSlot(prevSlot); + } else if (e.key === 'ArrowRight') { + e.preventDefault(); + const nextSlot = getNextSlot(container, slot); + if (nextSlot) focusSlot(nextSlot); + } + }); + + document.addEventListener('focus', (e) => { + const target = getEventTargetElement(e); + if (!target?.matches('[data-tui-inputotp-slot]')) return; + + const slot = target; + const container = slot.closest('[data-tui-inputotp]'); + if (!container) return; + + // Redirect to first empty slot + const firstEmpty = findFirstEmptySlot(container); + if (firstEmpty && firstEmpty !== slot) { + focusSlot(firstEmpty); + return; + } + + setTimeout(() => slot.select(), 0); + }, true); + + document.addEventListener('paste', (e) => { + const target = getEventTargetElement(e); + const slot = target?.closest('[data-tui-inputotp-slot]'); + if (!slot) return; + + e.preventDefault(); + const container = slot.closest('[data-tui-inputotp]'); + if (!container) return; + + const pastedData = (e.clipboardData || window.clipboardData).getData('text'); + const chars = pastedData.replace(/\s/g, '').split(''); + const slots = getSlots(container); + + let startIndex = slots.indexOf(slot); + for (let i = 0; i < chars.length && startIndex + i < slots.length; i++) { + slots[startIndex + i].value = chars[i]; + } + + updateHiddenValue(container); + + // Focus next empty or last filled slot + const nextEmpty = findFirstEmptySlot(container); + focusSlot(nextEmpty || slots[Math.min(startIndex + chars.length, slots.length - 1)]); + }); + + // Label click handling + document.addEventListener('click', (e) => { + const target = getEventTargetElement(e); + if (!target?.matches('label[for]')) return; + + const targetId = target.getAttribute('for'); + const hiddenInput = document.getElementById(targetId); + if (!hiddenInput?.matches('[data-tui-inputotp-value-target]')) return; + + e.preventDefault(); + const container = hiddenInput.closest('[data-tui-inputotp]'); + const slots = getSlots(container); + if (slots.length > 0) focusSlot(slots[0]); + }); + + // Form reset + document.addEventListener('reset', (e) => { + const target = getEventTargetElement(e); + if (!target?.matches('form')) return; + + target.querySelectorAll('[data-tui-inputotp]').forEach(container => { + getSlots(container).forEach(slot => { + slot.value = ''; + }); + updateHiddenValue(container); + }); + }); + + // MutationObserver for initial setup and autofocus + new MutationObserver(() => { + document.querySelectorAll('[data-tui-inputotp]').forEach(container => { + const slots = getSlots(container); + if (slots.length === 0) return; + + // Set initial value if provided + const initialValue = container.getAttribute('data-tui-inputotp-value'); + if (initialValue && !slots[0].value) { + for (let i = 0; i < slots.length && i < initialValue.length; i++) { + if (!slots[i].value) slots[i].value = initialValue[i]; + } + updateHiddenValue(container); + } + + // Handle autofocus + if (container.hasAttribute('autofocus') && !slots.some(s => s === document.activeElement)) { + requestAnimationFrame(() => { + if (slots[0] && !slots.some(s => s === document.activeElement)) { + focusSlot(slots[0]); + } + }); + } + }); + }).observe(document.body, { childList: true, subtree: true }); +})(); diff --git a/assets/js/inputotp.min.js b/assets/js/inputotp.min.js index d8e7ad5..7fafd77 100644 --- a/assets/js/inputotp.min.js +++ b/assets/js/inputotp.min.js @@ -1 +1 @@ -(()=>{(function(){"use strict";function u(e){return Array.from(e.querySelectorAll("[data-tui-inputotp-slot]")).sort((t,n)=>parseInt(t.getAttribute("data-tui-inputotp-index"))-parseInt(n.getAttribute("data-tui-inputotp-index")))}function a(e){e&&(e.focus(),setTimeout(()=>e.select(),0))}function i(e){let t=e.querySelector("[data-tui-inputotp-value-target]"),n=u(e);t&&n.length&&(t.value=n.map(o=>o.value).join(""))}function d(e){let t=u(e);for(let n of t)if(!n.value)return n;return null}function f(e,t){let n=u(e),o=n.indexOf(t);return o>=0&&o0?n[o-1]:null}document.addEventListener("input",e=>{if(!e.target.matches("[data-tui-inputotp-slot]"))return;let t=e.target,n=t.closest("[data-tui-inputotp]");if(n){if(t.value===" "){t.value="";return}if(t.value.length>1&&(t.value=t.value.slice(-1)),t.value){let o=f(n,t);o&&a(o)}i(n)}}),document.addEventListener("keydown",e=>{if(!e.target.matches("[data-tui-inputotp-slot]"))return;let t=e.target,n=t.closest("[data-tui-inputotp]");if(n){if(e.key==="Backspace")if(e.preventDefault(),t.value)t.value="",i(n);else{let o=p(n,t);o&&(o.value="",i(n),a(o))}else if(e.key==="ArrowLeft"){e.preventDefault();let o=p(n,t);o&&a(o)}else if(e.key==="ArrowRight"){e.preventDefault();let o=f(n,t);o&&a(o)}}}),document.addEventListener("focus",e=>{if(!e.target.matches("[data-tui-inputotp-slot]"))return;let t=e.target,n=t.closest("[data-tui-inputotp]");if(!n)return;let o=d(n);if(o&&o!==t){a(o);return}setTimeout(()=>t.select(),0)},!0),document.addEventListener("paste",e=>{let t=e.target.closest("[data-tui-inputotp-slot]");if(!t)return;e.preventDefault();let n=t.closest("[data-tui-inputotp]");if(!n)return;let r=(e.clipboardData||window.clipboardData).getData("text").replace(/\s/g,"").split(""),s=u(n),c=s.indexOf(t);for(let l=0;l{if(!e.target.matches("label[for]"))return;let t=e.target.getAttribute("for"),n=document.getElementById(t);if(!n?.matches("[data-tui-inputotp-value-target]"))return;e.preventDefault();let o=n.closest("[data-tui-inputotp]"),r=u(o);r.length>0&&a(r[0])}),document.addEventListener("reset",e=>{e.target.matches("form")&&e.target.querySelectorAll("[data-tui-inputotp]").forEach(t=>{u(t).forEach(n=>{n.value=""}),i(t)})}),new MutationObserver(()=>{document.querySelectorAll("[data-tui-inputotp]").forEach(e=>{let t=u(e);if(t.length===0)return;let n=e.getAttribute("data-tui-inputotp-value");if(n&&!t[0].value){for(let o=0;oo===document.activeElement)&&requestAnimationFrame(()=>{t[0]&&!t.some(o=>o===document.activeElement)&&a(t[0])})})}).observe(document.body,{childList:!0,subtree:!0})})();})(); +(()=>{(function(){"use strict";function s(e){return e.target instanceof Element?e.target:null}function a(e){return Array.from(e.querySelectorAll("[data-tui-inputotp-slot]")).sort((o,t)=>parseInt(o.getAttribute("data-tui-inputotp-index"))-parseInt(t.getAttribute("data-tui-inputotp-index")))}function i(e){e&&(e.focus(),setTimeout(()=>e.select(),0))}function r(e){let o=e.querySelector("[data-tui-inputotp-value-target]"),t=a(e);o&&t.length&&(o.value=t.map(n=>n.value).join(""))}function p(e){let o=a(e);for(let t of o)if(!t.value)return t;return null}function v(e,o){let t=a(e),n=t.indexOf(o);return n>=0&&n0?t[n-1]:null}document.addEventListener("input",e=>{let o=s(e);if(!o?.matches("[data-tui-inputotp-slot]"))return;let t=o,n=t.closest("[data-tui-inputotp]");if(n){if(t.value===" "){t.value="";return}if(t.value.length>1&&(t.value=t.value.slice(-1)),t.value){let u=v(n,t);u&&i(u)}r(n)}}),document.addEventListener("keydown",e=>{let o=s(e);if(!o?.matches("[data-tui-inputotp-slot]"))return;let t=o,n=t.closest("[data-tui-inputotp]");if(n){if(e.key==="Backspace")if(e.preventDefault(),t.value)t.value="",r(n);else{let u=g(n,t);u&&(u.value="",r(n),i(u))}else if(e.key==="ArrowLeft"){e.preventDefault();let u=g(n,t);u&&i(u)}else if(e.key==="ArrowRight"){e.preventDefault();let u=v(n,t);u&&i(u)}}}),document.addEventListener("focus",e=>{let o=s(e);if(!o?.matches("[data-tui-inputotp-slot]"))return;let t=o,n=t.closest("[data-tui-inputotp]");if(!n)return;let u=p(n);if(u&&u!==t){i(u);return}setTimeout(()=>t.select(),0)},!0),document.addEventListener("paste",e=>{let t=s(e)?.closest("[data-tui-inputotp-slot]");if(!t)return;e.preventDefault();let n=t.closest("[data-tui-inputotp]");if(!n)return;let l=(e.clipboardData||window.clipboardData).getData("text").replace(/\s/g,"").split(""),c=a(n),d=c.indexOf(t);for(let f=0;f{let o=s(e);if(!o?.matches("label[for]"))return;let t=o.getAttribute("for"),n=document.getElementById(t);if(!n?.matches("[data-tui-inputotp-value-target]"))return;e.preventDefault();let u=n.closest("[data-tui-inputotp]"),l=a(u);l.length>0&&i(l[0])}),document.addEventListener("reset",e=>{let o=s(e);o?.matches("form")&&o.querySelectorAll("[data-tui-inputotp]").forEach(t=>{a(t).forEach(n=>{n.value=""}),r(t)})}),new MutationObserver(()=>{document.querySelectorAll("[data-tui-inputotp]").forEach(e=>{let o=a(e);if(o.length===0)return;let t=e.getAttribute("data-tui-inputotp-value");if(t&&!o[0].value){for(let n=0;nn===document.activeElement)&&requestAnimationFrame(()=>{o[0]&&!o.some(n=>n===document.activeElement)&&i(o[0])})})}).observe(document.body,{childList:!0,subtree:!0})})();})(); diff --git a/assets/js/label.js b/assets/js/label.js new file mode 100644 index 0000000..49b0c66 --- /dev/null +++ b/assets/js/label.js @@ -0,0 +1,58 @@ +(function () { + 'use strict'; + + function updateLabelStyle(label) { + const forId = label.getAttribute('for'); + const targetElement = forId ? document.getElementById(forId) : null; + const disabledStyle = label.getAttribute('data-tui-label-disabled-style'); + + if (!targetElement || !disabledStyle) return; + + const classes = disabledStyle.split(' ').filter(Boolean); + + if (targetElement.disabled) { + label.classList.add(...classes); + } else { + label.classList.remove(...classes); + } + } + + document.addEventListener('DOMContentLoaded', () => { + const labelsToObserve = new Set(); + + // Find all labels and their targets + function setupLabels() { + document.querySelectorAll('label[for][data-tui-label-disabled-style]').forEach(label => { + updateLabelStyle(label); + const forId = label.getAttribute('for'); + if (forId) labelsToObserve.add(forId); + }); + } + + setupLabels(); + + // Observe disabled changes on any element + const observer = new MutationObserver((mutations) => { + mutations.forEach((mutation) => { + if (mutation.type === 'attributes' && + mutation.attributeName === 'disabled' && + mutation.target.id && + labelsToObserve.has(mutation.target.id)) { + document.querySelectorAll(`label[for="${mutation.target.id}"][data-tui-label-disabled-style]`).forEach(updateLabelStyle); + } + }); + }); + + // Observe the whole document for disabled changes + observer.observe(document.body, { + attributes: true, + attributeFilter: ['disabled'], + subtree: true + }); + + // Watch for new labels + new MutationObserver(() => { + setupLabels(); + }).observe(document.body, { childList: true, subtree: true }); + }); +})(); diff --git a/assets/js/popover.js b/assets/js/popover.js new file mode 100644 index 0000000..a9cf35b --- /dev/null +++ b/assets/js/popover.js @@ -0,0 +1,447 @@ +import "./floating_ui_core.js"; +import "./floating_ui_dom.js"; + +(function () { + "use strict"; + + const floatingCleanups = new WeakMap(); + const hoverTimeouts = new WeakMap(); + const arrowBaseClass = + "absolute h-2.5 w-2.5 rotate-45 bg-popover border border-border"; + const exitAnimationDuration = 150; + + function getRootById(id) { + const root = document.getElementById(id); + return root?.matches("[data-tui-popover-root]") ? root : null; + } + + function getRoots() { + return Array.from(document.querySelectorAll("[data-tui-popover-root]")); + } + + function getContent(root) { + return Array.from(root?.children || []).find((child) => + child.matches("[data-tui-popover-content]"), + ); + } + + function getTriggers(root) { + return Array.from(root?.children || []).filter((child) => + child.matches("[data-tui-popover-trigger]"), + ); + } + + function getReferenceElement(trigger) { + let ref = trigger; + let maxArea = 0; + + for (const child of trigger.children) { + const rect = child.getBoundingClientRect?.(); + if (!rect) continue; + + const area = rect.width * rect.height; + if (area > maxArea) { + maxArea = area; + ref = child; + } + } + + return ref; + } + + function isHoverRoot(root) { + return getTriggers(root).some( + (trigger) => trigger.getAttribute("data-tui-popover-type") === "hover", + ); + } + + function isOpenRoot(root) { + return getContent(root)?.getAttribute("data-tui-popover-open") === "true"; + } + + function isOpen(id) { + const root = getRootById(id); + return root ? isOpenRoot(root) : false; + } + + function clearHoverTimeouts(root) { + const timeouts = hoverTimeouts.get(root); + if (!timeouts) return; + clearTimeout(timeouts.enter); + clearTimeout(timeouts.leave); + hoverTimeouts.delete(root); + } + + function stopAutoUpdate(root) { + const cleanup = floatingCleanups.get(root); + if (!cleanup) return; + cleanup(); + floatingCleanups.delete(root); + } + + function showContent(content) { + clearTimeout(content._tuiPopoverCloseTimeout); + content._tuiPopoverCloseTimeout = null; + + if (!content.matches(":popover-open")) { + try { + content.showPopover(); + } catch { + return false; + } + } + + requestAnimationFrame(() => { + content.setAttribute("data-tui-popover-open", "true"); + }); + + return true; + } + + function hideContent(content) { + clearTimeout(content._tuiPopoverCloseTimeout); + content._tuiPopoverCloseTimeout = null; + content.setAttribute("data-tui-popover-open", "false"); + + if (!content.matches(":popover-open")) { + return; + } + + content._tuiPopoverCloseTimeout = setTimeout(() => { + content._tuiPopoverCloseTimeout = null; + if (content.matches(":popover-open")) { + try { + content.hidePopover(); + } catch { + // ignore + } + } + }, exitAnimationDuration); + } + + function arrowClassForPlacement(placement) { + switch (placement) { + case "top-start": + case "top": + case "top-end": + return `${arrowBaseClass} -bottom-[5px] border-t-transparent border-l-transparent`; + case "right-start": + case "right": + case "right-end": + return `${arrowBaseClass} -left-[5px] border-r-transparent border-t-transparent`; + case "bottom-start": + case "bottom": + case "bottom-end": + return `${arrowBaseClass} -top-[5px] border-b-transparent border-r-transparent`; + case "left-start": + case "left": + case "left-end": + return `${arrowBaseClass} -right-[5px] border-l-transparent border-b-transparent`; + default: + return `${arrowBaseClass} -top-[5px] border-b-transparent border-r-transparent`; + } + } + + function updatePosition(root, triggerOverride = null) { + if (!window.FloatingUIDOM) return; + + const trigger = triggerOverride || getTriggers(root)[0]; + const content = getContent(root); + if (!trigger || !content) return; + + const { computePosition, offset, flip, shift, arrow } = + window.FloatingUIDOM; + const reference = getReferenceElement(trigger); + const arrowEl = content.querySelector("[data-tui-popover-arrow]"); + const placement = + content.getAttribute("data-tui-popover-placement") || "bottom"; + const offsetValue = + parseInt(content.getAttribute("data-tui-popover-offset"), 10) || + (arrowEl ? 8 : 4); + + const middleware = [ + offset(offsetValue), + flip({ padding: 10 }), + shift({ padding: 10 }), + ]; + + if (arrowEl) { + middleware.push(arrow({ element: arrowEl, padding: 5 })); + } + + // Match the fixed-position popover layer so scroll offsets stay correct. + computePosition(reference, content, { + placement, + middleware, + strategy: "fixed", + }).then(({ x, y, placement: finalPlacement, middlewareData }) => { + Object.assign(content.style, { + left: `${x}px`, + top: `${y}px`, + }); + + if (arrowEl && middlewareData.arrow) { + const { x: arrowX, y: arrowY } = middlewareData.arrow; + + arrowEl.setAttribute("data-tui-popover-placement", finalPlacement); + arrowEl.className = arrowClassForPlacement(finalPlacement); + Object.assign(arrowEl.style, { + left: arrowX != null ? `${arrowX}px` : "", + top: arrowY != null ? `${arrowY}px` : "", + }); + } + }); + } + + function closeRoot(root) { + const content = getContent(root); + if (!content) return; + + stopAutoUpdate(root); + clearHoverTimeouts(root); + + getTriggers(root).forEach((trigger) => { + trigger.setAttribute("data-tui-popover-open", "false"); + }); + + hideContent(content); + } + + function close(id) { + const root = getRootById(id); + if (root) { + closeRoot(root); + } + } + + function closeAllRoots(exceptRoot = null) { + getRoots().forEach((root) => { + if (root !== exceptRoot && isOpenRoot(root)) { + closeRoot(root); + } + }); + } + + function closeAll(exceptId = null) { + closeAllRoots(exceptId ? getRootById(exceptId) : null); + } + + function openRoot(root, triggerOverride = null) { + const content = getContent(root); + const trigger = triggerOverride || getTriggers(root)[0]; + if (!content || !trigger) return; + + if (content.getAttribute("data-tui-popover-exclusive") === "true") { + closeAllRoots(root); + } + + if (!showContent(content)) return; + + getTriggers(root).forEach((item) => { + item.setAttribute("data-tui-popover-open", "true"); + }); + + stopAutoUpdate(root); + updatePosition(root, trigger); + + if (window.FloatingUIDOM) { + const cleanup = window.FloatingUIDOM.autoUpdate( + trigger, + content, + () => updatePosition(root, trigger), + { animationFrame: true }, + ); + floatingCleanups.set(root, cleanup); + } + } + + function open(id) { + const root = getRootById(id); + if (root) { + openRoot(root); + } + } + + function toggleRoot(root, triggerOverride = null) { + if (isOpenRoot(root)) { + closeRoot(root); + return; + } + + openRoot(root, triggerOverride); + } + + function toggle(id) { + const root = getRootById(id); + if (root) { + toggleRoot(root); + } + } + + function clearOtherHoverRoots(activeRoot) { + getRoots().forEach((root) => { + if (root === activeRoot || !isHoverRoot(root)) { + return; + } + + clearHoverTimeouts(root); + closeRoot(root); + }); + } + + function handleHoverEnter(root, trigger) { + const content = getContent(root); + if (!content || !isHoverRoot(root)) return; + + const delay = + parseInt(content.getAttribute("data-tui-popover-hover-delay"), 10) || 100; + const timeouts = hoverTimeouts.get(root) || {}; + + clearOtherHoverRoots(root); + clearTimeout(timeouts.leave); + clearTimeout(timeouts.enter); + timeouts.enter = setTimeout(() => openRoot(root, trigger), delay); + hoverTimeouts.set(root, timeouts); + } + + function handleHoverLeave(root, movingWithinPair) { + const content = getContent(root); + if (!content || !isHoverRoot(root)) return; + + const delay = + parseInt(content.getAttribute("data-tui-popover-hover-out-delay"), 10) || + 200; + const timeouts = hoverTimeouts.get(root) || {}; + + clearTimeout(timeouts.enter); + if (!movingWithinPair) { + timeouts.leave = setTimeout(() => closeRoot(root), delay); + hoverTimeouts.set(root, timeouts); + } + } + + document.addEventListener("click", (event) => { + const trigger = event.target.closest("[data-tui-popover-trigger]"); + const root = trigger?.closest("[data-tui-popover-root]"); + const triggerType = trigger?.getAttribute("data-tui-popover-type"); + + if ( + trigger && + root && + triggerType !== "hover" && + triggerType !== "manual" + ) { + const disabledChild = trigger.querySelector( + ':disabled, [disabled], [aria-disabled="true"]', + ); + if (disabledChild) { + return; + } + + event.preventDefault(); + event.stopPropagation(); + toggleRoot(root, trigger); + return; + } + + getRoots().forEach((currentRoot) => { + const content = getContent(currentRoot); + if ( + !content || + !content.matches(":popover-open") || + content.getAttribute("data-tui-popover-disable-clickaway") === "true" + ) { + return; + } + + const clickedInsideContent = content.contains(event.target); + const clickedTrigger = getTriggers(currentRoot).some((item) => + item.contains(event.target), + ); + + if (!clickedInsideContent && !clickedTrigger) { + closeRoot(currentRoot); + } + }); + }); + + document.addEventListener("mouseover", (event) => { + const trigger = event.target.closest("[data-tui-popover-trigger]"); + const root = trigger?.closest("[data-tui-popover-root]"); + if ( + trigger && + root && + !trigger.contains(event.relatedTarget) && + trigger.getAttribute("data-tui-popover-type") === "hover" + ) { + handleHoverEnter(root, trigger); + } + + const content = event.target.closest("[data-tui-popover-content]"); + const contentRoot = content?.closest("[data-tui-popover-root]"); + if ( + content && + contentRoot && + isHoverRoot(contentRoot) && + !content.contains(event.relatedTarget) && + content.matches(":popover-open") + ) { + const timeouts = hoverTimeouts.get(contentRoot) || {}; + clearTimeout(timeouts.leave); + hoverTimeouts.set(contentRoot, timeouts); + } + }); + + document.addEventListener("mouseout", (event) => { + const trigger = event.target.closest("[data-tui-popover-trigger]"); + const root = trigger?.closest("[data-tui-popover-root]"); + if ( + trigger && + root && + !trigger.contains(event.relatedTarget) && + trigger.getAttribute("data-tui-popover-type") === "hover" + ) { + const content = getContent(root); + handleHoverLeave(root, !!content?.contains(event.relatedTarget)); + } + + const content = event.target.closest("[data-tui-popover-content]"); + const contentRoot = content?.closest("[data-tui-popover-root]"); + if ( + content && + contentRoot && + isHoverRoot(contentRoot) && + !content.contains(event.relatedTarget) && + content.matches(":popover-open") + ) { + const movingToTrigger = getTriggers(contentRoot).some((item) => + item.contains(event.relatedTarget), + ); + handleHoverLeave(contentRoot, movingToTrigger); + } + }); + + document.addEventListener("keydown", (event) => { + if (event.key !== "Escape") return; + + getRoots().forEach((root) => { + const content = getContent(root); + if ( + content && + content.matches(":popover-open") && + content.getAttribute("data-tui-popover-disable-esc") !== "true" + ) { + closeRoot(root); + } + }); + }); + + window.tui = window.tui || {}; + window.tui.popover = { + open, + close, + closeAll, + toggle, + isOpen, + }; +})(); diff --git a/assets/js/popover.min.js b/assets/js/popover.min.js index 4cc6fa3..dc171db 100644 --- a/assets/js/popover.min.js +++ b/assets/js/popover.min.js @@ -1,6 +1 @@ -(()=>{var Vt=Object.create;var qt=Object.defineProperty;var Nt=Object.getOwnPropertyDescriptor;var jt=Object.getOwnPropertyNames;var Xt=Object.getPrototypeOf,Yt=Object.prototype.hasOwnProperty;var It=(g,R)=>()=>(R||g((R={exports:{}}).exports,R),R.exports);var _t=(g,R,at,lt)=>{if(R&&typeof R=="object"||typeof R=="function")for(let Q of jt(R))!Yt.call(g,Q)&&Q!==at&&qt(g,Q,{get:()=>R[Q],enumerable:!(lt=Nt(R,Q))||lt.enumerable});return g};var Wt=(g,R,at)=>(at=g!=null?Vt(Xt(g)):{},_t(R||!g||!g.__esModule?qt(at,"default",{value:g,enumerable:!0}):at,g));var Et=It((Tt,zt)=>{(function(g,R){typeof Tt=="object"&&typeof zt<"u"?R(Tt):typeof define=="function"&&define.amd?define(["exports"],R):R((g=typeof globalThis<"u"?globalThis:g||self).FloatingUICore={})})(Tt,function(g){"use strict";let R=["top","right","bottom","left"],at=["start","end"],lt=R.reduce((n,i)=>n.concat(i,i+"-"+at[0],i+"-"+at[1]),[]),Q=Math.min,G=Math.max,st={left:"right",right:"left",bottom:"top",top:"bottom"},gt={start:"end",end:"start"};function mt(n,i,h){return G(n,Q(i,h))}function V(n,i){return typeof n=="function"?n(i):n}function N(n){return n.split("-")[0]}function it(n){return n.split("-")[1]}function l(n){return n==="x"?"y":"x"}function c(n){return n==="y"?"height":"width"}function A(n){return["top","bottom"].includes(N(n))?"y":"x"}function D(n){return l(A(n))}function I(n,i,h){h===void 0&&(h=!1);let s=it(n),y=D(n),u=c(y),w=y==="x"?s===(h?"end":"start")?"right":"left":s==="start"?"bottom":"top";return i.reference[u]>i.floating[u]&&(w=_(w)),[w,_(w)]}function j(n){return n.replace(/start|end/g,i=>gt[i])}function _(n){return n.replace(/left|right|bottom|top/g,i=>st[i])}function nt(n){return typeof n!="number"?(function(i){return{top:0,right:0,bottom:0,left:0,...i}})(n):{top:n,right:n,bottom:n,left:n}}function dt(n){let{x:i,y:h,width:s,height:y}=n;return{width:s,height:y,top:h,left:i,right:i+s,bottom:h+y,x:i,y:h}}function rt(n,i,h){let{reference:s,floating:y}=n,u=A(i),w=D(i),k=c(w),W=N(i),M=u==="y",L=s.x+s.width/2-y.width/2,p=s.y+s.height/2-y.height/2,E=s[k]/2-y[k]/2,m;switch(W){case"top":m={x:L,y:s.y-y.height};break;case"bottom":m={x:L,y:s.y+s.height};break;case"right":m={x:s.x+s.width,y:p};break;case"left":m={x:s.x-y.width,y:p};break;default:m={x:s.x,y:s.y}}switch(it(i)){case"start":m[w]-=E*(h&&M?-1:1);break;case"end":m[w]+=E*(h&&M?-1:1)}return m}async function ct(n,i){var h;i===void 0&&(i={});let{x:s,y,platform:u,rects:w,elements:k,strategy:W}=n,{boundary:M="clippingAncestors",rootBoundary:L="viewport",elementContext:p="floating",altBoundary:E=!1,padding:m=0}=V(i,n),T=nt(m),P=k[E?p==="floating"?"reference":"floating":p],O=dt(await u.getClippingRect({element:(h=await(u.isElement==null?void 0:u.isElement(P)))==null||h?P:P.contextElement||await(u.getDocumentElement==null?void 0:u.getDocumentElement(k.floating)),boundary:M,rootBoundary:L,strategy:W})),H=p==="floating"?{x:s,y,width:w.floating.width,height:w.floating.height}:w.reference,B=await(u.getOffsetParent==null?void 0:u.getOffsetParent(k.floating)),C=await(u.isElement==null?void 0:u.isElement(B))&&await(u.getScale==null?void 0:u.getScale(B))||{x:1,y:1},S=dt(u.convertOffsetParentRelativeRectToViewportRelativeRect?await u.convertOffsetParentRelativeRectToViewportRelativeRect({elements:k,rect:H,offsetParent:B,strategy:W}):H);return{top:(O.top-S.top+T.top)/C.y,bottom:(S.bottom-O.bottom+T.bottom)/C.y,left:(O.left-S.left+T.left)/C.x,right:(S.right-O.right+T.right)/C.x}}function ut(n,i){return{top:n.top-i.height,right:n.right-i.width,bottom:n.bottom-i.height,left:n.left-i.width}}function ht(n){return R.some(i=>n[i]>=0)}function pt(n){let i=Q(...n.map(s=>s.left)),h=Q(...n.map(s=>s.top));return{x:i,y:h,width:G(...n.map(s=>s.right))-i,height:G(...n.map(s=>s.bottom))-h}}g.arrow=n=>({name:"arrow",options:n,async fn(i){let{x:h,y:s,placement:y,rects:u,platform:w,elements:k,middlewareData:W}=i,{element:M,padding:L=0}=V(n,i)||{};if(M==null)return{};let p=nt(L),E={x:h,y:s},m=D(y),T=c(m),P=await w.getDimensions(M),O=m==="y",H=O?"top":"left",B=O?"bottom":"right",C=O?"clientHeight":"clientWidth",S=u.reference[T]+u.reference[m]-E[m]-u.floating[T],F=E[m]-u.reference[m],J=await(w.getOffsetParent==null?void 0:w.getOffsetParent(M)),K=J?J[C]:0;K&&await(w.isElement==null?void 0:w.isElement(J))||(K=k.floating[C]||u.floating[T]);let ot=S/2-F/2,z=K/2-P[T]/2-1,X=Q(p[H],z),t=Q(p[B],z),e=X,o=K-P[T]-t,r=K/2-P[T]/2+ot,a=mt(e,r,o),f=!W.arrow&&it(y)!=null&&r!==a&&u.reference[T]/2-(rit(e)===z),...t.filter(e=>it(e)!==z)]:t.filter(e=>N(e)===e)).filter(e=>!z||it(e)===z||!!X&&j(e)!==e)})(p||null,m,E):E,O=await ct(i,T),H=((h=w.autoPlacement)==null?void 0:h.index)||0,B=P[H];if(B==null)return{};let C=I(B,u,await(W.isRTL==null?void 0:W.isRTL(M.floating)));if(k!==B)return{reset:{placement:P[0]}};let S=[O[N(B)],O[C[0]],O[C[1]]],F=[...((s=w.autoPlacement)==null?void 0:s.overflows)||[],{placement:B,overflows:S}],J=P[H+1];if(J)return{data:{index:H+1,overflows:F},reset:{placement:J}};let K=F.map(z=>{let X=it(z.placement);return[z.placement,X&&L?z.overflows.slice(0,2).reduce((t,e)=>t+e,0):z.overflows[0],z.overflows]}).sort((z,X)=>z[1]-X[1]),ot=((y=K.filter(z=>z[2].slice(0,it(z[0])?2:3).every(X=>X<=0))[0])==null?void 0:y[0])||K[0][0];return ot!==k?{data:{index:H+1,overflows:F},reset:{placement:ot}}:{}}}},g.computePosition=async(n,i,h)=>{let{placement:s="bottom",strategy:y="absolute",middleware:u=[],platform:w}=h,k=u.filter(Boolean),W=await(w.isRTL==null?void 0:w.isRTL(i)),M=await w.getElementRects({reference:n,floating:i,strategy:y}),{x:L,y:p}=rt(M,s,W),E=s,m={},T=0;for(let P=0;Pq+"-"+d),f&&(v=v.concat(v.map(j)))),v})(k,P,T,S));let K=[k,...F],ot=await ct(i,O),z=[],X=((s=u.flip)==null?void 0:s.overflows)||[];if(L&&z.push(ot[H]),p){let a=I(y,w,S);z.push(ot[a[0]],ot[a[1]])}if(X=[...X,{placement:y,overflows:z}],!z.every(a=>a<=0)){var t,e;let a=(((t=u.flip)==null?void 0:t.index)||0)+1,f=K[a];if(f){var o;let x=p==="alignment"&&B!==A(f),d=((o=X[0])==null?void 0:o.overflows[0])>0;if(!x||d)return{data:{index:a,overflows:X},reset:{placement:f}}}let b=(e=X.filter(x=>x.overflows[0]<=0).sort((x,d)=>x.overflows[1]-d.overflows[1])[0])==null?void 0:e.placement;if(!b)switch(m){case"bestFit":{var r;let x=(r=X.filter(d=>{if(J){let v=A(d.placement);return v===B||v==="y"}return!0}).map(d=>[d.placement,d.overflows.filter(v=>v>0).reduce((v,q)=>v+q,0)]).sort((d,v)=>d[1]-v[1])[0])==null?void 0:r[0];x&&(b=x);break}case"initialPlacement":b=k}if(y!==b)return{reset:{placement:b}}}return{}}}},g.hide=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(i){let{rects:h}=i,{strategy:s="referenceHidden",...y}=V(n,i);switch(s){case"referenceHidden":{let u=ut(await ct(i,{...y,elementContext:"reference"}),h.reference);return{data:{referenceHiddenOffsets:u,referenceHidden:ht(u)}}}case"escaped":{let u=ut(await ct(i,{...y,altBoundary:!0}),h.floating);return{data:{escapedOffsets:u,escaped:ht(u)}}}default:return{}}}}},g.inline=function(n){return n===void 0&&(n={}),{name:"inline",options:n,async fn(i){let{placement:h,elements:s,rects:y,platform:u,strategy:w}=i,{padding:k=2,x:W,y:M}=V(n,i),L=Array.from(await(u.getClientRects==null?void 0:u.getClientRects(s.reference))||[]),p=(function(P){let O=P.slice().sort((C,S)=>C.y-S.y),H=[],B=null;for(let C=0;CB.height/2?H.push([S]):H[H.length-1].push(S),B=S}return H.map(C=>dt(pt(C)))})(L),E=dt(pt(L)),m=nt(k),T=await u.getElementRects({reference:{getBoundingClientRect:function(){if(p.length===2&&p[0].left>p[1].right&&W!=null&&M!=null)return p.find(P=>W>P.left-m.left&&WP.top-m.top&&M=2){if(A(h)==="y"){let F=p[0],J=p[p.length-1],K=N(h)==="top",ot=F.top,z=J.bottom,X=K?F.left:J.left,t=K?F.right:J.right;return{top:ot,bottom:z,left:X,right:t,width:t-X,height:z-ot,x:X,y:ot}}let P=N(h)==="left",O=G(...p.map(F=>F.right)),H=Q(...p.map(F=>F.left)),B=p.filter(F=>P?F.left===H:F.right===O),C=B[0].top,S=B[B.length-1].bottom;return{top:C,bottom:S,left:H,right:O,width:O-H,height:S-C,x:H,y:C}}return E}},floating:s.floating,strategy:w});return y.reference.x!==T.reference.x||y.reference.y!==T.reference.y||y.reference.width!==T.reference.width||y.reference.height!==T.reference.height?{reset:{rects:T}}:{}}}},g.limitShift=function(n){return n===void 0&&(n={}),{options:n,fn(i){let{x:h,y:s,placement:y,rects:u,middlewareData:w}=i,{offset:k=0,mainAxis:W=!0,crossAxis:M=!0}=V(n,i),L={x:h,y:s},p=A(y),E=l(p),m=L[E],T=L[p],P=V(k,i),O=typeof P=="number"?{mainAxis:P,crossAxis:0}:{mainAxis:0,crossAxis:0,...P};if(W){let C=E==="y"?"height":"width",S=u.reference[E]-u.floating[C]+O.mainAxis,F=u.reference[E]+u.reference[C]-O.mainAxis;mF&&(m=F)}if(M){var H,B;let C=E==="y"?"width":"height",S=["top","left"].includes(N(y)),F=u.reference[p]-u.floating[C]+(S&&((H=w.offset)==null?void 0:H[p])||0)+(S?0:O.crossAxis),J=u.reference[p]+u.reference[C]+(S?0:((B=w.offset)==null?void 0:B[p])||0)-(S?O.crossAxis:0);TJ&&(T=J)}return{[E]:m,[p]:T}}}},g.offset=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(i){var h,s;let{x:y,y:u,placement:w,middlewareData:k}=i,W=await(async function(M,L){let{placement:p,platform:E,elements:m}=M,T=await(E.isRTL==null?void 0:E.isRTL(m.floating)),P=N(p),O=it(p),H=A(p)==="y",B=["left","top"].includes(P)?-1:1,C=T&&H?-1:1,S=V(L,M),{mainAxis:F,crossAxis:J,alignmentAxis:K}=typeof S=="number"?{mainAxis:S,crossAxis:0,alignmentAxis:null}:{mainAxis:S.mainAxis||0,crossAxis:S.crossAxis||0,alignmentAxis:S.alignmentAxis};return O&&typeof K=="number"&&(J=O==="end"?-1*K:K),H?{x:J*C,y:F*B}:{x:F*B,y:J*C}})(i,n);return w===((h=k.offset)==null?void 0:h.placement)&&(s=k.arrow)!=null&&s.alignmentOffset?{}:{x:y+W.x,y:u+W.y,data:{...W,placement:w}}}}},g.rectToClientRect=dt,g.shift=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(i){let{x:h,y:s,placement:y}=i,{mainAxis:u=!0,crossAxis:w=!1,limiter:k={fn:O=>{let{x:H,y:B}=O;return{x:H,y:B}}},...W}=V(n,i),M={x:h,y:s},L=await ct(i,W),p=A(N(y)),E=l(p),m=M[E],T=M[p];if(u){let O=E==="y"?"bottom":"right";m=mt(m+L[E==="y"?"top":"left"],m,m-L[O])}if(w){let O=p==="y"?"bottom":"right";T=mt(T+L[p==="y"?"top":"left"],T,T-L[O])}let P=k.fn({...i,[E]:m,[p]:T});return{...P,data:{x:P.x-h,y:P.y-s,enabled:{[E]:u,[p]:w}}}}}},g.size=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(i){var h,s;let{placement:y,rects:u,platform:w,elements:k}=i,{apply:W=()=>{},...M}=V(n,i),L=await ct(i,M),p=N(y),E=it(y),m=A(y)==="y",{width:T,height:P}=u.floating,O,H;p==="top"||p==="bottom"?(O=p,H=E===(await(w.isRTL==null?void 0:w.isRTL(k.floating))?"start":"end")?"left":"right"):(H=p,O=E==="end"?"top":"bottom");let B=P-L.top-L.bottom,C=T-L.left-L.right,S=Q(P-L[O],B),F=Q(T-L[H],C),J=!i.middlewareData.shift,K=S,ot=F;if((h=i.middlewareData.shift)!=null&&h.enabled.x&&(ot=C),(s=i.middlewareData.shift)!=null&&s.enabled.y&&(K=B),J&&!E){let X=G(L.left,0),t=G(L.right,0),e=G(L.top,0),o=G(L.bottom,0);m?ot=T-2*(X!==0||t!==0?X+t:G(L.left,L.right)):K=P-2*(e!==0||o!==0?e+o:G(L.top,L.bottom))}await W({...i,availableWidth:ot,availableHeight:K});let z=await w.getDimensions(k.floating);return T!==z.width||P!==z.height?{reset:{rects:!0}}:{}}}}})});var Ut=It((Rt,$t)=>{(function(g,R){typeof Rt=="object"&&typeof $t<"u"?R(Rt,Et()):typeof define=="function"&&define.amd?define(["exports","./floatingUICore"],R):R((g=typeof globalThis<"u"?globalThis:g||self).FloatingUIDOM={},g.FloatingUICore)})(Rt,function(g,R){"use strict";let at=Math.min,lt=Math.max,Q=Math.round,G=Math.floor,st=t=>({x:t,y:t});function gt(){return typeof window<"u"}function mt(t){return it(t)?(t.nodeName||"").toLowerCase():"#document"}function V(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function N(t){var e;return(e=(it(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function it(t){return!!gt()&&(t instanceof Node||t instanceof V(t).Node)}function l(t){return!!gt()&&(t instanceof Element||t instanceof V(t).Element)}function c(t){return!!gt()&&(t instanceof HTMLElement||t instanceof V(t).HTMLElement)}function A(t){return!(!gt()||typeof ShadowRoot>"u")&&(t instanceof ShadowRoot||t instanceof V(t).ShadowRoot)}function D(t){let{overflow:e,overflowX:o,overflowY:r,display:a}=rt(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+o)&&!["inline","contents"].includes(a)}function I(t){return["table","td","th"].includes(mt(t))}function j(t){return[":popover-open",":modal"].some(e=>{try{return t.matches(e)}catch{return!1}})}function _(t){let e=nt(),o=l(t)?rt(t):t;return["transform","translate","scale","rotate","perspective"].some(r=>!!o[r]&&o[r]!=="none")||!!o.containerType&&o.containerType!=="normal"||!e&&!!o.backdropFilter&&o.backdropFilter!=="none"||!e&&!!o.filter&&o.filter!=="none"||["transform","translate","scale","rotate","perspective","filter"].some(r=>(o.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(o.contain||"").includes(r))}function nt(){return!(typeof CSS>"u"||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function dt(t){return["html","body","#document"].includes(mt(t))}function rt(t){return V(t).getComputedStyle(t)}function ct(t){return l(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function ut(t){if(mt(t)==="html")return t;let e=t.assignedSlot||t.parentNode||A(t)&&t.host||N(t);return A(e)?e.host:e}function ht(t){let e=ut(t);return dt(e)?t.ownerDocument?t.ownerDocument.body:t.body:c(e)&&D(e)?e:ht(e)}function pt(t,e,o){var r;e===void 0&&(e=[]),o===void 0&&(o=!0);let a=ht(t),f=a===((r=t.ownerDocument)==null?void 0:r.body),b=V(a);if(f){let x=n(b);return e.concat(b,b.visualViewport||[],D(a)?a:[],x&&o?pt(x):[])}return e.concat(a,pt(a,[],o))}function n(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function i(t){let e=rt(t),o=parseFloat(e.width)||0,r=parseFloat(e.height)||0,a=c(t),f=a?t.offsetWidth:o,b=a?t.offsetHeight:r,x=Q(o)!==f||Q(r)!==b;return x&&(o=f,r=b),{width:o,height:r,$:x}}function h(t){return l(t)?t:t.contextElement}function s(t){let e=h(t);if(!c(e))return st(1);let o=e.getBoundingClientRect(),{width:r,height:a,$:f}=i(e),b=(f?Q(o.width):o.width)/r,x=(f?Q(o.height):o.height)/a;return b&&Number.isFinite(b)||(b=1),x&&Number.isFinite(x)||(x=1),{x:b,y:x}}let y=st(0);function u(t){let e=V(t);return nt()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:y}function w(t,e,o,r){e===void 0&&(e=!1),o===void 0&&(o=!1);let a=t.getBoundingClientRect(),f=h(t),b=st(1);e&&(r?l(r)&&(b=s(r)):b=s(t));let x=(function(et,Z,$){return Z===void 0&&(Z=!1),!(!$||Z&&$!==V(et))&&Z})(f,o,r)?u(f):st(0),d=(a.left+x.x)/b.x,v=(a.top+x.y)/b.y,q=a.width/b.x,Y=a.height/b.y;if(f){let et=V(f),Z=r&&l(r)?V(r):r,$=et,tt=n($);for(;tt&&r&&Z!==$;){let U=s(tt),ft=tt.getBoundingClientRect(),yt=rt(tt),vt=ft.left+(tt.clientLeft+parseFloat(yt.paddingLeft))*U.x,bt=ft.top+(tt.clientTop+parseFloat(yt.paddingTop))*U.y;d*=U.x,v*=U.y,q*=U.x,Y*=U.y,d+=vt,v+=bt,$=V(tt),tt=n($)}}return R.rectToClientRect({width:q,height:Y,x:d,y:v})}function k(t,e){let o=ct(t).scrollLeft;return e?e.left+o:w(N(t)).left+o}function W(t,e,o){o===void 0&&(o=!1);let r=t.getBoundingClientRect();return{x:r.left+e.scrollLeft-(o?0:k(t,r)),y:r.top+e.scrollTop}}function M(t,e,o){let r;if(e==="viewport")r=(function(a,f){let b=V(a),x=N(a),d=b.visualViewport,v=x.clientWidth,q=x.clientHeight,Y=0,et=0;if(d){v=d.width,q=d.height;let Z=nt();(!Z||Z&&f==="fixed")&&(Y=d.offsetLeft,et=d.offsetTop)}return{width:v,height:q,x:Y,y:et}})(t,o);else if(e==="document")r=(function(a){let f=N(a),b=ct(a),x=a.ownerDocument.body,d=lt(f.scrollWidth,f.clientWidth,x.scrollWidth,x.clientWidth),v=lt(f.scrollHeight,f.clientHeight,x.scrollHeight,x.clientHeight),q=-b.scrollLeft+k(a),Y=-b.scrollTop;return rt(x).direction==="rtl"&&(q+=lt(f.clientWidth,x.clientWidth)-d),{width:d,height:v,x:q,y:Y}})(N(t));else if(l(e))r=(function(a,f){let b=w(a,!0,f==="fixed"),x=b.top+a.clientTop,d=b.left+a.clientLeft,v=c(a)?s(a):st(1);return{width:a.clientWidth*v.x,height:a.clientHeight*v.y,x:d*v.x,y:x*v.y}})(e,o);else{let a=u(t);r={x:e.x-a.x,y:e.y-a.y,width:e.width,height:e.height}}return R.rectToClientRect(r)}function L(t,e){let o=ut(t);return!(o===e||!l(o)||dt(o))&&(rt(o).position==="fixed"||L(o,e))}function p(t,e,o){let r=c(e),a=N(e),f=o==="fixed",b=w(t,!0,f,e),x={scrollLeft:0,scrollTop:0},d=st(0);function v(){d.x=k(a)}if(r||!r&&!f)if((mt(e)!=="body"||D(a))&&(x=ct(e)),r){let Y=w(e,!0,f,e);d.x=Y.x+e.clientLeft,d.y=Y.y+e.clientTop}else a&&v();f&&!r&&a&&v();let q=!a||r||f?st(0):W(a,x);return{x:b.left+x.scrollLeft-d.x-q.x,y:b.top+x.scrollTop-d.y-q.y,width:b.width,height:b.height}}function E(t){return rt(t).position==="static"}function m(t,e){if(!c(t)||rt(t).position==="fixed")return null;if(e)return e(t);let o=t.offsetParent;return N(t)===o&&(o=o.ownerDocument.body),o}function T(t,e){let o=V(t);if(j(t))return o;if(!c(t)){let a=ut(t);for(;a&&!dt(a);){if(l(a)&&!E(a))return a;a=ut(a)}return o}let r=m(t,e);for(;r&&I(r)&&E(r);)r=m(r,e);return r&&dt(r)&&E(r)&&!_(r)?o:r||(function(a){let f=ut(a);for(;c(f)&&!dt(f);){if(_(f))return f;if(j(f))return null;f=ut(f)}return null})(t)||o}let P={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:o,offsetParent:r,strategy:a}=t,f=a==="fixed",b=N(r),x=!!e&&j(e.floating);if(r===b||x&&f)return o;let d={scrollLeft:0,scrollTop:0},v=st(1),q=st(0),Y=c(r);if((Y||!Y&&!f)&&((mt(r)!=="body"||D(b))&&(d=ct(r)),c(r))){let Z=w(r);v=s(r),q.x=Z.x+r.clientLeft,q.y=Z.y+r.clientTop}let et=!b||Y||f?st(0):W(b,d,!0);return{width:o.width*v.x,height:o.height*v.y,x:o.x*v.x-d.scrollLeft*v.x+q.x+et.x,y:o.y*v.y-d.scrollTop*v.y+q.y+et.y}},getDocumentElement:N,getClippingRect:function(t){let{element:e,boundary:o,rootBoundary:r,strategy:a}=t,f=[...o==="clippingAncestors"?j(e)?[]:(function(d,v){let q=v.get(d);if(q)return q;let Y=pt(d,[],!1).filter(tt=>l(tt)&&mt(tt)!=="body"),et=null,Z=rt(d).position==="fixed",$=Z?ut(d):d;for(;l($)&&!dt($);){let tt=rt($),U=_($);U||tt.position!=="fixed"||(et=null),(Z?!U&&!et:!U&&tt.position==="static"&&et&&["absolute","fixed"].includes(et.position)||D($)&&!U&&L(d,$))?Y=Y.filter(ft=>ft!==$):et=tt,$=ut($)}return v.set(d,Y),Y})(e,this._c):[].concat(o),r],b=f[0],x=f.reduce((d,v)=>{let q=M(e,v,a);return d.top=lt(q.top,d.top),d.right=at(q.right,d.right),d.bottom=at(q.bottom,d.bottom),d.left=lt(q.left,d.left),d},M(e,b,a));return{width:x.right-x.left,height:x.bottom-x.top,x:x.left,y:x.top}},getOffsetParent:T,getElementRects:async function(t){let e=this.getOffsetParent||T,o=this.getDimensions,r=await o(t.floating);return{reference:p(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){let{width:e,height:o}=i(t);return{width:e,height:o}},getScale:s,isElement:l,isRTL:function(t){return rt(t).direction==="rtl"}};function O(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}let H=R.detectOverflow,B=R.offset,C=R.autoPlacement,S=R.shift,F=R.flip,J=R.size,K=R.hide,ot=R.arrow,z=R.inline,X=R.limitShift;return g.arrow=ot,g.autoPlacement=C,g.autoUpdate=function(t,e,o,r){r===void 0&&(r={});let{ancestorScroll:a=!0,ancestorResize:f=!0,elementResize:b=typeof ResizeObserver=="function",layoutShift:x=typeof IntersectionObserver=="function",animationFrame:d=!1}=r,v=h(t),q=a||f?[...v?pt(v):[],...pt(e)]:[];q.forEach(U=>{a&&U.addEventListener("scroll",o,{passive:!0}),f&&U.addEventListener("resize",o)});let Y=v&&x?(function(U,ft){let yt,vt=null,bt=N(U);function Pt(){var wt;clearTimeout(yt),(wt=vt)==null||wt.disconnect(),vt=null}return(function wt(Lt,xt){Lt===void 0&&(Lt=!1),xt===void 0&&(xt=1),Pt();let Ot=U.getBoundingClientRect(),{left:Ct,top:St,width:Dt,height:kt}=Ot;if(Lt||ft(),!Dt||!kt)return;let Ft={rootMargin:-G(St)+"px "+-G(bt.clientWidth-(Ct+Dt))+"px "+-G(bt.clientHeight-(St+kt))+"px "+-G(Ct)+"px",threshold:lt(0,at(1,xt))||1},Bt=!0;function Ht(Mt){let At=Mt[0].intersectionRatio;if(At!==xt){if(!Bt)return wt();At?wt(!1,At):yt=setTimeout(()=>{wt(!1,1e-7)},1e3)}At!==1||O(Ot,U.getBoundingClientRect())||wt(),Bt=!1}try{vt=new IntersectionObserver(Ht,{...Ft,root:bt.ownerDocument})}catch{vt=new IntersectionObserver(Ht,Ft)}vt.observe(U)})(!0),Pt})(v,o):null,et,Z=-1,$=null;b&&($=new ResizeObserver(U=>{let[ft]=U;ft&&ft.target===v&&$&&($.unobserve(e),cancelAnimationFrame(Z),Z=requestAnimationFrame(()=>{var yt;(yt=$)==null||yt.observe(e)})),o()}),v&&!d&&$.observe(v),$.observe(e));let tt=d?w(t):null;return d&&(function U(){let ft=w(t);tt&&!O(tt,ft)&&o(),tt=ft,et=requestAnimationFrame(U)})(),o(),()=>{var U;q.forEach(ft=>{a&&ft.removeEventListener("scroll",o),f&&ft.removeEventListener("resize",o)}),Y?.(),(U=$)==null||U.disconnect(),$=null,d&&cancelAnimationFrame(et)}},g.computePosition=(t,e,o)=>{let r=new Map,a={platform:P,...o},f={...a.platform,_c:r};return R.computePosition(t,e,{...a,platform:f})},g.detectOverflow=H,g.flip=F,g.getOverflowAncestors=pt,g.hide=K,g.inline=z,g.limitShift=X,g.offset=B,g.platform=P,g.shift=S,g.size=J,window.FloatingUIDOM=g,g})});var Jt=Wt(Ut()),Kt=Wt(Et());(function(){"use strict";let g=new Map,R=new Map;if(!document.querySelector("[data-tui-popover-portal-container]")){let l=document.createElement("div");l.setAttribute("data-tui-popover-portal-container",""),l.className="fixed inset-0 z-[9999] pointer-events-none",document.body.appendChild(l)}if(!document.getElementById("popover-animations")){let l=document.createElement("style");l.id="popover-animations",l.textContent=` - @keyframes popover-in { 0% { opacity: 0; transform: scale(0.95); } 100% { opacity: 1; transform: scale(1); } } - @keyframes popover-out { 0% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(0.95); } } - [data-tui-popover-id].popover-animate-in { animation: popover-in 0.15s cubic-bezier(0.16, 1, 0.3, 1); } - [data-tui-popover-id].popover-animate-out { animation: popover-out 0.1s cubic-bezier(0.16, 1, 0.3, 1) forwards; } - `,document.head.appendChild(l)}function at(l,c){if(!window.FloatingUIDOM)return;let{computePosition:A,offset:D,flip:I,shift:j,arrow:_}=window.FloatingUIDOM,nt=c.querySelector("[data-tui-popover-arrow]"),dt=c.getAttribute("data-tui-popover-placement")||"bottom",rt=parseInt(c.getAttribute("data-tui-popover-offset"))||(nt?8:4),ct=[D(rt),I({padding:10}),j({padding:10})];nt&&ct.push(_({element:nt,padding:5}));let ut=l,ht=0;for(let pt of l.children){let n=pt.getBoundingClientRect?.();if(n){let i=n.width*n.height;i>ht&&(ht=i,ut=pt)}}A(ut,c,{placement:dt,middleware:ct}).then(({x:pt,y:n,placement:i,middlewareData:h})=>{if(Object.assign(c.style,{left:`${pt}px`,top:`${n}px`}),nt&&h.arrow){let{x:s,y}=h.arrow;nt.setAttribute("data-tui-popover-placement",i),Object.assign(nt.style,{left:s!=null?`${s}px`:"",top:y!=null?`${y}px`:""})}c.getAttribute("data-tui-popover-match-width")==="true"&&c.style.setProperty("--popover-trigger-width",`${ut.offsetWidth}px`)})}function lt(l){if(!window.FloatingUIDOM)return;let c=l.getAttribute("data-tui-popover-trigger");if(!c)return;let A=document.getElementById(c);if(!A)return;for(let j of document.querySelectorAll('[data-tui-popover-exclusive="true"][data-tui-popover-open="true"]')){let _=j.id;_&&_!==c&&!j.contains(l)&&G(_)}let D=document.querySelector("[data-tui-popover-portal-container]");D&&A.parentNode!==D&&D.appendChild(A),A.style.display="block",A.classList.remove("popover-animate-out"),A.classList.add("popover-animate-in"),A.setAttribute("data-tui-popover-open","true"),document.querySelectorAll(`[data-tui-popover-trigger="${c}"]`).forEach(j=>{j.setAttribute("data-tui-popover-open","true")}),at(l,A);let I=window.FloatingUIDOM.autoUpdate(l,A,()=>at(l,A),{animationFrame:!0});g.set(c,I)}function Q(l){let c=document.querySelector(`[data-tui-popover-trigger="${l}"]`);c&<(c)}function G(l,c=!1){let A=document.getElementById(l);if(!A)return;let D=g.get(l);D&&(D(),g.delete(l));let I=R.get(l);I&&(clearTimeout(I.enter),clearTimeout(I.leave),R.delete(l)),A.setAttribute("data-tui-popover-open","false"),document.querySelectorAll(`[data-tui-popover-trigger="${l}"]`).forEach(_=>{_.setAttribute("data-tui-popover-open","false")});function j(){A.style.display="none",A.classList.remove("popover-animate-in","popover-animate-out")}c?j():(A.classList.remove("popover-animate-in"),A.classList.add("popover-animate-out"),setTimeout(j,150))}function st(l){return document.getElementById(l)?.getAttribute("data-tui-popover-open")==="true"||!1}function gt(l){st(l)?G(l):Q(l)}function mt(l=null){document.querySelectorAll('[data-tui-popover-open="true"][data-tui-popover-id]').forEach(c=>{c.id&&c.id!==l&&G(c.id)})}document.addEventListener("click",l=>{let c=l.target.closest("[data-tui-popover-trigger]");if(c&&c.getAttribute("data-tui-popover-type")!=="hover"){if(c.querySelector(':disabled, [disabled], [aria-disabled="true"]'))return;l.stopPropagation();let I=c.getAttribute("data-tui-popover-trigger");I&>(I);return}let A=l.target.closest("[data-tui-popover-id]");document.querySelectorAll('[data-tui-popover-open="true"][data-tui-popover-id]').forEach(D=>{if(D!==A&&D.getAttribute("data-tui-popover-disable-clickaway")!=="true"){let I=D.id,j=document.querySelectorAll(`[data-tui-popover-trigger="${I}"]`),_=!1;for(let nt of j)if(nt.contains(l.target)){_=!0;break}_||G(I)}})});function V(l,c){let A=document.getElementById(c);if(!A)return;let D=parseInt(A.getAttribute("data-tui-popover-hover-delay"))||100,I=R.get(c)||{};clearTimeout(I.leave),I.enter=setTimeout(()=>lt(l),D),R.set(c,I)}function N(l,c){let A=document.getElementById(l);if(!A)return;let D=parseInt(A.getAttribute("data-tui-popover-hover-out-delay"))||200,I=R.get(l)||{};clearTimeout(I.enter),c||(I.leave=setTimeout(()=>G(l),D),R.set(l,I))}document.addEventListener("mouseover",l=>{let c=l.target.closest("[data-tui-popover-trigger]");if(c&&!c.contains(l.relatedTarget)&&c.getAttribute("data-tui-popover-type")==="hover"){let D=c.getAttribute("data-tui-popover-trigger");D&&V(c,D)}let A=l.target.closest("[data-tui-popover-id]");if(A&&!A.contains(l.relatedTarget)&&A.getAttribute("data-tui-popover-open")==="true"){let D=A.id,I=document.querySelectorAll(`[data-tui-popover-trigger="${D}"]`);for(let j of I)if(j.getAttribute("data-tui-popover-type")==="hover"){let _=R.get(D)||{};clearTimeout(_.leave),R.set(D,_);break}}}),document.addEventListener("mouseout",l=>{let c=l.target.closest("[data-tui-popover-trigger]");if(c&&!c.contains(l.relatedTarget)&&c.getAttribute("data-tui-popover-type")==="hover"){let D=c.getAttribute("data-tui-popover-trigger"),I=document.getElementById(D);N(D,I?.contains(l.relatedTarget))}let A=l.target.closest("[data-tui-popover-id]");if(A&&!A.contains(l.relatedTarget)&&A.getAttribute("data-tui-popover-open")==="true"){let D=A.id,I=document.querySelectorAll(`[data-tui-popover-trigger="${D}"]`),j=!1,_=!1;for(let nt of I)nt.getAttribute("data-tui-popover-type")==="hover"&&(j=!0,nt.contains(l.relatedTarget)&&(_=!0));j&&!_&&N(D,!1)}}),document.addEventListener("keydown",l=>{l.key==="Escape"&&document.querySelectorAll('[data-tui-popover-open="true"][data-tui-popover-id]').forEach(c=>{c.getAttribute("data-tui-popover-disable-esc")!=="true"&&G(c.id)})});function it(){document.querySelectorAll("[data-tui-popover-trigger]").forEach(l=>{l.querySelector(':disabled, [disabled], [aria-disabled="true"]')?(l.classList.add("cursor-not-allowed","opacity-50"),l.classList.remove("cursor-pointer")):(l.classList.remove("cursor-not-allowed","opacity-50"),l.classList.add("cursor-pointer"))})}document.addEventListener("DOMContentLoaded",it),new MutationObserver(it).observe(document.body,{subtree:!0,attributes:!0,attributeFilter:["disabled","aria-disabled"],childList:!0}),window.closePopover=G,window.tui=window.tui||{},window.tui.popover={open:Q,close:G,closeAll:mt,toggle:gt,isOpen:st}})();})(); +(()=>{var _t=Object.create;var It=Object.defineProperty;var qt=Object.getOwnPropertyDescriptor;var Nt=Object.getOwnPropertyNames;var jt=Object.getPrototypeOf,Xt=Object.prototype.hasOwnProperty;var Wt=(g,L)=>()=>(L||g((L={exports:{}}).exports,L),L.exports);var Yt=(g,L,J,at)=>{if(L&&typeof L=="object"||typeof L=="function")for(let _ of Nt(L))!Xt.call(g,_)&&_!==J&&It(g,_,{get:()=>L[_],enumerable:!(at=qt(L,_))||at.enumerable});return g};var Ut=(g,L,J)=>(J=g!=null?_t(jt(g)):{},Yt(L||!g||!g.__esModule?It(J,"default",{value:g,enumerable:!0}):J,g));var Et=Wt((At,Vt)=>{(function(g,L){typeof At=="object"&&typeof Vt<"u"?L(At):typeof define=="function"&&define.amd?define(["exports"],L):L((g=typeof globalThis<"u"?globalThis:g||self).FloatingUICore={})})(At,function(g){"use strict";let L=["top","right","bottom","left"],J=["start","end"],at=L.reduce((r,a)=>r.concat(a,a+"-"+J[0],a+"-"+J[1]),[]),_=Math.min,Y=Math.max,N={left:"right",right:"left",bottom:"top",top:"bottom"},st={start:"end",end:"start"};function ft(r,a,y){return Y(r,_(a,y))}function M(r,a){return typeof r=="function"?r(a):r}function W(r){return r.split("-")[0]}function tt(r){return r.split("-")[1]}function K(r){return r==="x"?"y":"x"}function Z(r){return r==="y"?"height":"width"}function rt(r){return["top","bottom"].includes(W(r))?"y":"x"}function dt(r){return K(rt(r))}function vt(r,a,y){y===void 0&&(y=!1);let t=tt(r),o=dt(r),i=Z(o),c=o==="x"?t===(y?"end":"start")?"right":"left":t==="start"?"bottom":"top";return a.reference[i]>a.floating[i]&&(c=et(c)),[c,et(c)]}function ut(r){return r.replace(/start|end/g,a=>st[a])}function et(r){return r.replace(/left|right|bottom|top/g,a=>N[a])}function mt(r){return typeof r!="number"?(function(a){return{top:0,right:0,bottom:0,left:0,...a}})(r):{top:r,right:r,bottom:r,left:r}}function it(r){let{x:a,y,width:t,height:o}=r;return{width:t,height:o,top:y,left:a,right:a+t,bottom:y+o,x:a,y}}function nt(r,a,y){let{reference:t,floating:o}=r,i=rt(a),c=dt(a),u=Z(c),A=W(a),S=i==="y",b=t.x+t.width/2-o.width/2,d=t.y+t.height/2-o.height/2,R=t[u]/2-o[u]/2,p;switch(A){case"top":p={x:b,y:t.y-o.height};break;case"bottom":p={x:b,y:t.y+t.height};break;case"right":p={x:t.x+t.width,y:d};break;case"left":p={x:t.x-o.width,y:d};break;default:p={x:t.x,y:t.y}}switch(tt(a)){case"start":p[c]-=R*(y&&S?-1:1);break;case"end":p[c]+=R*(y&&S?-1:1)}return p}async function ot(r,a){var y;a===void 0&&(a={});let{x:t,y:o,platform:i,rects:c,elements:u,strategy:A}=r,{boundary:S="clippingAncestors",rootBoundary:b="viewport",elementContext:d="floating",altBoundary:R=!1,padding:p=0}=M(a,r),T=mt(p),C=u[R?d==="floating"?"reference":"floating":d],E=it(await i.getClippingRect({element:(y=await(i.isElement==null?void 0:i.isElement(C)))==null||y?C:C.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(u.floating)),boundary:S,rootBoundary:b,strategy:A})),k=d==="floating"?{x:t,y:o,width:c.floating.width,height:c.floating.height}:c.reference,F=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u.floating)),P=await(i.isElement==null?void 0:i.isElement(F))&&await(i.getScale==null?void 0:i.getScale(F))||{x:1,y:1},O=it(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:u,rect:k,offsetParent:F,strategy:A}):k);return{top:(E.top-O.top+T.top)/P.y,bottom:(O.bottom-E.bottom+T.bottom)/P.y,left:(E.left-O.left+T.left)/P.x,right:(O.right-E.right+T.right)/P.x}}function ct(r,a){return{top:r.top-a.height,right:r.right-a.width,bottom:r.bottom-a.height,left:r.left-a.width}}function ht(r){return L.some(a=>r[a]>=0)}function pt(r){let a=_(...r.map(t=>t.left)),y=_(...r.map(t=>t.top));return{x:a,y,width:Y(...r.map(t=>t.right))-a,height:Y(...r.map(t=>t.bottom))-y}}g.arrow=r=>({name:"arrow",options:r,async fn(a){let{x:y,y:t,placement:o,rects:i,platform:c,elements:u,middlewareData:A}=a,{element:S,padding:b=0}=M(r,a)||{};if(S==null)return{};let d=mt(b),R={x:y,y:t},p=dt(o),T=Z(p),C=await c.getDimensions(S),E=p==="y",k=E?"top":"left",F=E?"bottom":"right",P=E?"clientHeight":"clientWidth",O=i.reference[T]+i.reference[p]-R[p]-i.floating[T],D=R[p]-i.reference[p],V=await(c.getOffsetParent==null?void 0:c.getOffsetParent(S)),q=V?V[P]:0;q&&await(c.isElement==null?void 0:c.isElement(V))||(q=u.floating[P]||i.floating[T]);let Q=O/2-D/2,B=q/2-C[T]/2-1,$=_(d[k],B),e=_(d[F],B),n=$,l=q-C[T]-e,s=q/2-C[T]/2+Q,f=ft(n,s,l),m=!A.arrow&&tt(o)!=null&&s!==f&&i.reference[T]/2-(stt(n)===B),...e.filter(n=>tt(n)!==B)]:e.filter(n=>W(n)===n)).filter(n=>!B||tt(n)===B||!!$&&ut(n)!==n)})(d||null,p,R):R,E=await ot(a,T),k=((y=c.autoPlacement)==null?void 0:y.index)||0,F=C[k];if(F==null)return{};let P=vt(F,i,await(A.isRTL==null?void 0:A.isRTL(S.floating)));if(u!==F)return{reset:{placement:C[0]}};let O=[E[W(F)],E[P[0]],E[P[1]]],D=[...((t=c.autoPlacement)==null?void 0:t.overflows)||[],{placement:F,overflows:O}],V=C[k+1];if(V)return{data:{index:k+1,overflows:D},reset:{placement:V}};let q=D.map(B=>{let $=tt(B.placement);return[B.placement,$&&b?B.overflows.slice(0,2).reduce((e,n)=>e+n,0):B.overflows[0],B.overflows]}).sort((B,$)=>B[1]-$[1]),Q=((o=q.filter(B=>B[2].slice(0,tt(B[0])?2:3).every($=>$<=0))[0])==null?void 0:o[0])||q[0][0];return Q!==u?{data:{index:k+1,overflows:D},reset:{placement:Q}}:{}}}},g.computePosition=async(r,a,y)=>{let{placement:t="bottom",strategy:o="absolute",middleware:i=[],platform:c}=y,u=i.filter(Boolean),A=await(c.isRTL==null?void 0:c.isRTL(a)),S=await c.getElementRects({reference:r,floating:a,strategy:o}),{x:b,y:d}=nt(S,t,A),R=t,p={},T=0;for(let C=0;CH+"-"+h),m&&(w=w.concat(w.map(ut)))),w})(u,C,T,O));let q=[u,...D],Q=await ot(a,E),B=[],$=((t=i.flip)==null?void 0:t.overflows)||[];if(b&&B.push(Q[k]),d){let f=vt(o,c,O);B.push(Q[f[0]],Q[f[1]])}if($=[...$,{placement:o,overflows:B}],!B.every(f=>f<=0)){var e,n;let f=(((e=i.flip)==null?void 0:e.index)||0)+1,m=q[f];if(m){var l;let x=d==="alignment"&&F!==rt(m),h=((l=$[0])==null?void 0:l.overflows[0])>0;if(!x||h)return{data:{index:f,overflows:$},reset:{placement:m}}}let v=(n=$.filter(x=>x.overflows[0]<=0).sort((x,h)=>x.overflows[1]-h.overflows[1])[0])==null?void 0:n.placement;if(!v)switch(p){case"bestFit":{var s;let x=(s=$.filter(h=>{if(V){let w=rt(h.placement);return w===F||w==="y"}return!0}).map(h=>[h.placement,h.overflows.filter(w=>w>0).reduce((w,H)=>w+H,0)]).sort((h,w)=>h[1]-w[1])[0])==null?void 0:s[0];x&&(v=x);break}case"initialPlacement":v=u}if(o!==v)return{reset:{placement:v}}}return{}}}},g.hide=function(r){return r===void 0&&(r={}),{name:"hide",options:r,async fn(a){let{rects:y}=a,{strategy:t="referenceHidden",...o}=M(r,a);switch(t){case"referenceHidden":{let i=ct(await ot(a,{...o,elementContext:"reference"}),y.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:ht(i)}}}case"escaped":{let i=ct(await ot(a,{...o,altBoundary:!0}),y.floating);return{data:{escapedOffsets:i,escaped:ht(i)}}}default:return{}}}}},g.inline=function(r){return r===void 0&&(r={}),{name:"inline",options:r,async fn(a){let{placement:y,elements:t,rects:o,platform:i,strategy:c}=a,{padding:u=2,x:A,y:S}=M(r,a),b=Array.from(await(i.getClientRects==null?void 0:i.getClientRects(t.reference))||[]),d=(function(C){let E=C.slice().sort((P,O)=>P.y-O.y),k=[],F=null;for(let P=0;PF.height/2?k.push([O]):k[k.length-1].push(O),F=O}return k.map(P=>it(pt(P)))})(b),R=it(pt(b)),p=mt(u),T=await i.getElementRects({reference:{getBoundingClientRect:function(){if(d.length===2&&d[0].left>d[1].right&&A!=null&&S!=null)return d.find(C=>A>C.left-p.left&&AC.top-p.top&&S=2){if(rt(y)==="y"){let D=d[0],V=d[d.length-1],q=W(y)==="top",Q=D.top,B=V.bottom,$=q?D.left:V.left,e=q?D.right:V.right;return{top:Q,bottom:B,left:$,right:e,width:e-$,height:B-Q,x:$,y:Q}}let C=W(y)==="left",E=Y(...d.map(D=>D.right)),k=_(...d.map(D=>D.left)),F=d.filter(D=>C?D.left===k:D.right===E),P=F[0].top,O=F[F.length-1].bottom;return{top:P,bottom:O,left:k,right:E,width:E-k,height:O-P,x:k,y:P}}return R}},floating:t.floating,strategy:c});return o.reference.x!==T.reference.x||o.reference.y!==T.reference.y||o.reference.width!==T.reference.width||o.reference.height!==T.reference.height?{reset:{rects:T}}:{}}}},g.limitShift=function(r){return r===void 0&&(r={}),{options:r,fn(a){let{x:y,y:t,placement:o,rects:i,middlewareData:c}=a,{offset:u=0,mainAxis:A=!0,crossAxis:S=!0}=M(r,a),b={x:y,y:t},d=rt(o),R=K(d),p=b[R],T=b[d],C=M(u,a),E=typeof C=="number"?{mainAxis:C,crossAxis:0}:{mainAxis:0,crossAxis:0,...C};if(A){let P=R==="y"?"height":"width",O=i.reference[R]-i.floating[P]+E.mainAxis,D=i.reference[R]+i.reference[P]-E.mainAxis;pD&&(p=D)}if(S){var k,F;let P=R==="y"?"width":"height",O=["top","left"].includes(W(o)),D=i.reference[d]-i.floating[P]+(O&&((k=c.offset)==null?void 0:k[d])||0)+(O?0:E.crossAxis),V=i.reference[d]+i.reference[P]+(O?0:((F=c.offset)==null?void 0:F[d])||0)-(O?E.crossAxis:0);TV&&(T=V)}return{[R]:p,[d]:T}}}},g.offset=function(r){return r===void 0&&(r=0),{name:"offset",options:r,async fn(a){var y,t;let{x:o,y:i,placement:c,middlewareData:u}=a,A=await(async function(S,b){let{placement:d,platform:R,elements:p}=S,T=await(R.isRTL==null?void 0:R.isRTL(p.floating)),C=W(d),E=tt(d),k=rt(d)==="y",F=["left","top"].includes(C)?-1:1,P=T&&k?-1:1,O=M(b,S),{mainAxis:D,crossAxis:V,alignmentAxis:q}=typeof O=="number"?{mainAxis:O,crossAxis:0,alignmentAxis:null}:{mainAxis:O.mainAxis||0,crossAxis:O.crossAxis||0,alignmentAxis:O.alignmentAxis};return E&&typeof q=="number"&&(V=E==="end"?-1*q:q),k?{x:V*P,y:D*F}:{x:D*F,y:V*P}})(a,r);return c===((y=u.offset)==null?void 0:y.placement)&&(t=u.arrow)!=null&&t.alignmentOffset?{}:{x:o+A.x,y:i+A.y,data:{...A,placement:c}}}}},g.rectToClientRect=it,g.shift=function(r){return r===void 0&&(r={}),{name:"shift",options:r,async fn(a){let{x:y,y:t,placement:o}=a,{mainAxis:i=!0,crossAxis:c=!1,limiter:u={fn:E=>{let{x:k,y:F}=E;return{x:k,y:F}}},...A}=M(r,a),S={x:y,y:t},b=await ot(a,A),d=rt(W(o)),R=K(d),p=S[R],T=S[d];if(i){let E=R==="y"?"bottom":"right";p=ft(p+b[R==="y"?"top":"left"],p,p-b[E])}if(c){let E=d==="y"?"bottom":"right";T=ft(T+b[d==="y"?"top":"left"],T,T-b[E])}let C=u.fn({...a,[R]:p,[d]:T});return{...C,data:{x:C.x-y,y:C.y-t,enabled:{[R]:i,[d]:c}}}}}},g.size=function(r){return r===void 0&&(r={}),{name:"size",options:r,async fn(a){var y,t;let{placement:o,rects:i,platform:c,elements:u}=a,{apply:A=()=>{},...S}=M(r,a),b=await ot(a,S),d=W(o),R=tt(o),p=rt(o)==="y",{width:T,height:C}=i.floating,E,k;d==="top"||d==="bottom"?(E=d,k=R===(await(c.isRTL==null?void 0:c.isRTL(u.floating))?"start":"end")?"left":"right"):(k=d,E=R==="end"?"top":"bottom");let F=C-b.top-b.bottom,P=T-b.left-b.right,O=_(C-b[E],F),D=_(T-b[k],P),V=!a.middlewareData.shift,q=O,Q=D;if((y=a.middlewareData.shift)!=null&&y.enabled.x&&(Q=P),(t=a.middlewareData.shift)!=null&&t.enabled.y&&(q=F),V&&!R){let $=Y(b.left,0),e=Y(b.right,0),n=Y(b.top,0),l=Y(b.bottom,0);p?Q=T-2*($!==0||e!==0?$+e:Y(b.left,b.right)):q=C-2*(n!==0||l!==0?n+l:Y(b.top,b.bottom))}await A({...a,availableWidth:Q,availableHeight:q});let B=await c.getDimensions(u.floating);return T!==B.width||C!==B.height?{reset:{rects:!0}}:{}}}}})});var zt=Wt((Rt,$t)=>{(function(g,L){typeof Rt=="object"&&typeof $t<"u"?L(Rt,Et()):typeof define=="function"&&define.amd?define(["exports","./floatingUICore"],L):L((g=typeof globalThis<"u"?globalThis:g||self).FloatingUIDOM={},g.FloatingUICore)})(Rt,function(g,L){"use strict";let J=Math.min,at=Math.max,_=Math.round,Y=Math.floor,N=e=>({x:e,y:e});function st(){return typeof window<"u"}function ft(e){return tt(e)?(e.nodeName||"").toLowerCase():"#document"}function M(e){var n;return(e==null||(n=e.ownerDocument)==null?void 0:n.defaultView)||window}function W(e){var n;return(n=(tt(e)?e.ownerDocument:e.document)||window.document)==null?void 0:n.documentElement}function tt(e){return!!st()&&(e instanceof Node||e instanceof M(e).Node)}function K(e){return!!st()&&(e instanceof Element||e instanceof M(e).Element)}function Z(e){return!!st()&&(e instanceof HTMLElement||e instanceof M(e).HTMLElement)}function rt(e){return!(!st()||typeof ShadowRoot>"u")&&(e instanceof ShadowRoot||e instanceof M(e).ShadowRoot)}function dt(e){let{overflow:n,overflowX:l,overflowY:s,display:f}=nt(e);return/auto|scroll|overlay|hidden|clip/.test(n+s+l)&&!["inline","contents"].includes(f)}function vt(e){return["table","td","th"].includes(ft(e))}function ut(e){return[":popover-open",":modal"].some(n=>{try{return e.matches(n)}catch{return!1}})}function et(e){let n=mt(),l=K(e)?nt(e):e;return["transform","translate","scale","rotate","perspective"].some(s=>!!l[s]&&l[s]!=="none")||!!l.containerType&&l.containerType!=="normal"||!n&&!!l.backdropFilter&&l.backdropFilter!=="none"||!n&&!!l.filter&&l.filter!=="none"||["transform","translate","scale","rotate","perspective","filter"].some(s=>(l.willChange||"").includes(s))||["paint","layout","strict","content"].some(s=>(l.contain||"").includes(s))}function mt(){return!(typeof CSS>"u"||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function it(e){return["html","body","#document"].includes(ft(e))}function nt(e){return M(e).getComputedStyle(e)}function ot(e){return K(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ct(e){if(ft(e)==="html")return e;let n=e.assignedSlot||e.parentNode||rt(e)&&e.host||W(e);return rt(n)?n.host:n}function ht(e){let n=ct(e);return it(n)?e.ownerDocument?e.ownerDocument.body:e.body:Z(n)&&dt(n)?n:ht(n)}function pt(e,n,l){var s;n===void 0&&(n=[]),l===void 0&&(l=!0);let f=ht(e),m=f===((s=e.ownerDocument)==null?void 0:s.body),v=M(f);if(m){let x=r(v);return n.concat(v,v.visualViewport||[],dt(f)?f:[],x&&l?pt(x):[])}return n.concat(f,pt(f,[],l))}function r(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function a(e){let n=nt(e),l=parseFloat(n.width)||0,s=parseFloat(n.height)||0,f=Z(e),m=f?e.offsetWidth:l,v=f?e.offsetHeight:s,x=_(l)!==m||_(s)!==v;return x&&(l=m,s=v),{width:l,height:s,$:x}}function y(e){return K(e)?e:e.contextElement}function t(e){let n=y(e);if(!Z(n))return N(1);let l=n.getBoundingClientRect(),{width:s,height:f,$:m}=a(n),v=(m?_(l.width):l.width)/s,x=(m?_(l.height):l.height)/f;return v&&Number.isFinite(v)||(v=1),x&&Number.isFinite(x)||(x=1),{x:v,y:x}}let o=N(0);function i(e){let n=M(e);return mt()&&n.visualViewport?{x:n.visualViewport.offsetLeft,y:n.visualViewport.offsetTop}:o}function c(e,n,l,s){n===void 0&&(n=!1),l===void 0&&(l=!1);let f=e.getBoundingClientRect(),m=y(e),v=N(1);n&&(s?K(s)&&(v=t(s)):v=t(e));let x=(function(G,j,I){return j===void 0&&(j=!1),!(!I||j&&I!==M(G))&&j})(m,l,s)?i(m):N(0),h=(f.left+x.x)/v.x,w=(f.top+x.y)/v.y,H=f.width/v.x,z=f.height/v.y;if(m){let G=M(m),j=s&&K(s)?M(s):s,I=G,X=r(I);for(;X&&s&&j!==I;){let U=t(X),lt=X.getBoundingClientRect(),gt=nt(X),yt=lt.left+(X.clientLeft+parseFloat(gt.paddingLeft))*U.x,xt=lt.top+(X.clientTop+parseFloat(gt.paddingTop))*U.y;h*=U.x,w*=U.y,H*=U.x,z*=U.y,h+=yt,w+=xt,I=M(X),X=r(I)}}return L.rectToClientRect({width:H,height:z,x:h,y:w})}function u(e,n){let l=ot(e).scrollLeft;return n?n.left+l:c(W(e)).left+l}function A(e,n,l){l===void 0&&(l=!1);let s=e.getBoundingClientRect();return{x:s.left+n.scrollLeft-(l?0:u(e,s)),y:s.top+n.scrollTop}}function S(e,n,l){let s;if(n==="viewport")s=(function(f,m){let v=M(f),x=W(f),h=v.visualViewport,w=x.clientWidth,H=x.clientHeight,z=0,G=0;if(h){w=h.width,H=h.height;let j=mt();(!j||j&&m==="fixed")&&(z=h.offsetLeft,G=h.offsetTop)}return{width:w,height:H,x:z,y:G}})(e,l);else if(n==="document")s=(function(f){let m=W(f),v=ot(f),x=f.ownerDocument.body,h=at(m.scrollWidth,m.clientWidth,x.scrollWidth,x.clientWidth),w=at(m.scrollHeight,m.clientHeight,x.scrollHeight,x.clientHeight),H=-v.scrollLeft+u(f),z=-v.scrollTop;return nt(x).direction==="rtl"&&(H+=at(m.clientWidth,x.clientWidth)-h),{width:h,height:w,x:H,y:z}})(W(e));else if(K(n))s=(function(f,m){let v=c(f,!0,m==="fixed"),x=v.top+f.clientTop,h=v.left+f.clientLeft,w=Z(f)?t(f):N(1);return{width:f.clientWidth*w.x,height:f.clientHeight*w.y,x:h*w.x,y:x*w.y}})(n,l);else{let f=i(e);s={x:n.x-f.x,y:n.y-f.y,width:n.width,height:n.height}}return L.rectToClientRect(s)}function b(e,n){let l=ct(e);return!(l===n||!K(l)||it(l))&&(nt(l).position==="fixed"||b(l,n))}function d(e,n,l){let s=Z(n),f=W(n),m=l==="fixed",v=c(e,!0,m,n),x={scrollLeft:0,scrollTop:0},h=N(0);function w(){h.x=u(f)}if(s||!s&&!m)if((ft(n)!=="body"||dt(f))&&(x=ot(n)),s){let z=c(n,!0,m,n);h.x=z.x+n.clientLeft,h.y=z.y+n.clientTop}else f&&w();m&&!s&&f&&w();let H=!f||s||m?N(0):A(f,x);return{x:v.left+x.scrollLeft-h.x-H.x,y:v.top+x.scrollTop-h.y-H.y,width:v.width,height:v.height}}function R(e){return nt(e).position==="static"}function p(e,n){if(!Z(e)||nt(e).position==="fixed")return null;if(n)return n(e);let l=e.offsetParent;return W(e)===l&&(l=l.ownerDocument.body),l}function T(e,n){let l=M(e);if(ut(e))return l;if(!Z(e)){let f=ct(e);for(;f&&!it(f);){if(K(f)&&!R(f))return f;f=ct(f)}return l}let s=p(e,n);for(;s&&vt(s)&&R(s);)s=p(s,n);return s&&it(s)&&R(s)&&!et(s)?l:s||(function(f){let m=ct(f);for(;Z(m)&&!it(m);){if(et(m))return m;if(ut(m))return null;m=ct(m)}return null})(e)||l}let C={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:n,rect:l,offsetParent:s,strategy:f}=e,m=f==="fixed",v=W(s),x=!!n&&ut(n.floating);if(s===v||x&&m)return l;let h={scrollLeft:0,scrollTop:0},w=N(1),H=N(0),z=Z(s);if((z||!z&&!m)&&((ft(s)!=="body"||dt(v))&&(h=ot(s)),Z(s))){let j=c(s);w=t(s),H.x=j.x+s.clientLeft,H.y=j.y+s.clientTop}let G=!v||z||m?N(0):A(v,h,!0);return{width:l.width*w.x,height:l.height*w.y,x:l.x*w.x-h.scrollLeft*w.x+H.x+G.x,y:l.y*w.y-h.scrollTop*w.y+H.y+G.y}},getDocumentElement:W,getClippingRect:function(e){let{element:n,boundary:l,rootBoundary:s,strategy:f}=e,m=[...l==="clippingAncestors"?ut(n)?[]:(function(h,w){let H=w.get(h);if(H)return H;let z=pt(h,[],!1).filter(X=>K(X)&&ft(X)!=="body"),G=null,j=nt(h).position==="fixed",I=j?ct(h):h;for(;K(I)&&!it(I);){let X=nt(I),U=et(I);U||X.position!=="fixed"||(G=null),(j?!U&&!G:!U&&X.position==="static"&&G&&["absolute","fixed"].includes(G.position)||dt(I)&&!U&&b(h,I))?z=z.filter(lt=>lt!==I):G=X,I=ct(I)}return w.set(h,z),z})(n,this._c):[].concat(l),s],v=m[0],x=m.reduce((h,w)=>{let H=S(n,w,f);return h.top=at(H.top,h.top),h.right=J(H.right,h.right),h.bottom=J(H.bottom,h.bottom),h.left=at(H.left,h.left),h},S(n,v,f));return{width:x.right-x.left,height:x.bottom-x.top,x:x.left,y:x.top}},getOffsetParent:T,getElementRects:async function(e){let n=this.getOffsetParent||T,l=this.getDimensions,s=await l(e.floating);return{reference:d(e.reference,await n(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){let{width:n,height:l}=a(e);return{width:n,height:l}},getScale:t,isElement:K,isRTL:function(e){return nt(e).direction==="rtl"}};function E(e,n){return e.x===n.x&&e.y===n.y&&e.width===n.width&&e.height===n.height}let k=L.detectOverflow,F=L.offset,P=L.autoPlacement,O=L.shift,D=L.flip,V=L.size,q=L.hide,Q=L.arrow,B=L.inline,$=L.limitShift;return g.arrow=Q,g.autoPlacement=P,g.autoUpdate=function(e,n,l,s){s===void 0&&(s={});let{ancestorScroll:f=!0,ancestorResize:m=!0,elementResize:v=typeof ResizeObserver=="function",layoutShift:x=typeof IntersectionObserver=="function",animationFrame:h=!1}=s,w=y(e),H=f||m?[...w?pt(w):[],...pt(n)]:[];H.forEach(U=>{f&&U.addEventListener("scroll",l,{passive:!0}),m&&U.addEventListener("resize",l)});let z=w&&x?(function(U,lt){let gt,yt=null,xt=W(U);function Lt(){var wt;clearTimeout(gt),(wt=yt)==null||wt.disconnect(),yt=null}return(function wt(Ct,bt){Ct===void 0&&(Ct=!1),bt===void 0&&(bt=1),Lt();let Pt=U.getBoundingClientRect(),{left:Ot,top:Dt,width:Ft,height:St}=Pt;if(Ct||lt(),!Ft||!St)return;let kt={rootMargin:-Y(Dt)+"px "+-Y(xt.clientWidth-(Ot+Ft))+"px "+-Y(xt.clientHeight-(Dt+St))+"px "+-Y(Ot)+"px",threshold:at(0,J(1,bt))||1},Ht=!0;function Bt(Mt){let Tt=Mt[0].intersectionRatio;if(Tt!==bt){if(!Ht)return wt();Tt?wt(!1,Tt):gt=setTimeout(()=>{wt(!1,1e-7)},1e3)}Tt!==1||E(Pt,U.getBoundingClientRect())||wt(),Ht=!1}try{yt=new IntersectionObserver(Bt,{...kt,root:xt.ownerDocument})}catch{yt=new IntersectionObserver(Bt,kt)}yt.observe(U)})(!0),Lt})(w,l):null,G,j=-1,I=null;v&&(I=new ResizeObserver(U=>{let[lt]=U;lt&<.target===w&&I&&(I.unobserve(n),cancelAnimationFrame(j),j=requestAnimationFrame(()=>{var gt;(gt=I)==null||gt.observe(n)})),l()}),w&&!h&&I.observe(w),I.observe(n));let X=h?c(e):null;return h&&(function U(){let lt=c(e);X&&!E(X,lt)&&l(),X=lt,G=requestAnimationFrame(U)})(),l(),()=>{var U;H.forEach(lt=>{f&<.removeEventListener("scroll",l),m&<.removeEventListener("resize",l)}),z?.(),(U=I)==null||U.disconnect(),I=null,h&&cancelAnimationFrame(G)}},g.computePosition=(e,n,l)=>{let s=new Map,f={platform:C,...l},m={...f.platform,_c:s};return L.computePosition(e,n,{...f,platform:m})},g.detectOverflow=k,g.flip=D,g.getOverflowAncestors=pt,g.hide=q,g.inline=B,g.limitShift=$,g.offset=F,g.platform=C,g.shift=O,g.size=V,window.FloatingUIDOM=g,g})});var Jt=Ut(Et()),Kt=Ut(zt());(function(){"use strict";let g=new WeakMap,L=new WeakMap,J="absolute h-2.5 w-2.5 rotate-45 bg-popover border border-border",at=150;function _(t){let o=document.getElementById(t);return o?.matches("[data-tui-popover-root]")?o:null}function Y(){return Array.from(document.querySelectorAll("[data-tui-popover-root]"))}function N(t){return Array.from(t?.children||[]).find(o=>o.matches("[data-tui-popover-content]"))}function st(t){return Array.from(t?.children||[]).filter(o=>o.matches("[data-tui-popover-trigger]"))}function ft(t){let o=t,i=0;for(let c of t.children){let u=c.getBoundingClientRect?.();if(!u)continue;let A=u.width*u.height;A>i&&(i=A,o=c)}return o}function M(t){return st(t).some(o=>o.getAttribute("data-tui-popover-type")==="hover")}function W(t){return N(t)?.getAttribute("data-tui-popover-open")==="true"}function tt(t){let o=_(t);return o?W(o):!1}function K(t){let o=L.get(t);o&&(clearTimeout(o.enter),clearTimeout(o.leave),L.delete(t))}function Z(t){let o=g.get(t);o&&(o(),g.delete(t))}function rt(t){if(clearTimeout(t._tuiPopoverCloseTimeout),t._tuiPopoverCloseTimeout=null,!t.matches(":popover-open"))try{t.showPopover()}catch{return!1}return requestAnimationFrame(()=>{t.setAttribute("data-tui-popover-open","true")}),!0}function dt(t){clearTimeout(t._tuiPopoverCloseTimeout),t._tuiPopoverCloseTimeout=null,t.setAttribute("data-tui-popover-open","false"),t.matches(":popover-open")&&(t._tuiPopoverCloseTimeout=setTimeout(()=>{if(t._tuiPopoverCloseTimeout=null,t.matches(":popover-open"))try{t.hidePopover()}catch{}},at))}function vt(t){switch(t){case"top-start":case"top":case"top-end":return`${J} -bottom-[5px] border-t-transparent border-l-transparent`;case"right-start":case"right":case"right-end":return`${J} -left-[5px] border-r-transparent border-t-transparent`;case"bottom-start":case"bottom":case"bottom-end":return`${J} -top-[5px] border-b-transparent border-r-transparent`;case"left-start":case"left":case"left-end":return`${J} -right-[5px] border-l-transparent border-b-transparent`;default:return`${J} -top-[5px] border-b-transparent border-r-transparent`}}function ut(t,o=null){if(!window.FloatingUIDOM)return;let i=o||st(t)[0],c=N(t);if(!i||!c)return;let{computePosition:u,offset:A,flip:S,shift:b,arrow:d}=window.FloatingUIDOM,R=ft(i),p=c.querySelector("[data-tui-popover-arrow]"),T=c.getAttribute("data-tui-popover-placement")||"bottom",C=parseInt(c.getAttribute("data-tui-popover-offset"),10)||(p?8:4),E=[A(C),S({padding:10}),b({padding:10})];p&&E.push(d({element:p,padding:5})),u(R,c,{placement:T,middleware:E,strategy:"fixed"}).then(({x:k,y:F,placement:P,middlewareData:O})=>{if(Object.assign(c.style,{left:`${k}px`,top:`${F}px`}),p&&O.arrow){let{x:D,y:V}=O.arrow;p.setAttribute("data-tui-popover-placement",P),p.className=vt(P),Object.assign(p.style,{left:D!=null?`${D}px`:"",top:V!=null?`${V}px`:""})}})}function et(t){let o=N(t);o&&(Z(t),K(t),st(t).forEach(i=>{i.setAttribute("data-tui-popover-open","false")}),dt(o))}function mt(t){let o=_(t);o&&et(o)}function it(t=null){Y().forEach(o=>{o!==t&&W(o)&&et(o)})}function nt(t=null){it(t?_(t):null)}function ot(t,o=null){let i=N(t),c=o||st(t)[0];if(!(!i||!c)&&(i.getAttribute("data-tui-popover-exclusive")==="true"&&it(t),!!rt(i)&&(st(t).forEach(u=>{u.setAttribute("data-tui-popover-open","true")}),Z(t),ut(t,c),window.FloatingUIDOM))){let u=window.FloatingUIDOM.autoUpdate(c,i,()=>ut(t,c),{animationFrame:!0});g.set(t,u)}}function ct(t){let o=_(t);o&&ot(o)}function ht(t,o=null){if(W(t)){et(t);return}ot(t,o)}function pt(t){let o=_(t);o&&ht(o)}function r(t){Y().forEach(o=>{o===t||!M(o)||(K(o),et(o))})}function a(t,o){let i=N(t);if(!i||!M(t))return;let c=parseInt(i.getAttribute("data-tui-popover-hover-delay"),10)||100,u=L.get(t)||{};r(t),clearTimeout(u.leave),clearTimeout(u.enter),u.enter=setTimeout(()=>ot(t,o),c),L.set(t,u)}function y(t,o){let i=N(t);if(!i||!M(t))return;let c=parseInt(i.getAttribute("data-tui-popover-hover-out-delay"),10)||200,u=L.get(t)||{};clearTimeout(u.enter),o||(u.leave=setTimeout(()=>et(t),c),L.set(t,u))}document.addEventListener("click",t=>{let o=t.target.closest("[data-tui-popover-trigger]"),i=o?.closest("[data-tui-popover-root]"),c=o?.getAttribute("data-tui-popover-type");if(o&&i&&c!=="hover"&&c!=="manual"){if(o.querySelector(':disabled, [disabled], [aria-disabled="true"]'))return;t.preventDefault(),t.stopPropagation(),ht(i,o);return}Y().forEach(u=>{let A=N(u);if(!A||!A.matches(":popover-open")||A.getAttribute("data-tui-popover-disable-clickaway")==="true")return;let S=A.contains(t.target),b=st(u).some(d=>d.contains(t.target));!S&&!b&&et(u)})}),document.addEventListener("mouseover",t=>{let o=t.target.closest("[data-tui-popover-trigger]"),i=o?.closest("[data-tui-popover-root]");o&&i&&!o.contains(t.relatedTarget)&&o.getAttribute("data-tui-popover-type")==="hover"&&a(i,o);let c=t.target.closest("[data-tui-popover-content]"),u=c?.closest("[data-tui-popover-root]");if(c&&u&&M(u)&&!c.contains(t.relatedTarget)&&c.matches(":popover-open")){let A=L.get(u)||{};clearTimeout(A.leave),L.set(u,A)}}),document.addEventListener("mouseout",t=>{let o=t.target.closest("[data-tui-popover-trigger]"),i=o?.closest("[data-tui-popover-root]");if(o&&i&&!o.contains(t.relatedTarget)&&o.getAttribute("data-tui-popover-type")==="hover"){let A=N(i);y(i,!!A?.contains(t.relatedTarget))}let c=t.target.closest("[data-tui-popover-content]"),u=c?.closest("[data-tui-popover-root]");if(c&&u&&M(u)&&!c.contains(t.relatedTarget)&&c.matches(":popover-open")){let A=st(u).some(S=>S.contains(t.relatedTarget));y(u,A)}}),document.addEventListener("keydown",t=>{t.key==="Escape"&&Y().forEach(o=>{let i=N(o);i&&i.matches(":popover-open")&&i.getAttribute("data-tui-popover-disable-esc")!=="true"&&et(o)})}),window.tui=window.tui||{},window.tui.popover={open:ct,close:mt,closeAll:nt,toggle:pt,isOpen:tt}})();})(); diff --git a/assets/js/progress.js b/assets/js/progress.js new file mode 100644 index 0000000..95de00a --- /dev/null +++ b/assets/js/progress.js @@ -0,0 +1,49 @@ +(function () { + 'use strict'; + + function updateProgress(progressBar) { + const indicator = progressBar.querySelector('[data-tui-progress-indicator]'); + if (!indicator) return; + + const value = parseFloat(progressBar.getAttribute('aria-valuenow') || '0'); + const max = parseFloat(progressBar.getAttribute('aria-valuemax') || '100') || 100; + const percentage = Math.max(0, Math.min(100, (value / max) * 100)); + + indicator.style.width = percentage + '%'; + } + + // Update all progress bars + function updateAll() { + document.querySelectorAll('[role="progressbar"]').forEach(updateProgress); + } + + // Initial update and observe for changes + document.addEventListener('DOMContentLoaded', () => { + updateAll(); + + // Observe for attribute changes on progress bars + const observer = new MutationObserver((mutations) => { + mutations.forEach((mutation) => { + if (mutation.type === 'attributes' && + (mutation.attributeName === 'aria-valuenow' || + mutation.attributeName === 'aria-valuemax')) { + updateProgress(mutation.target); + } + }); + }); + + // Observe all current and future progress bars + new MutationObserver(() => { + document.querySelectorAll('[role="progressbar"]').forEach((bar) => { + if (!bar.hasAttribute('data-tui-progress-observed')) { + bar.setAttribute('data-tui-progress-observed', 'true'); + updateProgress(bar); + observer.observe(bar, { + attributes: true, + attributeFilter: ['aria-valuenow', 'aria-valuemax'] + }); + } + }); + }).observe(document.body, { childList: true, subtree: true }); + }); +})(); diff --git a/assets/js/rating.js b/assets/js/rating.js new file mode 100644 index 0000000..54bcd04 --- /dev/null +++ b/assets/js/rating.js @@ -0,0 +1,216 @@ +(function () { + 'use strict'; + + /** + * Reactive Binding for hidden inputs + * + * Problem: Setting input.value programmatically (e.g., via Datastar/Alpine) + * does NOT fire 'input' events - this is standard browser behavior since the 90s. + * + * Solution: Override the value setter to dispatch 'input' events on change. + * This is the same pattern used by Vue.js, MobX, and other reactive frameworks. + */ + function enableReactiveBinding(input) { + if (input._tui) return; + input._tui = true; + + const desc = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value'); + if (!desc?.set) return; + + Object.defineProperty(input, 'value', { + get: desc.get, + set(v) { + const old = this.value; + desc.set.call(this, v); + if (old !== v) { + this.dispatchEvent(new Event('input', { bubbles: true })); + } + }, + configurable: true + }); + } + + // Utility functions + function getConfig(ratingElement) { + return { + value: parseFloat(ratingElement.getAttribute('data-tui-rating-initial-value')) || 0, + precision: parseFloat(ratingElement.getAttribute('data-tui-rating-precision')) || 1, + readonly: ratingElement.getAttribute('data-tui-rating-readonly') === 'true', + name: ratingElement.getAttribute('data-tui-rating-name') || '', + onlyInteger: ratingElement.getAttribute('data-tui-rating-onlyinteger') === 'true' + }; + } + + function getCurrentValue(ratingElement) { + return parseFloat(ratingElement.getAttribute('data-tui-rating-current')) || + parseFloat(ratingElement.getAttribute('data-tui-rating-initial-value')) || 0; + } + + function setCurrentValue(ratingElement, value) { + ratingElement.setAttribute('data-tui-rating-current', value); + const hiddenInput = ratingElement.querySelector('[data-tui-rating-hidden-input]'); + if (hiddenInput) { + hiddenInput.value = value.toFixed(2); + hiddenInput.dispatchEvent(new Event('input', { bubbles: true })); + hiddenInput.dispatchEvent(new Event('change', { bubbles: true })); + } + } + + function updateItemStyles(ratingElement, displayValue) { + const currentValue = getCurrentValue(ratingElement); + const valueToCompare = displayValue > 0 ? displayValue : currentValue; + + ratingElement.querySelectorAll('[data-tui-rating-item]').forEach(item => { + const itemValue = parseInt(item.getAttribute('data-tui-rating-value'), 10); + if (isNaN(itemValue)) return; + + const foreground = item.querySelector('[data-tui-rating-item-foreground]'); + if (!foreground) return; + + const filled = itemValue <= Math.floor(valueToCompare); + const partial = !filled && itemValue - 1 < valueToCompare && valueToCompare < itemValue; + const percentage = partial ? (valueToCompare - Math.floor(valueToCompare)) * 100 : 0; + + foreground.style.width = filled ? '100%' : partial ? `${percentage}%` : '0%'; + }); + } + + function getMaxValue(ratingElement) { + let max = 0; + ratingElement.querySelectorAll('[data-tui-rating-item]').forEach(item => { + const value = parseInt(item.getAttribute('data-tui-rating-value'), 10); + if (!isNaN(value) && value > max) max = value; + }); + return Math.max(1, max); + } + + // Event handlers + document.addEventListener('click', (e) => { + const item = e.target.closest('[data-tui-rating-item]'); + if (!item) return; + + const ratingElement = item.closest('[data-tui-rating-component]'); + if (!ratingElement) return; + + const config = getConfig(ratingElement); + if (config.readonly) return; + + const itemValue = parseInt(item.getAttribute('data-tui-rating-value'), 10); + if (isNaN(itemValue)) return; + + const currentValue = getCurrentValue(ratingElement); + const maxValue = getMaxValue(ratingElement); + + let newValue = itemValue; + if (config.onlyInteger) { + newValue = Math.round(newValue); + } else { + if (currentValue === newValue && newValue % 1 === 0) { + newValue = Math.max(0, newValue - config.precision); + } else { + newValue = Math.round(newValue / config.precision) * config.precision; + } + } + + newValue = Math.max(0, Math.min(maxValue, newValue)); + setCurrentValue(ratingElement, newValue); + updateItemStyles(ratingElement, 0); + + ratingElement.dispatchEvent( + new CustomEvent('rating-change', { + bubbles: true, + detail: { name: config.name, value: newValue, maxValue } + }) + ); + }); + + document.addEventListener('mouseover', (e) => { + const item = e.target.closest('[data-tui-rating-item]'); + if (!item) return; + + const ratingElement = item.closest('[data-tui-rating-component]'); + if (!ratingElement || getConfig(ratingElement).readonly) return; + + const previewValue = parseInt(item.getAttribute('data-tui-rating-value'), 10); + if (!isNaN(previewValue)) { + updateItemStyles(ratingElement, previewValue); + } + }); + + document.addEventListener('mouseout', (e) => { + const ratingElement = e.target.closest('[data-tui-rating-component]'); + if (!ratingElement || getConfig(ratingElement).readonly) return; + + // Check if we're leaving the rating component entirely + if (!ratingElement.contains(e.relatedTarget)) { + updateItemStyles(ratingElement, 0); + } + }); + + // Handle hidden input value changes (for reactive frameworks) + document.addEventListener('input', (e) => { + if (!e.target.matches('[data-tui-rating-hidden-input]')) return; + + const ratingElement = e.target.closest('[data-tui-rating-component]'); + if (ratingElement) { + const value = parseFloat(e.target.value) || 0; + const config = getConfig(ratingElement); + const maxValue = getMaxValue(ratingElement); + const clampedValue = Math.max(0, Math.min(maxValue, value)); + ratingElement.setAttribute('data-tui-rating-current', clampedValue); + updateItemStyles(ratingElement, 0); + } + }); + + // Form reset + document.addEventListener('reset', (e) => { + if (!e.target.matches('form')) return; + + e.target.querySelectorAll('[data-tui-rating-component]').forEach(ratingElement => { + const config = getConfig(ratingElement); + setCurrentValue(ratingElement, config.value); + updateItemStyles(ratingElement, 0); + }); + }); + + // Initialize ratings + function initializeRatings() { + document.querySelectorAll('[data-tui-rating-component]').forEach(ratingElement => { + // Enable reactive binding for hidden input + const hiddenInput = ratingElement.querySelector('[data-tui-rating-hidden-input]'); + if (hiddenInput && !hiddenInput._tui) { + enableReactiveBinding(hiddenInput); + } + + // Initialize current value if not set + if (!ratingElement.hasAttribute('data-tui-rating-current')) { + const config = getConfig(ratingElement); + const maxValue = getMaxValue(ratingElement); + const value = Math.max(0, Math.min(maxValue, config.value)); + setCurrentValue(ratingElement, Math.round(value / config.precision) * config.precision); + } + + // Update styles + updateItemStyles(ratingElement, 0); + + // Set cursor styles + const config = getConfig(ratingElement); + if (config.readonly) { + ratingElement.style.cursor = 'default'; + ratingElement.querySelectorAll('[data-tui-rating-item]').forEach(item => { + item.style.cursor = 'default'; + }); + } + }); + } + + // Initialize on DOM ready + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', initializeRatings); + } else { + initializeRatings(); + } + + // MutationObserver for dynamically added elements + new MutationObserver(initializeRatings).observe(document.body, { childList: true, subtree: true }); +})(); \ No newline at end of file diff --git a/assets/js/selectbox.js b/assets/js/selectbox.js new file mode 100644 index 0000000..74e231e --- /dev/null +++ b/assets/js/selectbox.js @@ -0,0 +1,507 @@ +(function () { + 'use strict'; + + /** + * Reactive Binding for hidden inputs + * + * Problem: Setting input.value programmatically (e.g., via Datastar/Alpine) + * does NOT fire 'input' events - this is standard browser behavior since the 90s. + * + * Solution: Override the value setter to dispatch 'input' events on change. + * This is the same pattern used by Vue.js, MobX, and other reactive frameworks. + */ + function enableReactiveBinding(input) { + if (input._tui) return; + input._tui = true; + + const desc = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value'); + if (!desc?.set) return; + + Object.defineProperty(input, 'value', { + get: desc.get, + set(v) { + const old = this.value; + desc.set.call(this, v); + if (old !== v) { + this.dispatchEvent(new Event('input', { bubbles: true })); + } + }, + configurable: true + }); + } + + function updateTriggerClearState(trigger) { + const clearTrigger = trigger.querySelector('[data-tui-selectbox-clear-trigger]'); + if (!clearTrigger) return; + + const chevron = trigger.querySelector('[data-tui-selectbox-chevron]'); + const hiddenInput = trigger.querySelector('input[type="hidden"]'); + const hasSelection = !!hiddenInput?.value && !trigger.disabled; + + clearTrigger.classList.toggle('hidden', !hasSelection); + if (chevron) chevron.classList.toggle('hidden', hasSelection); + } + + function clearFromTrigger(trigger) { + const hiddenInput = trigger.querySelector('input[type="hidden"]'); + if (!hiddenInput || !hiddenInput.value) return; + + hiddenInput.value = ''; + hiddenInput.dispatchEvent(new Event('input', { bubbles: true })); + hiddenInput.dispatchEvent(new Event('change', { bubbles: true })); + } + + function getContainer(element) { + return element?.closest('.select-container') || null; + } + + function getTriggerFromContainer(container) { + return container?.querySelector('button.select-trigger') || null; + } + + function getContentFromContainer(container) { + return container?.querySelector('[data-tui-selectbox-content]') || null; + } + + function getContentFromTrigger(trigger) { + return getContentFromContainer(getContainer(trigger)); + } + + function syncContentWidth(trigger) { + const content = getContentFromTrigger(trigger); + if (!content) return; + + const width = trigger.getBoundingClientRect().width; + content.style.width = `${width}px`; + content.style.minWidth = `${width}px`; + } + + function closePopover(trigger) { + const content = getContentFromTrigger(trigger); + if (!content?.matches(':popover-open')) return; + + try { + content.hidePopover(); + } catch { + // ignore + } + } + + // Helper to sync selections from hidden input value + function syncSelectionsFromValue(trigger) { + const hiddenInput = trigger.querySelector('input[type="hidden"]'); + const content = getContentFromTrigger(trigger); + + if (!hiddenInput || !content) return; + + const isMultiple = trigger.getAttribute('data-tui-selectbox-multiple') === 'true'; + const values = hiddenInput.value ? (isMultiple ? hiddenInput.value.split(',') : [hiddenInput.value]) : []; + + content.querySelectorAll('.select-item').forEach(item => { + const itemValue = item.getAttribute('data-tui-selectbox-value') || ''; + const shouldBeSelected = values.includes(itemValue); + const isSelected = item.getAttribute('data-tui-selectbox-selected') === 'true'; + + if (shouldBeSelected !== isSelected) { + item.setAttribute('data-tui-selectbox-selected', shouldBeSelected.toString()); + } + }); + } + + // Helper to update display value + function updateDisplayValue(trigger) { + const valueEl = trigger.querySelector('.select-value'); + const hiddenInput = trigger.querySelector('input[type="hidden"]'); + const content = getContentFromTrigger(trigger); + + if (!valueEl) { + updateTriggerClearState(trigger); + return; + } + + // If no content yet (not opened), try to init from hidden input value + if (!content && hiddenInput && hiddenInput.value) { + valueEl.textContent = hiddenInput.value; // Simple fallback + valueEl.classList.remove('text-muted-foreground'); + updateTriggerClearState(trigger); + return; + } + + if (!content) { + updateTriggerClearState(trigger); + return; + } + + const isMultiple = trigger.getAttribute('data-tui-selectbox-multiple') === 'true'; + const showPills = trigger.getAttribute('data-tui-selectbox-show-pills') === 'true'; + const placeholder = valueEl.getAttribute('data-tui-selectbox-placeholder') || 'Select...'; + + const selectedItems = content.querySelectorAll('.select-item[data-tui-selectbox-selected="true"]'); + + if (selectedItems.length === 0) { + valueEl.textContent = placeholder; + valueEl.classList.add('text-muted-foreground'); + if (hiddenInput) hiddenInput.value = ''; + updateTriggerClearState(trigger); + return; + } + + valueEl.classList.remove('text-muted-foreground'); + + if (isMultiple) { + if (showPills) { + // Create pills container + valueEl.innerHTML = ''; + const pillsContainer = document.createElement('div'); + pillsContainer.className = 'flex flex-wrap gap-1 items-center min-h-[1.5rem]'; + + const pills = []; + + Array.from(selectedItems).forEach(selectedItem => { + const pill = document.createElement('span'); + pill.className = 'inline-flex items-center gap-1 px-2 py-0.5 text-xs rounded-md bg-primary text-primary-foreground'; + + const text = document.createElement('span'); + text.textContent = selectedItem.querySelector('.select-item-text')?.textContent || ''; + pill.appendChild(text); + + // Add remove button for pills + const removeBtn = document.createElement('button'); + removeBtn.className = 'ml-0.5 hover:text-destructive focus:outline-none'; + removeBtn.type = 'button'; + removeBtn.innerHTML = '×'; + removeBtn.setAttribute('data-tui-selectbox-pill-remove', ''); + removeBtn.setAttribute('data-tui-selectbox-value', selectedItem.getAttribute('data-tui-selectbox-value')); + pill.appendChild(removeBtn); + + pills.push(pill); + }); + + // Try adding pills and check overflow + pills.forEach(pill => pillsContainer.appendChild(pill)); + valueEl.appendChild(pillsContainer); + + // Check overflow after render + requestAnimationFrame(() => { + const containerWidth = valueEl.offsetWidth; + const contentWidth = pillsContainer.scrollWidth; + + // If pills overflow and we have more than 3 items, switch to count + if (contentWidth > containerWidth - 10 && selectedItems.length > 3) { + const countText = trigger.getAttribute('data-tui-selectbox-selected-count-text') || '{n} items selected'; + valueEl.textContent = countText.replace('{n}', selectedItems.length); + } + }); + } else { + const countText = trigger.getAttribute('data-tui-selectbox-selected-count-text') || '{n} items selected'; + valueEl.textContent = countText.replace('{n}', selectedItems.length); + } + + // Update hidden input with CSV + const values = Array.from(selectedItems).map(item => + item.getAttribute('data-tui-selectbox-value') || '' + ); + if (hiddenInput) hiddenInput.value = values.join(','); + } else { + // Single selection + const selectedItem = selectedItems[0]; + const text = selectedItem.querySelector('.select-item-text')?.textContent || ''; + valueEl.textContent = text; + + if (hiddenInput) { + hiddenInput.value = selectedItem.getAttribute('data-tui-selectbox-value') || ''; + } + } + + updateTriggerClearState(trigger); + } + + function normalizeSearchValue(value) { + return (value || '').toLowerCase().trim().replace(/\s+/g, ' '); + } + + function fuzzyMatch(searchTerm, candidate) { + const needle = normalizeSearchValue(searchTerm).replace(/\s+/g, ''); + const haystack = normalizeSearchValue(candidate).replace(/\s+/g, ''); + + if (!needle) return true; + if (!haystack) return false; + if (haystack.includes(needle)) return true; + + let needleIndex = 0; + + for (let i = 0; i < haystack.length && needleIndex < needle.length; i += 1) { + if (haystack[i] === needle[needleIndex]) { + needleIndex += 1; + } + } + + return needleIndex === needle.length; + } + + // Helper to filter items based on search + function filterItems(searchInput) { + const searchTerm = normalizeSearchValue(searchInput.value); + const content = searchInput.closest('[data-tui-selectbox-content]'); + if (!content) return; + + content.querySelectorAll('.select-item').forEach(item => { + const text = normalizeSearchValue(item.querySelector('.select-item-text')?.textContent); + const value = normalizeSearchValue(item.getAttribute('data-tui-selectbox-value')); + const visible = !searchTerm || fuzzyMatch(searchTerm, text) || fuzzyMatch(searchTerm, value); + item.style.display = visible ? '' : 'none'; + }); + } + + // Helper to select/deselect item + function toggleItem(item) { + if (item.getAttribute('data-tui-selectbox-disabled') === 'true') return; + + const content = item.closest('[data-tui-selectbox-content]'); + const trigger = getTriggerFromContainer(getContainer(item)); + if (!trigger) return; + + const isMultiple = trigger.getAttribute('data-tui-selectbox-multiple') === 'true'; + const isSelected = item.getAttribute('data-tui-selectbox-selected') === 'true'; + + if (!isMultiple) { + // Single selection - deselect all others + content.querySelectorAll('.select-item').forEach(el => { + el.setAttribute('data-tui-selectbox-selected', 'false'); + }); + } + + // Toggle this item + item.setAttribute('data-tui-selectbox-selected', (!isSelected).toString()); + + // Update display + updateDisplayValue(trigger); + + // Trigger change event + const hiddenInput = trigger.querySelector('input[type="hidden"]'); + if (hiddenInput) { + hiddenInput.dispatchEvent(new Event('change', { bubbles: true })); + } + + // Close on single selection + if (!isMultiple) { + closePopover(trigger); + setTimeout(() => trigger.focus(), 50); + } + } + + // Initialize display values for existing selectboxes + function initializeDisplayValues() { + document.querySelectorAll('.select-container').forEach(container => { + const trigger = container.querySelector('button.select-trigger'); + if (trigger) { + updateDisplayValue(trigger); + } + }); + } + + // Handle clear in capture phase so trigger popover doesn't open. + document.addEventListener('pointerdown', (e) => { + const clearTrigger = e.target.closest('[data-tui-selectbox-clear-trigger]'); + if (!clearTrigger) return; + e.preventDefault(); + e.stopPropagation(); + const trigger = clearTrigger.closest('button.select-trigger'); + if (trigger) { + // The clear icon may disappear before click fires; suppress that next click. + trigger.setAttribute('data-tui-selectbox-suppress-click', 'true'); + clearFromTrigger(trigger); + } + }, true); + + // Block follow-up click event after clear so trigger/popover handlers don't run. + document.addEventListener('click', (e) => { + const clearTrigger = e.target.closest('[data-tui-selectbox-clear-trigger]'); + const trigger = e.target.closest('button.select-trigger'); + + if (clearTrigger) { + e.preventDefault(); + e.stopPropagation(); + return; + } + + if (trigger?.getAttribute('data-tui-selectbox-suppress-click') === 'true') { + trigger.removeAttribute('data-tui-selectbox-suppress-click'); + e.preventDefault(); + e.stopPropagation(); + } + }, true); + + // Global click handler using Event Delegation + document.addEventListener('click', (e) => { + // Handle pill remove clicks + if (e.target.matches('[data-tui-selectbox-pill-remove]')) { + e.stopPropagation(); + const value = e.target.getAttribute('data-tui-selectbox-value'); + const trigger = e.target.closest('button.select-trigger'); + const content = trigger ? getContentFromTrigger(trigger) : null; + const item = content?.querySelector(`.select-item[data-tui-selectbox-value="${value}"]`); + if (item) toggleItem(item); + return; + } + + // Handle item clicks + const item = e.target.closest('.select-item'); + if (item) { + e.preventDefault(); + toggleItem(item); + return; + } + + // Focus search when trigger clicked + const trigger = e.target.closest('button.select-trigger'); + if (trigger) { + const content = getContentFromTrigger(trigger); + syncContentWidth(trigger); + const searchInput = content?.querySelector('[data-tui-selectbox-search]'); + if (searchInput) { + requestAnimationFrame(() => { + if (content?.matches(':popover-open')) searchInput.focus(); + }); + } else { + requestAnimationFrame(() => { + const firstItem = content?.querySelector('.select-item'); + if (firstItem) firstItem.focus(); + }); + } + } + }); + + // Global input handler for search and value changes + document.addEventListener('input', (e) => { + // Handle search input + if (e.target.matches('[data-tui-selectbox-search]')) { + filterItems(e.target); + return; + } + + // Handle hidden input value changes (for reactive frameworks) + if (e.target.matches('[data-tui-selectbox-hidden-input]')) { + const trigger = e.target.closest('.select-trigger'); + if (trigger) { + syncSelectionsFromValue(trigger); + updateDisplayValue(trigger); + } + } + }); + + // Global keydown handler + document.addEventListener('keydown', (e) => { + const activeElement = document.activeElement; + + // Handle typing on trigger to open and search + if (activeElement?.matches('button.select-trigger')) { + if (e.key.length === 1 || e.key === 'Backspace') { + e.preventDefault(); + const content = getContentFromTrigger(activeElement); + activeElement.click(); // Open popover + + setTimeout(() => { + const searchInput = content?.querySelector('[data-tui-selectbox-search]'); + if (searchInput) { + searchInput.focus(); + if (e.key !== 'Backspace') searchInput.value = e.key; + } + }, 50); + } + } + + // Handle arrow navigation in content + const content = activeElement?.closest('[data-tui-selectbox-content]'); + if (content?.querySelector('.select-item')) { + if (e.key === 'ArrowDown' || e.key === 'ArrowUp') { + e.preventDefault(); + + const visibleItems = Array.from(content.querySelectorAll('.select-item')) + .filter(item => item.style.display !== 'none'); + + if (visibleItems.length === 0) return; + + const currentFocused = content.querySelector('.select-item:focus'); + let nextIndex = 0; + + if (currentFocused) { + const currentIndex = visibleItems.indexOf(currentFocused); + nextIndex = e.key === 'ArrowDown' + ? (currentIndex + 1) % visibleItems.length + : (currentIndex - 1 + visibleItems.length) % visibleItems.length; + } + + visibleItems[nextIndex].focus(); + } else if (e.key === 'Enter' && activeElement?.matches('.select-item')) { + e.preventDefault(); + toggleItem(activeElement); + } else if (e.key === 'Escape') { + const searchInput = content.querySelector('[data-tui-selectbox-search]'); + if (activeElement?.matches('.select-item')) { + searchInput?.focus(); + } else if (activeElement === searchInput) { + const trigger = getTriggerFromContainer(getContainer(content)); + if (trigger) { + closePopover(trigger); + } + setTimeout(() => trigger?.focus(), 50); + } + } + } + }); + + // Global form reset handler + document.addEventListener('reset', (e) => { + if (!e.target.matches('form')) return; + + e.target.querySelectorAll('.select-container').forEach(wrapper => { + const trigger = wrapper.querySelector('button.select-trigger'); + const content = trigger ? getContentFromTrigger(trigger) : null; + + if (content) { + // Clear selections + content.querySelectorAll('.select-item').forEach(item => { + item.setAttribute('data-tui-selectbox-selected', 'false'); + }); + + // Clear search + const searchInput = content.querySelector('[data-tui-selectbox-search]'); + if (searchInput) { + searchInput.value = ''; + filterItems(searchInput); + } + } + + if (trigger) updateDisplayValue(trigger); + }); + }); + + // Initialize selectboxes on DOM ready and handle dynamic content + function initializeSelectBoxes() { + document.querySelectorAll('.select-container').forEach(container => { + const trigger = container.querySelector('button.select-trigger'); + if (trigger && !trigger.hasAttribute('data-initialized')) { + trigger.setAttribute('data-initialized', 'true'); + + // Enable reactive binding for hidden input + const hiddenInput = trigger.querySelector('input[type="hidden"]'); + if (hiddenInput) { + enableReactiveBinding(hiddenInput); + } + + updateDisplayValue(trigger); + } + }); + } + + // Initialize on DOM ready + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', initializeSelectBoxes); + } else { + initializeSelectBoxes(); + } + + // Simple MutationObserver just for initialization + new MutationObserver(initializeSelectBoxes).observe(document.body, { childList: true, subtree: true }); +})(); diff --git a/assets/js/selectbox.min.js b/assets/js/selectbox.min.js index 1c73897..ced415d 100644 --- a/assets/js/selectbox.min.js +++ b/assets/js/selectbox.min.js @@ -1 +1 @@ -(()=>{(function(){"use strict";function v(t){if(t._tui)return;t._tui=!0;let e=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value");e?.set&&Object.defineProperty(t,"value",{get:e.get,set(c){let o=this.value;e.set.call(this,c),o!==c&&this.dispatchEvent(new Event("input",{bubbles:!0}))},configurable:!0})}function A(t){let e=t.querySelector('input[type="hidden"]'),c=t.getAttribute("data-tui-selectbox-content-id"),o=document.getElementById(c);if(!e||!o)return;let n=t.getAttribute("data-tui-selectbox-multiple")==="true",i=e.value?n?e.value.split(","):[e.value]:[];o.querySelectorAll(".select-item").forEach(s=>{let l=s.getAttribute("data-tui-selectbox-value")||"",a=i.includes(l),u=s.getAttribute("data-tui-selectbox-selected")==="true";if(a!==u)if(s.setAttribute("data-tui-selectbox-selected",a.toString()),a){s.classList.add("bg-accent","text-accent-foreground");let r=s.querySelector(".select-check");r&&r.classList.replace("opacity-0","opacity-100")}else{s.classList.remove("bg-accent","text-accent-foreground");let r=s.querySelector(".select-check");r&&r.classList.replace("opacity-100","opacity-0")}})}function b(t){let e=t.querySelector(".select-value"),c=t.querySelector('input[type="hidden"]'),o=t.getAttribute("data-tui-selectbox-content-id"),n=document.getElementById(o);if(!n&&c&&c.value){e.textContent=c.value,e.classList.remove("text-muted-foreground");return}if(!e||!n)return;let i=t.getAttribute("data-tui-selectbox-multiple")==="true",s=t.getAttribute("data-tui-selectbox-show-pills")==="true",l=e.getAttribute("data-tui-selectbox-placeholder")||"Select...",a=n.querySelectorAll('.select-item[data-tui-selectbox-selected="true"]');if(a.length===0){e.textContent=l,e.classList.add("text-muted-foreground"),c&&(c.value="");return}if(e.classList.remove("text-muted-foreground"),i){if(s){e.innerHTML="";let r=document.createElement("div");r.className="flex flex-wrap gap-1 items-center min-h-[1.5rem]";let h=[];Array.from(a).forEach(d=>{let p=document.createElement("span");p.className="inline-flex items-center gap-1 px-2 py-0.5 text-xs rounded-md bg-primary text-primary-foreground";let g=document.createElement("span");g.textContent=d.querySelector(".select-item-text")?.textContent||"",p.appendChild(g);let f=document.createElement("button");f.className="ml-0.5 hover:text-destructive focus:outline-none",f.type="button",f.innerHTML="\xD7",f.setAttribute("data-tui-selectbox-pill-remove",""),f.setAttribute("data-tui-selectbox-value",d.getAttribute("data-tui-selectbox-value")),p.appendChild(f),h.push(p)}),h.forEach(d=>r.appendChild(d)),e.appendChild(r),requestAnimationFrame(()=>{let d=e.offsetWidth;if(r.scrollWidth>d-10&&a.length>3){let g=t.getAttribute("data-tui-selectbox-selected-count-text")||"{n} items selected";e.textContent=g.replace("{n}",a.length)}})}else{let r=t.getAttribute("data-tui-selectbox-selected-count-text")||"{n} items selected";e.textContent=r.replace("{n}",a.length)}let u=Array.from(a).map(r=>r.getAttribute("data-tui-selectbox-value")||"");c&&(c.value=u.join(","))}else{let u=a[0],r=u.querySelector(".select-item-text")?.textContent||"";e.textContent=r,c&&(c.value=u.getAttribute("data-tui-selectbox-value")||"")}}function x(t){let e=t.value.toLowerCase().trim(),c=t.closest("[data-tui-popover-id]");c&&c.querySelectorAll(".select-item").forEach(o=>{let n=o.querySelector(".select-item-text")?.textContent.toLowerCase()||"",i=o.getAttribute("data-tui-selectbox-value")?.toLowerCase()||"",s=!e||n.includes(e)||i.includes(e);o.style.display=s?"":"none"})}function m(t){if(t.getAttribute("data-tui-selectbox-disabled")==="true")return;let e=t.closest("[data-tui-popover-id]"),c=e?.id,o=document.querySelector(`[data-tui-selectbox-content-id="${c}"]`);if(!o)return;let n=o.getAttribute("data-tui-selectbox-multiple")==="true",i=t.getAttribute("data-tui-selectbox-selected")==="true";if(n||e.querySelectorAll(".select-item").forEach(l=>{l.setAttribute("data-tui-selectbox-selected","false"),l.classList.remove("bg-accent","text-accent-foreground");let a=l.querySelector(".select-check");a&&a.classList.replace("opacity-100","opacity-0")}),t.setAttribute("data-tui-selectbox-selected",(!i).toString()),i){t.classList.remove("bg-accent","text-accent-foreground");let l=t.querySelector(".select-check");l&&l.classList.replace("opacity-100","opacity-0")}else{t.classList.add("bg-accent","text-accent-foreground");let l=t.querySelector(".select-check");l&&l.classList.replace("opacity-0","opacity-100")}b(o);let s=o.querySelector('input[type="hidden"]');s&&s.dispatchEvent(new Event("change",{bubbles:!0})),!n&&window.closePopover&&(window.closePopover(c),setTimeout(()=>o.focus(),50))}function S(){document.querySelectorAll(".select-container").forEach(t=>{let e=t.querySelector("button.select-trigger");e&&b(e)})}document.addEventListener("click",t=>{if(t.target.matches("[data-tui-selectbox-pill-remove]")){t.stopPropagation();let o=t.target.getAttribute("data-tui-selectbox-value"),i=t.target.closest("button.select-trigger")?.getAttribute("data-tui-selectbox-content-id"),l=document.getElementById(i)?.querySelector(`.select-item[data-tui-selectbox-value="${o}"]`);l&&m(l);return}let e=t.target.closest(".select-item");if(e){t.preventDefault(),m(e);return}let c=t.target.closest("button.select-trigger");if(c){let o=c.getAttribute("data-tui-selectbox-content-id"),n=document.getElementById(o),i=n?.querySelector("[data-tui-selectbox-search]");i&&setTimeout(()=>{n.style.display!=="none"&&i.focus()},50)}}),document.addEventListener("input",t=>{if(t.target.matches("[data-tui-selectbox-search]")){x(t.target);return}if(t.target.matches("[data-tui-selectbox-hidden-input]")){let e=t.target.closest(".select-trigger");e&&(A(e),b(e))}}),document.addEventListener("keydown",t=>{let e=document.activeElement;if(e?.matches("button.select-trigger")&&(t.key.length===1||t.key==="Backspace")){t.preventDefault();let o=e.getAttribute("data-tui-selectbox-content-id");e.click(),setTimeout(()=>{let n=document.getElementById(o)?.querySelector("[data-tui-selectbox-search]");n&&(n.focus(),t.key!=="Backspace"&&(n.value=t.key))},50)}let c=e?.closest("[data-tui-popover-id]");if(c?.querySelector(".select-item")){if(t.key==="ArrowDown"||t.key==="ArrowUp"){t.preventDefault();let o=Array.from(c.querySelectorAll(".select-item")).filter(s=>s.style.display!=="none");if(o.length===0)return;let n=c.querySelector(".select-item:focus"),i=0;if(n){let s=o.indexOf(n);i=t.key==="ArrowDown"?(s+1)%o.length:(s-1+o.length)%o.length}o[i].focus()}else if(t.key==="Enter"&&e?.matches(".select-item"))t.preventDefault(),m(e);else if(t.key==="Escape"){let o=c.querySelector("[data-tui-selectbox-search]");if(e?.matches(".select-item"))o?.focus();else if(e===o&&window.closePopover){window.closePopover(c.id);let n=document.querySelector(`[data-tui-selectbox-content-id="${c.id}"]`);setTimeout(()=>n?.focus(),50)}}}}),document.addEventListener("mouseover",t=>{let e=t.target.closest(".select-item");if(!e||e.getAttribute("data-tui-selectbox-disabled")==="true")return;let c=e.closest("[data-tui-popover-id]");c&&(c.querySelectorAll(".select-item").forEach(o=>{o.getAttribute("data-tui-selectbox-selected")!=="true"&&o.classList.remove("bg-accent","text-accent-foreground")}),e.getAttribute("data-tui-selectbox-selected")!=="true"&&e.classList.add("bg-accent","text-accent-foreground"))}),document.addEventListener("reset",t=>{t.target.matches("form")&&t.target.querySelectorAll(".select-container").forEach(e=>{let c=e.querySelector("button.select-trigger"),o=c?.getAttribute("data-tui-selectbox-content-id"),n=document.getElementById(o);if(n){n.querySelectorAll(".select-item").forEach(s=>{s.setAttribute("data-tui-selectbox-selected","false"),s.classList.remove("bg-accent","text-accent-foreground");let l=s.querySelector(".select-check");l&&l.classList.replace("opacity-100","opacity-0")});let i=n.querySelector("[data-tui-selectbox-search]");i&&(i.value="",x(i))}c&&b(c)})});function y(){document.querySelectorAll(".select-container").forEach(t=>{let e=t.querySelector("button.select-trigger");if(e&&!e.hasAttribute("data-initialized")){e.setAttribute("data-initialized","true");let c=e.querySelector('input[type="hidden"]');c&&v(c),b(e)}})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",y):y(),new MutationObserver(y).observe(document.body,{childList:!0,subtree:!0})})();})(); +(()=>{(function(){"use strict";function w(t){if(t._tui)return;t._tui=!0;let e=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value");e?.set&&Object.defineProperty(t,"value",{get:e.get,set(n){let c=this.value;e.set.call(this,n),c!==n&&this.dispatchEvent(new Event("input",{bubbles:!0}))},configurable:!0})}function p(t){let e=t.querySelector("[data-tui-selectbox-clear-trigger]");if(!e)return;let n=t.querySelector("[data-tui-selectbox-chevron]"),r=!!t.querySelector('input[type="hidden"]')?.value&&!t.disabled;e.classList.toggle("hidden",!r),n&&n.classList.toggle("hidden",r)}function k(t){let e=t.querySelector('input[type="hidden"]');!e||!e.value||(e.value="",e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})))}function x(t){return t?.closest(".select-container")||null}function S(t){return t?.querySelector("button.select-trigger")||null}function I(t){return t?.querySelector("[data-tui-selectbox-content]")||null}function u(t){return I(x(t))}function L(t){let e=u(t);if(!e)return;let n=t.getBoundingClientRect().width;e.style.width=`${n}px`,e.style.minWidth=`${n}px`}function A(t){let e=u(t);if(e?.matches(":popover-open"))try{e.hidePopover()}catch{}}function T(t){let e=t.querySelector('input[type="hidden"]'),n=u(t);if(!e||!n)return;let c=t.getAttribute("data-tui-selectbox-multiple")==="true",r=e.value?c?e.value.split(","):[e.value]:[];n.querySelectorAll(".select-item").forEach(o=>{let s=o.getAttribute("data-tui-selectbox-value")||"",i=r.includes(s),a=o.getAttribute("data-tui-selectbox-selected")==="true";i!==a&&o.setAttribute("data-tui-selectbox-selected",i.toString())})}function b(t){let e=t.querySelector(".select-value"),n=t.querySelector('input[type="hidden"]'),c=u(t);if(!e){p(t);return}if(!c&&n&&n.value){e.textContent=n.value,e.classList.remove("text-muted-foreground"),p(t);return}if(!c){p(t);return}let r=t.getAttribute("data-tui-selectbox-multiple")==="true",o=t.getAttribute("data-tui-selectbox-show-pills")==="true",s=e.getAttribute("data-tui-selectbox-placeholder")||"Select...",i=c.querySelectorAll('.select-item[data-tui-selectbox-selected="true"]');if(i.length===0){e.textContent=s,e.classList.add("text-muted-foreground"),n&&(n.value=""),p(t);return}if(e.classList.remove("text-muted-foreground"),r){if(o){e.innerHTML="";let l=document.createElement("div");l.className="flex flex-wrap gap-1 items-center min-h-[1.5rem]";let C=[];Array.from(i).forEach(d=>{let h=document.createElement("span");h.className="inline-flex items-center gap-1 px-2 py-0.5 text-xs rounded-md bg-primary text-primary-foreground";let m=document.createElement("span");m.textContent=d.querySelector(".select-item-text")?.textContent||"",h.appendChild(m);let f=document.createElement("button");f.className="ml-0.5 hover:text-destructive focus:outline-none",f.type="button",f.innerHTML="\xD7",f.setAttribute("data-tui-selectbox-pill-remove",""),f.setAttribute("data-tui-selectbox-value",d.getAttribute("data-tui-selectbox-value")),h.appendChild(f),C.push(h)}),C.forEach(d=>l.appendChild(d)),e.appendChild(l),requestAnimationFrame(()=>{let d=e.offsetWidth;if(l.scrollWidth>d-10&&i.length>3){let m=t.getAttribute("data-tui-selectbox-selected-count-text")||"{n} items selected";e.textContent=m.replace("{n}",i.length)}})}else{let l=t.getAttribute("data-tui-selectbox-selected-count-text")||"{n} items selected";e.textContent=l.replace("{n}",i.length)}let a=Array.from(i).map(l=>l.getAttribute("data-tui-selectbox-value")||"");n&&(n.value=a.join(","))}else{let a=i[0],l=a.querySelector(".select-item-text")?.textContent||"";e.textContent=l,n&&(n.value=a.getAttribute("data-tui-selectbox-value")||"")}p(t)}function g(t){return(t||"").toLowerCase().trim().replace(/\s+/g," ")}function q(t,e){let n=g(t).replace(/\s+/g,""),c=g(e).replace(/\s+/g,"");if(!n)return!0;if(!c)return!1;if(c.includes(n))return!0;let r=0;for(let o=0;o{let r=g(c.querySelector(".select-item-text")?.textContent),o=g(c.getAttribute("data-tui-selectbox-value")),s=!e||q(e,r)||q(e,o);c.style.display=s?"":"none"})}function y(t){if(t.getAttribute("data-tui-selectbox-disabled")==="true")return;let e=t.closest("[data-tui-selectbox-content]"),n=S(x(t));if(!n)return;let c=n.getAttribute("data-tui-selectbox-multiple")==="true",r=t.getAttribute("data-tui-selectbox-selected")==="true";c||e.querySelectorAll(".select-item").forEach(s=>{s.setAttribute("data-tui-selectbox-selected","false")}),t.setAttribute("data-tui-selectbox-selected",(!r).toString()),b(n);let o=n.querySelector('input[type="hidden"]');o&&o.dispatchEvent(new Event("change",{bubbles:!0})),c||(A(n),setTimeout(()=>n.focus(),50))}function D(){document.querySelectorAll(".select-container").forEach(t=>{let e=t.querySelector("button.select-trigger");e&&b(e)})}document.addEventListener("pointerdown",t=>{let e=t.target.closest("[data-tui-selectbox-clear-trigger]");if(!e)return;t.preventDefault(),t.stopPropagation();let n=e.closest("button.select-trigger");n&&(n.setAttribute("data-tui-selectbox-suppress-click","true"),k(n))},!0),document.addEventListener("click",t=>{let e=t.target.closest("[data-tui-selectbox-clear-trigger]"),n=t.target.closest("button.select-trigger");if(e){t.preventDefault(),t.stopPropagation();return}n?.getAttribute("data-tui-selectbox-suppress-click")==="true"&&(n.removeAttribute("data-tui-selectbox-suppress-click"),t.preventDefault(),t.stopPropagation())},!0),document.addEventListener("click",t=>{if(t.target.matches("[data-tui-selectbox-pill-remove]")){t.stopPropagation();let c=t.target.getAttribute("data-tui-selectbox-value"),r=t.target.closest("button.select-trigger"),s=(r?u(r):null)?.querySelector(`.select-item[data-tui-selectbox-value="${c}"]`);s&&y(s);return}let e=t.target.closest(".select-item");if(e){t.preventDefault(),y(e);return}let n=t.target.closest("button.select-trigger");if(n){let c=u(n);L(n);let r=c?.querySelector("[data-tui-selectbox-search]");requestAnimationFrame(r?()=>{c?.matches(":popover-open")&&r.focus()}:()=>{let o=c?.querySelector(".select-item");o&&o.focus()})}}),document.addEventListener("input",t=>{if(t.target.matches("[data-tui-selectbox-search]")){E(t.target);return}if(t.target.matches("[data-tui-selectbox-hidden-input]")){let e=t.target.closest(".select-trigger");e&&(T(e),b(e))}}),document.addEventListener("keydown",t=>{let e=document.activeElement;if(e?.matches("button.select-trigger")&&(t.key.length===1||t.key==="Backspace")){t.preventDefault();let c=u(e);e.click(),setTimeout(()=>{let r=c?.querySelector("[data-tui-selectbox-search]");r&&(r.focus(),t.key!=="Backspace"&&(r.value=t.key))},50)}let n=e?.closest("[data-tui-selectbox-content]");if(n?.querySelector(".select-item")){if(t.key==="ArrowDown"||t.key==="ArrowUp"){t.preventDefault();let c=Array.from(n.querySelectorAll(".select-item")).filter(s=>s.style.display!=="none");if(c.length===0)return;let r=n.querySelector(".select-item:focus"),o=0;if(r){let s=c.indexOf(r);o=t.key==="ArrowDown"?(s+1)%c.length:(s-1+c.length)%c.length}c[o].focus()}else if(t.key==="Enter"&&e?.matches(".select-item"))t.preventDefault(),y(e);else if(t.key==="Escape"){let c=n.querySelector("[data-tui-selectbox-search]");if(e?.matches(".select-item"))c?.focus();else if(e===c){let r=S(x(n));r&&A(r),setTimeout(()=>r?.focus(),50)}}}}),document.addEventListener("reset",t=>{t.target.matches("form")&&t.target.querySelectorAll(".select-container").forEach(e=>{let n=e.querySelector("button.select-trigger"),c=n?u(n):null;if(c){c.querySelectorAll(".select-item").forEach(o=>{o.setAttribute("data-tui-selectbox-selected","false")});let r=c.querySelector("[data-tui-selectbox-search]");r&&(r.value="",E(r))}n&&b(n)})});function v(){document.querySelectorAll(".select-container").forEach(t=>{let e=t.querySelector("button.select-trigger");if(e&&!e.hasAttribute("data-initialized")){e.setAttribute("data-initialized","true");let n=e.querySelector('input[type="hidden"]');n&&w(n),b(e)}})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",v):v(),new MutationObserver(v).observe(document.body,{childList:!0,subtree:!0})})();})(); diff --git a/assets/js/sidebar.js b/assets/js/sidebar.js new file mode 100644 index 0000000..dc074f4 --- /dev/null +++ b/assets/js/sidebar.js @@ -0,0 +1,129 @@ +(function () { + "use strict"; + + const SIDEBAR_COOKIE_NAME = "sidebar_state"; + const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7; // 7 days + + // Portal setup - moves content between desktop and mobile views + function setupMobilePortals() { + const contentElements = document.querySelectorAll( + "[data-tui-sidebar-content]", + ); + + contentElements.forEach((content) => { + const sidebarId = content.getAttribute("data-tui-sidebar-content"); + const portal = document.querySelector( + `[data-tui-sidebar-mobile-portal="${sidebarId}"]`, + ); + if (!portal) return; + + // Check viewport and move content if needed + const isMobile = window.matchMedia("(max-width: 767px)").matches; + + if (isMobile && content.parentElement !== portal) { + // Move to mobile portal + portal.appendChild(content); + } else if (!isMobile && content.parentElement === portal) { + // Move back to desktop sidebar + const desktopContainer = document.querySelector( + `[data-tui-sidebar-wrapper][data-tui-sidebar-id="${sidebarId}"] [data-sidebar="sidebar"] > div`, + ); + if (desktopContainer) { + desktopContainer.appendChild(content); + } + } + }); + } + + // Initial setup + setupMobilePortals(); + + // Handle viewport changes + window.addEventListener("resize", setupMobilePortals); + + // Handle DOM updates (for HTMX, Alpine, etc.) + const observer = new MutationObserver(setupMobilePortals); + observer.observe(document.body, { + childList: true, + subtree: true, + }); + + // Event delegation for sidebar interactions (Desktop only - Mobile uses Sheet) + document.addEventListener("click", (e) => { + const trigger = e.target.closest("[data-tui-sidebar-trigger]"); + if (trigger) { + e.preventDefault(); + const targetId = trigger.getAttribute("data-tui-sidebar-target"); + if (targetId) { + toggleSidebar(targetId); + } + } + }); + + // Handle keyboard shortcuts + document.addEventListener("keydown", (e) => { + // Ctrl/Cmd + key - toggle sidebar + if ((e.ctrlKey || e.metaKey) && e.key.length === 1) { + const wrapper = document.querySelector('[data-tui-sidebar-wrapper]'); + if (!wrapper) return; + + const shortcut = wrapper.getAttribute("data-tui-sidebar-keyboard-shortcut"); + if (!shortcut || shortcut.toLowerCase() !== e.key.toLowerCase()) return; + + e.preventDefault(); + const sidebar = wrapper.querySelector('[data-sidebar="sidebar"]'); + if (sidebar && sidebar.id) { + toggleSidebar(sidebar.id); + } + } + }); + + function toggleSidebar(sidebarId) { + const wrapper = document.querySelector( + `[data-tui-sidebar-wrapper][data-tui-sidebar-id="${sidebarId}"]`, + ); + if (!wrapper) return; + + const collapsible = wrapper.getAttribute("data-tui-sidebar-collapsible"); + + // Don't toggle if collapsible is "none" + if (collapsible === "none") { + return; + } + + const currentState = wrapper.getAttribute("data-tui-sidebar-state"); + const newState = currentState === "expanded" ? "collapsed" : "expanded"; + + setSidebarState(sidebarId, newState); + } + + function setSidebarState(sidebarId, state) { + const wrapper = document.querySelector( + `[data-tui-sidebar-wrapper][data-tui-sidebar-id="${sidebarId}"]`, + ); + if (!wrapper) return; + + const collapsible = wrapper.getAttribute("data-tui-sidebar-collapsible"); + + // Don't change state if collapsible is "none" + if (collapsible === "none") { + return; + } + + // Update data-tui-sidebar-state attribute + wrapper.setAttribute("data-tui-sidebar-state", state); + + // For icon mode, also set data-tui-sidebar-collapsible when collapsed + if (state === "collapsed" && collapsible) { + wrapper.setAttribute("data-tui-sidebar-collapsible", collapsible); + } + + // Save state to cookie + const cookieValue = state === "expanded" ? "true" : "false"; + saveSidebarState(sidebarId, cookieValue); + } + + function saveSidebarState(sidebarId, cookieValue) { + document.cookie = `${SIDEBAR_COOKIE_NAME}=${cookieValue}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`; + } +})(); diff --git a/assets/js/slider.js b/assets/js/slider.js new file mode 100644 index 0000000..d05bcfb --- /dev/null +++ b/assets/js/slider.js @@ -0,0 +1,26 @@ +(function () { + 'use strict'; + + // Update value display elements + document.addEventListener('input', (e) => { + const slider = e.target.closest('input[type="range"][data-tui-slider-input]'); + if (!slider || !slider.id) return; + + document.querySelectorAll(`[data-tui-slider-value][data-tui-slider-value-for="${slider.id}"]`).forEach(el => { + el.textContent = slider.value; + }); + }); + + // MutationObserver for initial value setup + new MutationObserver(() => { + document.querySelectorAll('input[type="range"][data-tui-slider-input]').forEach(slider => { + if (!slider.id) return; + + document.querySelectorAll(`[data-tui-slider-value][data-tui-slider-value-for="${slider.id}"]`).forEach(el => { + if (!el.textContent || el.textContent === '') { + el.textContent = slider.value; + } + }); + }); + }).observe(document.body, { childList: true, subtree: true }); +})(); \ No newline at end of file diff --git a/assets/js/tabs.js b/assets/js/tabs.js new file mode 100644 index 0000000..9959a6e --- /dev/null +++ b/assets/js/tabs.js @@ -0,0 +1,72 @@ +(function () { + "use strict"; + + // Update tab state + function setActiveTab(tabsId, value) { + // Update all triggers with this tabs-id + document + .querySelectorAll(`[data-tui-tabs-trigger][data-tui-tabs-id="${tabsId}"]`) + .forEach((trigger) => { + const isActive = trigger.getAttribute("data-tui-tabs-value") === value; + trigger.setAttribute( + "data-tui-tabs-state", + isActive ? "active" : "inactive", + ); + }); + + // Update all contents with this tabs-id + document + .querySelectorAll(`[data-tui-tabs-content][data-tui-tabs-id="${tabsId}"]`) + .forEach((content) => { + const isActive = content.getAttribute("data-tui-tabs-value") === value; + content.setAttribute( + "data-tui-tabs-state", + isActive ? "active" : "inactive", + ); + content.classList.toggle("hidden", !isActive); + }); + } + + // Click handler + document.addEventListener("click", (e) => { + const trigger = e.target.closest("[data-tui-tabs-trigger]"); + if (!trigger) return; + + const tabsId = trigger.getAttribute("data-tui-tabs-id"); + const value = trigger.getAttribute("data-tui-tabs-value"); + if (tabsId && value) { + setActiveTab(tabsId, value); + } + }); + + // Initialize active states + function setupInitialStates() { + document.querySelectorAll("[data-tui-tabs]").forEach((container) => { + const tabsId = container.getAttribute("data-tui-tabs-id"); + if (!tabsId) return; + + // Find active trigger or use first + const activeTrigger = + container.querySelector( + `[data-tui-tabs-trigger][data-tui-tabs-state="active"]`, + ) || container.querySelector(`[data-tui-tabs-trigger]`); + + if (activeTrigger) { + setActiveTab(tabsId, activeTrigger.getAttribute("data-tui-tabs-value")); + } + }); + } + + // Setup on load and mutations + document.addEventListener("DOMContentLoaded", setupInitialStates); + new MutationObserver(setupInitialStates).observe(document.body, { + childList: true, + subtree: true, + }); + + // Expose public API + window.tui = window.tui || {}; + window.tui.tabs = { + setActive: setActiveTab, + }; +})(); diff --git a/assets/js/tagsinput.js b/assets/js/tagsinput.js new file mode 100644 index 0000000..b2ae224 --- /dev/null +++ b/assets/js/tagsinput.js @@ -0,0 +1,213 @@ +(function () { + 'use strict'; + + function getSelectedTags(container) { + return Array.from(container.querySelectorAll('[data-tui-tagsinput-hidden-inputs] input')) + .map(i => i.value.toLowerCase()); + } + + function getSuggestionsRoot(container) { + const id = container.getAttribute('data-tui-tagsinput-suggestions-id'); + if (!id) return null; + const root = document.getElementById(id); + return root?.matches('[data-tui-popover-root]') ? root : null; + } + + function getSuggestionsContent(container) { + return getSuggestionsRoot(container)?.querySelector('[data-tui-popover-content]') || null; + } + + function showSuggestions(container, query) { + const id = container.getAttribute('data-tui-tagsinput-suggestions-id'); + const popup = getSuggestionsContent(container); + const input = container.querySelector('[data-tui-tagsinput-text-input]'); + if (!id || !popup || !input) return; + + popup.style.setProperty('--trigger-width', `${input.getBoundingClientRect().width}px`); + + const selected = getSelectedTags(container); + const q = query.toLowerCase().trim(); + let first = null; + + popup.querySelectorAll('[data-tui-tagsinput-suggestion]').forEach(el => { + const val = el.getAttribute('data-tui-tagsinput-suggestion-value').toLowerCase(); + const show = !selected.includes(val) && val.includes(q); + el.style.display = show ? '' : 'none'; + el.classList.remove('bg-accent'); + if (show && !first) { + first = el; + } + }); + + if (first) { + first.classList.add('bg-accent'); + window.tui?.popover?.open(id); + } else { + window.tui?.popover?.close(id); + } + } + + function getVisibleSuggestions(container) { + const popup = getSuggestionsContent(container); + if (!popup) return []; + return Array.from(popup.querySelectorAll('[data-tui-tagsinput-suggestion]')) + .filter(el => el.style.display !== 'none'); + } + + function moveSelection(container, dir) { + const items = getVisibleSuggestions(container); + if (!items.length) return; + + const current = items.findIndex(el => el.classList.contains('bg-accent')); + items.forEach(el => el.classList.remove('bg-accent')); + + let next = dir === 'down' ? current + 1 : current - 1; + if (next >= items.length) next = 0; + if (next < 0) next = items.length - 1; + + items[next].classList.add('bg-accent'); + items[next].scrollIntoView({ block: 'nearest' }); + } + + function addTag(container, value) { + const input = container.querySelector('[data-tui-tagsinput-text-input]'); + const val = value.trim(); + if (!val || input?.disabled) return; + + if (getSelectedTags(container).includes(val.toLowerCase())) { + input.value = ''; + return; + } + + // Create chip + const chip = document.createElement('div'); + chip.className = 'inline-flex items-center gap-2 rounded-md border px-2.5 py-0.5 text-xs font-semibold border-transparent bg-primary text-primary-foreground'; + chip.setAttribute('data-tui-tagsinput-chip', ''); + chip.innerHTML = `${val}`; + + // Add chip to chips container + container.querySelector('[data-tui-tagsinput-chips]').appendChild(chip); + + // Add hidden input + const hidden = document.createElement('input'); + hidden.type = 'hidden'; + hidden.name = container.getAttribute('data-tui-tagsinput-name') || ''; + hidden.value = val; + container.querySelector('[data-tui-tagsinput-hidden-inputs]').appendChild(hidden); + + input.value = ''; + } + + // Focus → show suggestions + document.addEventListener('focusin', e => { + const input = e.target.closest('[data-tui-tagsinput-text-input]'); + if (!input) return; + const container = input.closest('[data-tui-tagsinput]'); + if (container) showSuggestions(container, input.value); + }); + + // Focusout → close suggestions + document.addEventListener('focusout', e => { + const input = e.target.closest('[data-tui-tagsinput-text-input]'); + if (!input) return; + const container = input.closest('[data-tui-tagsinput]'); + const id = container?.getAttribute('data-tui-tagsinput-suggestions-id'); + const nextTarget = e.relatedTarget; + if (container?.contains(nextTarget) || getSuggestionsContent(container)?.contains(nextTarget)) return; + if (id) window.tui?.popover?.close(id); + }); + + // Input → filter suggestions + document.addEventListener('input', e => { + const input = e.target.closest('[data-tui-tagsinput-text-input]'); + if (!input) return; + const container = input.closest('[data-tui-tagsinput]'); + if (container) showSuggestions(container, input.value); + }); + + // Suggestion selection (mousedown to fire before focusout) + document.addEventListener('mousedown', e => { + const suggestion = e.target.closest('[data-tui-tagsinput-suggestion]'); + if (!suggestion) return; + e.preventDefault(); // Prevent focus change + const popupRoot = suggestion.closest('[data-tui-popover-root]'); + const container = document.querySelector(`[data-tui-tagsinput-suggestions-id="${popupRoot?.id}"]`); + if (container) { + addTag(container, suggestion.getAttribute('data-tui-tagsinput-suggestion-value')); + showSuggestions(container, ''); + } + }); + + // Click + document.addEventListener('click', e => { + // Click on input → show suggestions (handles re-click on already focused input) + const inputClick = e.target.closest('[data-tui-tagsinput-text-input]'); + if (inputClick) { + const container = inputClick.closest('[data-tui-tagsinput]'); + if (container) showSuggestions(container, inputClick.value); + return; + } + + // Remove click + const remove = e.target.closest('[data-tui-tagsinput-remove]'); + if (remove) { + const chip = remove.closest('[data-tui-tagsinput-chip]'); + const container = chip?.closest('[data-tui-tagsinput]'); + const val = chip?.querySelector('span')?.textContent; + chip?.remove(); + container?.querySelector(`[data-tui-tagsinput-hidden-inputs] input[value="${val}"]`)?.remove(); + return; + } + + // Click on container → focus input + const container = e.target.closest('[data-tui-tagsinput]'); + if (container && !e.target.closest('input')) { + container.querySelector('[data-tui-tagsinput-text-input]')?.focus(); + } + }); + + // Keyboard + document.addEventListener('keydown', e => { + const input = e.target.closest('[data-tui-tagsinput-text-input]'); + if (!input) return; + const container = input.closest('[data-tui-tagsinput]'); + if (!container) return; + + const id = container.getAttribute('data-tui-tagsinput-suggestions-id'); + const isOpen = id && window.tui?.popover?.isOpen(id); + + if (e.key === 'ArrowDown' && isOpen) { + e.preventDefault(); + moveSelection(container, 'down'); + } else if (e.key === 'ArrowUp' && isOpen) { + e.preventDefault(); + moveSelection(container, 'up'); + } else if (e.key === 'Enter') { + e.preventDefault(); + const items = getVisibleSuggestions(container); + const selected = items.find(el => el.classList.contains('bg-accent')); + if (selected) { + addTag(container, selected.getAttribute('data-tui-tagsinput-suggestion-value')); + showSuggestions(container, ''); + } else { + addTag(container, input.value); + showSuggestions(container, ''); + } + } else if (e.key === ',') { + e.preventDefault(); + addTag(container, input.value); + showSuggestions(container, ''); + } else if (e.key === 'Escape' && isOpen) { + e.preventDefault(); + window.tui?.popover?.close(id); + } else if (e.key === 'Backspace' && input.value === '') { + const chipsContainer = container.querySelector('[data-tui-tagsinput-chips]'); + const lastChip = chipsContainer?.lastElementChild; + if (lastChip) { + const val = lastChip.querySelector('span')?.textContent; + lastChip.remove(); + container.querySelector(`[data-tui-tagsinput-hidden-inputs] input[value="${val}"]`)?.remove(); + } + } + }); +})(); diff --git a/assets/js/tagsinput.min.js b/assets/js/tagsinput.min.js index cb4d202..b347f84 100644 --- a/assets/js/tagsinput.min.js +++ b/assets/js/tagsinput.min.js @@ -1,11 +1 @@ -(()=>{(function(){"use strict";function d(t,e){let n=document.createElement("div");return n.setAttribute("data-tui-tagsinput-chip",""),n.className="inline-flex items-center gap-2 rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 border-transparent bg-primary text-primary-foreground",n.innerHTML=` - ${t} - - `,n}function c(t,e){let n=t.querySelector("[data-tui-tagsinput-text-input]");if(n?.hasAttribute("disabled"))return;let i=e.trim();if(!i)return;let a=t.querySelector("[data-tui-tagsinput-hidden-inputs]"),u=t.querySelector("[data-tui-tagsinput-container]"),p=t.getAttribute("data-tui-tagsinput-name"),o=t.getAttribute("data-tui-tagsinput-form"),l=a.querySelectorAll('input[type="hidden"]');for(let f of l)if(f.value.toLowerCase()===i.toLowerCase()){n.value="";return}let g=d(i,n?.hasAttribute("disabled"));u.appendChild(g);let r=document.createElement("input");r.type="hidden",r.name=p,r.value=i,o!==null&&o!==""&&r.setAttribute("form",o),a.appendChild(r),n.value=""}function s(t){let e=t.closest("[data-tui-tagsinput-chip]");if(!e)return;let n=e.closest("[data-tui-tagsinput]"),i=e.querySelector("span").textContent.trim(),u=n.querySelector("[data-tui-tagsinput-hidden-inputs]").querySelector(`input[type="hidden"][value="${i}"]`);u&&u.remove(),e.remove()}document.addEventListener("keydown",t=>{let e=t.target.closest("[data-tui-tagsinput-text-input]");if(!e)return;let n=e.closest("[data-tui-tagsinput]");if(n){if(t.key==="Enter"||t.key===",")t.preventDefault(),c(n,e.value);else if(t.key==="Backspace"&&e.value===""){t.preventDefault();let a=n.querySelector("[data-tui-tagsinput-chip]:last-child")?.querySelector("[data-tui-tagsinput-remove]");a&&!a.disabled&&s(a)}}}),document.addEventListener("click",t=>{let e=t.target.closest("[data-tui-tagsinput-remove]");if(e&&!e.disabled){t.preventDefault(),t.stopPropagation(),s(e);return}let n=t.target.closest("[data-tui-tagsinput]");if(n&&!t.target.closest("input")){let i=n.querySelector("[data-tui-tagsinput-text-input]");i&&i.focus()}}),document.addEventListener("reset",t=>{t.target.matches("form")&&t.target.querySelectorAll("[data-tui-tagsinput]").forEach(e=>{e.querySelectorAll("[data-tui-tagsinput-chip]").forEach(i=>i.remove()),e.querySelectorAll('[data-tui-tagsinput-hidden-inputs] input[type="hidden"]').forEach(i=>i.remove());let n=e.querySelector("[data-tui-tagsinput-text-input]");n&&(n.value="")})})})();})(); +(()=>{(function(){"use strict";function p(e){return Array.from(e.querySelectorAll("[data-tui-tagsinput-hidden-inputs] input")).map(n=>n.value.toLowerCase())}function y(e){let n=e.getAttribute("data-tui-tagsinput-suggestions-id");if(!n)return null;let t=document.getElementById(n);return t?.matches("[data-tui-popover-root]")?t:null}function l(e){return y(e)?.querySelector("[data-tui-popover-content]")||null}function r(e,n){let t=e.getAttribute("data-tui-tagsinput-suggestions-id"),s=l(e),i=e.querySelector("[data-tui-tagsinput-text-input]");if(!t||!s||!i)return;s.style.setProperty("--trigger-width",`${i.getBoundingClientRect().width}px`);let u=p(e),o=n.toLowerCase().trim(),a=null;s.querySelectorAll("[data-tui-tagsinput-suggestion]").forEach(d=>{let v=d.getAttribute("data-tui-tagsinput-suggestion-value").toLowerCase(),m=!u.includes(v)&&v.includes(o);d.style.display=m?"":"none",d.classList.remove("bg-accent"),m&&!a&&(a=d)}),a?(a.classList.add("bg-accent"),window.tui?.popover?.open(t)):window.tui?.popover?.close(t)}function g(e){let n=l(e);return n?Array.from(n.querySelectorAll("[data-tui-tagsinput-suggestion]")).filter(t=>t.style.display!=="none"):[]}function f(e,n){let t=g(e);if(!t.length)return;let s=t.findIndex(u=>u.classList.contains("bg-accent"));t.forEach(u=>u.classList.remove("bg-accent"));let i=n==="down"?s+1:s-1;i>=t.length&&(i=0),i<0&&(i=t.length-1),t[i].classList.add("bg-accent"),t[i].scrollIntoView({block:"nearest"})}function c(e,n){let t=e.querySelector("[data-tui-tagsinput-text-input]"),s=n.trim();if(!s||t?.disabled)return;if(p(e).includes(s.toLowerCase())){t.value="";return}let i=document.createElement("div");i.className="inline-flex items-center gap-2 rounded-md border px-2.5 py-0.5 text-xs font-semibold border-transparent bg-primary text-primary-foreground",i.setAttribute("data-tui-tagsinput-chip",""),i.innerHTML=`${s}`,e.querySelector("[data-tui-tagsinput-chips]").appendChild(i);let u=document.createElement("input");u.type="hidden",u.name=e.getAttribute("data-tui-tagsinput-name")||"",u.value=s,e.querySelector("[data-tui-tagsinput-hidden-inputs]").appendChild(u),t.value=""}document.addEventListener("focusin",e=>{let n=e.target.closest("[data-tui-tagsinput-text-input]");if(!n)return;let t=n.closest("[data-tui-tagsinput]");t&&r(t,n.value)}),document.addEventListener("focusout",e=>{let n=e.target.closest("[data-tui-tagsinput-text-input]");if(!n)return;let t=n.closest("[data-tui-tagsinput]"),s=t?.getAttribute("data-tui-tagsinput-suggestions-id"),i=e.relatedTarget;t?.contains(i)||l(t)?.contains(i)||s&&window.tui?.popover?.close(s)}),document.addEventListener("input",e=>{let n=e.target.closest("[data-tui-tagsinput-text-input]");if(!n)return;let t=n.closest("[data-tui-tagsinput]");t&&r(t,n.value)}),document.addEventListener("mousedown",e=>{let n=e.target.closest("[data-tui-tagsinput-suggestion]");if(!n)return;e.preventDefault();let t=n.closest("[data-tui-popover-root]"),s=document.querySelector(`[data-tui-tagsinput-suggestions-id="${t?.id}"]`);s&&(c(s,n.getAttribute("data-tui-tagsinput-suggestion-value")),r(s,""))}),document.addEventListener("click",e=>{let n=e.target.closest("[data-tui-tagsinput-text-input]");if(n){let i=n.closest("[data-tui-tagsinput]");i&&r(i,n.value);return}let t=e.target.closest("[data-tui-tagsinput-remove]");if(t){let i=t.closest("[data-tui-tagsinput-chip]"),u=i?.closest("[data-tui-tagsinput]"),o=i?.querySelector("span")?.textContent;i?.remove(),u?.querySelector(`[data-tui-tagsinput-hidden-inputs] input[value="${o}"]`)?.remove();return}let s=e.target.closest("[data-tui-tagsinput]");s&&!e.target.closest("input")&&s.querySelector("[data-tui-tagsinput-text-input]")?.focus()}),document.addEventListener("keydown",e=>{let n=e.target.closest("[data-tui-tagsinput-text-input]");if(!n)return;let t=n.closest("[data-tui-tagsinput]");if(!t)return;let s=t.getAttribute("data-tui-tagsinput-suggestions-id"),i=s&&window.tui?.popover?.isOpen(s);if(e.key==="ArrowDown"&&i)e.preventDefault(),f(t,"down");else if(e.key==="ArrowUp"&&i)e.preventDefault(),f(t,"up");else if(e.key==="Enter"){e.preventDefault();let o=g(t).find(a=>a.classList.contains("bg-accent"));o?(c(t,o.getAttribute("data-tui-tagsinput-suggestion-value")),r(t,"")):(c(t,n.value),r(t,""))}else if(e.key===",")e.preventDefault(),c(t,n.value),r(t,"");else if(e.key==="Escape"&&i)e.preventDefault(),window.tui?.popover?.close(s);else if(e.key==="Backspace"&&n.value===""){let o=t.querySelector("[data-tui-tagsinput-chips]")?.lastElementChild;if(o){let a=o.querySelector("span")?.textContent;o.remove(),t.querySelector(`[data-tui-tagsinput-hidden-inputs] input[value="${a}"]`)?.remove()}}})})();})(); diff --git a/assets/js/textarea.js b/assets/js/textarea.js new file mode 100644 index 0000000..5c4cfba --- /dev/null +++ b/assets/js/textarea.js @@ -0,0 +1,22 @@ +(function () { + 'use strict'; + + // Auto-resize handler + document.addEventListener('input', (e) => { + const textarea = e.target.closest('textarea[data-tui-textarea]'); + if (!textarea || textarea.getAttribute('data-tui-textarea-auto-resize') !== 'true') return; + + const minHeight = textarea.style.minHeight || window.getComputedStyle(textarea).minHeight; + textarea.style.height = minHeight; + textarea.style.height = `${textarea.scrollHeight}px`; + }); + + // MutationObserver for initial setup + new MutationObserver(() => { + document.querySelectorAll('textarea[data-tui-textarea][data-tui-textarea-auto-resize="true"]').forEach(textarea => { + if (!textarea.style.height || textarea.style.height === textarea.style.minHeight) { + textarea.style.height = `${textarea.scrollHeight}px`; + } + }); + }).observe(document.body, { childList: true, subtree: true }); +})(); \ No newline at end of file diff --git a/assets/js/timepicker.js b/assets/js/timepicker.js new file mode 100644 index 0000000..cd02b99 --- /dev/null +++ b/assets/js/timepicker.js @@ -0,0 +1,379 @@ +(function () { + 'use strict'; + + /** + * Reactive Binding for hidden inputs + * + * Problem: Setting input.value programmatically (e.g., via Datastar/Alpine) + * does NOT fire 'input' events - this is standard browser behavior since the 90s. + * + * Solution: Override the value setter to dispatch 'input' events on change. + * This is the same pattern used by Vue.js, MobX, and other reactive frameworks. + */ + function enableReactiveBinding(input) { + if (input._tui) return; + input._tui = true; + + const desc = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value'); + if (!desc?.set) return; + + Object.defineProperty(input, 'value', { + get: desc.get, + set(v) { + const old = this.value; + desc.set.call(this, v); + if (old !== v) { + this.dispatchEvent(new Event('input', { bubbles: true })); + } + }, + configurable: true + }); + } + + // Utility functions + function parseTime(str) { + const match = str?.match(/^(\d{1,2}):(\d{2})$/); + if (!match) return null; + const [_, hour, minute] = match.map(Number); + return (hour >= 0 && hour <= 23 && minute >= 0 && minute <= 59) ? { hour, minute } : null; + } + + function formatTime(hour, minute, use12Hours) { + if (hour === null || minute === null) return null; + const pad = n => n.toString().padStart(2, '0'); + + if (use12Hours) { + const h = hour === 0 ? 12 : hour > 12 ? hour - 12 : hour; + return `${pad(h)}:${pad(minute)} ${hour >= 12 ? 'PM' : 'AM'}`; + } + return `${pad(hour)}:${pad(minute)}`; + } + + function isValidTime(hour, minute, minTime, maxTime) { + if (!minTime && !maxTime) return true; + const timeInMinutes = hour * 60 + minute; + + if (minTime) { + const minInMinutes = minTime.hour * 60 + minTime.minute; + if (timeInMinutes < minInMinutes) return false; + } + + if (maxTime) { + const maxInMinutes = maxTime.hour * 60 + maxTime.minute; + if (timeInMinutes > maxInMinutes) return false; + } + + return true; + } + + // DOM helpers + function findRoot(element) { + return element?.closest('[data-tui-timepicker-root]') || null; + } + + function findTrigger(element) { + return findRoot(element)?.querySelector('[data-tui-timepicker="true"]') || null; + } + + function getElements(trigger) { + const root = findRoot(trigger); + const popup = root?.querySelector('[data-tui-timepicker-popup]'); + if (!popup) return null; + + return { + root, + trigger, + popup, + hourList: popup.querySelector('[data-tui-timepicker-hour-list]'), + minuteList: popup.querySelector('[data-tui-timepicker-minute-list]'), + hiddenInput: root?.querySelector('[data-tui-timepicker-hidden-input]') + }; + } + + function closePopover(trigger) { + const root = findRoot(trigger); + const popoverContent = root?.querySelector('[data-tui-popover-content]'); + if (!popoverContent?.matches(':popover-open')) return; + + try { + popoverContent.hidePopover(); + } catch { + // ignore + } + } + + // State management + function getState(trigger) { + return { + hour: trigger.dataset.tuiTimepickerCurrentHour ? parseInt(trigger.dataset.tuiTimepickerCurrentHour) : null, + minute: trigger.dataset.tuiTimepickerCurrentMinute ? parseInt(trigger.dataset.tuiTimepickerCurrentMinute) : null, + use12Hours: trigger.getAttribute('data-tui-timepicker-use12hours') === 'true', + step: parseInt(trigger.getAttribute('data-tui-timepicker-step') || '1'), + minTime: parseTime(trigger.getAttribute('data-tui-timepicker-min-time')), + maxTime: parseTime(trigger.getAttribute('data-tui-timepicker-max-time')), + placeholder: trigger.getAttribute('data-tui-timepicker-placeholder') || 'Select time' + }; + } + + function setState(trigger, hour, minute) { + if (hour !== null) { + trigger.dataset.tuiTimepickerCurrentHour = hour; + } else { + delete trigger.dataset.tuiTimepickerCurrentHour; + } + + if (minute !== null) { + trigger.dataset.tuiTimepickerCurrentMinute = minute; + } else { + delete trigger.dataset.tuiTimepickerCurrentMinute; + } + + updateDisplay(trigger); + } + + // Display updates + function updateDisplay(trigger) { + const state = getState(trigger); + const elements = getElements(trigger); + + // Update trigger display + const display = trigger.querySelector('[data-tui-timepicker-display]'); + if (display) { + const formatted = formatTime(state.hour, state.minute, state.use12Hours); + display.textContent = formatted || state.placeholder; + display.classList.toggle('text-muted-foreground', !formatted); + } + + // Update hidden input + if (elements?.hiddenInput) { + elements.hiddenInput.value = (state.hour !== null && state.minute !== null) ? + formatTime(state.hour, state.minute, false) : ''; + } + + // Update selections if popup is visible + if (elements?.hourList && elements?.minuteList) { + updateSelections(elements, state); + } + } + + function updateSelections(elements, state) { + // Update hour buttons + elements.hourList.querySelectorAll('[data-tui-timepicker-hour]').forEach(btn => { + const hour = parseInt(btn.getAttribute('data-tui-timepicker-hour')); + let isSelected = false; + + if (state.hour !== null) { + if (state.use12Hours) { + isSelected = (hour === state.hour) || + (hour === 0 && state.hour === 12) || + (hour === state.hour - 12 && state.hour > 12); + } else { + isSelected = hour === state.hour; + } + } + + btn.setAttribute('data-tui-timepicker-selected', isSelected); + + // Check validity + let valid = false; + for (let m = 0; m < 60; m++) { + if (isValidTime(hour, m, state.minTime, state.maxTime)) { + valid = true; + break; + } + } + + btn.disabled = !valid; + btn.classList.toggle('opacity-50', !valid); + btn.classList.toggle('cursor-not-allowed', !valid); + }); + + // Update minute buttons + elements.minuteList.querySelectorAll('[data-tui-timepicker-minute]').forEach(btn => { + const minute = parseInt(btn.getAttribute('data-tui-timepicker-minute')); + const isSelected = minute === state.minute; + const valid = state.hour === null || isValidTime(state.hour, minute, state.minTime, state.maxTime); + + btn.setAttribute('data-tui-timepicker-selected', isSelected); + btn.disabled = !valid; + btn.classList.toggle('opacity-50', !valid); + btn.classList.toggle('cursor-not-allowed', !valid); + }); + + // Update AM/PM buttons + const amBtn = elements.popup.querySelector('[data-tui-timepicker-period="AM"]'); + const pmBtn = elements.popup.querySelector('[data-tui-timepicker-period="PM"]'); + + if (amBtn && pmBtn) { + const isAM = state.hour === null || state.hour < 12; + amBtn.setAttribute('data-tui-timepicker-active', isAM); + pmBtn.setAttribute('data-tui-timepicker-active', !isAM); + } + } + + // Event handlers + document.addEventListener('click', (e) => { + const target = e.target; + + // Hour selection + if (target.matches('[data-tui-timepicker-hour]') && !target.disabled) { + const trigger = findTrigger(target); + if (!trigger) return; + + const state = getState(trigger); + let hour = parseInt(target.getAttribute('data-tui-timepicker-hour')); + + if (state.use12Hours) { + const isPM = state.hour !== null && state.hour >= 12; + hour = hour === 0 ? (isPM ? 12 : 0) : (isPM ? hour + 12 : hour); + } + + if (!isValidTime(hour, state.minute, state.minTime, state.maxTime)) { + // Find first valid minute + for (let m = 0; m < 60; m += state.step) { + if (isValidTime(hour, m, state.minTime, state.maxTime)) { + setState(trigger, hour, m); + return; + } + } + } else { + setState(trigger, hour, state.minute); + } + return; + } + + // Minute selection + if (target.matches('[data-tui-timepicker-minute]') && !target.disabled) { + const trigger = findTrigger(target); + if (!trigger) return; + + const state = getState(trigger); + const minute = parseInt(target.getAttribute('data-tui-timepicker-minute')); + + if (state.hour === null || isValidTime(state.hour, minute, state.minTime, state.maxTime)) { + setState(trigger, state.hour, minute); + } + return; + } + + // AM/PM selection + if (target.matches('[data-tui-timepicker-period]')) { + const trigger = findTrigger(target); + if (!trigger) return; + + const state = getState(trigger); + if (state.hour === null) return; + + const period = target.getAttribute('data-tui-timepicker-period'); + let newHour = state.hour; + + if (period === 'AM' && state.hour >= 12) { + newHour = state.hour === 12 ? 0 : state.hour - 12; + } else if (period === 'PM' && state.hour < 12) { + newHour = state.hour === 0 ? 12 : state.hour + 12; + } + + if (newHour !== state.hour) { + if (!isValidTime(newHour, state.minute, state.minTime, state.maxTime)) { + // Find first valid minute + for (let m = 0; m < 60; m += state.step) { + if (isValidTime(newHour, m, state.minTime, state.maxTime)) { + setState(trigger, newHour, m); + return; + } + } + } else { + setState(trigger, newHour, state.minute); + } + } + return; + } + + // Done button + if (target.matches('[data-tui-timepicker-done]')) { + const trigger = findTrigger(target); + if (trigger) { + closePopover(trigger); + } + return; + } + }); + + // Handle hidden input value changes (for reactive frameworks) + document.addEventListener('input', (e) => { + if (!e.target.matches('[data-tui-timepicker-hidden-input]')) return; + + const trigger = findTrigger(e.target); + if (trigger) { + const parsed = parseTime(e.target.value); + if (parsed) { + setState(trigger, parsed.hour, parsed.minute); + } else { + setState(trigger, null, null); + } + } + }); + + // Form reset + document.addEventListener('reset', (e) => { + if (!e.target.matches('form')) return; + + e.target.querySelectorAll('[data-tui-timepicker-root]').forEach(root => { + const trigger = root.querySelector('[data-tui-timepicker="true"]'); + if (!trigger) return; + + setState(trigger, null, null); + const elements = getElements(trigger); + if (elements?.hiddenInput) { + elements.hiddenInput.value = ''; + } + }); + }); + + // Initialize timepickers + function initializeTimePickers() { + document.querySelectorAll('[data-tui-timepicker-root]').forEach(root => { + const trigger = root.querySelector('[data-tui-timepicker="true"]'); + const hiddenInput = root.querySelector('[data-tui-timepicker-hidden-input]'); + if (!trigger) return; + if (!hiddenInput || hiddenInput._tui) return; + + // Read initial value from hidden input + const initialValue = hiddenInput.value; + if (initialValue) { + const parsed = parseTime(initialValue); + if (parsed) { + setState(trigger, parsed.hour, parsed.minute); + } + } + + // Enable reactive binding for hidden input + enableReactiveBinding(hiddenInput); + updateDisplay(trigger); + }); + } + + // Initialize on DOM ready + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', initializeTimePickers); + } else { + initializeTimePickers(); + } + + // MutationObserver for dynamically added elements + new MutationObserver(initializeTimePickers).observe(document.body, { childList: true, subtree: true }); + + // Scroll to selected values when timepicker popover opens + new MutationObserver((mutations) => { + for (const m of mutations) { + if (m.target.getAttribute('data-tui-popover-open') !== 'true') continue; + const popup = m.target.querySelector('[data-tui-timepicker-popup]'); + if (!popup) continue; + + requestAnimationFrame(() => { + popup.querySelector('[data-tui-timepicker-hour-list] [data-tui-timepicker-selected="true"]')?.scrollIntoView({ block: 'center' }); + popup.querySelector('[data-tui-timepicker-minute-list] [data-tui-timepicker-selected="true"]')?.scrollIntoView({ block: 'center' }); + }); + } + }).observe(document.body, { attributes: true, attributeFilter: ['data-tui-popover-open'], subtree: true }); +})(); diff --git a/assets/js/timepicker.min.js b/assets/js/timepicker.min.js index 926da71..7056915 100644 --- a/assets/js/timepicker.min.js +++ b/assets/js/timepicker.min.js @@ -1 +1 @@ -(()=>{(function(){"use strict";function I(i){if(i._tui)return;i._tui=!0;let t=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value");t?.set&&Object.defineProperty(i,"value",{get:t.get,set(u){let e=this.value;t.set.call(this,u),e!==u&&this.dispatchEvent(new Event("input",{bubbles:!0}))},configurable:!0})}function s(i){let t=i?.match(/^(\d{1,2}):(\d{2})$/);if(!t)return null;let[u,e,r]=t.map(Number);return e>=0&&e<=23&&r>=0&&r<=59?{hour:e,minute:r}:null}function h(i,t,u){if(i===null||t===null)return null;let e=r=>r.toString().padStart(2,"0");if(u){let r=i===0?12:i>12?i-12:i;return`${e(r)}:${e(t)} ${i>=12?"PM":"AM"}`}return`${e(i)}:${e(t)}`}function l(i,t,u,e){if(!u&&!e)return!0;let r=i*60+t;if(u){let n=u.hour*60+u.minute;if(rn)return!1}return!0}function d(i){let t=i.closest("[data-tui-timepicker-popup]");if(!t)return null;let u=t.closest("[id]")?.id;return u?document.getElementById(u.replace("-content","")):null}function k(i){let t=i.id+"-content",u=document.getElementById(t)?.querySelector("[data-tui-timepicker-popup]");return u?{popup:u,hourList:u.querySelector("[data-tui-timepicker-hour-list]"),minuteList:u.querySelector("[data-tui-timepicker-minute-list]"),hiddenInput:document.getElementById(i.id+"-hidden")||i.parentElement?.querySelector("[data-tui-timepicker-hidden-input]")}:null}function m(i){return{hour:i.dataset.tuiTimepickerCurrentHour?parseInt(i.dataset.tuiTimepickerCurrentHour):null,minute:i.dataset.tuiTimepickerCurrentMinute?parseInt(i.dataset.tuiTimepickerCurrentMinute):null,use12Hours:i.getAttribute("data-tui-timepicker-use12hours")==="true",step:parseInt(i.getAttribute("data-tui-timepicker-step")||"1"),minTime:s(i.getAttribute("data-tui-timepicker-min-time")),maxTime:s(i.getAttribute("data-tui-timepicker-max-time")),placeholder:i.getAttribute("data-tui-timepicker-placeholder")||"Select time"}}function a(i,t,u){t!==null?i.dataset.tuiTimepickerCurrentHour=t:delete i.dataset.tuiTimepickerCurrentHour,u!==null?i.dataset.tuiTimepickerCurrentMinute=u:delete i.dataset.tuiTimepickerCurrentMinute,y(i)}function y(i){let t=m(i),u=k(i),e=i.querySelector("[data-tui-timepicker-display]");if(e){let r=h(t.hour,t.minute,t.use12Hours);e.textContent=r||t.placeholder,e.classList.toggle("text-muted-foreground",!r)}u?.hiddenInput&&(u.hiddenInput.value=t.hour!==null&&t.minute!==null?h(t.hour,t.minute,!1):""),u?.hourList&&u?.minuteList&&T(u,t)}function T(i,t){i.hourList.querySelectorAll("[data-tui-timepicker-hour]").forEach(r=>{let n=parseInt(r.getAttribute("data-tui-timepicker-hour")),o=!1;t.hour!==null&&(t.use12Hours?o=n===t.hour||n===0&&t.hour===12||n===t.hour-12&&t.hour>12:o=n===t.hour),r.setAttribute("data-tui-timepicker-selected",o);let c=!1;for(let f=0;f<60;f++)if(l(n,f,t.minTime,t.maxTime)){c=!0;break}r.disabled=!c,r.classList.toggle("opacity-50",!c),r.classList.toggle("cursor-not-allowed",!c)}),i.minuteList.querySelectorAll("[data-tui-timepicker-minute]").forEach(r=>{let n=parseInt(r.getAttribute("data-tui-timepicker-minute")),o=n===t.minute,c=t.hour===null||l(t.hour,n,t.minTime,t.maxTime);r.setAttribute("data-tui-timepicker-selected",o),r.disabled=!c,r.classList.toggle("opacity-50",!c),r.classList.toggle("cursor-not-allowed",!c)});let u=i.popup.querySelector('[data-tui-timepicker-period="AM"]'),e=i.popup.querySelector('[data-tui-timepicker-period="PM"]');if(u&&e){let r=t.hour===null||t.hour<12;u.setAttribute("data-tui-timepicker-active",r),e.setAttribute("data-tui-timepicker-active",!r)}}document.addEventListener("click",i=>{let t=i.target;if(t.matches("[data-tui-timepicker-hour]")&&!t.disabled){let u=d(t);if(!u)return;let e=m(u),r=parseInt(t.getAttribute("data-tui-timepicker-hour"));if(e.use12Hours){let n=e.hour!==null&&e.hour>=12;r=r===0?n?12:0:n?r+12:r}if(l(r,e.minute,e.minTime,e.maxTime))a(u,r,e.minute);else for(let n=0;n<60;n+=e.step)if(l(r,n,e.minTime,e.maxTime)){a(u,r,n);return}return}if(t.matches("[data-tui-timepicker-minute]")&&!t.disabled){let u=d(t);if(!u)return;let e=m(u),r=parseInt(t.getAttribute("data-tui-timepicker-minute"));(e.hour===null||l(e.hour,r,e.minTime,e.maxTime))&&a(u,e.hour,r);return}if(t.matches("[data-tui-timepicker-period]")){let u=d(t);if(!u)return;let e=m(u);if(e.hour===null)return;let r=t.getAttribute("data-tui-timepicker-period"),n=e.hour;if(r==="AM"&&e.hour>=12?n=e.hour===12?0:e.hour-12:r==="PM"&&e.hour<12&&(n=e.hour===0?12:e.hour+12),n!==e.hour){if(l(n,e.minute,e.minTime,e.maxTime))a(u,n,e.minute);else for(let o=0;o<60;o+=e.step)if(l(n,o,e.minTime,e.maxTime)){a(u,n,o);return}}return}if(t.matches("[data-tui-timepicker-done]")){let u=d(t);u&&window.closePopover&&window.closePopover(u.id+"-content");return}}),document.addEventListener("input",i=>{if(!i.target.matches("[data-tui-timepicker-hidden-input]"))return;let t=document.getElementById(i.target.id.replace("-hidden",""));if(t){let u=s(i.target.value);u?a(t,u.hour,u.minute):a(t,null,null)}}),document.addEventListener("reset",i=>{i.target.matches("form")&&i.target.querySelectorAll('[data-tui-timepicker="true"]').forEach(t=>{a(t,null,null);let u=k(t);u?.hiddenInput&&(u.hiddenInput.value="")})});function p(){document.querySelectorAll('[data-tui-timepicker="true"]').forEach(i=>{let t=document.getElementById(i.id+"-hidden");if(!t||t._tui)return;let u=t.value;if(u){let e=s(u);e&&a(i,e.hour,e.minute)}I(t),y(i)})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",p):p(),new MutationObserver(p).observe(document.body,{childList:!0,subtree:!0})})();})(); +(()=>{(function(){"use strict";function v(i){if(i._tui)return;i._tui=!0;let t=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value");t?.set&&Object.defineProperty(i,"value",{get:t.get,set(e){let r=this.value;t.set.call(this,e),r!==e&&this.dispatchEvent(new Event("input",{bubbles:!0}))},configurable:!0})}function d(i){let t=i?.match(/^(\d{1,2}):(\d{2})$/);if(!t)return null;let[e,r,u]=t.map(Number);return r>=0&&r<=23&&u>=0&&u<=59?{hour:r,minute:u}:null}function k(i,t,e){if(i===null||t===null)return null;let r=u=>u.toString().padStart(2,"0");if(e){let u=i===0?12:i>12?i-12:i;return`${r(u)}:${r(t)} ${i>=12?"PM":"AM"}`}return`${r(i)}:${r(t)}`}function s(i,t,e,r){if(!e&&!r)return!0;let u=i*60+t;if(e){let n=e.hour*60+e.minute;if(un)return!1}return!0}function p(i){return i?.closest("[data-tui-timepicker-root]")||null}function l(i){return p(i)?.querySelector('[data-tui-timepicker="true"]')||null}function b(i){let t=p(i),e=t?.querySelector("[data-tui-timepicker-popup]");return e?{root:t,trigger:i,popup:e,hourList:e.querySelector("[data-tui-timepicker-hour-list]"),minuteList:e.querySelector("[data-tui-timepicker-minute-list]"),hiddenInput:t?.querySelector("[data-tui-timepicker-hidden-input]")}:null}function S(i){let e=p(i)?.querySelector("[data-tui-popover-content]");if(e?.matches(":popover-open"))try{e.hidePopover()}catch{}}function m(i){return{hour:i.dataset.tuiTimepickerCurrentHour?parseInt(i.dataset.tuiTimepickerCurrentHour):null,minute:i.dataset.tuiTimepickerCurrentMinute?parseInt(i.dataset.tuiTimepickerCurrentMinute):null,use12Hours:i.getAttribute("data-tui-timepicker-use12hours")==="true",step:parseInt(i.getAttribute("data-tui-timepicker-step")||"1"),minTime:d(i.getAttribute("data-tui-timepicker-min-time")),maxTime:d(i.getAttribute("data-tui-timepicker-max-time")),placeholder:i.getAttribute("data-tui-timepicker-placeholder")||"Select time"}}function a(i,t,e){t!==null?i.dataset.tuiTimepickerCurrentHour=t:delete i.dataset.tuiTimepickerCurrentHour,e!==null?i.dataset.tuiTimepickerCurrentMinute=e:delete i.dataset.tuiTimepickerCurrentMinute,y(i)}function y(i){let t=m(i),e=b(i),r=i.querySelector("[data-tui-timepicker-display]");if(r){let u=k(t.hour,t.minute,t.use12Hours);r.textContent=u||t.placeholder,r.classList.toggle("text-muted-foreground",!u)}e?.hiddenInput&&(e.hiddenInput.value=t.hour!==null&&t.minute!==null?k(t.hour,t.minute,!1):""),e?.hourList&&e?.minuteList&&g(e,t)}function g(i,t){i.hourList.querySelectorAll("[data-tui-timepicker-hour]").forEach(u=>{let n=parseInt(u.getAttribute("data-tui-timepicker-hour")),o=!1;t.hour!==null&&(t.use12Hours?o=n===t.hour||n===0&&t.hour===12||n===t.hour-12&&t.hour>12:o=n===t.hour),u.setAttribute("data-tui-timepicker-selected",o);let c=!1;for(let h=0;h<60;h++)if(s(n,h,t.minTime,t.maxTime)){c=!0;break}u.disabled=!c,u.classList.toggle("opacity-50",!c),u.classList.toggle("cursor-not-allowed",!c)}),i.minuteList.querySelectorAll("[data-tui-timepicker-minute]").forEach(u=>{let n=parseInt(u.getAttribute("data-tui-timepicker-minute")),o=n===t.minute,c=t.hour===null||s(t.hour,n,t.minTime,t.maxTime);u.setAttribute("data-tui-timepicker-selected",o),u.disabled=!c,u.classList.toggle("opacity-50",!c),u.classList.toggle("cursor-not-allowed",!c)});let e=i.popup.querySelector('[data-tui-timepicker-period="AM"]'),r=i.popup.querySelector('[data-tui-timepicker-period="PM"]');if(e&&r){let u=t.hour===null||t.hour<12;e.setAttribute("data-tui-timepicker-active",u),r.setAttribute("data-tui-timepicker-active",!u)}}document.addEventListener("click",i=>{let t=i.target;if(t.matches("[data-tui-timepicker-hour]")&&!t.disabled){let e=l(t);if(!e)return;let r=m(e),u=parseInt(t.getAttribute("data-tui-timepicker-hour"));if(r.use12Hours){let n=r.hour!==null&&r.hour>=12;u=u===0?n?12:0:n?u+12:u}if(s(u,r.minute,r.minTime,r.maxTime))a(e,u,r.minute);else for(let n=0;n<60;n+=r.step)if(s(u,n,r.minTime,r.maxTime)){a(e,u,n);return}return}if(t.matches("[data-tui-timepicker-minute]")&&!t.disabled){let e=l(t);if(!e)return;let r=m(e),u=parseInt(t.getAttribute("data-tui-timepicker-minute"));(r.hour===null||s(r.hour,u,r.minTime,r.maxTime))&&a(e,r.hour,u);return}if(t.matches("[data-tui-timepicker-period]")){let e=l(t);if(!e)return;let r=m(e);if(r.hour===null)return;let u=t.getAttribute("data-tui-timepicker-period"),n=r.hour;if(u==="AM"&&r.hour>=12?n=r.hour===12?0:r.hour-12:u==="PM"&&r.hour<12&&(n=r.hour===0?12:r.hour+12),n!==r.hour){if(s(n,r.minute,r.minTime,r.maxTime))a(e,n,r.minute);else for(let o=0;o<60;o+=r.step)if(s(n,o,r.minTime,r.maxTime)){a(e,n,o);return}}return}if(t.matches("[data-tui-timepicker-done]")){let e=l(t);e&&S(e);return}}),document.addEventListener("input",i=>{if(!i.target.matches("[data-tui-timepicker-hidden-input]"))return;let t=l(i.target);if(t){let e=d(i.target.value);e?a(t,e.hour,e.minute):a(t,null,null)}}),document.addEventListener("reset",i=>{i.target.matches("form")&&i.target.querySelectorAll("[data-tui-timepicker-root]").forEach(t=>{let e=t.querySelector('[data-tui-timepicker="true"]');if(!e)return;a(e,null,null);let r=b(e);r?.hiddenInput&&(r.hiddenInput.value="")})});function f(){document.querySelectorAll("[data-tui-timepicker-root]").forEach(i=>{let t=i.querySelector('[data-tui-timepicker="true"]'),e=i.querySelector("[data-tui-timepicker-hidden-input]");if(!t||!e||e._tui)return;let r=e.value;if(r){let u=d(r);u&&a(t,u.hour,u.minute)}v(e),y(t)})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",f):f(),new MutationObserver(f).observe(document.body,{childList:!0,subtree:!0}),new MutationObserver(i=>{for(let t of i){if(t.target.getAttribute("data-tui-popover-open")!=="true")continue;let e=t.target.querySelector("[data-tui-timepicker-popup]");e&&requestAnimationFrame(()=>{e.querySelector('[data-tui-timepicker-hour-list] [data-tui-timepicker-selected="true"]')?.scrollIntoView({block:"center"}),e.querySelector('[data-tui-timepicker-minute-list] [data-tui-timepicker-selected="true"]')?.scrollIntoView({block:"center"})})}}).observe(document.body,{attributes:!0,attributeFilter:["data-tui-popover-open"],subtree:!0})})();})(); diff --git a/assets/js/toast.js b/assets/js/toast.js new file mode 100644 index 0000000..35d6bd6 --- /dev/null +++ b/assets/js/toast.js @@ -0,0 +1,128 @@ +(function () { + "use strict"; + + const toastTimers = new Map(); + + // Setup toast when it appears + function setupToast(toast) { + if (!toast || toastTimers.has(toast)) return; + + const duration = parseInt(toast.dataset.tuiToastDuration || "3000"); + const progress = toast.querySelector(".toast-progress"); + + // Initialize timer state + const state = { + timer: null, + startTime: Date.now(), + remaining: duration, + paused: false, + progressWidth: null, + }; + toastTimers.set(toast, state); + + // Animate progress bar if present + if (progress && duration > 0) { + progress.style.width = "100%"; + void progress.offsetWidth; + progress.style.transition = `width ${duration}ms linear`; + progress.style.width = "0px"; + } + + // Auto-dismiss after duration + if (duration > 0) { + state.timer = setTimeout(() => dismissToast(toast), duration); + } + + // Pause on hover + toast.addEventListener("mouseenter", () => { + const state = toastTimers.get(toast); + if (!state || state.paused) return; + + // Clear the dismiss timer + clearTimeout(state.timer); + + // Calculate remaining time + state.remaining = state.remaining - (Date.now() - state.startTime); + state.paused = true; + + // Pause progress animation + if (progress) { + state.progressWidth = getComputedStyle(progress).width; + progress.style.transition = "none"; + progress.style.width = state.progressWidth; + } + }); + + // Resume on mouse leave + toast.addEventListener("mouseleave", () => { + const state = toastTimers.get(toast); + if (!state || !state.paused || state.remaining <= 0) return; + + // Resume timer with remaining time + state.startTime = Date.now(); + state.paused = false; + state.timer = setTimeout(() => dismissToast(toast), state.remaining); + + // Resume progress animation + if (progress) { + progress.style.width = state.progressWidth; + void progress.offsetWidth; + progress.style.transition = `width ${state.remaining}ms linear`; + progress.style.width = "0px"; + } + }); + } + + // Dismiss toast with fade out + function dismissToast(toast) { + // Clean up timer state + toastTimers.delete(toast); + + // Add transition for smooth fade out + toast.style.transition = "opacity 300ms, transform 300ms"; + toast.style.opacity = "0"; + toast.style.transform = "translateY(1rem)"; + + // Remove after animation + setTimeout(() => toast.remove(), 300); + } + + // Handle dismiss button clicks + document.addEventListener("click", (e) => { + const dismissBtn = e.target.closest("[data-tui-toast-dismiss]"); + if (dismissBtn) { + const toast = dismissBtn.closest("[data-tui-toast]"); + if (toast) dismissToast(toast); + } + }); + + function initializeToasts(root) { + if (!root) return; + + if (root.matches?.("[data-tui-toast]")) { + setupToast(root); + } + + root.querySelectorAll?.("[data-tui-toast]").forEach(setupToast); + } + + // Initialize pre-rendered toasts + if (document.readyState === "loading") { + document.addEventListener("DOMContentLoaded", () => + initializeToasts(document), + ); + } else { + initializeToasts(document); + } + + // Watch for new toasts + new MutationObserver((mutations) => { + mutations.forEach((m) => { + m.addedNodes.forEach((node) => { + if (node.nodeType === 1) { + initializeToasts(node); + } + }); + }); + }).observe(document.body, { childList: true, subtree: true }); +})(); diff --git a/assets/js/toast.min.js b/assets/js/toast.min.js index 1fb13d3..3b5e378 100644 --- a/assets/js/toast.min.js +++ b/assets/js/toast.min.js @@ -1 +1 @@ -(()=>{(function(){"use strict";let n=new Map;function o(e){let i=parseInt(e.dataset.tuiToastDuration||"3000"),t=e.querySelector(".toast-progress"),a={timer:null,startTime:Date.now(),remaining:i,paused:!1};n.set(e,a),t&&i>0&&(t.style.transitionDuration=i+"ms",requestAnimationFrame(()=>{requestAnimationFrame(()=>{t.style.transform="scaleX(0)"})})),i>0&&(a.timer=setTimeout(()=>r(e),i)),e.addEventListener("mouseenter",()=>{let s=n.get(e);if(!(!s||s.paused)&&(clearTimeout(s.timer),s.remaining=s.remaining-(Date.now()-s.startTime),s.paused=!0,t)){let m=getComputedStyle(t);t.style.transitionDuration="0ms",t.style.transform=m.transform}}),e.addEventListener("mouseleave",()=>{let s=n.get(e);!s||!s.paused||s.remaining<=0||(s.startTime=Date.now(),s.paused=!1,s.timer=setTimeout(()=>r(e),s.remaining),t&&(t.style.transitionDuration=s.remaining+"ms",requestAnimationFrame(()=>{requestAnimationFrame(()=>{t.style.transform="scaleX(0)"})})))})}function r(e){n.delete(e),e.style.transition="opacity 300ms, transform 300ms",e.style.opacity="0",e.style.transform="translateY(1rem)",setTimeout(()=>e.remove(),300)}document.addEventListener("click",e=>{let i=e.target.closest("[data-tui-toast-dismiss]");if(i){let t=i.closest("[data-tui-toast]");t&&r(t)}}),new MutationObserver(e=>{e.forEach(i=>{i.addedNodes.forEach(t=>{t.nodeType===1&&t.matches?.("[data-tui-toast]")&&o(t)})})}).observe(document.body,{childList:!0,subtree:!0})})();})(); +(()=>{(function(){"use strict";let n=new Map;function d(e){if(!e||n.has(e))return;let s=parseInt(e.dataset.tuiToastDuration||"3000"),t=e.querySelector(".toast-progress"),o={timer:null,startTime:Date.now(),remaining:s,paused:!1,progressWidth:null};n.set(e,o),t&&s>0&&(t.style.width="100%",t.offsetWidth,t.style.transition=`width ${s}ms linear`,t.style.width="0px"),s>0&&(o.timer=setTimeout(()=>r(e),s)),e.addEventListener("mouseenter",()=>{let i=n.get(e);!i||i.paused||(clearTimeout(i.timer),i.remaining=i.remaining-(Date.now()-i.startTime),i.paused=!0,t&&(i.progressWidth=getComputedStyle(t).width,t.style.transition="none",t.style.width=i.progressWidth))}),e.addEventListener("mouseleave",()=>{let i=n.get(e);!i||!i.paused||i.remaining<=0||(i.startTime=Date.now(),i.paused=!1,i.timer=setTimeout(()=>r(e),i.remaining),t&&(t.style.width=i.progressWidth,t.offsetWidth,t.style.transition=`width ${i.remaining}ms linear`,t.style.width="0px"))})}function r(e){n.delete(e),e.style.transition="opacity 300ms, transform 300ms",e.style.opacity="0",e.style.transform="translateY(1rem)",setTimeout(()=>e.remove(),300)}document.addEventListener("click",e=>{let s=e.target.closest("[data-tui-toast-dismiss]");if(s){let t=s.closest("[data-tui-toast]");t&&r(t)}});function a(e){e&&(e.matches?.("[data-tui-toast]")&&d(e),e.querySelectorAll?.("[data-tui-toast]").forEach(d))}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>a(document)):a(document),new MutationObserver(e=>{e.forEach(s=>{s.addedNodes.forEach(t=>{t.nodeType===1&&a(t)})})}).observe(document.body,{childList:!0,subtree:!0})})();})(); diff --git a/devbox.json b/devbox.json index f67e6c2..5155b76 100644 --- a/devbox.json +++ b/devbox.json @@ -1,20 +1,20 @@ { - "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.16.0/.schema/devbox.schema.json", - "packages": [ - "go@1.25.5", - "templ@0.3.960", - "go-task@3.45.5", - "tailwindcss_4@4.2.1", - "nodejs@24", - "goose@latest" - ], - "shell": { - "init_hook": [ - "echo 'Welcome to devbox!' > /dev/null", - "unset DEVELOPER_DIR" - ], - "scripts": { - "setup": ["go install github.com/mfridman/tparse@latest"] - } - } + "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.16.0/.schema/devbox.schema.json", + "packages": [ + "go@1.25.5", + "go-task@3.45.5", + "tailwindcss_4@4.2.1", + "nodejs@24", + "goose@latest", + "templ@0.3.1001" + ], + "shell": { + "init_hook": [ + "echo 'Welcome to devbox!' > /dev/null", + "unset DEVELOPER_DIR" + ], + "scripts": { + "setup": ["go install github.com/mfridman/tparse@latest"] + } + } } diff --git a/devbox.lock b/devbox.lock index ac1fab3..0a2280c 100644 --- a/devbox.lock +++ b/devbox.lock @@ -278,51 +278,51 @@ } } }, - "templ@0.3.960": { - "last_modified": "2025-12-31T03:27:36Z", - "resolved": "github:NixOS/nixpkgs/f665af0cdb70ed27e1bd8f9fdfecaf451260fc55#templ", + "templ@0.3.1001": { + "last_modified": "2026-03-21T07:29:51Z", + "resolved": "github:NixOS/nixpkgs/09061f748ee21f68a089cd5d91ec1859cd93d0be#templ", "source": "devbox-search", - "version": "0.3.960", + "version": "0.3.1001", "systems": { "aarch64-darwin": { "outputs": [ { "name": "out", - "path": "/nix/store/g2b8z0ssdj1qxfkcvw4h47rzhdr91wwf-templ-0.3.960", + "path": "/nix/store/x9y3fnv2mb8j70r8k0i3n96qflrqq8d5-templ-0.3.1001", "default": true } ], - "store_path": "/nix/store/g2b8z0ssdj1qxfkcvw4h47rzhdr91wwf-templ-0.3.960" + "store_path": "/nix/store/x9y3fnv2mb8j70r8k0i3n96qflrqq8d5-templ-0.3.1001" }, "aarch64-linux": { "outputs": [ { "name": "out", - "path": "/nix/store/ws4nkq75id3wp1i741zzjqs6casbd0cw-templ-0.3.960", + "path": "/nix/store/3nhjivm3l1bk9gc98qrmafdk5n18lrdd-templ-0.3.1001", "default": true } ], - "store_path": "/nix/store/ws4nkq75id3wp1i741zzjqs6casbd0cw-templ-0.3.960" + "store_path": "/nix/store/3nhjivm3l1bk9gc98qrmafdk5n18lrdd-templ-0.3.1001" }, "x86_64-darwin": { "outputs": [ { "name": "out", - "path": "/nix/store/a1a7qklai2fjn6ika5a8q25mapi5xz77-templ-0.3.960", + "path": "/nix/store/7wjjyfwhkhavm8xyba699w3r1rhrkyci-templ-0.3.1001", "default": true } ], - "store_path": "/nix/store/a1a7qklai2fjn6ika5a8q25mapi5xz77-templ-0.3.960" + "store_path": "/nix/store/7wjjyfwhkhavm8xyba699w3r1rhrkyci-templ-0.3.1001" }, "x86_64-linux": { "outputs": [ { "name": "out", - "path": "/nix/store/033s4gq6nqywzxhzd8gr9l05xcvln4ld-templ-0.3.960", + "path": "/nix/store/v4qj3mml7lyps2nicavbys97w56dxvjy-templ-0.3.1001", "default": true } ], - "store_path": "/nix/store/033s4gq6nqywzxhzd8gr9l05xcvln4ld-templ-0.3.960" + "store_path": "/nix/store/v4qj3mml7lyps2nicavbys97w56dxvjy-templ-0.3.1001" } } } diff --git a/go.mod b/go.mod index 4d2b461..5521923 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.25.1 require ( github.com/Oudwins/tailwind-merge-go v0.2.1 - github.com/a-h/templ v0.3.960 + github.com/a-h/templ v0.3.1001 github.com/alexedwards/argon2id v1.0.0 github.com/emersion/go-imap v1.2.1 github.com/golang-jwt/jwt/v5 v5.2.2 @@ -62,7 +62,7 @@ require ( github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/segmentio/asm v1.2.0 // indirect github.com/sethvargo/go-retry v0.3.0 // indirect - github.com/templui/templui v1.0.0 // indirect + github.com/templui/templui v1.9.5 // indirect github.com/tursodatabase/libsql-client-go v0.0.0-20240902231107-85af5b9d094d // indirect github.com/vertica/vertica-sql-go v1.3.3 // indirect github.com/ydb-platform/ydb-go-genproto v0.0.0-20241112172322-ea1f63298f77 // indirect diff --git a/go.sum b/go.sum index 13a24e9..9671646 100644 --- a/go.sum +++ b/go.sum @@ -23,8 +23,8 @@ github.com/Oudwins/tailwind-merge-go v0.2.1 h1:jxRaEqGtwwwF48UuFIQ8g8XT7YSualNuG github.com/Oudwins/tailwind-merge-go v0.2.1/go.mod h1:kkZodgOPvZQ8f7SIrlWkG/w1g9JTbtnptnePIh3V72U= github.com/a-h/parse v0.0.0-20250122154542-74294addb73e h1:HjVbSQHy+dnlS6C3XajZ69NYAb5jbGNfHanvm1+iYlo= github.com/a-h/parse v0.0.0-20250122154542-74294addb73e/go.mod h1:3mnrkvGpurZ4ZrTDbYU84xhwXW2TjTKShSwjRi2ihfQ= -github.com/a-h/templ v0.3.960 h1:trshEpGa8clF5cdI39iY4ZrZG8Z/QixyzEyUnA7feTM= -github.com/a-h/templ v0.3.960/go.mod h1:oCZcnKRf5jjsGpf2yELzQfodLphd2mwecwG4Crk5HBo= +github.com/a-h/templ v0.3.1001 h1:yHDTgexACdJttyiyamcTHXr2QkIeVF1MukLy44EAhMY= +github.com/a-h/templ v0.3.1001/go.mod h1:oCZcnKRf5jjsGpf2yELzQfodLphd2mwecwG4Crk5HBo= github.com/alexedwards/argon2id v1.0.0 h1:wJzDx66hqWX7siL/SRUmgz3F8YMrd/nfX/xHHcQQP0w= github.com/alexedwards/argon2id v1.0.0/go.mod h1:tYKkqIjzXvZdzPvADMWOEZ+l6+BD6CtBXMj5fnJppiw= github.com/andybalholm/brotli v1.2.0 h1:ukwgCxwYrmACq68yiUqwIWnGY0cTPox/M94sVwToPjQ= @@ -148,8 +148,8 @@ github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47e github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= -github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -215,8 +215,8 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/templui/templui v1.0.0 h1:nsCh+tTL8U9rhh0hpwkvDpiDCPP43aoBB85TLgCh/Kg= -github.com/templui/templui v1.0.0/go.mod h1:SnKmOIs7t/ngsdWUws97CVodbz89ne9kQv3ivgdhiHo= +github.com/templui/templui v1.9.5 h1:qJyELi+xHCVYNgheAGkRP9EKjsufJgfpQOD+Cb4+Y+M= +github.com/templui/templui v1.9.5/go.mod h1:WWX9O4UebQiSipKaoUQ7Cb0UWtqopzZHtgBu1gtItzU= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tursodatabase/libsql-client-go v0.0.0-20240902231107-85af5b9d094d h1:dOMI4+zEbDI37KGb0TI44GUAwxHF9cMsIoDTJ7UmgfU= github.com/tursodatabase/libsql-client-go v0.0.0-20240902231107-85af5b9d094d/go.mod h1:l8xTsYB90uaVdMHXMCxKKLSgw5wLYBwBKKefNIUnm9s= diff --git a/internal/ui/blocks/themeswitcher.templ b/internal/ui/blocks/themeswitcher.templ index 9116799..e944c20 100644 --- a/internal/ui/blocks/themeswitcher.templ +++ b/internal/ui/blocks/themeswitcher.templ @@ -25,6 +25,6 @@ templ ThemeSwitcher(props ...ThemeSwitcherProps) { "aria-label": "Toggle theme", }, }) { - @icon.Eclipse(icon.Props{Size: 20}) + @icon.Eclipse(icon.Props{Class: ""}) } } diff --git a/internal/ui/components/accordion/accordion.templ b/internal/ui/components/accordion/accordion.templ index ad52cb1..a51256a 100644 --- a/internal/ui/components/accordion/accordion.templ +++ b/internal/ui/components/accordion/accordion.templ @@ -1,4 +1,4 @@ -// templui component accordion - version: v1.2.0 installed by templui v1.2.0 +// templui component accordion - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/accordion package accordion @@ -97,10 +97,7 @@ templ Trigger(props ...TriggerProps) { { p.Attributes... } > { children... } - @icon.ChevronDown(icon.Props{ - Size: 16, - Class: "size-4 shrink-0 translate-y-0.5 transition-transform duration-200 text-muted-foreground pointer-events-none", - }) + @icon.ChevronDown(icon.Props{Class: "size-4 shrink-0 translate-y-0.5 transition-transform duration-200 text-muted-foreground pointer-events-none"}) } diff --git a/internal/ui/components/alert/alert.templ b/internal/ui/components/alert/alert.templ index 6e4b1c6..da21c2d 100644 --- a/internal/ui/components/alert/alert.templ +++ b/internal/ui/components/alert/alert.templ @@ -1,4 +1,4 @@ -// templui component alert - version: v1.2.0 installed by templui v1.2.0 +// templui component alert - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/alert package alert diff --git a/internal/ui/components/aspectratio/aspectratio.templ b/internal/ui/components/aspectratio/aspectratio.templ index cd839a4..5e67f85 100644 --- a/internal/ui/components/aspectratio/aspectratio.templ +++ b/internal/ui/components/aspectratio/aspectratio.templ @@ -1,4 +1,4 @@ -// templui component aspectratio - version: v1.2.0 installed by templui v1.2.0 +// templui component aspectratio - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/aspect-ratio package aspectratio diff --git a/internal/ui/components/avatar/avatar.templ b/internal/ui/components/avatar/avatar.templ index ceb6b26..a08de1c 100644 --- a/internal/ui/components/avatar/avatar.templ +++ b/internal/ui/components/avatar/avatar.templ @@ -1,4 +1,4 @@ -// templui component avatar - version: v1.2.0 installed by templui v1.2.0 +// templui component avatar - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/avatar package avatar @@ -92,6 +92,10 @@ templ Fallback(props ...FallbackProps) { } +var scriptOnce = templ.NewOnceHandle() + templ Script() { - + @scriptOnce.Once() { + @utils.ComponentScript("avatar") + } } diff --git a/internal/ui/components/badge/badge.templ b/internal/ui/components/badge/badge.templ index 399980b..70636ac 100644 --- a/internal/ui/components/badge/badge.templ +++ b/internal/ui/components/badge/badge.templ @@ -1,4 +1,4 @@ -// templui component badge - version: v1.2.0 installed by templui v1.2.0 +// templui component badge - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/badge package badge diff --git a/internal/ui/components/breadcrumb/breadcrumb.templ b/internal/ui/components/breadcrumb/breadcrumb.templ index 9ce2fc6..5549836 100644 --- a/internal/ui/components/breadcrumb/breadcrumb.templ +++ b/internal/ui/components/breadcrumb/breadcrumb.templ @@ -1,4 +1,4 @@ -// templui component breadcrumb - version: v1.2.0 installed by templui v1.2.0 +// templui component breadcrumb - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/breadcrumb package breadcrumb @@ -148,7 +148,7 @@ templ Separator(props ...SeparatorProps) { if p.UseCustom { { children... } } else { - @icon.ChevronRight(icon.Props{Size: 14, Class: "text-muted-foreground"}) + @icon.ChevronRight(icon.Props{Class: "size-3.5 text-muted-foreground"}) } } diff --git a/internal/ui/components/button/button.templ b/internal/ui/components/button/button.templ index 3e12539..f74c1cf 100644 --- a/internal/ui/components/button/button.templ +++ b/internal/ui/components/button/button.templ @@ -1,4 +1,4 @@ -// templui component button - version: v1.2.0 installed by templui v1.2.0 +// templui component button - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/button package button diff --git a/internal/ui/components/calendar/calendar.templ b/internal/ui/components/calendar/calendar.templ index 4655154..60661a2 100644 --- a/internal/ui/components/calendar/calendar.templ +++ b/internal/ui/components/calendar/calendar.templ @@ -1,4 +1,4 @@ -// templui component calendar - version: v1.2.0 installed by templui v1.2.0 +// templui component calendar - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/calendar package calendar @@ -35,15 +35,15 @@ var ( ) type Props struct { - ID string - Class string - LocaleTag LocaleTag - Value *time.Time - Name string - InitialMonth int // Optional: 0-11 (Default: current or from Value). Controls the initially displayed month view. - InitialYear int // Optional: (Default: current or from Value). Controls the initially displayed year view. - StartOfWeek *Day // Optional: 0-6 [Sun-Sat] (Default: 1). - RenderHiddenInput bool // Optional: Whether to render the hidden input (Default: true). Set to false when used inside DatePicker. + ID string + Class string + LocaleTag LocaleTag + Value *time.Time + Name string + InitialMonth int // Optional: 0-11 (Default: current or from Value). Controls the initially displayed month view. + InitialYear int // Optional: (Default: current or from Value). Controls the initially displayed year view. + StartOfWeek *Day // Optional: 0-6 [Sun-Sat] (Default: 1). + HideHiddenInput bool // Optional: Hide the hidden input when a parent component owns form submission. } templ Calendar(props ...Props) { @@ -62,13 +62,6 @@ templ Calendar(props ...Props) { if p.LocaleTag == "" { p.LocaleTag = LocaleDefaultTag } - // Default to rendering hidden input unless explicitly set to false - if p.RenderHiddenInput == false && len(props) > 0 { - // Only respect false if it was explicitly passed - p.RenderHiddenInput = props[0].RenderHiddenInput - } else { - p.RenderHiddenInput = true - } initialStartOfWeek := Monday if p.StartOfWeek != nil { @@ -106,8 +99,12 @@ templ Calendar(props ...Props) { // Generate short month names (English only, JS will update with localized) monthNames := []string{"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"} }} -
- if p.RenderHiddenInput { +
+ if !p.HideHiddenInput { -
+
@@ -172,7 +170,7 @@ templ Calendar(props ...Props) {
@@ -185,13 +183,17 @@ templ Calendar(props ...Props) {
-
+
-
+
} +var scriptOnce = templ.NewOnceHandle() + templ Script() { - + @scriptOnce.Once() { + @utils.ComponentScript("calendar") + } } diff --git a/internal/ui/components/card/card.templ b/internal/ui/components/card/card.templ index 7c60e10..cccdf51 100644 --- a/internal/ui/components/card/card.templ +++ b/internal/ui/components/card/card.templ @@ -1,4 +1,4 @@ -// templui component card - version: v1.2.0 installed by templui v1.2.0 +// templui component card - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/card package card diff --git a/internal/ui/components/carousel/carousel.templ b/internal/ui/components/carousel/carousel.templ index d2424d2..bee945a 100644 --- a/internal/ui/components/carousel/carousel.templ +++ b/internal/ui/components/carousel/carousel.templ @@ -1,4 +1,4 @@ -// templui component carousel - version: v1.2.0 installed by templui v1.2.0 +// templui component carousel - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/carousel package carousel @@ -206,6 +206,10 @@ templ Indicators(props ...IndicatorsProps) { } +var scriptOnce = templ.NewOnceHandle() + templ Script() { - + @scriptOnce.Once() { + @utils.ComponentScript("carousel") + } } diff --git a/internal/ui/components/chart/chart.templ b/internal/ui/components/chart/chart.templ index 5dd616f..e345321 100644 --- a/internal/ui/components/chart/chart.templ +++ b/internal/ui/components/chart/chart.templ @@ -1,4 +1,4 @@ -// templui component chart - version: v1.2.0 installed by templui v1.2.0 +// templui component chart - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/charts package chart @@ -53,11 +53,17 @@ type Config struct { BeginAtZero *bool `json:"beginAtZero,omitempty"` } +type ScriptConfig struct { + RawConfig map[string]any `json:"rawConfig,omitempty"` + GeneratedConfig *Config `json:"generatedConfig,omitempty"` +} + type Props struct { ID string Variant Variant Data Data Options Options + RawConfig map[string]any ShowLegend bool ShowXAxis bool ShowYAxis bool @@ -96,27 +102,37 @@ templ Chart(props ...Props) { {{ - chartConfig := Config{ - Type: p.Variant, - Data: p.Data, - Options: p.Options, - ShowLegend: p.ShowLegend, - ShowXAxis: p.ShowXAxis, - ShowYAxis: p.ShowYAxis, - ShowXLabels: p.ShowXLabels, - ShowYLabels: p.ShowYLabels, - ShowXGrid: p.ShowXGrid, - ShowYGrid: p.ShowYGrid, - Horizontal: p.Horizontal, - Stacked: p.Stacked, - YMin: p.YMin, - YMax: p.YMax, - BeginAtZero: p.BeginAtZero, + scriptConfig := ScriptConfig{ + RawConfig: p.RawConfig, + } + if p.RawConfig == nil { + generatedConfig := Config{ + Type: p.Variant, + Data: p.Data, + Options: p.Options, + ShowLegend: p.ShowLegend, + ShowXAxis: p.ShowXAxis, + ShowYAxis: p.ShowYAxis, + ShowXLabels: p.ShowXLabels, + ShowYLabels: p.ShowYLabels, + ShowXGrid: p.ShowXGrid, + ShowYGrid: p.ShowYGrid, + Horizontal: p.Horizontal, + Stacked: p.Stacked, + YMin: p.YMin, + YMax: p.YMax, + BeginAtZero: p.BeginAtZero, + } + scriptConfig.GeneratedConfig = &generatedConfig } }} - @templ.JSONScript(dataId, chartConfig) + @templ.JSONScript(dataId, scriptConfig) } +var scriptOnce = templ.NewOnceHandle() + templ Script() { - + @scriptOnce.Once() { + @utils.ComponentScript("chart") + } } diff --git a/internal/ui/components/checkbox/checkbox.templ b/internal/ui/components/checkbox/checkbox.templ index 55a34fe..9e8c28f 100644 --- a/internal/ui/components/checkbox/checkbox.templ +++ b/internal/ui/components/checkbox/checkbox.templ @@ -1,4 +1,4 @@ -// templui component checkbox - version: v1.2.0 installed by templui v1.2.0 +// templui component checkbox - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/checkbox package checkbox @@ -71,17 +71,21 @@ templ Checkbox(props ...Props) { if p.Icon != nil { @p.Icon } else { - @icon.Check(icon.Props{Size: 14}) + @icon.Check(icon.Props{Class: "size-3.5"}) }
- @icon.Minus(icon.Props{Size: 14}) + @icon.Minus(icon.Props{Class: "size-3.5"})
} +var scriptOnce = templ.NewOnceHandle() + templ Script() { - + @scriptOnce.Once() { + @utils.ComponentScript("checkbox") + } } diff --git a/internal/ui/components/collapsible/collapsible.templ b/internal/ui/components/collapsible/collapsible.templ index 69b8d3a..2bcdbb7 100644 --- a/internal/ui/components/collapsible/collapsible.templ +++ b/internal/ui/components/collapsible/collapsible.templ @@ -1,4 +1,4 @@ -// templui component collapsible - version: v1.2.0 installed by templui v1.2.0 +// templui component collapsible - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/collapsible package collapsible @@ -81,6 +81,10 @@ templ Content(props ...ContentProps) { } +var scriptOnce = templ.NewOnceHandle() + templ Script() { - + @scriptOnce.Once() { + @utils.ComponentScript("collapsible") + } } diff --git a/internal/ui/components/copybutton/copybutton.templ b/internal/ui/components/copybutton/copybutton.templ index 26b7032..ac55fd0 100644 --- a/internal/ui/components/copybutton/copybutton.templ +++ b/internal/ui/components/copybutton/copybutton.templ @@ -1,4 +1,4 @@ -// templui component copybutton - version: v1.2.0 installed by templui v1.2.0 +// templui component copybutton - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/copy-button package copybutton @@ -34,15 +34,19 @@ templ CopyButton(props Props) { Type: button.TypeButton, }) { - @icon.Clipboard(icon.Props{Size: 16}) + @icon.Clipboard(icon.Props{Class: "size-4"}) } } +var scriptOnce = templ.NewOnceHandle() + templ Script() { - + @scriptOnce.Once() { + @utils.ComponentScript("copybutton") + } } diff --git a/internal/ui/components/datepicker/datepicker.templ b/internal/ui/components/datepicker/datepicker.templ index cba326f..16bf406 100644 --- a/internal/ui/components/datepicker/datepicker.templ +++ b/internal/ui/components/datepicker/datepicker.templ @@ -1,4 +1,4 @@ -// templui component datepicker - version: v1.2.0 installed by templui v1.2.0 +// templui component datepicker - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/date-picker package datepicker @@ -47,8 +47,6 @@ type Props struct { Placeholder string Disabled bool HasError bool - Required bool - Clearable bool } templ DatePicker(props ...Props) { @@ -73,99 +71,79 @@ templ DatePicker(props ...Props) { p.Format = FormatLOCALE_MEDIUM } - var contentID = p.ID + "-content" var valuePtr *time.Time var initialSelectedISO string if !p.Value.IsZero() { valuePtr = &p.Value initialSelectedISO = p.Value.Format("2006-01-02") } - - var required = "false" - if p.Required { - required = "true" - } }} -
- - @popover.Trigger(popover.TriggerProps{For: contentID}) { - @button.Button(button.Props{ - ID: p.ID, - Variant: button.VariantOutline, - Class: utils.TwMerge( - // Base styles matching input - "w-full h-9 px-3 py-1 text-base md:text-sm", - "flex items-center justify-between", - "rounded-md border border-input bg-transparent shadow-xs transition-[color,box-shadow] outline-none", - // Dark mode background - "dark:bg-input/30", - // Selection styles - "selection:bg-primary selection:text-primary-foreground", - // Focus styles - "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]", - // Error/Invalid styles - "aria-invalid:ring-destructive/20 aria-invalid:border-destructive dark:aria-invalid:ring-destructive/40", - utils.If(p.HasError, "border-destructive ring-destructive/20 dark:ring-destructive/40"), - p.Class, - ), - Disabled: p.Disabled, - Attributes: utils.MergeAttributes(p.Attributes, templ.Attributes{ - "data-tui-datepicker": "true", - "data-tui-datepicker-display-format": string(p.Format), - "data-tui-datepicker-locale-tag": string(p.LocaleTag), - "data-tui-datepicker-placeholder": p.Placeholder, - "data-tui-datepicker-required": required, - "aria-invalid": utils.If(p.HasError, "true"), - }), - }) { - if p.Placeholder != "" { - - { p.Placeholder } +
+ @popover.Root() { + + @popover.Trigger() { + @button.Button(button.Props{ + ID: p.ID, + Variant: button.VariantOutline, + Class: utils.TwMerge( + // Base styles matching input + "w-full h-9 px-3 py-1 text-base md:text-sm", + "flex items-center justify-between", + "rounded-md border border-input bg-transparent shadow-xs transition-[color,box-shadow] outline-none", + // Dark mode background + "dark:bg-input/30", + // Selection styles + "selection:bg-primary selection:text-primary-foreground", + // Focus styles + "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]", + // Error/Invalid styles + "aria-invalid:ring-destructive/20 aria-invalid:border-destructive dark:aria-invalid:ring-destructive/40", + utils.If(p.HasError, "border-destructive ring-destructive/20 dark:ring-destructive/40"), + p.Class, + ), + Disabled: p.Disabled, + Attributes: utils.MergeAttributes(p.Attributes, templ.Attributes{ + "data-tui-datepicker": "true", + "data-tui-datepicker-display-format": string(p.Format), + "data-tui-datepicker-locale-tag": string(p.LocaleTag), + "data-tui-datepicker-placeholder": p.Placeholder, + "aria-invalid": utils.If(p.HasError, "true"), + }), + }) { + if p.Placeholder != "" { + + { p.Placeholder } + + } + + @icon.Calendar(icon.Props{Class: "size-4"}) } - - @icon.Calendar(icon.Props{Size: 16}) - } - } - @popover.Content(popover.ContentProps{ - ID: contentID, - Placement: popover.PlacementBottomStart, - Class: "p-0", - }) { - @card.Card(card.Props{ - Class: "border-0 shadow-none", + @popover.Content(popover.ContentProps{ + Placement: popover.PlacementBottomStart, + Class: "p-0", }) { - @card.Content(card.ContentProps{ - Class: "p-3", + @card.Card(card.Props{ + Class: "border-0 shadow-none", }) { - @calendar.Calendar(calendar.Props{ - ID: p.ID + "-calendar-instance", // Pass ID for calendar instance - LocaleTag: calendar.LocaleTag(p.LocaleTag), // Pass locale tag to calendar - StartOfWeek: p.StartOfWeek, // Pass start of week to calendar - Value: valuePtr, // Pass pointer to value - RenderHiddenInput: false, // Don't render hidden input inside popover - }) - if p.Clearable { - @button.Button(button.Props{ - ID: p.ID + "-clear-button", - Class: "mt-4 w-full", - Variant: button.VariantOutline, - Attributes: templ.Attributes{ - "data-tui-datepicker-clear": "true", - }, - }) { - Clear - } + @card.Content(card.ContentProps{ + Class: "p-3", + }) { + @calendar.Calendar(calendar.Props{ + LocaleTag: calendar.LocaleTag(p.LocaleTag), + StartOfWeek: p.StartOfWeek, + Value: valuePtr, + HideHiddenInput: true, + }) } } } @@ -173,6 +151,12 @@ templ DatePicker(props ...Props) {
} +var scriptOnce = templ.NewOnceHandle() + templ Script() { - + @scriptOnce.Once() { + @calendar.Script() + @popover.Script() + @utils.ComponentScript("datepicker") + } } diff --git a/internal/ui/components/dialog/dialog.templ b/internal/ui/components/dialog/dialog.templ index dc83a1e..2f9e12e 100644 --- a/internal/ui/components/dialog/dialog.templ +++ b/internal/ui/components/dialog/dialog.templ @@ -1,4 +1,4 @@ -// templui component dialog - version: v1.2.0 installed by templui v1.2.0 +// templui component dialog - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/dialog package dialog @@ -11,8 +11,7 @@ import ( type contextKey string const ( - instanceKey contextKey = "dialogInstance" - openKey contextKey = "dialogOpen" + openKey contextKey = "dialogOpen" ) type Props struct { @@ -28,23 +27,20 @@ type TriggerProps struct { ID string Class string Attributes templ.Attributes - For string // Reference to a specific dialog ID (for external triggers) + For string // Dialog root ID for external triggers } type ContentProps struct { - ID string - Class string - Attributes templ.Attributes - HideCloseButton bool - Open bool // Initial open state for standalone usage (when no context) - DisableAutoFocus bool + Class string + Attributes templ.Attributes + HideCloseButton bool } type CloseProps struct { ID string Class string Attributes templ.Attributes - For string // ID of the dialog to close (optional, defaults to closest dialog) + For string // Dialog root ID to close (optional, defaults to closest dialog) } type HeaderProps struct { @@ -76,25 +72,20 @@ templ Dialog(props ...Props) { if len(props) > 0 { {{ p = props[0] }} } - {{ instanceID := p.ID }} - if instanceID == "" { - {{ instanceID = utils.RandomID() }} - } - {{ ctx = context.WithValue(ctx, instanceKey, instanceID) }} {{ ctx = context.WithValue(ctx, openKey, p.Open) }}
{ children... } @@ -106,19 +97,14 @@ templ Trigger(props ...TriggerProps) { if len(props) > 0 { {{ p = props[0] }} } - {{ instanceID := "" }} - // Explicit For prop takes priority over inherited context - if p.For != "" { - {{ instanceID = p.For }} - } else if val := ctx.Value(instanceKey); val != nil { - {{ instanceID = val.(string) }} - } 0 { {{ p = props[0] }} } - // Start with prop values as defaults - {{ instanceID := p.ID }} - {{ open := p.Open }} - // Override with context values if available - if val := ctx.Value(instanceKey); val != nil { - {{ instanceID = val.(string) }} - } + {{ open := false }} if val := ctx.Value(openKey); val != nil { {{ open = val.(bool) }} } - // Apply defaults if still empty - if instanceID == "" { - {{ instanceID = utils.RandomID() }} - } - -
- - + data-tui-dialog-close + aria-label="Close" + type="button" + > + @icon.X() + Close + + } +
+ } templ Close(props ...CloseProps) { @@ -251,10 +190,9 @@ templ Close(props ...CloseProps) { if p.ID != "" { id={ p.ID } } + data-tui-dialog-close if p.For != "" { - data-tui-dialog-close={ p.For } - } else { - data-tui-dialog-close + data-tui-dialog-target={ p.For } } class={ utils.TwMerge("contents cursor-pointer", p.Class) } { p.Attributes... } @@ -327,6 +265,10 @@ templ Description(props ...DescriptionProps) {

} +var scriptOnce = templ.NewOnceHandle() + templ Script() { - + @scriptOnce.Once() { + @utils.ComponentScript("dialog") + } } diff --git a/internal/ui/components/dropdown/dropdown.templ b/internal/ui/components/dropdown/dropdown.templ index ea142c9..6a887d9 100644 --- a/internal/ui/components/dropdown/dropdown.templ +++ b/internal/ui/components/dropdown/dropdown.templ @@ -1,9 +1,8 @@ -// templui component dropdown - version: v1.2.0 installed by templui v1.2.0 +// templui component dropdown - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/dropdown package dropdown import ( - "context" "git.juancwu.dev/juancwu/budgit/internal/ui/components/popover" "git.juancwu.dev/juancwu/budgit/internal/ui/utils" ) @@ -25,25 +24,16 @@ const ( PlacementLeftEnd = popover.PlacementLeftEnd ) -type contextKey string - -var ( - contentIDKey contextKey = "contentID" - subContentIDKey contextKey = "subContentID" -) - type Props struct { ID string } type TriggerProps struct { - ID string Class string Attributes templ.Attributes } type ContentProps struct { - ID string Class string Attributes templ.Attributes Placement Placement @@ -90,13 +80,11 @@ type SubProps struct { } type SubTriggerProps struct { - ID string Class string Attributes templ.Attributes } type SubContentProps struct { - ID string Class string Attributes templ.Attributes } @@ -108,36 +96,25 @@ type PortalProps struct { } templ Dropdown(props ...Props) { - {{ - var p Props - if len(props) > 0 { - p = props[0] - } - contentID := p.ID - if contentID == "" { - contentID = utils.RandomID() - } - ctx = context.WithValue(ctx, contentIDKey, contentID) - }} - { children... } + {{ var p Props }} + if len(props) > 0 { + {{ p = props[0] }} + } + @popover.Root(popover.RootProps{ + ID: p.ID, + }) { + { children... } + } } templ Trigger(props ...TriggerProps) { - {{ - var p TriggerProps - if len(props) > 0 { - p = props[0] - } - contentID, ok := ctx.Value(contentIDKey).(string) - if !ok { - contentID = "fallback-content-id" - } - }} + {{ var p TriggerProps }} + if len(props) > 0 { + {{ p = props[0] }} + } @popover.Trigger(popover.TriggerProps{ - ID: p.ID, Class: p.Class, Attributes: p.Attributes, - For: contentID, TriggerType: popover.TriggerTypeClick, }) { { children... } @@ -149,10 +126,6 @@ templ Content(props ...ContentProps) { if len(props) > 0 { {{ p = props[0] }} } - {{ contentID, ok := ctx.Value(contentIDKey).(string) }} - if !ok { - {{ contentID = "fallback-content-id" }} // Must match fallback in Trigger - } {{ placement := p.Placement if placement == "" { @@ -160,7 +133,6 @@ templ Content(props ...ContentProps) { } }} @popover.Content(popover.ContentProps{ - ID: contentID, Placement: placement, Class: utils.TwMerge( "z-50 rounded-md bg-popover p-1 shadow-md focus:outline-none overflow-auto", @@ -175,6 +147,15 @@ templ Content(props ...ContentProps) { } } +var scriptOnce = templ.NewOnceHandle() + +templ Script() { + @scriptOnce.Once() { + @popover.Script() + @utils.ComponentScript("dropdown") + } +} + templ Group(props ...GroupProps) { {{ var p GroupProps }} if len(props) > 0 { @@ -298,43 +279,25 @@ templ Shortcut(props ...ShortcutProps) { } templ Sub(props ...SubProps) { - {{ - var p SubProps - if len(props) > 0 { - p = props[0] - } - subContentID := p.ID - if subContentID == "" { - subContentID = utils.RandomID() - } - ctx = context.WithValue(ctx, subContentIDKey, subContentID) - }} -
+ {{ var p SubProps }} + if len(props) > 0 { + {{ p = props[0] }} + } + @popover.Root(popover.RootProps{ + ID: p.ID, + Class: p.Class, + Attributes: p.Attributes, + }) { { children... } -
+ } } templ SubTrigger(props ...SubTriggerProps) { - {{ - var p SubTriggerProps - if len(props) > 0 { - p = props[0] - } - subContentID, ok := ctx.Value(subContentIDKey).(string) - if !ok { - subContentID = "fallback-subcontent-id" - } - }} + {{ var p SubTriggerProps }} + if len(props) > 0 { + {{ p = props[0] }} + } @popover.Trigger(popover.TriggerProps{ - ID: p.ID, - For: subContentID, TriggerType: popover.TriggerTypeHover, }) {
} +var scriptOnce = templ.NewOnceHandle() + templ Script() { - + @scriptOnce.Once() { + @utils.ComponentScript("input") + } } diff --git a/internal/ui/components/inputotp/inputotp.templ b/internal/ui/components/inputotp/inputotp.templ index b40d58d..0ff55a3 100644 --- a/internal/ui/components/inputotp/inputotp.templ +++ b/internal/ui/components/inputotp/inputotp.templ @@ -1,8 +1,9 @@ -// templui component inputotp - version: v1.2.0 installed by templui v1.2.0 +// templui component inputotp - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/input-otp package inputotp import ( + "git.juancwu.dev/juancwu/budgit/internal/ui/components/input" "git.juancwu.dev/juancwu/budgit/internal/ui/utils" "strconv" ) @@ -176,6 +177,11 @@ templ Separator(props ...SeparatorProps) { } +var scriptOnce = templ.NewOnceHandle() + templ Script() { - + @scriptOnce.Once() { + @input.Script() + @utils.ComponentScript("inputotp") + } } diff --git a/internal/ui/components/label/label.templ b/internal/ui/components/label/label.templ index 3ba8bcb..4970393 100644 --- a/internal/ui/components/label/label.templ +++ b/internal/ui/components/label/label.templ @@ -1,4 +1,4 @@ -// templui component label - version: v1.2.0 installed by templui v1.2.0 +// templui component label - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/label package label @@ -38,6 +38,10 @@ templ Label(props ...Props) { } +var scriptOnce = templ.NewOnceHandle() + templ Script() { - + @scriptOnce.Once() { + @utils.ComponentScript("label") + } } diff --git a/internal/ui/components/pagination/pagination.templ b/internal/ui/components/pagination/pagination.templ index 7274121..aab4911 100644 --- a/internal/ui/components/pagination/pagination.templ +++ b/internal/ui/components/pagination/pagination.templ @@ -1,4 +1,4 @@ -// templui component pagination - version: v1.2.0 installed by templui v1.2.0 +// templui component pagination - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/pagination package pagination @@ -145,7 +145,7 @@ templ Previous(props ...PreviousProps) { Class: utils.TwMerge("gap-1", p.Class), Attributes: p.Attributes, }) { - @icon.ChevronLeft(icon.Props{Size: 16}) + @icon.ChevronLeft(icon.Props{Class: "size-4"}) if p.Label != "" { { p.Label } } @@ -168,12 +168,12 @@ templ Next(props ...NextProps) { if p.Label != "" { { p.Label } } - @icon.ChevronRight(icon.Props{Size: 16}) + @icon.ChevronRight(icon.Props{Class: "size-4"}) } } templ Ellipsis() { - @icon.Ellipsis(icon.Props{Size: 16}) + @icon.Ellipsis(icon.Props{Class: "size-4"}) } func CreatePagination(currentPage, totalPages, maxVisible int) struct { diff --git a/internal/ui/components/popover/popover.templ b/internal/ui/components/popover/popover.templ index 33340be..eec0f7f 100644 --- a/internal/ui/components/popover/popover.templ +++ b/internal/ui/components/popover/popover.templ @@ -1,4 +1,4 @@ -// templui component popover - version: v1.2.0 installed by templui v1.2.0 +// templui component popover - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/popover package popover @@ -27,15 +27,21 @@ const ( type TriggerType string const ( - TriggerTypeHover TriggerType = "hover" - TriggerTypeClick TriggerType = "click" + TriggerTypeHover TriggerType = "hover" + TriggerTypeClick TriggerType = "click" + TriggerTypeManual TriggerType = "manual" ) +type RootProps struct { + ID string + Class string + Attributes templ.Attributes +} + type TriggerProps struct { ID string Class string Attributes templ.Attributes - For string TriggerType TriggerType } @@ -50,10 +56,26 @@ type ContentProps struct { ShowArrow bool HoverDelay int HoverOutDelay int - MatchWidth bool Exclusive bool } +templ Root(props ...RootProps) { + {{ var p RootProps }} + if len(props) > 0 { + {{ p = props[0] }} + } +
+ { children... } +
+} + templ Trigger(props ...TriggerProps) { {{ var p TriggerProps }} if len(props) > 0 { @@ -66,11 +88,8 @@ templ Trigger(props ...TriggerProps) { if p.ID != "" { id={ p.ID } } - class={ utils.TwMerge("group cursor-pointer", p.Class) } - if p.For != "" { - data-tui-popover-trigger={ p.For } - } - data-tui-popover-open="false" + class={ utils.TwMerge("contents", p.Class) } + data-tui-popover-trigger data-tui-popover-type={ string(p.TriggerType) } { p.Attributes... } > @@ -94,8 +113,11 @@ templ Content(props ...ContentProps) { } } } } +var scriptOnce = templ.NewOnceHandle() + templ Script() { - + @scriptOnce.Once() { + @utils.ComponentScript("popover") + } } diff --git a/internal/ui/components/progress/progress.templ b/internal/ui/components/progress/progress.templ index 4f8ac22..e9a7d7f 100644 --- a/internal/ui/components/progress/progress.templ +++ b/internal/ui/components/progress/progress.templ @@ -1,4 +1,4 @@ -// templui component progress - version: v1.2.0 installed by templui v1.2.0 +// templui component progress - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/progress package progress @@ -122,6 +122,10 @@ func variantClasses(variant Variant) string { } } +var scriptOnce = templ.NewOnceHandle() + templ Script() { - + @scriptOnce.Once() { + @utils.ComponentScript("progress") + } } diff --git a/internal/ui/components/radio/radio.templ b/internal/ui/components/radio/radio.templ index 274a9e9..cc862f6 100644 --- a/internal/ui/components/radio/radio.templ +++ b/internal/ui/components/radio/radio.templ @@ -1,4 +1,4 @@ -// templui component radio - version: v1.2.0 installed by templui v1.2.0 +// templui component radio - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/radio package radio diff --git a/internal/ui/components/rating/rating.templ b/internal/ui/components/rating/rating.templ index a10827c..7ccd478 100644 --- a/internal/ui/components/rating/rating.templ +++ b/internal/ui/components/rating/rating.templ @@ -1,4 +1,4 @@ -// templui component rating - version: v1.2.0 installed by templui v1.2.0 +// templui component rating - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/rating package rating @@ -166,7 +166,7 @@ func ratingIcon(style Style, filled bool, value float64) templ.Component { } iconProps := icon.Props{} if filled { - iconProps.Fill = "currentColor" + iconProps.Class = "fill-current" } switch style { case StyleHeart: @@ -188,6 +188,10 @@ func (p *Props) setDefaults() { } } +var scriptOnce = templ.NewOnceHandle() + templ Script() { - + @scriptOnce.Once() { + @utils.ComponentScript("rating") + } } diff --git a/internal/ui/components/selectbox/selectbox.templ b/internal/ui/components/selectbox/selectbox.templ index 97b631b..34e236d 100644 --- a/internal/ui/components/selectbox/selectbox.templ +++ b/internal/ui/components/selectbox/selectbox.templ @@ -1,10 +1,8 @@ -// templui component selectbox - version: v1.2.0 installed by templui v1.2.0 +// templui component selectbox - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/select-box package selectbox import ( - "context" - "fmt" "git.juancwu.dev/juancwu/budgit/internal/ui/components/button" "git.juancwu.dev/juancwu/budgit/internal/ui/components/icon" "git.juancwu.dev/juancwu/budgit/internal/ui/components/input" @@ -13,10 +11,6 @@ import ( "strconv" ) -type contextKey string - -var contentIDKey contextKey = "contentID" - type Props struct { ID string Class string @@ -80,170 +74,18 @@ templ SelectBox(props ...Props) { if len(props) > 0 { p = props[0] } - wrapperID := p.ID - if wrapperID == "" { - wrapperID = utils.RandomID() - } - contentID := fmt.Sprintf("%s-content", wrapperID) - ctx = context.WithValue(ctx, contentIDKey, contentID) }}
- { children... } -
-} - -templ Trigger(props ...TriggerProps) { - {{ - var p TriggerProps - if len(props) > 0 { - p = props[0] - } - contentID, ok := ctx.Value(contentIDKey).(string) - if !ok { - contentID = "fallback-select-content-id" - } - if p.ShowPills { - p.Multiple = true - } - }} - @popover.Trigger(popover.TriggerProps{ - For: contentID, - TriggerType: popover.TriggerTypeClick, - }) { - @button.Button(button.Props{ - ID: p.ID, - Type: "button", - Variant: button.VariantOutline, - Class: utils.TwMerge( - // Required class for JavaScript - "select-trigger", - // Base styles matching input - "w-full h-9 px-3 py-1 text-base md:text-sm", - "flex items-center justify-between", - "rounded-md border border-input bg-transparent shadow-xs transition-[color,box-shadow] outline-none", - // Dark mode background - "dark:bg-input/30", - // Selection styles - "selection:bg-primary selection:text-primary-foreground", - // Focus styles - "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]", - // Error/Invalid styles - "aria-invalid:ring-destructive/20 aria-invalid:border-destructive dark:aria-invalid:ring-destructive/40", - utils.If(p.HasError, "border-destructive ring-destructive/20 dark:ring-destructive/40"), - p.Class, - ), - Disabled: p.Disabled, - Attributes: utils.MergeAttributes( - templ.Attributes{ - "data-tui-selectbox-content-id": contentID, - "data-tui-selectbox-multiple": strconv.FormatBool(p.Multiple), - "data-tui-selectbox-show-pills": strconv.FormatBool(p.ShowPills), - "data-tui-selectbox-selected-count-text": p.SelectedCountText, - "tabindex": "0", - "aria-invalid": utils.If(p.HasError, "true"), - }, - ), - }) { - - { children... } - - @icon.ChevronDown(icon.Props{ - Size: 16, - Class: "text-muted-foreground", - }) - - } - } -} - -templ Value(props ...ValueProps) { - {{ var p ValueProps }} - if len(props) > 0 { - {{ p = props[0] }} - } - - if p.Placeholder != "" { - { p.Placeholder } - } - { children... } - -} - -templ Content(props ...ContentProps) { - {{ - var p ContentProps - if len(props) > 0 { - p = props[0] - } - contentID, ok := ctx.Value(contentIDKey).(string) - if !ok { - contentID = "fallback-select-content-id" - } - }} - @popover.Content(popover.ContentProps{ - ID: contentID, - Placement: popover.PlacementBottomStart, - Offset: 4, - MatchWidth: true, - DisableESC: !p.NoSearch, - Class: utils.TwMerge( - "p-1 select-content z-50 overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md", - "min-w-[var(--popover-trigger-width)] w-[var(--popover-trigger-width)]", - p.Class, - ), - Attributes: utils.MergeAttributes( - templ.Attributes{ - "role": "listbox", - "tabindex": "-1", - }, - p.Attributes, - ), - Exclusive: true, - }) { - if !p.NoSearch { -
-
- - @icon.Search(icon.Props{Size: 16}) - - @input.Input(input.Props{ - Type: input.TypeSearch, - Class: "pl-8", - Placeholder: utils.IfElse(p.SearchPlaceholder != "", p.SearchPlaceholder, "Search..."), - Attributes: templ.Attributes{ - "data-tui-selectbox-search": "", - }, - }) -
-
- } -
+ @popover.Root() { { children... } -
- } + } + } templ Group(props ...GroupProps) { @@ -290,10 +132,10 @@ templ Item(props ...ItemProps) { } class={ utils.TwMerge( - "select-item relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 px-2 text-sm font-light outline-none", + "select-item group relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 px-2 text-sm font-light outline-none", "hover:bg-accent hover:text-accent-foreground", - "focus:bg-accent focus:text-accent-foreground", - utils.If(p.Selected, "bg-accent text-accent-foreground"), + "focus-visible:bg-accent focus-visible:text-accent-foreground", + "data-[tui-selectbox-selected=true]:bg-accent data-[tui-selectbox-selected=true]:text-accent-foreground", utils.If(p.Disabled, "pointer-events-none opacity-50"), p.Class, ), @@ -311,16 +153,163 @@ templ Item(props ...ItemProps) { - @icon.Check(icon.Props{Size: 16}) + @icon.Check(icon.Props{Class: "size-4"}) } -templ Script() { - +templ Trigger(props ...TriggerProps) { + {{ + var p TriggerProps + if len(props) > 0 { + p = props[0] + } + if p.ShowPills { + p.Multiple = true + } + }} + @popover.Trigger(popover.TriggerProps{ + TriggerType: popover.TriggerTypeClick, + }) { + @button.Button(button.Props{ + ID: p.ID, + Type: "button", + Variant: button.VariantOutline, + Class: utils.TwMerge( + // Required class for JavaScript + "select-trigger", + // Base styles matching input + "w-full h-9 px-3 py-1 text-base md:text-sm", + "flex items-center justify-between", + "rounded-md border border-input bg-transparent shadow-xs transition-[color,box-shadow] outline-none", + // Dark mode background + "dark:bg-input/30", + // Selection styles + "selection:bg-primary selection:text-primary-foreground", + // Focus styles + "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]", + // Error/Invalid styles + "aria-invalid:ring-destructive/20 aria-invalid:border-destructive dark:aria-invalid:ring-destructive/40", + utils.If(p.HasError, "border-destructive ring-destructive/20 dark:ring-destructive/40"), + p.Class, + ), + Disabled: p.Disabled, + Attributes: utils.MergeAttributes( + templ.Attributes{ + "data-tui-selectbox-multiple": strconv.FormatBool(p.Multiple), + "data-tui-selectbox-show-pills": strconv.FormatBool(p.ShowPills), + "data-tui-selectbox-selected-count-text": p.SelectedCountText, + "tabindex": "0", + "aria-invalid": utils.If(p.HasError, "true"), + }, + ), + }) { + + { children... } + + + @icon.ChevronDown(icon.Props{Class: "size-4 text-muted-foreground"}) + + } + } +} + +templ Value(props ...ValueProps) { + {{ var p ValueProps }} + if len(props) > 0 { + {{ p = props[0] }} + } + + if p.Placeholder != "" { + { p.Placeholder } + } + { children... } + +} + +templ Content(props ...ContentProps) { + {{ var p ContentProps }} + if len(props) > 0 { + {{ p = props[0] }} + } + @popover.Content(popover.ContentProps{ + Placement: popover.PlacementBottomStart, + Offset: 4, + DisableESC: !p.NoSearch, + Class: utils.TwMerge( + "p-1 select-content z-50 overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md", + p.Class, + ), + Attributes: utils.MergeAttributes( + templ.Attributes{ + "role": "listbox", + "tabindex": "-1", + "data-tui-selectbox-content": "true", + }, + p.Attributes, + ), + Exclusive: true, + }) { + if !p.NoSearch { +
+
+ + @icon.Search(icon.Props{Class: "size-4"}) + + @input.Input(input.Props{ + Type: input.TypeSearch, + Class: "pl-8", + Placeholder: utils.IfElse(p.SearchPlaceholder != "", p.SearchPlaceholder, "Search..."), + Attributes: templ.Attributes{ + "data-tui-selectbox-search": "", + }, + }) +
+
+ } +
+ { children... } +
+ } +} + +var scriptOnce = templ.NewOnceHandle() + +templ Script() { + @scriptOnce.Once() { + @input.Script() + @popover.Script() + @utils.ComponentScript("selectbox") + } } diff --git a/internal/ui/components/separator/separator.templ b/internal/ui/components/separator/separator.templ index 96d084e..18e8f79 100644 --- a/internal/ui/components/separator/separator.templ +++ b/internal/ui/components/separator/separator.templ @@ -1,4 +1,4 @@ -// templui component separator - version: v1.2.0 installed by templui v1.2.0 +// templui component separator - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/separator package separator diff --git a/internal/ui/components/sheet/sheet.templ b/internal/ui/components/sheet/sheet.templ index 6bd319f..871b652 100644 --- a/internal/ui/components/sheet/sheet.templ +++ b/internal/ui/components/sheet/sheet.templ @@ -1,4 +1,4 @@ -// templui component sheet - version: v1.2.0 installed by templui v1.2.0 +// templui component sheet - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/sheet package sheet @@ -37,16 +37,14 @@ type TriggerProps struct { ID string Class string Attributes templ.Attributes - For string // Reference to a specific sheet ID (for external triggers) + For string // Sheet root ID for external triggers } type ContentProps struct { - ID string Class string Attributes templ.Attributes HideCloseButton bool - Side Side // - Open bool // Initial open state for standalone usage + Side Side } type HeaderProps struct { @@ -140,20 +138,16 @@ templ Content(props ...ContentProps) { } // Sheet content uses Dialog content with sheet-specific styles @dialog.Content(dialog.ContentProps{ - ID: p.ID, - Open: p.Open, HideCloseButton: p.HideCloseButton, Class: utils.TwMerge( // First apply side-specific positioning and animations getSideClasses(p.Side), - // Default gap matching shadcn (no padding in content) - "gap-4 !p-0", // Remove Dialog's p-6 padding + // Move panel layout overrides to the inner dialog panel + "[&_[data-tui-dialog-panel]]:gap-4 [&_[data-tui-dialog-panel]]:!p-0", // Override Dialog styles "!scale-100", // Reset Dialog's scale animation "!rounded-none", // Remove dialog rounded corners "!opacity-100", // Keep fully opaque - no fade, only slide - // Remove pointer-events control during animation - "!pointer-events-auto data-[tui-dialog-hidden=true]:!pointer-events-none", // User-provided classes last p.Class, ), @@ -256,26 +250,26 @@ func getSideClasses(side Side) string { case SideRight: return baseClasses + // Positioning - "!inset-y-0 !right-0 !left-auto !top-auto " + + "!top-0 !bottom-0 !right-0 !left-auto " + // Size - "h-full w-3/4 sm:max-w-sm " + + "!h-dvh !max-h-dvh w-3/4 sm:!max-w-sm " + // Border "border-l border-t-0 border-r-0 border-b-0 " + // Reset Dialog transforms - "!translate-y-0 " + + "!translate-x-0 !translate-y-0 " + // Slide animation "data-[tui-dialog-open=false]:!translate-x-full " + "data-[tui-dialog-open=true]:!translate-x-0" case SideLeft: return baseClasses + // Positioning - "!inset-y-0 !left-0 !right-auto !top-auto " + + "!top-0 !bottom-0 !left-0 !right-auto " + // Size - "h-full w-3/4 sm:max-w-sm " + + "!h-dvh !max-h-dvh w-3/4 sm:!max-w-sm " + // Border "border-r border-t-0 border-l-0 border-b-0 " + // Reset Dialog transforms - "!translate-y-0 " + + "!translate-x-0 !translate-y-0 " + // Slide animation "data-[tui-dialog-open=false]:!-translate-x-full " + "data-[tui-dialog-open=true]:!translate-x-0" @@ -308,11 +302,19 @@ func getSideClasses(side Side) string { default: return baseClasses + // Default to right side - "!inset-y-0 !right-0 !left-auto !top-auto " + - "h-full w-3/4 " + + "!top-0 !bottom-0 !right-0 !left-auto " + + "!h-dvh !max-h-dvh w-3/4 sm:!max-w-sm " + "border-l border-t-0 border-r-0 border-b-0 " + - "!translate-y-0 " + + "!translate-x-0 !translate-y-0 " + "data-[tui-dialog-open=false]:!translate-x-full " + "data-[tui-dialog-open=true]:!translate-x-0" } } + +var scriptOnce = templ.NewOnceHandle() + +templ Script() { + @scriptOnce.Once() { + @dialog.Script() + } +} diff --git a/internal/ui/components/sidebar/sidebar.templ b/internal/ui/components/sidebar/sidebar.templ index f07173a..b2d0545 100644 --- a/internal/ui/components/sidebar/sidebar.templ +++ b/internal/ui/components/sidebar/sidebar.templ @@ -1,4 +1,4 @@ -// templui component sidebar - version: v1.2.0 installed by templui v1.2.0 +// templui component sidebar - version: v1.9.5 installed by templui v1.9.5 // 📚 Documentation: https://templui.io/docs/components/sidebar package sidebar @@ -47,6 +47,113 @@ type Props struct { KeyboardShortcut string // default: "b" } +templ Inset(props ...InsetProps) { + {{ var p InsetProps }} + if len(props) > 0 { + {{ p = props[0] }} + } +
+ { children... } +
+} + +templ Group(props ...GroupProps) { + {{ var p GroupProps }} + if len(props) > 0 { + {{ p = props[0] }} + } +
+ { children... } +
+} + +templ GroupLabel(props ...GroupLabelProps) { + {{ var p GroupLabelProps }} + if len(props) > 0 { + {{ p = props[0] }} + } +
svg]:size-4 [&>svg]:shrink-0", + "group-data-[tui-sidebar-state=collapsed]:group-data-[tui-sidebar-collapsible=icon]:-mt-8 group-data-[tui-sidebar-state=collapsed]:group-data-[tui-sidebar-collapsible=icon]:opacity-0", + p.Class, + ) } + data-tui-sidebar="group-label" + { p.Attributes... } + > + { children... } +
+} + +templ MenuBadge(props ...MenuBadgeProps) { + {{ var p MenuBadgeProps }} + if len(props) > 0 { + {{ p = props[0] }} + } + + { children... } + +} + +templ Separator(props ...SeparatorProps) { + {{ var p SeparatorProps }} + if len(props) > 0 { + {{ p = props[0] }} + } +
+} + type TriggerProps struct { ID string Class string @@ -453,9 +560,7 @@ templ MenuButton(props ...MenuButtonProps) { // When collapsed to icon mode - show with tooltip