mdas-jsview-sdk 1.0.26-uat.0 → 1.0.28-uat.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mdas-sdk.esm.js +3216 -3088
- package/dist/mdas-sdk.esm.js.map +1 -1
- package/dist/mdas-sdk.js +3180 -3052
- package/dist/mdas-sdk.js.map +1 -1
- package/dist/mdas-sdk.min.js +9 -9
- package/dist/mdas-sdk.min.js.map +1 -1
- package/package.json +1 -1
package/dist/mdas-sdk.min.js
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
!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).MdasSDK={})}(this,(function(t){"use strict";class e{constructor(){this.state=new Map,this.listeners=new Map}setState(t,e){this.state.set(t,e),this.notifyListeners(t,e)}getState(t){return this.state.get(t)}subscribe(t,e){return this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(e),()=>{const n=this.listeners.get(t);n&&n.delete(e)}}notifyListeners(t,e){const n=this.listeners.get(t);n&&n.forEach((t=>t(e)))}clear(){this.state.clear(),this.listeners.clear()}}class n{constructor(t,e,n){this.setContainer(t),this.options=e,this.widgetId=n,this.isDestroyed=!1,this.lastData=null,this.lastDataTimestamp=null,this.connectionQuality="disconnected",this.eventListeners=[],this.timeouts=[],this.intervals=[]}setContainer(t){if(!t)throw new Error("DOM element is required for widget");if("string"==typeof t){const e=document.querySelector(t);if(!e)throw new Error(`Element not found: ${t}`);this.container=e}else{if(t.nodeType!==Node.ELEMENT_NODE)throw new Error("Invalid element provided to widget");this.container=t}}showLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.remove("hidden")}hideLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.add("hidden")}showError(t){this.hideLoading(),this.clearError();const e=document.createElement("div");e.className="widget-error",e.textContent=`Error: ${t}`,this.container.appendChild(e)}clearError(){const t=this.container.querySelector(".widget-error");t&&t.remove()}showConnectionQuality(){const t=this.container.querySelector(".connection-quality");if(t&&t.remove(),"live"===this.connectionQuality)return;const e=this.container.querySelector('.last-update, [class*="last-update"], [class*="timestamp"]');if(e){const t=document.createElement("span");switch(t.className="connection-quality",this.connectionQuality){case"offline":t.textContent=" (disconnected)",t.style.color="#dc2626",t.style.fontWeight="500";break;case"reconnecting":t.textContent=" (reconnecting...)",t.style.color="#d97706"}t.style.fontSize="11px",e.appendChild(t)}}handleMessage(t){if(!this.isDestroyed)try{const{event:e,data:n}=t;if(console.log("[BaseWidget] handleMessage called with event:",e,"data:",n),this.debug&&console.log(`[${this.type}] Received:`,e,n),"connection"===e)return void this.handleConnectionStatus(n);if("data"===e)return console.log("[BaseWidget] Caching live data"),this.lastData=n,this.lastDataTimestamp=Date.now(),this.connectionQuality="live",void this.handleData(n);if("session_revoked"===e)return void this.handleSessionRevoked(n);this.handleCustomEvent&&this.handleCustomEvent(e,n)}catch(t){console.error(`[${this.constructor.name}] Error handling message:`,t),this.showError("Error processing data")}}handleSessionRevoked(t){"attempting_relogin"===t.status?(this.connectionQuality="reconnecting",this.lastData?this.showCachedData():this.showLoading()):"relogin_failed"===t.status?(this.connectionQuality="offline",this.showError(t.error||"Session expired. Please refresh the page.")):"relogin_successful"===t.status&&(this.connectionQuality="live",this.hideLoading(),this.clearError())}handleData(t){throw new Error("handleData must be implemented by child widget")}handleConnectionStatus(t){"connected"===t.status?(this.connectionQuality="live",this.clearError(),this.hideLoading()):"reconnecting"===t.status?(this.connectionQuality="reconnecting",this.lastData?this.showCachedData():this.showLoading()):"disconnected"===t.status?(this.connectionQuality="offline",this.lastData?this.showCachedData():this.hideLoading()):"failed"===t.status?(this.connectionQuality="offline",this.handleConnectionFailed(t),this.showConnectionQuality()):"error"===t.status&&(this.connectionQuality="offline",this.lastData?this.showCachedData():this.hideLoading())}showCachedData(){if(this.lastData&&this.lastDataTimestamp){const t=Date.now()-this.lastDataTimestamp,e=t>3e5,n={...this.lastData,_cached:!0,_cacheAge:t,_isStale:e,_quality:this.connectionQuality};this.handleData(n)}}addEventListener(t,e,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};t&&e&&n?(t.addEventListener(e,n,i),this.eventListeners.push({element:t,event:e,handler:n,options:i})):console.warn("[BaseWidget] Invalid addEventListener parameters")}setTimeout(t,e){const n=setTimeout(t,e);return this.timeouts.push(n),n}setInterval(t,e){const n=setInterval(t,e);return this.intervals.push(n),n}clearTimeout(t){clearTimeout(t);const e=this.timeouts.indexOf(t);e>-1&&this.timeouts.splice(e,1)}clearInterval(t){clearInterval(t);const e=this.intervals.indexOf(t);e>-1&&this.intervals.splice(e,1)}showInputError(t,e){if(!t)return;this.clearInputError(t);const n=document.createElement("div");n.className="input-error-message",n.textContent=e,n.style.cssText="\n color: #dc2626;\n font-size: 12px;\n margin-top: 4px;\n animation: slideDown 0.2s ease-out;\n ",t.classList.add("input-error"),t.style.borderColor="#dc2626",t.parentNode&&t.parentNode.insertBefore(n,t.nextSibling),t.errorElement=n}clearInputError(t){t&&(t.errorElement&&(t.errorElement.remove(),t.errorElement=null),t.classList.remove("input-error"),t.style.borderColor="")}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.eventListeners.forEach((t=>{let{element:e,event:n,handler:i,options:s}=t;try{e.removeEventListener(n,i,s)}catch(t){console.error("[BaseWidget] Error removing event listener:",t)}})),this.eventListeners=[],this.timeouts.forEach((t=>{clearTimeout(t)})),this.timeouts=[],this.intervals.forEach((t=>{clearInterval(t)})),this.intervals=[],this.lastData=null,this.container&&(this.container.innerHTML=""),this.debug&&console.log(`[${this.constructor.name}] Widget destroyed and cleaned up`))}handleConnectionFailed(t){this.connectionQuality="offline",this.lastData?(this.showCachedData(),this.hideLoading()):this.hideLoading(),this.debug&&console.log(`[${this.constructor.name}] Connection failed after ${t.maxAttempts} attempts`)}async validateInitialSymbol(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;try{const i=this.wsManager?.getApiService();if(!i)return this.debug&&console.log(`[${this.constructor.name}] API service not available for initial validation`),!0;if(!i[t])return console.error(`[${this.constructor.name}] API method ${t} does not exist`),!0;const s=await i[t](e);return s&&s.data&&s.data.length>0?(this.debug&&console.log(`[${this.constructor.name}] Initial symbol validated:`,{symbol:e,method:t,dataCount:s.data.length}),n&&"function"==typeof n&&n(s.data,s),!0):(this.debug&&console.log(`[${this.constructor.name}] No data returned from ${t} for ${e}`),!0)}catch(t){this.debug&&console.warn(`[${this.constructor.name}] Initial symbol validation failed:`,t);const n=(t.message||"").toLowerCase();if(n.includes("400")||n.includes("401")||n.includes("403")||n.includes("forbidden")||n.includes("unauthorized")||n.includes("no access")||n.includes("no opra access")||n.includes("permission denied")||n.includes("access denied")){this.hideLoading();let t=`Access denied: You don't have permission to view data for ${e}`;return n.includes("no opra access")&&(t=`Access denied: You don't have OPRA access for option ${e}`),this.showError(t),!1}return!0}}}class i{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.symbol=t.Symbol||"",this.companyName=t.CompName||"",this.companyDescription=t.CompDesc||"",this.instrumentType=t.InstrType||"",this.lastPrice=t.LastPx||0,this.previousClose=t.YestClosePx||0,this.open=t.OpenPx||0,this.high=t.HighPx||0,this.low=t.LowPx||0,this.close=t.ClosingPx||0,this.change=t.Change||0,this.changePercent=t.ChangePercent||0,this.vwap=t.VWAP||0,this.volume=t.Volume||0,this.averageVolume=t.AvgVol30d||0,this.yesterdayVolume=t.YesterdayTradeVolume||0,this.bidPrice=t.BidPx||0,this.bidSize=t.BidSz||0,this.bidExchange=t.BidExch||"",this.askPrice=t.AskPx||0,this.askSize=t.AskSz||0,this.askExchange=t.AskExch||"",this.issueMarket=t.IssueMarket||"",this.marketName=t.MarketName||"",this.marketDescription=t.MarketDesc||"",this.mic=t.MIC||"",this.countryCode=t.CountryCode||"",this.timeZone=t.TimeZone||"",this.tradePrice=t.TradePx||0,this.tradeSize=t.TradeSz||0,this.tradeCondition=t.Condition||0,this.tradeTime=t.TradeTime||"",this.tradeRegion=t.TradeRegion||"",this.tradeRegionName=t.TradeRegionName||"",this.preMarketPrice=t.PreLastPx||0,this.preMarketTradeTime=t.PreTradeTime||"",this.postMarketPrice=t.PostLastPx||0,this.postMarketTradeTime=t.PostTradeTime||"",this.high52Week=t.High52wPx||0,this.low52Week=t.Low52wPx||0,this.high52WeekDate=t.High52wDate||"",this.low52WeekDate=t.Low52wDate||"",this.calendarYearHigh=t.CalendarYearHigh||0,this.calendarYearLow=t.CalendarYearLow||0,this.calendarYearHighDate=t.CalendarYearHighDate||"",this.calendarYearLowDate=t.CalendarYearLowDate||"",this.marketCap=t.MktCap||0,this.peRatio=t.PeRatio||0,this.beta=t.FundBeta||0,this.sharesOutstanding=t.ComShrsOut||0,this.dividendYield=t.DivYield||0,this.dividendAmount=t.DivAmt||0,this.dividendRate=t.DividendRate||0,this.dividendPaymentDate=t.DividendPaymentDate||t.PayDate||"",this.dividendExDate=t.DividendExDate||t.DivDateEx||"",this.isin=t.ISIN||"",this.cusip=t.CUSIP||"",this.sedol=t.SEDOL||"",this.gics=t.GICS||"",this.status=t.Status||"",this.dataSource=t.DataSource||"",this.quoteTime=t.QuoteTime||"",this.infoTime=t.InfoTime||""}get openPrice(){return this.open}get description(){return this.companyDescription}get lastUpdate(){return this.quoteTime||this.infoTime}getSecurityType(){return{257:"Stock",262:"ETF",261:"Mutual Fund",258:"Bond",260:"Option",263:"Future",259:"Index"}[this.instrumentType]||"Stock"}getPriceChange(){return this.change}getPriceChangePercent(){return 100*this.changePercent}getDataSource(){return"delay"===this.dataSource.toLowerCase()?"20 mins delayed":"real-time"===this.dataSource.toLowerCase()?"Real-time":null!==this.dataSource&&""!==this.dataSource?this.dataSource:"MDAS Server"}getCurrentPrice(){return this.lastPrice}get52WeekRange(){return`${this.low52Week.toFixed(2)} - ${this.high52Week.toFixed(2)}`}getMarketCapFormatted(){return this.formatMarketCap()}formatPrice(){return`$${(arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.lastPrice).toFixed(2)}`}formatPriceChange(){const t=this.getPriceChange();return`${t>=0?"+":""} ${t.toFixed(2)}`}formatPriceChangePercent(){const t=this.getPriceChangePercent();return`${t>=0?"+":""}${t.toFixed(2)}%`}formatBidAsk(){return`$${this.bidPrice.toFixed(2)} x ${this.bidSize} / $${this.askPrice.toFixed(2)} x ${this.askSize}`}formatVolume(){return 0===this.volume?"N/A":this.volume.toLocaleString()}formatAvgVolume(){return 0===this.averageVolume?"N/A":this.averageVolume.toLocaleString()}formatAverageVolume(){return 0===this.averageVolume?"N/A":this.averageVolume.toLocaleString()}formatDayRange(){return 0===this.low&&0===this.high?"N/A":`$${this.low.toFixed(2)} - $${this.high.toFixed(2)}`}format52WeekRange(){return 0===this.low52Week&&0===this.high52Week?"N/A":`${this.low52Week.toFixed(2)} - ${this.high52Week.toFixed(2)}`}formatMarketCap(){if(0===this.marketCap)return"N/A";const t=1e6*this.marketCap;return t>=1e12?`$${(t/1e12).toFixed(2)}T`:t>=1e9?`$${(t/1e9).toFixed(2)}B`:t>=1e6?`$${(t/1e6).toFixed(2)}M`:t>=1e3?`$${(t/1e3).toFixed(2)}K`:`$${t.toFixed(2)}`}formatAvg30DayVolume(){return this.formatAverageVolume()}static fromApiResponse(t){return new i(t)}}class s{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.widget=t,this.options={maxLength:e.maxLength||10,placeholder:e.placeholder||"Enter symbol...",onSymbolChange:e.onSymbolChange||(()=>{}),debug:e.debug||!1,autoUppercase:!1!==e.autoUppercase,...e},this.symbolType=e.symbolType||null,this.apiService=this.widget.wsManager.getApiService(),this.isEditing=!1,this.isValidating=!1,this.originalSymbol="",this.elements={},this.addStyles(),this.initialize()}initialize(){this.setupElements(),this.attachEventListeners()}setupElements(){if(this.elements.symbolDisplay=this.widget.container.querySelector(".editable-symbol"),!this.elements.symbolDisplay)throw new Error('No element with class "editable-symbol" found in widget');this.originalSymbol=this.elements.symbolDisplay.textContent.trim(),this.elements.symbolDisplay.dataset.originalSymbol=this.originalSymbol}attachEventListeners(){this.startEditing=this.startEditing.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.handleInput=this.handleInput.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleClickOutside=this.handleClickOutside.bind(this),this.elements.symbolDisplay.addEventListener("dblclick",this.startEditing)}startEditing(){this.isEditing||this.isValidating||(this.isEditing=!0,this.originalSymbol=this.elements.symbolDisplay.textContent.trim(),this.options.debug&&(console.log(this.widget.connectionQuality),console.log("[SymbolEditor] Starting edit mode for:",this.originalSymbol)),this.transformToInput())}transformToInput(){const t=this.elements.symbolDisplay,e=window.getComputedStyle(t),n=document.createElement("div");n.className="symbol-edit-container",n.style.display="inline-flex",n.style.alignItems="center",n.style.gap="8px",n.style.verticalAlign="baseline";const i=document.createElement("input");i.type="text",i.value=this.originalSymbol,i.className=t.className+" symbol-input-mode",i.style.fontSize=e.fontSize,i.style.fontWeight=e.fontWeight,i.style.fontFamily=e.fontFamily,i.style.color=e.color,i.style.backgroundColor="transparent",i.style.border="2px solid #3b82f6",i.style.borderRadius="4px",i.style.padding="2px 6px",i.style.margin="0",i.style.outline="none",i.style.width="auto",i.style.minWidth="120px",i.style.maxWidth="200px",i.style.flexShrink="0";const s=document.createElement("button");s.className="symbol-save-btn",s.innerHTML="✓",s.title="Save symbol",s.style.width="28px",s.style.height="28px",s.style.border="none",s.style.borderRadius="4px",s.style.backgroundColor="#059669",s.style.color="white",s.style.cursor="pointer",s.style.fontSize="12px",s.style.display="inline-flex",s.style.alignItems="center",s.style.justifyContent="center",s.style.flexShrink="0",n.appendChild(i),n.appendChild(s),t.style.display="none",t.parentNode.insertBefore(n,t.nextSibling),this.elements.symbolInput=i,this.elements.saveBtn=s,this.elements.editContainer=n,i.focus(),i.select(),i.addEventListener("keydown",this.handleKeydown),i.addEventListener("input",this.handleInput),i.addEventListener("blur",this.handleBlur),document.addEventListener("click",this.handleClickOutside),s.addEventListener("click",(t=>{t.stopPropagation(),this.saveSymbol()}))}async saveSymbol(){if(this.isValidating)return;const t=this.elements.symbolInput.value.trim(),e=await this.validateSymbol(t);if(!e.isValid)return this.showError(e.message),void setTimeout((()=>{this.elements.symbolInput&&(this.elements.symbolInput.value=this.originalSymbol,this.clearError(),this.cancelEditing())}),2e3);this.setLoadingState(!0);try{const n=await this.options.onSymbolChange(t,this.originalSymbol,e.data);if(n&&n.success)this.finishEditing(t),this.showSuccess("Symbol updated successfully");else{const t=n?.message||"Failed to update symbol";this.showError(t)}}catch(t){console.error("[SymbolEditor] Error changing symbol:",t),this.showError("Error updating symbol")}finally{this.setLoadingState(!1)}}cancelEditing(){this.options.debug&&console.log("[SymbolEditor] Cancelling edit mode"),this.finishEditing(this.originalSymbol)}finishEditing(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.isEditing=!1;const e=t||this.originalSymbol;this.elements.symbolDisplay.textContent=e,this.elements.symbolDisplay.dataset.originalSymbol=e,this.elements.symbolDisplay.style.display="",this.elements.editContainer&&(this.elements.editContainer.remove(),this.elements.editContainer=null),this.elements.symbolInput=null,this.elements.saveBtn=null,document.removeEventListener("click",this.handleClickOutside)}handleKeydown(t){"Enter"===t.key?(t.preventDefault(),this.saveSymbol()):"Escape"===t.key&&(t.preventDefault(),this.cancelEditing())}handleInput(t){if(this.options.autoUppercase){const e=t.target,n=e.selectionStart,i=e.selectionEnd;e.value=e.value.toUpperCase(),e.setSelectionRange(n,i)}this.clearError()}handleBlur(t){t.relatedTarget&&t.relatedTarget===this.elements.saveBtn||setTimeout((()=>{this.isEditing&&this.cancelEditing()}),150)}handleClickOutside(t){if(!this.isEditing)return;this.elements.symbolInput?.contains(t.target)||this.elements.saveBtn?.contains(t.target)||this.cancelEditing()}async validateSymbol(t){if("live"!==this.widget.connectionQuality)return{isValid:!1,message:"Not connected to data service"};if(!t||0===t.trim().length)return{isValid:!1,message:"Symbol cannot be empty"};const e=t.trim().toUpperCase();try{if("optionsl1"==this.symbolType){const t=await this.apiService.quoteOptionl1(e);return t[0]&&(t[0].error||1==t[0].not_found)?1==t[0].not_found?{isValid:!1,message:"Symbol not found"}:{isValid:!1,message:t[0].error}:{isValid:!0,data:t[0]}}if("quotel1"==this.symbolType||"nightsession"==this.symbolType){const t=await this.apiService.quotel1(e);return t&&t.message?t.message.includes("no data")?{isValid:!1,message:"Symbol not found"}:{isValid:!1,message:t.message}:{isValid:!0,data:t.data[0]}}if("nightsession"==this.symbolType){const t=await this.apiService.quoteBlueOcean(e);return t[0]&&1==t[0].not_found?{isValid:!1,message:"Symbol not found"}:t[0]&&0==t[0].not_found?{isValid:!0,data:t[0]}:{isValid:!1,message:t[0].error}}}catch(t){return console.warn("[SymbolEditor] API validation failed, falling back to basic validation:",t),this.defaultValidator(e)}return this.defaultValidator(e)}defaultValidator(t){return t&&0!==t.length?t.length>this.options.maxLength?{isValid:!1,message:`Symbol too long (max ${this.options.maxLength} chars)`}:{isValid:!0,data:null}:{isValid:!1,message:"Symbol cannot be empty"}}setLoadingState(t){this.isValidating=t,this.elements.saveBtn&&(t?(this.elements.saveBtn.innerHTML='<div class="loading-spinner"></div>',this.elements.saveBtn.disabled=!0):(this.elements.saveBtn.innerHTML="✓",this.elements.saveBtn.disabled=!1)),this.elements.symbolInput&&(this.elements.symbolInput.disabled=t)}showError(t){if(this.elements.symbolInput){this.elements.symbolInput.style.borderColor="#dc2626",this.elements.symbolInput.style.boxShadow="0 0 0 3px rgba(220, 38, 38, 0.1)",this.removeErrorMessage();const e=document.createElement("div");e.className="symbol-error-message",e.textContent=t,e.style.cssText="\n color: #dc2626;\n font-size: 12px;\n margin-bottom: 2px;\n position: absolute;\n background: white;\n z-index: 1000;\n transform: translateY(-100%);\n top: -4px;\n left: 0; // Align with input box\n ";const n=this.elements.editContainer;n&&(n.style.position="relative",n.appendChild(e)),this.elements.errorMessage=e,this.elements.symbolInput.focus()}}removeErrorMessage(){this.elements.errorMessage&&(this.elements.errorMessage.remove(),this.elements.errorMessage=null)}clearError(){this.elements.symbolInput&&(this.elements.symbolInput.style.borderColor="#3b82f6",this.elements.symbolInput.style.boxShadow="0 0 0 3px rgba(59, 130, 246, 0.1)",this.elements.symbolInput.title=""),this.removeErrorMessage()}showSuccess(t){this.options.debug&&console.log("[SymbolEditor] Success:",t)}updateSymbol(t){const e=this.options.autoUppercase?t.toUpperCase():t;this.elements.symbolDisplay.textContent=e,this.elements.symbolDisplay.dataset.originalSymbol=e,this.options.debug&&console.log("[SymbolEditor] Symbol updated externally:",e)}destroy(){this.finishEditing(),this.elements.symbolDisplay?.removeEventListener("dblclick",this.startEditing)}addStyles(){if(document.querySelector("#symbol-editor-styles"))return;const t=document.createElement("style");t.id="symbol-editor-styles",t.textContent='\n .editable-symbol {\n cursor: pointer;\n transition: all 0.2s ease;\n position: relative;\n }\n\n .editable-symbol:hover {\n opacity: 0.8;\n transform: scale(1.02);\n }\n\n .editable-symbol:hover::after {\n content: "✎";\n position: absolute;\n top: -8px;\n right: -8px;\n background: #3b82f6;\n color: white;\n font-size: 10px;\n padding: 2px 4px;\n border-radius: 4px;\n opacity: 0.8;\n pointer-events: none;\n }\n\n .symbol-input-mode {\n text-transform: uppercase;\n }\n\n .symbol-save-btn:hover {\n background-color: #047857 !important;\n transform: scale(1.05);\n }\n\n .symbol-save-btn:disabled {\n background-color: #9ca3af !important;\n cursor: not-allowed !important;\n transform: none !important;\n }\n\n .loading-spinner {\n width: 12px;\n height: 12px;\n border: 2px solid rgba(255, 255, 255, 0.3);\n border-top-color: white;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n }\n\n @keyframes spin {\n to { transform: rotate(360deg); }\n }\n ',document.head.appendChild(t)}}const o='\n /* ========================================\n ⚠️ DEPRECATED - Use BaseStyles.js instead\n FONT SIZE SYSTEM - CSS Variables\n Adjust --mdas-base-font-size to scale all fonts\n ======================================== */\n :root {\n /* Base font size - change this to scale everything */\n --mdas-base-font-size: 14px;\n\n /* Relative font sizes (in em, scales with base) */\n --mdas-company-name-size: 1.43em; /* 20px at base 14px */\n --mdas-symbol-size: 1.79em; /* 25px at base 14px */\n --mdas-price-size: 2.29em; /* 32px at base 14px */\n --mdas-price-change-size: 1.14em; /* 16px at base 14px */\n --mdas-section-title-size: 1em; /* 14px at base 14px */\n --mdas-data-label-size: 0.93em; /* 13px at base 14px */\n --mdas-data-value-size: 1em; /* 14px at base 14px */\n --mdas-bid-ask-size: 1.07em; /* 15px at base 14px */\n --mdas-small-text-size: 0.86em; /* 12px at base 14px */\n --mdas-badge-size: 0.86em; /* 12px at base 14px */\n --mdas-loading-text-size: 1.14em; /* 16px at base 14px */\n --mdas-no-data-title-size: 1.14em; /* 16px at base 14px */\n --mdas-edit-icon-size: 0.71em; /* 10px at base 14px */\n }\n\n /* Apply base font size to widgets */\n .widget {\n font-size: var(--mdas-base-font-size);\n }\n\n /* ========================================\n OPTIONAL CARD STYLING\n Add \'widget-styled\' class for card design\n ======================================== */\n .widget-styled {\n background: white;\n border-radius: 12px;\n padding: 24px;\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);\n border: 1px solid #e5e7eb;\n }\n\n /* Base widget styles */\n .widget-loading-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(255, 255, 255, 0.95);\n backdrop-filter: blur(2px);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10;\n border-radius: 12px;\n }\n\n .widget-loading-overlay.hidden {\n display: none;\n }\n\n .widget {\n font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, sans-serif;\n width: 100%;\n max-width: 1400px;\n }\n\n /* HEADER STYLES */\n\n .widget-header {\n display: flex;\n justify-content: space-between;\n align-items: flex-start;\n margin-bottom: 20px;\n gap: 16px;\n }\n\n .symbol-section {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .night-company-name {\n font-size: var(--mdas-company-name-size);\n font-weight: 500;\n color: #111827;\n cursor: pointer;\n transition: all 0.2s ease;\n position: relative;\n }\n\n .symbol {\n font-size: var(--mdas-symbol-size);\n font-weight: 700;\n color: #111827;\n cursor: pointer;\n transition: all 0.2s ease;\n position: relative;\n }\n\n .symbol:hover {\n opacity: 0.8;\n transform: scale(1.02);\n }\n\n .symbol:hover::after {\n content: "✎";\n position: absolute;\n top: -8px;\n right: -8px;\n background: #3b82f6;\n color: white;\n font-size: var(--mdas-edit-icon-size);\n padding: 2px 4px;\n border-radius: 4px;\n opacity: 0.8;\n }\n\n .data-type {\n background:rgb(214, 228, 250);\n padding: 2px 8px;\n border-radius: 6px;\n font-size: var(--mdas-badge-size);\n font-weight: 500;\n color: #3b82f6;\n }\n\n .price-section {\n text-align: right;\n }\n\n .current-price {\n font-size: var(--mdas-price-size);\n font-weight: 700;\n color: #111827;\n line-height: 1;\n }\n\n .price-change {\n font-size: var(--mdas-price-change-size);\n font-weight: 600;\n margin-top: 4px;\n display: flex;\n align-items: center;\n justify-content: flex-end;\n gap: 4px;\n }\n\n .price-change.positive { \n color: #10b981; \n }\n\n .price-change.negative { \n color: #ef4444; \n }\n\n .price-change.neutral { \n color: #6b7280; \n }\n\n .market-data-widget .price-change.positive::before,\n .night-session-widget .price-change.positive::before,\n .options-widget .price-change.positive::before{\n content: "↗";\n }\n\n .market-data-widget .price-change.negative::before,\n .night-session-widget .price-change.negative::before,\n .options-widget .price-change.negative::before {\n content: "↘";\n }\n\n /* BODY SECTION STYLES */\n\n .data-grid {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 32px;\n margin-bottom: 24px;\n }\n\n .data-section {\n display: flex;\n flex-direction: column;\n gap: 16px;\n }\n\n .section-title {\n font-size: var(--mdas-section-title-size);\n font-weight: 600;\n color: #6b7280;\n margin: 0;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n border-bottom: 1px solid #e5e7eb;\n padding-bottom: 8px;\n }\n\n .data-row {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 16px;\n }\n\n .data-item {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .price-metadata,\n .data-label {\n font-size: var(--mdas-data-label-size);\n color: #6b7280;\n font-weight: 500;\n }\n\n .data-value {\n font-size: var(--mdas-data-value-size);\n font-weight: 600;\n color: #111827;\n text-align: right;\n flex-shrink: 0;\n }\n\n\n /* Footer */\n .widget-footer {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding-top: 16px;\n border-top: 1px solid #e5e7eb;\n font-size: var(--mdas-small-text-size);\n color: #9ca3af;\n }\n \n\n /* LOADING STYLES */\n\n\n .loading-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 16px;\n }\n\n .loading-spinner {\n width: 40px;\n height: 40px;\n border: 4px solid #e5e7eb;\n border-top-color: #3b82f6;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n }\n\n .loading-text {\n color: #6b7280;\n font-size: var(--mdas-loading-text-size);\n font-weight: 500;\n }\n\n @keyframes spin {\n to { transform: rotate(360deg); }\n }\n\n .widget-error {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n background: #fef2f2;\n border: 1px solid #fecaca;\n border-radius: 8px;\n padding: 16px;\n color: #dc2626;\n font-size: var(--mdas-data-value-size);\n font-weight: 600;\n text-align: center;\n z-index: 10;\n max-width: 80%;\n }\n\n /* Price change colors */\n .positive {\n color: #059669;\n }\n\n .negative {\n color: #dc2626;\n }\n\n \n\n /* No data state */\n .no-data-state {\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 160px;\n margin: 16px 0;\n background: #f9fafb;\n border: 1px solid #e5e7eb;\n border-radius: 12px;\n padding: 24px 16px;\n width: 100%;\n box-sizing: border-box;\n overflow: hidden;\n }\n\n .no-data-content {\n text-align: center;\n max-width: 280px;\n width: 100%;\n word-wrap: break-word;\n overflow-wrap: break-word;\n }\n\n .no-data-icon {\n margin-bottom: 16px;\n display: flex;\n justify-content: center;\n }\n\n .no-data-icon svg {\n opacity: 0.6;\n }\n\n .no-data-title {\n font-size: var(--mdas-no-data-title-size);\n font-weight: 600;\n color: #6b7280;\n margin: 0 0 8px 0;\n }\n\n .no-data-description {\n font-size: var(--mdas-data-value-size);\n color: #9ca3af;\n margin: 0 0 12px 0;\n line-height: 1.4;\n }\n\n .no-data-description strong {\n color: #6b7280;\n font-weight: 600;\n }\n\n .no-data-guidance {\n font-size: var(--mdas-small-text-size);\n color: #9ca3af;\n margin: 0;\n font-style: italic;\n }\n\n /* Error Access State */\n .no-data-state.error-access {\n border: 1px solid #fecaca;\n background:rgb(255, 255, 255);\n \n }\n\n .no-data-title.error {\n color: #ef4444;\n }\n\n .no-data-icon.error svg {\n stroke: #ef4444;\n }\n\n .no-data-icon.error svg circle[fill] {\n fill: #ef4444;\n }\n',a=`\n ${o}\n\n /* Reset and base styles for widget */\n\n .night-session-widget {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n line-height: 1.5;\n max-width: 800px;\n position: relative;\n }\n\n /* STANDARDIZED HEADER LAYOUT */\n\n\n .symbol-section {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .night-session-widget .symbol {\n font-size: var(--mdas-symbol-size);\n font-weight: 700;\n color: #111827;\n cursor: pointer;\n transition: all 0.2s ease;\n position: relative;\n }\n\n .night-session-widget .symbol:hover {\n opacity: 0.8;\n transform: scale(1.02);\n }\n\n .night-session-widget .symbol:hover::after {\n content: "✎";\n position: absolute;\n top: -8px;\n right: -8px;\n background: #3b82f6;\n color: white;\n font-size: var(--mdas-edit-icon-size);\n padding: 2px 4px;\n border-radius: 4px;\n opacity: 0.8;\n }\n\n .company-info {\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: var(--mdas-section-title-size);\n color: #6b7280;\n }\n\n .market-name {\n font-weight: 600;\n text-transform: uppercase;\n }\n\n /* Company and market info styling */\n .company-market-info {\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: var(--mdas-small-text-size);\n color: #6b7280;\n margin-bottom: 4px;\n }\n\n .company-market-info .market-name {\n font-weight: 600;\n }\n\n .company-market-info .market-name::before {\n content: '|';\n margin-right: 8px;\n color: #9ca3af;\n }\n\n .company-market-info .market-mic {\n font-weight: 600;\n }\n\n .company-market-info .market-mic::before {\n content: '•';\n margin-right: 8px;\n }\n\n /* Price metadata (source and last update) */\n .price-metadata {\n margin-top: 8px;\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n \n\n /* STANDARDIZED GRID LAYOUT */\n .data-grid {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n gap: 24px;\n margin-top: 24px;\n }\n\n .data-section {\n display: flex;\n flex-direction: column;\n gap: 12px;\n }\n\n .night-session-widget .section-title {\n font-size: var(--mdas-small-text-size);\n font-weight: 600;\n color: #6b7280;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n border-bottom: 1px solid #e5e7eb;\n padding-bottom: 8px;\n }\n\n .night-session-widget .data-row {\n display: flex;\n justify-content: space-between;\n align-items: center;\n min-height: 20px;\n }\n\n\n\n .night-session-widget .data-value {\n font-size: var(--mdas-data-value-size);\n font-weight: 600;\n color: #111827;\n text-align: right;\n }\n\n /* SPECIAL FORMATTING FOR DIFFERENT DATA TYPES */\n .night-session-widget .bid-ask-value {\n font-size: var(--mdas-bid-ask-size);\n font-weight: 700;\n }\n\n .night-session-widget .size-info {\n font-size: var(--mdas-small-text-size);\n color: #6b7280;\n margin-left: 4px;\n }\n\n /* Footer */\n .night-session-widget .widget-footer {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-top: 24px;\n padding-top: 16px;\n border-top: 1px solid #e5e7eb;\n font-size: var(--mdas-small-text-size);\n color: #9ca3af;\n grid-column: 1 / -1;\n }\n\n /* Loading Overlay */\n .widget-loading-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(255, 255, 255, 0.95);\n backdrop-filter: blur(2px);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10;\n border-radius: 12px;\n }\n\n .widget-loading-overlay.hidden {\n display: none;\n }\n\n .loading-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 12px;\n }\n\n .loading-spinner {\n width: 32px;\n height: 32px;\n border: 3px solid #f3f4f6;\n border-top-color: #3b82f6;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n }\n\n .night-session-widget .loading-text {\n color: #6b7280;\n font-size: var(--mdas-data-value-size);\n font-weight: 500;\n }\n\n @keyframes spin {\n to { transform: rotate(360deg); }\n }\n\n /* Widget Error Styles */\n .night-session-widget .widget-error {\n background: #fef2f2;\n color: #9ca3af;\n padding: 12px;\n border-radius: 8px;\n border: 1px solid #fecaca;\n margin-top: 16px;\n font-size: var(--mdas-data-value-size);\n font-weight: 500;\n }\n\n /* No Data State */\n .night-session-widget .no-data-state {\n padding: 24px;\n text-align: center;\n color: #6b7280;\n grid-column: 1 / -1;\n }\n\n .night-session-widget .no-data-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 12px;\n }\n\n .night-session-widget .no-data-icon {\n font-size: 3.43em;\n opacity: 0.5;\n }\n\n .night-session-widget .no-data-title {\n font-size: 1.29em;\n font-weight: 600;\n color: #374151;\n }\n\n .night-session-widget .no-data-message {\n font-size: var(--mdas-data-value-size);\n max-width: 300px;\n line-height: 1.5;\n }\n\n .night-session-widget .no-data-suggestion {\n font-size: var(--mdas-small-text-size);\n color: #9ca3af;\n max-width: 350px;\n line-height: 1.4;\n }\n\n /* Dimmed state for no data */\n .widget-header.dimmed,\n .price-section.dimmed {\n opacity: 0.6;\n }\n\n /* Responsive Design */\n @media (max-width: 768px) {\n :root {\n --mdas-base-font-size: 13px; /* Slightly smaller on tablets */\n }\n\n .widget-styled {\n padding: 16px;\n }\n\n .widget-header {\n grid-template-columns: 1fr;\n gap: 12px;\n text-align: center;\n }\n\n .symbol-section {\n align-items: center;\n }\n\n .price-section {\n text-align: center;\n }\n\n .data-grid {\n grid-template-columns: 1fr;\n gap: 16px;\n }\n\n .widget-footer {\n flex-direction: column;\n gap: 8px;\n text-align: center;\n }\n }\n\n @media (max-width: 480px) {\n :root {\n --mdas-base-font-size: 12px; /* Smaller on mobile */\n }\n }\n\n \n`,r=`\n ${o}\n\n /* Reset and base styles for widget */\n\n .market-data-widget {\n color: #333;\n margin: 0 auto;\n position: relative;\n overflow: hidden;\n }\n\n /* MARKET DATA HEADER STYLES */\n\n\n .market-data-widget .company-info {\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: var(--mdas-section-title-size);\n color: #6b7280;\n }\n\n .company-name {\n position: relative;\n cursor: help;\n transition: all 0.2s ease;\n }\n\n .company-name:hover {\n border-bottom-color: #3b82f6;\n color: #3b82f6;\n }\n\n\n /* STANDARDIZED GRID LAYOUT */\n \n .data-section {\n display: flex;\n flex-direction: column;\n gap: 12px;\n min-width: 0;\n overflow: hidden;\n }\n\n .market-data-widget .section-title {\n font-size: var(--mdas-small-text-size);\n font-weight: 600;\n color: #6b7280;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n padding-bottom: 8px;\n }\n\n\n\n /* SPECIAL FORMATTING FOR DIFFERENT DATA TYPES */\n .market-data-widget .bid-ask-value {\n font-size: var(--mdas-bid-ask-size);\n font-weight: 700;\n }\n\n .market-data-widget .size-info {\n font-size: var(--mdas-small-text-size);\n color: #6b7280;\n margin-left: 4px;\n }\n\n .market-data-widget .range-value {\n font-size: var(--mdas-data-label-size);\n }\n\n \n\n /* Tooltip Styles */\n .company-name::after {\n content: attr(data-tooltip);\n position: absolute;\n bottom: 100%;\n left: 50%;\n transform: translateX(-50%);\n background: #1f2937;\n color: white;\n padding: 8px 12px;\n border-radius: 6px;\n font-size: var(--mdas-small-text-size);\n font-weight: normal;\n white-space: nowrap;\n max-width: 300px;\n white-space: normal;\n line-height: 1.4;\n z-index: 1000;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n opacity: 0;\n visibility: hidden;\n transition: all 0.2s ease;\n pointer-events: none;\n margin-bottom: 5px;\n }\n\n .company-name:hover::after {\n opacity: 1;\n visibility: visible;\n }\n\n .company-name::before {\n content: '';\n position: absolute;\n bottom: 100%;\n left: 50%;\n transform: translateX(-50%);\n border: 5px solid transparent;\n border-top-color: #1f2937;\n opacity: 0;\n visibility: hidden;\n transition: all 0.2s ease;\n pointer-events: none;\n }\n\n .company-name:hover::before {\n opacity: 1;\n visibility: visible;\n }\n\n /* Loading Overlay */\n .widget-loading-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(255, 255, 255, 0.95);\n backdrop-filter: blur(2px);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10;\n border-radius: 12px;\n }\n\n .widget-loading-overlay.hidden {\n display: none;\n }\n\n .loading-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 12px;\n }\n\n .loading-spinner {\n width: 32px;\n height: 32px;\n border: 3px solid #f3f4f6;\n border-top-color: #3b82f6;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n }\n\n .market-data-widget .loading-text {\n color: #6b7280;\n font-size: var(--mdas-data-value-size);\n font-weight: 500;\n }\n\n @keyframes spin {\n to { transform: rotate(360deg); }\n }\n\n /* Widget Error Styles */\n .market-data-widget .widget-error {\n background: #fef2f2;\n color: #dc2626;\n padding: 12px;\n border-radius: 8px;\n border: 1px solid #fecaca;\n margin-top: 16px;\n font-size: var(--mdas-data-value-size);\n font-weight: 500;\n }\n\n /* Responsive Design */\n\n\n @media (max-width: 600px) {\n .widget-header {\n grid-template-columns: 1fr;\n gap: 12px;\n text-align: center;\n }\n\n .symbol-section {\n align-items: center;\n }\n\n .price-section {\n text-align: center;\n }\n\n .data-grid {\n grid-template-columns: 1fr;\n gap: 16px;\n }\n\n .widget-footer {\n flex-direction: column;\n gap: 8px;\n text-align: center;\n }\n }\n\n @media (max-width: 480px) {\n .company-name::after {\n left: 0;\n transform: none;\n max-width: 250px;\n }\n\n .company-name::before {\n left: 20px;\n transform: none;\n }\n }\n`,l=`\n ${o}\n\n .options-widget {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n color: #333;\n max-width: 1400px;\n width: 100%;\n margin: 0 auto;\n position: relative;\n overflow: hidden;\n }\n\n .widget-content {\n position: relative;\n z-index: 1;\n }\n\n \n .options-widget .symbol-info .symbol {\n font-size: var(--mdas-symbol-size);\n font-weight: 700;\n margin: 0 0 8px 0;\n color: #1f2937;\n }\n\n .options-widget .option-info {\n display: flex;\n align-items: center;\n gap: 8px;\n color: #6b7280;\n font-size: var(--mdas-price-change-size);\n }\n\n .options-widget .underlying-symbol {\n font-weight: 600;\n color: #6b7280;\n }\n\n .options-widget .option-details-section {\n display: flex;\n gap: 24px;\n margin-bottom: 24px;\n padding-bottom: 20px;\n border-bottom: 1px solid #e5e7eb;\n }\n\n .options-widget .option-details-section .detail-item {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .options-widget .option-details-section .detail-item label {\n font-size: var(--mdas-small-text-size);\n color: #6b7280;\n font-weight: 500;\n text-transform: uppercase;\n letter-spacing: 0.3px;\n }\n\n .options-widget .option-details-section .detail-item span {\n font-size: var(--mdas-price-change-size);\n font-weight: 600;\n color: #1f2937;\n }\n\n\n .options-widget .widget-footer {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding-top: 16px;\n border-top: 1px solid #e5e7eb;\n font-size: var(--mdas-small-text-size);\n color: #9ca3af;\n }\n\n /* Dimmed state for no-data */\n .widget-header.dimmed {\n opacity: 0.6;\n }\n\n .widget-header.dimmed .symbol {\n color: #9ca3af;\n }\n\n /* Responsive design */\n @media (max-width: 768px) {\n .widget-header {\n flex-direction: column;\n gap: 16px;\n text-align: left;\n }\n\n .price-info {\n text-align: left;\n }\n\n .data-grid {\n grid-template-columns: 1fr;\n gap: 20px;\n }\n\n .option-details-section {\n flex-wrap: wrap;\n gap: 16px;\n }\n\n .current-price {\n font-size: 32px;\n }\n\n .symbol {\n font-size: 20px !important;\n }\n }\n\n @media (max-width: 480px) {\n .widget-styled {\n padding: 12px;\n }\n\n .widget-header {\n margin-bottom: 16px;\n padding-bottom: 16px;\n }\n\n .current-price {\n font-size: 28px;\n }\n\n .data-row {\n grid-template-columns: 1fr;\n gap: 12px;\n }\n\n .option-details-section {\n flex-direction: column;\n gap: 12px;\n }\n\n .no-data-state {\n min-height: 120px;\n padding: 20px 12px;\n }\n\n .no-data-title {\n font-size: 14px;\n }\n\n .no-data-description {\n font-size: 12px;\n }\n\n .no-data-guidance {\n font-size: 11px;\n }\n }\n`;function c(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";const i=document.createElement(t);return n&&(i.className=n),e&&(i.textContent=e),i}function d(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"--";if(null==t||""===t)return n;const i=parseFloat(t);return isNaN(i)?n:i.toFixed(e)}function h(t){if(!t)return"";return String(t).replace(/[^A-Za-z0-9.\-_+ ]/g,"").substring(0,50)}function u(t){if(t)for(;t.firstChild;)t.removeChild(t.firstChild)}function g(t){if(!t||"string"!=typeof t)return{valid:!1,error:"Symbol is required",sanitized:""};const e=t.trim().toUpperCase();return 0===e.length?{valid:!1,error:"Symbol cannot be empty",sanitized:""}:e.length>10?{valid:!1,error:"Symbol too long (max 10 characters)",sanitized:""}:{valid:!0,sanitized:e}}function p(t){if(!t||"string"!=typeof t)return{valid:!1,error:"Option symbol is required",sanitized:""};const e=t.trim().toUpperCase();if(e.length<15||e.length>21)return{valid:!1,error:"Invalid option symbol length",sanitized:e};const n=e.match(/^([A-Z]{1,6})(\d{2})(0[1-9]|1[0-2])([0-2][0-9]|3[01])([CP])(\d{8})$/);if(!n)return{valid:!1,error:"Invalid option symbol format. Expected: SYMBOL+YYMMDD+C/P+STRIKE",sanitized:e};const[,i,s,o,a,r,l]=n,c=2e3+parseInt(s,10),d=parseInt(o,10),h=parseInt(a,10),u=new Date(c,d-1,h);if(u.getMonth()+1!==d||u.getDate()!==h)return{valid:!1,error:"Invalid expiration date in option symbol",sanitized:e};const g=new Date;g.setHours(0,0,0,0),u<g&&console.warn("Option symbol has expired");return{valid:!0,sanitized:e,parsed:{underlying:i,expiry:u,type:"C"===r?"call":"put",strike:parseInt(l,10)/1e3}}}function m(t){if(!t)return"ET";const[e,n,i]=t.split("-").map(Number),s=new Date(e,n-1,i),o=function(t,e){const n=new Date(t,e,1),i=1+(7-n.getDay())%7;return new Date(t,e,i+7)}(e,2),a=function(t,e){const n=new Date(t,e,1),i=1+(7-n.getDay())%7;return new Date(t,e,i)}(e,10);return s>=o&&s<a?"EDT":"EST"}function f(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{includeSeconds:n=!0,includeTimezone:i=!0,format:s="short"}=e;let o;if(t||(t=Date.now()),o=t instanceof Date?t:new Date(t),isNaN(o.getTime()))return"Invalid Date";const a=o.getUTCFullYear(),r=o.getUTCMonth(),l=o.getUTCDate(),c=o.getUTCHours(),d=o.getUTCMinutes(),h=o.getUTCSeconds(),u=function(t){const e=t.getUTCFullYear(),n=t.getUTCMonth(),i=t.getUTCDate(),s=new Date(Date.UTC(e,n,i)),o=function(t,e){const n=new Date(Date.UTC(t,e,1)),i=1+(7-n.getUTCDay())%7;return new Date(Date.UTC(t,e,i+7))}(e,2),a=function(t,e){const n=new Date(Date.UTC(t,e,1)),i=1+(7-n.getUTCDay())%7;return new Date(Date.UTC(t,e,i))}(e,10);return s>=o&&s<a}(o),g=u?-4:-5,p=new Date(Date.UTC(a,r,l,c+g,d,h)),m=p.getUTCFullYear(),f=p.getUTCMonth()+1,b=p.getUTCDate(),y=p.getUTCHours(),x=p.getUTCMinutes(),v=p.getUTCSeconds(),w=y%12||12,k=y>=12?"PM":"AM",S=x.toString().padStart(2,"0"),M=v.toString().padStart(2,"0"),C=n?`${w}:${S}:${M} ${k}`:`${w}:${S} ${k}`,_=i?u?" EDT":" EST":"";if("long"===s){return`${["January","February","March","April","May","June","July","August","September","Oct","November","December"][f-1]} ${b}, ${m}, ${C}${_}`}return`${f}/${b}/${m}, ${C}${_}`}class b extends n{constructor(t,e,n){if(super(t,e,n),!e.symbol)throw new Error("Symbol is required for MarketDataWidget");if(!e.wsManager)throw new Error("WebSocketManager is required for MarketDataWidget");this.type="marketdata";const i=g(e.symbol);if(!i.valid)throw new Error(`Invalid symbol: ${i.error}`);this.symbol=i.sanitized,this.wsManager=e.wsManager,this.debug=e.debug||!1,this.styled=void 0===e.styled||e.styled,this.data=null,this.isDestroyed=!1,this.unsubscribe=null,this.loadingTimeout=null,this.createWidgetStructure(),this.initializeSymbolEditor(),this.initialize()}createWidgetStructure(){if(this.container.innerHTML='\n <div class="market-data-widget widget">\n <div class="widget-content">\n \x3c!-- Header Section --\x3e\n <div class="widget-header">\n <div class="symbol-section">\n <h1 class="symbol editable-symbol" \n title="Double-click to edit symbol" \n data-original-symbol="">\n </h1>\n <div class="company-info">\n <span class="company-name" \n title="" \n data-tooltip="">\n </span>\n <span class="data-type">STOCK</span>\n </div>\n </div>\n <div class="price-section">\n <div class="current-price"></div>\n <div class="price-change">\n <span class="change-value"></span>\n <span class="change-percent"></span>\n </div>\n </div>\n </div>\n\n \x3c!-- Data Grid Section --\x3e\n <div class="data-grid">\n <div class="data-section">\n <div class="section-title">Quote</div>\n <div class="data-row">\n <span class="data-label">Bid</span>\n <span class="data-value bid-ask-value bid-data"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Ask</span>\n <span class="data-value bid-ask-value ask-data"></span>\n </div>\n </div>\n\n <div class="data-section">\n <div class="section-title">Trading Activity</div>\n <div class="data-row">\n <span class="data-label">Volume</span>\n <span class="data-value volume"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Average Volume</span>\n <span class="data-value avg-volume"></span>\n </div>\n </div>\n\n <div class="data-section">\n <div class="section-title">Performance</div>\n <div class="data-row">\n <span class="data-label">Previous Close</span>\n <span class="data-value prev-close"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Open</span>\n <span class="data-value open-price"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Day Range</span>\n <span class="data-value range-value day-range"></span>\n </div>\n <div class="data-row">\n <span class="data-label">52-Week Range</span>\n <span class="data-value range-value week-range"></span>\n </div>\n </div>\n\n <div class="data-section">\n <div class="section-title">Key Metrics</div>\n <div class="data-row">\n <span class="data-label">Market Cap</span>\n <span class="data-value market-cap"></span>\n </div>\n <div class="data-row">\n <span class="data-label">P/E Ratio</span>\n <span class="data-value pe-ratio"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Dividend Yield</span>\n <span class="data-value dividend-yield"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Beta</span>\n <span class="data-value beta"></span>\n </div>\n </div>\n </div>\n\n \x3c!-- Footer --\x3e\n <div class="widget-footer">\n <span class="last-update"></span>\n <span class="data-source"></span>\n </div>\n </div>\n \n \x3c!-- Loading Overlay --\x3e\n <div class="widget-loading-overlay">\n <div class="loading-content">\n <div class="loading-spinner"></div>\n <span class="loading-text">Loading market data...</span>\n </div>\n </div>\n </div>\n',this.styled){const t=this.container.querySelector(".market-data-widget");t&&t.classList.add("widget-styled")}this.addStyles()}addStyles(){if(!document.querySelector("#market-data-styles")){const t=document.createElement("style");t.id="market-data-styles",t.textContent=r,document.head.appendChild(t)}}initializeSymbolEditor(){this.symbolEditor=new s(this,{maxLength:10,placeholder:"Enter symbol...",onSymbolChange:this.handleSymbolChange.bind(this),debug:this.debug,autoUppercase:!0,symbolType:"quotel1"});const t=this.container.querySelector(".symbol");t&&(t.textContent=this.symbol,t.dataset.originalSymbol=this.symbol)}async handleSymbolChange(t){this.debug&&console.log("[MarketDataWidget] Symbol change requested:",t);const e=g(t);if(!e.valid)return this.debug&&console.log("[MarketDataWidget] Invalid symbol:",e.error),{success:!1,error:e.error};const n=e.sanitized;if(n===this.symbol)return this.debug&&console.log("[MarketDataWidget] Same symbol, no change needed"),{success:!0};try{const t=this.symbol;return this.showLoading(),this.loadingTimeout&&this.clearTimeout(this.loadingTimeout),this.loadingTimeout=this.setTimeout((()=>{this.debug&&console.log("[MarketDataWidget] Loading timeout for symbol:",n),this.hideLoading(),this.showError(`No data received for ${n}. Please try again.`)}),1e4),this.unsubscribe&&(this.debug&&console.log(`[MarketDataWidget] Unsubscribing from ${t}`),this.wsManager.sendUnsubscribe("queryl1",t),this.unsubscribe(),this.unsubscribe=null),this.symbol=n,this.debug&&console.log(`[MarketDataWidget] Subscribing to ${n}`),this.subscribeToData(),this.debug&&console.log(`[MarketDataWidget] Successfully changed symbol from ${t} to ${n}`),{success:!0}}catch(t){return console.error("[MarketDataWidget] Error changing symbol:",t),this.hideLoading(),this.showError(`Failed to load data for ${n}`),{success:!1,error:`Failed to load ${n}`}}}async initialize(){this.showLoading();!1!==await super.validateInitialSymbol("quotel1",this.symbol,(t=>{t&&t[0]&&(this.initialValidationData=t[0])}))&&this.subscribeToData()}subscribeToData(){this.unsubscribe=this.wsManager.subscribe(this.widgetId,["queryl1"],this.handleMessage.bind(this),this.symbol)}handleData(t){if(!0===t.error){this.debug&&console.log("[MarketDataWidget] Received error response:",t.message);const e=t.message||t.Message;if(e)return this.hideLoading(),void this.showError(e)}else if(t.Data&&"string"==typeof t.Data)return this.hideLoading(),void this.showError(t.Message);if(this.loadingTimeout&&(clearTimeout(this.loadingTimeout),this.loadingTimeout=null),"error"===t.type)return this.debug&&console.log("[MarketDataWidget] Received no data message:",t.message),void(this.data?(this.hideLoading(),this.debug&&console.log("[MarketDataWidget] No new data, keeping cached data visible")):this.showNoDataState({Symbol:this.symbol,NotFound:!0,message:t.message}));if("error"!==t.type){if("object"==typeof t&&t.Message){const e=t.Message.toLowerCase();if(e.includes("no data")||e.includes("not found"))return this.debug&&console.log("[MarketDataWidget] Received no data message:",t.Message),void(this.data?(this.hideLoading(),this.debug&&console.log("[MarketDataWidget] No new data, keeping cached data visible")):this.showNoDataState({Symbol:this.symbol,NotFound:!0,message:t.Message}))}if(t.Data&&t.Data.length>0){const e=t.Data.find((t=>t.Symbol===this.symbol));if(e){const t=new i(e);this.data=t,this.updateWidget(t)}else this.debug&&console.log("[MarketDataWidget] No data for symbol in response, keeping cached data"),this.hideLoading()}t._cached&&this.showConnectionQuality()}else{const e=t.message||"Server error";this.data?(this.hideLoading(),this.debug&&console.log("[MarketDataWidget] Error received but keeping cached data:",e)):this.showError(e)}}updateWidget(t){if(!this.isDestroyed)try{this.loadingTimeout&&(clearTimeout(this.loadingTimeout),this.loadingTimeout=null),this.clearError(),this.hideLoading();const e=this.container.querySelector(".widget-header");e&&e.classList.remove("dimmed");const n=this.container.querySelector(".data-grid");n&&(n.style.display="");const i=this.container.querySelector(".no-data-state");i&&i.remove();const s=this.container.querySelector(".symbol");s&&(s.textContent=t.symbol,s.dataset.originalSymbol=t.symbol);const o=this.container.querySelector(".company-name");if(o){const e=t.companyName||`${t.symbol} Inc`,n=t.companyDescription||`${t.symbol} designs, manufactures, and markets consumer electronics and software.`;o.textContent=e,o.setAttribute("title",n),o.setAttribute("data-tooltip",n)}const a=this.container.querySelector(".current-price");a&&(a.textContent=t.formatPrice());const r=t.getPriceChange(),l=this.container.querySelector(".price-change");if(l){const e=l.querySelector(".change-value"),n=l.querySelector(".change-percent");e&&(e.textContent=t.formatPriceChange()),n&&(n.textContent=` (${t.formatPriceChangePercent()})`),l.classList.remove("positive","negative","neutral"),r>0?l.classList.add("positive"):r<0?l.classList.add("negative"):l.classList.add("neutral")}const h=this.container.querySelector(".bid-data");if(h){u(h);const e=d(t.bidPrice,2,"0.00"),n=t.bidSize||0;h.appendChild(document.createTextNode(`$${e}`));const i=c("span",`× ${n}`,"size-info");h.appendChild(i)}const g=this.container.querySelector(".ask-data");if(g){u(g);const e=d(t.askPrice,2,"0.00"),n=t.askSize||0;g.appendChild(document.createTextNode(`$${e}`));const i=c("span",`× ${n}`,"size-info");g.appendChild(i)}const p=this.container.querySelector(".volume");p&&(p.textContent=t.formatVolume());const m=this.container.querySelector(".avg-volume");m&&(m.textContent=t.formatAverageVolume());const b=this.container.querySelector(".prev-close");b&&(b.textContent=`$${t.previousClose?.toFixed(2)||"0.00"}`);const y=this.container.querySelector(".open-price");y&&(y.textContent=`$${t.openPrice?.toFixed(2)||"0.00"}`);const x=this.container.querySelector(".day-range");x&&(x.textContent=t.formatDayRange());const v=this.container.querySelector(".week-range");v&&(v.textContent=t.format52WeekRange());const w=this.container.querySelector(".market-cap");w&&(w.textContent=t.formatMarketCap());const k=this.container.querySelector(".pe-ratio");k&&(k.textContent=t.peRatio?.toFixed(2)||"N/A");const S=this.container.querySelector(".dividend-yield");S&&(S.textContent=t.dividendYield?`${t.dividendYield.toFixed(2)}%`:"N/A");const M=this.container.querySelector(".beta");M&&(M.textContent=t.beta?.toFixed(2)||"N/A");const C=f(t.quoteTime),_=this.container.querySelector(".last-update");_&&(_.textContent=`Last update: ${C}`);const T=this.container.querySelector(".data-source");T&&(T.textContent=`Source: ${t.getDataSource()}`)}catch(t){console.error("Error updating widget:",t),this.showError("Error updating data")}}showLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.remove("hidden")}hideLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.add("hidden")}showError(t){this.hideLoading(),this.clearError();const e=document.createElement("div");e.className="widget-error",e.textContent=`Error: ${t}`,e.style.cssText="\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n padding: 15px 20px;\n background: #fee;\n border: 1px solid #f5c6cb;\n border-radius: 6px;\n color: #721c24;\n text-align: center;\n font-size: 14px;\n z-index: 100;\n ",this.container.appendChild(e)}clearError(){const t=this.container.querySelector(".widget-error"),e=this.container.querySelector(".widget-error-container");t&&t.remove(),e&&e.remove()}destroy(){this.isDestroyed=!0,this.loadingTimeout&&(this.clearTimeout(this.loadingTimeout),this.loadingTimeout=null),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null),this.symbolEditor&&(this.symbolEditor.destroy(),this.symbolEditor=null),super.destroy()}}class y{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.symbol=t.Symbol||"",this.marketName=t.MarketName||("bruce"===t.Source?.toLowerCase()?"Bruce":"Blue Ocean"),this.marketDesc=null!==t.MarketDesc?t.MarketDesc||"":null,this.countryCode=null!==t.CountryCode?t.CountryCode||"":null,this.volume=null!==t.Volume?t.Volume||0:null,this.askPrice=null!==t.AskPx?t.AskPx||0:null,this.askSize=null!==t.AskSz?t.AskSz||0:null,this.bidPrice=null!==t.BidPx?t.BidPx||0:null,this.bidSize=null!==t.BidSz?t.BidSz||0:null,this.lastPrice=null!==t.LastPx?t.LastPx||0:null,this.quoteTime=null!==t.QuoteTime?t.QuoteTime:null,this.activityTimestamp=null!==t.ActivityTimestamp?t.ActivityTimestamp||"":null,this.tradeSize=null!==t.TradeSz?t.TradeSz||0:null,this.bidExchange=null!==t.BidExch?t.BidExch||"":null,this.askExchange=null!==t.AskExch?t.AskExch||"":null,this.notFound=t.NotFound||!1,this.source=t.Source||"",this.accuAmount=null!==t.AccuAmmount?t.AccuAmmount||0:null,this.change=null!==t.Change?t.Change||0:null,this.changePercent=null!==t.ChangePercent?t.ChangePercent||0:null,this.closingPrice=null!==t.ClosingPx?t.ClosingPx:null!==t.PreviousClose?t.PreviousClose:null,this.highPrice=null!==t.HighPx?t.HighPx||0:null,this.lowPrice=null!==t.LowPx?t.LowPx||0:null,this.openPrice=null!==t.OpenPx?t.OpenPx||0:null,this.tradePrice=null!==t.TradePx?t.TradePx||0:null,this.tradeRegionName=null!==t.TradeRegionName?t.TradeRegionName||"":null,this.companyName=t.comp_name||t.CompanyName||"",this.exchangeName=t.market_name||t.Exchange||"",this.mic=t.mic||""}formatPrice(){return`$${this.lastPrice.toFixed(2)}`}formatBidAsk(){return`$${this.bidPrice.toFixed(2)} × ${this.bidSize} / $${this.askPrice.toFixed(2)} × ${this.askSize}`}formatVolume(){return this.volume.toLocaleString()}formatPriceChange(){if(null===this.change||void 0===this.change)return"--";return`${this.change>0?"+":""}${this.change.toFixed(2)}`}formatPriceChangePercent(){if(null===this.changePercent||void 0===this.changePercent)return"--";return`${this.changePercent>0?"+":""}${this.getPriceChangePercent().toFixed(2)}%`}getDataSource(){return"blueocean-d"===this.source.toLowerCase()||"bruce-d"===this.source.toLowerCase()?"bruce-d"===this.source.toLowerCase()?"Bruce 20 mins delayed":"BlueOcean 20 mins delayed":this.source.toLowerCase().includes("bruce")||this.source.toLowerCase().includes("blueocean")||this.source.toLowerCase().includes("onbbo")?"bruce"===this.source.toLowerCase()?"Bruce Real-time":"onbbo"===this.source.toLowerCase()?"ONBBO Real-time":"BlueOcean Real-time":null!==this.source&&""!==this.source?this.source:"MDAS"}getPriceChangePercent(){return null===this.changePercent||void 0===this.changePercent?0:Math.abs(this.changePercent)>1?this.changePercent:100*this.changePercent}}class x extends n{constructor(t,e,n){if(super(t,e,n),!e.symbol)throw new Error("Symbol is required for NightSessionWidget");if(!e.wsManager)throw new Error("WebSocketManager is required for NightSessionWidget");if(!e.source||"blueocean"!==e.source.toLowerCase()&&"bruce"!==e.source.toLowerCase()&&"onbbo"!==e.source.toLowerCase())throw new Error('Source should be either "blueocean", "bruce", or "onbbo"');this.type="nightsession "+e.source;const i=g(e.symbol);if(!i.valid)throw new Error(`Invalid symbol: ${i.error}`);this.symbol=i.sanitized,this.source=e.source||"blueocean",this.wsManager=e.wsManager,this.debug=e.debug||!1,this.styled=void 0===e.styled||e.styled,this.data=null,this.isDestroyed=!1,this.unsubscribe=null,this.symbolEditor=null,this.loadingTimeout=null,this.companyName="",this.exchangeName="",this.mic="",this.createWidgetStructure(),this.initialize()}createWidgetStructure(){if(this.container.innerHTML='\n <div class="night-session-widget widget">\n <div class="widget-content">\n \x3c!-- Header Section --\x3e\n <div class="widget-header">\n <div class="symbol-section">\n <div class="company-market-info">\n <span class="night-company-name"></span>\n <span class="market-name"></span>\n </div>\n <h1 class="symbol editable-symbol"\n title="Double-click to edit symbol"\n data-original-symbol="">\n </h1>\n\n </div>\n <div class="price-section">\n <div class="current-price"></div>\n <div class="price-change">\n <span class="change-value"></span>\n <span class="change-percent"></span>\n </div>\n <div class="price-metadata">\n <div class="last-update"></div>\n <div class="data-source"></div>\n </div>\n </div>\n </div>\n\n \x3c!-- Data Grid Section --\x3e\n <div class="data-grid">\n <div class="data-section">\n <div class="section-title">Quote</div>\n <div class="data-row">\n <span class="data-label">Bid</span>\n <span class="data-value bid-ask-value">\n <span class="bid-price"></span>\n <span class="size-info bid-size"></span>\n </span>\n </div>\n <div class="data-row">\n <span class="data-label">Ask</span>\n <span class="data-value bid-ask-value">\n <span class="ask-price"></span>\n <span class="size-info ask-size"></span>\n </span>\n </div>\n </div>\n\n <div class="data-section">\n <div class="section-title">Trading Activity</div>\n <div class="data-row">\n <span class="data-label">Volume</span>\n <span class="data-value volume"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Accumulated Amount</span>\n <span class="data-value accu-amount"></span>\n </div>\n </div>\n\n <div class="data-section">\n <div class="section-title">Performance</div>\n <div class="data-row">\n <span class="data-label">Previous Close</span>\n <span class="data-value previous-close"></span>\n </div>\n <div class="data-row at-close-row">\n <span class="data-label">At close</span>\n <span class="data-value at-close-time"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Open</span>\n <span class="data-value open-price"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Day Range</span>\n <span class="data-value range-value day-range"></span>\n </div>\n </div>\n </div>\n </div>\n\n \x3c!-- Loading Overlay --\x3e\n <div class="widget-loading-overlay">\n <div class="loading-content">\n <div class="loading-spinner"></div>\n <span class="loading-text">Loading night session data...</span>\n </div>\n </div>\n </div>\n',this.styled){const t=this.container.querySelector(".night-session-widget");t&&t.classList.add("widget-styled")}this.addStyles(),this.setupSymbolEditor()}addStyles(){if(!document.querySelector("#night-session-styles")){const t=document.createElement("style");t.id="night-session-styles",t.textContent=a,document.head.appendChild(t)}}setupSymbolEditor(){this.symbolEditor=new s(this,{maxLength:10,placeholder:"Enter symbol...",onSymbolChange:this.handleSymbolChange.bind(this),debug:this.debug,autoUppercase:!0,cancelOnBlur:!1,symbolType:"nightsession"})}async handleSymbolChange(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.debug&&(console.log("[NightSessionWidget] Symbol change requested:",t),console.log("[NightSessionWidget] Validation data:",n));const i=g(t);if(!i.valid)return this.debug&&console.log("[NightSessionWidget] Invalid symbol:",i.error),{success:!1,error:i.error};const s=i.sanitized;if(n&&(this.companyName=n.comp_name||"",this.exchangeName=n.market_name||"",this.mic=n.mic||"",this.debug&&console.log("[NightSessionWidget] Extracted company info:",{companyName:this.companyName,exchangeName:this.exchangeName},n)),s===this.symbol)return this.debug&&console.log("[NightSessionWidget] Same symbol, no change needed"),{success:!0};try{const t=this.symbol;return this.showLoading(),this.loadingTimeout&&this.clearTimeout(this.loadingTimeout),this.loadingTimeout=this.setTimeout((()=>{this.debug&&console.log("[NightSessionWidget] Loading timeout for symbol:",s),this.hideLoading(),this.showError(`No data received for ${s}. Please try again.`)}),1e4),this.unsubscribe&&(this.debug&&console.log(`[NightSessionWidget] Unsubscribing from ${t}`),this.unsubscribe(),this.unsubscribe=null),this.symbol=s,this.debug&&console.log(`[NightSessionWidget] Subscribing to ${s}`),this.subscribeToData(),this.debug&&console.log(`[NightSessionWidget] Successfully changed symbol from ${t} to ${s}`),{success:!0}}catch(t){return console.error("[NightSessionWidget] Error changing symbol:",t),this.showError(`Failed to load data for ${s}`),{success:!1,error:`Failed to load ${s}`}}}async initialize(){this.showLoading();!1!==await super.validateInitialSymbol("quotel1",this.symbol,(t=>{t&&t[0]&&(this.companyName=t[0].comp_name||"",this.exchangeName=t[0].market_name||"",this.mic=t[0].mic||"")}))&&(this.loadingTimeout=setTimeout((()=>{this.debug&&console.log("[NightSessionWidget] Loading timeout - no data received for:",this.symbol),this.hideLoading(),this.showNoDataState({Symbol:this.symbol,NotFound:!0,message:"No data available for this symbol"})}),1e4),this.subscribeToData())}subscribeToData(){let t;t="bruce"===this.source?"querybrucel1":"onbbo"===this.source?"queryonbbol1":"queryblueoceanl1",this.unsubscribe=this.wsManager.subscribe(this.widgetId,[t],this.handleMessage.bind(this),this.symbol)}handleData(t){if(console.log("DEBUG NIGHT",t),this.loadingTimeout&&(clearTimeout(this.loadingTimeout),this.loadingTimeout=null),!0===t.error){this.debug&&console.log("[Nigh] Received error response:",t.message);const e=t.message||t.Message;if(e)return this.hideLoading(),void this.showError(e)}else if(t.Data&&"string"==typeof t.Data)return this.hideLoading(),void this.showError(t.Message);if("error"===t.type)return this.debug&&console.log("[NightSessionWidget] Received no data message:",t.message),void(this.data?(this.hideLoading(),this.debug&&console.log("[MarketDataWidget] Error received but keeping cached data:",errorMsg)):this.showError(errorMsg));if(Array.isArray(t.data)){const e=t.data.find((t=>t.Symbol===this.symbol));if(e){if(this.debug&&console.log("[NightSessionWidget] Found data for symbol:",e),!0===e.NotFound)this.data?(this.hideLoading(),this.debug&&console.log("[NightSessionWidget] No new data, keeping cached data visible")):this.showNoDataState(e);else{const t=new y(e);this.data=t,this.updateWidget(t)}return}this.data?(this.hideLoading(),this.debug&&console.log("[NightSessionWidget] No matching data in response, keeping cached data")):this.showNoDataState({Symbol:this.symbol,NotFound:!0})}t._cached}updateWidget(t){if(!this.isDestroyed)try{this.hideLoading(),this.clearError();const e=this.container.querySelector(".widget-header");e&&e.classList.remove("dimmed");const n=this.container.querySelector(".price-section");n&&n.classList.remove("dimmed");const i=this.container.querySelector(".data-grid");i&&(i.style.display="grid");const s=this.container.querySelector(".no-data-state");s&&s.remove();const o=this.container.querySelector(".symbol");o&&(o.textContent=t.symbol);const a=this.container.querySelector(".night-company-name");a&&(a.textContent=this.companyName||t.companyName||"");const r=this.container.querySelector(".market-name");r&&(r.textContent=this.exchangeName||t.exchangeName||"");const l=this.container.querySelector(".current-price");l&&(l.textContent=null!==t.lastPrice?t.formatPrice():"--");const c=t.change,d=this.container.querySelector(".price-change");if(d){const e=d.querySelector(".change-value"),n=d.querySelector(".change-percent");e&&(e.textContent=null!==c&&0!==c?c:"--"),n&&(0!==t.changePercent?n.textContent=` (${t.getPriceChangePercent().toFixed(2)}%)`:n.textContent=" (0.00%)"),d.classList.remove("positive","negative","neutral"),c>0?d.classList.add("positive"):c<0?d.classList.add("negative"):d.classList.add("neutral")}const h=this.container.querySelector(".bid-price");h&&(h.textContent=null!==t.bidPrice?`$${t.bidPrice.toFixed(2)} `:"-- ×");const u=this.container.querySelector(".bid-size");u&&(u.textContent=null!==t.bidSize?`× ${t.bidSize}`:"--");const g=this.container.querySelector(".ask-price");g&&(g.textContent=null!==t.askPrice?`$${t.askPrice.toFixed(2)} `:"-- ×");const p=this.container.querySelector(".ask-size");p&&(p.textContent=null!==t.askSize?`× ${t.askSize}`:"--");const m=this.container.querySelector(".volume");m&&(m.textContent=null!==t.volume?t.formatVolume():"--");const b=this.container.querySelector(".accu-amount");b&&(b.textContent=null!==t.accuAmount?`$${t.accuAmount.toLocaleString()}`:"--");const y=this.container.querySelector(".open-price");y&&(y.textContent=null!==t.openPrice?`$${t.openPrice.toFixed(2)}`:"--");const x=this.container.querySelector(".previous-close");x&&(x.textContent=null!==t.closingPrice?`$${t.closingPrice.toFixed(2)}`:"--");const v=this.container.querySelector(".at-close-time");if(v){const e=t.quoteTime?f(new Date(t.quoteTime)):"--";v.textContent=e}const w=this.container.querySelector(".day-range");w&&(null!==t.highPrice&&null!==t.lowPrice?w.textContent=`$${t.lowPrice.toFixed(2)} - $${t.highPrice.toFixed(2)}`:w.textContent="--");const k=this.container.querySelector(".data-source");k&&(k.textContent="Source: "+t.getDataSource());const S=(t=>{if(!t)return f();const e=new Date(t);return isNaN(e.getTime())?f():f(e)})(t.quoteTime),M=this.container.querySelector(".last-update");M&&(M.textContent=`Overnight: ${S}`)}catch(t){console.error("Error updating widget:",t),this.showError("Error updating data")}}showLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.remove("hidden")}hideLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.add("hidden")}showError(t){this.hideLoading(),this.clearError();const e=document.createElement("div");e.className="widget-error",e.textContent=`Error: ${t}`,e.style.cssText="\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n padding: 15px 20px;\n background: #fee;\n border: 1px solid #f5c6cb;\n border-radius: 6px;\n color: #721c24;\n text-align: center;\n font-size: 14px;\n z-index: 100;\n ",this.container.appendChild(e)}clearError(){const t=this.container.querySelector(".widget-error"),e=this.container.querySelector(".widget-error-container");t&&t.remove(),e&&e.remove()}showNoDataState(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.isDestroyed)try{this.hideLoading(),this.clearError();const e=t.Symbol||this.symbol,n=this.container.querySelector(".symbol");n&&(n.textContent=e);const i=this.container.querySelector(".current-price");i&&(i.textContent="$0.00");const s=this.container.querySelector(".price-change");if(s){const t=s.querySelector(".change-value");t&&(t.textContent="+0.00");const e=s.querySelector(".change-percent");e&&(e.textContent=" (0.00%)"),s.classList.remove("positive","negative")}const o=this.container.querySelector(".widget-header");o&&o.classList.add("dimmed");const a=this.container.querySelector(".price-section");a&&a.classList.add("dimmed"),this.showNoDataMessage(e,t);const r=f(),l=this.container.querySelector(".last-update");l&&(l.textContent=`Overnight: ${r}`)}catch(t){console.error("Error showing no data state:",t),this.showError("Error displaying no data state")}}showNoDataMessage(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=this.container.querySelector(".data-grid");n&&(n.style.display="none");const i=this.container.querySelector(".no-data-state");i&&i.remove();const s=e.isAccessError||e.message&&e.message.toLowerCase().includes("access"),o=c("div","","no-data-state"),a=c("div","","no-data-content");if(s){const n=document.createElement("div");n.className="no-data-icon error",n.innerHTML='<svg width="32" height="32" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="12" cy="12" r="10" stroke="#ef4444" stroke-width="2"/>\n <path d="M12 8v4" stroke="#ef4444" stroke-width="2" stroke-linecap="round"/>\n <circle cx="12" cy="16" r="1" fill="#ef4444"/>\n </svg>',a.appendChild(n);const i=c("h3",String(e.message||"Access Denied"),"no-data-title error");a.appendChild(i);const s=c("p","","no-data-description");s.appendChild(document.createTextNode("You do not have permission to view night session data for "));const o=c("strong",h(t));s.appendChild(o),a.appendChild(s);const r=c("p","Contact your administrator or try a different symbol","no-data-guidance");a.appendChild(r)}else{const n=document.createElement("div");n.className="no-data-icon",n.innerHTML='<svg width="32" height="32" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="12" cy="12" r="10" stroke="#9ca3af" stroke-width="2"/>\n <path d="M12 6v6l4 2" stroke="#9ca3af" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>',a.appendChild(n);const i=c("h3",String(e.message||"No Data Available"),"no-data-title");a.appendChild(i);const s=c("p","","no-data-description");s.appendChild(document.createTextNode("Night session data for "));const o=c("strong",h(t));s.appendChild(o),s.appendChild(document.createTextNode(" was not found")),a.appendChild(s);const r=c("p","Please check the symbol or try again later","no-data-guidance");a.appendChild(r)}o.appendChild(a);const r=this.container.querySelector(".widget-footer");r&&r.parentNode?r.parentNode.insertBefore(o,r):this.container.appendChild(o)}destroy(){this.isDestroyed=!0,this.loadingTimeout&&(this.clearTimeout(this.loadingTimeout),this.loadingTimeout=null),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null),this.symbolEditor&&(this.symbolEditor.destroy(),this.symbolEditor=null),super.destroy()}updateSymbol(t){this.handleSymbolChange(t)}}class v{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.rawData=t,this.symbol=t.Symbol||"",this.rootSymbol=t.RootSymbol||"",this.underlying=t.Underlying||"",this.expire=t.Expire||"",this.strike=t.Strike||0,this.type=this.determineOptionType(),this.lastPrice=t.LastPx||0,this.closePx=t.ClosePx||0,this.yestClosePx=t.YestClosePx||0,this.openPx=t.OpenPx||0,this.highPx=t.HighPx||0,this.lowPx=t.LowPx||0,this.bidPx=t.BidPx||0,this.bidSz=t.BidSz||0,this.bidExch=t.BidExch||"",this.askPx=t.AskPx||0,this.askSz=t.AskSz||0,this.askExch=t.AskExch||"",this.volume=t.Volume||0,this.openInterest=t.OpenInst||0,this.primeShare=t.PrimeShare||0,this.exch=t.Exch||"",this.dataSource=t.DataSource||"",this.quoteTime=t.QuoteTime||"",this.notFound=t.NotFound||!1}determineOptionType(){return this.symbol?this.symbol.includes("C")?"call":this.symbol.includes("P")?"put":"unknown":"unknown"}getChange(){return this.lastPrice-this.yestClosePx}getChangePercent(){return 0===this.yestClosePx?0:(this.lastPrice-this.yestClosePx)/this.yestClosePx*100}getSpread(){return this.askPx-this.bidPx}getSpreadPercent(){const t=(this.askPx+this.bidPx)/2;return 0===t?0:(this.askPx-this.bidPx)/t*100}getMidPrice(){return(this.askPx+this.bidPx)/2}formatPrice(t){return t?t.toFixed(2):"0.00"}formatStrike(){return`$${this.formatPrice(this.strike)}`}formatLastPrice(){return`$${this.formatPrice(this.lastPrice)}`}formatClosePx(){return`$${this.formatPrice(this.closePx)}`}formatYestClosePx(){return`$${this.formatPrice(this.yestClosePx)}`}formatOpenPx(){return`$${this.formatPrice(this.openPx)}`}formatHighPx(){return`$${this.formatPrice(this.highPx)}`}formatLowPx(){return`$${this.formatPrice(this.lowPx)}`}formatBid(){return`$${this.formatPrice(this.bidPx)}`}formatAsk(){return`$${this.formatPrice(this.askPx)}`}formatBidSize(){return this.bidSz.toString()}formatAskSize(){return this.askSz.toString()}formatSpread(){return`$${this.formatPrice(this.getSpread())}`}formatMidPrice(){return`$${this.formatPrice(this.getMidPrice())}`}formatChange(){const t=this.getChange();return`${t>=0?"+":""}${this.formatPrice(t)}`}formatChangePercent(){const t=this.getChangePercent();return`${t>=0?"+":""}${t.toFixed(2)}%`}formatVolume(){return this.volume.toLocaleString()}formatOpenInterest(){return this.openInterest.toLocaleString()}formatPrimeShare(){return this.primeShare.toString()}formatExpirationDate(){if(!this.expire)return"N/A";try{return new Date(this.expire).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch(t){return this.expire}}formatQuoteTime(){if(!this.quoteTime)return"N/A";try{return new Date(this.quoteTime).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch(t){return this.quoteTime}}formatExchange(){return this.exch||"N/A"}formatDataSource(){return this.dataSource||"N/A"}formatDayRange(){return`$${this.formatPrice(this.lowPx)} - $${this.formatPrice(this.highPx)}`}formatOptionType(){return this.type.toUpperCase()}getDaysToExpiration(){if(!this.expire)return 0;try{const t=new Date(this.expire),e=new Date,n=t.getTime()-e.getTime(),i=Math.ceil(n/864e5);return Math.max(0,i)}catch(t){return 0}}formatDaysToExpiration(){const t=this.getDaysToExpiration();return`${t} day${1!==t?"s":""}`}getMoneyness(t){return t&&0!==this.strike?"call"===this.type?t-this.strike:"put"===this.type?this.strike-t:0:0}isInTheMoney(t){return this.getMoneyness(t)>0}parseSymbol(){return{underlying:this.rootSymbol||"",expirationDate:this.expire||"",type:this.type||"",strikePrice:this.strike||0,fullSymbol:this.symbol||""}}getSummary(){return{symbol:this.symbol,underlying:this.underlying,type:this.formatOptionType(),strike:this.formatStrike(),expiration:this.formatExpirationDate(),lastPrice:this.formatLastPrice(),change:this.formatChange(),changePercent:this.formatChangePercent(),volume:this.formatVolume(),openInterest:this.formatOpenInterest(),bid:this.formatBid(),ask:this.formatAsk(),exchange:this.formatExchange()}}getDataSource(){return"opra-d"===this.dataSource.toLowerCase()?"20 mins delayed":"real-time"===this.dataSource.toLowerCase()?"Real-time":"MDAS Server"}static fromApiResponse(t){return new v(t)}isValid(){return!this.notFound&&this.symbol&&this.strike>0}}class w extends n{constructor(t,e,n){if(super(t,e,n),!e.symbol)throw new Error("Symbol is required for OptionsWidget");if(!e.wsManager)throw new Error("WebSocketManager is required for OptionsWidget");this.type="options";const i=p(e.symbol);if(!i.valid)throw new Error(`Invalid option symbol: ${i.error}`);this.symbol=i.sanitized,this.wsManager=e.wsManager,this.debug=e.debug||!1,this.styled=void 0===e.styled||e.styled,this.data=null,this.isDestroyed=!1,this.unsubscribe=null,this.loadingTimeout=null,this.createWidgetStructure(),this.initializeSymbolEditor(),this.initialize()}createWidgetStructure(){if(this.container.innerHTML='\n <div class="options-widget widget">\n <div class="widget-content">\n \x3c!-- Header Section with Purple Background --\x3e\n <div class="widget-header">\n <div class="symbol-section">\n <h1 class="symbol editable-symbol" \n title="Double-click to edit symbol" \n data-original-symbol="">\n </h1>\n <div class="option-info">\n <span class="underlying-symbol"></span>\n <span class="data-type">OPTIONS</span>\n </div>\n </div>\n <div class="price-section">\n <div class="current-price"></div>\n <div class="price-change">\n <span class="change-value"></span>\n <span class="change-percent"></span>\n </div>\n </div>\n </div>\n\n \x3c!-- Data Grid Section --\x3e\n <div class="data-grid">\n <div class="data-section">\n <div class="section-title">Quote</div>\n <div class="data-row">\n <span class="data-label">Bid</span>\n <span class="data-value bid-ask-value bid-data"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Ask</span>\n <span class="data-value bid-ask-value ask-data"></span>\n </div>\n </div>\n\n <div class="data-section">\n <div class="section-title">Trading Activity</div>\n <div class="data-row">\n <span class="data-label">Volume</span>\n <span class="data-value volume"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Open Interest</span>\n <span class="data-value open-interest"></span>\n </div>\n </div>\n\n <div class="data-section">\n <div class="section-title">Performance</div>\n <div class="data-row">\n <span class="data-label">Previous Close</span>\n <span class="data-value yesterday-close"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Open</span>\n <span class="data-value open-price"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Day Range</span>\n <span class="data-value range-value day-range"></span>\n </div>\n </div>\n\n <div class="data-section">\n <div class="section-title">Contract Info</div>\n <div class="data-row">\n <span class="data-label">Strike Price</span>\n <span class="data-value strike-price"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Expiration</span>\n <span class="data-value expiry-date"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Prime Share</span>\n <span class="data-value prime-share"></span>\n </div>\n </div>\n </div>\n\n \x3c!-- Footer --\x3e\n <div class="widget-footer">\n <span class="last-update"></span>\n <span class="data-source"></span>\n </div>\n </div>\n \n \x3c!-- Loading Overlay --\x3e\n <div class="widget-loading-overlay">\n <div class="loading-content">\n <div class="loading-spinner"></div>\n <span class="loading-text">Loading options data...</span>\n </div>\n </div>\n </div>\n',this.styled){const t=this.container.querySelector(".options-widget");t&&t.classList.add("widget-styled")}this.addStyles()}addStyles(){if(!document.querySelector("#options-widget-styles")){const t=document.createElement("style");t.id="options-widget-styles",t.textContent=l,document.head.appendChild(t)}}initializeSymbolEditor(){this.symbolEditor=new s(this,{maxLength:20,placeholder:"Enter option contract...",onSymbolChange:this.handleSymbolChange.bind(this),debug:this.debug,autoUppercase:!0,symbolType:"optionsl1"});const t=this.container.querySelector(".symbol");t&&(t.textContent=this.symbol,t.dataset.originalSymbol=this.symbol)}async handleSymbolChange(t){this.debug&&console.log("[OptionsWidget] Symbol change requested:",t);const e=p(t);if(!e.valid)return this.debug&&console.log("[OptionsWidget] Invalid option symbol:",e.error),{success:!1,error:e.error};const n=e.sanitized;if(n===this.symbol)return this.debug&&console.log("[OptionsWidget] Same symbol, no change needed"),{success:!0};try{const t=this.symbol;return this.showLoading(),this.loadingTimeout&&this.clearTimeout(this.loadingTimeout),this.loadingTimeout=this.setTimeout((()=>{this.debug&&console.log("[OptionsWidget] Loading timeout for symbol:",n),this.hideLoading(),this.showError(`No data received for ${n}. Please try again.`)}),1e4),this.unsubscribe&&(this.debug&&console.log(`[OptionsWidget] Unsubscribing from ${t}`),this.wsManager.sendUnsubscribe("queryoptionl1",t),this.unsubscribe(),this.unsubscribe=null),this.symbol=n,this.debug&&console.log(`[OptionsWidget] Subscribing to ${n}`),this.subscribeToData(),this.debug&&console.log(`[OptionsWidget] Successfully changed symbol from ${t} to ${n}`),{success:!0}}catch(t){return console.error("[OptionsWidget] Error changing symbol:",t),this.showError(`Failed to load data for ${n}`),{success:!1,error:`Failed to load ${n}`}}}async initialize(){this.showLoading();!1!==await super.validateInitialSymbol("quoteOptionl1",this.symbol,(t=>{t&&t[0]&&!t[0].error&&!t[0].not_found&&(this.initialValidationData=t[0])}))&&this.subscribeToData()}subscribeToData(){this.unsubscribe=this.wsManager.subscribe(this.widgetId,["queryoptionl1"],this.handleMessage.bind(this),this.symbol)}handleData(t){if(this.loadingTimeout&&(clearTimeout(this.loadingTimeout),this.loadingTimeout=null),"error"!==t.type){if(t.RootSymbol===this.symbol||t.Underlying===this.symbol||t.Symbol?.includes(this.symbol))if(this.debug&&console.log("[OptionsWidget] Found matching options data for",this.symbol,":",t),!0===t.NotFound)this.data?(this.hideLoading(),this.debug&&console.log("[OptionsWidget] No new data, keeping cached data visible")):this.showNoDataState(t);else{const e=new v(t);this.data=e,this.updateWidget(e)}else if(Array.isArray(t)){const e=t.find((t=>t.RootSymbol===this.symbol||t.Underlying===this.symbol||t.Symbol?.includes(this.symbol)));if(e)if(!0===e.NotFound)this.data?(this.hideLoading(),this.debug&&console.log("[OptionsWidget] No new data, keeping cached data visible")):this.showNoDataState(e);else{const t=new v(e);this.data=t,this.updateWidget(t)}else this.debug&&console.log("[OptionsWidget] No matching data in response, keeping cached data"),this.hideLoading()}t._cached&&this.showConnectionQuality()}else{const e=t.message||"Server error";this.data?(this.hideLoading(),this.debug&&console.log("[OptionsWidget] Error received but keeping cached data:",e)):this.showError(e)}}showNoDataState(t){if(!this.isDestroyed)try{this.hideLoading();const e=t.Symbol||this.symbol,n=this.container.querySelector(".symbol");n&&(n.textContent=e);const i=this.container.querySelector(".underlying-symbol");i&&(i.textContent=t.RootSymbol||this.symbol);const s=this.container.querySelector(".current-price");s&&(s.textContent="$0.00");const o=this.container.querySelector(".price-change");if(o){const t=o.querySelector(".change-value");t&&(t.textContent="+0.00");const e=o.querySelector(".change-percent");e&&(e.textContent=" (0.00%)"),o.classList.remove("positive","negative")}const a=this.container.querySelector(".widget-header");a&&a.classList.add("dimmed"),this.showNoDataMessage(e);const r=f(),l=this.container.querySelector(".last-update");l&&(l.textContent=`Checked: ${r}`)}catch(t){console.error("Error showing no data state:",t),this.showError("Error displaying no data state")}}showNoDataMessage(t){const e=this.container.querySelector(".data-grid"),n=this.container.querySelector(".option-details-section");e&&(e.style.display="none"),n&&(n.style.display="none");const i=this.container.querySelector(".no-data-state");i&&i.remove();const s=c("div","","no-data-state"),o=c("div","","no-data-content"),a=document.createElement("div");a.className="no-data-icon",a.innerHTML='<svg width="48" height="48" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="12" cy="12" r="10" stroke="#9ca3af" stroke-width="2"/>\n <path d="M12 6v6l4 2" stroke="#9ca3af" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>',o.appendChild(a);const r=c("h3","No Data Available","no-data-title");o.appendChild(r);const l=c("p","","no-data-description");l.appendChild(document.createTextNode("Data for "));const d=c("strong",String(t));l.appendChild(d),l.appendChild(document.createTextNode(" was not found")),o.appendChild(l);const h=c("p","Please check the symbol or try again later","no-data-guidance");o.appendChild(h),s.appendChild(o);const u=this.container.querySelector(".widget-footer");u&&u.parentNode?u.parentNode.insertBefore(s,u):this.container.appendChild(s)}updateWidget(t){if(!this.isDestroyed)try{this.loadingTimeout&&(clearTimeout(this.loadingTimeout),this.loadingTimeout=null),this.hideLoading(),this.clearError();const e=this.container.querySelector(".widget-header");e&&e.classList.remove("dimmed");const n=this.container.querySelector(".data-grid");n&&(n.style.display="grid");const i=this.container.querySelector(".no-data-state");i&&i.remove();const s=this.container.querySelector(".symbol");s&&(s.textContent=t.symbol,s.dataset.originalSymbol=t.symbol);const o=this.container.querySelector(".underlying-symbol");o&&(o.textContent=t.rootSymbol||t.underlying||"QQQ");const a=this.container.querySelector(".current-price");a&&(a.textContent=t.formatLastPrice());const r=t.getChange(),l=this.container.querySelector(".price-change");if(l){const e=l.querySelector(".change-value"),n=l.querySelector(".change-percent");e&&(e.textContent=t.formatChange()),n&&(n.textContent=` (${t.formatChangePercent()})`),l.classList.remove("positive","negative","neutral"),r>0?l.classList.add("positive"):r<0?l.classList.add("negative"):l.classList.add("neutral")}const d=this.container.querySelector(".bid-data");if(d){u(d),d.appendChild(document.createTextNode(t.formatBid()));const e=c("span",`× ${t.bidSz}`,"size-info");d.appendChild(e)}const h=this.container.querySelector(".ask-data");if(h){u(h),h.appendChild(document.createTextNode(t.formatAsk()));const e=c("span",`× ${t.askSz}`,"size-info");h.appendChild(e)}const g=this.container.querySelector(".volume");g&&(g.textContent=t.formatVolume());const p=this.container.querySelector(".open-interest");p&&(p.textContent=t.formatOpenInterest());const m=this.container.querySelector(".day-range");m&&(m.textContent=t.formatDayRange());const b=this.container.querySelector(".open-price");b&&(b.textContent=t.formatOpenPx());const y=this.container.querySelector(".yesterday-close");y&&(y.textContent=t.formatYestClosePx());const x=this.container.querySelector(".strike-price");x&&(x.textContent=t.formatStrike());const v=this.container.querySelector(".expiry-date");v&&(v.textContent=t.formatExpirationDate());const w=this.container.querySelector(".prime-share");w&&(w.textContent=t.formatPrimeShare());const k=f(t.quoteTime||Date.now()),S=this.container.querySelector(".last-update");S&&(S.textContent=`Last update: ${k}`);const M=this.container.querySelector(".data-source");M&&(M.textContent=`Source: ${t.getDataSource()}`)}catch(t){console.error("Error updating options widget:",t),this.showError("Error updating data")}}formatPrice(t){return t?t.toFixed(2):"0.00"}formatPriceChange(t){return`${t>=0?"+":""}${t.toFixed(2)}`}showLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.remove("hidden")}hideLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.add("hidden")}showError(t){this.hideLoading(),this.clearError();const e=document.createElement("div");e.className="widget-error",e.textContent=`Error: ${t}`,e.style.cssText="\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n padding: 15px 20px;\n background: #fee;\n border: 1px solid #f5c6cb;\n border-radius: 6px;\n color: #721c24;\n text-align: center;\n font-size: 14px;\n z-index: 100;\n ",this.container.appendChild(e)}clearError(){const t=this.container.querySelector(".widget-error"),e=this.container.querySelector(".widget-error-container");t&&t.remove(),e&&e.remove()}destroy(){this.isDestroyed=!0,this.loadingTimeout&&(this.clearTimeout(this.loadingTimeout),this.loadingTimeout=null),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null),this.symbolEditor&&(this.symbolEditor.destroy(),this.symbolEditor=null),super.destroy()}}class k{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.openInterest=t.OpenInst||0,this.volume=t.Vol||0,this.askSize=t.AskSz||0,this.bidSize=t.BidSz||0,this.strike=t.Strike||0,this.askPrice=t.AskPx||0,this.bidPrice=t.BidPx||0,this.lastChange=t.LastChg||0,this.lastPrice=t.LastPx||0,this.dataSource=t.DataSource||"",this.expire=t.Expire||"",this.symbol=t.Symbol||""}}const S=`\n\n/* ============================================\n MDAS WIDGET CSS VARIABLES\n ============================================ */\n\n:root {\n /* --- FONT SIZE SYSTEM --- */\n /* Base font size - all other sizes are relative to this */\n --mdas-base-font-size: 14px;\n\n /* Component-specific font sizes (em units scale with base) */\n --mdas-small-text-size: 0.79em; /* 11px at 14px base */\n --mdas-medium-text-size: 0.93em; /* 13px at 14px base */\n --mdas-large-text-size: 1.14em; /* 16px at 14px base */\n\n /* Widget element sizes */\n --mdas-company-name-size: 1.43em; /* 20px at 14px base */\n --mdas-symbol-size: 1.79em; /* 25px at 14px base */\n --mdas-price-size: 2.29em; /* 32px at 14px base */\n --mdas-change-size: 1.14em; /* 16px at 14px base */\n\n /* Data display sizes */\n --mdas-label-size: 0.86em; /* 12px at 14px base */\n --mdas-value-size: 1em; /* 14px at 14px base */\n --mdas-footer-size: 0.79em; /* 11px at 14px base */\n\n /* Chart-specific sizes */\n --mdas-chart-title-size: 1.29em; /* 18px at 14px base */\n --mdas-chart-label-size: 0.93em; /* 13px at 14px base */\n --mdas-chart-value-size: 1.43em; /* 20px at 14px base */\n\n /* --- COLOR PALETTE (for future theming support) --- */\n /* Primary colors */\n --mdas-primary-color: #3b82f6;\n --mdas-primary-hover: #2563eb;\n\n /* Status colors */\n --mdas-color-positive: #059669;\n --mdas-color-positive-bg: #d1fae5;\n --mdas-color-negative: #dc2626;\n --mdas-color-negative-bg: #fee2e2;\n --mdas-color-neutral: #6b7280;\n\n /* Background colors */\n --mdas-bg-primary: #ffffff;\n --mdas-bg-secondary: #f9fafb;\n --mdas-bg-tertiary: #f3f4f6;\n\n /* Text colors */\n --mdas-text-primary: #111827;\n --mdas-text-secondary: #6b7280;\n --mdas-text-tertiary: #9ca3af;\n\n /* Border colors */\n --mdas-border-primary: #e5e7eb;\n --mdas-border-secondary: #d1d5db;\n\n /* --- SPACING SYSTEM --- */\n --mdas-spacing-xs: 4px;\n --mdas-spacing-sm: 8px;\n --mdas-spacing-md: 16px;\n --mdas-spacing-lg: 24px;\n --mdas-spacing-xl: 32px;\n\n /* --- EFFECTS --- */\n --mdas-border-radius: 8px;\n --mdas-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);\n --mdas-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);\n --mdas-shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);\n\n /* --- Z-INDEX LAYERS --- */\n --mdas-z-base: 1;\n --mdas-z-sticky: 10;\n --mdas-z-overlay: 100;\n --mdas-z-modal: 10000;\n}\n\n/* ============================================\n RESPONSIVE FONT SCALING\n ============================================ */\n\n/* Tablet breakpoint - slightly smaller fonts */\n@media (max-width: 768px) {\n :root {\n --mdas-base-font-size: 13px;\n }\n}\n\n/* Mobile breakpoint - smaller fonts for small screens */\n@media (max-width: 480px) {\n :root {\n --mdas-base-font-size: 12px;\n }\n}\n\n/* ============================================\n OPTIONAL UTILITY CLASSES\n Use these classes for consistent styling\n ============================================ */\n\n/* Widget card styling - apply to widget root element */\n.mdas-card {\n background: var(--mdas-bg-primary);\n border-radius: var(--mdas-border-radius);\n padding: var(--mdas-spacing-lg);\n box-shadow: var(--mdas-shadow-md);\n border: 1px solid var(--mdas-border-primary);\n}\n\n/* Responsive container */\n.mdas-container {\n width: 100%;\n max-width: 1400px;\n margin: 0 auto;\n}\n\n/* Text utilities */\n.mdas-text-primary {\n color: var(--mdas-text-primary);\n}\n\n.mdas-text-secondary {\n color: var(--mdas-text-secondary);\n}\n\n.mdas-text-muted {\n color: var(--mdas-text-tertiary);\n}\n\n/* Status colors */\n.mdas-positive {\n color: var(--mdas-color-positive);\n}\n\n.mdas-negative {\n color: var(--mdas-color-negative);\n}\n\n.mdas-neutral {\n color: var(--mdas-color-neutral);\n}\n\n${M="option-chain-widget",`\n/* Loading Overlay for ${M} */\n.${M} .widget-loading-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(255, 255, 255, 0.95);\n backdrop-filter: blur(2px);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: var(--mdas-z-overlay, 100);\n border-radius: var(--mdas-border-radius, 12px);\n}\n\n.${M} .widget-loading-overlay.hidden {\n display: none;\n}\n\n.${M} .loading-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 12px;\n}\n\n.${M} .loading-spinner {\n width: 40px;\n height: 40px;\n border: 4px solid var(--mdas-border-primary, #e5e7eb);\n border-top-color: var(--mdas-primary-color, #3b82f6);\n border-radius: 50%;\n animation: ${M}-spin 1s linear infinite;\n}\n\n.${M} .loading-text {\n color: var(--mdas-text-secondary, #6b7280);\n font-size: var(--mdas-medium-text-size, 0.93em);\n font-weight: 500;\n}\n\n@keyframes ${M}-spin {\n to { transform: rotate(360deg); }\n}\n`}\n${(t=>`\n/* Error Display for ${t} */\n.${t} .widget-error {\n padding: 16px 20px;\n background: var(--mdas-color-negative-bg, #fee2e2);\n border: 1px solid #fecaca;\n border-radius: var(--mdas-border-radius, 8px);\n color: var(--mdas-color-negative, #dc2626);\n font-size: var(--mdas-medium-text-size, 0.93em);\n margin: 16px;\n text-align: center;\n}\n\n.${t} .widget-error-container {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 12px;\n padding: 24px;\n}\n`)("option-chain-widget")}\n${(t=>`\n/* Footer for ${t} */\n.${t} .widget-footer {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 8px 16px;\n background: var(--mdas-bg-secondary, #f9fafb);\n border-top: 1px solid var(--mdas-border-primary, #e5e7eb);\n font-size: var(--mdas-footer-size, 0.79em);\n color: var(--mdas-text-secondary, #6b7280);\n}\n\n.${t} .widget-footer .last-update {\n color: var(--mdas-text-tertiary, #9ca3af);\n}\n\n.${t} .widget-footer .data-source {\n color: var(--mdas-text-secondary, #6b7280);\n font-weight: 500;\n}\n`)("option-chain-widget")}\n${(t=>`\n/* No Data State for ${t} */\n.${t} .no-data-state {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 40px 20px;\n text-align: center;\n color: var(--mdas-text-secondary, #6b7280);\n}\n\n.${t} .no-data-content {\n max-width: 400px;\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 16px;\n}\n\n.${t} .no-data-icon {\n width: 64px;\n height: 64px;\n display: flex;\n align-items: center;\n justify-content: center;\n opacity: 0.5;\n}\n\n.${t} .no-data-icon svg {\n width: 100%;\n height: 100%;\n}\n\n.${t} .no-data-title {\n font-size: var(--mdas-large-text-size, 1.14em);\n font-weight: 600;\n color: var(--mdas-text-primary, #111827);\n margin: 0;\n}\n\n.${t} .no-data-description {\n font-size: var(--mdas-medium-text-size, 0.93em);\n color: var(--mdas-text-secondary, #6b7280);\n margin: 0;\n line-height: 1.5;\n}\n\n.${t} .no-data-description strong {\n color: var(--mdas-text-primary, #111827);\n font-weight: 600;\n}\n\n.${t} .no-data-guidance {\n font-size: var(--mdas-small-text-size, 0.79em);\n color: var(--mdas-text-tertiary, #9ca3af);\n margin: 0;\n}\n\n/* Error variant of no-data state */\n.${t} .no-data-state.error-access {\n color: var(--mdas-color-negative, #dc2626);\n}\n\n.${t} .no-data-state.error-access .no-data-title {\n color: var(--mdas-color-negative, #dc2626);\n}\n\n.${t} .no-data-state.error-access .no-data-icon {\n opacity: 0.8;\n}\n\n.${t} .no-data-state.error-access .no-data-icon svg circle[fill] {\n fill: var(--mdas-color-negative, #dc2626);\n}\n`)("option-chain-widget")}\n\n/* Option Chain Widget Specific Styles */\n.option-chain-widget {\n border: 1px solid #e5e7eb;\n border-radius: 8px;\n background: white;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n font-size: 13px;\n max-width: 100%;\n overflow: hidden;\n position: relative;\n}\n\n.option-chain-widget .widget-header {\n background: #f9fafb;\n padding: 16px;\n border-bottom: 1px solid #e5e7eb;\n}\n\n.option-chain-widget .input-section {\n display: flex;\n gap: 12px;\n align-items: center;\n flex-wrap: wrap;\n}\n\n.option-chain-widget .filter-section {\n display: flex;\n gap: 8px;\n align-items: center;\n margin-top: 8px;\n}\n\n.option-chain-widget .filter-label {\n font-size: 13px;\n font-weight: 500;\n color: #374151;\n}\n\n.option-chain-widget .symbol-input,\n.option-chain-widget .date-select,\n.option-chain-widget .strike-filter {\n padding: 8px 12px;\n border: 1px solid #d1d5db;\n border-radius: 4px;\n font-size: 14px;\n font-family: inherit;\n min-width: 0;\n flex: 1;\n}\n\n.option-chain-widget .symbol-input {\n text-transform: uppercase;\n min-width: 100px;\n max-width: 120px;\n}\n\n.option-chain-widget .date-select {\n min-width: 140px;\n background: white;\n}\n\n.option-chain-widget .strike-filter {\n min-width: 200px;\n background: white;\n cursor: pointer;\n}\n\n.option-chain-widget .fetch-button {\n padding: 8px 16px;\n background: #3b82f6;\n color: white;\n border: none;\n border-radius: 4px;\n font-size: 14px;\n cursor: pointer;\n font-family: inherit;\n white-space: nowrap;\n}\n\n.option-chain-widget .fetch-button:hover {\n background: #2563eb;\n}\n\n.option-chain-widget .fetch-button:disabled {\n background: #9ca3af;\n cursor: not-allowed;\n}\n\n.option-chain-widget .date-select:disabled {\n background: #f3f4f6;\n color: #9ca3af;\n cursor: not-allowed;\n}\n\n.option-chain-widget .option-chain-table {\n max-height: 800px;\n overflow-x: auto; /* Enable horizontal scrolling */\n overflow-y: auto; /* Enable vertical scrolling if needed */\n -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */\n width: 100%; /* Ensure full width */\n position: relative; /* Establish positioning context */\n box-sizing: border-box; /* Include padding and border in the element's total width and height */\n}\n\n.option-chain-widget .table-header {\n background: #f3f4f6;\n font-weight: 600;\n border-bottom: 2px solid #d1d5db;\n position: sticky;\n top: 0;\n z-index: 10;\n width: fit-content; /* Ensure it spans the full width */\n box-sizing: border-box; /* Include padding and border in the element's total width and height */\n}\n\n.option-chain-widget .price-change.positive::before,\n.option-chain-widget .price-change.negative::before {\n content: none;\n}\n \n\n/* Better approach - make section headers align with actual column structure */\n.option-chain-widget .section-headers,\n.option-chain-widget .column-headers {\n\n display: grid;\n grid-template-columns: minmax(160px, 1fr) repeat(6, minmax(80px, 1fr)) 80px minmax(160px, 1fr) repeat(6, minmax(80px, 1fr));\n border-bottom: 1px solid #d1d5db;\n background: #f3f4f6;\n position: sticky;\n top: 0;\n z-index: 12;\n box-sizing: border-box; /* Include padding and border in the element's total width and height */\n margin: 0;\n padding: 0;\n min-width: fit-content;\n}\n\n.option-chain-widget .calls-header {\n grid-column: 1 / 8; /* Span across first 7 columns */\n padding: 8px;\n text-align: center;\n font-weight: 600;\n font-size: 14px;\n color: #374151;\n display: flex;\n align-items: center;\n justify-content: center;\n background: #f3f4f6;\n}\n\n.option-chain-widget .strike-header {\n grid-column: 8 / 9; /* Strike column */\n background: #e5e7eb;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.option-chain-widget .puts-header {\n grid-column: 9 / -1; /* Span from column 9 to the end */\n padding: 8px;\n text-align: center;\n font-weight: 600;\n font-size: 14px;\n color: #374151;\n display: flex;\n align-items: center;\n justify-content: center;\n background: #f3f4f6;\n}\n\n.option-chain-widget .column-headers {\n display: grid;\n grid-template-columns: minmax(160px, 1fr) repeat(6, minmax(80px, 1fr)) 80px minmax(160px, 1fr) repeat(6, minmax(80px, 1fr));\n position: sticky;\n top: 40px;\n z-index: 11;\n background: #f3f4f6;\n}\n\n.option-chain-widget .calls-columns,\n.option-chain-widget .puts-columns {\n display: contents; /* Remove their own grid, use parent grid */\n}\n\n.option-chain-widget .strike-column {\n display: flex;\n align-items: center;\n justify-content: center;\n background: #e5e7eb !important;\n font-weight: bold;\n color: #374151;\n font-size: 11px;\n text-transform: uppercase;\n}\n\n.option-chain-widget .strike-column span {\n background: transparent !important; /* Ensure span doesn't override parent background */\n}\n\n.option-chain-widget .column-headers span {\n padding: 6px 2px; /* Reduce padding to prevent text overflow */\n text-align: center;\n font-size: 11px; /* Reduce font size */\n text-transform: uppercase;\n color: #6b7280;\n font-weight: 600;\n letter-spacing: 0.3px; /* Reduce letter spacing */\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n background: #f3f4f6;\n}\n\n.option-chain-widget .option-row {\n display: grid;\n grid-template-columns: minmax(160px, 1fr) repeat(6, minmax(80px, 1fr)) 80px minmax(160px, 1fr) repeat(6, minmax(80px, 1fr));\n border-bottom: 1px solid #f3f4f6;\n min-height: 32px;\n}\n\n/* In-the-money highlighting */\n.option-chain-widget .calls-data.in-the-money span,\n.option-chain-widget .puts-data.in-the-money span {\n background-color: #fffbeb;\n}\n\n.option-chain-widget .option-row:hover {\n background: #f9fafb;\n}\n\n.option-chain-widget .option-row:hover .calls-data.in-the-money span,\n.option-chain-widget .option-row:hover .puts-data.in-the-money span {\n background-color: #fef3c7;\n}\n\n.option-chain-widget .option-row:hover .calls-data span,\n.option-chain-widget .option-row:hover .puts-data span,\n.option-chain-widget .option-row:hover .strike-data {\n background: #f9fafb;\n}\n\n.option-chain-widget .calls-data,\n.option-chain-widget .puts-data {\n display: contents; /* Make children participate in parent grid */\n}\n\n.option-chain-widget .strike-data {\n display: flex;\n align-items: center;\n justify-content: center;\n background: #f9fafb;\n font-weight: 600; /* Changed from bold to 600 for consistency */\n color: #6b7280; /* Changed from #1f2937 to match other widgets */\n}\n\n.option-chain-widget .calls-data span,\n.option-chain-widget .puts-data span {\n padding: 6px 4px;\n text-align: center;\n font-size: 12px;\n font-weight: 400;\n color: #111827;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n/* Override color for change values with positive/negative classes */\n.option-chain-widget .calls-data span.positive,\n.option-chain-widget .puts-data span.positive {\n color: #059669 !important;\n font-weight: 500;\n}\n\n.option-chain-widget .calls-data span.negative,\n.option-chain-widget .puts-data span.negative {\n color: #dc2626 !important;\n font-weight: 500;\n}\n\n.option-chain-widget .calls-data span.neutral,\n.option-chain-widget .puts-data span.neutral {\n color: #6b7280 !important;\n}\n\n.option-chain-widget .contract-cell {\n font-size: 10px;\n color: #6b7280;\n text-align: left;\n padding: 4px 6px;\n font-family: monospace;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.option-chain-widget .contract-cell.clickable {\n color: #3b82f6;\n cursor: pointer;\n text-decoration: underline;\n transition: all 0.2s ease;\n}\n\n.option-chain-widget .contract-cell.clickable:hover {\n color: #2563eb;\n background-color: #eff6ff;\n}\n\n.option-chain-widget .contract-cell.clickable:focus {\n outline: 2px solid #3b82f6;\n outline-offset: 2px;\n border-radius: 2px;\n}\n\n.option-chain-widget .contract-cell.clickable:active {\n color: #1e40af;\n background-color: #dbeafe;\n}\n\n.option-chain-widget .positive {\n color: #059669;\n}\n\n.option-chain-widget .negative {\n color: #dc2626;\n}\n\n.option-chain-widget .neutral {\n color: #6b7280;\n}\n\n/* Loading, Error, Footer, and No-Data styles provided by CommonWidgetPatterns */\n\n/* RESPONSIVE STYLES */\n\n/* Tablet styles (768px and down) */\n@media (max-width: 768px) {\n .option-chain-widget .input-section {\n flex-direction: column;\n align-items: stretch;\n gap: 8px;\n }\n\n .option-chain-widget .filter-section {\n flex-direction: row;\n margin-top: 0;\n }\n\n .option-chain-widget .symbol-input,\n .option-chain-widget .date-select,\n .option-chain-widget .strike-filter {\n width: 100%;\n max-width: none;\n }\n\n .option-chain-widget .fetch-button {\n width: 100%;\n }\n \n .option-chain-widget .calls-columns,\n .option-chain-widget .puts-columns {\n grid-template-columns: 120px repeat(6, minmax(50px, 1fr));\n }\n \n .option-chain-widget .calls-data,\n .option-chain-widget .puts-data {\n grid-template-columns: 120px repeat(6, minmax(50px, 1fr));\n }\n \n .option-chain-widget .column-headers span {\n font-size: 10px;\n padding: 6px 2px;\n }\n \n .option-chain-widget .calls-data span,\n .option-chain-widget .puts-data span {\n font-size: 11px;\n padding: 4px 2px;\n }\n \n .option-chain-widget .contract-cell {\n font-size: 9px;\n padding: 4px 4px;\n }\n \n .option-chain-widget .strike-data {\n font-size: 12px;\n }\n\n /* Update responsive breakpoints to match */\n .option-chain-widget .section-headers {\n grid-template-columns: 1fr 80px 1fr;\n background: #f3f4f6;\n width: 100%;\n\n }\n}\n\n/* Mobile styles (480px and down) */\n@media (max-width: 480px) {\n .option-chain-widget {\n font-size: 12px;\n }\n \n .option-chain-widget .widget-header {\n padding: 12px;\n }\n \n .option-chain-widget .section-headers {\n grid-template-columns: 1fr 60px 1fr;\n background: #f3f4f6;\n }\n \n .option-chain-widget .column-headers {\n grid-template-columns: 1fr 60px 1fr;\n }\n \n .option-chain-widget .option-row {\n grid-template-columns: 1fr 60px 1fr;\n min-height: 28px;\n }\n \n .option-chain-widget .calls-columns,\n .option-chain-widget .puts-columns {\n grid-template-columns: 100px repeat(6, minmax(40px, 1fr));\n }\n \n .option-chain-widget .calls-data,\n .option-chain-widget .puts-data {\n grid-template-columns: 100px repeat(6, minmax(40px, 1fr));\n }\n \n .option-chain-widget .column-headers span {\n font-size: 9px;\n padding: 4px 1px;\n }\n \n .option-chain-widget .calls-data span,\n .option-chain-widget .puts-data span {\n font-size: 10px;\n padding: 3px 1px;\n }\n \n .option-chain-widget .contract-cell {\n font-size: 8px;\n padding: 3px 2px;\n }\n \n .option-chain-widget .strike-data {\n font-size: 11px;\n padding: 3px;\n }\n \n \n .option-chain-widget .option-chain-table {\n max-height: 400px;\n }\n \n .option-chain-widget .no-data-state {\n padding: 20px;\n font-size: 12px;\n }\n \n .option-chain-widget .widget-error {\n margin: 8px;\n padding: 12px;\n font-size: 12px;\n }\n}\n\n/* Very small mobile (320px and down) */\n@media (max-width: 320px) {\n .option-chain-widget .section-headers {\n grid-template-columns: 1fr 50px 1fr;\n }\n \n .option-chain-widget .column-headers {\n grid-template-columns: 1fr 50px 1fr;\n }\n \n .option-chain-widget .option-row {\n grid-template-columns: 1fr 50px 1fr;\n }\n \n .option-chain-widget .calls-columns,\n .option-chain-widget .puts-columns {\n grid-template-columns: 80px repeat(6, minmax(35px, 1fr));\n }\n \n .option-chain-widget .calls-data,\n .option-chain-widget .puts-data {\n grid-template-columns: 80px repeat(6, minmax(35px, 1fr));\n }\n \n .option-chain-widget .column-headers span {\n font-size: 8px;\n padding: 3px 1px;\n }\n \n .option-chain-widget .calls-data span,\n .option-chain-widget .puts-data span {\n font-size: 9px;\n padding: 2px 1px;\n }\n \n .option-chain-widget .contract-cell {\n font-size: 7px;\n padding: 2px 1px;\n }\n}\n\n/* Modal Styles */\n.option-chain-modal-overlay {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(0, 0, 0, 0.6);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10000;\n padding: 20px;\n animation: fadeIn 0.2s ease-out;\n}\n\n@keyframes fadeIn {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n}\n\n.option-chain-modal {\n background: white;\n border-radius: 12px;\n box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);\n max-width: 800px;\n width: 100%;\n max-height: 90vh;\n display: flex;\n flex-direction: column;\n animation: slideUp 0.3s ease-out;\n}\n\n@keyframes slideUp {\n from {\n transform: translateY(20px);\n opacity: 0;\n }\n to {\n transform: translateY(0);\n opacity: 1;\n }\n}\n\n.option-chain-modal-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 20px 24px;\n border-bottom: 1px solid #e5e7eb;\n}\n\n.option-chain-modal-header h3 {\n margin: 0;\n font-size: 18px;\n font-weight: 600;\n color: #111827;\n}\n\n.option-chain-modal-close {\n background: none;\n border: none;\n font-size: 28px;\n line-height: 1;\n color: #6b7280;\n cursor: pointer;\n padding: 0;\n width: 32px;\n height: 32px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 4px;\n transition: all 0.2s ease;\n}\n\n.option-chain-modal-close:hover {\n background: #f3f4f6;\n color: #111827;\n}\n\n.option-chain-modal-close:active {\n background: #e5e7eb;\n}\n\n.option-chain-modal-body {\n flex: 1;\n overflow-y: auto;\n padding: 24px;\n}\n\n/* Responsive modal */\n@media (max-width: 768px) {\n .option-chain-modal {\n max-width: 95%;\n max-height: 95vh;\n }\n\n .option-chain-modal-header {\n padding: 16px;\n }\n\n .option-chain-modal-header h3 {\n font-size: 16px;\n }\n\n .option-chain-modal-body {\n padding: 16px;\n }\n}\n`;var M;class C extends n{constructor(t,e,n){if(super(t,e,n),!e.wsManager)throw new Error("WebSocketManager is required for OptionChainWidget");if(this.type="optionchain",this.wsManager=e.wsManager,this.debug=e.debug||!1,this.data=null,this.isDestroyed=!1,this.unsubscribe=null,this.unsubscribeUnderlying=null,this.underlyingPrice=null,this.loadingTimeout=null,this.renderDebounceTimeout=null,this.cachedOptionChainData=null,this.cachedUnderlyingPrice=null,this.optionsModal=null,this.optionsWidgetInstance=null,e.symbol){const t=g(e.symbol);t.valid?this.symbol=t.sanitized:(console.warn("[OptionChainWidget] Invalid initial symbol:",t.error),this.symbol="")}else this.symbol="";this.date="",this.availableDates={},this.strikeFilterRange=5,this.fetchRateLimiter=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:500,e=0;return()=>{const n=Date.now(),i=n-e;return i<t?{valid:!1,error:`Please wait ${Math.ceil((t-i)/1e3)} seconds`,remainingMs:t-i}:(e=n,{valid:!0})}}(1e3),this.createWidgetStructure(),this.initialize()}createWidgetStructure(){this.container.innerHTML='\n <div class="option-chain-widget widget">\n <div class="widget-content">\n \x3c!-- Header Section --\x3e\n <div class="widget-header">\n <div class="input-section">\n <input type="text" class="symbol-input" placeholder="Enter Symbol" value="" />\n <select class="date-select" disabled>\n <option value="">Select a date...</option>\n </select>\n <button class="fetch-button" disabled>Search</button>\n </div>\n <div class="filter-section">\n <label for="strike-filter" class="filter-label">Display:</label>\n <select class="strike-filter" id="strike-filter">\n <option value="5">Near the money (±5 strikes)</option>\n <option value="10">Near the money (±10 strikes)</option>\n <option value="15">Near the money (±15 strikes)</option>\n <option value="all">All strikes</option>\n </select>\n </div>\n </div>\n\n \x3c!-- Data Grid Section --\x3e\n <div class="option-chain-table">\n <div class="table-header">\n <div class="section-headers">\n <div class="calls-header">Calls</div>\n <div class="strike-header"></div>\n <div class="puts-header">Puts</div>\n </div>\n <div class="column-headers">\n <div class="calls-columns">\n <span>Contract</span>\n <span>Last</span>\n <span>Change</span>\n <span>Bid</span>\n <span>Ask</span>\n <span>Volume</span>\n <span>Open Int.</span>\n </div>\n <div class="strike-column">\n <span>Strike</span>\n </div>\n <div class="puts-columns">\n <span>Contract</span>\n <span>Last</span>\n <span>Change</span>\n <span>Bid</span>\n <span>Ask</span>\n <span>Volume</span>\n <span>Open Int.</span>\n </div>\n </div>\n </div>\n <div class="option-chain-data-grid">\n \x3c!-- Option chain data will be populated here --\x3e\n </div>\n </div>\n\n \x3c!-- Footer --\x3e\n <div class="widget-footer">\n <span class="last-update"></span>\n <span class="data-source"></span>\n </div>\n </div>\n \n \x3c!-- Loading Overlay --\x3e\n <div class="widget-loading-overlay hidden">\n <div class="loading-content">\n <div class="loading-spinner"></div>\n <span class="loading-text">Loading option chain data...</span>\n </div>\n </div>\n </div>\n',this.addStyles(),this.setupEventListeners()}addStyles(){if(!document.querySelector("#option-chain-styles")){const t=document.createElement("style");t.id="option-chain-styles",t.textContent=S,document.head.appendChild(t)}}setupEventListeners(){this.symbolInput=this.container.querySelector(".symbol-input"),this.dateSelect=this.container.querySelector(".date-select"),this.fetchButton=this.container.querySelector(".fetch-button"),this.dataGrid=this.container.querySelector(".option-chain-data-grid"),this.strikeFilterSelect=this.container.querySelector(".strike-filter"),this.symbol&&(this.symbolInput.value=this.symbol,this.fetchButton.disabled=!1,this.dateSelect.innerHTML='<option value="">Click search to load dates...</option>'),this.addEventListener(this.symbolInput,"input",(t=>{const e=t.target.value,n=g(e);this.clearInputError(this.symbolInput),n.valid?(this.symbol=n.sanitized,this.symbolInput.value=n.sanitized,this.dateSelect.innerHTML='<option value="">Click search to load dates...</option>',this.dateSelect.disabled=!0,this.fetchButton.disabled=!1,this.availableDates={},this.date=""):""!==e.trim()?(this.showInputError(this.symbolInput,n.error),this.fetchButton.disabled=!0):this.clearDateOptions()})),this.addEventListener(this.dateSelect,"change",(t=>{const e=t.target.value;if(!e)return void(this.date="");const n=function(t){if(!t||"string"!=typeof t)return{valid:!1,error:"Date is required",normalized:""};const e=t.trim();let n;if(/^\d{4}-\d{2}-\d{2}$/.test(e))n=new Date(e);else if(/^\d{2}\/\d{2}\/\d{4}$/.test(e)){const[t,i,s]=e.split("/");n=new Date(s,parseInt(t,10)-1,parseInt(i,10))}else{if(!/^\d+$/.test(e))return{valid:!1,error:"Invalid date format. Use YYYY-MM-DD or MM/DD/YYYY",normalized:""};n=new Date(parseInt(e,10))}return isNaN(n.getTime())?{valid:!1,error:"Invalid date",normalized:""}:{valid:!0,normalized:n.toISOString().split("T")[0]}}(e);n.valid?(this.date=n.normalized,this.symbol&&this.fetchOptionChain()):(this.showError(n.error),this.date="")})),this.addEventListener(this.fetchButton,"click",(()=>{const t=g(this.symbol);if(!t.valid)return void this.showError(t.error||"Please enter a valid symbol first");const e=this.fetchRateLimiter();e.valid?this.loadAvailableDates(t.sanitized):this.showError(e.error)})),this.addEventListener(this.strikeFilterSelect,"change",(t=>{const e=t.target.value;this.strikeFilterRange="all"===e?"all":parseInt(e,10),this.data&&this.displayOptionChain(this.data)}))}async loadAvailableDates(t){if(t)try{this.symbol=t,this.symbolInput.value=t,this.dateSelect.disabled=!0,this.dateSelect.innerHTML='<option value="">Loading dates...</option>',this.fetchButton.disabled=!0;const e=this.wsManager.getApiService(),n=await e.getOptionChainDates(t);this.debug&&console.log("[OptionChainWidget] Available dates:",n.dates_dictionary),this.availableDates=n.dates_dictionary||{},this.populateDateOptions()}catch(e){console.error("[OptionChainWidget] Error loading dates:",e),this.dateSelect.innerHTML='<option value="">Error loading dates</option>',this.fetchButton.disabled=!1,this.showError(`Failed to load dates for ${t}: ${e.message}`)}}populateDateOptions(){this.dateSelect.innerHTML='<option value="">Select expiration date...</option>';const t=Object.keys(this.availableDates).sort();if(0===t.length)return this.dateSelect.innerHTML='<option value="">No dates available</option>',void(this.fetchButton.disabled=!1);t.forEach((t=>{const e=document.createElement("option");e.value=t;const n=this.availableDates[t],i=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{timezone:n="ET",format:i="short"}=e;if(!t||"string"!=typeof t)return"";const s=t.split("-");if(3!==s.length)return t;const[o,a,r]=s,l=parseInt(a,10)-1,c=parseInt(r,10),d=("long"===i?["January","February","March","April","May","June","July","August","September","October","November","December"]:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"])[l];return`${d} ${c}, ${o}`}(t,{timezone:m(t),format:"short"});e.textContent=i,e.className=`date-option ${n}`,this.dateSelect.appendChild(e)})),this.dateSelect.disabled=!1,this.fetchButton.disabled=!1,t.length>0&&(this.dateSelect.value=t[0],this.date=t[0],this.fetchOptionChain())}clearDateOptions(){this.dateSelect.innerHTML='<option value="">Click fetch to load dates...</option>',this.dateSelect.disabled=!0,this.fetchButton.disabled=!this.symbol,this.symbol=this.symbolInput.value.trim().toUpperCase()||"",this.date="",this.availableDates={}}initialize(){this.hideLoading(),this.symbol&&this.loadAvailableDates(this.symbol)}fetchOptionChain(){if(this.symbol&&this.date)try{this.showLoading(),this.loadingTimeout&&this.clearTimeout(this.loadingTimeout),this.loadingTimeout=this.setTimeout((()=>{this.debug&&console.log("[OptionChainWidget] Loading timeout for:",this.symbol,this.date),this.hideLoading(),this.showError(`No data received for ${this.symbol} on ${this.date}. Please try again.`)}),1e4),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null),this.unsubscribeUnderlying&&(this.unsubscribeUnderlying(),this.unsubscribeUnderlying=null),this.subscribeToData()}catch(t){console.error("[OptionChainWidget] Error fetching option chain:",t),this.showError(`Failed to load data for ${this.symbol}`)}else console.warn("[OptionChainWidget] Missing symbol or date")}subscribeToData(){this.unsubscribe=this.wsManager.subscribe(this.widgetId,["queryoptionchain"],this.handleMessage.bind(this),this.symbol,{date:this.date}),this.unsubscribeUnderlying=this.wsManager.subscribe(`${this.widgetId}-underlying`,["queryl1"],this.handleMessage.bind(this),this.symbol)}findNearestStrike(t,e){if(!t||0===t.length||!e)return null;let n=t[0],i=Math.abs(parseFloat(t[0])-e);for(const s of t){const t=Math.abs(parseFloat(s)-e);t<i&&(i=t,n=s)}return n}filterNearMoneyStrikes(t,e,n){if(!e||!t||0===t.length)return t;const i=t.indexOf(e);if(-1===i)return t;const s=Math.max(0,i-n),o=Math.min(t.length-1,i+n);return t.slice(s,o+1)}handleData(t){if(this.loadingTimeout&&(this.clearTimeout(this.loadingTimeout),this.loadingTimeout=null),"error"!==t.type){if(Array.isArray(t))0===t.length?this.data?(this.hideLoading(),this.debug&&console.log("[OptionChainWidget] No new data, keeping cached data visible")):this.showNoDataState():(this.data=t,this.cachedOptionChainData=t,this.displayOptionChain(t));else if("queryoptionchain"===t.type&&Array.isArray(t.data))0===t.data.length?this.data?(this.hideLoading(),this.debug&&console.log("[OptionChainWidget] No new data, keeping cached data visible")):this.showNoDataState():(this.data=t.data,this.cachedOptionChainData=t.data,this.displayOptionChain(t.data));else if("queryl1"===t.type&&t.Data){this.debug&&console.log("[OptionChainWidget] Received underlying price update");const e=t.Data.find((t=>t.Symbol===this.symbol));e&&e.LastPx&&(this.underlyingPrice=parseFloat(e.LastPx),this.cachedUnderlyingPrice=parseFloat(e.LastPx),this.renderDebounceTimeout&&this.clearTimeout(this.renderDebounceTimeout),this.renderDebounceTimeout=this.setTimeout((()=>{this.data&&this.displayOptionChain(this.data),this.renderDebounceTimeout=null}),500))}t._cached&&this.showConnectionQuality()}else{const e=t.message||"Server error";this.data?(this.hideLoading(),this.debug&&console.log("[OptionChainWidget] Error received but keeping cached data:",e)):this.showError(e)}}displayOptionChain(t){if(!this.isDestroyed)if(t&&Array.isArray(t)&&0!==t.length)try{this.hideLoading(),this.clearError(),this.dataGrid.innerHTML="";const e={};t.forEach((t=>{const n=new k(t),i=n.strike;e[i]||(e[i]={call:null,put:null});"call"===_(n.symbol)?e[i].call=n:e[i].put=n}));const n=Object.keys(e).sort(((t,e)=>parseFloat(t)-parseFloat(e)));let i=n;if("all"!==this.strikeFilterRange&&this.underlyingPrice){const t=this.findNearestStrike(n,this.underlyingPrice);t&&(i=this.filterNearMoneyStrikes(n,t,this.strikeFilterRange))}if(i.forEach((t=>{const{call:n,put:i}=e[t],s=document.createElement("div");s.classList.add("option-row");const o=t=>{const e=document.createElement("span");if(!t||0===t)return e.className="neutral",e.textContent="0.00",e;const n=parseFloat(t).toFixed(2),i=t>0?"positive":t<0?"negative":"neutral",s=t>0?"+":"";return e.className=i,e.textContent=`${s}${n}`,e},a=t=>d(t,2,"0.00"),r=document.createElement("div");r.className="calls-data",this.underlyingPrice&&parseFloat(t)<this.underlyingPrice&&r.classList.add("in-the-money");const l=c("span",n?h(n.symbol):"--","contract-cell");n&&n.symbol&&(l.classList.add("clickable"),l.setAttribute("role","button"),l.setAttribute("tabindex","0"),l.setAttribute("data-symbol",n.symbol),this.addEventListener(l,"click",(()=>this.showOptionsModal(n.symbol))),this.addEventListener(l,"keypress",(t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.showOptionsModal(n.symbol))}))),r.appendChild(l),r.appendChild(c("span",a(n?.lastPrice)));const u=document.createElement("span");n?u.appendChild(o(n.lastChange)):(u.textContent="0.00",u.className="neutral"),r.appendChild(u),r.appendChild(c("span",a(n?.bidPrice))),r.appendChild(c("span",a(n?.askPrice))),r.appendChild(c("span",n?String(n.volume):"0")),r.appendChild(c("span",n?String(n.openInterest):"0"));const g=document.createElement("div");g.className="strike-data",g.textContent=t;const p=document.createElement("div");p.className="puts-data",this.underlyingPrice&&parseFloat(t)>this.underlyingPrice&&p.classList.add("in-the-money");const m=c("span",i?h(i.symbol):"","contract-cell");i&&i.symbol&&(m.classList.add("clickable"),m.setAttribute("role","button"),m.setAttribute("tabindex","0"),m.setAttribute("data-symbol",i.symbol),this.addEventListener(m,"click",(()=>this.showOptionsModal(i.symbol))),this.addEventListener(m,"keypress",(t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.showOptionsModal(i.symbol))}))),p.appendChild(m),p.appendChild(c("span",a(i?.lastPrice)));const f=document.createElement("span");i?f.appendChild(o(i.lastChange)):(f.textContent="0.00",f.className="neutral"),p.appendChild(f),p.appendChild(c("span",a(i?.bidPrice))),p.appendChild(c("span",a(i?.askPrice))),p.appendChild(c("span",i?String(i.volume):"0")),p.appendChild(c("span",i?String(i.openInterest):"0")),s.appendChild(r),s.appendChild(g),s.appendChild(p),this.dataGrid.appendChild(s)})),t&&t.length>0){const e="OPRA-D"===t[0].DataSource;let n=t[0].quoteTime||Date.now();e&&(n-=12e5);const i=f(n),s=this.container.querySelector(".last-update");s&&(s.textContent=`Last update: ${i}`);const o=e?"20 mins delayed":"Real-time",a=this.container.querySelector(".data-source");a&&(a.textContent=`Source: ${o}`)}}catch(t){console.error("Error displaying option chain:",t),this.showError("Error displaying data")}else this.debug&&console.warn("[OptionChainWidget] Invalid or empty data passed to displayOptionChain")}showLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.remove("hidden")}hideLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.add("hidden")}showError(t){this.hideLoading(),this.clearError();const e=document.createElement("div");e.className="widget-error",e.textContent=`Error: ${t}`,e.style.cssText="\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n padding: 15px 20px;\n background: #fee;\n border: 1px solid #f5c6cb;\n border-radius: 6px;\n color: #721c24;\n text-align: center;\n font-size: 14px;\n z-index: 100;\n ",this.container.appendChild(e)}clearError(){const t=this.container.querySelector(".widget-error"),e=this.container.querySelector(".widget-error-container");t&&t.remove(),e&&e.remove()}showNoDataState(){this.hideLoading(),this.clearError();const t=c("div","","no-data-state"),e=c("div","","no-data-content"),n=document.createElement("div");n.className="no-data-icon",n.innerHTML='<svg width="32" height="32" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="12" cy="12" r="10" stroke="#9ca3af" stroke-width="2"/>\n <path d="M12 6v6l4 2" stroke="#9ca3af" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>',e.appendChild(n);const i=c("h3","No Option Chain Data","no-data-title");e.appendChild(i);const s=c("p","","no-data-description");s.appendChild(document.createTextNode("Option chain data for "));const o=c("strong",h(this.symbol));s.appendChild(o),s.appendChild(document.createTextNode(" on "));const a=c("strong",String(this.date));s.appendChild(a),s.appendChild(document.createTextNode(" was not found")),e.appendChild(s);const r=c("p","Please check the symbol and date or try again later","no-data-guidance");e.appendChild(r),t.appendChild(e);const l=this.container.querySelector(".widget-footer");l&&l.parentNode?l.parentNode.insertBefore(t,l):this.container.appendChild(t)}showOptionsModal(t){if(!t||"--"===t)return;this.closeOptionsModal(),this.optionsModal=document.createElement("div"),this.optionsModal.className="option-chain-modal-overlay",this.optionsModal.innerHTML=`\n <div class="option-chain-modal">\n <div class="option-chain-modal-header">\n <h3>Option Details: ${h(t)}</h3>\n <button class="option-chain-modal-close" aria-label="Close modal">×</button>\n </div>\n <div class="option-chain-modal-body">\n <div id="option-chain-modal-widget"></div>\n </div>\n </div>\n `,document.body.appendChild(this.optionsModal);const e=this.optionsModal.querySelector(".option-chain-modal-close");this.addEventListener(e,"click",(()=>this.closeOptionsModal())),this.addEventListener(this.optionsModal,"click",(t=>{t.target===this.optionsModal&&this.closeOptionsModal()}));const n=t=>{"Escape"===t.key&&this.closeOptionsModal()};document.addEventListener("keydown",n),this._escapeHandler=n;try{const e=this.optionsModal.querySelector("#option-chain-modal-widget");this.optionsWidgetInstance=new w(e,{symbol:t,wsManager:this.wsManager,debug:this.debug,styled:!0},`${this.widgetId}-options-modal`),this.debug&&console.log("[OptionChainWidget] Options modal opened for:",t)}catch(t){console.error("[OptionChainWidget] Error creating Options widget:",t),this.closeOptionsModal(),this.showError(`Failed to load option details: ${t.message}`)}}closeOptionsModal(){this.optionsWidgetInstance&&(this.optionsWidgetInstance.destroy(),this.optionsWidgetInstance=null),this.optionsModal&&(this.optionsModal.remove(),this.optionsModal=null),this._escapeHandler&&(document.removeEventListener("keydown",this._escapeHandler),this._escapeHandler=null),this.debug&&console.log("[OptionChainWidget] Options modal closed")}destroy(){this.isDestroyed=!0,this.closeOptionsModal(),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null),this.unsubscribeUnderlying&&(this.unsubscribeUnderlying(),this.unsubscribeUnderlying=null),this.loadingTimeout&&(this.clearTimeout(this.loadingTimeout),this.loadingTimeout=null),this.renderDebounceTimeout&&(this.clearTimeout(this.renderDebounceTimeout),this.renderDebounceTimeout=null),this.cachedOptionChainData=null,this.cachedUnderlyingPrice=null,this.underlyingPrice=null,this.data=null,super.destroy()}}const _=t=>{const e=t.match(/^(.+?)(\d{6})([CP])(\d{8})$/);if(e){const[,t,n,i,s]=e;return"C"===i?"call":"put"}return null};class T extends n{constructor(t,e,n){if(super(t,e,n),!e.symbol)throw new Error("Symbol is required for DataWidget");if(!e.wsManager)throw new Error("WebSocketManager is required for DataWidget");this.type="data",this.symbol=(e.symbol||"").toString().toUpperCase(),this.wsManager=e.wsManager,this.dataSource=e.dataSource||"queryl1",this.debug=e.debug||!1,this.data=null,this.isDestroyed=!1,this.unsubscribe=null,this.loadingTimeout=null,this.createWidgetStructure(),this.initializeSymbolEditor(),this.initialize()}createWidgetStructure(){this.container.innerHTML='\n <div class="data-widget widget">\n <div class="widget-content">\n \x3c!-- Header Section --\x3e\n <div class="widget-header">\n <div class="symbol-section">\n <h1 class="symbol editable-symbol" \n title="Double-click to edit symbol" \n data-original-symbol="">\n </h1>\n <div class="company-info">\n <span class="data-type">Stock</span>\n <span class="company-name"></span>\n </div>\n </div>\n </div>\n\n \x3c!-- Price Section --\x3e\n <div class="price-section">\n <div class="current-price"></div>\n <div class="price-change">\n <span class="change-value"></span>\n <span class="change-percent"></span>\n </div>\n </div>\n\n \x3c!-- Bid/Ask Section --\x3e\n <div class="bid-ask-section">\n <div class="ask">\n <span class="label">Ask</span>\n <span class="value ask-price"></span>\n <span class="size ask-size"></span>\n </div>\n <div class="bid">\n <span class="label">Bid</span>\n <span class="value bid-price"></span>\n <span class="size bid-size"></span>\n </div>\n </div>\n\n \x3c!-- Footer --\x3e\n <div class="widget-footer">\n <span class="last-size">Last Size: <span class="trade-size"></span></span>\n <span class="source">Market Data Powered by MDAS</span>\n </div>\n </div>\n\n \n </div>\n',this.addStyles()}addStyles(){if(!document.querySelector("#data-styles")){const t=document.createElement("style");t.id="data-styles",t.textContent="\n .data-widget {\n position: relative;\n border: 1px solid #ddd;\n border-radius: 8px;\n overflow: hidden;\n background-color: #fff;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);\n padding: 10px;\n font-family: Arial, sans-serif;\n }\n\n .data-widget .widget-header {\n display: flex;\n flex-direction: column;\n margin-bottom: 10px;\n }\n\n .data-widget .symbol {\n font-size: 24px;\n font-weight: bold;\n margin-right: 10px;\n }\n\n .data-widget .company-info {\n font-size: 12px;\n color: #666;\n }\n\n .data-widget .trading-info {\n font-size: 12px;\n color: #999;\n }\n\n .data-widget .price-section {\n display: flex;\n align-items: baseline;\n margin-bottom: 10px;\n }\n\n .data-widget .current-price {\n font-size: 36px;\n font-weight: bold;\n margin-right: 10px;\n }\n\n .data-widget .price-change {\n font-size: 18px;\n }\n\n .data-widget .price-change.positive {\n color: green;\n }\n\n .data-widget .price-change.negative {\n color: red;\n }\n\n .data-widget .bid-ask-section {\n display: flex;\n justify-content: space-between;\n margin-bottom: 10px;\n }\n\n .data-widget .ask,\n .data-widget .bid {\n display: flex;\n align-items: center;\n }\n\n .data-widget .label {\n font-size: 14px;\n margin-right: 5px;\n }\n\n .data-widget .value {\n font-size: 16px;\n font-weight: bold;\n margin-right: 5px;\n }\n\n .data-widget .size {\n font-size: 14px;\n color: red;\n }\n\n .data-widget .widget-footer {\n font-size: 12px;\n color: #333;\n }\n",document.head.appendChild(t)}}initializeSymbolEditor(){this.symbolEditor=new s(this,{maxLength:10,placeholder:"Enter symbol...",onSymbolChange:this.handleSymbolChange.bind(this),debug:this.debug,autoUppercase:!0,symbolType:"quotel1"});const t=this.container.querySelector(".symbol");t&&(t.textContent=this.symbol,t.dataset.originalSymbol=this.symbol)}async handleSymbolChange(t){this.debug&&console.log("[DataWidget] Symbol change requested:",t);const e=t.toUpperCase();if(e===this.symbol)return this.debug&&console.log("[DataWidget] Same symbol, no change needed"),{success:!0};try{const t=this.symbol;return this.showLoading(),this.loadingTimeout&&clearTimeout(this.loadingTimeout),this.loadingTimeout=setTimeout((()=>{this.debug&&console.log("[DataWidget] Loading timeout for symbol:",e),this.hideLoading(),this.showError(`No data received for ${e}. Please try again.`)}),1e4),this.unsubscribe&&(this.debug&&console.log(`[DataWidget] Unsubscribing from ${t}`),this.wsManager.sendUnsubscribe(this.dataSource,t),this.unsubscribe(),this.unsubscribe=null),this.symbol=e,this.debug&&console.log(`[DataWidget] Subscribing to ${e}`),this.subscribeToData(),this.debug&&console.log(`[DataWidget] Successfully changed symbol from ${t} to ${e}`),{success:!0}}catch(t){return console.error("[DataWidget] Error changing symbol:",t),this.hideLoading(),this.showError(`Failed to load data for ${e}`),{success:!1,error:`Failed to load ${e}`}}}initialize(){this.showLoading(),this.subscribeToData()}subscribeToData(){this.unsubscribe=this.wsManager.subscribe(this.widgetId,[this.dataSource],this.handleMessage.bind(this),this.symbol)}showNoDataState(t){let{Symbol:e,NotFound:n,message:i}=t;this.clearError(),this.hideLoading();const s=document.createElement("div");s.className="no-data-state",s.innerHTML=`\n <div class="no-data-content">\n <div class="no-data-icon">\n <svg width="32" height="32" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="12" cy="12" r="10" stroke="#9ca3af" stroke-width="2"/>\n <path d="M12 6v6l4 2" stroke="#9ca3af" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>\n </div>\n <h3 class="no-data-title">No Data Available</h3>\n <p class="no-data-description">Data for <strong>${e}</strong> was not found.</p>\n <p class="no-data-guidance">${i||"Please check the symbol or try again later."}</p>\n </div>\n `,this.container.appendChild(s)}handleData(t){if(this.loadingTimeout&&(clearTimeout(this.loadingTimeout),this.loadingTimeout=null),"error"===t.type&&t.noData)return this.debug&&console.log("[DataWidget] Received no data message:",t.message),void this.showNoDataState({Symbol:this.symbol,NotFound:!0,message:t.message});if("error"!==t.type){if(t.Data&&t.Data.length>0){const e=t.Data.find((t=>t.Symbol===this.symbol));if(e){const t=new i(e);this.updateWidget(t)}else console.log("hereee"),this.showNoDataState({Symbol:this.symbol,NotFound:!0,message:`No data found for ${this.symbol}`})}t._cached&&this.showConnectionQuality()}else{const e=t.message||"Server error";this.showError(e)}}updateWidget(t){if(!this.isDestroyed)try{this.clearError(),this.hideLoading();const e=this.container.querySelector(".symbol");e&&(e.textContent=t.symbol,e.dataset.originalSymbol=t.symbol);const n=this.container.querySelector(".current-price");n&&(n.textContent=t.formatPrice());const i=this.container.querySelector(".price-change"),s=i.querySelector(".change-value"),o=i.querySelector(".change-percent");s.textContent=t.formatPriceChange(),o.textContent=` (${t.formatPriceChangePercent()})`,i.classList.remove("positive","negative","neutral"),t.getPriceChange()>0?i.classList.add("positive"):t.getPriceChange()<0?i.classList.add("negative"):i.classList.add("neutral");const a=this.container.querySelector(".bid-price");a&&(a.textContent=t.bidPrice.toFixed(2));const r=this.container.querySelector(".ask-price");r&&(r.textContent=t.askPrice.toFixed(2));const l=this.container.querySelector(".bid-size");l&&(l.textContent=`× ${t.bidSize}`);const c=this.container.querySelector(".ask-size");c&&(c.textContent=`× ${t.askSize}`);const d=this.container.querySelector(".trade-size");d&&(d.textContent=t.tradeSize);const h=this.container.querySelector(".last-update");if(h){const e=f(t.quoteTime);h.textContent=`Last update: ${e}`}const u=this.container.querySelector(".data-source");u&&(u.textContent=`Source: ${t.getDataSource()}`)}catch(t){console.error("Error updating widget:",t),this.showError("Error updating data")}}}class D extends n{constructor(t,e,n){if(super(t,e,n),!e.symbol)throw new Error("Symbol is required for CombinedMarketWidget");if(!e.wsManager)throw new Error("WebSocketManager is required for CombinedMarketWidget");const i=g(e.symbol);if(!i.valid)throw new Error(`Invalid symbol: ${i.error}`);this.type="combined-market",this.wsManager=e.wsManager,this.symbol=i.sanitized,this.debug=e.debug||!1,this.removeNightSession=!0,this.marketData=null,this.nightSessionData=null,this.unsubscribeMarket=null,this.unsubscribeNight=null,this.createWidgetStructure(),this.initializeSymbolEditor(),this.subscribeToData()}createWidgetStructure(){this.container.innerHTML='\n <div class="combined-market-widget">\n <div class="combined-market-header">\n <div class="combined-symbol-section">\n <h1 class="combined-symbol editable-symbol"\n title="Double-click to edit symbol"\n data-original-symbol="">\n </h1>\n <div class="combined-company-info">\n <span class="company-name">\n </span>\n </div>\n </div>\n </div>\n\n <div class="combined-data-container">\n \x3c!-- Regular Market Data (Left) --\x3e\n <div class="combined-market-section regular-market">\n <div class="combined-price-info">\n <div class="combined-current-price">--</div>\n <div class="combined-price-change neutral">\n <span class="combined-change-value">--</span>\n <span class="combined-change-percent">(--)</span>\n </div>\n </div>\n <div class="combined-market-status"><span class="market-status-label"></span> <span class="combined-timestamp">--</span></div>\n </div>\n\n \x3c!-- Night Session Data (Right) --\x3e\n <div class="combined-market-section night-session">\n\n <div class="combined-price-info">\n <div class="combined-current-price">--</div>\n <div class="combined-price-change neutral">\n <span class="combined-change-value">--</span>\n <span class="combined-change-percent">(--)</span>\n </div>\n </div>\n <div class="combined-market-status">Overnight: <span class="combined-timestamp">--</span></div>\n </div>\n </div>\n\n <div class="combined-loading-overlay hidden">\n <div class="combined-loading-content">\n <div class="combined-loading-spinner"></div>\n <span class="combined-loading-text">Loading market data...</span>\n </div>\n </div>\n </div>\n';const t=this.container.querySelector(".combined-symbol");if(t&&(t.textContent=this.symbol,t.dataset.originalSymbol=this.symbol),this.removeNightSession&&!this.isNightSessionActive()){const t=this.container.querySelector(".night-session");t&&(t.style.display="none")}this.addStyles()}addStyles(){if(!document.querySelector("#combined-market-styles")){const t=document.createElement("style");t.id="combined-market-styles",t.textContent='\n .combined-market-widget {\n background: #ffffff;\n color: #111827;\n padding: 24px;\n border-radius: 12px;\n border: 1px solid #e5e7eb;\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n position: relative;\n }\n\n .combined-market-widget .combined-market-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: 24px;\n padding-bottom: 16px;\n border-bottom: 1px solid #e5e7eb;\n }\n\n .combined-market-widget .combined-symbol-section {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .combined-market-widget .combined-symbol {\n font-size: 24px;\n font-weight: 700;\n margin: 0;\n color: #111827;\n cursor: pointer;\n transition: all 0.2s ease;\n position: relative;\n }\n\n .combined-market-widget .combined-symbol:hover {\n opacity: 0.8;\n transform: scale(1.02);\n }\n\n .combined-market-widget .combined-symbol:hover::after {\n content: "✎";\n position: absolute;\n top: -8px;\n right: -8px;\n background: #3b82f6;\n color: white;\n font-size: 10px;\n padding: 2px 4px;\n border-radius: 4px;\n opacity: 0.8;\n pointer-events: none;\n }\n\n .combined-market-widget .follow-btn {\n background: #ffffff;\n border: 1px solid #d1d5db;\n color: #374151;\n padding: 8px 16px;\n border-radius: 20px;\n cursor: pointer;\n font-size: 14px;\n font-weight: 500;\n transition: all 0.2s;\n }\n\n .combined-market-widget .follow-btn:hover {\n border-color: #9ca3af;\n background: #f9fafb;\n }\n\n .combined-market-widget .combined-data-container {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 40px;\n }\n\n .combined-market-widget .combined-market-section {\n display: flex;\n flex-direction: column;\n gap: 8px;\n }\n\n .combined-market-widget .combined-price-info {\n display: flex;\n flex-direction: column;\n min-height: 90px;\n }\n\n .combined-market-widget .session-label {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 14px;\n color: #6b7280;\n margin-bottom: 4px;\n font-weight: 500;\n }\n\n .combined-market-widget .session-label .icon {\n font-size: 16px;\n }\n\n .combined-market-widget .combined-current-price {\n font-size: 48px;\n font-weight: 700;\n line-height: 1;\n color: #111827;\n }\n\n .combined-market-widget .combined-price-change {\n display: flex;\n gap: 8px;\n font-size: 20px;\n font-weight: 600;\n margin-top: 4px;\n }\n\n .combined-market-widget .combined-price-change.positive {\n color: #059669;\n }\n\n .combined-market-widget .combined-price-change.negative {\n color: #dc2626;\n }\n\n .combined-market-widget .combined-price-change.neutral {\n color: #6b7280;\n }\n\n .combined-market-widget .combined-market-status {\n font-size: 14px;\n color: #6b7280;\n margin-top: 8px;\n }\n\n .combined-market-widget .combined-timestamp {\n color: #9ca3af;\n font-weight: 400;\n }\n\n /* Loading overlay */\n .combined-market-widget .combined-loading-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(255, 255, 255, 0.95);\n backdrop-filter: blur(2px);\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 12px;\n z-index: 10;\n }\n\n .combined-market-widget .combined-loading-overlay.hidden {\n display: none;\n }\n\n .combined-market-widget .combined-loading-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 12px;\n }\n\n .combined-market-widget .combined-loading-spinner {\n width: 40px;\n height: 40px;\n border: 3px solid #e5e7eb;\n border-top-color: #3b82f6;\n border-radius: 50%;\n animation: combined-market-spin 1s linear infinite;\n }\n\n .combined-market-widget .combined-loading-text {\n color: #6b7280;\n font-size: 14px;\n font-weight: 500;\n }\n\n @keyframes combined-market-spin {\n to { transform: rotate(360deg); }\n }\n\n /* Responsive */\n @media (max-width: 768px) {\n .combined-market-widget .combined-data-container {\n grid-template-columns: 1fr;\n gap: 30px;\n }\n\n .combined-market-widget .combined-current-price {\n font-size: 36px;\n }\n\n .combined-market-widget .combined-price-change {\n font-size: 16px;\n }\n }\n',document.head.appendChild(t)}}initializeSymbolEditor(){this.symbolEditor=new s(this,{maxLength:10,placeholder:"Enter symbol...",onSymbolChange:this.handleSymbolChange.bind(this),debug:this.debug,autoUppercase:!0,symbolType:"quotel1"});const t=this.container.querySelector(".combined-symbol");t&&(t.textContent=this.symbol,t.dataset.originalSymbol=this.symbol)}async handleSymbolChange(t){this.debug&&console.log("[CombinedMarketWidget] Symbol change requested:",t);const e=g(t);if(!e.valid)return this.debug&&console.log("[CombinedMarketWidget] Invalid symbol:",e.error),{success:!1,error:e.error};const n=e.sanitized;if(n===this.symbol)return this.debug&&console.log("[CombinedMarketWidget] Same symbol, no change needed"),{success:!0};try{const t=this.symbol;return this.showLoading(),this.unsubscribeMarket&&(this.debug&&console.log(`[CombinedMarketWidget] Unsubscribing from market data: ${t}`),this.wsManager.sendUnsubscribe("queryl1",t),this.unsubscribeMarket(),this.unsubscribeMarket=null),this.unsubscribeNight&&(this.debug&&console.log(`[CombinedMarketWidget] Unsubscribing from night session: ${t}`),this.wsManager.sendUnsubscribe("queryblueoceanl1",t),this.unsubscribeNight(),this.unsubscribeNight=null),this.symbol=n,this.marketData=null,this.nightSessionData=null,this.debug&&console.log(`[CombinedMarketWidget] Subscribing to new symbol: ${n}`),this.subscribeToData(),this.debug&&console.log(`[CombinedMarketWidget] Successfully changed symbol from ${t} to ${n}`),{success:!0}}catch(t){return console.error("[CombinedMarketWidget] Error changing symbol:",t),this.hideLoading(),{success:!1,error:`Failed to load ${n}`}}}subscribeToData(){this.showLoading(),this.unsubscribeMarket=this.wsManager.subscribe(`${this.widgetId}-market`,["queryl1"],this.handleMessage.bind(this),this.symbol),this.unsubscribeNight=this.wsManager.subscribe(`${this.widgetId}-night`,["queryblueoceanl1"],this.handleMessage.bind(this),this.symbol)}handleData(t){const e=t.type;if(this.debug&&console.log(`[CombinedMarketWidget] handleData called with type: ${e}`,t),this.loadingTimeout&&(this.clearTimeout(this.loadingTimeout),this.loadingTimeout=null),Array.isArray(t)&&0===t.length&&(this.data?(this.hideLoading(),this.debug&&console.log("[OptionChainWidget] No new data, keeping cached data visible")):this.showNoDataState()),"error"===t.type||1==t.error)return this.debug&&console.log(`[CombinedMarketWidget] Received no data message for ${e}:`,t.message),"queryl1"!==e||this.marketData?"blueoceanl1"!==e||this.nightSessionData||this.debug&&console.log("[CombinedMarketWidget] No night session data available"):this.debug&&console.log("[CombinedMarketWidget] No market data available"),void this.hideLoading();if("error"===t.type){const n=t.message||"Server error";return this.debug&&console.log(`[CombinedMarketWidget] Error received for ${e}:`,n),void this.hideLoading()}if("object"==typeof t&&t.Message){const n=t.Message.toLowerCase();if(n.includes("no data")||n.includes("not found"))return this.debug&&console.log(`[CombinedMarketWidget] No data message for ${e}:`,t.Message),void this.hideLoading()}if("market"===e){if(t.Data&&Array.isArray(t.Data)){const e=t.Data.find((t=>t.Symbol===this.symbol));e?(this.debug&&console.log("[CombinedMarketWidget] Market data received:",e),this.marketData=new i(e),this.updateMarketSection(),this.hideLoading()):(this.debug&&console.log("[CombinedMarketWidget] No market data for symbol in response, keeping cached data"),this.hideLoading())}delete t._dataType}if("night"===e){if(Array.isArray(t)){const e=t.find((t=>t.Symbol===this.symbol));e?!0!==e.NotFound&&e.MarketName&&"BLUE"===e.MarketName?(this.debug&&console.log("[CombinedMarketWidget] Night session data received:",e),this.nightSessionData=new y(e),this.updateNightSessionSection(),this.hideLoading()):(this.debug&&console.log("[CombinedMarketWidget] Night session data not found or not available"),this.hideLoading()):(this.debug&&console.log("[CombinedMarketWidget] No night session data for symbol in response, keeping cached data"),this.hideLoading())}else"queryblueoceanl1"!==t.type&&"querybrucel1"!==t.type||(t[0]?.Symbol===this.symbol?!0!==t[0].NotFound&&t[0].MarketName&&"BLUE"===t[0].MarketName?(this.debug&&console.log("[CombinedMarketWidget] Night session data received (wrapped format):",t[0]),this.nightSessionData=new y(t[0]),this.updateNightSessionSection(),this.hideLoading()):(this.debug&&console.log("[CombinedMarketWidget] Night session data not found or not available (wrapped format)"),this.hideLoading()):(this.debug&&console.log("[CombinedMarketWidget] No matching symbol in wrapped response, keeping cached data"),this.hideLoading()));delete t._dataType}t._cached&&this.showConnectionQuality()}updateMarketSection(){if(!this.marketData)return;const t=this.container.querySelector(".regular-market"),e=this.container.querySelector(".company-name");if(e){const t=this.marketData.companyName||`${this.marketData.symbol} Inc.`,n=this.marketData.companyDescription||`${this.marketData.symbol}`;e.textContent=t,e.setAttribute("title",n),e.setAttribute("data-tooltip",n)}t.querySelector(".combined-current-price").textContent=this.marketData.formatPrice();const n=t.querySelector(".combined-price-change"),i=t.querySelector(".combined-change-value"),s=t.querySelector(".combined-change-percent"),o=this.marketData.change,a=o>0?"positive":o<0?"negative":"neutral";n.className=`combined-price-change ${a}`,i.textContent=this.marketData.formatPriceChange(),s.textContent=`(${this.marketData.formatPriceChangePercent()})`;const r=t.querySelector(".market-status-label");r&&(r.textContent=`${this.getSessionType()}:`);t.querySelector(".combined-timestamp").textContent=f(this.marketData.quoteTime,{format:"long"}),this.debug&&console.log("[CombinedMarketWidget] Updated market section:",this.marketData)}updateNightSessionSection(){if(!this.nightSessionData)return;const t=this.container.querySelector(".night-session");if(this.removeNightSession&&!this.isNightSessionActive())return t.style.display="none",void(this.debug&&console.log("[CombinedMarketWidget] Night session hidden (market closed)"));t.style.display="";const e=t.querySelector(".combined-current-price");e&&(e.textContent=this.nightSessionData.lastPrice?this.nightSessionData.formatPrice():"--");const n=t.querySelector(".combined-price-change"),i=t.querySelector(".combined-change-value"),s=t.querySelector(".combined-change-percent"),o=this.nightSessionData.change,a=o>0?"positive":o<0?"negative":"neutral";n.className=`combined-price-change ${a}`,i.textContent=null!==this.nightSessionData.change?this.nightSessionData.formatPriceChange():"--",s.textContent=`(${this.nightSessionData.formatPriceChangePercent()})`;t.querySelector(".combined-timestamp").textContent=f(this.nightSessionData.quoteTime,{format:"long"}),this.debug&&(console.log("connection quality:",this.connectionQuality),console.log("[CombinedMarketWidget] Updated night session section:",this.nightSessionData))}getSessionType(){const t=(new Date).toLocaleString("en-US",{timeZone:"America/New_York"}),e=new Date(t),n=e.getHours(),i=e.getMinutes(),s=60*n+i;return console.log("Current EST time:",n+":"+(i<10?"0":"")+i),s>=240&&s<570?"Pre-Market":s>=570&&s<960?"Market Hours":s>=960&&s<1200?"Post-Market":"Market Closed"}isNightSessionActive(){return"Market Closed"===this.getSessionType()}destroy(){this.unsubscribeMarket&&(this.unsubscribeMarket(),this.unsubscribeMarket=null),this.unsubscribeNight&&(this.unsubscribeNight(),this.unsubscribeNight=null),this.symbolEditor&&(this.symbolEditor.destroy(),this.symbolEditor=null),super.destroy()}}class P{constructor(t){Array.isArray(t)?(console.log("[IntradayChartModel] Processing",t.length,"raw data points"),t.length>0&&console.log("[IntradayChartModel] Sample raw point:",t[0]),this.dataPoints=t.map(((t,e)=>{const n={symbol:t.symbol||t.Symbol,time:t.time||t.Time||t.timestamp||t.Timestamp,open:parseFloat(t.open||t.Open)||0,high:parseFloat(t.high||t.High)||0,low:parseFloat(t.low||t.Low)||0,close:parseFloat(t.close||t.Close)||0,volume:parseInt(t.volume||t.Volume)||0,source:t.source||t.Source};return e<2&&console.log(`[IntradayChartModel] Processed point ${e}:`,n),n.time||console.warn(`[IntradayChartModel] Point ${e} missing time:`,t),0===n.close&&console.warn(`[IntradayChartModel] Point ${e} has zero close price:`,t),n})).filter((t=>{if(!t.time||t.close<=0)return!1;const e=new Date(t.time).getTime();return!(isNaN(e)||e<9466848e5)||(console.warn("[IntradayChartModel] Invalid timestamp:",t.time),!1)})),this.dataPoints.sort(((t,e)=>new Date(t.time).getTime()-new Date(e.time).getTime())),console.log("[IntradayChartModel] Valid data points after filtering:",this.dataPoints.length),this.dataPoints.length>0&&console.log("[IntradayChartModel] Time range:",this.dataPoints[0].time,"to",this.dataPoints[this.dataPoints.length-1].time)):(console.warn("[IntradayChartModel] Expected array of data points, got:",typeof t),this.dataPoints=[]),this.symbol=this.dataPoints.length>0?this.dataPoints[0].symbol:null,this.source=this.dataPoints.length>0?this.dataPoints[0].source:null}getTimeLabels(){return this.dataPoints.map((t=>{const e=new Date(t.time);let n=e.getHours();const i=n>=12?"PM":"AM";n%=12,n=n||12;return[`${n}:${e.getMinutes().toString().padStart(2,"0")} ${i}`,`${(e.getMonth()+1).toString().padStart(2,"0")}/${e.getDate().toString().padStart(2,"0")}`]}))}getOHLCData(){return this.dataPoints.map((t=>({x:new Date(t.time).getTime(),o:t.open,h:t.high,l:t.low,c:t.close})))}getClosePrices(){return this.dataPoints.map((t=>t.close))}getVolumeData(){return this.dataPoints.map((t=>t.volume))}getHighPrices(){return this.dataPoints.map((t=>t.high))}getLowPrices(){return this.dataPoints.map((t=>t.low))}getOpenPrices(){return this.dataPoints.map((t=>t.open))}getStats(){if(0===this.dataPoints.length)return{high:0,low:0,open:0,close:0,change:0,changePercent:0,volume:0};this.getClosePrices();const t=this.getHighPrices(),e=this.getLowPrices(),n=this.getVolumeData(),i=this.dataPoints[0],s=this.dataPoints[this.dataPoints.length-1],o=s.close-i.open,a=0!==i.open?o/i.open*100:0;return{high:Math.max(...t),low:Math.min(...e),open:i.open,close:s.close,change:o,changePercent:a,volume:n.reduce(((t,e)=>t+e),0),dataPoints:this.dataPoints.length}}formatPrice(t){return t.toFixed(2)}formatVolume(t){return t>=1e6?(t/1e6).toFixed(2)+"M":t>=1e3?(t/1e3).toFixed(2)+"K":t.toString()}}
|
|
1
|
+
!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).MdasSDK={})}(this,(function(t){"use strict";class e{constructor(){this.state=new Map,this.listeners=new Map}setState(t,e){this.state.set(t,e),this.notifyListeners(t,e)}getState(t){return this.state.get(t)}subscribe(t,e){return this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(e),()=>{const n=this.listeners.get(t);n&&n.delete(e)}}notifyListeners(t,e){const n=this.listeners.get(t);n&&n.forEach((t=>t(e)))}clear(){this.state.clear(),this.listeners.clear()}}class n{constructor(t,e,n){this.setContainer(t),this.options=e,this.widgetId=n,this.isDestroyed=!1,this.lastData=null,this.lastDataTimestamp=null,this.connectionQuality="disconnected",this.eventListeners=[],this.timeouts=[],this.intervals=[]}setContainer(t){if(!t)throw new Error("DOM element is required for widget");if("string"==typeof t){const e=document.querySelector(t);if(!e)throw new Error(`Element not found: ${t}`);this.container=e}else{if(t.nodeType!==Node.ELEMENT_NODE)throw new Error("Invalid element provided to widget");this.container=t}}showLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.remove("hidden")}hideLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.add("hidden")}showError(t){this.hideLoading(),this.clearError();const e=document.createElement("div");e.className="widget-error",e.textContent=`Error: ${t}`,this.container.appendChild(e)}clearError(){const t=this.container.querySelector(".widget-error");t&&t.remove()}showConnectionQuality(){const t=this.container.querySelector(".connection-quality");if(t&&t.remove(),"live"===this.connectionQuality)return;const e=this.container.querySelector('.last-update, [class*="last-update"], [class*="timestamp"]');if(e){const t=document.createElement("span");switch(t.className="connection-quality",this.connectionQuality){case"offline":t.textContent=" (disconnected)",t.style.color="#dc2626",t.style.fontWeight="500";break;case"reconnecting":t.textContent=" (reconnecting...)",t.style.color="#d97706"}t.style.fontSize="11px",e.appendChild(t)}}handleMessage(t){if(!this.isDestroyed)try{const{event:e,data:n}=t;if(console.log("[BaseWidget] handleMessage called with event:",e,"data:",n),this.debug&&console.log(`[${this.type}] Received:`,e,n),"connection"===e)return void this.handleConnectionStatus(n);if("data"===e)return console.log("[BaseWidget] Caching live data"),this.lastData=n,this.lastDataTimestamp=Date.now(),this.connectionQuality="live",void this.handleData(n);if("session_revoked"===e)return void this.handleSessionRevoked(n);this.handleCustomEvent&&this.handleCustomEvent(e,n)}catch(t){console.error(`[${this.constructor.name}] Error handling message:`,t),this.showError("Error processing data")}}handleSessionRevoked(t){"attempting_relogin"===t.status?(this.connectionQuality="reconnecting",this.lastData?this.showCachedData():this.showLoading()):"relogin_failed"===t.status?(this.connectionQuality="offline",this.showError(t.error||"Session expired. Please refresh the page.")):"relogin_successful"===t.status&&(this.connectionQuality="live",this.hideLoading(),this.clearError())}handleData(t){throw new Error("handleData must be implemented by child widget")}handleConnectionStatus(t){"connected"===t.status?(this.connectionQuality="live",this.clearError(),this.hideLoading()):"reconnecting"===t.status?(this.connectionQuality="reconnecting",this.lastData?this.showCachedData():this.showLoading()):"disconnected"===t.status?(this.connectionQuality="offline",this.lastData?this.showCachedData():this.hideLoading()):"failed"===t.status?(this.connectionQuality="offline",this.handleConnectionFailed(t),this.showConnectionQuality()):"error"===t.status&&(this.connectionQuality="offline",this.lastData?this.showCachedData():this.hideLoading())}showCachedData(){if(this.lastData&&this.lastDataTimestamp){const t=Date.now()-this.lastDataTimestamp,e=t>3e5,n={...this.lastData,_cached:!0,_cacheAge:t,_isStale:e,_quality:this.connectionQuality};this.handleData(n)}}addEventListener(t,e,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};t&&e&&n?(t.addEventListener(e,n,i),this.eventListeners.push({element:t,event:e,handler:n,options:i})):console.warn("[BaseWidget] Invalid addEventListener parameters")}setTimeout(t,e){const n=setTimeout(t,e);return this.timeouts.push(n),n}setInterval(t,e){const n=setInterval(t,e);return this.intervals.push(n),n}clearTimeout(t){clearTimeout(t);const e=this.timeouts.indexOf(t);e>-1&&this.timeouts.splice(e,1)}clearInterval(t){clearInterval(t);const e=this.intervals.indexOf(t);e>-1&&this.intervals.splice(e,1)}showInputError(t,e){if(!t)return;this.clearInputError(t);const n=document.createElement("div");n.className="input-error-message",n.textContent=e,n.style.cssText="\n color: #dc2626;\n font-size: 12px;\n margin-top: 4px;\n animation: slideDown 0.2s ease-out;\n ",t.classList.add("input-error"),t.style.borderColor="#dc2626",t.parentNode&&t.parentNode.insertBefore(n,t.nextSibling),t.errorElement=n}clearInputError(t){t&&(t.errorElement&&(t.errorElement.remove(),t.errorElement=null),t.classList.remove("input-error"),t.style.borderColor="")}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.eventListeners.forEach((t=>{let{element:e,event:n,handler:i,options:s}=t;try{e.removeEventListener(n,i,s)}catch(t){console.error("[BaseWidget] Error removing event listener:",t)}})),this.eventListeners=[],this.timeouts.forEach((t=>{clearTimeout(t)})),this.timeouts=[],this.intervals.forEach((t=>{clearInterval(t)})),this.intervals=[],this.lastData=null,this.container&&(this.container.innerHTML=""),this.debug&&console.log(`[${this.constructor.name}] Widget destroyed and cleaned up`))}handleConnectionFailed(t){this.connectionQuality="offline",this.lastData?(this.showCachedData(),this.hideLoading()):this.hideLoading(),this.debug&&console.log(`[${this.constructor.name}] Connection failed after ${t.maxAttempts} attempts`)}async validateInitialSymbol(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;try{const i=this.wsManager?.getApiService();if(!i)return this.debug&&console.log(`[${this.constructor.name}] API service not available for initial validation`),!0;if(!i[t])return console.error(`[${this.constructor.name}] API method ${t} does not exist`),!0;const s=await i[t](e);return s&&s.data&&s.data.length>0?(this.debug&&console.log(`[${this.constructor.name}] Initial symbol validated:`,{symbol:e,method:t,dataCount:s.data.length}),n&&"function"==typeof n&&n(s.data,s),!0):(this.debug&&console.log(`[${this.constructor.name}] No data returned from ${t} for ${e}`),!0)}catch(t){this.debug&&console.warn(`[${this.constructor.name}] Initial symbol validation failed:`,t);const n=(t.message||"").toLowerCase();if(n.includes("400")||n.includes("401")||n.includes("403")||n.includes("forbidden")||n.includes("unauthorized")||n.includes("no access")||n.includes("no opra access")||n.includes("permission denied")||n.includes("access denied")){this.hideLoading();let t=`Access denied: You don't have permission to view data for ${e}`;return n.includes("no opra access")&&(t=`Access denied: You don't have OPRA access for option ${e}`),this.showError(t),!1}return!0}}}class i{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.symbol=t.Symbol||"",this.companyName=t.CompName||"",this.companyDescription=t.CompDesc||"",this.instrumentType=t.InstrType||"",this.lastPrice=t.LastPx||0,this.previousClose=t.YestClosePx||0,this.open=t.OpenPx||0,this.high=t.HighPx||0,this.low=t.LowPx||0,this.close=t.ClosingPx||0,this.change=t.Change||0,this.changePercent=t.ChangePercent||0,this.vwap=t.VWAP||0,this.volume=t.Volume||0,this.averageVolume=t.AvgVol30d||0,this.yesterdayVolume=t.YesterdayTradeVolume||0,this.bidPrice=t.BidPx||0,this.bidSize=t.BidSz||0,this.bidExchange=t.BidExch||"",this.askPrice=t.AskPx||0,this.askSize=t.AskSz||0,this.askExchange=t.AskExch||"",this.issueMarket=t.IssueMarket||"",this.marketName=t.MarketName||"",this.marketDescription=t.MarketDesc||"",this.mic=t.MIC||"",this.countryCode=t.CountryCode||"",this.timeZone=t.TimeZone||"",this.tradePrice=t.TradePx||0,this.tradeSize=t.TradeSz||0,this.tradeCondition=t.Condition||0,this.tradeTime=t.TradeTime||"",this.tradeRegion=t.TradeRegion||"",this.tradeRegionName=t.TradeRegionName||"",this.preMarketPrice=t.PreLastPx||0,this.preMarketTradeTime=t.PreTradeTime||"",this.postMarketPrice=t.PostLastPx||0,this.postMarketTradeTime=t.PostTradeTime||"",this.high52Week=t.High52wPx||0,this.low52Week=t.Low52wPx||0,this.high52WeekDate=t.High52wDate||"",this.low52WeekDate=t.Low52wDate||"",this.calendarYearHigh=t.CalendarYearHigh||0,this.calendarYearLow=t.CalendarYearLow||0,this.calendarYearHighDate=t.CalendarYearHighDate||"",this.calendarYearLowDate=t.CalendarYearLowDate||"",this.marketCap=t.MktCap||0,this.peRatio=t.PeRatio||0,this.beta=t.FundBeta||0,this.sharesOutstanding=t.ComShrsOut||0,this.dividendYield=t.DivYield||0,this.dividendAmount=t.DivAmt||0,this.dividendRate=t.DividendRate||0,this.dividendPaymentDate=t.DividendPaymentDate||t.PayDate||"",this.dividendExDate=t.DividendExDate||t.DivDateEx||"",this.isin=t.ISIN||"",this.cusip=t.CUSIP||"",this.sedol=t.SEDOL||"",this.gics=t.GICS||"",this.status=t.Status||"",this.dataSource=t.DataSource||"",this.quoteTime=t.QuoteTime||"",this.infoTime=t.InfoTime||""}get openPrice(){return this.open}get description(){return this.companyDescription}get lastUpdate(){return this.quoteTime||this.infoTime}getSecurityType(){return{257:"Stock",262:"ETF",261:"Mutual Fund",258:"Bond",260:"Option",263:"Future",259:"Index"}[this.instrumentType]||"Stock"}getPriceChange(){return this.change}getPriceChangePercent(){return 100*this.changePercent}getDataSource(){return"delay"===this.dataSource.toLowerCase()?"20 mins delayed":"real-time"===this.dataSource.toLowerCase()?"Real-time":null!==this.dataSource&&""!==this.dataSource?this.dataSource:"MDAS Server"}getCurrentPrice(){return this.lastPrice}get52WeekRange(){return`${this.low52Week.toFixed(2)} - ${this.high52Week.toFixed(2)}`}getMarketCapFormatted(){return this.formatMarketCap()}formatPrice(){return`$${(arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.lastPrice).toFixed(2)}`}formatPriceChange(){const t=this.getPriceChange();return`${t>=0?"+":""} ${t.toFixed(2)}`}formatPriceChangePercent(){const t=this.getPriceChangePercent();return`${t>=0?"+":""}${t.toFixed(2)}%`}formatBidAsk(){return`$${this.bidPrice.toFixed(2)} x ${this.bidSize} / $${this.askPrice.toFixed(2)} x ${this.askSize}`}formatVolume(){return 0===this.volume?"N/A":this.volume.toLocaleString()}formatAvgVolume(){return 0===this.averageVolume?"N/A":this.averageVolume.toLocaleString()}formatAverageVolume(){return 0===this.averageVolume?"N/A":this.averageVolume.toLocaleString()}formatDayRange(){return 0===this.low&&0===this.high?"N/A":`$${this.low.toFixed(2)} - $${this.high.toFixed(2)}`}format52WeekRange(){return 0===this.low52Week&&0===this.high52Week?"N/A":`${this.low52Week.toFixed(2)} - ${this.high52Week.toFixed(2)}`}formatMarketCap(){if(0===this.marketCap)return"N/A";const t=1e6*this.marketCap;return t>=1e12?`$${(t/1e12).toFixed(2)}T`:t>=1e9?`$${(t/1e9).toFixed(2)}B`:t>=1e6?`$${(t/1e6).toFixed(2)}M`:t>=1e3?`$${(t/1e3).toFixed(2)}K`:`$${t.toFixed(2)}`}formatAvg30DayVolume(){return this.formatAverageVolume()}static fromApiResponse(t){return new i(t)}}class s{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.widget=t,this.options={maxLength:e.maxLength||10,placeholder:e.placeholder||"Enter symbol...",onSymbolChange:e.onSymbolChange||(()=>{}),debug:e.debug||!1,autoUppercase:!1!==e.autoUppercase,...e},this.symbolType=e.symbolType||null,this.apiService=this.widget.wsManager.getApiService(),this.isEditing=!1,this.isValidating=!1,this.originalSymbol="",this.elements={},this.addStyles(),this.initialize()}initialize(){this.setupElements(),this.attachEventListeners()}setupElements(){if(this.elements.symbolDisplay=this.widget.container.querySelector(".editable-symbol"),!this.elements.symbolDisplay)throw new Error('No element with class "editable-symbol" found in widget');this.originalSymbol=this.elements.symbolDisplay.textContent.trim(),this.elements.symbolDisplay.dataset.originalSymbol=this.originalSymbol}attachEventListeners(){this.startEditing=this.startEditing.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.handleInput=this.handleInput.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleClickOutside=this.handleClickOutside.bind(this),this.elements.symbolDisplay.addEventListener("dblclick",this.startEditing)}startEditing(){this.isEditing||this.isValidating||(this.isEditing=!0,this.originalSymbol=this.elements.symbolDisplay.textContent.trim(),this.options.debug&&(console.log(this.widget.connectionQuality),console.log("[SymbolEditor] Starting edit mode for:",this.originalSymbol)),this.transformToInput())}transformToInput(){const t=this.elements.symbolDisplay,e=window.getComputedStyle(t),n=document.createElement("div");n.className="symbol-edit-container",n.style.display="inline-flex",n.style.alignItems="center",n.style.gap="8px",n.style.verticalAlign="baseline";const i=document.createElement("input");i.type="text",i.value=this.originalSymbol,i.className=t.className+" symbol-input-mode",i.style.fontSize=e.fontSize,i.style.fontWeight=e.fontWeight,i.style.fontFamily=e.fontFamily,i.style.color=e.color,i.style.backgroundColor="transparent",i.style.border="2px solid #3b82f6",i.style.borderRadius="4px",i.style.padding="2px 6px",i.style.margin="0",i.style.outline="none",i.style.width="auto",i.style.minWidth="120px",i.style.maxWidth="200px",i.style.flexShrink="0";const s=document.createElement("button");s.className="symbol-save-btn",s.innerHTML="✓",s.title="Save symbol",s.style.width="28px",s.style.height="28px",s.style.border="none",s.style.borderRadius="4px",s.style.backgroundColor="#059669",s.style.color="white",s.style.cursor="pointer",s.style.fontSize="12px",s.style.display="inline-flex",s.style.alignItems="center",s.style.justifyContent="center",s.style.flexShrink="0",n.appendChild(i),n.appendChild(s),t.style.display="none",t.parentNode.insertBefore(n,t.nextSibling),this.elements.symbolInput=i,this.elements.saveBtn=s,this.elements.editContainer=n,i.focus(),i.select(),i.addEventListener("keydown",this.handleKeydown),i.addEventListener("input",this.handleInput),i.addEventListener("blur",this.handleBlur),document.addEventListener("click",this.handleClickOutside),s.addEventListener("click",(t=>{t.stopPropagation(),this.saveSymbol()}))}async saveSymbol(){if(this.isValidating)return;const t=this.elements.symbolInput.value.trim(),e=await this.validateSymbol(t);if(!e.isValid)return this.showError(e.message),void setTimeout((()=>{this.elements.symbolInput&&(this.elements.symbolInput.value=this.originalSymbol,this.clearError(),this.cancelEditing())}),2e3);this.setLoadingState(!0);try{const n=await this.options.onSymbolChange(t,this.originalSymbol,e.data);if(n&&n.success)this.finishEditing(t),this.showSuccess("Symbol updated successfully");else{const t=n?.message||"Failed to update symbol";this.showError(t)}}catch(t){console.error("[SymbolEditor] Error changing symbol:",t),this.showError("Error updating symbol")}finally{this.setLoadingState(!1)}}cancelEditing(){this.options.debug&&console.log("[SymbolEditor] Cancelling edit mode"),this.finishEditing(this.originalSymbol)}finishEditing(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.isEditing=!1;const e=t||this.originalSymbol;this.elements.symbolDisplay.textContent=e,this.elements.symbolDisplay.dataset.originalSymbol=e,this.elements.symbolDisplay.style.display="",this.elements.editContainer&&(this.elements.editContainer.remove(),this.elements.editContainer=null),this.elements.symbolInput=null,this.elements.saveBtn=null,document.removeEventListener("click",this.handleClickOutside)}handleKeydown(t){"Enter"===t.key?(t.preventDefault(),this.saveSymbol()):"Escape"===t.key&&(t.preventDefault(),this.cancelEditing())}handleInput(t){if(this.options.autoUppercase){const e=t.target,n=e.selectionStart,i=e.selectionEnd;e.value=e.value.toUpperCase(),e.setSelectionRange(n,i)}this.clearError()}handleBlur(t){t.relatedTarget&&t.relatedTarget===this.elements.saveBtn||setTimeout((()=>{this.isEditing&&this.cancelEditing()}),150)}handleClickOutside(t){if(!this.isEditing)return;this.elements.symbolInput?.contains(t.target)||this.elements.saveBtn?.contains(t.target)||this.cancelEditing()}async validateSymbol(t){if("live"!==this.widget.connectionQuality)return{isValid:!1,message:"Not connected to data service"};if(!t||0===t.trim().length)return{isValid:!1,message:"Symbol cannot be empty"};const e=t.trim().toUpperCase();try{if("optionsl1"==this.symbolType){const t=await this.apiService.quoteOptionl1(e);return t[0]&&(t[0].error||1==t[0].not_found)?1==t[0].not_found?{isValid:!1,message:"Symbol not found"}:{isValid:!1,message:t[0].error}:{isValid:!0,data:t[0]}}if("quotel1"==this.symbolType||"nightsession"==this.symbolType){const t=await this.apiService.quotel1(e);return t&&t.message?t.message.includes("no data")?{isValid:!1,message:"Symbol not found"}:{isValid:!1,message:t.message}:{isValid:!0,data:t.data[0]}}if("nightsession"==this.symbolType){const t=await this.apiService.quoteBlueOcean(e);return t[0]&&1==t[0].not_found?{isValid:!1,message:"Symbol not found"}:t[0]&&0==t[0].not_found?{isValid:!0,data:t[0]}:{isValid:!1,message:t[0].error}}}catch(t){return console.warn("[SymbolEditor] API validation failed, falling back to basic validation:",t),this.defaultValidator(e)}return this.defaultValidator(e)}defaultValidator(t){return t&&0!==t.length?t.length>this.options.maxLength?{isValid:!1,message:`Symbol too long (max ${this.options.maxLength} chars)`}:{isValid:!0,data:null}:{isValid:!1,message:"Symbol cannot be empty"}}setLoadingState(t){this.isValidating=t,this.elements.saveBtn&&(t?(this.elements.saveBtn.innerHTML='<div class="loading-spinner"></div>',this.elements.saveBtn.disabled=!0):(this.elements.saveBtn.innerHTML="✓",this.elements.saveBtn.disabled=!1)),this.elements.symbolInput&&(this.elements.symbolInput.disabled=t)}showError(t){if(this.elements.symbolInput){this.elements.symbolInput.style.borderColor="#dc2626",this.elements.symbolInput.style.boxShadow="0 0 0 3px rgba(220, 38, 38, 0.1)",this.removeErrorMessage();const e=document.createElement("div");e.className="symbol-error-message",e.textContent=t,e.style.cssText="\n color: #dc2626;\n font-size: 12px;\n margin-bottom: 2px;\n position: absolute;\n background: white;\n z-index: 1000;\n transform: translateY(-100%);\n top: -4px;\n left: 0; // Align with input box\n ";const n=this.elements.editContainer;n&&(n.style.position="relative",n.appendChild(e)),this.elements.errorMessage=e,this.elements.symbolInput.focus()}}removeErrorMessage(){this.elements.errorMessage&&(this.elements.errorMessage.remove(),this.elements.errorMessage=null)}clearError(){this.elements.symbolInput&&(this.elements.symbolInput.style.borderColor="#3b82f6",this.elements.symbolInput.style.boxShadow="0 0 0 3px rgba(59, 130, 246, 0.1)",this.elements.symbolInput.title=""),this.removeErrorMessage()}showSuccess(t){this.options.debug&&console.log("[SymbolEditor] Success:",t)}updateSymbol(t){const e=this.options.autoUppercase?t.toUpperCase():t;this.elements.symbolDisplay.textContent=e,this.elements.symbolDisplay.dataset.originalSymbol=e,this.options.debug&&console.log("[SymbolEditor] Symbol updated externally:",e)}destroy(){this.finishEditing(),this.elements.symbolDisplay?.removeEventListener("dblclick",this.startEditing)}addStyles(){if(document.querySelector("#symbol-editor-styles"))return;const t=document.createElement("style");t.id="symbol-editor-styles",t.textContent='\n .editable-symbol {\n cursor: pointer;\n transition: all 0.2s ease;\n position: relative;\n }\n\n .editable-symbol:hover {\n opacity: 0.8;\n transform: scale(1.02);\n }\n\n .editable-symbol:hover::after {\n content: "✎";\n position: absolute;\n top: -8px;\n right: -8px;\n background: #3b82f6;\n color: white;\n font-size: 10px;\n padding: 2px 4px;\n border-radius: 4px;\n opacity: 0.8;\n pointer-events: none;\n }\n\n .symbol-input-mode {\n text-transform: uppercase;\n }\n\n .symbol-save-btn:hover {\n background-color: #047857 !important;\n transform: scale(1.05);\n }\n\n .symbol-save-btn:disabled {\n background-color: #9ca3af !important;\n cursor: not-allowed !important;\n transform: none !important;\n }\n\n .loading-spinner {\n width: 12px;\n height: 12px;\n border: 2px solid rgba(255, 255, 255, 0.3);\n border-top-color: white;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n }\n\n @keyframes spin {\n to { transform: rotate(360deg); }\n }\n ',document.head.appendChild(t)}}const o="\n/* ============================================\n MDAS WIDGET CSS VARIABLES\n ============================================ */\n\n:root {\n /* --- FONT SIZE SYSTEM --- */\n /* Base font size - all other sizes are relative to this */\n --mdas-base-font-size: 14px;\n\n /* Component-specific font sizes (em units scale with base) */\n --mdas-small-text-size: 0.79em; /* 11px at 14px base */\n --mdas-medium-text-size: 0.93em; /* 13px at 14px base */\n --mdas-large-text-size: 1.14em; /* 16px at 14px base */\n\n /* Widget element sizes */\n --mdas-company-name-size: 1.43em; /* 20px at 14px base */\n --mdas-symbol-size: 1.79em; /* 25px at 14px base */\n --mdas-price-size: 2.29em; /* 32px at 14px base */\n --mdas-change-size: 1.14em; /* 16px at 14px base */\n\n /* Data display sizes */\n --mdas-label-size: 0.86em; /* 12px at 14px base */\n --mdas-value-size: 1em; /* 14px at 14px base */\n --mdas-footer-size: 0.79em; /* 11px at 14px base */\n\n /* Chart-specific sizes */\n --mdas-chart-title-size: 1.29em; /* 18px at 14px base */\n --mdas-chart-label-size: 0.93em; /* 13px at 14px base */\n --mdas-chart-value-size: 1.43em; /* 20px at 14px base */\n\n /* --- COLOR PALETTE (for future theming support) --- */\n /* Primary colors */\n --mdas-primary-color: #3b82f6;\n --mdas-primary-hover: #2563eb;\n\n /* Status colors */\n --mdas-color-positive: #059669;\n --mdas-color-positive-bg: #d1fae5;\n --mdas-color-negative: #dc2626;\n --mdas-color-negative-bg: #fee2e2;\n --mdas-color-neutral: #6b7280;\n\n /* Background colors */\n --mdas-bg-primary: #ffffff;\n --mdas-bg-secondary: #f9fafb;\n --mdas-bg-tertiary: #f3f4f6;\n\n /* Text colors */\n --mdas-text-primary: #111827;\n --mdas-text-secondary: #6b7280;\n --mdas-text-tertiary: #9ca3af;\n\n /* Border colors */\n --mdas-border-primary: #e5e7eb;\n --mdas-border-secondary: #d1d5db;\n\n /* --- SPACING SYSTEM --- */\n --mdas-spacing-xs: 4px;\n --mdas-spacing-sm: 8px;\n --mdas-spacing-md: 16px;\n --mdas-spacing-lg: 24px;\n --mdas-spacing-xl: 32px;\n\n /* --- EFFECTS --- */\n --mdas-border-radius: 8px;\n --mdas-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);\n --mdas-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);\n --mdas-shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);\n\n /* --- Z-INDEX LAYERS --- */\n --mdas-z-base: 1;\n --mdas-z-sticky: 10;\n --mdas-z-overlay: 100;\n --mdas-z-modal: 10000;\n}\n\n/* ============================================\n RESPONSIVE FONT SCALING\n ============================================ */\n\n/* Tablet breakpoint - slightly smaller fonts */\n@media (max-width: 768px) {\n :root {\n --mdas-base-font-size: 13px;\n }\n}\n\n/* Mobile breakpoint - smaller fonts for small screens */\n@media (max-width: 480px) {\n :root {\n --mdas-base-font-size: 12px;\n }\n}\n\n/* ============================================\n OPTIONAL UTILITY CLASSES\n Use these classes for consistent styling\n ============================================ */\n\n/* Widget card styling - apply to widget root element */\n.mdas-card {\n background: var(--mdas-bg-primary);\n border-radius: var(--mdas-border-radius);\n padding: var(--mdas-spacing-lg);\n box-shadow: var(--mdas-shadow-md);\n border: 1px solid var(--mdas-border-primary);\n}\n\n/* Responsive container */\n.mdas-container {\n width: 100%;\n max-width: 1400px;\n margin: 0 auto;\n}\n\n/* Text utilities */\n.mdas-text-primary {\n color: var(--mdas-text-primary);\n}\n\n.mdas-text-secondary {\n color: var(--mdas-text-secondary);\n}\n\n.mdas-text-muted {\n color: var(--mdas-text-tertiary);\n}\n\n/* Status colors */\n.mdas-positive {\n color: var(--mdas-color-positive);\n}\n\n.mdas-negative {\n color: var(--mdas-color-negative);\n}\n\n.mdas-neutral {\n color: var(--mdas-color-neutral);\n}\n",a=t=>`\n/* Loading Overlay for ${t} */\n.${t} .widget-loading-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(255, 255, 255, 0.95);\n backdrop-filter: blur(2px);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: var(--mdas-z-overlay, 100);\n border-radius: var(--mdas-border-radius, 12px);\n}\n\n.${t} .widget-loading-overlay.hidden {\n display: none;\n}\n\n.${t} .loading-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 12px;\n}\n\n.${t} .loading-spinner {\n width: 40px;\n height: 40px;\n border: 4px solid var(--mdas-border-primary, #e5e7eb);\n border-top-color: var(--mdas-primary-color, #3b82f6);\n border-radius: 50%;\n animation: ${t}-spin 1s linear infinite;\n}\n\n.${t} .loading-text {\n color: var(--mdas-text-secondary, #6b7280);\n font-size: var(--mdas-medium-text-size, 0.93em);\n font-weight: 500;\n}\n\n@keyframes ${t}-spin {\n to { transform: rotate(360deg); }\n}\n`,r=t=>`\n/* Error Display for ${t} */\n.${t} .widget-error {\n padding: 16px 20px;\n background: var(--mdas-color-negative-bg, #fee2e2);\n border: 1px solid #fecaca;\n border-radius: var(--mdas-border-radius, 8px);\n color: var(--mdas-color-negative, #dc2626);\n font-size: var(--mdas-medium-text-size, 0.93em);\n margin: 16px;\n text-align: center;\n}\n\n.${t} .widget-error-container {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 12px;\n padding: 24px;\n}\n`,l=t=>`\n/* Footer for ${t} */\n.${t} .widget-footer {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 8px 16px;\n background: var(--mdas-bg-secondary, #f9fafb);\n border-top: 1px solid var(--mdas-border-primary, #e5e7eb);\n font-size: var(--mdas-footer-size, 0.79em);\n color: var(--mdas-text-secondary, #6b7280);\n}\n\n.${t} .widget-footer .last-update {\n color: var(--mdas-text-tertiary, #9ca3af);\n}\n\n.${t} .widget-footer .data-source {\n color: var(--mdas-text-secondary, #6b7280);\n font-weight: 500;\n}\n`,c=t=>`\n/* No Data State for ${t} */\n.${t} .no-data-state {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 40px 20px;\n text-align: center;\n color: var(--mdas-text-secondary, #6b7280);\n}\n\n.${t} .no-data-content {\n max-width: 400px;\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 16px;\n}\n\n.${t} .no-data-icon {\n width: 64px;\n height: 64px;\n display: flex;\n align-items: center;\n justify-content: center;\n opacity: 0.5;\n}\n\n.${t} .no-data-icon svg {\n width: 100%;\n height: 100%;\n}\n\n.${t} .no-data-title {\n font-size: var(--mdas-large-text-size, 1.14em);\n font-weight: 600;\n color: var(--mdas-text-primary, #111827);\n margin: 0;\n}\n\n.${t} .no-data-description {\n font-size: var(--mdas-medium-text-size, 0.93em);\n color: var(--mdas-text-secondary, #6b7280);\n margin: 0;\n line-height: 1.5;\n}\n\n.${t} .no-data-description strong {\n color: var(--mdas-text-primary, #111827);\n font-weight: 600;\n}\n\n.${t} .no-data-guidance {\n font-size: var(--mdas-small-text-size, 0.79em);\n color: var(--mdas-text-tertiary, #9ca3af);\n margin: 0;\n}\n\n/* Error variant of no-data state */\n.${t} .no-data-state.error-access {\n color: var(--mdas-color-negative, #dc2626);\n}\n\n.${t} .no-data-state.error-access .no-data-title {\n color: var(--mdas-color-negative, #dc2626);\n}\n\n.${t} .no-data-state.error-access .no-data-icon {\n opacity: 0.8;\n}\n\n.${t} .no-data-state.error-access .no-data-icon svg circle[fill] {\n fill: var(--mdas-color-negative, #dc2626);\n}\n`,d=`\n${o}\n${a("market-data-widget")}\n${r("market-data-widget")}\n${l("market-data-widget")}\n${c("market-data-widget")}\n${h="market-data-widget",`\n/* Symbol Display for ${h} */\n.${h} .symbol {\n font-size: var(--mdas-symbol-size, 1.79em);\n font-weight: 700;\n color: var(--mdas-text-primary, #111827);\n letter-spacing: 0.5px;\n}\n\n.${h} .company-name {\n font-size: var(--mdas-company-name-size, 1.43em);\n font-weight: 500;\n color: var(--mdas-text-primary, #111827);\n}\n\n.${h} .symbol-section {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n`}\n${(t=>`\n/* Price Display for ${t} */\n.${t} .current-price {\n font-size: var(--mdas-price-size, 2.29em);\n font-weight: 700;\n color: var(--mdas-text-primary, #111827);\n line-height: 1;\n}\n\n.${t} .price-change {\n font-size: var(--mdas-change-size, 1.14em);\n font-weight: 600;\n display: inline-flex;\n align-items: center;\n gap: 4px;\n}\n\n.${t} .price-change.positive {\n color: var(--mdas-color-positive, #059669);\n}\n\n.${t} .price-change.negative {\n color: var(--mdas-color-negative, #dc2626);\n}\n\n.${t} .price-change.neutral {\n color: var(--mdas-color-neutral, #6b7280);\n}\n\n/* Arrow indicators for price change */\n.${t} .price-change.positive::before {\n content: "↗";\n font-size: 1em;\n}\n\n.${t} .price-change.negative::before {\n content: "↘";\n font-size: 1em;\n}\n`)("market-data-widget")}\n${(t=>`\n/* Data Grid for ${t} */\n.${t} .data-grid {\n display: flex;\n flex-direction: column;\n gap: 16px;\n}\n\n.${t} .data-section {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.${t} .section-title {\n font-size: var(--mdas-small-text-size, 0.79em);\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n color: var(--mdas-text-secondary, #6b7280);\n}\n\n.${t} .data-row {\n display: flex;\n justify-content: space-between;\n padding: 8px 0;\n border-bottom: 1px solid var(--mdas-border-primary, #e5e7eb);\n}\n\n.${t} .data-row:last-child {\n border-bottom: none;\n}\n\n.${t} .data-label {\n font-size: var(--mdas-label-size, 0.86em);\n color: var(--mdas-text-secondary, #6b7280);\n}\n\n.${t} .data-value {\n font-size: var(--mdas-value-size, 1em);\n font-weight: 600;\n color: var(--mdas-text-primary, #111827);\n}\n`)("market-data-widget")}\n${(t=>`\n/* Widget Header for ${t} */\n.${t} .widget-header {\n display: flex;\n justify-content: space-between;\n align-items: flex-start;\n margin-bottom: 20px;\n gap: 16px;\n}\n\n.${t} .widget-header.dimmed {\n opacity: 0.5;\n}\n`)("market-data-widget")}\n\n/* ========================================\n MARKET DATA WIDGET - SCOPED STYLES\n ======================================== */\n\n.market-data-widget {\n border: 1px solid var(--mdas-border-primary, #e5e7eb);\n border-radius: var(--mdas-border-radius, 12px);\n background: var(--mdas-bg-primary, white);\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n font-size: var(--mdas-base-font-size, 14px);\n max-width: 100%;\n overflow: hidden;\n position: relative;\n color: var(--mdas-text-primary, #333);\n margin: 0 auto;\n}\n\n/* Override data-grid to use 2-column layout */\n.market-data-widget .data-grid {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 32px;\n margin-bottom: 24px;\n}\n\n/* Override data-row to have proper spacing */\n.market-data-widget .data-row {\n display: flex;\n justify-content: space-between;\n padding: 8px 0;\n border-bottom: none;\n}\n\n/* Optional card styling */\n.market-data-widget.widget-styled {\n padding: var(--mdas-spacing-lg, 24px);\n box-shadow: var(--mdas-shadow-md, 0 1px 3px rgba(0, 0, 0, 0.1));\n}\n\n/* Header section with white background */\n.market-data-widget .widget-header {\n background: white;\n padding: 0;\n margin-bottom: 20px;\n}\n\n/* ========================================\n COMPANY INFO\n ======================================== */\n\n.market-data-widget .company-info {\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: var(--mdas-medium-text-size, 0.93em);\n color: var(--mdas-text-secondary, #6b7280);\n}\n\n.market-data-widget .data-type {\n background: rgb(214, 228, 250);\n padding: 2px 8px;\n border-radius: 6px;\n font-size: var(--mdas-small-text-size, 0.79em);\n font-weight: 500;\n color: var(--mdas-primary-color, #3b82f6);\n}\n\n.market-data-widget .company-name {\n position: relative;\n cursor: help;\n transition: all 0.2s ease;\n border-bottom: 1px dashed var(--mdas-border-primary, #e5e7eb);\n}\n\n.market-data-widget .company-name:hover {\n border-bottom-color: var(--mdas-primary-color, #3b82f6);\n color: var(--mdas-primary-color, #3b82f6);\n}\n\n/* Tooltip Styles */\n.market-data-widget .company-name::after {\n content: attr(data-tooltip);\n position: absolute;\n bottom: 100%;\n left: 50%;\n transform: translateX(-50%);\n background: #1f2937;\n color: white;\n padding: 8px 12px;\n border-radius: 6px;\n font-size: var(--mdas-small-text-size, 0.79em);\n font-weight: normal;\n white-space: normal;\n max-width: 300px;\n line-height: 1.4;\n z-index: 1000;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n opacity: 0;\n visibility: hidden;\n transition: all 0.2s ease;\n pointer-events: none;\n margin-bottom: 5px;\n}\n\n.market-data-widget .company-name:hover::after {\n opacity: 1;\n visibility: visible;\n}\n\n.market-data-widget .company-name::before {\n content: '';\n position: absolute;\n bottom: 100%;\n left: 50%;\n transform: translateX(-50%);\n border: 5px solid transparent;\n border-top-color: #1f2937;\n opacity: 0;\n visibility: hidden;\n transition: all 0.2s ease;\n pointer-events: none;\n}\n\n.market-data-widget .company-name:hover::before {\n opacity: 1;\n visibility: visible;\n}\n\n/* ========================================\n QUOTE DATA (BID/ASK)\n ======================================== */\n\n.market-data-widget .bid-data,\n.market-data-widget .ask-data {\n font-size: var(--mdas-value-size, 1em);\n font-weight: 700;\n}\n\n.market-data-widget .size-info {\n font-size: var(--mdas-small-text-size, 0.79em);\n color: var(--mdas-text-secondary, #6b7280);\n margin-left: 4px;\n font-weight: 500;\n}\n\n.market-data-widget .range-value {\n font-size: var(--mdas-label-size, 0.86em);\n}\n\n/* ========================================\n RESPONSIVE DESIGN\n ======================================== */\n\n@media (max-width: 768px) {\n .market-data-widget .widget-header {\n flex-direction: column;\n gap: 12px;\n text-align: center;\n }\n\n .market-data-widget .symbol-section {\n align-items: center;\n }\n\n .market-data-widget .price-section {\n text-align: center;\n }\n\n .market-data-widget .data-grid {\n grid-template-columns: 1fr;\n gap: 16px;\n }\n\n .market-data-widget .widget-footer {\n flex-direction: column;\n gap: 8px;\n text-align: center;\n }\n}\n\n@media (max-width: 480px) {\n .market-data-widget.widget-styled {\n padding: var(--mdas-spacing-md, 16px);\n }\n\n .market-data-widget .company-name::after {\n left: 0;\n transform: none;\n max-width: 250px;\n }\n\n .market-data-widget .company-name::before {\n left: 20px;\n transform: none;\n }\n}\n`;var h;function u(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";const i=document.createElement(t);return n&&(i.className=n),e&&(i.textContent=e),i}function g(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"--";if(null==t||""===t)return n;const i=parseFloat(t);return isNaN(i)?n:i.toFixed(e)}function p(t){if(!t)return"";return String(t).replace(/[^A-Za-z0-9.\-_+ ]/g,"").substring(0,50)}function m(t){if(t)for(;t.firstChild;)t.removeChild(t.firstChild)}function f(t){if(!t||"string"!=typeof t)return{valid:!1,error:"Symbol is required",sanitized:""};const e=t.trim().toUpperCase();return 0===e.length?{valid:!1,error:"Symbol cannot be empty",sanitized:""}:e.length>10?{valid:!1,error:"Symbol too long (max 10 characters)",sanitized:""}:{valid:!0,sanitized:e}}function b(t){if(!t||"string"!=typeof t)return{valid:!1,error:"Option symbol is required",sanitized:""};const e=t.trim().toUpperCase();if(e.length<15||e.length>21)return{valid:!1,error:"Invalid option symbol length",sanitized:e};const n=e.match(/^([A-Z]{1,6})(\d{2})(0[1-9]|1[0-2])([0-2][0-9]|3[01])([CP])(\d{8})$/);if(!n)return{valid:!1,error:"Invalid option symbol format. Expected: SYMBOL+YYMMDD+C/P+STRIKE",sanitized:e};const[,i,s,o,a,r,l]=n,c=2e3+parseInt(s,10),d=parseInt(o,10),h=parseInt(a,10),u=new Date(c,d-1,h);if(u.getMonth()+1!==d||u.getDate()!==h)return{valid:!1,error:"Invalid expiration date in option symbol",sanitized:e};const g=new Date;g.setHours(0,0,0,0),u<g&&console.warn("Option symbol has expired");return{valid:!0,sanitized:e,parsed:{underlying:i,expiry:u,type:"C"===r?"call":"put",strike:parseInt(l,10)/1e3}}}function y(t){if(!t)return"ET";const[e,n,i]=t.split("-").map(Number),s=new Date(e,n-1,i),o=function(t,e){const n=new Date(t,e,1),i=1+(7-n.getDay())%7;return new Date(t,e,i+7)}(e,2),a=function(t,e){const n=new Date(t,e,1),i=1+(7-n.getDay())%7;return new Date(t,e,i)}(e,10);return s>=o&&s<a?"EDT":"EST"}function x(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{includeSeconds:n=!0,includeTimezone:i=!0,format:s="short"}=e;let o;if(t||(t=Date.now()),o=t instanceof Date?t:new Date(t),isNaN(o.getTime()))return"Invalid Date";const a=o.getUTCFullYear(),r=o.getUTCMonth(),l=o.getUTCDate(),c=o.getUTCHours(),d=o.getUTCMinutes(),h=o.getUTCSeconds(),u=function(t){const e=t.getUTCFullYear(),n=t.getUTCMonth(),i=t.getUTCDate(),s=new Date(Date.UTC(e,n,i)),o=function(t,e){const n=new Date(Date.UTC(t,e,1)),i=1+(7-n.getUTCDay())%7;return new Date(Date.UTC(t,e,i+7))}(e,2),a=function(t,e){const n=new Date(Date.UTC(t,e,1)),i=1+(7-n.getUTCDay())%7;return new Date(Date.UTC(t,e,i))}(e,10);return s>=o&&s<a}(o),g=u?-4:-5,p=new Date(Date.UTC(a,r,l,c+g,d,h)),m=p.getUTCFullYear(),f=p.getUTCMonth()+1,b=p.getUTCDate(),y=p.getUTCHours(),x=p.getUTCMinutes(),v=p.getUTCSeconds(),w=y%12||12,k=y>=12?"PM":"AM",S=x.toString().padStart(2,"0"),M=v.toString().padStart(2,"0"),C=n?`${w}:${S}:${M} ${k}`:`${w}:${S} ${k}`,_=i?u?" EDT":" EST":"";if("long"===s){return`${["January","February","March","April","May","June","July","August","September","Oct","November","December"][f-1]} ${b}, ${m}, ${C}${_}`}return`${f}/${b}/${m}, ${C}${_}`}class v extends n{constructor(t,e,n){if(super(t,e,n),!e.symbol)throw new Error("Symbol is required for MarketDataWidget");if(!e.wsManager)throw new Error("WebSocketManager is required for MarketDataWidget");this.type="marketdata";const i=f(e.symbol);if(!i.valid)throw new Error(`Invalid symbol: ${i.error}`);this.symbol=i.sanitized,this.wsManager=e.wsManager,this.debug=e.debug||!1,this.styled=void 0===e.styled||e.styled,this.data=null,this.isDestroyed=!1,this.unsubscribe=null,this.loadingTimeout=null,this.createWidgetStructure(),this.initializeSymbolEditor(),this.initialize()}createWidgetStructure(){if(this.container.innerHTML='\n <div class="market-data-widget widget">\n <div class="widget-content">\n \x3c!-- Header Section --\x3e\n <div class="widget-header">\n <div class="symbol-section">\n <h1 class="symbol editable-symbol" \n title="Double-click to edit symbol" \n data-original-symbol="">\n </h1>\n <div class="company-info">\n <span class="company-name" \n title="" \n data-tooltip="">\n </span>\n <span class="data-type">STOCK</span>\n </div>\n </div>\n <div class="price-section">\n <div class="current-price"></div>\n <div class="price-change">\n <span class="change-value"></span>\n <span class="change-percent"></span>\n </div>\n </div>\n </div>\n\n \x3c!-- Data Grid Section --\x3e\n <div class="data-grid">\n <div class="data-section">\n <div class="section-title">Quote</div>\n <div class="data-row">\n <span class="data-label">Bid</span>\n <span class="data-value bid-ask-value bid-data"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Ask</span>\n <span class="data-value bid-ask-value ask-data"></span>\n </div>\n </div>\n\n <div class="data-section">\n <div class="section-title">Trading Activity</div>\n <div class="data-row">\n <span class="data-label">Volume</span>\n <span class="data-value volume"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Average Volume</span>\n <span class="data-value avg-volume"></span>\n </div>\n </div>\n\n <div class="data-section">\n <div class="section-title">Performance</div>\n <div class="data-row">\n <span class="data-label">Previous Close</span>\n <span class="data-value prev-close"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Open</span>\n <span class="data-value open-price"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Day Range</span>\n <span class="data-value range-value day-range"></span>\n </div>\n <div class="data-row">\n <span class="data-label">52-Week Range</span>\n <span class="data-value range-value week-range"></span>\n </div>\n </div>\n\n <div class="data-section">\n <div class="section-title">Key Metrics</div>\n <div class="data-row">\n <span class="data-label">Market Cap</span>\n <span class="data-value market-cap"></span>\n </div>\n <div class="data-row">\n <span class="data-label">P/E Ratio</span>\n <span class="data-value pe-ratio"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Dividend Yield</span>\n <span class="data-value dividend-yield"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Beta</span>\n <span class="data-value beta"></span>\n </div>\n </div>\n </div>\n\n \x3c!-- Footer --\x3e\n <div class="widget-footer">\n <span class="last-update"></span>\n <span class="data-source"></span>\n </div>\n </div>\n \n \x3c!-- Loading Overlay --\x3e\n <div class="widget-loading-overlay">\n <div class="loading-content">\n <div class="loading-spinner"></div>\n <span class="loading-text">Loading market data...</span>\n </div>\n </div>\n </div>\n',this.styled){const t=this.container.querySelector(".market-data-widget");t&&t.classList.add("widget-styled")}this.addStyles()}addStyles(){if(!document.querySelector("#market-data-styles")){const t=document.createElement("style");t.id="market-data-styles",t.textContent=d,document.head.appendChild(t)}}initializeSymbolEditor(){this.symbolEditor=new s(this,{maxLength:10,placeholder:"Enter symbol...",onSymbolChange:this.handleSymbolChange.bind(this),debug:this.debug,autoUppercase:!0,symbolType:"quotel1"});const t=this.container.querySelector(".symbol");t&&(t.textContent=this.symbol,t.dataset.originalSymbol=this.symbol)}async handleSymbolChange(t){this.debug&&console.log("[MarketDataWidget] Symbol change requested:",t);const e=f(t);if(!e.valid)return this.debug&&console.log("[MarketDataWidget] Invalid symbol:",e.error),{success:!1,error:e.error};const n=e.sanitized;if(n===this.symbol)return this.debug&&console.log("[MarketDataWidget] Same symbol, no change needed"),{success:!0};try{const t=this.symbol;return this.showLoading(),this.loadingTimeout&&this.clearTimeout(this.loadingTimeout),this.loadingTimeout=this.setTimeout((()=>{this.debug&&console.log("[MarketDataWidget] Loading timeout for symbol:",n),this.hideLoading(),this.showError(`No data received for ${n}. Please try again.`)}),1e4),this.unsubscribe&&(this.debug&&console.log(`[MarketDataWidget] Unsubscribing from ${t}`),this.wsManager.sendUnsubscribe("queryl1",t),this.unsubscribe(),this.unsubscribe=null),this.symbol=n,this.debug&&console.log(`[MarketDataWidget] Subscribing to ${n}`),this.subscribeToData(),this.debug&&console.log(`[MarketDataWidget] Successfully changed symbol from ${t} to ${n}`),{success:!0}}catch(t){return console.error("[MarketDataWidget] Error changing symbol:",t),this.hideLoading(),this.showError(`Failed to load data for ${n}`),{success:!1,error:`Failed to load ${n}`}}}async initialize(){this.showLoading();!1!==await super.validateInitialSymbol("quotel1",this.symbol,(t=>{t&&t[0]&&(this.initialValidationData=t[0])}))&&this.subscribeToData()}subscribeToData(){this.unsubscribe=this.wsManager.subscribe(this.widgetId,["queryl1"],this.handleMessage.bind(this),this.symbol)}handleData(t){if(!0===t.error){this.debug&&console.log("[MarketDataWidget] Received error response:",t.message);const e=t.message||t.Message;if(e)return this.hideLoading(),void this.showError(e)}else if(t.Data&&"string"==typeof t.Data)return this.hideLoading(),void this.showError(t.Message);if(this.loadingTimeout&&(clearTimeout(this.loadingTimeout),this.loadingTimeout=null),"error"===t.type)return this.debug&&console.log("[MarketDataWidget] Received no data message:",t.message),void(this.data?(this.hideLoading(),this.debug&&console.log("[MarketDataWidget] No new data, keeping cached data visible")):this.showNoDataState({Symbol:this.symbol,NotFound:!0,message:t.message}));if("error"!==t.type){if("object"==typeof t&&t.Message){const e=t.Message.toLowerCase();if(e.includes("no data")||e.includes("not found"))return this.debug&&console.log("[MarketDataWidget] Received no data message:",t.Message),void(this.data?(this.hideLoading(),this.debug&&console.log("[MarketDataWidget] No new data, keeping cached data visible")):this.showNoDataState({Symbol:this.symbol,NotFound:!0,message:t.Message}))}if(t.Data&&t.Data.length>0){const e=t.Data.find((t=>t.Symbol===this.symbol));if(e){const t=new i(e);this.data=t,this.updateWidget(t)}else this.debug&&console.log("[MarketDataWidget] No data for symbol in response, keeping cached data"),this.hideLoading()}t._cached&&this.showConnectionQuality()}else{const e=t.message||"Server error";this.data?(this.hideLoading(),this.debug&&console.log("[MarketDataWidget] Error received but keeping cached data:",e)):this.showError(e)}}updateWidget(t){if(!this.isDestroyed)try{this.loadingTimeout&&(clearTimeout(this.loadingTimeout),this.loadingTimeout=null),this.clearError(),this.hideLoading();const e=this.container.querySelector(".widget-header");e&&e.classList.remove("dimmed");const n=this.container.querySelector(".data-grid");n&&(n.style.display="");const i=this.container.querySelector(".no-data-state");i&&i.remove();const s=this.container.querySelector(".symbol");s&&(s.textContent=t.symbol,s.dataset.originalSymbol=t.symbol);const o=this.container.querySelector(".company-name");if(o){const e=t.companyName||`${t.symbol} Inc`,n=t.companyDescription||`${t.symbol} designs, manufactures, and markets consumer electronics and software.`;o.textContent=e,o.setAttribute("title",n),o.setAttribute("data-tooltip",n)}const a=this.container.querySelector(".current-price");a&&(a.textContent=t.formatPrice());const r=t.getPriceChange(),l=this.container.querySelector(".price-change");if(l){const e=l.querySelector(".change-value"),n=l.querySelector(".change-percent");e&&(e.textContent=t.formatPriceChange()),n&&(n.textContent=` (${t.formatPriceChangePercent()})`),l.classList.remove("positive","negative","neutral"),r>0?l.classList.add("positive"):r<0?l.classList.add("negative"):l.classList.add("neutral")}const c=this.container.querySelector(".bid-data");if(c){m(c);const e=g(t.bidPrice,2,"0.00"),n=t.bidSize||0;c.appendChild(document.createTextNode(`$${e}`));const i=u("span",`× ${n}`,"size-info");c.appendChild(i)}const d=this.container.querySelector(".ask-data");if(d){m(d);const e=g(t.askPrice,2,"0.00"),n=t.askSize||0;d.appendChild(document.createTextNode(`$${e}`));const i=u("span",`× ${n}`,"size-info");d.appendChild(i)}const h=this.container.querySelector(".volume");h&&(h.textContent=t.formatVolume());const p=this.container.querySelector(".avg-volume");p&&(p.textContent=t.formatAverageVolume());const f=this.container.querySelector(".prev-close");f&&(f.textContent=`$${t.previousClose?.toFixed(2)||"0.00"}`);const b=this.container.querySelector(".open-price");b&&(b.textContent=`$${t.openPrice?.toFixed(2)||"0.00"}`);const y=this.container.querySelector(".day-range");y&&(y.textContent=t.formatDayRange());const v=this.container.querySelector(".week-range");v&&(v.textContent=t.format52WeekRange());const w=this.container.querySelector(".market-cap");w&&(w.textContent=t.formatMarketCap());const k=this.container.querySelector(".pe-ratio");k&&(k.textContent=t.peRatio?.toFixed(2)||"N/A");const S=this.container.querySelector(".dividend-yield");S&&(S.textContent=t.dividendYield?`${t.dividendYield.toFixed(2)}%`:"N/A");const M=this.container.querySelector(".beta");M&&(M.textContent=t.beta?.toFixed(2)||"N/A");const C=x(t.quoteTime),_=this.container.querySelector(".last-update");_&&(_.textContent=`Last update: ${C}`);const T=this.container.querySelector(".data-source");T&&(T.textContent=`Source: ${t.getDataSource()}`)}catch(t){console.error("Error updating widget:",t),this.showError("Error updating data")}}showLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.remove("hidden")}hideLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.add("hidden")}showError(t){this.hideLoading(),this.clearError();const e=document.createElement("div");e.className="widget-error",e.textContent=`Error: ${t}`,e.style.cssText="\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n padding: 15px 20px;\n background: #fee;\n border: 1px solid #f5c6cb;\n border-radius: 6px;\n color: #721c24;\n text-align: center;\n font-size: 14px;\n z-index: 100;\n ",this.container.appendChild(e)}clearError(){const t=this.container.querySelector(".widget-error"),e=this.container.querySelector(".widget-error-container");t&&t.remove(),e&&e.remove()}destroy(){this.isDestroyed=!0,this.loadingTimeout&&(this.clearTimeout(this.loadingTimeout),this.loadingTimeout=null),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null),this.symbolEditor&&(this.symbolEditor.destroy(),this.symbolEditor=null),super.destroy()}}class w{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.symbol=t.Symbol||"",this.marketName=t.MarketName||("bruce"===t.Source?.toLowerCase()?"Bruce":"Blue Ocean"),this.marketDesc=null!==t.MarketDesc?t.MarketDesc||"":null,this.countryCode=null!==t.CountryCode?t.CountryCode||"":null,this.volume=null!==t.Volume?t.Volume||0:null,this.askPrice=null!==t.AskPx?t.AskPx||0:null,this.askSize=null!==t.AskSz?t.AskSz||0:null,this.bidPrice=null!==t.BidPx?t.BidPx||0:null,this.bidSize=null!==t.BidSz?t.BidSz||0:null,this.lastPrice=null!==t.LastPx?t.LastPx||0:null,this.quoteTime=null!==t.QuoteTime?t.QuoteTime:null,this.activityTimestamp=null!==t.ActivityTimestamp?t.ActivityTimestamp||"":null,this.tradeSize=null!==t.TradeSz?t.TradeSz||0:null,this.bidExchange=null!==t.BidExch?t.BidExch||"":null,this.askExchange=null!==t.AskExch?t.AskExch||"":null,this.notFound=t.NotFound||!1,this.source=t.Source||"",this.accuAmount=null!==t.AccuAmmount?t.AccuAmmount||0:null,this.change=null!==t.Change?t.Change||0:null,this.changePercent=null!==t.ChangePercent?t.ChangePercent||0:null,this.closingPrice=null!==t.ClosingPx?t.ClosingPx:null!==t.PreviousClose?t.PreviousClose:null,this.highPrice=null!==t.HighPx?t.HighPx||0:null,this.lowPrice=null!==t.LowPx?t.LowPx||0:null,this.openPrice=null!==t.OpenPx?t.OpenPx||0:null,this.tradePrice=null!==t.TradePx?t.TradePx||0:null,this.tradeRegionName=null!==t.TradeRegionName?t.TradeRegionName||"":null,this.companyName=t.comp_name||t.CompanyName||"",this.exchangeName=t.market_name||t.Exchange||"",this.mic=t.mic||""}formatPrice(){return`$${this.lastPrice.toFixed(2)}`}formatBidAsk(){return`$${this.bidPrice.toFixed(2)} × ${this.bidSize} / $${this.askPrice.toFixed(2)} × ${this.askSize}`}formatVolume(){return this.volume.toLocaleString()}formatPriceChange(){if(null===this.change||void 0===this.change)return"--";return`${this.change>0?"+":""}${this.change.toFixed(2)}`}formatPriceChangePercent(){if(null===this.changePercent||void 0===this.changePercent)return"--";return`${this.changePercent>0?"+":""}${this.getPriceChangePercent().toFixed(2)}%`}getDataSource(){return"blueocean-d"===this.source.toLowerCase()||"bruce-d"===this.source.toLowerCase()?"bruce-d"===this.source.toLowerCase()?"Bruce 20 mins delayed":"BlueOcean 20 mins delayed":this.source.toLowerCase().includes("bruce")||this.source.toLowerCase().includes("blueocean")||this.source.toLowerCase().includes("onbbo")?"bruce"===this.source.toLowerCase()?"Bruce Real-time":"onbbo"===this.source.toLowerCase()?"ONBBO Real-time":"BlueOcean Real-time":null!==this.source&&""!==this.source?this.source:"MDAS"}getPriceChangePercent(){return null===this.changePercent||void 0===this.changePercent?0:Math.abs(this.changePercent)>1?this.changePercent:100*this.changePercent}}const k='\n /* ========================================\n ⚠️ DEPRECATED - Use BaseStyles.js instead\n FONT SIZE SYSTEM - CSS Variables\n Adjust --mdas-base-font-size to scale all fonts\n ======================================== */\n :root {\n /* Base font size - change this to scale everything */\n --mdas-base-font-size: 14px;\n\n /* Relative font sizes (in em, scales with base) */\n --mdas-company-name-size: 1.43em; /* 20px at base 14px */\n --mdas-symbol-size: 1.79em; /* 25px at base 14px */\n --mdas-price-size: 2.29em; /* 32px at base 14px */\n --mdas-price-change-size: 1.14em; /* 16px at base 14px */\n --mdas-section-title-size: 1em; /* 14px at base 14px */\n --mdas-data-label-size: 0.93em; /* 13px at base 14px */\n --mdas-data-value-size: 1em; /* 14px at base 14px */\n --mdas-bid-ask-size: 1.07em; /* 15px at base 14px */\n --mdas-small-text-size: 0.86em; /* 12px at base 14px */\n --mdas-badge-size: 0.86em; /* 12px at base 14px */\n --mdas-loading-text-size: 1.14em; /* 16px at base 14px */\n --mdas-no-data-title-size: 1.14em; /* 16px at base 14px */\n --mdas-edit-icon-size: 0.71em; /* 10px at base 14px */\n }\n\n /* Apply base font size to widgets */\n .widget {\n font-size: var(--mdas-base-font-size);\n }\n\n /* ========================================\n OPTIONAL CARD STYLING\n Add \'widget-styled\' class for card design\n ======================================== */\n .widget-styled {\n background: white;\n border-radius: 12px;\n padding: 24px;\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);\n border: 1px solid #e5e7eb;\n }\n\n /* Base widget styles */\n .widget-loading-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(255, 255, 255, 0.95);\n backdrop-filter: blur(2px);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10;\n border-radius: 12px;\n }\n\n .widget-loading-overlay.hidden {\n display: none;\n }\n\n .widget {\n font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, sans-serif;\n width: 100%;\n max-width: 1400px;\n }\n\n /* HEADER STYLES */\n\n .widget-header {\n display: flex;\n justify-content: space-between;\n align-items: flex-start;\n margin-bottom: 20px;\n gap: 16px;\n }\n\n .symbol-section {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .night-company-name {\n font-size: var(--mdas-company-name-size);\n font-weight: 500;\n color: #111827;\n cursor: pointer;\n transition: all 0.2s ease;\n position: relative;\n }\n\n .symbol {\n font-size: var(--mdas-symbol-size);\n font-weight: 700;\n color: #111827;\n cursor: pointer;\n transition: all 0.2s ease;\n position: relative;\n }\n\n .symbol:hover {\n opacity: 0.8;\n transform: scale(1.02);\n }\n\n .symbol:hover::after {\n content: "✎";\n position: absolute;\n top: -8px;\n right: -8px;\n background: #3b82f6;\n color: white;\n font-size: var(--mdas-edit-icon-size);\n padding: 2px 4px;\n border-radius: 4px;\n opacity: 0.8;\n }\n\n .data-type {\n background:rgb(214, 228, 250);\n padding: 2px 8px;\n border-radius: 6px;\n font-size: var(--mdas-badge-size);\n font-weight: 500;\n color: #3b82f6;\n }\n\n .price-section {\n text-align: right;\n }\n\n .current-price {\n font-size: var(--mdas-price-size);\n font-weight: 700;\n color: #111827;\n line-height: 1;\n }\n\n .price-change {\n font-size: var(--mdas-price-change-size);\n font-weight: 600;\n margin-top: 4px;\n display: flex;\n align-items: center;\n justify-content: flex-end;\n gap: 4px;\n }\n\n .price-change.positive { \n color: #10b981; \n }\n\n .price-change.negative { \n color: #ef4444; \n }\n\n .price-change.neutral { \n color: #6b7280; \n }\n\n .market-data-widget .price-change.positive::before,\n .night-session-widget .price-change.positive::before,\n .options-widget .price-change.positive::before{\n content: "↗";\n }\n\n .market-data-widget .price-change.negative::before,\n .night-session-widget .price-change.negative::before,\n .options-widget .price-change.negative::before {\n content: "↘";\n }\n\n /* BODY SECTION STYLES */\n\n .data-grid {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 32px;\n margin-bottom: 24px;\n }\n\n .data-section {\n display: flex;\n flex-direction: column;\n gap: 16px;\n }\n\n .section-title {\n font-size: var(--mdas-section-title-size);\n font-weight: 600;\n color: #6b7280;\n margin: 0;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n border-bottom: 1px solid #e5e7eb;\n padding-bottom: 8px;\n }\n\n .data-row {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 16px;\n }\n\n .data-item {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .price-metadata,\n .data-label {\n font-size: var(--mdas-data-label-size);\n color: #6b7280;\n font-weight: 500;\n }\n\n .data-value {\n font-size: var(--mdas-data-value-size);\n font-weight: 600;\n color: #111827;\n text-align: right;\n flex-shrink: 0;\n }\n\n\n /* Footer */\n .widget-footer {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding-top: 16px;\n border-top: 1px solid #e5e7eb;\n font-size: var(--mdas-small-text-size);\n color: #9ca3af;\n }\n \n\n /* LOADING STYLES */\n\n\n .loading-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 16px;\n }\n\n .loading-spinner {\n width: 40px;\n height: 40px;\n border: 4px solid #e5e7eb;\n border-top-color: #3b82f6;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n }\n\n .loading-text {\n color: #6b7280;\n font-size: var(--mdas-loading-text-size);\n font-weight: 500;\n }\n\n @keyframes spin {\n to { transform: rotate(360deg); }\n }\n\n .widget-error {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n background: #fef2f2;\n border: 1px solid #fecaca;\n border-radius: 8px;\n padding: 16px;\n color: #dc2626;\n font-size: var(--mdas-data-value-size);\n font-weight: 600;\n text-align: center;\n z-index: 10;\n max-width: 80%;\n }\n\n /* Price change colors */\n .positive {\n color: #059669;\n }\n\n .negative {\n color: #dc2626;\n }\n\n \n\n /* No data state */\n .no-data-state {\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 160px;\n margin: 16px 0;\n background: #f9fafb;\n border: 1px solid #e5e7eb;\n border-radius: 12px;\n padding: 24px 16px;\n width: 100%;\n box-sizing: border-box;\n overflow: hidden;\n }\n\n .no-data-content {\n text-align: center;\n max-width: 280px;\n width: 100%;\n word-wrap: break-word;\n overflow-wrap: break-word;\n }\n\n .no-data-icon {\n margin-bottom: 16px;\n display: flex;\n justify-content: center;\n }\n\n .no-data-icon svg {\n opacity: 0.6;\n }\n\n .no-data-title {\n font-size: var(--mdas-no-data-title-size);\n font-weight: 600;\n color: #6b7280;\n margin: 0 0 8px 0;\n }\n\n .no-data-description {\n font-size: var(--mdas-data-value-size);\n color: #9ca3af;\n margin: 0 0 12px 0;\n line-height: 1.4;\n }\n\n .no-data-description strong {\n color: #6b7280;\n font-weight: 600;\n }\n\n .no-data-guidance {\n font-size: var(--mdas-small-text-size);\n color: #9ca3af;\n margin: 0;\n font-style: italic;\n }\n\n /* Error Access State */\n .no-data-state.error-access {\n border: 1px solid #fecaca;\n background:rgb(255, 255, 255);\n \n }\n\n .no-data-title.error {\n color: #ef4444;\n }\n\n .no-data-icon.error svg {\n stroke: #ef4444;\n }\n\n .no-data-icon.error svg circle[fill] {\n fill: #ef4444;\n }\n',S=`\n ${k}\n\n /* Reset and base styles for widget */\n\n .night-session-widget {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n line-height: 1.5;\n max-width: 800px;\n position: relative;\n }\n\n /* STANDARDIZED HEADER LAYOUT */\n\n\n .symbol-section {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .night-session-widget .symbol {\n font-size: var(--mdas-symbol-size);\n font-weight: 700;\n color: #111827;\n cursor: pointer;\n transition: all 0.2s ease;\n position: relative;\n }\n\n .night-session-widget .symbol:hover {\n opacity: 0.8;\n transform: scale(1.02);\n }\n\n .night-session-widget .symbol:hover::after {\n content: "✎";\n position: absolute;\n top: -8px;\n right: -8px;\n background: #3b82f6;\n color: white;\n font-size: var(--mdas-edit-icon-size);\n padding: 2px 4px;\n border-radius: 4px;\n opacity: 0.8;\n }\n\n .company-info {\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: var(--mdas-section-title-size);\n color: #6b7280;\n }\n\n .market-name {\n font-weight: 600;\n text-transform: uppercase;\n }\n\n /* Company and market info styling */\n .company-market-info {\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: var(--mdas-small-text-size);\n color: #6b7280;\n margin-bottom: 4px;\n }\n\n .company-market-info .market-name {\n font-weight: 600;\n }\n\n .company-market-info .market-name::before {\n content: '|';\n margin-right: 8px;\n color: #9ca3af;\n }\n\n .company-market-info .market-mic {\n font-weight: 600;\n }\n\n .company-market-info .market-mic::before {\n content: '•';\n margin-right: 8px;\n }\n\n /* Price metadata (source and last update) */\n .price-metadata {\n margin-top: 8px;\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n \n\n /* STANDARDIZED GRID LAYOUT */\n .data-grid {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n gap: 24px;\n margin-top: 24px;\n }\n\n .data-section {\n display: flex;\n flex-direction: column;\n gap: 12px;\n }\n\n .night-session-widget .section-title {\n font-size: var(--mdas-small-text-size);\n font-weight: 600;\n color: #6b7280;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n border-bottom: 1px solid #e5e7eb;\n padding-bottom: 8px;\n }\n\n .night-session-widget .data-row {\n display: flex;\n justify-content: space-between;\n align-items: center;\n min-height: 20px;\n }\n\n\n\n .night-session-widget .data-value {\n font-size: var(--mdas-data-value-size);\n font-weight: 600;\n color: #111827;\n text-align: right;\n }\n\n /* SPECIAL FORMATTING FOR DIFFERENT DATA TYPES */\n .night-session-widget .bid-ask-value {\n font-size: var(--mdas-bid-ask-size);\n font-weight: 700;\n }\n\n .night-session-widget .size-info {\n font-size: var(--mdas-small-text-size);\n color: #6b7280;\n margin-left: 4px;\n }\n\n /* Footer */\n .night-session-widget .widget-footer {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-top: 24px;\n padding-top: 16px;\n border-top: 1px solid #e5e7eb;\n font-size: var(--mdas-small-text-size);\n color: #9ca3af;\n grid-column: 1 / -1;\n }\n\n /* Loading Overlay */\n .widget-loading-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(255, 255, 255, 0.95);\n backdrop-filter: blur(2px);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10;\n border-radius: 12px;\n }\n\n .widget-loading-overlay.hidden {\n display: none;\n }\n\n .loading-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 12px;\n }\n\n .loading-spinner {\n width: 32px;\n height: 32px;\n border: 3px solid #f3f4f6;\n border-top-color: #3b82f6;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n }\n\n .night-session-widget .loading-text {\n color: #6b7280;\n font-size: var(--mdas-data-value-size);\n font-weight: 500;\n }\n\n @keyframes spin {\n to { transform: rotate(360deg); }\n }\n\n /* Widget Error Styles */\n .night-session-widget .widget-error {\n background: #fef2f2;\n color: #9ca3af;\n padding: 12px;\n border-radius: 8px;\n border: 1px solid #fecaca;\n margin-top: 16px;\n font-size: var(--mdas-data-value-size);\n font-weight: 500;\n }\n\n /* No Data State */\n .night-session-widget .no-data-state {\n padding: 24px;\n text-align: center;\n color: #6b7280;\n grid-column: 1 / -1;\n }\n\n .night-session-widget .no-data-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 12px;\n }\n\n .night-session-widget .no-data-icon {\n font-size: 3.43em;\n opacity: 0.5;\n }\n\n .night-session-widget .no-data-title {\n font-size: 1.29em;\n font-weight: 600;\n color: #374151;\n }\n\n .night-session-widget .no-data-message {\n font-size: var(--mdas-data-value-size);\n max-width: 300px;\n line-height: 1.5;\n }\n\n .night-session-widget .no-data-suggestion {\n font-size: var(--mdas-small-text-size);\n color: #9ca3af;\n max-width: 350px;\n line-height: 1.4;\n }\n\n /* Dimmed state for no data */\n .widget-header.dimmed,\n .price-section.dimmed {\n opacity: 0.6;\n }\n\n /* Responsive Design */\n @media (max-width: 768px) {\n :root {\n --mdas-base-font-size: 13px; /* Slightly smaller on tablets */\n }\n\n .widget-styled {\n padding: 16px;\n }\n\n .widget-header {\n grid-template-columns: 1fr;\n gap: 12px;\n text-align: center;\n }\n\n .symbol-section {\n align-items: center;\n }\n\n .price-section {\n text-align: center;\n }\n\n .data-grid {\n grid-template-columns: 1fr;\n gap: 16px;\n }\n\n .widget-footer {\n flex-direction: column;\n gap: 8px;\n text-align: center;\n }\n }\n\n @media (max-width: 480px) {\n :root {\n --mdas-base-font-size: 12px; /* Smaller on mobile */\n }\n }\n\n \n`,M=`\n ${k}\n\n .options-widget {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n color: #333;\n max-width: 1400px;\n width: 100%;\n margin: 0 auto;\n position: relative;\n overflow: hidden;\n }\n\n .widget-content {\n position: relative;\n z-index: 1;\n }\n\n \n .options-widget .symbol-info .symbol {\n font-size: var(--mdas-symbol-size);\n font-weight: 700;\n margin: 0 0 8px 0;\n color: #1f2937;\n }\n\n .options-widget .option-info {\n display: flex;\n align-items: center;\n gap: 8px;\n color: #6b7280;\n font-size: var(--mdas-price-change-size);\n }\n\n .options-widget .underlying-symbol {\n font-weight: 600;\n color: #6b7280;\n }\n\n .options-widget .option-details-section {\n display: flex;\n gap: 24px;\n margin-bottom: 24px;\n padding-bottom: 20px;\n border-bottom: 1px solid #e5e7eb;\n }\n\n .options-widget .option-details-section .detail-item {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .options-widget .option-details-section .detail-item label {\n font-size: var(--mdas-small-text-size);\n color: #6b7280;\n font-weight: 500;\n text-transform: uppercase;\n letter-spacing: 0.3px;\n }\n\n .options-widget .option-details-section .detail-item span {\n font-size: var(--mdas-price-change-size);\n font-weight: 600;\n color: #1f2937;\n }\n\n\n .options-widget .widget-footer {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding-top: 16px;\n border-top: 1px solid #e5e7eb;\n font-size: var(--mdas-small-text-size);\n color: #9ca3af;\n }\n\n /* Dimmed state for no-data */\n .widget-header.dimmed {\n opacity: 0.6;\n }\n\n .widget-header.dimmed .symbol {\n color: #9ca3af;\n }\n\n /* Responsive design */\n @media (max-width: 768px) {\n .widget-header {\n flex-direction: column;\n gap: 16px;\n text-align: left;\n }\n\n .price-info {\n text-align: left;\n }\n\n .data-grid {\n grid-template-columns: 1fr;\n gap: 20px;\n }\n\n .option-details-section {\n flex-wrap: wrap;\n gap: 16px;\n }\n\n .current-price {\n font-size: 32px;\n }\n\n .symbol {\n font-size: 20px !important;\n }\n }\n\n @media (max-width: 480px) {\n .widget-styled {\n padding: 12px;\n }\n\n .widget-header {\n margin-bottom: 16px;\n padding-bottom: 16px;\n }\n\n .current-price {\n font-size: 28px;\n }\n\n .data-row {\n grid-template-columns: 1fr;\n gap: 12px;\n }\n\n .option-details-section {\n flex-direction: column;\n gap: 12px;\n }\n\n .no-data-state {\n min-height: 120px;\n padding: 20px 12px;\n }\n\n .no-data-title {\n font-size: 14px;\n }\n\n .no-data-description {\n font-size: 12px;\n }\n\n .no-data-guidance {\n font-size: 11px;\n }\n }\n`;class C extends n{constructor(t,e,n){if(super(t,e,n),!e.symbol)throw new Error("Symbol is required for NightSessionWidget");if(!e.wsManager)throw new Error("WebSocketManager is required for NightSessionWidget");if(!e.source||"blueocean"!==e.source.toLowerCase()&&"bruce"!==e.source.toLowerCase()&&"onbbo"!==e.source.toLowerCase())throw new Error('Source should be either "blueocean", "bruce", or "onbbo"');this.type="nightsession "+e.source;const i=f(e.symbol);if(!i.valid)throw new Error(`Invalid symbol: ${i.error}`);this.symbol=i.sanitized,this.source=e.source||"blueocean",this.wsManager=e.wsManager,this.debug=e.debug||!1,this.styled=void 0===e.styled||e.styled,this.data=null,this.isDestroyed=!1,this.unsubscribe=null,this.symbolEditor=null,this.loadingTimeout=null,this.companyName="",this.exchangeName="",this.mic="",this.createWidgetStructure(),this.initialize()}createWidgetStructure(){if(this.container.innerHTML='\n <div class="night-session-widget widget">\n <div class="widget-content">\n \x3c!-- Header Section --\x3e\n <div class="widget-header">\n <div class="symbol-section">\n <div class="company-market-info">\n <span class="night-company-name"></span>\n <span class="market-name"></span>\n </div>\n <h1 class="symbol editable-symbol"\n title="Double-click to edit symbol"\n data-original-symbol="">\n </h1>\n\n </div>\n <div class="price-section">\n <div class="current-price"></div>\n <div class="price-change">\n <span class="change-value"></span>\n <span class="change-percent"></span>\n </div>\n <div class="price-metadata">\n <div class="last-update"></div>\n <div class="data-source"></div>\n </div>\n </div>\n </div>\n\n \x3c!-- Data Grid Section --\x3e\n <div class="data-grid">\n <div class="data-section">\n <div class="section-title">Quote</div>\n <div class="data-row">\n <span class="data-label">Bid</span>\n <span class="data-value bid-ask-value">\n <span class="bid-price"></span>\n <span class="size-info bid-size"></span>\n </span>\n </div>\n <div class="data-row">\n <span class="data-label">Ask</span>\n <span class="data-value bid-ask-value">\n <span class="ask-price"></span>\n <span class="size-info ask-size"></span>\n </span>\n </div>\n </div>\n\n <div class="data-section">\n <div class="section-title">Trading Activity</div>\n <div class="data-row">\n <span class="data-label">Volume</span>\n <span class="data-value volume"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Accumulated Amount</span>\n <span class="data-value accu-amount"></span>\n </div>\n </div>\n\n <div class="data-section">\n <div class="section-title">Performance</div>\n <div class="data-row">\n <span class="data-label">Previous Close</span>\n <span class="data-value previous-close"></span>\n </div>\n <div class="data-row at-close-row">\n <span class="data-label">At close</span>\n <span class="data-value at-close-time"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Open</span>\n <span class="data-value open-price"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Day Range</span>\n <span class="data-value range-value day-range"></span>\n </div>\n </div>\n </div>\n </div>\n\n \x3c!-- Loading Overlay --\x3e\n <div class="widget-loading-overlay">\n <div class="loading-content">\n <div class="loading-spinner"></div>\n <span class="loading-text">Loading night session data...</span>\n </div>\n </div>\n </div>\n',this.styled){const t=this.container.querySelector(".night-session-widget");t&&t.classList.add("widget-styled")}this.addStyles(),this.setupSymbolEditor()}addStyles(){if(!document.querySelector("#night-session-styles")){const t=document.createElement("style");t.id="night-session-styles",t.textContent=S,document.head.appendChild(t)}}setupSymbolEditor(){this.symbolEditor=new s(this,{maxLength:10,placeholder:"Enter symbol...",onSymbolChange:this.handleSymbolChange.bind(this),debug:this.debug,autoUppercase:!0,cancelOnBlur:!1,symbolType:"nightsession"})}async handleSymbolChange(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.debug&&(console.log("[NightSessionWidget] Symbol change requested:",t),console.log("[NightSessionWidget] Validation data:",n));const i=f(t);if(!i.valid)return this.debug&&console.log("[NightSessionWidget] Invalid symbol:",i.error),{success:!1,error:i.error};const s=i.sanitized;if(n&&(this.companyName=n.comp_name||"",this.exchangeName=n.market_name||"",this.mic=n.mic||"",this.debug&&console.log("[NightSessionWidget] Extracted company info:",{companyName:this.companyName,exchangeName:this.exchangeName},n)),s===this.symbol)return this.debug&&console.log("[NightSessionWidget] Same symbol, no change needed"),{success:!0};try{const t=this.symbol;return this.showLoading(),this.loadingTimeout&&this.clearTimeout(this.loadingTimeout),this.loadingTimeout=this.setTimeout((()=>{this.debug&&console.log("[NightSessionWidget] Loading timeout for symbol:",s),this.hideLoading(),this.showError(`No data received for ${s}. Please try again.`)}),1e4),this.unsubscribe&&(this.debug&&console.log(`[NightSessionWidget] Unsubscribing from ${t}`),this.unsubscribe(),this.unsubscribe=null),this.symbol=s,this.debug&&console.log(`[NightSessionWidget] Subscribing to ${s}`),this.subscribeToData(),this.debug&&console.log(`[NightSessionWidget] Successfully changed symbol from ${t} to ${s}`),{success:!0}}catch(t){return console.error("[NightSessionWidget] Error changing symbol:",t),this.showError(`Failed to load data for ${s}`),{success:!1,error:`Failed to load ${s}`}}}async initialize(){this.showLoading();!1!==await super.validateInitialSymbol("quotel1",this.symbol,(t=>{t&&t[0]&&(this.companyName=t[0].comp_name||"",this.exchangeName=t[0].market_name||"",this.mic=t[0].mic||"")}))&&(this.loadingTimeout=setTimeout((()=>{this.debug&&console.log("[NightSessionWidget] Loading timeout - no data received for:",this.symbol),this.hideLoading(),this.showNoDataState({Symbol:this.symbol,NotFound:!0,message:"No data available for this symbol"})}),1e4),this.subscribeToData())}subscribeToData(){let t;t="bruce"===this.source?"querybrucel1":"onbbo"===this.source?"queryonbbol1":"queryblueoceanl1",this.unsubscribe=this.wsManager.subscribe(this.widgetId,[t],this.handleMessage.bind(this),this.symbol)}handleData(t){if(console.log("DEBUG NIGHT",t),this.loadingTimeout&&(clearTimeout(this.loadingTimeout),this.loadingTimeout=null),!0===t.error){this.debug&&console.log("[Nigh] Received error response:",t.message);const e=t.message||t.Message;if(e)return this.hideLoading(),void this.showError(e)}else if(t.Data&&"string"==typeof t.Data)return this.hideLoading(),void this.showError(t.Message);if("error"===t.type)return this.debug&&console.log("[NightSessionWidget] Received no data message:",t.message),void(this.data?(this.hideLoading(),this.debug&&console.log("[MarketDataWidget] Error received but keeping cached data:",errorMsg)):this.showError(errorMsg));if(Array.isArray(t.data)){const e=t.data.find((t=>t.Symbol===this.symbol));if(e){if(this.debug&&console.log("[NightSessionWidget] Found data for symbol:",e),!0===e.NotFound)this.data?(this.hideLoading(),this.debug&&console.log("[NightSessionWidget] No new data, keeping cached data visible")):this.showNoDataState(e);else{const t=new w(e);this.data=t,this.updateWidget(t)}return}this.data?(this.hideLoading(),this.debug&&console.log("[NightSessionWidget] No matching data in response, keeping cached data")):this.showNoDataState({Symbol:this.symbol,NotFound:!0})}t._cached}updateWidget(t){if(!this.isDestroyed)try{this.hideLoading(),this.clearError();const e=this.container.querySelector(".widget-header");e&&e.classList.remove("dimmed");const n=this.container.querySelector(".price-section");n&&n.classList.remove("dimmed");const i=this.container.querySelector(".data-grid");i&&(i.style.display="grid");const s=this.container.querySelector(".no-data-state");s&&s.remove();const o=this.container.querySelector(".symbol");o&&(o.textContent=t.symbol);const a=this.container.querySelector(".night-company-name");a&&(a.textContent=this.companyName||t.companyName||"");const r=this.container.querySelector(".market-name");r&&(r.textContent=this.exchangeName||t.exchangeName||"");const l=this.container.querySelector(".current-price");l&&(l.textContent=null!==t.lastPrice?t.formatPrice():"--");const c=t.change,d=this.container.querySelector(".price-change");if(d){const e=d.querySelector(".change-value"),n=d.querySelector(".change-percent");e&&(e.textContent=null!==c&&0!==c?c:"--"),n&&(0!==t.changePercent?n.textContent=` (${t.getPriceChangePercent().toFixed(2)}%)`:n.textContent=" (0.00%)"),d.classList.remove("positive","negative","neutral"),c>0?d.classList.add("positive"):c<0?d.classList.add("negative"):d.classList.add("neutral")}const h=this.container.querySelector(".bid-price");h&&(h.textContent=null!==t.bidPrice?`$${t.bidPrice.toFixed(2)} `:"-- ×");const u=this.container.querySelector(".bid-size");u&&(u.textContent=null!==t.bidSize?`× ${t.bidSize}`:"--");const g=this.container.querySelector(".ask-price");g&&(g.textContent=null!==t.askPrice?`$${t.askPrice.toFixed(2)} `:"-- ×");const p=this.container.querySelector(".ask-size");p&&(p.textContent=null!==t.askSize?`× ${t.askSize}`:"--");const m=this.container.querySelector(".volume");m&&(m.textContent=null!==t.volume?t.formatVolume():"--");const f=this.container.querySelector(".accu-amount");f&&(f.textContent=null!==t.accuAmount?`$${t.accuAmount.toLocaleString()}`:"--");const b=this.container.querySelector(".open-price");b&&(b.textContent=null!==t.openPrice?`$${t.openPrice.toFixed(2)}`:"--");const y=this.container.querySelector(".previous-close");y&&(y.textContent=null!==t.closingPrice?`$${t.closingPrice.toFixed(2)}`:"--");const v=this.container.querySelector(".at-close-time");if(v){const e=t.quoteTime?x(new Date(t.quoteTime)):"--";v.textContent=e}const w=this.container.querySelector(".day-range");w&&(null!==t.highPrice&&null!==t.lowPrice?w.textContent=`$${t.lowPrice.toFixed(2)} - $${t.highPrice.toFixed(2)}`:w.textContent="--");const k=this.container.querySelector(".data-source");k&&(k.textContent="Source: "+t.getDataSource());const S=(t=>{if(!t)return x();const e=new Date(t);return isNaN(e.getTime())?x():x(e)})(t.quoteTime),M=this.container.querySelector(".last-update");M&&(M.textContent=`Overnight: ${S}`)}catch(t){console.error("Error updating widget:",t),this.showError("Error updating data")}}showLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.remove("hidden")}hideLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.add("hidden")}showError(t){this.hideLoading(),this.clearError();const e=document.createElement("div");e.className="widget-error",e.textContent=`Error: ${t}`,e.style.cssText="\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n padding: 15px 20px;\n background: #fee;\n border: 1px solid #f5c6cb;\n border-radius: 6px;\n color: #721c24;\n text-align: center;\n font-size: 14px;\n z-index: 100;\n ",this.container.appendChild(e)}clearError(){const t=this.container.querySelector(".widget-error"),e=this.container.querySelector(".widget-error-container");t&&t.remove(),e&&e.remove()}showNoDataState(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.isDestroyed)try{this.hideLoading(),this.clearError();const e=t.Symbol||this.symbol,n=this.container.querySelector(".symbol");n&&(n.textContent=e);const i=this.container.querySelector(".current-price");i&&(i.textContent="$0.00");const s=this.container.querySelector(".price-change");if(s){const t=s.querySelector(".change-value");t&&(t.textContent="+0.00");const e=s.querySelector(".change-percent");e&&(e.textContent=" (0.00%)"),s.classList.remove("positive","negative")}const o=this.container.querySelector(".widget-header");o&&o.classList.add("dimmed");const a=this.container.querySelector(".price-section");a&&a.classList.add("dimmed"),this.showNoDataMessage(e,t);const r=x(),l=this.container.querySelector(".last-update");l&&(l.textContent=`Overnight: ${r}`)}catch(t){console.error("Error showing no data state:",t),this.showError("Error displaying no data state")}}showNoDataMessage(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=this.container.querySelector(".data-grid");n&&(n.style.display="none");const i=this.container.querySelector(".no-data-state");i&&i.remove();const s=e.isAccessError||e.message&&e.message.toLowerCase().includes("access"),o=u("div","","no-data-state"),a=u("div","","no-data-content");if(s){const n=document.createElement("div");n.className="no-data-icon error",n.innerHTML='<svg width="32" height="32" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="12" cy="12" r="10" stroke="#ef4444" stroke-width="2"/>\n <path d="M12 8v4" stroke="#ef4444" stroke-width="2" stroke-linecap="round"/>\n <circle cx="12" cy="16" r="1" fill="#ef4444"/>\n </svg>',a.appendChild(n);const i=u("h3",String(e.message||"Access Denied"),"no-data-title error");a.appendChild(i);const s=u("p","","no-data-description");s.appendChild(document.createTextNode("You do not have permission to view night session data for "));const o=u("strong",p(t));s.appendChild(o),a.appendChild(s);const r=u("p","Contact your administrator or try a different symbol","no-data-guidance");a.appendChild(r)}else{const n=document.createElement("div");n.className="no-data-icon",n.innerHTML='<svg width="32" height="32" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="12" cy="12" r="10" stroke="#9ca3af" stroke-width="2"/>\n <path d="M12 6v6l4 2" stroke="#9ca3af" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>',a.appendChild(n);const i=u("h3",String(e.message||"No Data Available"),"no-data-title");a.appendChild(i);const s=u("p","","no-data-description");s.appendChild(document.createTextNode("Night session data for "));const o=u("strong",p(t));s.appendChild(o),s.appendChild(document.createTextNode(" was not found")),a.appendChild(s);const r=u("p","Please check the symbol or try again later","no-data-guidance");a.appendChild(r)}o.appendChild(a);const r=this.container.querySelector(".widget-footer");r&&r.parentNode?r.parentNode.insertBefore(o,r):this.container.appendChild(o)}destroy(){this.isDestroyed=!0,this.loadingTimeout&&(this.clearTimeout(this.loadingTimeout),this.loadingTimeout=null),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null),this.symbolEditor&&(this.symbolEditor.destroy(),this.symbolEditor=null),super.destroy()}updateSymbol(t){this.handleSymbolChange(t)}}class _{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.rawData=t,this.symbol=t.Symbol||"",this.rootSymbol=t.RootSymbol||"",this.underlying=t.Underlying||"",this.expire=t.Expire||"",this.strike=t.Strike||0,this.type=this.determineOptionType(),this.lastPrice=t.LastPx||0,this.closePx=t.ClosePx||0,this.yestClosePx=t.YestClosePx||0,this.openPx=t.OpenPx||0,this.highPx=t.HighPx||0,this.lowPx=t.LowPx||0,this.bidPx=t.BidPx||0,this.bidSz=t.BidSz||0,this.bidExch=t.BidExch||"",this.askPx=t.AskPx||0,this.askSz=t.AskSz||0,this.askExch=t.AskExch||"",this.volume=t.Volume||0,this.openInterest=t.OpenInst||0,this.primeShare=t.PrimeShare||0,this.exch=t.Exch||"",this.dataSource=t.DataSource||"",this.quoteTime=t.QuoteTime||"",this.notFound=t.NotFound||!1}determineOptionType(){return this.symbol?this.symbol.includes("C")?"call":this.symbol.includes("P")?"put":"unknown":"unknown"}getChange(){return this.lastPrice-this.yestClosePx}getChangePercent(){return 0===this.yestClosePx?0:(this.lastPrice-this.yestClosePx)/this.yestClosePx*100}getSpread(){return this.askPx-this.bidPx}getSpreadPercent(){const t=(this.askPx+this.bidPx)/2;return 0===t?0:(this.askPx-this.bidPx)/t*100}getMidPrice(){return(this.askPx+this.bidPx)/2}formatPrice(t){return t?t.toFixed(2):"0.00"}formatStrike(){return`$${this.formatPrice(this.strike)}`}formatLastPrice(){return`$${this.formatPrice(this.lastPrice)}`}formatClosePx(){return`$${this.formatPrice(this.closePx)}`}formatYestClosePx(){return`$${this.formatPrice(this.yestClosePx)}`}formatOpenPx(){return`$${this.formatPrice(this.openPx)}`}formatHighPx(){return`$${this.formatPrice(this.highPx)}`}formatLowPx(){return`$${this.formatPrice(this.lowPx)}`}formatBid(){return`$${this.formatPrice(this.bidPx)}`}formatAsk(){return`$${this.formatPrice(this.askPx)}`}formatBidSize(){return this.bidSz.toString()}formatAskSize(){return this.askSz.toString()}formatSpread(){return`$${this.formatPrice(this.getSpread())}`}formatMidPrice(){return`$${this.formatPrice(this.getMidPrice())}`}formatChange(){const t=this.getChange();return`${t>=0?"+":""}${this.formatPrice(t)}`}formatChangePercent(){const t=this.getChangePercent();return`${t>=0?"+":""}${t.toFixed(2)}%`}formatVolume(){return this.volume.toLocaleString()}formatOpenInterest(){return this.openInterest.toLocaleString()}formatPrimeShare(){return this.primeShare.toString()}formatExpirationDate(){if(!this.expire)return"N/A";try{return new Date(this.expire).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch(t){return this.expire}}formatQuoteTime(){if(!this.quoteTime)return"N/A";try{return new Date(this.quoteTime).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch(t){return this.quoteTime}}formatExchange(){return this.exch||"N/A"}formatDataSource(){return this.dataSource||"N/A"}formatDayRange(){return`$${this.formatPrice(this.lowPx)} - $${this.formatPrice(this.highPx)}`}formatOptionType(){return this.type.toUpperCase()}getDaysToExpiration(){if(!this.expire)return 0;try{const t=new Date(this.expire),e=new Date,n=t.getTime()-e.getTime(),i=Math.ceil(n/864e5);return Math.max(0,i)}catch(t){return 0}}formatDaysToExpiration(){const t=this.getDaysToExpiration();return`${t} day${1!==t?"s":""}`}getMoneyness(t){return t&&0!==this.strike?"call"===this.type?t-this.strike:"put"===this.type?this.strike-t:0:0}isInTheMoney(t){return this.getMoneyness(t)>0}parseSymbol(){return{underlying:this.rootSymbol||"",expirationDate:this.expire||"",type:this.type||"",strikePrice:this.strike||0,fullSymbol:this.symbol||""}}getSummary(){return{symbol:this.symbol,underlying:this.underlying,type:this.formatOptionType(),strike:this.formatStrike(),expiration:this.formatExpirationDate(),lastPrice:this.formatLastPrice(),change:this.formatChange(),changePercent:this.formatChangePercent(),volume:this.formatVolume(),openInterest:this.formatOpenInterest(),bid:this.formatBid(),ask:this.formatAsk(),exchange:this.formatExchange()}}getDataSource(){return"opra-d"===this.dataSource.toLowerCase()?"20 mins delayed":"real-time"===this.dataSource.toLowerCase()?"Real-time":"MDAS Server"}static fromApiResponse(t){return new _(t)}isValid(){return!this.notFound&&this.symbol&&this.strike>0}}class T extends n{constructor(t,e,n){if(super(t,e,n),!e.symbol)throw new Error("Symbol is required for OptionsWidget");if(!e.wsManager)throw new Error("WebSocketManager is required for OptionsWidget");this.type="options";const i=b(e.symbol);if(!i.valid)throw new Error(`Invalid option symbol: ${i.error}`);this.symbol=i.sanitized,this.wsManager=e.wsManager,this.debug=e.debug||!1,this.styled=void 0===e.styled||e.styled,this.data=null,this.isDestroyed=!1,this.unsubscribe=null,this.loadingTimeout=null,this.createWidgetStructure(),this.initializeSymbolEditor(),this.initialize()}createWidgetStructure(){if(this.container.innerHTML='\n <div class="options-widget widget">\n <div class="widget-content">\n \x3c!-- Header Section with Purple Background --\x3e\n <div class="widget-header">\n <div class="symbol-section">\n <h1 class="symbol editable-symbol" \n title="Double-click to edit symbol" \n data-original-symbol="">\n </h1>\n <div class="option-info">\n <span class="underlying-symbol"></span>\n <span class="data-type">OPTIONS</span>\n </div>\n </div>\n <div class="price-section">\n <div class="current-price"></div>\n <div class="price-change">\n <span class="change-value"></span>\n <span class="change-percent"></span>\n </div>\n </div>\n </div>\n\n \x3c!-- Data Grid Section --\x3e\n <div class="data-grid">\n <div class="data-section">\n <div class="section-title">Quote</div>\n <div class="data-row">\n <span class="data-label">Bid</span>\n <span class="data-value bid-ask-value bid-data"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Ask</span>\n <span class="data-value bid-ask-value ask-data"></span>\n </div>\n </div>\n\n <div class="data-section">\n <div class="section-title">Trading Activity</div>\n <div class="data-row">\n <span class="data-label">Volume</span>\n <span class="data-value volume"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Open Interest</span>\n <span class="data-value open-interest"></span>\n </div>\n </div>\n\n <div class="data-section">\n <div class="section-title">Performance</div>\n <div class="data-row">\n <span class="data-label">Previous Close</span>\n <span class="data-value yesterday-close"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Open</span>\n <span class="data-value open-price"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Day Range</span>\n <span class="data-value range-value day-range"></span>\n </div>\n </div>\n\n <div class="data-section">\n <div class="section-title">Contract Info</div>\n <div class="data-row">\n <span class="data-label">Strike Price</span>\n <span class="data-value strike-price"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Expiration</span>\n <span class="data-value expiry-date"></span>\n </div>\n <div class="data-row">\n <span class="data-label">Prime Share</span>\n <span class="data-value prime-share"></span>\n </div>\n </div>\n </div>\n\n \x3c!-- Footer --\x3e\n <div class="widget-footer">\n <span class="last-update"></span>\n <span class="data-source"></span>\n </div>\n </div>\n \n \x3c!-- Loading Overlay --\x3e\n <div class="widget-loading-overlay">\n <div class="loading-content">\n <div class="loading-spinner"></div>\n <span class="loading-text">Loading options data...</span>\n </div>\n </div>\n </div>\n',this.styled){const t=this.container.querySelector(".options-widget");t&&t.classList.add("widget-styled")}this.addStyles()}addStyles(){if(!document.querySelector("#options-widget-styles")){const t=document.createElement("style");t.id="options-widget-styles",t.textContent=M,document.head.appendChild(t)}}initializeSymbolEditor(){this.symbolEditor=new s(this,{maxLength:20,placeholder:"Enter option contract...",onSymbolChange:this.handleSymbolChange.bind(this),debug:this.debug,autoUppercase:!0,symbolType:"optionsl1"});const t=this.container.querySelector(".symbol");t&&(t.textContent=this.symbol,t.dataset.originalSymbol=this.symbol)}async handleSymbolChange(t){this.debug&&console.log("[OptionsWidget] Symbol change requested:",t);const e=b(t);if(!e.valid)return this.debug&&console.log("[OptionsWidget] Invalid option symbol:",e.error),{success:!1,error:e.error};const n=e.sanitized;if(n===this.symbol)return this.debug&&console.log("[OptionsWidget] Same symbol, no change needed"),{success:!0};try{const t=this.symbol;return this.showLoading(),this.loadingTimeout&&this.clearTimeout(this.loadingTimeout),this.loadingTimeout=this.setTimeout((()=>{this.debug&&console.log("[OptionsWidget] Loading timeout for symbol:",n),this.hideLoading(),this.showError(`No data received for ${n}. Please try again.`)}),1e4),this.unsubscribe&&(this.debug&&console.log(`[OptionsWidget] Unsubscribing from ${t}`),this.wsManager.sendUnsubscribe("queryoptionl1",t),this.unsubscribe(),this.unsubscribe=null),this.symbol=n,this.debug&&console.log(`[OptionsWidget] Subscribing to ${n}`),this.subscribeToData(),this.debug&&console.log(`[OptionsWidget] Successfully changed symbol from ${t} to ${n}`),{success:!0}}catch(t){return console.error("[OptionsWidget] Error changing symbol:",t),this.showError(`Failed to load data for ${n}`),{success:!1,error:`Failed to load ${n}`}}}async initialize(){this.showLoading();!1!==await super.validateInitialSymbol("quoteOptionl1",this.symbol,(t=>{t&&t[0]&&!t[0].error&&!t[0].not_found&&(this.initialValidationData=t[0])}))&&this.subscribeToData()}subscribeToData(){this.unsubscribe=this.wsManager.subscribe(this.widgetId,["queryoptionl1"],this.handleMessage.bind(this),this.symbol)}handleData(t){if(this.loadingTimeout&&(clearTimeout(this.loadingTimeout),this.loadingTimeout=null),"error"!==t.type){if(t.RootSymbol===this.symbol||t.Underlying===this.symbol||t.Symbol?.includes(this.symbol))if(this.debug&&console.log("[OptionsWidget] Found matching options data for",this.symbol,":",t),!0===t.NotFound)this.data?(this.hideLoading(),this.debug&&console.log("[OptionsWidget] No new data, keeping cached data visible")):this.showNoDataState(t);else{const e=new _(t);this.data=e,this.updateWidget(e)}else if(Array.isArray(t)){const e=t.find((t=>t.RootSymbol===this.symbol||t.Underlying===this.symbol||t.Symbol?.includes(this.symbol)));if(e)if(!0===e.NotFound)this.data?(this.hideLoading(),this.debug&&console.log("[OptionsWidget] No new data, keeping cached data visible")):this.showNoDataState(e);else{const t=new _(e);this.data=t,this.updateWidget(t)}else this.debug&&console.log("[OptionsWidget] No matching data in response, keeping cached data"),this.hideLoading()}t._cached&&this.showConnectionQuality()}else{const e=t.message||"Server error";this.data?(this.hideLoading(),this.debug&&console.log("[OptionsWidget] Error received but keeping cached data:",e)):this.showError(e)}}showNoDataState(t){if(!this.isDestroyed)try{this.hideLoading();const e=t.Symbol||this.symbol,n=this.container.querySelector(".symbol");n&&(n.textContent=e);const i=this.container.querySelector(".underlying-symbol");i&&(i.textContent=t.RootSymbol||this.symbol);const s=this.container.querySelector(".current-price");s&&(s.textContent="$0.00");const o=this.container.querySelector(".price-change");if(o){const t=o.querySelector(".change-value");t&&(t.textContent="+0.00");const e=o.querySelector(".change-percent");e&&(e.textContent=" (0.00%)"),o.classList.remove("positive","negative")}const a=this.container.querySelector(".widget-header");a&&a.classList.add("dimmed"),this.showNoDataMessage(e);const r=x(),l=this.container.querySelector(".last-update");l&&(l.textContent=`Checked: ${r}`)}catch(t){console.error("Error showing no data state:",t),this.showError("Error displaying no data state")}}showNoDataMessage(t){const e=this.container.querySelector(".data-grid"),n=this.container.querySelector(".option-details-section");e&&(e.style.display="none"),n&&(n.style.display="none");const i=this.container.querySelector(".no-data-state");i&&i.remove();const s=u("div","","no-data-state"),o=u("div","","no-data-content"),a=document.createElement("div");a.className="no-data-icon",a.innerHTML='<svg width="48" height="48" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="12" cy="12" r="10" stroke="#9ca3af" stroke-width="2"/>\n <path d="M12 6v6l4 2" stroke="#9ca3af" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>',o.appendChild(a);const r=u("h3","No Data Available","no-data-title");o.appendChild(r);const l=u("p","","no-data-description");l.appendChild(document.createTextNode("Data for "));const c=u("strong",String(t));l.appendChild(c),l.appendChild(document.createTextNode(" was not found")),o.appendChild(l);const d=u("p","Please check the symbol or try again later","no-data-guidance");o.appendChild(d),s.appendChild(o);const h=this.container.querySelector(".widget-footer");h&&h.parentNode?h.parentNode.insertBefore(s,h):this.container.appendChild(s)}updateWidget(t){if(!this.isDestroyed)try{this.loadingTimeout&&(clearTimeout(this.loadingTimeout),this.loadingTimeout=null),this.hideLoading(),this.clearError();const e=this.container.querySelector(".widget-header");e&&e.classList.remove("dimmed");const n=this.container.querySelector(".data-grid");n&&(n.style.display="grid");const i=this.container.querySelector(".no-data-state");i&&i.remove();const s=this.container.querySelector(".symbol");s&&(s.textContent=t.symbol,s.dataset.originalSymbol=t.symbol);const o=this.container.querySelector(".underlying-symbol");o&&(o.textContent=t.rootSymbol||t.underlying||"QQQ");const a=this.container.querySelector(".current-price");a&&(a.textContent=t.formatLastPrice());const r=t.getChange(),l=this.container.querySelector(".price-change");if(l){const e=l.querySelector(".change-value"),n=l.querySelector(".change-percent");e&&(e.textContent=t.formatChange()),n&&(n.textContent=` (${t.formatChangePercent()})`),l.classList.remove("positive","negative","neutral"),r>0?l.classList.add("positive"):r<0?l.classList.add("negative"):l.classList.add("neutral")}const c=this.container.querySelector(".bid-data");if(c){m(c),c.appendChild(document.createTextNode(t.formatBid()));const e=u("span",`× ${t.bidSz}`,"size-info");c.appendChild(e)}const d=this.container.querySelector(".ask-data");if(d){m(d),d.appendChild(document.createTextNode(t.formatAsk()));const e=u("span",`× ${t.askSz}`,"size-info");d.appendChild(e)}const h=this.container.querySelector(".volume");h&&(h.textContent=t.formatVolume());const g=this.container.querySelector(".open-interest");g&&(g.textContent=t.formatOpenInterest());const p=this.container.querySelector(".day-range");p&&(p.textContent=t.formatDayRange());const f=this.container.querySelector(".open-price");f&&(f.textContent=t.formatOpenPx());const b=this.container.querySelector(".yesterday-close");b&&(b.textContent=t.formatYestClosePx());const y=this.container.querySelector(".strike-price");y&&(y.textContent=t.formatStrike());const v=this.container.querySelector(".expiry-date");v&&(v.textContent=t.formatExpirationDate());const w=this.container.querySelector(".prime-share");w&&(w.textContent=t.formatPrimeShare());const k=x(t.quoteTime||Date.now()),S=this.container.querySelector(".last-update");S&&(S.textContent=`Last update: ${k}`);const M=this.container.querySelector(".data-source");M&&(M.textContent=`Source: ${t.getDataSource()}`)}catch(t){console.error("Error updating options widget:",t),this.showError("Error updating data")}}formatPrice(t){return t?t.toFixed(2):"0.00"}formatPriceChange(t){return`${t>=0?"+":""}${t.toFixed(2)}`}showLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.remove("hidden")}hideLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.add("hidden")}showError(t){this.hideLoading(),this.clearError();const e=document.createElement("div");e.className="widget-error",e.textContent=`Error: ${t}`,e.style.cssText="\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n padding: 15px 20px;\n background: #fee;\n border: 1px solid #f5c6cb;\n border-radius: 6px;\n color: #721c24;\n text-align: center;\n font-size: 14px;\n z-index: 100;\n ",this.container.appendChild(e)}clearError(){const t=this.container.querySelector(".widget-error"),e=this.container.querySelector(".widget-error-container");t&&t.remove(),e&&e.remove()}destroy(){this.isDestroyed=!0,this.loadingTimeout&&(this.clearTimeout(this.loadingTimeout),this.loadingTimeout=null),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null),this.symbolEditor&&(this.symbolEditor.destroy(),this.symbolEditor=null),super.destroy()}}class D{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.openInterest=t.OpenInst||0,this.volume=t.Vol||0,this.askSize=t.AskSz||0,this.bidSize=t.BidSz||0,this.strike=t.Strike||0,this.askPrice=t.AskPx||0,this.bidPrice=t.BidPx||0,this.lastChange=t.LastChg||0,this.lastPrice=t.LastPx||0,this.dataSource=t.DataSource||"",this.expire=t.Expire||"",this.symbol=t.Symbol||""}}const P=`\n${o}\n${a("option-chain-widget")}\n${r("option-chain-widget")}\n${l("option-chain-widget")}\n${c("option-chain-widget")}\n\n/* Option Chain Widget Specific Styles */\n.option-chain-widget {\n border: 1px solid #e5e7eb;\n border-radius: 8px;\n background: white;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n font-size: 13px;\n max-width: 100%;\n overflow: hidden;\n position: relative;\n}\n\n.option-chain-widget .widget-header {\n background: #f9fafb;\n padding: 16px;\n border-bottom: 1px solid #e5e7eb;\n}\n\n.option-chain-widget .input-section {\n display: flex;\n gap: 12px;\n align-items: center;\n flex-wrap: wrap;\n}\n\n.option-chain-widget .filter-section {\n display: flex;\n gap: 8px;\n align-items: center;\n margin-top: 8px;\n}\n\n.option-chain-widget .filter-label {\n font-size: 13px;\n font-weight: 500;\n color: #374151;\n}\n\n.option-chain-widget .symbol-input,\n.option-chain-widget .date-select,\n.option-chain-widget .strike-filter {\n padding: 8px 12px;\n border: 1px solid #d1d5db;\n border-radius: 4px;\n font-size: 14px;\n font-family: inherit;\n min-width: 0;\n flex: 1;\n}\n\n.option-chain-widget .symbol-input {\n text-transform: uppercase;\n min-width: 100px;\n max-width: 120px;\n}\n\n.option-chain-widget .date-select {\n min-width: 140px;\n background: white;\n}\n\n.option-chain-widget .strike-filter {\n min-width: 200px;\n background: white;\n cursor: pointer;\n}\n\n.option-chain-widget .fetch-button {\n padding: 8px 16px;\n background: #3b82f6;\n color: white;\n border: none;\n border-radius: 4px;\n font-size: 14px;\n cursor: pointer;\n font-family: inherit;\n white-space: nowrap;\n}\n\n.option-chain-widget .fetch-button:hover {\n background: #2563eb;\n}\n\n.option-chain-widget .fetch-button:disabled {\n background: #9ca3af;\n cursor: not-allowed;\n}\n\n.option-chain-widget .date-select:disabled {\n background: #f3f4f6;\n color: #9ca3af;\n cursor: not-allowed;\n}\n\n.option-chain-widget .option-chain-table {\n max-height: 800px;\n overflow-x: auto; /* Enable horizontal scrolling */\n overflow-y: auto; /* Enable vertical scrolling if needed */\n -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */\n width: 100%; /* Ensure full width */\n position: relative; /* Establish positioning context */\n box-sizing: border-box; /* Include padding and border in the element's total width and height */\n}\n\n.option-chain-widget .table-header {\n background: #f3f4f6;\n font-weight: 600;\n border-bottom: 2px solid #d1d5db;\n position: sticky;\n top: 0;\n z-index: 10;\n width: fit-content; /* Ensure it spans the full width */\n box-sizing: border-box; /* Include padding and border in the element's total width and height */\n}\n\n.option-chain-widget .price-change.positive::before,\n.option-chain-widget .price-change.negative::before {\n content: none;\n}\n \n\n/* Better approach - make section headers align with actual column structure */\n.option-chain-widget .section-headers,\n.option-chain-widget .column-headers {\n\n display: grid;\n grid-template-columns: minmax(160px, 1fr) repeat(6, minmax(80px, 1fr)) 80px minmax(160px, 1fr) repeat(6, minmax(80px, 1fr));\n border-bottom: 1px solid #d1d5db;\n background: #f3f4f6;\n position: sticky;\n top: 0;\n z-index: 12;\n box-sizing: border-box; /* Include padding and border in the element's total width and height */\n margin: 0;\n padding: 0;\n min-width: fit-content;\n}\n\n.option-chain-widget .calls-header {\n grid-column: 1 / 8; /* Span across first 7 columns */\n padding: 8px;\n text-align: center;\n font-weight: 600;\n font-size: 14px;\n color: #374151;\n display: flex;\n align-items: center;\n justify-content: center;\n background: #f3f4f6;\n}\n\n.option-chain-widget .strike-header {\n grid-column: 8 / 9; /* Strike column */\n background: #e5e7eb;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.option-chain-widget .puts-header {\n grid-column: 9 / -1; /* Span from column 9 to the end */\n padding: 8px;\n text-align: center;\n font-weight: 600;\n font-size: 14px;\n color: #374151;\n display: flex;\n align-items: center;\n justify-content: center;\n background: #f3f4f6;\n}\n\n.option-chain-widget .column-headers {\n display: grid;\n grid-template-columns: minmax(160px, 1fr) repeat(6, minmax(80px, 1fr)) 80px minmax(160px, 1fr) repeat(6, minmax(80px, 1fr));\n position: sticky;\n top: 40px;\n z-index: 11;\n background: #f3f4f6;\n}\n\n.option-chain-widget .calls-columns,\n.option-chain-widget .puts-columns {\n display: contents; /* Remove their own grid, use parent grid */\n}\n\n.option-chain-widget .strike-column {\n display: flex;\n align-items: center;\n justify-content: center;\n background: #e5e7eb !important;\n font-weight: bold;\n color: #374151;\n font-size: 11px;\n text-transform: uppercase;\n}\n\n.option-chain-widget .strike-column span {\n background: transparent !important; /* Ensure span doesn't override parent background */\n}\n\n.option-chain-widget .column-headers span {\n padding: 6px 2px; /* Reduce padding to prevent text overflow */\n text-align: center;\n font-size: 11px; /* Reduce font size */\n text-transform: uppercase;\n color: #6b7280;\n font-weight: 600;\n letter-spacing: 0.3px; /* Reduce letter spacing */\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n background: #f3f4f6;\n}\n\n.option-chain-widget .option-row {\n display: grid;\n grid-template-columns: minmax(160px, 1fr) repeat(6, minmax(80px, 1fr)) 80px minmax(160px, 1fr) repeat(6, minmax(80px, 1fr));\n border-bottom: 1px solid #f3f4f6;\n min-height: 32px;\n}\n\n/* In-the-money highlighting */\n.option-chain-widget .calls-data.in-the-money span,\n.option-chain-widget .puts-data.in-the-money span {\n background-color: #fffbeb;\n}\n\n.option-chain-widget .option-row:hover {\n background: #f9fafb;\n}\n\n.option-chain-widget .option-row:hover .calls-data.in-the-money span,\n.option-chain-widget .option-row:hover .puts-data.in-the-money span {\n background-color: #fef3c7;\n}\n\n.option-chain-widget .option-row:hover .calls-data span,\n.option-chain-widget .option-row:hover .puts-data span,\n.option-chain-widget .option-row:hover .strike-data {\n background: #f9fafb;\n}\n\n.option-chain-widget .calls-data,\n.option-chain-widget .puts-data {\n display: contents; /* Make children participate in parent grid */\n}\n\n.option-chain-widget .strike-data {\n display: flex;\n align-items: center;\n justify-content: center;\n background: #f9fafb;\n font-weight: 600; /* Changed from bold to 600 for consistency */\n color: #6b7280; /* Changed from #1f2937 to match other widgets */\n}\n\n.option-chain-widget .calls-data span,\n.option-chain-widget .puts-data span {\n padding: 6px 4px;\n text-align: center;\n font-size: 12px;\n font-weight: 400;\n color: #111827;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n/* Override color for change values with positive/negative classes */\n.option-chain-widget .calls-data span.positive,\n.option-chain-widget .puts-data span.positive {\n color: #059669 !important;\n font-weight: 500;\n}\n\n.option-chain-widget .calls-data span.negative,\n.option-chain-widget .puts-data span.negative {\n color: #dc2626 !important;\n font-weight: 500;\n}\n\n.option-chain-widget .calls-data span.neutral,\n.option-chain-widget .puts-data span.neutral {\n color: #6b7280 !important;\n}\n\n.option-chain-widget .contract-cell {\n font-size: 10px;\n color: #6b7280;\n text-align: left;\n padding: 4px 6px;\n font-family: monospace;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.option-chain-widget .contract-cell.clickable {\n color: #3b82f6;\n cursor: pointer;\n text-decoration: underline;\n transition: all 0.2s ease;\n}\n\n.option-chain-widget .contract-cell.clickable:hover {\n color: #2563eb;\n background-color: #eff6ff;\n}\n\n.option-chain-widget .contract-cell.clickable:focus {\n outline: 2px solid #3b82f6;\n outline-offset: 2px;\n border-radius: 2px;\n}\n\n.option-chain-widget .contract-cell.clickable:active {\n color: #1e40af;\n background-color: #dbeafe;\n}\n\n.option-chain-widget .positive {\n color: #059669;\n}\n\n.option-chain-widget .negative {\n color: #dc2626;\n}\n\n.option-chain-widget .neutral {\n color: #6b7280;\n}\n\n/* Loading, Error, Footer, and No-Data styles provided by CommonWidgetPatterns */\n\n/* RESPONSIVE STYLES */\n\n/* Tablet styles (768px and down) */\n@media (max-width: 768px) {\n .option-chain-widget .input-section {\n flex-direction: column;\n align-items: stretch;\n gap: 8px;\n }\n\n .option-chain-widget .filter-section {\n flex-direction: row;\n margin-top: 0;\n }\n\n .option-chain-widget .symbol-input,\n .option-chain-widget .date-select,\n .option-chain-widget .strike-filter {\n width: 100%;\n max-width: none;\n }\n\n .option-chain-widget .fetch-button {\n width: 100%;\n }\n \n .option-chain-widget .calls-columns,\n .option-chain-widget .puts-columns {\n grid-template-columns: 120px repeat(6, minmax(50px, 1fr));\n }\n \n .option-chain-widget .calls-data,\n .option-chain-widget .puts-data {\n grid-template-columns: 120px repeat(6, minmax(50px, 1fr));\n }\n \n .option-chain-widget .column-headers span {\n font-size: 10px;\n padding: 6px 2px;\n }\n \n .option-chain-widget .calls-data span,\n .option-chain-widget .puts-data span {\n font-size: 11px;\n padding: 4px 2px;\n }\n \n .option-chain-widget .contract-cell {\n font-size: 9px;\n padding: 4px 4px;\n }\n \n .option-chain-widget .strike-data {\n font-size: 12px;\n }\n\n /* Update responsive breakpoints to match */\n .option-chain-widget .section-headers {\n grid-template-columns: 1fr 80px 1fr;\n background: #f3f4f6;\n width: 100%;\n\n }\n}\n\n/* Mobile styles (480px and down) */\n@media (max-width: 480px) {\n .option-chain-widget {\n font-size: 12px;\n }\n \n .option-chain-widget .widget-header {\n padding: 12px;\n }\n \n .option-chain-widget .section-headers {\n grid-template-columns: 1fr 60px 1fr;\n background: #f3f4f6;\n }\n \n .option-chain-widget .column-headers {\n grid-template-columns: 1fr 60px 1fr;\n }\n \n .option-chain-widget .option-row {\n grid-template-columns: 1fr 60px 1fr;\n min-height: 28px;\n }\n \n .option-chain-widget .calls-columns,\n .option-chain-widget .puts-columns {\n grid-template-columns: 100px repeat(6, minmax(40px, 1fr));\n }\n \n .option-chain-widget .calls-data,\n .option-chain-widget .puts-data {\n grid-template-columns: 100px repeat(6, minmax(40px, 1fr));\n }\n \n .option-chain-widget .column-headers span {\n font-size: 9px;\n padding: 4px 1px;\n }\n \n .option-chain-widget .calls-data span,\n .option-chain-widget .puts-data span {\n font-size: 10px;\n padding: 3px 1px;\n }\n \n .option-chain-widget .contract-cell {\n font-size: 8px;\n padding: 3px 2px;\n }\n \n .option-chain-widget .strike-data {\n font-size: 11px;\n padding: 3px;\n }\n \n \n .option-chain-widget .option-chain-table {\n max-height: 400px;\n }\n \n .option-chain-widget .no-data-state {\n padding: 20px;\n font-size: 12px;\n }\n \n .option-chain-widget .widget-error {\n margin: 8px;\n padding: 12px;\n font-size: 12px;\n }\n}\n\n/* Very small mobile (320px and down) */\n@media (max-width: 320px) {\n .option-chain-widget .section-headers {\n grid-template-columns: 1fr 50px 1fr;\n }\n \n .option-chain-widget .column-headers {\n grid-template-columns: 1fr 50px 1fr;\n }\n \n .option-chain-widget .option-row {\n grid-template-columns: 1fr 50px 1fr;\n }\n \n .option-chain-widget .calls-columns,\n .option-chain-widget .puts-columns {\n grid-template-columns: 80px repeat(6, minmax(35px, 1fr));\n }\n \n .option-chain-widget .calls-data,\n .option-chain-widget .puts-data {\n grid-template-columns: 80px repeat(6, minmax(35px, 1fr));\n }\n \n .option-chain-widget .column-headers span {\n font-size: 8px;\n padding: 3px 1px;\n }\n \n .option-chain-widget .calls-data span,\n .option-chain-widget .puts-data span {\n font-size: 9px;\n padding: 2px 1px;\n }\n \n .option-chain-widget .contract-cell {\n font-size: 7px;\n padding: 2px 1px;\n }\n}\n\n/* Modal Styles */\n.option-chain-modal-overlay {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(0, 0, 0, 0.6);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10000;\n padding: 20px;\n animation: fadeIn 0.2s ease-out;\n}\n\n@keyframes fadeIn {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n}\n\n.option-chain-modal {\n background: white;\n border-radius: 12px;\n box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);\n max-width: 800px;\n width: 100%;\n max-height: 90vh;\n display: flex;\n flex-direction: column;\n animation: slideUp 0.3s ease-out;\n}\n\n@keyframes slideUp {\n from {\n transform: translateY(20px);\n opacity: 0;\n }\n to {\n transform: translateY(0);\n opacity: 1;\n }\n}\n\n.option-chain-modal-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 20px 24px;\n border-bottom: 1px solid #e5e7eb;\n}\n\n.option-chain-modal-header h3 {\n margin: 0;\n font-size: 18px;\n font-weight: 600;\n color: #111827;\n}\n\n.option-chain-modal-close {\n background: none;\n border: none;\n font-size: 28px;\n line-height: 1;\n color: #6b7280;\n cursor: pointer;\n padding: 0;\n width: 32px;\n height: 32px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 4px;\n transition: all 0.2s ease;\n}\n\n.option-chain-modal-close:hover {\n background: #f3f4f6;\n color: #111827;\n}\n\n.option-chain-modal-close:active {\n background: #e5e7eb;\n}\n\n.option-chain-modal-body {\n flex: 1;\n overflow-y: auto;\n padding: 24px;\n}\n\n/* Responsive modal */\n@media (max-width: 768px) {\n .option-chain-modal {\n max-width: 95%;\n max-height: 95vh;\n }\n\n .option-chain-modal-header {\n padding: 16px;\n }\n\n .option-chain-modal-header h3 {\n font-size: 16px;\n }\n\n .option-chain-modal-body {\n padding: 16px;\n }\n}\n`;class E extends n{constructor(t,e,n){if(super(t,e,n),!e.wsManager)throw new Error("WebSocketManager is required for OptionChainWidget");if(this.type="optionchain",this.wsManager=e.wsManager,this.debug=e.debug||!1,this.data=null,this.isDestroyed=!1,this.unsubscribe=null,this.unsubscribeUnderlying=null,this.underlyingPrice=null,this.loadingTimeout=null,this.renderDebounceTimeout=null,this.cachedOptionChainData=null,this.cachedUnderlyingPrice=null,this.optionsModal=null,this.optionsWidgetInstance=null,e.symbol){const t=f(e.symbol);t.valid?this.symbol=t.sanitized:(console.warn("[OptionChainWidget] Invalid initial symbol:",t.error),this.symbol="")}else this.symbol="";this.date="",this.availableDates={},this.strikeFilterRange=5,this.fetchRateLimiter=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:500,e=0;return()=>{const n=Date.now(),i=n-e;return i<t?{valid:!1,error:`Please wait ${Math.ceil((t-i)/1e3)} seconds`,remainingMs:t-i}:(e=n,{valid:!0})}}(1e3),this.createWidgetStructure(),this.initialize()}createWidgetStructure(){this.container.innerHTML='\n <div class="option-chain-widget widget">\n <div class="widget-content">\n \x3c!-- Header Section --\x3e\n <div class="widget-header">\n <div class="input-section">\n <input type="text" class="symbol-input" placeholder="Enter Symbol" value="" />\n <select class="date-select" disabled>\n <option value="">Select a date...</option>\n </select>\n <button class="fetch-button" disabled>Search</button>\n </div>\n <div class="filter-section">\n <label for="strike-filter" class="filter-label">Display:</label>\n <select class="strike-filter" id="strike-filter">\n <option value="5">Near the money (±5 strikes)</option>\n <option value="10">Near the money (±10 strikes)</option>\n <option value="15">Near the money (±15 strikes)</option>\n <option value="all">All strikes</option>\n </select>\n </div>\n </div>\n\n \x3c!-- Data Grid Section --\x3e\n <div class="option-chain-table">\n <div class="table-header">\n <div class="section-headers">\n <div class="calls-header">Calls</div>\n <div class="strike-header"></div>\n <div class="puts-header">Puts</div>\n </div>\n <div class="column-headers">\n <div class="calls-columns">\n <span>Contract</span>\n <span>Last</span>\n <span>Change</span>\n <span>Bid</span>\n <span>Ask</span>\n <span>Volume</span>\n <span>Open Int.</span>\n </div>\n <div class="strike-column">\n <span>Strike</span>\n </div>\n <div class="puts-columns">\n <span>Contract</span>\n <span>Last</span>\n <span>Change</span>\n <span>Bid</span>\n <span>Ask</span>\n <span>Volume</span>\n <span>Open Int.</span>\n </div>\n </div>\n </div>\n <div class="option-chain-data-grid">\n \x3c!-- Option chain data will be populated here --\x3e\n </div>\n </div>\n\n \x3c!-- Footer --\x3e\n <div class="widget-footer">\n <span class="last-update"></span>\n <span class="data-source"></span>\n </div>\n </div>\n \n \x3c!-- Loading Overlay --\x3e\n <div class="widget-loading-overlay hidden">\n <div class="loading-content">\n <div class="loading-spinner"></div>\n <span class="loading-text">Loading option chain data...</span>\n </div>\n </div>\n </div>\n',this.addStyles(),this.setupEventListeners()}addStyles(){if(!document.querySelector("#option-chain-styles")){const t=document.createElement("style");t.id="option-chain-styles",t.textContent=P,document.head.appendChild(t)}}setupEventListeners(){this.symbolInput=this.container.querySelector(".symbol-input"),this.dateSelect=this.container.querySelector(".date-select"),this.fetchButton=this.container.querySelector(".fetch-button"),this.dataGrid=this.container.querySelector(".option-chain-data-grid"),this.strikeFilterSelect=this.container.querySelector(".strike-filter"),this.symbol&&(this.symbolInput.value=this.symbol,this.fetchButton.disabled=!1,this.dateSelect.innerHTML='<option value="">Click search to load dates...</option>'),this.addEventListener(this.symbolInput,"input",(t=>{const e=t.target.value,n=f(e);this.clearInputError(this.symbolInput),n.valid?(this.symbol=n.sanitized,this.symbolInput.value=n.sanitized,this.dateSelect.innerHTML='<option value="">Click search to load dates...</option>',this.dateSelect.disabled=!0,this.fetchButton.disabled=!1,this.availableDates={},this.date=""):""!==e.trim()?(this.showInputError(this.symbolInput,n.error),this.fetchButton.disabled=!0):this.clearDateOptions()})),this.addEventListener(this.dateSelect,"change",(t=>{const e=t.target.value;if(!e)return void(this.date="");const n=function(t){if(!t||"string"!=typeof t)return{valid:!1,error:"Date is required",normalized:""};const e=t.trim();let n;if(/^\d{4}-\d{2}-\d{2}$/.test(e))n=new Date(e);else if(/^\d{2}\/\d{2}\/\d{4}$/.test(e)){const[t,i,s]=e.split("/");n=new Date(s,parseInt(t,10)-1,parseInt(i,10))}else{if(!/^\d+$/.test(e))return{valid:!1,error:"Invalid date format. Use YYYY-MM-DD or MM/DD/YYYY",normalized:""};n=new Date(parseInt(e,10))}return isNaN(n.getTime())?{valid:!1,error:"Invalid date",normalized:""}:{valid:!0,normalized:n.toISOString().split("T")[0]}}(e);n.valid?(this.date=n.normalized,this.symbol&&this.fetchOptionChain()):(this.showError(n.error),this.date="")})),this.addEventListener(this.fetchButton,"click",(()=>{const t=f(this.symbol);if(!t.valid)return void this.showError(t.error||"Please enter a valid symbol first");const e=this.fetchRateLimiter();e.valid?this.loadAvailableDates(t.sanitized):this.showError(e.error)})),this.addEventListener(this.strikeFilterSelect,"change",(t=>{const e=t.target.value;this.strikeFilterRange="all"===e?"all":parseInt(e,10),this.data&&this.displayOptionChain(this.data)}))}async loadAvailableDates(t){if(t)try{this.symbol=t,this.symbolInput.value=t,this.dateSelect.disabled=!0,this.dateSelect.innerHTML='<option value="">Loading dates...</option>',this.fetchButton.disabled=!0;const e=this.wsManager.getApiService(),n=await e.getOptionChainDates(t);this.debug&&console.log("[OptionChainWidget] Available dates:",n.dates_dictionary),this.availableDates=n.dates_dictionary||{},this.populateDateOptions()}catch(e){console.error("[OptionChainWidget] Error loading dates:",e),this.dateSelect.innerHTML='<option value="">Error loading dates</option>',this.fetchButton.disabled=!1,this.showError(`Failed to load dates for ${t}: ${e.message}`)}}populateDateOptions(){this.dateSelect.innerHTML='<option value="">Select expiration date...</option>';const t=Object.keys(this.availableDates).sort();if(0===t.length)return this.dateSelect.innerHTML='<option value="">No dates available</option>',void(this.fetchButton.disabled=!1);t.forEach((t=>{const e=document.createElement("option");e.value=t;const n=this.availableDates[t],i=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{timezone:n="ET",format:i="short"}=e;if(!t||"string"!=typeof t)return"";const s=t.split("-");if(3!==s.length)return t;const[o,a,r]=s,l=parseInt(a,10)-1,c=parseInt(r,10),d=("long"===i?["January","February","March","April","May","June","July","August","September","October","November","December"]:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"])[l];return`${d} ${c}, ${o}`}(t,{timezone:y(t),format:"short"});e.textContent=i,e.className=`date-option ${n}`,this.dateSelect.appendChild(e)})),this.dateSelect.disabled=!1,this.fetchButton.disabled=!1,t.length>0&&(this.dateSelect.value=t[0],this.date=t[0],this.fetchOptionChain())}clearDateOptions(){this.dateSelect.innerHTML='<option value="">Click fetch to load dates...</option>',this.dateSelect.disabled=!0,this.fetchButton.disabled=!this.symbol,this.symbol=this.symbolInput.value.trim().toUpperCase()||"",this.date="",this.availableDates={}}initialize(){this.hideLoading(),this.symbol&&this.loadAvailableDates(this.symbol)}fetchOptionChain(){if(this.symbol&&this.date)try{this.showLoading(),this.loadingTimeout&&this.clearTimeout(this.loadingTimeout),this.loadingTimeout=this.setTimeout((()=>{this.debug&&console.log("[OptionChainWidget] Loading timeout for:",this.symbol,this.date),this.hideLoading(),this.showError(`No data received for ${this.symbol} on ${this.date}. Please try again.`)}),1e4),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null),this.unsubscribeUnderlying&&(this.unsubscribeUnderlying(),this.unsubscribeUnderlying=null),this.subscribeToData()}catch(t){console.error("[OptionChainWidget] Error fetching option chain:",t),this.showError(`Failed to load data for ${this.symbol}`)}else console.warn("[OptionChainWidget] Missing symbol or date")}subscribeToData(){this.unsubscribe=this.wsManager.subscribe(this.widgetId,["queryoptionchain"],this.handleMessage.bind(this),this.symbol,{date:this.date}),this.unsubscribeUnderlying=this.wsManager.subscribe(`${this.widgetId}-underlying`,["queryl1"],this.handleMessage.bind(this),this.symbol)}findNearestStrike(t,e){if(!t||0===t.length||!e)return null;let n=t[0],i=Math.abs(parseFloat(t[0])-e);for(const s of t){const t=Math.abs(parseFloat(s)-e);t<i&&(i=t,n=s)}return n}filterNearMoneyStrikes(t,e,n){if(!e||!t||0===t.length)return t;const i=t.indexOf(e);if(-1===i)return t;const s=Math.max(0,i-n),o=Math.min(t.length-1,i+n);return t.slice(s,o+1)}handleData(t){if(this.loadingTimeout&&(this.clearTimeout(this.loadingTimeout),this.loadingTimeout=null),"error"!==t.type){if(Array.isArray(t))0===t.length?this.data?(this.hideLoading(),this.debug&&console.log("[OptionChainWidget] No new data, keeping cached data visible")):this.showNoDataState():(this.data=t,this.cachedOptionChainData=t,this.displayOptionChain(t));else if("queryoptionchain"===t.type&&Array.isArray(t.data))0===t.data.length?this.data?(this.hideLoading(),this.debug&&console.log("[OptionChainWidget] No new data, keeping cached data visible")):this.showNoDataState():(this.data=t.data,this.cachedOptionChainData=t.data,this.displayOptionChain(t.data));else if("queryl1"===t.type&&t.Data){this.debug&&console.log("[OptionChainWidget] Received underlying price update");const e=t.Data.find((t=>t.Symbol===this.symbol));e&&e.LastPx&&(this.underlyingPrice=parseFloat(e.LastPx),this.cachedUnderlyingPrice=parseFloat(e.LastPx),this.renderDebounceTimeout&&this.clearTimeout(this.renderDebounceTimeout),this.renderDebounceTimeout=this.setTimeout((()=>{this.data&&this.displayOptionChain(this.data),this.renderDebounceTimeout=null}),500))}t._cached&&this.showConnectionQuality()}else{const e=t.message||"Server error";this.data?(this.hideLoading(),this.debug&&console.log("[OptionChainWidget] Error received but keeping cached data:",e)):this.showError(e)}}displayOptionChain(t){if(!this.isDestroyed)if(t&&Array.isArray(t)&&0!==t.length)try{this.hideLoading(),this.clearError(),this.dataGrid.innerHTML="";const e={};t.forEach((t=>{const n=new D(t),i=n.strike;e[i]||(e[i]={call:null,put:null});"call"===L(n.symbol)?e[i].call=n:e[i].put=n}));const n=Object.keys(e).sort(((t,e)=>parseFloat(t)-parseFloat(e)));let i=n;if("all"!==this.strikeFilterRange&&this.underlyingPrice){const t=this.findNearestStrike(n,this.underlyingPrice);t&&(i=this.filterNearMoneyStrikes(n,t,this.strikeFilterRange))}if(i.forEach((t=>{const{call:n,put:i}=e[t],s=document.createElement("div");s.classList.add("option-row");const o=t=>{const e=document.createElement("span");if(!t||0===t)return e.className="neutral",e.textContent="0.00",e;const n=parseFloat(t).toFixed(2),i=t>0?"positive":t<0?"negative":"neutral",s=t>0?"+":"";return e.className=i,e.textContent=`${s}${n}`,e},a=t=>g(t,2,"0.00"),r=document.createElement("div");r.className="calls-data",this.underlyingPrice&&parseFloat(t)<this.underlyingPrice&&r.classList.add("in-the-money");const l=u("span",n?p(n.symbol):"--","contract-cell");n&&n.symbol&&(l.classList.add("clickable"),l.setAttribute("role","button"),l.setAttribute("tabindex","0"),l.setAttribute("data-symbol",n.symbol),this.addEventListener(l,"click",(()=>this.showOptionsModal(n.symbol))),this.addEventListener(l,"keypress",(t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.showOptionsModal(n.symbol))}))),r.appendChild(l),r.appendChild(u("span",a(n?.lastPrice)));const c=document.createElement("span");n?c.appendChild(o(n.lastChange)):(c.textContent="0.00",c.className="neutral"),r.appendChild(c),r.appendChild(u("span",a(n?.bidPrice))),r.appendChild(u("span",a(n?.askPrice))),r.appendChild(u("span",n?String(n.volume):"0")),r.appendChild(u("span",n?String(n.openInterest):"0"));const d=document.createElement("div");d.className="strike-data",d.textContent=t;const h=document.createElement("div");h.className="puts-data",this.underlyingPrice&&parseFloat(t)>this.underlyingPrice&&h.classList.add("in-the-money");const m=u("span",i?p(i.symbol):"","contract-cell");i&&i.symbol&&(m.classList.add("clickable"),m.setAttribute("role","button"),m.setAttribute("tabindex","0"),m.setAttribute("data-symbol",i.symbol),this.addEventListener(m,"click",(()=>this.showOptionsModal(i.symbol))),this.addEventListener(m,"keypress",(t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.showOptionsModal(i.symbol))}))),h.appendChild(m),h.appendChild(u("span",a(i?.lastPrice)));const f=document.createElement("span");i?f.appendChild(o(i.lastChange)):(f.textContent="0.00",f.className="neutral"),h.appendChild(f),h.appendChild(u("span",a(i?.bidPrice))),h.appendChild(u("span",a(i?.askPrice))),h.appendChild(u("span",i?String(i.volume):"0")),h.appendChild(u("span",i?String(i.openInterest):"0")),s.appendChild(r),s.appendChild(d),s.appendChild(h),this.dataGrid.appendChild(s)})),t&&t.length>0){const e="OPRA-D"===t[0].DataSource;let n=t[0].quoteTime||Date.now();e&&(n-=12e5);const i=x(n),s=this.container.querySelector(".last-update");s&&(s.textContent=`Last update: ${i}`);const o=e?"20 mins delayed":"Real-time",a=this.container.querySelector(".data-source");a&&(a.textContent=`Source: ${o}`)}}catch(t){console.error("Error displaying option chain:",t),this.showError("Error displaying data")}else this.debug&&console.warn("[OptionChainWidget] Invalid or empty data passed to displayOptionChain")}showLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.remove("hidden")}hideLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.add("hidden")}showError(t){this.hideLoading(),this.clearError();const e=document.createElement("div");e.className="widget-error",e.textContent=`Error: ${t}`,e.style.cssText="\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n padding: 15px 20px;\n background: #fee;\n border: 1px solid #f5c6cb;\n border-radius: 6px;\n color: #721c24;\n text-align: center;\n font-size: 14px;\n z-index: 100;\n ",this.container.appendChild(e)}clearError(){const t=this.container.querySelector(".widget-error"),e=this.container.querySelector(".widget-error-container");t&&t.remove(),e&&e.remove()}showNoDataState(){this.hideLoading(),this.clearError();const t=u("div","","no-data-state"),e=u("div","","no-data-content"),n=document.createElement("div");n.className="no-data-icon",n.innerHTML='<svg width="32" height="32" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="12" cy="12" r="10" stroke="#9ca3af" stroke-width="2"/>\n <path d="M12 6v6l4 2" stroke="#9ca3af" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>',e.appendChild(n);const i=u("h3","No Option Chain Data","no-data-title");e.appendChild(i);const s=u("p","","no-data-description");s.appendChild(document.createTextNode("Option chain data for "));const o=u("strong",p(this.symbol));s.appendChild(o),s.appendChild(document.createTextNode(" on "));const a=u("strong",String(this.date));s.appendChild(a),s.appendChild(document.createTextNode(" was not found")),e.appendChild(s);const r=u("p","Please check the symbol and date or try again later","no-data-guidance");e.appendChild(r),t.appendChild(e);const l=this.container.querySelector(".widget-footer");l&&l.parentNode?l.parentNode.insertBefore(t,l):this.container.appendChild(t)}showOptionsModal(t){if(!t||"--"===t)return;this.closeOptionsModal(),this.optionsModal=document.createElement("div"),this.optionsModal.className="option-chain-modal-overlay",this.optionsModal.innerHTML=`\n <div class="option-chain-modal">\n <div class="option-chain-modal-header">\n <h3>Option Details: ${p(t)}</h3>\n <button class="option-chain-modal-close" aria-label="Close modal">×</button>\n </div>\n <div class="option-chain-modal-body">\n <div id="option-chain-modal-widget"></div>\n </div>\n </div>\n `,document.body.appendChild(this.optionsModal);const e=this.optionsModal.querySelector(".option-chain-modal-close");this.addEventListener(e,"click",(()=>this.closeOptionsModal())),this.addEventListener(this.optionsModal,"click",(t=>{t.target===this.optionsModal&&this.closeOptionsModal()}));const n=t=>{"Escape"===t.key&&this.closeOptionsModal()};document.addEventListener("keydown",n),this._escapeHandler=n;try{const e=this.optionsModal.querySelector("#option-chain-modal-widget");this.optionsWidgetInstance=new T(e,{symbol:t,wsManager:this.wsManager,debug:this.debug,styled:!0},`${this.widgetId}-options-modal`),this.debug&&console.log("[OptionChainWidget] Options modal opened for:",t)}catch(t){console.error("[OptionChainWidget] Error creating Options widget:",t),this.closeOptionsModal(),this.showError(`Failed to load option details: ${t.message}`)}}closeOptionsModal(){this.optionsWidgetInstance&&(this.optionsWidgetInstance.destroy(),this.optionsWidgetInstance=null),this.optionsModal&&(this.optionsModal.remove(),this.optionsModal=null),this._escapeHandler&&(document.removeEventListener("keydown",this._escapeHandler),this._escapeHandler=null),this.debug&&console.log("[OptionChainWidget] Options modal closed")}destroy(){this.isDestroyed=!0,this.closeOptionsModal(),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null),this.unsubscribeUnderlying&&(this.unsubscribeUnderlying(),this.unsubscribeUnderlying=null),this.loadingTimeout&&(this.clearTimeout(this.loadingTimeout),this.loadingTimeout=null),this.renderDebounceTimeout&&(this.clearTimeout(this.renderDebounceTimeout),this.renderDebounceTimeout=null),this.cachedOptionChainData=null,this.cachedUnderlyingPrice=null,this.underlyingPrice=null,this.data=null,super.destroy()}}const L=t=>{const e=t.match(/^(.+?)(\d{6})([CP])(\d{8})$/);if(e){const[,t,n,i,s]=e;return"C"===i?"call":"put"}return null};class A extends n{constructor(t,e,n){if(super(t,e,n),!e.symbol)throw new Error("Symbol is required for DataWidget");if(!e.wsManager)throw new Error("WebSocketManager is required for DataWidget");this.type="data",this.symbol=(e.symbol||"").toString().toUpperCase(),this.wsManager=e.wsManager,this.dataSource=e.dataSource||"queryl1",this.debug=e.debug||!1,this.data=null,this.isDestroyed=!1,this.unsubscribe=null,this.loadingTimeout=null,this.createWidgetStructure(),this.initializeSymbolEditor(),this.initialize()}createWidgetStructure(){this.container.innerHTML='\n <div class="data-widget widget">\n <div class="widget-content">\n \x3c!-- Header Section --\x3e\n <div class="widget-header">\n <div class="symbol-section">\n <h1 class="symbol editable-symbol" \n title="Double-click to edit symbol" \n data-original-symbol="">\n </h1>\n <div class="company-info">\n <span class="data-type">Stock</span>\n <span class="company-name"></span>\n </div>\n </div>\n </div>\n\n \x3c!-- Price Section --\x3e\n <div class="price-section">\n <div class="current-price"></div>\n <div class="price-change">\n <span class="change-value"></span>\n <span class="change-percent"></span>\n </div>\n </div>\n\n \x3c!-- Bid/Ask Section --\x3e\n <div class="bid-ask-section">\n <div class="ask">\n <span class="label">Ask</span>\n <span class="value ask-price"></span>\n <span class="size ask-size"></span>\n </div>\n <div class="bid">\n <span class="label">Bid</span>\n <span class="value bid-price"></span>\n <span class="size bid-size"></span>\n </div>\n </div>\n\n \x3c!-- Footer --\x3e\n <div class="widget-footer">\n <span class="last-size">Last Size: <span class="trade-size"></span></span>\n <span class="source">Market Data Powered by MDAS</span>\n </div>\n </div>\n\n \n </div>\n',this.addStyles()}addStyles(){if(!document.querySelector("#data-styles")){const t=document.createElement("style");t.id="data-styles",t.textContent="\n .data-widget {\n position: relative;\n border: 1px solid #ddd;\n border-radius: 8px;\n overflow: hidden;\n background-color: #fff;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);\n padding: 10px;\n font-family: Arial, sans-serif;\n }\n\n .data-widget .widget-header {\n display: flex;\n flex-direction: column;\n margin-bottom: 10px;\n }\n\n .data-widget .symbol {\n font-size: 24px;\n font-weight: bold;\n margin-right: 10px;\n }\n\n .data-widget .company-info {\n font-size: 12px;\n color: #666;\n }\n\n .data-widget .trading-info {\n font-size: 12px;\n color: #999;\n }\n\n .data-widget .price-section {\n display: flex;\n align-items: baseline;\n margin-bottom: 10px;\n }\n\n .data-widget .current-price {\n font-size: 36px;\n font-weight: bold;\n margin-right: 10px;\n }\n\n .data-widget .price-change {\n font-size: 18px;\n }\n\n .data-widget .price-change.positive {\n color: green;\n }\n\n .data-widget .price-change.negative {\n color: red;\n }\n\n .data-widget .bid-ask-section {\n display: flex;\n justify-content: space-between;\n margin-bottom: 10px;\n }\n\n .data-widget .ask,\n .data-widget .bid {\n display: flex;\n align-items: center;\n }\n\n .data-widget .label {\n font-size: 14px;\n margin-right: 5px;\n }\n\n .data-widget .value {\n font-size: 16px;\n font-weight: bold;\n margin-right: 5px;\n }\n\n .data-widget .size {\n font-size: 14px;\n color: red;\n }\n\n .data-widget .widget-footer {\n font-size: 12px;\n color: #333;\n }\n",document.head.appendChild(t)}}initializeSymbolEditor(){this.symbolEditor=new s(this,{maxLength:10,placeholder:"Enter symbol...",onSymbolChange:this.handleSymbolChange.bind(this),debug:this.debug,autoUppercase:!0,symbolType:"quotel1"});const t=this.container.querySelector(".symbol");t&&(t.textContent=this.symbol,t.dataset.originalSymbol=this.symbol)}async handleSymbolChange(t){this.debug&&console.log("[DataWidget] Symbol change requested:",t);const e=t.toUpperCase();if(e===this.symbol)return this.debug&&console.log("[DataWidget] Same symbol, no change needed"),{success:!0};try{const t=this.symbol;return this.showLoading(),this.loadingTimeout&&clearTimeout(this.loadingTimeout),this.loadingTimeout=setTimeout((()=>{this.debug&&console.log("[DataWidget] Loading timeout for symbol:",e),this.hideLoading(),this.showError(`No data received for ${e}. Please try again.`)}),1e4),this.unsubscribe&&(this.debug&&console.log(`[DataWidget] Unsubscribing from ${t}`),this.wsManager.sendUnsubscribe(this.dataSource,t),this.unsubscribe(),this.unsubscribe=null),this.symbol=e,this.debug&&console.log(`[DataWidget] Subscribing to ${e}`),this.subscribeToData(),this.debug&&console.log(`[DataWidget] Successfully changed symbol from ${t} to ${e}`),{success:!0}}catch(t){return console.error("[DataWidget] Error changing symbol:",t),this.hideLoading(),this.showError(`Failed to load data for ${e}`),{success:!1,error:`Failed to load ${e}`}}}initialize(){this.showLoading(),this.subscribeToData()}subscribeToData(){this.unsubscribe=this.wsManager.subscribe(this.widgetId,[this.dataSource],this.handleMessage.bind(this),this.symbol)}showNoDataState(t){let{Symbol:e,NotFound:n,message:i}=t;this.clearError(),this.hideLoading();const s=document.createElement("div");s.className="no-data-state",s.innerHTML=`\n <div class="no-data-content">\n <div class="no-data-icon">\n <svg width="32" height="32" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="12" cy="12" r="10" stroke="#9ca3af" stroke-width="2"/>\n <path d="M12 6v6l4 2" stroke="#9ca3af" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>\n </div>\n <h3 class="no-data-title">No Data Available</h3>\n <p class="no-data-description">Data for <strong>${e}</strong> was not found.</p>\n <p class="no-data-guidance">${i||"Please check the symbol or try again later."}</p>\n </div>\n `,this.container.appendChild(s)}handleData(t){if(this.loadingTimeout&&(clearTimeout(this.loadingTimeout),this.loadingTimeout=null),"error"===t.type&&t.noData)return this.debug&&console.log("[DataWidget] Received no data message:",t.message),void this.showNoDataState({Symbol:this.symbol,NotFound:!0,message:t.message});if("error"!==t.type){if(t.Data&&t.Data.length>0){const e=t.Data.find((t=>t.Symbol===this.symbol));if(e){const t=new i(e);this.updateWidget(t)}else console.log("hereee"),this.showNoDataState({Symbol:this.symbol,NotFound:!0,message:`No data found for ${this.symbol}`})}t._cached&&this.showConnectionQuality()}else{const e=t.message||"Server error";this.showError(e)}}updateWidget(t){if(!this.isDestroyed)try{this.clearError(),this.hideLoading();const e=this.container.querySelector(".symbol");e&&(e.textContent=t.symbol,e.dataset.originalSymbol=t.symbol);const n=this.container.querySelector(".current-price");n&&(n.textContent=t.formatPrice());const i=this.container.querySelector(".price-change"),s=i.querySelector(".change-value"),o=i.querySelector(".change-percent");s.textContent=t.formatPriceChange(),o.textContent=` (${t.formatPriceChangePercent()})`,i.classList.remove("positive","negative","neutral"),t.getPriceChange()>0?i.classList.add("positive"):t.getPriceChange()<0?i.classList.add("negative"):i.classList.add("neutral");const a=this.container.querySelector(".bid-price");a&&(a.textContent=t.bidPrice.toFixed(2));const r=this.container.querySelector(".ask-price");r&&(r.textContent=t.askPrice.toFixed(2));const l=this.container.querySelector(".bid-size");l&&(l.textContent=`× ${t.bidSize}`);const c=this.container.querySelector(".ask-size");c&&(c.textContent=`× ${t.askSize}`);const d=this.container.querySelector(".trade-size");d&&(d.textContent=t.tradeSize);const h=this.container.querySelector(".last-update");if(h){const e=x(t.quoteTime);h.textContent=`Last update: ${e}`}const u=this.container.querySelector(".data-source");u&&(u.textContent=`Source: ${t.getDataSource()}`)}catch(t){console.error("Error updating widget:",t),this.showError("Error updating data")}}}class I extends n{constructor(t,e,n){if(super(t,e,n),!e.symbol)throw new Error("Symbol is required for CombinedMarketWidget");if(!e.wsManager)throw new Error("WebSocketManager is required for CombinedMarketWidget");const i=f(e.symbol);if(!i.valid)throw new Error(`Invalid symbol: ${i.error}`);this.type="combined-market",this.wsManager=e.wsManager,this.symbol=i.sanitized,this.debug=e.debug||!1,this.removeNightSession=!0,this.marketData=null,this.nightSessionData=null,this.unsubscribeMarket=null,this.unsubscribeNight=null,this.createWidgetStructure(),this.initializeSymbolEditor(),this.subscribeToData()}createWidgetStructure(){this.container.innerHTML='\n <div class="combined-market-widget">\n <div class="combined-market-header">\n <div class="combined-symbol-section">\n <h1 class="combined-symbol editable-symbol"\n title="Double-click to edit symbol"\n data-original-symbol="">\n </h1>\n <div class="combined-company-info">\n <span class="company-name">\n </span>\n </div>\n </div>\n </div>\n\n <div class="combined-data-container">\n \x3c!-- Regular Market Data (Left) --\x3e\n <div class="combined-market-section regular-market">\n <div class="combined-price-info">\n <div class="combined-current-price">--</div>\n <div class="combined-price-change neutral">\n <span class="combined-change-value">--</span>\n <span class="combined-change-percent">(--)</span>\n </div>\n </div>\n <div class="combined-market-status"><span class="market-status-label"></span> <span class="combined-timestamp">--</span></div>\n </div>\n\n \x3c!-- Night Session Data (Right) --\x3e\n <div class="combined-market-section night-session">\n\n <div class="combined-price-info">\n <div class="combined-current-price">--</div>\n <div class="combined-price-change neutral">\n <span class="combined-change-value">--</span>\n <span class="combined-change-percent">(--)</span>\n </div>\n </div>\n <div class="combined-market-status">Overnight: <span class="combined-timestamp">--</span></div>\n </div>\n </div>\n\n <div class="combined-loading-overlay hidden">\n <div class="combined-loading-content">\n <div class="combined-loading-spinner"></div>\n <span class="combined-loading-text">Loading market data...</span>\n </div>\n </div>\n </div>\n';const t=this.container.querySelector(".combined-symbol");if(t&&(t.textContent=this.symbol,t.dataset.originalSymbol=this.symbol),this.removeNightSession&&!this.isNightSessionActive()){const t=this.container.querySelector(".night-session");t&&(t.style.display="none")}this.addStyles()}addStyles(){if(!document.querySelector("#combined-market-styles")){const t=document.createElement("style");t.id="combined-market-styles",t.textContent='\n .combined-market-widget {\n background: #ffffff;\n color: #111827;\n padding: 24px;\n border-radius: 12px;\n border: 1px solid #e5e7eb;\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n position: relative;\n }\n\n .combined-market-widget .combined-market-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: 24px;\n padding-bottom: 16px;\n border-bottom: 1px solid #e5e7eb;\n }\n\n .combined-market-widget .combined-symbol-section {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .combined-market-widget .combined-symbol {\n font-size: 24px;\n font-weight: 700;\n margin: 0;\n color: #111827;\n cursor: pointer;\n transition: all 0.2s ease;\n position: relative;\n }\n\n .combined-market-widget .combined-symbol:hover {\n opacity: 0.8;\n transform: scale(1.02);\n }\n\n .combined-market-widget .combined-symbol:hover::after {\n content: "✎";\n position: absolute;\n top: -8px;\n right: -8px;\n background: #3b82f6;\n color: white;\n font-size: 10px;\n padding: 2px 4px;\n border-radius: 4px;\n opacity: 0.8;\n pointer-events: none;\n }\n\n .combined-market-widget .follow-btn {\n background: #ffffff;\n border: 1px solid #d1d5db;\n color: #374151;\n padding: 8px 16px;\n border-radius: 20px;\n cursor: pointer;\n font-size: 14px;\n font-weight: 500;\n transition: all 0.2s;\n }\n\n .combined-market-widget .follow-btn:hover {\n border-color: #9ca3af;\n background: #f9fafb;\n }\n\n .combined-market-widget .combined-data-container {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 40px;\n }\n\n .combined-market-widget .combined-market-section {\n display: flex;\n flex-direction: column;\n gap: 8px;\n }\n\n .combined-market-widget .combined-price-info {\n display: flex;\n flex-direction: column;\n min-height: 90px;\n }\n\n .combined-market-widget .session-label {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 14px;\n color: #6b7280;\n margin-bottom: 4px;\n font-weight: 500;\n }\n\n .combined-market-widget .session-label .icon {\n font-size: 16px;\n }\n\n .combined-market-widget .combined-current-price {\n font-size: 48px;\n font-weight: 700;\n line-height: 1;\n color: #111827;\n }\n\n .combined-market-widget .combined-price-change {\n display: flex;\n gap: 8px;\n font-size: 20px;\n font-weight: 600;\n margin-top: 4px;\n }\n\n .combined-market-widget .combined-price-change.positive {\n color: #059669;\n }\n\n .combined-market-widget .combined-price-change.negative {\n color: #dc2626;\n }\n\n .combined-market-widget .combined-price-change.neutral {\n color: #6b7280;\n }\n\n .combined-market-widget .combined-market-status {\n font-size: 14px;\n color: #6b7280;\n margin-top: 8px;\n }\n\n .combined-market-widget .combined-timestamp {\n color: #9ca3af;\n font-weight: 400;\n }\n\n /* Loading overlay */\n .combined-market-widget .combined-loading-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(255, 255, 255, 0.95);\n backdrop-filter: blur(2px);\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 12px;\n z-index: 10;\n }\n\n .combined-market-widget .combined-loading-overlay.hidden {\n display: none;\n }\n\n .combined-market-widget .combined-loading-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 12px;\n }\n\n .combined-market-widget .combined-loading-spinner {\n width: 40px;\n height: 40px;\n border: 3px solid #e5e7eb;\n border-top-color: #3b82f6;\n border-radius: 50%;\n animation: combined-market-spin 1s linear infinite;\n }\n\n .combined-market-widget .combined-loading-text {\n color: #6b7280;\n font-size: 14px;\n font-weight: 500;\n }\n\n @keyframes combined-market-spin {\n to { transform: rotate(360deg); }\n }\n\n /* Responsive */\n @media (max-width: 768px) {\n .combined-market-widget .combined-data-container {\n grid-template-columns: 1fr;\n gap: 30px;\n }\n\n .combined-market-widget .combined-current-price {\n font-size: 36px;\n }\n\n .combined-market-widget .combined-price-change {\n font-size: 16px;\n }\n }\n',document.head.appendChild(t)}}initializeSymbolEditor(){this.symbolEditor=new s(this,{maxLength:10,placeholder:"Enter symbol...",onSymbolChange:this.handleSymbolChange.bind(this),debug:this.debug,autoUppercase:!0,symbolType:"quotel1"});const t=this.container.querySelector(".combined-symbol");t&&(t.textContent=this.symbol,t.dataset.originalSymbol=this.symbol)}async handleSymbolChange(t){this.debug&&console.log("[CombinedMarketWidget] Symbol change requested:",t);const e=f(t);if(!e.valid)return this.debug&&console.log("[CombinedMarketWidget] Invalid symbol:",e.error),{success:!1,error:e.error};const n=e.sanitized;if(n===this.symbol)return this.debug&&console.log("[CombinedMarketWidget] Same symbol, no change needed"),{success:!0};try{const t=this.symbol;return this.showLoading(),this.unsubscribeMarket&&(this.debug&&console.log(`[CombinedMarketWidget] Unsubscribing from market data: ${t}`),this.wsManager.sendUnsubscribe("queryl1",t),this.unsubscribeMarket(),this.unsubscribeMarket=null),this.unsubscribeNight&&(this.debug&&console.log(`[CombinedMarketWidget] Unsubscribing from night session: ${t}`),this.wsManager.sendUnsubscribe("queryblueoceanl1",t),this.unsubscribeNight(),this.unsubscribeNight=null),this.symbol=n,this.marketData=null,this.nightSessionData=null,this.debug&&console.log(`[CombinedMarketWidget] Subscribing to new symbol: ${n}`),this.subscribeToData(),this.debug&&console.log(`[CombinedMarketWidget] Successfully changed symbol from ${t} to ${n}`),{success:!0}}catch(t){return console.error("[CombinedMarketWidget] Error changing symbol:",t),this.hideLoading(),{success:!1,error:`Failed to load ${n}`}}}subscribeToData(){this.showLoading(),this.unsubscribeMarket=this.wsManager.subscribe(`${this.widgetId}-market`,["queryl1"],this.handleMessage.bind(this),this.symbol),this.unsubscribeNight=this.wsManager.subscribe(`${this.widgetId}-night`,["queryblueoceanl1"],this.handleMessage.bind(this),this.symbol)}handleData(t){this.debug&&console.log("[CombinedMarketWidget] handleData called",t),this.loadingTimeout&&(this.clearTimeout(this.loadingTimeout),this.loadingTimeout=null);const e=t.Data||t.data,n=t.type;if("error"===t.type||1==t.error)return this.debug&&console.log("[CombinedMarketWidget] Received error:",t.message),void this.hideLoading();if("object"==typeof t&&t.Message){const e=t.Message.toLowerCase();if(e.includes("no data")||e.includes("not found"))return this.debug&&console.log("[CombinedMarketWidget] No data message:",t.Message),void this.hideLoading()}if("queryl1"===n){if(this.debug&&console.log("[CombinedMarketWidget] Processing queryl1 data"),e&&Array.isArray(e)){const t=e.find((t=>t.Symbol===this.symbol));t?(this.debug&&console.log("[CombinedMarketWidget] Market data received:",t),this.marketData=new i(t),this.updateMarketSection(),this.hideLoading()):(this.debug&&console.log("[CombinedMarketWidget] No market data for symbol in response, keeping cached data"),this.hideLoading())}}else if(("queryblueoceanl1"===n||"querybrucel1"===n)&&(this.debug&&console.log("[CombinedMarketWidget] Processing night session data"),e&&Array.isArray(e))){const t=e.find((t=>t.Symbol===this.symbol));t?!0!==t.NotFound&&t.MarketName&&"BLUE"===t.MarketName?(this.debug&&console.log("[CombinedMarketWidget] Night session data received:",t),this.nightSessionData=new w(t),this.updateNightSessionSection(),this.hideLoading()):(this.debug&&console.log("[CombinedMarketWidget] Night session data not found or not available"),this.hideLoading()):(this.debug&&console.log("[CombinedMarketWidget] No night session data for symbol in response, keeping cached data"),this.hideLoading())}t._cached&&this.showConnectionQuality()}updateMarketSection(){if(!this.marketData)return;const t=this.container.querySelector(".regular-market"),e=this.container.querySelector(".company-name");if(e){const t=this.marketData.companyName||`${this.marketData.symbol} Inc.`,n=this.marketData.companyDescription||`${this.marketData.symbol}`;e.textContent=t,e.setAttribute("title",n),e.setAttribute("data-tooltip",n)}t.querySelector(".combined-current-price").textContent=this.marketData.formatPrice();const n=t.querySelector(".combined-price-change"),i=t.querySelector(".combined-change-value"),s=t.querySelector(".combined-change-percent"),o=this.marketData.change,a=o>0?"positive":o<0?"negative":"neutral";n.className=`combined-price-change ${a}`,i.textContent=this.marketData.formatPriceChange(),s.textContent=`(${this.marketData.formatPriceChangePercent()})`;const r=t.querySelector(".market-status-label");r&&(r.textContent=`${this.getSessionType()}:`);t.querySelector(".combined-timestamp").textContent=x(this.marketData.quoteTime,{format:"long"}),this.debug&&console.log("[CombinedMarketWidget] Updated market section:",this.marketData)}updateNightSessionSection(){if(!this.nightSessionData)return;const t=this.container.querySelector(".night-session");if(this.removeNightSession&&!this.isNightSessionActive())return t.style.display="none",void(this.debug&&console.log("[CombinedMarketWidget] Night session hidden (market closed)"));t.style.display="";const e=t.querySelector(".combined-current-price");e&&(e.textContent=this.nightSessionData.lastPrice?this.nightSessionData.formatPrice():"--");const n=t.querySelector(".combined-price-change"),i=t.querySelector(".combined-change-value"),s=t.querySelector(".combined-change-percent"),o=this.nightSessionData.change,a=o>0?"positive":o<0?"negative":"neutral";n.className=`combined-price-change ${a}`,i.textContent=null!==this.nightSessionData.change?this.nightSessionData.formatPriceChange():"--",s.textContent=`(${this.nightSessionData.formatPriceChangePercent()})`;t.querySelector(".combined-timestamp").textContent=x(this.nightSessionData.quoteTime,{format:"long"}),this.debug&&(console.log("connection quality:",this.connectionQuality),console.log("[CombinedMarketWidget] Updated night session section:",this.nightSessionData))}getSessionType(){const t=(new Date).toLocaleString("en-US",{timeZone:"America/New_York"}),e=new Date(t),n=e.getHours(),i=e.getMinutes(),s=60*n+i;return console.log("Current EST time:",n+":"+(i<10?"0":"")+i),s>=240&&s<570?"Pre-Market":s>=570&&s<960?"Market Hours":s>=960&&s<1200?"Post-Market":"Market Closed"}isNightSessionActive(){return"Market Closed"===this.getSessionType()}destroy(){this.unsubscribeMarket&&(this.unsubscribeMarket(),this.unsubscribeMarket=null),this.unsubscribeNight&&(this.unsubscribeNight(),this.unsubscribeNight=null),this.symbolEditor&&(this.symbolEditor.destroy(),this.symbolEditor=null),super.destroy()}}class z{constructor(t){Array.isArray(t)?(console.log("[IntradayChartModel] Processing",t.length,"raw data points"),t.length>0&&console.log("[IntradayChartModel] Sample raw point:",t[0]),this.dataPoints=t.map(((t,e)=>{const n={symbol:t.symbol||t.Symbol,time:t.time||t.Time||t.timestamp||t.Timestamp,open:parseFloat(t.open||t.Open)||0,high:parseFloat(t.high||t.High)||0,low:parseFloat(t.low||t.Low)||0,close:parseFloat(t.close||t.Close)||0,volume:parseInt(t.volume||t.Volume)||0,source:t.source||t.Source};return e<2&&console.log(`[IntradayChartModel] Processed point ${e}:`,n),n.time||console.warn(`[IntradayChartModel] Point ${e} missing time:`,t),0===n.close&&console.warn(`[IntradayChartModel] Point ${e} has zero close price:`,t),n})).filter((t=>{if(!t.time||t.close<=0)return!1;const e=new Date(t.time).getTime();return!(isNaN(e)||e<9466848e5)||(console.warn("[IntradayChartModel] Invalid timestamp:",t.time),!1)})),this.dataPoints.sort(((t,e)=>new Date(t.time).getTime()-new Date(e.time).getTime())),console.log("[IntradayChartModel] Valid data points after filtering:",this.dataPoints.length),this.dataPoints.length>0&&console.log("[IntradayChartModel] Time range:",this.dataPoints[0].time,"to",this.dataPoints[this.dataPoints.length-1].time)):(console.warn("[IntradayChartModel] Expected array of data points, got:",typeof t),this.dataPoints=[]),this.symbol=this.dataPoints.length>0?this.dataPoints[0].symbol:null,this.source=this.dataPoints.length>0?this.dataPoints[0].source:null}getTimeLabels(){return this.dataPoints.map((t=>{const e=new Date(t.time);let n=e.getHours();const i=n>=12?"PM":"AM";n%=12,n=n||12;return[`${n}:${e.getMinutes().toString().padStart(2,"0")} ${i}`,`${(e.getMonth()+1).toString().padStart(2,"0")}/${e.getDate().toString().padStart(2,"0")}`]}))}getOHLCData(){return this.dataPoints.map((t=>({x:new Date(t.time).getTime(),o:t.open,h:t.high,l:t.low,c:t.close})))}getClosePrices(){return this.dataPoints.map((t=>t.close))}getVolumeData(){return this.dataPoints.map((t=>t.volume))}getHighPrices(){return this.dataPoints.map((t=>t.high))}getLowPrices(){return this.dataPoints.map((t=>t.low))}getOpenPrices(){return this.dataPoints.map((t=>t.open))}getStats(){if(0===this.dataPoints.length)return{high:0,low:0,open:0,close:0,change:0,changePercent:0,volume:0};this.getClosePrices();const t=this.getHighPrices(),e=this.getLowPrices(),n=this.getVolumeData(),i=this.dataPoints[0],s=this.dataPoints[this.dataPoints.length-1],o=s.close-i.open,a=0!==i.open?o/i.open*100:0;return{high:Math.max(...t),low:Math.min(...e),open:i.open,close:s.close,change:o,changePercent:a,volume:n.reduce(((t,e)=>t+e),0),dataPoints:this.dataPoints.length}}formatPrice(t){return t.toFixed(2)}formatVolume(t){return t>=1e6?(t/1e6).toFixed(2)+"M":t>=1e3?(t/1e3).toFixed(2)+"K":t.toString()}}
|
|
2
2
|
/*!
|
|
3
3
|
* @kurkle/color v0.3.4
|
|
4
4
|
* https://github.com/kurkle/color#readme
|
|
5
5
|
* (c) 2024 Jukka Kurkela
|
|
6
6
|
* Released under the MIT License
|
|
7
7
|
*/
|
|
8
|
-
function
|
|
8
|
+
function O(t){return t+.5|0}const W=(t,e,n)=>Math.max(Math.min(t,n),e);function N(t){return W(O(2.55*t),0,255)}function $(t){return W(O(255*t),0,255)}function R(t){return W(O(t/2.55)/100,0,1)}function F(t){return W(O(100*t),0,100)}const B={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},q=[..."0123456789ABCDEF"],H=t=>q[15&t],V=t=>q[(240&t)>>4]+q[15&t],j=t=>(240&t)>>4==(15&t);function Y(t){var e=(t=>j(t.r)&&j(t.g)&&j(t.b)&&j(t.a))(t)?H:V;return t?"#"+e(t.r)+e(t.g)+e(t.b)+((t,e)=>t<255?e(t):"")(t.a,e):void 0}const U=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function X(t,e,n){const i=e*Math.min(n,1-n),s=(e,s=(e+t/30)%12)=>n-i*Math.max(Math.min(s-3,9-s,1),-1);return[s(0),s(8),s(4)]}function Q(t,e,n){const i=(i,s=(i+t/60)%6)=>n-n*e*Math.max(Math.min(s,4-s,1),0);return[i(5),i(3),i(1)]}function G(t,e,n){const i=X(t,1,.5);let s;for(e+n>1&&(s=1/(e+n),e*=s,n*=s),s=0;s<3;s++)i[s]*=1-e-n,i[s]+=e;return i}function K(t){const e=t.r/255,n=t.g/255,i=t.b/255,s=Math.max(e,n,i),o=Math.min(e,n,i),a=(s+o)/2;let r,l,c;return s!==o&&(c=s-o,l=a>.5?c/(2-s-o):c/(s+o),r=function(t,e,n,i,s){return t===s?(e-n)/i+(e<n?6:0):e===s?(n-t)/i+2:(t-e)/i+4}(e,n,i,c,s),r=60*r+.5),[0|r,l||0,a]}function Z(t,e,n,i){return(Array.isArray(e)?t(e[0],e[1],e[2]):t(e,n,i)).map($)}function J(t,e,n){return Z(X,t,e,n)}function tt(t){return(t%360+360)%360}function et(t){const e=U.exec(t);let n,i=255;if(!e)return;e[5]!==n&&(i=e[6]?N(+e[5]):$(+e[5]));const s=tt(+e[2]),o=+e[3]/100,a=+e[4]/100;return n="hwb"===e[1]?function(t,e,n){return Z(G,t,e,n)}(s,o,a):"hsv"===e[1]?function(t,e,n){return Z(Q,t,e,n)}(s,o,a):J(s,o,a),{r:n[0],g:n[1],b:n[2],a:i}}const nt={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"},it={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 st;function ot(t){st||(st=function(){const t={},e=Object.keys(it),n=Object.keys(nt);let i,s,o,a,r;for(i=0;i<e.length;i++){for(a=r=e[i],s=0;s<n.length;s++)o=n[s],r=r.replace(o,nt[o]);o=parseInt(it[a],16),t[r]=[o>>16&255,o>>8&255,255&o]}return t}(),st.transparent=[0,0,0,0]);const e=st[t.toLowerCase()];return e&&{r:e[0],g:e[1],b:e[2],a:4===e.length?e[3]:255}}const at=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;const rt=t=>t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055,lt=t=>t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4);function ct(t,e,n){if(t){let i=K(t);i[e]=Math.max(0,Math.min(i[e]+i[e]*n,0===e?360:1)),i=J(i),t.r=i[0],t.g=i[1],t.b=i[2]}}function dt(t,e){return t?Object.assign(e||{},t):t}function ht(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=$(t[3]))):(e=dt(t,{r:0,g:0,b:0,a:1})).a=$(e.a),e}function ut(t){return"r"===t.charAt(0)?function(t){const e=at.exec(t);let n,i,s,o=255;if(e){if(e[7]!==n){const t=+e[7];o=e[8]?N(t):W(255*t,0,255)}return n=+e[1],i=+e[3],s=+e[5],n=255&(e[2]?N(n):W(n,0,255)),i=255&(e[4]?N(i):W(i,0,255)),s=255&(e[6]?N(s):W(s,0,255)),{r:n,g:i,b:s,a:o}}}(t):et(t)}class gt{constructor(t){if(t instanceof gt)return t;const e=typeof t;let n;var i,s,o;"object"===e?n=ht(t):"string"===e&&(o=(i=t).length,"#"===i[0]&&(4===o||5===o?s={r:255&17*B[i[1]],g:255&17*B[i[2]],b:255&17*B[i[3]],a:5===o?17*B[i[4]]:255}:7!==o&&9!==o||(s={r:B[i[1]]<<4|B[i[2]],g:B[i[3]]<<4|B[i[4]],b:B[i[5]]<<4|B[i[6]],a:9===o?B[i[7]]<<4|B[i[8]]:255})),n=s||ot(t)||ut(t)),this._rgb=n,this._valid=!!n}get valid(){return this._valid}get rgb(){var t=dt(this._rgb);return t&&(t.a=R(t.a)),t}set rgb(t){this._rgb=ht(t)}rgbString(){return this._valid?(t=this._rgb)&&(t.a<255?`rgba(${t.r}, ${t.g}, ${t.b}, ${R(t.a)})`:`rgb(${t.r}, ${t.g}, ${t.b})`):void 0;var t}hexString(){return this._valid?Y(this._rgb):void 0}hslString(){return this._valid?function(t){if(!t)return;const e=K(t),n=e[0],i=F(e[1]),s=F(e[2]);return t.a<255?`hsla(${n}, ${i}%, ${s}%, ${R(t.a)})`:`hsl(${n}, ${i}%, ${s}%)`}(this._rgb):void 0}mix(t,e){if(t){const n=this.rgb,i=t.rgb;let s;const o=e===s?.5:e,a=2*o-1,r=n.a-i.a,l=((a*r===-1?a:(a+r)/(1+a*r))+1)/2;s=1-l,n.r=255&l*n.r+s*i.r+.5,n.g=255&l*n.g+s*i.g+.5,n.b=255&l*n.b+s*i.b+.5,n.a=o*n.a+(1-o)*i.a,this.rgb=n}return this}interpolate(t,e){return t&&(this._rgb=function(t,e,n){const i=lt(R(t.r)),s=lt(R(t.g)),o=lt(R(t.b));return{r:$(rt(i+n*(lt(R(e.r))-i))),g:$(rt(s+n*(lt(R(e.g))-s))),b:$(rt(o+n*(lt(R(e.b))-o))),a:t.a+n*(e.a-t.a)}}(this._rgb,t._rgb,e)),this}clone(){return new gt(this.rgb)}alpha(t){return this._rgb.a=$(t),this}clearer(t){return this._rgb.a*=1-t,this}greyscale(){const t=this._rgb,e=O(.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(){const t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return ct(this._rgb,2,t),this}darken(t){return ct(this._rgb,2,-t),this}saturate(t){return ct(this._rgb,1,t),this}desaturate(t){return ct(this._rgb,1,-t),this}rotate(t){return function(t,e){var n=K(t);n[0]=tt(n[0]+e),n=J(n),t.r=n[0],t.g=n[1],t.b=n[2]}(this._rgb,t),this}}
|
|
9
9
|
/*!
|
|
10
10
|
* Chart.js v4.5.1
|
|
11
11
|
* https://www.chartjs.org
|
|
12
12
|
* (c) 2025 Chart.js Contributors
|
|
13
13
|
* Released under the MIT License
|
|
14
|
-
*/function ct(){}const dt=(()=>{let t=0;return()=>t++})();function ht(t){return null==t}function ut(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 gt(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)}function pt(t){return("number"==typeof t||t instanceof Number)&&isFinite(+t)}function mt(t,e){return pt(t)?t:e}function ft(t,e){return void 0===t?e:t}const bt=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100*e:+t;function yt(t,e,n){if(t&&"function"==typeof t.call)return t.apply(n,e)}function xt(t,e,n,i){let s,o,a;if(ut(t))if(o=t.length,i)for(s=o-1;s>=0;s--)e.call(n,t[s],s);else for(s=0;s<o;s++)e.call(n,t[s],s);else if(gt(t))for(a=Object.keys(t),o=a.length,s=0;s<o;s++)e.call(n,t[a[s]],a[s])}function vt(t,e){let n,i,s,o;if(!t||!e||t.length!==e.length)return!1;for(n=0,i=t.length;n<i;++n)if(s=t[n],o=e[n],s.datasetIndex!==o.datasetIndex||s.index!==o.index)return!1;return!0}function wt(t){if(ut(t))return t.map(wt);if(gt(t)){const e=Object.create(null),n=Object.keys(t),i=n.length;let s=0;for(;s<i;++s)e[n[s]]=wt(t[n[s]]);return e}return t}function kt(t){return-1===["__proto__","prototype","constructor"].indexOf(t)}function St(t,e,n,i){if(!kt(t))return;const s=e[t],o=n[t];gt(s)&>(o)?Mt(s,o,i):e[t]=wt(o)}function Mt(t,e,n){const i=ut(e)?e:[e],s=i.length;if(!gt(t))return t;const o=(n=n||{}).merger||St;let a;for(let e=0;e<s;++e){if(a=i[e],!gt(a))continue;const s=Object.keys(a);for(let e=0,i=s.length;e<i;++e)o(s[e],t,a,n)}return t}function Ct(t,e){return Mt(t,e,{merger:_t})}function _t(t,e,n){if(!kt(t))return;const i=e[t],s=n[t];gt(i)&>(s)?Ct(i,s):Object.prototype.hasOwnProperty.call(e,t)||(e[t]=wt(s))}const Tt={"":t=>t,x:t=>t.x,y:t=>t.y};function Dt(t,e){const n=Tt[e]||(Tt[e]=function(t){const e=function(t){const e=t.split("."),n=[];let i="";for(const t of e)i+=t,i.endsWith("\\")?i=i.slice(0,-1)+".":(n.push(i),i="");return n}(t);return t=>{for(const n of e){if(""===n)break;t=t&&t[n]}return t}}(e));return n(t)}function Pt(t){return t.charAt(0).toUpperCase()+t.slice(1)}const Et=t=>void 0!==t,Lt=t=>"function"==typeof t,At=(t,e)=>{if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;return!0};const It=Math.PI,zt=2*It,Ot=zt+It,Wt=Number.POSITIVE_INFINITY,Nt=It/180,Rt=It/2,$t=It/4,Ft=2*It/3,Bt=Math.log10,qt=Math.sign;function Ht(t,e,n){return Math.abs(t-e)<n}function Vt(t){const e=Math.round(t);t=Ht(t,e,t/1e3)?e:t;const n=Math.pow(10,Math.floor(Bt(t))),i=t/n;return(i<=1?1:i<=2?2:i<=5?5:10)*n}function Yt(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 jt(t,e,n){let i,s,o;for(i=0,s=t.length;i<s;i++)o=t[i][n],isNaN(o)||(e.min=Math.min(e.min,o),e.max=Math.max(e.max,o))}function Ut(t){return t*(It/180)}function Xt(t){return t*(180/It)}function Qt(t){if(!pt(t))return;let e=1,n=0;for(;Math.round(t*e)/e!==t;)e*=10,n++;return n}function Gt(t,e){const n=e.x-t.x,i=e.y-t.y,s=Math.sqrt(n*n+i*i);let o=Math.atan2(i,n);return o<-.5*It&&(o+=zt),{angle:o,distance:s}}function Kt(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Zt(t,e){return(t-e+Ot)%zt-It}function Jt(t){return(t%zt+zt)%zt}function te(t,e,n,i){const s=Jt(t),o=Jt(e),a=Jt(n),r=Jt(o-s),l=Jt(a-s),c=Jt(s-o),d=Jt(s-a);return s===o||s===a||i&&o===a||r>l&&c<d}function ee(t,e,n){return Math.max(e,Math.min(n,t))}function ne(t,e,n,i=1e-6){return t>=Math.min(e,n)-i&&t<=Math.max(e,n)+i}function ie(t,e,n){n=n||(n=>t[n]<e);let i,s=t.length-1,o=0;for(;s-o>1;)i=o+s>>1,n(i)?o=i:s=i;return{lo:o,hi:s}}const se=(t,e,n,i)=>ie(t,n,i?i=>{const s=t[i][e];return s<n||s===n&&t[i+1][e]===n}:i=>t[i][e]<n),oe=(t,e,n)=>ie(t,n,(i=>t[i][e]>=n));const ae=["push","pop","shift","splice","unshift"];function re(t,e){const n=t._chartjs;if(!n)return;const i=n.listeners,s=i.indexOf(e);-1!==s&&i.splice(s,1),i.length>0||(ae.forEach((e=>{delete t[e]})),delete t._chartjs)}function le(t){const e=new Set(t);return e.size===t.length?t:Array.from(e)}const ce="undefined"==typeof window?function(t){return t()}:window.requestAnimationFrame;function de(t,e){let n=[],i=!1;return function(...s){n=s,i||(i=!0,ce.call(window,(()=>{i=!1,t.apply(e,n)})))}}const he=t=>"start"===t?"left":"end"===t?"right":"center",ue=(t,e,n)=>"start"===t?e:"end"===t?n:(e+n)/2;function ge(t,e,n){const i=e.length;let s=0,o=i;if(t._sorted){const{iScale:a,vScale:r,_parsed:l}=t,c=t.dataset&&t.dataset.options?t.dataset.options.spanGaps:null,d=a.axis,{min:h,max:u,minDefined:g,maxDefined:p}=a.getUserBounds();if(g){if(s=Math.min(se(l,d,h).lo,n?i:se(e,d,a.getPixelForValue(h)).lo),c){const t=l.slice(0,s+1).reverse().findIndex((t=>!ht(t[r.axis])));s-=Math.max(0,t)}s=ee(s,0,i-1)}if(p){let t=Math.max(se(l,a.axis,u,!0).hi+1,n?0:se(e,d,a.getPixelForValue(u),!0).hi+1);if(c){const e=l.slice(t-1).findIndex((t=>!ht(t[r.axis])));t+=Math.max(0,e)}o=ee(t,s,i)-s}else o=i-s}return{start:s,count:o}}function pe(t){const{xScale:e,yScale:n,_scaleRanges:i}=t,s={xmin:e.min,xmax:e.max,ymin:n.min,ymax:n.max};if(!i)return t._scaleRanges=s,!0;const o=i.xmin!==e.min||i.xmax!==e.max||i.ymin!==n.min||i.ymax!==n.max;return Object.assign(i,s),o}const me=t=>0===t||1===t,fe=(t,e,n)=>-Math.pow(2,10*(t-=1))*Math.sin((t-e)*zt/n),be=(t,e,n)=>Math.pow(2,-10*t)*Math.sin((t-e)*zt/n)+1,ye={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>-t*(t-2),easeInOutQuad:t=>(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1),easeInCubic:t=>t*t*t,easeOutCubic:t=>(t-=1)*t*t+1,easeInOutCubic:t=>(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2),easeInQuart:t=>t*t*t*t,easeOutQuart:t=>-((t-=1)*t*t*t-1),easeInOutQuart:t=>(t/=.5)<1?.5*t*t*t*t:-.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/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2),easeInSine:t=>1-Math.cos(t*Rt),easeOutSine:t=>Math.sin(t*Rt),easeInOutSine:t=>-.5*(Math.cos(It*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=>me(t)?t:t<.5?.5*Math.pow(2,10*(2*t-1)):.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/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1),easeInElastic:t=>me(t)?t:fe(t,.075,.3),easeOutElastic:t=>me(t)?t:be(t,.075,.3),easeInOutElastic(t){const e=.1125;return me(t)?t:t<.5?.5*fe(2*t,e,.45):.5+.5*be(2*t-1,e,.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/=.5)<1?t*t*((1+(e*=1.525))*t-e)*.5:.5*((t-=2)*t*((1+(e*=1.525))*t+e)+2)},easeInBounce:t=>1-ye.easeOutBounce(1-t),easeOutBounce(t){const e=7.5625,n=2.75;return t<1/n?e*t*t:t<2/n?e*(t-=1.5/n)*t+.75:t<2.5/n?e*(t-=2.25/n)*t+.9375:e*(t-=2.625/n)*t+.984375},easeInOutBounce:t=>t<.5?.5*ye.easeInBounce(2*t):.5*ye.easeOutBounce(2*t-1)+.5};function xe(t){if(t&&"object"==typeof t){const e=t.toString();return"[object CanvasPattern]"===e||"[object CanvasGradient]"===e}return!1}function ve(t){return xe(t)?t:new lt(t)}function we(t){return xe(t)?t:new lt(t).saturate(.5).darken(.1).hexString()}const ke=["x","y","borderWidth","radius","tension"],Se=["color","borderColor","backgroundColor"];const Me=new Map;function Ce(t,e,n){return function(t,e){e=e||{};const n=t+JSON.stringify(e);let i=Me.get(n);return i||(i=new Intl.NumberFormat(t,e),Me.set(n,i)),i}(e,n).format(t)}const _e={values:t=>ut(t)?t:""+t,numeric(t,e,n){if(0===t)return"0";const i=this.chart.options.locale;let s,o=t;if(n.length>1){const e=Math.max(Math.abs(n[0].value),Math.abs(n[n.length-1].value));(e<1e-4||e>1e15)&&(s="scientific"),o=function(t,e){let n=e.length>3?e[2].value-e[1].value:e[1].value-e[0].value;Math.abs(n)>=1&&t!==Math.floor(t)&&(n=t-Math.floor(t));return n}(t,n)}const a=Bt(Math.abs(o)),r=isNaN(a)?1:Math.max(Math.min(-1*Math.floor(a),20),0),l={notation:s,minimumFractionDigits:r,maximumFractionDigits:r};return Object.assign(l,this.options.ticks.format),Ce(t,i,l)},logarithmic(t,e,n){if(0===t)return"0";const i=n[e].significand||t/Math.pow(10,Math.floor(Bt(t)));return[1,2,3,5,10,15].includes(i)||e>.8*n.length?_e.numeric.call(this,t,e,n):""}};var Te={formatters:_e};const De=Object.create(null),Pe=Object.create(null);function Ee(t,e){if(!e)return t;const n=e.split(".");for(let e=0,i=n.length;e<i;++e){const i=n[e];t=t[i]||(t[i]=Object.create(null))}return t}function Le(t,e,n){return"string"==typeof e?Mt(Ee(t,e),n):Mt(Ee(t,""),e)}class Ae{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)=>we(e.backgroundColor),this.hoverBorderColor=(t,e)=>we(e.borderColor),this.hoverColor=(t,e)=>we(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 Le(this,t,e)}get(t){return Ee(this,t)}describe(t,e){return Le(Pe,t,e)}override(t,e){return Le(De,t,e)}route(t,e,n,i){const s=Ee(this,t),o=Ee(this,n),a="_"+e;Object.defineProperties(s,{[a]:{value:s[e],writable:!0},[e]:{enumerable:!0,get(){const t=this[a],e=o[i];return gt(t)?Object.assign({},e,t):ft(t,e)},set(t){this[a]=t}}})}apply(t){t.forEach((t=>t(this)))}}var Ie=new Ae({_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:Se},numbers:{type:"number",properties:ke}}),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:Te.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 ze(t,e,n,i,s){let o=e[s];return o||(o=e[s]=t.measureText(s).width,n.push(s)),o>i&&(i=o),i}function Oe(t,e,n,i){let s=(i=i||{}).data=i.data||{},o=i.garbageCollect=i.garbageCollect||[];i.font!==e&&(s=i.data={},o=i.garbageCollect=[],i.font=e),t.save(),t.font=e;let a=0;const r=n.length;let l,c,d,h,u;for(l=0;l<r;l++)if(h=n[l],null==h||ut(h)){if(ut(h))for(c=0,d=h.length;c<d;c++)u=h[c],null==u||ut(u)||(a=ze(t,s,o,a,u))}else a=ze(t,s,o,a,h);t.restore();const g=o.length/2;if(g>n.length){for(l=0;l<g;l++)delete s[o[l]];o.splice(0,g)}return a}function We(t,e,n){const i=t.currentDevicePixelRatio,s=0!==n?Math.max(n/2,.5):0;return Math.round((e-s)*i)/i+s}function Ne(t,e){(e||t)&&((e=e||t.getContext("2d")).save(),e.resetTransform(),e.clearRect(0,0,t.width,t.height),e.restore())}function Re(t,e,n,i){$e(t,e,n,i,null)}function $e(t,e,n,i,s){let o,a,r,l,c,d,h,u;const g=e.pointStyle,p=e.rotation,m=e.radius;let f=(p||0)*Nt;if(g&&"object"==typeof g&&(o=g.toString(),"[object HTMLImageElement]"===o||"[object HTMLCanvasElement]"===o))return t.save(),t.translate(n,i),t.rotate(f),t.drawImage(g,-g.width/2,-g.height/2,g.width,g.height),void t.restore();if(!(isNaN(m)||m<=0)){switch(t.beginPath(),g){default:s?t.ellipse(n,i,s/2,m,0,0,zt):t.arc(n,i,m,0,zt),t.closePath();break;case"triangle":d=s?s/2:m,t.moveTo(n+Math.sin(f)*d,i-Math.cos(f)*m),f+=Ft,t.lineTo(n+Math.sin(f)*d,i-Math.cos(f)*m),f+=Ft,t.lineTo(n+Math.sin(f)*d,i-Math.cos(f)*m),t.closePath();break;case"rectRounded":c=.516*m,l=m-c,a=Math.cos(f+$t)*l,h=Math.cos(f+$t)*(s?s/2-c:l),r=Math.sin(f+$t)*l,u=Math.sin(f+$t)*(s?s/2-c:l),t.arc(n-h,i-r,c,f-It,f-Rt),t.arc(n+u,i-a,c,f-Rt,f),t.arc(n+h,i+r,c,f,f+Rt),t.arc(n-u,i+a,c,f+Rt,f+It),t.closePath();break;case"rect":if(!p){l=Math.SQRT1_2*m,d=s?s/2:l,t.rect(n-d,i-l,2*d,2*l);break}f+=$t;case"rectRot":h=Math.cos(f)*(s?s/2:m),a=Math.cos(f)*m,r=Math.sin(f)*m,u=Math.sin(f)*(s?s/2:m),t.moveTo(n-h,i-r),t.lineTo(n+u,i-a),t.lineTo(n+h,i+r),t.lineTo(n-u,i+a),t.closePath();break;case"crossRot":f+=$t;case"cross":h=Math.cos(f)*(s?s/2:m),a=Math.cos(f)*m,r=Math.sin(f)*m,u=Math.sin(f)*(s?s/2:m),t.moveTo(n-h,i-r),t.lineTo(n+h,i+r),t.moveTo(n+u,i-a),t.lineTo(n-u,i+a);break;case"star":h=Math.cos(f)*(s?s/2:m),a=Math.cos(f)*m,r=Math.sin(f)*m,u=Math.sin(f)*(s?s/2:m),t.moveTo(n-h,i-r),t.lineTo(n+h,i+r),t.moveTo(n+u,i-a),t.lineTo(n-u,i+a),f+=$t,h=Math.cos(f)*(s?s/2:m),a=Math.cos(f)*m,r=Math.sin(f)*m,u=Math.sin(f)*(s?s/2:m),t.moveTo(n-h,i-r),t.lineTo(n+h,i+r),t.moveTo(n+u,i-a),t.lineTo(n-u,i+a);break;case"line":a=s?s/2:Math.cos(f)*m,r=Math.sin(f)*m,t.moveTo(n-a,i-r),t.lineTo(n+a,i+r);break;case"dash":t.moveTo(n,i),t.lineTo(n+Math.cos(f)*(s?s/2:m),i+Math.sin(f)*m);break;case!1:t.closePath()}t.fill(),e.borderWidth>0&&t.stroke()}}function Fe(t,e,n){return n=n||.5,!e||t&&t.x>e.left-n&&t.x<e.right+n&&t.y>e.top-n&&t.y<e.bottom+n}function Be(t,e){t.save(),t.beginPath(),t.rect(e.left,e.top,e.right-e.left,e.bottom-e.top),t.clip()}function qe(t){t.restore()}function He(t,e,n,i,s){if(!e)return t.lineTo(n.x,n.y);if("middle"===s){const i=(e.x+n.x)/2;t.lineTo(i,e.y),t.lineTo(i,n.y)}else"after"===s!=!!i?t.lineTo(e.x,n.y):t.lineTo(n.x,e.y);t.lineTo(n.x,n.y)}function Ve(t,e,n,i){if(!e)return t.lineTo(n.x,n.y);t.bezierCurveTo(i?e.cp1x:e.cp2x,i?e.cp1y:e.cp2y,i?n.cp2x:n.cp1x,i?n.cp2y:n.cp1y,n.x,n.y)}function Ye(t,e,n,i,s){if(s.strikethrough||s.underline){const o=t.measureText(i),a=e-o.actualBoundingBoxLeft,r=e+o.actualBoundingBoxRight,l=n-o.actualBoundingBoxAscent,c=n+o.actualBoundingBoxDescent,d=s.strikethrough?(l+c)/2:c;t.strokeStyle=t.fillStyle,t.beginPath(),t.lineWidth=s.decorationWidth||2,t.moveTo(a,d),t.lineTo(r,d),t.stroke()}}function je(t,e){const n=t.fillStyle;t.fillStyle=e.color,t.fillRect(e.left,e.top,e.width,e.height),t.fillStyle=n}function Ue(t,e,n,i,s,o={}){const a=ut(e)?e:[e],r=o.strokeWidth>0&&""!==o.strokeColor;let l,c;for(t.save(),t.font=s.string,function(t,e){e.translation&&t.translate(e.translation[0],e.translation[1]),ht(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,o),l=0;l<a.length;++l)c=a[l],o.backdrop&&je(t,o.backdrop),r&&(o.strokeColor&&(t.strokeStyle=o.strokeColor),ht(o.strokeWidth)||(t.lineWidth=o.strokeWidth),t.strokeText(c,n,i,o.maxWidth)),t.fillText(c,n,i,o.maxWidth),Ye(t,n,i,c,o),i+=Number(s.lineHeight);t.restore()}function Xe(t,e){const{x:n,y:i,w:s,h:o,radius:a}=e;t.arc(n+a.topLeft,i+a.topLeft,a.topLeft,1.5*It,It,!0),t.lineTo(n,i+o-a.bottomLeft),t.arc(n+a.bottomLeft,i+o-a.bottomLeft,a.bottomLeft,It,Rt,!0),t.lineTo(n+s-a.bottomRight,i+o),t.arc(n+s-a.bottomRight,i+o-a.bottomRight,a.bottomRight,Rt,0,!0),t.lineTo(n+s,i+a.topRight),t.arc(n+s-a.topRight,i+a.topRight,a.topRight,0,-Rt,!0),t.lineTo(n+a.topLeft,i)}const Qe=/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/,Ge=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;function Ke(t,e){const n=(""+t).match(Qe);if(!n||"normal"===n[1])return 1.2*e;switch(t=+n[2],n[3]){case"px":return t;case"%":t/=100}return e*t}function Ze(t,e){const n={},i=gt(e),s=i?Object.keys(e):e,o=gt(t)?i?n=>ft(t[n],t[e[n]]):e=>t[e]:()=>t;for(const t of s)n[t]=+o(t)||0;return n}function Je(t){return Ze(t,{top:"y",right:"x",bottom:"y",left:"x"})}function tn(t){return Ze(t,["topLeft","topRight","bottomLeft","bottomRight"])}function en(t){const e=Je(t);return e.width=e.left+e.right,e.height=e.top+e.bottom,e}function nn(t,e){t=t||{},e=e||Ie.font;let n=ft(t.size,e.size);"string"==typeof n&&(n=parseInt(n,10));let i=ft(t.style,e.style);i&&!(""+i).match(Ge)&&(console.warn('Invalid font style specified: "'+i+'"'),i=void 0);const s={family:ft(t.family,e.family),lineHeight:Ke(ft(t.lineHeight,e.lineHeight),n),size:n,style:i,weight:ft(t.weight,e.weight),string:""};return s.string=function(t){return!t||ht(t.size)||ht(t.family)?null:(t.style?t.style+" ":"")+(t.weight?t.weight+" ":"")+t.size+"px "+t.family}(s),s}function sn(t,e,n,i){let s,o,a,r=!0;for(s=0,o=t.length;s<o;++s)if(a=t[s],void 0!==a&&(void 0!==e&&"function"==typeof a&&(a=a(e),r=!1),void 0!==n&&ut(a)&&(a=a[n%a.length],r=!1),void 0!==a))return i&&!r&&(i.cacheable=!1),a}function on(t,e){return Object.assign(Object.create(t),e)}function an(t,e=[""],n,i,s=()=>t[0]){const o=n||t;void 0===i&&(i=bn("_fallback",t));const a={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:t,_rootScopes:o,_fallback:i,_getTarget:s,override:n=>an([n,...t],e,o,i)};return new Proxy(a,{deleteProperty:(e,n)=>(delete e[n],delete e._keys,delete t[0][n],!0),get:(n,i)=>hn(n,i,(()=>function(t,e,n,i){let s;for(const o of e)if(s=bn(cn(o,t),n),void 0!==s)return dn(t,s)?mn(n,i,t,s):s}(i,e,t,n))),getOwnPropertyDescriptor:(t,e)=>Reflect.getOwnPropertyDescriptor(t._scopes[0],e),getPrototypeOf:()=>Reflect.getPrototypeOf(t[0]),has:(t,e)=>yn(t).includes(e),ownKeys:t=>yn(t),set(t,e,n){const i=t._storage||(t._storage=s());return t[e]=i[e]=n,delete t._keys,!0}})}function rn(t,e,n,i){const s={_cacheable:!1,_proxy:t,_context:e,_subProxy:n,_stack:new Set,_descriptors:ln(t,i),setContext:e=>rn(t,e,n,i),override:s=>rn(t.override(s),e,n,i)};return new Proxy(s,{deleteProperty:(e,n)=>(delete e[n],delete t[n],!0),get:(t,e,n)=>hn(t,e,(()=>function(t,e,n){const{_proxy:i,_context:s,_subProxy:o,_descriptors:a}=t;let r=i[e];Lt(r)&&a.isScriptable(e)&&(r=function(t,e,n,i){const{_proxy:s,_context:o,_subProxy:a,_stack:r}=n;if(r.has(t))throw new Error("Recursion detected: "+Array.from(r).join("->")+"->"+t);r.add(t);let l=e(o,a||i);r.delete(t),dn(t,l)&&(l=mn(s._scopes,s,t,l));return l}(e,r,t,n));ut(r)&&r.length&&(r=function(t,e,n,i){const{_proxy:s,_context:o,_subProxy:a,_descriptors:r}=n;if(void 0!==o.index&&i(t))return e[o.index%e.length];if(gt(e[0])){const n=e,i=s._scopes.filter((t=>t!==n));e=[];for(const l of n){const n=mn(i,s,t,l);e.push(rn(n,o,a&&a[t],r))}}return e}(e,r,t,a.isIndexable));dn(e,r)&&(r=rn(r,s,o&&o[e],a));return r}(t,e,n))),getOwnPropertyDescriptor:(e,n)=>e._descriptors.allKeys?Reflect.has(t,n)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(t,n),getPrototypeOf:()=>Reflect.getPrototypeOf(t),has:(e,n)=>Reflect.has(t,n),ownKeys:()=>Reflect.ownKeys(t),set:(e,n,i)=>(t[n]=i,delete e[n],!0)})}function ln(t,e={scriptable:!0,indexable:!0}){const{_scriptable:n=e.scriptable,_indexable:i=e.indexable,_allKeys:s=e.allKeys}=t;return{allKeys:s,scriptable:n,indexable:i,isScriptable:Lt(n)?n:()=>n,isIndexable:Lt(i)?i:()=>i}}const cn=(t,e)=>t?t+Pt(e):e,dn=(t,e)=>gt(e)&&"adapters"!==t&&(null===Object.getPrototypeOf(e)||e.constructor===Object);function hn(t,e,n){if(Object.prototype.hasOwnProperty.call(t,e)||"constructor"===e)return t[e];const i=n();return t[e]=i,i}function un(t,e,n){return Lt(t)?t(e,n):t}const gn=(t,e)=>!0===t?e:"string"==typeof t?Dt(e,t):void 0;function pn(t,e,n,i,s){for(const o of e){const e=gn(n,o);if(e){t.add(e);const o=un(e._fallback,n,s);if(void 0!==o&&o!==n&&o!==i)return o}else if(!1===e&&void 0!==i&&n!==i)return null}return!1}function mn(t,e,n,i){const s=e._rootScopes,o=un(e._fallback,n,i),a=[...t,...s],r=new Set;r.add(i);let l=fn(r,a,n,o||n,i);return null!==l&&((void 0===o||o===n||(l=fn(r,a,o,l,i),null!==l))&&an(Array.from(r),[""],s,o,(()=>function(t,e,n){const i=t._getTarget();e in i||(i[e]={});const s=i[e];if(ut(s)&>(n))return n;return s||{}}(e,n,i))))}function fn(t,e,n,i,s){for(;n;)n=pn(t,e,n,i,s);return n}function bn(t,e){for(const n of e){if(!n)continue;const e=n[t];if(void 0!==e)return e}}function yn(t){let e=t._keys;return e||(e=t._keys=function(t){const e=new Set;for(const n of t)for(const t of Object.keys(n).filter((t=>!t.startsWith("_"))))e.add(t);return Array.from(e)}(t._scopes)),e}function xn(t,e,n,i){const{iScale:s}=t,{key:o="r"}=this._parsing,a=new Array(i);let r,l,c,d;for(r=0,l=i;r<l;++r)c=r+n,d=e[c],a[r]={r:s.parse(Dt(d,o),c)};return a}const vn=Number.EPSILON||1e-14,wn=(t,e)=>e<t.length&&!t[e].skip&&t[e],kn=t=>"x"===t?"y":"x";function Sn(t,e,n,i){const s=t.skip?e:t,o=e,a=n.skip?e:n,r=Kt(o,s),l=Kt(a,o);let c=r/(r+l),d=l/(r+l);c=isNaN(c)?0:c,d=isNaN(d)?0:d;const h=i*c,u=i*d;return{previous:{x:o.x-h*(a.x-s.x),y:o.y-h*(a.y-s.y)},next:{x:o.x+u*(a.x-s.x),y:o.y+u*(a.y-s.y)}}}function Mn(t,e="x"){const n=kn(e),i=t.length,s=Array(i).fill(0),o=Array(i);let a,r,l,c=wn(t,0);for(a=0;a<i;++a)if(r=l,l=c,c=wn(t,a+1),l){if(c){const t=c[e]-l[e];s[a]=0!==t?(c[n]-l[n])/t:0}o[a]=r?c?qt(s[a-1])!==qt(s[a])?0:(s[a-1]+s[a])/2:s[a-1]:s[a]}!function(t,e,n){const i=t.length;let s,o,a,r,l,c=wn(t,0);for(let d=0;d<i-1;++d)l=c,c=wn(t,d+1),l&&c&&(Ht(e[d],0,vn)?n[d]=n[d+1]=0:(s=n[d]/e[d],o=n[d+1]/e[d],r=Math.pow(s,2)+Math.pow(o,2),r<=9||(a=3/Math.sqrt(r),n[d]=s*a*e[d],n[d+1]=o*a*e[d])))}(t,s,o),function(t,e,n="x"){const i=kn(n),s=t.length;let o,a,r,l=wn(t,0);for(let c=0;c<s;++c){if(a=r,r=l,l=wn(t,c+1),!r)continue;const s=r[n],d=r[i];a&&(o=(s-a[n])/3,r[`cp1${n}`]=s-o,r[`cp1${i}`]=d-o*e[c]),l&&(o=(l[n]-s)/3,r[`cp2${n}`]=s+o,r[`cp2${i}`]=d+o*e[c])}}(t,o,e)}function Cn(t,e,n){return Math.max(Math.min(t,n),e)}function _n(t,e,n,i,s){let o,a,r,l;if(e.spanGaps&&(t=t.filter((t=>!t.skip))),"monotone"===e.cubicInterpolationMode)Mn(t,s);else{let n=i?t[t.length-1]:t[0];for(o=0,a=t.length;o<a;++o)r=t[o],l=Sn(n,r,t[Math.min(o+1,a-(i?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,n=r}e.capBezierPoints&&function(t,e){let n,i,s,o,a,r=Fe(t[0],e);for(n=0,i=t.length;n<i;++n)a=o,o=r,r=n<i-1&&Fe(t[n+1],e),o&&(s=t[n],a&&(s.cp1x=Cn(s.cp1x,e.left,e.right),s.cp1y=Cn(s.cp1y,e.top,e.bottom)),r&&(s.cp2x=Cn(s.cp2x,e.left,e.right),s.cp2y=Cn(s.cp2y,e.top,e.bottom)))}(t,n)}function Tn(){return"undefined"!=typeof window&&"undefined"!=typeof document}function Dn(t){let e=t.parentNode;return e&&"[object ShadowRoot]"===e.toString()&&(e=e.host),e}function Pn(t,e,n){let i;return"string"==typeof t?(i=parseInt(t,10),-1!==t.indexOf("%")&&(i=i/100*e.parentNode[n])):i=t,i}const En=t=>t.ownerDocument.defaultView.getComputedStyle(t,null);const Ln=["top","right","bottom","left"];function An(t,e,n){const i={};n=n?"-"+n:"";for(let s=0;s<4;s++){const o=Ln[s];i[o]=parseFloat(t[e+"-"+o+n])||0}return i.width=i.left+i.right,i.height=i.top+i.bottom,i}function In(t,e){if("native"in t)return t;const{canvas:n,currentDevicePixelRatio:i}=e,s=En(n),o="border-box"===s.boxSizing,a=An(s,"padding"),r=An(s,"border","width"),{x:l,y:c,box:d}=function(t,e){const n=t.touches,i=n&&n.length?n[0]:t,{offsetX:s,offsetY:o}=i;let a,r,l=!1;if(((t,e,n)=>(t>0||e>0)&&(!n||!n.shadowRoot))(s,o,t.target))a=s,r=o;else{const t=e.getBoundingClientRect();a=i.clientX-t.left,r=i.clientY-t.top,l=!0}return{x:a,y:r,box:l}}(t,n),h=a.left+(d&&r.left),u=a.top+(d&&r.top);let{width:g,height:p}=e;return o&&(g-=a.width+r.width,p-=a.height+r.height),{x:Math.round((l-h)/g*n.width/i),y:Math.round((c-u)/p*n.height/i)}}const zn=t=>Math.round(10*t)/10;function On(t,e,n,i){const s=En(t),o=An(s,"margin"),a=Pn(s.maxWidth,t,"clientWidth")||Wt,r=Pn(s.maxHeight,t,"clientHeight")||Wt,l=function(t,e,n){let i,s;if(void 0===e||void 0===n){const o=t&&Dn(t);if(o){const t=o.getBoundingClientRect(),a=En(o),r=An(a,"border","width"),l=An(a,"padding");e=t.width-l.width-r.width,n=t.height-l.height-r.height,i=Pn(a.maxWidth,o,"clientWidth"),s=Pn(a.maxHeight,o,"clientHeight")}else e=t.clientWidth,n=t.clientHeight}return{width:e,height:n,maxWidth:i||Wt,maxHeight:s||Wt}}(t,e,n);let{width:c,height:d}=l;if("content-box"===s.boxSizing){const t=An(s,"border","width"),e=An(s,"padding");c-=e.width+t.width,d-=e.height+t.height}c=Math.max(0,c-o.width),d=Math.max(0,i?c/i:d-o.height),c=zn(Math.min(c,a,l.maxWidth)),d=zn(Math.min(d,r,l.maxHeight)),c&&!d&&(d=zn(c/2));return(void 0!==e||void 0!==n)&&i&&l.height&&d>l.height&&(d=l.height,c=zn(Math.floor(d*i))),{width:c,height:d}}function Wn(t,e,n){const i=e||1,s=zn(t.height*i),o=zn(t.width*i);t.height=zn(t.height),t.width=zn(t.width);const a=t.canvas;return a.style&&(n||!a.style.height&&!a.style.width)&&(a.style.height=`${t.height}px`,a.style.width=`${t.width}px`),(t.currentDevicePixelRatio!==i||a.height!==s||a.width!==o)&&(t.currentDevicePixelRatio=i,a.height=s,a.width=o,t.ctx.setTransform(i,0,0,i,0,0),!0)}const Nn=function(){let t=!1;try{const e={get passive(){return t=!0,!1}};Tn()&&(window.addEventListener("test",null,e),window.removeEventListener("test",null,e))}catch(t){}return t}();function Rn(t,e){const n=function(t,e){return En(t).getPropertyValue(e)}(t,e),i=n&&n.match(/^(\d+)(\.\d+)?px$/);return i?+i[1]:void 0}function $n(t,e,n,i){return{x:t.x+n*(e.x-t.x),y:t.y+n*(e.y-t.y)}}function Fn(t,e,n,i){return{x:t.x+n*(e.x-t.x),y:"middle"===i?n<.5?t.y:e.y:"after"===i?n<1?t.y:e.y:n>0?e.y:t.y}}function Bn(t,e,n,i){const s={x:t.cp2x,y:t.cp2y},o={x:e.cp1x,y:e.cp1y},a=$n(t,s,n),r=$n(s,o,n),l=$n(o,e,n),c=$n(a,r,n),d=$n(r,l,n);return $n(c,d,n)}function qn(t,e,n){return t?function(t,e){return{x:n=>t+t+e-n,setWidth(t){e=t},textAlign:t=>"center"===t?t:"right"===t?"left":"right",xPlus:(t,e)=>t-e,leftForLtr:(t,e)=>t-e}}(e,n):{x:t=>t,setWidth(t){},textAlign:t=>t,xPlus:(t,e)=>t+e,leftForLtr:(t,e)=>t}}function Hn(t,e){let n,i;"ltr"!==e&&"rtl"!==e||(n=t.canvas.style,i=[n.getPropertyValue("direction"),n.getPropertyPriority("direction")],n.setProperty("direction",e,"important"),t.prevTextDirection=i)}function Vn(t,e){void 0!==e&&(delete t.prevTextDirection,t.canvas.style.setProperty("direction",e[0],e[1]))}function Yn(t){return"angle"===t?{between:te,compare:Zt,normalize:Jt}:{between:ne,compare:(t,e)=>t-e,normalize:t=>t}}function jn({start:t,end:e,count:n,loop:i,style:s}){return{start:t%n,end:e%n,loop:i&&(e-t+1)%n==0,style:s}}function Un(t,e,n){if(!n)return[t];const{property:i,start:s,end:o}=n,a=e.length,{compare:r,between:l,normalize:c}=Yn(i),{start:d,end:h,loop:u,style:g}=function(t,e,n){const{property:i,start:s,end:o}=n,{between:a,normalize:r}=Yn(i),l=e.length;let c,d,{start:h,end:u,loop:g}=t;if(g){for(h+=l,u+=l,c=0,d=l;c<d&&a(r(e[h%l][i]),s,o);++c)h--,u--;h%=l,u%=l}return u<h&&(u+=l),{start:h,end:u,loop:g,style:t.style}}(t,e,n),p=[];let m,f,b,y=!1,x=null;const v=()=>y||l(s,b,m)&&0!==r(s,b),w=()=>!y||0===r(o,m)||l(o,b,m);for(let t=d,n=d;t<=h;++t)f=e[t%a],f.skip||(m=c(f[i]),m!==b&&(y=l(m,s,o),null===x&&v()&&(x=0===r(m,s)?t:n),null!==x&&w()&&(p.push(jn({start:x,end:t,loop:u,count:a,style:g})),x=null),n=t,b=m));return null!==x&&p.push(jn({start:x,end:h,loop:u,count:a,style:g})),p}function Xn(t,e){const n=[],i=t.segments;for(let s=0;s<i.length;s++){const o=Un(i[s],t.points,e);o.length&&n.push(...o)}return n}function Qn(t,e,n,i){return i&&i.setContext&&n?function(t,e,n,i){const s=t._chart.getContext(),o=Gn(t.options),{_datasetIndex:a,options:{spanGaps:r}}=t,l=n.length,c=[];let d=o,h=e[0].start,u=h;function g(t,e,i,s){const o=r?-1:1;if(t!==e){for(t+=l;n[t%l].skip;)t-=o;for(;n[e%l].skip;)e+=o;t%l!==e%l&&(c.push({start:t%l,end:e%l,loop:i,style:s}),d=s,h=e%l)}}for(const t of e){h=r?h:t.start;let e,o=n[h%l];for(u=h+1;u<=t.end;u++){const r=n[u%l];e=Gn(i.setContext(on(s,{type:"segment",p0:o,p1:r,p0DataIndex:(u-1)%l,p1DataIndex:u%l,datasetIndex:a}))),Kn(e,d)&&g(h,u-1,t.loop,d),o=r,d=e}h<u-1&&g(h,u-1,t.loop,d)}return c}(t,e,n,i):e}function Gn(t){return{backgroundColor:t.backgroundColor,borderCapStyle:t.borderCapStyle,borderDash:t.borderDash,borderDashOffset:t.borderDashOffset,borderJoinStyle:t.borderJoinStyle,borderWidth:t.borderWidth,borderColor:t.borderColor}}function Kn(t,e){if(!e)return!1;const n=[],i=function(t,e){return xe(e)?(n.includes(e)||n.push(e),n.indexOf(e)):e};return JSON.stringify(t,i)!==JSON.stringify(e,i)}function Zn(t,e,n){return t.options.clip?t[n]:e[n]}function Jn(t,e){const n=e._clip;if(n.disabled)return!1;const i=function(t,e){const{xScale:n,yScale:i}=t;return n&&i?{left:Zn(n,e,"left"),right:Zn(n,e,"right"),top:Zn(i,e,"top"),bottom:Zn(i,e,"bottom")}:e}(e,t.chartArea);return{left:!1===n.left?0:i.left-(!0===n.left?0:n.left),right:!1===n.right?t.width:i.right+(!0===n.right?0:n.right),top:!1===n.top?0:i.top-(!0===n.top?0:n.top),bottom:!1===n.bottom?t.height:i.bottom+(!0===n.bottom?0:n.bottom)}}
|
|
14
|
+
*/function pt(){}const mt=(()=>{let t=0;return()=>t++})();function ft(t){return null==t}function bt(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 yt(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)}function xt(t){return("number"==typeof t||t instanceof Number)&&isFinite(+t)}function vt(t,e){return xt(t)?t:e}function wt(t,e){return void 0===t?e:t}const kt=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100*e:+t;function St(t,e,n){if(t&&"function"==typeof t.call)return t.apply(n,e)}function Mt(t,e,n,i){let s,o,a;if(bt(t))if(o=t.length,i)for(s=o-1;s>=0;s--)e.call(n,t[s],s);else for(s=0;s<o;s++)e.call(n,t[s],s);else if(yt(t))for(a=Object.keys(t),o=a.length,s=0;s<o;s++)e.call(n,t[a[s]],a[s])}function Ct(t,e){let n,i,s,o;if(!t||!e||t.length!==e.length)return!1;for(n=0,i=t.length;n<i;++n)if(s=t[n],o=e[n],s.datasetIndex!==o.datasetIndex||s.index!==o.index)return!1;return!0}function _t(t){if(bt(t))return t.map(_t);if(yt(t)){const e=Object.create(null),n=Object.keys(t),i=n.length;let s=0;for(;s<i;++s)e[n[s]]=_t(t[n[s]]);return e}return t}function Tt(t){return-1===["__proto__","prototype","constructor"].indexOf(t)}function Dt(t,e,n,i){if(!Tt(t))return;const s=e[t],o=n[t];yt(s)&&yt(o)?Pt(s,o,i):e[t]=_t(o)}function Pt(t,e,n){const i=bt(e)?e:[e],s=i.length;if(!yt(t))return t;const o=(n=n||{}).merger||Dt;let a;for(let e=0;e<s;++e){if(a=i[e],!yt(a))continue;const s=Object.keys(a);for(let e=0,i=s.length;e<i;++e)o(s[e],t,a,n)}return t}function Et(t,e){return Pt(t,e,{merger:Lt})}function Lt(t,e,n){if(!Tt(t))return;const i=e[t],s=n[t];yt(i)&&yt(s)?Et(i,s):Object.prototype.hasOwnProperty.call(e,t)||(e[t]=_t(s))}const At={"":t=>t,x:t=>t.x,y:t=>t.y};function It(t,e){const n=At[e]||(At[e]=function(t){const e=function(t){const e=t.split("."),n=[];let i="";for(const t of e)i+=t,i.endsWith("\\")?i=i.slice(0,-1)+".":(n.push(i),i="");return n}(t);return t=>{for(const n of e){if(""===n)break;t=t&&t[n]}return t}}(e));return n(t)}function zt(t){return t.charAt(0).toUpperCase()+t.slice(1)}const Ot=t=>void 0!==t,Wt=t=>"function"==typeof t,Nt=(t,e)=>{if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;return!0};const $t=Math.PI,Rt=2*$t,Ft=Rt+$t,Bt=Number.POSITIVE_INFINITY,qt=$t/180,Ht=$t/2,Vt=$t/4,jt=2*$t/3,Yt=Math.log10,Ut=Math.sign;function Xt(t,e,n){return Math.abs(t-e)<n}function Qt(t){const e=Math.round(t);t=Xt(t,e,t/1e3)?e:t;const n=Math.pow(10,Math.floor(Yt(t))),i=t/n;return(i<=1?1:i<=2?2:i<=5?5:10)*n}function Gt(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 Kt(t,e,n){let i,s,o;for(i=0,s=t.length;i<s;i++)o=t[i][n],isNaN(o)||(e.min=Math.min(e.min,o),e.max=Math.max(e.max,o))}function Zt(t){return t*($t/180)}function Jt(t){return t*(180/$t)}function te(t){if(!xt(t))return;let e=1,n=0;for(;Math.round(t*e)/e!==t;)e*=10,n++;return n}function ee(t,e){const n=e.x-t.x,i=e.y-t.y,s=Math.sqrt(n*n+i*i);let o=Math.atan2(i,n);return o<-.5*$t&&(o+=Rt),{angle:o,distance:s}}function ne(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function ie(t,e){return(t-e+Ft)%Rt-$t}function se(t){return(t%Rt+Rt)%Rt}function oe(t,e,n,i){const s=se(t),o=se(e),a=se(n),r=se(o-s),l=se(a-s),c=se(s-o),d=se(s-a);return s===o||s===a||i&&o===a||r>l&&c<d}function ae(t,e,n){return Math.max(e,Math.min(n,t))}function re(t,e,n,i=1e-6){return t>=Math.min(e,n)-i&&t<=Math.max(e,n)+i}function le(t,e,n){n=n||(n=>t[n]<e);let i,s=t.length-1,o=0;for(;s-o>1;)i=o+s>>1,n(i)?o=i:s=i;return{lo:o,hi:s}}const ce=(t,e,n,i)=>le(t,n,i?i=>{const s=t[i][e];return s<n||s===n&&t[i+1][e]===n}:i=>t[i][e]<n),de=(t,e,n)=>le(t,n,(i=>t[i][e]>=n));const he=["push","pop","shift","splice","unshift"];function ue(t,e){const n=t._chartjs;if(!n)return;const i=n.listeners,s=i.indexOf(e);-1!==s&&i.splice(s,1),i.length>0||(he.forEach((e=>{delete t[e]})),delete t._chartjs)}function ge(t){const e=new Set(t);return e.size===t.length?t:Array.from(e)}const pe="undefined"==typeof window?function(t){return t()}:window.requestAnimationFrame;function me(t,e){let n=[],i=!1;return function(...s){n=s,i||(i=!0,pe.call(window,(()=>{i=!1,t.apply(e,n)})))}}const fe=t=>"start"===t?"left":"end"===t?"right":"center",be=(t,e,n)=>"start"===t?e:"end"===t?n:(e+n)/2;function ye(t,e,n){const i=e.length;let s=0,o=i;if(t._sorted){const{iScale:a,vScale:r,_parsed:l}=t,c=t.dataset&&t.dataset.options?t.dataset.options.spanGaps:null,d=a.axis,{min:h,max:u,minDefined:g,maxDefined:p}=a.getUserBounds();if(g){if(s=Math.min(ce(l,d,h).lo,n?i:ce(e,d,a.getPixelForValue(h)).lo),c){const t=l.slice(0,s+1).reverse().findIndex((t=>!ft(t[r.axis])));s-=Math.max(0,t)}s=ae(s,0,i-1)}if(p){let t=Math.max(ce(l,a.axis,u,!0).hi+1,n?0:ce(e,d,a.getPixelForValue(u),!0).hi+1);if(c){const e=l.slice(t-1).findIndex((t=>!ft(t[r.axis])));t+=Math.max(0,e)}o=ae(t,s,i)-s}else o=i-s}return{start:s,count:o}}function xe(t){const{xScale:e,yScale:n,_scaleRanges:i}=t,s={xmin:e.min,xmax:e.max,ymin:n.min,ymax:n.max};if(!i)return t._scaleRanges=s,!0;const o=i.xmin!==e.min||i.xmax!==e.max||i.ymin!==n.min||i.ymax!==n.max;return Object.assign(i,s),o}const ve=t=>0===t||1===t,we=(t,e,n)=>-Math.pow(2,10*(t-=1))*Math.sin((t-e)*Rt/n),ke=(t,e,n)=>Math.pow(2,-10*t)*Math.sin((t-e)*Rt/n)+1,Se={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>-t*(t-2),easeInOutQuad:t=>(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1),easeInCubic:t=>t*t*t,easeOutCubic:t=>(t-=1)*t*t+1,easeInOutCubic:t=>(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2),easeInQuart:t=>t*t*t*t,easeOutQuart:t=>-((t-=1)*t*t*t-1),easeInOutQuart:t=>(t/=.5)<1?.5*t*t*t*t:-.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/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2),easeInSine:t=>1-Math.cos(t*Ht),easeOutSine:t=>Math.sin(t*Ht),easeInOutSine:t=>-.5*(Math.cos($t*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=>ve(t)?t:t<.5?.5*Math.pow(2,10*(2*t-1)):.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/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1),easeInElastic:t=>ve(t)?t:we(t,.075,.3),easeOutElastic:t=>ve(t)?t:ke(t,.075,.3),easeInOutElastic(t){const e=.1125;return ve(t)?t:t<.5?.5*we(2*t,e,.45):.5+.5*ke(2*t-1,e,.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/=.5)<1?t*t*((1+(e*=1.525))*t-e)*.5:.5*((t-=2)*t*((1+(e*=1.525))*t+e)+2)},easeInBounce:t=>1-Se.easeOutBounce(1-t),easeOutBounce(t){const e=7.5625,n=2.75;return t<1/n?e*t*t:t<2/n?e*(t-=1.5/n)*t+.75:t<2.5/n?e*(t-=2.25/n)*t+.9375:e*(t-=2.625/n)*t+.984375},easeInOutBounce:t=>t<.5?.5*Se.easeInBounce(2*t):.5*Se.easeOutBounce(2*t-1)+.5};function Me(t){if(t&&"object"==typeof t){const e=t.toString();return"[object CanvasPattern]"===e||"[object CanvasGradient]"===e}return!1}function Ce(t){return Me(t)?t:new gt(t)}function _e(t){return Me(t)?t:new gt(t).saturate(.5).darken(.1).hexString()}const Te=["x","y","borderWidth","radius","tension"],De=["color","borderColor","backgroundColor"];const Pe=new Map;function Ee(t,e,n){return function(t,e){e=e||{};const n=t+JSON.stringify(e);let i=Pe.get(n);return i||(i=new Intl.NumberFormat(t,e),Pe.set(n,i)),i}(e,n).format(t)}const Le={values:t=>bt(t)?t:""+t,numeric(t,e,n){if(0===t)return"0";const i=this.chart.options.locale;let s,o=t;if(n.length>1){const e=Math.max(Math.abs(n[0].value),Math.abs(n[n.length-1].value));(e<1e-4||e>1e15)&&(s="scientific"),o=function(t,e){let n=e.length>3?e[2].value-e[1].value:e[1].value-e[0].value;Math.abs(n)>=1&&t!==Math.floor(t)&&(n=t-Math.floor(t));return n}(t,n)}const a=Yt(Math.abs(o)),r=isNaN(a)?1:Math.max(Math.min(-1*Math.floor(a),20),0),l={notation:s,minimumFractionDigits:r,maximumFractionDigits:r};return Object.assign(l,this.options.ticks.format),Ee(t,i,l)},logarithmic(t,e,n){if(0===t)return"0";const i=n[e].significand||t/Math.pow(10,Math.floor(Yt(t)));return[1,2,3,5,10,15].includes(i)||e>.8*n.length?Le.numeric.call(this,t,e,n):""}};var Ae={formatters:Le};const Ie=Object.create(null),ze=Object.create(null);function Oe(t,e){if(!e)return t;const n=e.split(".");for(let e=0,i=n.length;e<i;++e){const i=n[e];t=t[i]||(t[i]=Object.create(null))}return t}function We(t,e,n){return"string"==typeof e?Pt(Oe(t,e),n):Pt(Oe(t,""),e)}class Ne{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)=>_e(e.backgroundColor),this.hoverBorderColor=(t,e)=>_e(e.borderColor),this.hoverColor=(t,e)=>_e(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 We(this,t,e)}get(t){return Oe(this,t)}describe(t,e){return We(ze,t,e)}override(t,e){return We(Ie,t,e)}route(t,e,n,i){const s=Oe(this,t),o=Oe(this,n),a="_"+e;Object.defineProperties(s,{[a]:{value:s[e],writable:!0},[e]:{enumerable:!0,get(){const t=this[a],e=o[i];return yt(t)?Object.assign({},e,t):wt(t,e)},set(t){this[a]=t}}})}apply(t){t.forEach((t=>t(this)))}}var $e=new Ne({_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:De},numbers:{type:"number",properties:Te}}),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 Re(t,e,n,i,s){let o=e[s];return o||(o=e[s]=t.measureText(s).width,n.push(s)),o>i&&(i=o),i}function Fe(t,e,n,i){let s=(i=i||{}).data=i.data||{},o=i.garbageCollect=i.garbageCollect||[];i.font!==e&&(s=i.data={},o=i.garbageCollect=[],i.font=e),t.save(),t.font=e;let a=0;const r=n.length;let l,c,d,h,u;for(l=0;l<r;l++)if(h=n[l],null==h||bt(h)){if(bt(h))for(c=0,d=h.length;c<d;c++)u=h[c],null==u||bt(u)||(a=Re(t,s,o,a,u))}else a=Re(t,s,o,a,h);t.restore();const g=o.length/2;if(g>n.length){for(l=0;l<g;l++)delete s[o[l]];o.splice(0,g)}return a}function Be(t,e,n){const i=t.currentDevicePixelRatio,s=0!==n?Math.max(n/2,.5):0;return Math.round((e-s)*i)/i+s}function qe(t,e){(e||t)&&((e=e||t.getContext("2d")).save(),e.resetTransform(),e.clearRect(0,0,t.width,t.height),e.restore())}function He(t,e,n,i){Ve(t,e,n,i,null)}function Ve(t,e,n,i,s){let o,a,r,l,c,d,h,u;const g=e.pointStyle,p=e.rotation,m=e.radius;let f=(p||0)*qt;if(g&&"object"==typeof g&&(o=g.toString(),"[object HTMLImageElement]"===o||"[object HTMLCanvasElement]"===o))return t.save(),t.translate(n,i),t.rotate(f),t.drawImage(g,-g.width/2,-g.height/2,g.width,g.height),void t.restore();if(!(isNaN(m)||m<=0)){switch(t.beginPath(),g){default:s?t.ellipse(n,i,s/2,m,0,0,Rt):t.arc(n,i,m,0,Rt),t.closePath();break;case"triangle":d=s?s/2:m,t.moveTo(n+Math.sin(f)*d,i-Math.cos(f)*m),f+=jt,t.lineTo(n+Math.sin(f)*d,i-Math.cos(f)*m),f+=jt,t.lineTo(n+Math.sin(f)*d,i-Math.cos(f)*m),t.closePath();break;case"rectRounded":c=.516*m,l=m-c,a=Math.cos(f+Vt)*l,h=Math.cos(f+Vt)*(s?s/2-c:l),r=Math.sin(f+Vt)*l,u=Math.sin(f+Vt)*(s?s/2-c:l),t.arc(n-h,i-r,c,f-$t,f-Ht),t.arc(n+u,i-a,c,f-Ht,f),t.arc(n+h,i+r,c,f,f+Ht),t.arc(n-u,i+a,c,f+Ht,f+$t),t.closePath();break;case"rect":if(!p){l=Math.SQRT1_2*m,d=s?s/2:l,t.rect(n-d,i-l,2*d,2*l);break}f+=Vt;case"rectRot":h=Math.cos(f)*(s?s/2:m),a=Math.cos(f)*m,r=Math.sin(f)*m,u=Math.sin(f)*(s?s/2:m),t.moveTo(n-h,i-r),t.lineTo(n+u,i-a),t.lineTo(n+h,i+r),t.lineTo(n-u,i+a),t.closePath();break;case"crossRot":f+=Vt;case"cross":h=Math.cos(f)*(s?s/2:m),a=Math.cos(f)*m,r=Math.sin(f)*m,u=Math.sin(f)*(s?s/2:m),t.moveTo(n-h,i-r),t.lineTo(n+h,i+r),t.moveTo(n+u,i-a),t.lineTo(n-u,i+a);break;case"star":h=Math.cos(f)*(s?s/2:m),a=Math.cos(f)*m,r=Math.sin(f)*m,u=Math.sin(f)*(s?s/2:m),t.moveTo(n-h,i-r),t.lineTo(n+h,i+r),t.moveTo(n+u,i-a),t.lineTo(n-u,i+a),f+=Vt,h=Math.cos(f)*(s?s/2:m),a=Math.cos(f)*m,r=Math.sin(f)*m,u=Math.sin(f)*(s?s/2:m),t.moveTo(n-h,i-r),t.lineTo(n+h,i+r),t.moveTo(n+u,i-a),t.lineTo(n-u,i+a);break;case"line":a=s?s/2:Math.cos(f)*m,r=Math.sin(f)*m,t.moveTo(n-a,i-r),t.lineTo(n+a,i+r);break;case"dash":t.moveTo(n,i),t.lineTo(n+Math.cos(f)*(s?s/2:m),i+Math.sin(f)*m);break;case!1:t.closePath()}t.fill(),e.borderWidth>0&&t.stroke()}}function je(t,e,n){return n=n||.5,!e||t&&t.x>e.left-n&&t.x<e.right+n&&t.y>e.top-n&&t.y<e.bottom+n}function Ye(t,e){t.save(),t.beginPath(),t.rect(e.left,e.top,e.right-e.left,e.bottom-e.top),t.clip()}function Ue(t){t.restore()}function Xe(t,e,n,i,s){if(!e)return t.lineTo(n.x,n.y);if("middle"===s){const i=(e.x+n.x)/2;t.lineTo(i,e.y),t.lineTo(i,n.y)}else"after"===s!=!!i?t.lineTo(e.x,n.y):t.lineTo(n.x,e.y);t.lineTo(n.x,n.y)}function Qe(t,e,n,i){if(!e)return t.lineTo(n.x,n.y);t.bezierCurveTo(i?e.cp1x:e.cp2x,i?e.cp1y:e.cp2y,i?n.cp2x:n.cp1x,i?n.cp2y:n.cp1y,n.x,n.y)}function Ge(t,e,n,i,s){if(s.strikethrough||s.underline){const o=t.measureText(i),a=e-o.actualBoundingBoxLeft,r=e+o.actualBoundingBoxRight,l=n-o.actualBoundingBoxAscent,c=n+o.actualBoundingBoxDescent,d=s.strikethrough?(l+c)/2:c;t.strokeStyle=t.fillStyle,t.beginPath(),t.lineWidth=s.decorationWidth||2,t.moveTo(a,d),t.lineTo(r,d),t.stroke()}}function Ke(t,e){const n=t.fillStyle;t.fillStyle=e.color,t.fillRect(e.left,e.top,e.width,e.height),t.fillStyle=n}function Ze(t,e,n,i,s,o={}){const a=bt(e)?e:[e],r=o.strokeWidth>0&&""!==o.strokeColor;let l,c;for(t.save(),t.font=s.string,function(t,e){e.translation&&t.translate(e.translation[0],e.translation[1]),ft(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,o),l=0;l<a.length;++l)c=a[l],o.backdrop&&Ke(t,o.backdrop),r&&(o.strokeColor&&(t.strokeStyle=o.strokeColor),ft(o.strokeWidth)||(t.lineWidth=o.strokeWidth),t.strokeText(c,n,i,o.maxWidth)),t.fillText(c,n,i,o.maxWidth),Ge(t,n,i,c,o),i+=Number(s.lineHeight);t.restore()}function Je(t,e){const{x:n,y:i,w:s,h:o,radius:a}=e;t.arc(n+a.topLeft,i+a.topLeft,a.topLeft,1.5*$t,$t,!0),t.lineTo(n,i+o-a.bottomLeft),t.arc(n+a.bottomLeft,i+o-a.bottomLeft,a.bottomLeft,$t,Ht,!0),t.lineTo(n+s-a.bottomRight,i+o),t.arc(n+s-a.bottomRight,i+o-a.bottomRight,a.bottomRight,Ht,0,!0),t.lineTo(n+s,i+a.topRight),t.arc(n+s-a.topRight,i+a.topRight,a.topRight,0,-Ht,!0),t.lineTo(n+a.topLeft,i)}const tn=/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/,en=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;function nn(t,e){const n=(""+t).match(tn);if(!n||"normal"===n[1])return 1.2*e;switch(t=+n[2],n[3]){case"px":return t;case"%":t/=100}return e*t}function sn(t,e){const n={},i=yt(e),s=i?Object.keys(e):e,o=yt(t)?i?n=>wt(t[n],t[e[n]]):e=>t[e]:()=>t;for(const t of s)n[t]=+o(t)||0;return n}function on(t){return sn(t,{top:"y",right:"x",bottom:"y",left:"x"})}function an(t){return sn(t,["topLeft","topRight","bottomLeft","bottomRight"])}function rn(t){const e=on(t);return e.width=e.left+e.right,e.height=e.top+e.bottom,e}function ln(t,e){t=t||{},e=e||$e.font;let n=wt(t.size,e.size);"string"==typeof n&&(n=parseInt(n,10));let i=wt(t.style,e.style);i&&!(""+i).match(en)&&(console.warn('Invalid font style specified: "'+i+'"'),i=void 0);const s={family:wt(t.family,e.family),lineHeight:nn(wt(t.lineHeight,e.lineHeight),n),size:n,style:i,weight:wt(t.weight,e.weight),string:""};return s.string=function(t){return!t||ft(t.size)||ft(t.family)?null:(t.style?t.style+" ":"")+(t.weight?t.weight+" ":"")+t.size+"px "+t.family}(s),s}function cn(t,e,n,i){let s,o,a,r=!0;for(s=0,o=t.length;s<o;++s)if(a=t[s],void 0!==a&&(void 0!==e&&"function"==typeof a&&(a=a(e),r=!1),void 0!==n&&bt(a)&&(a=a[n%a.length],r=!1),void 0!==a))return i&&!r&&(i.cacheable=!1),a}function dn(t,e){return Object.assign(Object.create(t),e)}function hn(t,e=[""],n,i,s=()=>t[0]){const o=n||t;void 0===i&&(i=kn("_fallback",t));const a={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:t,_rootScopes:o,_fallback:i,_getTarget:s,override:n=>hn([n,...t],e,o,i)};return new Proxy(a,{deleteProperty:(e,n)=>(delete e[n],delete e._keys,delete t[0][n],!0),get:(n,i)=>fn(n,i,(()=>function(t,e,n,i){let s;for(const o of e)if(s=kn(pn(o,t),n),void 0!==s)return mn(t,s)?vn(n,i,t,s):s}(i,e,t,n))),getOwnPropertyDescriptor:(t,e)=>Reflect.getOwnPropertyDescriptor(t._scopes[0],e),getPrototypeOf:()=>Reflect.getPrototypeOf(t[0]),has:(t,e)=>Sn(t).includes(e),ownKeys:t=>Sn(t),set(t,e,n){const i=t._storage||(t._storage=s());return t[e]=i[e]=n,delete t._keys,!0}})}function un(t,e,n,i){const s={_cacheable:!1,_proxy:t,_context:e,_subProxy:n,_stack:new Set,_descriptors:gn(t,i),setContext:e=>un(t,e,n,i),override:s=>un(t.override(s),e,n,i)};return new Proxy(s,{deleteProperty:(e,n)=>(delete e[n],delete t[n],!0),get:(t,e,n)=>fn(t,e,(()=>function(t,e,n){const{_proxy:i,_context:s,_subProxy:o,_descriptors:a}=t;let r=i[e];Wt(r)&&a.isScriptable(e)&&(r=function(t,e,n,i){const{_proxy:s,_context:o,_subProxy:a,_stack:r}=n;if(r.has(t))throw new Error("Recursion detected: "+Array.from(r).join("->")+"->"+t);r.add(t);let l=e(o,a||i);r.delete(t),mn(t,l)&&(l=vn(s._scopes,s,t,l));return l}(e,r,t,n));bt(r)&&r.length&&(r=function(t,e,n,i){const{_proxy:s,_context:o,_subProxy:a,_descriptors:r}=n;if(void 0!==o.index&&i(t))return e[o.index%e.length];if(yt(e[0])){const n=e,i=s._scopes.filter((t=>t!==n));e=[];for(const l of n){const n=vn(i,s,t,l);e.push(un(n,o,a&&a[t],r))}}return e}(e,r,t,a.isIndexable));mn(e,r)&&(r=un(r,s,o&&o[e],a));return r}(t,e,n))),getOwnPropertyDescriptor:(e,n)=>e._descriptors.allKeys?Reflect.has(t,n)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(t,n),getPrototypeOf:()=>Reflect.getPrototypeOf(t),has:(e,n)=>Reflect.has(t,n),ownKeys:()=>Reflect.ownKeys(t),set:(e,n,i)=>(t[n]=i,delete e[n],!0)})}function gn(t,e={scriptable:!0,indexable:!0}){const{_scriptable:n=e.scriptable,_indexable:i=e.indexable,_allKeys:s=e.allKeys}=t;return{allKeys:s,scriptable:n,indexable:i,isScriptable:Wt(n)?n:()=>n,isIndexable:Wt(i)?i:()=>i}}const pn=(t,e)=>t?t+zt(e):e,mn=(t,e)=>yt(e)&&"adapters"!==t&&(null===Object.getPrototypeOf(e)||e.constructor===Object);function fn(t,e,n){if(Object.prototype.hasOwnProperty.call(t,e)||"constructor"===e)return t[e];const i=n();return t[e]=i,i}function bn(t,e,n){return Wt(t)?t(e,n):t}const yn=(t,e)=>!0===t?e:"string"==typeof t?It(e,t):void 0;function xn(t,e,n,i,s){for(const o of e){const e=yn(n,o);if(e){t.add(e);const o=bn(e._fallback,n,s);if(void 0!==o&&o!==n&&o!==i)return o}else if(!1===e&&void 0!==i&&n!==i)return null}return!1}function vn(t,e,n,i){const s=e._rootScopes,o=bn(e._fallback,n,i),a=[...t,...s],r=new Set;r.add(i);let l=wn(r,a,n,o||n,i);return null!==l&&((void 0===o||o===n||(l=wn(r,a,o,l,i),null!==l))&&hn(Array.from(r),[""],s,o,(()=>function(t,e,n){const i=t._getTarget();e in i||(i[e]={});const s=i[e];if(bt(s)&&yt(n))return n;return s||{}}(e,n,i))))}function wn(t,e,n,i,s){for(;n;)n=xn(t,e,n,i,s);return n}function kn(t,e){for(const n of e){if(!n)continue;const e=n[t];if(void 0!==e)return e}}function Sn(t){let e=t._keys;return e||(e=t._keys=function(t){const e=new Set;for(const n of t)for(const t of Object.keys(n).filter((t=>!t.startsWith("_"))))e.add(t);return Array.from(e)}(t._scopes)),e}function Mn(t,e,n,i){const{iScale:s}=t,{key:o="r"}=this._parsing,a=new Array(i);let r,l,c,d;for(r=0,l=i;r<l;++r)c=r+n,d=e[c],a[r]={r:s.parse(It(d,o),c)};return a}const Cn=Number.EPSILON||1e-14,_n=(t,e)=>e<t.length&&!t[e].skip&&t[e],Tn=t=>"x"===t?"y":"x";function Dn(t,e,n,i){const s=t.skip?e:t,o=e,a=n.skip?e:n,r=ne(o,s),l=ne(a,o);let c=r/(r+l),d=l/(r+l);c=isNaN(c)?0:c,d=isNaN(d)?0:d;const h=i*c,u=i*d;return{previous:{x:o.x-h*(a.x-s.x),y:o.y-h*(a.y-s.y)},next:{x:o.x+u*(a.x-s.x),y:o.y+u*(a.y-s.y)}}}function Pn(t,e="x"){const n=Tn(e),i=t.length,s=Array(i).fill(0),o=Array(i);let a,r,l,c=_n(t,0);for(a=0;a<i;++a)if(r=l,l=c,c=_n(t,a+1),l){if(c){const t=c[e]-l[e];s[a]=0!==t?(c[n]-l[n])/t:0}o[a]=r?c?Ut(s[a-1])!==Ut(s[a])?0:(s[a-1]+s[a])/2:s[a-1]:s[a]}!function(t,e,n){const i=t.length;let s,o,a,r,l,c=_n(t,0);for(let d=0;d<i-1;++d)l=c,c=_n(t,d+1),l&&c&&(Xt(e[d],0,Cn)?n[d]=n[d+1]=0:(s=n[d]/e[d],o=n[d+1]/e[d],r=Math.pow(s,2)+Math.pow(o,2),r<=9||(a=3/Math.sqrt(r),n[d]=s*a*e[d],n[d+1]=o*a*e[d])))}(t,s,o),function(t,e,n="x"){const i=Tn(n),s=t.length;let o,a,r,l=_n(t,0);for(let c=0;c<s;++c){if(a=r,r=l,l=_n(t,c+1),!r)continue;const s=r[n],d=r[i];a&&(o=(s-a[n])/3,r[`cp1${n}`]=s-o,r[`cp1${i}`]=d-o*e[c]),l&&(o=(l[n]-s)/3,r[`cp2${n}`]=s+o,r[`cp2${i}`]=d+o*e[c])}}(t,o,e)}function En(t,e,n){return Math.max(Math.min(t,n),e)}function Ln(t,e,n,i,s){let o,a,r,l;if(e.spanGaps&&(t=t.filter((t=>!t.skip))),"monotone"===e.cubicInterpolationMode)Pn(t,s);else{let n=i?t[t.length-1]:t[0];for(o=0,a=t.length;o<a;++o)r=t[o],l=Dn(n,r,t[Math.min(o+1,a-(i?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,n=r}e.capBezierPoints&&function(t,e){let n,i,s,o,a,r=je(t[0],e);for(n=0,i=t.length;n<i;++n)a=o,o=r,r=n<i-1&&je(t[n+1],e),o&&(s=t[n],a&&(s.cp1x=En(s.cp1x,e.left,e.right),s.cp1y=En(s.cp1y,e.top,e.bottom)),r&&(s.cp2x=En(s.cp2x,e.left,e.right),s.cp2y=En(s.cp2y,e.top,e.bottom)))}(t,n)}function An(){return"undefined"!=typeof window&&"undefined"!=typeof document}function In(t){let e=t.parentNode;return e&&"[object ShadowRoot]"===e.toString()&&(e=e.host),e}function zn(t,e,n){let i;return"string"==typeof t?(i=parseInt(t,10),-1!==t.indexOf("%")&&(i=i/100*e.parentNode[n])):i=t,i}const On=t=>t.ownerDocument.defaultView.getComputedStyle(t,null);const Wn=["top","right","bottom","left"];function Nn(t,e,n){const i={};n=n?"-"+n:"";for(let s=0;s<4;s++){const o=Wn[s];i[o]=parseFloat(t[e+"-"+o+n])||0}return i.width=i.left+i.right,i.height=i.top+i.bottom,i}function $n(t,e){if("native"in t)return t;const{canvas:n,currentDevicePixelRatio:i}=e,s=On(n),o="border-box"===s.boxSizing,a=Nn(s,"padding"),r=Nn(s,"border","width"),{x:l,y:c,box:d}=function(t,e){const n=t.touches,i=n&&n.length?n[0]:t,{offsetX:s,offsetY:o}=i;let a,r,l=!1;if(((t,e,n)=>(t>0||e>0)&&(!n||!n.shadowRoot))(s,o,t.target))a=s,r=o;else{const t=e.getBoundingClientRect();a=i.clientX-t.left,r=i.clientY-t.top,l=!0}return{x:a,y:r,box:l}}(t,n),h=a.left+(d&&r.left),u=a.top+(d&&r.top);let{width:g,height:p}=e;return o&&(g-=a.width+r.width,p-=a.height+r.height),{x:Math.round((l-h)/g*n.width/i),y:Math.round((c-u)/p*n.height/i)}}const Rn=t=>Math.round(10*t)/10;function Fn(t,e,n,i){const s=On(t),o=Nn(s,"margin"),a=zn(s.maxWidth,t,"clientWidth")||Bt,r=zn(s.maxHeight,t,"clientHeight")||Bt,l=function(t,e,n){let i,s;if(void 0===e||void 0===n){const o=t&&In(t);if(o){const t=o.getBoundingClientRect(),a=On(o),r=Nn(a,"border","width"),l=Nn(a,"padding");e=t.width-l.width-r.width,n=t.height-l.height-r.height,i=zn(a.maxWidth,o,"clientWidth"),s=zn(a.maxHeight,o,"clientHeight")}else e=t.clientWidth,n=t.clientHeight}return{width:e,height:n,maxWidth:i||Bt,maxHeight:s||Bt}}(t,e,n);let{width:c,height:d}=l;if("content-box"===s.boxSizing){const t=Nn(s,"border","width"),e=Nn(s,"padding");c-=e.width+t.width,d-=e.height+t.height}c=Math.max(0,c-o.width),d=Math.max(0,i?c/i:d-o.height),c=Rn(Math.min(c,a,l.maxWidth)),d=Rn(Math.min(d,r,l.maxHeight)),c&&!d&&(d=Rn(c/2));return(void 0!==e||void 0!==n)&&i&&l.height&&d>l.height&&(d=l.height,c=Rn(Math.floor(d*i))),{width:c,height:d}}function Bn(t,e,n){const i=e||1,s=Rn(t.height*i),o=Rn(t.width*i);t.height=Rn(t.height),t.width=Rn(t.width);const a=t.canvas;return a.style&&(n||!a.style.height&&!a.style.width)&&(a.style.height=`${t.height}px`,a.style.width=`${t.width}px`),(t.currentDevicePixelRatio!==i||a.height!==s||a.width!==o)&&(t.currentDevicePixelRatio=i,a.height=s,a.width=o,t.ctx.setTransform(i,0,0,i,0,0),!0)}const qn=function(){let t=!1;try{const e={get passive(){return t=!0,!1}};An()&&(window.addEventListener("test",null,e),window.removeEventListener("test",null,e))}catch(t){}return t}();function Hn(t,e){const n=function(t,e){return On(t).getPropertyValue(e)}(t,e),i=n&&n.match(/^(\d+)(\.\d+)?px$/);return i?+i[1]:void 0}function Vn(t,e,n,i){return{x:t.x+n*(e.x-t.x),y:t.y+n*(e.y-t.y)}}function jn(t,e,n,i){return{x:t.x+n*(e.x-t.x),y:"middle"===i?n<.5?t.y:e.y:"after"===i?n<1?t.y:e.y:n>0?e.y:t.y}}function Yn(t,e,n,i){const s={x:t.cp2x,y:t.cp2y},o={x:e.cp1x,y:e.cp1y},a=Vn(t,s,n),r=Vn(s,o,n),l=Vn(o,e,n),c=Vn(a,r,n),d=Vn(r,l,n);return Vn(c,d,n)}function Un(t,e,n){return t?function(t,e){return{x:n=>t+t+e-n,setWidth(t){e=t},textAlign:t=>"center"===t?t:"right"===t?"left":"right",xPlus:(t,e)=>t-e,leftForLtr:(t,e)=>t-e}}(e,n):{x:t=>t,setWidth(t){},textAlign:t=>t,xPlus:(t,e)=>t+e,leftForLtr:(t,e)=>t}}function Xn(t,e){let n,i;"ltr"!==e&&"rtl"!==e||(n=t.canvas.style,i=[n.getPropertyValue("direction"),n.getPropertyPriority("direction")],n.setProperty("direction",e,"important"),t.prevTextDirection=i)}function Qn(t,e){void 0!==e&&(delete t.prevTextDirection,t.canvas.style.setProperty("direction",e[0],e[1]))}function Gn(t){return"angle"===t?{between:oe,compare:ie,normalize:se}:{between:re,compare:(t,e)=>t-e,normalize:t=>t}}function Kn({start:t,end:e,count:n,loop:i,style:s}){return{start:t%n,end:e%n,loop:i&&(e-t+1)%n==0,style:s}}function Zn(t,e,n){if(!n)return[t];const{property:i,start:s,end:o}=n,a=e.length,{compare:r,between:l,normalize:c}=Gn(i),{start:d,end:h,loop:u,style:g}=function(t,e,n){const{property:i,start:s,end:o}=n,{between:a,normalize:r}=Gn(i),l=e.length;let c,d,{start:h,end:u,loop:g}=t;if(g){for(h+=l,u+=l,c=0,d=l;c<d&&a(r(e[h%l][i]),s,o);++c)h--,u--;h%=l,u%=l}return u<h&&(u+=l),{start:h,end:u,loop:g,style:t.style}}(t,e,n),p=[];let m,f,b,y=!1,x=null;const v=()=>y||l(s,b,m)&&0!==r(s,b),w=()=>!y||0===r(o,m)||l(o,b,m);for(let t=d,n=d;t<=h;++t)f=e[t%a],f.skip||(m=c(f[i]),m!==b&&(y=l(m,s,o),null===x&&v()&&(x=0===r(m,s)?t:n),null!==x&&w()&&(p.push(Kn({start:x,end:t,loop:u,count:a,style:g})),x=null),n=t,b=m));return null!==x&&p.push(Kn({start:x,end:h,loop:u,count:a,style:g})),p}function Jn(t,e){const n=[],i=t.segments;for(let s=0;s<i.length;s++){const o=Zn(i[s],t.points,e);o.length&&n.push(...o)}return n}function ti(t,e,n,i){return i&&i.setContext&&n?function(t,e,n,i){const s=t._chart.getContext(),o=ei(t.options),{_datasetIndex:a,options:{spanGaps:r}}=t,l=n.length,c=[];let d=o,h=e[0].start,u=h;function g(t,e,i,s){const o=r?-1:1;if(t!==e){for(t+=l;n[t%l].skip;)t-=o;for(;n[e%l].skip;)e+=o;t%l!==e%l&&(c.push({start:t%l,end:e%l,loop:i,style:s}),d=s,h=e%l)}}for(const t of e){h=r?h:t.start;let e,o=n[h%l];for(u=h+1;u<=t.end;u++){const r=n[u%l];e=ei(i.setContext(dn(s,{type:"segment",p0:o,p1:r,p0DataIndex:(u-1)%l,p1DataIndex:u%l,datasetIndex:a}))),ni(e,d)&&g(h,u-1,t.loop,d),o=r,d=e}h<u-1&&g(h,u-1,t.loop,d)}return c}(t,e,n,i):e}function ei(t){return{backgroundColor:t.backgroundColor,borderCapStyle:t.borderCapStyle,borderDash:t.borderDash,borderDashOffset:t.borderDashOffset,borderJoinStyle:t.borderJoinStyle,borderWidth:t.borderWidth,borderColor:t.borderColor}}function ni(t,e){if(!e)return!1;const n=[],i=function(t,e){return Me(e)?(n.includes(e)||n.push(e),n.indexOf(e)):e};return JSON.stringify(t,i)!==JSON.stringify(e,i)}function ii(t,e,n){return t.options.clip?t[n]:e[n]}function si(t,e){const n=e._clip;if(n.disabled)return!1;const i=function(t,e){const{xScale:n,yScale:i}=t;return n&&i?{left:ii(n,e,"left"),right:ii(n,e,"right"),top:ii(i,e,"top"),bottom:ii(i,e,"bottom")}:e}(e,t.chartArea);return{left:!1===n.left?0:i.left-(!0===n.left?0:n.left),right:!1===n.right?t.width:i.right+(!0===n.right?0:n.right),top:!1===n.top?0:i.top-(!0===n.top?0:n.top),bottom:!1===n.bottom?t.height:i.bottom+(!0===n.bottom?0:n.bottom)}}
|
|
15
15
|
/*!
|
|
16
16
|
* Chart.js v4.5.1
|
|
17
17
|
* https://www.chartjs.org
|
|
18
18
|
* (c) 2025 Chart.js Contributors
|
|
19
19
|
* Released under the MIT License
|
|
20
|
-
*/class ti{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,n,i){const s=e.listeners[i],o=e.duration;s.forEach((i=>i({chart:t,initial:e.initial,numSteps:o,currentStep:Math.min(n-e.start,o)})))}_refresh(){this._request||(this._running=!0,this._request=ce.call(window,(()=>{this._update(),this._request=null,this._running&&this._refresh()})))}_update(t=Date.now()){let e=0;this._charts.forEach(((n,i)=>{if(!n.running||!n.items.length)return;const s=n.items;let o,a=s.length-1,r=!1;for(;a>=0;--a)o=s[a],o._active?(o._total>n.duration&&(n.duration=o._total),o.tick(t),r=!0):(s[a]=s[s.length-1],s.pop());r&&(i.draw(),this._notify(i,n,t,"progress")),s.length||(n.running=!1,this._notify(i,n,t,"complete"),n.initial=!1),e+=s.length})),this._lastDate=t,0===e&&(this._running=!1)}_getAnims(t){const e=this._charts;let n=e.get(t);return n||(n={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,n)),n}listen(t,e,n){this._getAnims(t).listeners[e].push(n)}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 n=e.items;let i=n.length-1;for(;i>=0;--i)n[i].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var ei=new ti;const ni="transparent",ii={boolean:(t,e,n)=>n>.5?e:t,color(t,e,n){const i=ve(t||ni),s=i.valid&&ve(e||ni);return s&&s.valid?s.mix(i,n).hexString():e},number:(t,e,n)=>t+(e-t)*n};class si{constructor(t,e,n,i){const s=e[n];i=sn([t.to,i,s,t.from]);const o=sn([t.from,s,i]);this._active=!0,this._fn=t.fn||ii[t.type||typeof o],this._easing=ye[t.easing]||ye.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=n,this._from=o,this._to=i,this._promises=void 0}active(){return this._active}update(t,e,n){if(this._active){this._notify(!1);const i=this._target[this._prop],s=n-this._start,o=this._duration-s;this._start=n,this._duration=Math.floor(Math.max(o,t.duration)),this._total+=s,this._loop=!!t.loop,this._to=sn([t.to,e,i,t.from]),this._from=sn([t.from,i,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const e=t-this._start,n=this._duration,i=this._prop,s=this._from,o=this._loop,a=this._to;let r;if(this._active=s!==a&&(o||e<n),!this._active)return this._target[i]=a,void this._notify(!0);e<0?this._target[i]=s:(r=e/n%2,r=o&&r>1?2-r:r,r=this._easing(Math.min(1,Math.max(0,r))),this._target[i]=this._fn(s,a,r))}wait(){const t=this._promises||(this._promises=[]);return new Promise(((e,n)=>{t.push({res:e,rej:n})}))}_notify(t){const e=t?"res":"rej",n=this._promises||[];for(let t=0;t<n.length;t++)n[t][e]()}}class oi{constructor(t,e){this._chart=t,this._properties=new Map,this.configure(e)}configure(t){if(!gt(t))return;const e=Object.keys(Ie.animation),n=this._properties;Object.getOwnPropertyNames(t).forEach((i=>{const s=t[i];if(!gt(s))return;const o={};for(const t of e)o[t]=s[t];(ut(s.properties)&&s.properties||[i]).forEach((t=>{t!==i&&n.has(t)||n.set(t,o)}))}))}_animateOptions(t,e){const n=e.options,i=function(t,e){if(!e)return;let n=t.options;if(!n)return void(t.options=e);n.$shared&&(t.options=n=Object.assign({},n,{$shared:!1,$animations:{}}));return n}(t,n);if(!i)return[];const s=this._createAnimations(i,n);return n.$shared&&function(t,e){const n=[],i=Object.keys(e);for(let e=0;e<i.length;e++){const s=t[i[e]];s&&s.active()&&n.push(s.wait())}return Promise.all(n)}(t.options.$animations,n).then((()=>{t.options=n}),(()=>{})),s}_createAnimations(t,e){const n=this._properties,i=[],s=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){i.push(...this._animateOptions(t,e));continue}const c=e[l];let d=s[l];const h=n.get(l);if(d){if(h&&d.active()){d.update(h,c,a);continue}d.cancel()}h&&h.duration?(s[l]=d=new si(h,t,l,c),i.push(d)):t[l]=c}return i}update(t,e){if(0===this._properties.size)return void Object.assign(t,e);const n=this._createAnimations(t,e);return n.length?(ei.add(this._chart,n),!0):void 0}}function ai(t,e){const n=t&&t.options||{},i=n.reverse,s=void 0===n.min?e:0,o=void 0===n.max?e:0;return{start:i?o:s,end:i?s:o}}function ri(t,e){const n=[],i=t._getSortedDatasetMetas(e);let s,o;for(s=0,o=i.length;s<o;++s)n.push(i[s].index);return n}function li(t,e,n,i={}){const s=t.keys,o="single"===i.mode;let a,r,l,c;if(null===e)return;let d=!1;for(a=0,r=s.length;a<r;++a){if(l=+s[a],l===n){if(d=!0,i.all)continue;break}c=t.values[l],pt(c)&&(o||0===e||qt(e)===qt(c))&&(e+=c)}return d||i.all?e:0}function ci(t,e){const n=t&&t.options.stacked;return n||void 0===n&&void 0!==e.stack}function di(t,e,n){const i=t[e]||(t[e]={});return i[n]||(i[n]={})}function hi(t,e,n,i){for(const s of e.getMatchingVisibleMetas(i).reverse()){const e=t[s.index];if(n&&e>0||!n&&e<0)return s.index}return null}function ui(t,e){const{chart:n,_cachedMeta:i}=t,s=n._stacks||(n._stacks={}),{iScale:o,vScale:a,index:r}=i,l=o.axis,c=a.axis,d=function(t,e,n){return`${t.id}.${e.id}.${n.stack||n.type}`}(o,a,i),h=e.length;let u;for(let t=0;t<h;++t){const n=e[t],{[l]:o,[c]:h}=n;u=(n._stacks||(n._stacks={}))[c]=di(s,d,o),u[r]=h,u._top=hi(u,a,!0,i.type),u._bottom=hi(u,a,!1,i.type);(u._visualValues||(u._visualValues={}))[r]=h}}function gi(t,e){const n=t.scales;return Object.keys(n).filter((t=>n[t].axis===e)).shift()}function pi(t,e){const n=t.controller.index,i=t.vScale&&t.vScale.axis;if(i){e=e||t._parsed;for(const t of e){const e=t._stacks;if(!e||void 0===e[i]||void 0===e[i][n])return;delete e[i][n],void 0!==e[i]._visualValues&&void 0!==e[i]._visualValues[n]&&delete e[i]._visualValues[n]}}}const mi=t=>"reset"===t||"none"===t,fi=(t,e)=>e?t:Object.assign({},t);class bi{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=ci(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&&pi(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,e=this._cachedMeta,n=this.getDataset(),i=(t,e,n,i)=>"x"===t?e:"r"===t?i:n,s=e.xAxisID=ft(n.xAxisID,gi(t,"x")),o=e.yAxisID=ft(n.yAxisID,gi(t,"y")),a=e.rAxisID=ft(n.rAxisID,gi(t,"r")),r=e.indexAxis,l=e.iAxisID=i(r,s,o,a),c=e.vAxisID=i(r,o,s,a);e.xScale=this.getScaleForId(s),e.yScale=this.getScaleForId(o),e.rScale=this.getScaleForId(a),e.iScale=this.getScaleForId(l),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&&re(this._data,this),t._stacked&&pi(t)}_dataCheck(){const t=this.getDataset(),e=t.data||(t.data=[]),n=this._data;if(gt(e)){const t=this._cachedMeta;this._data=function(t,e){const{iScale:n,vScale:i}=e,s="x"===n.axis?"x":"y",o="x"===i.axis?"x":"y",a=Object.keys(t),r=new Array(a.length);let l,c,d;for(l=0,c=a.length;l<c;++l)d=a[l],r[l]={[s]:d,[o]:t[d]};return r}(e,t)}else if(n!==e){if(n){re(n,this);const t=this._cachedMeta;pi(t),t._parsed=[]}e&&Object.isExtensible(e)&&(s=this,(i=e)._chartjs?i._chartjs.listeners.push(s):(Object.defineProperty(i,"_chartjs",{configurable:!0,enumerable:!1,value:{listeners:[s]}}),ae.forEach((t=>{const e="_onData"+Pt(t),n=i[t];Object.defineProperty(i,t,{configurable:!0,enumerable:!1,value(...t){const s=n.apply(this,t);return i._chartjs.listeners.forEach((n=>{"function"==typeof n[e]&&n[e](...t)})),s}})})))),this._syncList=[],this._data=e}var i,s}addElements(){const t=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(t.dataset=new this.datasetElementType)}buildOrUpdateElements(t){const e=this._cachedMeta,n=this.getDataset();let i=!1;this._dataCheck();const s=e._stacked;e._stacked=ci(e.vScale,e),e.stack!==n.stack&&(i=!0,pi(e),e.stack=n.stack),this._resyncElements(t),(i||s!==e._stacked)&&(ui(this,e._parsed),e._stacked=ci(e.vScale,e))}configure(){const t=this.chart.config,e=t.datasetScopeKeys(this._type),n=t.getOptionScopes(this.getDataset(),e,!0);this.options=t.createResolver(n,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,e){const{_cachedMeta:n,_data:i}=this,{iScale:s,_stacked:o}=n,a=s.axis;let r,l,c,d=0===t&&e===i.length||n._sorted,h=t>0&&n._parsed[t-1];if(!1===this._parsing)n._parsed=i,n._sorted=!0,c=i;else{c=ut(i[t])?this.parseArrayData(n,i,t,e):gt(i[t])?this.parseObjectData(n,i,t,e):this.parsePrimitiveData(n,i,t,e);const s=()=>null===l[a]||h&&l[a]<h[a];for(r=0;r<e;++r)n._parsed[r+t]=l=c[r],d&&(s()&&(d=!1),h=l);n._sorted=d}o&&ui(this,c)}parsePrimitiveData(t,e,n,i){const{iScale:s,vScale:o}=t,a=s.axis,r=o.axis,l=s.getLabels(),c=s===o,d=new Array(i);let h,u,g;for(h=0,u=i;h<u;++h)g=h+n,d[h]={[a]:c||s.parse(l[g],g),[r]:o.parse(e[g],g)};return d}parseArrayData(t,e,n,i){const{xScale:s,yScale:o}=t,a=new Array(i);let r,l,c,d;for(r=0,l=i;r<l;++r)c=r+n,d=e[c],a[r]={x:s.parse(d[0],c),y:o.parse(d[1],c)};return a}parseObjectData(t,e,n,i){const{xScale:s,yScale:o}=t,{xAxisKey:a="x",yAxisKey:r="y"}=this._parsing,l=new Array(i);let c,d,h,u;for(c=0,d=i;c<d;++c)h=c+n,u=e[h],l[c]={x:s.parse(Dt(u,a),h),y:o.parse(Dt(u,r),h)};return l}getParsed(t){return this._cachedMeta._parsed[t]}getDataElement(t){return this._cachedMeta.data[t]}applyStack(t,e,n){const i=this.chart,s=this._cachedMeta,o=e[t.axis];return li({keys:ri(i,!0),values:e._stacks[t.axis]._visualValues},o,s.index,{mode:n})}updateRangeFromParsed(t,e,n,i){const s=n[e.axis];let o=null===s?NaN:s;const a=i&&n._stacks[e.axis];i&&a&&(i.values=a,o=li(i,s,this._cachedMeta.index)),t.min=Math.min(t.min,o),t.max=Math.max(t.max,o)}getMinMax(t,e){const n=this._cachedMeta,i=n._parsed,s=n._sorted&&t===n.iScale,o=i.length,a=this._getOtherScale(t),r=((t,e,n)=>t&&!e.hidden&&e._stacked&&{keys:ri(n,!0),values:null})(e,n,this.chart),l={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:c,max:d}=function(t){const{min:e,max:n,minDefined:i,maxDefined:s}=t.getUserBounds();return{min:i?e:Number.NEGATIVE_INFINITY,max:s?n:Number.POSITIVE_INFINITY}}(a);let h,u;function g(){u=i[h];const e=u[a.axis];return!pt(u[t.axis])||c>e||d<e}for(h=0;h<o&&(g()||(this.updateRangeFromParsed(l,t,u,r),!s));++h);if(s)for(h=o-1;h>=0;--h)if(!g()){this.updateRangeFromParsed(l,t,u,r);break}return l}getAllParsedValues(t){const e=this._cachedMeta._parsed,n=[];let i,s,o;for(i=0,s=e.length;i<s;++i)o=e[i][t.axis],pt(o)&&n.push(o);return n}getMaxOverflow(){return!1}getLabelAndValue(t){const e=this._cachedMeta,n=e.iScale,i=e.vScale,s=this.getParsed(t);return{label:n?""+n.getLabelForValue(s[n.axis]):"",value:i?""+i.getLabelForValue(s[i.axis]):""}}_update(t){const e=this._cachedMeta;this.update(t||"default"),e._clip=function(t){let e,n,i,s;return gt(t)?(e=t.top,n=t.right,i=t.bottom,s=t.left):e=n=i=s=t,{top:e,right:n,bottom:i,left:s,disabled:!1===t}}(ft(this.options.clip,function(t,e,n){if(!1===n)return!1;const i=ai(t,n),s=ai(e,n);return{top:s.end,right:i.end,bottom:s.start,left:i.start}}(e.xScale,e.yScale,this.getMaxOverflow())))}update(t){}draw(){const t=this._ctx,e=this.chart,n=this._cachedMeta,i=n.data||[],s=e.chartArea,o=[],a=this._drawStart||0,r=this._drawCount||i.length-a,l=this.options.drawActiveElementsOnTop;let c;for(n.dataset&&n.dataset.draw(t,s,a,r),c=a;c<a+r;++c){const e=i[c];e.hidden||(e.active&&l?o.push(e):e.draw(t,s))}for(c=0;c<o.length;++c)o[c].draw(t,s)}getStyle(t,e){const n=e?"active":"default";return void 0===t&&this._cachedMeta.dataset?this.resolveDatasetElementOptions(n):this.resolveDataElementOptions(t||0,n)}getContext(t,e,n){const i=this.getDataset();let s;if(t>=0&&t<this._cachedMeta.data.length){const e=this._cachedMeta.data[t];s=e.$context||(e.$context=function(t,e,n){return on(t,{active:!1,dataIndex:e,parsed:void 0,raw:void 0,element:n,index:e,mode:"default",type:"data"})}(this.getContext(),t,e)),s.parsed=this.getParsed(t),s.raw=i.data[t],s.index=s.dataIndex=t}else s=this.$context||(this.$context=function(t,e){return on(t,{active:!1,dataset:void 0,datasetIndex:e,index:e,mode:"default",type:"dataset"})}(this.chart.getContext(),this.index)),s.dataset=i,s.index=s.datasetIndex=this.index;return s.active=!!e,s.mode=n,s}resolveDatasetElementOptions(t){return this._resolveElementOptions(this.datasetElementType.id,t)}resolveDataElementOptions(t,e){return this._resolveElementOptions(this.dataElementType.id,e,t)}_resolveElementOptions(t,e="default",n){const i="active"===e,s=this._cachedDataOpts,o=t+"-"+e,a=s[o],r=this.enableOptionSharing&&Et(n);if(a)return fi(a,r);const l=this.chart.config,c=l.datasetElementScopeKeys(this._type,t),d=i?[`${t}Hover`,"hover",t,""]:[t,""],h=l.getOptionScopes(this.getDataset(),c),u=Object.keys(Ie.elements[t]),g=l.resolveNamedOptions(h,u,(()=>this.getContext(n,i,e)),d);return g.$shared&&(g.$shared=r,s[o]=Object.freeze(fi(g,r))),g}_resolveAnimations(t,e,n){const i=this.chart,s=this._cachedDataOpts,o=`animation-${e}`,a=s[o];if(a)return a;let r;if(!1!==i.options.animation){const i=this.chart.config,s=i.datasetAnimationScopeKeys(this._type,e),o=i.getOptionScopes(this.getDataset(),s);r=i.createResolver(o,this.getContext(t,n,e))}const l=new oi(i,r&&r.animations);return r&&r._cacheable&&(s[o]=Object.freeze(l)),l}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||mi(t)||this.chart._animationsDisabled}_getSharedOptions(t,e){const n=this.resolveDataElementOptions(t,e),i=this._sharedOptions,s=this.getSharedOptions(n),o=this.includeOptions(e,s)||s!==i;return this.updateSharedOptions(s,e,n),{sharedOptions:s,includeOptions:o}}updateElement(t,e,n,i){mi(i)?Object.assign(t,n):this._resolveAnimations(e,i).update(t,n)}updateSharedOptions(t,e,n){t&&!mi(e)&&this._resolveAnimations(void 0,e).update(t,n)}_setStyle(t,e,n,i){t.active=i;const s=this.getStyle(e,i);this._resolveAnimations(e,n,i).update(t,{options:!i&&this.getSharedOptions(s)||s})}removeHoverStyle(t,e,n){this._setStyle(t,n,"active",!1)}setHoverStyle(t,e,n){this._setStyle(t,n,"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,n=this._cachedMeta.data;for(const[t,e,n]of this._syncList)this[t](e,n);this._syncList=[];const i=n.length,s=e.length,o=Math.min(s,i);o&&this.parse(0,o),s>i?this._insertElements(i,s-i,t):s<i&&this._removeElements(s,i-s)}_insertElements(t,e,n=!0){const i=this._cachedMeta,s=i.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(s),a=t;a<o;++a)s[a]=new this.dataElementType;this._parsing&&r(i._parsed),this.parse(t,e),n&&this.updateElements(s,t,e,"reset")}updateElements(t,e,n,i){}_removeElements(t,e){const n=this._cachedMeta;if(this._parsing){const i=n._parsed.splice(t,e);n._stacked&&pi(n,i)}n.data.splice(t,e)}_sync(t){if(this._parsing)this._syncList.push(t);else{const[e,n,i]=t;this[e](n,i)}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 n=arguments.length-2;n&&this._sync(["_insertElements",t,n])}_onDataUnshift(){this._sync(["_insertElements",0,arguments.length])}}function yi(t){const e=t.iScale,n=function(t,e){if(!t._cache.$bar){const n=t.getMatchingVisibleMetas(e);let i=[];for(let e=0,s=n.length;e<s;e++)i=i.concat(n[e].controller.getAllParsedValues(t));t._cache.$bar=le(i.sort(((t,e)=>t-e)))}return t._cache.$bar}(e,t.type);let i,s,o,a,r=e._length;const l=()=>{32767!==o&&-32768!==o&&(Et(a)&&(r=Math.min(r,Math.abs(o-a)||r)),a=o)};for(i=0,s=n.length;i<s;++i)o=e.getPixelForValue(n[i]),l();for(a=void 0,i=0,s=e.ticks.length;i<s;++i)o=e.getPixelForTick(i),l();return r}function xi(t,e,n,i){return ut(t)?function(t,e,n,i){const s=n.parse(t[0],i),o=n.parse(t[1],i),a=Math.min(s,o),r=Math.max(s,o);let l=a,c=r;Math.abs(a)>Math.abs(r)&&(l=r,c=a),e[n.axis]=c,e._custom={barStart:l,barEnd:c,start:s,end:o,min:a,max:r}}(t,e,n,i):e[n.axis]=n.parse(t,i),e}function vi(t,e,n,i){const s=t.iScale,o=t.vScale,a=s.getLabels(),r=s===o,l=[];let c,d,h,u;for(c=n,d=n+i;c<d;++c)u=e[c],h={},h[s.axis]=r||s.parse(a[c],c),l.push(xi(u,h,o,c));return l}function wi(t){return t&&void 0!==t.barStart&&void 0!==t.barEnd}function ki(t,e,n,i){let s=e.borderSkipped;const o={};if(!s)return void(t.borderSkipped=o);if(!0===s)return void(t.borderSkipped={top:!0,right:!0,bottom:!0,left:!0});const{start:a,end:r,reverse:l,top:c,bottom:d}=function(t){let e,n,i,s,o;return t.horizontal?(e=t.base>t.x,n="left",i="right"):(e=t.base<t.y,n="bottom",i="top"),e?(s="end",o="start"):(s="start",o="end"),{start:n,end:i,reverse:e,top:s,bottom:o}}(t);"middle"===s&&n&&(t.enableBorderRadius=!0,(n._top||0)===i?s=c:(n._bottom||0)===i?s=d:(o[Si(d,a,r,l)]=!0,s=c)),o[Si(s,a,r,l)]=!0,t.borderSkipped=o}function Si(t,e,n,i){var s,o,a;return i?(a=n,t=Mi(t=(s=t)===(o=e)?a:s===a?o:s,n,e)):t=Mi(t,e,n),t}function Mi(t,e,n){return"start"===t?e:"end"===t?n:t}function Ci(t,{inflateAmount:e},n){t.inflateAmount="auto"===e?1===n?.33:0:e}class _i extends bi{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(t,e,n,i){return vi(t,e,n,i)}parseArrayData(t,e,n,i){return vi(t,e,n,i)}parseObjectData(t,e,n,i){const{iScale:s,vScale:o}=t,{xAxisKey:a="x",yAxisKey:r="y"}=this._parsing,l="x"===s.axis?a:r,c="x"===o.axis?a:r,d=[];let h,u,g,p;for(h=n,u=n+i;h<u;++h)p=e[h],g={},g[s.axis]=s.parse(Dt(p,l),h),d.push(xi(Dt(p,c),g,o,h));return d}updateRangeFromParsed(t,e,n,i){super.updateRangeFromParsed(t,e,n,i);const s=n._custom;s&&e===this._cachedMeta.vScale&&(t.min=Math.min(t.min,s.min),t.max=Math.max(t.max,s.max))}getMaxOverflow(){return 0}getLabelAndValue(t){const e=this._cachedMeta,{iScale:n,vScale:i}=e,s=this.getParsed(t),o=s._custom,a=wi(o)?"["+o.start+", "+o.end+"]":""+i.getLabelForValue(s[i.axis]);return{label:""+n.getLabelForValue(s[n.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,n,i){const s="reset"===i,{index:o,_cachedMeta:{vScale:a}}=this,r=a.getBasePixel(),l=a.isHorizontal(),c=this._getRuler(),{sharedOptions:d,includeOptions:h}=this._getSharedOptions(e,i);for(let u=e;u<e+n;u++){const e=this.getParsed(u),n=s||ht(e[a.axis])?{base:r,head:r}:this._calculateBarValuePixels(u),g=this._calculateBarIndexPixels(u,c),p=(e._stacks||{})[a.axis],m={horizontal:l,base:n.base,enableBorderRadius:!p||wi(e._custom)||o===p._top||o===p._bottom,x:l?n.head:g.center,y:l?g.center:n.head,height:l?g.size:Math.abs(n.size),width:l?Math.abs(n.size):g.size};h&&(m.options=d||this.resolveDataElementOptions(u,t[u].active?"active":i));const f=m.options||t[u].options;ki(m,f,p,o),Ci(m,f,c.ratio),this.updateElement(t[u],u,m,i)}}_getStacks(t,e){const{iScale:n}=this._cachedMeta,i=n.getMatchingVisibleMetas(this._type).filter((t=>t.controller.options.grouped)),s=n.options.stacked,o=[],a=this._cachedMeta.controller.getParsed(e),r=a&&a[n.axis],l=t=>{const e=t._parsed.find((t=>t[n.axis]===r)),i=e&&e[t.vScale.axis];if(ht(i)||isNaN(i))return!0};for(const n of i)if((void 0===e||!l(n))&&((!1===s||-1===o.indexOf(n.stack)||void 0===s&&void 0===n.stack)&&o.push(n.stack),n.index===t))break;return o.length||o.push(void 0),o}_getStackCount(t){return this._getStacks(void 0,t).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){const t=this.chart.scales,e=this.chart.options.indexAxis;return Object.keys(t).filter((n=>t[n].axis===e)).shift()}_getAxis(){const t={},e=this.getFirstScaleIdForIndexAxis();for(const n of this.chart.data.datasets)t[ft("x"===this.chart.options.indexAxis?n.xAxisID:n.yAxisID,e)]=!0;return Object.keys(t)}_getStackIndex(t,e,n){const i=this._getStacks(t,n),s=void 0!==e?i.indexOf(e):-1;return-1===s?i.length-1:s}_getRuler(){const t=this.options,e=this._cachedMeta,n=e.iScale,i=[];let s,o;for(s=0,o=e.data.length;s<o;++s)i.push(n.getPixelForValue(this.getParsed(s)[n.axis],s));const a=t.barThickness;return{min:a||yi(e),pixels:i,start:n._startPixel,end:n._endPixel,stackCount:this._getStackCount(),scale:n,grouped:t.grouped,ratio:a?1:t.categoryPercentage*t.barPercentage}}_calculateBarValuePixels(t){const{_cachedMeta:{vScale:e,_stacked:n,index:i},options:{base:s,minBarLength:o}}=this,a=s||0,r=this.getParsed(t),l=r._custom,c=wi(l);let d,h,u=r[e.axis],g=0,p=n?this.applyStack(e,r,n):u;p!==u&&(g=p-u,p=u),c&&(u=l.barStart,p=l.barEnd-l.barStart,0!==u&&qt(u)!==qt(l.barEnd)&&(g=0),g+=u);const m=ht(s)||c?g:s;let f=e.getPixelForValue(m);if(d=this.chart.getDataVisibility(t)?e.getPixelForValue(g+p):f,h=d-f,Math.abs(h)<o){h=function(t,e,n){return 0!==t?qt(t):(e.isHorizontal()?1:-1)*(e.min>=n?1:-1)}(h,e,a)*o,u===a&&(f-=h/2);const t=e.getPixelForDecimal(0),s=e.getPixelForDecimal(1),l=Math.min(t,s),g=Math.max(t,s);f=Math.max(Math.min(f,g),l),d=f+h,n&&!c&&(r._stacks[e.axis]._visualValues[i]=e.getValueForPixel(d)-e.getValueForPixel(f))}if(f===e.getPixelForValue(a)){const t=qt(h)*e.getLineWidthForValue(a)/2;f+=t,h-=t}return{size:h,base:f,head:d,center:d+h/2}}_calculateBarIndexPixels(t,e){const n=e.scale,i=this.options,s=i.skipNull,o=ft(i.maxBarThickness,1/0);let a,r;const l=this._getAxisCount();if(e.grouped){const n=s?this._getStackCount(t):e.stackCount,c="flex"===i.barThickness?function(t,e,n,i){const s=e.pixels,o=s[t];let a=t>0?s[t-1]:null,r=t<s.length-1?s[t+1]:null;const l=n.categoryPercentage;null===a&&(a=o-(null===r?e.end-e.start:r-o)),null===r&&(r=o+o-a);const c=o-(o-Math.min(a,r))/2*l;return{chunk:Math.abs(r-a)/2*l/i,ratio:n.barPercentage,start:c}}(t,e,i,n*l):function(t,e,n,i){const s=n.barThickness;let o,a;return ht(s)?(o=e.min*n.categoryPercentage,a=n.barPercentage):(o=s*i,a=1),{chunk:o/i,ratio:a,start:e.pixels[t]-o/2}}(t,e,i,n*l),d="x"===this.chart.options.indexAxis?this.getDataset().xAxisID:this.getDataset().yAxisID,h=this._getAxis().indexOf(ft(d,this.getFirstScaleIdForIndexAxis())),u=this._getStackIndex(this.index,this._cachedMeta.stack,s?t:void 0)+h;a=c.start+c.chunk*u+c.chunk/2,r=Math.min(o,c.chunk*c.ratio)}else a=n.getPixelForValue(this.getParsed(t)[n.axis],t),r=Math.min(o,e.min*e.ratio);return{base:a-r/2,head:a+r/2,center:a,size:r}}draw(){const t=this._cachedMeta,e=t.vScale,n=t.data,i=n.length;let s=0;for(;s<i;++s)null===this.getParsed(s)[e.axis]||n[s].hidden||n[s].draw(this._ctx)}}class Ti extends bi{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,{labels:{pointStyle:n,textAlign:i,color:s,useBorderRadius:o,borderRadius:a}}=t.legend.options;return e.labels.length&&e.datasets.length?e.labels.map(((e,r)=>{const l=t.getDatasetMeta(0).controller.getStyle(r);return{text:e,fillStyle:l.backgroundColor,fontColor:s,hidden:!t.getDataVisibility(r),lineDash:l.borderDash,lineDashOffset:l.borderDashOffset,lineJoin:l.borderJoinStyle,lineWidth:l.borderWidth,strokeStyle:l.borderColor,textAlign:i,pointStyle:n,borderRadius:o&&(a||l.borderRadius),index:r}})):[]}},onClick(t,e,n){n.chart.toggleDataVisibility(e.index),n.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 n=this.getDataset().data,i=this._cachedMeta;if(!1===this._parsing)i._parsed=n;else{let s,o,a=t=>+n[t];if(gt(n[t])){const{key:t="value"}=this._parsing;a=e=>+Dt(n[e],t)}for(s=t,o=t+e;s<o;++s)i._parsed[s]=a(s)}}_getRotation(){return Ut(this.options.rotation-90)}_getCircumference(){return Ut(this.options.circumference)}_getRotationExtents(){let t=zt,e=-zt;for(let n=0;n<this.chart.data.datasets.length;++n)if(this.chart.isDatasetVisible(n)&&this.chart.getDatasetMeta(n).type===this._type){const i=this.chart.getDatasetMeta(n).controller,s=i._getRotation(),o=i._getCircumference();t=Math.min(t,s),e=Math.max(e,s+o)}return{rotation:t,circumference:e-t}}update(t){const e=this.chart,{chartArea:n}=e,i=this._cachedMeta,s=i.data,o=this.getMaxBorderWidth()+this.getMaxOffset(s)+this.options.spacing,a=Math.max((Math.min(n.width,n.height)-o)/2,0),r=Math.min((l=this.options.cutout,c=a,"string"==typeof l&&l.endsWith("%")?parseFloat(l)/100:+l/c),1);var l,c;const d=this._getRingWeight(this.index),{circumference:h,rotation:u}=this._getRotationExtents(),{ratioX:g,ratioY:p,offsetX:m,offsetY:f}=function(t,e,n){let i=1,s=1,o=0,a=0;if(e<zt){const r=t,l=r+e,c=Math.cos(r),d=Math.sin(r),h=Math.cos(l),u=Math.sin(l),g=(t,e,i)=>te(t,r,l,!0)?1:Math.max(e,e*n,i,i*n),p=(t,e,i)=>te(t,r,l,!0)?-1:Math.min(e,e*n,i,i*n),m=g(0,c,h),f=g(Rt,d,u),b=p(It,c,h),y=p(It+Rt,d,u);i=(m-b)/2,s=(f-y)/2,o=-(m+b)/2,a=-(f+y)/2}return{ratioX:i,ratioY:s,offsetX:o,offsetY:a}}(u,h,r),b=(n.width-o)/g,y=(n.height-o)/p,x=Math.max(Math.min(b,y)/2,0),v=bt(this.options.radius,x),w=(v-Math.max(v*r,0))/this._getVisibleDatasetWeightTotal();this.offsetX=m*v,this.offsetY=f*v,i.total=this.calculateTotal(),this.outerRadius=v-w*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-w*d,0),this.updateElements(s,0,s.length,t)}_circumference(t,e){const n=this.options,i=this._cachedMeta,s=this._getCircumference();return e&&n.animation.animateRotate||!this.chart.getDataVisibility(t)||null===i._parsed[t]||i.data[t].hidden?0:this.calculateCircumference(i._parsed[t]*s/zt)}updateElements(t,e,n,i){const s="reset"===i,o=this.chart,a=o.chartArea,r=o.options.animation,l=(a.left+a.right)/2,c=(a.top+a.bottom)/2,d=s&&r.animateScale,h=d?0:this.innerRadius,u=d?0:this.outerRadius,{sharedOptions:g,includeOptions:p}=this._getSharedOptions(e,i);let m,f=this._getRotation();for(m=0;m<e;++m)f+=this._circumference(m,s);for(m=e;m<e+n;++m){const e=this._circumference(m,s),n=t[m],o={x:l+this.offsetX,y:c+this.offsetY,startAngle:f,endAngle:f+e,circumference:e,outerRadius:u,innerRadius:h};p&&(o.options=g||this.resolveDataElementOptions(m,n.active?"active":i)),f+=e,this.updateElement(n,m,o,i)}}calculateTotal(){const t=this._cachedMeta,e=t.data;let n,i=0;for(n=0;n<e.length;n++){const s=t._parsed[n];null===s||isNaN(s)||!this.chart.getDataVisibility(n)||e[n].hidden||(i+=Math.abs(s))}return i}calculateCircumference(t){const e=this._cachedMeta.total;return e>0&&!isNaN(t)?zt*(Math.abs(t)/e):0}getLabelAndValue(t){const e=this._cachedMeta,n=this.chart,i=n.data.labels||[],s=Ce(e._parsed[t],n.options.locale);return{label:i[t]||"",value:s}}getMaxBorderWidth(t){let e=0;const n=this.chart;let i,s,o,a,r;if(!t)for(i=0,s=n.data.datasets.length;i<s;++i)if(n.isDatasetVisible(i)){o=n.getDatasetMeta(i),t=o.data,a=o.controller;break}if(!t)return 0;for(i=0,s=t.length;i<s;++i)r=a.resolveDataElementOptions(i),"inner"!==r.borderAlign&&(e=Math.max(e,r.borderWidth||0,r.hoverBorderWidth||0));return e}getMaxOffset(t){let e=0;for(let n=0,i=t.length;n<i;++n){const t=this.resolveDataElementOptions(n);e=Math.max(e,t.offset||0,t.hoverOffset||0)}return e}_getRingWeightOffset(t){let e=0;for(let n=0;n<t;++n)this.chart.isDatasetVisible(n)&&(e+=this._getRingWeight(n));return e}_getRingWeight(t){return Math.max(ft(this.chart.data.datasets[t].weight,1),0)}_getVisibleDatasetWeightTotal(){return this._getRingWeightOffset(this.chart.data.datasets.length)||1}}class Di extends bi{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:n,color:i}}=t.legend.options;return e.labels.map(((e,s)=>{const o=t.getDatasetMeta(0).controller.getStyle(s);return{text:e,fillStyle:o.backgroundColor,strokeStyle:o.borderColor,fontColor:i,lineWidth:o.borderWidth,pointStyle:n,hidden:!t.getDataVisibility(s),index:s}}))}return[]}},onClick(t,e,n){n.chart.toggleDataVisibility(e.index),n.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,n=this.chart,i=n.data.labels||[],s=Ce(e._parsed[t].r,n.options.locale);return{label:i[t]||"",value:s}}parseObjectData(t,e,n,i){return xn.bind(this)(t,e,n,i)}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,n)=>{const i=this.getParsed(n).r;!isNaN(i)&&this.chart.getDataVisibility(n)&&(i<e.min&&(e.min=i),i>e.max&&(e.max=i))})),e}_updateRadius(){const t=this.chart,e=t.chartArea,n=t.options,i=Math.min(e.right-e.left,e.bottom-e.top),s=Math.max(i/2,0),o=(s-Math.max(n.cutoutPercentage?s/100*n.cutoutPercentage:1,0))/t.getVisibleDatasetCount();this.outerRadius=s-o*this.index,this.innerRadius=this.outerRadius-o}updateElements(t,e,n,i){const s="reset"===i,o=this.chart,a=o.options.animation,r=this._cachedMeta.rScale,l=r.xCenter,c=r.yCenter,d=r.getIndexAngle(0)-.5*It;let h,u=d;const g=360/this.countVisibleElements();for(h=0;h<e;++h)u+=this._computeAngle(h,i,g);for(h=e;h<e+n;h++){const e=t[h];let n=u,p=u+this._computeAngle(h,i,g),m=o.getDataVisibility(h)?r.getDistanceFromCenterForValue(this.getParsed(h).r):0;u=p,s&&(a.animateScale&&(m=0),a.animateRotate&&(n=p=d));const f={x:l,y:c,innerRadius:0,outerRadius:m,startAngle:n,endAngle:p,options:this.resolveDataElementOptions(h,e.active?"active":i)};this.updateElement(e,h,f,i)}}countVisibleElements(){const t=this._cachedMeta;let e=0;return t.data.forEach(((t,n)=>{!isNaN(this.getParsed(n).r)&&this.chart.getDataVisibility(n)&&e++})),e}_computeAngle(t,e,n){return this.chart.getDataVisibility(t)?Ut(this.resolveDataElementOptions(t,e).angle||n):0}}var Pi=Object.freeze({__proto__:null,BarController:_i,BubbleController:class extends bi{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,n,i){const s=super.parsePrimitiveData(t,e,n,i);for(let t=0;t<s.length;t++)s[t]._custom=this.resolveDataElementOptions(t+n).radius;return s}parseArrayData(t,e,n,i){const s=super.parseArrayData(t,e,n,i);for(let t=0;t<s.length;t++){const i=e[n+t];s[t]._custom=ft(i[2],this.resolveDataElementOptions(t+n).radius)}return s}parseObjectData(t,e,n,i){const s=super.parseObjectData(t,e,n,i);for(let t=0;t<s.length;t++){const i=e[n+t];s[t]._custom=ft(i&&i.r&&+i.r,this.resolveDataElementOptions(t+n).radius)}return s}getMaxOverflow(){const t=this._cachedMeta.data;let e=0;for(let n=t.length-1;n>=0;--n)e=Math.max(e,t[n].size(this.resolveDataElementOptions(n))/2);return e>0&&e}getLabelAndValue(t){const e=this._cachedMeta,n=this.chart.data.labels||[],{xScale:i,yScale:s}=e,o=this.getParsed(t),a=i.getLabelForValue(o.x),r=s.getLabelForValue(o.y),l=o._custom;return{label:n[t]||"",value:"("+a+", "+r+(l?", "+l:"")+")"}}update(t){const e=this._cachedMeta.data;this.updateElements(e,0,e.length,t)}updateElements(t,e,n,i){const s="reset"===i,{iScale:o,vScale:a}=this._cachedMeta,{sharedOptions:r,includeOptions:l}=this._getSharedOptions(e,i),c=o.axis,d=a.axis;for(let h=e;h<e+n;h++){const e=t[h],n=!s&&this.getParsed(h),u={},g=u[c]=s?o.getPixelForDecimal(.5):o.getPixelForValue(n[c]),p=u[d]=s?a.getBasePixel():a.getPixelForValue(n[d]);u.skip=isNaN(g)||isNaN(p),l&&(u.options=r||this.resolveDataElementOptions(h,e.active?"active":i),s&&(u.options.radius=0)),this.updateElement(e,h,u,i)}}resolveDataElementOptions(t,e){const n=this.getParsed(t);let i=super.resolveDataElementOptions(t,e);i.$shared&&(i=Object.assign({},i,{$shared:!1}));const s=i.radius;return"active"!==e&&(i.radius=0),i.radius+=ft(n&&n._custom,s),i}},DoughnutController:Ti,LineController:class extends bi{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:n,data:i=[],_dataset:s}=e,o=this.chart._animationsDisabled;let{start:a,count:r}=ge(e,i,o);this._drawStart=a,this._drawCount=r,pe(e)&&(a=0,r=i.length),n._chart=this.chart,n._datasetIndex=this.index,n._decimated=!!s._decimated,n.points=i;const l=this.resolveDatasetElementOptions(t);this.options.showLine||(l.borderWidth=0),l.segment=this.options.segment,this.updateElement(n,void 0,{animated:!o,options:l},t),this.updateElements(i,a,r,t)}updateElements(t,e,n,i){const s="reset"===i,{iScale:o,vScale:a,_stacked:r,_dataset:l}=this._cachedMeta,{sharedOptions:c,includeOptions:d}=this._getSharedOptions(e,i),h=o.axis,u=a.axis,{spanGaps:g,segment:p}=this.options,m=Yt(g)?g:Number.POSITIVE_INFINITY,f=this.chart._animationsDisabled||s||"none"===i,b=e+n,y=t.length;let x=e>0&&this.getParsed(e-1);for(let n=0;n<y;++n){const g=t[n],y=f?g:{};if(n<e||n>=b){y.skip=!0;continue}const v=this.getParsed(n),w=ht(v[u]),k=y[h]=o.getPixelForValue(v[h],n),S=y[u]=s||w?a.getBasePixel():a.getPixelForValue(r?this.applyStack(a,v,r):v[u],n);y.skip=isNaN(k)||isNaN(S)||w,y.stop=n>0&&Math.abs(v[h]-x[h])>m,p&&(y.parsed=v,y.raw=l.data[n]),d&&(y.options=c||this.resolveDataElementOptions(n,g.active?"active":i)),f||this.updateElement(g,n,y,i),x=v}}getMaxOverflow(){const t=this._cachedMeta,e=t.dataset,n=e.options&&e.options.borderWidth||0,i=t.data||[];if(!i.length)return n;const s=i[0].size(this.resolveDataElementOptions(0)),o=i[i.length-1].size(this.resolveDataElementOptions(i.length-1));return Math.max(n,s,o)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}},PieController:class extends Ti{static id="pie";static defaults={cutout:0,rotation:0,circumference:360,radius:"100%"}},PolarAreaController:Di,RadarController:class extends bi{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,n=this.getParsed(t);return{label:e.getLabels()[t],value:""+e.getLabelForValue(n[e.axis])}}parseObjectData(t,e,n,i){return xn.bind(this)(t,e,n,i)}update(t){const e=this._cachedMeta,n=e.dataset,i=e.data||[],s=e.iScale.getLabels();if(n.points=i,"resize"!==t){const e=this.resolveDatasetElementOptions(t);this.options.showLine||(e.borderWidth=0);const o={_loop:!0,_fullLoop:s.length===i.length,options:e};this.updateElement(n,void 0,o,t)}this.updateElements(i,0,i.length,t)}updateElements(t,e,n,i){const s=this._cachedMeta.rScale,o="reset"===i;for(let a=e;a<e+n;a++){const e=t[a],n=this.resolveDataElementOptions(a,e.active?"active":i),r=s.getPointPositionForValue(a,this.getParsed(a).r),l=o?s.xCenter:r.x,c=o?s.yCenter:r.y,d={x:l,y:c,angle:r.angle,skip:isNaN(l)||isNaN(c),options:n};this.updateElement(e,a,d,i)}}},ScatterController:class extends bi{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,n=this.chart.data.labels||[],{xScale:i,yScale:s}=e,o=this.getParsed(t),a=i.getLabelForValue(o.x),r=s.getLabelForValue(o.y);return{label:n[t]||"",value:"("+a+", "+r+")"}}update(t){const e=this._cachedMeta,{data:n=[]}=e,i=this.chart._animationsDisabled;let{start:s,count:o}=ge(e,n,i);if(this._drawStart=s,this._drawCount=o,pe(e)&&(s=0,o=n.length),this.options.showLine){this.datasetElementType||this.addElements();const{dataset:s,_dataset:o}=e;s._chart=this.chart,s._datasetIndex=this.index,s._decimated=!!o._decimated,s.points=n;const a=this.resolveDatasetElementOptions(t);a.segment=this.options.segment,this.updateElement(s,void 0,{animated:!i,options:a},t)}else this.datasetElementType&&(delete e.dataset,this.datasetElementType=!1);this.updateElements(n,s,o,t)}addElements(){const{showLine:t}=this.options;!this.datasetElementType&&t&&(this.datasetElementType=this.chart.registry.getElement("line")),super.addElements()}updateElements(t,e,n,i){const s="reset"===i,{iScale:o,vScale:a,_stacked:r,_dataset:l}=this._cachedMeta,c=this.resolveDataElementOptions(e,i),d=this.getSharedOptions(c),h=this.includeOptions(i,d),u=o.axis,g=a.axis,{spanGaps:p,segment:m}=this.options,f=Yt(p)?p:Number.POSITIVE_INFINITY,b=this.chart._animationsDisabled||s||"none"===i;let y=e>0&&this.getParsed(e-1);for(let c=e;c<e+n;++c){const e=t[c],n=this.getParsed(c),p=b?e:{},x=ht(n[g]),v=p[u]=o.getPixelForValue(n[u],c),w=p[g]=s||x?a.getBasePixel():a.getPixelForValue(r?this.applyStack(a,n,r):n[g],c);p.skip=isNaN(v)||isNaN(w)||x,p.stop=c>0&&Math.abs(n[u]-y[u])>f,m&&(p.parsed=n,p.raw=l.data[c]),h&&(p.options=d||this.resolveDataElementOptions(c,e.active?"active":i)),b||this.updateElement(e,c,p,i),y=n}this.updateSharedOptions(d,i,c)}getMaxOverflow(){const t=this._cachedMeta,e=t.data||[];if(!this.options.showLine){let t=0;for(let n=e.length-1;n>=0;--n)t=Math.max(t,e[n].size(this.resolveDataElementOptions(n))/2);return t>0&&t}const n=t.dataset,i=n.options&&n.options.borderWidth||0;if(!e.length)return i;const s=e[0].size(this.resolveDataElementOptions(0)),o=e[e.length-1].size(this.resolveDataElementOptions(e.length-1));return Math.max(i,s,o)/2}}});function Ei(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class Li{static override(t){Object.assign(Li.prototype,t)}options;constructor(t){this.options=t||{}}init(){}formats(){return Ei()}parse(){return Ei()}format(){return Ei()}add(){return Ei()}diff(){return Ei()}startOf(){return Ei()}endOf(){return Ei()}}var Ai={_date:Li};function Ii(t,e,n,i){const{controller:s,data:o,_sorted:a}=t,r=s._cachedMeta.iScale,l=t.dataset&&t.dataset.options?t.dataset.options.spanGaps:null;if(r&&e===r.axis&&"r"!==e&&a&&o.length){const a=r._reversePixels?oe:se;if(!i){const i=a(o,e,n);if(l){const{vScale:e}=s._cachedMeta,{_parsed:n}=t,o=n.slice(0,i.lo+1).reverse().findIndex((t=>!ht(t[e.axis])));i.lo-=Math.max(0,o);const a=n.slice(i.hi).findIndex((t=>!ht(t[e.axis])));i.hi+=Math.max(0,a)}return i}if(s._sharedOptions){const t=o[0],i="function"==typeof t.getRange&&t.getRange(e);if(i){const t=a(o,e,n-i),s=a(o,e,n+i);return{lo:t.lo,hi:s.hi}}}}return{lo:0,hi:o.length-1}}function zi(t,e,n,i,s){const o=t.getSortedVisibleDatasetMetas(),a=n[e];for(let t=0,n=o.length;t<n;++t){const{index:n,data:r}=o[t],{lo:l,hi:c}=Ii(o[t],e,a,s);for(let t=l;t<=c;++t){const e=r[t];e.skip||i(e,n,t)}}}function Oi(t,e,n,i,s){const o=[];if(!s&&!t.isPointInArea(e))return o;return zi(t,n,e,(function(n,a,r){(s||Fe(n,t.chartArea,0))&&n.inRange(e.x,e.y,i)&&o.push({element:n,datasetIndex:a,index:r})}),!0),o}function Wi(t,e,n,i,s,o){let a=[];const r=function(t){const e=-1!==t.indexOf("x"),n=-1!==t.indexOf("y");return function(t,i){const s=e?Math.abs(t.x-i.x):0,o=n?Math.abs(t.y-i.y):0;return Math.sqrt(Math.pow(s,2)+Math.pow(o,2))}}(n);let l=Number.POSITIVE_INFINITY;return zi(t,n,e,(function(n,c,d){const h=n.inRange(e.x,e.y,s);if(i&&!h)return;const u=n.getCenterPoint(s);if(!(!!o||t.isPointInArea(u))&&!h)return;const g=r(e,u);g<l?(a=[{element:n,datasetIndex:c,index:d}],l=g):g===l&&a.push({element:n,datasetIndex:c,index:d})})),a}function Ni(t,e,n,i,s,o){return o||t.isPointInArea(e)?"r"!==n||i?Wi(t,e,n,i,s,o):function(t,e,n,i){let s=[];return zi(t,n,e,(function(t,n,o){const{startAngle:a,endAngle:r}=t.getProps(["startAngle","endAngle"],i),{angle:l}=Gt(t,{x:e.x,y:e.y});te(l,a,r)&&s.push({element:t,datasetIndex:n,index:o})})),s}(t,e,n,s):[]}function Ri(t,e,n,i,s){const o=[],a="x"===n?"inXRange":"inYRange";let r=!1;return zi(t,n,e,((t,i,l)=>{t[a]&&t[a](e[n],s)&&(o.push({element:t,datasetIndex:i,index:l}),r=r||t.inRange(e.x,e.y,s))})),i&&!r?[]:o}var $i={evaluateInteractionItems:zi,modes:{index(t,e,n,i){const s=In(e,t),o=n.axis||"x",a=n.includeInvisible||!1,r=n.intersect?Oi(t,s,o,i,a):Ni(t,s,o,!1,i,a),l=[];return r.length?(t.getSortedVisibleDatasetMetas().forEach((t=>{const e=r[0].index,n=t.data[e];n&&!n.skip&&l.push({element:n,datasetIndex:t.index,index:e})})),l):[]},dataset(t,e,n,i){const s=In(e,t),o=n.axis||"xy",a=n.includeInvisible||!1;let r=n.intersect?Oi(t,s,o,i,a):Ni(t,s,o,!1,i,a);if(r.length>0){const e=r[0].datasetIndex,n=t.getDatasetMeta(e).data;r=[];for(let t=0;t<n.length;++t)r.push({element:n[t],datasetIndex:e,index:t})}return r},point:(t,e,n,i)=>Oi(t,In(e,t),n.axis||"xy",i,n.includeInvisible||!1),nearest(t,e,n,i){const s=In(e,t),o=n.axis||"xy",a=n.includeInvisible||!1;return Ni(t,s,o,n.intersect,i,a)},x:(t,e,n,i)=>Ri(t,In(e,t),"x",n.intersect,i),y:(t,e,n,i)=>Ri(t,In(e,t),"y",n.intersect,i)}};const Fi=["left","top","right","bottom"];function Bi(t,e){return t.filter((t=>t.pos===e))}function qi(t,e){return t.filter((t=>-1===Fi.indexOf(t.pos)&&t.box.axis===e))}function Hi(t,e){return t.sort(((t,n)=>{const i=e?n:t,s=e?t:n;return i.weight===s.weight?i.index-s.index:i.weight-s.weight}))}function Vi(t,e){const n=function(t){const e={};for(const n of t){const{stack:t,pos:i,stackWeight:s}=n;if(!t||!Fi.includes(i))continue;const o=e[t]||(e[t]={count:0,placed:0,weight:0,size:0});o.count++,o.weight+=s}return e}(t),{vBoxMaxWidth:i,hBoxMaxHeight:s}=e;let o,a,r;for(o=0,a=t.length;o<a;++o){r=t[o];const{fullSize:a}=r.box,l=n[r.stack],c=l&&r.stackWeight/l.weight;r.horizontal?(r.width=c?c*i:a&&e.availableWidth,r.height=s):(r.width=i,r.height=c?c*s:a&&e.availableHeight)}return n}function Yi(t,e,n,i){return Math.max(t[n],e[n])+Math.max(t[i],e[i])}function ji(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 Ui(t,e,n,i){const{pos:s,box:o}=n,a=t.maxPadding;if(!gt(s)){n.size&&(t[s]-=n.size);const e=i[n.stack]||{size:0,count:1};e.size=Math.max(e.size,n.horizontal?o.height:o.width),n.size=e.size/e.count,t[s]+=n.size}o.getPadding&&ji(a,o.getPadding());const r=Math.max(0,e.outerWidth-Yi(a,t,"left","right")),l=Math.max(0,e.outerHeight-Yi(a,t,"top","bottom")),c=r!==t.w,d=l!==t.h;return t.w=r,t.h=l,n.horizontal?{same:c,other:d}:{same:d,other:c}}function Xi(t,e){const n=e.maxPadding;function i(t){const i={left:0,top:0,right:0,bottom:0};return t.forEach((t=>{i[t]=Math.max(e[t],n[t])})),i}return i(t?["left","right"]:["top","bottom"])}function Qi(t,e,n,i){const s=[];let o,a,r,l,c,d;for(o=0,a=t.length,c=0;o<a;++o){r=t[o],l=r.box,l.update(r.width||e.w,r.height||e.h,Xi(r.horizontal,e));const{same:a,other:h}=Ui(e,n,r,i);c|=a&&s.length,d=d||h,l.fullSize||s.push(r)}return c&&Qi(s,e,n,i)||d}function Gi(t,e,n,i,s){t.top=n,t.left=e,t.right=e+i,t.bottom=n+s,t.width=i,t.height=s}function Ki(t,e,n,i){const s=n.padding;let{x:o,y:a}=e;for(const r of t){const t=r.box,l=i[r.stack]||{count:1,placed:0,weight:1},c=r.stackWeight/l.weight||1;if(r.horizontal){const i=e.w*c,o=l.size||t.height;Et(l.start)&&(a=l.start),t.fullSize?Gi(t,s.left,a,n.outerWidth-s.right-s.left,o):Gi(t,e.left+l.placed,a,i,o),l.start=a,l.placed+=i,a=t.bottom}else{const i=e.h*c,a=l.size||t.width;Et(l.start)&&(o=l.start),t.fullSize?Gi(t,o,s.top,a,n.outerHeight-s.bottom-s.top):Gi(t,o,e.top+l.placed,a,i),l.start=o,l.placed+=i,o=t.right}}e.x=o,e.y=a}var Zi={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 n=t.boxes?t.boxes.indexOf(e):-1;-1!==n&&t.boxes.splice(n,1)},configure(t,e,n){e.fullSize=n.fullSize,e.position=n.position,e.weight=n.weight},update(t,e,n,i){if(!t)return;const s=en(t.options.layout.padding),o=Math.max(e-s.width,0),a=Math.max(n-s.height,0),r=function(t){const e=function(t){const e=[];let n,i,s,o,a,r;for(n=0,i=(t||[]).length;n<i;++n)s=t[n],({position:o,options:{stack:a,stackWeight:r=1}}=s),e.push({index:n,box:s,pos:o,horizontal:s.isHorizontal(),weight:s.weight,stack:a&&o+a,stackWeight:r});return e}(t),n=Hi(e.filter((t=>t.box.fullSize)),!0),i=Hi(Bi(e,"left"),!0),s=Hi(Bi(e,"right")),o=Hi(Bi(e,"top"),!0),a=Hi(Bi(e,"bottom")),r=qi(e,"x"),l=qi(e,"y");return{fullSize:n,leftAndTop:i.concat(o),rightAndBottom:s.concat(l).concat(a).concat(r),chartArea:Bi(e,"chartArea"),vertical:i.concat(s).concat(l),horizontal:o.concat(a).concat(r)}}(t.boxes),l=r.vertical,c=r.horizontal;xt(t.boxes,(t=>{"function"==typeof t.beforeLayout&&t.beforeLayout()}));const d=l.reduce(((t,e)=>e.box.options&&!1===e.box.options.display?t:t+1),0)||1,h=Object.freeze({outerWidth:e,outerHeight:n,padding:s,availableWidth:o,availableHeight:a,vBoxMaxWidth:o/2/d,hBoxMaxHeight:a/2}),u=Object.assign({},s);ji(u,en(i));const g=Object.assign({maxPadding:u,w:o,h:a,x:s.left,y:s.top},s),p=Vi(l.concat(c),h);Qi(r.fullSize,g,h,p),Qi(l,g,h,p),Qi(c,g,h,p)&&Qi(l,g,h,p),function(t){const e=t.maxPadding;function n(n){const i=Math.max(e[n]-t[n],0);return t[n]+=i,i}t.y+=n("top"),t.x+=n("left"),n("right"),n("bottom")}(g),Ki(r.leftAndTop,g,h,p),g.x+=g.w,g.y+=g.h,Ki(r.rightAndBottom,g,h,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},xt(r.chartArea,(e=>{const n=e.box;Object.assign(n,t.chartArea),n.update(g.w,g.h,{left:0,top:0,right:0,bottom:0})}))}};class Ji{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,n){}removeEventListener(t,e,n){}getDevicePixelRatio(){return 1}getMaximumSize(t,e,n,i){return e=Math.max(0,e||t.width),n=n||t.height,{width:e,height:Math.max(0,i?Math.floor(e/i):n)}}isAttached(t){return!0}updateConfig(t){}}class ts extends Ji{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const es="$chartjs",ns={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},is=t=>null===t||""===t;const ss=!!Nn&&{passive:!0};function os(t,e,n){t&&t.canvas&&t.canvas.removeEventListener(e,n,ss)}function as(t,e){for(const n of t)if(n===e||n.contains(e))return!0}function rs(t,e,n){const i=t.canvas,s=new MutationObserver((t=>{let e=!1;for(const n of t)e=e||as(n.addedNodes,i),e=e&&!as(n.removedNodes,i);e&&n()}));return s.observe(document,{childList:!0,subtree:!0}),s}function ls(t,e,n){const i=t.canvas,s=new MutationObserver((t=>{let e=!1;for(const n of t)e=e||as(n.removedNodes,i),e=e&&!as(n.addedNodes,i);e&&n()}));return s.observe(document,{childList:!0,subtree:!0}),s}const cs=new Map;let ds=0;function hs(){const t=window.devicePixelRatio;t!==ds&&(ds=t,cs.forEach(((e,n)=>{n.currentDevicePixelRatio!==t&&e()})))}function us(t,e,n){const i=t.canvas,s=i&&Dn(i);if(!s)return;const o=de(((t,e)=>{const i=s.clientWidth;n(t,e),i<s.clientWidth&&n()}),window),a=new ResizeObserver((t=>{const e=t[0],n=e.contentRect.width,i=e.contentRect.height;0===n&&0===i||o(n,i)}));return a.observe(s),function(t,e){cs.size||window.addEventListener("resize",hs),cs.set(t,e)}(t,o),a}function gs(t,e,n){n&&n.disconnect(),"resize"===e&&function(t){cs.delete(t),cs.size||window.removeEventListener("resize",hs)}(t)}function ps(t,e,n){const i=t.canvas,s=de((e=>{null!==t.ctx&&n(function(t,e){const n=ns[t.type]||t.type,{x:i,y:s}=In(t,e);return{type:n,chart:e,native:t,x:void 0!==i?i:null,y:void 0!==s?s:null}}(e,t))}),t);return function(t,e,n){t&&t.addEventListener(e,n,ss)}(i,e,s),s}class ms extends Ji{acquireContext(t,e){const n=t&&t.getContext&&t.getContext("2d");return n&&n.canvas===t?(function(t,e){const n=t.style,i=t.getAttribute("height"),s=t.getAttribute("width");if(t[es]={initial:{height:i,width:s,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||"block",n.boxSizing=n.boxSizing||"border-box",is(s)){const e=Rn(t,"width");void 0!==e&&(t.width=e)}if(is(i))if(""===t.style.height)t.height=t.width/(e||2);else{const e=Rn(t,"height");void 0!==e&&(t.height=e)}}(t,e),n):null}releaseContext(t){const e=t.canvas;if(!e[es])return!1;const n=e[es].initial;["height","width"].forEach((t=>{const i=n[t];ht(i)?e.removeAttribute(t):e.setAttribute(t,i)}));const i=n.style||{};return Object.keys(i).forEach((t=>{e.style[t]=i[t]})),e.width=e.width,delete e[es],!0}addEventListener(t,e,n){this.removeEventListener(t,e);const i=t.$proxies||(t.$proxies={}),s={attach:rs,detach:ls,resize:us}[e]||ps;i[e]=s(t,e,n)}removeEventListener(t,e){const n=t.$proxies||(t.$proxies={}),i=n[e];if(!i)return;({attach:gs,detach:gs,resize:gs}[e]||os)(t,e,i),n[e]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,n,i){return On(t,e,n,i)}isAttached(t){const e=t&&Dn(t);return!(!e||!e.isConnected)}}class fs{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(t){const{x:e,y:n}=this.getProps(["x","y"],t);return{x:e,y:n}}hasValue(){return Yt(this.x)&&Yt(this.y)}getProps(t,e){const n=this.$animations;if(!e||!n)return this;const i={};return t.forEach((t=>{i[t]=n[t]&&n[t].active()?n[t]._to:this[t]})),i}}function bs(t,e){const n=t.options.ticks,i=function(t){const e=t.options.offset,n=t._tickSize(),i=t._length/n+(e?0:1),s=t._maxLength/n;return Math.floor(Math.min(i,s))}(t),s=Math.min(n.maxTicksLimit||i,i),o=n.major.enabled?function(t){const e=[];let n,i;for(n=0,i=t.length;n<i;n++)t[n].major&&e.push(n);return e}(e):[],a=o.length,r=o[0],l=o[a-1],c=[];if(a>s)return function(t,e,n,i){let s,o=0,a=n[0];for(i=Math.ceil(i),s=0;s<t.length;s++)s===a&&(e.push(t[s]),o++,a=n[o*i])}(e,c,o,a/s),c;const d=function(t,e,n){const i=function(t){const e=t.length;let n,i;if(e<2)return!1;for(i=t[0],n=1;n<e;++n)if(t[n]-t[n-1]!==i)return!1;return i}(t),s=e.length/n;if(!i)return Math.max(s,1);const o=function(t){const e=[],n=Math.sqrt(t);let i;for(i=1;i<n;i++)t%i===0&&(e.push(i),e.push(t/i));return n===(0|n)&&e.push(n),e.sort(((t,e)=>t-e)).pop(),e}(i);for(let t=0,e=o.length-1;t<e;t++){const e=o[t];if(e>s)return e}return Math.max(s,1)}(o,e,s);if(a>0){let t,n;const i=a>1?Math.round((l-r)/(a-1)):null;for(ys(e,c,d,ht(i)?0:r-i,r),t=0,n=a-1;t<n;t++)ys(e,c,d,o[t],o[t+1]);return ys(e,c,d,l,ht(i)?e.length:l+i),c}return ys(e,c,d),c}function ys(t,e,n,i,s){const o=ft(i,0),a=Math.min(ft(s,t.length),t.length);let r,l,c,d=0;for(n=Math.ceil(n),s&&(r=s-i,n=r/Math.floor(r/n)),c=o;c<0;)d++,c=Math.round(o+d*n);for(l=Math.max(o,0);l<a;l++)l===c&&(e.push(t[l]),d++,c=Math.round(o+d*n))}const xs=(t,e,n)=>"top"===e||"left"===e?t[e]+n:t[e]-n,vs=(t,e)=>Math.min(e||t,t);function ws(t,e){const n=[],i=t.length/e,s=t.length;let o=0;for(;o<s;o+=i)n.push(t[Math.floor(o)]);return n}function ks(t,e,n){const i=t.ticks.length,s=Math.min(e,i-1),o=t._startPixel,a=t._endPixel,r=1e-6;let l,c=t.getPixelForTick(s);if(!(n&&(l=1===i?Math.max(c-o,a-c):0===e?(t.getPixelForTick(1)-c)/2:(c-t.getPixelForTick(s-1))/2,c+=s<e?l:-l,c<o-r||c>a+r)))return c}function Ss(t){return t.drawTicks?t.tickLength:0}function Ms(t,e){if(!t.display)return 0;const n=nn(t.font,e),i=en(t.padding);return(ut(t.text)?t.text.length:1)*n.lineHeight+i.height}function Cs(t,e,n){let i=he(t);return(n&&"right"!==e||!n&&"right"===e)&&(i=(t=>"left"===t?"right":"right"===t?"left":t)(i)),i}class _s extends fs{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:n,_suggestedMax:i}=this;return t=mt(t,Number.POSITIVE_INFINITY),e=mt(e,Number.NEGATIVE_INFINITY),n=mt(n,Number.POSITIVE_INFINITY),i=mt(i,Number.NEGATIVE_INFINITY),{min:mt(t,n),max:mt(e,i),minDefined:pt(t),maxDefined:pt(e)}}getMinMax(t){let e,{min:n,max:i,minDefined:s,maxDefined:o}=this.getUserBounds();if(s&&o)return{min:n,max:i};const a=this.getMatchingVisibleMetas();for(let r=0,l=a.length;r<l;++r)e=a[r].controller.getMinMax(this,t),s||(n=Math.min(n,e.min)),o||(i=Math.max(i,e.max));return n=o&&n>i?i:n,i=s&&n>i?n:i,{min:mt(n,mt(i,n)),max:mt(i,mt(n,i))}}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(){yt(this.options.beforeUpdate,[this])}update(t,e,n){const{beginAtZero:i,grace:s,ticks:o}=this.options,a=o.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=n=Object.assign({left:0,right:0,top:0,bottom:0},n),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+n.left+n.right:this.height+n.top+n.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=function(t,e,n){const{min:i,max:s}=t,o=bt(e,(s-i)/2),a=(t,e)=>n&&0===t?0:t+e;return{min:a(i,-Math.abs(o)),max:a(s,o)}}(this,s,i),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const r=a<this.ticks.length;this._convertTicksToLabels(r?ws(this.ticks,a):this.ticks),this.configure(),this.beforeCalculateLabelRotation(),this.calculateLabelRotation(),this.afterCalculateLabelRotation(),o.display&&(o.autoSkip||"auto"===o.source)&&(this.ticks=bs(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,n=this.options.reverse;this.isHorizontal()?(t=this.left,e=this.right):(t=this.top,e=this.bottom,n=!n),this._startPixel=t,this._endPixel=e,this._reversePixels=n,this._length=e-t,this._alignToPixels=this.options.alignToPixels}afterUpdate(){yt(this.options.afterUpdate,[this])}beforeSetDimensions(){yt(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(){yt(this.options.afterSetDimensions,[this])}_callHooks(t){this.chart.notifyPlugins(t,this.getContext()),yt(this.options[t],[this])}beforeDataLimits(){this._callHooks("beforeDataLimits")}determineDataLimits(){}afterDataLimits(){this._callHooks("afterDataLimits")}beforeBuildTicks(){this._callHooks("beforeBuildTicks")}buildTicks(){return[]}afterBuildTicks(){this._callHooks("afterBuildTicks")}beforeTickToLabelConversion(){yt(this.options.beforeTickToLabelConversion,[this])}generateTickLabels(t){const e=this.options.ticks;let n,i,s;for(n=0,i=t.length;n<i;n++)s=t[n],s.label=yt(e.callback,[s.value,n,t],this)}afterTickToLabelConversion(){yt(this.options.afterTickToLabelConversion,[this])}beforeCalculateLabelRotation(){yt(this.options.beforeCalculateLabelRotation,[this])}calculateLabelRotation(){const t=this.options,e=t.ticks,n=vs(this.ticks.length,t.ticks.maxTicksLimit),i=e.minRotation||0,s=e.maxRotation;let o,a,r,l=i;if(!this._isVisible()||!e.display||i>=s||n<=1||!this.isHorizontal())return void(this.labelRotation=i);const c=this._getLabelSizes(),d=c.widest.width,h=c.highest.height,u=ee(this.chart.width-d,0,this.maxWidth);o=t.offset?this.maxWidth/n:u/(n-1),d+6>o&&(o=u/(n-(t.offset?.5:1)),a=this.maxHeight-Ss(t.grid)-e.padding-Ms(t.title,this.chart.options.font),r=Math.sqrt(d*d+h*h),l=Xt(Math.min(Math.asin(ee((c.highest.height+6)/o,-1,1)),Math.asin(ee(a/r,-1,1))-Math.asin(ee(h/r,-1,1)))),l=Math.max(i,Math.min(s,l))),this.labelRotation=l}afterCalculateLabelRotation(){yt(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){yt(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:e,options:{ticks:n,title:i,grid:s}}=this,o=this._isVisible(),a=this.isHorizontal();if(o){const o=Ms(i,e.options.font);if(a?(t.width=this.maxWidth,t.height=Ss(s)+o):(t.height=this.maxHeight,t.width=Ss(s)+o),n.display&&this.ticks.length){const{first:e,last:i,widest:s,highest:o}=this._getLabelSizes(),r=2*n.padding,l=Ut(this.labelRotation),c=Math.cos(l),d=Math.sin(l);if(a){const e=n.mirror?0:d*s.width+c*o.height;t.height=Math.min(this.maxHeight,t.height+e+r)}else{const e=n.mirror?0:c*s.width+d*o.height;t.width=Math.min(this.maxWidth,t.width+e+r)}this._calculatePadding(e,i,d,c)}}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,n,i){const{ticks:{align:s,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,c=this.right-this.getPixelForTick(this.ticks.length-1);let d=0,h=0;r?l?(d=i*t.width,h=n*e.height):(d=n*t.height,h=i*e.width):"start"===s?h=e.width:"end"===s?d=t.width:"inner"!==s&&(d=t.width/2,h=e.width/2),this.paddingLeft=Math.max((d-a+o)*this.width/(this.width-a),0),this.paddingRight=Math.max((h-c+o)*this.width/(this.width-c),0)}else{let n=e.height/2,i=t.height/2;"start"===s?(n=0,i=t.height):"end"===s&&(n=e.height,i=0),this.paddingTop=n+o,this.paddingBottom=i+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(){yt(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,n;for(this.beforeTickToLabelConversion(),this.generateTickLabels(t),e=0,n=t.length;e<n;e++)ht(t[e].label)&&(t.splice(e,1),n--,e--);this.afterTickToLabelConversion()}_getLabelSizes(){let t=this._labelSizes;if(!t){const e=this.options.ticks.sampleSize;let n=this.ticks;e<n.length&&(n=ws(n,e)),this._labelSizes=t=this._computeLabelSizes(n,n.length,this.options.ticks.maxTicksLimit)}return t}_computeLabelSizes(t,e,n){const{ctx:i,_longestTextCache:s}=this,o=[],a=[],r=Math.floor(e/vs(e,n));let l,c,d,h,u,g,p,m,f,b,y,x=0,v=0;for(l=0;l<e;l+=r){if(h=t[l].label,u=this._resolveTickFontOptions(l),i.font=g=u.string,p=s[g]=s[g]||{data:{},gc:[]},m=u.lineHeight,f=b=0,ht(h)||ut(h)){if(ut(h))for(c=0,d=h.length;c<d;++c)y=h[c],ht(y)||ut(y)||(f=ze(i,p.data,p.gc,f,y),b+=m)}else f=ze(i,p.data,p.gc,f,h),b=m;o.push(f),a.push(b),x=Math.max(f,x),v=Math.max(b,v)}!function(t,e){xt(t,(t=>{const n=t.gc,i=n.length/2;let s;if(i>e){for(s=0;s<i;++s)delete t.data[n[s]];n.splice(0,i)}}))}(s,e);const w=o.indexOf(x),k=a.indexOf(v),S=t=>({width:o[t]||0,height:a[t]||0});return{first:S(0),last:S(e-1),widest:S(w),highest:S(k),widths:o,heights:a}}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 ee(this._alignToPixels?We(this.chart,e,0):e,-32768,32767)}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 n=e[t];return n.$context||(n.$context=function(t,e,n){return on(t,{tick:n,index:e,type:"tick"})}(this.getContext(),t,n))}return this.$context||(this.$context=on(this.chart.getContext(),{scale:this,type:"scale"}))}_tickSize(){const t=this.options.ticks,e=Ut(this.labelRotation),n=Math.abs(Math.cos(e)),i=Math.abs(Math.sin(e)),s=this._getLabelSizes(),o=t.autoSkipPadding||0,a=s?s.widest.width+o:0,r=s?s.highest.height+o:0;return this.isHorizontal()?r*n>a*i?a/n:r/i:r*i<a*n?r/n:a/i}_isVisible(){const t=this.options.display;return"auto"!==t?!!t:this.getMatchingVisibleMetas().length>0}_computeGridLineItems(t){const e=this.axis,n=this.chart,i=this.options,{grid:s,position:o,border:a}=i,r=s.offset,l=this.isHorizontal(),c=this.ticks.length+(r?1:0),d=Ss(s),h=[],u=a.setContext(this.getContext()),g=u.display?u.width:0,p=g/2,m=function(t){return We(n,t,g)};let f,b,y,x,v,w,k,S,M,C,_,T;if("top"===o)f=m(this.bottom),w=this.bottom-d,S=f-p,C=m(t.top)+p,T=t.bottom;else if("bottom"===o)f=m(this.top),C=t.top,T=m(t.bottom)-p,w=f+p,S=this.top+d;else if("left"===o)f=m(this.right),v=this.right-d,k=f-p,M=m(t.left)+p,_=t.right;else if("right"===o)f=m(this.left),M=t.left,_=m(t.right)-p,v=f+p,k=this.left+d;else if("x"===e){if("center"===o)f=m((t.top+t.bottom)/2+.5);else if(gt(o)){const t=Object.keys(o)[0],e=o[t];f=m(this.chart.scales[t].getPixelForValue(e))}C=t.top,T=t.bottom,w=f+p,S=w+d}else if("y"===e){if("center"===o)f=m((t.left+t.right)/2);else if(gt(o)){const t=Object.keys(o)[0],e=o[t];f=m(this.chart.scales[t].getPixelForValue(e))}v=f-p,k=v-d,M=t.left,_=t.right}const D=ft(i.ticks.maxTicksLimit,c),P=Math.max(1,Math.ceil(c/D));for(b=0;b<c;b+=P){const t=this.getContext(b),e=s.setContext(t),i=a.setContext(t),o=e.lineWidth,c=e.color,d=i.dash||[],u=i.dashOffset,g=e.tickWidth,p=e.tickColor,m=e.tickBorderDash||[],f=e.tickBorderDashOffset;y=ks(this,b,r),void 0!==y&&(x=We(n,y,o),l?v=k=M=_=x:w=S=C=T=x,h.push({tx1:v,ty1:w,tx2:k,ty2:S,x1:M,y1:C,x2:_,y2:T,width:o,color:c,borderDash:d,borderDashOffset:u,tickWidth:g,tickColor:p,tickBorderDash:m,tickBorderDashOffset:f}))}return this._ticksLength=c,this._borderValue=f,h}_computeLabelItems(t){const e=this.axis,n=this.options,{position:i,ticks:s}=n,o=this.isHorizontal(),a=this.ticks,{align:r,crossAlign:l,padding:c,mirror:d}=s,h=Ss(n.grid),u=h+c,g=d?-c:u,p=-Ut(this.labelRotation),m=[];let f,b,y,x,v,w,k,S,M,C,_,T,D="middle";if("top"===i)w=this.bottom-g,k=this._getXAxisLabelAlignment();else if("bottom"===i)w=this.top+g,k=this._getXAxisLabelAlignment();else if("left"===i){const t=this._getYAxisLabelAlignment(h);k=t.textAlign,v=t.x}else if("right"===i){const t=this._getYAxisLabelAlignment(h);k=t.textAlign,v=t.x}else if("x"===e){if("center"===i)w=(t.top+t.bottom)/2+u;else if(gt(i)){const t=Object.keys(i)[0],e=i[t];w=this.chart.scales[t].getPixelForValue(e)+u}k=this._getXAxisLabelAlignment()}else if("y"===e){if("center"===i)v=(t.left+t.right)/2-u;else if(gt(i)){const t=Object.keys(i)[0],e=i[t];v=this.chart.scales[t].getPixelForValue(e)}k=this._getYAxisLabelAlignment(h).textAlign}"y"===e&&("start"===r?D="top":"end"===r&&(D="bottom"));const P=this._getLabelSizes();for(f=0,b=a.length;f<b;++f){y=a[f],x=y.label;const t=s.setContext(this.getContext(f));S=this.getPixelForTick(f)+s.labelOffset,M=this._resolveTickFontOptions(f),C=M.lineHeight,_=ut(x)?x.length:1;const e=_/2,n=t.color,r=t.textStrokeColor,c=t.textStrokeWidth;let h,u=k;if(o?(v=S,"inner"===k&&(u=f===b-1?this.options.reverse?"left":"right":0===f?this.options.reverse?"right":"left":"center"),T="top"===i?"near"===l||0!==p?-_*C+C/2:"center"===l?-P.highest.height/2-e*C+C:-P.highest.height+C/2:"near"===l||0!==p?C/2:"center"===l?P.highest.height/2-e*C:P.highest.height-_*C,d&&(T*=-1),0===p||t.showLabelBackdrop||(v+=C/2*Math.sin(p))):(w=S,T=(1-_)*C/2),t.showLabelBackdrop){const e=en(t.backdropPadding),n=P.heights[f],i=P.widths[f];let s=T-e.top,o=0-e.left;switch(D){case"middle":s-=n/2;break;case"bottom":s-=n}switch(k){case"center":o-=i/2;break;case"right":o-=i;break;case"inner":f===b-1?o-=i:f>0&&(o-=i/2)}h={left:o,top:s,width:i+e.width,height:n+e.height,color:t.backdropColor}}m.push({label:x,font:M,textOffset:T,options:{rotation:p,color:n,strokeColor:r,strokeWidth:c,textAlign:u,textBaseline:D,translation:[v,w],backdrop:h}})}return m}_getXAxisLabelAlignment(){const{position:t,ticks:e}=this.options;if(-Ut(this.labelRotation))return"top"===t?"left":"right";let n="center";return"start"===e.align?n="left":"end"===e.align?n="right":"inner"===e.align&&(n="inner"),n}_getYAxisLabelAlignment(t){const{position:e,ticks:{crossAlign:n,mirror:i,padding:s}}=this.options,o=t+s,a=this._getLabelSizes().widest.width;let r,l;return"left"===e?i?(l=this.right+s,"near"===n?r="left":"center"===n?(r="center",l+=a/2):(r="right",l+=a)):(l=this.right-o,"near"===n?r="right":"center"===n?(r="center",l-=a/2):(r="left",l=this.left)):"right"===e?i?(l=this.left+s,"near"===n?r="right":"center"===n?(r="center",l-=a/2):(r="left",l-=a)):(l=this.left+o,"near"===n?r="left":"center"===n?(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:n,top:i,width:s,height:o}=this;e&&(t.save(),t.fillStyle=e,t.fillRect(n,i,s,o),t.restore())}getLineWidthForValue(t){const e=this.options.grid;if(!this._isVisible()||!e.display)return 0;const n=this.ticks.findIndex((e=>e.value===t));if(n>=0){return e.setContext(this.getContext(n)).lineWidth}return 0}drawGrid(t){const e=this.options.grid,n=this.ctx,i=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let s,o;const a=(t,e,i)=>{i.width&&i.color&&(n.save(),n.lineWidth=i.width,n.strokeStyle=i.color,n.setLineDash(i.borderDash||[]),n.lineDashOffset=i.borderDashOffset,n.beginPath(),n.moveTo(t.x,t.y),n.lineTo(e.x,e.y),n.stroke(),n.restore())};if(e.display)for(s=0,o=i.length;s<o;++s){const t=i[s];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:n,grid:i}}=this,s=n.setContext(this.getContext()),o=n.display?s.width:0;if(!o)return;const a=i.setContext(this.getContext(0)).lineWidth,r=this._borderValue;let l,c,d,h;this.isHorizontal()?(l=We(t,this.left,o)-o/2,c=We(t,this.right,a)+a/2,d=h=r):(d=We(t,this.top,o)-o/2,h=We(t,this.bottom,a)+a/2,l=c=r),e.save(),e.lineWidth=s.width,e.strokeStyle=s.color,e.beginPath(),e.moveTo(l,d),e.lineTo(c,h),e.stroke(),e.restore()}drawLabels(t){if(!this.options.ticks.display)return;const e=this.ctx,n=this._computeLabelArea();n&&Be(e,n);const i=this.getLabelItems(t);for(const t of i){const n=t.options,i=t.font;Ue(e,t.label,0,t.textOffset,i,n)}n&&qe(e)}drawTitle(){const{ctx:t,options:{position:e,title:n,reverse:i}}=this;if(!n.display)return;const s=nn(n.font),o=en(n.padding),a=n.align;let r=s.lineHeight/2;"bottom"===e||"center"===e||gt(e)?(r+=o.bottom,ut(n.text)&&(r+=s.lineHeight*(n.text.length-1))):r+=o.top;const{titleX:l,titleY:c,maxWidth:d,rotation:h}=function(t,e,n,i){const{top:s,left:o,bottom:a,right:r,chart:l}=t,{chartArea:c,scales:d}=l;let h,u,g,p=0;const m=a-s,f=r-o;if(t.isHorizontal()){if(u=ue(i,o,r),gt(n)){const t=Object.keys(n)[0],i=n[t];g=d[t].getPixelForValue(i)+m-e}else g="center"===n?(c.bottom+c.top)/2+m-e:xs(t,n,e);h=r-o}else{if(gt(n)){const t=Object.keys(n)[0],i=n[t];u=d[t].getPixelForValue(i)-f+e}else u="center"===n?(c.left+c.right)/2-f+e:xs(t,n,e);g=ue(i,a,s),p="left"===n?-Rt:Rt}return{titleX:u,titleY:g,maxWidth:h,rotation:p}}(this,r,e,a);Ue(t,n.text,0,0,s,{color:n.color,maxWidth:d,rotation:h,textAlign:Cs(a,e,i),textBaseline:"middle",translation:[l,c]})}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,n=ft(t.grid&&t.grid.z,-1),i=ft(t.border&&t.border.z,0);return this._isVisible()&&this.draw===_s.prototype.draw?[{z:n,draw:t=>{this.drawBackground(),this.drawGrid(t),this.drawTitle()}},{z:i,draw:()=>{this.drawBorder()}},{z:e,draw:t=>{this.drawLabels(t)}}]:[{z:e,draw:t=>{this.draw(t)}}]}getMatchingVisibleMetas(t){const e=this.chart.getSortedVisibleDatasetMetas(),n=this.axis+"AxisID",i=[];let s,o;for(s=0,o=e.length;s<o;++s){const o=e[s];o[n]!==this.id||t&&o.type!==t||i.push(o)}return i}_resolveTickFontOptions(t){return nn(this.options.ticks.setContext(this.getContext(t)).font)}_maxDigits(){const t=this._resolveTickFontOptions(0).lineHeight;return(this.isHorizontal()?this.width:this.height)/t}}class Ts{constructor(t,e,n){this.type=t,this.scope=e,this.override=n,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 n;(function(t){return"id"in t&&"defaults"in t})(e)&&(n=this.register(e));const i=this.items,s=t.id,o=this.scope+"."+s;if(!s)throw new Error("class does not have id: "+t);return s in i||(i[s]=t,function(t,e,n){const i=Mt(Object.create(null),[n?Ie.get(n):{},Ie.get(e),t.defaults]);Ie.set(e,i),t.defaultRoutes&&function(t,e){Object.keys(e).forEach((n=>{const i=n.split("."),s=i.pop(),o=[t].concat(i).join("."),a=e[n].split("."),r=a.pop(),l=a.join(".");Ie.route(o,s,l,r)}))}(e,t.defaultRoutes);t.descriptors&&Ie.describe(e,t.descriptors)}(t,o,n),this.override&&Ie.override(t.id,t.overrides)),o}get(t){return this.items[t]}unregister(t){const e=this.items,n=t.id,i=this.scope;n in e&&delete e[n],i&&n in Ie[i]&&(delete Ie[i][n],this.override&&delete De[n])}}class Ds{constructor(){this.controllers=new Ts(bi,"datasets",!0),this.elements=new Ts(fs,"elements"),this.plugins=new Ts(Object,"plugins"),this.scales=new Ts(_s,"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,n){[...e].forEach((e=>{const i=n||this._getRegistryForType(e);n||i.isForType(e)||i===this.plugins&&e.id?this._exec(t,i,e):xt(e,(e=>{const i=n||this._getRegistryForType(e);this._exec(t,i,e)}))}))}_exec(t,e,n){const i=Pt(t);yt(n["before"+i],[],n),e[t](n),yt(n["after"+i],[],n)}_getRegistryForType(t){for(let e=0;e<this._typedRegistries.length;e++){const n=this._typedRegistries[e];if(n.isForType(t))return n}return this.plugins}_get(t,e,n){const i=e.get(t);if(void 0===i)throw new Error('"'+t+'" is not a registered '+n+".");return i}}var Ps=new Ds;class Es{constructor(){this._init=void 0}notify(t,e,n,i){if("beforeInit"===e&&(this._init=this._createDescriptors(t,!0),this._notify(this._init,t,"install")),void 0===this._init)return;const s=i?this._descriptors(t).filter(i):this._descriptors(t),o=this._notify(s,t,e,n);return"afterDestroy"===e&&(this._notify(s,t,"stop"),this._notify(this._init,t,"uninstall"),this._init=void 0),o}_notify(t,e,n,i){i=i||{};for(const s of t){const t=s.plugin;if(!1===yt(t[n],[e,i,s.options],t)&&i.cancelable)return!1}return!0}invalidate(){ht(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 n=t&&t.config,i=ft(n.options&&n.options.plugins,{}),s=function(t){const e={},n=[],i=Object.keys(Ps.plugins.items);for(let t=0;t<i.length;t++)n.push(Ps.getPlugin(i[t]));const s=t.plugins||[];for(let t=0;t<s.length;t++){const i=s[t];-1===n.indexOf(i)&&(n.push(i),e[i.id]=!0)}return{plugins:n,localIds:e}}(n);return!1!==i||e?function(t,{plugins:e,localIds:n},i,s){const o=[],a=t.getContext();for(const r of e){const e=r.id,l=Ls(i[e],s);null!==l&&o.push({plugin:r,options:As(t.config,{plugin:r,local:n[e]},l,a)})}return o}(t,s,i,e):[]}_notifyStateChanges(t){const e=this._oldCache||[],n=this._cache,i=(t,e)=>t.filter((t=>!e.some((e=>t.plugin.id===e.plugin.id))));this._notify(i(e,n),t,"stop"),this._notify(i(n,e),t,"start")}}function Ls(t,e){return e||!1!==t?!0===t?{}:t:null}function As(t,{plugin:e,local:n},i,s){const o=t.pluginScopeKeys(e),a=t.getOptionScopes(i,o);return n&&e.defaults&&a.push(e.defaults),t.createResolver(a,s,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function Is(t,e){const n=Ie.datasets[t]||{};return((e.datasets||{})[t]||{}).indexAxis||e.indexAxis||n.indexAxis||"x"}function zs(t){if("x"===t||"y"===t||"r"===t)return t}function Os(t,...e){if(zs(t))return t;for(const i of e){const e=i.axis||("top"===(n=i.position)||"bottom"===n?"x":"left"===n||"right"===n?"y":void 0)||t.length>1&&zs(t[0].toLowerCase());if(e)return e}var n;throw new Error(`Cannot determine type of '${t}' axis. Please provide 'axis' or 'position' option.`)}function Ws(t,e,n){if(n[e+"AxisID"]===t)return{axis:e}}function Ns(t,e){const n=De[t.type]||{scales:{}},i=e.scales||{},s=Is(t.type,e),o=Object.create(null);return Object.keys(i).forEach((e=>{const a=i[e];if(!gt(a))return console.error(`Invalid scale configuration for scale: ${e}`);if(a._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${e}`);const r=Os(e,a,function(t,e){if(e.data&&e.data.datasets){const n=e.data.datasets.filter((e=>e.xAxisID===t||e.yAxisID===t));if(n.length)return Ws(t,"x",n[0])||Ws(t,"y",n[0])}return{}}(e,t),Ie.scales[a.type]),l=function(t,e){return t===e?"_index_":"_value_"}(r,s),c=n.scales||{};o[e]=Ct(Object.create(null),[{axis:r},a,c[r],c[l]])})),t.data.datasets.forEach((n=>{const s=n.type||t.type,a=n.indexAxis||Is(s,e),r=(De[s]||{}).scales||{};Object.keys(r).forEach((t=>{const e=function(t,e){let n=t;return"_index_"===t?n=e:"_value_"===t&&(n="x"===e?"y":"x"),n}(t,a),s=n[e+"AxisID"]||e;o[s]=o[s]||Object.create(null),Ct(o[s],[{axis:e},i[s],r[t]])}))})),Object.keys(o).forEach((t=>{const e=o[t];Ct(e,[Ie.scales[e.type],Ie.scale])})),o}function Rs(t){const e=t.options||(t.options={});e.plugins=ft(e.plugins,{}),e.scales=Ns(t,e)}function $s(t){return(t=t||{}).datasets=t.datasets||[],t.labels=t.labels||[],t}const Fs=new Map,Bs=new Set;function qs(t,e){let n=Fs.get(t);return n||(n=e(),Fs.set(t,n),Bs.add(n)),n}const Hs=(t,e,n)=>{const i=Dt(e,n);void 0!==i&&t.add(i)};class Vs{constructor(t){this._config=function(t){return(t=t||{}).data=$s(t.data),Rs(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=$s(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(),Rs(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return qs(t,(()=>[[`datasets.${t}`,""]]))}datasetAnimationScopeKeys(t,e){return qs(`${t}.transition.${e}`,(()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]]))}datasetElementScopeKeys(t,e){return qs(`${t}-${e}`,(()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]]))}pluginScopeKeys(t){const e=t.id;return qs(`${this.type}-plugin-${e}`,(()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]]))}_cachedScopes(t,e){const n=this._scopeCache;let i=n.get(t);return i&&!e||(i=new Map,n.set(t,i)),i}getOptionScopes(t,e,n){const{options:i,type:s}=this,o=this._cachedScopes(t,n),a=o.get(e);if(a)return a;const r=new Set;e.forEach((e=>{t&&(r.add(t),e.forEach((e=>Hs(r,t,e)))),e.forEach((t=>Hs(r,i,t))),e.forEach((t=>Hs(r,De[s]||{},t))),e.forEach((t=>Hs(r,Ie,t))),e.forEach((t=>Hs(r,Pe,t)))}));const l=Array.from(r);return 0===l.length&&l.push(Object.create(null)),Bs.has(e)&&o.set(e,l),l}chartOptionScopes(){const{options:t,type:e}=this;return[t,De[e]||{},Ie.datasets[e]||{},{type:e},Ie,Pe]}resolveNamedOptions(t,e,n,i=[""]){const s={$shared:!0},{resolver:o,subPrefixes:a}=Ys(this._resolverCache,t,i);let r=o;if(function(t,e){const{isScriptable:n,isIndexable:i}=ln(t);for(const s of e){const e=n(s),o=i(s),a=(o||e)&&t[s];if(e&&(Lt(a)||js(a))||o&&ut(a))return!0}return!1}(o,e)){s.$shared=!1;r=rn(o,n=Lt(n)?n():n,this.createResolver(t,n,a))}for(const t of e)s[t]=r[t];return s}createResolver(t,e,n=[""],i){const{resolver:s}=Ys(this._resolverCache,t,n);return gt(e)?rn(s,e,void 0,i):s}}function Ys(t,e,n){let i=t.get(e);i||(i=new Map,t.set(e,i));const s=n.join();let o=i.get(s);if(!o){o={resolver:an(e,n),subPrefixes:n.filter((t=>!t.toLowerCase().includes("hover")))},i.set(s,o)}return o}const js=t=>gt(t)&&Object.getOwnPropertyNames(t).some((e=>Lt(t[e])));const Us=["top","bottom","left","right","chartArea"];function Xs(t,e){return"top"===t||"bottom"===t||-1===Us.indexOf(t)&&"x"===e}function Qs(t,e){return function(n,i){return n[t]===i[t]?n[e]-i[e]:n[t]-i[t]}}function Gs(t){const e=t.chart,n=e.options.animation;e.notifyPlugins("afterRender"),yt(n&&n.onComplete,[t],e)}function Ks(t){const e=t.chart,n=e.options.animation;yt(n&&n.onProgress,[t],e)}function Zs(t){return Tn()&&"string"==typeof t?t=document.getElementById(t):t&&t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas),t}const Js={},to=t=>{const e=Zs(t);return Object.values(Js).filter((t=>t.canvas===e)).pop()};function eo(t,e,n){const i=Object.keys(t);for(const s of i){const i=+s;if(i>=e){const o=t[s];delete t[s],(n>0||i>e)&&(t[i+n]=o)}}}class no{static defaults=Ie;static instances=Js;static overrides=De;static registry=Ps;static version="4.5.1";static getChart=to;static register(...t){Ps.add(...t),io()}static unregister(...t){Ps.remove(...t),io()}constructor(t,e){const n=this.config=new Vs(e),i=Zs(t),s=to(i);if(s)throw new Error("Canvas is already in use. Chart with ID '"+s.id+"' must be destroyed before the canvas with ID '"+s.canvas.id+"' can be reused.");const o=n.createResolver(n.chartOptionScopes(),this.getContext());this.platform=new(n.platform||function(t){return!Tn()||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas?ts:ms}(i)),this.platform.updateConfig(n);const a=this.platform.acquireContext(i,o.aspectRatio),r=a&&a.canvas,l=r&&r.height,c=r&&r.width;this.id=dt(),this.ctx=a,this.canvas=r,this.width=c,this.height=l,this._options=o,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 Es,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=function(t,e){let n;return function(...i){return e?(clearTimeout(n),n=setTimeout(t,e,i)):t.apply(this,i),e}}((t=>this.update(t)),o.resizeDelay||0),this._dataChanges=[],Js[this.id]=this,a&&r?(ei.listen(this,"complete",Gs),ei.listen(this,"progress",Ks),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:n,height:i,_aspectRatio:s}=this;return ht(t)?e&&s?s:i?n/i: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 Ps}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():Wn(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return Ne(this.canvas,this.ctx),this}stop(){return ei.stop(this),this}resize(t,e){ei.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){const n=this.options,i=this.canvas,s=n.maintainAspectRatio&&this.aspectRatio,o=this.platform.getMaximumSize(i,t,e,s),a=n.devicePixelRatio||this.platform.getDevicePixelRatio(),r=this.width?"resize":"attach";this.width=o.width,this.height=o.height,this._aspectRatio=this.aspectRatio,Wn(this,a,!0)&&(this.notifyPlugins("resize",{size:o}),yt(n.onResize,[this,o],this),this.attached&&this._doResize(r)&&this.render())}ensureScalesHaveIDs(){xt(this.options.scales||{},((t,e)=>{t.id=e}))}buildOrUpdateScales(){const t=this.options,e=t.scales,n=this.scales,i=Object.keys(n).reduce(((t,e)=>(t[e]=!1,t)),{});let s=[];e&&(s=s.concat(Object.keys(e).map((t=>{const n=e[t],i=Os(t,n),s="r"===i,o="x"===i;return{options:n,dposition:s?"chartArea":o?"bottom":"left",dtype:s?"radialLinear":o?"category":"linear"}})))),xt(s,(e=>{const s=e.options,o=s.id,a=Os(o,s),r=ft(s.type,e.dtype);void 0!==s.position&&Xs(s.position,a)===Xs(e.dposition)||(s.position=e.dposition),i[o]=!0;let l=null;if(o in n&&n[o].type===r)l=n[o];else{l=new(Ps.getScale(r))({id:o,type:r,ctx:this.ctx,chart:this}),n[l.id]=l}l.init(s,t)})),xt(i,((t,e)=>{t||delete n[e]})),xt(n,(t=>{Zi.configure(this,t,t.options),Zi.addBox(this,t)}))}_updateMetasets(){const t=this._metasets,e=this.data.datasets.length,n=t.length;if(t.sort(((t,e)=>t.index-e.index)),n>e){for(let t=e;t<n;++t)this._destroyDatasetMeta(t);t.splice(e,n-e)}this._sortedMetasets=t.slice(0).sort(Qs("order","index"))}_removeUnreferencedMetasets(){const{_metasets:t,data:{datasets:e}}=this;t.length>e.length&&delete this._stacks,t.forEach(((t,n)=>{0===e.filter((e=>e===t._dataset)).length&&this._destroyDatasetMeta(n)}))}buildOrUpdateControllers(){const t=[],e=this.data.datasets;let n,i;for(this._removeUnreferencedMetasets(),n=0,i=e.length;n<i;n++){const i=e[n];let s=this.getDatasetMeta(n);const o=i.type||this.config.type;if(s.type&&s.type!==o&&(this._destroyDatasetMeta(n),s=this.getDatasetMeta(n)),s.type=o,s.indexAxis=i.indexAxis||Is(o,this.options),s.order=i.order||0,s.index=n,s.label=""+i.label,s.visible=this.isDatasetVisible(n),s.controller)s.controller.updateIndex(n),s.controller.linkScales();else{const e=Ps.getController(o),{datasetElementType:i,dataElementType:a}=Ie.datasets[o];Object.assign(e,{dataElementType:Ps.getElement(a),datasetElementType:i&&Ps.getElement(i)}),s.controller=new e(this,n),t.push(s.controller)}}return this._updateMetasets(),t}_resetElements(){xt(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 n=this._options=e.createResolver(e.chartOptionScopes(),this.getContext()),i=this._animationsDisabled=!n.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),!1===this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0}))return;const s=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),n=!i&&-1===s.indexOf(e);e.buildOrUpdateElements(n),o=Math.max(+e.getMaxOverflow(),o)}o=this._minPadding=n.layout.autoPadding?o:0,this._updateLayout(o),i||xt(s,(t=>{t.reset()})),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(Qs("z","_idx"));const{_active:a,_lastEvent:r}=this;r?this._eventHandler(r,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}_updateScales(){xt(this.scales,(t=>{Zi.removeBox(this,t)})),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,e=new Set(Object.keys(this._listeners)),n=new Set(t.events);At(e,n)&&!!this._responsiveListeners===t.responsive||(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,e=this._getUniformDataChanges()||[];for(const{method:n,start:i,count:s}of e){eo(t,i,"_removeElements"===n?-s:s)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const e=this.data.datasets.length,n=e=>new Set(t.filter((t=>t[0]===e)).map(((t,e)=>e+","+t.splice(1).join(",")))),i=n(0);for(let t=1;t<e;t++)if(!At(i,n(t)))return;return Array.from(i).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;Zi.update(this,this.width,this.height,t);const e=this.chartArea,n=e.width<=0||e.height<=0;this._layers=[],xt(this.boxes,(t=>{n&&"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,n=this.data.datasets.length;e<n;++e)this._updateDataset(e,Lt(t)?t({datasetIndex:e}):t);this.notifyPlugins("afterDatasetsUpdate",{mode:t})}}_updateDataset(t,e){const n=this.getDatasetMeta(t),i={meta:n,index:t,mode:e,cancelable:!0};!1!==this.notifyPlugins("beforeDatasetUpdate",i)&&(n.controller._update(e),i.cancelable=!1,this.notifyPlugins("afterDatasetUpdate",i))}render(){!1!==this.notifyPlugins("beforeRender",{cancelable:!0})&&(ei.has(this)?this.attached&&!ei.running(this)&&ei.start(this):(this.draw(),Gs({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,n=[];let i,s;for(i=0,s=e.length;i<s;++i){const s=e[i];t&&!s.visible||n.push(s)}return n}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,n={meta:t,index:t.index,cancelable:!0},i=Jn(this,t);!1!==this.notifyPlugins("beforeDatasetDraw",n)&&(i&&Be(e,i),t.controller.draw(),i&&qe(e),n.cancelable=!1,this.notifyPlugins("afterDatasetDraw",n))}isPointInArea(t){return Fe(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,e,n,i){const s=$i.modes[e];return"function"==typeof s?s(this,t,n,i):[]}getDatasetMeta(t){const e=this.data.datasets[t],n=this._metasets;let i=n.filter((t=>t&&t._dataset===e)).pop();return i||(i={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},n.push(i)),i}getContext(){return this.$context||(this.$context=on(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const e=this.data.datasets[t];if(!e)return!1;const n=this.getDatasetMeta(t);return"boolean"==typeof n.hidden?!n.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,n){const i=n?"show":"hide",s=this.getDatasetMeta(t),o=s.controller._resolveAnimations(void 0,i);Et(e)?(s.data[e].hidden=!n,this.update()):(this.setDatasetVisibility(t,n),o.update(s,{visible:n}),this.update((e=>e.datasetIndex===t?i: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(),ei.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(),Ne(t,e),this.platform.releaseContext(e),this.canvas=null,this.ctx=null),delete Js[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,n=(n,i)=>{e.addEventListener(this,n,i),t[n]=i},i=(t,e,n)=>{t.offsetX=e,t.offsetY=n,this._eventHandler(t)};xt(this.options.events,(t=>n(t,i)))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,e=this.platform,n=(n,i)=>{e.addEventListener(this,n,i),t[n]=i},i=(n,i)=>{t[n]&&(e.removeEventListener(this,n,i),delete t[n])},s=(t,e)=>{this.canvas&&this.resize(t,e)};let o;const a=()=>{i("attach",a),this.attached=!0,this.resize(),n("resize",s),n("detach",o)};o=()=>{this.attached=!1,i("resize",s),this._stop(),this._resize(0,0),n("attach",a)},e.isAttached(this.canvas)?a():o()}unbindEvents(){xt(this._listeners,((t,e)=>{this.platform.removeEventListener(this,e,t)})),this._listeners={},xt(this._responsiveListeners,((t,e)=>{this.platform.removeEventListener(this,e,t)})),this._responsiveListeners=void 0}updateHoverStyle(t,e,n){const i=n?"set":"remove";let s,o,a,r;for("dataset"===e&&(s=this.getDatasetMeta(t[0].datasetIndex),s.controller["_"+i+"DatasetHoverStyle"]()),a=0,r=t.length;a<r;++a){o=t[a];const e=o&&this.getDatasetMeta(o.datasetIndex).controller;e&&e[i+"HoverStyle"](o.element,o.datasetIndex,o.index)}}getActiveElements(){return this._active||[]}setActiveElements(t){const e=this._active||[],n=t.map((({datasetIndex:t,index:e})=>{const n=this.getDatasetMeta(t);if(!n)throw new Error("No dataset found at index "+t);return{datasetIndex:t,element:n.data[e],index:e}}));!vt(n,e)&&(this._active=n,this._lastEvent=null,this._updateHoverStyles(n,e))}notifyPlugins(t,e,n){return this._plugins.notify(this,t,e,n)}isPluginEnabled(t){return 1===this._plugins._cache.filter((e=>e.plugin.id===t)).length}_updateHoverStyles(t,e,n){const i=this.options.hover,s=(t,e)=>t.filter((t=>!e.some((e=>t.datasetIndex===e.datasetIndex&&t.index===e.index)))),o=s(e,t),a=n?t:s(t,e);o.length&&this.updateHoverStyle(o,i.mode,!1),a.length&&i.mode&&this.updateHoverStyle(a,i.mode,!0)}_eventHandler(t,e){const n={event:t,replay:e,cancelable:!0,inChartArea:this.isPointInArea(t)},i=e=>(e.options.events||this.options.events).includes(t.native.type);if(!1===this.notifyPlugins("beforeEvent",n,i))return;const s=this._handleEvent(t,e,n.inChartArea);return n.cancelable=!1,this.notifyPlugins("afterEvent",n,i),(s||n.changed)&&this.render(),this}_handleEvent(t,e,n){const{_active:i=[],options:s}=this,o=e,a=this._getActiveElements(t,i,n,o),r=function(t){return"mouseup"===t.type||"click"===t.type||"contextmenu"===t.type}(t),l=function(t,e,n,i){return n&&"mouseout"!==t.type?i?e:t:null}(t,this._lastEvent,n,r);n&&(this._lastEvent=null,yt(s.onHover,[t,a,this],this),r&&yt(s.onClick,[t,a,this],this));const c=!vt(a,i);return(c||e)&&(this._active=a,this._updateHoverStyles(a,i,e)),this._lastEvent=l,c}_getActiveElements(t,e,n,i){if("mouseout"===t.type)return[];if(!n)return e;const s=this.options.hover;return this.getElementsAtEventForMode(t,s.mode,s,i)}}function io(){return xt(no.instances,(t=>t._plugins.invalidate()))}function so(t,e,n,i){const s=Ze(t.options.borderRadius,["outerStart","outerEnd","innerStart","innerEnd"]);const o=(n-e)/2,a=Math.min(o,i*e/2),r=t=>{const e=(n-Math.min(o,t))*i/2;return ee(t,0,Math.min(o,e))};return{outerStart:r(s.outerStart),outerEnd:r(s.outerEnd),innerStart:ee(s.innerStart,0,a),innerEnd:ee(s.innerEnd,0,a)}}function oo(t,e,n,i){return{x:n+t*Math.cos(e),y:i+t*Math.sin(e)}}function ao(t,e,n,i,s,o){const{x:a,y:r,startAngle:l,pixelMargin:c,innerRadius:d}=e,h=Math.max(e.outerRadius+i+n-c,0),u=d>0?d+i+n+c:0;let g=0;const p=s-l;if(i){const t=((d>0?d-i:0)+(h>0?h-i:0))/2;g=(p-(0!==t?p*t/(t+i):p))/2}const m=(p-Math.max(.001,p*h-n/It)/h)/2,f=l+m+g,b=s-m-g,{outerStart:y,outerEnd:x,innerStart:v,innerEnd:w}=so(e,u,h,b-f),k=h-y,S=h-x,M=f+y/k,C=b-x/S,_=u+v,T=u+w,D=f+v/_,P=b-w/T;if(t.beginPath(),o){const e=(M+C)/2;if(t.arc(a,r,h,M,e),t.arc(a,r,h,e,C),x>0){const e=oo(S,C,a,r);t.arc(e.x,e.y,x,C,b+Rt)}const n=oo(T,b,a,r);if(t.lineTo(n.x,n.y),w>0){const e=oo(T,P,a,r);t.arc(e.x,e.y,w,b+Rt,P+Math.PI)}const i=(b-w/u+(f+v/u))/2;if(t.arc(a,r,u,b-w/u,i,!0),t.arc(a,r,u,i,f+v/u,!0),v>0){const e=oo(_,D,a,r);t.arc(e.x,e.y,v,D+Math.PI,f-Rt)}const s=oo(k,f,a,r);if(t.lineTo(s.x,s.y),y>0){const e=oo(k,M,a,r);t.arc(e.x,e.y,y,f-Rt,M)}}else{t.moveTo(a,r);const e=Math.cos(M)*h+a,n=Math.sin(M)*h+r;t.lineTo(e,n);const i=Math.cos(C)*h+a,s=Math.sin(C)*h+r;t.lineTo(i,s)}t.closePath()}function ro(t,e,n,i,s){const{fullCircles:o,startAngle:a,circumference:r,options:l}=e,{borderWidth:c,borderJoinStyle:d,borderDash:h,borderDashOffset:u,borderRadius:g}=l,p="inner"===l.borderAlign;if(!c)return;t.setLineDash(h||[]),t.lineDashOffset=u,p?(t.lineWidth=2*c,t.lineJoin=d||"round"):(t.lineWidth=c,t.lineJoin=d||"bevel");let m=e.endAngle;if(o){ao(t,e,n,i,m,s);for(let e=0;e<o;++e)t.stroke();isNaN(r)||(m=a+(r%zt||zt))}p&&function(t,e,n){const{startAngle:i,pixelMargin:s,x:o,y:a,outerRadius:r,innerRadius:l}=e;let c=s/r;t.beginPath(),t.arc(o,a,r,i-c,n+c),l>s?(c=s/l,t.arc(o,a,l,n+c,i-c,!0)):t.arc(o,a,s,n+Rt,i-Rt),t.closePath(),t.clip()}(t,e,m),l.selfJoin&&m-a>=It&&0===g&&"miter"!==d&&function(t,e,n){const{startAngle:i,x:s,y:o,outerRadius:a,innerRadius:r,options:l}=e,{borderWidth:c,borderJoinStyle:d}=l,h=Math.min(c/a,Jt(i-n));if(t.beginPath(),t.arc(s,o,a-c/2,i+h/2,n-h/2),r>0){const e=Math.min(c/r,Jt(i-n));t.arc(s,o,r+c/2,n-e/2,i+e/2,!0)}else{const e=Math.min(c/2,a*Jt(i-n));if("round"===d)t.arc(s,o,e,n-It/2,i+It/2,!0);else if("bevel"===d){const a=2*e*e,r=-a*Math.cos(n+It/2)+s,l=-a*Math.sin(n+It/2)+o,c=a*Math.cos(i+It/2)+s,d=a*Math.sin(i+It/2)+o;t.lineTo(r,l),t.lineTo(c,d)}}t.closePath(),t.moveTo(0,0),t.rect(0,0,t.canvas.width,t.canvas.height),t.clip("evenodd")}(t,e,m),o||(ao(t,e,n,i,m,s),t.stroke())}function lo(t,e,n=e){t.lineCap=ft(n.borderCapStyle,e.borderCapStyle),t.setLineDash(ft(n.borderDash,e.borderDash)),t.lineDashOffset=ft(n.borderDashOffset,e.borderDashOffset),t.lineJoin=ft(n.borderJoinStyle,e.borderJoinStyle),t.lineWidth=ft(n.borderWidth,e.borderWidth),t.strokeStyle=ft(n.borderColor,e.borderColor)}function co(t,e,n){t.lineTo(n.x,n.y)}function ho(t,e,n={}){const i=t.length,{start:s=0,end:o=i-1}=n,{start:a,end:r}=e,l=Math.max(s,a),c=Math.min(o,r),d=s<a&&o<a||s>r&&o>r;return{count:i,start:l,loop:e.loop,ilen:c<l&&!d?i+c-l:c-l}}function uo(t,e,n,i){const{points:s,options:o}=e,{count:a,start:r,loop:l,ilen:c}=ho(s,n,i),d=function(t){return t.stepped?He:t.tension||"monotone"===t.cubicInterpolationMode?Ve:co}(o);let h,u,g,{move:p=!0,reverse:m}=i||{};for(h=0;h<=c;++h)u=s[(r+(m?c-h:h))%a],u.skip||(p?(t.moveTo(u.x,u.y),p=!1):d(t,g,u,m,o.stepped),g=u);return l&&(u=s[(r+(m?c:0))%a],d(t,g,u,m,o.stepped)),!!l}function go(t,e,n,i){const s=e.points,{count:o,start:a,ilen:r}=ho(s,n,i),{move:l=!0,reverse:c}=i||{};let d,h,u,g,p,m,f=0,b=0;const y=t=>(a+(c?r-t:t))%o,x=()=>{g!==p&&(t.lineTo(f,p),t.lineTo(f,g),t.lineTo(f,m))};for(l&&(h=s[y(0)],t.moveTo(h.x,h.y)),d=0;d<=r;++d){if(h=s[y(d)],h.skip)continue;const e=h.x,n=h.y,i=0|e;i===u?(n<g?g=n:n>p&&(p=n),f=(b*f+e)/++b):(x(),t.lineTo(e,n),u=i,b=0,g=p=n),m=n}x()}function po(t){const e=t.options,n=e.borderDash&&e.borderDash.length;return!(t._decimated||t._loop||e.tension||"monotone"===e.cubicInterpolationMode||e.stepped||n)?go:uo}const mo="function"==typeof Path2D;function fo(t,e,n,i){mo&&!e.options.segment?function(t,e,n,i){let s=e._path;s||(s=e._path=new Path2D,e.path(s,n,i)&&s.closePath()),lo(t,e.options),t.stroke(s)}(t,e,n,i):function(t,e,n,i){const{segments:s,options:o}=e,a=po(e);for(const r of s)lo(t,o,r.style),t.beginPath(),a(t,e,r,{start:n,end:n+i-1})&&t.closePath(),t.stroke()}(t,e,n,i)}class bo extends fs{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 n=this.options;if((n.tension||"monotone"===n.cubicInterpolationMode)&&!n.stepped&&!this._pointsUpdated){const i=n.spanGaps?this._loop:this._fullLoop;_n(this._points,n,t,i,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=function(t,e){const n=t.points,i=t.options.spanGaps,s=n.length;if(!s)return[];const o=!!t._loop,{start:a,end:r}=function(t,e,n,i){let s=0,o=e-1;if(n&&!i)for(;s<e&&!t[s].skip;)s++;for(;s<e&&t[s].skip;)s++;for(s%=e,n&&(o+=s);o>s&&t[o%e].skip;)o--;return o%=e,{start:s,end:o}}(n,s,o,i);return Qn(t,!0===i?[{start:a,end:r,loop:o}]:function(t,e,n,i){const s=t.length,o=[];let a,r=e,l=t[e];for(a=e+1;a<=n;++a){const n=t[a%s];n.skip||n.stop?l.skip||(i=!1,o.push({start:e%s,end:(a-1)%s,loop:i}),e=r=n.stop?a:null):(r=a,l.skip&&(e=a)),l=n}return null!==r&&o.push({start:e%s,end:r%s,loop:i}),o}(n,a,r<a?r+s:r,!!t._fullLoop&&0===a&&r===s-1),n,e)}(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,n=t.length;return n&&e[t[n-1].end]}interpolate(t,e){const n=this.options,i=t[e],s=this.points,o=Xn(this,{property:e,start:i,end:i});if(!o.length)return;const a=[],r=function(t){return t.stepped?Fn:t.tension||"monotone"===t.cubicInterpolationMode?Bn:$n}(n);let l,c;for(l=0,c=o.length;l<c;++l){const{start:c,end:d}=o[l],h=s[c],u=s[d];if(h===u){a.push(h);continue}const g=r(h,u,Math.abs((i-h[e])/(u[e]-h[e])),n.stepped);g[e]=t[e],a.push(g)}return 1===a.length?a[0]:a}pathSegment(t,e,n){return po(this)(t,this,e,n)}path(t,e,n){const i=this.segments,s=po(this);let o=this._loop;e=e||0,n=n||this.points.length-e;for(const a of i)o&=s(t,this,a,{start:e,end:e+n-1});return!!o}draw(t,e,n,i){const s=this.options||{};(this.points||[]).length&&s.borderWidth&&(t.save(),fo(t,this,n,i),t.restore()),this.animated&&(this._pointsUpdated=!1,this._path=void 0)}}function yo(t,e,n,i){const s=t.options,{[n]:o}=t.getProps([n],i);return Math.abs(e-o)<s.radius+s.hitRadius}function xo(t,e){const{x:n,y:i,base:s,width:o,height:a}=t.getProps(["x","y","base","width","height"],e);let r,l,c,d,h;return t.horizontal?(h=a/2,r=Math.min(n,s),l=Math.max(n,s),c=i-h,d=i+h):(h=o/2,r=n-h,l=n+h,c=Math.min(i,s),d=Math.max(i,s)),{left:r,top:c,right:l,bottom:d}}function vo(t,e,n,i){return t?0:ee(e,n,i)}function wo(t){const e=xo(t),n=e.right-e.left,i=e.bottom-e.top,s=function(t,e,n){const i=t.options.borderWidth,s=t.borderSkipped,o=Je(i);return{t:vo(s.top,o.top,0,n),r:vo(s.right,o.right,0,e),b:vo(s.bottom,o.bottom,0,n),l:vo(s.left,o.left,0,e)}}(t,n/2,i/2),o=function(t,e,n){const{enableBorderRadius:i}=t.getProps(["enableBorderRadius"]),s=t.options.borderRadius,o=tn(s),a=Math.min(e,n),r=t.borderSkipped,l=i||gt(s);return{topLeft:vo(!l||r.top||r.left,o.topLeft,0,a),topRight:vo(!l||r.top||r.right,o.topRight,0,a),bottomLeft:vo(!l||r.bottom||r.left,o.bottomLeft,0,a),bottomRight:vo(!l||r.bottom||r.right,o.bottomRight,0,a)}}(t,n/2,i/2);return{outer:{x:e.left,y:e.top,w:n,h:i,radius:o},inner:{x:e.left+s.l,y:e.top+s.t,w:n-s.l-s.r,h:i-s.t-s.b,radius:{topLeft:Math.max(0,o.topLeft-Math.max(s.t,s.l)),topRight:Math.max(0,o.topRight-Math.max(s.t,s.r)),bottomLeft:Math.max(0,o.bottomLeft-Math.max(s.b,s.l)),bottomRight:Math.max(0,o.bottomRight-Math.max(s.b,s.r))}}}}function ko(t,e,n,i){const s=null===e,o=null===n,a=t&&!(s&&o)&&xo(t,i);return a&&(s||ne(e,a.left,a.right))&&(o||ne(n,a.top,a.bottom))}function So(t,e){t.rect(e.x,e.y,e.w,e.h)}function Mo(t,e,n={}){const i=t.x!==n.x?-e:0,s=t.y!==n.y?-e:0,o=(t.x+t.w!==n.x+n.w?e:0)-i,a=(t.y+t.h!==n.y+n.h?e:0)-s;return{x:t.x+i,y:t.y+s,w:t.w+o,h:t.h+a,radius:t.radius}}class Co extends fs{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:n,backgroundColor:i}}=this,{inner:s,outer:o}=wo(this),a=(r=o.radius).topLeft||r.topRight||r.bottomLeft||r.bottomRight?Xe:So;var r;t.save(),o.w===s.w&&o.h===s.h||(t.beginPath(),a(t,Mo(o,e,s)),t.clip(),a(t,Mo(s,-e,o)),t.fillStyle=n,t.fill("evenodd")),t.beginPath(),a(t,Mo(s,e)),t.fillStyle=i,t.fill(),t.restore()}inRange(t,e,n){return ko(this,t,e,n)}inXRange(t,e){return ko(this,t,null,e)}inYRange(t,e){return ko(this,null,t,e)}getCenterPoint(t){const{x:e,y:n,base:i,horizontal:s}=this.getProps(["x","y","base","horizontal"],t);return{x:s?(e+i)/2:e,y:s?n:(n+i)/2}}getRange(t){return"x"===t?this.width/2:this.height/2}}var _o=Object.freeze({__proto__:null,ArcElement:class extends fs{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,selfJoin:!1};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,n){const i=this.getProps(["x","y"],n),{angle:s,distance:o}=Gt(i,{x:t,y:e}),{startAngle:a,endAngle:r,innerRadius:l,outerRadius:c,circumference:d}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],n),h=(this.options.spacing+this.options.borderWidth)/2,u=ft(d,r-a),g=te(s,a,r)&&a!==r,p=u>=zt||g,m=ne(o,l+h,c+h);return p&&m}getCenterPoint(t){const{x:e,y:n,startAngle:i,endAngle:s,innerRadius:o,outerRadius:a}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],t),{offset:r,spacing:l}=this.options,c=(i+s)/2,d=(o+a+l+r)/2;return{x:e+Math.cos(c)*d,y:n+Math.sin(c)*d}}tooltipPosition(t){return this.getCenterPoint(t)}draw(t){const{options:e,circumference:n}=this,i=(e.offset||0)/4,s=(e.spacing||0)/2,o=e.circular;if(this.pixelMargin="inner"===e.borderAlign?.33:0,this.fullCircles=n>zt?Math.floor(n/zt):0,0===n||this.innerRadius<0||this.outerRadius<0)return;t.save();const a=(this.startAngle+this.endAngle)/2;t.translate(Math.cos(a)*i,Math.sin(a)*i);const r=i*(1-Math.sin(Math.min(It,n||0)));t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,function(t,e,n,i,s){const{fullCircles:o,startAngle:a,circumference:r}=e;let l=e.endAngle;if(o){ao(t,e,n,i,l,s);for(let e=0;e<o;++e)t.fill();isNaN(r)||(l=a+(r%zt||zt))}ao(t,e,n,i,l,s),t.fill()}(t,this,r,s,o),ro(t,this,r,s,o),t.restore()}},BarElement:Co,LineElement:bo,PointElement:class extends fs{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,n){const i=this.options,{x:s,y:o}=this.getProps(["x","y"],n);return Math.pow(t-s,2)+Math.pow(e-o,2)<Math.pow(i.hitRadius+i.radius,2)}inXRange(t,e){return yo(this,t,"x",e)}inYRange(t,e){return yo(this,t,"y",e)}getCenterPoint(t){const{x:e,y:n}=this.getProps(["x","y"],t);return{x:e,y:n}}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 n=this.options;this.skip||n.radius<.1||!Fe(this,e,this.size(n)/2)||(t.strokeStyle=n.borderColor,t.lineWidth=n.borderWidth,t.fillStyle=n.backgroundColor,Re(t,n,this.x,this.y))}getRange(){const t=this.options||{};return t.radius+t.hitRadius}}});const To=["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)"],Do=To.map((t=>t.replace("rgb(","rgba(").replace(")",", 0.5)")));function Po(t){return To[t%To.length]}function Eo(t){return Do[t%Do.length]}function Lo(t){let e=0;return(n,i)=>{const s=t.getDatasetMeta(i).controller;s instanceof Ti?e=function(t,e){return t.backgroundColor=t.data.map((()=>Po(e++))),e}(n,e):s instanceof Di?e=function(t,e){return t.backgroundColor=t.data.map((()=>Eo(e++))),e}(n,e):s&&(e=function(t,e){return t.borderColor=Po(e),t.backgroundColor=Eo(e),++e}(n,e))}}function Ao(t){let e;for(e in t)if(t[e].borderColor||t[e].backgroundColor)return!0;return!1}var Io={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(t,e,n){if(!n.enabled)return;const{data:{datasets:i},options:s}=t.config,{elements:o}=s,a=Ao(i)||(r=s)&&(r.borderColor||r.backgroundColor)||o&&Ao(o)||"rgba(0,0,0,0.1)"!==Ie.borderColor||"rgba(0,0,0,0.1)"!==Ie.backgroundColor;var r;if(!n.forceOverride&&a)return;const l=Lo(t);i.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 Oo(t){t.data.datasets.forEach((t=>{zo(t)}))}var Wo={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(t,e,n)=>{if(!n.enabled)return void Oo(t);const i=t.width;t.data.datasets.forEach(((e,s)=>{const{_data:o,indexAxis:a}=e,r=t.getDatasetMeta(s),l=o||e.data;if("y"===sn([a,t.options.indexAxis]))return;if(!r.controller.supportsDecimation)return;const c=t.scales[r.xAxisID];if("linear"!==c.type&&"time"!==c.type)return;if(t.options.parsing)return;let{start:d,count:h}=function(t,e){const n=e.length;let i,s=0;const{iScale:o}=t,{min:a,max:r,minDefined:l,maxDefined:c}=o.getUserBounds();return l&&(s=ee(se(e,o.axis,a).lo,0,n-1)),i=c?ee(se(e,o.axis,r).hi+1,s,n)-s:n-s,{start:s,count:i}}(r,l);if(h<=(n.threshold||4*i))return void zo(e);let u;switch(ht(o)&&(e._data=l,delete e.data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(t){this._data=t}})),n.algorithm){case"lttb":u=function(t,e,n,i,s){const o=s.samples||i;if(o>=n)return t.slice(e,e+n);const a=[],r=(n-2)/(o-2);let l=0;const c=e+n-1;let d,h,u,g,p,m=e;for(a[l++]=t[m],d=0;d<o-2;d++){let i,s=0,o=0;const c=Math.floor((d+1)*r)+1+e,f=Math.min(Math.floor((d+2)*r)+1,n)+e,b=f-c;for(i=c;i<f;i++)s+=t[i].x,o+=t[i].y;s/=b,o/=b;const y=Math.floor(d*r)+1+e,x=Math.min(Math.floor((d+1)*r)+1,n)+e,{x:v,y:w}=t[m];for(u=g=-1,i=y;i<x;i++)g=.5*Math.abs((v-s)*(t[i].y-w)-(v-t[i].x)*(o-w)),g>u&&(u=g,h=t[i],p=i);a[l++]=h,m=p}return a[l++]=t[c],a}(l,d,h,i,n);break;case"min-max":u=function(t,e,n,i){let s,o,a,r,l,c,d,h,u,g,p=0,m=0;const f=[],b=e+n-1,y=t[e].x,x=t[b].x-y;for(s=e;s<e+n;++s){o=t[s],a=(o.x-y)/x*i,r=o.y;const e=0|a;if(e===l)r<u?(u=r,c=s):r>g&&(g=r,d=s),p=(m*p+o.x)/++m;else{const n=s-1;if(!ht(c)&&!ht(d)){const e=Math.min(c,d),i=Math.max(c,d);e!==h&&e!==n&&f.push({...t[e],x:p}),i!==h&&i!==n&&f.push({...t[i],x:p})}s>0&&n!==h&&f.push(t[n]),f.push(o),l=e,m=0,u=g=r,c=d=h=s}}return f}(l,d,h,i);break;default:throw new Error(`Unsupported decimation algorithm '${n.algorithm}'`)}e._decimated=u}))},destroy(t){Oo(t)}};function No(t,e,n,i){if(i)return;let s=e[t],o=n[t];return"angle"===t&&(s=Jt(s),o=Jt(o)),{property:t,start:s,end:o}}function Ro(t,e,n){for(;e>t;e--){const t=n[e];if(!isNaN(t.x)&&!isNaN(t.y))break}return e}function $o(t,e,n,i){return t&&e?i(t[n],e[n]):t?t[n]:e?e[n]:0}function Fo(t,e){let n=[],i=!1;return ut(t)?(i=!0,n=t):n=function(t,e){const{x:n=null,y:i=null}=t||{},s=e.points,o=[];return e.segments.forEach((({start:t,end:e})=>{e=Ro(t,e,s);const a=s[t],r=s[e];null!==i?(o.push({x:a.x,y:i}),o.push({x:r.x,y:i})):null!==n&&(o.push({x:n,y:a.y}),o.push({x:n,y:r.y}))})),o}(t,e),n.length?new bo({points:n,options:{tension:0},_loop:i,_fullLoop:i}):null}function Bo(t){return t&&!1!==t.fill}function qo(t,e,n){let i=t[e].fill;const s=[e];let o;if(!n)return i;for(;!1!==i&&-1===s.indexOf(i);){if(!pt(i))return i;if(o=t[i],!o)return!1;if(o.visible)return i;s.push(i),i=o.fill}return!1}function Ho(t,e,n){const i=function(t){const e=t.options,n=e.fill;let i=ft(n&&n.target,n);void 0===i&&(i=!!e.backgroundColor);if(!1===i||null===i)return!1;if(!0===i)return"origin";return i}(t);if(gt(i))return!isNaN(i.value)&&i;let s=parseFloat(i);return pt(s)&&Math.floor(s)===s?function(t,e,n,i){"-"!==t&&"+"!==t||(n=e+n);if(n===e||n<0||n>=i)return!1;return n}(i[0],e,s,n):["origin","start","end","stack","shape"].indexOf(i)>=0&&i}function Vo(t,e,n){const i=[];for(let s=0;s<n.length;s++){const o=n[s],{first:a,last:r,point:l}=Yo(o,e,"x");if(!(!l||a&&r))if(a)i.unshift(l);else if(t.push(l),!r)break}t.push(...i)}function Yo(t,e,n){const i=t.interpolate(e,n);if(!i)return{};const s=i[n],o=t.segments,a=t.points;let r=!1,l=!1;for(let t=0;t<o.length;t++){const e=o[t],i=a[e.start][n],c=a[e.end][n];if(ne(s,i,c)){r=s===i,l=s===c;break}}return{first:r,last:l,point:i}}class jo{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,e,n){const{x:i,y:s,radius:o}=this;return e=e||{start:0,end:zt},t.arc(i,s,o,e.end,e.start,!0),!n.bounds}interpolate(t){const{x:e,y:n,radius:i}=this,s=t.angle;return{x:e+Math.cos(s)*i,y:n+Math.sin(s)*i,angle:s}}}function Uo(t){const{chart:e,fill:n,line:i}=t;if(pt(n))return function(t,e){const n=t.getDatasetMeta(e),i=n&&t.isDatasetVisible(e);return i?n.dataset:null}(e,n);if("stack"===n)return function(t){const{scale:e,index:n,line:i}=t,s=[],o=i.segments,a=i.points,r=function(t,e){const n=[],i=t.getMatchingVisibleMetas("line");for(let t=0;t<i.length;t++){const s=i[t];if(s.index===e)break;s.hidden||n.unshift(s.dataset)}return n}(e,n);r.push(Fo({x:null,y:e.bottom},i));for(let t=0;t<o.length;t++){const e=o[t];for(let t=e.start;t<=e.end;t++)Vo(s,a[t],r)}return new bo({points:s,options:{}})}(t);if("shape"===n)return!0;const s=function(t){const e=t.scale||{};if(e.getPointPositionForValue)return function(t){const{scale:e,fill:n}=t,i=e.options,s=e.getLabels().length,o=i.reverse?e.max:e.min,a=function(t,e,n){let i;return i="start"===t?n:"end"===t?e.options.reverse?e.min:e.max:gt(t)?t.value:e.getBaseValue(),i}(n,e,o),r=[];if(i.grid.circular){const t=e.getPointPositionForValue(0,o);return new jo({x:t.x,y:t.y,radius:e.getDistanceFromCenterForValue(a)})}for(let t=0;t<s;++t)r.push(e.getPointPositionForValue(t,a));return r}(t);return function(t){const{scale:e={},fill:n}=t,i=function(t,e){let n=null;return"start"===t?n=e.bottom:"end"===t?n=e.top:gt(t)?n=e.getPixelForValue(t.value):e.getBasePixel&&(n=e.getBasePixel()),n}(n,e);if(pt(i)){const t=e.isHorizontal();return{x:t?i:null,y:t?null:i}}return null}(t)}(t);return s instanceof jo?s:Fo(s,i)}function Xo(t,e,n){const i=Uo(e),{chart:s,index:o,line:a,scale:r,axis:l}=e,c=a.options,d=c.fill,h=c.backgroundColor,{above:u=h,below:g=h}=d||{},p=s.getDatasetMeta(o),m=Jn(s,p);i&&a.points.length&&(Be(t,n),function(t,e){const{line:n,target:i,above:s,below:o,area:a,scale:r,clip:l}=e,c=n._loop?"angle":e.axis;t.save();let d=o;o!==s&&("x"===c?(Qo(t,i,a.top),Ko(t,{line:n,target:i,color:s,scale:r,property:c,clip:l}),t.restore(),t.save(),Qo(t,i,a.bottom)):"y"===c&&(Go(t,i,a.left),Ko(t,{line:n,target:i,color:o,scale:r,property:c,clip:l}),t.restore(),t.save(),Go(t,i,a.right),d=s));Ko(t,{line:n,target:i,color:d,scale:r,property:c,clip:l}),t.restore()}(t,{line:a,target:i,above:u,below:g,area:n,scale:r,axis:l,clip:m}),qe(t))}function Qo(t,e,n){const{segments:i,points:s}=e;let o=!0,a=!1;t.beginPath();for(const r of i){const{start:i,end:l}=r,c=s[i],d=s[Ro(i,l,s)];o?(t.moveTo(c.x,c.y),o=!1):(t.lineTo(c.x,n),t.lineTo(c.x,c.y)),a=!!e.pathSegment(t,r,{move:a}),a?t.closePath():t.lineTo(d.x,n)}t.lineTo(e.first().x,n),t.closePath(),t.clip()}function Go(t,e,n){const{segments:i,points:s}=e;let o=!0,a=!1;t.beginPath();for(const r of i){const{start:i,end:l}=r,c=s[i],d=s[Ro(i,l,s)];o?(t.moveTo(c.x,c.y),o=!1):(t.lineTo(n,c.y),t.lineTo(c.x,c.y)),a=!!e.pathSegment(t,r,{move:a}),a?t.closePath():t.lineTo(n,d.y)}t.lineTo(n,e.first().y),t.closePath(),t.clip()}function Ko(t,e){const{line:n,target:i,property:s,color:o,scale:a,clip:r}=e,l=function(t,e,n){const i=t.segments,s=t.points,o=e.points,a=[];for(const t of i){let{start:i,end:r}=t;r=Ro(i,r,s);const l=No(n,s[i],s[r],t.loop);if(!e.segments){a.push({source:t,target:l,start:s[i],end:s[r]});continue}const c=Xn(e,l);for(const e of c){const i=No(n,o[e.start],o[e.end],e.loop),r=Un(t,s,i);for(const t of r)a.push({source:t,target:e,start:{[n]:$o(l,i,"start",Math.max)},end:{[n]:$o(l,i,"end",Math.min)}})}}return a}(n,i,s);for(const{source:e,target:c,start:d,end:h}of l){const{style:{backgroundColor:l=o}={}}=e,u=!0!==i;t.save(),t.fillStyle=l,Zo(t,a,r,u&&No(s,d,h)),t.beginPath();const g=!!n.pathSegment(t,e);let p;if(u){g?t.closePath():Jo(t,i,h,s);const e=!!i.pathSegment(t,c,{move:g,reverse:!0});p=g&&e,p||Jo(t,i,d,s)}t.closePath(),t.fill(p?"evenodd":"nonzero"),t.restore()}}function Zo(t,e,n,i){const s=e.chart.chartArea,{property:o,start:a,end:r}=i||{};if("x"===o||"y"===o){let e,i,l,c;"x"===o?(e=a,i=s.top,l=r,c=s.bottom):(e=s.left,i=a,l=s.right,c=r),t.beginPath(),n&&(e=Math.max(e,n.left),l=Math.min(l,n.right),i=Math.max(i,n.top),c=Math.min(c,n.bottom)),t.rect(e,i,l-e,c-i),t.clip()}}function Jo(t,e,n,i){const s=e.interpolate(n,i);s&&t.lineTo(s.x,s.y)}var ta={id:"filler",afterDatasetsUpdate(t,e,n){const i=(t.data.datasets||[]).length,s=[];let o,a,r,l;for(a=0;a<i;++a)o=t.getDatasetMeta(a),r=o.dataset,l=null,r&&r.options&&r instanceof bo&&(l={visible:t.isDatasetVisible(a),index:a,fill:Ho(r,a,i),chart:t,axis:o.controller.options.indexAxis,scale:o.vScale,line:r}),o.$filler=l,s.push(l);for(a=0;a<i;++a)l=s[a],l&&!1!==l.fill&&(l.fill=qo(s,a,n.propagate))},beforeDraw(t,e,n){const i="beforeDraw"===n.drawTime,s=t.getSortedVisibleDatasetMetas(),o=t.chartArea;for(let e=s.length-1;e>=0;--e){const n=s[e].$filler;n&&(n.line.updateControlPoints(o,n.axis),i&&n.fill&&Xo(t.ctx,n,o))}},beforeDatasetsDraw(t,e,n){if("beforeDatasetsDraw"!==n.drawTime)return;const i=t.getSortedVisibleDatasetMetas();for(let e=i.length-1;e>=0;--e){const n=i[e].$filler;Bo(n)&&Xo(t.ctx,n,t.chartArea)}},beforeDatasetDraw(t,e,n){const i=e.meta.$filler;Bo(i)&&"beforeDatasetDraw"===n.drawTime&&Xo(t.ctx,i,t.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const ea=(t,e)=>{let{boxHeight:n=e,boxWidth:i=e}=t;return t.usePointStyle&&(n=Math.min(n,e),i=t.pointStyleWidth||Math.min(i,e)),{boxWidth:i,boxHeight:n,itemHeight:Math.max(e,n)}};class na extends fs{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,n){this.maxWidth=t,this.maxHeight=e,this._margins=n,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=yt(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter((e=>t.filter(e,this.chart.data)))),t.sort&&(e=e.sort(((e,n)=>t.sort(e,n,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 n=t.labels,i=nn(n.font),s=i.size,o=this._computeTitleHeight(),{boxWidth:a,itemHeight:r}=ea(n,s);let l,c;e.font=i.string,this.isHorizontal()?(l=this.maxWidth,c=this._fitRows(o,s,a,r)+10):(c=this.maxHeight,l=this._fitCols(o,i,a,r)+10),this.width=Math.min(l,t.maxWidth||this.maxWidth),this.height=Math.min(c,t.maxHeight||this.maxHeight)}_fitRows(t,e,n,i){const{ctx:s,maxWidth:o,options:{labels:{padding:a}}}=this,r=this.legendHitBoxes=[],l=this.lineWidths=[0],c=i+a;let d=t;s.textAlign="left",s.textBaseline="middle";let h=-1,u=-c;return this.legendItems.forEach(((t,g)=>{const p=n+e/2+s.measureText(t.text).width;(0===g||l[l.length-1]+p+2*a>o)&&(d+=c,l[l.length-(g>0?0:1)]=0,u+=c,h++),r[g]={left:0,top:u,row:h,width:p,height:i},l[l.length-1]+=p+a})),d}_fitCols(t,e,n,i){const{ctx:s,maxHeight:o,options:{labels:{padding:a}}}=this,r=this.legendHitBoxes=[],l=this.columnSizes=[],c=o-t;let d=a,h=0,u=0,g=0,p=0;return this.legendItems.forEach(((t,o)=>{const{itemWidth:m,itemHeight:f}=function(t,e,n,i,s){const o=function(t,e,n,i){let s=t.text;s&&"string"!=typeof s&&(s=s.reduce(((t,e)=>t.length>e.length?t:e)));return e+n.size/2+i.measureText(s).width}(i,t,e,n),a=function(t,e,n){let i=t;"string"!=typeof e.text&&(i=ia(e,n));return i}(s,i,e.lineHeight);return{itemWidth:o,itemHeight:a}}(n,e,s,t,i);o>0&&u+f+2*a>c&&(d+=h+a,l.push({width:h,height:u}),g+=h+a,p++,h=u=0),r[o]={left:g,top:u,col:p,width:m,height:f},h=Math.max(h,m),u+=f+a})),d+=h,l.push({width:h,height:u}),d}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:n,labels:{padding:i},rtl:s}}=this,o=qn(s,this.left,this.width);if(this.isHorizontal()){let s=0,a=ue(n,this.left+i,this.right-this.lineWidths[s]);for(const r of e)s!==r.row&&(s=r.row,a=ue(n,this.left+i,this.right-this.lineWidths[s])),r.top+=this.top+t+i,r.left=o.leftForLtr(o.x(a),r.width),a+=r.width+i}else{let s=0,a=ue(n,this.top+t+i,this.bottom-this.columnSizes[s].height);for(const r of e)r.col!==s&&(s=r.col,a=ue(n,this.top+t+i,this.bottom-this.columnSizes[s].height)),r.top=a,r.left+=this.left+i,r.left=o.leftForLtr(o.x(r.left),r.width),a+=r.height+i}}isHorizontal(){return"top"===this.options.position||"bottom"===this.options.position}draw(){if(this.options.display){const t=this.ctx;Be(t,this),this._draw(),qe(t)}}_draw(){const{options:t,columnSizes:e,lineWidths:n,ctx:i}=this,{align:s,labels:o}=t,a=Ie.color,r=qn(t.rtl,this.left,this.width),l=nn(o.font),{padding:c}=o,d=l.size,h=d/2;let u;this.drawTitle(),i.textAlign=r.textAlign("left"),i.textBaseline="middle",i.lineWidth=.5,i.font=l.string;const{boxWidth:g,boxHeight:p,itemHeight:m}=ea(o,d),f=this.isHorizontal(),b=this._computeTitleHeight();u=f?{x:ue(s,this.left+c,this.right-n[0]),y:this.top+c+b,line:0}:{x:this.left+c,y:ue(s,this.top+b+c,this.bottom-e[0].height),line:0},Hn(this.ctx,t.textDirection);const y=m+c;this.legendItems.forEach(((x,v)=>{i.strokeStyle=x.fontColor,i.fillStyle=x.fontColor;const w=i.measureText(x.text).width,k=r.textAlign(x.textAlign||(x.textAlign=o.textAlign)),S=g+h+w;let M=u.x,C=u.y;r.setWidth(this.width),f?v>0&&M+S+c>this.right&&(C=u.y+=y,u.line++,M=u.x=ue(s,this.left+c,this.right-n[u.line])):v>0&&C+y>this.bottom&&(M=u.x=M+e[u.line].width+c,u.line++,C=u.y=ue(s,this.top+b+c,this.bottom-e[u.line].height));if(function(t,e,n){if(isNaN(g)||g<=0||isNaN(p)||p<0)return;i.save();const s=ft(n.lineWidth,1);if(i.fillStyle=ft(n.fillStyle,a),i.lineCap=ft(n.lineCap,"butt"),i.lineDashOffset=ft(n.lineDashOffset,0),i.lineJoin=ft(n.lineJoin,"miter"),i.lineWidth=s,i.strokeStyle=ft(n.strokeStyle,a),i.setLineDash(ft(n.lineDash,[])),o.usePointStyle){const a={radius:p*Math.SQRT2/2,pointStyle:n.pointStyle,rotation:n.rotation,borderWidth:s},l=r.xPlus(t,g/2);$e(i,a,l,e+h,o.pointStyleWidth&&g)}else{const o=e+Math.max((d-p)/2,0),a=r.leftForLtr(t,g),l=tn(n.borderRadius);i.beginPath(),Object.values(l).some((t=>0!==t))?Xe(i,{x:a,y:o,w:g,h:p,radius:l}):i.rect(a,o,g,p),i.fill(),0!==s&&i.stroke()}i.restore()}(r.x(M),C,x),M=((t,e,n,i)=>t===(i?"left":"right")?n:"center"===t?(e+n)/2:e)(k,M+g+h,f?M+S:this.right,t.rtl),function(t,e,n){Ue(i,n.text,t,e+m/2,l,{strikethrough:n.hidden,textAlign:r.textAlign(n.textAlign)})}(r.x(M),C,x),f)u.x+=S+c;else if("string"!=typeof x.text){const t=l.lineHeight;u.y+=ia(x,t)+c}else u.y+=y})),Vn(this.ctx,t.textDirection)}drawTitle(){const t=this.options,e=t.title,n=nn(e.font),i=en(e.padding);if(!e.display)return;const s=qn(t.rtl,this.left,this.width),o=this.ctx,a=e.position,r=n.size/2,l=i.top+r;let c,d=this.left,h=this.width;if(this.isHorizontal())h=Math.max(...this.lineWidths),c=this.top+l,d=ue(t.align,d,this.right-h);else{const e=this.columnSizes.reduce(((t,e)=>Math.max(t,e.height)),0);c=l+ue(t.align,this.top,this.bottom-e-t.labels.padding-this._computeTitleHeight())}const u=ue(a,d,d+h);o.textAlign=s.textAlign(he(a)),o.textBaseline="middle",o.strokeStyle=e.color,o.fillStyle=e.color,o.font=n.string,Ue(o,e.text,u,c,n)}_computeTitleHeight(){const t=this.options.title,e=nn(t.font),n=en(t.padding);return t.display?e.lineHeight+n.height:0}_getLegendItemAt(t,e){let n,i,s;if(ne(t,this.left,this.right)&&ne(e,this.top,this.bottom))for(s=this.legendHitBoxes,n=0;n<s.length;++n)if(i=s[n],ne(t,i.left,i.left+i.width)&&ne(e,i.top,i.top+i.height))return this.legendItems[n];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 n=this._getLegendItemAt(t.x,t.y);if("mousemove"===t.type||"mouseout"===t.type){const o=this._hoveredItem,a=(s=n,null!==(i=o)&&null!==s&&i.datasetIndex===s.datasetIndex&&i.index===s.index);o&&!a&&yt(e.onLeave,[t,o,this],this),this._hoveredItem=n,n&&!a&&yt(e.onHover,[t,n,this],this)}else n&&yt(e.onClick,[t,n,this],this);var i,s}}function ia(t,e){return e*(t.text?t.text.length:0)}var sa={id:"legend",_element:na,start(t,e,n){const i=t.legend=new na({ctx:t.ctx,options:n,chart:t});Zi.configure(t,i,n),Zi.addBox(t,i)},stop(t){Zi.removeBox(t,t.legend),delete t.legend},beforeUpdate(t,e,n){const i=t.legend;Zi.configure(t,i,n),i.options=n},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,n){const i=e.datasetIndex,s=n.chart;s.isDatasetVisible(i)?(s.hide(i),e.hidden=!0):(s.show(i),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:n,pointStyle:i,textAlign:s,color:o,useBorderRadius:a,borderRadius:r}}=t.legend.options;return t._getSortedDatasetMetas().map((t=>{const l=t.controller.getStyle(n?0:void 0),c=en(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:(c.width+c.height)/4,strokeStyle:l.borderColor,pointStyle:i||l.pointStyle,rotation:l.rotation,textAlign:s||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 oa extends fs{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 n=this.options;if(this.left=0,this.top=0,!n.display)return void(this.width=this.height=this.right=this.bottom=0);this.width=this.right=t,this.height=this.bottom=e;const i=ut(n.text)?n.text.length:1;this._padding=en(n.padding);const s=i*nn(n.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=s:this.width=s}isHorizontal(){const t=this.options.position;return"top"===t||"bottom"===t}_drawArgs(t){const{top:e,left:n,bottom:i,right:s,options:o}=this,a=o.align;let r,l,c,d=0;return this.isHorizontal()?(l=ue(a,n,s),c=e+t,r=s-n):("left"===o.position?(l=n+t,c=ue(a,i,e),d=-.5*It):(l=s-t,c=ue(a,e,i),d=.5*It),r=i-e),{titleX:l,titleY:c,maxWidth:r,rotation:d}}draw(){const t=this.ctx,e=this.options;if(!e.display)return;const n=nn(e.font),i=n.lineHeight/2+this._padding.top,{titleX:s,titleY:o,maxWidth:a,rotation:r}=this._drawArgs(i);Ue(t,e.text,0,0,n,{color:e.color,maxWidth:a,rotation:r,textAlign:he(e.align),textBaseline:"middle",translation:[s,o]})}}var aa={id:"title",_element:oa,start(t,e,n){!function(t,e){const n=new oa({ctx:t.ctx,options:e,chart:t});Zi.configure(t,n,e),Zi.addBox(t,n),t.titleBlock=n}(t,n)},stop(t){const e=t.titleBlock;Zi.removeBox(t,e),delete t.titleBlock},beforeUpdate(t,e,n){const i=t.titleBlock;Zi.configure(t,i,n),i.options=n},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 ra=new WeakMap;var la={id:"subtitle",start(t,e,n){const i=new oa({ctx:t.ctx,options:n,chart:t});Zi.configure(t,i,n),Zi.addBox(t,i),ra.set(t,i)},stop(t){Zi.removeBox(t,ra.get(t)),ra.delete(t)},beforeUpdate(t,e,n){const i=ra.get(t);Zi.configure(t,i,n),i.options=n},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 ca={average(t){if(!t.length)return!1;let e,n,i=new Set,s=0,o=0;for(e=0,n=t.length;e<n;++e){const n=t[e].element;if(n&&n.hasValue()){const t=n.tooltipPosition();i.add(t.x),s+=t.y,++o}}if(0===o||0===i.size)return!1;return{x:[...i].reduce(((t,e)=>t+e))/i.size,y:s/o}},nearest(t,e){if(!t.length)return!1;let n,i,s,o=e.x,a=e.y,r=Number.POSITIVE_INFINITY;for(n=0,i=t.length;n<i;++n){const i=t[n].element;if(i&&i.hasValue()){const t=Kt(e,i.getCenterPoint());t<r&&(r=t,s=i)}}if(s){const t=s.tooltipPosition();o=t.x,a=t.y}return{x:o,y:a}}};function da(t,e){return e&&(ut(e)?Array.prototype.push.apply(t,e):t.push(e)),t}function ha(t){return("string"==typeof t||t instanceof String)&&t.indexOf("\n")>-1?t.split("\n"):t}function ua(t,e){const{element:n,datasetIndex:i,index:s}=e,o=t.getDatasetMeta(i).controller,{label:a,value:r}=o.getLabelAndValue(s);return{chart:t,label:a,parsed:o.getParsed(s),raw:t.data.datasets[i].data[s],formattedValue:r,dataset:o.getDataset(),dataIndex:s,datasetIndex:i,element:n}}function ga(t,e){const n=t.chart.ctx,{body:i,footer:s,title:o}=t,{boxWidth:a,boxHeight:r}=e,l=nn(e.bodyFont),c=nn(e.titleFont),d=nn(e.footerFont),h=o.length,u=s.length,g=i.length,p=en(e.padding);let m=p.height,f=0,b=i.reduce(((t,e)=>t+e.before.length+e.lines.length+e.after.length),0);if(b+=t.beforeBody.length+t.afterBody.length,h&&(m+=h*c.lineHeight+(h-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}u&&(m+=e.footerMarginTop+u*d.lineHeight+(u-1)*e.footerSpacing);let y=0;const x=function(t){f=Math.max(f,n.measureText(t).width+y)};return n.save(),n.font=c.string,xt(t.title,x),n.font=l.string,xt(t.beforeBody.concat(t.afterBody),x),y=e.displayColors?a+2+e.boxPadding:0,xt(i,(t=>{xt(t.before,x),xt(t.lines,x),xt(t.after,x)})),y=0,n.font=d.string,xt(t.footer,x),n.restore(),f+=p.width,{width:f,height:m}}function pa(t,e,n,i){const{x:s,width:o}=n,{width:a,chartArea:{left:r,right:l}}=t;let c="center";return"center"===i?c=s<=(r+l)/2?"left":"right":s<=o/2?c="left":s>=a-o/2&&(c="right"),function(t,e,n,i){const{x:s,width:o}=i,a=n.caretSize+n.caretPadding;return"left"===t&&s+o+a>e.width||"right"===t&&s-o-a<0||void 0}(c,t,e,n)&&(c="center"),c}function ma(t,e,n){const i=n.yAlign||e.yAlign||function(t,e){const{y:n,height:i}=e;return n<i/2?"top":n>t.height-i/2?"bottom":"center"}(t,n);return{xAlign:n.xAlign||e.xAlign||pa(t,e,n,i),yAlign:i}}function fa(t,e,n,i){const{caretSize:s,caretPadding:o,cornerRadius:a}=t,{xAlign:r,yAlign:l}=n,c=s+o,{topLeft:d,topRight:h,bottomLeft:u,bottomRight:g}=tn(a);let p=function(t,e){let{x:n,width:i}=t;return"right"===e?n-=i:"center"===e&&(n-=i/2),n}(e,r);const m=function(t,e,n){let{y:i,height:s}=t;return"top"===e?i+=n:i-="bottom"===e?s+n:s/2,i}(e,l,c);return"center"===l?"left"===r?p+=c:"right"===r&&(p-=c):"left"===r?p-=Math.max(d,u)+s:"right"===r&&(p+=Math.max(h,g)+s),{x:ee(p,0,i.width-e.width),y:ee(m,0,i.height-e.height)}}function ba(t,e,n){const i=en(n.padding);return"center"===e?t.x+t.width/2:"right"===e?t.x+t.width-i.right:t.x+i.left}function ya(t){return da([],ha(t))}function xa(t,e){const n=e&&e.dataset&&e.dataset.tooltip&&e.dataset.tooltip.callbacks;return n?t.override(n):t}const va={beforeTitle:ct,title(t){if(t.length>0){const e=t[0],n=e.chart.data.labels,i=n?n.length:0;if(this&&this.options&&"dataset"===this.options.mode)return e.dataset.label||"";if(e.label)return e.label;if(i>0&&e.dataIndex<i)return n[e.dataIndex]}return""},afterTitle:ct,beforeBody:ct,beforeLabel:ct,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 n=t.formattedValue;return ht(n)||(e+=n),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:ct,afterBody:ct,beforeFooter:ct,footer:ct,afterFooter:ct};function wa(t,e,n,i){const s=t[e].call(n,i);return void 0===s?va[e].call(n,i):s}class ka extends fs{static positioners=ca;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,n=this.options.setContext(this.getContext()),i=n.enabled&&e.options.animation&&n.animations,s=new oi(this.chart,i);return i._cacheable&&(this._cachedAnimations=Object.freeze(s)),s}getContext(){return this.$context||(this.$context=(t=this.chart.getContext(),e=this,n=this._tooltipItems,on(t,{tooltip:e,tooltipItems:n,type:"tooltip"})));var t,e,n}getTitle(t,e){const{callbacks:n}=e,i=wa(n,"beforeTitle",this,t),s=wa(n,"title",this,t),o=wa(n,"afterTitle",this,t);let a=[];return a=da(a,ha(i)),a=da(a,ha(s)),a=da(a,ha(o)),a}getBeforeBody(t,e){return ya(wa(e.callbacks,"beforeBody",this,t))}getBody(t,e){const{callbacks:n}=e,i=[];return xt(t,(t=>{const e={before:[],lines:[],after:[]},s=xa(n,t);da(e.before,ha(wa(s,"beforeLabel",this,t))),da(e.lines,wa(s,"label",this,t)),da(e.after,ha(wa(s,"afterLabel",this,t))),i.push(e)})),i}getAfterBody(t,e){return ya(wa(e.callbacks,"afterBody",this,t))}getFooter(t,e){const{callbacks:n}=e,i=wa(n,"beforeFooter",this,t),s=wa(n,"footer",this,t),o=wa(n,"afterFooter",this,t);let a=[];return a=da(a,ha(i)),a=da(a,ha(s)),a=da(a,ha(o)),a}_createItems(t){const e=this._active,n=this.chart.data,i=[],s=[],o=[];let a,r,l=[];for(a=0,r=e.length;a<r;++a)l.push(ua(this.chart,e[a]));return t.filter&&(l=l.filter(((e,i,s)=>t.filter(e,i,s,n)))),t.itemSort&&(l=l.sort(((e,i)=>t.itemSort(e,i,n)))),xt(l,(e=>{const n=xa(t.callbacks,e);i.push(wa(n,"labelColor",this,e)),s.push(wa(n,"labelPointStyle",this,e)),o.push(wa(n,"labelTextColor",this,e))})),this.labelColors=i,this.labelPointStyles=s,this.labelTextColors=o,this.dataPoints=l,l}update(t,e){const n=this.options.setContext(this.getContext()),i=this._active;let s,o=[];if(i.length){const t=ca[n.position].call(this,i,this._eventPosition);o=this._createItems(n),this.title=this.getTitle(o,n),this.beforeBody=this.getBeforeBody(o,n),this.body=this.getBody(o,n),this.afterBody=this.getAfterBody(o,n),this.footer=this.getFooter(o,n);const e=this._size=ga(this,n),a=Object.assign({},t,e),r=ma(this.chart,n,a),l=fa(n,a,r,this.chart);this.xAlign=r.xAlign,this.yAlign=r.yAlign,s={opacity:1,x:l.x,y:l.y,width:e.width,height:e.height,caretX:t.x,caretY:t.y}}else 0!==this.opacity&&(s={opacity:0});this._tooltipItems=o,this.$context=void 0,s&&this._resolveAnimations().update(this,s),t&&n.external&&n.external.call(this,{chart:this.chart,tooltip:this,replay:e})}drawCaret(t,e,n,i){const s=this.getCaretPosition(t,n,i);e.lineTo(s.x1,s.y1),e.lineTo(s.x2,s.y2),e.lineTo(s.x3,s.y3)}getCaretPosition(t,e,n){const{xAlign:i,yAlign:s}=this,{caretSize:o,cornerRadius:a}=n,{topLeft:r,topRight:l,bottomLeft:c,bottomRight:d}=tn(a),{x:h,y:u}=t,{width:g,height:p}=e;let m,f,b,y,x,v;return"center"===s?(x=u+p/2,"left"===i?(m=h,f=m-o,y=x+o,v=x-o):(m=h+g,f=m+o,y=x-o,v=x+o),b=m):(f="left"===i?h+Math.max(r,c)+o:"right"===i?h+g-Math.max(l,d)-o:this.caretX,"top"===s?(y=u,x=y-o,m=f-o,b=f+o):(y=u+p,x=y+o,m=f+o,b=f-o),v=y),{x1:m,x2:f,x3:b,y1:y,y2:x,y3:v}}drawTitle(t,e,n){const i=this.title,s=i.length;let o,a,r;if(s){const l=qn(n.rtl,this.x,this.width);for(t.x=ba(this,n.titleAlign,n),e.textAlign=l.textAlign(n.titleAlign),e.textBaseline="middle",o=nn(n.titleFont),a=n.titleSpacing,e.fillStyle=n.titleColor,e.font=o.string,r=0;r<s;++r)e.fillText(i[r],l.x(t.x),t.y+o.lineHeight/2),t.y+=o.lineHeight+a,r+1===s&&(t.y+=n.titleMarginBottom-a)}}_drawColorBox(t,e,n,i,s){const o=this.labelColors[n],a=this.labelPointStyles[n],{boxHeight:r,boxWidth:l}=s,c=nn(s.bodyFont),d=ba(this,"left",s),h=i.x(d),u=r<c.lineHeight?(c.lineHeight-r)/2:0,g=e.y+u;if(s.usePointStyle){const e={radius:Math.min(l,r)/2,pointStyle:a.pointStyle,rotation:a.rotation,borderWidth:1},n=i.leftForLtr(h,l)+l/2,c=g+r/2;t.strokeStyle=s.multiKeyBackground,t.fillStyle=s.multiKeyBackground,Re(t,e,n,c),t.strokeStyle=o.borderColor,t.fillStyle=o.backgroundColor,Re(t,e,n,c)}else{t.lineWidth=gt(o.borderWidth)?Math.max(...Object.values(o.borderWidth)):o.borderWidth||1,t.strokeStyle=o.borderColor,t.setLineDash(o.borderDash||[]),t.lineDashOffset=o.borderDashOffset||0;const e=i.leftForLtr(h,l),n=i.leftForLtr(i.xPlus(h,1),l-2),a=tn(o.borderRadius);Object.values(a).some((t=>0!==t))?(t.beginPath(),t.fillStyle=s.multiKeyBackground,Xe(t,{x:e,y:g,w:l,h:r,radius:a}),t.fill(),t.stroke(),t.fillStyle=o.backgroundColor,t.beginPath(),Xe(t,{x:n,y:g+1,w:l-2,h:r-2,radius:a}),t.fill()):(t.fillStyle=s.multiKeyBackground,t.fillRect(e,g,l,r),t.strokeRect(e,g,l,r),t.fillStyle=o.backgroundColor,t.fillRect(n,g+1,l-2,r-2))}t.fillStyle=this.labelTextColors[n]}drawBody(t,e,n){const{body:i}=this,{bodySpacing:s,bodyAlign:o,displayColors:a,boxHeight:r,boxWidth:l,boxPadding:c}=n,d=nn(n.bodyFont);let h=d.lineHeight,u=0;const g=qn(n.rtl,this.x,this.width),p=function(n){e.fillText(n,g.x(t.x+u),t.y+h/2),t.y+=h+s},m=g.textAlign(o);let f,b,y,x,v,w,k;for(e.textAlign=o,e.textBaseline="middle",e.font=d.string,t.x=ba(this,m,n),e.fillStyle=n.bodyColor,xt(this.beforeBody,p),u=a&&"right"!==m?"center"===o?l/2+c:l+2+c:0,x=0,w=i.length;x<w;++x){for(f=i[x],b=this.labelTextColors[x],e.fillStyle=b,xt(f.before,p),y=f.lines,a&&y.length&&(this._drawColorBox(e,t,x,g,n),h=Math.max(d.lineHeight,r)),v=0,k=y.length;v<k;++v)p(y[v]),h=d.lineHeight;xt(f.after,p)}u=0,h=d.lineHeight,xt(this.afterBody,p),t.y-=s}drawFooter(t,e,n){const i=this.footer,s=i.length;let o,a;if(s){const r=qn(n.rtl,this.x,this.width);for(t.x=ba(this,n.footerAlign,n),t.y+=n.footerMarginTop,e.textAlign=r.textAlign(n.footerAlign),e.textBaseline="middle",o=nn(n.footerFont),e.fillStyle=n.footerColor,e.font=o.string,a=0;a<s;++a)e.fillText(i[a],r.x(t.x),t.y+o.lineHeight/2),t.y+=o.lineHeight+n.footerSpacing}}drawBackground(t,e,n,i){const{xAlign:s,yAlign:o}=this,{x:a,y:r}=t,{width:l,height:c}=n,{topLeft:d,topRight:h,bottomLeft:u,bottomRight:g}=tn(i.cornerRadius);e.fillStyle=i.backgroundColor,e.strokeStyle=i.borderColor,e.lineWidth=i.borderWidth,e.beginPath(),e.moveTo(a+d,r),"top"===o&&this.drawCaret(t,e,n,i),e.lineTo(a+l-h,r),e.quadraticCurveTo(a+l,r,a+l,r+h),"center"===o&&"right"===s&&this.drawCaret(t,e,n,i),e.lineTo(a+l,r+c-g),e.quadraticCurveTo(a+l,r+c,a+l-g,r+c),"bottom"===o&&this.drawCaret(t,e,n,i),e.lineTo(a+u,r+c),e.quadraticCurveTo(a,r+c,a,r+c-u),"center"===o&&"left"===s&&this.drawCaret(t,e,n,i),e.lineTo(a,r+d),e.quadraticCurveTo(a,r,a+d,r),e.closePath(),e.fill(),i.borderWidth>0&&e.stroke()}_updateAnimationTarget(t){const e=this.chart,n=this.$animations,i=n&&n.x,s=n&&n.y;if(i||s){const n=ca[t.position].call(this,this._active,this._eventPosition);if(!n)return;const o=this._size=ga(this,t),a=Object.assign({},n,this._size),r=ma(e,t,a),l=fa(t,a,r,e);i._to===l.x&&s._to===l.y||(this.xAlign=r.xAlign,this.yAlign=r.yAlign,this.width=o.width,this.height=o.height,this.caretX=n.x,this.caretY=n.y,this._resolveAnimations().update(this,l))}}_willRender(){return!!this.opacity}draw(t){const e=this.options.setContext(this.getContext());let n=this.opacity;if(!n)return;this._updateAnimationTarget(e);const i={width:this.width,height:this.height},s={x:this.x,y:this.y};n=Math.abs(n)<.001?0:n;const o=en(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=n,this.drawBackground(s,t,i,e),Hn(t,e.textDirection),s.y+=o.top,this.drawTitle(s,t,e),this.drawBody(s,t,e),this.drawFooter(s,t,e),Vn(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const n=this._active,i=t.map((({datasetIndex:t,index:e})=>{const n=this.chart.getDatasetMeta(t);if(!n)throw new Error("Cannot find a dataset at index "+t);return{datasetIndex:t,element:n.data[e],index:e}})),s=!vt(n,i),o=this._positionChanged(i,e);(s||o)&&(this._active=i,this._eventPosition=e,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,e,n=!0){if(e&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const i=this.options,s=this._active||[],o=this._getActiveElements(t,s,e,n),a=this._positionChanged(o,t),r=e||!vt(o,s)||a;return r&&(this._active=o,(i.enabled||i.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),r}_getActiveElements(t,e,n,i){const s=this.options;if("mouseout"===t.type)return[];if(!i)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,s.mode,s,n);return s.reverse&&o.reverse(),o}_positionChanged(t,e){const{caretX:n,caretY:i,options:s}=this,o=ca[s.position].call(this,t,e);return!1!==o&&(n!==o.x||i!==o.y)}}var Sa={id:"tooltip",_element:ka,positioners:ca,afterInit(t,e,n){n&&(t.tooltip=new ka({chart:t,options:n}))},beforeUpdate(t,e,n){t.tooltip&&t.tooltip.initialize(n)},reset(t,e,n){t.tooltip&&t.tooltip.initialize(n)},afterDraw(t){const e=t.tooltip;if(e&&e._willRender()){const n={tooltip:e};if(!1===t.notifyPlugins("beforeTooltipDraw",{...n,cancelable:!0}))return;e.draw(t.ctx),t.notifyPlugins("afterTooltipDraw",n)}},afterEvent(t,e){if(t.tooltip){const n=e.replay;t.tooltip.handleEvent(e.event,n,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:va},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"]},Ma=Object.freeze({__proto__:null,Colors:Io,Decimation:Wo,Filler:ta,Legend:sa,SubTitle:la,Title:aa,Tooltip:Sa});function Ca(t,e,n,i){const s=t.indexOf(e);if(-1===s)return((t,e,n,i)=>("string"==typeof e?(n=t.push(e)-1,i.unshift({index:n,label:e})):isNaN(e)&&(n=null),n))(t,e,n,i);return s!==t.lastIndexOf(e)?n:s}function _a(t){const e=this.getLabels();return t>=0&&t<e.length?e[t]:t}function Ta(t,e){const n=[],{bounds:i,step:s,min:o,max:a,precision:r,count:l,maxTicks:c,maxDigits:d,includeBounds:h}=t,u=s||1,g=c-1,{min:p,max:m}=e,f=!ht(o),b=!ht(a),y=!ht(l),x=(m-p)/(d+1);let v,w,k,S,M=Vt((m-p)/g/u)*u;if(M<1e-14&&!f&&!b)return[{value:p},{value:m}];S=Math.ceil(m/M)-Math.floor(p/M),S>g&&(M=Vt(S*M/g/u)*u),ht(r)||(v=Math.pow(10,r),M=Math.ceil(M*v)/v),"ticks"===i?(w=Math.floor(p/M)*M,k=Math.ceil(m/M)*M):(w=p,k=m),f&&b&&s&&function(t,e){const n=Math.round(t);return n-e<=t&&n+e>=t}((a-o)/s,M/1e3)?(S=Math.round(Math.min((a-o)/M,c)),M=(a-o)/S,w=o,k=a):y?(w=f?o:w,k=b?a:k,S=l-1,M=(k-w)/S):(S=(k-w)/M,S=Ht(S,Math.round(S),M/1e3)?Math.round(S):Math.ceil(S));const C=Math.max(Qt(M),Qt(w));v=Math.pow(10,ht(r)?C:r),w=Math.round(w*v)/v,k=Math.round(k*v)/v;let _=0;for(f&&(h&&w!==o?(n.push({value:o}),w<o&&_++,Ht(Math.round((w+_*M)*v)/v,o,Da(o,x,t))&&_++):w<o&&_++);_<S;++_){const t=Math.round((w+_*M)*v)/v;if(b&&t>a)break;n.push({value:t})}return b&&h&&k!==a?n.length&&Ht(n[n.length-1].value,a,Da(a,x,t))?n[n.length-1].value=a:n.push({value:a}):b&&k!==a||n.push({value:k}),n}function Da(t,e,{horizontal:n,minRotation:i}){const s=Ut(i),o=(n?Math.sin(s):Math.cos(s))||.001,a=.75*e*(""+t).length;return Math.min(e/o,a)}class Pa extends _s{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 ht(t)||("number"==typeof t||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:e,maxDefined:n}=this.getUserBounds();let{min:i,max:s}=this;const o=t=>i=e?i:t,a=t=>s=n?s:t;if(t){const t=qt(i),e=qt(s);t<0&&e<0?a(0):t>0&&e>0&&o(0)}if(i===s){let e=0===s?1:Math.abs(.05*s);a(s+e),t||o(i-e)}this.min=i,this.max=s}getTickLimit(){const t=this.options.ticks;let e,{maxTicksLimit:n,stepSize:i}=t;return i?(e=Math.ceil(this.max/i)-Math.floor(this.min/i)+1,e>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${i} would result generating up to ${e} ticks. Limiting to 1000.`),e=1e3)):(e=this.computeTickLimit(),n=n||11),n&&(e=Math.min(n,e)),e}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,e=t.ticks;let n=this.getTickLimit();n=Math.max(2,n);const i=Ta({maxTicks:n,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&&jt(i,this,"value"),t.reverse?(i.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),i}configure(){const t=this.ticks;let e=this.min,n=this.max;if(super.configure(),this.options.offset&&t.length){const i=(n-e)/Math.max(t.length-1,1)/2;e-=i,n+=i}this._startValue=e,this._endValue=n,this._valueRange=n-e}getLabelForValue(t){return Ce(t,this.chart.options.locale,this.options.ticks.format)}}class Ea extends Pa{static id="linear";static defaults={ticks:{callback:Te.formatters.numeric}};determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=pt(t)?t:0,this.max=pt(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),e=t?this.width:this.height,n=Ut(this.options.ticks.minRotation),i=(t?Math.sin(n):Math.cos(n))||.001,s=this._resolveTickFontOptions(0);return Math.ceil(e/Math.min(40,s.lineHeight/i))}getPixelForValue(t){return null===t?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}const La=t=>Math.floor(Bt(t)),Aa=(t,e)=>Math.pow(10,La(t)+e);function Ia(t){return 1===t/Math.pow(10,La(t))}function za(t,e,n){const i=Math.pow(10,n),s=Math.floor(t/i);return Math.ceil(e/i)-s}function Oa(t,{min:e,max:n}){e=mt(t.min,e);const i=[],s=La(e);let o=function(t,e){let n=La(e-t);for(;za(t,e,n)>10;)n++;for(;za(t,e,n)<10;)n--;return Math.min(n,La(t))}(e,n),a=o<0?Math.pow(10,Math.abs(o)):1;const r=Math.pow(10,o),l=s>o?Math.pow(10,s):0,c=Math.round((e-l)*a)/a,d=Math.floor((e-l)/r/10)*r*10;let h=Math.floor((c-d)/Math.pow(10,o)),u=mt(t.min,Math.round((l+d+h*Math.pow(10,o))*a)/a);for(;u<n;)i.push({value:u,major:Ia(u),significand:h}),h>=10?h=h<15?15:20:h++,h>=20&&(o++,h=2,a=o>=0?1:a),u=Math.round((l+d+h*Math.pow(10,o))*a)/a;const g=mt(t.max,u);return i.push({value:g,major:Ia(g),significand:h}),i}class Wa extends _s{static id="logarithmic";static defaults={ticks:{callback:Te.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 n=Pa.prototype.parse.apply(this,[t,e]);if(0!==n)return pt(n)&&n>0?n:null;this._zero=!0}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=pt(t)?Math.max(0,t):null,this.max=pt(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!pt(this._userMin)&&(this.min=t===Aa(this.min,0)?Aa(this.min,-1):Aa(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let n=this.min,i=this.max;const s=e=>n=t?n:e,o=t=>i=e?i:t;n===i&&(n<=0?(s(1),o(10)):(s(Aa(n,-1)),o(Aa(i,1)))),n<=0&&s(Aa(i,-1)),i<=0&&o(Aa(n,1)),this.min=n,this.max=i}buildTicks(){const t=this.options,e=Oa({min:this._userMin,max:this._userMax},this);return"ticks"===t.bounds&&jt(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":Ce(t,this.chart.options.locale,this.options.ticks.format)}configure(){const t=this.min;super.configure(),this._startValue=Bt(t),this._valueRange=Bt(this.max)-Bt(t)}getPixelForValue(t){return void 0!==t&&0!==t||(t=this.min),null===t||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(Bt(t)-this._startValue)/this._valueRange)}getValueForPixel(t){const e=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+e*this._valueRange)}}function Na(t){const e=t.ticks;if(e.display&&t.display){const t=en(e.backdropPadding);return ft(e.font&&e.font.size,Ie.font.size)+t.height}return 0}function Ra(t,e,n,i,s){return t===i||t===s?{start:e-n/2,end:e+n/2}:t<i||t>s?{start:e-n,end:e}:{start:e,end:e+n}}function $a(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},n=Object.assign({},e),i=[],s=[],o=t._pointLabels.length,a=t.options.pointLabels,r=a.centerPointLabels?It/o:0;for(let h=0;h<o;h++){const o=a.setContext(t.getPointLabelContext(h));s[h]=o.padding;const u=t.getPointPosition(h,t.drawingArea+s[h],r),g=nn(o.font),p=(l=t.ctx,c=g,d=ut(d=t._pointLabels[h])?d:[d],{w:Oe(l,c.string,d),h:d.length*c.lineHeight});i[h]=p;const m=Jt(t.getIndexAngle(h)+r),f=Math.round(Xt(m));Fa(n,e,m,Ra(f,u.x,p.w,0,180),Ra(f,u.y,p.h,90,270))}var l,c,d;t.setCenterPoint(e.l-n.l,n.r-e.r,e.t-n.t,n.b-e.b),t._pointLabelItems=function(t,e,n){const i=[],s=t._pointLabels.length,o=t.options,{centerPointLabels:a,display:r}=o.pointLabels,l={extra:Na(o)/2,additionalAngle:a?It/s:0};let c;for(let o=0;o<s;o++){l.padding=n[o],l.size=e[o];const s=Ba(t,o,l);i.push(s),"auto"===r&&(s.visible=qa(s,c),s.visible&&(c=s))}return i}(t,i,s)}function Fa(t,e,n,i,s){const o=Math.abs(Math.sin(n)),a=Math.abs(Math.cos(n));let r=0,l=0;i.start<e.l?(r=(e.l-i.start)/o,t.l=Math.min(t.l,e.l-r)):i.end>e.r&&(r=(i.end-e.r)/o,t.r=Math.max(t.r,e.r+r)),s.start<e.t?(l=(e.t-s.start)/a,t.t=Math.min(t.t,e.t-l)):s.end>e.b&&(l=(s.end-e.b)/a,t.b=Math.max(t.b,e.b+l))}function Ba(t,e,n){const i=t.drawingArea,{extra:s,additionalAngle:o,padding:a,size:r}=n,l=t.getPointPosition(e,i+s+a,o),c=Math.round(Xt(Jt(l.angle+Rt))),d=function(t,e,n){90===n||270===n?t-=e/2:(n>270||n<90)&&(t-=e);return t}(l.y,r.h,c),h=function(t){if(0===t||180===t)return"center";if(t<180)return"left";return"right"}(c),u=function(t,e,n){"right"===n?t-=e:"center"===n&&(t-=e/2);return t}(l.x,r.w,h);return{visible:!0,x:l.x,y:d,textAlign:h,left:u,top:d,right:u+r.w,bottom:d+r.h}}function qa(t,e){if(!e)return!0;const{left:n,top:i,right:s,bottom:o}=t;return!(Fe({x:n,y:i},e)||Fe({x:n,y:o},e)||Fe({x:s,y:i},e)||Fe({x:s,y:o},e))}function Ha(t,e,n){const{left:i,top:s,right:o,bottom:a}=n,{backdropColor:r}=e;if(!ht(r)){const n=tn(e.borderRadius),l=en(e.backdropPadding);t.fillStyle=r;const c=i-l.left,d=s-l.top,h=o-i+l.width,u=a-s+l.height;Object.values(n).some((t=>0!==t))?(t.beginPath(),Xe(t,{x:c,y:d,w:h,h:u,radius:n}),t.fill()):t.fillRect(c,d,h,u)}}function Va(t,e,n,i){const{ctx:s}=t;if(n)s.arc(t.xCenter,t.yCenter,e,0,zt);else{let n=t.getPointPosition(0,e);s.moveTo(n.x,n.y);for(let o=1;o<i;o++)n=t.getPointPosition(o,e),s.lineTo(n.x,n.y)}}class Ya extends Pa{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:Te.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=en(Na(this.options)/2),e=this.width=this.maxWidth-t.width,n=this.height=this.maxHeight-t.height;this.xCenter=Math.floor(this.left+e/2+t.left),this.yCenter=Math.floor(this.top+n/2+t.top),this.drawingArea=Math.floor(Math.min(e,n)/2)}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!1);this.min=pt(t)&&!isNaN(t)?t:0,this.max=pt(e)&&!isNaN(e)?e:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/Na(this.options))}generateTickLabels(t){Pa.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map(((t,e)=>{const n=yt(this.options.pointLabels.callback,[t,e],this);return n||0===n?n:""})).filter(((t,e)=>this.chart.getDataVisibility(e)))}fit(){const t=this.options;t.display&&t.pointLabels.display?$a(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,e,n,i){this.xCenter+=Math.floor((t-e)/2),this.yCenter+=Math.floor((n-i)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,e,n,i))}getIndexAngle(t){return Jt(t*(zt/(this._pointLabels.length||1))+Ut(this.options.startAngle||0))}getDistanceFromCenterForValue(t){if(ht(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(ht(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 n=e[t];return function(t,e,n){return on(t,{label:n,index:e,type:"pointLabel"})}(this.getContext(),t,n)}}getPointPosition(t,e,n=0){const i=this.getIndexAngle(t)-Rt+n;return{x:Math.cos(i)*e+this.xCenter,y:Math.sin(i)*e+this.yCenter,angle:i}}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:n,right:i,bottom:s}=this._pointLabelItems[t];return{left:e,top:n,right:i,bottom:s}}drawBackground(){const{backgroundColor:t,grid:{circular:e}}=this.options;if(t){const n=this.ctx;n.save(),n.beginPath(),Va(this,this.getDistanceFromCenterForValue(this._endValue),e,this._pointLabels.length),n.closePath(),n.fillStyle=t,n.fill(),n.restore()}}drawGrid(){const t=this.ctx,e=this.options,{angleLines:n,grid:i,border:s}=e,o=this._pointLabels.length;let a,r,l;if(e.pointLabels.display&&function(t,e){const{ctx:n,options:{pointLabels:i}}=t;for(let s=e-1;s>=0;s--){const e=t._pointLabelItems[s];if(!e.visible)continue;const o=i.setContext(t.getPointLabelContext(s));Ha(n,o,e);const a=nn(o.font),{x:r,y:l,textAlign:c}=e;Ue(n,t._pointLabels[s],r,l+a.lineHeight/2,a,{color:o.color,textAlign:c,textBaseline:"middle"})}}(this,o),i.display&&this.ticks.forEach(((t,e)=>{if(0!==e||0===e&&this.min<0){r=this.getDistanceFromCenterForValue(t.value);const n=this.getContext(e),a=i.setContext(n),l=s.setContext(n);!function(t,e,n,i,s){const o=t.ctx,a=e.circular,{color:r,lineWidth:l}=e;!a&&!i||!r||!l||n<0||(o.save(),o.strokeStyle=r,o.lineWidth=l,o.setLineDash(s.dash||[]),o.lineDashOffset=s.dashOffset,o.beginPath(),Va(t,n,a,i),o.closePath(),o.stroke(),o.restore())}(this,a,r,o,l)}})),n.display){for(t.save(),a=o-1;a>=0;a--){const i=n.setContext(this.getPointLabelContext(a)),{color:s,lineWidth:o}=i;o&&s&&(t.lineWidth=o,t.strokeStyle=s,t.setLineDash(i.borderDash),t.lineDashOffset=i.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,n=e.ticks;if(!n.display)return;const i=this.getIndexAngle(0);let s,o;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(i),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach(((i,a)=>{if(0===a&&this.min>=0&&!e.reverse)return;const r=n.setContext(this.getContext(a)),l=nn(r.font);if(s=this.getDistanceFromCenterForValue(this.ticks[a].value),r.showLabelBackdrop){t.font=l.string,o=t.measureText(i.label).width,t.fillStyle=r.backdropColor;const e=en(r.backdropPadding);t.fillRect(-o/2-e.left,-s-l.size/2-e.top,o+e.width,l.size+e.height)}Ue(t,i.label,0,-s,l,{color:r.color,strokeColor:r.textStrokeColor,strokeWidth:r.textStrokeWidth})})),t.restore()}drawTitle(){}}const ja={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}},Ua=Object.keys(ja);function Xa(t,e){return t-e}function Qa(t,e){if(ht(e))return null;const n=t._adapter,{parser:i,round:s,isoWeekday:o}=t._parseOpts;let a=e;return"function"==typeof i&&(a=i(a)),pt(a)||(a="string"==typeof i?n.parse(a,i):n.parse(a)),null===a?null:(s&&(a="week"!==s||!Yt(o)&&!0!==o?n.startOf(a,s):n.startOf(a,"isoWeek",o)),+a)}function Ga(t,e,n,i){const s=Ua.length;for(let o=Ua.indexOf(t);o<s-1;++o){const t=ja[Ua[o]],s=t.steps?t.steps:Number.MAX_SAFE_INTEGER;if(t.common&&Math.ceil((n-e)/(s*t.size))<=i)return Ua[o]}return Ua[s-1]}function Ka(t,e,n){if(n){if(n.length){const{lo:i,hi:s}=ie(n,e);t[n[i]>=e?n[i]:n[s]]=!0}}else t[e]=!0}function Za(t,e,n){const i=[],s={},o=e.length;let a,r;for(a=0;a<o;++a)r=e[a],s[r]=a,i.push({value:r,major:!1});return 0!==o&&n?function(t,e,n,i){const s=t._adapter,o=+s.startOf(e[0].value,i),a=e[e.length-1].value;let r,l;for(r=o;r<=a;r=+s.add(r,1,i))l=n[r],l>=0&&(e[l].major=!0);return e}(t,i,s,n):i}class Ja extends _s{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 n=t.time||(t.time={}),i=this._adapter=new Ai._date(t.adapters.date);i.init(e),Ct(n.displayFormats,i.formats()),this._parseOpts={parser:n.parser,round:n.round,isoWeekday:n.isoWeekday},super.init(t),this._normalized=e.normalized}parse(t,e){return void 0===t?null:Qa(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,e=this._adapter,n=t.time.unit||"day";let{min:i,max:s,minDefined:o,maxDefined:a}=this.getUserBounds();function r(t){o||isNaN(t.min)||(i=Math.min(i,t.min)),a||isNaN(t.max)||(s=Math.max(s,t.max))}o&&a||(r(this._getLabelBounds()),"ticks"===t.bounds&&"labels"===t.ticks.source||r(this.getMinMax(!1))),i=pt(i)&&!isNaN(i)?i:+e.startOf(Date.now(),n),s=pt(s)&&!isNaN(s)?s:+e.endOf(Date.now(),n)+1,this.min=Math.min(i,s-1),this.max=Math.max(i+1,s)}_getLabelBounds(){const t=this.getLabelTimestamps();let e=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],n=t[t.length-1]),{min:e,max:n}}buildTicks(){const t=this.options,e=t.time,n=t.ticks,i="labels"===n.source?this.getLabelTimestamps():this._generate();"ticks"===t.bounds&&i.length&&(this.min=this._userMin||i[0],this.max=this._userMax||i[i.length-1]);const s=this.min,o=function(t,e,n){let i=0,s=t.length;for(;i<s&&t[i]<e;)i++;for(;s>i&&t[s-1]>n;)s--;return i>0||s<t.length?t.slice(i,s):t}(i,s,this.max);return this._unit=e.unit||(n.autoSkip?Ga(e.minUnit,this.min,this.max,this._getLabelCapacity(s)):function(t,e,n,i,s){for(let o=Ua.length-1;o>=Ua.indexOf(n);o--){const n=Ua[o];if(ja[n].common&&t._adapter.diff(s,i,n)>=e-1)return n}return Ua[n?Ua.indexOf(n):0]}(this,o.length,e.minUnit,this.min,this.max)),this._majorUnit=n.major.enabled&&"year"!==this._unit?function(t){for(let e=Ua.indexOf(t)+1,n=Ua.length;e<n;++e)if(ja[Ua[e]].common)return Ua[e]}(this._unit):void 0,this.initOffsets(i),t.reverse&&o.reverse(),Za(this,o,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map((t=>+t.value)))}initOffsets(t=[]){let e,n,i=0,s=0;this.options.offset&&t.length&&(e=this.getDecimalForValue(t[0]),i=1===t.length?1-e:(this.getDecimalForValue(t[1])-e)/2,n=this.getDecimalForValue(t[t.length-1]),s=1===t.length?n:(n-this.getDecimalForValue(t[t.length-2]))/2);const o=t.length<3?.5:.25;i=ee(i,0,o),s=ee(s,0,o),this._offsets={start:i,end:s,factor:1/(i+1+s)}}_generate(){const t=this._adapter,e=this.min,n=this.max,i=this.options,s=i.time,o=s.unit||Ga(s.minUnit,e,n,this._getLabelCapacity(e)),a=ft(i.ticks.stepSize,1),r="week"===o&&s.isoWeekday,l=Yt(r)||!0===r,c={};let d,h,u=e;if(l&&(u=+t.startOf(u,"isoWeek",r)),u=+t.startOf(u,l?"day":o),t.diff(n,e,o)>1e5*a)throw new Error(e+" and "+n+" are too far apart with stepSize of "+a+" "+o);const g="data"===i.ticks.source&&this.getDataTimestamps();for(d=u,h=0;d<n;d=+t.add(d,a,o),h++)Ka(c,d,g);return d!==n&&"ticks"!==i.bounds&&1!==h||Ka(c,d,g),Object.keys(c).sort(Xa).map((t=>+t))}getLabelForValue(t){const e=this._adapter,n=this.options.time;return n.tooltipFormat?e.format(t,n.tooltipFormat):e.format(t,n.displayFormats.datetime)}format(t,e){const n=this.options.time.displayFormats,i=this._unit,s=e||n[i];return this._adapter.format(t,s)}_tickFormatFunction(t,e,n,i){const s=this.options,o=s.ticks.callback;if(o)return yt(o,[t,e,n],this);const a=s.time.displayFormats,r=this._unit,l=this._majorUnit,c=r&&a[r],d=l&&a[l],h=n[e],u=l&&d&&h&&h.major;return this._adapter.format(t,i||(u?d:c))}generateTickLabels(t){let e,n,i;for(e=0,n=t.length;e<n;++e)i=t[e],i.label=this._tickFormatFunction(i.value,e,t)}getDecimalForValue(t){return null===t?NaN:(t-this.min)/(this.max-this.min)}getPixelForValue(t){const e=this._offsets,n=this.getDecimalForValue(t);return this.getPixelForDecimal((e.start+n)*e.factor)}getValueForPixel(t){const e=this._offsets,n=this.getDecimalForPixel(t)/e.factor-e.end;return this.min+n*(this.max-this.min)}_getLabelSize(t){const e=this.options.ticks,n=this.ctx.measureText(t).width,i=Ut(this.isHorizontal()?e.maxRotation:e.minRotation),s=Math.cos(i),o=Math.sin(i),a=this._resolveTickFontOptions(0).size;return{w:n*s+a*o,h:n*o+a*s}}_getLabelCapacity(t){const e=this.options.time,n=e.displayFormats,i=n[e.unit]||n.millisecond,s=this._tickFormatFunction(t,0,Za(this,[t],this._majorUnit),i),o=this._getLabelSize(s),a=Math.floor(this.isHorizontal()?this.width/o.w:this.height/o.h)-1;return a>0?a:1}getDataTimestamps(){let t,e,n=this._cache.data||[];if(n.length)return n;const i=this.getMatchingVisibleMetas();if(this._normalized&&i.length)return this._cache.data=i[0].controller.getAllParsedValues(this);for(t=0,e=i.length;t<e;++t)n=n.concat(i[t].controller.getAllParsedValues(this));return this._cache.data=this.normalize(n)}getLabelTimestamps(){const t=this._cache.labels||[];let e,n;if(t.length)return t;const i=this.getLabels();for(e=0,n=i.length;e<n;++e)t.push(Qa(this,i[e]));return this._cache.labels=this._normalized?t:this.normalize(t)}normalize(t){return le(t.sort(Xa))}}function tr(t,e,n){let i,s,o,a,r=0,l=t.length-1;n?(e>=t[r].pos&&e<=t[l].pos&&({lo:r,hi:l}=se(t,"pos",e)),({pos:i,time:o}=t[r]),({pos:s,time:a}=t[l])):(e>=t[r].time&&e<=t[l].time&&({lo:r,hi:l}=se(t,"time",e)),({time:i,pos:o}=t[r]),({time:s,pos:a}=t[l]));const c=s-i;return c?o+(a-o)*(e-i)/c:o}var er=Object.freeze({__proto__:null,CategoryScale:class extends _s{static id="category";static defaults={ticks:{callback:_a}};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:n,label:i}of e)t[n]===i&&t.splice(n,1);this._addedLabels=[]}super.init(t)}parse(t,e){if(ht(t))return null;const n=this.getLabels();return((t,e)=>null===t?null:ee(Math.round(t),0,e))(e=isFinite(e)&&n[e]===t?e:Ca(n,t,ft(e,t),this._addedLabels),n.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let{min:n,max:i}=this.getMinMax(!0);"ticks"===this.options.bounds&&(t||(n=0),e||(i=this.getLabels().length-1)),this.min=n,this.max=i}buildTicks(){const t=this.min,e=this.max,n=this.options.offset,i=[];let s=this.getLabels();s=0===t&&e===s.length-1?s:s.slice(t,e+1),this._valueRange=Math.max(s.length-(n?0:1),1),this._startValue=this.min-(n?.5:0);for(let n=t;n<=e;n++)i.push({value:n});return i}getLabelForValue(t){return _a.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:Ea,LogarithmicScale:Wa,RadialLinearScale:Ya,TimeScale:Ja,TimeSeriesScale:class extends Ja{static id="timeseries";static defaults=Ja.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=tr(e,this.min),this._tableRange=tr(e,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:e,max:n}=this,i=[],s=[];let o,a,r,l,c;for(o=0,a=t.length;o<a;++o)l=t[o],l>=e&&l<=n&&i.push(l);if(i.length<2)return[{time:e,pos:0},{time:n,pos:1}];for(o=0,a=i.length;o<a;++o)c=i[o+1],r=i[o-1],l=i[o],Math.round((c+r)/2)!==l&&s.push({time:l,pos:o/(a-1)});return s}_generate(){const t=this.min,e=this.max;let n=super.getDataTimestamps();return n.includes(t)&&n.length||n.splice(0,0,t),n.includes(e)&&1!==n.length||n.push(e),n.sort(((t,e)=>t-e))}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const e=this.getDataTimestamps(),n=this.getLabelTimestamps();return t=e.length&&n.length?this.normalize(e.concat(n)):e.length?e:n,t=this._cache.all=t,t}getDecimalForValue(t){return(tr(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const e=this._offsets,n=this.getDecimalForPixel(t)/e.factor-e.end;return tr(this._table,n*this._tableRange+this._minPos,!0)}}});const nr=[Pi,_o,Ma,er],ir=6048e5,sr=6e4,or=36e5,ar=Symbol.for("constructDateFrom");function rr(t,e){return"function"==typeof t?t(e):t&&"object"==typeof t&&ar in t?t[ar](e):t instanceof Date?new t.constructor(e):new Date(e)}function lr(t,e){return rr(e||t,t)}function cr(t,e,n){const i=lr(t,n?.in);return isNaN(e)?rr(n?.in||t,NaN):e?(i.setDate(i.getDate()+e),i):i}function dr(t,e,n){const i=lr(t,n?.in);if(isNaN(e))return rr(n?.in||t,NaN);if(!e)return i;const s=i.getDate(),o=rr(n?.in||t,i.getTime());o.setMonth(i.getMonth()+e+1,0);return s>=o.getDate()?o:(i.setFullYear(o.getFullYear(),o.getMonth(),s),i)}function hr(t,e,n){return rr(n?.in||t,+lr(t)+e)}let ur={};function gr(){return ur}function pr(t,e){const n=gr(),i=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,s=lr(t,e?.in),o=s.getDay(),a=(o<i?7:0)+o-i;return s.setDate(s.getDate()-a),s.setHours(0,0,0,0),s}function mr(t,e){return pr(t,{...e,weekStartsOn:1})}function fr(t,e){const n=lr(t,e?.in),i=n.getFullYear(),s=rr(n,0);s.setFullYear(i+1,0,4),s.setHours(0,0,0,0);const o=mr(s),a=rr(n,0);a.setFullYear(i,0,4),a.setHours(0,0,0,0);const r=mr(a);return n.getTime()>=o.getTime()?i+1:n.getTime()>=r.getTime()?i:i-1}function br(t){const e=lr(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function yr(t,...e){const n=rr.bind(null,t||e.find((t=>"object"==typeof t)));return e.map(n)}function xr(t,e){const n=lr(t,e?.in);return n.setHours(0,0,0,0),n}function vr(t,e,n){const[i,s]=yr(n?.in,t,e),o=xr(i),a=xr(s),r=+o-br(o),l=+a-br(a);return Math.round((r-l)/864e5)}function wr(t,e){const n=+lr(t)-+lr(e);return n<0?-1:n>0?1:n}function kr(t){return!(!((e=t)instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e))&&"number"!=typeof t||isNaN(+lr(t)));var e}function Sr(t,e,n){const[i,s]=yr(n?.in,t,e),o=Mr(i,s),a=Math.abs(vr(i,s));i.setDate(i.getDate()-o*a);const r=o*(a-Number(Mr(i,s)===-o));return 0===r?0:r}function Mr(t,e){const n=t.getFullYear()-e.getFullYear()||t.getMonth()-e.getMonth()||t.getDate()-e.getDate()||t.getHours()-e.getHours()||t.getMinutes()-e.getMinutes()||t.getSeconds()-e.getSeconds()||t.getMilliseconds()-e.getMilliseconds();return n<0?-1:n>0?1:n}function Cr(t){return e=>{const n=(t?Math[t]:Math.trunc)(e);return 0===n?0:n}}function _r(t,e){return+lr(t)-+lr(e)}function Tr(t,e){const n=lr(t,e?.in);return n.setHours(23,59,59,999),n}function Dr(t,e){const n=lr(t,e?.in),i=n.getMonth();return n.setFullYear(n.getFullYear(),i+1,0),n.setHours(23,59,59,999),n}function Pr(t,e,n){const[i,s,o]=yr(n?.in,t,t,e),a=wr(s,o),r=Math.abs(function(t,e,n){const[i,s]=yr(n?.in,t,e);return 12*(i.getFullYear()-s.getFullYear())+(i.getMonth()-s.getMonth())}(s,o));if(r<1)return 0;1===s.getMonth()&&s.getDate()>27&&s.setDate(30),s.setMonth(s.getMonth()-a*r);let l=wr(s,o)===-a;(function(t,e){const n=lr(t,e?.in);return+Tr(n,e)===+Dr(n,e)})(i)&&1===r&&1===wr(i,o)&&(l=!1);const c=a*(r-+l);return 0===c?0:c}function Er(t,e,n){const[i,s]=yr(n?.in,t,e),o=wr(i,s),a=Math.abs(function(t,e,n){const[i,s]=yr(n?.in,t,e);return i.getFullYear()-s.getFullYear()}(i,s));i.setFullYear(1584),s.setFullYear(1584);const r=o*(a-+(wr(i,s)===-o));return 0===r?0:r}function Lr(t,e){const n=lr(t,e?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}const Ar={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};function Ir(t){return(e={})=>{const n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const zr={date:Ir({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:Ir({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:Ir({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Or={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function Wr(t){return(e,n)=>{let i;if("formatting"===(n?.context?String(n.context):"standalone")&&t.formattingValues){const e=t.defaultFormattingWidth||t.defaultWidth,s=n?.width?String(n.width):e;i=t.formattingValues[s]||t.formattingValues[e]}else{const e=t.defaultWidth,s=n?.width?String(n.width):t.defaultWidth;i=t.values[s]||t.values[e]}return i[t.argumentCallback?t.argumentCallback(e):e]}}const Nr={ordinalNumber:(t,e)=>{const n=Number(t),i=n%100;if(i>20||i<10)switch(i%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},era:Wr({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:Wr({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:t=>t-1}),month:Wr({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:Wr({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:Wr({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})};function Rr(t){return(e,n={})=>{const i=n.width,s=i&&t.matchPatterns[i]||t.matchPatterns[t.defaultMatchWidth],o=e.match(s);if(!o)return null;const a=o[0],r=i&&t.parsePatterns[i]||t.parsePatterns[t.defaultParseWidth],l=Array.isArray(r)?function(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return n;return}(r,(t=>t.test(a))):function(t,e){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n;return}(r,(t=>t.test(a)));let c;c=t.valueCallback?t.valueCallback(l):l,c=n.valueCallback?n.valueCallback(c):c;return{value:c,rest:e.slice(a.length)}}}const $r={ordinalNumber:(Fr={matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:t=>parseInt(t,10)},(t,e={})=>{const n=t.match(Fr.matchPattern);if(!n)return null;const i=n[0],s=t.match(Fr.parsePattern);if(!s)return null;let o=Fr.valueCallback?Fr.valueCallback(s[0]):s[0];return o=e.valueCallback?e.valueCallback(o):o,{value:o,rest:t.slice(i.length)}}),era:Rr({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:Rr({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:t=>t+1}),month:Rr({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:Rr({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:Rr({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})};var Fr;const Br={code:"en-US",formatDistance:(t,e,n)=>{let i;const s=Ar[t];return i="string"==typeof s?s:1===e?s.one:s.other.replace("{{count}}",e.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+i:i+" ago":i},formatLong:zr,formatRelative:(t,e,n,i)=>Or[t],localize:Nr,match:$r,options:{weekStartsOn:0,firstWeekContainsDate:1}};function qr(t,e){const n=lr(t,e?.in),i=+mr(n)-+function(t,e){const n=fr(t,e),i=rr(e?.in||t,0);return i.setFullYear(n,0,4),i.setHours(0,0,0,0),mr(i)}(n);return Math.round(i/ir)+1}function Hr(t,e){const n=lr(t,e?.in),i=n.getFullYear(),s=gr(),o=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,a=rr(e?.in||t,0);a.setFullYear(i+1,0,o),a.setHours(0,0,0,0);const r=pr(a,e),l=rr(e?.in||t,0);l.setFullYear(i,0,o),l.setHours(0,0,0,0);const c=pr(l,e);return+n>=+r?i+1:+n>=+c?i:i-1}function Vr(t,e){const n=lr(t,e?.in),i=+pr(n,e)-+function(t,e){const n=gr(),i=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,s=Hr(t,e),o=rr(e?.in||t,0);return o.setFullYear(s,0,i),o.setHours(0,0,0,0),pr(o,e)}(n,e);return Math.round(i/ir)+1}function Yr(t,e){return(t<0?"-":"")+Math.abs(t).toString().padStart(e,"0")}const jr={y(t,e){const n=t.getFullYear(),i=n>0?n:1-n;return Yr("yy"===e?i%100:i,e.length)},M(t,e){const n=t.getMonth();return"M"===e?String(n+1):Yr(n+1,2)},d:(t,e)=>Yr(t.getDate(),e.length),a(t,e){const n=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];default:return"am"===n?"a.m.":"p.m."}},h:(t,e)=>Yr(t.getHours()%12||12,e.length),H:(t,e)=>Yr(t.getHours(),e.length),m:(t,e)=>Yr(t.getMinutes(),e.length),s:(t,e)=>Yr(t.getSeconds(),e.length),S(t,e){const n=e.length,i=t.getMilliseconds();return Yr(Math.trunc(i*Math.pow(10,n-3)),e.length)}},Ur="midnight",Xr="noon",Qr="morning",Gr="afternoon",Kr="evening",Zr="night",Jr={G:function(t,e,n){const i=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(i,{width:"abbreviated"});case"GGGGG":return n.era(i,{width:"narrow"});default:return n.era(i,{width:"wide"})}},y:function(t,e,n){if("yo"===e){const e=t.getFullYear(),i=e>0?e:1-e;return n.ordinalNumber(i,{unit:"year"})}return jr.y(t,e)},Y:function(t,e,n,i){const s=Hr(t,i),o=s>0?s:1-s;if("YY"===e){return Yr(o%100,2)}return"Yo"===e?n.ordinalNumber(o,{unit:"year"}):Yr(o,e.length)},R:function(t,e){return Yr(fr(t),e.length)},u:function(t,e){return Yr(t.getFullYear(),e.length)},Q:function(t,e,n){const i=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(i);case"QQ":return Yr(i,2);case"Qo":return n.ordinalNumber(i,{unit:"quarter"});case"QQQ":return n.quarter(i,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(i,{width:"narrow",context:"formatting"});default:return n.quarter(i,{width:"wide",context:"formatting"})}},q:function(t,e,n){const i=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(i);case"qq":return Yr(i,2);case"qo":return n.ordinalNumber(i,{unit:"quarter"});case"qqq":return n.quarter(i,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(i,{width:"narrow",context:"standalone"});default:return n.quarter(i,{width:"wide",context:"standalone"})}},M:function(t,e,n){const i=t.getMonth();switch(e){case"M":case"MM":return jr.M(t,e);case"Mo":return n.ordinalNumber(i+1,{unit:"month"});case"MMM":return n.month(i,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(i,{width:"narrow",context:"formatting"});default:return n.month(i,{width:"wide",context:"formatting"})}},L:function(t,e,n){const i=t.getMonth();switch(e){case"L":return String(i+1);case"LL":return Yr(i+1,2);case"Lo":return n.ordinalNumber(i+1,{unit:"month"});case"LLL":return n.month(i,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(i,{width:"narrow",context:"standalone"});default:return n.month(i,{width:"wide",context:"standalone"})}},w:function(t,e,n,i){const s=Vr(t,i);return"wo"===e?n.ordinalNumber(s,{unit:"week"}):Yr(s,e.length)},I:function(t,e,n){const i=qr(t);return"Io"===e?n.ordinalNumber(i,{unit:"week"}):Yr(i,e.length)},d:function(t,e,n){return"do"===e?n.ordinalNumber(t.getDate(),{unit:"date"}):jr.d(t,e)},D:function(t,e,n){const i=function(t,e){const n=lr(t,e?.in);return vr(n,Lr(n))+1}(t);return"Do"===e?n.ordinalNumber(i,{unit:"dayOfYear"}):Yr(i,e.length)},E:function(t,e,n){const i=t.getDay();switch(e){case"E":case"EE":case"EEE":return n.day(i,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(i,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(i,{width:"short",context:"formatting"});default:return n.day(i,{width:"wide",context:"formatting"})}},e:function(t,e,n,i){const s=t.getDay(),o=(s-i.weekStartsOn+8)%7||7;switch(e){case"e":return String(o);case"ee":return Yr(o,2);case"eo":return n.ordinalNumber(o,{unit:"day"});case"eee":return n.day(s,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(s,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(s,{width:"short",context:"formatting"});default:return n.day(s,{width:"wide",context:"formatting"})}},c:function(t,e,n,i){const s=t.getDay(),o=(s-i.weekStartsOn+8)%7||7;switch(e){case"c":return String(o);case"cc":return Yr(o,e.length);case"co":return n.ordinalNumber(o,{unit:"day"});case"ccc":return n.day(s,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(s,{width:"narrow",context:"standalone"});case"cccccc":return n.day(s,{width:"short",context:"standalone"});default:return n.day(s,{width:"wide",context:"standalone"})}},i:function(t,e,n){const i=t.getDay(),s=0===i?7:i;switch(e){case"i":return String(s);case"ii":return Yr(s,e.length);case"io":return n.ordinalNumber(s,{unit:"day"});case"iii":return n.day(i,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(i,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(i,{width:"short",context:"formatting"});default:return n.day(i,{width:"wide",context:"formatting"})}},a:function(t,e,n){const i=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(i,{width:"narrow",context:"formatting"});default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(t,e,n){const i=t.getHours();let s;switch(s=12===i?Xr:0===i?Ur:i/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(s,{width:"narrow",context:"formatting"});default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},B:function(t,e,n){const i=t.getHours();let s;switch(s=i>=17?Kr:i>=12?Gr:i>=4?Qr:Zr,e){case"B":case"BB":case"BBB":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(s,{width:"narrow",context:"formatting"});default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},h:function(t,e,n){if("ho"===e){let e=t.getHours()%12;return 0===e&&(e=12),n.ordinalNumber(e,{unit:"hour"})}return jr.h(t,e)},H:function(t,e,n){return"Ho"===e?n.ordinalNumber(t.getHours(),{unit:"hour"}):jr.H(t,e)},K:function(t,e,n){const i=t.getHours()%12;return"Ko"===e?n.ordinalNumber(i,{unit:"hour"}):Yr(i,e.length)},k:function(t,e,n){let i=t.getHours();return 0===i&&(i=24),"ko"===e?n.ordinalNumber(i,{unit:"hour"}):Yr(i,e.length)},m:function(t,e,n){return"mo"===e?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):jr.m(t,e)},s:function(t,e,n){return"so"===e?n.ordinalNumber(t.getSeconds(),{unit:"second"}):jr.s(t,e)},S:function(t,e){return jr.S(t,e)},X:function(t,e,n){const i=t.getTimezoneOffset();if(0===i)return"Z";switch(e){case"X":return el(i);case"XXXX":case"XX":return nl(i);default:return nl(i,":")}},x:function(t,e,n){const i=t.getTimezoneOffset();switch(e){case"x":return el(i);case"xxxx":case"xx":return nl(i);default:return nl(i,":")}},O:function(t,e,n){const i=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+tl(i,":");default:return"GMT"+nl(i,":")}},z:function(t,e,n){const i=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+tl(i,":");default:return"GMT"+nl(i,":")}},t:function(t,e,n){return Yr(Math.trunc(+t/1e3),e.length)},T:function(t,e,n){return Yr(+t,e.length)}};function tl(t,e=""){const n=t>0?"-":"+",i=Math.abs(t),s=Math.trunc(i/60),o=i%60;return 0===o?n+String(s):n+String(s)+e+Yr(o,2)}function el(t,e){if(t%60==0){return(t>0?"-":"+")+Yr(Math.abs(t)/60,2)}return nl(t,e)}function nl(t,e=""){const n=t>0?"-":"+",i=Math.abs(t);return n+Yr(Math.trunc(i/60),2)+e+Yr(i%60,2)}const il=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});default:return e.date({width:"full"})}},sl=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});default:return e.time({width:"full"})}},ol={p:sl,P:(t,e)=>{const n=t.match(/(P+)(p+)?/)||[],i=n[1],s=n[2];if(!s)return il(t,e);let o;switch(i){case"P":o=e.dateTime({width:"short"});break;case"PP":o=e.dateTime({width:"medium"});break;case"PPP":o=e.dateTime({width:"long"});break;default:o=e.dateTime({width:"full"})}return o.replace("{{date}}",il(i,e)).replace("{{time}}",sl(s,e))}},al=/^D+$/,rl=/^Y+$/,ll=["D","DD","YY","YYYY"];function cl(t){return al.test(t)}function dl(t){return rl.test(t)}function hl(t,e,n){const i=function(t,e,n){const i="Y"===t[0]?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${i} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}(t,e,n);if(console.warn(i),ll.includes(t))throw new RangeError(i)}const ul=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,gl=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,pl=/^'([^]*?)'?$/,ml=/''/g,fl=/[a-zA-Z]/;function bl(t){const e=t.match(pl);return e?e[1].replace(ml,"'"):t}class yl{subPriority=0;validate(t,e){return!0}}class xl extends yl{constructor(t,e,n,i,s){super(),this.value=t,this.validateValue=e,this.setValue=n,this.priority=i,s&&(this.subPriority=s)}validate(t,e){return this.validateValue(t,this.value,e)}set(t,e,n){return this.setValue(t,e,this.value,n)}}class vl extends yl{priority=10;subPriority=-1;constructor(t,e){super(),this.context=t||(t=>rr(e,t))}set(t,e){return e.timestampIsSet?t:rr(t,function(t,e){const n=function(t){return"function"==typeof t&&t.prototype?.constructor===t}(e)?new e(0):rr(e,0);return n.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),n.setHours(t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()),n}(t,this.context))}}class wl{run(t,e,n,i){const s=this.parse(t,e,n,i);return s?{setter:new xl(s.value,this.validate,this.set,this.priority,this.subPriority),rest:s.rest}:null}validate(t,e,n){return!0}}const kl=/^(1[0-2]|0?\d)/,Sl=/^(3[0-1]|[0-2]?\d)/,Ml=/^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,Cl=/^(5[0-3]|[0-4]?\d)/,_l=/^(2[0-3]|[0-1]?\d)/,Tl=/^(2[0-4]|[0-1]?\d)/,Dl=/^(1[0-1]|0?\d)/,Pl=/^(1[0-2]|0?\d)/,El=/^[0-5]?\d/,Ll=/^[0-5]?\d/,Al=/^\d/,Il=/^\d{1,2}/,zl=/^\d{1,3}/,Ol=/^\d{1,4}/,Wl=/^-?\d+/,Nl=/^-?\d/,Rl=/^-?\d{1,2}/,$l=/^-?\d{1,3}/,Fl=/^-?\d{1,4}/,Bl=/^([+-])(\d{2})(\d{2})?|Z/,ql=/^([+-])(\d{2})(\d{2})|Z/,Hl=/^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,Vl=/^([+-])(\d{2}):(\d{2})|Z/,Yl=/^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/;function jl(t,e){return t?{value:e(t.value),rest:t.rest}:t}function Ul(t,e){const n=e.match(t);return n?{value:parseInt(n[0],10),rest:e.slice(n[0].length)}:null}function Xl(t,e){const n=e.match(t);if(!n)return null;if("Z"===n[0])return{value:0,rest:e.slice(1)};const i="+"===n[1]?1:-1,s=n[2]?parseInt(n[2],10):0,o=n[3]?parseInt(n[3],10):0,a=n[5]?parseInt(n[5],10):0;return{value:i*(s*or+o*sr+1e3*a),rest:e.slice(n[0].length)}}function Ql(t){return Ul(Wl,t)}function Gl(t,e){switch(t){case 1:return Ul(Al,e);case 2:return Ul(Il,e);case 3:return Ul(zl,e);case 4:return Ul(Ol,e);default:return Ul(new RegExp("^\\d{1,"+t+"}"),e)}}function Kl(t,e){switch(t){case 1:return Ul(Nl,e);case 2:return Ul(Rl,e);case 3:return Ul($l,e);case 4:return Ul(Fl,e);default:return Ul(new RegExp("^-?\\d{1,"+t+"}"),e)}}function Zl(t){switch(t){case"morning":return 4;case"evening":return 17;case"pm":case"noon":case"afternoon":return 12;default:return 0}}function Jl(t,e){const n=e>0,i=n?e:1-e;let s;if(i<=50)s=t||100;else{const e=i+50;s=t+100*Math.trunc(e/100)-(t>=e%100?100:0)}return n?s:1-s}function tc(t){return t%400==0||t%4==0&&t%100!=0}const ec=[31,28,31,30,31,30,31,31,30,31,30,31],nc=[31,29,31,30,31,30,31,31,30,31,30,31];function ic(t,e,n){const i=gr(),s=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??i.weekStartsOn??i.locale?.options?.weekStartsOn??0,o=lr(t,n?.in),a=o.getDay(),r=7-s;return cr(o,e<0||e>6?e-(a+r)%7:((e%7+7)%7+r)%7-(a+r)%7,n)}function sc(t,e,n){const i=lr(t,n?.in),s=function(t,e){const n=lr(t,e?.in).getDay();return 0===n?7:n}(i,n);return cr(i,e-s,n)}const oc={G:new class extends wl{priority=140;parse(t,e,n){switch(e){case"G":case"GG":case"GGG":return n.era(t,{width:"abbreviated"})||n.era(t,{width:"narrow"});case"GGGGG":return n.era(t,{width:"narrow"});default:return n.era(t,{width:"wide"})||n.era(t,{width:"abbreviated"})||n.era(t,{width:"narrow"})}}set(t,e,n){return e.era=n,t.setFullYear(n,0,1),t.setHours(0,0,0,0),t}incompatibleTokens=["R","u","t","T"]},y:new class extends wl{priority=130;incompatibleTokens=["Y","R","u","w","I","i","e","c","t","T"];parse(t,e,n){const i=t=>({year:t,isTwoDigitYear:"yy"===e});switch(e){case"y":return jl(Gl(4,t),i);case"yo":return jl(n.ordinalNumber(t,{unit:"year"}),i);default:return jl(Gl(e.length,t),i)}}validate(t,e){return e.isTwoDigitYear||e.year>0}set(t,e,n){const i=t.getFullYear();if(n.isTwoDigitYear){const e=Jl(n.year,i);return t.setFullYear(e,0,1),t.setHours(0,0,0,0),t}const s="era"in e&&1!==e.era?1-n.year:n.year;return t.setFullYear(s,0,1),t.setHours(0,0,0,0),t}},Y:new class extends wl{priority=130;parse(t,e,n){const i=t=>({year:t,isTwoDigitYear:"YY"===e});switch(e){case"Y":return jl(Gl(4,t),i);case"Yo":return jl(n.ordinalNumber(t,{unit:"year"}),i);default:return jl(Gl(e.length,t),i)}}validate(t,e){return e.isTwoDigitYear||e.year>0}set(t,e,n,i){const s=Hr(t,i);if(n.isTwoDigitYear){const e=Jl(n.year,s);return t.setFullYear(e,0,i.firstWeekContainsDate),t.setHours(0,0,0,0),pr(t,i)}const o="era"in e&&1!==e.era?1-n.year:n.year;return t.setFullYear(o,0,i.firstWeekContainsDate),t.setHours(0,0,0,0),pr(t,i)}incompatibleTokens=["y","R","u","Q","q","M","L","I","d","D","i","t","T"]},R:new class extends wl{priority=130;parse(t,e){return Kl("R"===e?4:e.length,t)}set(t,e,n){const i=rr(t,0);return i.setFullYear(n,0,4),i.setHours(0,0,0,0),mr(i)}incompatibleTokens=["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"]},u:new class extends wl{priority=130;parse(t,e){return Kl("u"===e?4:e.length,t)}set(t,e,n){return t.setFullYear(n,0,1),t.setHours(0,0,0,0),t}incompatibleTokens=["G","y","Y","R","w","I","i","e","c","t","T"]},Q:new class extends wl{priority=120;parse(t,e,n){switch(e){case"Q":case"QQ":return Gl(e.length,t);case"Qo":return n.ordinalNumber(t,{unit:"quarter"});case"QQQ":return n.quarter(t,{width:"abbreviated",context:"formatting"})||n.quarter(t,{width:"narrow",context:"formatting"});case"QQQQQ":return n.quarter(t,{width:"narrow",context:"formatting"});default:return n.quarter(t,{width:"wide",context:"formatting"})||n.quarter(t,{width:"abbreviated",context:"formatting"})||n.quarter(t,{width:"narrow",context:"formatting"})}}validate(t,e){return e>=1&&e<=4}set(t,e,n){return t.setMonth(3*(n-1),1),t.setHours(0,0,0,0),t}incompatibleTokens=["Y","R","q","M","L","w","I","d","D","i","e","c","t","T"]},q:new class extends wl{priority=120;parse(t,e,n){switch(e){case"q":case"qq":return Gl(e.length,t);case"qo":return n.ordinalNumber(t,{unit:"quarter"});case"qqq":return n.quarter(t,{width:"abbreviated",context:"standalone"})||n.quarter(t,{width:"narrow",context:"standalone"});case"qqqqq":return n.quarter(t,{width:"narrow",context:"standalone"});default:return n.quarter(t,{width:"wide",context:"standalone"})||n.quarter(t,{width:"abbreviated",context:"standalone"})||n.quarter(t,{width:"narrow",context:"standalone"})}}validate(t,e){return e>=1&&e<=4}set(t,e,n){return t.setMonth(3*(n-1),1),t.setHours(0,0,0,0),t}incompatibleTokens=["Y","R","Q","M","L","w","I","d","D","i","e","c","t","T"]},M:new class extends wl{incompatibleTokens=["Y","R","q","Q","L","w","I","D","i","e","c","t","T"];priority=110;parse(t,e,n){const i=t=>t-1;switch(e){case"M":return jl(Ul(kl,t),i);case"MM":return jl(Gl(2,t),i);case"Mo":return jl(n.ordinalNumber(t,{unit:"month"}),i);case"MMM":return n.month(t,{width:"abbreviated",context:"formatting"})||n.month(t,{width:"narrow",context:"formatting"});case"MMMMM":return n.month(t,{width:"narrow",context:"formatting"});default:return n.month(t,{width:"wide",context:"formatting"})||n.month(t,{width:"abbreviated",context:"formatting"})||n.month(t,{width:"narrow",context:"formatting"})}}validate(t,e){return e>=0&&e<=11}set(t,e,n){return t.setMonth(n,1),t.setHours(0,0,0,0),t}},L:new class extends wl{priority=110;parse(t,e,n){const i=t=>t-1;switch(e){case"L":return jl(Ul(kl,t),i);case"LL":return jl(Gl(2,t),i);case"Lo":return jl(n.ordinalNumber(t,{unit:"month"}),i);case"LLL":return n.month(t,{width:"abbreviated",context:"standalone"})||n.month(t,{width:"narrow",context:"standalone"});case"LLLLL":return n.month(t,{width:"narrow",context:"standalone"});default:return n.month(t,{width:"wide",context:"standalone"})||n.month(t,{width:"abbreviated",context:"standalone"})||n.month(t,{width:"narrow",context:"standalone"})}}validate(t,e){return e>=0&&e<=11}set(t,e,n){return t.setMonth(n,1),t.setHours(0,0,0,0),t}incompatibleTokens=["Y","R","q","Q","M","w","I","D","i","e","c","t","T"]},w:new class extends wl{priority=100;parse(t,e,n){switch(e){case"w":return Ul(Cl,t);case"wo":return n.ordinalNumber(t,{unit:"week"});default:return Gl(e.length,t)}}validate(t,e){return e>=1&&e<=53}set(t,e,n,i){return pr(function(t,e,n){const i=lr(t,n?.in),s=Vr(i,n)-e;return i.setDate(i.getDate()-7*s),lr(i,n?.in)}(t,n,i),i)}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","i","t","T"]},I:new class extends wl{priority=100;parse(t,e,n){switch(e){case"I":return Ul(Cl,t);case"Io":return n.ordinalNumber(t,{unit:"week"});default:return Gl(e.length,t)}}validate(t,e){return e>=1&&e<=53}set(t,e,n){return mr(function(t,e,n){const i=lr(t,n?.in),s=qr(i,n)-e;return i.setDate(i.getDate()-7*s),i}(t,n))}incompatibleTokens=["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"]},d:new class extends wl{priority=90;subPriority=1;parse(t,e,n){switch(e){case"d":return Ul(Sl,t);case"do":return n.ordinalNumber(t,{unit:"date"});default:return Gl(e.length,t)}}validate(t,e){const n=tc(t.getFullYear()),i=t.getMonth();return n?e>=1&&e<=nc[i]:e>=1&&e<=ec[i]}set(t,e,n){return t.setDate(n),t.setHours(0,0,0,0),t}incompatibleTokens=["Y","R","q","Q","w","I","D","i","e","c","t","T"]},D:new class extends wl{priority=90;subpriority=1;parse(t,e,n){switch(e){case"D":case"DD":return Ul(Ml,t);case"Do":return n.ordinalNumber(t,{unit:"date"});default:return Gl(e.length,t)}}validate(t,e){return tc(t.getFullYear())?e>=1&&e<=366:e>=1&&e<=365}set(t,e,n){return t.setMonth(0,n),t.setHours(0,0,0,0),t}incompatibleTokens=["Y","R","q","Q","M","L","w","I","d","E","i","e","c","t","T"]},E:new class extends wl{priority=90;parse(t,e,n){switch(e){case"E":case"EE":case"EEE":return n.day(t,{width:"abbreviated",context:"formatting"})||n.day(t,{width:"short",context:"formatting"})||n.day(t,{width:"narrow",context:"formatting"});case"EEEEE":return n.day(t,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(t,{width:"short",context:"formatting"})||n.day(t,{width:"narrow",context:"formatting"});default:return n.day(t,{width:"wide",context:"formatting"})||n.day(t,{width:"abbreviated",context:"formatting"})||n.day(t,{width:"short",context:"formatting"})||n.day(t,{width:"narrow",context:"formatting"})}}validate(t,e){return e>=0&&e<=6}set(t,e,n,i){return(t=ic(t,n,i)).setHours(0,0,0,0),t}incompatibleTokens=["D","i","e","c","t","T"]},e:new class extends wl{priority=90;parse(t,e,n,i){const s=t=>{const e=7*Math.floor((t-1)/7);return(t+i.weekStartsOn+6)%7+e};switch(e){case"e":case"ee":return jl(Gl(e.length,t),s);case"eo":return jl(n.ordinalNumber(t,{unit:"day"}),s);case"eee":return n.day(t,{width:"abbreviated",context:"formatting"})||n.day(t,{width:"short",context:"formatting"})||n.day(t,{width:"narrow",context:"formatting"});case"eeeee":return n.day(t,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(t,{width:"short",context:"formatting"})||n.day(t,{width:"narrow",context:"formatting"});default:return n.day(t,{width:"wide",context:"formatting"})||n.day(t,{width:"abbreviated",context:"formatting"})||n.day(t,{width:"short",context:"formatting"})||n.day(t,{width:"narrow",context:"formatting"})}}validate(t,e){return e>=0&&e<=6}set(t,e,n,i){return(t=ic(t,n,i)).setHours(0,0,0,0),t}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"]},c:new class extends wl{priority=90;parse(t,e,n,i){const s=t=>{const e=7*Math.floor((t-1)/7);return(t+i.weekStartsOn+6)%7+e};switch(e){case"c":case"cc":return jl(Gl(e.length,t),s);case"co":return jl(n.ordinalNumber(t,{unit:"day"}),s);case"ccc":return n.day(t,{width:"abbreviated",context:"standalone"})||n.day(t,{width:"short",context:"standalone"})||n.day(t,{width:"narrow",context:"standalone"});case"ccccc":return n.day(t,{width:"narrow",context:"standalone"});case"cccccc":return n.day(t,{width:"short",context:"standalone"})||n.day(t,{width:"narrow",context:"standalone"});default:return n.day(t,{width:"wide",context:"standalone"})||n.day(t,{width:"abbreviated",context:"standalone"})||n.day(t,{width:"short",context:"standalone"})||n.day(t,{width:"narrow",context:"standalone"})}}validate(t,e){return e>=0&&e<=6}set(t,e,n,i){return(t=ic(t,n,i)).setHours(0,0,0,0),t}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"]},i:new class extends wl{priority=90;parse(t,e,n){const i=t=>0===t?7:t;switch(e){case"i":case"ii":return Gl(e.length,t);case"io":return n.ordinalNumber(t,{unit:"day"});case"iii":return jl(n.day(t,{width:"abbreviated",context:"formatting"})||n.day(t,{width:"short",context:"formatting"})||n.day(t,{width:"narrow",context:"formatting"}),i);case"iiiii":return jl(n.day(t,{width:"narrow",context:"formatting"}),i);case"iiiiii":return jl(n.day(t,{width:"short",context:"formatting"})||n.day(t,{width:"narrow",context:"formatting"}),i);default:return jl(n.day(t,{width:"wide",context:"formatting"})||n.day(t,{width:"abbreviated",context:"formatting"})||n.day(t,{width:"short",context:"formatting"})||n.day(t,{width:"narrow",context:"formatting"}),i)}}validate(t,e){return e>=1&&e<=7}set(t,e,n){return(t=sc(t,n)).setHours(0,0,0,0),t}incompatibleTokens=["y","Y","u","q","Q","M","L","w","d","D","E","e","c","t","T"]},a:new class extends wl{priority=80;parse(t,e,n){switch(e){case"a":case"aa":case"aaa":return n.dayPeriod(t,{width:"abbreviated",context:"formatting"})||n.dayPeriod(t,{width:"narrow",context:"formatting"});case"aaaaa":return n.dayPeriod(t,{width:"narrow",context:"formatting"});default:return n.dayPeriod(t,{width:"wide",context:"formatting"})||n.dayPeriod(t,{width:"abbreviated",context:"formatting"})||n.dayPeriod(t,{width:"narrow",context:"formatting"})}}set(t,e,n){return t.setHours(Zl(n),0,0,0),t}incompatibleTokens=["b","B","H","k","t","T"]},b:new class extends wl{priority=80;parse(t,e,n){switch(e){case"b":case"bb":case"bbb":return n.dayPeriod(t,{width:"abbreviated",context:"formatting"})||n.dayPeriod(t,{width:"narrow",context:"formatting"});case"bbbbb":return n.dayPeriod(t,{width:"narrow",context:"formatting"});default:return n.dayPeriod(t,{width:"wide",context:"formatting"})||n.dayPeriod(t,{width:"abbreviated",context:"formatting"})||n.dayPeriod(t,{width:"narrow",context:"formatting"})}}set(t,e,n){return t.setHours(Zl(n),0,0,0),t}incompatibleTokens=["a","B","H","k","t","T"]},B:new class extends wl{priority=80;parse(t,e,n){switch(e){case"B":case"BB":case"BBB":return n.dayPeriod(t,{width:"abbreviated",context:"formatting"})||n.dayPeriod(t,{width:"narrow",context:"formatting"});case"BBBBB":return n.dayPeriod(t,{width:"narrow",context:"formatting"});default:return n.dayPeriod(t,{width:"wide",context:"formatting"})||n.dayPeriod(t,{width:"abbreviated",context:"formatting"})||n.dayPeriod(t,{width:"narrow",context:"formatting"})}}set(t,e,n){return t.setHours(Zl(n),0,0,0),t}incompatibleTokens=["a","b","t","T"]},h:new class extends wl{priority=70;parse(t,e,n){switch(e){case"h":return Ul(Pl,t);case"ho":return n.ordinalNumber(t,{unit:"hour"});default:return Gl(e.length,t)}}validate(t,e){return e>=1&&e<=12}set(t,e,n){const i=t.getHours()>=12;return i&&n<12?t.setHours(n+12,0,0,0):i||12!==n?t.setHours(n,0,0,0):t.setHours(0,0,0,0),t}incompatibleTokens=["H","K","k","t","T"]},H:new class extends wl{priority=70;parse(t,e,n){switch(e){case"H":return Ul(_l,t);case"Ho":return n.ordinalNumber(t,{unit:"hour"});default:return Gl(e.length,t)}}validate(t,e){return e>=0&&e<=23}set(t,e,n){return t.setHours(n,0,0,0),t}incompatibleTokens=["a","b","h","K","k","t","T"]},K:new class extends wl{priority=70;parse(t,e,n){switch(e){case"K":return Ul(Dl,t);case"Ko":return n.ordinalNumber(t,{unit:"hour"});default:return Gl(e.length,t)}}validate(t,e){return e>=0&&e<=11}set(t,e,n){return t.getHours()>=12&&n<12?t.setHours(n+12,0,0,0):t.setHours(n,0,0,0),t}incompatibleTokens=["h","H","k","t","T"]},k:new class extends wl{priority=70;parse(t,e,n){switch(e){case"k":return Ul(Tl,t);case"ko":return n.ordinalNumber(t,{unit:"hour"});default:return Gl(e.length,t)}}validate(t,e){return e>=1&&e<=24}set(t,e,n){const i=n<=24?n%24:n;return t.setHours(i,0,0,0),t}incompatibleTokens=["a","b","h","H","K","t","T"]},m:new class extends wl{priority=60;parse(t,e,n){switch(e){case"m":return Ul(El,t);case"mo":return n.ordinalNumber(t,{unit:"minute"});default:return Gl(e.length,t)}}validate(t,e){return e>=0&&e<=59}set(t,e,n){return t.setMinutes(n,0,0),t}incompatibleTokens=["t","T"]},s:new class extends wl{priority=50;parse(t,e,n){switch(e){case"s":return Ul(Ll,t);case"so":return n.ordinalNumber(t,{unit:"second"});default:return Gl(e.length,t)}}validate(t,e){return e>=0&&e<=59}set(t,e,n){return t.setSeconds(n,0),t}incompatibleTokens=["t","T"]},S:new class extends wl{priority=30;parse(t,e){return jl(Gl(e.length,t),(t=>Math.trunc(t*Math.pow(10,3-e.length))))}set(t,e,n){return t.setMilliseconds(n),t}incompatibleTokens=["t","T"]},X:new class extends wl{priority=10;parse(t,e){switch(e){case"X":return Xl(Bl,t);case"XX":return Xl(ql,t);case"XXXX":return Xl(Hl,t);case"XXXXX":return Xl(Yl,t);default:return Xl(Vl,t)}}set(t,e,n){return e.timestampIsSet?t:rr(t,t.getTime()-br(t)-n)}incompatibleTokens=["t","T","x"]},x:new class extends wl{priority=10;parse(t,e){switch(e){case"x":return Xl(Bl,t);case"xx":return Xl(ql,t);case"xxxx":return Xl(Hl,t);case"xxxxx":return Xl(Yl,t);default:return Xl(Vl,t)}}set(t,e,n){return e.timestampIsSet?t:rr(t,t.getTime()-br(t)-n)}incompatibleTokens=["t","T","X"]},t:new class extends wl{priority=40;parse(t){return Ql(t)}set(t,e,n){return[rr(t,1e3*n),{timestampIsSet:!0}]}incompatibleTokens="*"},T:new class extends wl{priority=20;parse(t){return Ql(t)}set(t,e,n){return[rr(t,n),{timestampIsSet:!0}]}incompatibleTokens="*"}},ac=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,rc=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,lc=/^'([^]*?)'?$/,cc=/''/g,dc=/\S/,hc=/[a-zA-Z]/;function uc(t,e,n,i){const s=()=>rr(i?.in||n,NaN),o=Object.assign({},gr()),a=i?.locale??o.locale??Br,r=i?.firstWeekContainsDate??i?.locale?.options?.firstWeekContainsDate??o.firstWeekContainsDate??o.locale?.options?.firstWeekContainsDate??1,l=i?.weekStartsOn??i?.locale?.options?.weekStartsOn??o.weekStartsOn??o.locale?.options?.weekStartsOn??0;if(!e)return t?s():lr(n,i?.in);const c={firstWeekContainsDate:r,weekStartsOn:l,locale:a},d=[new vl(i?.in,n)],h=e.match(rc).map((t=>{const e=t[0];if(e in ol){return(0,ol[e])(t,a.formatLong)}return t})).join("").match(ac),u=[];for(let n of h){!i?.useAdditionalWeekYearTokens&&dl(n)&&hl(n,e,t),!i?.useAdditionalDayOfYearTokens&&cl(n)&&hl(n,e,t);const o=n[0],r=oc[o];if(r){const{incompatibleTokens:e}=r;if(Array.isArray(e)){const t=u.find((t=>e.includes(t.token)||t.token===o));if(t)throw new RangeError(`The format string mustn't contain \`${t.fullToken}\` and \`${n}\` at the same time`)}else if("*"===r.incompatibleTokens&&u.length>0)throw new RangeError(`The format string mustn't contain \`${n}\` and any other token at the same time`);u.push({token:o,fullToken:n});const i=r.run(t,n,a.match,c);if(!i)return s();d.push(i.setter),t=i.rest}else{if(o.match(hc))throw new RangeError("Format string contains an unescaped latin alphabet character `"+o+"`");if("''"===n?n="'":"'"===o&&(n=n.match(lc)[1].replace(cc,"'")),0!==t.indexOf(n))return s();t=t.slice(n.length)}}if(t.length>0&&dc.test(t))return s();const g=d.map((t=>t.priority)).sort(((t,e)=>e-t)).filter(((t,e,n)=>n.indexOf(t)===e)).map((t=>d.filter((e=>e.priority===t)).sort(((t,e)=>e.subPriority-t.subPriority)))).map((t=>t[0]));let p=lr(n,i?.in);if(isNaN(+p))return s();const m={};for(const t of g){if(!t.validate(p,c))return s();const e=t.set(p,m,c);Array.isArray(e)?(p=e[0],Object.assign(m,e[1])):p=e}return p}function gc(t,e){const n=()=>rr(e?.in,NaN),i=e?.additionalDigits??2,s=function(t){const e={},n=t.split(pc.dateTimeDelimiter);let i;if(n.length>2)return e;/:/.test(n[0])?i=n[0]:(e.date=n[0],i=n[1],pc.timeZoneDelimiter.test(e.date)&&(e.date=t.split(pc.timeZoneDelimiter)[0],i=t.substr(e.date.length,t.length)));if(i){const t=pc.timezone.exec(i);t?(e.time=i.replace(t[1],""),e.timezone=t[1]):e.time=i}return e}(t);let o;if(s.date){const t=function(t,e){const n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+e)+"})|(\\d{2}|[+-]\\d{"+(2+e)+"})$)"),i=t.match(n);if(!i)return{year:NaN,restDateString:""};const s=i[1]?parseInt(i[1]):null,o=i[2]?parseInt(i[2]):null;return{year:null===o?s:100*o,restDateString:t.slice((i[1]||i[2]).length)}}(s.date,i);o=function(t,e){if(null===e)return new Date(NaN);const n=t.match(mc);if(!n)return new Date(NaN);const i=!!n[4],s=yc(n[1]),o=yc(n[2])-1,a=yc(n[3]),r=yc(n[4]),l=yc(n[5])-1;if(i)return function(t,e,n){return e>=1&&e<=53&&n>=0&&n<=6}(0,r,l)?function(t,e,n){const i=new Date(0);i.setUTCFullYear(t,0,4);const s=i.getUTCDay()||7,o=7*(e-1)+n+1-s;return i.setUTCDate(i.getUTCDate()+o),i}(e,r,l):new Date(NaN);{const t=new Date(0);return function(t,e,n){return e>=0&&e<=11&&n>=1&&n<=(vc[e]||(wc(t)?29:28))}(e,o,a)&&function(t,e){return e>=1&&e<=(wc(t)?366:365)}(e,s)?(t.setUTCFullYear(e,o,Math.max(s,a)),t):new Date(NaN)}}(t.restDateString,t.year)}if(!o||isNaN(+o))return n();const a=+o;let r,l=0;if(s.time&&(l=function(t){const e=t.match(fc);if(!e)return NaN;const n=xc(e[1]),i=xc(e[2]),s=xc(e[3]);if(!function(t,e,n){if(24===t)return 0===e&&0===n;return n>=0&&n<60&&e>=0&&e<60&&t>=0&&t<25}(n,i,s))return NaN;return n*or+i*sr+1e3*s}(s.time),isNaN(l)))return n();if(!s.timezone){const t=new Date(a+l),n=lr(0,e?.in);return n.setFullYear(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()),n.setHours(t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds()),n}return r=function(t){if("Z"===t)return 0;const e=t.match(bc);if(!e)return 0;const n="+"===e[1]?-1:1,i=parseInt(e[2]),s=e[3]&&parseInt(e[3])||0;if(!function(t,e){return e>=0&&e<=59}
|
|
20
|
+
*/class oi{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,n,i){const s=e.listeners[i],o=e.duration;s.forEach((i=>i({chart:t,initial:e.initial,numSteps:o,currentStep:Math.min(n-e.start,o)})))}_refresh(){this._request||(this._running=!0,this._request=pe.call(window,(()=>{this._update(),this._request=null,this._running&&this._refresh()})))}_update(t=Date.now()){let e=0;this._charts.forEach(((n,i)=>{if(!n.running||!n.items.length)return;const s=n.items;let o,a=s.length-1,r=!1;for(;a>=0;--a)o=s[a],o._active?(o._total>n.duration&&(n.duration=o._total),o.tick(t),r=!0):(s[a]=s[s.length-1],s.pop());r&&(i.draw(),this._notify(i,n,t,"progress")),s.length||(n.running=!1,this._notify(i,n,t,"complete"),n.initial=!1),e+=s.length})),this._lastDate=t,0===e&&(this._running=!1)}_getAnims(t){const e=this._charts;let n=e.get(t);return n||(n={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,n)),n}listen(t,e,n){this._getAnims(t).listeners[e].push(n)}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 n=e.items;let i=n.length-1;for(;i>=0;--i)n[i].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var ai=new oi;const ri="transparent",li={boolean:(t,e,n)=>n>.5?e:t,color(t,e,n){const i=Ce(t||ri),s=i.valid&&Ce(e||ri);return s&&s.valid?s.mix(i,n).hexString():e},number:(t,e,n)=>t+(e-t)*n};class ci{constructor(t,e,n,i){const s=e[n];i=cn([t.to,i,s,t.from]);const o=cn([t.from,s,i]);this._active=!0,this._fn=t.fn||li[t.type||typeof o],this._easing=Se[t.easing]||Se.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=n,this._from=o,this._to=i,this._promises=void 0}active(){return this._active}update(t,e,n){if(this._active){this._notify(!1);const i=this._target[this._prop],s=n-this._start,o=this._duration-s;this._start=n,this._duration=Math.floor(Math.max(o,t.duration)),this._total+=s,this._loop=!!t.loop,this._to=cn([t.to,e,i,t.from]),this._from=cn([t.from,i,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const e=t-this._start,n=this._duration,i=this._prop,s=this._from,o=this._loop,a=this._to;let r;if(this._active=s!==a&&(o||e<n),!this._active)return this._target[i]=a,void this._notify(!0);e<0?this._target[i]=s:(r=e/n%2,r=o&&r>1?2-r:r,r=this._easing(Math.min(1,Math.max(0,r))),this._target[i]=this._fn(s,a,r))}wait(){const t=this._promises||(this._promises=[]);return new Promise(((e,n)=>{t.push({res:e,rej:n})}))}_notify(t){const e=t?"res":"rej",n=this._promises||[];for(let t=0;t<n.length;t++)n[t][e]()}}class di{constructor(t,e){this._chart=t,this._properties=new Map,this.configure(e)}configure(t){if(!yt(t))return;const e=Object.keys($e.animation),n=this._properties;Object.getOwnPropertyNames(t).forEach((i=>{const s=t[i];if(!yt(s))return;const o={};for(const t of e)o[t]=s[t];(bt(s.properties)&&s.properties||[i]).forEach((t=>{t!==i&&n.has(t)||n.set(t,o)}))}))}_animateOptions(t,e){const n=e.options,i=function(t,e){if(!e)return;let n=t.options;if(!n)return void(t.options=e);n.$shared&&(t.options=n=Object.assign({},n,{$shared:!1,$animations:{}}));return n}(t,n);if(!i)return[];const s=this._createAnimations(i,n);return n.$shared&&function(t,e){const n=[],i=Object.keys(e);for(let e=0;e<i.length;e++){const s=t[i[e]];s&&s.active()&&n.push(s.wait())}return Promise.all(n)}(t.options.$animations,n).then((()=>{t.options=n}),(()=>{})),s}_createAnimations(t,e){const n=this._properties,i=[],s=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){i.push(...this._animateOptions(t,e));continue}const c=e[l];let d=s[l];const h=n.get(l);if(d){if(h&&d.active()){d.update(h,c,a);continue}d.cancel()}h&&h.duration?(s[l]=d=new ci(h,t,l,c),i.push(d)):t[l]=c}return i}update(t,e){if(0===this._properties.size)return void Object.assign(t,e);const n=this._createAnimations(t,e);return n.length?(ai.add(this._chart,n),!0):void 0}}function hi(t,e){const n=t&&t.options||{},i=n.reverse,s=void 0===n.min?e:0,o=void 0===n.max?e:0;return{start:i?o:s,end:i?s:o}}function ui(t,e){const n=[],i=t._getSortedDatasetMetas(e);let s,o;for(s=0,o=i.length;s<o;++s)n.push(i[s].index);return n}function gi(t,e,n,i={}){const s=t.keys,o="single"===i.mode;let a,r,l,c;if(null===e)return;let d=!1;for(a=0,r=s.length;a<r;++a){if(l=+s[a],l===n){if(d=!0,i.all)continue;break}c=t.values[l],xt(c)&&(o||0===e||Ut(e)===Ut(c))&&(e+=c)}return d||i.all?e:0}function pi(t,e){const n=t&&t.options.stacked;return n||void 0===n&&void 0!==e.stack}function mi(t,e,n){const i=t[e]||(t[e]={});return i[n]||(i[n]={})}function fi(t,e,n,i){for(const s of e.getMatchingVisibleMetas(i).reverse()){const e=t[s.index];if(n&&e>0||!n&&e<0)return s.index}return null}function bi(t,e){const{chart:n,_cachedMeta:i}=t,s=n._stacks||(n._stacks={}),{iScale:o,vScale:a,index:r}=i,l=o.axis,c=a.axis,d=function(t,e,n){return`${t.id}.${e.id}.${n.stack||n.type}`}(o,a,i),h=e.length;let u;for(let t=0;t<h;++t){const n=e[t],{[l]:o,[c]:h}=n;u=(n._stacks||(n._stacks={}))[c]=mi(s,d,o),u[r]=h,u._top=fi(u,a,!0,i.type),u._bottom=fi(u,a,!1,i.type);(u._visualValues||(u._visualValues={}))[r]=h}}function yi(t,e){const n=t.scales;return Object.keys(n).filter((t=>n[t].axis===e)).shift()}function xi(t,e){const n=t.controller.index,i=t.vScale&&t.vScale.axis;if(i){e=e||t._parsed;for(const t of e){const e=t._stacks;if(!e||void 0===e[i]||void 0===e[i][n])return;delete e[i][n],void 0!==e[i]._visualValues&&void 0!==e[i]._visualValues[n]&&delete e[i]._visualValues[n]}}}const vi=t=>"reset"===t||"none"===t,wi=(t,e)=>e?t:Object.assign({},t);class ki{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=pi(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&&xi(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,e=this._cachedMeta,n=this.getDataset(),i=(t,e,n,i)=>"x"===t?e:"r"===t?i:n,s=e.xAxisID=wt(n.xAxisID,yi(t,"x")),o=e.yAxisID=wt(n.yAxisID,yi(t,"y")),a=e.rAxisID=wt(n.rAxisID,yi(t,"r")),r=e.indexAxis,l=e.iAxisID=i(r,s,o,a),c=e.vAxisID=i(r,o,s,a);e.xScale=this.getScaleForId(s),e.yScale=this.getScaleForId(o),e.rScale=this.getScaleForId(a),e.iScale=this.getScaleForId(l),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&&ue(this._data,this),t._stacked&&xi(t)}_dataCheck(){const t=this.getDataset(),e=t.data||(t.data=[]),n=this._data;if(yt(e)){const t=this._cachedMeta;this._data=function(t,e){const{iScale:n,vScale:i}=e,s="x"===n.axis?"x":"y",o="x"===i.axis?"x":"y",a=Object.keys(t),r=new Array(a.length);let l,c,d;for(l=0,c=a.length;l<c;++l)d=a[l],r[l]={[s]:d,[o]:t[d]};return r}(e,t)}else if(n!==e){if(n){ue(n,this);const t=this._cachedMeta;xi(t),t._parsed=[]}e&&Object.isExtensible(e)&&(s=this,(i=e)._chartjs?i._chartjs.listeners.push(s):(Object.defineProperty(i,"_chartjs",{configurable:!0,enumerable:!1,value:{listeners:[s]}}),he.forEach((t=>{const e="_onData"+zt(t),n=i[t];Object.defineProperty(i,t,{configurable:!0,enumerable:!1,value(...t){const s=n.apply(this,t);return i._chartjs.listeners.forEach((n=>{"function"==typeof n[e]&&n[e](...t)})),s}})})))),this._syncList=[],this._data=e}var i,s}addElements(){const t=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(t.dataset=new this.datasetElementType)}buildOrUpdateElements(t){const e=this._cachedMeta,n=this.getDataset();let i=!1;this._dataCheck();const s=e._stacked;e._stacked=pi(e.vScale,e),e.stack!==n.stack&&(i=!0,xi(e),e.stack=n.stack),this._resyncElements(t),(i||s!==e._stacked)&&(bi(this,e._parsed),e._stacked=pi(e.vScale,e))}configure(){const t=this.chart.config,e=t.datasetScopeKeys(this._type),n=t.getOptionScopes(this.getDataset(),e,!0);this.options=t.createResolver(n,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,e){const{_cachedMeta:n,_data:i}=this,{iScale:s,_stacked:o}=n,a=s.axis;let r,l,c,d=0===t&&e===i.length||n._sorted,h=t>0&&n._parsed[t-1];if(!1===this._parsing)n._parsed=i,n._sorted=!0,c=i;else{c=bt(i[t])?this.parseArrayData(n,i,t,e):yt(i[t])?this.parseObjectData(n,i,t,e):this.parsePrimitiveData(n,i,t,e);const s=()=>null===l[a]||h&&l[a]<h[a];for(r=0;r<e;++r)n._parsed[r+t]=l=c[r],d&&(s()&&(d=!1),h=l);n._sorted=d}o&&bi(this,c)}parsePrimitiveData(t,e,n,i){const{iScale:s,vScale:o}=t,a=s.axis,r=o.axis,l=s.getLabels(),c=s===o,d=new Array(i);let h,u,g;for(h=0,u=i;h<u;++h)g=h+n,d[h]={[a]:c||s.parse(l[g],g),[r]:o.parse(e[g],g)};return d}parseArrayData(t,e,n,i){const{xScale:s,yScale:o}=t,a=new Array(i);let r,l,c,d;for(r=0,l=i;r<l;++r)c=r+n,d=e[c],a[r]={x:s.parse(d[0],c),y:o.parse(d[1],c)};return a}parseObjectData(t,e,n,i){const{xScale:s,yScale:o}=t,{xAxisKey:a="x",yAxisKey:r="y"}=this._parsing,l=new Array(i);let c,d,h,u;for(c=0,d=i;c<d;++c)h=c+n,u=e[h],l[c]={x:s.parse(It(u,a),h),y:o.parse(It(u,r),h)};return l}getParsed(t){return this._cachedMeta._parsed[t]}getDataElement(t){return this._cachedMeta.data[t]}applyStack(t,e,n){const i=this.chart,s=this._cachedMeta,o=e[t.axis];return gi({keys:ui(i,!0),values:e._stacks[t.axis]._visualValues},o,s.index,{mode:n})}updateRangeFromParsed(t,e,n,i){const s=n[e.axis];let o=null===s?NaN:s;const a=i&&n._stacks[e.axis];i&&a&&(i.values=a,o=gi(i,s,this._cachedMeta.index)),t.min=Math.min(t.min,o),t.max=Math.max(t.max,o)}getMinMax(t,e){const n=this._cachedMeta,i=n._parsed,s=n._sorted&&t===n.iScale,o=i.length,a=this._getOtherScale(t),r=((t,e,n)=>t&&!e.hidden&&e._stacked&&{keys:ui(n,!0),values:null})(e,n,this.chart),l={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:c,max:d}=function(t){const{min:e,max:n,minDefined:i,maxDefined:s}=t.getUserBounds();return{min:i?e:Number.NEGATIVE_INFINITY,max:s?n:Number.POSITIVE_INFINITY}}(a);let h,u;function g(){u=i[h];const e=u[a.axis];return!xt(u[t.axis])||c>e||d<e}for(h=0;h<o&&(g()||(this.updateRangeFromParsed(l,t,u,r),!s));++h);if(s)for(h=o-1;h>=0;--h)if(!g()){this.updateRangeFromParsed(l,t,u,r);break}return l}getAllParsedValues(t){const e=this._cachedMeta._parsed,n=[];let i,s,o;for(i=0,s=e.length;i<s;++i)o=e[i][t.axis],xt(o)&&n.push(o);return n}getMaxOverflow(){return!1}getLabelAndValue(t){const e=this._cachedMeta,n=e.iScale,i=e.vScale,s=this.getParsed(t);return{label:n?""+n.getLabelForValue(s[n.axis]):"",value:i?""+i.getLabelForValue(s[i.axis]):""}}_update(t){const e=this._cachedMeta;this.update(t||"default"),e._clip=function(t){let e,n,i,s;return yt(t)?(e=t.top,n=t.right,i=t.bottom,s=t.left):e=n=i=s=t,{top:e,right:n,bottom:i,left:s,disabled:!1===t}}(wt(this.options.clip,function(t,e,n){if(!1===n)return!1;const i=hi(t,n),s=hi(e,n);return{top:s.end,right:i.end,bottom:s.start,left:i.start}}(e.xScale,e.yScale,this.getMaxOverflow())))}update(t){}draw(){const t=this._ctx,e=this.chart,n=this._cachedMeta,i=n.data||[],s=e.chartArea,o=[],a=this._drawStart||0,r=this._drawCount||i.length-a,l=this.options.drawActiveElementsOnTop;let c;for(n.dataset&&n.dataset.draw(t,s,a,r),c=a;c<a+r;++c){const e=i[c];e.hidden||(e.active&&l?o.push(e):e.draw(t,s))}for(c=0;c<o.length;++c)o[c].draw(t,s)}getStyle(t,e){const n=e?"active":"default";return void 0===t&&this._cachedMeta.dataset?this.resolveDatasetElementOptions(n):this.resolveDataElementOptions(t||0,n)}getContext(t,e,n){const i=this.getDataset();let s;if(t>=0&&t<this._cachedMeta.data.length){const e=this._cachedMeta.data[t];s=e.$context||(e.$context=function(t,e,n){return dn(t,{active:!1,dataIndex:e,parsed:void 0,raw:void 0,element:n,index:e,mode:"default",type:"data"})}(this.getContext(),t,e)),s.parsed=this.getParsed(t),s.raw=i.data[t],s.index=s.dataIndex=t}else s=this.$context||(this.$context=function(t,e){return dn(t,{active:!1,dataset:void 0,datasetIndex:e,index:e,mode:"default",type:"dataset"})}(this.chart.getContext(),this.index)),s.dataset=i,s.index=s.datasetIndex=this.index;return s.active=!!e,s.mode=n,s}resolveDatasetElementOptions(t){return this._resolveElementOptions(this.datasetElementType.id,t)}resolveDataElementOptions(t,e){return this._resolveElementOptions(this.dataElementType.id,e,t)}_resolveElementOptions(t,e="default",n){const i="active"===e,s=this._cachedDataOpts,o=t+"-"+e,a=s[o],r=this.enableOptionSharing&&Ot(n);if(a)return wi(a,r);const l=this.chart.config,c=l.datasetElementScopeKeys(this._type,t),d=i?[`${t}Hover`,"hover",t,""]:[t,""],h=l.getOptionScopes(this.getDataset(),c),u=Object.keys($e.elements[t]),g=l.resolveNamedOptions(h,u,(()=>this.getContext(n,i,e)),d);return g.$shared&&(g.$shared=r,s[o]=Object.freeze(wi(g,r))),g}_resolveAnimations(t,e,n){const i=this.chart,s=this._cachedDataOpts,o=`animation-${e}`,a=s[o];if(a)return a;let r;if(!1!==i.options.animation){const i=this.chart.config,s=i.datasetAnimationScopeKeys(this._type,e),o=i.getOptionScopes(this.getDataset(),s);r=i.createResolver(o,this.getContext(t,n,e))}const l=new di(i,r&&r.animations);return r&&r._cacheable&&(s[o]=Object.freeze(l)),l}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||vi(t)||this.chart._animationsDisabled}_getSharedOptions(t,e){const n=this.resolveDataElementOptions(t,e),i=this._sharedOptions,s=this.getSharedOptions(n),o=this.includeOptions(e,s)||s!==i;return this.updateSharedOptions(s,e,n),{sharedOptions:s,includeOptions:o}}updateElement(t,e,n,i){vi(i)?Object.assign(t,n):this._resolveAnimations(e,i).update(t,n)}updateSharedOptions(t,e,n){t&&!vi(e)&&this._resolveAnimations(void 0,e).update(t,n)}_setStyle(t,e,n,i){t.active=i;const s=this.getStyle(e,i);this._resolveAnimations(e,n,i).update(t,{options:!i&&this.getSharedOptions(s)||s})}removeHoverStyle(t,e,n){this._setStyle(t,n,"active",!1)}setHoverStyle(t,e,n){this._setStyle(t,n,"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,n=this._cachedMeta.data;for(const[t,e,n]of this._syncList)this[t](e,n);this._syncList=[];const i=n.length,s=e.length,o=Math.min(s,i);o&&this.parse(0,o),s>i?this._insertElements(i,s-i,t):s<i&&this._removeElements(s,i-s)}_insertElements(t,e,n=!0){const i=this._cachedMeta,s=i.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(s),a=t;a<o;++a)s[a]=new this.dataElementType;this._parsing&&r(i._parsed),this.parse(t,e),n&&this.updateElements(s,t,e,"reset")}updateElements(t,e,n,i){}_removeElements(t,e){const n=this._cachedMeta;if(this._parsing){const i=n._parsed.splice(t,e);n._stacked&&xi(n,i)}n.data.splice(t,e)}_sync(t){if(this._parsing)this._syncList.push(t);else{const[e,n,i]=t;this[e](n,i)}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 n=arguments.length-2;n&&this._sync(["_insertElements",t,n])}_onDataUnshift(){this._sync(["_insertElements",0,arguments.length])}}function Si(t){const e=t.iScale,n=function(t,e){if(!t._cache.$bar){const n=t.getMatchingVisibleMetas(e);let i=[];for(let e=0,s=n.length;e<s;e++)i=i.concat(n[e].controller.getAllParsedValues(t));t._cache.$bar=ge(i.sort(((t,e)=>t-e)))}return t._cache.$bar}(e,t.type);let i,s,o,a,r=e._length;const l=()=>{32767!==o&&-32768!==o&&(Ot(a)&&(r=Math.min(r,Math.abs(o-a)||r)),a=o)};for(i=0,s=n.length;i<s;++i)o=e.getPixelForValue(n[i]),l();for(a=void 0,i=0,s=e.ticks.length;i<s;++i)o=e.getPixelForTick(i),l();return r}function Mi(t,e,n,i){return bt(t)?function(t,e,n,i){const s=n.parse(t[0],i),o=n.parse(t[1],i),a=Math.min(s,o),r=Math.max(s,o);let l=a,c=r;Math.abs(a)>Math.abs(r)&&(l=r,c=a),e[n.axis]=c,e._custom={barStart:l,barEnd:c,start:s,end:o,min:a,max:r}}(t,e,n,i):e[n.axis]=n.parse(t,i),e}function Ci(t,e,n,i){const s=t.iScale,o=t.vScale,a=s.getLabels(),r=s===o,l=[];let c,d,h,u;for(c=n,d=n+i;c<d;++c)u=e[c],h={},h[s.axis]=r||s.parse(a[c],c),l.push(Mi(u,h,o,c));return l}function _i(t){return t&&void 0!==t.barStart&&void 0!==t.barEnd}function Ti(t,e,n,i){let s=e.borderSkipped;const o={};if(!s)return void(t.borderSkipped=o);if(!0===s)return void(t.borderSkipped={top:!0,right:!0,bottom:!0,left:!0});const{start:a,end:r,reverse:l,top:c,bottom:d}=function(t){let e,n,i,s,o;return t.horizontal?(e=t.base>t.x,n="left",i="right"):(e=t.base<t.y,n="bottom",i="top"),e?(s="end",o="start"):(s="start",o="end"),{start:n,end:i,reverse:e,top:s,bottom:o}}(t);"middle"===s&&n&&(t.enableBorderRadius=!0,(n._top||0)===i?s=c:(n._bottom||0)===i?s=d:(o[Di(d,a,r,l)]=!0,s=c)),o[Di(s,a,r,l)]=!0,t.borderSkipped=o}function Di(t,e,n,i){var s,o,a;return i?(a=n,t=Pi(t=(s=t)===(o=e)?a:s===a?o:s,n,e)):t=Pi(t,e,n),t}function Pi(t,e,n){return"start"===t?e:"end"===t?n:t}function Ei(t,{inflateAmount:e},n){t.inflateAmount="auto"===e?1===n?.33:0:e}class Li extends ki{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(t,e,n,i){return Ci(t,e,n,i)}parseArrayData(t,e,n,i){return Ci(t,e,n,i)}parseObjectData(t,e,n,i){const{iScale:s,vScale:o}=t,{xAxisKey:a="x",yAxisKey:r="y"}=this._parsing,l="x"===s.axis?a:r,c="x"===o.axis?a:r,d=[];let h,u,g,p;for(h=n,u=n+i;h<u;++h)p=e[h],g={},g[s.axis]=s.parse(It(p,l),h),d.push(Mi(It(p,c),g,o,h));return d}updateRangeFromParsed(t,e,n,i){super.updateRangeFromParsed(t,e,n,i);const s=n._custom;s&&e===this._cachedMeta.vScale&&(t.min=Math.min(t.min,s.min),t.max=Math.max(t.max,s.max))}getMaxOverflow(){return 0}getLabelAndValue(t){const e=this._cachedMeta,{iScale:n,vScale:i}=e,s=this.getParsed(t),o=s._custom,a=_i(o)?"["+o.start+", "+o.end+"]":""+i.getLabelForValue(s[i.axis]);return{label:""+n.getLabelForValue(s[n.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,n,i){const s="reset"===i,{index:o,_cachedMeta:{vScale:a}}=this,r=a.getBasePixel(),l=a.isHorizontal(),c=this._getRuler(),{sharedOptions:d,includeOptions:h}=this._getSharedOptions(e,i);for(let u=e;u<e+n;u++){const e=this.getParsed(u),n=s||ft(e[a.axis])?{base:r,head:r}:this._calculateBarValuePixels(u),g=this._calculateBarIndexPixels(u,c),p=(e._stacks||{})[a.axis],m={horizontal:l,base:n.base,enableBorderRadius:!p||_i(e._custom)||o===p._top||o===p._bottom,x:l?n.head:g.center,y:l?g.center:n.head,height:l?g.size:Math.abs(n.size),width:l?Math.abs(n.size):g.size};h&&(m.options=d||this.resolveDataElementOptions(u,t[u].active?"active":i));const f=m.options||t[u].options;Ti(m,f,p,o),Ei(m,f,c.ratio),this.updateElement(t[u],u,m,i)}}_getStacks(t,e){const{iScale:n}=this._cachedMeta,i=n.getMatchingVisibleMetas(this._type).filter((t=>t.controller.options.grouped)),s=n.options.stacked,o=[],a=this._cachedMeta.controller.getParsed(e),r=a&&a[n.axis],l=t=>{const e=t._parsed.find((t=>t[n.axis]===r)),i=e&&e[t.vScale.axis];if(ft(i)||isNaN(i))return!0};for(const n of i)if((void 0===e||!l(n))&&((!1===s||-1===o.indexOf(n.stack)||void 0===s&&void 0===n.stack)&&o.push(n.stack),n.index===t))break;return o.length||o.push(void 0),o}_getStackCount(t){return this._getStacks(void 0,t).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){const t=this.chart.scales,e=this.chart.options.indexAxis;return Object.keys(t).filter((n=>t[n].axis===e)).shift()}_getAxis(){const t={},e=this.getFirstScaleIdForIndexAxis();for(const n of this.chart.data.datasets)t[wt("x"===this.chart.options.indexAxis?n.xAxisID:n.yAxisID,e)]=!0;return Object.keys(t)}_getStackIndex(t,e,n){const i=this._getStacks(t,n),s=void 0!==e?i.indexOf(e):-1;return-1===s?i.length-1:s}_getRuler(){const t=this.options,e=this._cachedMeta,n=e.iScale,i=[];let s,o;for(s=0,o=e.data.length;s<o;++s)i.push(n.getPixelForValue(this.getParsed(s)[n.axis],s));const a=t.barThickness;return{min:a||Si(e),pixels:i,start:n._startPixel,end:n._endPixel,stackCount:this._getStackCount(),scale:n,grouped:t.grouped,ratio:a?1:t.categoryPercentage*t.barPercentage}}_calculateBarValuePixels(t){const{_cachedMeta:{vScale:e,_stacked:n,index:i},options:{base:s,minBarLength:o}}=this,a=s||0,r=this.getParsed(t),l=r._custom,c=_i(l);let d,h,u=r[e.axis],g=0,p=n?this.applyStack(e,r,n):u;p!==u&&(g=p-u,p=u),c&&(u=l.barStart,p=l.barEnd-l.barStart,0!==u&&Ut(u)!==Ut(l.barEnd)&&(g=0),g+=u);const m=ft(s)||c?g:s;let f=e.getPixelForValue(m);if(d=this.chart.getDataVisibility(t)?e.getPixelForValue(g+p):f,h=d-f,Math.abs(h)<o){h=function(t,e,n){return 0!==t?Ut(t):(e.isHorizontal()?1:-1)*(e.min>=n?1:-1)}(h,e,a)*o,u===a&&(f-=h/2);const t=e.getPixelForDecimal(0),s=e.getPixelForDecimal(1),l=Math.min(t,s),g=Math.max(t,s);f=Math.max(Math.min(f,g),l),d=f+h,n&&!c&&(r._stacks[e.axis]._visualValues[i]=e.getValueForPixel(d)-e.getValueForPixel(f))}if(f===e.getPixelForValue(a)){const t=Ut(h)*e.getLineWidthForValue(a)/2;f+=t,h-=t}return{size:h,base:f,head:d,center:d+h/2}}_calculateBarIndexPixels(t,e){const n=e.scale,i=this.options,s=i.skipNull,o=wt(i.maxBarThickness,1/0);let a,r;const l=this._getAxisCount();if(e.grouped){const n=s?this._getStackCount(t):e.stackCount,c="flex"===i.barThickness?function(t,e,n,i){const s=e.pixels,o=s[t];let a=t>0?s[t-1]:null,r=t<s.length-1?s[t+1]:null;const l=n.categoryPercentage;null===a&&(a=o-(null===r?e.end-e.start:r-o)),null===r&&(r=o+o-a);const c=o-(o-Math.min(a,r))/2*l;return{chunk:Math.abs(r-a)/2*l/i,ratio:n.barPercentage,start:c}}(t,e,i,n*l):function(t,e,n,i){const s=n.barThickness;let o,a;return ft(s)?(o=e.min*n.categoryPercentage,a=n.barPercentage):(o=s*i,a=1),{chunk:o/i,ratio:a,start:e.pixels[t]-o/2}}(t,e,i,n*l),d="x"===this.chart.options.indexAxis?this.getDataset().xAxisID:this.getDataset().yAxisID,h=this._getAxis().indexOf(wt(d,this.getFirstScaleIdForIndexAxis())),u=this._getStackIndex(this.index,this._cachedMeta.stack,s?t:void 0)+h;a=c.start+c.chunk*u+c.chunk/2,r=Math.min(o,c.chunk*c.ratio)}else a=n.getPixelForValue(this.getParsed(t)[n.axis],t),r=Math.min(o,e.min*e.ratio);return{base:a-r/2,head:a+r/2,center:a,size:r}}draw(){const t=this._cachedMeta,e=t.vScale,n=t.data,i=n.length;let s=0;for(;s<i;++s)null===this.getParsed(s)[e.axis]||n[s].hidden||n[s].draw(this._ctx)}}class Ai extends ki{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,{labels:{pointStyle:n,textAlign:i,color:s,useBorderRadius:o,borderRadius:a}}=t.legend.options;return e.labels.length&&e.datasets.length?e.labels.map(((e,r)=>{const l=t.getDatasetMeta(0).controller.getStyle(r);return{text:e,fillStyle:l.backgroundColor,fontColor:s,hidden:!t.getDataVisibility(r),lineDash:l.borderDash,lineDashOffset:l.borderDashOffset,lineJoin:l.borderJoinStyle,lineWidth:l.borderWidth,strokeStyle:l.borderColor,textAlign:i,pointStyle:n,borderRadius:o&&(a||l.borderRadius),index:r}})):[]}},onClick(t,e,n){n.chart.toggleDataVisibility(e.index),n.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 n=this.getDataset().data,i=this._cachedMeta;if(!1===this._parsing)i._parsed=n;else{let s,o,a=t=>+n[t];if(yt(n[t])){const{key:t="value"}=this._parsing;a=e=>+It(n[e],t)}for(s=t,o=t+e;s<o;++s)i._parsed[s]=a(s)}}_getRotation(){return Zt(this.options.rotation-90)}_getCircumference(){return Zt(this.options.circumference)}_getRotationExtents(){let t=Rt,e=-Rt;for(let n=0;n<this.chart.data.datasets.length;++n)if(this.chart.isDatasetVisible(n)&&this.chart.getDatasetMeta(n).type===this._type){const i=this.chart.getDatasetMeta(n).controller,s=i._getRotation(),o=i._getCircumference();t=Math.min(t,s),e=Math.max(e,s+o)}return{rotation:t,circumference:e-t}}update(t){const e=this.chart,{chartArea:n}=e,i=this._cachedMeta,s=i.data,o=this.getMaxBorderWidth()+this.getMaxOffset(s)+this.options.spacing,a=Math.max((Math.min(n.width,n.height)-o)/2,0),r=Math.min((l=this.options.cutout,c=a,"string"==typeof l&&l.endsWith("%")?parseFloat(l)/100:+l/c),1);var l,c;const d=this._getRingWeight(this.index),{circumference:h,rotation:u}=this._getRotationExtents(),{ratioX:g,ratioY:p,offsetX:m,offsetY:f}=function(t,e,n){let i=1,s=1,o=0,a=0;if(e<Rt){const r=t,l=r+e,c=Math.cos(r),d=Math.sin(r),h=Math.cos(l),u=Math.sin(l),g=(t,e,i)=>oe(t,r,l,!0)?1:Math.max(e,e*n,i,i*n),p=(t,e,i)=>oe(t,r,l,!0)?-1:Math.min(e,e*n,i,i*n),m=g(0,c,h),f=g(Ht,d,u),b=p($t,c,h),y=p($t+Ht,d,u);i=(m-b)/2,s=(f-y)/2,o=-(m+b)/2,a=-(f+y)/2}return{ratioX:i,ratioY:s,offsetX:o,offsetY:a}}(u,h,r),b=(n.width-o)/g,y=(n.height-o)/p,x=Math.max(Math.min(b,y)/2,0),v=kt(this.options.radius,x),w=(v-Math.max(v*r,0))/this._getVisibleDatasetWeightTotal();this.offsetX=m*v,this.offsetY=f*v,i.total=this.calculateTotal(),this.outerRadius=v-w*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-w*d,0),this.updateElements(s,0,s.length,t)}_circumference(t,e){const n=this.options,i=this._cachedMeta,s=this._getCircumference();return e&&n.animation.animateRotate||!this.chart.getDataVisibility(t)||null===i._parsed[t]||i.data[t].hidden?0:this.calculateCircumference(i._parsed[t]*s/Rt)}updateElements(t,e,n,i){const s="reset"===i,o=this.chart,a=o.chartArea,r=o.options.animation,l=(a.left+a.right)/2,c=(a.top+a.bottom)/2,d=s&&r.animateScale,h=d?0:this.innerRadius,u=d?0:this.outerRadius,{sharedOptions:g,includeOptions:p}=this._getSharedOptions(e,i);let m,f=this._getRotation();for(m=0;m<e;++m)f+=this._circumference(m,s);for(m=e;m<e+n;++m){const e=this._circumference(m,s),n=t[m],o={x:l+this.offsetX,y:c+this.offsetY,startAngle:f,endAngle:f+e,circumference:e,outerRadius:u,innerRadius:h};p&&(o.options=g||this.resolveDataElementOptions(m,n.active?"active":i)),f+=e,this.updateElement(n,m,o,i)}}calculateTotal(){const t=this._cachedMeta,e=t.data;let n,i=0;for(n=0;n<e.length;n++){const s=t._parsed[n];null===s||isNaN(s)||!this.chart.getDataVisibility(n)||e[n].hidden||(i+=Math.abs(s))}return i}calculateCircumference(t){const e=this._cachedMeta.total;return e>0&&!isNaN(t)?Rt*(Math.abs(t)/e):0}getLabelAndValue(t){const e=this._cachedMeta,n=this.chart,i=n.data.labels||[],s=Ee(e._parsed[t],n.options.locale);return{label:i[t]||"",value:s}}getMaxBorderWidth(t){let e=0;const n=this.chart;let i,s,o,a,r;if(!t)for(i=0,s=n.data.datasets.length;i<s;++i)if(n.isDatasetVisible(i)){o=n.getDatasetMeta(i),t=o.data,a=o.controller;break}if(!t)return 0;for(i=0,s=t.length;i<s;++i)r=a.resolveDataElementOptions(i),"inner"!==r.borderAlign&&(e=Math.max(e,r.borderWidth||0,r.hoverBorderWidth||0));return e}getMaxOffset(t){let e=0;for(let n=0,i=t.length;n<i;++n){const t=this.resolveDataElementOptions(n);e=Math.max(e,t.offset||0,t.hoverOffset||0)}return e}_getRingWeightOffset(t){let e=0;for(let n=0;n<t;++n)this.chart.isDatasetVisible(n)&&(e+=this._getRingWeight(n));return e}_getRingWeight(t){return Math.max(wt(this.chart.data.datasets[t].weight,1),0)}_getVisibleDatasetWeightTotal(){return this._getRingWeightOffset(this.chart.data.datasets.length)||1}}class Ii extends ki{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:n,color:i}}=t.legend.options;return e.labels.map(((e,s)=>{const o=t.getDatasetMeta(0).controller.getStyle(s);return{text:e,fillStyle:o.backgroundColor,strokeStyle:o.borderColor,fontColor:i,lineWidth:o.borderWidth,pointStyle:n,hidden:!t.getDataVisibility(s),index:s}}))}return[]}},onClick(t,e,n){n.chart.toggleDataVisibility(e.index),n.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,n=this.chart,i=n.data.labels||[],s=Ee(e._parsed[t].r,n.options.locale);return{label:i[t]||"",value:s}}parseObjectData(t,e,n,i){return Mn.bind(this)(t,e,n,i)}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,n)=>{const i=this.getParsed(n).r;!isNaN(i)&&this.chart.getDataVisibility(n)&&(i<e.min&&(e.min=i),i>e.max&&(e.max=i))})),e}_updateRadius(){const t=this.chart,e=t.chartArea,n=t.options,i=Math.min(e.right-e.left,e.bottom-e.top),s=Math.max(i/2,0),o=(s-Math.max(n.cutoutPercentage?s/100*n.cutoutPercentage:1,0))/t.getVisibleDatasetCount();this.outerRadius=s-o*this.index,this.innerRadius=this.outerRadius-o}updateElements(t,e,n,i){const s="reset"===i,o=this.chart,a=o.options.animation,r=this._cachedMeta.rScale,l=r.xCenter,c=r.yCenter,d=r.getIndexAngle(0)-.5*$t;let h,u=d;const g=360/this.countVisibleElements();for(h=0;h<e;++h)u+=this._computeAngle(h,i,g);for(h=e;h<e+n;h++){const e=t[h];let n=u,p=u+this._computeAngle(h,i,g),m=o.getDataVisibility(h)?r.getDistanceFromCenterForValue(this.getParsed(h).r):0;u=p,s&&(a.animateScale&&(m=0),a.animateRotate&&(n=p=d));const f={x:l,y:c,innerRadius:0,outerRadius:m,startAngle:n,endAngle:p,options:this.resolveDataElementOptions(h,e.active?"active":i)};this.updateElement(e,h,f,i)}}countVisibleElements(){const t=this._cachedMeta;let e=0;return t.data.forEach(((t,n)=>{!isNaN(this.getParsed(n).r)&&this.chart.getDataVisibility(n)&&e++})),e}_computeAngle(t,e,n){return this.chart.getDataVisibility(t)?Zt(this.resolveDataElementOptions(t,e).angle||n):0}}var zi=Object.freeze({__proto__:null,BarController:Li,BubbleController:class extends ki{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,n,i){const s=super.parsePrimitiveData(t,e,n,i);for(let t=0;t<s.length;t++)s[t]._custom=this.resolveDataElementOptions(t+n).radius;return s}parseArrayData(t,e,n,i){const s=super.parseArrayData(t,e,n,i);for(let t=0;t<s.length;t++){const i=e[n+t];s[t]._custom=wt(i[2],this.resolveDataElementOptions(t+n).radius)}return s}parseObjectData(t,e,n,i){const s=super.parseObjectData(t,e,n,i);for(let t=0;t<s.length;t++){const i=e[n+t];s[t]._custom=wt(i&&i.r&&+i.r,this.resolveDataElementOptions(t+n).radius)}return s}getMaxOverflow(){const t=this._cachedMeta.data;let e=0;for(let n=t.length-1;n>=0;--n)e=Math.max(e,t[n].size(this.resolveDataElementOptions(n))/2);return e>0&&e}getLabelAndValue(t){const e=this._cachedMeta,n=this.chart.data.labels||[],{xScale:i,yScale:s}=e,o=this.getParsed(t),a=i.getLabelForValue(o.x),r=s.getLabelForValue(o.y),l=o._custom;return{label:n[t]||"",value:"("+a+", "+r+(l?", "+l:"")+")"}}update(t){const e=this._cachedMeta.data;this.updateElements(e,0,e.length,t)}updateElements(t,e,n,i){const s="reset"===i,{iScale:o,vScale:a}=this._cachedMeta,{sharedOptions:r,includeOptions:l}=this._getSharedOptions(e,i),c=o.axis,d=a.axis;for(let h=e;h<e+n;h++){const e=t[h],n=!s&&this.getParsed(h),u={},g=u[c]=s?o.getPixelForDecimal(.5):o.getPixelForValue(n[c]),p=u[d]=s?a.getBasePixel():a.getPixelForValue(n[d]);u.skip=isNaN(g)||isNaN(p),l&&(u.options=r||this.resolveDataElementOptions(h,e.active?"active":i),s&&(u.options.radius=0)),this.updateElement(e,h,u,i)}}resolveDataElementOptions(t,e){const n=this.getParsed(t);let i=super.resolveDataElementOptions(t,e);i.$shared&&(i=Object.assign({},i,{$shared:!1}));const s=i.radius;return"active"!==e&&(i.radius=0),i.radius+=wt(n&&n._custom,s),i}},DoughnutController:Ai,LineController:class extends ki{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:n,data:i=[],_dataset:s}=e,o=this.chart._animationsDisabled;let{start:a,count:r}=ye(e,i,o);this._drawStart=a,this._drawCount=r,xe(e)&&(a=0,r=i.length),n._chart=this.chart,n._datasetIndex=this.index,n._decimated=!!s._decimated,n.points=i;const l=this.resolveDatasetElementOptions(t);this.options.showLine||(l.borderWidth=0),l.segment=this.options.segment,this.updateElement(n,void 0,{animated:!o,options:l},t),this.updateElements(i,a,r,t)}updateElements(t,e,n,i){const s="reset"===i,{iScale:o,vScale:a,_stacked:r,_dataset:l}=this._cachedMeta,{sharedOptions:c,includeOptions:d}=this._getSharedOptions(e,i),h=o.axis,u=a.axis,{spanGaps:g,segment:p}=this.options,m=Gt(g)?g:Number.POSITIVE_INFINITY,f=this.chart._animationsDisabled||s||"none"===i,b=e+n,y=t.length;let x=e>0&&this.getParsed(e-1);for(let n=0;n<y;++n){const g=t[n],y=f?g:{};if(n<e||n>=b){y.skip=!0;continue}const v=this.getParsed(n),w=ft(v[u]),k=y[h]=o.getPixelForValue(v[h],n),S=y[u]=s||w?a.getBasePixel():a.getPixelForValue(r?this.applyStack(a,v,r):v[u],n);y.skip=isNaN(k)||isNaN(S)||w,y.stop=n>0&&Math.abs(v[h]-x[h])>m,p&&(y.parsed=v,y.raw=l.data[n]),d&&(y.options=c||this.resolveDataElementOptions(n,g.active?"active":i)),f||this.updateElement(g,n,y,i),x=v}}getMaxOverflow(){const t=this._cachedMeta,e=t.dataset,n=e.options&&e.options.borderWidth||0,i=t.data||[];if(!i.length)return n;const s=i[0].size(this.resolveDataElementOptions(0)),o=i[i.length-1].size(this.resolveDataElementOptions(i.length-1));return Math.max(n,s,o)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}},PieController:class extends Ai{static id="pie";static defaults={cutout:0,rotation:0,circumference:360,radius:"100%"}},PolarAreaController:Ii,RadarController:class extends ki{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,n=this.getParsed(t);return{label:e.getLabels()[t],value:""+e.getLabelForValue(n[e.axis])}}parseObjectData(t,e,n,i){return Mn.bind(this)(t,e,n,i)}update(t){const e=this._cachedMeta,n=e.dataset,i=e.data||[],s=e.iScale.getLabels();if(n.points=i,"resize"!==t){const e=this.resolveDatasetElementOptions(t);this.options.showLine||(e.borderWidth=0);const o={_loop:!0,_fullLoop:s.length===i.length,options:e};this.updateElement(n,void 0,o,t)}this.updateElements(i,0,i.length,t)}updateElements(t,e,n,i){const s=this._cachedMeta.rScale,o="reset"===i;for(let a=e;a<e+n;a++){const e=t[a],n=this.resolveDataElementOptions(a,e.active?"active":i),r=s.getPointPositionForValue(a,this.getParsed(a).r),l=o?s.xCenter:r.x,c=o?s.yCenter:r.y,d={x:l,y:c,angle:r.angle,skip:isNaN(l)||isNaN(c),options:n};this.updateElement(e,a,d,i)}}},ScatterController:class extends ki{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,n=this.chart.data.labels||[],{xScale:i,yScale:s}=e,o=this.getParsed(t),a=i.getLabelForValue(o.x),r=s.getLabelForValue(o.y);return{label:n[t]||"",value:"("+a+", "+r+")"}}update(t){const e=this._cachedMeta,{data:n=[]}=e,i=this.chart._animationsDisabled;let{start:s,count:o}=ye(e,n,i);if(this._drawStart=s,this._drawCount=o,xe(e)&&(s=0,o=n.length),this.options.showLine){this.datasetElementType||this.addElements();const{dataset:s,_dataset:o}=e;s._chart=this.chart,s._datasetIndex=this.index,s._decimated=!!o._decimated,s.points=n;const a=this.resolveDatasetElementOptions(t);a.segment=this.options.segment,this.updateElement(s,void 0,{animated:!i,options:a},t)}else this.datasetElementType&&(delete e.dataset,this.datasetElementType=!1);this.updateElements(n,s,o,t)}addElements(){const{showLine:t}=this.options;!this.datasetElementType&&t&&(this.datasetElementType=this.chart.registry.getElement("line")),super.addElements()}updateElements(t,e,n,i){const s="reset"===i,{iScale:o,vScale:a,_stacked:r,_dataset:l}=this._cachedMeta,c=this.resolveDataElementOptions(e,i),d=this.getSharedOptions(c),h=this.includeOptions(i,d),u=o.axis,g=a.axis,{spanGaps:p,segment:m}=this.options,f=Gt(p)?p:Number.POSITIVE_INFINITY,b=this.chart._animationsDisabled||s||"none"===i;let y=e>0&&this.getParsed(e-1);for(let c=e;c<e+n;++c){const e=t[c],n=this.getParsed(c),p=b?e:{},x=ft(n[g]),v=p[u]=o.getPixelForValue(n[u],c),w=p[g]=s||x?a.getBasePixel():a.getPixelForValue(r?this.applyStack(a,n,r):n[g],c);p.skip=isNaN(v)||isNaN(w)||x,p.stop=c>0&&Math.abs(n[u]-y[u])>f,m&&(p.parsed=n,p.raw=l.data[c]),h&&(p.options=d||this.resolveDataElementOptions(c,e.active?"active":i)),b||this.updateElement(e,c,p,i),y=n}this.updateSharedOptions(d,i,c)}getMaxOverflow(){const t=this._cachedMeta,e=t.data||[];if(!this.options.showLine){let t=0;for(let n=e.length-1;n>=0;--n)t=Math.max(t,e[n].size(this.resolveDataElementOptions(n))/2);return t>0&&t}const n=t.dataset,i=n.options&&n.options.borderWidth||0;if(!e.length)return i;const s=e[0].size(this.resolveDataElementOptions(0)),o=e[e.length-1].size(this.resolveDataElementOptions(e.length-1));return Math.max(i,s,o)/2}}});function Oi(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class Wi{static override(t){Object.assign(Wi.prototype,t)}options;constructor(t){this.options=t||{}}init(){}formats(){return Oi()}parse(){return Oi()}format(){return Oi()}add(){return Oi()}diff(){return Oi()}startOf(){return Oi()}endOf(){return Oi()}}var Ni={_date:Wi};function $i(t,e,n,i){const{controller:s,data:o,_sorted:a}=t,r=s._cachedMeta.iScale,l=t.dataset&&t.dataset.options?t.dataset.options.spanGaps:null;if(r&&e===r.axis&&"r"!==e&&a&&o.length){const a=r._reversePixels?de:ce;if(!i){const i=a(o,e,n);if(l){const{vScale:e}=s._cachedMeta,{_parsed:n}=t,o=n.slice(0,i.lo+1).reverse().findIndex((t=>!ft(t[e.axis])));i.lo-=Math.max(0,o);const a=n.slice(i.hi).findIndex((t=>!ft(t[e.axis])));i.hi+=Math.max(0,a)}return i}if(s._sharedOptions){const t=o[0],i="function"==typeof t.getRange&&t.getRange(e);if(i){const t=a(o,e,n-i),s=a(o,e,n+i);return{lo:t.lo,hi:s.hi}}}}return{lo:0,hi:o.length-1}}function Ri(t,e,n,i,s){const o=t.getSortedVisibleDatasetMetas(),a=n[e];for(let t=0,n=o.length;t<n;++t){const{index:n,data:r}=o[t],{lo:l,hi:c}=$i(o[t],e,a,s);for(let t=l;t<=c;++t){const e=r[t];e.skip||i(e,n,t)}}}function Fi(t,e,n,i,s){const o=[];if(!s&&!t.isPointInArea(e))return o;return Ri(t,n,e,(function(n,a,r){(s||je(n,t.chartArea,0))&&n.inRange(e.x,e.y,i)&&o.push({element:n,datasetIndex:a,index:r})}),!0),o}function Bi(t,e,n,i,s,o){let a=[];const r=function(t){const e=-1!==t.indexOf("x"),n=-1!==t.indexOf("y");return function(t,i){const s=e?Math.abs(t.x-i.x):0,o=n?Math.abs(t.y-i.y):0;return Math.sqrt(Math.pow(s,2)+Math.pow(o,2))}}(n);let l=Number.POSITIVE_INFINITY;return Ri(t,n,e,(function(n,c,d){const h=n.inRange(e.x,e.y,s);if(i&&!h)return;const u=n.getCenterPoint(s);if(!(!!o||t.isPointInArea(u))&&!h)return;const g=r(e,u);g<l?(a=[{element:n,datasetIndex:c,index:d}],l=g):g===l&&a.push({element:n,datasetIndex:c,index:d})})),a}function qi(t,e,n,i,s,o){return o||t.isPointInArea(e)?"r"!==n||i?Bi(t,e,n,i,s,o):function(t,e,n,i){let s=[];return Ri(t,n,e,(function(t,n,o){const{startAngle:a,endAngle:r}=t.getProps(["startAngle","endAngle"],i),{angle:l}=ee(t,{x:e.x,y:e.y});oe(l,a,r)&&s.push({element:t,datasetIndex:n,index:o})})),s}(t,e,n,s):[]}function Hi(t,e,n,i,s){const o=[],a="x"===n?"inXRange":"inYRange";let r=!1;return Ri(t,n,e,((t,i,l)=>{t[a]&&t[a](e[n],s)&&(o.push({element:t,datasetIndex:i,index:l}),r=r||t.inRange(e.x,e.y,s))})),i&&!r?[]:o}var Vi={evaluateInteractionItems:Ri,modes:{index(t,e,n,i){const s=$n(e,t),o=n.axis||"x",a=n.includeInvisible||!1,r=n.intersect?Fi(t,s,o,i,a):qi(t,s,o,!1,i,a),l=[];return r.length?(t.getSortedVisibleDatasetMetas().forEach((t=>{const e=r[0].index,n=t.data[e];n&&!n.skip&&l.push({element:n,datasetIndex:t.index,index:e})})),l):[]},dataset(t,e,n,i){const s=$n(e,t),o=n.axis||"xy",a=n.includeInvisible||!1;let r=n.intersect?Fi(t,s,o,i,a):qi(t,s,o,!1,i,a);if(r.length>0){const e=r[0].datasetIndex,n=t.getDatasetMeta(e).data;r=[];for(let t=0;t<n.length;++t)r.push({element:n[t],datasetIndex:e,index:t})}return r},point:(t,e,n,i)=>Fi(t,$n(e,t),n.axis||"xy",i,n.includeInvisible||!1),nearest(t,e,n,i){const s=$n(e,t),o=n.axis||"xy",a=n.includeInvisible||!1;return qi(t,s,o,n.intersect,i,a)},x:(t,e,n,i)=>Hi(t,$n(e,t),"x",n.intersect,i),y:(t,e,n,i)=>Hi(t,$n(e,t),"y",n.intersect,i)}};const ji=["left","top","right","bottom"];function Yi(t,e){return t.filter((t=>t.pos===e))}function Ui(t,e){return t.filter((t=>-1===ji.indexOf(t.pos)&&t.box.axis===e))}function Xi(t,e){return t.sort(((t,n)=>{const i=e?n:t,s=e?t:n;return i.weight===s.weight?i.index-s.index:i.weight-s.weight}))}function Qi(t,e){const n=function(t){const e={};for(const n of t){const{stack:t,pos:i,stackWeight:s}=n;if(!t||!ji.includes(i))continue;const o=e[t]||(e[t]={count:0,placed:0,weight:0,size:0});o.count++,o.weight+=s}return e}(t),{vBoxMaxWidth:i,hBoxMaxHeight:s}=e;let o,a,r;for(o=0,a=t.length;o<a;++o){r=t[o];const{fullSize:a}=r.box,l=n[r.stack],c=l&&r.stackWeight/l.weight;r.horizontal?(r.width=c?c*i:a&&e.availableWidth,r.height=s):(r.width=i,r.height=c?c*s:a&&e.availableHeight)}return n}function Gi(t,e,n,i){return Math.max(t[n],e[n])+Math.max(t[i],e[i])}function Ki(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 Zi(t,e,n,i){const{pos:s,box:o}=n,a=t.maxPadding;if(!yt(s)){n.size&&(t[s]-=n.size);const e=i[n.stack]||{size:0,count:1};e.size=Math.max(e.size,n.horizontal?o.height:o.width),n.size=e.size/e.count,t[s]+=n.size}o.getPadding&&Ki(a,o.getPadding());const r=Math.max(0,e.outerWidth-Gi(a,t,"left","right")),l=Math.max(0,e.outerHeight-Gi(a,t,"top","bottom")),c=r!==t.w,d=l!==t.h;return t.w=r,t.h=l,n.horizontal?{same:c,other:d}:{same:d,other:c}}function Ji(t,e){const n=e.maxPadding;function i(t){const i={left:0,top:0,right:0,bottom:0};return t.forEach((t=>{i[t]=Math.max(e[t],n[t])})),i}return i(t?["left","right"]:["top","bottom"])}function ts(t,e,n,i){const s=[];let o,a,r,l,c,d;for(o=0,a=t.length,c=0;o<a;++o){r=t[o],l=r.box,l.update(r.width||e.w,r.height||e.h,Ji(r.horizontal,e));const{same:a,other:h}=Zi(e,n,r,i);c|=a&&s.length,d=d||h,l.fullSize||s.push(r)}return c&&ts(s,e,n,i)||d}function es(t,e,n,i,s){t.top=n,t.left=e,t.right=e+i,t.bottom=n+s,t.width=i,t.height=s}function ns(t,e,n,i){const s=n.padding;let{x:o,y:a}=e;for(const r of t){const t=r.box,l=i[r.stack]||{count:1,placed:0,weight:1},c=r.stackWeight/l.weight||1;if(r.horizontal){const i=e.w*c,o=l.size||t.height;Ot(l.start)&&(a=l.start),t.fullSize?es(t,s.left,a,n.outerWidth-s.right-s.left,o):es(t,e.left+l.placed,a,i,o),l.start=a,l.placed+=i,a=t.bottom}else{const i=e.h*c,a=l.size||t.width;Ot(l.start)&&(o=l.start),t.fullSize?es(t,o,s.top,a,n.outerHeight-s.bottom-s.top):es(t,o,e.top+l.placed,a,i),l.start=o,l.placed+=i,o=t.right}}e.x=o,e.y=a}var is={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 n=t.boxes?t.boxes.indexOf(e):-1;-1!==n&&t.boxes.splice(n,1)},configure(t,e,n){e.fullSize=n.fullSize,e.position=n.position,e.weight=n.weight},update(t,e,n,i){if(!t)return;const s=rn(t.options.layout.padding),o=Math.max(e-s.width,0),a=Math.max(n-s.height,0),r=function(t){const e=function(t){const e=[];let n,i,s,o,a,r;for(n=0,i=(t||[]).length;n<i;++n)s=t[n],({position:o,options:{stack:a,stackWeight:r=1}}=s),e.push({index:n,box:s,pos:o,horizontal:s.isHorizontal(),weight:s.weight,stack:a&&o+a,stackWeight:r});return e}(t),n=Xi(e.filter((t=>t.box.fullSize)),!0),i=Xi(Yi(e,"left"),!0),s=Xi(Yi(e,"right")),o=Xi(Yi(e,"top"),!0),a=Xi(Yi(e,"bottom")),r=Ui(e,"x"),l=Ui(e,"y");return{fullSize:n,leftAndTop:i.concat(o),rightAndBottom:s.concat(l).concat(a).concat(r),chartArea:Yi(e,"chartArea"),vertical:i.concat(s).concat(l),horizontal:o.concat(a).concat(r)}}(t.boxes),l=r.vertical,c=r.horizontal;Mt(t.boxes,(t=>{"function"==typeof t.beforeLayout&&t.beforeLayout()}));const d=l.reduce(((t,e)=>e.box.options&&!1===e.box.options.display?t:t+1),0)||1,h=Object.freeze({outerWidth:e,outerHeight:n,padding:s,availableWidth:o,availableHeight:a,vBoxMaxWidth:o/2/d,hBoxMaxHeight:a/2}),u=Object.assign({},s);Ki(u,rn(i));const g=Object.assign({maxPadding:u,w:o,h:a,x:s.left,y:s.top},s),p=Qi(l.concat(c),h);ts(r.fullSize,g,h,p),ts(l,g,h,p),ts(c,g,h,p)&&ts(l,g,h,p),function(t){const e=t.maxPadding;function n(n){const i=Math.max(e[n]-t[n],0);return t[n]+=i,i}t.y+=n("top"),t.x+=n("left"),n("right"),n("bottom")}(g),ns(r.leftAndTop,g,h,p),g.x+=g.w,g.y+=g.h,ns(r.rightAndBottom,g,h,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},Mt(r.chartArea,(e=>{const n=e.box;Object.assign(n,t.chartArea),n.update(g.w,g.h,{left:0,top:0,right:0,bottom:0})}))}};class ss{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,n){}removeEventListener(t,e,n){}getDevicePixelRatio(){return 1}getMaximumSize(t,e,n,i){return e=Math.max(0,e||t.width),n=n||t.height,{width:e,height:Math.max(0,i?Math.floor(e/i):n)}}isAttached(t){return!0}updateConfig(t){}}class os extends ss{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const as="$chartjs",rs={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},ls=t=>null===t||""===t;const cs=!!qn&&{passive:!0};function ds(t,e,n){t&&t.canvas&&t.canvas.removeEventListener(e,n,cs)}function hs(t,e){for(const n of t)if(n===e||n.contains(e))return!0}function us(t,e,n){const i=t.canvas,s=new MutationObserver((t=>{let e=!1;for(const n of t)e=e||hs(n.addedNodes,i),e=e&&!hs(n.removedNodes,i);e&&n()}));return s.observe(document,{childList:!0,subtree:!0}),s}function gs(t,e,n){const i=t.canvas,s=new MutationObserver((t=>{let e=!1;for(const n of t)e=e||hs(n.removedNodes,i),e=e&&!hs(n.addedNodes,i);e&&n()}));return s.observe(document,{childList:!0,subtree:!0}),s}const ps=new Map;let ms=0;function fs(){const t=window.devicePixelRatio;t!==ms&&(ms=t,ps.forEach(((e,n)=>{n.currentDevicePixelRatio!==t&&e()})))}function bs(t,e,n){const i=t.canvas,s=i&&In(i);if(!s)return;const o=me(((t,e)=>{const i=s.clientWidth;n(t,e),i<s.clientWidth&&n()}),window),a=new ResizeObserver((t=>{const e=t[0],n=e.contentRect.width,i=e.contentRect.height;0===n&&0===i||o(n,i)}));return a.observe(s),function(t,e){ps.size||window.addEventListener("resize",fs),ps.set(t,e)}(t,o),a}function ys(t,e,n){n&&n.disconnect(),"resize"===e&&function(t){ps.delete(t),ps.size||window.removeEventListener("resize",fs)}(t)}function xs(t,e,n){const i=t.canvas,s=me((e=>{null!==t.ctx&&n(function(t,e){const n=rs[t.type]||t.type,{x:i,y:s}=$n(t,e);return{type:n,chart:e,native:t,x:void 0!==i?i:null,y:void 0!==s?s:null}}(e,t))}),t);return function(t,e,n){t&&t.addEventListener(e,n,cs)}(i,e,s),s}class vs extends ss{acquireContext(t,e){const n=t&&t.getContext&&t.getContext("2d");return n&&n.canvas===t?(function(t,e){const n=t.style,i=t.getAttribute("height"),s=t.getAttribute("width");if(t[as]={initial:{height:i,width:s,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||"block",n.boxSizing=n.boxSizing||"border-box",ls(s)){const e=Hn(t,"width");void 0!==e&&(t.width=e)}if(ls(i))if(""===t.style.height)t.height=t.width/(e||2);else{const e=Hn(t,"height");void 0!==e&&(t.height=e)}}(t,e),n):null}releaseContext(t){const e=t.canvas;if(!e[as])return!1;const n=e[as].initial;["height","width"].forEach((t=>{const i=n[t];ft(i)?e.removeAttribute(t):e.setAttribute(t,i)}));const i=n.style||{};return Object.keys(i).forEach((t=>{e.style[t]=i[t]})),e.width=e.width,delete e[as],!0}addEventListener(t,e,n){this.removeEventListener(t,e);const i=t.$proxies||(t.$proxies={}),s={attach:us,detach:gs,resize:bs}[e]||xs;i[e]=s(t,e,n)}removeEventListener(t,e){const n=t.$proxies||(t.$proxies={}),i=n[e];if(!i)return;({attach:ys,detach:ys,resize:ys}[e]||ds)(t,e,i),n[e]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,n,i){return Fn(t,e,n,i)}isAttached(t){const e=t&&In(t);return!(!e||!e.isConnected)}}class ws{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(t){const{x:e,y:n}=this.getProps(["x","y"],t);return{x:e,y:n}}hasValue(){return Gt(this.x)&&Gt(this.y)}getProps(t,e){const n=this.$animations;if(!e||!n)return this;const i={};return t.forEach((t=>{i[t]=n[t]&&n[t].active()?n[t]._to:this[t]})),i}}function ks(t,e){const n=t.options.ticks,i=function(t){const e=t.options.offset,n=t._tickSize(),i=t._length/n+(e?0:1),s=t._maxLength/n;return Math.floor(Math.min(i,s))}(t),s=Math.min(n.maxTicksLimit||i,i),o=n.major.enabled?function(t){const e=[];let n,i;for(n=0,i=t.length;n<i;n++)t[n].major&&e.push(n);return e}(e):[],a=o.length,r=o[0],l=o[a-1],c=[];if(a>s)return function(t,e,n,i){let s,o=0,a=n[0];for(i=Math.ceil(i),s=0;s<t.length;s++)s===a&&(e.push(t[s]),o++,a=n[o*i])}(e,c,o,a/s),c;const d=function(t,e,n){const i=function(t){const e=t.length;let n,i;if(e<2)return!1;for(i=t[0],n=1;n<e;++n)if(t[n]-t[n-1]!==i)return!1;return i}(t),s=e.length/n;if(!i)return Math.max(s,1);const o=function(t){const e=[],n=Math.sqrt(t);let i;for(i=1;i<n;i++)t%i===0&&(e.push(i),e.push(t/i));return n===(0|n)&&e.push(n),e.sort(((t,e)=>t-e)).pop(),e}(i);for(let t=0,e=o.length-1;t<e;t++){const e=o[t];if(e>s)return e}return Math.max(s,1)}(o,e,s);if(a>0){let t,n;const i=a>1?Math.round((l-r)/(a-1)):null;for(Ss(e,c,d,ft(i)?0:r-i,r),t=0,n=a-1;t<n;t++)Ss(e,c,d,o[t],o[t+1]);return Ss(e,c,d,l,ft(i)?e.length:l+i),c}return Ss(e,c,d),c}function Ss(t,e,n,i,s){const o=wt(i,0),a=Math.min(wt(s,t.length),t.length);let r,l,c,d=0;for(n=Math.ceil(n),s&&(r=s-i,n=r/Math.floor(r/n)),c=o;c<0;)d++,c=Math.round(o+d*n);for(l=Math.max(o,0);l<a;l++)l===c&&(e.push(t[l]),d++,c=Math.round(o+d*n))}const Ms=(t,e,n)=>"top"===e||"left"===e?t[e]+n:t[e]-n,Cs=(t,e)=>Math.min(e||t,t);function _s(t,e){const n=[],i=t.length/e,s=t.length;let o=0;for(;o<s;o+=i)n.push(t[Math.floor(o)]);return n}function Ts(t,e,n){const i=t.ticks.length,s=Math.min(e,i-1),o=t._startPixel,a=t._endPixel,r=1e-6;let l,c=t.getPixelForTick(s);if(!(n&&(l=1===i?Math.max(c-o,a-c):0===e?(t.getPixelForTick(1)-c)/2:(c-t.getPixelForTick(s-1))/2,c+=s<e?l:-l,c<o-r||c>a+r)))return c}function Ds(t){return t.drawTicks?t.tickLength:0}function Ps(t,e){if(!t.display)return 0;const n=ln(t.font,e),i=rn(t.padding);return(bt(t.text)?t.text.length:1)*n.lineHeight+i.height}function Es(t,e,n){let i=fe(t);return(n&&"right"!==e||!n&&"right"===e)&&(i=(t=>"left"===t?"right":"right"===t?"left":t)(i)),i}class Ls extends ws{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:n,_suggestedMax:i}=this;return t=vt(t,Number.POSITIVE_INFINITY),e=vt(e,Number.NEGATIVE_INFINITY),n=vt(n,Number.POSITIVE_INFINITY),i=vt(i,Number.NEGATIVE_INFINITY),{min:vt(t,n),max:vt(e,i),minDefined:xt(t),maxDefined:xt(e)}}getMinMax(t){let e,{min:n,max:i,minDefined:s,maxDefined:o}=this.getUserBounds();if(s&&o)return{min:n,max:i};const a=this.getMatchingVisibleMetas();for(let r=0,l=a.length;r<l;++r)e=a[r].controller.getMinMax(this,t),s||(n=Math.min(n,e.min)),o||(i=Math.max(i,e.max));return n=o&&n>i?i:n,i=s&&n>i?n:i,{min:vt(n,vt(i,n)),max:vt(i,vt(n,i))}}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(){St(this.options.beforeUpdate,[this])}update(t,e,n){const{beginAtZero:i,grace:s,ticks:o}=this.options,a=o.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=n=Object.assign({left:0,right:0,top:0,bottom:0},n),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+n.left+n.right:this.height+n.top+n.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=function(t,e,n){const{min:i,max:s}=t,o=kt(e,(s-i)/2),a=(t,e)=>n&&0===t?0:t+e;return{min:a(i,-Math.abs(o)),max:a(s,o)}}(this,s,i),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const r=a<this.ticks.length;this._convertTicksToLabels(r?_s(this.ticks,a):this.ticks),this.configure(),this.beforeCalculateLabelRotation(),this.calculateLabelRotation(),this.afterCalculateLabelRotation(),o.display&&(o.autoSkip||"auto"===o.source)&&(this.ticks=ks(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,n=this.options.reverse;this.isHorizontal()?(t=this.left,e=this.right):(t=this.top,e=this.bottom,n=!n),this._startPixel=t,this._endPixel=e,this._reversePixels=n,this._length=e-t,this._alignToPixels=this.options.alignToPixels}afterUpdate(){St(this.options.afterUpdate,[this])}beforeSetDimensions(){St(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(){St(this.options.afterSetDimensions,[this])}_callHooks(t){this.chart.notifyPlugins(t,this.getContext()),St(this.options[t],[this])}beforeDataLimits(){this._callHooks("beforeDataLimits")}determineDataLimits(){}afterDataLimits(){this._callHooks("afterDataLimits")}beforeBuildTicks(){this._callHooks("beforeBuildTicks")}buildTicks(){return[]}afterBuildTicks(){this._callHooks("afterBuildTicks")}beforeTickToLabelConversion(){St(this.options.beforeTickToLabelConversion,[this])}generateTickLabels(t){const e=this.options.ticks;let n,i,s;for(n=0,i=t.length;n<i;n++)s=t[n],s.label=St(e.callback,[s.value,n,t],this)}afterTickToLabelConversion(){St(this.options.afterTickToLabelConversion,[this])}beforeCalculateLabelRotation(){St(this.options.beforeCalculateLabelRotation,[this])}calculateLabelRotation(){const t=this.options,e=t.ticks,n=Cs(this.ticks.length,t.ticks.maxTicksLimit),i=e.minRotation||0,s=e.maxRotation;let o,a,r,l=i;if(!this._isVisible()||!e.display||i>=s||n<=1||!this.isHorizontal())return void(this.labelRotation=i);const c=this._getLabelSizes(),d=c.widest.width,h=c.highest.height,u=ae(this.chart.width-d,0,this.maxWidth);o=t.offset?this.maxWidth/n:u/(n-1),d+6>o&&(o=u/(n-(t.offset?.5:1)),a=this.maxHeight-Ds(t.grid)-e.padding-Ps(t.title,this.chart.options.font),r=Math.sqrt(d*d+h*h),l=Jt(Math.min(Math.asin(ae((c.highest.height+6)/o,-1,1)),Math.asin(ae(a/r,-1,1))-Math.asin(ae(h/r,-1,1)))),l=Math.max(i,Math.min(s,l))),this.labelRotation=l}afterCalculateLabelRotation(){St(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){St(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:e,options:{ticks:n,title:i,grid:s}}=this,o=this._isVisible(),a=this.isHorizontal();if(o){const o=Ps(i,e.options.font);if(a?(t.width=this.maxWidth,t.height=Ds(s)+o):(t.height=this.maxHeight,t.width=Ds(s)+o),n.display&&this.ticks.length){const{first:e,last:i,widest:s,highest:o}=this._getLabelSizes(),r=2*n.padding,l=Zt(this.labelRotation),c=Math.cos(l),d=Math.sin(l);if(a){const e=n.mirror?0:d*s.width+c*o.height;t.height=Math.min(this.maxHeight,t.height+e+r)}else{const e=n.mirror?0:c*s.width+d*o.height;t.width=Math.min(this.maxWidth,t.width+e+r)}this._calculatePadding(e,i,d,c)}}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,n,i){const{ticks:{align:s,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,c=this.right-this.getPixelForTick(this.ticks.length-1);let d=0,h=0;r?l?(d=i*t.width,h=n*e.height):(d=n*t.height,h=i*e.width):"start"===s?h=e.width:"end"===s?d=t.width:"inner"!==s&&(d=t.width/2,h=e.width/2),this.paddingLeft=Math.max((d-a+o)*this.width/(this.width-a),0),this.paddingRight=Math.max((h-c+o)*this.width/(this.width-c),0)}else{let n=e.height/2,i=t.height/2;"start"===s?(n=0,i=t.height):"end"===s&&(n=e.height,i=0),this.paddingTop=n+o,this.paddingBottom=i+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(){St(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,n;for(this.beforeTickToLabelConversion(),this.generateTickLabels(t),e=0,n=t.length;e<n;e++)ft(t[e].label)&&(t.splice(e,1),n--,e--);this.afterTickToLabelConversion()}_getLabelSizes(){let t=this._labelSizes;if(!t){const e=this.options.ticks.sampleSize;let n=this.ticks;e<n.length&&(n=_s(n,e)),this._labelSizes=t=this._computeLabelSizes(n,n.length,this.options.ticks.maxTicksLimit)}return t}_computeLabelSizes(t,e,n){const{ctx:i,_longestTextCache:s}=this,o=[],a=[],r=Math.floor(e/Cs(e,n));let l,c,d,h,u,g,p,m,f,b,y,x=0,v=0;for(l=0;l<e;l+=r){if(h=t[l].label,u=this._resolveTickFontOptions(l),i.font=g=u.string,p=s[g]=s[g]||{data:{},gc:[]},m=u.lineHeight,f=b=0,ft(h)||bt(h)){if(bt(h))for(c=0,d=h.length;c<d;++c)y=h[c],ft(y)||bt(y)||(f=Re(i,p.data,p.gc,f,y),b+=m)}else f=Re(i,p.data,p.gc,f,h),b=m;o.push(f),a.push(b),x=Math.max(f,x),v=Math.max(b,v)}!function(t,e){Mt(t,(t=>{const n=t.gc,i=n.length/2;let s;if(i>e){for(s=0;s<i;++s)delete t.data[n[s]];n.splice(0,i)}}))}(s,e);const w=o.indexOf(x),k=a.indexOf(v),S=t=>({width:o[t]||0,height:a[t]||0});return{first:S(0),last:S(e-1),widest:S(w),highest:S(k),widths:o,heights:a}}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 ae(this._alignToPixels?Be(this.chart,e,0):e,-32768,32767)}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 n=e[t];return n.$context||(n.$context=function(t,e,n){return dn(t,{tick:n,index:e,type:"tick"})}(this.getContext(),t,n))}return this.$context||(this.$context=dn(this.chart.getContext(),{scale:this,type:"scale"}))}_tickSize(){const t=this.options.ticks,e=Zt(this.labelRotation),n=Math.abs(Math.cos(e)),i=Math.abs(Math.sin(e)),s=this._getLabelSizes(),o=t.autoSkipPadding||0,a=s?s.widest.width+o:0,r=s?s.highest.height+o:0;return this.isHorizontal()?r*n>a*i?a/n:r/i:r*i<a*n?r/n:a/i}_isVisible(){const t=this.options.display;return"auto"!==t?!!t:this.getMatchingVisibleMetas().length>0}_computeGridLineItems(t){const e=this.axis,n=this.chart,i=this.options,{grid:s,position:o,border:a}=i,r=s.offset,l=this.isHorizontal(),c=this.ticks.length+(r?1:0),d=Ds(s),h=[],u=a.setContext(this.getContext()),g=u.display?u.width:0,p=g/2,m=function(t){return Be(n,t,g)};let f,b,y,x,v,w,k,S,M,C,_,T;if("top"===o)f=m(this.bottom),w=this.bottom-d,S=f-p,C=m(t.top)+p,T=t.bottom;else if("bottom"===o)f=m(this.top),C=t.top,T=m(t.bottom)-p,w=f+p,S=this.top+d;else if("left"===o)f=m(this.right),v=this.right-d,k=f-p,M=m(t.left)+p,_=t.right;else if("right"===o)f=m(this.left),M=t.left,_=m(t.right)-p,v=f+p,k=this.left+d;else if("x"===e){if("center"===o)f=m((t.top+t.bottom)/2+.5);else if(yt(o)){const t=Object.keys(o)[0],e=o[t];f=m(this.chart.scales[t].getPixelForValue(e))}C=t.top,T=t.bottom,w=f+p,S=w+d}else if("y"===e){if("center"===o)f=m((t.left+t.right)/2);else if(yt(o)){const t=Object.keys(o)[0],e=o[t];f=m(this.chart.scales[t].getPixelForValue(e))}v=f-p,k=v-d,M=t.left,_=t.right}const D=wt(i.ticks.maxTicksLimit,c),P=Math.max(1,Math.ceil(c/D));for(b=0;b<c;b+=P){const t=this.getContext(b),e=s.setContext(t),i=a.setContext(t),o=e.lineWidth,c=e.color,d=i.dash||[],u=i.dashOffset,g=e.tickWidth,p=e.tickColor,m=e.tickBorderDash||[],f=e.tickBorderDashOffset;y=Ts(this,b,r),void 0!==y&&(x=Be(n,y,o),l?v=k=M=_=x:w=S=C=T=x,h.push({tx1:v,ty1:w,tx2:k,ty2:S,x1:M,y1:C,x2:_,y2:T,width:o,color:c,borderDash:d,borderDashOffset:u,tickWidth:g,tickColor:p,tickBorderDash:m,tickBorderDashOffset:f}))}return this._ticksLength=c,this._borderValue=f,h}_computeLabelItems(t){const e=this.axis,n=this.options,{position:i,ticks:s}=n,o=this.isHorizontal(),a=this.ticks,{align:r,crossAlign:l,padding:c,mirror:d}=s,h=Ds(n.grid),u=h+c,g=d?-c:u,p=-Zt(this.labelRotation),m=[];let f,b,y,x,v,w,k,S,M,C,_,T,D="middle";if("top"===i)w=this.bottom-g,k=this._getXAxisLabelAlignment();else if("bottom"===i)w=this.top+g,k=this._getXAxisLabelAlignment();else if("left"===i){const t=this._getYAxisLabelAlignment(h);k=t.textAlign,v=t.x}else if("right"===i){const t=this._getYAxisLabelAlignment(h);k=t.textAlign,v=t.x}else if("x"===e){if("center"===i)w=(t.top+t.bottom)/2+u;else if(yt(i)){const t=Object.keys(i)[0],e=i[t];w=this.chart.scales[t].getPixelForValue(e)+u}k=this._getXAxisLabelAlignment()}else if("y"===e){if("center"===i)v=(t.left+t.right)/2-u;else if(yt(i)){const t=Object.keys(i)[0],e=i[t];v=this.chart.scales[t].getPixelForValue(e)}k=this._getYAxisLabelAlignment(h).textAlign}"y"===e&&("start"===r?D="top":"end"===r&&(D="bottom"));const P=this._getLabelSizes();for(f=0,b=a.length;f<b;++f){y=a[f],x=y.label;const t=s.setContext(this.getContext(f));S=this.getPixelForTick(f)+s.labelOffset,M=this._resolveTickFontOptions(f),C=M.lineHeight,_=bt(x)?x.length:1;const e=_/2,n=t.color,r=t.textStrokeColor,c=t.textStrokeWidth;let h,u=k;if(o?(v=S,"inner"===k&&(u=f===b-1?this.options.reverse?"left":"right":0===f?this.options.reverse?"right":"left":"center"),T="top"===i?"near"===l||0!==p?-_*C+C/2:"center"===l?-P.highest.height/2-e*C+C:-P.highest.height+C/2:"near"===l||0!==p?C/2:"center"===l?P.highest.height/2-e*C:P.highest.height-_*C,d&&(T*=-1),0===p||t.showLabelBackdrop||(v+=C/2*Math.sin(p))):(w=S,T=(1-_)*C/2),t.showLabelBackdrop){const e=rn(t.backdropPadding),n=P.heights[f],i=P.widths[f];let s=T-e.top,o=0-e.left;switch(D){case"middle":s-=n/2;break;case"bottom":s-=n}switch(k){case"center":o-=i/2;break;case"right":o-=i;break;case"inner":f===b-1?o-=i:f>0&&(o-=i/2)}h={left:o,top:s,width:i+e.width,height:n+e.height,color:t.backdropColor}}m.push({label:x,font:M,textOffset:T,options:{rotation:p,color:n,strokeColor:r,strokeWidth:c,textAlign:u,textBaseline:D,translation:[v,w],backdrop:h}})}return m}_getXAxisLabelAlignment(){const{position:t,ticks:e}=this.options;if(-Zt(this.labelRotation))return"top"===t?"left":"right";let n="center";return"start"===e.align?n="left":"end"===e.align?n="right":"inner"===e.align&&(n="inner"),n}_getYAxisLabelAlignment(t){const{position:e,ticks:{crossAlign:n,mirror:i,padding:s}}=this.options,o=t+s,a=this._getLabelSizes().widest.width;let r,l;return"left"===e?i?(l=this.right+s,"near"===n?r="left":"center"===n?(r="center",l+=a/2):(r="right",l+=a)):(l=this.right-o,"near"===n?r="right":"center"===n?(r="center",l-=a/2):(r="left",l=this.left)):"right"===e?i?(l=this.left+s,"near"===n?r="right":"center"===n?(r="center",l-=a/2):(r="left",l-=a)):(l=this.left+o,"near"===n?r="left":"center"===n?(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:n,top:i,width:s,height:o}=this;e&&(t.save(),t.fillStyle=e,t.fillRect(n,i,s,o),t.restore())}getLineWidthForValue(t){const e=this.options.grid;if(!this._isVisible()||!e.display)return 0;const n=this.ticks.findIndex((e=>e.value===t));if(n>=0){return e.setContext(this.getContext(n)).lineWidth}return 0}drawGrid(t){const e=this.options.grid,n=this.ctx,i=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let s,o;const a=(t,e,i)=>{i.width&&i.color&&(n.save(),n.lineWidth=i.width,n.strokeStyle=i.color,n.setLineDash(i.borderDash||[]),n.lineDashOffset=i.borderDashOffset,n.beginPath(),n.moveTo(t.x,t.y),n.lineTo(e.x,e.y),n.stroke(),n.restore())};if(e.display)for(s=0,o=i.length;s<o;++s){const t=i[s];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:n,grid:i}}=this,s=n.setContext(this.getContext()),o=n.display?s.width:0;if(!o)return;const a=i.setContext(this.getContext(0)).lineWidth,r=this._borderValue;let l,c,d,h;this.isHorizontal()?(l=Be(t,this.left,o)-o/2,c=Be(t,this.right,a)+a/2,d=h=r):(d=Be(t,this.top,o)-o/2,h=Be(t,this.bottom,a)+a/2,l=c=r),e.save(),e.lineWidth=s.width,e.strokeStyle=s.color,e.beginPath(),e.moveTo(l,d),e.lineTo(c,h),e.stroke(),e.restore()}drawLabels(t){if(!this.options.ticks.display)return;const e=this.ctx,n=this._computeLabelArea();n&&Ye(e,n);const i=this.getLabelItems(t);for(const t of i){const n=t.options,i=t.font;Ze(e,t.label,0,t.textOffset,i,n)}n&&Ue(e)}drawTitle(){const{ctx:t,options:{position:e,title:n,reverse:i}}=this;if(!n.display)return;const s=ln(n.font),o=rn(n.padding),a=n.align;let r=s.lineHeight/2;"bottom"===e||"center"===e||yt(e)?(r+=o.bottom,bt(n.text)&&(r+=s.lineHeight*(n.text.length-1))):r+=o.top;const{titleX:l,titleY:c,maxWidth:d,rotation:h}=function(t,e,n,i){const{top:s,left:o,bottom:a,right:r,chart:l}=t,{chartArea:c,scales:d}=l;let h,u,g,p=0;const m=a-s,f=r-o;if(t.isHorizontal()){if(u=be(i,o,r),yt(n)){const t=Object.keys(n)[0],i=n[t];g=d[t].getPixelForValue(i)+m-e}else g="center"===n?(c.bottom+c.top)/2+m-e:Ms(t,n,e);h=r-o}else{if(yt(n)){const t=Object.keys(n)[0],i=n[t];u=d[t].getPixelForValue(i)-f+e}else u="center"===n?(c.left+c.right)/2-f+e:Ms(t,n,e);g=be(i,a,s),p="left"===n?-Ht:Ht}return{titleX:u,titleY:g,maxWidth:h,rotation:p}}(this,r,e,a);Ze(t,n.text,0,0,s,{color:n.color,maxWidth:d,rotation:h,textAlign:Es(a,e,i),textBaseline:"middle",translation:[l,c]})}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,n=wt(t.grid&&t.grid.z,-1),i=wt(t.border&&t.border.z,0);return this._isVisible()&&this.draw===Ls.prototype.draw?[{z:n,draw:t=>{this.drawBackground(),this.drawGrid(t),this.drawTitle()}},{z:i,draw:()=>{this.drawBorder()}},{z:e,draw:t=>{this.drawLabels(t)}}]:[{z:e,draw:t=>{this.draw(t)}}]}getMatchingVisibleMetas(t){const e=this.chart.getSortedVisibleDatasetMetas(),n=this.axis+"AxisID",i=[];let s,o;for(s=0,o=e.length;s<o;++s){const o=e[s];o[n]!==this.id||t&&o.type!==t||i.push(o)}return i}_resolveTickFontOptions(t){return ln(this.options.ticks.setContext(this.getContext(t)).font)}_maxDigits(){const t=this._resolveTickFontOptions(0).lineHeight;return(this.isHorizontal()?this.width:this.height)/t}}class As{constructor(t,e,n){this.type=t,this.scope=e,this.override=n,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 n;(function(t){return"id"in t&&"defaults"in t})(e)&&(n=this.register(e));const i=this.items,s=t.id,o=this.scope+"."+s;if(!s)throw new Error("class does not have id: "+t);return s in i||(i[s]=t,function(t,e,n){const i=Pt(Object.create(null),[n?$e.get(n):{},$e.get(e),t.defaults]);$e.set(e,i),t.defaultRoutes&&function(t,e){Object.keys(e).forEach((n=>{const i=n.split("."),s=i.pop(),o=[t].concat(i).join("."),a=e[n].split("."),r=a.pop(),l=a.join(".");$e.route(o,s,l,r)}))}(e,t.defaultRoutes);t.descriptors&&$e.describe(e,t.descriptors)}(t,o,n),this.override&&$e.override(t.id,t.overrides)),o}get(t){return this.items[t]}unregister(t){const e=this.items,n=t.id,i=this.scope;n in e&&delete e[n],i&&n in $e[i]&&(delete $e[i][n],this.override&&delete Ie[n])}}class Is{constructor(){this.controllers=new As(ki,"datasets",!0),this.elements=new As(ws,"elements"),this.plugins=new As(Object,"plugins"),this.scales=new As(Ls,"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,n){[...e].forEach((e=>{const i=n||this._getRegistryForType(e);n||i.isForType(e)||i===this.plugins&&e.id?this._exec(t,i,e):Mt(e,(e=>{const i=n||this._getRegistryForType(e);this._exec(t,i,e)}))}))}_exec(t,e,n){const i=zt(t);St(n["before"+i],[],n),e[t](n),St(n["after"+i],[],n)}_getRegistryForType(t){for(let e=0;e<this._typedRegistries.length;e++){const n=this._typedRegistries[e];if(n.isForType(t))return n}return this.plugins}_get(t,e,n){const i=e.get(t);if(void 0===i)throw new Error('"'+t+'" is not a registered '+n+".");return i}}var zs=new Is;class Os{constructor(){this._init=void 0}notify(t,e,n,i){if("beforeInit"===e&&(this._init=this._createDescriptors(t,!0),this._notify(this._init,t,"install")),void 0===this._init)return;const s=i?this._descriptors(t).filter(i):this._descriptors(t),o=this._notify(s,t,e,n);return"afterDestroy"===e&&(this._notify(s,t,"stop"),this._notify(this._init,t,"uninstall"),this._init=void 0),o}_notify(t,e,n,i){i=i||{};for(const s of t){const t=s.plugin;if(!1===St(t[n],[e,i,s.options],t)&&i.cancelable)return!1}return!0}invalidate(){ft(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 n=t&&t.config,i=wt(n.options&&n.options.plugins,{}),s=function(t){const e={},n=[],i=Object.keys(zs.plugins.items);for(let t=0;t<i.length;t++)n.push(zs.getPlugin(i[t]));const s=t.plugins||[];for(let t=0;t<s.length;t++){const i=s[t];-1===n.indexOf(i)&&(n.push(i),e[i.id]=!0)}return{plugins:n,localIds:e}}(n);return!1!==i||e?function(t,{plugins:e,localIds:n},i,s){const o=[],a=t.getContext();for(const r of e){const e=r.id,l=Ws(i[e],s);null!==l&&o.push({plugin:r,options:Ns(t.config,{plugin:r,local:n[e]},l,a)})}return o}(t,s,i,e):[]}_notifyStateChanges(t){const e=this._oldCache||[],n=this._cache,i=(t,e)=>t.filter((t=>!e.some((e=>t.plugin.id===e.plugin.id))));this._notify(i(e,n),t,"stop"),this._notify(i(n,e),t,"start")}}function Ws(t,e){return e||!1!==t?!0===t?{}:t:null}function Ns(t,{plugin:e,local:n},i,s){const o=t.pluginScopeKeys(e),a=t.getOptionScopes(i,o);return n&&e.defaults&&a.push(e.defaults),t.createResolver(a,s,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function $s(t,e){const n=$e.datasets[t]||{};return((e.datasets||{})[t]||{}).indexAxis||e.indexAxis||n.indexAxis||"x"}function Rs(t){if("x"===t||"y"===t||"r"===t)return t}function Fs(t,...e){if(Rs(t))return t;for(const i of e){const e=i.axis||("top"===(n=i.position)||"bottom"===n?"x":"left"===n||"right"===n?"y":void 0)||t.length>1&&Rs(t[0].toLowerCase());if(e)return e}var n;throw new Error(`Cannot determine type of '${t}' axis. Please provide 'axis' or 'position' option.`)}function Bs(t,e,n){if(n[e+"AxisID"]===t)return{axis:e}}function qs(t,e){const n=Ie[t.type]||{scales:{}},i=e.scales||{},s=$s(t.type,e),o=Object.create(null);return Object.keys(i).forEach((e=>{const a=i[e];if(!yt(a))return console.error(`Invalid scale configuration for scale: ${e}`);if(a._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${e}`);const r=Fs(e,a,function(t,e){if(e.data&&e.data.datasets){const n=e.data.datasets.filter((e=>e.xAxisID===t||e.yAxisID===t));if(n.length)return Bs(t,"x",n[0])||Bs(t,"y",n[0])}return{}}(e,t),$e.scales[a.type]),l=function(t,e){return t===e?"_index_":"_value_"}(r,s),c=n.scales||{};o[e]=Et(Object.create(null),[{axis:r},a,c[r],c[l]])})),t.data.datasets.forEach((n=>{const s=n.type||t.type,a=n.indexAxis||$s(s,e),r=(Ie[s]||{}).scales||{};Object.keys(r).forEach((t=>{const e=function(t,e){let n=t;return"_index_"===t?n=e:"_value_"===t&&(n="x"===e?"y":"x"),n}(t,a),s=n[e+"AxisID"]||e;o[s]=o[s]||Object.create(null),Et(o[s],[{axis:e},i[s],r[t]])}))})),Object.keys(o).forEach((t=>{const e=o[t];Et(e,[$e.scales[e.type],$e.scale])})),o}function Hs(t){const e=t.options||(t.options={});e.plugins=wt(e.plugins,{}),e.scales=qs(t,e)}function Vs(t){return(t=t||{}).datasets=t.datasets||[],t.labels=t.labels||[],t}const js=new Map,Ys=new Set;function Us(t,e){let n=js.get(t);return n||(n=e(),js.set(t,n),Ys.add(n)),n}const Xs=(t,e,n)=>{const i=It(e,n);void 0!==i&&t.add(i)};class Qs{constructor(t){this._config=function(t){return(t=t||{}).data=Vs(t.data),Hs(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=Vs(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(),Hs(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return Us(t,(()=>[[`datasets.${t}`,""]]))}datasetAnimationScopeKeys(t,e){return Us(`${t}.transition.${e}`,(()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]]))}datasetElementScopeKeys(t,e){return Us(`${t}-${e}`,(()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]]))}pluginScopeKeys(t){const e=t.id;return Us(`${this.type}-plugin-${e}`,(()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]]))}_cachedScopes(t,e){const n=this._scopeCache;let i=n.get(t);return i&&!e||(i=new Map,n.set(t,i)),i}getOptionScopes(t,e,n){const{options:i,type:s}=this,o=this._cachedScopes(t,n),a=o.get(e);if(a)return a;const r=new Set;e.forEach((e=>{t&&(r.add(t),e.forEach((e=>Xs(r,t,e)))),e.forEach((t=>Xs(r,i,t))),e.forEach((t=>Xs(r,Ie[s]||{},t))),e.forEach((t=>Xs(r,$e,t))),e.forEach((t=>Xs(r,ze,t)))}));const l=Array.from(r);return 0===l.length&&l.push(Object.create(null)),Ys.has(e)&&o.set(e,l),l}chartOptionScopes(){const{options:t,type:e}=this;return[t,Ie[e]||{},$e.datasets[e]||{},{type:e},$e,ze]}resolveNamedOptions(t,e,n,i=[""]){const s={$shared:!0},{resolver:o,subPrefixes:a}=Gs(this._resolverCache,t,i);let r=o;if(function(t,e){const{isScriptable:n,isIndexable:i}=gn(t);for(const s of e){const e=n(s),o=i(s),a=(o||e)&&t[s];if(e&&(Wt(a)||Ks(a))||o&&bt(a))return!0}return!1}(o,e)){s.$shared=!1;r=un(o,n=Wt(n)?n():n,this.createResolver(t,n,a))}for(const t of e)s[t]=r[t];return s}createResolver(t,e,n=[""],i){const{resolver:s}=Gs(this._resolverCache,t,n);return yt(e)?un(s,e,void 0,i):s}}function Gs(t,e,n){let i=t.get(e);i||(i=new Map,t.set(e,i));const s=n.join();let o=i.get(s);if(!o){o={resolver:hn(e,n),subPrefixes:n.filter((t=>!t.toLowerCase().includes("hover")))},i.set(s,o)}return o}const Ks=t=>yt(t)&&Object.getOwnPropertyNames(t).some((e=>Wt(t[e])));const Zs=["top","bottom","left","right","chartArea"];function Js(t,e){return"top"===t||"bottom"===t||-1===Zs.indexOf(t)&&"x"===e}function to(t,e){return function(n,i){return n[t]===i[t]?n[e]-i[e]:n[t]-i[t]}}function eo(t){const e=t.chart,n=e.options.animation;e.notifyPlugins("afterRender"),St(n&&n.onComplete,[t],e)}function no(t){const e=t.chart,n=e.options.animation;St(n&&n.onProgress,[t],e)}function io(t){return An()&&"string"==typeof t?t=document.getElementById(t):t&&t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas),t}const so={},oo=t=>{const e=io(t);return Object.values(so).filter((t=>t.canvas===e)).pop()};function ao(t,e,n){const i=Object.keys(t);for(const s of i){const i=+s;if(i>=e){const o=t[s];delete t[s],(n>0||i>e)&&(t[i+n]=o)}}}class ro{static defaults=$e;static instances=so;static overrides=Ie;static registry=zs;static version="4.5.1";static getChart=oo;static register(...t){zs.add(...t),lo()}static unregister(...t){zs.remove(...t),lo()}constructor(t,e){const n=this.config=new Qs(e),i=io(t),s=oo(i);if(s)throw new Error("Canvas is already in use. Chart with ID '"+s.id+"' must be destroyed before the canvas with ID '"+s.canvas.id+"' can be reused.");const o=n.createResolver(n.chartOptionScopes(),this.getContext());this.platform=new(n.platform||function(t){return!An()||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas?os:vs}(i)),this.platform.updateConfig(n);const a=this.platform.acquireContext(i,o.aspectRatio),r=a&&a.canvas,l=r&&r.height,c=r&&r.width;this.id=mt(),this.ctx=a,this.canvas=r,this.width=c,this.height=l,this._options=o,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 Os,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=function(t,e){let n;return function(...i){return e?(clearTimeout(n),n=setTimeout(t,e,i)):t.apply(this,i),e}}((t=>this.update(t)),o.resizeDelay||0),this._dataChanges=[],so[this.id]=this,a&&r?(ai.listen(this,"complete",eo),ai.listen(this,"progress",no),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:n,height:i,_aspectRatio:s}=this;return ft(t)?e&&s?s:i?n/i: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 zs}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():Bn(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return qe(this.canvas,this.ctx),this}stop(){return ai.stop(this),this}resize(t,e){ai.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){const n=this.options,i=this.canvas,s=n.maintainAspectRatio&&this.aspectRatio,o=this.platform.getMaximumSize(i,t,e,s),a=n.devicePixelRatio||this.platform.getDevicePixelRatio(),r=this.width?"resize":"attach";this.width=o.width,this.height=o.height,this._aspectRatio=this.aspectRatio,Bn(this,a,!0)&&(this.notifyPlugins("resize",{size:o}),St(n.onResize,[this,o],this),this.attached&&this._doResize(r)&&this.render())}ensureScalesHaveIDs(){Mt(this.options.scales||{},((t,e)=>{t.id=e}))}buildOrUpdateScales(){const t=this.options,e=t.scales,n=this.scales,i=Object.keys(n).reduce(((t,e)=>(t[e]=!1,t)),{});let s=[];e&&(s=s.concat(Object.keys(e).map((t=>{const n=e[t],i=Fs(t,n),s="r"===i,o="x"===i;return{options:n,dposition:s?"chartArea":o?"bottom":"left",dtype:s?"radialLinear":o?"category":"linear"}})))),Mt(s,(e=>{const s=e.options,o=s.id,a=Fs(o,s),r=wt(s.type,e.dtype);void 0!==s.position&&Js(s.position,a)===Js(e.dposition)||(s.position=e.dposition),i[o]=!0;let l=null;if(o in n&&n[o].type===r)l=n[o];else{l=new(zs.getScale(r))({id:o,type:r,ctx:this.ctx,chart:this}),n[l.id]=l}l.init(s,t)})),Mt(i,((t,e)=>{t||delete n[e]})),Mt(n,(t=>{is.configure(this,t,t.options),is.addBox(this,t)}))}_updateMetasets(){const t=this._metasets,e=this.data.datasets.length,n=t.length;if(t.sort(((t,e)=>t.index-e.index)),n>e){for(let t=e;t<n;++t)this._destroyDatasetMeta(t);t.splice(e,n-e)}this._sortedMetasets=t.slice(0).sort(to("order","index"))}_removeUnreferencedMetasets(){const{_metasets:t,data:{datasets:e}}=this;t.length>e.length&&delete this._stacks,t.forEach(((t,n)=>{0===e.filter((e=>e===t._dataset)).length&&this._destroyDatasetMeta(n)}))}buildOrUpdateControllers(){const t=[],e=this.data.datasets;let n,i;for(this._removeUnreferencedMetasets(),n=0,i=e.length;n<i;n++){const i=e[n];let s=this.getDatasetMeta(n);const o=i.type||this.config.type;if(s.type&&s.type!==o&&(this._destroyDatasetMeta(n),s=this.getDatasetMeta(n)),s.type=o,s.indexAxis=i.indexAxis||$s(o,this.options),s.order=i.order||0,s.index=n,s.label=""+i.label,s.visible=this.isDatasetVisible(n),s.controller)s.controller.updateIndex(n),s.controller.linkScales();else{const e=zs.getController(o),{datasetElementType:i,dataElementType:a}=$e.datasets[o];Object.assign(e,{dataElementType:zs.getElement(a),datasetElementType:i&&zs.getElement(i)}),s.controller=new e(this,n),t.push(s.controller)}}return this._updateMetasets(),t}_resetElements(){Mt(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 n=this._options=e.createResolver(e.chartOptionScopes(),this.getContext()),i=this._animationsDisabled=!n.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),!1===this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0}))return;const s=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),n=!i&&-1===s.indexOf(e);e.buildOrUpdateElements(n),o=Math.max(+e.getMaxOverflow(),o)}o=this._minPadding=n.layout.autoPadding?o:0,this._updateLayout(o),i||Mt(s,(t=>{t.reset()})),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(to("z","_idx"));const{_active:a,_lastEvent:r}=this;r?this._eventHandler(r,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}_updateScales(){Mt(this.scales,(t=>{is.removeBox(this,t)})),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,e=new Set(Object.keys(this._listeners)),n=new Set(t.events);Nt(e,n)&&!!this._responsiveListeners===t.responsive||(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,e=this._getUniformDataChanges()||[];for(const{method:n,start:i,count:s}of e){ao(t,i,"_removeElements"===n?-s:s)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const e=this.data.datasets.length,n=e=>new Set(t.filter((t=>t[0]===e)).map(((t,e)=>e+","+t.splice(1).join(",")))),i=n(0);for(let t=1;t<e;t++)if(!Nt(i,n(t)))return;return Array.from(i).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;is.update(this,this.width,this.height,t);const e=this.chartArea,n=e.width<=0||e.height<=0;this._layers=[],Mt(this.boxes,(t=>{n&&"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,n=this.data.datasets.length;e<n;++e)this._updateDataset(e,Wt(t)?t({datasetIndex:e}):t);this.notifyPlugins("afterDatasetsUpdate",{mode:t})}}_updateDataset(t,e){const n=this.getDatasetMeta(t),i={meta:n,index:t,mode:e,cancelable:!0};!1!==this.notifyPlugins("beforeDatasetUpdate",i)&&(n.controller._update(e),i.cancelable=!1,this.notifyPlugins("afterDatasetUpdate",i))}render(){!1!==this.notifyPlugins("beforeRender",{cancelable:!0})&&(ai.has(this)?this.attached&&!ai.running(this)&&ai.start(this):(this.draw(),eo({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,n=[];let i,s;for(i=0,s=e.length;i<s;++i){const s=e[i];t&&!s.visible||n.push(s)}return n}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,n={meta:t,index:t.index,cancelable:!0},i=si(this,t);!1!==this.notifyPlugins("beforeDatasetDraw",n)&&(i&&Ye(e,i),t.controller.draw(),i&&Ue(e),n.cancelable=!1,this.notifyPlugins("afterDatasetDraw",n))}isPointInArea(t){return je(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,e,n,i){const s=Vi.modes[e];return"function"==typeof s?s(this,t,n,i):[]}getDatasetMeta(t){const e=this.data.datasets[t],n=this._metasets;let i=n.filter((t=>t&&t._dataset===e)).pop();return i||(i={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},n.push(i)),i}getContext(){return this.$context||(this.$context=dn(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const e=this.data.datasets[t];if(!e)return!1;const n=this.getDatasetMeta(t);return"boolean"==typeof n.hidden?!n.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,n){const i=n?"show":"hide",s=this.getDatasetMeta(t),o=s.controller._resolveAnimations(void 0,i);Ot(e)?(s.data[e].hidden=!n,this.update()):(this.setDatasetVisibility(t,n),o.update(s,{visible:n}),this.update((e=>e.datasetIndex===t?i: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(),ai.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(),qe(t,e),this.platform.releaseContext(e),this.canvas=null,this.ctx=null),delete so[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,n=(n,i)=>{e.addEventListener(this,n,i),t[n]=i},i=(t,e,n)=>{t.offsetX=e,t.offsetY=n,this._eventHandler(t)};Mt(this.options.events,(t=>n(t,i)))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,e=this.platform,n=(n,i)=>{e.addEventListener(this,n,i),t[n]=i},i=(n,i)=>{t[n]&&(e.removeEventListener(this,n,i),delete t[n])},s=(t,e)=>{this.canvas&&this.resize(t,e)};let o;const a=()=>{i("attach",a),this.attached=!0,this.resize(),n("resize",s),n("detach",o)};o=()=>{this.attached=!1,i("resize",s),this._stop(),this._resize(0,0),n("attach",a)},e.isAttached(this.canvas)?a():o()}unbindEvents(){Mt(this._listeners,((t,e)=>{this.platform.removeEventListener(this,e,t)})),this._listeners={},Mt(this._responsiveListeners,((t,e)=>{this.platform.removeEventListener(this,e,t)})),this._responsiveListeners=void 0}updateHoverStyle(t,e,n){const i=n?"set":"remove";let s,o,a,r;for("dataset"===e&&(s=this.getDatasetMeta(t[0].datasetIndex),s.controller["_"+i+"DatasetHoverStyle"]()),a=0,r=t.length;a<r;++a){o=t[a];const e=o&&this.getDatasetMeta(o.datasetIndex).controller;e&&e[i+"HoverStyle"](o.element,o.datasetIndex,o.index)}}getActiveElements(){return this._active||[]}setActiveElements(t){const e=this._active||[],n=t.map((({datasetIndex:t,index:e})=>{const n=this.getDatasetMeta(t);if(!n)throw new Error("No dataset found at index "+t);return{datasetIndex:t,element:n.data[e],index:e}}));!Ct(n,e)&&(this._active=n,this._lastEvent=null,this._updateHoverStyles(n,e))}notifyPlugins(t,e,n){return this._plugins.notify(this,t,e,n)}isPluginEnabled(t){return 1===this._plugins._cache.filter((e=>e.plugin.id===t)).length}_updateHoverStyles(t,e,n){const i=this.options.hover,s=(t,e)=>t.filter((t=>!e.some((e=>t.datasetIndex===e.datasetIndex&&t.index===e.index)))),o=s(e,t),a=n?t:s(t,e);o.length&&this.updateHoverStyle(o,i.mode,!1),a.length&&i.mode&&this.updateHoverStyle(a,i.mode,!0)}_eventHandler(t,e){const n={event:t,replay:e,cancelable:!0,inChartArea:this.isPointInArea(t)},i=e=>(e.options.events||this.options.events).includes(t.native.type);if(!1===this.notifyPlugins("beforeEvent",n,i))return;const s=this._handleEvent(t,e,n.inChartArea);return n.cancelable=!1,this.notifyPlugins("afterEvent",n,i),(s||n.changed)&&this.render(),this}_handleEvent(t,e,n){const{_active:i=[],options:s}=this,o=e,a=this._getActiveElements(t,i,n,o),r=function(t){return"mouseup"===t.type||"click"===t.type||"contextmenu"===t.type}(t),l=function(t,e,n,i){return n&&"mouseout"!==t.type?i?e:t:null}(t,this._lastEvent,n,r);n&&(this._lastEvent=null,St(s.onHover,[t,a,this],this),r&&St(s.onClick,[t,a,this],this));const c=!Ct(a,i);return(c||e)&&(this._active=a,this._updateHoverStyles(a,i,e)),this._lastEvent=l,c}_getActiveElements(t,e,n,i){if("mouseout"===t.type)return[];if(!n)return e;const s=this.options.hover;return this.getElementsAtEventForMode(t,s.mode,s,i)}}function lo(){return Mt(ro.instances,(t=>t._plugins.invalidate()))}function co(t,e,n,i){const s=sn(t.options.borderRadius,["outerStart","outerEnd","innerStart","innerEnd"]);const o=(n-e)/2,a=Math.min(o,i*e/2),r=t=>{const e=(n-Math.min(o,t))*i/2;return ae(t,0,Math.min(o,e))};return{outerStart:r(s.outerStart),outerEnd:r(s.outerEnd),innerStart:ae(s.innerStart,0,a),innerEnd:ae(s.innerEnd,0,a)}}function ho(t,e,n,i){return{x:n+t*Math.cos(e),y:i+t*Math.sin(e)}}function uo(t,e,n,i,s,o){const{x:a,y:r,startAngle:l,pixelMargin:c,innerRadius:d}=e,h=Math.max(e.outerRadius+i+n-c,0),u=d>0?d+i+n+c:0;let g=0;const p=s-l;if(i){const t=((d>0?d-i:0)+(h>0?h-i:0))/2;g=(p-(0!==t?p*t/(t+i):p))/2}const m=(p-Math.max(.001,p*h-n/$t)/h)/2,f=l+m+g,b=s-m-g,{outerStart:y,outerEnd:x,innerStart:v,innerEnd:w}=co(e,u,h,b-f),k=h-y,S=h-x,M=f+y/k,C=b-x/S,_=u+v,T=u+w,D=f+v/_,P=b-w/T;if(t.beginPath(),o){const e=(M+C)/2;if(t.arc(a,r,h,M,e),t.arc(a,r,h,e,C),x>0){const e=ho(S,C,a,r);t.arc(e.x,e.y,x,C,b+Ht)}const n=ho(T,b,a,r);if(t.lineTo(n.x,n.y),w>0){const e=ho(T,P,a,r);t.arc(e.x,e.y,w,b+Ht,P+Math.PI)}const i=(b-w/u+(f+v/u))/2;if(t.arc(a,r,u,b-w/u,i,!0),t.arc(a,r,u,i,f+v/u,!0),v>0){const e=ho(_,D,a,r);t.arc(e.x,e.y,v,D+Math.PI,f-Ht)}const s=ho(k,f,a,r);if(t.lineTo(s.x,s.y),y>0){const e=ho(k,M,a,r);t.arc(e.x,e.y,y,f-Ht,M)}}else{t.moveTo(a,r);const e=Math.cos(M)*h+a,n=Math.sin(M)*h+r;t.lineTo(e,n);const i=Math.cos(C)*h+a,s=Math.sin(C)*h+r;t.lineTo(i,s)}t.closePath()}function go(t,e,n,i,s){const{fullCircles:o,startAngle:a,circumference:r,options:l}=e,{borderWidth:c,borderJoinStyle:d,borderDash:h,borderDashOffset:u,borderRadius:g}=l,p="inner"===l.borderAlign;if(!c)return;t.setLineDash(h||[]),t.lineDashOffset=u,p?(t.lineWidth=2*c,t.lineJoin=d||"round"):(t.lineWidth=c,t.lineJoin=d||"bevel");let m=e.endAngle;if(o){uo(t,e,n,i,m,s);for(let e=0;e<o;++e)t.stroke();isNaN(r)||(m=a+(r%Rt||Rt))}p&&function(t,e,n){const{startAngle:i,pixelMargin:s,x:o,y:a,outerRadius:r,innerRadius:l}=e;let c=s/r;t.beginPath(),t.arc(o,a,r,i-c,n+c),l>s?(c=s/l,t.arc(o,a,l,n+c,i-c,!0)):t.arc(o,a,s,n+Ht,i-Ht),t.closePath(),t.clip()}(t,e,m),l.selfJoin&&m-a>=$t&&0===g&&"miter"!==d&&function(t,e,n){const{startAngle:i,x:s,y:o,outerRadius:a,innerRadius:r,options:l}=e,{borderWidth:c,borderJoinStyle:d}=l,h=Math.min(c/a,se(i-n));if(t.beginPath(),t.arc(s,o,a-c/2,i+h/2,n-h/2),r>0){const e=Math.min(c/r,se(i-n));t.arc(s,o,r+c/2,n-e/2,i+e/2,!0)}else{const e=Math.min(c/2,a*se(i-n));if("round"===d)t.arc(s,o,e,n-$t/2,i+$t/2,!0);else if("bevel"===d){const a=2*e*e,r=-a*Math.cos(n+$t/2)+s,l=-a*Math.sin(n+$t/2)+o,c=a*Math.cos(i+$t/2)+s,d=a*Math.sin(i+$t/2)+o;t.lineTo(r,l),t.lineTo(c,d)}}t.closePath(),t.moveTo(0,0),t.rect(0,0,t.canvas.width,t.canvas.height),t.clip("evenodd")}(t,e,m),o||(uo(t,e,n,i,m,s),t.stroke())}function po(t,e,n=e){t.lineCap=wt(n.borderCapStyle,e.borderCapStyle),t.setLineDash(wt(n.borderDash,e.borderDash)),t.lineDashOffset=wt(n.borderDashOffset,e.borderDashOffset),t.lineJoin=wt(n.borderJoinStyle,e.borderJoinStyle),t.lineWidth=wt(n.borderWidth,e.borderWidth),t.strokeStyle=wt(n.borderColor,e.borderColor)}function mo(t,e,n){t.lineTo(n.x,n.y)}function fo(t,e,n={}){const i=t.length,{start:s=0,end:o=i-1}=n,{start:a,end:r}=e,l=Math.max(s,a),c=Math.min(o,r),d=s<a&&o<a||s>r&&o>r;return{count:i,start:l,loop:e.loop,ilen:c<l&&!d?i+c-l:c-l}}function bo(t,e,n,i){const{points:s,options:o}=e,{count:a,start:r,loop:l,ilen:c}=fo(s,n,i),d=function(t){return t.stepped?Xe:t.tension||"monotone"===t.cubicInterpolationMode?Qe:mo}(o);let h,u,g,{move:p=!0,reverse:m}=i||{};for(h=0;h<=c;++h)u=s[(r+(m?c-h:h))%a],u.skip||(p?(t.moveTo(u.x,u.y),p=!1):d(t,g,u,m,o.stepped),g=u);return l&&(u=s[(r+(m?c:0))%a],d(t,g,u,m,o.stepped)),!!l}function yo(t,e,n,i){const s=e.points,{count:o,start:a,ilen:r}=fo(s,n,i),{move:l=!0,reverse:c}=i||{};let d,h,u,g,p,m,f=0,b=0;const y=t=>(a+(c?r-t:t))%o,x=()=>{g!==p&&(t.lineTo(f,p),t.lineTo(f,g),t.lineTo(f,m))};for(l&&(h=s[y(0)],t.moveTo(h.x,h.y)),d=0;d<=r;++d){if(h=s[y(d)],h.skip)continue;const e=h.x,n=h.y,i=0|e;i===u?(n<g?g=n:n>p&&(p=n),f=(b*f+e)/++b):(x(),t.lineTo(e,n),u=i,b=0,g=p=n),m=n}x()}function xo(t){const e=t.options,n=e.borderDash&&e.borderDash.length;return!(t._decimated||t._loop||e.tension||"monotone"===e.cubicInterpolationMode||e.stepped||n)?yo:bo}const vo="function"==typeof Path2D;function wo(t,e,n,i){vo&&!e.options.segment?function(t,e,n,i){let s=e._path;s||(s=e._path=new Path2D,e.path(s,n,i)&&s.closePath()),po(t,e.options),t.stroke(s)}(t,e,n,i):function(t,e,n,i){const{segments:s,options:o}=e,a=xo(e);for(const r of s)po(t,o,r.style),t.beginPath(),a(t,e,r,{start:n,end:n+i-1})&&t.closePath(),t.stroke()}(t,e,n,i)}class ko extends ws{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 n=this.options;if((n.tension||"monotone"===n.cubicInterpolationMode)&&!n.stepped&&!this._pointsUpdated){const i=n.spanGaps?this._loop:this._fullLoop;Ln(this._points,n,t,i,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=function(t,e){const n=t.points,i=t.options.spanGaps,s=n.length;if(!s)return[];const o=!!t._loop,{start:a,end:r}=function(t,e,n,i){let s=0,o=e-1;if(n&&!i)for(;s<e&&!t[s].skip;)s++;for(;s<e&&t[s].skip;)s++;for(s%=e,n&&(o+=s);o>s&&t[o%e].skip;)o--;return o%=e,{start:s,end:o}}(n,s,o,i);return ti(t,!0===i?[{start:a,end:r,loop:o}]:function(t,e,n,i){const s=t.length,o=[];let a,r=e,l=t[e];for(a=e+1;a<=n;++a){const n=t[a%s];n.skip||n.stop?l.skip||(i=!1,o.push({start:e%s,end:(a-1)%s,loop:i}),e=r=n.stop?a:null):(r=a,l.skip&&(e=a)),l=n}return null!==r&&o.push({start:e%s,end:r%s,loop:i}),o}(n,a,r<a?r+s:r,!!t._fullLoop&&0===a&&r===s-1),n,e)}(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,n=t.length;return n&&e[t[n-1].end]}interpolate(t,e){const n=this.options,i=t[e],s=this.points,o=Jn(this,{property:e,start:i,end:i});if(!o.length)return;const a=[],r=function(t){return t.stepped?jn:t.tension||"monotone"===t.cubicInterpolationMode?Yn:Vn}(n);let l,c;for(l=0,c=o.length;l<c;++l){const{start:c,end:d}=o[l],h=s[c],u=s[d];if(h===u){a.push(h);continue}const g=r(h,u,Math.abs((i-h[e])/(u[e]-h[e])),n.stepped);g[e]=t[e],a.push(g)}return 1===a.length?a[0]:a}pathSegment(t,e,n){return xo(this)(t,this,e,n)}path(t,e,n){const i=this.segments,s=xo(this);let o=this._loop;e=e||0,n=n||this.points.length-e;for(const a of i)o&=s(t,this,a,{start:e,end:e+n-1});return!!o}draw(t,e,n,i){const s=this.options||{};(this.points||[]).length&&s.borderWidth&&(t.save(),wo(t,this,n,i),t.restore()),this.animated&&(this._pointsUpdated=!1,this._path=void 0)}}function So(t,e,n,i){const s=t.options,{[n]:o}=t.getProps([n],i);return Math.abs(e-o)<s.radius+s.hitRadius}function Mo(t,e){const{x:n,y:i,base:s,width:o,height:a}=t.getProps(["x","y","base","width","height"],e);let r,l,c,d,h;return t.horizontal?(h=a/2,r=Math.min(n,s),l=Math.max(n,s),c=i-h,d=i+h):(h=o/2,r=n-h,l=n+h,c=Math.min(i,s),d=Math.max(i,s)),{left:r,top:c,right:l,bottom:d}}function Co(t,e,n,i){return t?0:ae(e,n,i)}function _o(t){const e=Mo(t),n=e.right-e.left,i=e.bottom-e.top,s=function(t,e,n){const i=t.options.borderWidth,s=t.borderSkipped,o=on(i);return{t:Co(s.top,o.top,0,n),r:Co(s.right,o.right,0,e),b:Co(s.bottom,o.bottom,0,n),l:Co(s.left,o.left,0,e)}}(t,n/2,i/2),o=function(t,e,n){const{enableBorderRadius:i}=t.getProps(["enableBorderRadius"]),s=t.options.borderRadius,o=an(s),a=Math.min(e,n),r=t.borderSkipped,l=i||yt(s);return{topLeft:Co(!l||r.top||r.left,o.topLeft,0,a),topRight:Co(!l||r.top||r.right,o.topRight,0,a),bottomLeft:Co(!l||r.bottom||r.left,o.bottomLeft,0,a),bottomRight:Co(!l||r.bottom||r.right,o.bottomRight,0,a)}}(t,n/2,i/2);return{outer:{x:e.left,y:e.top,w:n,h:i,radius:o},inner:{x:e.left+s.l,y:e.top+s.t,w:n-s.l-s.r,h:i-s.t-s.b,radius:{topLeft:Math.max(0,o.topLeft-Math.max(s.t,s.l)),topRight:Math.max(0,o.topRight-Math.max(s.t,s.r)),bottomLeft:Math.max(0,o.bottomLeft-Math.max(s.b,s.l)),bottomRight:Math.max(0,o.bottomRight-Math.max(s.b,s.r))}}}}function To(t,e,n,i){const s=null===e,o=null===n,a=t&&!(s&&o)&&Mo(t,i);return a&&(s||re(e,a.left,a.right))&&(o||re(n,a.top,a.bottom))}function Do(t,e){t.rect(e.x,e.y,e.w,e.h)}function Po(t,e,n={}){const i=t.x!==n.x?-e:0,s=t.y!==n.y?-e:0,o=(t.x+t.w!==n.x+n.w?e:0)-i,a=(t.y+t.h!==n.y+n.h?e:0)-s;return{x:t.x+i,y:t.y+s,w:t.w+o,h:t.h+a,radius:t.radius}}class Eo extends ws{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:n,backgroundColor:i}}=this,{inner:s,outer:o}=_o(this),a=(r=o.radius).topLeft||r.topRight||r.bottomLeft||r.bottomRight?Je:Do;var r;t.save(),o.w===s.w&&o.h===s.h||(t.beginPath(),a(t,Po(o,e,s)),t.clip(),a(t,Po(s,-e,o)),t.fillStyle=n,t.fill("evenodd")),t.beginPath(),a(t,Po(s,e)),t.fillStyle=i,t.fill(),t.restore()}inRange(t,e,n){return To(this,t,e,n)}inXRange(t,e){return To(this,t,null,e)}inYRange(t,e){return To(this,null,t,e)}getCenterPoint(t){const{x:e,y:n,base:i,horizontal:s}=this.getProps(["x","y","base","horizontal"],t);return{x:s?(e+i)/2:e,y:s?n:(n+i)/2}}getRange(t){return"x"===t?this.width/2:this.height/2}}var Lo=Object.freeze({__proto__:null,ArcElement:class extends ws{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,selfJoin:!1};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,n){const i=this.getProps(["x","y"],n),{angle:s,distance:o}=ee(i,{x:t,y:e}),{startAngle:a,endAngle:r,innerRadius:l,outerRadius:c,circumference:d}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],n),h=(this.options.spacing+this.options.borderWidth)/2,u=wt(d,r-a),g=oe(s,a,r)&&a!==r,p=u>=Rt||g,m=re(o,l+h,c+h);return p&&m}getCenterPoint(t){const{x:e,y:n,startAngle:i,endAngle:s,innerRadius:o,outerRadius:a}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],t),{offset:r,spacing:l}=this.options,c=(i+s)/2,d=(o+a+l+r)/2;return{x:e+Math.cos(c)*d,y:n+Math.sin(c)*d}}tooltipPosition(t){return this.getCenterPoint(t)}draw(t){const{options:e,circumference:n}=this,i=(e.offset||0)/4,s=(e.spacing||0)/2,o=e.circular;if(this.pixelMargin="inner"===e.borderAlign?.33:0,this.fullCircles=n>Rt?Math.floor(n/Rt):0,0===n||this.innerRadius<0||this.outerRadius<0)return;t.save();const a=(this.startAngle+this.endAngle)/2;t.translate(Math.cos(a)*i,Math.sin(a)*i);const r=i*(1-Math.sin(Math.min($t,n||0)));t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,function(t,e,n,i,s){const{fullCircles:o,startAngle:a,circumference:r}=e;let l=e.endAngle;if(o){uo(t,e,n,i,l,s);for(let e=0;e<o;++e)t.fill();isNaN(r)||(l=a+(r%Rt||Rt))}uo(t,e,n,i,l,s),t.fill()}(t,this,r,s,o),go(t,this,r,s,o),t.restore()}},BarElement:Eo,LineElement:ko,PointElement:class extends ws{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,n){const i=this.options,{x:s,y:o}=this.getProps(["x","y"],n);return Math.pow(t-s,2)+Math.pow(e-o,2)<Math.pow(i.hitRadius+i.radius,2)}inXRange(t,e){return So(this,t,"x",e)}inYRange(t,e){return So(this,t,"y",e)}getCenterPoint(t){const{x:e,y:n}=this.getProps(["x","y"],t);return{x:e,y:n}}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 n=this.options;this.skip||n.radius<.1||!je(this,e,this.size(n)/2)||(t.strokeStyle=n.borderColor,t.lineWidth=n.borderWidth,t.fillStyle=n.backgroundColor,He(t,n,this.x,this.y))}getRange(){const t=this.options||{};return t.radius+t.hitRadius}}});const Ao=["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)"],Io=Ao.map((t=>t.replace("rgb(","rgba(").replace(")",", 0.5)")));function zo(t){return Ao[t%Ao.length]}function Oo(t){return Io[t%Io.length]}function Wo(t){let e=0;return(n,i)=>{const s=t.getDatasetMeta(i).controller;s instanceof Ai?e=function(t,e){return t.backgroundColor=t.data.map((()=>zo(e++))),e}(n,e):s instanceof Ii?e=function(t,e){return t.backgroundColor=t.data.map((()=>Oo(e++))),e}(n,e):s&&(e=function(t,e){return t.borderColor=zo(e),t.backgroundColor=Oo(e),++e}(n,e))}}function No(t){let e;for(e in t)if(t[e].borderColor||t[e].backgroundColor)return!0;return!1}var $o={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(t,e,n){if(!n.enabled)return;const{data:{datasets:i},options:s}=t.config,{elements:o}=s,a=No(i)||(r=s)&&(r.borderColor||r.backgroundColor)||o&&No(o)||"rgba(0,0,0,0.1)"!==$e.borderColor||"rgba(0,0,0,0.1)"!==$e.backgroundColor;var r;if(!n.forceOverride&&a)return;const l=Wo(t);i.forEach(l)}};function Ro(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 Fo(t){t.data.datasets.forEach((t=>{Ro(t)}))}var Bo={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(t,e,n)=>{if(!n.enabled)return void Fo(t);const i=t.width;t.data.datasets.forEach(((e,s)=>{const{_data:o,indexAxis:a}=e,r=t.getDatasetMeta(s),l=o||e.data;if("y"===cn([a,t.options.indexAxis]))return;if(!r.controller.supportsDecimation)return;const c=t.scales[r.xAxisID];if("linear"!==c.type&&"time"!==c.type)return;if(t.options.parsing)return;let{start:d,count:h}=function(t,e){const n=e.length;let i,s=0;const{iScale:o}=t,{min:a,max:r,minDefined:l,maxDefined:c}=o.getUserBounds();return l&&(s=ae(ce(e,o.axis,a).lo,0,n-1)),i=c?ae(ce(e,o.axis,r).hi+1,s,n)-s:n-s,{start:s,count:i}}(r,l);if(h<=(n.threshold||4*i))return void Ro(e);let u;switch(ft(o)&&(e._data=l,delete e.data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(t){this._data=t}})),n.algorithm){case"lttb":u=function(t,e,n,i,s){const o=s.samples||i;if(o>=n)return t.slice(e,e+n);const a=[],r=(n-2)/(o-2);let l=0;const c=e+n-1;let d,h,u,g,p,m=e;for(a[l++]=t[m],d=0;d<o-2;d++){let i,s=0,o=0;const c=Math.floor((d+1)*r)+1+e,f=Math.min(Math.floor((d+2)*r)+1,n)+e,b=f-c;for(i=c;i<f;i++)s+=t[i].x,o+=t[i].y;s/=b,o/=b;const y=Math.floor(d*r)+1+e,x=Math.min(Math.floor((d+1)*r)+1,n)+e,{x:v,y:w}=t[m];for(u=g=-1,i=y;i<x;i++)g=.5*Math.abs((v-s)*(t[i].y-w)-(v-t[i].x)*(o-w)),g>u&&(u=g,h=t[i],p=i);a[l++]=h,m=p}return a[l++]=t[c],a}(l,d,h,i,n);break;case"min-max":u=function(t,e,n,i){let s,o,a,r,l,c,d,h,u,g,p=0,m=0;const f=[],b=e+n-1,y=t[e].x,x=t[b].x-y;for(s=e;s<e+n;++s){o=t[s],a=(o.x-y)/x*i,r=o.y;const e=0|a;if(e===l)r<u?(u=r,c=s):r>g&&(g=r,d=s),p=(m*p+o.x)/++m;else{const n=s-1;if(!ft(c)&&!ft(d)){const e=Math.min(c,d),i=Math.max(c,d);e!==h&&e!==n&&f.push({...t[e],x:p}),i!==h&&i!==n&&f.push({...t[i],x:p})}s>0&&n!==h&&f.push(t[n]),f.push(o),l=e,m=0,u=g=r,c=d=h=s}}return f}(l,d,h,i);break;default:throw new Error(`Unsupported decimation algorithm '${n.algorithm}'`)}e._decimated=u}))},destroy(t){Fo(t)}};function qo(t,e,n,i){if(i)return;let s=e[t],o=n[t];return"angle"===t&&(s=se(s),o=se(o)),{property:t,start:s,end:o}}function Ho(t,e,n){for(;e>t;e--){const t=n[e];if(!isNaN(t.x)&&!isNaN(t.y))break}return e}function Vo(t,e,n,i){return t&&e?i(t[n],e[n]):t?t[n]:e?e[n]:0}function jo(t,e){let n=[],i=!1;return bt(t)?(i=!0,n=t):n=function(t,e){const{x:n=null,y:i=null}=t||{},s=e.points,o=[];return e.segments.forEach((({start:t,end:e})=>{e=Ho(t,e,s);const a=s[t],r=s[e];null!==i?(o.push({x:a.x,y:i}),o.push({x:r.x,y:i})):null!==n&&(o.push({x:n,y:a.y}),o.push({x:n,y:r.y}))})),o}(t,e),n.length?new ko({points:n,options:{tension:0},_loop:i,_fullLoop:i}):null}function Yo(t){return t&&!1!==t.fill}function Uo(t,e,n){let i=t[e].fill;const s=[e];let o;if(!n)return i;for(;!1!==i&&-1===s.indexOf(i);){if(!xt(i))return i;if(o=t[i],!o)return!1;if(o.visible)return i;s.push(i),i=o.fill}return!1}function Xo(t,e,n){const i=function(t){const e=t.options,n=e.fill;let i=wt(n&&n.target,n);void 0===i&&(i=!!e.backgroundColor);if(!1===i||null===i)return!1;if(!0===i)return"origin";return i}(t);if(yt(i))return!isNaN(i.value)&&i;let s=parseFloat(i);return xt(s)&&Math.floor(s)===s?function(t,e,n,i){"-"!==t&&"+"!==t||(n=e+n);if(n===e||n<0||n>=i)return!1;return n}(i[0],e,s,n):["origin","start","end","stack","shape"].indexOf(i)>=0&&i}function Qo(t,e,n){const i=[];for(let s=0;s<n.length;s++){const o=n[s],{first:a,last:r,point:l}=Go(o,e,"x");if(!(!l||a&&r))if(a)i.unshift(l);else if(t.push(l),!r)break}t.push(...i)}function Go(t,e,n){const i=t.interpolate(e,n);if(!i)return{};const s=i[n],o=t.segments,a=t.points;let r=!1,l=!1;for(let t=0;t<o.length;t++){const e=o[t],i=a[e.start][n],c=a[e.end][n];if(re(s,i,c)){r=s===i,l=s===c;break}}return{first:r,last:l,point:i}}class Ko{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,e,n){const{x:i,y:s,radius:o}=this;return e=e||{start:0,end:Rt},t.arc(i,s,o,e.end,e.start,!0),!n.bounds}interpolate(t){const{x:e,y:n,radius:i}=this,s=t.angle;return{x:e+Math.cos(s)*i,y:n+Math.sin(s)*i,angle:s}}}function Zo(t){const{chart:e,fill:n,line:i}=t;if(xt(n))return function(t,e){const n=t.getDatasetMeta(e),i=n&&t.isDatasetVisible(e);return i?n.dataset:null}(e,n);if("stack"===n)return function(t){const{scale:e,index:n,line:i}=t,s=[],o=i.segments,a=i.points,r=function(t,e){const n=[],i=t.getMatchingVisibleMetas("line");for(let t=0;t<i.length;t++){const s=i[t];if(s.index===e)break;s.hidden||n.unshift(s.dataset)}return n}(e,n);r.push(jo({x:null,y:e.bottom},i));for(let t=0;t<o.length;t++){const e=o[t];for(let t=e.start;t<=e.end;t++)Qo(s,a[t],r)}return new ko({points:s,options:{}})}(t);if("shape"===n)return!0;const s=function(t){const e=t.scale||{};if(e.getPointPositionForValue)return function(t){const{scale:e,fill:n}=t,i=e.options,s=e.getLabels().length,o=i.reverse?e.max:e.min,a=function(t,e,n){let i;return i="start"===t?n:"end"===t?e.options.reverse?e.min:e.max:yt(t)?t.value:e.getBaseValue(),i}(n,e,o),r=[];if(i.grid.circular){const t=e.getPointPositionForValue(0,o);return new Ko({x:t.x,y:t.y,radius:e.getDistanceFromCenterForValue(a)})}for(let t=0;t<s;++t)r.push(e.getPointPositionForValue(t,a));return r}(t);return function(t){const{scale:e={},fill:n}=t,i=function(t,e){let n=null;return"start"===t?n=e.bottom:"end"===t?n=e.top:yt(t)?n=e.getPixelForValue(t.value):e.getBasePixel&&(n=e.getBasePixel()),n}(n,e);if(xt(i)){const t=e.isHorizontal();return{x:t?i:null,y:t?null:i}}return null}(t)}(t);return s instanceof Ko?s:jo(s,i)}function Jo(t,e,n){const i=Zo(e),{chart:s,index:o,line:a,scale:r,axis:l}=e,c=a.options,d=c.fill,h=c.backgroundColor,{above:u=h,below:g=h}=d||{},p=s.getDatasetMeta(o),m=si(s,p);i&&a.points.length&&(Ye(t,n),function(t,e){const{line:n,target:i,above:s,below:o,area:a,scale:r,clip:l}=e,c=n._loop?"angle":e.axis;t.save();let d=o;o!==s&&("x"===c?(ta(t,i,a.top),na(t,{line:n,target:i,color:s,scale:r,property:c,clip:l}),t.restore(),t.save(),ta(t,i,a.bottom)):"y"===c&&(ea(t,i,a.left),na(t,{line:n,target:i,color:o,scale:r,property:c,clip:l}),t.restore(),t.save(),ea(t,i,a.right),d=s));na(t,{line:n,target:i,color:d,scale:r,property:c,clip:l}),t.restore()}(t,{line:a,target:i,above:u,below:g,area:n,scale:r,axis:l,clip:m}),Ue(t))}function ta(t,e,n){const{segments:i,points:s}=e;let o=!0,a=!1;t.beginPath();for(const r of i){const{start:i,end:l}=r,c=s[i],d=s[Ho(i,l,s)];o?(t.moveTo(c.x,c.y),o=!1):(t.lineTo(c.x,n),t.lineTo(c.x,c.y)),a=!!e.pathSegment(t,r,{move:a}),a?t.closePath():t.lineTo(d.x,n)}t.lineTo(e.first().x,n),t.closePath(),t.clip()}function ea(t,e,n){const{segments:i,points:s}=e;let o=!0,a=!1;t.beginPath();for(const r of i){const{start:i,end:l}=r,c=s[i],d=s[Ho(i,l,s)];o?(t.moveTo(c.x,c.y),o=!1):(t.lineTo(n,c.y),t.lineTo(c.x,c.y)),a=!!e.pathSegment(t,r,{move:a}),a?t.closePath():t.lineTo(n,d.y)}t.lineTo(n,e.first().y),t.closePath(),t.clip()}function na(t,e){const{line:n,target:i,property:s,color:o,scale:a,clip:r}=e,l=function(t,e,n){const i=t.segments,s=t.points,o=e.points,a=[];for(const t of i){let{start:i,end:r}=t;r=Ho(i,r,s);const l=qo(n,s[i],s[r],t.loop);if(!e.segments){a.push({source:t,target:l,start:s[i],end:s[r]});continue}const c=Jn(e,l);for(const e of c){const i=qo(n,o[e.start],o[e.end],e.loop),r=Zn(t,s,i);for(const t of r)a.push({source:t,target:e,start:{[n]:Vo(l,i,"start",Math.max)},end:{[n]:Vo(l,i,"end",Math.min)}})}}return a}(n,i,s);for(const{source:e,target:c,start:d,end:h}of l){const{style:{backgroundColor:l=o}={}}=e,u=!0!==i;t.save(),t.fillStyle=l,ia(t,a,r,u&&qo(s,d,h)),t.beginPath();const g=!!n.pathSegment(t,e);let p;if(u){g?t.closePath():sa(t,i,h,s);const e=!!i.pathSegment(t,c,{move:g,reverse:!0});p=g&&e,p||sa(t,i,d,s)}t.closePath(),t.fill(p?"evenodd":"nonzero"),t.restore()}}function ia(t,e,n,i){const s=e.chart.chartArea,{property:o,start:a,end:r}=i||{};if("x"===o||"y"===o){let e,i,l,c;"x"===o?(e=a,i=s.top,l=r,c=s.bottom):(e=s.left,i=a,l=s.right,c=r),t.beginPath(),n&&(e=Math.max(e,n.left),l=Math.min(l,n.right),i=Math.max(i,n.top),c=Math.min(c,n.bottom)),t.rect(e,i,l-e,c-i),t.clip()}}function sa(t,e,n,i){const s=e.interpolate(n,i);s&&t.lineTo(s.x,s.y)}var oa={id:"filler",afterDatasetsUpdate(t,e,n){const i=(t.data.datasets||[]).length,s=[];let o,a,r,l;for(a=0;a<i;++a)o=t.getDatasetMeta(a),r=o.dataset,l=null,r&&r.options&&r instanceof ko&&(l={visible:t.isDatasetVisible(a),index:a,fill:Xo(r,a,i),chart:t,axis:o.controller.options.indexAxis,scale:o.vScale,line:r}),o.$filler=l,s.push(l);for(a=0;a<i;++a)l=s[a],l&&!1!==l.fill&&(l.fill=Uo(s,a,n.propagate))},beforeDraw(t,e,n){const i="beforeDraw"===n.drawTime,s=t.getSortedVisibleDatasetMetas(),o=t.chartArea;for(let e=s.length-1;e>=0;--e){const n=s[e].$filler;n&&(n.line.updateControlPoints(o,n.axis),i&&n.fill&&Jo(t.ctx,n,o))}},beforeDatasetsDraw(t,e,n){if("beforeDatasetsDraw"!==n.drawTime)return;const i=t.getSortedVisibleDatasetMetas();for(let e=i.length-1;e>=0;--e){const n=i[e].$filler;Yo(n)&&Jo(t.ctx,n,t.chartArea)}},beforeDatasetDraw(t,e,n){const i=e.meta.$filler;Yo(i)&&"beforeDatasetDraw"===n.drawTime&&Jo(t.ctx,i,t.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const aa=(t,e)=>{let{boxHeight:n=e,boxWidth:i=e}=t;return t.usePointStyle&&(n=Math.min(n,e),i=t.pointStyleWidth||Math.min(i,e)),{boxWidth:i,boxHeight:n,itemHeight:Math.max(e,n)}};class ra extends ws{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,n){this.maxWidth=t,this.maxHeight=e,this._margins=n,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=St(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter((e=>t.filter(e,this.chart.data)))),t.sort&&(e=e.sort(((e,n)=>t.sort(e,n,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 n=t.labels,i=ln(n.font),s=i.size,o=this._computeTitleHeight(),{boxWidth:a,itemHeight:r}=aa(n,s);let l,c;e.font=i.string,this.isHorizontal()?(l=this.maxWidth,c=this._fitRows(o,s,a,r)+10):(c=this.maxHeight,l=this._fitCols(o,i,a,r)+10),this.width=Math.min(l,t.maxWidth||this.maxWidth),this.height=Math.min(c,t.maxHeight||this.maxHeight)}_fitRows(t,e,n,i){const{ctx:s,maxWidth:o,options:{labels:{padding:a}}}=this,r=this.legendHitBoxes=[],l=this.lineWidths=[0],c=i+a;let d=t;s.textAlign="left",s.textBaseline="middle";let h=-1,u=-c;return this.legendItems.forEach(((t,g)=>{const p=n+e/2+s.measureText(t.text).width;(0===g||l[l.length-1]+p+2*a>o)&&(d+=c,l[l.length-(g>0?0:1)]=0,u+=c,h++),r[g]={left:0,top:u,row:h,width:p,height:i},l[l.length-1]+=p+a})),d}_fitCols(t,e,n,i){const{ctx:s,maxHeight:o,options:{labels:{padding:a}}}=this,r=this.legendHitBoxes=[],l=this.columnSizes=[],c=o-t;let d=a,h=0,u=0,g=0,p=0;return this.legendItems.forEach(((t,o)=>{const{itemWidth:m,itemHeight:f}=function(t,e,n,i,s){const o=function(t,e,n,i){let s=t.text;s&&"string"!=typeof s&&(s=s.reduce(((t,e)=>t.length>e.length?t:e)));return e+n.size/2+i.measureText(s).width}(i,t,e,n),a=function(t,e,n){let i=t;"string"!=typeof e.text&&(i=la(e,n));return i}(s,i,e.lineHeight);return{itemWidth:o,itemHeight:a}}(n,e,s,t,i);o>0&&u+f+2*a>c&&(d+=h+a,l.push({width:h,height:u}),g+=h+a,p++,h=u=0),r[o]={left:g,top:u,col:p,width:m,height:f},h=Math.max(h,m),u+=f+a})),d+=h,l.push({width:h,height:u}),d}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:n,labels:{padding:i},rtl:s}}=this,o=Un(s,this.left,this.width);if(this.isHorizontal()){let s=0,a=be(n,this.left+i,this.right-this.lineWidths[s]);for(const r of e)s!==r.row&&(s=r.row,a=be(n,this.left+i,this.right-this.lineWidths[s])),r.top+=this.top+t+i,r.left=o.leftForLtr(o.x(a),r.width),a+=r.width+i}else{let s=0,a=be(n,this.top+t+i,this.bottom-this.columnSizes[s].height);for(const r of e)r.col!==s&&(s=r.col,a=be(n,this.top+t+i,this.bottom-this.columnSizes[s].height)),r.top=a,r.left+=this.left+i,r.left=o.leftForLtr(o.x(r.left),r.width),a+=r.height+i}}isHorizontal(){return"top"===this.options.position||"bottom"===this.options.position}draw(){if(this.options.display){const t=this.ctx;Ye(t,this),this._draw(),Ue(t)}}_draw(){const{options:t,columnSizes:e,lineWidths:n,ctx:i}=this,{align:s,labels:o}=t,a=$e.color,r=Un(t.rtl,this.left,this.width),l=ln(o.font),{padding:c}=o,d=l.size,h=d/2;let u;this.drawTitle(),i.textAlign=r.textAlign("left"),i.textBaseline="middle",i.lineWidth=.5,i.font=l.string;const{boxWidth:g,boxHeight:p,itemHeight:m}=aa(o,d),f=this.isHorizontal(),b=this._computeTitleHeight();u=f?{x:be(s,this.left+c,this.right-n[0]),y:this.top+c+b,line:0}:{x:this.left+c,y:be(s,this.top+b+c,this.bottom-e[0].height),line:0},Xn(this.ctx,t.textDirection);const y=m+c;this.legendItems.forEach(((x,v)=>{i.strokeStyle=x.fontColor,i.fillStyle=x.fontColor;const w=i.measureText(x.text).width,k=r.textAlign(x.textAlign||(x.textAlign=o.textAlign)),S=g+h+w;let M=u.x,C=u.y;r.setWidth(this.width),f?v>0&&M+S+c>this.right&&(C=u.y+=y,u.line++,M=u.x=be(s,this.left+c,this.right-n[u.line])):v>0&&C+y>this.bottom&&(M=u.x=M+e[u.line].width+c,u.line++,C=u.y=be(s,this.top+b+c,this.bottom-e[u.line].height));if(function(t,e,n){if(isNaN(g)||g<=0||isNaN(p)||p<0)return;i.save();const s=wt(n.lineWidth,1);if(i.fillStyle=wt(n.fillStyle,a),i.lineCap=wt(n.lineCap,"butt"),i.lineDashOffset=wt(n.lineDashOffset,0),i.lineJoin=wt(n.lineJoin,"miter"),i.lineWidth=s,i.strokeStyle=wt(n.strokeStyle,a),i.setLineDash(wt(n.lineDash,[])),o.usePointStyle){const a={radius:p*Math.SQRT2/2,pointStyle:n.pointStyle,rotation:n.rotation,borderWidth:s},l=r.xPlus(t,g/2);Ve(i,a,l,e+h,o.pointStyleWidth&&g)}else{const o=e+Math.max((d-p)/2,0),a=r.leftForLtr(t,g),l=an(n.borderRadius);i.beginPath(),Object.values(l).some((t=>0!==t))?Je(i,{x:a,y:o,w:g,h:p,radius:l}):i.rect(a,o,g,p),i.fill(),0!==s&&i.stroke()}i.restore()}(r.x(M),C,x),M=((t,e,n,i)=>t===(i?"left":"right")?n:"center"===t?(e+n)/2:e)(k,M+g+h,f?M+S:this.right,t.rtl),function(t,e,n){Ze(i,n.text,t,e+m/2,l,{strikethrough:n.hidden,textAlign:r.textAlign(n.textAlign)})}(r.x(M),C,x),f)u.x+=S+c;else if("string"!=typeof x.text){const t=l.lineHeight;u.y+=la(x,t)+c}else u.y+=y})),Qn(this.ctx,t.textDirection)}drawTitle(){const t=this.options,e=t.title,n=ln(e.font),i=rn(e.padding);if(!e.display)return;const s=Un(t.rtl,this.left,this.width),o=this.ctx,a=e.position,r=n.size/2,l=i.top+r;let c,d=this.left,h=this.width;if(this.isHorizontal())h=Math.max(...this.lineWidths),c=this.top+l,d=be(t.align,d,this.right-h);else{const e=this.columnSizes.reduce(((t,e)=>Math.max(t,e.height)),0);c=l+be(t.align,this.top,this.bottom-e-t.labels.padding-this._computeTitleHeight())}const u=be(a,d,d+h);o.textAlign=s.textAlign(fe(a)),o.textBaseline="middle",o.strokeStyle=e.color,o.fillStyle=e.color,o.font=n.string,Ze(o,e.text,u,c,n)}_computeTitleHeight(){const t=this.options.title,e=ln(t.font),n=rn(t.padding);return t.display?e.lineHeight+n.height:0}_getLegendItemAt(t,e){let n,i,s;if(re(t,this.left,this.right)&&re(e,this.top,this.bottom))for(s=this.legendHitBoxes,n=0;n<s.length;++n)if(i=s[n],re(t,i.left,i.left+i.width)&&re(e,i.top,i.top+i.height))return this.legendItems[n];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 n=this._getLegendItemAt(t.x,t.y);if("mousemove"===t.type||"mouseout"===t.type){const o=this._hoveredItem,a=(s=n,null!==(i=o)&&null!==s&&i.datasetIndex===s.datasetIndex&&i.index===s.index);o&&!a&&St(e.onLeave,[t,o,this],this),this._hoveredItem=n,n&&!a&&St(e.onHover,[t,n,this],this)}else n&&St(e.onClick,[t,n,this],this);var i,s}}function la(t,e){return e*(t.text?t.text.length:0)}var ca={id:"legend",_element:ra,start(t,e,n){const i=t.legend=new ra({ctx:t.ctx,options:n,chart:t});is.configure(t,i,n),is.addBox(t,i)},stop(t){is.removeBox(t,t.legend),delete t.legend},beforeUpdate(t,e,n){const i=t.legend;is.configure(t,i,n),i.options=n},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,n){const i=e.datasetIndex,s=n.chart;s.isDatasetVisible(i)?(s.hide(i),e.hidden=!0):(s.show(i),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:n,pointStyle:i,textAlign:s,color:o,useBorderRadius:a,borderRadius:r}}=t.legend.options;return t._getSortedDatasetMetas().map((t=>{const l=t.controller.getStyle(n?0:void 0),c=rn(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:(c.width+c.height)/4,strokeStyle:l.borderColor,pointStyle:i||l.pointStyle,rotation:l.rotation,textAlign:s||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 da extends ws{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 n=this.options;if(this.left=0,this.top=0,!n.display)return void(this.width=this.height=this.right=this.bottom=0);this.width=this.right=t,this.height=this.bottom=e;const i=bt(n.text)?n.text.length:1;this._padding=rn(n.padding);const s=i*ln(n.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=s:this.width=s}isHorizontal(){const t=this.options.position;return"top"===t||"bottom"===t}_drawArgs(t){const{top:e,left:n,bottom:i,right:s,options:o}=this,a=o.align;let r,l,c,d=0;return this.isHorizontal()?(l=be(a,n,s),c=e+t,r=s-n):("left"===o.position?(l=n+t,c=be(a,i,e),d=-.5*$t):(l=s-t,c=be(a,e,i),d=.5*$t),r=i-e),{titleX:l,titleY:c,maxWidth:r,rotation:d}}draw(){const t=this.ctx,e=this.options;if(!e.display)return;const n=ln(e.font),i=n.lineHeight/2+this._padding.top,{titleX:s,titleY:o,maxWidth:a,rotation:r}=this._drawArgs(i);Ze(t,e.text,0,0,n,{color:e.color,maxWidth:a,rotation:r,textAlign:fe(e.align),textBaseline:"middle",translation:[s,o]})}}var ha={id:"title",_element:da,start(t,e,n){!function(t,e){const n=new da({ctx:t.ctx,options:e,chart:t});is.configure(t,n,e),is.addBox(t,n),t.titleBlock=n}(t,n)},stop(t){const e=t.titleBlock;is.removeBox(t,e),delete t.titleBlock},beforeUpdate(t,e,n){const i=t.titleBlock;is.configure(t,i,n),i.options=n},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 ua=new WeakMap;var ga={id:"subtitle",start(t,e,n){const i=new da({ctx:t.ctx,options:n,chart:t});is.configure(t,i,n),is.addBox(t,i),ua.set(t,i)},stop(t){is.removeBox(t,ua.get(t)),ua.delete(t)},beforeUpdate(t,e,n){const i=ua.get(t);is.configure(t,i,n),i.options=n},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 pa={average(t){if(!t.length)return!1;let e,n,i=new Set,s=0,o=0;for(e=0,n=t.length;e<n;++e){const n=t[e].element;if(n&&n.hasValue()){const t=n.tooltipPosition();i.add(t.x),s+=t.y,++o}}if(0===o||0===i.size)return!1;return{x:[...i].reduce(((t,e)=>t+e))/i.size,y:s/o}},nearest(t,e){if(!t.length)return!1;let n,i,s,o=e.x,a=e.y,r=Number.POSITIVE_INFINITY;for(n=0,i=t.length;n<i;++n){const i=t[n].element;if(i&&i.hasValue()){const t=ne(e,i.getCenterPoint());t<r&&(r=t,s=i)}}if(s){const t=s.tooltipPosition();o=t.x,a=t.y}return{x:o,y:a}}};function ma(t,e){return e&&(bt(e)?Array.prototype.push.apply(t,e):t.push(e)),t}function fa(t){return("string"==typeof t||t instanceof String)&&t.indexOf("\n")>-1?t.split("\n"):t}function ba(t,e){const{element:n,datasetIndex:i,index:s}=e,o=t.getDatasetMeta(i).controller,{label:a,value:r}=o.getLabelAndValue(s);return{chart:t,label:a,parsed:o.getParsed(s),raw:t.data.datasets[i].data[s],formattedValue:r,dataset:o.getDataset(),dataIndex:s,datasetIndex:i,element:n}}function ya(t,e){const n=t.chart.ctx,{body:i,footer:s,title:o}=t,{boxWidth:a,boxHeight:r}=e,l=ln(e.bodyFont),c=ln(e.titleFont),d=ln(e.footerFont),h=o.length,u=s.length,g=i.length,p=rn(e.padding);let m=p.height,f=0,b=i.reduce(((t,e)=>t+e.before.length+e.lines.length+e.after.length),0);if(b+=t.beforeBody.length+t.afterBody.length,h&&(m+=h*c.lineHeight+(h-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}u&&(m+=e.footerMarginTop+u*d.lineHeight+(u-1)*e.footerSpacing);let y=0;const x=function(t){f=Math.max(f,n.measureText(t).width+y)};return n.save(),n.font=c.string,Mt(t.title,x),n.font=l.string,Mt(t.beforeBody.concat(t.afterBody),x),y=e.displayColors?a+2+e.boxPadding:0,Mt(i,(t=>{Mt(t.before,x),Mt(t.lines,x),Mt(t.after,x)})),y=0,n.font=d.string,Mt(t.footer,x),n.restore(),f+=p.width,{width:f,height:m}}function xa(t,e,n,i){const{x:s,width:o}=n,{width:a,chartArea:{left:r,right:l}}=t;let c="center";return"center"===i?c=s<=(r+l)/2?"left":"right":s<=o/2?c="left":s>=a-o/2&&(c="right"),function(t,e,n,i){const{x:s,width:o}=i,a=n.caretSize+n.caretPadding;return"left"===t&&s+o+a>e.width||"right"===t&&s-o-a<0||void 0}(c,t,e,n)&&(c="center"),c}function va(t,e,n){const i=n.yAlign||e.yAlign||function(t,e){const{y:n,height:i}=e;return n<i/2?"top":n>t.height-i/2?"bottom":"center"}(t,n);return{xAlign:n.xAlign||e.xAlign||xa(t,e,n,i),yAlign:i}}function wa(t,e,n,i){const{caretSize:s,caretPadding:o,cornerRadius:a}=t,{xAlign:r,yAlign:l}=n,c=s+o,{topLeft:d,topRight:h,bottomLeft:u,bottomRight:g}=an(a);let p=function(t,e){let{x:n,width:i}=t;return"right"===e?n-=i:"center"===e&&(n-=i/2),n}(e,r);const m=function(t,e,n){let{y:i,height:s}=t;return"top"===e?i+=n:i-="bottom"===e?s+n:s/2,i}(e,l,c);return"center"===l?"left"===r?p+=c:"right"===r&&(p-=c):"left"===r?p-=Math.max(d,u)+s:"right"===r&&(p+=Math.max(h,g)+s),{x:ae(p,0,i.width-e.width),y:ae(m,0,i.height-e.height)}}function ka(t,e,n){const i=rn(n.padding);return"center"===e?t.x+t.width/2:"right"===e?t.x+t.width-i.right:t.x+i.left}function Sa(t){return ma([],fa(t))}function Ma(t,e){const n=e&&e.dataset&&e.dataset.tooltip&&e.dataset.tooltip.callbacks;return n?t.override(n):t}const Ca={beforeTitle:pt,title(t){if(t.length>0){const e=t[0],n=e.chart.data.labels,i=n?n.length:0;if(this&&this.options&&"dataset"===this.options.mode)return e.dataset.label||"";if(e.label)return e.label;if(i>0&&e.dataIndex<i)return n[e.dataIndex]}return""},afterTitle:pt,beforeBody:pt,beforeLabel:pt,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 n=t.formattedValue;return ft(n)||(e+=n),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:pt,afterBody:pt,beforeFooter:pt,footer:pt,afterFooter:pt};function _a(t,e,n,i){const s=t[e].call(n,i);return void 0===s?Ca[e].call(n,i):s}class Ta extends ws{static positioners=pa;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,n=this.options.setContext(this.getContext()),i=n.enabled&&e.options.animation&&n.animations,s=new di(this.chart,i);return i._cacheable&&(this._cachedAnimations=Object.freeze(s)),s}getContext(){return this.$context||(this.$context=(t=this.chart.getContext(),e=this,n=this._tooltipItems,dn(t,{tooltip:e,tooltipItems:n,type:"tooltip"})));var t,e,n}getTitle(t,e){const{callbacks:n}=e,i=_a(n,"beforeTitle",this,t),s=_a(n,"title",this,t),o=_a(n,"afterTitle",this,t);let a=[];return a=ma(a,fa(i)),a=ma(a,fa(s)),a=ma(a,fa(o)),a}getBeforeBody(t,e){return Sa(_a(e.callbacks,"beforeBody",this,t))}getBody(t,e){const{callbacks:n}=e,i=[];return Mt(t,(t=>{const e={before:[],lines:[],after:[]},s=Ma(n,t);ma(e.before,fa(_a(s,"beforeLabel",this,t))),ma(e.lines,_a(s,"label",this,t)),ma(e.after,fa(_a(s,"afterLabel",this,t))),i.push(e)})),i}getAfterBody(t,e){return Sa(_a(e.callbacks,"afterBody",this,t))}getFooter(t,e){const{callbacks:n}=e,i=_a(n,"beforeFooter",this,t),s=_a(n,"footer",this,t),o=_a(n,"afterFooter",this,t);let a=[];return a=ma(a,fa(i)),a=ma(a,fa(s)),a=ma(a,fa(o)),a}_createItems(t){const e=this._active,n=this.chart.data,i=[],s=[],o=[];let a,r,l=[];for(a=0,r=e.length;a<r;++a)l.push(ba(this.chart,e[a]));return t.filter&&(l=l.filter(((e,i,s)=>t.filter(e,i,s,n)))),t.itemSort&&(l=l.sort(((e,i)=>t.itemSort(e,i,n)))),Mt(l,(e=>{const n=Ma(t.callbacks,e);i.push(_a(n,"labelColor",this,e)),s.push(_a(n,"labelPointStyle",this,e)),o.push(_a(n,"labelTextColor",this,e))})),this.labelColors=i,this.labelPointStyles=s,this.labelTextColors=o,this.dataPoints=l,l}update(t,e){const n=this.options.setContext(this.getContext()),i=this._active;let s,o=[];if(i.length){const t=pa[n.position].call(this,i,this._eventPosition);o=this._createItems(n),this.title=this.getTitle(o,n),this.beforeBody=this.getBeforeBody(o,n),this.body=this.getBody(o,n),this.afterBody=this.getAfterBody(o,n),this.footer=this.getFooter(o,n);const e=this._size=ya(this,n),a=Object.assign({},t,e),r=va(this.chart,n,a),l=wa(n,a,r,this.chart);this.xAlign=r.xAlign,this.yAlign=r.yAlign,s={opacity:1,x:l.x,y:l.y,width:e.width,height:e.height,caretX:t.x,caretY:t.y}}else 0!==this.opacity&&(s={opacity:0});this._tooltipItems=o,this.$context=void 0,s&&this._resolveAnimations().update(this,s),t&&n.external&&n.external.call(this,{chart:this.chart,tooltip:this,replay:e})}drawCaret(t,e,n,i){const s=this.getCaretPosition(t,n,i);e.lineTo(s.x1,s.y1),e.lineTo(s.x2,s.y2),e.lineTo(s.x3,s.y3)}getCaretPosition(t,e,n){const{xAlign:i,yAlign:s}=this,{caretSize:o,cornerRadius:a}=n,{topLeft:r,topRight:l,bottomLeft:c,bottomRight:d}=an(a),{x:h,y:u}=t,{width:g,height:p}=e;let m,f,b,y,x,v;return"center"===s?(x=u+p/2,"left"===i?(m=h,f=m-o,y=x+o,v=x-o):(m=h+g,f=m+o,y=x-o,v=x+o),b=m):(f="left"===i?h+Math.max(r,c)+o:"right"===i?h+g-Math.max(l,d)-o:this.caretX,"top"===s?(y=u,x=y-o,m=f-o,b=f+o):(y=u+p,x=y+o,m=f+o,b=f-o),v=y),{x1:m,x2:f,x3:b,y1:y,y2:x,y3:v}}drawTitle(t,e,n){const i=this.title,s=i.length;let o,a,r;if(s){const l=Un(n.rtl,this.x,this.width);for(t.x=ka(this,n.titleAlign,n),e.textAlign=l.textAlign(n.titleAlign),e.textBaseline="middle",o=ln(n.titleFont),a=n.titleSpacing,e.fillStyle=n.titleColor,e.font=o.string,r=0;r<s;++r)e.fillText(i[r],l.x(t.x),t.y+o.lineHeight/2),t.y+=o.lineHeight+a,r+1===s&&(t.y+=n.titleMarginBottom-a)}}_drawColorBox(t,e,n,i,s){const o=this.labelColors[n],a=this.labelPointStyles[n],{boxHeight:r,boxWidth:l}=s,c=ln(s.bodyFont),d=ka(this,"left",s),h=i.x(d),u=r<c.lineHeight?(c.lineHeight-r)/2:0,g=e.y+u;if(s.usePointStyle){const e={radius:Math.min(l,r)/2,pointStyle:a.pointStyle,rotation:a.rotation,borderWidth:1},n=i.leftForLtr(h,l)+l/2,c=g+r/2;t.strokeStyle=s.multiKeyBackground,t.fillStyle=s.multiKeyBackground,He(t,e,n,c),t.strokeStyle=o.borderColor,t.fillStyle=o.backgroundColor,He(t,e,n,c)}else{t.lineWidth=yt(o.borderWidth)?Math.max(...Object.values(o.borderWidth)):o.borderWidth||1,t.strokeStyle=o.borderColor,t.setLineDash(o.borderDash||[]),t.lineDashOffset=o.borderDashOffset||0;const e=i.leftForLtr(h,l),n=i.leftForLtr(i.xPlus(h,1),l-2),a=an(o.borderRadius);Object.values(a).some((t=>0!==t))?(t.beginPath(),t.fillStyle=s.multiKeyBackground,Je(t,{x:e,y:g,w:l,h:r,radius:a}),t.fill(),t.stroke(),t.fillStyle=o.backgroundColor,t.beginPath(),Je(t,{x:n,y:g+1,w:l-2,h:r-2,radius:a}),t.fill()):(t.fillStyle=s.multiKeyBackground,t.fillRect(e,g,l,r),t.strokeRect(e,g,l,r),t.fillStyle=o.backgroundColor,t.fillRect(n,g+1,l-2,r-2))}t.fillStyle=this.labelTextColors[n]}drawBody(t,e,n){const{body:i}=this,{bodySpacing:s,bodyAlign:o,displayColors:a,boxHeight:r,boxWidth:l,boxPadding:c}=n,d=ln(n.bodyFont);let h=d.lineHeight,u=0;const g=Un(n.rtl,this.x,this.width),p=function(n){e.fillText(n,g.x(t.x+u),t.y+h/2),t.y+=h+s},m=g.textAlign(o);let f,b,y,x,v,w,k;for(e.textAlign=o,e.textBaseline="middle",e.font=d.string,t.x=ka(this,m,n),e.fillStyle=n.bodyColor,Mt(this.beforeBody,p),u=a&&"right"!==m?"center"===o?l/2+c:l+2+c:0,x=0,w=i.length;x<w;++x){for(f=i[x],b=this.labelTextColors[x],e.fillStyle=b,Mt(f.before,p),y=f.lines,a&&y.length&&(this._drawColorBox(e,t,x,g,n),h=Math.max(d.lineHeight,r)),v=0,k=y.length;v<k;++v)p(y[v]),h=d.lineHeight;Mt(f.after,p)}u=0,h=d.lineHeight,Mt(this.afterBody,p),t.y-=s}drawFooter(t,e,n){const i=this.footer,s=i.length;let o,a;if(s){const r=Un(n.rtl,this.x,this.width);for(t.x=ka(this,n.footerAlign,n),t.y+=n.footerMarginTop,e.textAlign=r.textAlign(n.footerAlign),e.textBaseline="middle",o=ln(n.footerFont),e.fillStyle=n.footerColor,e.font=o.string,a=0;a<s;++a)e.fillText(i[a],r.x(t.x),t.y+o.lineHeight/2),t.y+=o.lineHeight+n.footerSpacing}}drawBackground(t,e,n,i){const{xAlign:s,yAlign:o}=this,{x:a,y:r}=t,{width:l,height:c}=n,{topLeft:d,topRight:h,bottomLeft:u,bottomRight:g}=an(i.cornerRadius);e.fillStyle=i.backgroundColor,e.strokeStyle=i.borderColor,e.lineWidth=i.borderWidth,e.beginPath(),e.moveTo(a+d,r),"top"===o&&this.drawCaret(t,e,n,i),e.lineTo(a+l-h,r),e.quadraticCurveTo(a+l,r,a+l,r+h),"center"===o&&"right"===s&&this.drawCaret(t,e,n,i),e.lineTo(a+l,r+c-g),e.quadraticCurveTo(a+l,r+c,a+l-g,r+c),"bottom"===o&&this.drawCaret(t,e,n,i),e.lineTo(a+u,r+c),e.quadraticCurveTo(a,r+c,a,r+c-u),"center"===o&&"left"===s&&this.drawCaret(t,e,n,i),e.lineTo(a,r+d),e.quadraticCurveTo(a,r,a+d,r),e.closePath(),e.fill(),i.borderWidth>0&&e.stroke()}_updateAnimationTarget(t){const e=this.chart,n=this.$animations,i=n&&n.x,s=n&&n.y;if(i||s){const n=pa[t.position].call(this,this._active,this._eventPosition);if(!n)return;const o=this._size=ya(this,t),a=Object.assign({},n,this._size),r=va(e,t,a),l=wa(t,a,r,e);i._to===l.x&&s._to===l.y||(this.xAlign=r.xAlign,this.yAlign=r.yAlign,this.width=o.width,this.height=o.height,this.caretX=n.x,this.caretY=n.y,this._resolveAnimations().update(this,l))}}_willRender(){return!!this.opacity}draw(t){const e=this.options.setContext(this.getContext());let n=this.opacity;if(!n)return;this._updateAnimationTarget(e);const i={width:this.width,height:this.height},s={x:this.x,y:this.y};n=Math.abs(n)<.001?0:n;const o=rn(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=n,this.drawBackground(s,t,i,e),Xn(t,e.textDirection),s.y+=o.top,this.drawTitle(s,t,e),this.drawBody(s,t,e),this.drawFooter(s,t,e),Qn(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const n=this._active,i=t.map((({datasetIndex:t,index:e})=>{const n=this.chart.getDatasetMeta(t);if(!n)throw new Error("Cannot find a dataset at index "+t);return{datasetIndex:t,element:n.data[e],index:e}})),s=!Ct(n,i),o=this._positionChanged(i,e);(s||o)&&(this._active=i,this._eventPosition=e,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,e,n=!0){if(e&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const i=this.options,s=this._active||[],o=this._getActiveElements(t,s,e,n),a=this._positionChanged(o,t),r=e||!Ct(o,s)||a;return r&&(this._active=o,(i.enabled||i.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),r}_getActiveElements(t,e,n,i){const s=this.options;if("mouseout"===t.type)return[];if(!i)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,s.mode,s,n);return s.reverse&&o.reverse(),o}_positionChanged(t,e){const{caretX:n,caretY:i,options:s}=this,o=pa[s.position].call(this,t,e);return!1!==o&&(n!==o.x||i!==o.y)}}var Da={id:"tooltip",_element:Ta,positioners:pa,afterInit(t,e,n){n&&(t.tooltip=new Ta({chart:t,options:n}))},beforeUpdate(t,e,n){t.tooltip&&t.tooltip.initialize(n)},reset(t,e,n){t.tooltip&&t.tooltip.initialize(n)},afterDraw(t){const e=t.tooltip;if(e&&e._willRender()){const n={tooltip:e};if(!1===t.notifyPlugins("beforeTooltipDraw",{...n,cancelable:!0}))return;e.draw(t.ctx),t.notifyPlugins("afterTooltipDraw",n)}},afterEvent(t,e){if(t.tooltip){const n=e.replay;t.tooltip.handleEvent(e.event,n,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:Ca},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"]},Pa=Object.freeze({__proto__:null,Colors:$o,Decimation:Bo,Filler:oa,Legend:ca,SubTitle:ga,Title:ha,Tooltip:Da});function Ea(t,e,n,i){const s=t.indexOf(e);if(-1===s)return((t,e,n,i)=>("string"==typeof e?(n=t.push(e)-1,i.unshift({index:n,label:e})):isNaN(e)&&(n=null),n))(t,e,n,i);return s!==t.lastIndexOf(e)?n:s}function La(t){const e=this.getLabels();return t>=0&&t<e.length?e[t]:t}function Aa(t,e){const n=[],{bounds:i,step:s,min:o,max:a,precision:r,count:l,maxTicks:c,maxDigits:d,includeBounds:h}=t,u=s||1,g=c-1,{min:p,max:m}=e,f=!ft(o),b=!ft(a),y=!ft(l),x=(m-p)/(d+1);let v,w,k,S,M=Qt((m-p)/g/u)*u;if(M<1e-14&&!f&&!b)return[{value:p},{value:m}];S=Math.ceil(m/M)-Math.floor(p/M),S>g&&(M=Qt(S*M/g/u)*u),ft(r)||(v=Math.pow(10,r),M=Math.ceil(M*v)/v),"ticks"===i?(w=Math.floor(p/M)*M,k=Math.ceil(m/M)*M):(w=p,k=m),f&&b&&s&&function(t,e){const n=Math.round(t);return n-e<=t&&n+e>=t}((a-o)/s,M/1e3)?(S=Math.round(Math.min((a-o)/M,c)),M=(a-o)/S,w=o,k=a):y?(w=f?o:w,k=b?a:k,S=l-1,M=(k-w)/S):(S=(k-w)/M,S=Xt(S,Math.round(S),M/1e3)?Math.round(S):Math.ceil(S));const C=Math.max(te(M),te(w));v=Math.pow(10,ft(r)?C:r),w=Math.round(w*v)/v,k=Math.round(k*v)/v;let _=0;for(f&&(h&&w!==o?(n.push({value:o}),w<o&&_++,Xt(Math.round((w+_*M)*v)/v,o,Ia(o,x,t))&&_++):w<o&&_++);_<S;++_){const t=Math.round((w+_*M)*v)/v;if(b&&t>a)break;n.push({value:t})}return b&&h&&k!==a?n.length&&Xt(n[n.length-1].value,a,Ia(a,x,t))?n[n.length-1].value=a:n.push({value:a}):b&&k!==a||n.push({value:k}),n}function Ia(t,e,{horizontal:n,minRotation:i}){const s=Zt(i),o=(n?Math.sin(s):Math.cos(s))||.001,a=.75*e*(""+t).length;return Math.min(e/o,a)}class za extends Ls{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 ft(t)||("number"==typeof t||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:e,maxDefined:n}=this.getUserBounds();let{min:i,max:s}=this;const o=t=>i=e?i:t,a=t=>s=n?s:t;if(t){const t=Ut(i),e=Ut(s);t<0&&e<0?a(0):t>0&&e>0&&o(0)}if(i===s){let e=0===s?1:Math.abs(.05*s);a(s+e),t||o(i-e)}this.min=i,this.max=s}getTickLimit(){const t=this.options.ticks;let e,{maxTicksLimit:n,stepSize:i}=t;return i?(e=Math.ceil(this.max/i)-Math.floor(this.min/i)+1,e>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${i} would result generating up to ${e} ticks. Limiting to 1000.`),e=1e3)):(e=this.computeTickLimit(),n=n||11),n&&(e=Math.min(n,e)),e}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,e=t.ticks;let n=this.getTickLimit();n=Math.max(2,n);const i=Aa({maxTicks:n,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&&Kt(i,this,"value"),t.reverse?(i.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),i}configure(){const t=this.ticks;let e=this.min,n=this.max;if(super.configure(),this.options.offset&&t.length){const i=(n-e)/Math.max(t.length-1,1)/2;e-=i,n+=i}this._startValue=e,this._endValue=n,this._valueRange=n-e}getLabelForValue(t){return Ee(t,this.chart.options.locale,this.options.ticks.format)}}class Oa extends za{static id="linear";static defaults={ticks:{callback:Ae.formatters.numeric}};determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=xt(t)?t:0,this.max=xt(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),e=t?this.width:this.height,n=Zt(this.options.ticks.minRotation),i=(t?Math.sin(n):Math.cos(n))||.001,s=this._resolveTickFontOptions(0);return Math.ceil(e/Math.min(40,s.lineHeight/i))}getPixelForValue(t){return null===t?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}const Wa=t=>Math.floor(Yt(t)),Na=(t,e)=>Math.pow(10,Wa(t)+e);function $a(t){return 1===t/Math.pow(10,Wa(t))}function Ra(t,e,n){const i=Math.pow(10,n),s=Math.floor(t/i);return Math.ceil(e/i)-s}function Fa(t,{min:e,max:n}){e=vt(t.min,e);const i=[],s=Wa(e);let o=function(t,e){let n=Wa(e-t);for(;Ra(t,e,n)>10;)n++;for(;Ra(t,e,n)<10;)n--;return Math.min(n,Wa(t))}(e,n),a=o<0?Math.pow(10,Math.abs(o)):1;const r=Math.pow(10,o),l=s>o?Math.pow(10,s):0,c=Math.round((e-l)*a)/a,d=Math.floor((e-l)/r/10)*r*10;let h=Math.floor((c-d)/Math.pow(10,o)),u=vt(t.min,Math.round((l+d+h*Math.pow(10,o))*a)/a);for(;u<n;)i.push({value:u,major:$a(u),significand:h}),h>=10?h=h<15?15:20:h++,h>=20&&(o++,h=2,a=o>=0?1:a),u=Math.round((l+d+h*Math.pow(10,o))*a)/a;const g=vt(t.max,u);return i.push({value:g,major:$a(g),significand:h}),i}class Ba extends Ls{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 n=za.prototype.parse.apply(this,[t,e]);if(0!==n)return xt(n)&&n>0?n:null;this._zero=!0}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=xt(t)?Math.max(0,t):null,this.max=xt(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!xt(this._userMin)&&(this.min=t===Na(this.min,0)?Na(this.min,-1):Na(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let n=this.min,i=this.max;const s=e=>n=t?n:e,o=t=>i=e?i:t;n===i&&(n<=0?(s(1),o(10)):(s(Na(n,-1)),o(Na(i,1)))),n<=0&&s(Na(i,-1)),i<=0&&o(Na(n,1)),this.min=n,this.max=i}buildTicks(){const t=this.options,e=Fa({min:this._userMin,max:this._userMax},this);return"ticks"===t.bounds&&Kt(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":Ee(t,this.chart.options.locale,this.options.ticks.format)}configure(){const t=this.min;super.configure(),this._startValue=Yt(t),this._valueRange=Yt(this.max)-Yt(t)}getPixelForValue(t){return void 0!==t&&0!==t||(t=this.min),null===t||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(Yt(t)-this._startValue)/this._valueRange)}getValueForPixel(t){const e=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+e*this._valueRange)}}function qa(t){const e=t.ticks;if(e.display&&t.display){const t=rn(e.backdropPadding);return wt(e.font&&e.font.size,$e.font.size)+t.height}return 0}function Ha(t,e,n,i,s){return t===i||t===s?{start:e-n/2,end:e+n/2}:t<i||t>s?{start:e-n,end:e}:{start:e,end:e+n}}function Va(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},n=Object.assign({},e),i=[],s=[],o=t._pointLabels.length,a=t.options.pointLabels,r=a.centerPointLabels?$t/o:0;for(let h=0;h<o;h++){const o=a.setContext(t.getPointLabelContext(h));s[h]=o.padding;const u=t.getPointPosition(h,t.drawingArea+s[h],r),g=ln(o.font),p=(l=t.ctx,c=g,d=bt(d=t._pointLabels[h])?d:[d],{w:Fe(l,c.string,d),h:d.length*c.lineHeight});i[h]=p;const m=se(t.getIndexAngle(h)+r),f=Math.round(Jt(m));ja(n,e,m,Ha(f,u.x,p.w,0,180),Ha(f,u.y,p.h,90,270))}var l,c,d;t.setCenterPoint(e.l-n.l,n.r-e.r,e.t-n.t,n.b-e.b),t._pointLabelItems=function(t,e,n){const i=[],s=t._pointLabels.length,o=t.options,{centerPointLabels:a,display:r}=o.pointLabels,l={extra:qa(o)/2,additionalAngle:a?$t/s:0};let c;for(let o=0;o<s;o++){l.padding=n[o],l.size=e[o];const s=Ya(t,o,l);i.push(s),"auto"===r&&(s.visible=Ua(s,c),s.visible&&(c=s))}return i}(t,i,s)}function ja(t,e,n,i,s){const o=Math.abs(Math.sin(n)),a=Math.abs(Math.cos(n));let r=0,l=0;i.start<e.l?(r=(e.l-i.start)/o,t.l=Math.min(t.l,e.l-r)):i.end>e.r&&(r=(i.end-e.r)/o,t.r=Math.max(t.r,e.r+r)),s.start<e.t?(l=(e.t-s.start)/a,t.t=Math.min(t.t,e.t-l)):s.end>e.b&&(l=(s.end-e.b)/a,t.b=Math.max(t.b,e.b+l))}function Ya(t,e,n){const i=t.drawingArea,{extra:s,additionalAngle:o,padding:a,size:r}=n,l=t.getPointPosition(e,i+s+a,o),c=Math.round(Jt(se(l.angle+Ht))),d=function(t,e,n){90===n||270===n?t-=e/2:(n>270||n<90)&&(t-=e);return t}(l.y,r.h,c),h=function(t){if(0===t||180===t)return"center";if(t<180)return"left";return"right"}(c),u=function(t,e,n){"right"===n?t-=e:"center"===n&&(t-=e/2);return t}(l.x,r.w,h);return{visible:!0,x:l.x,y:d,textAlign:h,left:u,top:d,right:u+r.w,bottom:d+r.h}}function Ua(t,e){if(!e)return!0;const{left:n,top:i,right:s,bottom:o}=t;return!(je({x:n,y:i},e)||je({x:n,y:o},e)||je({x:s,y:i},e)||je({x:s,y:o},e))}function Xa(t,e,n){const{left:i,top:s,right:o,bottom:a}=n,{backdropColor:r}=e;if(!ft(r)){const n=an(e.borderRadius),l=rn(e.backdropPadding);t.fillStyle=r;const c=i-l.left,d=s-l.top,h=o-i+l.width,u=a-s+l.height;Object.values(n).some((t=>0!==t))?(t.beginPath(),Je(t,{x:c,y:d,w:h,h:u,radius:n}),t.fill()):t.fillRect(c,d,h,u)}}function Qa(t,e,n,i){const{ctx:s}=t;if(n)s.arc(t.xCenter,t.yCenter,e,0,Rt);else{let n=t.getPointPosition(0,e);s.moveTo(n.x,n.y);for(let o=1;o<i;o++)n=t.getPointPosition(o,e),s.lineTo(n.x,n.y)}}class Ga extends za{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=rn(qa(this.options)/2),e=this.width=this.maxWidth-t.width,n=this.height=this.maxHeight-t.height;this.xCenter=Math.floor(this.left+e/2+t.left),this.yCenter=Math.floor(this.top+n/2+t.top),this.drawingArea=Math.floor(Math.min(e,n)/2)}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!1);this.min=xt(t)&&!isNaN(t)?t:0,this.max=xt(e)&&!isNaN(e)?e:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/qa(this.options))}generateTickLabels(t){za.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map(((t,e)=>{const n=St(this.options.pointLabels.callback,[t,e],this);return n||0===n?n:""})).filter(((t,e)=>this.chart.getDataVisibility(e)))}fit(){const t=this.options;t.display&&t.pointLabels.display?Va(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,e,n,i){this.xCenter+=Math.floor((t-e)/2),this.yCenter+=Math.floor((n-i)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,e,n,i))}getIndexAngle(t){return se(t*(Rt/(this._pointLabels.length||1))+Zt(this.options.startAngle||0))}getDistanceFromCenterForValue(t){if(ft(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(ft(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 n=e[t];return function(t,e,n){return dn(t,{label:n,index:e,type:"pointLabel"})}(this.getContext(),t,n)}}getPointPosition(t,e,n=0){const i=this.getIndexAngle(t)-Ht+n;return{x:Math.cos(i)*e+this.xCenter,y:Math.sin(i)*e+this.yCenter,angle:i}}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:n,right:i,bottom:s}=this._pointLabelItems[t];return{left:e,top:n,right:i,bottom:s}}drawBackground(){const{backgroundColor:t,grid:{circular:e}}=this.options;if(t){const n=this.ctx;n.save(),n.beginPath(),Qa(this,this.getDistanceFromCenterForValue(this._endValue),e,this._pointLabels.length),n.closePath(),n.fillStyle=t,n.fill(),n.restore()}}drawGrid(){const t=this.ctx,e=this.options,{angleLines:n,grid:i,border:s}=e,o=this._pointLabels.length;let a,r,l;if(e.pointLabels.display&&function(t,e){const{ctx:n,options:{pointLabels:i}}=t;for(let s=e-1;s>=0;s--){const e=t._pointLabelItems[s];if(!e.visible)continue;const o=i.setContext(t.getPointLabelContext(s));Xa(n,o,e);const a=ln(o.font),{x:r,y:l,textAlign:c}=e;Ze(n,t._pointLabels[s],r,l+a.lineHeight/2,a,{color:o.color,textAlign:c,textBaseline:"middle"})}}(this,o),i.display&&this.ticks.forEach(((t,e)=>{if(0!==e||0===e&&this.min<0){r=this.getDistanceFromCenterForValue(t.value);const n=this.getContext(e),a=i.setContext(n),l=s.setContext(n);!function(t,e,n,i,s){const o=t.ctx,a=e.circular,{color:r,lineWidth:l}=e;!a&&!i||!r||!l||n<0||(o.save(),o.strokeStyle=r,o.lineWidth=l,o.setLineDash(s.dash||[]),o.lineDashOffset=s.dashOffset,o.beginPath(),Qa(t,n,a,i),o.closePath(),o.stroke(),o.restore())}(this,a,r,o,l)}})),n.display){for(t.save(),a=o-1;a>=0;a--){const i=n.setContext(this.getPointLabelContext(a)),{color:s,lineWidth:o}=i;o&&s&&(t.lineWidth=o,t.strokeStyle=s,t.setLineDash(i.borderDash),t.lineDashOffset=i.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,n=e.ticks;if(!n.display)return;const i=this.getIndexAngle(0);let s,o;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(i),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach(((i,a)=>{if(0===a&&this.min>=0&&!e.reverse)return;const r=n.setContext(this.getContext(a)),l=ln(r.font);if(s=this.getDistanceFromCenterForValue(this.ticks[a].value),r.showLabelBackdrop){t.font=l.string,o=t.measureText(i.label).width,t.fillStyle=r.backdropColor;const e=rn(r.backdropPadding);t.fillRect(-o/2-e.left,-s-l.size/2-e.top,o+e.width,l.size+e.height)}Ze(t,i.label,0,-s,l,{color:r.color,strokeColor:r.textStrokeColor,strokeWidth:r.textStrokeWidth})})),t.restore()}drawTitle(){}}const Ka={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}},Za=Object.keys(Ka);function Ja(t,e){return t-e}function tr(t,e){if(ft(e))return null;const n=t._adapter,{parser:i,round:s,isoWeekday:o}=t._parseOpts;let a=e;return"function"==typeof i&&(a=i(a)),xt(a)||(a="string"==typeof i?n.parse(a,i):n.parse(a)),null===a?null:(s&&(a="week"!==s||!Gt(o)&&!0!==o?n.startOf(a,s):n.startOf(a,"isoWeek",o)),+a)}function er(t,e,n,i){const s=Za.length;for(let o=Za.indexOf(t);o<s-1;++o){const t=Ka[Za[o]],s=t.steps?t.steps:Number.MAX_SAFE_INTEGER;if(t.common&&Math.ceil((n-e)/(s*t.size))<=i)return Za[o]}return Za[s-1]}function nr(t,e,n){if(n){if(n.length){const{lo:i,hi:s}=le(n,e);t[n[i]>=e?n[i]:n[s]]=!0}}else t[e]=!0}function ir(t,e,n){const i=[],s={},o=e.length;let a,r;for(a=0;a<o;++a)r=e[a],s[r]=a,i.push({value:r,major:!1});return 0!==o&&n?function(t,e,n,i){const s=t._adapter,o=+s.startOf(e[0].value,i),a=e[e.length-1].value;let r,l;for(r=o;r<=a;r=+s.add(r,1,i))l=n[r],l>=0&&(e[l].major=!0);return e}(t,i,s,n):i}class sr extends Ls{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 n=t.time||(t.time={}),i=this._adapter=new Ni._date(t.adapters.date);i.init(e),Et(n.displayFormats,i.formats()),this._parseOpts={parser:n.parser,round:n.round,isoWeekday:n.isoWeekday},super.init(t),this._normalized=e.normalized}parse(t,e){return void 0===t?null:tr(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,e=this._adapter,n=t.time.unit||"day";let{min:i,max:s,minDefined:o,maxDefined:a}=this.getUserBounds();function r(t){o||isNaN(t.min)||(i=Math.min(i,t.min)),a||isNaN(t.max)||(s=Math.max(s,t.max))}o&&a||(r(this._getLabelBounds()),"ticks"===t.bounds&&"labels"===t.ticks.source||r(this.getMinMax(!1))),i=xt(i)&&!isNaN(i)?i:+e.startOf(Date.now(),n),s=xt(s)&&!isNaN(s)?s:+e.endOf(Date.now(),n)+1,this.min=Math.min(i,s-1),this.max=Math.max(i+1,s)}_getLabelBounds(){const t=this.getLabelTimestamps();let e=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],n=t[t.length-1]),{min:e,max:n}}buildTicks(){const t=this.options,e=t.time,n=t.ticks,i="labels"===n.source?this.getLabelTimestamps():this._generate();"ticks"===t.bounds&&i.length&&(this.min=this._userMin||i[0],this.max=this._userMax||i[i.length-1]);const s=this.min,o=function(t,e,n){let i=0,s=t.length;for(;i<s&&t[i]<e;)i++;for(;s>i&&t[s-1]>n;)s--;return i>0||s<t.length?t.slice(i,s):t}(i,s,this.max);return this._unit=e.unit||(n.autoSkip?er(e.minUnit,this.min,this.max,this._getLabelCapacity(s)):function(t,e,n,i,s){for(let o=Za.length-1;o>=Za.indexOf(n);o--){const n=Za[o];if(Ka[n].common&&t._adapter.diff(s,i,n)>=e-1)return n}return Za[n?Za.indexOf(n):0]}(this,o.length,e.minUnit,this.min,this.max)),this._majorUnit=n.major.enabled&&"year"!==this._unit?function(t){for(let e=Za.indexOf(t)+1,n=Za.length;e<n;++e)if(Ka[Za[e]].common)return Za[e]}(this._unit):void 0,this.initOffsets(i),t.reverse&&o.reverse(),ir(this,o,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map((t=>+t.value)))}initOffsets(t=[]){let e,n,i=0,s=0;this.options.offset&&t.length&&(e=this.getDecimalForValue(t[0]),i=1===t.length?1-e:(this.getDecimalForValue(t[1])-e)/2,n=this.getDecimalForValue(t[t.length-1]),s=1===t.length?n:(n-this.getDecimalForValue(t[t.length-2]))/2);const o=t.length<3?.5:.25;i=ae(i,0,o),s=ae(s,0,o),this._offsets={start:i,end:s,factor:1/(i+1+s)}}_generate(){const t=this._adapter,e=this.min,n=this.max,i=this.options,s=i.time,o=s.unit||er(s.minUnit,e,n,this._getLabelCapacity(e)),a=wt(i.ticks.stepSize,1),r="week"===o&&s.isoWeekday,l=Gt(r)||!0===r,c={};let d,h,u=e;if(l&&(u=+t.startOf(u,"isoWeek",r)),u=+t.startOf(u,l?"day":o),t.diff(n,e,o)>1e5*a)throw new Error(e+" and "+n+" are too far apart with stepSize of "+a+" "+o);const g="data"===i.ticks.source&&this.getDataTimestamps();for(d=u,h=0;d<n;d=+t.add(d,a,o),h++)nr(c,d,g);return d!==n&&"ticks"!==i.bounds&&1!==h||nr(c,d,g),Object.keys(c).sort(Ja).map((t=>+t))}getLabelForValue(t){const e=this._adapter,n=this.options.time;return n.tooltipFormat?e.format(t,n.tooltipFormat):e.format(t,n.displayFormats.datetime)}format(t,e){const n=this.options.time.displayFormats,i=this._unit,s=e||n[i];return this._adapter.format(t,s)}_tickFormatFunction(t,e,n,i){const s=this.options,o=s.ticks.callback;if(o)return St(o,[t,e,n],this);const a=s.time.displayFormats,r=this._unit,l=this._majorUnit,c=r&&a[r],d=l&&a[l],h=n[e],u=l&&d&&h&&h.major;return this._adapter.format(t,i||(u?d:c))}generateTickLabels(t){let e,n,i;for(e=0,n=t.length;e<n;++e)i=t[e],i.label=this._tickFormatFunction(i.value,e,t)}getDecimalForValue(t){return null===t?NaN:(t-this.min)/(this.max-this.min)}getPixelForValue(t){const e=this._offsets,n=this.getDecimalForValue(t);return this.getPixelForDecimal((e.start+n)*e.factor)}getValueForPixel(t){const e=this._offsets,n=this.getDecimalForPixel(t)/e.factor-e.end;return this.min+n*(this.max-this.min)}_getLabelSize(t){const e=this.options.ticks,n=this.ctx.measureText(t).width,i=Zt(this.isHorizontal()?e.maxRotation:e.minRotation),s=Math.cos(i),o=Math.sin(i),a=this._resolveTickFontOptions(0).size;return{w:n*s+a*o,h:n*o+a*s}}_getLabelCapacity(t){const e=this.options.time,n=e.displayFormats,i=n[e.unit]||n.millisecond,s=this._tickFormatFunction(t,0,ir(this,[t],this._majorUnit),i),o=this._getLabelSize(s),a=Math.floor(this.isHorizontal()?this.width/o.w:this.height/o.h)-1;return a>0?a:1}getDataTimestamps(){let t,e,n=this._cache.data||[];if(n.length)return n;const i=this.getMatchingVisibleMetas();if(this._normalized&&i.length)return this._cache.data=i[0].controller.getAllParsedValues(this);for(t=0,e=i.length;t<e;++t)n=n.concat(i[t].controller.getAllParsedValues(this));return this._cache.data=this.normalize(n)}getLabelTimestamps(){const t=this._cache.labels||[];let e,n;if(t.length)return t;const i=this.getLabels();for(e=0,n=i.length;e<n;++e)t.push(tr(this,i[e]));return this._cache.labels=this._normalized?t:this.normalize(t)}normalize(t){return ge(t.sort(Ja))}}function or(t,e,n){let i,s,o,a,r=0,l=t.length-1;n?(e>=t[r].pos&&e<=t[l].pos&&({lo:r,hi:l}=ce(t,"pos",e)),({pos:i,time:o}=t[r]),({pos:s,time:a}=t[l])):(e>=t[r].time&&e<=t[l].time&&({lo:r,hi:l}=ce(t,"time",e)),({time:i,pos:o}=t[r]),({time:s,pos:a}=t[l]));const c=s-i;return c?o+(a-o)*(e-i)/c:o}var ar=Object.freeze({__proto__:null,CategoryScale:class extends Ls{static id="category";static defaults={ticks:{callback:La}};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:n,label:i}of e)t[n]===i&&t.splice(n,1);this._addedLabels=[]}super.init(t)}parse(t,e){if(ft(t))return null;const n=this.getLabels();return((t,e)=>null===t?null:ae(Math.round(t),0,e))(e=isFinite(e)&&n[e]===t?e:Ea(n,t,wt(e,t),this._addedLabels),n.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let{min:n,max:i}=this.getMinMax(!0);"ticks"===this.options.bounds&&(t||(n=0),e||(i=this.getLabels().length-1)),this.min=n,this.max=i}buildTicks(){const t=this.min,e=this.max,n=this.options.offset,i=[];let s=this.getLabels();s=0===t&&e===s.length-1?s:s.slice(t,e+1),this._valueRange=Math.max(s.length-(n?0:1),1),this._startValue=this.min-(n?.5:0);for(let n=t;n<=e;n++)i.push({value:n});return i}getLabelForValue(t){return La.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:Oa,LogarithmicScale:Ba,RadialLinearScale:Ga,TimeScale:sr,TimeSeriesScale:class extends sr{static id="timeseries";static defaults=sr.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=or(e,this.min),this._tableRange=or(e,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:e,max:n}=this,i=[],s=[];let o,a,r,l,c;for(o=0,a=t.length;o<a;++o)l=t[o],l>=e&&l<=n&&i.push(l);if(i.length<2)return[{time:e,pos:0},{time:n,pos:1}];for(o=0,a=i.length;o<a;++o)c=i[o+1],r=i[o-1],l=i[o],Math.round((c+r)/2)!==l&&s.push({time:l,pos:o/(a-1)});return s}_generate(){const t=this.min,e=this.max;let n=super.getDataTimestamps();return n.includes(t)&&n.length||n.splice(0,0,t),n.includes(e)&&1!==n.length||n.push(e),n.sort(((t,e)=>t-e))}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const e=this.getDataTimestamps(),n=this.getLabelTimestamps();return t=e.length&&n.length?this.normalize(e.concat(n)):e.length?e:n,t=this._cache.all=t,t}getDecimalForValue(t){return(or(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const e=this._offsets,n=this.getDecimalForPixel(t)/e.factor-e.end;return or(this._table,n*this._tableRange+this._minPos,!0)}}});const rr=[zi,Lo,Pa,ar],lr=6048e5,cr=6e4,dr=36e5,hr=Symbol.for("constructDateFrom");function ur(t,e){return"function"==typeof t?t(e):t&&"object"==typeof t&&hr in t?t[hr](e):t instanceof Date?new t.constructor(e):new Date(e)}function gr(t,e){return ur(e||t,t)}function pr(t,e,n){const i=gr(t,n?.in);return isNaN(e)?ur(n?.in||t,NaN):e?(i.setDate(i.getDate()+e),i):i}function mr(t,e,n){const i=gr(t,n?.in);if(isNaN(e))return ur(n?.in||t,NaN);if(!e)return i;const s=i.getDate(),o=ur(n?.in||t,i.getTime());o.setMonth(i.getMonth()+e+1,0);return s>=o.getDate()?o:(i.setFullYear(o.getFullYear(),o.getMonth(),s),i)}function fr(t,e,n){return ur(n?.in||t,+gr(t)+e)}let br={};function yr(){return br}function xr(t,e){const n=yr(),i=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,s=gr(t,e?.in),o=s.getDay(),a=(o<i?7:0)+o-i;return s.setDate(s.getDate()-a),s.setHours(0,0,0,0),s}function vr(t,e){return xr(t,{...e,weekStartsOn:1})}function wr(t,e){const n=gr(t,e?.in),i=n.getFullYear(),s=ur(n,0);s.setFullYear(i+1,0,4),s.setHours(0,0,0,0);const o=vr(s),a=ur(n,0);a.setFullYear(i,0,4),a.setHours(0,0,0,0);const r=vr(a);return n.getTime()>=o.getTime()?i+1:n.getTime()>=r.getTime()?i:i-1}function kr(t){const e=gr(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function Sr(t,...e){const n=ur.bind(null,t||e.find((t=>"object"==typeof t)));return e.map(n)}function Mr(t,e){const n=gr(t,e?.in);return n.setHours(0,0,0,0),n}function Cr(t,e,n){const[i,s]=Sr(n?.in,t,e),o=Mr(i),a=Mr(s),r=+o-kr(o),l=+a-kr(a);return Math.round((r-l)/864e5)}function _r(t,e){const n=+gr(t)-+gr(e);return n<0?-1:n>0?1:n}function Tr(t){return!(!((e=t)instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e))&&"number"!=typeof t||isNaN(+gr(t)));var e}function Dr(t,e,n){const[i,s]=Sr(n?.in,t,e),o=Pr(i,s),a=Math.abs(Cr(i,s));i.setDate(i.getDate()-o*a);const r=o*(a-Number(Pr(i,s)===-o));return 0===r?0:r}function Pr(t,e){const n=t.getFullYear()-e.getFullYear()||t.getMonth()-e.getMonth()||t.getDate()-e.getDate()||t.getHours()-e.getHours()||t.getMinutes()-e.getMinutes()||t.getSeconds()-e.getSeconds()||t.getMilliseconds()-e.getMilliseconds();return n<0?-1:n>0?1:n}function Er(t){return e=>{const n=(t?Math[t]:Math.trunc)(e);return 0===n?0:n}}function Lr(t,e){return+gr(t)-+gr(e)}function Ar(t,e){const n=gr(t,e?.in);return n.setHours(23,59,59,999),n}function Ir(t,e){const n=gr(t,e?.in),i=n.getMonth();return n.setFullYear(n.getFullYear(),i+1,0),n.setHours(23,59,59,999),n}function zr(t,e,n){const[i,s,o]=Sr(n?.in,t,t,e),a=_r(s,o),r=Math.abs(function(t,e,n){const[i,s]=Sr(n?.in,t,e);return 12*(i.getFullYear()-s.getFullYear())+(i.getMonth()-s.getMonth())}(s,o));if(r<1)return 0;1===s.getMonth()&&s.getDate()>27&&s.setDate(30),s.setMonth(s.getMonth()-a*r);let l=_r(s,o)===-a;(function(t,e){const n=gr(t,e?.in);return+Ar(n,e)===+Ir(n,e)})(i)&&1===r&&1===_r(i,o)&&(l=!1);const c=a*(r-+l);return 0===c?0:c}function Or(t,e,n){const[i,s]=Sr(n?.in,t,e),o=_r(i,s),a=Math.abs(function(t,e,n){const[i,s]=Sr(n?.in,t,e);return i.getFullYear()-s.getFullYear()}(i,s));i.setFullYear(1584),s.setFullYear(1584);const r=o*(a-+(_r(i,s)===-o));return 0===r?0:r}function Wr(t,e){const n=gr(t,e?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}const Nr={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};function $r(t){return(e={})=>{const n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const Rr={date:$r({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:$r({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:$r({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Fr={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function Br(t){return(e,n)=>{let i;if("formatting"===(n?.context?String(n.context):"standalone")&&t.formattingValues){const e=t.defaultFormattingWidth||t.defaultWidth,s=n?.width?String(n.width):e;i=t.formattingValues[s]||t.formattingValues[e]}else{const e=t.defaultWidth,s=n?.width?String(n.width):t.defaultWidth;i=t.values[s]||t.values[e]}return i[t.argumentCallback?t.argumentCallback(e):e]}}const qr={ordinalNumber:(t,e)=>{const n=Number(t),i=n%100;if(i>20||i<10)switch(i%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},era:Br({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:Br({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:t=>t-1}),month:Br({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:Br({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:Br({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})};function Hr(t){return(e,n={})=>{const i=n.width,s=i&&t.matchPatterns[i]||t.matchPatterns[t.defaultMatchWidth],o=e.match(s);if(!o)return null;const a=o[0],r=i&&t.parsePatterns[i]||t.parsePatterns[t.defaultParseWidth],l=Array.isArray(r)?function(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return n;return}(r,(t=>t.test(a))):function(t,e){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n;return}(r,(t=>t.test(a)));let c;c=t.valueCallback?t.valueCallback(l):l,c=n.valueCallback?n.valueCallback(c):c;return{value:c,rest:e.slice(a.length)}}}const Vr={ordinalNumber:(jr={matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:t=>parseInt(t,10)},(t,e={})=>{const n=t.match(jr.matchPattern);if(!n)return null;const i=n[0],s=t.match(jr.parsePattern);if(!s)return null;let o=jr.valueCallback?jr.valueCallback(s[0]):s[0];return o=e.valueCallback?e.valueCallback(o):o,{value:o,rest:t.slice(i.length)}}),era:Hr({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:Hr({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:t=>t+1}),month:Hr({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:Hr({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:Hr({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})};var jr;const Yr={code:"en-US",formatDistance:(t,e,n)=>{let i;const s=Nr[t];return i="string"==typeof s?s:1===e?s.one:s.other.replace("{{count}}",e.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+i:i+" ago":i},formatLong:Rr,formatRelative:(t,e,n,i)=>Fr[t],localize:qr,match:Vr,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Ur(t,e){const n=gr(t,e?.in),i=+vr(n)-+function(t,e){const n=wr(t,e),i=ur(e?.in||t,0);return i.setFullYear(n,0,4),i.setHours(0,0,0,0),vr(i)}(n);return Math.round(i/lr)+1}function Xr(t,e){const n=gr(t,e?.in),i=n.getFullYear(),s=yr(),o=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,a=ur(e?.in||t,0);a.setFullYear(i+1,0,o),a.setHours(0,0,0,0);const r=xr(a,e),l=ur(e?.in||t,0);l.setFullYear(i,0,o),l.setHours(0,0,0,0);const c=xr(l,e);return+n>=+r?i+1:+n>=+c?i:i-1}function Qr(t,e){const n=gr(t,e?.in),i=+xr(n,e)-+function(t,e){const n=yr(),i=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,s=Xr(t,e),o=ur(e?.in||t,0);return o.setFullYear(s,0,i),o.setHours(0,0,0,0),xr(o,e)}(n,e);return Math.round(i/lr)+1}function Gr(t,e){return(t<0?"-":"")+Math.abs(t).toString().padStart(e,"0")}const Kr={y(t,e){const n=t.getFullYear(),i=n>0?n:1-n;return Gr("yy"===e?i%100:i,e.length)},M(t,e){const n=t.getMonth();return"M"===e?String(n+1):Gr(n+1,2)},d:(t,e)=>Gr(t.getDate(),e.length),a(t,e){const n=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];default:return"am"===n?"a.m.":"p.m."}},h:(t,e)=>Gr(t.getHours()%12||12,e.length),H:(t,e)=>Gr(t.getHours(),e.length),m:(t,e)=>Gr(t.getMinutes(),e.length),s:(t,e)=>Gr(t.getSeconds(),e.length),S(t,e){const n=e.length,i=t.getMilliseconds();return Gr(Math.trunc(i*Math.pow(10,n-3)),e.length)}},Zr="midnight",Jr="noon",tl="morning",el="afternoon",nl="evening",il="night",sl={G:function(t,e,n){const i=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(i,{width:"abbreviated"});case"GGGGG":return n.era(i,{width:"narrow"});default:return n.era(i,{width:"wide"})}},y:function(t,e,n){if("yo"===e){const e=t.getFullYear(),i=e>0?e:1-e;return n.ordinalNumber(i,{unit:"year"})}return Kr.y(t,e)},Y:function(t,e,n,i){const s=Xr(t,i),o=s>0?s:1-s;if("YY"===e){return Gr(o%100,2)}return"Yo"===e?n.ordinalNumber(o,{unit:"year"}):Gr(o,e.length)},R:function(t,e){return Gr(wr(t),e.length)},u:function(t,e){return Gr(t.getFullYear(),e.length)},Q:function(t,e,n){const i=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(i);case"QQ":return Gr(i,2);case"Qo":return n.ordinalNumber(i,{unit:"quarter"});case"QQQ":return n.quarter(i,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(i,{width:"narrow",context:"formatting"});default:return n.quarter(i,{width:"wide",context:"formatting"})}},q:function(t,e,n){const i=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(i);case"qq":return Gr(i,2);case"qo":return n.ordinalNumber(i,{unit:"quarter"});case"qqq":return n.quarter(i,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(i,{width:"narrow",context:"standalone"});default:return n.quarter(i,{width:"wide",context:"standalone"})}},M:function(t,e,n){const i=t.getMonth();switch(e){case"M":case"MM":return Kr.M(t,e);case"Mo":return n.ordinalNumber(i+1,{unit:"month"});case"MMM":return n.month(i,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(i,{width:"narrow",context:"formatting"});default:return n.month(i,{width:"wide",context:"formatting"})}},L:function(t,e,n){const i=t.getMonth();switch(e){case"L":return String(i+1);case"LL":return Gr(i+1,2);case"Lo":return n.ordinalNumber(i+1,{unit:"month"});case"LLL":return n.month(i,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(i,{width:"narrow",context:"standalone"});default:return n.month(i,{width:"wide",context:"standalone"})}},w:function(t,e,n,i){const s=Qr(t,i);return"wo"===e?n.ordinalNumber(s,{unit:"week"}):Gr(s,e.length)},I:function(t,e,n){const i=Ur(t);return"Io"===e?n.ordinalNumber(i,{unit:"week"}):Gr(i,e.length)},d:function(t,e,n){return"do"===e?n.ordinalNumber(t.getDate(),{unit:"date"}):Kr.d(t,e)},D:function(t,e,n){const i=function(t,e){const n=gr(t,e?.in);return Cr(n,Wr(n))+1}(t);return"Do"===e?n.ordinalNumber(i,{unit:"dayOfYear"}):Gr(i,e.length)},E:function(t,e,n){const i=t.getDay();switch(e){case"E":case"EE":case"EEE":return n.day(i,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(i,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(i,{width:"short",context:"formatting"});default:return n.day(i,{width:"wide",context:"formatting"})}},e:function(t,e,n,i){const s=t.getDay(),o=(s-i.weekStartsOn+8)%7||7;switch(e){case"e":return String(o);case"ee":return Gr(o,2);case"eo":return n.ordinalNumber(o,{unit:"day"});case"eee":return n.day(s,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(s,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(s,{width:"short",context:"formatting"});default:return n.day(s,{width:"wide",context:"formatting"})}},c:function(t,e,n,i){const s=t.getDay(),o=(s-i.weekStartsOn+8)%7||7;switch(e){case"c":return String(o);case"cc":return Gr(o,e.length);case"co":return n.ordinalNumber(o,{unit:"day"});case"ccc":return n.day(s,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(s,{width:"narrow",context:"standalone"});case"cccccc":return n.day(s,{width:"short",context:"standalone"});default:return n.day(s,{width:"wide",context:"standalone"})}},i:function(t,e,n){const i=t.getDay(),s=0===i?7:i;switch(e){case"i":return String(s);case"ii":return Gr(s,e.length);case"io":return n.ordinalNumber(s,{unit:"day"});case"iii":return n.day(i,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(i,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(i,{width:"short",context:"formatting"});default:return n.day(i,{width:"wide",context:"formatting"})}},a:function(t,e,n){const i=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(i,{width:"narrow",context:"formatting"});default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(t,e,n){const i=t.getHours();let s;switch(s=12===i?Jr:0===i?Zr:i/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(s,{width:"narrow",context:"formatting"});default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},B:function(t,e,n){const i=t.getHours();let s;switch(s=i>=17?nl:i>=12?el:i>=4?tl:il,e){case"B":case"BB":case"BBB":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(s,{width:"narrow",context:"formatting"});default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},h:function(t,e,n){if("ho"===e){let e=t.getHours()%12;return 0===e&&(e=12),n.ordinalNumber(e,{unit:"hour"})}return Kr.h(t,e)},H:function(t,e,n){return"Ho"===e?n.ordinalNumber(t.getHours(),{unit:"hour"}):Kr.H(t,e)},K:function(t,e,n){const i=t.getHours()%12;return"Ko"===e?n.ordinalNumber(i,{unit:"hour"}):Gr(i,e.length)},k:function(t,e,n){let i=t.getHours();return 0===i&&(i=24),"ko"===e?n.ordinalNumber(i,{unit:"hour"}):Gr(i,e.length)},m:function(t,e,n){return"mo"===e?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):Kr.m(t,e)},s:function(t,e,n){return"so"===e?n.ordinalNumber(t.getSeconds(),{unit:"second"}):Kr.s(t,e)},S:function(t,e){return Kr.S(t,e)},X:function(t,e,n){const i=t.getTimezoneOffset();if(0===i)return"Z";switch(e){case"X":return al(i);case"XXXX":case"XX":return rl(i);default:return rl(i,":")}},x:function(t,e,n){const i=t.getTimezoneOffset();switch(e){case"x":return al(i);case"xxxx":case"xx":return rl(i);default:return rl(i,":")}},O:function(t,e,n){const i=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+ol(i,":");default:return"GMT"+rl(i,":")}},z:function(t,e,n){const i=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+ol(i,":");default:return"GMT"+rl(i,":")}},t:function(t,e,n){return Gr(Math.trunc(+t/1e3),e.length)},T:function(t,e,n){return Gr(+t,e.length)}};function ol(t,e=""){const n=t>0?"-":"+",i=Math.abs(t),s=Math.trunc(i/60),o=i%60;return 0===o?n+String(s):n+String(s)+e+Gr(o,2)}function al(t,e){if(t%60==0){return(t>0?"-":"+")+Gr(Math.abs(t)/60,2)}return rl(t,e)}function rl(t,e=""){const n=t>0?"-":"+",i=Math.abs(t);return n+Gr(Math.trunc(i/60),2)+e+Gr(i%60,2)}const ll=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});default:return e.date({width:"full"})}},cl=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});default:return e.time({width:"full"})}},dl={p:cl,P:(t,e)=>{const n=t.match(/(P+)(p+)?/)||[],i=n[1],s=n[2];if(!s)return ll(t,e);let o;switch(i){case"P":o=e.dateTime({width:"short"});break;case"PP":o=e.dateTime({width:"medium"});break;case"PPP":o=e.dateTime({width:"long"});break;default:o=e.dateTime({width:"full"})}return o.replace("{{date}}",ll(i,e)).replace("{{time}}",cl(s,e))}},hl=/^D+$/,ul=/^Y+$/,gl=["D","DD","YY","YYYY"];function pl(t){return hl.test(t)}function ml(t){return ul.test(t)}function fl(t,e,n){const i=function(t,e,n){const i="Y"===t[0]?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${i} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}(t,e,n);if(console.warn(i),gl.includes(t))throw new RangeError(i)}const bl=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,yl=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,xl=/^'([^]*?)'?$/,vl=/''/g,wl=/[a-zA-Z]/;function kl(t){const e=t.match(xl);return e?e[1].replace(vl,"'"):t}class Sl{subPriority=0;validate(t,e){return!0}}class Ml extends Sl{constructor(t,e,n,i,s){super(),this.value=t,this.validateValue=e,this.setValue=n,this.priority=i,s&&(this.subPriority=s)}validate(t,e){return this.validateValue(t,this.value,e)}set(t,e,n){return this.setValue(t,e,this.value,n)}}class Cl extends Sl{priority=10;subPriority=-1;constructor(t,e){super(),this.context=t||(t=>ur(e,t))}set(t,e){return e.timestampIsSet?t:ur(t,function(t,e){const n=function(t){return"function"==typeof t&&t.prototype?.constructor===t}(e)?new e(0):ur(e,0);return n.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),n.setHours(t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()),n}(t,this.context))}}class _l{run(t,e,n,i){const s=this.parse(t,e,n,i);return s?{setter:new Ml(s.value,this.validate,this.set,this.priority,this.subPriority),rest:s.rest}:null}validate(t,e,n){return!0}}const Tl=/^(1[0-2]|0?\d)/,Dl=/^(3[0-1]|[0-2]?\d)/,Pl=/^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,El=/^(5[0-3]|[0-4]?\d)/,Ll=/^(2[0-3]|[0-1]?\d)/,Al=/^(2[0-4]|[0-1]?\d)/,Il=/^(1[0-1]|0?\d)/,zl=/^(1[0-2]|0?\d)/,Ol=/^[0-5]?\d/,Wl=/^[0-5]?\d/,Nl=/^\d/,$l=/^\d{1,2}/,Rl=/^\d{1,3}/,Fl=/^\d{1,4}/,Bl=/^-?\d+/,ql=/^-?\d/,Hl=/^-?\d{1,2}/,Vl=/^-?\d{1,3}/,jl=/^-?\d{1,4}/,Yl=/^([+-])(\d{2})(\d{2})?|Z/,Ul=/^([+-])(\d{2})(\d{2})|Z/,Xl=/^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,Ql=/^([+-])(\d{2}):(\d{2})|Z/,Gl=/^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/;function Kl(t,e){return t?{value:e(t.value),rest:t.rest}:t}function Zl(t,e){const n=e.match(t);return n?{value:parseInt(n[0],10),rest:e.slice(n[0].length)}:null}function Jl(t,e){const n=e.match(t);if(!n)return null;if("Z"===n[0])return{value:0,rest:e.slice(1)};const i="+"===n[1]?1:-1,s=n[2]?parseInt(n[2],10):0,o=n[3]?parseInt(n[3],10):0,a=n[5]?parseInt(n[5],10):0;return{value:i*(s*dr+o*cr+1e3*a),rest:e.slice(n[0].length)}}function tc(t){return Zl(Bl,t)}function ec(t,e){switch(t){case 1:return Zl(Nl,e);case 2:return Zl($l,e);case 3:return Zl(Rl,e);case 4:return Zl(Fl,e);default:return Zl(new RegExp("^\\d{1,"+t+"}"),e)}}function nc(t,e){switch(t){case 1:return Zl(ql,e);case 2:return Zl(Hl,e);case 3:return Zl(Vl,e);case 4:return Zl(jl,e);default:return Zl(new RegExp("^-?\\d{1,"+t+"}"),e)}}function ic(t){switch(t){case"morning":return 4;case"evening":return 17;case"pm":case"noon":case"afternoon":return 12;default:return 0}}function sc(t,e){const n=e>0,i=n?e:1-e;let s;if(i<=50)s=t||100;else{const e=i+50;s=t+100*Math.trunc(e/100)-(t>=e%100?100:0)}return n?s:1-s}function oc(t){return t%400==0||t%4==0&&t%100!=0}const ac=[31,28,31,30,31,30,31,31,30,31,30,31],rc=[31,29,31,30,31,30,31,31,30,31,30,31];function lc(t,e,n){const i=yr(),s=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??i.weekStartsOn??i.locale?.options?.weekStartsOn??0,o=gr(t,n?.in),a=o.getDay(),r=7-s;return pr(o,e<0||e>6?e-(a+r)%7:((e%7+7)%7+r)%7-(a+r)%7,n)}function cc(t,e,n){const i=gr(t,n?.in),s=function(t,e){const n=gr(t,e?.in).getDay();return 0===n?7:n}(i,n);return pr(i,e-s,n)}const dc={G:new class extends _l{priority=140;parse(t,e,n){switch(e){case"G":case"GG":case"GGG":return n.era(t,{width:"abbreviated"})||n.era(t,{width:"narrow"});case"GGGGG":return n.era(t,{width:"narrow"});default:return n.era(t,{width:"wide"})||n.era(t,{width:"abbreviated"})||n.era(t,{width:"narrow"})}}set(t,e,n){return e.era=n,t.setFullYear(n,0,1),t.setHours(0,0,0,0),t}incompatibleTokens=["R","u","t","T"]},y:new class extends _l{priority=130;incompatibleTokens=["Y","R","u","w","I","i","e","c","t","T"];parse(t,e,n){const i=t=>({year:t,isTwoDigitYear:"yy"===e});switch(e){case"y":return Kl(ec(4,t),i);case"yo":return Kl(n.ordinalNumber(t,{unit:"year"}),i);default:return Kl(ec(e.length,t),i)}}validate(t,e){return e.isTwoDigitYear||e.year>0}set(t,e,n){const i=t.getFullYear();if(n.isTwoDigitYear){const e=sc(n.year,i);return t.setFullYear(e,0,1),t.setHours(0,0,0,0),t}const s="era"in e&&1!==e.era?1-n.year:n.year;return t.setFullYear(s,0,1),t.setHours(0,0,0,0),t}},Y:new class extends _l{priority=130;parse(t,e,n){const i=t=>({year:t,isTwoDigitYear:"YY"===e});switch(e){case"Y":return Kl(ec(4,t),i);case"Yo":return Kl(n.ordinalNumber(t,{unit:"year"}),i);default:return Kl(ec(e.length,t),i)}}validate(t,e){return e.isTwoDigitYear||e.year>0}set(t,e,n,i){const s=Xr(t,i);if(n.isTwoDigitYear){const e=sc(n.year,s);return t.setFullYear(e,0,i.firstWeekContainsDate),t.setHours(0,0,0,0),xr(t,i)}const o="era"in e&&1!==e.era?1-n.year:n.year;return t.setFullYear(o,0,i.firstWeekContainsDate),t.setHours(0,0,0,0),xr(t,i)}incompatibleTokens=["y","R","u","Q","q","M","L","I","d","D","i","t","T"]},R:new class extends _l{priority=130;parse(t,e){return nc("R"===e?4:e.length,t)}set(t,e,n){const i=ur(t,0);return i.setFullYear(n,0,4),i.setHours(0,0,0,0),vr(i)}incompatibleTokens=["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"]},u:new class extends _l{priority=130;parse(t,e){return nc("u"===e?4:e.length,t)}set(t,e,n){return t.setFullYear(n,0,1),t.setHours(0,0,0,0),t}incompatibleTokens=["G","y","Y","R","w","I","i","e","c","t","T"]},Q:new class extends _l{priority=120;parse(t,e,n){switch(e){case"Q":case"QQ":return ec(e.length,t);case"Qo":return n.ordinalNumber(t,{unit:"quarter"});case"QQQ":return n.quarter(t,{width:"abbreviated",context:"formatting"})||n.quarter(t,{width:"narrow",context:"formatting"});case"QQQQQ":return n.quarter(t,{width:"narrow",context:"formatting"});default:return n.quarter(t,{width:"wide",context:"formatting"})||n.quarter(t,{width:"abbreviated",context:"formatting"})||n.quarter(t,{width:"narrow",context:"formatting"})}}validate(t,e){return e>=1&&e<=4}set(t,e,n){return t.setMonth(3*(n-1),1),t.setHours(0,0,0,0),t}incompatibleTokens=["Y","R","q","M","L","w","I","d","D","i","e","c","t","T"]},q:new class extends _l{priority=120;parse(t,e,n){switch(e){case"q":case"qq":return ec(e.length,t);case"qo":return n.ordinalNumber(t,{unit:"quarter"});case"qqq":return n.quarter(t,{width:"abbreviated",context:"standalone"})||n.quarter(t,{width:"narrow",context:"standalone"});case"qqqqq":return n.quarter(t,{width:"narrow",context:"standalone"});default:return n.quarter(t,{width:"wide",context:"standalone"})||n.quarter(t,{width:"abbreviated",context:"standalone"})||n.quarter(t,{width:"narrow",context:"standalone"})}}validate(t,e){return e>=1&&e<=4}set(t,e,n){return t.setMonth(3*(n-1),1),t.setHours(0,0,0,0),t}incompatibleTokens=["Y","R","Q","M","L","w","I","d","D","i","e","c","t","T"]},M:new class extends _l{incompatibleTokens=["Y","R","q","Q","L","w","I","D","i","e","c","t","T"];priority=110;parse(t,e,n){const i=t=>t-1;switch(e){case"M":return Kl(Zl(Tl,t),i);case"MM":return Kl(ec(2,t),i);case"Mo":return Kl(n.ordinalNumber(t,{unit:"month"}),i);case"MMM":return n.month(t,{width:"abbreviated",context:"formatting"})||n.month(t,{width:"narrow",context:"formatting"});case"MMMMM":return n.month(t,{width:"narrow",context:"formatting"});default:return n.month(t,{width:"wide",context:"formatting"})||n.month(t,{width:"abbreviated",context:"formatting"})||n.month(t,{width:"narrow",context:"formatting"})}}validate(t,e){return e>=0&&e<=11}set(t,e,n){return t.setMonth(n,1),t.setHours(0,0,0,0),t}},L:new class extends _l{priority=110;parse(t,e,n){const i=t=>t-1;switch(e){case"L":return Kl(Zl(Tl,t),i);case"LL":return Kl(ec(2,t),i);case"Lo":return Kl(n.ordinalNumber(t,{unit:"month"}),i);case"LLL":return n.month(t,{width:"abbreviated",context:"standalone"})||n.month(t,{width:"narrow",context:"standalone"});case"LLLLL":return n.month(t,{width:"narrow",context:"standalone"});default:return n.month(t,{width:"wide",context:"standalone"})||n.month(t,{width:"abbreviated",context:"standalone"})||n.month(t,{width:"narrow",context:"standalone"})}}validate(t,e){return e>=0&&e<=11}set(t,e,n){return t.setMonth(n,1),t.setHours(0,0,0,0),t}incompatibleTokens=["Y","R","q","Q","M","w","I","D","i","e","c","t","T"]},w:new class extends _l{priority=100;parse(t,e,n){switch(e){case"w":return Zl(El,t);case"wo":return n.ordinalNumber(t,{unit:"week"});default:return ec(e.length,t)}}validate(t,e){return e>=1&&e<=53}set(t,e,n,i){return xr(function(t,e,n){const i=gr(t,n?.in),s=Qr(i,n)-e;return i.setDate(i.getDate()-7*s),gr(i,n?.in)}(t,n,i),i)}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","i","t","T"]},I:new class extends _l{priority=100;parse(t,e,n){switch(e){case"I":return Zl(El,t);case"Io":return n.ordinalNumber(t,{unit:"week"});default:return ec(e.length,t)}}validate(t,e){return e>=1&&e<=53}set(t,e,n){return vr(function(t,e,n){const i=gr(t,n?.in),s=Ur(i,n)-e;return i.setDate(i.getDate()-7*s),i}(t,n))}incompatibleTokens=["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"]},d:new class extends _l{priority=90;subPriority=1;parse(t,e,n){switch(e){case"d":return Zl(Dl,t);case"do":return n.ordinalNumber(t,{unit:"date"});default:return ec(e.length,t)}}validate(t,e){const n=oc(t.getFullYear()),i=t.getMonth();return n?e>=1&&e<=rc[i]:e>=1&&e<=ac[i]}set(t,e,n){return t.setDate(n),t.setHours(0,0,0,0),t}incompatibleTokens=["Y","R","q","Q","w","I","D","i","e","c","t","T"]},D:new class extends _l{priority=90;subpriority=1;parse(t,e,n){switch(e){case"D":case"DD":return Zl(Pl,t);case"Do":return n.ordinalNumber(t,{unit:"date"});default:return ec(e.length,t)}}validate(t,e){return oc(t.getFullYear())?e>=1&&e<=366:e>=1&&e<=365}set(t,e,n){return t.setMonth(0,n),t.setHours(0,0,0,0),t}incompatibleTokens=["Y","R","q","Q","M","L","w","I","d","E","i","e","c","t","T"]},E:new class extends _l{priority=90;parse(t,e,n){switch(e){case"E":case"EE":case"EEE":return n.day(t,{width:"abbreviated",context:"formatting"})||n.day(t,{width:"short",context:"formatting"})||n.day(t,{width:"narrow",context:"formatting"});case"EEEEE":return n.day(t,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(t,{width:"short",context:"formatting"})||n.day(t,{width:"narrow",context:"formatting"});default:return n.day(t,{width:"wide",context:"formatting"})||n.day(t,{width:"abbreviated",context:"formatting"})||n.day(t,{width:"short",context:"formatting"})||n.day(t,{width:"narrow",context:"formatting"})}}validate(t,e){return e>=0&&e<=6}set(t,e,n,i){return(t=lc(t,n,i)).setHours(0,0,0,0),t}incompatibleTokens=["D","i","e","c","t","T"]},e:new class extends _l{priority=90;parse(t,e,n,i){const s=t=>{const e=7*Math.floor((t-1)/7);return(t+i.weekStartsOn+6)%7+e};switch(e){case"e":case"ee":return Kl(ec(e.length,t),s);case"eo":return Kl(n.ordinalNumber(t,{unit:"day"}),s);case"eee":return n.day(t,{width:"abbreviated",context:"formatting"})||n.day(t,{width:"short",context:"formatting"})||n.day(t,{width:"narrow",context:"formatting"});case"eeeee":return n.day(t,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(t,{width:"short",context:"formatting"})||n.day(t,{width:"narrow",context:"formatting"});default:return n.day(t,{width:"wide",context:"formatting"})||n.day(t,{width:"abbreviated",context:"formatting"})||n.day(t,{width:"short",context:"formatting"})||n.day(t,{width:"narrow",context:"formatting"})}}validate(t,e){return e>=0&&e<=6}set(t,e,n,i){return(t=lc(t,n,i)).setHours(0,0,0,0),t}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"]},c:new class extends _l{priority=90;parse(t,e,n,i){const s=t=>{const e=7*Math.floor((t-1)/7);return(t+i.weekStartsOn+6)%7+e};switch(e){case"c":case"cc":return Kl(ec(e.length,t),s);case"co":return Kl(n.ordinalNumber(t,{unit:"day"}),s);case"ccc":return n.day(t,{width:"abbreviated",context:"standalone"})||n.day(t,{width:"short",context:"standalone"})||n.day(t,{width:"narrow",context:"standalone"});case"ccccc":return n.day(t,{width:"narrow",context:"standalone"});case"cccccc":return n.day(t,{width:"short",context:"standalone"})||n.day(t,{width:"narrow",context:"standalone"});default:return n.day(t,{width:"wide",context:"standalone"})||n.day(t,{width:"abbreviated",context:"standalone"})||n.day(t,{width:"short",context:"standalone"})||n.day(t,{width:"narrow",context:"standalone"})}}validate(t,e){return e>=0&&e<=6}set(t,e,n,i){return(t=lc(t,n,i)).setHours(0,0,0,0),t}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"]},i:new class extends _l{priority=90;parse(t,e,n){const i=t=>0===t?7:t;switch(e){case"i":case"ii":return ec(e.length,t);case"io":return n.ordinalNumber(t,{unit:"day"});case"iii":return Kl(n.day(t,{width:"abbreviated",context:"formatting"})||n.day(t,{width:"short",context:"formatting"})||n.day(t,{width:"narrow",context:"formatting"}),i);case"iiiii":return Kl(n.day(t,{width:"narrow",context:"formatting"}),i);case"iiiiii":return Kl(n.day(t,{width:"short",context:"formatting"})||n.day(t,{width:"narrow",context:"formatting"}),i);default:return Kl(n.day(t,{width:"wide",context:"formatting"})||n.day(t,{width:"abbreviated",context:"formatting"})||n.day(t,{width:"short",context:"formatting"})||n.day(t,{width:"narrow",context:"formatting"}),i)}}validate(t,e){return e>=1&&e<=7}set(t,e,n){return(t=cc(t,n)).setHours(0,0,0,0),t}incompatibleTokens=["y","Y","u","q","Q","M","L","w","d","D","E","e","c","t","T"]},a:new class extends _l{priority=80;parse(t,e,n){switch(e){case"a":case"aa":case"aaa":return n.dayPeriod(t,{width:"abbreviated",context:"formatting"})||n.dayPeriod(t,{width:"narrow",context:"formatting"});case"aaaaa":return n.dayPeriod(t,{width:"narrow",context:"formatting"});default:return n.dayPeriod(t,{width:"wide",context:"formatting"})||n.dayPeriod(t,{width:"abbreviated",context:"formatting"})||n.dayPeriod(t,{width:"narrow",context:"formatting"})}}set(t,e,n){return t.setHours(ic(n),0,0,0),t}incompatibleTokens=["b","B","H","k","t","T"]},b:new class extends _l{priority=80;parse(t,e,n){switch(e){case"b":case"bb":case"bbb":return n.dayPeriod(t,{width:"abbreviated",context:"formatting"})||n.dayPeriod(t,{width:"narrow",context:"formatting"});case"bbbbb":return n.dayPeriod(t,{width:"narrow",context:"formatting"});default:return n.dayPeriod(t,{width:"wide",context:"formatting"})||n.dayPeriod(t,{width:"abbreviated",context:"formatting"})||n.dayPeriod(t,{width:"narrow",context:"formatting"})}}set(t,e,n){return t.setHours(ic(n),0,0,0),t}incompatibleTokens=["a","B","H","k","t","T"]},B:new class extends _l{priority=80;parse(t,e,n){switch(e){case"B":case"BB":case"BBB":return n.dayPeriod(t,{width:"abbreviated",context:"formatting"})||n.dayPeriod(t,{width:"narrow",context:"formatting"});case"BBBBB":return n.dayPeriod(t,{width:"narrow",context:"formatting"});default:return n.dayPeriod(t,{width:"wide",context:"formatting"})||n.dayPeriod(t,{width:"abbreviated",context:"formatting"})||n.dayPeriod(t,{width:"narrow",context:"formatting"})}}set(t,e,n){return t.setHours(ic(n),0,0,0),t}incompatibleTokens=["a","b","t","T"]},h:new class extends _l{priority=70;parse(t,e,n){switch(e){case"h":return Zl(zl,t);case"ho":return n.ordinalNumber(t,{unit:"hour"});default:return ec(e.length,t)}}validate(t,e){return e>=1&&e<=12}set(t,e,n){const i=t.getHours()>=12;return i&&n<12?t.setHours(n+12,0,0,0):i||12!==n?t.setHours(n,0,0,0):t.setHours(0,0,0,0),t}incompatibleTokens=["H","K","k","t","T"]},H:new class extends _l{priority=70;parse(t,e,n){switch(e){case"H":return Zl(Ll,t);case"Ho":return n.ordinalNumber(t,{unit:"hour"});default:return ec(e.length,t)}}validate(t,e){return e>=0&&e<=23}set(t,e,n){return t.setHours(n,0,0,0),t}incompatibleTokens=["a","b","h","K","k","t","T"]},K:new class extends _l{priority=70;parse(t,e,n){switch(e){case"K":return Zl(Il,t);case"Ko":return n.ordinalNumber(t,{unit:"hour"});default:return ec(e.length,t)}}validate(t,e){return e>=0&&e<=11}set(t,e,n){return t.getHours()>=12&&n<12?t.setHours(n+12,0,0,0):t.setHours(n,0,0,0),t}incompatibleTokens=["h","H","k","t","T"]},k:new class extends _l{priority=70;parse(t,e,n){switch(e){case"k":return Zl(Al,t);case"ko":return n.ordinalNumber(t,{unit:"hour"});default:return ec(e.length,t)}}validate(t,e){return e>=1&&e<=24}set(t,e,n){const i=n<=24?n%24:n;return t.setHours(i,0,0,0),t}incompatibleTokens=["a","b","h","H","K","t","T"]},m:new class extends _l{priority=60;parse(t,e,n){switch(e){case"m":return Zl(Ol,t);case"mo":return n.ordinalNumber(t,{unit:"minute"});default:return ec(e.length,t)}}validate(t,e){return e>=0&&e<=59}set(t,e,n){return t.setMinutes(n,0,0),t}incompatibleTokens=["t","T"]},s:new class extends _l{priority=50;parse(t,e,n){switch(e){case"s":return Zl(Wl,t);case"so":return n.ordinalNumber(t,{unit:"second"});default:return ec(e.length,t)}}validate(t,e){return e>=0&&e<=59}set(t,e,n){return t.setSeconds(n,0),t}incompatibleTokens=["t","T"]},S:new class extends _l{priority=30;parse(t,e){return Kl(ec(e.length,t),(t=>Math.trunc(t*Math.pow(10,3-e.length))))}set(t,e,n){return t.setMilliseconds(n),t}incompatibleTokens=["t","T"]},X:new class extends _l{priority=10;parse(t,e){switch(e){case"X":return Jl(Yl,t);case"XX":return Jl(Ul,t);case"XXXX":return Jl(Xl,t);case"XXXXX":return Jl(Gl,t);default:return Jl(Ql,t)}}set(t,e,n){return e.timestampIsSet?t:ur(t,t.getTime()-kr(t)-n)}incompatibleTokens=["t","T","x"]},x:new class extends _l{priority=10;parse(t,e){switch(e){case"x":return Jl(Yl,t);case"xx":return Jl(Ul,t);case"xxxx":return Jl(Xl,t);case"xxxxx":return Jl(Gl,t);default:return Jl(Ql,t)}}set(t,e,n){return e.timestampIsSet?t:ur(t,t.getTime()-kr(t)-n)}incompatibleTokens=["t","T","X"]},t:new class extends _l{priority=40;parse(t){return tc(t)}set(t,e,n){return[ur(t,1e3*n),{timestampIsSet:!0}]}incompatibleTokens="*"},T:new class extends _l{priority=20;parse(t){return tc(t)}set(t,e,n){return[ur(t,n),{timestampIsSet:!0}]}incompatibleTokens="*"}},hc=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,uc=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,gc=/^'([^]*?)'?$/,pc=/''/g,mc=/\S/,fc=/[a-zA-Z]/;function bc(t,e,n,i){const s=()=>ur(i?.in||n,NaN),o=Object.assign({},yr()),a=i?.locale??o.locale??Yr,r=i?.firstWeekContainsDate??i?.locale?.options?.firstWeekContainsDate??o.firstWeekContainsDate??o.locale?.options?.firstWeekContainsDate??1,l=i?.weekStartsOn??i?.locale?.options?.weekStartsOn??o.weekStartsOn??o.locale?.options?.weekStartsOn??0;if(!e)return t?s():gr(n,i?.in);const c={firstWeekContainsDate:r,weekStartsOn:l,locale:a},d=[new Cl(i?.in,n)],h=e.match(uc).map((t=>{const e=t[0];if(e in dl){return(0,dl[e])(t,a.formatLong)}return t})).join("").match(hc),u=[];for(let n of h){!i?.useAdditionalWeekYearTokens&&ml(n)&&fl(n,e,t),!i?.useAdditionalDayOfYearTokens&&pl(n)&&fl(n,e,t);const o=n[0],r=dc[o];if(r){const{incompatibleTokens:e}=r;if(Array.isArray(e)){const t=u.find((t=>e.includes(t.token)||t.token===o));if(t)throw new RangeError(`The format string mustn't contain \`${t.fullToken}\` and \`${n}\` at the same time`)}else if("*"===r.incompatibleTokens&&u.length>0)throw new RangeError(`The format string mustn't contain \`${n}\` and any other token at the same time`);u.push({token:o,fullToken:n});const i=r.run(t,n,a.match,c);if(!i)return s();d.push(i.setter),t=i.rest}else{if(o.match(fc))throw new RangeError("Format string contains an unescaped latin alphabet character `"+o+"`");if("''"===n?n="'":"'"===o&&(n=n.match(gc)[1].replace(pc,"'")),0!==t.indexOf(n))return s();t=t.slice(n.length)}}if(t.length>0&&mc.test(t))return s();const g=d.map((t=>t.priority)).sort(((t,e)=>e-t)).filter(((t,e,n)=>n.indexOf(t)===e)).map((t=>d.filter((e=>e.priority===t)).sort(((t,e)=>e.subPriority-t.subPriority)))).map((t=>t[0]));let p=gr(n,i?.in);if(isNaN(+p))return s();const m={};for(const t of g){if(!t.validate(p,c))return s();const e=t.set(p,m,c);Array.isArray(e)?(p=e[0],Object.assign(m,e[1])):p=e}return p}function yc(t,e){const n=()=>ur(e?.in,NaN),i=e?.additionalDigits??2,s=function(t){const e={},n=t.split(xc.dateTimeDelimiter);let i;if(n.length>2)return e;/:/.test(n[0])?i=n[0]:(e.date=n[0],i=n[1],xc.timeZoneDelimiter.test(e.date)&&(e.date=t.split(xc.timeZoneDelimiter)[0],i=t.substr(e.date.length,t.length)));if(i){const t=xc.timezone.exec(i);t?(e.time=i.replace(t[1],""),e.timezone=t[1]):e.time=i}return e}(t);let o;if(s.date){const t=function(t,e){const n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+e)+"})|(\\d{2}|[+-]\\d{"+(2+e)+"})$)"),i=t.match(n);if(!i)return{year:NaN,restDateString:""};const s=i[1]?parseInt(i[1]):null,o=i[2]?parseInt(i[2]):null;return{year:null===o?s:100*o,restDateString:t.slice((i[1]||i[2]).length)}}(s.date,i);o=function(t,e){if(null===e)return new Date(NaN);const n=t.match(vc);if(!n)return new Date(NaN);const i=!!n[4],s=Sc(n[1]),o=Sc(n[2])-1,a=Sc(n[3]),r=Sc(n[4]),l=Sc(n[5])-1;if(i)return function(t,e,n){return e>=1&&e<=53&&n>=0&&n<=6}(0,r,l)?function(t,e,n){const i=new Date(0);i.setUTCFullYear(t,0,4);const s=i.getUTCDay()||7,o=7*(e-1)+n+1-s;return i.setUTCDate(i.getUTCDate()+o),i}(e,r,l):new Date(NaN);{const t=new Date(0);return function(t,e,n){return e>=0&&e<=11&&n>=1&&n<=(Cc[e]||(_c(t)?29:28))}(e,o,a)&&function(t,e){return e>=1&&e<=(_c(t)?366:365)}(e,s)?(t.setUTCFullYear(e,o,Math.max(s,a)),t):new Date(NaN)}}(t.restDateString,t.year)}if(!o||isNaN(+o))return n();const a=+o;let r,l=0;if(s.time&&(l=function(t){const e=t.match(wc);if(!e)return NaN;const n=Mc(e[1]),i=Mc(e[2]),s=Mc(e[3]);if(!function(t,e,n){if(24===t)return 0===e&&0===n;return n>=0&&n<60&&e>=0&&e<60&&t>=0&&t<25}(n,i,s))return NaN;return n*dr+i*cr+1e3*s}(s.time),isNaN(l)))return n();if(!s.timezone){const t=new Date(a+l),n=gr(0,e?.in);return n.setFullYear(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()),n.setHours(t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds()),n}return r=function(t){if("Z"===t)return 0;const e=t.match(kc);if(!e)return 0;const n="+"===e[1]?-1:1,i=parseInt(e[2]),s=e[3]&&parseInt(e[3])||0;if(!function(t,e){return e>=0&&e<=59}
|
|
21
21
|
/*!
|
|
22
22
|
* chartjs-adapter-date-fns v3.0.0
|
|
23
23
|
* https://www.chartjs.org
|
|
24
24
|
* (c) 2022 chartjs-adapter-date-fns Contributors
|
|
25
25
|
* Released under the MIT license
|
|
26
|
-
*/(0,s))return NaN;return n*(i*
|
|
26
|
+
*/(0,s))return NaN;return n*(i*dr+s*cr)}(s.timezone),isNaN(r)?n():gr(a+l+r,e?.in)}const xc={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},vc=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,wc=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,kc=/^([+-])(\d{2})(?::?(\d{2}))?$/;function Sc(t){return t?parseInt(t):1}function Mc(t){return t&&parseFloat(t.replace(",","."))||0}const Cc=[31,null,31,30,31,30,31,31,30,31,30,31];function _c(t){return t%400==0||t%4==0&&t%100!=0}const Tc={datetime:"MMM d, yyyy, h:mm:ss aaaa",millisecond:"h:mm:ss.SSS aaaa",second:"h:mm:ss aaaa",minute:"h:mm aaaa",hour:"ha",day:"MMM d",week:"PP",month:"MMM yyyy",quarter:"qqq - yyyy",year:"yyyy"};Ni._date.override({_id:"date-fns",formats:function(){return Tc},parse:function(t,e){if(null==t)return null;const n=typeof t;return"number"===n||t instanceof Date?t=gr(t):"string"===n&&(t="string"==typeof e?bc(t,e,new Date,this.options):yc(t,this.options)),Tr(t)?t.getTime():null},format:function(t,e){return function(t,e,n){const i=yr(),s=n?.locale??i.locale??Yr,o=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,a=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??i.weekStartsOn??i.locale?.options?.weekStartsOn??0,r=gr(t,n?.in);if(!Tr(r))throw new RangeError("Invalid time value");let l=e.match(yl).map((t=>{const e=t[0];return"p"===e||"P"===e?(0,dl[e])(t,s.formatLong):t})).join("").match(bl).map((t=>{if("''"===t)return{isToken:!1,value:"'"};const e=t[0];if("'"===e)return{isToken:!1,value:kl(t)};if(sl[e])return{isToken:!0,value:t};if(e.match(wl))throw new RangeError("Format string contains an unescaped latin alphabet character `"+e+"`");return{isToken:!1,value:t}}));s.localize.preprocessor&&(l=s.localize.preprocessor(r,l));const c={firstWeekContainsDate:o,weekStartsOn:a,locale:s};return l.map((i=>{if(!i.isToken)return i.value;const o=i.value;return(!n?.useAdditionalWeekYearTokens&&ml(o)||!n?.useAdditionalDayOfYearTokens&&pl(o))&&fl(o,e,String(t)),(0,sl[o[0]])(r,o,s.localize,c)})).join("")}(t,e,this.options)},add:function(t,e,n){switch(n){case"millisecond":return fr(t,e);case"second":return function(t,e,n){return fr(t,1e3*e,n)}(t,e);case"minute":return function(t,e,n){const i=gr(t,n?.in);return i.setTime(i.getTime()+e*cr),i}(t,e);case"hour":return function(t,e,n){return fr(t,e*dr,n)}(t,e);case"day":return pr(t,e);case"week":return function(t,e,n){return pr(t,7*e,n)}(t,e);case"month":return mr(t,e);case"quarter":return function(t,e,n){return mr(t,3*e,n)}(t,e);case"year":return function(t,e,n){return mr(t,12*e,n)}(t,e);default:return t}},diff:function(t,e,n){switch(n){case"millisecond":return Lr(t,e);case"second":return function(t,e,n){const i=Lr(t,e)/1e3;return Er(n?.roundingMethod)(i)}(t,e);case"minute":return function(t,e,n){const i=Lr(t,e)/cr;return Er(n?.roundingMethod)(i)}(t,e);case"hour":return function(t,e,n){const[i,s]=Sr(n?.in,t,e),o=(+i-+s)/dr;return Er(n?.roundingMethod)(o)}(t,e);case"day":return Dr(t,e);case"week":return function(t,e,n){const i=Dr(t,e,n)/7;return Er(n?.roundingMethod)(i)}(t,e);case"month":return zr(t,e);case"quarter":return function(t,e,n){const i=zr(t,e,n)/3;return Er(n?.roundingMethod)(i)}(t,e);case"year":return Or(t,e);default:return 0}},startOf:function(t,e,n){switch(e){case"second":return function(t,e){const n=gr(t,e?.in);return n.setMilliseconds(0),n}(t);case"minute":return function(t,e){const n=gr(t,e?.in);return n.setSeconds(0,0),n}(t);case"hour":return function(t,e){const n=gr(t,e?.in);return n.setMinutes(0,0,0),n}(t);case"day":return Mr(t);case"week":return xr(t);case"isoWeek":return xr(t,{weekStartsOn:+n});case"month":return function(t,e){const n=gr(t,e?.in);return n.setDate(1),n.setHours(0,0,0,0),n}(t);case"quarter":return function(t,e){const n=gr(t,e?.in),i=n.getMonth(),s=i-i%3;return n.setMonth(s,1),n.setHours(0,0,0,0),n}(t);case"year":return Wr(t);default:return t}},endOf:function(t,e){switch(e){case"second":return function(t,e){const n=gr(t,e?.in);return n.setMilliseconds(999),n}(t);case"minute":return function(t,e){const n=gr(t,e?.in);return n.setSeconds(59,999),n}(t);case"hour":return function(t,e){const n=gr(t,e?.in);return n.setMinutes(59,59,999),n}(t);case"day":return Ar(t);case"week":return function(t,e){const n=yr(),i=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,s=gr(t,e?.in),o=s.getDay(),a=6+(o<i?-7:0)-(o-i);return s.setDate(s.getDate()+a),s.setHours(23,59,59,999),s}(t);case"month":return Ir(t);case"quarter":return function(t,e){const n=gr(t,e?.in),i=n.getMonth(),s=i-i%3+3;return n.setMonth(s,0),n.setHours(23,59,59,999),n}(t);case"year":return function(t,e){const n=gr(t,e?.in),i=n.getFullYear();return n.setFullYear(i+1,0,0),n.setHours(23,59,59,999),n}(t);default:return t}}});
|
|
27
27
|
/*!
|
|
28
28
|
* chartjs-plugin-annotation v3.1.0
|
|
29
29
|
* https://www.chartjs.org/chartjs-plugin-annotation/index
|
|
30
30
|
* (c) 2024 chartjs-plugin-annotation Contributors
|
|
31
31
|
* Released under the MIT License
|
|
32
32
|
*/
|
|
33
|
-
const Sc={modes:{point:(t,e)=>Cc(t,e,{intersect:!0}),nearest:(t,e,n)=>function(t,e,n){let i=Number.POSITIVE_INFINITY;return Cc(t,e,n).reduce(((t,s)=>{const o=s.getCenterPoint(),a=function(t,e,n){if("x"===n)return{x:t.x,y:e.y};if("y"===n)return{x:e.x,y:t.y};return e}(e,o,n.axis),r=Kt(e,a);return r<i?(t=[s],i=r):r===i&&t.push(s),t}),[]).sort(((t,e)=>t._index-e._index)).slice(0,1)}(t,e,n),x:(t,e,n)=>Cc(t,e,{intersect:n.intersect,axis:"x"}),y:(t,e,n)=>Cc(t,e,{intersect:n.intersect,axis:"y"})}};function Mc(t,e,n){return(Sc.modes[n.mode]||Sc.modes.nearest)(t,e,n)}function Cc(t,e,n){return t.filter((t=>n.intersect?t.inRange(e.x,e.y):function(t,e,n){return"x"!==n&&"y"!==n?t.inRange(e.x,e.y,"x",!0)||t.inRange(e.x,e.y,"y",!0):t.inRange(e.x,e.y,n,!0)}(t,e,n.axis)))}function _c(t,e,n){const i=Math.cos(n),s=Math.sin(n),o=e.x,a=e.y;return{x:o+i*(t.x-o)-s*(t.y-a),y:a+s*(t.x-o)+i*(t.y-a)}}const Tc=(t,e)=>e>t||t.length>e.length&&t.slice(0,e.length)===e,Dc=.001,Pc=(t,e,n)=>Math.min(n,Math.max(e,t)),Ec=(t,e)=>t.value>=t.start-e&&t.value<=t.end+e;function Lc(t,e,n){for(const i of Object.keys(t))t[i]=Pc(t[i],e,n);return t}function Ac(t,{x:e,y:n,x2:i,y2:s},o,{borderWidth:a,hitTolerance:r}){const l=(a+r)/2,c=t.x>=e-l-Dc&&t.x<=i+l+Dc,d=t.y>=n-l-Dc&&t.y<=s+l+Dc;return"x"===o?c:("y"===o||c)&&d}function Ic(t,{rect:e,center:n},i,{rotation:s,borderWidth:o,hitTolerance:a}){return Ac(_c(t,n,Ut(-s)),e,i,{borderWidth:o,hitTolerance:a})}function zc(t,e){const{centerX:n,centerY:i}=t.getProps(["centerX","centerY"],e);return{x:n,y:i}}const Oc=t=>"string"==typeof t&&t.endsWith("%"),Wc=t=>parseFloat(t)/100,Nc=t=>Pc(Wc(t),0,1),Rc=(t,e)=>({x:t,y:e,x2:t,y2:e,width:0,height:0}),$c={box:t=>Rc(t.centerX,t.centerY),doughnutLabel:t=>Rc(t.centerX,t.centerY),ellipse:t=>({centerX:t.centerX,centerY:t.centerX,radius:0,width:0,height:0}),label:t=>Rc(t.centerX,t.centerY),line:t=>Rc(t.x,t.y),point:t=>({centerX:t.centerX,centerY:t.centerY,radius:0,width:0,height:0}),polygon:t=>Rc(t.centerX,t.centerY)};function Fc(t,e){return"start"===e?0:"end"===e?t:Oc(e)?Nc(e)*t:t/2}function Bc(t,e,n=!0){return"number"==typeof e?e:Oc(e)?(n?Nc(e):Wc(e))*t:t}function qc(t,e,{borderWidth:n,position:i,xAdjust:s,yAdjust:o},a){const r=gt(a),l=e.width+(r?a.width:0)+n,c=e.height+(r?a.height:0)+n,d=Hc(i),h=Uc(t.x,l,s,d.x),u=Uc(t.y,c,o,d.y);return{x:h,y:u,x2:h+l,y2:u+c,width:l,height:c,centerX:h+l/2,centerY:u+c/2}}function Hc(t,e="center"){return gt(t)?{x:ft(t.x,e),y:ft(t.y,e)}:{x:t=ft(t,e),y:t}}const Vc=(t,e)=>t&&t.autoFit&&e<1;function Yc(t,e){const n=t.font,i=ut(n)?n:[n];return Vc(t,e)?i.map((function(t){const n=nn(t);return n.size=Math.floor(t.size*e),n.lineHeight=t.lineHeight,nn(n)})):i.map((t=>nn(t)))}function jc(t){return t&&(Et(t.xValue)||Et(t.yValue))}function Uc(t,e,n=0,i){return t-Fc(e,i)+n}function Xc(t,e,n){const i=n.init;if(i)return!0===i?Gc(e,n):function(t,e,n){const i=yt(n.init,[{chart:t,properties:e,options:n}]);if(!0===i)return Gc(e,n);if(gt(i))return i}(t,e,n)}function Qc(t,e,n){let i=!1;return e.forEach((e=>{Lt(t[e])?(i=!0,n[e]=t[e]):Et(n[e])&&delete n[e]})),i}function Gc(t,e){const n=e.type||"line";return $c[n](t)}const Kc=new Map;function Zc(t){if(t&&"object"==typeof t){const e=t.toString();return"[object HTMLImageElement]"===e||"[object HTMLCanvasElement]"===e}}function Jc(t,{x:e,y:n},i){i&&(t.translate(e,n),t.rotate(Ut(i)),t.translate(-e,-n))}function td(t,e){if(e&&e.borderWidth)return t.lineCap=e.borderCapStyle||"butt",t.setLineDash(e.borderDash),t.lineDashOffset=e.borderDashOffset,t.lineJoin=e.borderJoinStyle||"miter",t.lineWidth=e.borderWidth,t.strokeStyle=e.borderColor,!0}function ed(t,e){t.shadowColor=e.backgroundShadowColor,t.shadowBlur=e.shadowBlur,t.shadowOffsetX=e.shadowOffsetX,t.shadowOffsetY=e.shadowOffsetY}function nd(t,e){const n=e.content;if(Zc(n)){return{width:Bc(n.width,e.width),height:Bc(n.height,e.height)}}const i=Yc(e),s=e.textStrokeWidth,o=ut(n)?n:[n],a=o.join()+(t=>t.reduce((function(t,e){return t+e.string}),""))(i)+s+(t._measureText?"-spriting":"");return Kc.has(a)||Kc.set(a,function(t,e,n,i){t.save();const s=e.length;let o=0,a=i;for(let r=0;r<s;r++){const s=n[Math.min(r,n.length-1)];t.font=s.string;const l=e[r];o=Math.max(o,t.measureText(l).width+i),a+=s.lineHeight}return t.restore(),{width:o,height:a}}(t,o,i,s)),Kc.get(a)}function id(t,e,n){const{x:i,y:s,width:o,height:a}=e;t.save(),ed(t,n);const r=td(t,n);t.fillStyle=n.backgroundColor,t.beginPath(),Xe(t,{x:i,y:s,w:o,h:a,radius:Lc(tn(n.borderRadius),0,Math.min(o,a)/2)}),t.closePath(),t.fill(),r&&(t.shadowColor=n.borderShadowColor,t.stroke()),t.restore()}function sd(t,e,n,i){const s=n.content;if(Zc(s))return t.save(),t.globalAlpha=function(t,e){const n=Yt(t)?t:e;return Yt(n)?Pc(n,0,1):1}(n.opacity,s.style.opacity),t.drawImage(s,e.x,e.y,e.width,e.height),void t.restore();const o=ut(s)?s:[s],a=Yc(n,i),r=n.color,l=ut(r)?r:[r],c=function(t,e){const{x:n,width:i}=t,s=e.textAlign;return"center"===s?n+i/2:"end"===s||"right"===s?n+i:n}(e,n),d=e.y+n.textStrokeWidth/2;t.save(),t.textBaseline="middle",t.textAlign=n.textAlign,function(t,e){if(e.textStrokeWidth>0)return t.lineJoin="round",t.miterLimit=2,t.lineWidth=e.textStrokeWidth,t.strokeStyle=e.textStrokeColor,!0}(t,n)&&function(t,{x:e,y:n},i,s){t.beginPath();let o=0;i.forEach((function(i,a){const r=s[Math.min(a,s.length-1)],l=r.lineHeight;t.font=r.string,t.strokeText(i,e,n+l/2+o),o+=l})),t.stroke()}(t,{x:c,y:d},o,a),function(t,{x:e,y:n},i,{fonts:s,colors:o}){let a=0;i.forEach((function(i,r){const l=o[Math.min(r,o.length-1)],c=s[Math.min(r,s.length-1)],d=c.lineHeight;t.beginPath(),t.font=c.string,t.fillStyle=l,t.fillText(i,e,n+d/2+a),a+=d,t.fill()}))}(t,{x:c,y:d},o,{fonts:a,colors:l}),t.restore()}function od(t,e,n,i){const{radius:s,options:o}=e,a=o.pointStyle,r=o.rotation;let l=(r||0)*Nt;if(Zc(a))return t.save(),t.translate(n,i),t.rotate(l),t.drawImage(a,-a.width/2,-a.height/2,a.width,a.height),void t.restore();(t=>isNaN(t)||t<=0)(s)||function(t,{x:e,y:n,radius:i,rotation:s,style:o,rad:a}){let r,l,c,d;switch(t.beginPath(),o){default:t.arc(e,n,i,0,zt),t.closePath();break;case"triangle":t.moveTo(e+Math.sin(a)*i,n-Math.cos(a)*i),a+=Ft,t.lineTo(e+Math.sin(a)*i,n-Math.cos(a)*i),a+=Ft,t.lineTo(e+Math.sin(a)*i,n-Math.cos(a)*i),t.closePath();break;case"rectRounded":d=.516*i,c=i-d,r=Math.cos(a+$t)*c,l=Math.sin(a+$t)*c,t.arc(e-r,n-l,d,a-It,a-Rt),t.arc(e+l,n-r,d,a-Rt,a),t.arc(e+r,n+l,d,a,a+Rt),t.arc(e-l,n+r,d,a+Rt,a+It),t.closePath();break;case"rect":if(!s){c=Math.SQRT1_2*i,t.rect(e-c,n-c,2*c,2*c);break}a+=$t;case"rectRot":r=Math.cos(a)*i,l=Math.sin(a)*i,t.moveTo(e-r,n-l),t.lineTo(e+l,n-r),t.lineTo(e+r,n+l),t.lineTo(e-l,n+r),t.closePath();break;case"crossRot":a+=$t;case"cross":r=Math.cos(a)*i,l=Math.sin(a)*i,t.moveTo(e-r,n-l),t.lineTo(e+r,n+l),t.moveTo(e+l,n-r),t.lineTo(e-l,n+r);break;case"star":r=Math.cos(a)*i,l=Math.sin(a)*i,t.moveTo(e-r,n-l),t.lineTo(e+r,n+l),t.moveTo(e+l,n-r),t.lineTo(e-l,n+r),a+=$t,r=Math.cos(a)*i,l=Math.sin(a)*i,t.moveTo(e-r,n-l),t.lineTo(e+r,n+l),t.moveTo(e+l,n-r),t.lineTo(e-l,n+r);break;case"line":r=Math.cos(a)*i,l=Math.sin(a)*i,t.moveTo(e-r,n-l),t.lineTo(e+r,n+l);break;case"dash":t.moveTo(e,n),t.lineTo(e+Math.cos(a)*i,n+Math.sin(a)*i)}t.fill()}(t,{x:n,y:i,radius:s,rotation:r,style:a,rad:l})}const ad=["left","bottom","top","right"];function rd(t,e){const{pointX:n,pointY:i,options:s}=e,o=s.callout,a=o&&o.display&&function(t,e){const n=e.position;if(ad.includes(n))return n;return function(t,e){const{x:n,y:i,x2:s,y2:o,width:a,height:r,pointX:l,pointY:c,centerX:d,centerY:h,rotation:u}=t,g={x:d,y:h},p=e.start,m=Bc(a,p),f=Bc(r,p),b=[n,n+m,n+m,s],y=[i+f,o,i,o],x=[];for(let t=0;t<4;t++){const e=_c({x:b[t],y:y[t]},g,Ut(u));x.push({position:ad[t],distance:Kt(e,{x:l,y:c})})}return x.sort(((t,e)=>t.distance-e.distance))[0].position}(t,e)}(e,o);if(!a||function(t,e,n){const{pointX:i,pointY:s}=t,o=e.margin;let a=i,r=s;"left"===n?a+=o:"right"===n?a-=o:"top"===n?r+=o:"bottom"===n&&(r-=o);return t.inRange(a,r)}(e,o,a))return;t.save(),t.beginPath();if(!td(t,o))return t.restore();const{separatorStart:r,separatorEnd:l}=function(t,e){const{x:n,y:i,x2:s,y2:o}=t,a=function(t,e){const{width:n,height:i,options:s}=t,o=s.callout.margin+s.borderWidth/2;if("right"===e)return n+o;if("bottom"===e)return i+o;return-o}(t,e);let r,l;"left"===e||"right"===e?(r={x:n+a,y:i},l={x:r.x,y:o}):(r={x:n,y:i+a},l={x:s,y:r.y});return{separatorStart:r,separatorEnd:l}}(e,a),{sideStart:c,sideEnd:d}=function(t,e,n){const{y:i,width:s,height:o,options:a}=t,r=a.callout.start,l=function(t,e){const n=e.side;if("left"===t||"top"===t)return-n;return n}(e,a.callout);let c,d;"left"===e||"right"===e?(c={x:n.x,y:i+Bc(o,r)},d={x:c.x+l,y:c.y}):(c={x:n.x+Bc(s,r),y:n.y},d={x:c.x,y:c.y+l});return{sideStart:c,sideEnd:d}}(e,a,r);(o.margin>0||0===s.borderWidth)&&(t.moveTo(r.x,r.y),t.lineTo(l.x,l.y)),t.moveTo(c.x,c.y),t.lineTo(d.x,d.y);const h=_c({x:n,y:i},e.getCenterPoint(),Ut(-e.rotation));t.lineTo(h.x,h.y),t.stroke(),t.restore()}const ld={xScaleID:{min:"xMin",max:"xMax",start:"left",end:"right",startProp:"x",endProp:"x2"},yScaleID:{min:"yMin",max:"yMax",start:"bottom",end:"top",startProp:"y",endProp:"y2"}};function cd(t,e,n){return pt(e="number"==typeof e?e:t.parse(e))?t.getPixelForValue(e):n}function dd(t,e,n){const i=e[n];if(i||"scaleID"===n)return i;const s=n.charAt(0),o=Object.values(t).filter((t=>t.axis&&t.axis===s));return o.length?o[0].id:s}function hd(t,e){if(t){const n=t.options.reverse;return{start:cd(t,e.min,n?e.end:e.start),end:cd(t,e.max,n?e.start:e.end)}}}function ud(t,e){const{chartArea:n,scales:i}=t,s=i[dd(i,e,"xScaleID")],o=i[dd(i,e,"yScaleID")];let a=n.width/2,r=n.height/2;return s&&(a=cd(s,e.xValue,s.left+s.width/2)),o&&(r=cd(o,e.yValue,o.top+o.height/2)),{x:a,y:r}}function gd(t,e){const n=t.scales,i=n[dd(n,e,"xScaleID")],s=n[dd(n,e,"yScaleID")];if(!i&&!s)return{};let{left:o,right:a}=i||t.chartArea,{top:r,bottom:l}=s||t.chartArea;const c=bd(i,{min:e.xMin,max:e.xMax,start:o,end:a});o=c.start,a=c.end;const d=bd(s,{min:e.yMin,max:e.yMax,start:l,end:r});return r=d.start,l=d.end,{x:o,y:r,x2:a,y2:l,width:a-o,height:l-r,centerX:o+(a-o)/2,centerY:r+(l-r)/2}}function pd(t,e){if(!jc(e)){const n=gd(t,e);let i=e.radius;i&&!isNaN(i)||(i=Math.min(n.width,n.height)/2,e.radius=i);const s=2*i,o=n.centerX+e.xAdjust,a=n.centerY+e.yAdjust;return{x:o-i,y:a-i,x2:o+i,y2:a+i,centerX:o,centerY:a,width:s,height:s,radius:i}}return function(t,e){const n=ud(t,e),i=2*e.radius;return{x:n.x-e.radius+e.xAdjust,y:n.y-e.radius+e.yAdjust,x2:n.x+e.radius+e.xAdjust,y2:n.y+e.radius+e.yAdjust,centerX:n.x+e.xAdjust,centerY:n.y+e.yAdjust,radius:e.radius,width:i,height:i}}(t,e)}function md(t,e){const{scales:n,chartArea:i}=t,s=n[e.scaleID],o={x:i.left,y:i.top,x2:i.right,y2:i.bottom};return s?function(t,e,n){const i=cd(t,n.value,NaN),s=cd(t,n.endValue,i);t.isHorizontal()?(e.x=i,e.x2=s):(e.y=i,e.y2=s)}(s,o,e):function(t,e,n){for(const i of Object.keys(ld)){const s=t[dd(t,n,i)];if(s){const{min:t,max:o,start:a,end:r,startProp:l,endProp:c}=ld[i],d=hd(s,{min:n[t],max:n[o],start:s[a],end:s[r]});e[l]=d.start,e[c]=d.end}}}(n,o,e),o}function fd(t,e){const n=gd(t,e);return n.initProperties=Xc(t,n,e),n.elements=[{type:"label",optionScope:"label",properties:xd(t,n,e),initProperties:n.initProperties}],n}function bd(t,e){const n=hd(t,e)||e;return{start:Math.min(n.start,n.end),end:Math.max(n.start,n.end)}}function yd(t,e){const{start:n,end:i,borderWidth:s}=t,{position:o,padding:{start:a,end:r},adjust:l}=e;return n+s/2+l+Fc(i-s-n-a-r-e.size,o)}function xd(t,e,n){const i=n.label;i.backgroundColor="transparent",i.callout.display=!1;const s=Hc(i.position),o=en(i.padding),a=nd(t.ctx,i),r=function({properties:t,options:e},n,i,s){const{x:o,x2:a,width:r}=t;return yd({start:o,end:a,size:r,borderWidth:e.borderWidth},{position:i.x,padding:{start:s.left,end:s.right},adjust:e.label.xAdjust,size:n.width})}({properties:e,options:n},a,s,o),l=function({properties:t,options:e},n,i,s){const{y:o,y2:a,height:r}=t;return yd({start:o,end:a,size:r,borderWidth:e.borderWidth},{position:i.y,padding:{start:s.top,end:s.bottom},adjust:e.label.yAdjust,size:n.height})}({properties:e,options:n},a,s,o),c=a.width+o.width,d=a.height+o.height;return{x:r,y:l,x2:r+c,y2:l+d,width:c,height:d,centerX:r+c/2,centerY:l+d/2,rotation:i.rotation}}const vd=["enter","leave"],wd=vd.concat("click");function kd(t,e,n){if(t.listened)switch(e.type){case"mousemove":case"mouseout":return function(t,e,n){if(!t.moveListened)return;let i;i="mousemove"===e.type?Mc(t.visibleElements,e,n.interaction):[];const s=t.hovered;t.hovered=i;const o={state:t,event:e};let a=Sd(o,"leave",s,i);return Sd(o,"enter",i,s)||a}(t,e,n);case"click":return function(t,e,n){const i=t.listeners,s=Mc(t.visibleElements,e,n.interaction);let o;for(const t of s)o=Md(t.options.click||i.click,t,e)||o;return o}(t,e,n)}}function Sd({state:t,event:e},n,i,s){let o;for(const a of i)s.indexOf(a)<0&&(o=Md(a.options[n]||t.listeners[n],a,e)||o);return o}function Md(t,e,n){return!0===yt(t,[e.$context,n])}const Cd=["afterDraw","beforeDraw"];function _d(t,e,n){if(t.hooked){return yt(e.options[n]||t.hooks[n],[e.$context])}}function Td(t,e,n){const i=function(t,e,n){const i=e.axis,s=e.id,o=i+"ScaleID",a={min:ft(e.min,Number.NEGATIVE_INFINITY),max:ft(e.max,Number.POSITIVE_INFINITY)};for(const r of n)r.scaleID===s?Ld(r,e,["value","endValue"],a):dd(t,r,o)===s&&Ld(r,e,[i+"Min",i+"Max",i+"Value"],a);return a}(t.scales,e,n);let s=Dd(e,i,"min","suggestedMin");s=Dd(e,i,"max","suggestedMax")||s,s&&Lt(e.handleTickRangeOptions)&&e.handleTickRangeOptions()}function Dd(t,e,n,i){if(pt(e[n])&&!function(t,e,n){return Et(t[e])||Et(t[n])}(t.options,n,i)){const i=t[n]!==e[n];return t[n]=e[n],i}}function Pd(t,e){for(const n of["scaleID","xScaleID","yScaleID"]){const i=dd(e,t,n);i&&!e[i]&&Ed(t,n)&&console.warn(`No scale found with id '${i}' for annotation '${t.id}'`)}}function Ed(t,e){if("scaleID"===e)return!0;const n=e.charAt(0);for(const e of["Min","Max","Value"])if(Et(t[n+e]))return!0;return!1}function Ld(t,e,n,i){for(const s of n){const n=t[s];if(Et(n)){const t=e.parse(n);i.min=Math.min(i.min,t),i.max=Math.max(i.max,t)}}}class Ad extends fs{inRange(t,e,n,i){const{x:s,y:o}=_c({x:t,y:e},this.getCenterPoint(i),Ut(-this.options.rotation));return Ac({x:s,y:o},this.getProps(["x","y","x2","y2"],i),n,this.options)}getCenterPoint(t){return zc(this,t)}draw(t){t.save(),Jc(t,this.getCenterPoint(),this.options.rotation),id(t,this,this.options),t.restore()}get label(){return this.elements&&this.elements[0]}resolveElementProperties(t,e){return fd(t,e)}}Ad.id="boxAnnotation",Ad.defaults={adjustScaleRange:!0,backgroundShadowColor:"transparent",borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderRadius:0,borderShadowColor:"transparent",borderWidth:1,display:!0,init:void 0,hitTolerance:0,label:{backgroundColor:"transparent",borderWidth:0,callout:{display:!1},color:"black",content:null,display:!1,drawTime:void 0,font:{family:void 0,lineHeight:void 0,size:void 0,style:void 0,weight:"bold"},height:void 0,hitTolerance:void 0,opacity:void 0,padding:6,position:"center",rotation:void 0,textAlign:"start",textStrokeColor:void 0,textStrokeWidth:0,width:void 0,xAdjust:0,yAdjust:0,z:void 0},rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,xMax:void 0,xMin:void 0,xScaleID:void 0,yMax:void 0,yMin:void 0,yScaleID:void 0,z:0},Ad.defaultRoutes={borderColor:"color",backgroundColor:"color"},Ad.descriptors={label:{_fallback:!0}};class Id extends fs{inRange(t,e,n,i){return Ic({x:t,y:e},{rect:this.getProps(["x","y","x2","y2"],i),center:this.getCenterPoint(i)},n,{rotation:this.rotation,borderWidth:0,hitTolerance:this.options.hitTolerance})}getCenterPoint(t){return zc(this,t)}draw(t){const e=this.options;e.display&&e.content&&(!function(t,e){const{_centerX:n,_centerY:i,_radius:s,_startAngle:o,_endAngle:a,_counterclockwise:r,options:l}=e;t.save();const c=td(t,l);t.fillStyle=l.backgroundColor,t.beginPath(),t.arc(n,i,s,o,a,r),t.closePath(),t.fill(),c&&t.stroke();t.restore()}(t,this),t.save(),Jc(t,this.getCenterPoint(),this.rotation),sd(t,this,e,this._fitRatio),t.restore())}resolveElementProperties(t,e){const n=function(t,e){return t.getSortedVisibleDatasetMetas().reduce((function(n,i){const s=i.controller;return s instanceof Ti&&function(t,e,n){if(!e.autoHide)return!0;for(let e=0;e<n.length;e++)if(!n[e].hidden&&t.getDataVisibility(e))return!0}(t,e,i.data)&&(!n||s.innerRadius<n.controller.innerRadius)&&s.options.circumference>=90?i:n}),void 0)}(t,e);if(!n)return{};const{controllerMeta:i,point:s,radius:o}=function({chartArea:t},e,n){const{left:i,top:s,right:o,bottom:a}=t,{innerRadius:r,offsetX:l,offsetY:c}=n.controller,d=(i+o)/2+l,h=(s+a)/2+c,u={left:Math.max(d-r,i),right:Math.min(d+r,o),top:Math.max(h-r,s),bottom:Math.min(h+r,a)},g={x:(u.left+u.right)/2,y:(u.top+u.bottom)/2},p=e.spacing+e.borderWidth/2,m=r-p,f=g.y>h,b=function(t,e,n,i){const s=Math.pow(n-t,2),o=Math.pow(i,2),a=-2*e,r=Math.pow(e,2)+s-o,l=Math.pow(a,2)-4*r;if(l<=0)return{_startAngle:0,_endAngle:zt};const c=(-a-Math.sqrt(l))/2,d=(-a+Math.sqrt(l))/2;return{_startAngle:Gt({x:e,y:n},{x:c,y:t}).angle,_endAngle:Gt({x:e,y:n},{x:d,y:t}).angle}}(f?s+p:a-p,d,h,m),y={_centerX:d,_centerY:h,_radius:m,_counterclockwise:f,...b};return{controllerMeta:y,point:g,radius:Math.min(r,Math.min(u.right-u.left,u.bottom-u.top)/2)}}(t,e,n);let a=nd(t.ctx,e);const r=function({width:t,height:e},n){const i=Math.sqrt(Math.pow(t,2)+Math.pow(e,2));return 2*n/i}(a,o);Vc(e,r)&&(a={width:a.width*r,height:a.height*r});const{position:l,xAdjust:c,yAdjust:d}=e,h=qc(s,a,{borderWidth:0,position:l,xAdjust:c,yAdjust:d});return{initProperties:Xc(t,h,e),...h,...i,rotation:e.rotation,_fitRatio:r}}}Id.id="doughnutLabelAnnotation",Id.defaults={autoFit:!0,autoHide:!0,backgroundColor:"transparent",backgroundShadowColor:"transparent",borderColor:"transparent",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderShadowColor:"transparent",borderWidth:0,color:"black",content:null,display:!0,font:{family:void 0,lineHeight:void 0,size:void 0,style:void 0,weight:void 0},height:void 0,hitTolerance:0,init:void 0,opacity:void 0,position:"center",rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,spacing:1,textAlign:"center",textStrokeColor:void 0,textStrokeWidth:0,width:void 0,xAdjust:0,yAdjust:0},Id.defaultRoutes={};class zd extends fs{inRange(t,e,n,i){return Ic({x:t,y:e},{rect:this.getProps(["x","y","x2","y2"],i),center:this.getCenterPoint(i)},n,{rotation:this.rotation,borderWidth:this.options.borderWidth,hitTolerance:this.options.hitTolerance})}getCenterPoint(t){return zc(this,t)}draw(t){const e=this.options,n=!Et(this._visible)||this._visible;e.display&&e.content&&n&&(t.save(),Jc(t,this.getCenterPoint(),this.rotation),rd(t,this),id(t,this,e),sd(t,function({x:t,y:e,width:n,height:i,options:s}){const o=s.borderWidth/2,a=en(s.padding);return{x:t+a.left+o,y:e+a.top+o,width:n-a.left-a.right-s.borderWidth,height:i-a.top-a.bottom-s.borderWidth}}(this),e),t.restore())}resolveElementProperties(t,e){let n;if(jc(e))n=ud(t,e);else{const{centerX:i,centerY:s}=gd(t,e);n={x:i,y:s}}const i=en(e.padding),s=qc(n,nd(t.ctx,e),e,i);return{initProperties:Xc(t,s,e),pointX:n.x,pointY:n.y,...s,rotation:e.rotation}}}zd.id="labelAnnotation",zd.defaults={adjustScaleRange:!0,backgroundColor:"transparent",backgroundShadowColor:"transparent",borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderRadius:0,borderShadowColor:"transparent",borderWidth:0,callout:{borderCapStyle:"butt",borderColor:void 0,borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:1,display:!1,margin:5,position:"auto",side:5,start:"50%"},color:"black",content:null,display:!0,font:{family:void 0,lineHeight:void 0,size:void 0,style:void 0,weight:void 0},height:void 0,hitTolerance:0,init:void 0,opacity:void 0,padding:6,position:"center",rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,textAlign:"center",textStrokeColor:void 0,textStrokeWidth:0,width:void 0,xAdjust:0,xMax:void 0,xMin:void 0,xScaleID:void 0,xValue:void 0,yAdjust:0,yMax:void 0,yMin:void 0,yScaleID:void 0,yValue:void 0,z:0},zd.defaultRoutes={borderColor:"color"};const Od=(t,e,n)=>({x:t.x+n*(e.x-t.x),y:t.y+n*(e.y-t.y)}),Wd=(t,e,n)=>Od(e,n,Math.abs((t-e.y)/(n.y-e.y))).x,Nd=(t,e,n)=>Od(e,n,Math.abs((t-e.x)/(n.x-e.x))).y,Rd=t=>t*t,$d=(t,e,n,i)=>(1-i)*(1-i)*t+2*(1-i)*i*e+i*i*n,Fd=(t,e,n,i)=>({x:$d(t.x,e.x,n.x,i),y:$d(t.y,e.y,n.y,i)}),Bd=(t,e,n,i)=>2*(1-i)*(e-t)+2*i*(n-e),qd=(t,e,n,i)=>-Math.atan2(Bd(t.x,e.x,n.x,i),Bd(t.y,e.y,n.y,i))+.5*It;class Hd extends fs{inRange(t,e,n,i){const s=(this.options.borderWidth+this.options.hitTolerance)/2;if("x"!==n&&"y"!==n){const n={mouseX:t,mouseY:e},{path:o,ctx:a}=this;if(o){td(a,this.options),a.lineWidth+=this.options.hitTolerance;const{chart:s}=this.$context,r=t*s.currentDevicePixelRatio,l=e*s.currentDevicePixelRatio,c=a.isPointInStroke(o,r,l)||jd(this,n,i);return a.restore(),c}return function(t,{mouseX:e,mouseY:n},i=.001,s){const{x:o,y:a,x2:r,y2:l}=t.getProps(["x","y","x2","y2"],s),c=r-o,d=l-a,h=Rd(c)+Rd(d),u=0===h?-1:((e-o)*c+(n-a)*d)/h;let g,p;u<0?(g=o,p=a):u>1?(g=r,p=l):(g=o+u*c,p=a+u*d);return Rd(e-g)+Rd(n-p)<=i}(this,n,Rd(s),i)||jd(this,n,i)}return function(t,{mouseX:e,mouseY:n},i,{hitSize:s,useFinalPosition:o}){const a=((t,e,{x:n,y:i,x2:s,y2:o},a)=>"y"===a?{start:Math.min(i,o),end:Math.max(i,o),value:e}:{start:Math.min(n,s),end:Math.max(n,s),value:t})(e,n,t.getProps(["x","y","x2","y2"],o),i);return Ec(a,s)||jd(t,{mouseX:e,mouseY:n},o,i)}(this,{mouseX:t,mouseY:e},n,{hitSize:s,useFinalPosition:i})}getCenterPoint(t){return zc(this,t)}draw(t){const{x:e,y:n,x2:i,y2:s,cp:o,options:a}=this;if(t.save(),!td(t,a))return t.restore();ed(t,a);const r=Math.sqrt(Math.pow(i-e,2)+Math.pow(s-n,2));if(a.curve&&o)return function(t,e,n,i){const{x:s,y:o,x2:a,y2:r,options:l}=e,{startOpts:c,endOpts:d,startAdjust:h,endAdjust:u}=Qd(e),g={x:s,y:o},p={x:a,y:r},m=qd(g,n,p,0),f=qd(g,n,p,1)-It,b=Fd(g,n,p,h/i),y=Fd(g,n,p,1-u/i),x=new Path2D;t.beginPath(),x.moveTo(b.x,b.y),x.quadraticCurveTo(n.x,n.y,y.x,y.y),t.shadowColor=l.borderShadowColor,t.stroke(x),e.path=x,e.ctx=t,Zd(t,b,{angle:m,adjust:h},c),Zd(t,y,{angle:f,adjust:u},d)}(t,this,o,r),t.restore();const{startOpts:l,endOpts:c,startAdjust:d,endAdjust:h}=Qd(this),u=Math.atan2(s-n,i-e);t.translate(e,n),t.rotate(u),t.beginPath(),t.moveTo(0+d,0),t.lineTo(r-h,0),t.shadowColor=a.borderShadowColor,t.stroke(),Kd(t,0,d,l),Kd(t,r,-h,c),t.restore()}get label(){return this.elements&&this.elements[0]}resolveElementProperties(t,e){const n=md(t,e),{x:i,y:s,x2:o,y2:a}=n,r=function({x:t,y:e,x2:n,y2:i},{top:s,right:o,bottom:a,left:r}){return!(t<r&&n<r||t>o&&n>o||e<s&&i<s||e>a&&i>a)}(n,t.chartArea),l=r?function(t,e,n){const{x:i,y:s}=Yd(t,e,n),{x:o,y:a}=Yd(e,t,n);return{x:i,y:s,x2:o,y2:a,width:Math.abs(o-i),height:Math.abs(a-s)}}({x:i,y:s},{x:o,y:a},t.chartArea):{x:i,y:s,x2:o,y2:a,width:Math.abs(o-i),height:Math.abs(a-s)};if(l.centerX=(o+i)/2,l.centerY=(a+s)/2,l.initProperties=Xc(t,l,e),e.curve){const t={x:l.x,y:l.y},n={x:l.x2,y:l.y2};l.cp=function(t,e,n){const{x:i,y:s,x2:o,y2:a,centerX:r,centerY:l}=t,c=Math.atan2(a-s,o-i),d=Hc(e.controlPoint,0);return _c({x:r+Bc(n,d.x,!1),y:l+Bc(n,d.y,!1)},{x:r,y:l},c)}(l,e,Kt(t,n))}const c=function(t,e,n){const i=n.borderWidth,s=en(n.padding),o=nd(t.ctx,n),a=o.width+s.width+i,r=o.height+s.height+i;return function(t,e,n,i){const{width:s,height:o,padding:a}=n,{xAdjust:r,yAdjust:l}=e,c={x:t.x,y:t.y},d={x:t.x2,y:t.y2},h="auto"===e.rotation?function(t){const{x:e,y:n,x2:i,y2:s}=t,o=Math.atan2(s-n,i-e);return o>It/2?o-It:o<It/-2?o+It:o}(t):Ut(e.rotation),u=function(t,e,n){const i=Math.cos(n),s=Math.sin(n);return{w:Math.abs(t*i)+Math.abs(e*s),h:Math.abs(t*s)+Math.abs(e*i)}}(s,o,h),g=function(t,e,n,i){let s;const o=function(t,e){const{x:n,x2:i,y:s,y2:o}=t,a=Math.min(s,o)-e.top,r=Math.min(n,i)-e.left,l=e.bottom-Math.max(s,o),c=e.right-Math.max(n,i);return{x:Math.min(r,c),y:Math.min(a,l),dx:r<=c?1:-1,dy:a<=l?1:-1}}(t,i);s="start"===e.position?Ud({w:t.x2-t.x,h:t.y2-t.y},n,e,o):"end"===e.position?1-Ud({w:t.x-t.x2,h:t.y-t.y2},n,e,o):Fc(1,e.position);return s}(t,e,{labelSize:u,padding:a},i),p=t.cp?Fd(c,t.cp,d,g):Od(c,d,g),m={size:u.w,min:i.left,max:i.right,padding:a.left},f={size:u.h,min:i.top,max:i.bottom,padding:a.top},b=Xd(p.x,m)+r,y=Xd(p.y,f)+l;return{x:b-s/2,y:y-o/2,x2:b+s/2,y2:y+o/2,centerX:b,centerY:y,pointX:p.x,pointY:p.y,width:s,height:o,rotation:Xt(h)}}(e,n,{width:a,height:r,padding:s},t.chartArea)}(t,l,e.label);return c._visible=r,l.elements=[{type:"label",optionScope:"label",properties:c,initProperties:l.initProperties}],l}}Hd.id="lineAnnotation";const Vd={backgroundColor:void 0,backgroundShadowColor:void 0,borderColor:void 0,borderDash:void 0,borderDashOffset:void 0,borderShadowColor:void 0,borderWidth:void 0,display:void 0,fill:void 0,length:void 0,shadowBlur:void 0,shadowOffsetX:void 0,shadowOffsetY:void 0,width:void 0};function Yd({x:t,y:e},n,{top:i,right:s,bottom:o,left:a}){return t<a&&(e=Nd(a,{x:t,y:e},n),t=a),t>s&&(e=Nd(s,{x:t,y:e},n),t=s),e<i&&(t=Wd(i,{x:t,y:e},n),e=i),e>o&&(t=Wd(o,{x:t,y:e},n),e=o),{x:t,y:e}}function jd(t,{mouseX:e,mouseY:n},i,s){const o=t.label;return o.options.display&&o.inRange(e,n,s,i)}function Ud(t,e,n,i){const{labelSize:s,padding:o}=e,a=t.w*i.dx,r=t.h*i.dy,l=a>0&&(s.w/2+o.left-i.x)/a,c=r>0&&(s.h/2+o.top-i.y)/r;return Pc(Math.max(l,c),0,.25)}function Xd(t,e){const{size:n,min:i,max:s,padding:o}=e,a=n/2;return n>s-i?(s+i)/2:(i>=t-o-a&&(t=i+o+a),s<=t+o+a&&(t=s-o-a),t)}function Qd(t){const e=t.options,n=e.arrowHeads&&e.arrowHeads.start,i=e.arrowHeads&&e.arrowHeads.end;return{startOpts:n,endOpts:i,startAdjust:Gd(t,n),endAdjust:Gd(t,i)}}function Gd(t,e){if(!e||!e.display)return 0;const{length:n,width:i}=e,s=t.options.borderWidth/2,o={x:n,y:i+s},a={x:0,y:s};return Math.abs(Wd(0,o,a))}function Kd(t,e,n,i){if(!i||!i.display)return;const{length:s,width:o,fill:a,backgroundColor:r,borderColor:l}=i,c=Math.abs(e-s)+n;t.beginPath(),ed(t,i),td(t,i),t.moveTo(c,-o),t.lineTo(e+n,0),t.lineTo(c,o),!0===a?(t.fillStyle=r||l,t.closePath(),t.fill(),t.shadowColor="transparent"):t.shadowColor=i.borderShadowColor,t.stroke()}function Zd(t,{x:e,y:n},{angle:i,adjust:s},o){o&&o.display&&(t.save(),t.translate(e,n),t.rotate(i),Kd(t,0,-s,o),t.restore())}Hd.defaults={adjustScaleRange:!0,arrowHeads:{display:!1,end:Object.assign({},Vd),fill:!1,length:12,start:Object.assign({},Vd),width:6},borderDash:[],borderDashOffset:0,borderShadowColor:"transparent",borderWidth:2,curve:!1,controlPoint:{y:"-50%"},display:!0,endValue:void 0,init:void 0,hitTolerance:0,label:{backgroundColor:"rgba(0,0,0,0.8)",backgroundShadowColor:"transparent",borderCapStyle:"butt",borderColor:"black",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderRadius:6,borderShadowColor:"transparent",borderWidth:0,callout:Object.assign({},zd.defaults.callout),color:"#fff",content:null,display:!1,drawTime:void 0,font:{family:void 0,lineHeight:void 0,size:void 0,style:void 0,weight:"bold"},height:void 0,hitTolerance:void 0,opacity:void 0,padding:6,position:"center",rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,textAlign:"center",textStrokeColor:void 0,textStrokeWidth:0,width:void 0,xAdjust:0,yAdjust:0,z:void 0},scaleID:void 0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,value:void 0,xMax:void 0,xMin:void 0,xScaleID:void 0,yMax:void 0,yMin:void 0,yScaleID:void 0,z:0},Hd.descriptors={arrowHeads:{start:{_fallback:!0},end:{_fallback:!0},_fallback:!0}},Hd.defaultRoutes={borderColor:"color"};class Jd extends fs{inRange(t,e,n,i){const s=this.options.rotation,o=(this.options.borderWidth+this.options.hitTolerance)/2;if("x"!==n&&"y"!==n)return function(t,e,n,i){const{width:s,height:o,centerX:a,centerY:r}=e,l=s/2,c=o/2;if(l<=0||c<=0)return!1;const d=Ut(n||0),h=Math.cos(d),u=Math.sin(d),g=Math.pow(h*(t.x-a)+u*(t.y-r),2),p=Math.pow(u*(t.x-a)-h*(t.y-r),2);return g/Math.pow(l+i,2)+p/Math.pow(c+i,2)<=1.0001}({x:t,y:e},this.getProps(["width","height","centerX","centerY"],i),s,o);const{x:a,y:r,x2:l,y2:c}=this.getProps(["x","y","x2","y2"],i),d="y"===n?{start:r,end:c}:{start:a,end:l},h=_c({x:t,y:e},this.getCenterPoint(i),Ut(-s));return h[n]>=d.start-o-Dc&&h[n]<=d.end+o+Dc}getCenterPoint(t){return zc(this,t)}draw(t){const{width:e,height:n,centerX:i,centerY:s,options:o}=this;t.save(),Jc(t,this.getCenterPoint(),o.rotation),ed(t,this.options),t.beginPath(),t.fillStyle=o.backgroundColor;const a=td(t,o);t.ellipse(i,s,n/2,e/2,It/2,0,2*It),t.fill(),a&&(t.shadowColor=o.borderShadowColor,t.stroke()),t.restore()}get label(){return this.elements&&this.elements[0]}resolveElementProperties(t,e){return fd(t,e)}}Jd.id="ellipseAnnotation",Jd.defaults={adjustScaleRange:!0,backgroundShadowColor:"transparent",borderDash:[],borderDashOffset:0,borderShadowColor:"transparent",borderWidth:1,display:!0,hitTolerance:0,init:void 0,label:Object.assign({},Ad.defaults.label),rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,xMax:void 0,xMin:void 0,xScaleID:void 0,yMax:void 0,yMin:void 0,yScaleID:void 0,z:0},Jd.defaultRoutes={borderColor:"color",backgroundColor:"color"},Jd.descriptors={label:{_fallback:!0}};class th extends fs{inRange(t,e,n,i){const{x:s,y:o,x2:a,y2:r,width:l}=this.getProps(["x","y","x2","y2","width"],i),c=(this.options.borderWidth+this.options.hitTolerance)/2;if("x"!==n&&"y"!==n)return function(t,e,n,i){return!(!t||!e||n<=0)&&Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)<=Math.pow(n+i,2)}({x:t,y:e},this.getCenterPoint(i),l/2,c);return Ec("y"===n?{start:o,end:r,value:e}:{start:s,end:a,value:t},c)}getCenterPoint(t){return zc(this,t)}draw(t){const e=this.options,n=e.borderWidth;if(e.radius<.1)return;t.save(),t.fillStyle=e.backgroundColor,ed(t,e);const i=td(t,e);od(t,this,this.centerX,this.centerY),i&&!Zc(e.pointStyle)&&(t.shadowColor=e.borderShadowColor,t.stroke()),t.restore(),e.borderWidth=n}resolveElementProperties(t,e){const n=pd(t,e);return n.initProperties=Xc(t,n,e),n}}th.id="pointAnnotation",th.defaults={adjustScaleRange:!0,backgroundShadowColor:"transparent",borderDash:[],borderDashOffset:0,borderShadowColor:"transparent",borderWidth:1,display:!0,hitTolerance:0,init:void 0,pointStyle:"circle",radius:10,rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,xAdjust:0,xMax:void 0,xMin:void 0,xScaleID:void 0,xValue:void 0,yAdjust:0,yMax:void 0,yMin:void 0,yScaleID:void 0,yValue:void 0,z:0},th.defaultRoutes={borderColor:"color",backgroundColor:"color"};class eh extends fs{inRange(t,e,n,i){if("x"!==n&&"y"!==n)return this.options.radius>=.1&&this.elements.length>1&&function(t,e,n,i){let s=!1,o=t[t.length-1].getProps(["bX","bY"],i);for(const a of t){const t=a.getProps(["bX","bY"],i);t.bY>n!=o.bY>n&&e<(o.bX-t.bX)*(n-t.bY)/(o.bY-t.bY)+t.bX&&(s=!s),o=t}return s}(this.elements,t,e,i);const s=_c({x:t,y:e},this.getCenterPoint(i),Ut(-this.options.rotation)),o=this.elements.map((t=>"y"===n?t.bY:t.bX)),a=Math.min(...o),r=Math.max(...o);return s[n]>=a&&s[n]<=r}getCenterPoint(t){return zc(this,t)}draw(t){const{elements:e,options:n}=this;t.save(),t.beginPath(),t.fillStyle=n.backgroundColor,ed(t,n);const i=td(t,n);let s=!0;for(const n of e)s?(t.moveTo(n.x,n.y),s=!1):t.lineTo(n.x,n.y);t.closePath(),t.fill(),i&&(t.shadowColor=n.borderShadowColor,t.stroke()),t.restore()}resolveElementProperties(t,e){const n=pd(t,e),{sides:i,rotation:s}=e,o=[],a=2*It/i;let r=s*Nt;for(let s=0;s<i;s++,r+=a){const i=nh(n,e,r);i.initProperties=Xc(t,n,e),o.push(i)}return n.elements=o,n}}function nh({centerX:t,centerY:e},{radius:n,borderWidth:i,hitTolerance:s},o){const a=(i+s)/2,r=Math.sin(o),l=Math.cos(o),c={x:t+r*n,y:e-l*n};return{type:"point",optionScope:"point",properties:{x:c.x,y:c.y,centerX:c.x,centerY:c.y,bX:t+r*(n+a),bY:e-l*(n+a)}}}eh.id="polygonAnnotation",eh.defaults={adjustScaleRange:!0,backgroundShadowColor:"transparent",borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderShadowColor:"transparent",borderWidth:1,display:!0,hitTolerance:0,init:void 0,point:{radius:0},radius:10,rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,sides:3,xAdjust:0,xMax:void 0,xMin:void 0,xScaleID:void 0,xValue:void 0,yAdjust:0,yMax:void 0,yMin:void 0,yScaleID:void 0,yValue:void 0,z:0},eh.defaultRoutes={borderColor:"color",backgroundColor:"color"};const ih={box:Ad,doughnutLabel:Id,ellipse:Jd,label:zd,line:Hd,point:th,polygon:eh};Object.keys(ih).forEach((t=>{Ie.describe(`elements.${ih[t].id}`,{_fallback:"plugins.annotation.common"})}));const sh={update:Object.assign},oh=wd.concat(Cd),ah=(t,e)=>gt(e)?ph(t,e):t,rh=t=>"color"===t||"font"===t;function lh(t="line"){return ih[t]?t:(console.warn(`Unknown annotation type: '${t}', defaulting to 'line'`),"line")}function ch(t,e,n,i){const s=function(t,e,n){if("reset"===n||"none"===n||"resize"===n)return sh;return new oi(t,e)}(t,n.animations,i),o=e.annotations,a=function(t,e){const n=e.length,i=t.length;if(i<n){const e=n-i;t.splice(i,0,...new Array(e))}else i>n&&t.splice(n,i-n);return t}(e.elements,o);for(let e=0;e<o.length;e++){const n=o[e],i=uh(a,e,n.type),r=n.setContext(mh(t,i,a,n)),l=i.resolveElementProperties(t,r);l.skip=dh(l),"elements"in l&&(hh(i,l.elements,r,s),delete l.elements),Et(i.x)||Object.assign(i,l),Object.assign(i,l.initProperties),l.options=gh(r),s.update(i,l)}}function dh(t){return isNaN(t.x)||isNaN(t.y)}function hh(t,e,n,i){const s=t.elements||(t.elements=[]);s.length=e.length;for(let t=0;t<e.length;t++){const o=e[t],a=o.properties,r=uh(s,t,o.type,o.initProperties),l=n[o.optionScope].override(o);a.options=gh(l),i.update(r,a)}}function uh(t,e,n,i){const s=ih[lh(n)];let o=t[e];return o&&o instanceof s||(o=t[e]=new s,Object.assign(o,i)),o}function gh(t){const e=ih[lh(t.type)],n={};n.id=t.id,n.type=t.type,n.drawTime=t.drawTime,Object.assign(n,ph(t,e.defaults),ph(t,e.defaultRoutes));for(const e of oh)n[e]=t[e];return n}function ph(t,e){const n={};for(const i of Object.keys(e)){const s=e[i],o=t[i];rh(i)&&ut(o)?n[i]=o.map((t=>ah(t,s))):n[i]=ah(o,s)}return n}function mh(t,e,n,i){return e.$context||(e.$context=Object.assign(Object.create(t.getContext()),{element:e,get elements(){return n.filter((t=>t&&t.options))},id:i.id,type:"annotation"}))}const fh=new Map,bh=t=>"doughnutLabel"!==t.type,yh=wd.concat(Cd);var xh={id:"annotation",version:"3.1.0",beforeRegister(){!function(t,e,n,i=!0){const s=n.split(".");let o=0;for(const a of e.split(".")){const r=s[o++];if(parseInt(a,10)<parseInt(r,10))break;if(Tc(r,a)){if(i)throw new Error(`${t} v${n} is not supported. v${e} or newer is required.`);return!1}}}("chart.js","4.0",no.version)},afterRegister(){no.register(ih)},afterUnregister(){no.unregister(ih)},beforeInit(t){fh.set(t,{annotations:[],elements:[],visibleElements:[],listeners:{},listened:!1,moveListened:!1,hooks:{},hooked:!1,hovered:[]})},beforeUpdate(t,e,n){const i=fh.get(t).annotations=[];let s=n.annotations;gt(s)?Object.keys(s).forEach((t=>{const e=s[t];gt(e)&&(e.id=t,i.push(e))})):ut(s)&&i.push(...s),function(t,e){for(const n of t)Pd(n,e)}(i.filter(bh),t.scales)},afterDataLimits(t,e){const n=fh.get(t);Td(t,e.scale,n.annotations.filter(bh).filter((t=>t.display&&t.adjustScaleRange)))},afterUpdate(t,e,n){const i=fh.get(t);!function(t,e,n){e.listened=Qc(n,wd,e.listeners),e.moveListened=!1,vd.forEach((t=>{Lt(n[t])&&(e.moveListened=!0)})),e.listened&&e.moveListened||e.annotations.forEach((t=>{!e.listened&&Lt(t.click)&&(e.listened=!0),e.moveListened||vd.forEach((n=>{Lt(t[n])&&(e.listened=!0,e.moveListened=!0)}))}))}(0,i,n),ch(t,i,n,e.mode),i.visibleElements=i.elements.filter((t=>!t.skip&&t.options.display)),function(t,e,n){const i=e.visibleElements;e.hooked=Qc(n,Cd,e.hooks),e.hooked||i.forEach((t=>{e.hooked||Cd.forEach((n=>{Lt(t.options[n])&&(e.hooked=!0)}))}))}(0,i,n)},beforeDatasetsDraw(t,e,n){vh(t,"beforeDatasetsDraw",n.clip)},afterDatasetsDraw(t,e,n){vh(t,"afterDatasetsDraw",n.clip)},beforeDatasetDraw(t,e,n){vh(t,e.index,n.clip)},beforeDraw(t,e,n){vh(t,"beforeDraw",n.clip)},afterDraw(t,e,n){vh(t,"afterDraw",n.clip)},beforeEvent(t,e,n){kd(fh.get(t),e.event,n)&&(e.changed=!0)},afterDestroy(t){fh.delete(t)},getAnnotations(t){const e=fh.get(t);return e?e.elements:[]},_getAnnotationElementsAtEventForMode:(t,e,n)=>Mc(t,e,n),defaults:{animations:{numbers:{properties:["x","y","x2","y2","width","height","centerX","centerY","pointX","pointY","radius"],type:"number"},colors:{properties:["backgroundColor","borderColor"],type:"color"}},clip:!0,interaction:{mode:void 0,axis:void 0,intersect:void 0},common:{drawTime:"afterDatasetsDraw",init:!1,label:{}}},descriptors:{_indexable:!1,_scriptable:t=>!yh.includes(t)&&"init"!==t,annotations:{_allKeys:!1,_fallback:(t,e)=>`elements.${ih[lh(e.type)].id}`},interaction:{_fallback:!0},common:{label:{_indexable:rh,_fallback:!0},_indexable:rh}},additionalOptionScopes:[""]};function vh(t,e,n){const{ctx:i,chartArea:s}=t,o=fh.get(t);n&&Be(i,s);const a=function(t,e){const n=[];for(const i of t)if(i.options.drawTime===e&&n.push({element:i,main:!0}),i.elements&&i.elements.length)for(const t of i.elements)t.options.display&&t.options.drawTime===e&&n.push({element:t});return n}(o.visibleElements,e).sort(((t,e)=>t.element.options.z-e.element.options.z));for(const t of a)wh(i,s,o,t);n&&qe(i)}function wh(t,e,n,i){const s=i.element;i.main?(_d(n,s,"beforeDraw"),s.draw(t,e),_d(n,s,"afterDraw")):s.draw(t,e)}function kh(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Sh={exports:{}};
|
|
33
|
+
const Dc={modes:{point:(t,e)=>Ec(t,e,{intersect:!0}),nearest:(t,e,n)=>function(t,e,n){let i=Number.POSITIVE_INFINITY;return Ec(t,e,n).reduce(((t,s)=>{const o=s.getCenterPoint(),a=function(t,e,n){if("x"===n)return{x:t.x,y:e.y};if("y"===n)return{x:e.x,y:t.y};return e}(e,o,n.axis),r=ne(e,a);return r<i?(t=[s],i=r):r===i&&t.push(s),t}),[]).sort(((t,e)=>t._index-e._index)).slice(0,1)}(t,e,n),x:(t,e,n)=>Ec(t,e,{intersect:n.intersect,axis:"x"}),y:(t,e,n)=>Ec(t,e,{intersect:n.intersect,axis:"y"})}};function Pc(t,e,n){return(Dc.modes[n.mode]||Dc.modes.nearest)(t,e,n)}function Ec(t,e,n){return t.filter((t=>n.intersect?t.inRange(e.x,e.y):function(t,e,n){return"x"!==n&&"y"!==n?t.inRange(e.x,e.y,"x",!0)||t.inRange(e.x,e.y,"y",!0):t.inRange(e.x,e.y,n,!0)}(t,e,n.axis)))}function Lc(t,e,n){const i=Math.cos(n),s=Math.sin(n),o=e.x,a=e.y;return{x:o+i*(t.x-o)-s*(t.y-a),y:a+s*(t.x-o)+i*(t.y-a)}}const Ac=(t,e)=>e>t||t.length>e.length&&t.slice(0,e.length)===e,Ic=.001,zc=(t,e,n)=>Math.min(n,Math.max(e,t)),Oc=(t,e)=>t.value>=t.start-e&&t.value<=t.end+e;function Wc(t,e,n){for(const i of Object.keys(t))t[i]=zc(t[i],e,n);return t}function Nc(t,{x:e,y:n,x2:i,y2:s},o,{borderWidth:a,hitTolerance:r}){const l=(a+r)/2,c=t.x>=e-l-Ic&&t.x<=i+l+Ic,d=t.y>=n-l-Ic&&t.y<=s+l+Ic;return"x"===o?c:("y"===o||c)&&d}function $c(t,{rect:e,center:n},i,{rotation:s,borderWidth:o,hitTolerance:a}){return Nc(Lc(t,n,Zt(-s)),e,i,{borderWidth:o,hitTolerance:a})}function Rc(t,e){const{centerX:n,centerY:i}=t.getProps(["centerX","centerY"],e);return{x:n,y:i}}const Fc=t=>"string"==typeof t&&t.endsWith("%"),Bc=t=>parseFloat(t)/100,qc=t=>zc(Bc(t),0,1),Hc=(t,e)=>({x:t,y:e,x2:t,y2:e,width:0,height:0}),Vc={box:t=>Hc(t.centerX,t.centerY),doughnutLabel:t=>Hc(t.centerX,t.centerY),ellipse:t=>({centerX:t.centerX,centerY:t.centerX,radius:0,width:0,height:0}),label:t=>Hc(t.centerX,t.centerY),line:t=>Hc(t.x,t.y),point:t=>({centerX:t.centerX,centerY:t.centerY,radius:0,width:0,height:0}),polygon:t=>Hc(t.centerX,t.centerY)};function jc(t,e){return"start"===e?0:"end"===e?t:Fc(e)?qc(e)*t:t/2}function Yc(t,e,n=!0){return"number"==typeof e?e:Fc(e)?(n?qc(e):Bc(e))*t:t}function Uc(t,e,{borderWidth:n,position:i,xAdjust:s,yAdjust:o},a){const r=yt(a),l=e.width+(r?a.width:0)+n,c=e.height+(r?a.height:0)+n,d=Xc(i),h=Zc(t.x,l,s,d.x),u=Zc(t.y,c,o,d.y);return{x:h,y:u,x2:h+l,y2:u+c,width:l,height:c,centerX:h+l/2,centerY:u+c/2}}function Xc(t,e="center"){return yt(t)?{x:wt(t.x,e),y:wt(t.y,e)}:{x:t=wt(t,e),y:t}}const Qc=(t,e)=>t&&t.autoFit&&e<1;function Gc(t,e){const n=t.font,i=bt(n)?n:[n];return Qc(t,e)?i.map((function(t){const n=ln(t);return n.size=Math.floor(t.size*e),n.lineHeight=t.lineHeight,ln(n)})):i.map((t=>ln(t)))}function Kc(t){return t&&(Ot(t.xValue)||Ot(t.yValue))}function Zc(t,e,n=0,i){return t-jc(e,i)+n}function Jc(t,e,n){const i=n.init;if(i)return!0===i?ed(e,n):function(t,e,n){const i=St(n.init,[{chart:t,properties:e,options:n}]);if(!0===i)return ed(e,n);if(yt(i))return i}(t,e,n)}function td(t,e,n){let i=!1;return e.forEach((e=>{Wt(t[e])?(i=!0,n[e]=t[e]):Ot(n[e])&&delete n[e]})),i}function ed(t,e){const n=e.type||"line";return Vc[n](t)}const nd=new Map;function id(t){if(t&&"object"==typeof t){const e=t.toString();return"[object HTMLImageElement]"===e||"[object HTMLCanvasElement]"===e}}function sd(t,{x:e,y:n},i){i&&(t.translate(e,n),t.rotate(Zt(i)),t.translate(-e,-n))}function od(t,e){if(e&&e.borderWidth)return t.lineCap=e.borderCapStyle||"butt",t.setLineDash(e.borderDash),t.lineDashOffset=e.borderDashOffset,t.lineJoin=e.borderJoinStyle||"miter",t.lineWidth=e.borderWidth,t.strokeStyle=e.borderColor,!0}function ad(t,e){t.shadowColor=e.backgroundShadowColor,t.shadowBlur=e.shadowBlur,t.shadowOffsetX=e.shadowOffsetX,t.shadowOffsetY=e.shadowOffsetY}function rd(t,e){const n=e.content;if(id(n)){return{width:Yc(n.width,e.width),height:Yc(n.height,e.height)}}const i=Gc(e),s=e.textStrokeWidth,o=bt(n)?n:[n],a=o.join()+(t=>t.reduce((function(t,e){return t+e.string}),""))(i)+s+(t._measureText?"-spriting":"");return nd.has(a)||nd.set(a,function(t,e,n,i){t.save();const s=e.length;let o=0,a=i;for(let r=0;r<s;r++){const s=n[Math.min(r,n.length-1)];t.font=s.string;const l=e[r];o=Math.max(o,t.measureText(l).width+i),a+=s.lineHeight}return t.restore(),{width:o,height:a}}(t,o,i,s)),nd.get(a)}function ld(t,e,n){const{x:i,y:s,width:o,height:a}=e;t.save(),ad(t,n);const r=od(t,n);t.fillStyle=n.backgroundColor,t.beginPath(),Je(t,{x:i,y:s,w:o,h:a,radius:Wc(an(n.borderRadius),0,Math.min(o,a)/2)}),t.closePath(),t.fill(),r&&(t.shadowColor=n.borderShadowColor,t.stroke()),t.restore()}function cd(t,e,n,i){const s=n.content;if(id(s))return t.save(),t.globalAlpha=function(t,e){const n=Gt(t)?t:e;return Gt(n)?zc(n,0,1):1}(n.opacity,s.style.opacity),t.drawImage(s,e.x,e.y,e.width,e.height),void t.restore();const o=bt(s)?s:[s],a=Gc(n,i),r=n.color,l=bt(r)?r:[r],c=function(t,e){const{x:n,width:i}=t,s=e.textAlign;return"center"===s?n+i/2:"end"===s||"right"===s?n+i:n}(e,n),d=e.y+n.textStrokeWidth/2;t.save(),t.textBaseline="middle",t.textAlign=n.textAlign,function(t,e){if(e.textStrokeWidth>0)return t.lineJoin="round",t.miterLimit=2,t.lineWidth=e.textStrokeWidth,t.strokeStyle=e.textStrokeColor,!0}(t,n)&&function(t,{x:e,y:n},i,s){t.beginPath();let o=0;i.forEach((function(i,a){const r=s[Math.min(a,s.length-1)],l=r.lineHeight;t.font=r.string,t.strokeText(i,e,n+l/2+o),o+=l})),t.stroke()}(t,{x:c,y:d},o,a),function(t,{x:e,y:n},i,{fonts:s,colors:o}){let a=0;i.forEach((function(i,r){const l=o[Math.min(r,o.length-1)],c=s[Math.min(r,s.length-1)],d=c.lineHeight;t.beginPath(),t.font=c.string,t.fillStyle=l,t.fillText(i,e,n+d/2+a),a+=d,t.fill()}))}(t,{x:c,y:d},o,{fonts:a,colors:l}),t.restore()}function dd(t,e,n,i){const{radius:s,options:o}=e,a=o.pointStyle,r=o.rotation;let l=(r||0)*qt;if(id(a))return t.save(),t.translate(n,i),t.rotate(l),t.drawImage(a,-a.width/2,-a.height/2,a.width,a.height),void t.restore();(t=>isNaN(t)||t<=0)(s)||function(t,{x:e,y:n,radius:i,rotation:s,style:o,rad:a}){let r,l,c,d;switch(t.beginPath(),o){default:t.arc(e,n,i,0,Rt),t.closePath();break;case"triangle":t.moveTo(e+Math.sin(a)*i,n-Math.cos(a)*i),a+=jt,t.lineTo(e+Math.sin(a)*i,n-Math.cos(a)*i),a+=jt,t.lineTo(e+Math.sin(a)*i,n-Math.cos(a)*i),t.closePath();break;case"rectRounded":d=.516*i,c=i-d,r=Math.cos(a+Vt)*c,l=Math.sin(a+Vt)*c,t.arc(e-r,n-l,d,a-$t,a-Ht),t.arc(e+l,n-r,d,a-Ht,a),t.arc(e+r,n+l,d,a,a+Ht),t.arc(e-l,n+r,d,a+Ht,a+$t),t.closePath();break;case"rect":if(!s){c=Math.SQRT1_2*i,t.rect(e-c,n-c,2*c,2*c);break}a+=Vt;case"rectRot":r=Math.cos(a)*i,l=Math.sin(a)*i,t.moveTo(e-r,n-l),t.lineTo(e+l,n-r),t.lineTo(e+r,n+l),t.lineTo(e-l,n+r),t.closePath();break;case"crossRot":a+=Vt;case"cross":r=Math.cos(a)*i,l=Math.sin(a)*i,t.moveTo(e-r,n-l),t.lineTo(e+r,n+l),t.moveTo(e+l,n-r),t.lineTo(e-l,n+r);break;case"star":r=Math.cos(a)*i,l=Math.sin(a)*i,t.moveTo(e-r,n-l),t.lineTo(e+r,n+l),t.moveTo(e+l,n-r),t.lineTo(e-l,n+r),a+=Vt,r=Math.cos(a)*i,l=Math.sin(a)*i,t.moveTo(e-r,n-l),t.lineTo(e+r,n+l),t.moveTo(e+l,n-r),t.lineTo(e-l,n+r);break;case"line":r=Math.cos(a)*i,l=Math.sin(a)*i,t.moveTo(e-r,n-l),t.lineTo(e+r,n+l);break;case"dash":t.moveTo(e,n),t.lineTo(e+Math.cos(a)*i,n+Math.sin(a)*i)}t.fill()}(t,{x:n,y:i,radius:s,rotation:r,style:a,rad:l})}const hd=["left","bottom","top","right"];function ud(t,e){const{pointX:n,pointY:i,options:s}=e,o=s.callout,a=o&&o.display&&function(t,e){const n=e.position;if(hd.includes(n))return n;return function(t,e){const{x:n,y:i,x2:s,y2:o,width:a,height:r,pointX:l,pointY:c,centerX:d,centerY:h,rotation:u}=t,g={x:d,y:h},p=e.start,m=Yc(a,p),f=Yc(r,p),b=[n,n+m,n+m,s],y=[i+f,o,i,o],x=[];for(let t=0;t<4;t++){const e=Lc({x:b[t],y:y[t]},g,Zt(u));x.push({position:hd[t],distance:ne(e,{x:l,y:c})})}return x.sort(((t,e)=>t.distance-e.distance))[0].position}(t,e)}(e,o);if(!a||function(t,e,n){const{pointX:i,pointY:s}=t,o=e.margin;let a=i,r=s;"left"===n?a+=o:"right"===n?a-=o:"top"===n?r+=o:"bottom"===n&&(r-=o);return t.inRange(a,r)}(e,o,a))return;t.save(),t.beginPath();if(!od(t,o))return t.restore();const{separatorStart:r,separatorEnd:l}=function(t,e){const{x:n,y:i,x2:s,y2:o}=t,a=function(t,e){const{width:n,height:i,options:s}=t,o=s.callout.margin+s.borderWidth/2;if("right"===e)return n+o;if("bottom"===e)return i+o;return-o}(t,e);let r,l;"left"===e||"right"===e?(r={x:n+a,y:i},l={x:r.x,y:o}):(r={x:n,y:i+a},l={x:s,y:r.y});return{separatorStart:r,separatorEnd:l}}(e,a),{sideStart:c,sideEnd:d}=function(t,e,n){const{y:i,width:s,height:o,options:a}=t,r=a.callout.start,l=function(t,e){const n=e.side;if("left"===t||"top"===t)return-n;return n}(e,a.callout);let c,d;"left"===e||"right"===e?(c={x:n.x,y:i+Yc(o,r)},d={x:c.x+l,y:c.y}):(c={x:n.x+Yc(s,r),y:n.y},d={x:c.x,y:c.y+l});return{sideStart:c,sideEnd:d}}(e,a,r);(o.margin>0||0===s.borderWidth)&&(t.moveTo(r.x,r.y),t.lineTo(l.x,l.y)),t.moveTo(c.x,c.y),t.lineTo(d.x,d.y);const h=Lc({x:n,y:i},e.getCenterPoint(),Zt(-e.rotation));t.lineTo(h.x,h.y),t.stroke(),t.restore()}const gd={xScaleID:{min:"xMin",max:"xMax",start:"left",end:"right",startProp:"x",endProp:"x2"},yScaleID:{min:"yMin",max:"yMax",start:"bottom",end:"top",startProp:"y",endProp:"y2"}};function pd(t,e,n){return xt(e="number"==typeof e?e:t.parse(e))?t.getPixelForValue(e):n}function md(t,e,n){const i=e[n];if(i||"scaleID"===n)return i;const s=n.charAt(0),o=Object.values(t).filter((t=>t.axis&&t.axis===s));return o.length?o[0].id:s}function fd(t,e){if(t){const n=t.options.reverse;return{start:pd(t,e.min,n?e.end:e.start),end:pd(t,e.max,n?e.start:e.end)}}}function bd(t,e){const{chartArea:n,scales:i}=t,s=i[md(i,e,"xScaleID")],o=i[md(i,e,"yScaleID")];let a=n.width/2,r=n.height/2;return s&&(a=pd(s,e.xValue,s.left+s.width/2)),o&&(r=pd(o,e.yValue,o.top+o.height/2)),{x:a,y:r}}function yd(t,e){const n=t.scales,i=n[md(n,e,"xScaleID")],s=n[md(n,e,"yScaleID")];if(!i&&!s)return{};let{left:o,right:a}=i||t.chartArea,{top:r,bottom:l}=s||t.chartArea;const c=kd(i,{min:e.xMin,max:e.xMax,start:o,end:a});o=c.start,a=c.end;const d=kd(s,{min:e.yMin,max:e.yMax,start:l,end:r});return r=d.start,l=d.end,{x:o,y:r,x2:a,y2:l,width:a-o,height:l-r,centerX:o+(a-o)/2,centerY:r+(l-r)/2}}function xd(t,e){if(!Kc(e)){const n=yd(t,e);let i=e.radius;i&&!isNaN(i)||(i=Math.min(n.width,n.height)/2,e.radius=i);const s=2*i,o=n.centerX+e.xAdjust,a=n.centerY+e.yAdjust;return{x:o-i,y:a-i,x2:o+i,y2:a+i,centerX:o,centerY:a,width:s,height:s,radius:i}}return function(t,e){const n=bd(t,e),i=2*e.radius;return{x:n.x-e.radius+e.xAdjust,y:n.y-e.radius+e.yAdjust,x2:n.x+e.radius+e.xAdjust,y2:n.y+e.radius+e.yAdjust,centerX:n.x+e.xAdjust,centerY:n.y+e.yAdjust,radius:e.radius,width:i,height:i}}(t,e)}function vd(t,e){const{scales:n,chartArea:i}=t,s=n[e.scaleID],o={x:i.left,y:i.top,x2:i.right,y2:i.bottom};return s?function(t,e,n){const i=pd(t,n.value,NaN),s=pd(t,n.endValue,i);t.isHorizontal()?(e.x=i,e.x2=s):(e.y=i,e.y2=s)}(s,o,e):function(t,e,n){for(const i of Object.keys(gd)){const s=t[md(t,n,i)];if(s){const{min:t,max:o,start:a,end:r,startProp:l,endProp:c}=gd[i],d=fd(s,{min:n[t],max:n[o],start:s[a],end:s[r]});e[l]=d.start,e[c]=d.end}}}(n,o,e),o}function wd(t,e){const n=yd(t,e);return n.initProperties=Jc(t,n,e),n.elements=[{type:"label",optionScope:"label",properties:Md(t,n,e),initProperties:n.initProperties}],n}function kd(t,e){const n=fd(t,e)||e;return{start:Math.min(n.start,n.end),end:Math.max(n.start,n.end)}}function Sd(t,e){const{start:n,end:i,borderWidth:s}=t,{position:o,padding:{start:a,end:r},adjust:l}=e;return n+s/2+l+jc(i-s-n-a-r-e.size,o)}function Md(t,e,n){const i=n.label;i.backgroundColor="transparent",i.callout.display=!1;const s=Xc(i.position),o=rn(i.padding),a=rd(t.ctx,i),r=function({properties:t,options:e},n,i,s){const{x:o,x2:a,width:r}=t;return Sd({start:o,end:a,size:r,borderWidth:e.borderWidth},{position:i.x,padding:{start:s.left,end:s.right},adjust:e.label.xAdjust,size:n.width})}({properties:e,options:n},a,s,o),l=function({properties:t,options:e},n,i,s){const{y:o,y2:a,height:r}=t;return Sd({start:o,end:a,size:r,borderWidth:e.borderWidth},{position:i.y,padding:{start:s.top,end:s.bottom},adjust:e.label.yAdjust,size:n.height})}({properties:e,options:n},a,s,o),c=a.width+o.width,d=a.height+o.height;return{x:r,y:l,x2:r+c,y2:l+d,width:c,height:d,centerX:r+c/2,centerY:l+d/2,rotation:i.rotation}}const Cd=["enter","leave"],_d=Cd.concat("click");function Td(t,e,n){if(t.listened)switch(e.type){case"mousemove":case"mouseout":return function(t,e,n){if(!t.moveListened)return;let i;i="mousemove"===e.type?Pc(t.visibleElements,e,n.interaction):[];const s=t.hovered;t.hovered=i;const o={state:t,event:e};let a=Dd(o,"leave",s,i);return Dd(o,"enter",i,s)||a}(t,e,n);case"click":return function(t,e,n){const i=t.listeners,s=Pc(t.visibleElements,e,n.interaction);let o;for(const t of s)o=Pd(t.options.click||i.click,t,e)||o;return o}(t,e,n)}}function Dd({state:t,event:e},n,i,s){let o;for(const a of i)s.indexOf(a)<0&&(o=Pd(a.options[n]||t.listeners[n],a,e)||o);return o}function Pd(t,e,n){return!0===St(t,[e.$context,n])}const Ed=["afterDraw","beforeDraw"];function Ld(t,e,n){if(t.hooked){return St(e.options[n]||t.hooks[n],[e.$context])}}function Ad(t,e,n){const i=function(t,e,n){const i=e.axis,s=e.id,o=i+"ScaleID",a={min:wt(e.min,Number.NEGATIVE_INFINITY),max:wt(e.max,Number.POSITIVE_INFINITY)};for(const r of n)r.scaleID===s?Wd(r,e,["value","endValue"],a):md(t,r,o)===s&&Wd(r,e,[i+"Min",i+"Max",i+"Value"],a);return a}(t.scales,e,n);let s=Id(e,i,"min","suggestedMin");s=Id(e,i,"max","suggestedMax")||s,s&&Wt(e.handleTickRangeOptions)&&e.handleTickRangeOptions()}function Id(t,e,n,i){if(xt(e[n])&&!function(t,e,n){return Ot(t[e])||Ot(t[n])}(t.options,n,i)){const i=t[n]!==e[n];return t[n]=e[n],i}}function zd(t,e){for(const n of["scaleID","xScaleID","yScaleID"]){const i=md(e,t,n);i&&!e[i]&&Od(t,n)&&console.warn(`No scale found with id '${i}' for annotation '${t.id}'`)}}function Od(t,e){if("scaleID"===e)return!0;const n=e.charAt(0);for(const e of["Min","Max","Value"])if(Ot(t[n+e]))return!0;return!1}function Wd(t,e,n,i){for(const s of n){const n=t[s];if(Ot(n)){const t=e.parse(n);i.min=Math.min(i.min,t),i.max=Math.max(i.max,t)}}}class Nd extends ws{inRange(t,e,n,i){const{x:s,y:o}=Lc({x:t,y:e},this.getCenterPoint(i),Zt(-this.options.rotation));return Nc({x:s,y:o},this.getProps(["x","y","x2","y2"],i),n,this.options)}getCenterPoint(t){return Rc(this,t)}draw(t){t.save(),sd(t,this.getCenterPoint(),this.options.rotation),ld(t,this,this.options),t.restore()}get label(){return this.elements&&this.elements[0]}resolveElementProperties(t,e){return wd(t,e)}}Nd.id="boxAnnotation",Nd.defaults={adjustScaleRange:!0,backgroundShadowColor:"transparent",borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderRadius:0,borderShadowColor:"transparent",borderWidth:1,display:!0,init:void 0,hitTolerance:0,label:{backgroundColor:"transparent",borderWidth:0,callout:{display:!1},color:"black",content:null,display:!1,drawTime:void 0,font:{family:void 0,lineHeight:void 0,size:void 0,style:void 0,weight:"bold"},height:void 0,hitTolerance:void 0,opacity:void 0,padding:6,position:"center",rotation:void 0,textAlign:"start",textStrokeColor:void 0,textStrokeWidth:0,width:void 0,xAdjust:0,yAdjust:0,z:void 0},rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,xMax:void 0,xMin:void 0,xScaleID:void 0,yMax:void 0,yMin:void 0,yScaleID:void 0,z:0},Nd.defaultRoutes={borderColor:"color",backgroundColor:"color"},Nd.descriptors={label:{_fallback:!0}};class $d extends ws{inRange(t,e,n,i){return $c({x:t,y:e},{rect:this.getProps(["x","y","x2","y2"],i),center:this.getCenterPoint(i)},n,{rotation:this.rotation,borderWidth:0,hitTolerance:this.options.hitTolerance})}getCenterPoint(t){return Rc(this,t)}draw(t){const e=this.options;e.display&&e.content&&(!function(t,e){const{_centerX:n,_centerY:i,_radius:s,_startAngle:o,_endAngle:a,_counterclockwise:r,options:l}=e;t.save();const c=od(t,l);t.fillStyle=l.backgroundColor,t.beginPath(),t.arc(n,i,s,o,a,r),t.closePath(),t.fill(),c&&t.stroke();t.restore()}(t,this),t.save(),sd(t,this.getCenterPoint(),this.rotation),cd(t,this,e,this._fitRatio),t.restore())}resolveElementProperties(t,e){const n=function(t,e){return t.getSortedVisibleDatasetMetas().reduce((function(n,i){const s=i.controller;return s instanceof Ai&&function(t,e,n){if(!e.autoHide)return!0;for(let e=0;e<n.length;e++)if(!n[e].hidden&&t.getDataVisibility(e))return!0}(t,e,i.data)&&(!n||s.innerRadius<n.controller.innerRadius)&&s.options.circumference>=90?i:n}),void 0)}(t,e);if(!n)return{};const{controllerMeta:i,point:s,radius:o}=function({chartArea:t},e,n){const{left:i,top:s,right:o,bottom:a}=t,{innerRadius:r,offsetX:l,offsetY:c}=n.controller,d=(i+o)/2+l,h=(s+a)/2+c,u={left:Math.max(d-r,i),right:Math.min(d+r,o),top:Math.max(h-r,s),bottom:Math.min(h+r,a)},g={x:(u.left+u.right)/2,y:(u.top+u.bottom)/2},p=e.spacing+e.borderWidth/2,m=r-p,f=g.y>h,b=function(t,e,n,i){const s=Math.pow(n-t,2),o=Math.pow(i,2),a=-2*e,r=Math.pow(e,2)+s-o,l=Math.pow(a,2)-4*r;if(l<=0)return{_startAngle:0,_endAngle:Rt};const c=(-a-Math.sqrt(l))/2,d=(-a+Math.sqrt(l))/2;return{_startAngle:ee({x:e,y:n},{x:c,y:t}).angle,_endAngle:ee({x:e,y:n},{x:d,y:t}).angle}}(f?s+p:a-p,d,h,m),y={_centerX:d,_centerY:h,_radius:m,_counterclockwise:f,...b};return{controllerMeta:y,point:g,radius:Math.min(r,Math.min(u.right-u.left,u.bottom-u.top)/2)}}(t,e,n);let a=rd(t.ctx,e);const r=function({width:t,height:e},n){const i=Math.sqrt(Math.pow(t,2)+Math.pow(e,2));return 2*n/i}(a,o);Qc(e,r)&&(a={width:a.width*r,height:a.height*r});const{position:l,xAdjust:c,yAdjust:d}=e,h=Uc(s,a,{borderWidth:0,position:l,xAdjust:c,yAdjust:d});return{initProperties:Jc(t,h,e),...h,...i,rotation:e.rotation,_fitRatio:r}}}$d.id="doughnutLabelAnnotation",$d.defaults={autoFit:!0,autoHide:!0,backgroundColor:"transparent",backgroundShadowColor:"transparent",borderColor:"transparent",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderShadowColor:"transparent",borderWidth:0,color:"black",content:null,display:!0,font:{family:void 0,lineHeight:void 0,size:void 0,style:void 0,weight:void 0},height:void 0,hitTolerance:0,init:void 0,opacity:void 0,position:"center",rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,spacing:1,textAlign:"center",textStrokeColor:void 0,textStrokeWidth:0,width:void 0,xAdjust:0,yAdjust:0},$d.defaultRoutes={};class Rd extends ws{inRange(t,e,n,i){return $c({x:t,y:e},{rect:this.getProps(["x","y","x2","y2"],i),center:this.getCenterPoint(i)},n,{rotation:this.rotation,borderWidth:this.options.borderWidth,hitTolerance:this.options.hitTolerance})}getCenterPoint(t){return Rc(this,t)}draw(t){const e=this.options,n=!Ot(this._visible)||this._visible;e.display&&e.content&&n&&(t.save(),sd(t,this.getCenterPoint(),this.rotation),ud(t,this),ld(t,this,e),cd(t,function({x:t,y:e,width:n,height:i,options:s}){const o=s.borderWidth/2,a=rn(s.padding);return{x:t+a.left+o,y:e+a.top+o,width:n-a.left-a.right-s.borderWidth,height:i-a.top-a.bottom-s.borderWidth}}(this),e),t.restore())}resolveElementProperties(t,e){let n;if(Kc(e))n=bd(t,e);else{const{centerX:i,centerY:s}=yd(t,e);n={x:i,y:s}}const i=rn(e.padding),s=Uc(n,rd(t.ctx,e),e,i);return{initProperties:Jc(t,s,e),pointX:n.x,pointY:n.y,...s,rotation:e.rotation}}}Rd.id="labelAnnotation",Rd.defaults={adjustScaleRange:!0,backgroundColor:"transparent",backgroundShadowColor:"transparent",borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderRadius:0,borderShadowColor:"transparent",borderWidth:0,callout:{borderCapStyle:"butt",borderColor:void 0,borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:1,display:!1,margin:5,position:"auto",side:5,start:"50%"},color:"black",content:null,display:!0,font:{family:void 0,lineHeight:void 0,size:void 0,style:void 0,weight:void 0},height:void 0,hitTolerance:0,init:void 0,opacity:void 0,padding:6,position:"center",rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,textAlign:"center",textStrokeColor:void 0,textStrokeWidth:0,width:void 0,xAdjust:0,xMax:void 0,xMin:void 0,xScaleID:void 0,xValue:void 0,yAdjust:0,yMax:void 0,yMin:void 0,yScaleID:void 0,yValue:void 0,z:0},Rd.defaultRoutes={borderColor:"color"};const Fd=(t,e,n)=>({x:t.x+n*(e.x-t.x),y:t.y+n*(e.y-t.y)}),Bd=(t,e,n)=>Fd(e,n,Math.abs((t-e.y)/(n.y-e.y))).x,qd=(t,e,n)=>Fd(e,n,Math.abs((t-e.x)/(n.x-e.x))).y,Hd=t=>t*t,Vd=(t,e,n,i)=>(1-i)*(1-i)*t+2*(1-i)*i*e+i*i*n,jd=(t,e,n,i)=>({x:Vd(t.x,e.x,n.x,i),y:Vd(t.y,e.y,n.y,i)}),Yd=(t,e,n,i)=>2*(1-i)*(e-t)+2*i*(n-e),Ud=(t,e,n,i)=>-Math.atan2(Yd(t.x,e.x,n.x,i),Yd(t.y,e.y,n.y,i))+.5*$t;class Xd extends ws{inRange(t,e,n,i){const s=(this.options.borderWidth+this.options.hitTolerance)/2;if("x"!==n&&"y"!==n){const n={mouseX:t,mouseY:e},{path:o,ctx:a}=this;if(o){od(a,this.options),a.lineWidth+=this.options.hitTolerance;const{chart:s}=this.$context,r=t*s.currentDevicePixelRatio,l=e*s.currentDevicePixelRatio,c=a.isPointInStroke(o,r,l)||Kd(this,n,i);return a.restore(),c}return function(t,{mouseX:e,mouseY:n},i=.001,s){const{x:o,y:a,x2:r,y2:l}=t.getProps(["x","y","x2","y2"],s),c=r-o,d=l-a,h=Hd(c)+Hd(d),u=0===h?-1:((e-o)*c+(n-a)*d)/h;let g,p;u<0?(g=o,p=a):u>1?(g=r,p=l):(g=o+u*c,p=a+u*d);return Hd(e-g)+Hd(n-p)<=i}(this,n,Hd(s),i)||Kd(this,n,i)}return function(t,{mouseX:e,mouseY:n},i,{hitSize:s,useFinalPosition:o}){const a=((t,e,{x:n,y:i,x2:s,y2:o},a)=>"y"===a?{start:Math.min(i,o),end:Math.max(i,o),value:e}:{start:Math.min(n,s),end:Math.max(n,s),value:t})(e,n,t.getProps(["x","y","x2","y2"],o),i);return Oc(a,s)||Kd(t,{mouseX:e,mouseY:n},o,i)}(this,{mouseX:t,mouseY:e},n,{hitSize:s,useFinalPosition:i})}getCenterPoint(t){return Rc(this,t)}draw(t){const{x:e,y:n,x2:i,y2:s,cp:o,options:a}=this;if(t.save(),!od(t,a))return t.restore();ad(t,a);const r=Math.sqrt(Math.pow(i-e,2)+Math.pow(s-n,2));if(a.curve&&o)return function(t,e,n,i){const{x:s,y:o,x2:a,y2:r,options:l}=e,{startOpts:c,endOpts:d,startAdjust:h,endAdjust:u}=th(e),g={x:s,y:o},p={x:a,y:r},m=Ud(g,n,p,0),f=Ud(g,n,p,1)-$t,b=jd(g,n,p,h/i),y=jd(g,n,p,1-u/i),x=new Path2D;t.beginPath(),x.moveTo(b.x,b.y),x.quadraticCurveTo(n.x,n.y,y.x,y.y),t.shadowColor=l.borderShadowColor,t.stroke(x),e.path=x,e.ctx=t,ih(t,b,{angle:m,adjust:h},c),ih(t,y,{angle:f,adjust:u},d)}(t,this,o,r),t.restore();const{startOpts:l,endOpts:c,startAdjust:d,endAdjust:h}=th(this),u=Math.atan2(s-n,i-e);t.translate(e,n),t.rotate(u),t.beginPath(),t.moveTo(0+d,0),t.lineTo(r-h,0),t.shadowColor=a.borderShadowColor,t.stroke(),nh(t,0,d,l),nh(t,r,-h,c),t.restore()}get label(){return this.elements&&this.elements[0]}resolveElementProperties(t,e){const n=vd(t,e),{x:i,y:s,x2:o,y2:a}=n,r=function({x:t,y:e,x2:n,y2:i},{top:s,right:o,bottom:a,left:r}){return!(t<r&&n<r||t>o&&n>o||e<s&&i<s||e>a&&i>a)}(n,t.chartArea),l=r?function(t,e,n){const{x:i,y:s}=Gd(t,e,n),{x:o,y:a}=Gd(e,t,n);return{x:i,y:s,x2:o,y2:a,width:Math.abs(o-i),height:Math.abs(a-s)}}({x:i,y:s},{x:o,y:a},t.chartArea):{x:i,y:s,x2:o,y2:a,width:Math.abs(o-i),height:Math.abs(a-s)};if(l.centerX=(o+i)/2,l.centerY=(a+s)/2,l.initProperties=Jc(t,l,e),e.curve){const t={x:l.x,y:l.y},n={x:l.x2,y:l.y2};l.cp=function(t,e,n){const{x:i,y:s,x2:o,y2:a,centerX:r,centerY:l}=t,c=Math.atan2(a-s,o-i),d=Xc(e.controlPoint,0);return Lc({x:r+Yc(n,d.x,!1),y:l+Yc(n,d.y,!1)},{x:r,y:l},c)}(l,e,ne(t,n))}const c=function(t,e,n){const i=n.borderWidth,s=rn(n.padding),o=rd(t.ctx,n),a=o.width+s.width+i,r=o.height+s.height+i;return function(t,e,n,i){const{width:s,height:o,padding:a}=n,{xAdjust:r,yAdjust:l}=e,c={x:t.x,y:t.y},d={x:t.x2,y:t.y2},h="auto"===e.rotation?function(t){const{x:e,y:n,x2:i,y2:s}=t,o=Math.atan2(s-n,i-e);return o>$t/2?o-$t:o<$t/-2?o+$t:o}(t):Zt(e.rotation),u=function(t,e,n){const i=Math.cos(n),s=Math.sin(n);return{w:Math.abs(t*i)+Math.abs(e*s),h:Math.abs(t*s)+Math.abs(e*i)}}(s,o,h),g=function(t,e,n,i){let s;const o=function(t,e){const{x:n,x2:i,y:s,y2:o}=t,a=Math.min(s,o)-e.top,r=Math.min(n,i)-e.left,l=e.bottom-Math.max(s,o),c=e.right-Math.max(n,i);return{x:Math.min(r,c),y:Math.min(a,l),dx:r<=c?1:-1,dy:a<=l?1:-1}}(t,i);s="start"===e.position?Zd({w:t.x2-t.x,h:t.y2-t.y},n,e,o):"end"===e.position?1-Zd({w:t.x-t.x2,h:t.y-t.y2},n,e,o):jc(1,e.position);return s}(t,e,{labelSize:u,padding:a},i),p=t.cp?jd(c,t.cp,d,g):Fd(c,d,g),m={size:u.w,min:i.left,max:i.right,padding:a.left},f={size:u.h,min:i.top,max:i.bottom,padding:a.top},b=Jd(p.x,m)+r,y=Jd(p.y,f)+l;return{x:b-s/2,y:y-o/2,x2:b+s/2,y2:y+o/2,centerX:b,centerY:y,pointX:p.x,pointY:p.y,width:s,height:o,rotation:Jt(h)}}(e,n,{width:a,height:r,padding:s},t.chartArea)}(t,l,e.label);return c._visible=r,l.elements=[{type:"label",optionScope:"label",properties:c,initProperties:l.initProperties}],l}}Xd.id="lineAnnotation";const Qd={backgroundColor:void 0,backgroundShadowColor:void 0,borderColor:void 0,borderDash:void 0,borderDashOffset:void 0,borderShadowColor:void 0,borderWidth:void 0,display:void 0,fill:void 0,length:void 0,shadowBlur:void 0,shadowOffsetX:void 0,shadowOffsetY:void 0,width:void 0};function Gd({x:t,y:e},n,{top:i,right:s,bottom:o,left:a}){return t<a&&(e=qd(a,{x:t,y:e},n),t=a),t>s&&(e=qd(s,{x:t,y:e},n),t=s),e<i&&(t=Bd(i,{x:t,y:e},n),e=i),e>o&&(t=Bd(o,{x:t,y:e},n),e=o),{x:t,y:e}}function Kd(t,{mouseX:e,mouseY:n},i,s){const o=t.label;return o.options.display&&o.inRange(e,n,s,i)}function Zd(t,e,n,i){const{labelSize:s,padding:o}=e,a=t.w*i.dx,r=t.h*i.dy,l=a>0&&(s.w/2+o.left-i.x)/a,c=r>0&&(s.h/2+o.top-i.y)/r;return zc(Math.max(l,c),0,.25)}function Jd(t,e){const{size:n,min:i,max:s,padding:o}=e,a=n/2;return n>s-i?(s+i)/2:(i>=t-o-a&&(t=i+o+a),s<=t+o+a&&(t=s-o-a),t)}function th(t){const e=t.options,n=e.arrowHeads&&e.arrowHeads.start,i=e.arrowHeads&&e.arrowHeads.end;return{startOpts:n,endOpts:i,startAdjust:eh(t,n),endAdjust:eh(t,i)}}function eh(t,e){if(!e||!e.display)return 0;const{length:n,width:i}=e,s=t.options.borderWidth/2,o={x:n,y:i+s},a={x:0,y:s};return Math.abs(Bd(0,o,a))}function nh(t,e,n,i){if(!i||!i.display)return;const{length:s,width:o,fill:a,backgroundColor:r,borderColor:l}=i,c=Math.abs(e-s)+n;t.beginPath(),ad(t,i),od(t,i),t.moveTo(c,-o),t.lineTo(e+n,0),t.lineTo(c,o),!0===a?(t.fillStyle=r||l,t.closePath(),t.fill(),t.shadowColor="transparent"):t.shadowColor=i.borderShadowColor,t.stroke()}function ih(t,{x:e,y:n},{angle:i,adjust:s},o){o&&o.display&&(t.save(),t.translate(e,n),t.rotate(i),nh(t,0,-s,o),t.restore())}Xd.defaults={adjustScaleRange:!0,arrowHeads:{display:!1,end:Object.assign({},Qd),fill:!1,length:12,start:Object.assign({},Qd),width:6},borderDash:[],borderDashOffset:0,borderShadowColor:"transparent",borderWidth:2,curve:!1,controlPoint:{y:"-50%"},display:!0,endValue:void 0,init:void 0,hitTolerance:0,label:{backgroundColor:"rgba(0,0,0,0.8)",backgroundShadowColor:"transparent",borderCapStyle:"butt",borderColor:"black",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderRadius:6,borderShadowColor:"transparent",borderWidth:0,callout:Object.assign({},Rd.defaults.callout),color:"#fff",content:null,display:!1,drawTime:void 0,font:{family:void 0,lineHeight:void 0,size:void 0,style:void 0,weight:"bold"},height:void 0,hitTolerance:void 0,opacity:void 0,padding:6,position:"center",rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,textAlign:"center",textStrokeColor:void 0,textStrokeWidth:0,width:void 0,xAdjust:0,yAdjust:0,z:void 0},scaleID:void 0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,value:void 0,xMax:void 0,xMin:void 0,xScaleID:void 0,yMax:void 0,yMin:void 0,yScaleID:void 0,z:0},Xd.descriptors={arrowHeads:{start:{_fallback:!0},end:{_fallback:!0},_fallback:!0}},Xd.defaultRoutes={borderColor:"color"};class sh extends ws{inRange(t,e,n,i){const s=this.options.rotation,o=(this.options.borderWidth+this.options.hitTolerance)/2;if("x"!==n&&"y"!==n)return function(t,e,n,i){const{width:s,height:o,centerX:a,centerY:r}=e,l=s/2,c=o/2;if(l<=0||c<=0)return!1;const d=Zt(n||0),h=Math.cos(d),u=Math.sin(d),g=Math.pow(h*(t.x-a)+u*(t.y-r),2),p=Math.pow(u*(t.x-a)-h*(t.y-r),2);return g/Math.pow(l+i,2)+p/Math.pow(c+i,2)<=1.0001}({x:t,y:e},this.getProps(["width","height","centerX","centerY"],i),s,o);const{x:a,y:r,x2:l,y2:c}=this.getProps(["x","y","x2","y2"],i),d="y"===n?{start:r,end:c}:{start:a,end:l},h=Lc({x:t,y:e},this.getCenterPoint(i),Zt(-s));return h[n]>=d.start-o-Ic&&h[n]<=d.end+o+Ic}getCenterPoint(t){return Rc(this,t)}draw(t){const{width:e,height:n,centerX:i,centerY:s,options:o}=this;t.save(),sd(t,this.getCenterPoint(),o.rotation),ad(t,this.options),t.beginPath(),t.fillStyle=o.backgroundColor;const a=od(t,o);t.ellipse(i,s,n/2,e/2,$t/2,0,2*$t),t.fill(),a&&(t.shadowColor=o.borderShadowColor,t.stroke()),t.restore()}get label(){return this.elements&&this.elements[0]}resolveElementProperties(t,e){return wd(t,e)}}sh.id="ellipseAnnotation",sh.defaults={adjustScaleRange:!0,backgroundShadowColor:"transparent",borderDash:[],borderDashOffset:0,borderShadowColor:"transparent",borderWidth:1,display:!0,hitTolerance:0,init:void 0,label:Object.assign({},Nd.defaults.label),rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,xMax:void 0,xMin:void 0,xScaleID:void 0,yMax:void 0,yMin:void 0,yScaleID:void 0,z:0},sh.defaultRoutes={borderColor:"color",backgroundColor:"color"},sh.descriptors={label:{_fallback:!0}};class oh extends ws{inRange(t,e,n,i){const{x:s,y:o,x2:a,y2:r,width:l}=this.getProps(["x","y","x2","y2","width"],i),c=(this.options.borderWidth+this.options.hitTolerance)/2;if("x"!==n&&"y"!==n)return function(t,e,n,i){return!(!t||!e||n<=0)&&Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)<=Math.pow(n+i,2)}({x:t,y:e},this.getCenterPoint(i),l/2,c);return Oc("y"===n?{start:o,end:r,value:e}:{start:s,end:a,value:t},c)}getCenterPoint(t){return Rc(this,t)}draw(t){const e=this.options,n=e.borderWidth;if(e.radius<.1)return;t.save(),t.fillStyle=e.backgroundColor,ad(t,e);const i=od(t,e);dd(t,this,this.centerX,this.centerY),i&&!id(e.pointStyle)&&(t.shadowColor=e.borderShadowColor,t.stroke()),t.restore(),e.borderWidth=n}resolveElementProperties(t,e){const n=xd(t,e);return n.initProperties=Jc(t,n,e),n}}oh.id="pointAnnotation",oh.defaults={adjustScaleRange:!0,backgroundShadowColor:"transparent",borderDash:[],borderDashOffset:0,borderShadowColor:"transparent",borderWidth:1,display:!0,hitTolerance:0,init:void 0,pointStyle:"circle",radius:10,rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,xAdjust:0,xMax:void 0,xMin:void 0,xScaleID:void 0,xValue:void 0,yAdjust:0,yMax:void 0,yMin:void 0,yScaleID:void 0,yValue:void 0,z:0},oh.defaultRoutes={borderColor:"color",backgroundColor:"color"};class ah extends ws{inRange(t,e,n,i){if("x"!==n&&"y"!==n)return this.options.radius>=.1&&this.elements.length>1&&function(t,e,n,i){let s=!1,o=t[t.length-1].getProps(["bX","bY"],i);for(const a of t){const t=a.getProps(["bX","bY"],i);t.bY>n!=o.bY>n&&e<(o.bX-t.bX)*(n-t.bY)/(o.bY-t.bY)+t.bX&&(s=!s),o=t}return s}(this.elements,t,e,i);const s=Lc({x:t,y:e},this.getCenterPoint(i),Zt(-this.options.rotation)),o=this.elements.map((t=>"y"===n?t.bY:t.bX)),a=Math.min(...o),r=Math.max(...o);return s[n]>=a&&s[n]<=r}getCenterPoint(t){return Rc(this,t)}draw(t){const{elements:e,options:n}=this;t.save(),t.beginPath(),t.fillStyle=n.backgroundColor,ad(t,n);const i=od(t,n);let s=!0;for(const n of e)s?(t.moveTo(n.x,n.y),s=!1):t.lineTo(n.x,n.y);t.closePath(),t.fill(),i&&(t.shadowColor=n.borderShadowColor,t.stroke()),t.restore()}resolveElementProperties(t,e){const n=xd(t,e),{sides:i,rotation:s}=e,o=[],a=2*$t/i;let r=s*qt;for(let s=0;s<i;s++,r+=a){const i=rh(n,e,r);i.initProperties=Jc(t,n,e),o.push(i)}return n.elements=o,n}}function rh({centerX:t,centerY:e},{radius:n,borderWidth:i,hitTolerance:s},o){const a=(i+s)/2,r=Math.sin(o),l=Math.cos(o),c={x:t+r*n,y:e-l*n};return{type:"point",optionScope:"point",properties:{x:c.x,y:c.y,centerX:c.x,centerY:c.y,bX:t+r*(n+a),bY:e-l*(n+a)}}}ah.id="polygonAnnotation",ah.defaults={adjustScaleRange:!0,backgroundShadowColor:"transparent",borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderShadowColor:"transparent",borderWidth:1,display:!0,hitTolerance:0,init:void 0,point:{radius:0},radius:10,rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,sides:3,xAdjust:0,xMax:void 0,xMin:void 0,xScaleID:void 0,xValue:void 0,yAdjust:0,yMax:void 0,yMin:void 0,yScaleID:void 0,yValue:void 0,z:0},ah.defaultRoutes={borderColor:"color",backgroundColor:"color"};const lh={box:Nd,doughnutLabel:$d,ellipse:sh,label:Rd,line:Xd,point:oh,polygon:ah};Object.keys(lh).forEach((t=>{$e.describe(`elements.${lh[t].id}`,{_fallback:"plugins.annotation.common"})}));const ch={update:Object.assign},dh=_d.concat(Ed),hh=(t,e)=>yt(e)?xh(t,e):t,uh=t=>"color"===t||"font"===t;function gh(t="line"){return lh[t]?t:(console.warn(`Unknown annotation type: '${t}', defaulting to 'line'`),"line")}function ph(t,e,n,i){const s=function(t,e,n){if("reset"===n||"none"===n||"resize"===n)return ch;return new di(t,e)}(t,n.animations,i),o=e.annotations,a=function(t,e){const n=e.length,i=t.length;if(i<n){const e=n-i;t.splice(i,0,...new Array(e))}else i>n&&t.splice(n,i-n);return t}(e.elements,o);for(let e=0;e<o.length;e++){const n=o[e],i=bh(a,e,n.type),r=n.setContext(vh(t,i,a,n)),l=i.resolveElementProperties(t,r);l.skip=mh(l),"elements"in l&&(fh(i,l.elements,r,s),delete l.elements),Ot(i.x)||Object.assign(i,l),Object.assign(i,l.initProperties),l.options=yh(r),s.update(i,l)}}function mh(t){return isNaN(t.x)||isNaN(t.y)}function fh(t,e,n,i){const s=t.elements||(t.elements=[]);s.length=e.length;for(let t=0;t<e.length;t++){const o=e[t],a=o.properties,r=bh(s,t,o.type,o.initProperties),l=n[o.optionScope].override(o);a.options=yh(l),i.update(r,a)}}function bh(t,e,n,i){const s=lh[gh(n)];let o=t[e];return o&&o instanceof s||(o=t[e]=new s,Object.assign(o,i)),o}function yh(t){const e=lh[gh(t.type)],n={};n.id=t.id,n.type=t.type,n.drawTime=t.drawTime,Object.assign(n,xh(t,e.defaults),xh(t,e.defaultRoutes));for(const e of dh)n[e]=t[e];return n}function xh(t,e){const n={};for(const i of Object.keys(e)){const s=e[i],o=t[i];uh(i)&&bt(o)?n[i]=o.map((t=>hh(t,s))):n[i]=hh(o,s)}return n}function vh(t,e,n,i){return e.$context||(e.$context=Object.assign(Object.create(t.getContext()),{element:e,get elements(){return n.filter((t=>t&&t.options))},id:i.id,type:"annotation"}))}const wh=new Map,kh=t=>"doughnutLabel"!==t.type,Sh=_d.concat(Ed);var Mh={id:"annotation",version:"3.1.0",beforeRegister(){!function(t,e,n,i=!0){const s=n.split(".");let o=0;for(const a of e.split(".")){const r=s[o++];if(parseInt(a,10)<parseInt(r,10))break;if(Ac(r,a)){if(i)throw new Error(`${t} v${n} is not supported. v${e} or newer is required.`);return!1}}}("chart.js","4.0",ro.version)},afterRegister(){ro.register(lh)},afterUnregister(){ro.unregister(lh)},beforeInit(t){wh.set(t,{annotations:[],elements:[],visibleElements:[],listeners:{},listened:!1,moveListened:!1,hooks:{},hooked:!1,hovered:[]})},beforeUpdate(t,e,n){const i=wh.get(t).annotations=[];let s=n.annotations;yt(s)?Object.keys(s).forEach((t=>{const e=s[t];yt(e)&&(e.id=t,i.push(e))})):bt(s)&&i.push(...s),function(t,e){for(const n of t)zd(n,e)}(i.filter(kh),t.scales)},afterDataLimits(t,e){const n=wh.get(t);Ad(t,e.scale,n.annotations.filter(kh).filter((t=>t.display&&t.adjustScaleRange)))},afterUpdate(t,e,n){const i=wh.get(t);!function(t,e,n){e.listened=td(n,_d,e.listeners),e.moveListened=!1,Cd.forEach((t=>{Wt(n[t])&&(e.moveListened=!0)})),e.listened&&e.moveListened||e.annotations.forEach((t=>{!e.listened&&Wt(t.click)&&(e.listened=!0),e.moveListened||Cd.forEach((n=>{Wt(t[n])&&(e.listened=!0,e.moveListened=!0)}))}))}(0,i,n),ph(t,i,n,e.mode),i.visibleElements=i.elements.filter((t=>!t.skip&&t.options.display)),function(t,e,n){const i=e.visibleElements;e.hooked=td(n,Ed,e.hooks),e.hooked||i.forEach((t=>{e.hooked||Ed.forEach((n=>{Wt(t.options[n])&&(e.hooked=!0)}))}))}(0,i,n)},beforeDatasetsDraw(t,e,n){Ch(t,"beforeDatasetsDraw",n.clip)},afterDatasetsDraw(t,e,n){Ch(t,"afterDatasetsDraw",n.clip)},beforeDatasetDraw(t,e,n){Ch(t,e.index,n.clip)},beforeDraw(t,e,n){Ch(t,"beforeDraw",n.clip)},afterDraw(t,e,n){Ch(t,"afterDraw",n.clip)},beforeEvent(t,e,n){Td(wh.get(t),e.event,n)&&(e.changed=!0)},afterDestroy(t){wh.delete(t)},getAnnotations(t){const e=wh.get(t);return e?e.elements:[]},_getAnnotationElementsAtEventForMode:(t,e,n)=>Pc(t,e,n),defaults:{animations:{numbers:{properties:["x","y","x2","y2","width","height","centerX","centerY","pointX","pointY","radius"],type:"number"},colors:{properties:["backgroundColor","borderColor"],type:"color"}},clip:!0,interaction:{mode:void 0,axis:void 0,intersect:void 0},common:{drawTime:"afterDatasetsDraw",init:!1,label:{}}},descriptors:{_indexable:!1,_scriptable:t=>!Sh.includes(t)&&"init"!==t,annotations:{_allKeys:!1,_fallback:(t,e)=>`elements.${lh[gh(e.type)].id}`},interaction:{_fallback:!0},common:{label:{_indexable:uh,_fallback:!0},_indexable:uh}},additionalOptionScopes:[""]};function Ch(t,e,n){const{ctx:i,chartArea:s}=t,o=wh.get(t);n&&Ye(i,s);const a=function(t,e){const n=[];for(const i of t)if(i.options.drawTime===e&&n.push({element:i,main:!0}),i.elements&&i.elements.length)for(const t of i.elements)t.options.display&&t.options.drawTime===e&&n.push({element:t});return n}(o.visibleElements,e).sort(((t,e)=>t.element.options.z-e.element.options.z));for(const t of a)_h(i,s,o,t);n&&Ue(i)}function _h(t,e,n,i){const s=i.element;i.main?(Ld(n,s,"beforeDraw"),s.draw(t,e),Ld(n,s,"afterDraw")):s.draw(t,e)}function Th(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Dh={exports:{}};
|
|
34
34
|
/*! Hammer.JS - v2.0.7 - 2016-04-22
|
|
35
35
|
* http://hammerjs.github.io/
|
|
36
36
|
*
|
|
37
37
|
* Copyright (c) 2016 Jorik Tangelder;
|
|
38
|
-
* Licensed under the MIT license */!function(t){!function(e,n,i,s){var o,a=["","webkit","Moz","MS","ms","o"],r=n.createElement("div"),l=Math.round,c=Math.abs,d=Date.now;function h(t,e,n){return setTimeout(y(t,n),e)}function u(t,e,n){return!!Array.isArray(t)&&(g(t,n[e],n),!0)}function g(t,e,n){var i;if(t)if(t.forEach)t.forEach(e,n);else if(t.length!==s)for(i=0;i<t.length;)e.call(n,t[i],i,t),i++;else for(i in t)t.hasOwnProperty(i)&&e.call(n,t[i],i,t)}function p(t,n,i){var s="DEPRECATED METHOD: "+n+"\n"+i+" AT \n";return function(){var n=new Error("get-stack-trace"),i=n&&n.stack?n.stack.replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",o=e.console&&(e.console.warn||e.console.log);return o&&o.call(e.console,s,i),t.apply(this,arguments)}}o="function"!=typeof Object.assign?function(t){if(t===s||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n<arguments.length;n++){var i=arguments[n];if(i!==s&&null!==i)for(var o in i)i.hasOwnProperty(o)&&(e[o]=i[o])}return e}:Object.assign;var m=p((function(t,e,n){for(var i=Object.keys(e),o=0;o<i.length;)(!n||n&&t[i[o]]===s)&&(t[i[o]]=e[i[o]]),o++;return t}),"extend","Use `assign`."),f=p((function(t,e){return m(t,e,!0)}),"merge","Use `assign`.");function b(t,e,n){var i,s=e.prototype;(i=t.prototype=Object.create(s)).constructor=t,i._super=s,n&&o(i,n)}function y(t,e){return function(){return t.apply(e,arguments)}}function x(t,e){return"function"==typeof t?t.apply(e&&e[0]||s,e):t}function v(t,e){return t===s?e:t}function w(t,e,n){g(C(e),(function(e){t.addEventListener(e,n,!1)}))}function k(t,e,n){g(C(e),(function(e){t.removeEventListener(e,n,!1)}))}function S(t,e){for(;t;){if(t==e)return!0;t=t.parentNode}return!1}function M(t,e){return t.indexOf(e)>-1}function C(t){return t.trim().split(/\s+/g)}function _(t,e,n){if(t.indexOf&&!n)return t.indexOf(e);for(var i=0;i<t.length;){if(n&&t[i][n]==e||!n&&t[i]===e)return i;i++}return-1}function T(t){return Array.prototype.slice.call(t,0)}function D(t,e,n){for(var i=[],s=[],o=0;o<t.length;){var a=e?t[o][e]:t[o];_(s,a)<0&&i.push(t[o]),s[o]=a,o++}return n&&(i=e?i.sort((function(t,n){return t[e]>n[e]})):i.sort()),i}function P(t,e){for(var n,i,o=e[0].toUpperCase()+e.slice(1),r=0;r<a.length;){if((i=(n=a[r])?n+o:e)in t)return i;r++}return s}var E=1;function L(t){var n=t.ownerDocument||t;return n.defaultView||n.parentWindow||e}var A="ontouchstart"in e,I=P(e,"PointerEvent")!==s,z=A&&/mobile|tablet|ip(ad|hone|od)|android/i.test(navigator.userAgent),O="touch",W="mouse",N=24,R=["x","y"],$=["clientX","clientY"];function F(t,e){var n=this;this.manager=t,this.callback=e,this.element=t.element,this.target=t.options.inputTarget,this.domHandler=function(e){x(t.options.enable,[t])&&n.handler(e)},this.init()}function B(t,e,n){var i=n.pointers.length,o=n.changedPointers.length,a=1&e&&i-o===0,r=12&e&&i-o===0;n.isFirst=!!a,n.isFinal=!!r,a&&(t.session={}),n.eventType=e,function(t,e){var n=t.session,i=e.pointers,o=i.length;n.firstInput||(n.firstInput=q(e));o>1&&!n.firstMultiple?n.firstMultiple=q(e):1===o&&(n.firstMultiple=!1);var a=n.firstInput,r=n.firstMultiple,l=r?r.center:a.center,h=e.center=H(i);e.timeStamp=d(),e.deltaTime=e.timeStamp-a.timeStamp,e.angle=U(l,h),e.distance=j(l,h),function(t,e){var n=e.center,i=t.offsetDelta||{},s=t.prevDelta||{},o=t.prevInput||{};1!==e.eventType&&4!==o.eventType||(s=t.prevDelta={x:o.deltaX||0,y:o.deltaY||0},i=t.offsetDelta={x:n.x,y:n.y});e.deltaX=s.x+(n.x-i.x),e.deltaY=s.y+(n.y-i.y)}(n,e),e.offsetDirection=Y(e.deltaX,e.deltaY);var u=V(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=u.x,e.overallVelocityY=u.y,e.overallVelocity=c(u.x)>c(u.y)?u.x:u.y,e.scale=r?(g=r.pointers,p=i,j(p[0],p[1],$)/j(g[0],g[1],$)):1,e.rotation=r?function(t,e){return U(e[1],e[0],$)+U(t[1],t[0],$)}(r.pointers,i):0,e.maxPointers=n.prevInput?e.pointers.length>n.prevInput.maxPointers?e.pointers.length:n.prevInput.maxPointers:e.pointers.length,function(t,e){var n,i,o,a,r=t.lastInterval||e,l=e.timeStamp-r.timeStamp;if(8!=e.eventType&&(l>25||r.velocity===s)){var d=e.deltaX-r.deltaX,h=e.deltaY-r.deltaY,u=V(l,d,h);i=u.x,o=u.y,n=c(u.x)>c(u.y)?u.x:u.y,a=Y(d,h),t.lastInterval=e}else n=r.velocity,i=r.velocityX,o=r.velocityY,a=r.direction;e.velocity=n,e.velocityX=i,e.velocityY=o,e.direction=a}(n,e);var g,p;var m=t.element;S(e.srcEvent.target,m)&&(m=e.srcEvent.target);e.target=m}(t,n),t.emit("hammer.input",n),t.recognize(n),t.session.prevInput=n}function q(t){for(var e=[],n=0;n<t.pointers.length;)e[n]={clientX:l(t.pointers[n].clientX),clientY:l(t.pointers[n].clientY)},n++;return{timeStamp:d(),pointers:e,center:H(e),deltaX:t.deltaX,deltaY:t.deltaY}}function H(t){var e=t.length;if(1===e)return{x:l(t[0].clientX),y:l(t[0].clientY)};for(var n=0,i=0,s=0;s<e;)n+=t[s].clientX,i+=t[s].clientY,s++;return{x:l(n/e),y:l(i/e)}}function V(t,e,n){return{x:e/t||0,y:n/t||0}}function Y(t,e){return t===e?1:c(t)>=c(e)?t<0?2:4:e<0?8:16}function j(t,e,n){n||(n=R);var i=e[n[0]]-t[n[0]],s=e[n[1]]-t[n[1]];return Math.sqrt(i*i+s*s)}function U(t,e,n){n||(n=R);var i=e[n[0]]-t[n[0]],s=e[n[1]]-t[n[1]];return 180*Math.atan2(s,i)/Math.PI}F.prototype={handler:function(){},init:function(){this.evEl&&w(this.element,this.evEl,this.domHandler),this.evTarget&&w(this.target,this.evTarget,this.domHandler),this.evWin&&w(L(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&k(this.element,this.evEl,this.domHandler),this.evTarget&&k(this.target,this.evTarget,this.domHandler),this.evWin&&k(L(this.element),this.evWin,this.domHandler)}};var X={mousedown:1,mousemove:2,mouseup:4},Q="mousedown",G="mousemove mouseup";function K(){this.evEl=Q,this.evWin=G,this.pressed=!1,F.apply(this,arguments)}b(K,F,{handler:function(t){var e=X[t.type];1&e&&0===t.button&&(this.pressed=!0),2&e&&1!==t.which&&(e=4),this.pressed&&(4&e&&(this.pressed=!1),this.callback(this.manager,e,{pointers:[t],changedPointers:[t],pointerType:W,srcEvent:t}))}});var Z={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},J={2:O,3:"pen",4:W,5:"kinect"},tt="pointerdown",et="pointermove pointerup pointercancel";function nt(){this.evEl=tt,this.evWin=et,F.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}e.MSPointerEvent&&!e.PointerEvent&&(tt="MSPointerDown",et="MSPointerMove MSPointerUp MSPointerCancel"),b(nt,F,{handler:function(t){var e=this.store,n=!1,i=t.type.toLowerCase().replace("ms",""),s=Z[i],o=J[t.pointerType]||t.pointerType,a=o==O,r=_(e,t.pointerId,"pointerId");1&s&&(0===t.button||a)?r<0&&(e.push(t),r=e.length-1):12&s&&(n=!0),r<0||(e[r]=t,this.callback(this.manager,s,{pointers:e,changedPointers:[t],pointerType:o,srcEvent:t}),n&&e.splice(r,1))}});var it={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function st(){this.evTarget="touchstart",this.evWin="touchstart touchmove touchend touchcancel",this.started=!1,F.apply(this,arguments)}function ot(t,e){var n=T(t.touches),i=T(t.changedTouches);return 12&e&&(n=D(n.concat(i),"identifier",!0)),[n,i]}b(st,F,{handler:function(t){var e=it[t.type];if(1===e&&(this.started=!0),this.started){var n=ot.call(this,t,e);12&e&&n[0].length-n[1].length===0&&(this.started=!1),this.callback(this.manager,e,{pointers:n[0],changedPointers:n[1],pointerType:O,srcEvent:t})}}});var at={touchstart:1,touchmove:2,touchend:4,touchcancel:8},rt="touchstart touchmove touchend touchcancel";function lt(){this.evTarget=rt,this.targetIds={},F.apply(this,arguments)}function ct(t,e){var n=T(t.touches),i=this.targetIds;if(3&e&&1===n.length)return i[n[0].identifier]=!0,[n,n];var s,o,a=T(t.changedTouches),r=[],l=this.target;if(o=n.filter((function(t){return S(t.target,l)})),1===e)for(s=0;s<o.length;)i[o[s].identifier]=!0,s++;for(s=0;s<a.length;)i[a[s].identifier]&&r.push(a[s]),12&e&&delete i[a[s].identifier],s++;return r.length?[D(o.concat(r),"identifier",!0),r]:void 0}b(lt,F,{handler:function(t){var e=at[t.type],n=ct.call(this,t,e);n&&this.callback(this.manager,e,{pointers:n[0],changedPointers:n[1],pointerType:O,srcEvent:t})}});function dt(){F.apply(this,arguments);var t=y(this.handler,this);this.touch=new lt(this.manager,t),this.mouse=new K(this.manager,t),this.primaryTouch=null,this.lastTouches=[]}function ht(t,e){1&t?(this.primaryTouch=e.changedPointers[0].identifier,ut.call(this,e)):12&t&&ut.call(this,e)}function ut(t){var e=t.changedPointers[0];if(e.identifier===this.primaryTouch){var n={x:e.clientX,y:e.clientY};this.lastTouches.push(n);var i=this.lastTouches;setTimeout((function(){var t=i.indexOf(n);t>-1&&i.splice(t,1)}),2500)}}function gt(t){for(var e=t.srcEvent.clientX,n=t.srcEvent.clientY,i=0;i<this.lastTouches.length;i++){var s=this.lastTouches[i],o=Math.abs(e-s.x),a=Math.abs(n-s.y);if(o<=25&&a<=25)return!0}return!1}b(dt,F,{handler:function(t,e,n){var i=n.pointerType==O,s=n.pointerType==W;if(!(s&&n.sourceCapabilities&&n.sourceCapabilities.firesTouchEvents)){if(i)ht.call(this,e,n);else if(s&>.call(this,n))return;this.callback(t,e,n)}},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var pt=P(r.style,"touchAction"),mt=pt!==s,ft="compute",bt="auto",yt="manipulation",xt="none",vt="pan-x",wt="pan-y",kt=function(){if(!mt)return!1;var t={},n=e.CSS&&e.CSS.supports;return["auto","manipulation","pan-y","pan-x","pan-x pan-y","none"].forEach((function(i){t[i]=!n||e.CSS.supports("touch-action",i)})),t}();function St(t,e){this.manager=t,this.set(e)}St.prototype={set:function(t){t==ft&&(t=this.compute()),mt&&this.manager.element.style&&kt[t]&&(this.manager.element.style[pt]=t),this.actions=t.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var t=[];return g(this.manager.recognizers,(function(e){x(e.options.enable,[e])&&(t=t.concat(e.getTouchAction()))})),function(t){if(M(t,xt))return xt;var e=M(t,vt),n=M(t,wt);if(e&&n)return xt;if(e||n)return e?vt:wt;if(M(t,yt))return yt;return bt}(t.join(" "))},preventDefaults:function(t){var e=t.srcEvent,n=t.offsetDirection;if(this.manager.session.prevented)e.preventDefault();else{var i=this.actions,s=M(i,xt)&&!kt[xt],o=M(i,wt)&&!kt[wt],a=M(i,vt)&&!kt[vt];if(s){var r=1===t.pointers.length,l=t.distance<2,c=t.deltaTime<250;if(r&&l&&c)return}if(!a||!o)return s||o&&6&n||a&&n&N?this.preventSrc(e):void 0}},preventSrc:function(t){this.manager.session.prevented=!0,t.preventDefault()}};var Mt=32;function Ct(t){this.options=o({},this.defaults,t||{}),this.id=E++,this.manager=null,this.options.enable=v(this.options.enable,!0),this.state=1,this.simultaneous={},this.requireFail=[]}function _t(t){return 16&t?"cancel":8&t?"end":4&t?"move":2&t?"start":""}function Tt(t){return 16==t?"down":8==t?"up":2==t?"left":4==t?"right":""}function Dt(t,e){var n=e.manager;return n?n.get(t):t}function Pt(){Ct.apply(this,arguments)}function Et(){Pt.apply(this,arguments),this.pX=null,this.pY=null}function Lt(){Pt.apply(this,arguments)}function At(){Ct.apply(this,arguments),this._timer=null,this._input=null}function It(){Pt.apply(this,arguments)}function zt(){Pt.apply(this,arguments)}function Ot(){Ct.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}function Wt(t,e){return(e=e||{}).recognizers=v(e.recognizers,Wt.defaults.preset),new Nt(t,e)}Ct.prototype={defaults:{},set:function(t){return o(this.options,t),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(t){if(u(t,"recognizeWith",this))return this;var e=this.simultaneous;return e[(t=Dt(t,this)).id]||(e[t.id]=t,t.recognizeWith(this)),this},dropRecognizeWith:function(t){return u(t,"dropRecognizeWith",this)||(t=Dt(t,this),delete this.simultaneous[t.id]),this},requireFailure:function(t){if(u(t,"requireFailure",this))return this;var e=this.requireFail;return-1===_(e,t=Dt(t,this))&&(e.push(t),t.requireFailure(this)),this},dropRequireFailure:function(t){if(u(t,"dropRequireFailure",this))return this;t=Dt(t,this);var e=_(this.requireFail,t);return e>-1&&this.requireFail.splice(e,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(t){return!!this.simultaneous[t.id]},emit:function(t){var e=this,n=this.state;function i(n){e.manager.emit(n,t)}n<8&&i(e.options.event+_t(n)),i(e.options.event),t.additionalEvent&&i(t.additionalEvent),n>=8&&i(e.options.event+_t(n))},tryEmit:function(t){if(this.canEmit())return this.emit(t);this.state=Mt},canEmit:function(){for(var t=0;t<this.requireFail.length;){if(!(33&this.requireFail[t].state))return!1;t++}return!0},recognize:function(t){var e=o({},t);if(!x(this.options.enable,[this,e]))return this.reset(),void(this.state=Mt);56&this.state&&(this.state=1),this.state=this.process(e),30&this.state&&this.tryEmit(e)},process:function(t){},getTouchAction:function(){},reset:function(){}},b(Pt,Ct,{defaults:{pointers:1},attrTest:function(t){var e=this.options.pointers;return 0===e||t.pointers.length===e},process:function(t){var e=this.state,n=t.eventType,i=6&e,s=this.attrTest(t);return i&&(8&n||!s)?16|e:i||s?4&n?8|e:2&e?4|e:2:Mt}}),b(Et,Pt,{defaults:{event:"pan",threshold:10,pointers:1,direction:30},getTouchAction:function(){var t=this.options.direction,e=[];return 6&t&&e.push(wt),t&N&&e.push(vt),e},directionTest:function(t){var e=this.options,n=!0,i=t.distance,s=t.direction,o=t.deltaX,a=t.deltaY;return s&e.direction||(6&e.direction?(s=0===o?1:o<0?2:4,n=o!=this.pX,i=Math.abs(t.deltaX)):(s=0===a?1:a<0?8:16,n=a!=this.pY,i=Math.abs(t.deltaY))),t.direction=s,n&&i>e.threshold&&s&e.direction},attrTest:function(t){return Pt.prototype.attrTest.call(this,t)&&(2&this.state||!(2&this.state)&&this.directionTest(t))},emit:function(t){this.pX=t.deltaX,this.pY=t.deltaY;var e=Tt(t.direction);e&&(t.additionalEvent=this.options.event+e),this._super.emit.call(this,t)}}),b(Lt,Pt,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[xt]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.scale-1)>this.options.threshold||2&this.state)},emit:function(t){if(1!==t.scale){var e=t.scale<1?"in":"out";t.additionalEvent=this.options.event+e}this._super.emit.call(this,t)}}),b(At,Ct,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[bt]},process:function(t){var e=this.options,n=t.pointers.length===e.pointers,i=t.distance<e.threshold,s=t.deltaTime>e.time;if(this._input=t,!i||!n||12&t.eventType&&!s)this.reset();else if(1&t.eventType)this.reset(),this._timer=h((function(){this.state=8,this.tryEmit()}),e.time,this);else if(4&t.eventType)return 8;return Mt},reset:function(){clearTimeout(this._timer)},emit:function(t){8===this.state&&(t&&4&t.eventType?this.manager.emit(this.options.event+"up",t):(this._input.timeStamp=d(),this.manager.emit(this.options.event,this._input)))}}),b(It,Pt,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[xt]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.rotation)>this.options.threshold||2&this.state)}}),b(zt,Pt,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:30,pointers:1},getTouchAction:function(){return Et.prototype.getTouchAction.call(this)},attrTest:function(t){var e,n=this.options.direction;return 30&n?e=t.overallVelocity:6&n?e=t.overallVelocityX:n&N&&(e=t.overallVelocityY),this._super.attrTest.call(this,t)&&n&t.offsetDirection&&t.distance>this.options.threshold&&t.maxPointers==this.options.pointers&&c(e)>this.options.velocity&&4&t.eventType},emit:function(t){var e=Tt(t.offsetDirection);e&&this.manager.emit(this.options.event+e,t),this.manager.emit(this.options.event,t)}}),b(Ot,Ct,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[yt]},process:function(t){var e=this.options,n=t.pointers.length===e.pointers,i=t.distance<e.threshold,s=t.deltaTime<e.time;if(this.reset(),1&t.eventType&&0===this.count)return this.failTimeout();if(i&&s&&n){if(4!=t.eventType)return this.failTimeout();var o=!this.pTime||t.timeStamp-this.pTime<e.interval,a=!this.pCenter||j(this.pCenter,t.center)<e.posThreshold;if(this.pTime=t.timeStamp,this.pCenter=t.center,a&&o?this.count+=1:this.count=1,this._input=t,0===this.count%e.taps)return this.hasRequireFailures()?(this._timer=h((function(){this.state=8,this.tryEmit()}),e.interval,this),2):8}return Mt},failTimeout:function(){return this._timer=h((function(){this.state=Mt}),this.options.interval,this),Mt},reset:function(){clearTimeout(this._timer)},emit:function(){8==this.state&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))}}),Wt.VERSION="2.0.7",Wt.defaults={domEvents:!1,touchAction:ft,enable:!0,inputTarget:null,inputClass:null,preset:[[It,{enable:!1}],[Lt,{enable:!1},["rotate"]],[zt,{direction:6}],[Et,{direction:6},["swipe"]],[Ot],[Ot,{event:"doubletap",taps:2},["tap"]],[At]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};function Nt(t,e){var n;this.options=o({},Wt.defaults,e||{}),this.options.inputTarget=this.options.inputTarget||t,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=t,this.input=new((n=this).options.inputClass||(I?nt:z?lt:A?dt:K))(n,B),this.touchAction=new St(this,this.options.touchAction),Rt(this,!0),g(this.options.recognizers,(function(t){var e=this.add(new t[0](t[1]));t[2]&&e.recognizeWith(t[2]),t[3]&&e.requireFailure(t[3])}),this)}function Rt(t,e){var n,i=t.element;i.style&&(g(t.options.cssProps,(function(s,o){n=P(i.style,o),e?(t.oldCssProps[n]=i.style[n],i.style[n]=s):i.style[n]=t.oldCssProps[n]||""})),e||(t.oldCssProps={}))}Nt.prototype={set:function(t){return o(this.options,t),t.touchAction&&this.touchAction.update(),t.inputTarget&&(this.input.destroy(),this.input.target=t.inputTarget,this.input.init()),this},stop:function(t){this.session.stopped=t?2:1},recognize:function(t){var e=this.session;if(!e.stopped){var n;this.touchAction.preventDefaults(t);var i=this.recognizers,s=e.curRecognizer;(!s||s&&8&s.state)&&(s=e.curRecognizer=null);for(var o=0;o<i.length;)n=i[o],2===e.stopped||s&&n!=s&&!n.canRecognizeWith(s)?n.reset():n.recognize(t),!s&&14&n.state&&(s=e.curRecognizer=n),o++}},get:function(t){if(t instanceof Ct)return t;for(var e=this.recognizers,n=0;n<e.length;n++)if(e[n].options.event==t)return e[n];return null},add:function(t){if(u(t,"add",this))return this;var e=this.get(t.options.event);return e&&this.remove(e),this.recognizers.push(t),t.manager=this,this.touchAction.update(),t},remove:function(t){if(u(t,"remove",this))return this;if(t=this.get(t)){var e=this.recognizers,n=_(e,t);-1!==n&&(e.splice(n,1),this.touchAction.update())}return this},on:function(t,e){if(t!==s&&e!==s){var n=this.handlers;return g(C(t),(function(t){n[t]=n[t]||[],n[t].push(e)})),this}},off:function(t,e){if(t!==s){var n=this.handlers;return g(C(t),(function(t){e?n[t]&&n[t].splice(_(n[t],e),1):delete n[t]})),this}},emit:function(t,e){this.options.domEvents&&function(t,e){var i=n.createEvent("Event");i.initEvent(t,!0,!0),i.gesture=e,e.target.dispatchEvent(i)}(t,e);var i=this.handlers[t]&&this.handlers[t].slice();if(i&&i.length){e.type=t,e.preventDefault=function(){e.srcEvent.preventDefault()};for(var s=0;s<i.length;)i[s](e),s++}},destroy:function(){this.element&&Rt(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}},o(Wt,{INPUT_START:1,INPUT_MOVE:2,INPUT_END:4,INPUT_CANCEL:8,STATE_POSSIBLE:1,STATE_BEGAN:2,STATE_CHANGED:4,STATE_ENDED:8,STATE_RECOGNIZED:8,STATE_CANCELLED:16,STATE_FAILED:Mt,DIRECTION_NONE:1,DIRECTION_LEFT:2,DIRECTION_RIGHT:4,DIRECTION_UP:8,DIRECTION_DOWN:16,DIRECTION_HORIZONTAL:6,DIRECTION_VERTICAL:N,DIRECTION_ALL:30,Manager:Nt,Input:F,TouchAction:St,TouchInput:lt,MouseInput:K,PointerEventInput:nt,TouchMouseInput:dt,SingleTouchInput:st,Recognizer:Ct,AttrRecognizer:Pt,Tap:Ot,Pan:Et,Swipe:zt,Pinch:Lt,Rotate:It,Press:At,on:w,off:k,each:g,merge:f,extend:m,assign:o,inherit:b,bindFn:y,prefixed:P}),(void 0!==e?e:"undefined"!=typeof self?self:{}).Hammer=Wt,t.exports?t.exports=Wt:e.Hammer=Wt}(window,document)}(Sh);var Mh=kh(Sh.exports);
|
|
38
|
+
* Licensed under the MIT license */!function(t){!function(e,n,i,s){var o,a=["","webkit","Moz","MS","ms","o"],r=n.createElement("div"),l=Math.round,c=Math.abs,d=Date.now;function h(t,e,n){return setTimeout(y(t,n),e)}function u(t,e,n){return!!Array.isArray(t)&&(g(t,n[e],n),!0)}function g(t,e,n){var i;if(t)if(t.forEach)t.forEach(e,n);else if(t.length!==s)for(i=0;i<t.length;)e.call(n,t[i],i,t),i++;else for(i in t)t.hasOwnProperty(i)&&e.call(n,t[i],i,t)}function p(t,n,i){var s="DEPRECATED METHOD: "+n+"\n"+i+" AT \n";return function(){var n=new Error("get-stack-trace"),i=n&&n.stack?n.stack.replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",o=e.console&&(e.console.warn||e.console.log);return o&&o.call(e.console,s,i),t.apply(this,arguments)}}o="function"!=typeof Object.assign?function(t){if(t===s||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n<arguments.length;n++){var i=arguments[n];if(i!==s&&null!==i)for(var o in i)i.hasOwnProperty(o)&&(e[o]=i[o])}return e}:Object.assign;var m=p((function(t,e,n){for(var i=Object.keys(e),o=0;o<i.length;)(!n||n&&t[i[o]]===s)&&(t[i[o]]=e[i[o]]),o++;return t}),"extend","Use `assign`."),f=p((function(t,e){return m(t,e,!0)}),"merge","Use `assign`.");function b(t,e,n){var i,s=e.prototype;(i=t.prototype=Object.create(s)).constructor=t,i._super=s,n&&o(i,n)}function y(t,e){return function(){return t.apply(e,arguments)}}function x(t,e){return"function"==typeof t?t.apply(e&&e[0]||s,e):t}function v(t,e){return t===s?e:t}function w(t,e,n){g(C(e),(function(e){t.addEventListener(e,n,!1)}))}function k(t,e,n){g(C(e),(function(e){t.removeEventListener(e,n,!1)}))}function S(t,e){for(;t;){if(t==e)return!0;t=t.parentNode}return!1}function M(t,e){return t.indexOf(e)>-1}function C(t){return t.trim().split(/\s+/g)}function _(t,e,n){if(t.indexOf&&!n)return t.indexOf(e);for(var i=0;i<t.length;){if(n&&t[i][n]==e||!n&&t[i]===e)return i;i++}return-1}function T(t){return Array.prototype.slice.call(t,0)}function D(t,e,n){for(var i=[],s=[],o=0;o<t.length;){var a=e?t[o][e]:t[o];_(s,a)<0&&i.push(t[o]),s[o]=a,o++}return n&&(i=e?i.sort((function(t,n){return t[e]>n[e]})):i.sort()),i}function P(t,e){for(var n,i,o=e[0].toUpperCase()+e.slice(1),r=0;r<a.length;){if((i=(n=a[r])?n+o:e)in t)return i;r++}return s}var E=1;function L(t){var n=t.ownerDocument||t;return n.defaultView||n.parentWindow||e}var A="ontouchstart"in e,I=P(e,"PointerEvent")!==s,z=A&&/mobile|tablet|ip(ad|hone|od)|android/i.test(navigator.userAgent),O="touch",W="mouse",N=24,$=["x","y"],R=["clientX","clientY"];function F(t,e){var n=this;this.manager=t,this.callback=e,this.element=t.element,this.target=t.options.inputTarget,this.domHandler=function(e){x(t.options.enable,[t])&&n.handler(e)},this.init()}function B(t,e,n){var i=n.pointers.length,o=n.changedPointers.length,a=1&e&&i-o===0,r=12&e&&i-o===0;n.isFirst=!!a,n.isFinal=!!r,a&&(t.session={}),n.eventType=e,function(t,e){var n=t.session,i=e.pointers,o=i.length;n.firstInput||(n.firstInput=q(e));o>1&&!n.firstMultiple?n.firstMultiple=q(e):1===o&&(n.firstMultiple=!1);var a=n.firstInput,r=n.firstMultiple,l=r?r.center:a.center,h=e.center=H(i);e.timeStamp=d(),e.deltaTime=e.timeStamp-a.timeStamp,e.angle=U(l,h),e.distance=Y(l,h),function(t,e){var n=e.center,i=t.offsetDelta||{},s=t.prevDelta||{},o=t.prevInput||{};1!==e.eventType&&4!==o.eventType||(s=t.prevDelta={x:o.deltaX||0,y:o.deltaY||0},i=t.offsetDelta={x:n.x,y:n.y});e.deltaX=s.x+(n.x-i.x),e.deltaY=s.y+(n.y-i.y)}(n,e),e.offsetDirection=j(e.deltaX,e.deltaY);var u=V(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=u.x,e.overallVelocityY=u.y,e.overallVelocity=c(u.x)>c(u.y)?u.x:u.y,e.scale=r?(g=r.pointers,p=i,Y(p[0],p[1],R)/Y(g[0],g[1],R)):1,e.rotation=r?function(t,e){return U(e[1],e[0],R)+U(t[1],t[0],R)}(r.pointers,i):0,e.maxPointers=n.prevInput?e.pointers.length>n.prevInput.maxPointers?e.pointers.length:n.prevInput.maxPointers:e.pointers.length,function(t,e){var n,i,o,a,r=t.lastInterval||e,l=e.timeStamp-r.timeStamp;if(8!=e.eventType&&(l>25||r.velocity===s)){var d=e.deltaX-r.deltaX,h=e.deltaY-r.deltaY,u=V(l,d,h);i=u.x,o=u.y,n=c(u.x)>c(u.y)?u.x:u.y,a=j(d,h),t.lastInterval=e}else n=r.velocity,i=r.velocityX,o=r.velocityY,a=r.direction;e.velocity=n,e.velocityX=i,e.velocityY=o,e.direction=a}(n,e);var g,p;var m=t.element;S(e.srcEvent.target,m)&&(m=e.srcEvent.target);e.target=m}(t,n),t.emit("hammer.input",n),t.recognize(n),t.session.prevInput=n}function q(t){for(var e=[],n=0;n<t.pointers.length;)e[n]={clientX:l(t.pointers[n].clientX),clientY:l(t.pointers[n].clientY)},n++;return{timeStamp:d(),pointers:e,center:H(e),deltaX:t.deltaX,deltaY:t.deltaY}}function H(t){var e=t.length;if(1===e)return{x:l(t[0].clientX),y:l(t[0].clientY)};for(var n=0,i=0,s=0;s<e;)n+=t[s].clientX,i+=t[s].clientY,s++;return{x:l(n/e),y:l(i/e)}}function V(t,e,n){return{x:e/t||0,y:n/t||0}}function j(t,e){return t===e?1:c(t)>=c(e)?t<0?2:4:e<0?8:16}function Y(t,e,n){n||(n=$);var i=e[n[0]]-t[n[0]],s=e[n[1]]-t[n[1]];return Math.sqrt(i*i+s*s)}function U(t,e,n){n||(n=$);var i=e[n[0]]-t[n[0]],s=e[n[1]]-t[n[1]];return 180*Math.atan2(s,i)/Math.PI}F.prototype={handler:function(){},init:function(){this.evEl&&w(this.element,this.evEl,this.domHandler),this.evTarget&&w(this.target,this.evTarget,this.domHandler),this.evWin&&w(L(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&k(this.element,this.evEl,this.domHandler),this.evTarget&&k(this.target,this.evTarget,this.domHandler),this.evWin&&k(L(this.element),this.evWin,this.domHandler)}};var X={mousedown:1,mousemove:2,mouseup:4},Q="mousedown",G="mousemove mouseup";function K(){this.evEl=Q,this.evWin=G,this.pressed=!1,F.apply(this,arguments)}b(K,F,{handler:function(t){var e=X[t.type];1&e&&0===t.button&&(this.pressed=!0),2&e&&1!==t.which&&(e=4),this.pressed&&(4&e&&(this.pressed=!1),this.callback(this.manager,e,{pointers:[t],changedPointers:[t],pointerType:W,srcEvent:t}))}});var Z={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},J={2:O,3:"pen",4:W,5:"kinect"},tt="pointerdown",et="pointermove pointerup pointercancel";function nt(){this.evEl=tt,this.evWin=et,F.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}e.MSPointerEvent&&!e.PointerEvent&&(tt="MSPointerDown",et="MSPointerMove MSPointerUp MSPointerCancel"),b(nt,F,{handler:function(t){var e=this.store,n=!1,i=t.type.toLowerCase().replace("ms",""),s=Z[i],o=J[t.pointerType]||t.pointerType,a=o==O,r=_(e,t.pointerId,"pointerId");1&s&&(0===t.button||a)?r<0&&(e.push(t),r=e.length-1):12&s&&(n=!0),r<0||(e[r]=t,this.callback(this.manager,s,{pointers:e,changedPointers:[t],pointerType:o,srcEvent:t}),n&&e.splice(r,1))}});var it={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function st(){this.evTarget="touchstart",this.evWin="touchstart touchmove touchend touchcancel",this.started=!1,F.apply(this,arguments)}function ot(t,e){var n=T(t.touches),i=T(t.changedTouches);return 12&e&&(n=D(n.concat(i),"identifier",!0)),[n,i]}b(st,F,{handler:function(t){var e=it[t.type];if(1===e&&(this.started=!0),this.started){var n=ot.call(this,t,e);12&e&&n[0].length-n[1].length===0&&(this.started=!1),this.callback(this.manager,e,{pointers:n[0],changedPointers:n[1],pointerType:O,srcEvent:t})}}});var at={touchstart:1,touchmove:2,touchend:4,touchcancel:8},rt="touchstart touchmove touchend touchcancel";function lt(){this.evTarget=rt,this.targetIds={},F.apply(this,arguments)}function ct(t,e){var n=T(t.touches),i=this.targetIds;if(3&e&&1===n.length)return i[n[0].identifier]=!0,[n,n];var s,o,a=T(t.changedTouches),r=[],l=this.target;if(o=n.filter((function(t){return S(t.target,l)})),1===e)for(s=0;s<o.length;)i[o[s].identifier]=!0,s++;for(s=0;s<a.length;)i[a[s].identifier]&&r.push(a[s]),12&e&&delete i[a[s].identifier],s++;return r.length?[D(o.concat(r),"identifier",!0),r]:void 0}b(lt,F,{handler:function(t){var e=at[t.type],n=ct.call(this,t,e);n&&this.callback(this.manager,e,{pointers:n[0],changedPointers:n[1],pointerType:O,srcEvent:t})}});function dt(){F.apply(this,arguments);var t=y(this.handler,this);this.touch=new lt(this.manager,t),this.mouse=new K(this.manager,t),this.primaryTouch=null,this.lastTouches=[]}function ht(t,e){1&t?(this.primaryTouch=e.changedPointers[0].identifier,ut.call(this,e)):12&t&&ut.call(this,e)}function ut(t){var e=t.changedPointers[0];if(e.identifier===this.primaryTouch){var n={x:e.clientX,y:e.clientY};this.lastTouches.push(n);var i=this.lastTouches;setTimeout((function(){var t=i.indexOf(n);t>-1&&i.splice(t,1)}),2500)}}function gt(t){for(var e=t.srcEvent.clientX,n=t.srcEvent.clientY,i=0;i<this.lastTouches.length;i++){var s=this.lastTouches[i],o=Math.abs(e-s.x),a=Math.abs(n-s.y);if(o<=25&&a<=25)return!0}return!1}b(dt,F,{handler:function(t,e,n){var i=n.pointerType==O,s=n.pointerType==W;if(!(s&&n.sourceCapabilities&&n.sourceCapabilities.firesTouchEvents)){if(i)ht.call(this,e,n);else if(s&>.call(this,n))return;this.callback(t,e,n)}},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var pt=P(r.style,"touchAction"),mt=pt!==s,ft="compute",bt="auto",yt="manipulation",xt="none",vt="pan-x",wt="pan-y",kt=function(){if(!mt)return!1;var t={},n=e.CSS&&e.CSS.supports;return["auto","manipulation","pan-y","pan-x","pan-x pan-y","none"].forEach((function(i){t[i]=!n||e.CSS.supports("touch-action",i)})),t}();function St(t,e){this.manager=t,this.set(e)}St.prototype={set:function(t){t==ft&&(t=this.compute()),mt&&this.manager.element.style&&kt[t]&&(this.manager.element.style[pt]=t),this.actions=t.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var t=[];return g(this.manager.recognizers,(function(e){x(e.options.enable,[e])&&(t=t.concat(e.getTouchAction()))})),function(t){if(M(t,xt))return xt;var e=M(t,vt),n=M(t,wt);if(e&&n)return xt;if(e||n)return e?vt:wt;if(M(t,yt))return yt;return bt}(t.join(" "))},preventDefaults:function(t){var e=t.srcEvent,n=t.offsetDirection;if(this.manager.session.prevented)e.preventDefault();else{var i=this.actions,s=M(i,xt)&&!kt[xt],o=M(i,wt)&&!kt[wt],a=M(i,vt)&&!kt[vt];if(s){var r=1===t.pointers.length,l=t.distance<2,c=t.deltaTime<250;if(r&&l&&c)return}if(!a||!o)return s||o&&6&n||a&&n&N?this.preventSrc(e):void 0}},preventSrc:function(t){this.manager.session.prevented=!0,t.preventDefault()}};var Mt=32;function Ct(t){this.options=o({},this.defaults,t||{}),this.id=E++,this.manager=null,this.options.enable=v(this.options.enable,!0),this.state=1,this.simultaneous={},this.requireFail=[]}function _t(t){return 16&t?"cancel":8&t?"end":4&t?"move":2&t?"start":""}function Tt(t){return 16==t?"down":8==t?"up":2==t?"left":4==t?"right":""}function Dt(t,e){var n=e.manager;return n?n.get(t):t}function Pt(){Ct.apply(this,arguments)}function Et(){Pt.apply(this,arguments),this.pX=null,this.pY=null}function Lt(){Pt.apply(this,arguments)}function At(){Ct.apply(this,arguments),this._timer=null,this._input=null}function It(){Pt.apply(this,arguments)}function zt(){Pt.apply(this,arguments)}function Ot(){Ct.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}function Wt(t,e){return(e=e||{}).recognizers=v(e.recognizers,Wt.defaults.preset),new Nt(t,e)}Ct.prototype={defaults:{},set:function(t){return o(this.options,t),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(t){if(u(t,"recognizeWith",this))return this;var e=this.simultaneous;return e[(t=Dt(t,this)).id]||(e[t.id]=t,t.recognizeWith(this)),this},dropRecognizeWith:function(t){return u(t,"dropRecognizeWith",this)||(t=Dt(t,this),delete this.simultaneous[t.id]),this},requireFailure:function(t){if(u(t,"requireFailure",this))return this;var e=this.requireFail;return-1===_(e,t=Dt(t,this))&&(e.push(t),t.requireFailure(this)),this},dropRequireFailure:function(t){if(u(t,"dropRequireFailure",this))return this;t=Dt(t,this);var e=_(this.requireFail,t);return e>-1&&this.requireFail.splice(e,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(t){return!!this.simultaneous[t.id]},emit:function(t){var e=this,n=this.state;function i(n){e.manager.emit(n,t)}n<8&&i(e.options.event+_t(n)),i(e.options.event),t.additionalEvent&&i(t.additionalEvent),n>=8&&i(e.options.event+_t(n))},tryEmit:function(t){if(this.canEmit())return this.emit(t);this.state=Mt},canEmit:function(){for(var t=0;t<this.requireFail.length;){if(!(33&this.requireFail[t].state))return!1;t++}return!0},recognize:function(t){var e=o({},t);if(!x(this.options.enable,[this,e]))return this.reset(),void(this.state=Mt);56&this.state&&(this.state=1),this.state=this.process(e),30&this.state&&this.tryEmit(e)},process:function(t){},getTouchAction:function(){},reset:function(){}},b(Pt,Ct,{defaults:{pointers:1},attrTest:function(t){var e=this.options.pointers;return 0===e||t.pointers.length===e},process:function(t){var e=this.state,n=t.eventType,i=6&e,s=this.attrTest(t);return i&&(8&n||!s)?16|e:i||s?4&n?8|e:2&e?4|e:2:Mt}}),b(Et,Pt,{defaults:{event:"pan",threshold:10,pointers:1,direction:30},getTouchAction:function(){var t=this.options.direction,e=[];return 6&t&&e.push(wt),t&N&&e.push(vt),e},directionTest:function(t){var e=this.options,n=!0,i=t.distance,s=t.direction,o=t.deltaX,a=t.deltaY;return s&e.direction||(6&e.direction?(s=0===o?1:o<0?2:4,n=o!=this.pX,i=Math.abs(t.deltaX)):(s=0===a?1:a<0?8:16,n=a!=this.pY,i=Math.abs(t.deltaY))),t.direction=s,n&&i>e.threshold&&s&e.direction},attrTest:function(t){return Pt.prototype.attrTest.call(this,t)&&(2&this.state||!(2&this.state)&&this.directionTest(t))},emit:function(t){this.pX=t.deltaX,this.pY=t.deltaY;var e=Tt(t.direction);e&&(t.additionalEvent=this.options.event+e),this._super.emit.call(this,t)}}),b(Lt,Pt,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[xt]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.scale-1)>this.options.threshold||2&this.state)},emit:function(t){if(1!==t.scale){var e=t.scale<1?"in":"out";t.additionalEvent=this.options.event+e}this._super.emit.call(this,t)}}),b(At,Ct,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[bt]},process:function(t){var e=this.options,n=t.pointers.length===e.pointers,i=t.distance<e.threshold,s=t.deltaTime>e.time;if(this._input=t,!i||!n||12&t.eventType&&!s)this.reset();else if(1&t.eventType)this.reset(),this._timer=h((function(){this.state=8,this.tryEmit()}),e.time,this);else if(4&t.eventType)return 8;return Mt},reset:function(){clearTimeout(this._timer)},emit:function(t){8===this.state&&(t&&4&t.eventType?this.manager.emit(this.options.event+"up",t):(this._input.timeStamp=d(),this.manager.emit(this.options.event,this._input)))}}),b(It,Pt,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[xt]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.rotation)>this.options.threshold||2&this.state)}}),b(zt,Pt,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:30,pointers:1},getTouchAction:function(){return Et.prototype.getTouchAction.call(this)},attrTest:function(t){var e,n=this.options.direction;return 30&n?e=t.overallVelocity:6&n?e=t.overallVelocityX:n&N&&(e=t.overallVelocityY),this._super.attrTest.call(this,t)&&n&t.offsetDirection&&t.distance>this.options.threshold&&t.maxPointers==this.options.pointers&&c(e)>this.options.velocity&&4&t.eventType},emit:function(t){var e=Tt(t.offsetDirection);e&&this.manager.emit(this.options.event+e,t),this.manager.emit(this.options.event,t)}}),b(Ot,Ct,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[yt]},process:function(t){var e=this.options,n=t.pointers.length===e.pointers,i=t.distance<e.threshold,s=t.deltaTime<e.time;if(this.reset(),1&t.eventType&&0===this.count)return this.failTimeout();if(i&&s&&n){if(4!=t.eventType)return this.failTimeout();var o=!this.pTime||t.timeStamp-this.pTime<e.interval,a=!this.pCenter||Y(this.pCenter,t.center)<e.posThreshold;if(this.pTime=t.timeStamp,this.pCenter=t.center,a&&o?this.count+=1:this.count=1,this._input=t,0===this.count%e.taps)return this.hasRequireFailures()?(this._timer=h((function(){this.state=8,this.tryEmit()}),e.interval,this),2):8}return Mt},failTimeout:function(){return this._timer=h((function(){this.state=Mt}),this.options.interval,this),Mt},reset:function(){clearTimeout(this._timer)},emit:function(){8==this.state&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))}}),Wt.VERSION="2.0.7",Wt.defaults={domEvents:!1,touchAction:ft,enable:!0,inputTarget:null,inputClass:null,preset:[[It,{enable:!1}],[Lt,{enable:!1},["rotate"]],[zt,{direction:6}],[Et,{direction:6},["swipe"]],[Ot],[Ot,{event:"doubletap",taps:2},["tap"]],[At]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};function Nt(t,e){var n;this.options=o({},Wt.defaults,e||{}),this.options.inputTarget=this.options.inputTarget||t,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=t,this.input=new((n=this).options.inputClass||(I?nt:z?lt:A?dt:K))(n,B),this.touchAction=new St(this,this.options.touchAction),$t(this,!0),g(this.options.recognizers,(function(t){var e=this.add(new t[0](t[1]));t[2]&&e.recognizeWith(t[2]),t[3]&&e.requireFailure(t[3])}),this)}function $t(t,e){var n,i=t.element;i.style&&(g(t.options.cssProps,(function(s,o){n=P(i.style,o),e?(t.oldCssProps[n]=i.style[n],i.style[n]=s):i.style[n]=t.oldCssProps[n]||""})),e||(t.oldCssProps={}))}Nt.prototype={set:function(t){return o(this.options,t),t.touchAction&&this.touchAction.update(),t.inputTarget&&(this.input.destroy(),this.input.target=t.inputTarget,this.input.init()),this},stop:function(t){this.session.stopped=t?2:1},recognize:function(t){var e=this.session;if(!e.stopped){var n;this.touchAction.preventDefaults(t);var i=this.recognizers,s=e.curRecognizer;(!s||s&&8&s.state)&&(s=e.curRecognizer=null);for(var o=0;o<i.length;)n=i[o],2===e.stopped||s&&n!=s&&!n.canRecognizeWith(s)?n.reset():n.recognize(t),!s&&14&n.state&&(s=e.curRecognizer=n),o++}},get:function(t){if(t instanceof Ct)return t;for(var e=this.recognizers,n=0;n<e.length;n++)if(e[n].options.event==t)return e[n];return null},add:function(t){if(u(t,"add",this))return this;var e=this.get(t.options.event);return e&&this.remove(e),this.recognizers.push(t),t.manager=this,this.touchAction.update(),t},remove:function(t){if(u(t,"remove",this))return this;if(t=this.get(t)){var e=this.recognizers,n=_(e,t);-1!==n&&(e.splice(n,1),this.touchAction.update())}return this},on:function(t,e){if(t!==s&&e!==s){var n=this.handlers;return g(C(t),(function(t){n[t]=n[t]||[],n[t].push(e)})),this}},off:function(t,e){if(t!==s){var n=this.handlers;return g(C(t),(function(t){e?n[t]&&n[t].splice(_(n[t],e),1):delete n[t]})),this}},emit:function(t,e){this.options.domEvents&&function(t,e){var i=n.createEvent("Event");i.initEvent(t,!0,!0),i.gesture=e,e.target.dispatchEvent(i)}(t,e);var i=this.handlers[t]&&this.handlers[t].slice();if(i&&i.length){e.type=t,e.preventDefault=function(){e.srcEvent.preventDefault()};for(var s=0;s<i.length;)i[s](e),s++}},destroy:function(){this.element&&$t(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}},o(Wt,{INPUT_START:1,INPUT_MOVE:2,INPUT_END:4,INPUT_CANCEL:8,STATE_POSSIBLE:1,STATE_BEGAN:2,STATE_CHANGED:4,STATE_ENDED:8,STATE_RECOGNIZED:8,STATE_CANCELLED:16,STATE_FAILED:Mt,DIRECTION_NONE:1,DIRECTION_LEFT:2,DIRECTION_RIGHT:4,DIRECTION_UP:8,DIRECTION_DOWN:16,DIRECTION_HORIZONTAL:6,DIRECTION_VERTICAL:N,DIRECTION_ALL:30,Manager:Nt,Input:F,TouchAction:St,TouchInput:lt,MouseInput:K,PointerEventInput:nt,TouchMouseInput:dt,SingleTouchInput:st,Recognizer:Ct,AttrRecognizer:Pt,Tap:Ot,Pan:Et,Swipe:zt,Pinch:Lt,Rotate:It,Press:At,on:w,off:k,each:g,merge:f,extend:m,assign:o,inherit:b,bindFn:y,prefixed:P}),(void 0!==e?e:"undefined"!=typeof self?self:{}).Hammer=Wt,t.exports?t.exports=Wt:e.Hammer=Wt}(window,document)}(Dh);var Ph=Th(Dh.exports);
|
|
39
39
|
/*!
|
|
40
40
|
* chartjs-plugin-zoom v2.2.0
|
|
41
41
|
* https://www.chartjs.org/chartjs-plugin-zoom/2.2.0/
|
|
42
42
|
* (c) 2016-2024 chartjs-plugin-zoom Contributors
|
|
43
43
|
* Released under the MIT License
|
|
44
44
|
*/
|
|
45
|
-
const Ch=t=>t&&t.enabled&&t.modifierKey,_h=(t,e)=>t&&e[t+"Key"],Th=(t,e)=>t&&!e[t+"Key"];function Dh(t,e,n){return void 0===t||("string"==typeof t?-1!==t.indexOf(e):"function"==typeof t&&-1!==t({chart:n}).indexOf(e))}function Ph(t,e){return"function"==typeof t&&(t=t({chart:e})),"string"==typeof t?{x:-1!==t.indexOf("x"),y:-1!==t.indexOf("y")}:{x:!1,y:!1}}function Eh(t,e,n){const{mode:i="xy",scaleMode:s,overScaleMode:o}=t||{},a=function({x:t,y:e},n){const i=n.scales,s=Object.keys(i);for(let n=0;n<s.length;n++){const o=i[s[n]];if(e>=o.top&&e<=o.bottom&&t>=o.left&&t<=o.right)return o}return null}(e,n),r=Ph(i,n),l=Ph(s,n);if(o){const t=Ph(o,n);for(const e of["x","y"])t[e]&&(l[e]=r[e],r[e]=!1)}if(a&&l[a.axis])return[a];const c=[];return xt(n.scales,(function(t){r[t.axis]&&c.push(t)})),c}const Lh=new WeakMap;function Ah(t){let e=Lh.get(t);return e||(e={originalScaleLimits:{},updatedScaleLimits:{},handlers:{},panDelta:{},dragging:!1,panning:!1},Lh.set(t,e)),e}function Ih(t,e,n,i){const s=Math.max(0,Math.min(1,(t-e)/n||0));return{min:i*s,max:i*(1-s)}}function zh(t,e){const n=t.isHorizontal()?e.x:e.y;return t.getValueForPixel(n)}function Oh(t,e,n){const i=t.max-t.min,s=i*(e-1);return Ih(zh(t,n),t.min,i,s)}function Wh(t,e,n,i,s){let o=n[i];if("original"===o){const n=t.originalScaleLimits[e.id][i];o=ft(n.options,n.scale)}return ft(o,s)}function Nh(t,{min:e,max:n},i,s=!1){const o=Ah(t.chart),{options:a}=t,r=function(t,e){return e&&(e[t.id]||e[t.axis])||{}}(t,i),{minRange:l=0}=r,c=Wh(o,t,r,"min",-1/0),d=Wh(o,t,r,"max",1/0);if("pan"===s&&(e<c||n>d))return!0;const h=t.max-t.min,u=s?Math.max(n-e,l):h;if(s&&u===l&&h<=l)return!0;const g=function(t,{min:e,max:n,minLimit:i,maxLimit:s},o){const a=(t-n+e)/2;e-=a,n+=a;const r=o.min.options??o.min.scale,l=o.max.options??o.max.scale,c=t/1e6;return Ht(e,r,c)&&(e=r),Ht(n,l,c)&&(n=l),e<i?(e=i,n=Math.min(i+t,s)):n>s&&(n=s,e=Math.max(s-t,i)),{min:e,max:n}}(u,{min:e,max:n,minLimit:c,maxLimit:d},o.originalScaleLimits[t.id]);return a.min=g.min,a.max=g.max,o.updatedScaleLimits[t.id]=g,t.parse(g.min)!==t.min||t.parse(g.max)!==t.max}const Rh=t=>0===t||isNaN(t)?0:t<0?Math.min(Math.round(t),-1):Math.max(Math.round(t),1);const $h={second:500,minute:3e4,hour:18e5,day:432e5,week:3024e5,month:1296e6,quarter:5184e6,year:157248e5};function Fh(t,e,n,i=!1){const{min:s,max:o,options:a}=t,r=a.time&&a.time.round,l=$h[r]||0,c=t.getValueForPixel(t.getPixelForValue(s+l)-e),d=t.getValueForPixel(t.getPixelForValue(o+l)-e);return!(!isNaN(c)&&!isNaN(d))||Nh(t,{min:c,max:d},n,!!i&&"pan")}function Bh(t,e,n){return Fh(t,e,n,!0)}const qh={category:function(t,e,n,i){const s=Oh(t,e,n);return t.min===t.max&&e<1&&function(t){const e=t.getLabels().length-1;t.min>0&&(t.min-=1),t.max<e&&(t.max+=1)}(t),Nh(t,{min:t.min+Rh(s.min),max:t.max-Rh(s.max)},i,!0)},default:function(t,e,n,i){const s=Oh(t,e,n);return Nh(t,{min:t.min+s.min,max:t.max-s.max},i,!0)},logarithmic:function(t,e,n,i){const s=function(t,e,n){const i=zh(t,n);if(void 0===i)return{min:t.min,max:t.max};const s=Math.log10(t.min),o=Math.log10(t.max),a=o-s,r=Ih(Math.log10(i),s,a,a*(e-1));return{min:Math.pow(10,s+r.min),max:Math.pow(10,o-r.max)}}(t,e,n);return Nh(t,s,i,!0)}},Hh={default:function(t,e,n,i){Nh(t,function(t,e,n){const i=t.getValueForPixel(e),s=t.getValueForPixel(n);return{min:Math.min(i,s),max:Math.max(i,s)}}(t,e,n),i,!0)}},Vh={category:function(t,e,n){const i=t.getLabels().length-1;let{min:s,max:o}=t;const a=Math.max(o-s,1),r=Math.round(function(t){return t.isHorizontal()?t.width:t.height}(t)/Math.max(a,10)),l=Math.round(Math.abs(e/r));let c;return e<-r?(o=Math.min(o+l,i),s=1===a?o:o-a,c=o===i):e>r&&(s=Math.max(0,s-l),o=1===a?s:s+a,c=0===s),Nh(t,{min:s,max:o},n)||c},default:Fh,logarithmic:Bh,timeseries:Bh};function Yh(t,e){xt(t,((n,i)=>{e[i]||delete t[i]}))}function jh(t,e){const{scales:n}=t,{originalScaleLimits:i,updatedScaleLimits:s}=e;return xt(n,(function(t){(function(t,e,n){const{id:i,options:{min:s,max:o}}=t;if(!e[i]||!n[i])return!0;const a=n[i];return a.min!==s||a.max!==o})(t,i,s)&&(i[t.id]={min:{scale:t.min,options:t.options.min},max:{scale:t.max,options:t.options.max}})})),Yh(i,n),Yh(s,n),i}function Uh(t,e,n,i){yt(qh[t.type]||qh.default,[t,e,n,i])}function Xh(t,e,n,i){yt(Hh[t.type]||Hh.default,[t,e,n,i])}function Qh(t){const e=t.chartArea;return{x:(e.left+e.right)/2,y:(e.top+e.bottom)/2}}function Gh(t,e,n="none",i="api"){const{x:s=1,y:o=1,focalPoint:a=Qh(t)}="number"==typeof e?{x:e,y:e}:e,r=Ah(t),{options:{limits:l,zoom:c}}=r;jh(t,r);const d=1!==s,h=1!==o;xt(Eh(c,a,t)||t.scales,(function(t){t.isHorizontal()&&d?Uh(t,s,a,l):!t.isHorizontal()&&h&&Uh(t,o,a,l)})),t.update(n),yt(c.onZoom,[{chart:t,trigger:i}])}function Kh(t,e,n,i="none",s="api"){const o=Ah(t),{options:{limits:a,zoom:r}}=o,{mode:l="xy"}=r;jh(t,o);const c=Dh(l,"x",t),d=Dh(l,"y",t);xt(t.scales,(function(t){t.isHorizontal()&&c?Xh(t,e.x,n.x,a):!t.isHorizontal()&&d&&Xh(t,e.y,n.y,a)})),t.update(i),yt(r.onZoom,[{chart:t,trigger:s}])}function Zh(t){const e=Ah(t);let n=1,i=1;return xt(t.scales,(function(t){const s=function(t,e){const n=t.originalScaleLimits[e];if(!n)return;const{min:i,max:s}=n;return ft(s.options,s.scale)-ft(i.options,i.scale)}(e,t.id);if(s){const e=Math.round(s/(t.max-t.min)*100)/100;n=Math.min(n,e),i=Math.max(i,e)}})),n<1?n:i}function Jh(t,e,n,i){const{panDelta:s}=i,o=s[t.id]||0;qt(o)===qt(e)&&(e+=o);yt(Vh[t.type]||Vh.default,[t,e,n])?s[t.id]=0:s[t.id]=e}function tu(t,e,n,i="none"){const{x:s=0,y:o=0}="number"==typeof e?{x:e,y:e}:e,a=Ah(t),{options:{pan:r,limits:l}}=a,{onPan:c}=r||{};jh(t,a);const d=0!==s,h=0!==o;xt(n||t.scales,(function(t){t.isHorizontal()&&d?Jh(t,s,l,a):!t.isHorizontal()&&h&&Jh(t,o,l,a)})),t.update(i),yt(c,[{chart:t}])}function eu(t){const e=Ah(t);jh(t,e);const n={};for(const i of Object.keys(t.scales)){const{min:t,max:s}=e.originalScaleLimits[i]||{min:{},max:{}};n[i]={min:t.scale,max:s.scale}}return n}function nu(t){const e=Ah(t);return e.panning||e.dragging}const iu=(t,e,n)=>Math.min(n,Math.max(e,t));function su(t,e){const{handlers:n}=Ah(t),i=n[e];i&&i.target&&(i.target.removeEventListener(e,i),delete n[e])}function ou(t,e,n,i){const{handlers:s,options:o}=Ah(t),a=s[n];if(a&&a.target===e)return;su(t,n),s[n]=e=>i(t,e,o),s[n].target=e;const r="wheel"!==n&&void 0;e.addEventListener(n,s[n],{passive:r})}function au(t,e){const n=Ah(t);n.dragStart&&(n.dragging=!0,n.dragEnd=e,t.update("none"))}function ru(t,e){const n=Ah(t);n.dragStart&&"Escape"===e.key&&(su(t,"keydown"),n.dragging=!1,n.dragStart=n.dragEnd=null,t.update("none"))}function lu(t,e){if(t.target!==e.canvas){const n=e.canvas.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}}return In(t,e)}function cu(t,e,n){const{onZoomStart:i,onZoomRejected:s}=n;if(i){if(!1===yt(i,[{chart:t,event:e,point:lu(e,t)}]))return yt(s,[{chart:t,event:e}]),!1}}function du(t,e){if(t.legend){if(Fe(In(e,t),t.legend))return}const n=Ah(t),{pan:i,zoom:s={}}=n.options;if(0!==e.button||_h(Ch(i),e)||Th(Ch(s.drag),e))return yt(s.onZoomRejected,[{chart:t,event:e}]);!1!==cu(t,e,s)&&(n.dragStart=e,ou(t,t.canvas.ownerDocument,"mousemove",au),ou(t,window.document,"keydown",ru))}function hu(t,e,n,{min:i,max:s,prop:o}){t[i]=iu(Math.min(n.begin[o],n.end[o]),e[i],e[s]),t[s]=iu(Math.max(n.begin[o],n.end[o]),e[i],e[s])}function uu(t,e,n){const i={begin:lu(e.dragStart,t),end:lu(e.dragEnd,t)};if(n){!function({begin:t,end:e},n){let i=e.x-t.x,s=e.y-t.y;const o=Math.abs(i/s);o>n?i=Math.sign(i)*Math.abs(s*n):o<n&&(s=Math.sign(s)*Math.abs(i/n)),e.x=t.x+i,e.y=t.y+s}(i,t.chartArea.width/t.chartArea.height)}return i}function gu(t,e,n,i){const s=Dh(e,"x",t),o=Dh(e,"y",t),{top:a,left:r,right:l,bottom:c,width:d,height:h}=t.chartArea,u={top:a,left:r,right:l,bottom:c},g=uu(t,n,i&&s&&o);s&&hu(u,t.chartArea,g,{min:"left",max:"right",prop:"x"}),o&&hu(u,t.chartArea,g,{min:"top",max:"bottom",prop:"y"});const p=u.right-u.left,m=u.bottom-u.top;return{...u,width:p,height:m,zoomX:s&&p?1+(d-p)/d:1,zoomY:o&&m?1+(h-m)/h:1}}function pu(t,e){const n=Ah(t);if(!n.dragStart)return;su(t,"mousemove");const{mode:i,onZoomComplete:s,drag:{threshold:o=0,maintainAspectRatio:a}}=n.options.zoom,r=gu(t,i,{dragStart:n.dragStart,dragEnd:e},a),l=Dh(i,"x",t)?r.width:0,c=Dh(i,"y",t)?r.height:0,d=Math.sqrt(l*l+c*c);if(n.dragStart=n.dragEnd=null,d<=o)return n.dragging=!1,void t.update("none");Kh(t,{x:r.left,y:r.top},{x:r.right,y:r.bottom},"zoom","drag"),n.dragging=!1,n.filterNextClick=!0,yt(s,[{chart:t}])}function mu(t,e){const{handlers:{onZoomComplete:n},options:{zoom:i}}=Ah(t);if(!function(t,e,n){if(Th(Ch(n.wheel),e))yt(n.onZoomRejected,[{chart:t,event:e}]);else if(!1!==cu(t,e,n)&&(e.cancelable&&e.preventDefault(),void 0!==e.deltaY))return!0}(t,e,i))return;const s=e.target.getBoundingClientRect(),o=i.wheel.speed,a=e.deltaY>=0?2-1/(1-o):1+o;Gh(t,{x:a,y:a,focalPoint:{x:e.clientX-s.left,y:e.clientY-s.top}},"zoom","wheel"),yt(n,[{chart:t}])}function fu(t,e,n,i){n&&(Ah(t).handlers[e]=function(t,e){let n;return function(){return clearTimeout(n),n=setTimeout(t,e),e}}((()=>yt(n,[{chart:t}])),i))}function bu(t,e){return function(n,i){const{pan:s,zoom:o={}}=e.options;if(!s||!s.enabled)return!1;const a=i&&i.srcEvent;return!a||(!(!e.panning&&"mouse"===i.pointerType&&(Th(Ch(s),a)||_h(Ch(o.drag),a)))||(yt(s.onPanRejected,[{chart:t,event:i}]),!1))}}function yu(t,e,n){if(e.scale){const{center:i,pointers:s}=n,o=1/e.scale*n.scale,a=n.target.getBoundingClientRect(),r=function(t,e){const n=Math.abs(t.clientX-e.clientX),i=Math.abs(t.clientY-e.clientY),s=n/i;let o,a;return s>.3&&s<1.7?o=a=!0:n>i?o=!0:a=!0,{x:o,y:a}}(s[0],s[1]),l=e.options.zoom.mode;Gh(t,{x:r.x&&Dh(l,"x",t)?o:1,y:r.y&&Dh(l,"y",t)?o:1,focalPoint:{x:i.x-a.left,y:i.y-a.top}},"zoom","pinch"),e.scale=n.scale}}function xu(t,e,n){const i=e.delta;i&&(e.panning=!0,tu(t,{x:n.deltaX-i.x,y:n.deltaY-i.y},e.panScales),e.delta={x:n.deltaX,y:n.deltaY})}const vu=new WeakMap;function wu(t,e){const n=Ah(t),i=t.canvas,{pan:s,zoom:o}=e,a=new Mh.Manager(i);o&&o.pinch.enabled&&(a.add(new Mh.Pinch),a.on("pinchstart",(e=>function(t,e,n){if(e.options.zoom.pinch.enabled){const i=In(n,t);!1===yt(e.options.zoom.onZoomStart,[{chart:t,event:n,point:i}])?(e.scale=null,yt(e.options.zoom.onZoomRejected,[{chart:t,event:n}])):e.scale=1}}(t,n,e))),a.on("pinch",(e=>yu(t,n,e))),a.on("pinchend",(e=>function(t,e,n){e.scale&&(yu(t,e,n),e.scale=null,yt(e.options.zoom.onZoomComplete,[{chart:t}]))}(t,n,e)))),s&&s.enabled&&(a.add(new Mh.Pan({threshold:s.threshold,enable:bu(t,n)})),a.on("panstart",(e=>function(t,e,n){const{enabled:i,onPanStart:s,onPanRejected:o}=e.options.pan;if(!i)return;const a=n.target.getBoundingClientRect(),r={x:n.center.x-a.left,y:n.center.y-a.top};if(!1===yt(s,[{chart:t,event:n,point:r}]))return yt(o,[{chart:t,event:n}]);e.panScales=Eh(e.options.pan,r,t),e.delta={x:0,y:0},xu(t,e,n)}(t,n,e))),a.on("panmove",(e=>xu(t,n,e))),a.on("panend",(()=>function(t,e){e.delta=null,e.panning&&(e.panning=!1,e.filterNextClick=!0,yt(e.options.pan.onPanComplete,[{chart:t}]))}(t,n)))),vu.set(t,a)}function ku(t){const e=vu.get(t);e&&(e.remove("pinchstart"),e.remove("pinch"),e.remove("pinchend"),e.remove("panstart"),e.remove("pan"),e.remove("panend"),e.destroy(),vu.delete(t))}function Su(t,e,n){const i=n.zoom.drag,{dragStart:s,dragEnd:o}=Ah(t);if(i.drawTime!==e||!o)return;const{left:a,top:r,width:l,height:c}=gu(t,n.zoom.mode,{dragStart:s,dragEnd:o},i.maintainAspectRatio),d=t.ctx;d.save(),d.beginPath(),d.fillStyle=i.backgroundColor||"rgba(225,225,225,0.3)",d.fillRect(a,r,l,c),i.borderWidth>0&&(d.lineWidth=i.borderWidth,d.strokeStyle=i.borderColor||"rgba(225,225,225)",d.strokeRect(a,r,l,c)),d.restore()}var Mu={id:"zoom",version:"2.2.0",defaults:{pan:{enabled:!1,mode:"xy",threshold:10,modifierKey:null},zoom:{wheel:{enabled:!1,speed:.1,modifierKey:null},drag:{enabled:!1,drawTime:"beforeDatasetsDraw",modifierKey:null},pinch:{enabled:!1},mode:"xy"}},start:function(t,e,n){Ah(t).options=n,Object.prototype.hasOwnProperty.call(n.zoom,"enabled")&&console.warn("The option `zoom.enabled` is no longer supported. Please use `zoom.wheel.enabled`, `zoom.drag.enabled`, or `zoom.pinch.enabled`."),(Object.prototype.hasOwnProperty.call(n.zoom,"overScaleMode")||Object.prototype.hasOwnProperty.call(n.pan,"overScaleMode"))&&console.warn("The option `overScaleMode` is deprecated. Please use `scaleMode` instead (and update `mode` as desired)."),Mh&&wu(t,n),t.pan=(e,n,i)=>tu(t,e,n,i),t.zoom=(e,n)=>Gh(t,e,n),t.zoomRect=(e,n,i)=>Kh(t,e,n,i),t.zoomScale=(e,n,i)=>function(t,e,n,i="none",s="api"){const o=Ah(t);jh(t,o),Nh(t.scales[e],n,void 0,!0),t.update(i),yt(o.options.zoom?.onZoom,[{chart:t,trigger:s}])}(t,e,n,i),t.resetZoom=e=>function(t,e="default"){const n=Ah(t),i=jh(t,n);xt(t.scales,(function(t){const e=t.options;i[t.id]?(e.min=i[t.id].min.options,e.max=i[t.id].max.options):(delete e.min,delete e.max),delete n.updatedScaleLimits[t.id]})),t.update(e),yt(n.options.zoom.onZoomComplete,[{chart:t}])}(t,e),t.getZoomLevel=()=>Zh(t),t.getInitialScaleBounds=()=>eu(t),t.getZoomedScaleBounds=()=>function(t){const e=Ah(t),n={};for(const i of Object.keys(t.scales))n[i]=e.updatedScaleLimits[i];return n}(t),t.isZoomedOrPanned=()=>function(t){const e=eu(t);for(const n of Object.keys(t.scales)){const{min:i,max:s}=e[n];if(void 0!==i&&t.scales[n].min!==i)return!0;if(void 0!==s&&t.scales[n].max!==s)return!0}return!1}(t),t.isZoomingOrPanning=()=>nu(t)},beforeEvent(t,{event:e}){if(nu(t))return!1;if("click"===e.type||"mouseup"===e.type){const e=Ah(t);if(e.filterNextClick)return e.filterNextClick=!1,!1}},beforeUpdate:function(t,e,n){const i=Ah(t),s=i.options;i.options=n,function(t,e){const{pan:n,zoom:i}=t,{pan:s,zoom:o}=e;return i?.zoom?.pinch?.enabled!==o?.zoom?.pinch?.enabled||n?.enabled!==s?.enabled||n?.threshold!==s?.threshold}(s,n)&&(ku(t),wu(t,n)),function(t,e){const n=t.canvas,{wheel:i,drag:s,onZoomComplete:o}=e.zoom;i.enabled?(ou(t,n,"wheel",mu),fu(t,"onZoomComplete",o,250)):su(t,"wheel"),s.enabled?(ou(t,n,"mousedown",du),ou(t,n.ownerDocument,"mouseup",pu)):(su(t,"mousedown"),su(t,"mousemove"),su(t,"mouseup"),su(t,"keydown"))}(t,n)},beforeDatasetsDraw(t,e,n){Su(t,"beforeDatasetsDraw",n)},afterDatasetsDraw(t,e,n){Su(t,"afterDatasetsDraw",n)},beforeDraw(t,e,n){Su(t,"beforeDraw",n)},afterDraw(t,e,n){Su(t,"afterDraw",n)},stop:function(t){!function(t){su(t,"mousedown"),su(t,"mousemove"),su(t,"mouseup"),su(t,"wheel"),su(t,"click"),su(t,"keydown")}(t),Mh&&ku(t),function(t){Lh.delete(t)}(t)},panFunctions:Vh,zoomFunctions:qh,zoomRectFunctions:Hh};
|
|
45
|
+
const Eh=t=>t&&t.enabled&&t.modifierKey,Lh=(t,e)=>t&&e[t+"Key"],Ah=(t,e)=>t&&!e[t+"Key"];function Ih(t,e,n){return void 0===t||("string"==typeof t?-1!==t.indexOf(e):"function"==typeof t&&-1!==t({chart:n}).indexOf(e))}function zh(t,e){return"function"==typeof t&&(t=t({chart:e})),"string"==typeof t?{x:-1!==t.indexOf("x"),y:-1!==t.indexOf("y")}:{x:!1,y:!1}}function Oh(t,e,n){const{mode:i="xy",scaleMode:s,overScaleMode:o}=t||{},a=function({x:t,y:e},n){const i=n.scales,s=Object.keys(i);for(let n=0;n<s.length;n++){const o=i[s[n]];if(e>=o.top&&e<=o.bottom&&t>=o.left&&t<=o.right)return o}return null}(e,n),r=zh(i,n),l=zh(s,n);if(o){const t=zh(o,n);for(const e of["x","y"])t[e]&&(l[e]=r[e],r[e]=!1)}if(a&&l[a.axis])return[a];const c=[];return Mt(n.scales,(function(t){r[t.axis]&&c.push(t)})),c}const Wh=new WeakMap;function Nh(t){let e=Wh.get(t);return e||(e={originalScaleLimits:{},updatedScaleLimits:{},handlers:{},panDelta:{},dragging:!1,panning:!1},Wh.set(t,e)),e}function $h(t,e,n,i){const s=Math.max(0,Math.min(1,(t-e)/n||0));return{min:i*s,max:i*(1-s)}}function Rh(t,e){const n=t.isHorizontal()?e.x:e.y;return t.getValueForPixel(n)}function Fh(t,e,n){const i=t.max-t.min,s=i*(e-1);return $h(Rh(t,n),t.min,i,s)}function Bh(t,e,n,i,s){let o=n[i];if("original"===o){const n=t.originalScaleLimits[e.id][i];o=wt(n.options,n.scale)}return wt(o,s)}function qh(t,{min:e,max:n},i,s=!1){const o=Nh(t.chart),{options:a}=t,r=function(t,e){return e&&(e[t.id]||e[t.axis])||{}}(t,i),{minRange:l=0}=r,c=Bh(o,t,r,"min",-1/0),d=Bh(o,t,r,"max",1/0);if("pan"===s&&(e<c||n>d))return!0;const h=t.max-t.min,u=s?Math.max(n-e,l):h;if(s&&u===l&&h<=l)return!0;const g=function(t,{min:e,max:n,minLimit:i,maxLimit:s},o){const a=(t-n+e)/2;e-=a,n+=a;const r=o.min.options??o.min.scale,l=o.max.options??o.max.scale,c=t/1e6;return Xt(e,r,c)&&(e=r),Xt(n,l,c)&&(n=l),e<i?(e=i,n=Math.min(i+t,s)):n>s&&(n=s,e=Math.max(s-t,i)),{min:e,max:n}}(u,{min:e,max:n,minLimit:c,maxLimit:d},o.originalScaleLimits[t.id]);return a.min=g.min,a.max=g.max,o.updatedScaleLimits[t.id]=g,t.parse(g.min)!==t.min||t.parse(g.max)!==t.max}const Hh=t=>0===t||isNaN(t)?0:t<0?Math.min(Math.round(t),-1):Math.max(Math.round(t),1);const Vh={second:500,minute:3e4,hour:18e5,day:432e5,week:3024e5,month:1296e6,quarter:5184e6,year:157248e5};function jh(t,e,n,i=!1){const{min:s,max:o,options:a}=t,r=a.time&&a.time.round,l=Vh[r]||0,c=t.getValueForPixel(t.getPixelForValue(s+l)-e),d=t.getValueForPixel(t.getPixelForValue(o+l)-e);return!(!isNaN(c)&&!isNaN(d))||qh(t,{min:c,max:d},n,!!i&&"pan")}function Yh(t,e,n){return jh(t,e,n,!0)}const Uh={category:function(t,e,n,i){const s=Fh(t,e,n);return t.min===t.max&&e<1&&function(t){const e=t.getLabels().length-1;t.min>0&&(t.min-=1),t.max<e&&(t.max+=1)}(t),qh(t,{min:t.min+Hh(s.min),max:t.max-Hh(s.max)},i,!0)},default:function(t,e,n,i){const s=Fh(t,e,n);return qh(t,{min:t.min+s.min,max:t.max-s.max},i,!0)},logarithmic:function(t,e,n,i){const s=function(t,e,n){const i=Rh(t,n);if(void 0===i)return{min:t.min,max:t.max};const s=Math.log10(t.min),o=Math.log10(t.max),a=o-s,r=$h(Math.log10(i),s,a,a*(e-1));return{min:Math.pow(10,s+r.min),max:Math.pow(10,o-r.max)}}(t,e,n);return qh(t,s,i,!0)}},Xh={default:function(t,e,n,i){qh(t,function(t,e,n){const i=t.getValueForPixel(e),s=t.getValueForPixel(n);return{min:Math.min(i,s),max:Math.max(i,s)}}(t,e,n),i,!0)}},Qh={category:function(t,e,n){const i=t.getLabels().length-1;let{min:s,max:o}=t;const a=Math.max(o-s,1),r=Math.round(function(t){return t.isHorizontal()?t.width:t.height}(t)/Math.max(a,10)),l=Math.round(Math.abs(e/r));let c;return e<-r?(o=Math.min(o+l,i),s=1===a?o:o-a,c=o===i):e>r&&(s=Math.max(0,s-l),o=1===a?s:s+a,c=0===s),qh(t,{min:s,max:o},n)||c},default:jh,logarithmic:Yh,timeseries:Yh};function Gh(t,e){Mt(t,((n,i)=>{e[i]||delete t[i]}))}function Kh(t,e){const{scales:n}=t,{originalScaleLimits:i,updatedScaleLimits:s}=e;return Mt(n,(function(t){(function(t,e,n){const{id:i,options:{min:s,max:o}}=t;if(!e[i]||!n[i])return!0;const a=n[i];return a.min!==s||a.max!==o})(t,i,s)&&(i[t.id]={min:{scale:t.min,options:t.options.min},max:{scale:t.max,options:t.options.max}})})),Gh(i,n),Gh(s,n),i}function Zh(t,e,n,i){St(Uh[t.type]||Uh.default,[t,e,n,i])}function Jh(t,e,n,i){St(Xh[t.type]||Xh.default,[t,e,n,i])}function tu(t){const e=t.chartArea;return{x:(e.left+e.right)/2,y:(e.top+e.bottom)/2}}function eu(t,e,n="none",i="api"){const{x:s=1,y:o=1,focalPoint:a=tu(t)}="number"==typeof e?{x:e,y:e}:e,r=Nh(t),{options:{limits:l,zoom:c}}=r;Kh(t,r);const d=1!==s,h=1!==o;Mt(Oh(c,a,t)||t.scales,(function(t){t.isHorizontal()&&d?Zh(t,s,a,l):!t.isHorizontal()&&h&&Zh(t,o,a,l)})),t.update(n),St(c.onZoom,[{chart:t,trigger:i}])}function nu(t,e,n,i="none",s="api"){const o=Nh(t),{options:{limits:a,zoom:r}}=o,{mode:l="xy"}=r;Kh(t,o);const c=Ih(l,"x",t),d=Ih(l,"y",t);Mt(t.scales,(function(t){t.isHorizontal()&&c?Jh(t,e.x,n.x,a):!t.isHorizontal()&&d&&Jh(t,e.y,n.y,a)})),t.update(i),St(r.onZoom,[{chart:t,trigger:s}])}function iu(t){const e=Nh(t);let n=1,i=1;return Mt(t.scales,(function(t){const s=function(t,e){const n=t.originalScaleLimits[e];if(!n)return;const{min:i,max:s}=n;return wt(s.options,s.scale)-wt(i.options,i.scale)}(e,t.id);if(s){const e=Math.round(s/(t.max-t.min)*100)/100;n=Math.min(n,e),i=Math.max(i,e)}})),n<1?n:i}function su(t,e,n,i){const{panDelta:s}=i,o=s[t.id]||0;Ut(o)===Ut(e)&&(e+=o);St(Qh[t.type]||Qh.default,[t,e,n])?s[t.id]=0:s[t.id]=e}function ou(t,e,n,i="none"){const{x:s=0,y:o=0}="number"==typeof e?{x:e,y:e}:e,a=Nh(t),{options:{pan:r,limits:l}}=a,{onPan:c}=r||{};Kh(t,a);const d=0!==s,h=0!==o;Mt(n||t.scales,(function(t){t.isHorizontal()&&d?su(t,s,l,a):!t.isHorizontal()&&h&&su(t,o,l,a)})),t.update(i),St(c,[{chart:t}])}function au(t){const e=Nh(t);Kh(t,e);const n={};for(const i of Object.keys(t.scales)){const{min:t,max:s}=e.originalScaleLimits[i]||{min:{},max:{}};n[i]={min:t.scale,max:s.scale}}return n}function ru(t){const e=Nh(t);return e.panning||e.dragging}const lu=(t,e,n)=>Math.min(n,Math.max(e,t));function cu(t,e){const{handlers:n}=Nh(t),i=n[e];i&&i.target&&(i.target.removeEventListener(e,i),delete n[e])}function du(t,e,n,i){const{handlers:s,options:o}=Nh(t),a=s[n];if(a&&a.target===e)return;cu(t,n),s[n]=e=>i(t,e,o),s[n].target=e;const r="wheel"!==n&&void 0;e.addEventListener(n,s[n],{passive:r})}function hu(t,e){const n=Nh(t);n.dragStart&&(n.dragging=!0,n.dragEnd=e,t.update("none"))}function uu(t,e){const n=Nh(t);n.dragStart&&"Escape"===e.key&&(cu(t,"keydown"),n.dragging=!1,n.dragStart=n.dragEnd=null,t.update("none"))}function gu(t,e){if(t.target!==e.canvas){const n=e.canvas.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}}return $n(t,e)}function pu(t,e,n){const{onZoomStart:i,onZoomRejected:s}=n;if(i){if(!1===St(i,[{chart:t,event:e,point:gu(e,t)}]))return St(s,[{chart:t,event:e}]),!1}}function mu(t,e){if(t.legend){if(je($n(e,t),t.legend))return}const n=Nh(t),{pan:i,zoom:s={}}=n.options;if(0!==e.button||Lh(Eh(i),e)||Ah(Eh(s.drag),e))return St(s.onZoomRejected,[{chart:t,event:e}]);!1!==pu(t,e,s)&&(n.dragStart=e,du(t,t.canvas.ownerDocument,"mousemove",hu),du(t,window.document,"keydown",uu))}function fu(t,e,n,{min:i,max:s,prop:o}){t[i]=lu(Math.min(n.begin[o],n.end[o]),e[i],e[s]),t[s]=lu(Math.max(n.begin[o],n.end[o]),e[i],e[s])}function bu(t,e,n){const i={begin:gu(e.dragStart,t),end:gu(e.dragEnd,t)};if(n){!function({begin:t,end:e},n){let i=e.x-t.x,s=e.y-t.y;const o=Math.abs(i/s);o>n?i=Math.sign(i)*Math.abs(s*n):o<n&&(s=Math.sign(s)*Math.abs(i/n)),e.x=t.x+i,e.y=t.y+s}(i,t.chartArea.width/t.chartArea.height)}return i}function yu(t,e,n,i){const s=Ih(e,"x",t),o=Ih(e,"y",t),{top:a,left:r,right:l,bottom:c,width:d,height:h}=t.chartArea,u={top:a,left:r,right:l,bottom:c},g=bu(t,n,i&&s&&o);s&&fu(u,t.chartArea,g,{min:"left",max:"right",prop:"x"}),o&&fu(u,t.chartArea,g,{min:"top",max:"bottom",prop:"y"});const p=u.right-u.left,m=u.bottom-u.top;return{...u,width:p,height:m,zoomX:s&&p?1+(d-p)/d:1,zoomY:o&&m?1+(h-m)/h:1}}function xu(t,e){const n=Nh(t);if(!n.dragStart)return;cu(t,"mousemove");const{mode:i,onZoomComplete:s,drag:{threshold:o=0,maintainAspectRatio:a}}=n.options.zoom,r=yu(t,i,{dragStart:n.dragStart,dragEnd:e},a),l=Ih(i,"x",t)?r.width:0,c=Ih(i,"y",t)?r.height:0,d=Math.sqrt(l*l+c*c);if(n.dragStart=n.dragEnd=null,d<=o)return n.dragging=!1,void t.update("none");nu(t,{x:r.left,y:r.top},{x:r.right,y:r.bottom},"zoom","drag"),n.dragging=!1,n.filterNextClick=!0,St(s,[{chart:t}])}function vu(t,e){const{handlers:{onZoomComplete:n},options:{zoom:i}}=Nh(t);if(!function(t,e,n){if(Ah(Eh(n.wheel),e))St(n.onZoomRejected,[{chart:t,event:e}]);else if(!1!==pu(t,e,n)&&(e.cancelable&&e.preventDefault(),void 0!==e.deltaY))return!0}(t,e,i))return;const s=e.target.getBoundingClientRect(),o=i.wheel.speed,a=e.deltaY>=0?2-1/(1-o):1+o;eu(t,{x:a,y:a,focalPoint:{x:e.clientX-s.left,y:e.clientY-s.top}},"zoom","wheel"),St(n,[{chart:t}])}function wu(t,e,n,i){n&&(Nh(t).handlers[e]=function(t,e){let n;return function(){return clearTimeout(n),n=setTimeout(t,e),e}}((()=>St(n,[{chart:t}])),i))}function ku(t,e){return function(n,i){const{pan:s,zoom:o={}}=e.options;if(!s||!s.enabled)return!1;const a=i&&i.srcEvent;return!a||(!(!e.panning&&"mouse"===i.pointerType&&(Ah(Eh(s),a)||Lh(Eh(o.drag),a)))||(St(s.onPanRejected,[{chart:t,event:i}]),!1))}}function Su(t,e,n){if(e.scale){const{center:i,pointers:s}=n,o=1/e.scale*n.scale,a=n.target.getBoundingClientRect(),r=function(t,e){const n=Math.abs(t.clientX-e.clientX),i=Math.abs(t.clientY-e.clientY),s=n/i;let o,a;return s>.3&&s<1.7?o=a=!0:n>i?o=!0:a=!0,{x:o,y:a}}(s[0],s[1]),l=e.options.zoom.mode;eu(t,{x:r.x&&Ih(l,"x",t)?o:1,y:r.y&&Ih(l,"y",t)?o:1,focalPoint:{x:i.x-a.left,y:i.y-a.top}},"zoom","pinch"),e.scale=n.scale}}function Mu(t,e,n){const i=e.delta;i&&(e.panning=!0,ou(t,{x:n.deltaX-i.x,y:n.deltaY-i.y},e.panScales),e.delta={x:n.deltaX,y:n.deltaY})}const Cu=new WeakMap;function _u(t,e){const n=Nh(t),i=t.canvas,{pan:s,zoom:o}=e,a=new Ph.Manager(i);o&&o.pinch.enabled&&(a.add(new Ph.Pinch),a.on("pinchstart",(e=>function(t,e,n){if(e.options.zoom.pinch.enabled){const i=$n(n,t);!1===St(e.options.zoom.onZoomStart,[{chart:t,event:n,point:i}])?(e.scale=null,St(e.options.zoom.onZoomRejected,[{chart:t,event:n}])):e.scale=1}}(t,n,e))),a.on("pinch",(e=>Su(t,n,e))),a.on("pinchend",(e=>function(t,e,n){e.scale&&(Su(t,e,n),e.scale=null,St(e.options.zoom.onZoomComplete,[{chart:t}]))}(t,n,e)))),s&&s.enabled&&(a.add(new Ph.Pan({threshold:s.threshold,enable:ku(t,n)})),a.on("panstart",(e=>function(t,e,n){const{enabled:i,onPanStart:s,onPanRejected:o}=e.options.pan;if(!i)return;const a=n.target.getBoundingClientRect(),r={x:n.center.x-a.left,y:n.center.y-a.top};if(!1===St(s,[{chart:t,event:n,point:r}]))return St(o,[{chart:t,event:n}]);e.panScales=Oh(e.options.pan,r,t),e.delta={x:0,y:0},Mu(t,e,n)}(t,n,e))),a.on("panmove",(e=>Mu(t,n,e))),a.on("panend",(()=>function(t,e){e.delta=null,e.panning&&(e.panning=!1,e.filterNextClick=!0,St(e.options.pan.onPanComplete,[{chart:t}]))}(t,n)))),Cu.set(t,a)}function Tu(t){const e=Cu.get(t);e&&(e.remove("pinchstart"),e.remove("pinch"),e.remove("pinchend"),e.remove("panstart"),e.remove("pan"),e.remove("panend"),e.destroy(),Cu.delete(t))}function Du(t,e,n){const i=n.zoom.drag,{dragStart:s,dragEnd:o}=Nh(t);if(i.drawTime!==e||!o)return;const{left:a,top:r,width:l,height:c}=yu(t,n.zoom.mode,{dragStart:s,dragEnd:o},i.maintainAspectRatio),d=t.ctx;d.save(),d.beginPath(),d.fillStyle=i.backgroundColor||"rgba(225,225,225,0.3)",d.fillRect(a,r,l,c),i.borderWidth>0&&(d.lineWidth=i.borderWidth,d.strokeStyle=i.borderColor||"rgba(225,225,225)",d.strokeRect(a,r,l,c)),d.restore()}var Pu={id:"zoom",version:"2.2.0",defaults:{pan:{enabled:!1,mode:"xy",threshold:10,modifierKey:null},zoom:{wheel:{enabled:!1,speed:.1,modifierKey:null},drag:{enabled:!1,drawTime:"beforeDatasetsDraw",modifierKey:null},pinch:{enabled:!1},mode:"xy"}},start:function(t,e,n){Nh(t).options=n,Object.prototype.hasOwnProperty.call(n.zoom,"enabled")&&console.warn("The option `zoom.enabled` is no longer supported. Please use `zoom.wheel.enabled`, `zoom.drag.enabled`, or `zoom.pinch.enabled`."),(Object.prototype.hasOwnProperty.call(n.zoom,"overScaleMode")||Object.prototype.hasOwnProperty.call(n.pan,"overScaleMode"))&&console.warn("The option `overScaleMode` is deprecated. Please use `scaleMode` instead (and update `mode` as desired)."),Ph&&_u(t,n),t.pan=(e,n,i)=>ou(t,e,n,i),t.zoom=(e,n)=>eu(t,e,n),t.zoomRect=(e,n,i)=>nu(t,e,n,i),t.zoomScale=(e,n,i)=>function(t,e,n,i="none",s="api"){const o=Nh(t);Kh(t,o),qh(t.scales[e],n,void 0,!0),t.update(i),St(o.options.zoom?.onZoom,[{chart:t,trigger:s}])}(t,e,n,i),t.resetZoom=e=>function(t,e="default"){const n=Nh(t),i=Kh(t,n);Mt(t.scales,(function(t){const e=t.options;i[t.id]?(e.min=i[t.id].min.options,e.max=i[t.id].max.options):(delete e.min,delete e.max),delete n.updatedScaleLimits[t.id]})),t.update(e),St(n.options.zoom.onZoomComplete,[{chart:t}])}(t,e),t.getZoomLevel=()=>iu(t),t.getInitialScaleBounds=()=>au(t),t.getZoomedScaleBounds=()=>function(t){const e=Nh(t),n={};for(const i of Object.keys(t.scales))n[i]=e.updatedScaleLimits[i];return n}(t),t.isZoomedOrPanned=()=>function(t){const e=au(t);for(const n of Object.keys(t.scales)){const{min:i,max:s}=e[n];if(void 0!==i&&t.scales[n].min!==i)return!0;if(void 0!==s&&t.scales[n].max!==s)return!0}return!1}(t),t.isZoomingOrPanning=()=>ru(t)},beforeEvent(t,{event:e}){if(ru(t))return!1;if("click"===e.type||"mouseup"===e.type){const e=Nh(t);if(e.filterNextClick)return e.filterNextClick=!1,!1}},beforeUpdate:function(t,e,n){const i=Nh(t),s=i.options;i.options=n,function(t,e){const{pan:n,zoom:i}=t,{pan:s,zoom:o}=e;return i?.zoom?.pinch?.enabled!==o?.zoom?.pinch?.enabled||n?.enabled!==s?.enabled||n?.threshold!==s?.threshold}(s,n)&&(Tu(t),_u(t,n)),function(t,e){const n=t.canvas,{wheel:i,drag:s,onZoomComplete:o}=e.zoom;i.enabled?(du(t,n,"wheel",vu),wu(t,"onZoomComplete",o,250)):cu(t,"wheel"),s.enabled?(du(t,n,"mousedown",mu),du(t,n.ownerDocument,"mouseup",xu)):(cu(t,"mousedown"),cu(t,"mousemove"),cu(t,"mouseup"),cu(t,"keydown"))}(t,n)},beforeDatasetsDraw(t,e,n){Du(t,"beforeDatasetsDraw",n)},afterDatasetsDraw(t,e,n){Du(t,"afterDatasetsDraw",n)},beforeDraw(t,e,n){Du(t,"beforeDraw",n)},afterDraw(t,e,n){Du(t,"afterDraw",n)},stop:function(t){!function(t){cu(t,"mousedown"),cu(t,"mousemove"),cu(t,"mouseup"),cu(t,"wheel"),cu(t,"click"),cu(t,"keydown")}(t),Ph&&Tu(t),function(t){Wh.delete(t)}(t)},panFunctions:Qh,zoomFunctions:Uh,zoomRectFunctions:Xh};
|
|
46
46
|
/*!
|
|
47
47
|
* @license
|
|
48
48
|
* chartjs-chart-financial
|
|
@@ -52,4 +52,4 @@ const Ch=t=>t&&t.enabled&&t.modifierKey,_h=(t,e)=>t&&e[t+"Key"],Th=(t,e)=>t&&!e[
|
|
|
52
52
|
* Copyright 2024 Chart.js Contributors
|
|
53
53
|
* Released under the MIT license
|
|
54
54
|
* https://github.com/chartjs/chartjs-chart-financial/blob/master/LICENSE.md
|
|
55
|
-
*/function Cu(t,e,n,i){const s=null===e,o=null===n,a=!(!t||s&&o)&&function(t,e){const{x:n,y:i,base:s,width:o,height:a}=t.getProps(["x","low","high","width","height"],e);let r,l,c,d,h;return t.horizontal?(h=a/2,r=Math.min(n,s),l=Math.max(n,s),c=i-h,d=i+h):(h=o/2,r=n-h,l=n+h,c=Math.min(i,s),d=Math.max(i,s)),{left:r,top:c,right:l,bottom:d}}(t,i);return a&&(s||e>=a.left&&e<=a.right)&&(o||n>=a.top&&n<=a.bottom)}class _u extends Co{static defaults={backgroundColors:{up:"rgba(75, 192, 192, 0.5)",down:"rgba(255, 99, 132, 0.5)",unchanged:"rgba(201, 203, 207, 0.5)"},borderColors:{up:"rgb(75, 192, 192)",down:"rgb(255, 99, 132)",unchanged:"rgb(201, 203, 207)"}};height(){return this.base-this.y}inRange(t,e,n){return Cu(this,t,e,n)}inXRange(t,e){return Cu(this,t,null,e)}inYRange(t,e){return Cu(this,null,t,e)}getRange(t){return"x"===t?this.width/2:this.height/2}getCenterPoint(t){const{x:e,low:n,high:i}=this.getProps(["x","low","high"],t);return{x:e,y:(i+n)/2}}tooltipPosition(t){const{x:e,open:n,close:i}=this.getProps(["x","open","close"],t);return{x:e,y:(n+i)/2}}}const Tu=no.defaults;class Du extends _u{static id="ohlc";static defaults={..._u.defaults,lineWidth:2,armLength:null,armLengthRatio:.8};draw(t){const e=this,{x:n,open:i,high:s,low:o,close:a}=e,r=ft(e.armLengthRatio,Tu.elements.ohlc.armLengthRatio);let l=ft(e.armLength,Tu.elements.ohlc.armLength);null===l&&(l=e.width*r*.5),t.strokeStyle=a<i?ft(e.options.borderColors?e.options.borderColors.up:void 0,Tu.elements.ohlc.borderColors.up):a>i?ft(e.options.borderColors?e.options.borderColors.down:void 0,Tu.elements.ohlc.borderColors.down):ft(e.options.borderColors?e.options.borderColors.unchanged:void 0,Tu.elements.ohlc.borderColors.unchanged),t.lineWidth=ft(e.lineWidth,Tu.elements.ohlc.lineWidth),t.beginPath(),t.moveTo(n,s),t.lineTo(n,o),t.moveTo(n-l,i),t.lineTo(n,i),t.moveTo(n+l,a),t.lineTo(n,a),t.stroke()}}class Pu extends _i{static overrides={label:"",parsing:!1,hover:{mode:"label"},animations:{numbers:{type:"number",properties:["x","y","base","width","open","high","low","close"]}},scales:{x:{type:"timeseries",offset:!0,ticks:{major:{enabled:!0},source:"data",maxRotation:0,autoSkip:!0,autoSkipPadding:75,sampleSize:100}},y:{type:"linear"}},plugins:{tooltip:{intersect:!1,mode:"index",callbacks:{label(t){const e=t.parsed;if(!ht(e.y))return Ie.plugins.tooltip.callbacks.label(t);const{o:n,h:i,l:s,c:o}=e;return`O: ${n} H: ${i} L: ${s} C: ${o}`}}}}};getLabelAndValue(t){const e=this,n=e.getParsed(t),i=e._cachedMeta.iScale.axis,{o:s,h:o,l:a,c:r}=n,l=`O: ${s} H: ${o} L: ${a} C: ${r}`;return{label:`${e._cachedMeta.iScale.getLabelForValue(n[i])}`,value:l}}getUserBounds(t){const{min:e,max:n,minDefined:i,maxDefined:s}=t.getUserBounds();return{min:i?e:Number.NEGATIVE_INFINITY,max:s?n:Number.POSITIVE_INFINITY}}getMinMax(t){const e=this._cachedMeta,n=e._parsed,i=e.iScale.axis,s=this._getOtherScale(t),{min:o,max:a}=this.getUserBounds(s);if(n.length<2)return{min:0,max:1};if(t===e.iScale)return{min:n[0][i],max:n[n.length-1][i]};const r=n.filter((({x:t})=>t>=o&&t<a));let l=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY;for(let t=0;t<r.length;t++){const e=r[t];l=Math.min(l,e.l),c=Math.max(c,e.h)}return{min:l,max:c}}calculateElementProperties(t,e,n,i){const s=this,o=s._cachedMeta.vScale,a=o.getBasePixel(),r=s._calculateBarIndexPixels(t,e,i),l=s.chart.data.datasets[s.index].data[t],c=o.getPixelForValue(l.o),d=o.getPixelForValue(l.h),h=o.getPixelForValue(l.l),u=o.getPixelForValue(l.c);return{base:n?a:h,x:r.center,y:(h+d)/2,width:r.size,open:c,high:d,low:h,close:u}}draw(){const t=this,e=t.chart,n=t._cachedMeta.data;Be(e.ctx,e.chartArea);for(let e=0;e<n.length;++e)n[e].draw(t._ctx);qe(e.ctx)}}class Eu extends _u{static id="candlestick";static defaults={..._u.defaults,borderWidth:1};draw(t){const e=this,{x:n,open:i,high:s,low:o,close:a}=e;let r,l=e.options.borderColors;"string"==typeof l&&(l={up:l,down:l,unchanged:l}),a<i?(r=ft(l?l.up:void 0,Ie.elements.candlestick.borderColors.up),t.fillStyle=ft(e.options.backgroundColors?e.options.backgroundColors.up:void 0,Ie.elements.candlestick.backgroundColors.up)):a>i?(r=ft(l?l.down:void 0,Ie.elements.candlestick.borderColors.down),t.fillStyle=ft(e.options.backgroundColors?e.options.backgroundColors.down:void 0,Ie.elements.candlestick.backgroundColors.down)):(r=ft(l?l.unchanged:void 0,Ie.elements.candlestick.borderColors.unchanged),t.fillStyle=ft(e.backgroundColors?e.backgroundColors.unchanged:void 0,Ie.elements.candlestick.backgroundColors.unchanged)),t.lineWidth=ft(e.options.borderWidth,Ie.elements.candlestick.borderWidth),t.strokeStyle=r,t.beginPath(),t.moveTo(n,s),t.lineTo(n,Math.min(i,a)),t.moveTo(n,o),t.lineTo(n,Math.max(i,a)),t.stroke(),t.fillRect(n-e.width/2,a,e.width,i-a),t.strokeRect(n-e.width/2,a,e.width,i-a),t.closePath()}}class Lu extends Pu{static id="candlestick";static defaults={...Pu.defaults,dataElementType:Eu.id};static defaultRoutes=_i.defaultRoutes;updateElements(t,e,n,i){const s="reset"===i,o=this._getRuler(),{sharedOptions:a,includeOptions:r}=this._getSharedOptions(e,i);for(let l=e;l<e+n;l++){const e=a||this.resolveDataElementOptions(l,i),n=this.calculateElementProperties(l,o,s,e);r&&(n.options=e),this.updateElement(t[l],l,n,i)}}}no.register(...nr,xh,Mu,Lu,Eu);class Au extends n{constructor(t,e,n){if(super(t,e,n),!e.symbol)throw new Error("Symbol is required for IntradayChartWidget");if(!e.wsManager)throw new Error("WebSocketManager is required for IntradayChartWidget");const i=g(e.symbol);if(!i.valid)throw new Error(`Invalid symbol: ${i.error}`);this.type="intraday-chart",this.wsManager=e.wsManager,this.symbol=i.sanitized,this.debug=e.debug||!1,this.source=e.source||"blueocean",this.rangeBack=e.rangeBack||0,this.chartType=e.chartType||"line",this.autoRefresh=void 0===e.autoRefresh||e.autoRefresh,this.refreshInterval=e.refreshInterval||6e4,this.refreshTimer=null,this.isUserInteracting=!1,this.marketIsOpen=null,this.marketStatusChecked=!1,this.chartData=null,this.chartInstance=null,this.unsubscribe=null,this.livePrice=null,this.companyName="",this.exchangeName="",this.mic="",this.symbolEditor=null,this.cached1DData=null,this.cached5DData=null,this.is5DDataLoading=!1,this.createWidgetStructure(),this.setupSymbolEditor(),this.initialize()}createWidgetStructure(){this.container.innerHTML='\n <div class="intraday-chart-widget">\n <div class="chart-header">\n <div class="chart-title-section">\n <div class="company-market-info">\n <span class="intraday-company-name"></span>\n </div>\n <h3 class="intraday-chart-symbol editable-symbol"\n title="Double-click to edit symbol"\n data-original-symbol="">AAPL</h3>\n </div>\n <div class="chart-change positive">+0.00 (+0.00%)</div>\n </div>\n\n <div class="chart-controls">\n <div class="chart-range-selector">\n <button class="range-btn active" data-range="0">1D</button>\n <button class="range-btn" data-range="5">5D</button>\n </div>\n <div class="chart-type-selector">\n <button class="type-btn active" data-type="line" title="Line Chart">Line</button>\n <button class="type-btn" data-type="area" title="Area Chart">Mountain</button>\n <button class="type-btn" data-type="candlestick" title="Candlestick Chart">Candles</button>\n </div>\n <button class="zoom-reset-btn" title="Reset Zoom">\n <svg width="16" height="16" viewBox="0 0 16 16" fill="none">\n <path d="M2 8a6 6 0 1 1 12 0A6 6 0 0 1 2 8zm6-7a7 7 0 1 0 0 14A7 7 0 0 0 8 1z" fill="currentColor"/>\n <path d="M5 8h6M8 5v6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>\n </svg>\n Reset Zoom\n </button>\n </div>\n\n <div class="chart-container">\n <canvas id="intradayChart"></canvas>\n </div>\n\n <div class="chart-stats">\n <div class="stats-header">Daily Stats</div>\n <div class="stats-grid">\n <div class="stat-item stat-open">\n <span class="stat-label">Open</span>\n <span class="stat-value">$0.00</span>\n </div>\n <div class="stat-item stat-high">\n <span class="stat-label">High</span>\n <span class="stat-value">$0.00</span>\n </div>\n <div class="stat-item stat-low">\n <span class="stat-label">Low</span>\n <span class="stat-value">$0.00</span>\n </div>\n <div class="stat-item stat-close">\n <span class="stat-label">Close</span>\n <span class="stat-value">$0.00</span>\n </div>\n <div class="stat-item stat-volume">\n <span class="stat-label">Volume</span>\n <span class="stat-value">0</span>\n </div>\n </div>\n </div>\n\n <div class="widget-loading-overlay hidden">\n <div class="loading-spinner"></div>\n <div class="loading-text">Loading chart data...</div>\n </div>\n </div>\n';const t=this.container.querySelector(".intraday-chart-symbol");t&&(t.textContent=this.symbol),this.setupRangeButtons(),this.setupChartTypeButtons(),this.addStyles()}setupSymbolEditor(){this.symbolEditor=new s(this,{maxLength:10,placeholder:"Enter symbol...",onSymbolChange:this.handleSymbolChange.bind(this),debug:this.debug,autoUppercase:!0,symbolType:"nightsession"});const t=this.container.querySelector(".intraday-chart-symbol");t&&(t.textContent=this.symbol,t.dataset.originalSymbol=this.symbol)}async handleSymbolChange(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.debug&&(console.log("[IntradayChartWidget] Symbol change requested:",t),console.log("[IntradayChartWidget] Validation data:",n));const i=g(t);if(!i.valid)return this.debug&&console.log("[IntradayChartWidget] Invalid symbol:",i.error),{success:!1,error:i.error};const s=i.sanitized;if(n&&(this.companyName=n.comp_name||"",this.exchangeName=n.market_name||"",this.mic=n.mic||"",this.debug&&console.log("[IntradayChartWidget] Extracted company info:",{companyName:this.companyName,exchangeName:this.exchangeName})),s===this.symbol)return this.debug&&console.log("[IntradayChartWidget] Same symbol, no change needed"),{success:!0};try{return this.showLoading(),this.stopAutoRefresh(),this.unsubscribe&&(this.debug&&console.log(`[IntradayChartWidget] Unsubscribing from ${e}`),this.unsubscribe(),this.unsubscribe=null),this.chartInstance&&(this.debug&&console.log("[IntradayChartWidget] Clearing chart for symbol change"),this.chartInstance.destroy(),this.chartInstance=null),this.chartData=null,this.livePrice=null,this.cached1DData=null,this.cached5DData=null,this.is5DDataLoading=!1,this.symbol=s,this.updateCompanyName(),await this.loadChartData(),this.debug&&console.log(`[IntradayChartWidget] Successfully changed symbol from ${e} to ${s}`),{success:!0}}catch(t){return console.error("[IntradayChartWidget] Error changing symbol:",t),this.showError(`Failed to load data for ${s}`),{success:!1,error:`Failed to load ${s}`}}}async initialize(){!1!==await super.validateInitialSymbol("quotel1",this.symbol,(t=>{t&&t[0]&&(this.companyName=t[0].comp_name||"",this.exchangeName=t[0].market_name||"",this.mic=t[0].mic||"")}))&&(this.updateCompanyName(),await this.loadChartData())}updateCompanyName(){const t=this.container.querySelector(".intraday-company-name");t&&(t.textContent=this.companyName||"")}setupRangeButtons(){const t=this.container.querySelectorAll(".range-btn");t.forEach((e=>{e.addEventListener("click",(async e=>{const n=parseInt(e.target.getAttribute("data-range"));t.forEach((t=>t.classList.remove("active"))),e.target.classList.add("active"),this.rangeBack=n,await this.loadChartData(),0===n?(await this.startAutoRefresh(),await this.subscribeToLivePrice()):(this.stopAutoRefresh(),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null,this.livePrice=null))}))}))}setupChartTypeButtons(){const t=this.container.querySelectorAll(".type-btn");t.forEach((e=>{e.addEventListener("click",(e=>{const n=e.target.getAttribute("data-type");t.forEach((t=>t.classList.remove("active"))),e.target.classList.add("active"),this.chartType=n,this.renderChart()}))}))}addStyles(){if(this.options.skipStyleInjection||document.querySelector('link[href*="mdas-styles.css"]'))this.debug&&console.log("[IntradayChartWidget] Skipping style injection - external styles detected");else if(!document.querySelector("#intraday-chart-styles"))try{const t=document.createElement("style");t.id="intraday-chart-styles",t.textContent="\n .intraday-chart-widget {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;\n background: white;\n border-radius: 12px;\n padding: 20px;\n box-shadow: 0 2px 8px rgba(0,0,0,0.1);\n position: relative;\n width: 100%;\n min-width: 600px;\n max-width: 1400px;\n margin: 0 auto;\n }\n\n .intraday-chart-widget .chart-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: 20px;\n padding-bottom: 15px;\n border-bottom: 1px solid #e5e7eb;\n }\n\n .intraday-chart-widget .chart-title-section {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .intraday-chart-widget .company-market-info {\n display: flex;\n gap: 8px;\n align-items: center;\n font-size: 0.75em;\n color: #6b7280;\n }\n\n .intraday-chart-widget .intraday-company-name {\n font-weight: 500;\n }\n\n .intraday-chart-widget .intraday-chart-symbol {\n font-size: 1.5em;\n font-weight: 700;\n color: #1f2937;\n margin: 0;\n }\n\n .intraday-chart-widget .intraday-chart-source {\n font-size: 0.75em;\n padding: 4px 8px;\n border-radius: 4px;\n background: #e0e7ff;\n color: #4338ca;\n font-weight: 600;\n }\n\n .intraday-chart-widget .chart-change {\n font-size: 1.1em;\n font-weight: 600;\n padding: 6px 12px;\n border-radius: 6px;\n }\n\n .intraday-chart-widget .chart-change.positive {\n color: #059669;\n background: #d1fae5;\n }\n\n .intraday-chart-widget .chart-change.negative {\n color: #dc2626;\n background: #fee2e2;\n }\n\n .intraday-chart-widget .chart-controls {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: 15px;\n }\n\n .intraday-chart-widget .chart-range-selector {\n display: flex;\n gap: 8px;\n }\n\n .intraday-chart-widget .range-btn {\n padding: 8px 16px;\n border: 1px solid #e5e7eb;\n background: white;\n border-radius: 6px;\n font-size: 0.875em;\n font-weight: 600;\n color: #6b7280;\n cursor: pointer;\n transition: all 0.2s ease;\n }\n\n .intraday-chart-widget .range-btn:hover {\n background: #f9fafb;\n border-color: #d1d5db;\n }\n\n .intraday-chart-widget .range-btn.active {\n background: #667eea;\n color: white;\n border-color: #667eea;\n }\n\n .intraday-chart-widget .range-btn:focus {\n outline: none;\n box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);\n }\n\n .intraday-chart-widget .chart-type-selector {\n display: flex;\n gap: 8px;\n }\n\n .intraday-chart-widget .type-btn {\n padding: 8px 16px;\n border: 1px solid #e5e7eb;\n background: white;\n border-radius: 6px;\n font-size: 0.875em;\n font-weight: 600;\n color: #6b7280;\n cursor: pointer;\n transition: all 0.2s ease;\n }\n\n .intraday-chart-widget .type-btn:hover {\n background: #f9fafb;\n border-color: #d1d5db;\n }\n\n .intraday-chart-widget .type-btn.active {\n background: #10b981;\n color: white;\n border-color: #10b981;\n }\n\n .intraday-chart-widget .type-btn:focus {\n outline: none;\n box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);\n }\n\n .intraday-chart-widget .zoom-reset-btn {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 8px 12px;\n border: 1px solid #e5e7eb;\n background: white;\n border-radius: 6px;\n font-size: 0.875em;\n font-weight: 500;\n color: #6b7280;\n cursor: pointer;\n transition: all 0.2s ease;\n }\n\n .intraday-chart-widget .zoom-reset-btn:hover {\n background: #f9fafb;\n border-color: #667eea;\n color: #667eea;\n }\n\n .intraday-chart-widget .zoom-reset-btn:focus {\n outline: none;\n box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);\n }\n\n .intraday-chart-widget .zoom-reset-btn svg {\n flex-shrink: 0;\n }\n\n .intraday-chart-widget .chart-container {\n height: 500px;\n margin-bottom: 20px;\n position: relative;\n }\n\n .intraday-chart-widget .chart-stats {\n padding: 15px;\n background: #f9fafb;\n border-radius: 8px;\n }\n\n .intraday-chart-widget .stats-header {\n font-size: 0.875em;\n font-weight: 700;\n color: #374151;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n margin-bottom: 12px;\n padding-bottom: 8px;\n border-bottom: 2px solid #e5e7eb;\n }\n\n .intraday-chart-widget .stats-grid {\n display: grid;\n grid-template-columns: repeat(5, 1fr);\n gap: 15px;\n }\n\n .intraday-chart-widget .stat-item {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .intraday-chart-widget .stat-label {\n font-size: 0.75em;\n color: #6b7280;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n }\n\n .intraday-chart-widget .stat-value {\n font-size: 1.1em;\n font-weight: 700;\n color: #1f2937;\n }\n\n .intraday-chart-widget .widget-loading-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(255, 255, 255, 0.4);\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n gap: 10px;\n padding: 10px 16px;\n border-radius: 12px;\n z-index: 10;\n pointer-events: none;\n backdrop-filter: blur(1px);\n }\n\n .intraday-chart-widget .widget-loading-overlay.hidden {\n display: none;\n }\n\n .intraday-chart-widget .loading-spinner {\n width: 20px;\n height: 20px;\n border: 3px solid #e5e7eb;\n border-top-color: #667eea;\n border-radius: 50%;\n animation: intraday-spin 0.8s linear infinite;\n }\n\n .intraday-chart-widget .loading-text {\n color: #6b7280;\n font-size: 0.875em;\n font-weight: 500;\n }\n\n @keyframes intraday-spin {\n to { transform: rotate(360deg); }\n }\n\n @media (max-width: 768px) {\n .intraday-chart-widget {\n min-width: unset;\n padding: 15px;\n }\n\n .intraday-chart-widget .stats-grid {\n grid-template-columns: repeat(3, 1fr);\n gap: 10px;\n }\n\n .intraday-chart-widget .stats-header {\n font-size: 0.8em;\n margin-bottom: 10px;\n }\n\n .intraday-chart-widget .chart-container {\n height: 350px;\n }\n\n .intraday-chart-widget .intraday-chart-symbol {\n font-size: 1.2em;\n }\n }\n\n .intraday-chart-widget .widget-error {\n padding: 15px;\n background: #fee2e2;\n border: 1px solid #fecaca;\n border-radius: 8px;\n color: #dc2626;\n font-size: 0.9em;\n margin-top: 10px;\n }\n",document.head.appendChild(t),this.debug&&console.log("[IntradayChartWidget] Styles injected successfully")}catch(t){console.warn("[IntradayChartWidget] Failed to inject styles:",t),console.warn('[IntradayChartWidget] Please add <link rel="stylesheet" href="mdas-styles.css"> to your HTML')}}async loadChartData(){try{this.showLoading(),this.clearError();const t=this.wsManager.getApiService();if(!t)throw new Error("API service not available");if(5===this.rangeBack)return void await this.load5DayChartData(t);if(0===this.rangeBack&&this.cached1DData)return this.debug&&console.log("[IntradayChartWidget] Using cached 1D data"),this.chartData=this.cached1DData,this.renderChart(),this.hideLoading(),await this.startAutoRefresh(),void this.subscribeToLivePrice();const e=7;let n=this.rangeBack,i=!1,s=null,o=null,a=!1;for(let r=0;r<e;r++){if(this.debug&&console.log(`[IntradayChartWidget] Loading data for ${this.symbol} from ${this.source}, range_back: ${n} (attempt ${r+1}/${e})`),s=await t.getIntradayChart(this.source,this.symbol,n),console.log("[IntradayChartWidget] API response type:",typeof s),console.log("[IntradayChartWidget] API response:",s),s&&(console.log("[IntradayChartWidget] Response keys:",Object.keys(s)),Array.isArray(s)&&(console.log("[IntradayChartWidget] Response is array, length:",s.length),s.length>0&&(console.log("[IntradayChartWidget] First item:",s[0]),console.log("[IntradayChartWidget] First item keys:",Object.keys(s[0]))))),s&&s.error)throw new Error(s.error||"Server error");if(o=s,s&&s.data&&Array.isArray(s.data)&&(console.log("[IntradayChartWidget] Found data array in response.data"),o=s.data),o&&Array.isArray(o)&&o.length>0){i=!0,n!==this.rangeBack&&(a=!0,this.debug&&console.log(`[IntradayChartWidget] Using fallback data: requested rangeBack ${this.rangeBack}, got data from rangeBack ${n}`));break}console.log(`[IntradayChartWidget] No data for rangeBack ${n}, trying ${n+1}...`),n++}if(!i||!o||0===o.length)throw new Error(`No intraday data available for ${this.symbol} in the past ${e} days`);if(console.log("[IntradayChartWidget] Processing",o.length,"data points"),this.chartData=new P(o),console.log("[IntradayChartWidget] Model created with",this.chartData.dataPoints.length,"points"),0===this.chartData.dataPoints.length)throw console.error("[IntradayChartWidget] Model has no data points after processing"),new Error(`No valid data points for ${this.symbol}`);0===this.rangeBack&&(this.cached1DData=this.chartData,this.debug&&console.log("[IntradayChartWidget] Cached 1D data for instant switching")),this.renderChart(),this.hideLoading(),this.debug&&console.log(`[IntradayChartWidget] Loaded ${o.length} data points`),0!==this.rangeBack||a?(this.stopAutoRefresh(),this.debug&&console.log("[IntradayChartWidget] Not starting auto-refresh for historical/fallback data")):(await this.startAutoRefresh(),this.subscribeToLivePrice(),this.preload5DDataInBackground())}catch(t){console.error("[IntradayChartWidget] Error loading chart data:",t),this.hideLoading();let e="Failed to load chart data";t.message.includes("No intraday data")?e=t.message:t.message.includes("API service not available")?e="Unable to connect to data service":t.message.includes("HTTP error")||t.message.includes("status: 4")?e=`Unable to load data for ${this.symbol}`:t.message.includes("status: 5")?e="Server error. Please try again later":t.message.includes("Failed to fetch")&&(e="Network error. Please check your connection"),this.showError(e)}}async load5DayChartData(t){try{if(this.cached5DData)return this.debug&&console.log("[IntradayChartWidget] Using cached 5D data"),this.chartData=this.cached5DData,this.renderChart(),this.hideLoading(),this.subscribeToLivePrice(),void this.stopAutoRefresh();const e=await this.fetch5DayData(t);if(this.chartData=new P(e),0===this.chartData.dataPoints.length)throw new Error(`No valid data points for ${this.symbol}`);this.cached5DData=this.chartData,this.renderChart(),this.hideLoading(),this.debug&&console.log(`[IntradayChartWidget] 5D chart loaded with ${this.chartData.dataPoints.length} data points`),this.subscribeToLivePrice(),this.stopAutoRefresh()}catch(t){throw console.error("[IntradayChartWidget] Error loading 5D chart data:",t),t}}async fetch5DayData(t){this.debug&&console.log("[IntradayChartWidget] Fetching 5D chart data with parallel requests (API limit: rangeback 0-6)");const e=[];for(let n=0;n<7;n++)e.push(t.getIntradayChart(this.source,this.symbol,n).then((t=>{let e=t;return t&&t.data&&Array.isArray(t.data)&&(e=t.data),{rangeBack:n,data:e}})).catch((t=>(this.debug&&console.warn(`[IntradayChartWidget] Request failed for rangeback ${n}:`,t),{rangeBack:n,data:null}))));const n=await Promise.all(e);this.debug&&console.log("[IntradayChartWidget] All parallel requests completed");const i=n.filter((t=>{const e=t.data&&Array.isArray(t.data)&&t.data.length>0;return this.debug&&(e?console.log(`[IntradayChartWidget] Rangeback ${t.rangeBack}: ${t.data.length} data points`):console.log(`[IntradayChartWidget] Rangeback ${t.rangeBack}: No data (skipped)`)),e})).slice(0,5);if(0===i.length)throw new Error(`No intraday data available for ${this.symbol} in the past 7 days`);this.debug&&(console.log(`[IntradayChartWidget] Collected ${i.length}/5 days of data`),i.length<5&&console.log(`[IntradayChartWidget] Note: Only ${i.length} days available within API limit (rangeback 0-6)`));const s=[];for(let t=i.length-1;t>=0;t--)s.push(...i[t].data);return this.debug&&console.log(`[IntradayChartWidget] Combined ${s.length} total data points from ${i.length} days`),s}preload5DDataInBackground(){this.is5DDataLoading||this.cached5DData||(this.is5DDataLoading=!0,this.debug&&console.log("[IntradayChartWidget] Starting background preload of 5D data..."),setTimeout((async()=>{try{const t=this.wsManager.getApiService();if(!t)return void(this.debug&&console.log("[IntradayChartWidget] API service not available for preload"));const e=await this.fetch5DayData(t),n=new P(e);this.cached5DData=n,this.debug&&console.log(`[IntradayChartWidget] ✓ Background preload complete: ${n.dataPoints.length} data points cached`)}catch(t){this.debug&&console.warn("[IntradayChartWidget] Background preload failed:",t)}finally{this.is5DDataLoading=!1}}),1e3))}subscribeToLivePrice(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null);const t="bruce"===this.source?"querybrucel1":"queryblueoceanl1";this.debug&&console.log(`[IntradayChartWidget] Subscribing to live price with ${t} for ${this.symbol}`),this.unsubscribe=this.wsManager.subscribe(this.widgetId,[t],this.handleMessage.bind(this),this.symbol)}handleError(t){this.debug&&console.error("[IntradayChartWidget] WebSocket error:",t.message||t)}handleData(t){console.log("[IntradayChartWidget] handleData called with:",t),console.log("[IntradayChartWidget] Looking for symbol:",this.symbol),console.log("[IntradayChartWidget] Message is array?",Array.isArray(t));let e=null;if(Array.isArray(t.data)){console.log("[IntradayChartWidget] Processing array format, length:",t.length);const n=t.data.find((t=>t.Symbol===this.symbol));console.log("[IntradayChartWidget] Found symbol data:",n),n&&!n.NotFound&&(e=n)}else t.Symbol!==this.symbol||t.NotFound||(console.log("[IntradayChartWidget] Processing direct format"),e=t);if(!e)return void console.log("[IntradayChartWidget] No matching price data found for symbol:",this.symbol);console.log("[IntradayChartWidget] Price data found:",e);let n=null;void 0!==e.LastPx&&null!==e.LastPx?(n=parseFloat(e.LastPx),console.log("[IntradayChartWidget] Price from LastPx:",n)):void 0!==e.Last&&null!==e.Last?(n=parseFloat(e.Last),console.log("[IntradayChartWidget] Price from Last:",n)):void 0!==e.last_price&&null!==e.last_price?(n=parseFloat(e.last_price),console.log("[IntradayChartWidget] Price from last_price:",n)):void 0!==e.TradePx&&null!==e.TradePx?(n=parseFloat(e.TradePx),console.log("[IntradayChartWidget] Price from TradePx:",n)):void 0!==e.Close&&null!==e.Close?(n=parseFloat(e.Close),console.log("[IntradayChartWidget] Price from Close:",n)):void 0!==e.close&&null!==e.close&&(n=parseFloat(e.close),console.log("[IntradayChartWidget] Price from close:",n)),console.log("[IntradayChartWidget] Extracted price:",n),n&&!isNaN(n)&&n>0?(this.livePrice=n,console.log("[IntradayChartWidget] Updating live price line to:",n),this.updateLivePriceLine(),console.log(`[IntradayChartWidget] Live price update: $${n.toFixed(2)}`)):console.log("[IntradayChartWidget] Invalid price, not updating:",n),this.updateStatsFromLiveData(e)}updateStatsFromLiveData(t){if(!t)return;const e={high:void 0!==t.HighPx&&null!==t.HighPx?parseFloat(t.HighPx):null,low:void 0!==t.LowPx&&null!==t.LowPx?parseFloat(t.LowPx):null,open:void 0!==t.OpenPx&&null!==t.OpenPx?parseFloat(t.OpenPx):null,close:void 0!==t.LastPx&&null!==t.LastPx?parseFloat(t.LastPx):void 0!==t.TradePx&&null!==t.TradePx?parseFloat(t.TradePx):null,volume:void 0!==t.Volume&&null!==t.Volume?parseInt(t.Volume):null,change:void 0!==t.Change&&null!==t.Change?parseFloat(t.Change):null,changePercent:void 0!==t.ChangePercent&&null!==t.ChangePercent?100*parseFloat(t.ChangePercent):null};this.debug&&console.log("[IntradayChartWidget] Updating stats from live data:",e);const n=this.container.querySelector(".stat-high .stat-value"),i=this.container.querySelector(".stat-low .stat-value"),s=this.container.querySelector(".stat-open .stat-value"),o=this.container.querySelector(".stat-close .stat-value"),a=this.container.querySelector(".stat-volume .stat-value"),r=this.container.querySelector(".chart-change");if(n&&null!==e.high&&(n.textContent=`$${e.high.toFixed(2)}`),i&&null!==e.low&&(i.textContent=`$${e.low.toFixed(2)}`),s&&null!==e.open&&(s.textContent=`$${e.open.toFixed(2)}`),o&&null!==e.close&&(o.textContent=`$${e.close.toFixed(2)}`),a&&null!==e.volume&&(a.textContent=this.formatVolume(e.volume)),r&&null!==e.change&&null!==e.changePercent){const t=e.change>=0?"positive":"negative";r.className=`chart-change ${t}`;const n=e.change>=0?"+":"";r.textContent=`${n}${e.change.toFixed(2)} (${n}${e.changePercent.toFixed(2)}%)`}}formatVolume(t){return t>=1e6?(t/1e6).toFixed(2)+"M":t>=1e3?(t/1e3).toFixed(2)+"K":t.toString()}updateLivePriceLine(){this.chartInstance&&this.livePrice?this.chartInstance.options.plugins.annotation&&(this.chartInstance.options.plugins.annotation.annotations.livePriceLine.value=this.livePrice,this.chartInstance.options.plugins.annotation.annotations.livePriceLine.label.content=`$${this.livePrice.toFixed(2)}`,this.chartInstance.options.plugins.annotation.annotations.livePriceLine.label.display=!0,this.debug&&console.log("[IntradayChartWidget] Live price line updated:",{price:this.livePrice,label:this.chartInstance.options.plugins.annotation.annotations.livePriceLine.label.content}),this.chartInstance.update("none")):this.debug&&console.log("[IntradayChartWidget] Cannot update live price line:",{hasChart:!!this.chartInstance,livePrice:this.livePrice})}async isMarketOpen(){const t=new Date,e=t.toLocaleString("en-US",{timeZone:"America/New_York",weekday:"short"}),n=parseInt(t.toLocaleString("en-US",{timeZone:"America/New_York",hour12:!1,hour:"numeric"}),10),i=parseInt(t.toLocaleString("en-US",{timeZone:"America/New_York",minute:"numeric"}),10);if("Sat"===e||"Sun"===e)return!1;const s=n>=20||n<4;if(this.debug&&console.log(`[IntradayChartWidget] Market check: ET hour=${n}, minute=${i}, day=${e}, open=${s}`),!s)return this.debug&&console.log("[IntradayChartWidget] Market is currently closed (outside 8pm-4am ET on weekdays)."),!1;if(!this.marketStatusChecked)try{const t=this.wsManager.getApiService(),e=await t.getMarketStatus(this.source);if(e&&Array.isArray(e)&&e.length>0){const t=e[0].status;return this.marketIsOpen=t&&"open"===t.toLowerCase(),this.marketStatusChecked=!0,this.debug&&console.log(`[IntradayChartWidget] Market status from API: ${t} (${this.marketIsOpen?"Open":"Closed"})`),this.marketIsOpen}}catch(t){return this.debug&&console.warn("[IntradayChartWidget] Failed to get market status from API, assuming open based on time:",t),this.marketIsOpen=!0,this.marketStatusChecked=!0,!0}return!1!==this.marketIsOpen&&(!0!==this.marketIsOpen||(!(3===n&&i>=45)||(this.debug&&console.log("[IntradayChartWidget] Approaching market close, re-checking status..."),this.marketStatusChecked=!1,await this.isMarketOpen())))}async startAutoRefresh(){if(this.stopAutoRefresh(),!this.autoRefresh)return;await this.isMarketOpen()?(this.debug&&console.log(`[IntradayChartWidget] Starting auto-refresh every ${this.refreshInterval/1e3} seconds`),this.refreshTimer=setInterval((async()=>{if(!await this.isMarketOpen())return this.debug&&console.log("[IntradayChartWidget] Market closed. Stopping auto-refresh."),void this.stopAutoRefresh();if(this.isUserInteracting)this.debug&&console.log("[IntradayChartWidget] Skipping refresh - user is interacting");else{this.debug&&console.log("[IntradayChartWidget] Auto-refreshing chart data");try{const t=this.wsManager.getApiService(),e=await t.getIntradayChart(this.source,this.symbol,this.rangeBack);e&&Array.isArray(e)&&(this.chartData=new P(e),this.renderChart(),this.debug&&console.log(`[IntradayChartWidget] Auto-refresh complete - ${e.length} data points`))}catch(t){console.error("[IntradayChartWidget] Auto-refresh failed:",t)}}}),this.refreshInterval)):this.debug&&console.log("[IntradayChartWidget] Market is closed. Auto-refresh will not start.")}stopAutoRefresh(){this.refreshTimer&&(this.debug&&console.log("[IntradayChartWidget] Stopping auto-refresh"),clearInterval(this.refreshTimer),this.refreshTimer=null)}parseTimestamp(t){return new Date(t)}renderChart(){if(console.log("[IntradayChartWidget] renderChart called"),!this.chartData||0===this.chartData.dataPoints.length)return void console.error("[IntradayChartWidget] No data to render");console.log("[IntradayChartWidget] Chart data points:",this.chartData.dataPoints.length);const t=this.container.querySelector("#intradayChart");if(console.log("[IntradayChartWidget] Canvas element:",t),!t)return void console.error("[IntradayChartWidget] Canvas element not found");if(this.chartInstance){console.log("[IntradayChartWidget] Destroying existing chart instance");try{this.chartInstance.destroy(),this.chartInstance=null}catch(t){console.error("[IntradayChartWidget] Error destroying chart:",t),this.chartInstance=null}}const e=t.getContext("2d");console.log("[IntradayChartWidget] Canvas context:",e),console.log("[IntradayChartWidget] Preparing chart data...");const n=this.chartData.getStats();console.log("[IntradayChartWidget] Stats:",n);const i=n.change>=0,s=i?"#10b981":"#ef4444";let o,a;const r=this.chartData.dataPoints;if(0===r.length)return console.error("[IntradayChartWidget] No valid data points from model"),void this.showError("No valid chart data available");if(console.log("[IntradayChartWidget] Rendering",r.length,"data points"),"candlestick"===this.chartType){if(o=this.rangeBack>0?r.map(((t,e)=>({x:e,o:t.open,h:t.high,l:t.low,c:t.close}))):r.map((t=>({x:this.parseTimestamp(t.time).getTime(),o:t.open,h:t.high,l:t.low,c:t.close}))).filter((t=>!isNaN(t.x)&&t.x>0)),0===o.length)return console.error("[IntradayChartWidget] No valid candlestick data points after date parsing"),void this.showError("Unable to parse chart data timestamps");a={label:"Price",data:o,color:{up:"#10b981",down:"#ef4444",unchanged:"#6b7280"},borderColor:{up:"#10b981",down:"#ef4444",unchanged:"#6b7280"}}}else{if(o=this.rangeBack>0?r.map(((t,e)=>({x:e,y:t.close}))):r.map((t=>({x:this.parseTimestamp(t.time),y:t.close}))).filter((t=>{const e=t.x.getTime();return!isNaN(e)&&e>0})),0===o.length)return console.error("[IntradayChartWidget] No valid chart data points after date parsing"),void this.showError("Unable to parse chart data timestamps");const t=e.createLinearGradient(0,0,0,300);i?(t.addColorStop(0,"rgba(16, 185, 129, 0.3)"),t.addColorStop(1,"rgba(16, 185, 129, 0.01)")):(t.addColorStop(0,"rgba(239, 68, 68, 0.3)"),t.addColorStop(1,"rgba(239, 68, 68, 0.01)")),a={label:"Price",data:o,borderColor:s,backgroundColor:"area"===this.chartType?t:"transparent",borderWidth:2,fill:"area"===this.chartType,tension:.4,pointRadius:0,pointHoverRadius:4,pointBackgroundColor:s,pointBorderColor:"#fff",pointBorderWidth:2}}let l,c;if(console.log("[IntradayChartWidget] Chart data points prepared:",o.length),console.log("[IntradayChartWidget] First data point - Source time:",r[0].time),console.log("[IntradayChartWidget] First chart point:",o[0]),console.log("[IntradayChartWidget] Last data point - Source time:",r[r.length-1].time),console.log("[IntradayChartWidget] Last chart point:",o[o.length-1]),0===this.rangeBack){const t=o.map((t=>"candlestick"===this.chartType?t.x:t.x.getTime()));l=Math.min(...t),c=Math.max(...t),console.log("[IntradayChartWidget] X-axis bounds:",{min:l,max:c,minDate:new Date(l),maxDate:new Date(c)})}else console.log("[IntradayChartWidget] Using linear scale with",o.length,"data points");const d={type:"candlestick"===this.chartType?"candlestick":"line",data:{datasets:[a]},options:{responsive:!0,maintainAspectRatio:!1,interaction:{intersect:!1,mode:"index"},plugins:{legend:{display:!1},decimation:{enabled:o.length>1e3,algorithm:"lttb",samples:500,threshold:1e3},tooltip:{enabled:!0,backgroundColor:"rgba(0, 0, 0, 0.8)",titleColor:"#fff",bodyColor:"#fff",borderColor:s,borderWidth:1,padding:10,displayColors:!1,callbacks:{title:t=>{const e=t[0].dataIndex,n=r[e];if(n){return new Date(n.time).toLocaleString("en-US",{month:"2-digit",day:"2-digit",year:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit",hour12:!0})}return""},label:t=>{const e=t.dataIndex,n=r[e];return n?"candlestick"===this.chartType?[`Open: $${n.open.toFixed(2)}`,`High: $${n.high.toFixed(2)}`,`Low: $${n.low.toFixed(2)}`,`Close: $${n.close.toFixed(2)}`,`Volume: ${this.chartData.formatVolume(n.volume)}`]:[`Price: $${n.close.toFixed(2)}`,`Open: $${n.open.toFixed(2)}`,`High: $${n.high.toFixed(2)}`,`Low: $${n.low.toFixed(2)}`,`Volume: ${this.chartData.formatVolume(n.volume)}`]:[]}}},zoom:{pan:{enabled:!0,mode:"x",modifierKey:"ctrl"},zoom:{wheel:{enabled:!0,speed:.1},pinch:{enabled:!0},mode:"x"},limits:{x:{min:"original",max:"original"}}},annotation:{annotations:this.createAnnotations(r,n)}},scales:{x:{type:0===this.rangeBack?"time":"linear",min:0===this.rangeBack?l:void 0,max:0===this.rangeBack?c:void 0,time:0===this.rangeBack?{unit:"hour",stepSize:1,displayFormats:{hour:"h:mm a"},tooltipFormat:"MMM d, h:mm a"}:void 0,grid:{display:!1},ticks:{maxTicksLimit:0===this.rangeBack?10:8,color:"#6b7280",autoSkip:!0,maxRotation:0,minRotation:0,callback:(t,e,n)=>{if(this.rangeBack>0){const e=Math.round(t),n=r[e];if(n){return new Date(n.time).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0})}return""}if("number"==typeof t){return new Date(t).toLocaleString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}return t}}},y:{position:"right",grid:{color:"rgba(0, 0, 0, 0.05)"},ticks:{color:"#6b7280",callback:function(t){return"$"+t.toFixed(2)}},afterDataLimits:t=>{const e=.1*(t.max-t.min);t.max+=e,t.min-=e}}}}};console.log("[IntradayChartWidget] Creating Chart.js instance with config:",d),console.log("[IntradayChartWidget] Chart available?",void 0!==no);try{this.chartInstance=new no(e,d),console.log("[IntradayChartWidget] Chart instance created successfully:",this.chartInstance)}catch(t){throw console.error("[IntradayChartWidget] Error creating chart:",t),t}t.addEventListener("mouseenter",(()=>{this.isUserInteracting=!0})),t.addEventListener("mouseleave",(()=>{this.isUserInteracting=!1})),this.setupZoomReset()}createAnnotations(t,e){const n={livePriceLine:{type:"line",scaleID:"y",value:this.livePrice||e.close,borderColor:"#667eea",borderWidth:2,borderDash:[5,5],label:{display:!0,content:this.livePrice?`$${this.livePrice.toFixed(2)}`:`$${e.close.toFixed(2)}`,enabled:!0,position:"end",backgroundColor:"rgb(102, 126, 234)",color:"#ffffff",font:{size:12,weight:"bold",family:"system-ui, -apple-system, sans-serif"},padding:{top:4,bottom:4,left:8,right:8},borderRadius:4,xAdjust:-10,yAdjust:0}}};if(this.rangeBack>0&&t.length>0){let e=null;t.forEach(((t,i)=>{const s=new Date(t.time).toDateString();e!==s&&null!==e&&(n[`daySeparator${i}`]={type:"line",scaleID:"x",value:i,borderColor:"rgba(0, 0, 0, 0.1)",borderWidth:1,borderDash:[3,3]}),e=s}))}return n}setupZoomReset(){const t=this.container.querySelector(".zoom-reset-btn");t&&t.addEventListener("click",(()=>{this.chartInstance&&(this.chartInstance.resetZoom(),this.debug&&console.log("[IntradayChartWidget] Zoom reset"))}))}updateStats(){if(!this.chartData)return;const t=this.chartData.getStats(),e=this.container.querySelector(".stat-high .stat-value"),n=this.container.querySelector(".stat-low .stat-value"),i=this.container.querySelector(".stat-open .stat-value"),s=this.container.querySelector(".stat-close .stat-value"),o=this.container.querySelector(".stat-volume .stat-value"),a=this.container.querySelector(".chart-change");if(e&&(e.textContent=`$${t.high.toFixed(2)}`),n&&(n.textContent=`$${t.low.toFixed(2)}`),i&&(i.textContent=`$${t.open.toFixed(2)}`),s&&(s.textContent=`$${t.close.toFixed(2)}`),o&&(o.textContent=this.chartData.formatVolume(t.volume)),a){const e=t.change>=0?"positive":"negative";a.className=`chart-change ${e}`;const n=t.change>=0?"+":"";a.textContent=`${n}${t.change.toFixed(2)} (${n}${t.changePercent.toFixed(2)}%)`}}async refreshData(){await this.loadChartData()}destroy(){this.stopAutoRefresh(),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null),this.chartInstance&&(this.chartInstance.destroy(),this.chartInstance=null),this.symbolEditor&&(this.symbolEditor.destroy(),this.symbolEditor=null),super.destroy()}}class Iu{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Array.isArray(t)?this.parseMMIDArray(t):(this.symbol=t.Symbol||"",this.timestamp=t.Timestamp||t.QuoteTime||"",this.bids=this.parseLevels(t.Bids||t.bids||[]),this.asks=this.parseLevels(t.Asks||t.asks||[]),0===this.bids.length&&t.BidPx&&t.BidPx>0&&(this.bids=[{mmid:t.BidExch||"BLUE",price:parseFloat(t.BidPx),size:parseInt(t.BidSz||0,10)}]),0===this.asks.length&&t.AskPx&&t.AskPx>0&&(this.asks=[{mmid:t.AskExch||"BLUE",price:parseFloat(t.AskPx),size:parseInt(t.AskSz||0,10)}])),this.bestBid=this.bids.length>0?this.bids[0].price:0,this.bestAsk=this.asks.length>0?this.asks[0].price:0,this.midPrice=this.bestBid&&this.bestAsk?(this.bestBid+this.bestAsk)/2:0,this.spread=this.bestBid&&this.bestAsk?this.bestAsk-this.bestBid:0}parseMMIDArray(t){this.symbol="",this.timestamp=t[0]?.BidTime||t[0]?.AskTime||"",this.bids=[],this.asks=[];let e=0,n=0;t.forEach((t=>{const i=t.MMID||"";if(void 0!==t.BidPx&&null!==t.BidPx){const n=parseFloat(t.BidPx);this.bids.push({mmid:i,price:n,size:parseInt(t.BidSz||0,10)}),n>0&&e++}if(void 0!==t.AskPx&&null!==t.AskPx){const e=parseFloat(t.AskPx);this.asks.push({mmid:i,price:e,size:parseInt(t.AskSz||0,10)}),e>0&&n++}})),this.bids.sort(((t,e)=>e.price-t.price)),this.asks.sort(((t,e)=>t.price-e.price)),console.log(`[ONBBOLevel2Model] Parsed ${t.length} MMID quotes: ${e} valid bids, ${n} valid asks`)}parseLevels(t){return Array.isArray(t)?t.map((t=>({mmid:t.MMID||t.mmid||"",price:parseFloat(t.Price||t.price||0),size:parseInt(t.Size||t.size||0,10)}))).filter((t=>t.price>0)):[]}getTopBids(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;return this.bids.slice(0,t)}getTopAsks(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;return this.asks.slice(0,t)}getBidColorIntensity(t){if(!this.bestBid||0===this.bids.length)return 0;if(t===this.bestBid)return 1;const e=this.bestBid-t,n=this.bids.length>0?this.bestBid-this.bids[this.bids.length-1].price:0;return 0===n?.5:Math.max(0,1-e/n)}getAskColorIntensity(t){if(!this.bestAsk||0===this.asks.length)return 0;if(t===this.bestAsk)return 1;const e=t-this.bestAsk,n=this.asks.length>0?this.asks[this.asks.length-1].price-this.bestAsk:0;return 0===n?.5:Math.max(0,1-e/n)}formatPrice(t){return t.toFixed(2)}formatSize(t){return t.toLocaleString()}formatSpread(){return this.spread.toFixed(2)}getTotalBidSize(){return this.bids.reduce(((t,e)=>t+e.size),0)}getTotalAskSize(){return this.asks.reduce(((t,e)=>t+e.size),0)}static fromApiResponse(t){return new Iu(t)}}class zu extends n{constructor(t,e,n){if(super(t,e,n),!e.symbol)throw new Error("Symbol is required for ONBBOLevel2Widget");if(!e.wsManager)throw new Error("WebSocketManager is required for ONBBOLevel2Widget");this.type="onbbo-level2";const i=g(e.symbol);if(!i.valid)throw new Error(`Invalid symbol: ${i.error}`);this.symbol=i.sanitized,this.wsManager=e.wsManager,this.debug=e.debug||!1,this.styled=void 0===e.styled||e.styled,this.maxLevels=e.maxLevels||10,this.data=null,this.level1Data=null,this.isDestroyed=!1,this.unsubscribeL2=null,this.unsubscribeL1=null,this.symbolEditor=null,this.loadingTimeout=null,this.companyName="",this.exchangeName="",this.createWidgetStructure(),this.initialize()}createWidgetStructure(){if(this.container.innerHTML='\n<div class="onbbo-level2-widget widget">\n <div class="widget-loading-overlay hidden">\n <div class="loading-content">\n <div class="loading-spinner"></div>\n <div class="loading-text">Loading order book...</div>\n </div>\n </div>\n\n <div class="widget-header">\n <div class="symbol-section">\n <div class="company-market-info">\n <span class="l2-company-name"></span>\n <span class="l2-market-name"></span>\n </div>\n <span class="symbol editable-symbol">--</span>\n <div class="level1-info">\n <div class="l1-item">\n <span class="l1-label">Last:</span>\n <span class="l1-value l1-last-px">--</span>\n </div>\n <div class="l1-item">\n <span class="l1-label">Low:</span>\n <span class="l1-value l1-low-px">--</span>\n </div>\n <div class="l1-item">\n <span class="l1-label">High:</span>\n <span class="l1-value l1-high-px">--</span>\n </div>\n <div class="l1-item">\n <span class="l1-label">Volume:</span>\n <span class="l1-value l1-volume">--</span>\n </div>\n </div>\n </div>\n </div>\n\n <div class="orderbook-container">\n \x3c!-- Bid Panel (Left) --\x3e\n <div class="orderbook-panel bid-panel">\n <div class="panel-header">\n <div class="col-header mmid-col">MMID</div>\n <div class="col-header bid-col">BID</div>\n <div class="col-header size-col">SIZE</div>\n </div>\n <div class="panel-body bid-body">\n \x3c!-- Bid levels will be dynamically inserted here --\x3e\n </div>\n </div>\n\n \x3c!-- Ask Panel (Right) --\x3e\n <div class="orderbook-panel ask-panel">\n <div class="panel-header">\n <div class="col-header mmid-col">MMID</div>\n <div class="col-header ask-col">ASK</div>\n <div class="col-header size-col">SIZE</div>\n </div>\n <div class="panel-body ask-body">\n \x3c!-- Ask levels will be dynamically inserted here --\x3e\n </div>\n </div>\n </div>\n\n <div class="widget-footer">\n <span class="last-update">Last update: --</span>\n <span class="data-source">ONBBO</span>\n </div>\n</div>\n',this.styled){const t=this.container.querySelector(".onbbo-level2-widget");t&&t.classList.add("widget-styled")}this.addStyles(),this.setupSymbolEditor()}addStyles(){if(!document.querySelector("#onbbo-level2-styles")){const t=document.createElement("style");t.id="onbbo-level2-styles",t.textContent="\n.onbbo-level2-widget {\n border: 1px solid #e5e7eb;\n border-radius: 8px;\n background: white;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n font-size: 13px;\n max-width: 100%;\n overflow: hidden;\n position: relative;\n}\n\n.onbbo-level2-widget .widget-header {\n background: #f9fafb;\n padding: 16px;\n border-bottom: 1px solid #e5e7eb;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n.onbbo-level2-widget .symbol-section {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n.onbbo-level2-widget .company-market-info {\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: 0.86em;\n color: #6b7280;\n}\n\n.onbbo-level2-widget .l2-company-name {\n font-weight: 600;\n color: #374151;\n}\n\n.onbbo-level2-widget .l2-market-name {\n font-weight: 500;\n color: #6b7280;\n}\n\n.onbbo-level2-widget .l2-market-name::before {\n content: '|';\n margin-right: 8px;\n color: #d1d5db;\n}\n\n.onbbo-level2-widget .symbol {\n font-size: 1.71em;\n font-weight: 700;\n color: #111827;\n}\n\n.onbbo-level2-widget .data-type {\n background: #dbeafe;\n padding: 4px 10px;\n border-radius: 6px;\n font-size: 0.86em;\n font-weight: 600;\n color: #1e40af;\n}\n\n.onbbo-level2-widget .spread-section {\n text-align: right;\n}\n\n.onbbo-level2-widget .spread-label {\n font-size: 0.86em;\n color: #6b7280;\n font-weight: 500;\n margin-bottom: 4px;\n}\n\n.onbbo-level2-widget .spread-value {\n font-size: 1.29em;\n font-weight: 700;\n color: #111827;\n}\n\n/* ========================================\n LEVEL 1 INFO (INSIDE HEADER)\n ======================================== */\n\n.onbbo-level2-widget .level1-info {\n display: grid;\n grid-template-columns: repeat(4, 1fr);\n gap: 12px;\n margin-top: 10px;\n}\n\n.onbbo-level2-widget .l1-item {\n display: flex;\n flex-direction: column;\n gap: 3px;\n}\n\n.onbbo-level2-widget .l1-label {\n font-size: 11px;\n font-weight: 600;\n color: #6b7280;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n}\n\n.onbbo-level2-widget .l1-value {\n font-size: 15px;\n font-weight: 700;\n color: #111827;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n}\n\n/* ========================================\n ORDER BOOK CONTAINER\n ======================================== */\n\n.onbbo-level2-widget .orderbook-container {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 0;\n}\n\n.onbbo-level2-widget .orderbook-panel {\n border-right: 1px solid #e5e7eb;\n overflow: hidden;\n background: white;\n}\n\n.onbbo-level2-widget .orderbook-panel:last-child {\n border-right: none;\n}\n\n/* ========================================\n PANEL HEADERS\n ======================================== */\n\n.onbbo-level2-widget .panel-header {\n display: grid;\n grid-template-columns: 80px 1fr 80px;\n background: #f3f4f6;\n padding: 8px 4px;\n font-size: 11px;\n font-weight: 700;\n color: #374151;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n border-bottom: 2px solid #d1d5db;\n position: sticky;\n top: 0;\n z-index: 10;\n}\n\n.onbbo-level2-widget .col-header {\n text-align: center;\n padding: 0 4px;\n}\n\n/* ========================================\n PANEL BODY - SCROLLABLE AREA\n ======================================== */\n\n.onbbo-level2-widget .panel-body {\n min-height: 300px;\n max-height: 400px;\n overflow-y: auto;\n}\n\n/* Custom scrollbar */\n.onbbo-level2-widget .panel-body::-webkit-scrollbar {\n width: 6px;\n}\n\n.onbbo-level2-widget .panel-body::-webkit-scrollbar-track {\n background: #f3f4f6;\n}\n\n.onbbo-level2-widget .panel-body::-webkit-scrollbar-thumb {\n background: #9ca3af;\n border-radius: 3px;\n}\n\n.onbbo-level2-widget .panel-body::-webkit-scrollbar-thumb:hover {\n background: #6b7280;\n}\n\n/* ========================================\n ORDER BOOK ROWS\n ======================================== */\n\n.onbbo-level2-widget .level-row {\n display: grid;\n grid-template-columns: 80px 1fr 80px;\n padding: 6px 4px;\n border-bottom: 1px solid #f3f4f6;\n transition: background-color 0.15s ease;\n min-height: 32px;\n}\n\n.onbbo-level2-widget .level-row:hover {\n filter: brightness(0.95);\n}\n\n.onbbo-level2-widget .level-row > div {\n padding: 0 6px;\n text-align: center;\n font-size: 12px;\n font-weight: 400;\n display: flex;\n align-items: center;\n justify-content: center;\n color: #111827;\n}\n\n/* ========================================\n COLOR SCHEME FOR BIDS (GREEN/YELLOW)\n Based on the image provided\n ======================================== */\n\n/* Best bid - brightest yellow */\n.onbbo-level2-widget .bid-row.intensity-100 {\n background: #fef08a; /* Yellow-200 */\n color: #713f12;\n}\n\n.onbbo-level2-widget .bid-row.intensity-100 > div {\n color: #713f12;\n}\n\n/* Very competitive bids */\n.onbbo-level2-widget .bid-row.intensity-90,\n.onbbo-level2-widget .bid-row.intensity-80 {\n background: #fef9c3; /* Yellow-100 */\n color: #854d0e;\n}\n\n.onbbo-level2-widget .bid-row.intensity-90 > div,\n.onbbo-level2-widget .bid-row.intensity-80 > div {\n color: #854d0e;\n}\n\n/* Competitive bids */\n.onbbo-level2-widget .bid-row.intensity-70,\n.onbbo-level2-widget .bid-row.intensity-60 {\n background: #d9f99d; /* Lime-200 */\n color: #3f6212;\n}\n\n.onbbo-level2-widget .bid-row.intensity-70 > div,\n.onbbo-level2-widget .bid-row.intensity-60 > div {\n color: #3f6212;\n}\n\n/* Standard bids - light green */\n.onbbo-level2-widget .bid-row.intensity-50,\n.onbbo-level2-widget .bid-row.intensity-40 {\n background: #bbf7d0; /* Green-200 */\n color: #14532d;\n}\n\n.onbbo-level2-widget .bid-row.intensity-50 > div,\n.onbbo-level2-widget .bid-row.intensity-40 > div {\n color: #14532d;\n}\n\n/* Lower bids - darker green */\n.onbbo-level2-widget .bid-row.intensity-30,\n.onbbo-level2-widget .bid-row.intensity-20,\n.onbbo-level2-widget .bid-row.intensity-10 {\n background: #86efac; /* Green-300 */\n color: #14532d;\n}\n\n.onbbo-level2-widget .bid-row.intensity-30 > div,\n.onbbo-level2-widget .bid-row.intensity-20 > div,\n.onbbo-level2-widget .bid-row.intensity-10 > div {\n color: #14532d;\n}\n\n/* ========================================\n COLOR SCHEME FOR ASKS (RED/YELLOW)\n Based on the image provided\n ======================================== */\n\n/* Best ask - brightest yellow */\n.onbbo-level2-widget .ask-row.intensity-100 {\n background: #fef08a; /* Yellow-200 */\n color: #713f12;\n}\n\n.onbbo-level2-widget .ask-row.intensity-100 > div {\n color: #713f12;\n}\n\n/* Very competitive asks */\n.onbbo-level2-widget .ask-row.intensity-90,\n.onbbo-level2-widget .ask-row.intensity-80 {\n background: #fef9c3; /* Yellow-100 */\n color: #854d0e;\n}\n\n.onbbo-level2-widget .ask-row.intensity-90 > div,\n.onbbo-level2-widget .ask-row.intensity-80 > div {\n color: #854d0e;\n}\n\n/* Competitive asks */\n.onbbo-level2-widget .ask-row.intensity-70,\n.onbbo-level2-widget .ask-row.intensity-60 {\n background: #fecaca; /* Red-200 */\n color: #7f1d1d;\n}\n\n.onbbo-level2-widget .ask-row.intensity-70 > div,\n.onbbo-level2-widget .ask-row.intensity-60 > div {\n color: #7f1d1d;\n}\n\n/* Standard asks - light red */\n.onbbo-level2-widget .ask-row.intensity-50,\n.onbbo-level2-widget .ask-row.intensity-40 {\n background: #fca5a5; /* Red-300 */\n color: #7f1d1d;\n}\n\n.onbbo-level2-widget .ask-row.intensity-50 > div,\n.onbbo-level2-widget .ask-row.intensity-40 > div {\n color: #7f1d1d;\n}\n\n/* Higher asks - darker red */\n.onbbo-level2-widget .ask-row.intensity-30,\n.onbbo-level2-widget .ask-row.intensity-20,\n.onbbo-level2-widget .ask-row.intensity-10 {\n background: #f87171; /* Red-400 */\n color: #450a0a;\n}\n\n.onbbo-level2-widget .ask-row.intensity-30 > div,\n.onbbo-level2-widget .ask-row.intensity-20 > div,\n.onbbo-level2-widget .ask-row.intensity-10 > div {\n color: #450a0a;\n}\n\n/* ========================================\n PANEL FOOTERS\n ======================================== */\n\n.onbbo-level2-widget .panel-footer {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 10px 12px;\n background: #f9fafb;\n border-top: 2px solid #d1d5db;\n font-size: 11px;\n font-weight: 600;\n}\n\n.onbbo-level2-widget .bid-panel .panel-footer {\n color: #065f46;\n}\n\n.onbbo-level2-widget .ask-panel .panel-footer {\n color: #991b1b;\n}\n\n.onbbo-level2-widget .footer-label {\n font-weight: 500;\n color: #6b7280;\n}\n\n.onbbo-level2-widget .footer-value {\n font-family: 'Courier New', Courier, monospace;\n font-weight: 700;\n}\n\n/* ========================================\n WIDGET FOOTER\n ======================================== */\n\n.onbbo-level2-widget .widget-footer {\n background: #f9fafb;\n padding: 8px 16px;\n border-top: 1px solid #e5e7eb;\n text-align: center;\n font-size: 11px;\n color: #6b7280;\n}\n\n/* ========================================\n NO DATA / EMPTY STATE\n ======================================== */\n\n.onbbo-level2-widget .empty-book {\n padding: 40px 20px;\n text-align: center;\n color: #6b7280;\n font-style: italic;\n}\n\n/* ========================================\n INACTIVE QUOTES (zero prices)\n ======================================== */\n\n.onbbo-level2-widget .inactive-quote {\n background: #f9fafb !important;\n opacity: 0.7;\n}\n\n.onbbo-level2-widget .inactive-quote > div {\n color: #9ca3af !important;\n font-style: italic;\n}\n\n.onbbo-level2-widget .inactive-quote:hover {\n opacity: 0.85;\n}\n\n/* ========================================\n LOADING STATE\n ======================================== */\n\n.onbbo-level2-widget .widget-loading-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(255, 255, 255, 0.9);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 20;\n}\n\n.onbbo-level2-widget .widget-loading-overlay.hidden {\n display: none;\n}\n\n.onbbo-level2-widget .loading-content {\n text-align: center;\n}\n\n.onbbo-level2-widget .loading-spinner {\n width: 32px;\n height: 32px;\n border: 3px solid #e5e7eb;\n border-top: 3px solid #3b82f6;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin: 0 auto 12px;\n}\n\n@keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n}\n\n.onbbo-level2-widget .no-data-state {\n padding: 40px;\n text-align: center;\n color: #6b7280;\n}\n\n.onbbo-level2-widget .widget-error {\n padding: 20px;\n background: #fef2f2;\n color: #dc2626;\n border: 1px solid #fecaca;\n margin: 16px;\n border-radius: 4px;\n text-align: center;\n}\n\n/* ========================================\n RESPONSIVE DESIGN\n ======================================== */\n\n@media (max-width: 768px) {\n .onbbo-level2-widget .orderbook-container {\n grid-template-columns: 1fr;\n gap: 16px;\n }\n\n .onbbo-level2-widget .panel-body {\n max-height: 250px;\n }\n\n .onbbo-level2-widget .orderbook-panel {\n border-right: none;\n border-bottom: 1px solid #e5e7eb;\n }\n\n .onbbo-level2-widget .orderbook-panel:last-child {\n border-bottom: none;\n }\n\n .onbbo-level2-widget .level1-info {\n grid-template-columns: repeat(2, 1fr);\n gap: 6px;\n }\n}\n\n@media (max-width: 480px) {\n .onbbo-level2-widget {\n font-size: 12px;\n }\n\n .onbbo-level2-widget .widget-header {\n padding: 12px;\n flex-direction: column;\n align-items: flex-start;\n gap: 8px;\n }\n\n .onbbo-level2-widget .spread-section {\n text-align: left;\n }\n\n .onbbo-level2-widget .level1-info {\n grid-template-columns: repeat(2, 1fr);\n gap: 4px;\n }\n\n .onbbo-level2-widget .l1-label {\n font-size: 9px;\n }\n\n .onbbo-level2-widget .l1-value {\n font-size: 11px;\n }\n\n .onbbo-level2-widget .panel-header {\n font-size: 10px;\n padding: 6px 2px;\n }\n\n .onbbo-level2-widget .level-row {\n grid-template-columns: 60px 1fr 60px;\n padding: 4px 2px;\n font-size: 11px;\n }\n\n .onbbo-level2-widget .level-row > div {\n padding: 0 4px;\n }\n\n .onbbo-level2-widget .panel-footer {\n font-size: 10px;\n padding: 8px 10px;\n }\n\n .onbbo-level2-widget .panel-body {\n max-height: 200px;\n }\n}\n",document.head.appendChild(t)}}setupSymbolEditor(){this.symbolEditor=new s(this,{maxLength:10,placeholder:"Enter symbol...",onSymbolChange:this.handleSymbolChange.bind(this),debug:this.debug,autoUppercase:!0,cancelOnBlur:!1,symbolType:"quotel1"})}async handleSymbolChange(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.debug&&console.log("[ONBBOLevel2Widget] Symbol change requested:",t);const i=g(t);if(!i.valid)return this.debug&&console.log("[ONBBOLevel2Widget] Invalid symbol:",i.error),{success:!1,error:i.error};const s=i.sanitized;if(n&&(this.companyName=n.comp_name||"",this.exchangeName=n.market_name||""),s===this.symbol)return this.debug&&console.log("[ONBBOLevel2Widget] Same symbol, no change needed"),{success:!0};try{return this.showLoading(),this.loadingTimeout&&this.clearTimeout(this.loadingTimeout),this.loadingTimeout=this.setTimeout((()=>{this.debug&&console.log("[ONBBOLevel2Widget] Loading timeout for symbol:",s),this.hideLoading(),this.showError(`No data received for ${s}. Please try again.`)}),1e4),this.unsubscribeL2&&(this.debug&&console.log(`[ONBBOLevel2Widget] Unsubscribing from ${this.symbol} L2`),this.wsManager.sendUnsubscribe("queryonbbol2",this.symbol),this.unsubscribeL2(),this.unsubscribeL2=null),this.unsubscribeL1&&(this.debug&&console.log(`[ONBBOLevel2Widget] Unsubscribing from ${this.symbol} L1`),this.wsManager.sendUnsubscribe("queryonbbol1",this.symbol),this.unsubscribeL1(),this.unsubscribeL1=null),this.symbol=s,this.debug&&console.log(`[ONBBOLevel2Widget] Subscribing to ${s}`),this.subscribeToData(),{success:!0}}catch(t){return console.error("[ONBBOLevel2Widget] Error changing symbol:",t),this.showError(`Failed to load data for ${s}`),{success:!1,error:`Failed to load ${s}`}}}async initialize(){this.showLoading();!1!==await super.validateInitialSymbol("quotel1",this.symbol,(t=>{t&&t[0]&&(this.companyName=t[0].comp_name||"",this.exchangeName=t[0].market_name||"")}))&&(this.loadingTimeout=setTimeout((()=>{this.debug&&console.log("[ONBBOLevel2Widget] Loading timeout - no data received for:",this.symbol),this.hideLoading(),this.showError("No Level 2 data available for this symbol")}),1e4),this.subscribeToData())}subscribeToData(){this.unsubscribeL2=this.wsManager.subscribe(`${this.widgetId}-l2`,["queryonbbol2"],(t=>{const{event:e,data:n}=t;"connection"!==e?"data"===e&&(n._dataType="level2",this.handleMessage({event:e,data:n})):this.handleConnectionStatus(n)}),this.symbol),this.unsubscribeL1=this.wsManager.subscribe(`${this.widgetId}-l1`,["queryonbbol1"],(t=>{const{event:e,data:n}=t;"connection"!==e&&"data"===e&&(n._dataType="level1",this.handleMessage({event:e,data:n}))}),this.symbol)}handleData(t){this.loadingTimeout&&(clearTimeout(this.loadingTimeout),this.loadingTimeout=null);const e=t._dataType;if(this.debug&&console.log(`[ONBBOLevel2Widget] handleData called with type: ${e}`,t),"error"===t.type||1==t.error){const e=t.message||"Server error";return this.debug&&console.log("[ONBBOLevel2Widget] Error:",e),void this.showError(e)}if("queryonbbol1"!==t.type){if(Array.isArray(t.data)){if(t.data.length>0&&t.data[0].MMID){this.debug&&console.log("[ONBBOLevel2Widget] Received MMID array:",t);const e=new Iu(t.data);return e.symbol=this.symbol,this.data=e,void this.updateWidget(e)}const e=t.data.find((t=>t.Symbol===this.symbol));if(e){if(!0===e.NotFound)this.showError(`No Level 2 data available for ${this.symbol}`);else{const t=new Iu(e);this.data=t,this.updateWidget(t)}return}this.showError(`No Level 2 data available for ${this.symbol}`)}}else{if(this.debug&&console.log("[ONBBOLevel2Widget] Processing Level 1 data:",t),t.data&&Array.isArray(t.data)){const e=t.data.find((t=>t.Symbol===this.symbol));e&&(this.level1Data={lastPx:e.LastPx||0,lowPx:e.LowPx||0,highPx:e.HighPx||0,volume:e.Volume||0},this.updateLevel1Display())}else if(Array.isArray(t)){const e=t.find((t=>t.Symbol===this.symbol));e&&(this.level1Data={lastPx:e.LastPx||0,lowPx:e.LowPx||0,highPx:e.HighPx||0,volume:e.Volume||0},this.updateLevel1Display())}delete t._dataType}}updateWidget(t){if(!this.isDestroyed)try{this.hideLoading(),this.clearError();const e=this.container.querySelector(".l2-company-name");e&&this.companyName&&(e.textContent=this.companyName);const n=this.container.querySelector(".l2-market-name");n&&this.exchangeName&&(n.textContent=this.exchangeName);const i=this.container.querySelector(".symbol");i&&(i.textContent=t.symbol),this.updateBidPanel(t),this.updateAskPanel(t);const s=f(new Date(t.timestamp||Date.now())),o=this.container.querySelector(".last-update");o&&(o.textContent=`Last update: ${s}`)}catch(t){console.error("[ONBBOLevel2Widget] Error updating widget:",t),this.showError("Error updating data")}}updateBidPanel(t){const e=this.container.querySelector(".bid-body");if(!e)return;e.innerHTML="";const n=t.getTopBids(this.maxLevels);0!==n.length?n.forEach((n=>{const i=t.getBidColorIntensity(n.price),s=c("div","",`level-row bid-row ${`intensity-${Math.round(100*i)}`} ${0===n.price?"inactive-quote":""}`),o=c("div",h(n.mmid)),a=c("div",t.formatPrice(n.price)),r=c("div",t.formatSize(n.size));s.appendChild(o),s.appendChild(a),s.appendChild(r),e.appendChild(s)})):e.innerHTML='<div class="empty-book">No bid data available</div>'}updateAskPanel(t){const e=this.container.querySelector(".ask-body");if(!e)return;e.innerHTML="";const n=t.getTopAsks(this.maxLevels);0!==n.length?n.forEach((n=>{const i=t.getAskColorIntensity(n.price),s=c("div","",`level-row ask-row ${`intensity-${Math.round(100*i)}`} ${0===n.price?"inactive-quote":""}`),o=c("div",h(n.mmid)),a=c("div",t.formatPrice(n.price)),r=c("div",t.formatSize(n.size));s.appendChild(o),s.appendChild(a),s.appendChild(r),e.appendChild(s)})):e.innerHTML='<div class="empty-book">No ask data available</div>'}updateLevel1Display(){if(!this.level1Data)return;const t=t=>t?t.toFixed(2):"--",e=this.container.querySelector(".l1-last-px");e&&(e.textContent=t(this.level1Data.lastPx));const n=this.container.querySelector(".l1-low-px");n&&(n.textContent=t(this.level1Data.lowPx));const i=this.container.querySelector(".l1-high-px");i&&(i.textContent=t(this.level1Data.highPx));const s=this.container.querySelector(".l1-volume");var o;s&&(s.textContent=(o=this.level1Data.volume)?o.toLocaleString():"--"),this.debug&&console.log("[ONBBOLevel2Widget] Updated Level 1 display:",this.level1Data)}showLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.remove("hidden")}hideLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.add("hidden")}showError(t){this.hideLoading(),this.clearError();const e=document.createElement("div");e.className="widget-error",e.textContent=`Error: ${t}`,e.style.cssText="\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n padding: 15px 20px;\n background: #fee;\n border: 1px solid #f5c6cb;\n border-radius: 6px;\n color: #721c24;\n text-align: center;\n font-size: 14px;\n z-index: 100;\n ",this.container.appendChild(e)}clearError(){const t=this.container.querySelector(".widget-error");t&&t.remove()}destroy(){this.isDestroyed=!0,this.loadingTimeout&&(this.clearTimeout(this.loadingTimeout),this.loadingTimeout=null),this.unsubscribeL2&&(this.unsubscribeL2(),this.unsubscribeL2=null),this.unsubscribeL1&&(this.unsubscribeL1(),this.unsubscribeL1=null),this.symbolEditor&&(this.symbolEditor.destroy(),this.symbolEditor=null),super.destroy()}}class Ou{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20;this.maxTrades=e,this.trades=[],Array.isArray(t)&&t.length>0?(this.symbol=t[0].Symbol||"",this.addTrades(t)):this.symbol=""}addTrades(t){if(!Array.isArray(t))return;const e=this.parseTrades(t);this.trades=[...e,...this.trades],this.trades.length>this.maxTrades&&(this.trades=this.trades.slice(0,this.maxTrades))}setTrades(t){Array.isArray(t)&&(this.trades=this.parseTrades(t).slice(0,this.maxTrades),t.length>0&&(this.symbol=t[0].Symbol||this.symbol))}parseTrades(t){return Array.isArray(t)?t.map((t=>{const e=t.ActivityTimestamp||t.time||"";return{time:e,price:parseFloat(t.TradePx||t.price||0),size:parseInt(t.TradeSz||t.size||0,10),source:t.TradeRegion||t.source||t.DataSource||"",timestamp:e?new Date(e).getTime():0}})).filter((t=>t.price>0)).sort(((t,e)=>e.timestamp-t.timestamp)):[]}getTrades(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return t?this.trades.slice(0,t):this.trades}formatPrice(t){return t.toFixed(2)}formatSize(t){return t.toLocaleString()}formatTime(t){if(!t)return"--";try{if(t.includes("T")){const e=t.split("T")[1];if(e){return e.split(/[+\-Z]/)[0]}}if(t.includes(" ")){const e=t.split(" ");if(e.length>=2)return e[1]}return/^\d{2}:\d{2}:\d{2}/.test(t),t}catch(e){return t}}getTotalVolume(){return this.trades.reduce(((t,e)=>t+e.size),0)}getLatestTrade(){return this.trades.length>0?this.trades[0]:null}clear(){this.trades=[]}static fromApiResponse(t){return new Ou(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:20)}}class Wu extends n{constructor(t,e,n){if(super(t,e,n),!e.symbol)throw new Error("Symbol is required for TimeSalesWidget");if(!e.wsManager)throw new Error("WebSocketManager is required for TimeSalesWidget");this.type="time-sales";const i=g(e.symbol);if(!i.valid)throw new Error(`Invalid symbol: ${i.error}`);this.symbol=i.sanitized,this.wsManager=e.wsManager,this.debug=e.debug||!1,this.styled=void 0===e.styled||e.styled,this.maxTrades=e.maxTrades||20,this.data=new Ou([],this.maxTrades),this.data.symbol=this.symbol,this.isDestroyed=!1,this.unsubscribe=null,this.symbolEditor=null,this.loadingTimeout=null,this.companyName="",this.exchangeName="",this.createWidgetStructure(),this.initializeSymbolEditor(),this.initialize()}createWidgetStructure(){if(this.container.innerHTML='\n<div class="time-sales-widget widget">\n <div class="widget-loading-overlay hidden">\n <div class="loading-content">\n <div class="loading-spinner"></div>\n <div class="loading-text">Loading Time & Sales...</div>\n </div>\n </div>\n\n <div class="widget-header">\n <div class="symbol-section">\n <div class="company-market-info">\n <span class="ts-company-name"></span>\n <span class="ts-market-name"></span>\n </div>\n <span class="symbol editable-symbol">--</span>\n </div>\n </div>\n\n <div class="trades-container">\n <div class="trades-panel">\n <div class="panel-header">\n <div class="col-header time-col">TIME</div>\n <div class="col-header price-col">PRICE</div>\n <div class="col-header size-col">SIZE</div>\n <div class="col-header source-col">SOURCE</div>\n </div>\n <div class="panel-body trades-body">\n \x3c!-- Trade rows will be dynamically inserted here --\x3e\n </div>\n </div>\n </div>\n\n <div class="widget-footer">\n <span class="last-update">Last update: --</span>\n <span class="data-source">Time & Sales</span>\n </div>\n</div>\n',this.styled){const t=this.container.querySelector(".time-sales-widget");t&&t.classList.add("widget-styled")}this.addStyles()}initializeSymbolEditor(){this.symbolEditor=new s(this,{maxLength:10,placeholder:"Enter symbol...",onSymbolChange:this.handleSymbolChange.bind(this),debug:this.debug,autoUppercase:!0,symbolType:"quotel1"});const t=this.container.querySelector(".symbol");t&&(t.textContent=this.symbol,t.dataset.originalSymbol=this.symbol)}addStyles(){if(!document.querySelector("#time-sales-styles")){const t=document.createElement("style");t.id="time-sales-styles",t.textContent="\n.time-sales-widget {\n border: 1px solid #e5e7eb;\n border-radius: 8px;\n background: white;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n font-size: 13px;\n max-width: 100%;\n overflow: hidden;\n position: relative;\n}\n\n.time-sales-widget .widget-header {\n background: #f9fafb;\n padding: 16px;\n border-bottom: 1px solid #e5e7eb;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n.time-sales-widget .symbol-section {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n.time-sales-widget .company-market-info {\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: 0.86em;\n color: #6b7280;\n}\n\n.time-sales-widget .ts-company-name {\n font-weight: 600;\n color: #374151;\n}\n\n.time-sales-widget .ts-market-name {\n font-weight: 500;\n color: #6b7280;\n}\n\n.time-sales-widget .ts-market-name::before {\n content: '|';\n margin-right: 8px;\n color: #d1d5db;\n}\n\n.time-sales-widget .symbol {\n font-size: 1.71em;\n font-weight: 700;\n color: #111827;\n}\n\n/* ========================================\n TRADES CONTAINER\n ======================================== */\n\n.time-sales-widget .trades-container {\n background: white;\n}\n\n.time-sales-widget .trades-panel {\n overflow: hidden;\n}\n\n/* ========================================\n PANEL HEADER\n ======================================== */\n\n.time-sales-widget .panel-header {\n display: grid;\n grid-template-columns: 120px 1fr 100px 100px;\n background: #f3f4f6;\n padding: 8px 4px;\n font-size: 11px;\n font-weight: 700;\n color: #374151;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n border-bottom: 2px solid #d1d5db;\n position: sticky;\n top: 0;\n z-index: 10;\n}\n\n.time-sales-widget .col-header {\n text-align: center;\n padding: 0 4px;\n}\n\n/* ========================================\n PANEL BODY - SCROLLABLE AREA\n ======================================== */\n\n.time-sales-widget .panel-body {\n min-height: 300px;\n max-height: 500px;\n overflow-y: auto;\n}\n\n/* Custom scrollbar */\n.time-sales-widget .panel-body::-webkit-scrollbar {\n width: 6px;\n}\n\n.time-sales-widget .panel-body::-webkit-scrollbar-track {\n background: #f3f4f6;\n}\n\n.time-sales-widget .panel-body::-webkit-scrollbar-thumb {\n background: #9ca3af;\n border-radius: 3px;\n}\n\n.time-sales-widget .panel-body::-webkit-scrollbar-thumb:hover {\n background: #6b7280;\n}\n\n/* ========================================\n TRADE ROWS\n ======================================== */\n\n.time-sales-widget .trade-row {\n display: grid;\n grid-template-columns: 120px 1fr 100px 100px;\n padding: 8px 4px;\n border-bottom: 1px solid #f3f4f6;\n transition: background-color 0.3s ease;\n min-height: 36px;\n background: white;\n}\n\n.time-sales-widget .trade-row:hover {\n background: #f9fafb;\n}\n\n.time-sales-widget .trade-cell {\n padding: 0 8px;\n text-align: center;\n font-size: 12px;\n font-weight: 400;\n display: flex;\n align-items: center;\n justify-content: center;\n color: #111827;\n}\n\n/* Newest trade highlight */\n.time-sales-widget .trade-row.newest-trade {\n background: #dbeafe;\n animation: fadeHighlight 2s ease-out;\n}\n\n@keyframes fadeHighlight {\n 0% {\n background: #bfdbfe;\n }\n 100% {\n background: #dbeafe;\n }\n}\n\n/* Column specific styling */\n.time-sales-widget .time-cell {\n color: #6b7280;\n font-size: 0.95em;\n}\n\n.time-sales-widget .price-cell {\n color: #111827;\n font-weight: 700;\n font-size: 1.05em;\n}\n\n.time-sales-widget .size-cell {\n color: #374151;\n}\n\n.time-sales-widget .source-cell {\n color: #6b7280;\n font-size: 0.95em;\n}\n\n/* ========================================\n WIDGET FOOTER\n ======================================== */\n\n.time-sales-widget .widget-footer {\n background: #f9fafb;\n padding: 8px 16px;\n border-top: 1px solid #e5e7eb;\n display: flex;\n justify-content: space-between;\n align-items: center;\n font-size: 11px;\n color: #6b7280;\n}\n\n.time-sales-widget .data-source {\n font-weight: 600;\n color: #374151;\n}\n\n/* ========================================\n NO DATA / EMPTY STATE\n ======================================== */\n\n.time-sales-widget .empty-trades {\n padding: 40px 20px;\n text-align: center;\n color: #6b7280;\n font-style: italic;\n}\n\n/* ========================================\n LOADING STATE\n ======================================== */\n\n.time-sales-widget .widget-loading-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(255, 255, 255, 0.9);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 20;\n}\n\n.time-sales-widget .widget-loading-overlay.hidden {\n display: none;\n}\n\n.time-sales-widget .loading-content {\n text-align: center;\n}\n\n.time-sales-widget .loading-spinner {\n width: 32px;\n height: 32px;\n border: 3px solid #e5e7eb;\n border-top: 3px solid #3b82f6;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin: 0 auto 12px;\n}\n\n@keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n}\n\n.time-sales-widget .no-data-state {\n padding: 40px;\n text-align: center;\n color: #6b7280;\n}\n\n.time-sales-widget .widget-error {\n padding: 20px;\n background: #fef2f2;\n color: #dc2626;\n border: 1px solid #fecaca;\n margin: 16px;\n border-radius: 4px;\n text-align: center;\n}\n\n/* ========================================\n RESPONSIVE DESIGN\n ======================================== */\n\n@media (max-width: 768px) {\n .time-sales-widget .panel-header {\n grid-template-columns: 100px 1fr 80px 80px;\n font-size: 10px;\n }\n\n .time-sales-widget .trade-row {\n grid-template-columns: 100px 1fr 80px 80px;\n }\n\n .time-sales-widget .panel-body {\n max-height: 400px;\n }\n}\n\n@media (max-width: 480px) {\n .time-sales-widget {\n font-size: 12px;\n }\n\n .time-sales-widget .widget-header {\n padding: 12px;\n }\n\n .time-sales-widget .panel-header {\n grid-template-columns: 80px 1fr 70px 70px;\n font-size: 9px;\n padding: 6px 2px;\n }\n\n .time-sales-widget .trade-row {\n grid-template-columns: 80px 1fr 70px 70px;\n padding: 6px 2px;\n font-size: 11px;\n }\n\n .time-sales-widget .trade-cell {\n padding: 0 4px;\n }\n\n .time-sales-widget .panel-body {\n max-height: 300px;\n }\n\n .time-sales-widget .widget-footer {\n font-size: 10px;\n padding: 6px 12px;\n }\n}\n",document.head.appendChild(t)}}setupSymbolEditor(){this.symbolEditor=new s(this,{maxLength:10,placeholder:"Enter symbol...",onSymbolChange:this.handleSymbolChange.bind(this),debug:this.debug,autoUppercase:!0,cancelOnBlur:!1,symbolType:"quotel1"})}async handleSymbolChange(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.debug&&(console.log("[TimeSalesWidget] Symbol change requested:",t),console.log("[TimeSalesWidget] Validation data:",n));const i=g(t);if(!i.valid)return this.debug&&console.log("[TimeSalesWidget] Invalid symbol:",i.error),{success:!1,error:i.error};const s=i.sanitized;if(n&&(this.companyName=n.comp_name||"",this.exchangeName=n.market_name||"",this.debug&&console.log("[TimeSalesWidget] Extracted company info:",{companyName:this.companyName,exchangeName:this.exchangeName},n)),s===this.symbol)return this.debug&&console.log("[TimeSalesWidget] Same symbol, no change needed"),{success:!0};try{const t=this.symbol;return this.showLoading(),this.loadingTimeout&&this.clearTimeout(this.loadingTimeout),this.loadingTimeout=this.setTimeout((()=>{this.debug&&console.log("[TimeSalesWidget] Loading timeout for symbol:",s),this.hideLoading(),this.showError(`No data received for ${s}. Please try again.`)}),1e4),this.unsubscribe&&(this.debug&&console.log(`[TimeSalesWidget] Unsubscribing from ${t}`),this.unsubscribe(),this.unsubscribe=null),this.symbol=s,this.data.clear(),this.data.symbol=s,this.debug&&console.log(`[TimeSalesWidget] Subscribing to ${s}`),this.subscribeToData(),this.debug&&console.log(`[TimeSalesWidget] Successfully changed symbol from ${t} to ${s}`),{success:!0}}catch(t){return console.error("[TimeSalesWidget] Error changing symbol:",t),this.showError(`Failed to load data for ${s}`),{success:!1,error:`Failed to load ${s}`}}}async initialize(){this.showLoading();!1!==await super.validateInitialSymbol("quotel1",this.symbol,(t=>{t&&t[0]&&(this.companyName=t[0].comp_name||"",this.exchangeName=t[0].market_name||"")}))&&(this.loadingTimeout=setTimeout((()=>{this.debug&&console.log("[TimeSalesWidget] Loading timeout - no data received for:",this.symbol),this.hideLoading(),this.showError("No Time & Sales data available for this symbol")}),1e4),this.subscribeToData())}subscribeToData(){this.unsubscribe=this.wsManager.subscribe(this.widgetId,["queryonbbotimesale"],this.handleMessage.bind(this),this.symbol)}handleData(t){if(this.loadingTimeout&&(clearTimeout(this.loadingTimeout),this.loadingTimeout=null),"queryonbbotimesale"==t.type){if("error"===t.type){const e=t.message||"Server error";return this.debug&&console.log("[TimeSalesWidget] Error:",e),void this.showError(e)}if(Array.isArray(t.data))return this.debug&&console.log("[TimeSalesWidget] Received trades array:",t),this.data.addTrades(t.data),void this.updateWidget();this.debug&&console.log("[TimeSalesWidget] Unexpected message format:",t)}}updateWidget(){if(!this.isDestroyed)try{this.hideLoading(),this.clearError();const t=this.container.querySelector(".ts-company-name");t&&this.companyName&&(t.textContent=this.companyName);const e=this.container.querySelector(".ts-market-name");e&&this.exchangeName&&(e.textContent=this.exchangeName);const n=this.container.querySelector(".symbol");n&&(n.textContent=this.data.symbol),this.updateTradesTable();const i=this.data.getLatestTrade();if(i){const t=f(new Date(i.time)),e=this.container.querySelector(".last-update");e&&(e.textContent=`Last update: ${t}`)}}catch(t){console.error("[TimeSalesWidget] Error updating widget:",t),this.showError("Error updating data")}}updateTradesTable(){const t=this.container.querySelector(".trades-body");if(!t)return;t.innerHTML="";const e=this.data.getTrades();0!==e.length?e.forEach(((e,n)=>{const i=c("div","","trade-row");0===n&&i.classList.add("newest-trade");const s=c("div",this.data.formatTime(e.time),"trade-cell time-cell"),o=c("div",this.data.formatPrice(e.price),"trade-cell price-cell"),a=c("div",this.data.formatSize(e.size),"trade-cell size-cell"),r=c("div",h(e.source),"trade-cell source-cell");i.appendChild(s),i.appendChild(o),i.appendChild(a),i.appendChild(r),t.appendChild(i)})):t.innerHTML='<div class="empty-trades">No trades available</div>'}showLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.remove("hidden")}hideLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.add("hidden")}showError(t){this.hideLoading(),this.clearError();const e=document.createElement("div");e.className="widget-error",e.textContent=`Error: ${t}`,e.style.cssText="\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n padding: 15px 20px;\n background: #fee;\n border: 1px solid #f5c6cb;\n border-radius: 6px;\n color: #721c24;\n text-align: center;\n font-size: 14px;\n z-index: 100;\n ",this.container.appendChild(e)}clearError(){const t=this.container.querySelector(".widget-error");t&&t.remove()}destroy(){this.isDestroyed=!0,this.loadingTimeout&&(this.clearTimeout(this.loadingTimeout),this.loadingTimeout=null),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null),this.symbolEditor&&(this.symbolEditor.destroy(),this.symbolEditor=null),super.destroy()}updateSymbol(t){this.handleSymbolChange(t)}}class Nu{constructor(t){this.stateManager=t,this.widgets=new Map}createWidget(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=this.generateWidgetId();let s;switch(t){case"quote-level1":s=new b(e,n,i);break;case"night-session":s=new x(e,n,i);break;case"options":s=new w(e,n,i);break;case"option-chain":s=new C(e,n,i);break;case"data":s=new T(e,n,i);break;case"combined-market":s=new D(e,n,i);break;case"intraday-chart":s=new Au(e,n,i);break;case"onbbo-level2":s=new zu(e,n,i);break;case"onbbo-time-sale":s=new Wu(e,n,i);break;default:throw new Error(`Unknown widget type: ${t}`)}return this.widgets.set(i,s),s}generateWidgetId(){return`widget_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}destroyWidget(t){const e=this.widgets.get(t);e&&(e.destroy(),this.widgets.delete(t))}getWidgetCount(){return this.widgets.size}destroy(){this.widgets.forEach((t=>t.destroy())),this.widgets.clear()}}class Ru{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"https://mdas-api-dev.viewtrade.dev";this.token=t,this.baseUrl=e}async request(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=`${this.baseUrl}${t}`,i={method:"GET",headers:{Authorization:`Bearer ${this.token}`,"Content-Type":"application/json",...e.headers},...e};try{const t=await fetch(n,i);if(!t.ok){let e="";try{e=await t.text(),console.error(`[ApiService] HTTP ${t.status} - Response body:`,e)}catch(t){console.error("[ApiService] Could not read error response body:",t)}throw new Error(`HTTP error! status: ${t.status}, body: ${e}`)}return await t.json()}catch(t){throw console.error(`[ApiService] Request failed for ${n}:`,t),t}}async getOptionChainDates(t){return this.request(`/api/quote/option-chain-dates?symbol=${t}&response_camel_case=false`)}async quoteOptionl1(t){return this.request(`/api/quote/option-level1?option_names=${t}&response_camel_case=false`)}async quotel1(t){return this.request(`/api/quote/level1?symbols=${t}&response_camel_case=false`)}async quoteBlueOcean(t){return this.request(`/api/quote/night-session/level1/blueocean?symbols=${t}&response_camel_case=false`)}async getIntradayChart(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return this.request(`/api/quote/night-session/intraday/${t}?symbol=${e}&range_back=${n}`)}async getMarketStatus(t){return this.request(`/api/quote/night-session/market-status/${t}`)}}class $u{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.config={debug:t.debug||!1,token:t.token,baseUrl:t.baseUrl||"ws://localhost:3000/wssub",apiBaseUrl:t.apiBaseUrl,maxConnections:t.maxConnections||1,reconnectOptions:{maxAttempts:t.reconnectOptions?.maxAttempts||10,initialDelay:t.reconnectOptions?.initialDelay||1e3,maxDelay:t.reconnectOptions?.maxDelay||3e4,backoff:t.reconnectOptions?.backoff||1.5,jitter:t.reconnectOptions?.jitter||.3},timeouts:{connection:t.timeouts?.connection||1e4,inactivity:t.timeouts?.inactivity||9e4},enableActivityMonitoring:!1},this.apiService=new Ru(this.config.token,this.config.apiBaseUrl),this.connection=null,this.connectionState="disconnected",this.reconnectAttempts=0,this.reconnectTimer=null,this.connectionStartTime=null,this.subscriptions=new Map,this.activeSubscriptions=new Set,this.messageQueue=[],this.symbolSubscriptions=new Map,this.typeSubscriptions=new Map,this.lastMessageCache=new Map,this.connectionPromise=null,this.reloginCallback=t.reloginCallback||null,this.isReloginInProgress=!1,this.lastMessageReceived=null,this.activityCheckInterval=null,this.isOnline="undefined"==typeof navigator||navigator.onLine,this.onlineHandler=null,this.offlineHandler=null,this.circuitBreaker={state:"closed",failureCount:0,failureThreshold:5,timeout:6e4,lastFailureTime:null,resetTimer:null},this.metrics={successfulConnections:0,failedConnections:0,totalReconnects:0,avgConnectionTime:0,lastSuccessfulConnection:null,messagesReceived:0,messagesSent:0},this.handleOpen=this.handleOpen.bind(this),this.handleMessage=this.handleMessage.bind(this),this.handleClose=this.handleClose.bind(this),this.handleError=this.handleError.bind(this),this.isManualDisconnect=!1,this._initNetworkMonitoring(),this.config.debug&&console.log("[WebSocketManager] Initialized with config:",this.config)}async connect(){return"connected"===this.connectionState||"connecting"===this.connectionState?Promise.resolve():new Promise(((t,e)=>{this.connectionPromise={resolve:t,reject:e},this._connect()}))}subscribe(t,e,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};Array.isArray(e)||(e=[e]);const o=this.subscriptions.get(t);if(o){if(this.config.debug&&console.log(`[WebSocketManager] Cleaning up existing subscription for widget ${t} before re-subscribing`),o.symbol){const e=this.symbolSubscriptions.get(o.symbol);e&&(e.delete(t),0===e.size&&this.symbolSubscriptions.delete(o.symbol))}o.types&&o.types.forEach((e=>{const n=this.typeSubscriptions.get(e);n&&(n.delete(t),0===n.size&&this.typeSubscriptions.delete(e))}))}const a={types:new Set(e),callback:n,symbol:i?.toUpperCase(),additionalParams:s};if(this.subscriptions.set(t,a),i){const e=i.toUpperCase();this.symbolSubscriptions.has(e)||this.symbolSubscriptions.set(e,new Set),this.symbolSubscriptions.get(e).add(t)}return e.forEach((e=>{this.typeSubscriptions.has(e)||this.typeSubscriptions.set(e,new Set),this.typeSubscriptions.get(e).add(t)})),this.config.debug&&console.log(`[WebSocketManager] Widget ${t} subscribed to:`,e,`for symbol: ${i}`,s),"connected"===this.connectionState&&(this._sendSubscriptions(e),e.forEach((e=>{const s=i?`${e}:${i}`:e,o=this.lastMessageCache.get(s);if(o&&this.activeSubscriptions.has(s)){this.config.debug&&console.log(`[WebSocketManager] Sending cached data to new widget ${t} for ${s}`);try{n({event:"data",data:o,widgetId:t})}catch(e){console.error(`[WebSocketManager] Error sending cached data to widget ${t}:`,e)}}}))),()=>this.unsubscribe(t)}unsubscribe(t){const e=this.subscriptions.get(t);if(e){if(e.symbol&&e.types&&e.types.forEach((t=>{this.sendUnsubscribe(t,e.symbol,e.additionalParams||{})})),e.symbol){const n=this.symbolSubscriptions.get(e.symbol);n&&(n.delete(t),0===n.size&&this.symbolSubscriptions.delete(e.symbol))}e.types.forEach((e=>{const n=this.typeSubscriptions.get(e);n&&(n.delete(t),0===n.size&&this.typeSubscriptions.delete(e))})),this.subscriptions.delete(t),this.config.debug&&console.log(`[WebSocketManager] Widget ${t} unsubscribed`),this._cleanupUnusedSubscriptions()}}sendUnsubscribe(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};try{let i,s;"queryoptionchain"===t?(s=`${t}:${e}:${n.date||""}`,i={type:t,underlying:e,date:n.date,unsubscribe:!0}):"queryoptionl1"===t?(s=`${t}:${e}`,i={type:t,optionName:e,unsubscribe:!0}):(s=`${t}:${e}`,i={type:t,symbol:e,unsubscribe:!0}),this.config.debug&&console.log(`[WebSocketManager] Sending unsubscribe for ${s}:`,i),this.send(i),this.activeSubscriptions.delete(s),this.config.debug&&console.log(`[WebSocketManager] Removed ${s} from active subscriptions`)}catch(t){console.error("[WebSocketManager] Error sending unsubscribe:",t)}}sendUnsubscribeAll(){try{const t={unsubscribe_all:!0};this.config.debug&&console.log("[WebSocketManager] Sending unsubscribe all"),this.send(t),this.activeSubscriptions.clear()}catch(t){console.error("[WebSocketManager] Error sending unsubscribe all:",t)}}send(t){if("connected"!==this.connectionState||!this.connection||1!==this.connection.readyState)return this.messageQueue&&Array.isArray(this.messageQueue)||(this.messageQueue=[]),this.messageQueue.push(t),this.config.debug&&console.log("[WebSocketManager] Message queued (not connected):",t),!1;try{return this.connection.send(JSON.stringify(t)),this.config.debug&&console.log("[WebSocketManager] Sent message:",t),this.metrics.messagesSent++,!0}catch(t){return console.error("[WebSocketManager] Error sending message:",t),!1}}getConnectionState(){return this.connectionState}getSubscriptionCount(){return this.subscriptions.size}_connect(){if("connecting"!==this.connectionState){this.isManualDisconnect=!1,this.connectionState="connecting",this.connectionStartTime=Date.now();try{this.connection&&(this.connection.removeEventListener("open",this.handleOpen),this.connection.removeEventListener("message",this.handleMessage),this.connection.removeEventListener("close",this.handleClose),this.connection.removeEventListener("error",this.handleError),this.connection=null);const t=`${this.config.baseUrl}?token=${this.config.token}`;this.config.debug&&console.log("[WebSocketManager] Connecting to:",t),this.connection=new WebSocket(t);const e=setTimeout((()=>{this.connection&&0===this.connection.readyState&&(console.error("[WebSocketManager] Connection timeout"),this.connection.close(),this.connectionState="disconnected",this._updateCircuitBreaker(!1),this.connectionPromise&&(this.connectionPromise.reject(new Error("Connection timeout")),this.connectionPromise=null),this._scheduleReconnect())}),this.config.timeouts.connection);this.connection.addEventListener("open",(t=>{clearTimeout(e),this.handleOpen(t)})),this.connection.addEventListener("message",this.handleMessage),this.connection.addEventListener("close",(t=>{clearTimeout(e),this.handleClose(t)})),this.connection.addEventListener("error",(t=>{clearTimeout(e),this.handleError(t)}))}catch(t){console.error("[WebSocketManager] Connection error:",t),this.connectionState="disconnected",this.connectionPromise&&(this.connectionPromise.reject(t),this.connectionPromise=null),this._scheduleReconnect()}}}handleOpen(t){const e=Date.now()-this.connectionStartTime;this.connectionState="connected",this.reconnectAttempts=0,this.lastMessageReceived=Date.now(),this.metrics.successfulConnections++,this.metrics.lastSuccessfulConnection=Date.now();const n=this.metrics.avgConnectionTime,i=this.metrics.successfulConnections;this.metrics.avgConnectionTime=(n*(i-1)+e)/i,this._updateCircuitBreaker(!0),this.config.debug&&console.log("[WebSocketManager] Connected successfully",{connectionTime:`${e}ms`,avgConnectionTime:`${Math.round(this.metrics.avgConnectionTime)}ms`,attempt:this.metrics.totalReconnects+1}),this.connectionPromise&&(this.connectionPromise.resolve(),this.connectionPromise=null);try{this._startActivityMonitoring(),this._sendAllSubscriptions(),this._processMessageQueue(),this._notifyWidgets("connection",{status:"connected"})}catch(t){console.error("[WebSocketManager] Error in handleOpen:",t)}}handleMessage(t){try{let e;this.lastMessageReceived=Date.now(),this.metrics.messagesReceived++;try{e=JSON.parse(t.data)}catch(n){const i=t.data.toString();if(this.config.debug&&console.log("[WebSocketManager] Received plain text message:",i),i.toLowerCase().includes("session revoked")||i.toLowerCase().includes("please relogin")||i.toLowerCase().includes("session expired")||i.toLowerCase().includes("unauthorized")||i.toLowerCase().includes("authentication failed"))return this.config.debug&&console.log("[WebSocketManager] Session revoked detected, attempting relogin..."),void this._handleSessionRevoked(i);const s=this._getTargetTypeFromErrorMessage(i)||"error";e=i.toLowerCase().includes("no night session")||i.toLowerCase().includes("no data")?{type:s,message:i,error:!0,noData:!0}:{type:s,message:i,error:!0}}this.config.debug&&console.log("[WebSocketManager] Processed message:",e);let n=e;this._routeMessage(n)}catch(t){console.error("[WebSocketManager] Error handling message:",t),this._notifyWidgets("error",{error:"Failed to process message",details:t.message})}}handleClose(t){const e="connected"===this.connectionState;this.connectionState="disconnected",this.activeSubscriptions.clear(),this._stopActivityMonitoring(),this.config.debug&&console.log(`[WebSocketManager] Connection closed: ${t.code} ${t.reason}`),e&&this._notifyWidgets("connection",{status:"disconnected",code:t.code,reason:t.reason}),!this.isManualDisconnect&&this.subscriptions.size>0?(this.metrics.totalReconnects++,this._scheduleReconnect()):this.isManualDisconnect&&(this.config.debug&&console.log("[WebSocketManager] Manual disconnect - skipping reconnection"),this.isManualDisconnect=!1)}handleError(t){const e=this.connection?this.connection.readyState:"no connection";console.error("[WebSocketManager] WebSocket error:",{readyState:e,stateName:{0:"CONNECTING",1:"OPEN",2:"CLOSING",3:"CLOSED"}[e]||"UNKNOWN",url:this.connection?.url,error:t}),this.connection&&(3===this.connection.readyState?(console.log("[WebSocketManager] Connection closed due to error"),this.connectionState="disconnected",!this.isManualDisconnect&&this.subscriptions.size>0?(console.log("[WebSocketManager] Attempting reconnection after error..."),this._scheduleReconnect()):this.isManualDisconnect&&console.log("[WebSocketManager] Manual disconnect - skipping reconnection after error")):2===this.connection.readyState&&console.log("[WebSocketManager] Connection closing...")),this._notifyWidgets("connection",{status:"error",error:"WebSocket connection error",readyState:e,details:"Connection failed or was closed unexpectedly"}),this.connectionPromise&&(this.connectionPromise.reject(new Error("WebSocket connection failed")),this.connectionPromise=null)}_sendAllSubscriptions(){try{const t=new Set;this.subscriptions.forEach((e=>{e&&e.types&&e.types.forEach((e=>t.add(e)))})),this._sendSubscriptions([...t])}catch(t){console.error("[WebSocketManager] Error sending subscriptions:",t)}}_sendSubscriptions(t){t.forEach((t=>{if("queryoptionchain"===t)this._sendOptionChainSubscriptions();else{this._getSymbolsForType(t).forEach((e=>{const n=`${t}:${e}`;if(this.activeSubscriptions.has(n)){this.config.debug&&console.log(`[WebSocketManager] Subscription ${n} already active, skipping server subscription`);const i=this.lastMessageCache.get(n);console.log("LAST",this.lastMessageCache),i&&(this.config.debug&&console.log(`[WebSocketManager] Sending cached data to newly subscribing widgets for ${n}`),this.subscriptions.forEach(((n,s)=>{if(n.types.has(t)&&n.symbol===e)try{n.callback({event:"data",data:i,widgetId:s})}catch(t){console.error(`[WebSocketManager] Error sending cached data to widget ${s}:`,t)}})))}else{let i;i="queryoptionl1"===t?{type:t,optionName:e}:{type:t,symbol:e},this.config.debug&&console.log(`[WebSocketManager] Sending subscription for ${n}`),this.send(i)&&this.activeSubscriptions.add(n)}}))}}))}_sendOptionChainSubscriptions(){this.subscriptions.forEach(((t,e)=>{if(t.types.has("queryoptionchain")&&t.symbol&&t.additionalParams?.date){const e=`queryoptionchain:${t.symbol}:${t.additionalParams.date}`;if(this.activeSubscriptions.has(e))this.config.debug&&console.log(`[WebSocketManager] Option chain subscription ${e} already active, skipping`);else{const n={type:"queryoptionchain",underlying:t.symbol,date:t.additionalParams.date};this.config.debug&&console.log(`[WebSocketManager] Sending option chain subscription for ${e}`),this.send(n)&&this.activeSubscriptions.add(e)}}}))}_getSymbolsForType(t){const e=new Set;return this.subscriptions.forEach(((n,i)=>{n.types.has(t)&&n.symbol&&e.add(n.symbol)})),[...e]}_normalizeMessage(t){const e=t.error,n=t.type,i=t.message||t.Message;if(!0===e||"true"===e)return this.config.debug&&console.log(`[WebSocketManager] Detected error message with type: ${n}`),{...t,...t.type||t.Type||!n?{}:{type:n}};if(i&&"string"==typeof i){const e=i.toLowerCase();if(["no data","no access","not found","invalid","unauthorized","forbidden","error","failed","unavailable"].some((t=>e.includes(t)))&&n)return this.config.debug&&console.log(`[WebSocketManager] Detected implicit error in Message field: "${i}" with type: ${n}`),{...t,...t.type||t.Type||!n?{}:{type:n},error:!0}}return t}_routeMessage(t){this._cacheMessage(t);const e=this._getRelevantWidgets(t);if(this.config.debug&&e.size>0&&console.log(`[WebSocketManager] Routing message to ${e.size} relevant widgets`),0===e.size&&this.subscriptions.size>0)return this.config.debug&&console.log("[WebSocketManager] No specific routing found, broadcasting to all widgets"),void this.subscriptions.forEach(((e,n)=>{try{e.callback({event:"data",data:t,widgetId:n})}catch(t){console.error(`[WebSocketManager] Error in widget ${n} callback:`,t)}}));e.forEach((e=>{const n=this.subscriptions.get(e);if(n)try{n.callback({event:"data",data:t,widgetId:e})}catch(t){console.error(`[WebSocketManager] Error in widget ${e} callback:`,t)}}))}_cacheMessage(t){try{let e;e=t.data?t.data:t.Data?t.Data:t;const n=this._extractSymbol(e),i=t.type;if(this.config.debug&&console.log(`[WebSocketManager] _cacheMessage - extracted symbol: "${n}", messageType: "${i}"`),i&&n){const e=`${i}:${n}`;this.lastMessageCache.set(e,t),this.config.debug&&console.log(`[WebSocketManager] Cached message for ${e}`)}else i&&(this.config.debug&&console.log(`[WebSocketManager] No symbol found in message, attempting to infer from subscriptions for type: ${i}`),this.activeSubscriptions.forEach((e=>{const[n,s]=e.split(":");if(n===i&&s){const n=e;this.lastMessageCache.set(n,t),this.config.debug&&console.log(`[WebSocketManager] Cached message for ${n} (inferred from active subscription)`)}})))}catch(t){console.error("[WebSocketManager] Error caching message:",t)}}_getRelevantWidgets(t){const e=new Set;let n=t.Data||t.data;const i=t.type||this._extractMessageType(n);return this._addRelevantWidgetsForItem(t,e,i),e}_addRelevantWidgetsForItem(t,e,n){t.Data&&Array.isArray(t.Data)?t.Data.forEach((t=>{this._processDataItem(t,e,n)})):t.data&&t.data[0]&&void 0!==t.data[0].Strike&&t.data[0].Expire&&!t.data[0].underlyingSymbol?this._processOptionChainData(t.data,e):this._processDataItem(t,e,n)}_processOptionChainData(t,e){if(!t||0===t.length)return;const n=t[0],i=this._extractUnderlyingFromOption(n.Symbol),s=n.Expire;if(this.config.debug&&console.log("[WebSocketManager] Processing option chain data:",{underlyingSymbol:i,expireDate:s,contractCount:t.length}),i){const t=this.symbolSubscriptions.get(i);t&&t.forEach((t=>{const n=this.subscriptions.get(t);if(n&&n.types.has("queryoptionchain")){let o=!0;if(n.additionalParams?.date&&s){o=this._normalizeDate(n.additionalParams.date)===this._normalizeDate(s)}o&&(e.add(t),this.config.debug&&console.log(`[WebSocketManager] Routing option chain data for ${i} (${s}) to widget ${t}`))}}))}}_processDataItem(t,e,n){const i=this._extractSymbol(t);if(this.config.debug&&console.log("[WebSocketManager] Processing data item:",{symbol:i,messageType:n,dataItem:t}),i){const t=this.symbolSubscriptions.get(i);t&&t.forEach((t=>{const s=this.subscriptions.get(t);if(s){this._isDataTypeCompatible(n,s.types)&&(e.add(t),this.config.debug&&console.log(`[WebSocketManager] Routing ${n} data for ${i} to widget ${t}`))}}))}if(n){const t=this.typeSubscriptions.get(n);t&&t.forEach((t=>{const s=this.subscriptions.get(t);!s||s.symbol&&i&&s.symbol!==i||(e.add(t),this.config.debug&&console.log(`[WebSocketManager] Routing ${n} data to type-subscribed widget ${t}`))}))}}_isDataTypeCompatible(t,e){if(e.has(t))return!0;const n={queryoptionchain:["queryoptionchain","optionchain","option-chain"],queryl1:["queryl1","stock","equity"],queryoptionl1:["queryoptionl1","option","options"],queryblueoceanl1:["queryblueoceanl1","blueoceanl1","blueocean"],querybrucel1:["querybrucel1","brucel1","bruce"],queryonbbol1:["queryonbbol1","onbbol1","onbbo"],queryonbbol2:["queryonbbol2","onbbol2","onbbo-level2"],queryonbbotimesale:["queryonbbotimesale","querytns","timesale","time-sales"]};for(const i of e){if((n[i]||[i]).includes(t))return!0}return!1}_normalizeDate(t){if(!t)return null;if(t.includes("/")){const[e,n,i]=t.split("/");return`${i}-${e.padStart(2,"0")}-${n.padStart(2,"0")}`}return t}_extractSymbol(t){return Array.isArray(t)&&t.length>0&&t[0]?this._extractSymbolFromItem(t[0]):(t._messageType,this._extractSymbolFromItem(t))}_extractSymbolFromItem(t){if(Array.isArray(t)&&t[0]&&t[0].Source&&null!==t[0].Symbol){const e=t[0].Source.toLowerCase();(e.includes("blueocean")||e.includes("bruce")||e.includes("onbbo"))&&(t=t[0])}return t.Symbol&&!t.Underlying&&t.Strike?this._extractUnderlyingFromOption(t.Symbol):t.Symbol||t.symbol||t.RootSymbol||t.rootSymbol||t.Underlying||t.underlying}_isOptionSymbol(t){return/^[A-Z]+\d{6}[CP]\d+$/.test(t)}_extractUnderlyingFromOption(t){const e=t.match(/^([A-Z]+)\d{6}[CP]\d+$/),n=e?e[1]:t;return{SPXW:"SPX$",SPX:"SPX$",NDXP:"NDX$",RUT:"RUT$",VIX:"VIX$",DJX:"DJX$"}[n]||n}_extractMessageType(t){if(Array.isArray(t)&&t.length>0&&void 0!==t[0].MMID)return"queryonbbol2";if(Array.isArray(t)&&t.length>0&&void 0!==t[0].Strike)return"queryoptionchain";if(t[0]&&t[0].Source){const e=t[0].Source.toLowerCase();if(e.includes("onbbo"))return"queryonbbol1";if(e.includes("blueocean")||e.includes("blueocean-d")||e.includes("bruce"))return e.includes("bruce")?"querybrucel1":"queryblueoceanl1"}return void 0!==t.Strike||void 0!==t.Expire||t.Symbol&&this._isOptionSymbol(t.Symbol)?"queryoptionl1":void 0!==t.BidPx||void 0!==t.AskPx?"queryl1":null}_notifyWidgets(t,e){try{this.subscriptions.forEach(((n,i)=>{try{n&&n.callback&&n.callback({event:t,data:e,widgetId:i})}catch(t){console.error(`[WebSocketManager] Error notifying widget ${i}:`,t)}}))}catch(t){console.error("[WebSocketManager] Error in _notifyWidgets:",t)}}_processMessageQueue(){if(!this.messageQueue||!Array.isArray(this.messageQueue))return this.config.debug&&console.warn("[WebSocketManager] messageQueue not properly initialized, creating new array"),void(this.messageQueue=[]);for(this.config.debug&&this.messageQueue.length>0&&console.log(`[WebSocketManager] Processing ${this.messageQueue.length} queued messages`);this.messageQueue.length>0;){const t=this.messageQueue.shift();t&&this.send(t)}}_cleanupUnusedSubscriptions(){const t=new Set;this.subscriptions.forEach((e=>{e.types.forEach((e=>t.add(e)))})),this.activeSubscriptions.forEach((e=>{const[n]=e.split(":");t.has(n)||this.activeSubscriptions.delete(e)}))}_scheduleReconnect(){if(!this.isOnline)return this.config.debug&&console.log("[WebSocketManager] Network offline, waiting for network to return..."),void this._notifyWidgets("connection",{status:"offline",reason:"Network offline - will reconnect when network returns"});if("open"===this.circuitBreaker.state){const t=Date.now()-this.circuitBreaker.lastFailureTime,e=this.circuitBreaker.timeout-t;return console.warn(`[WebSocketManager] Circuit breaker OPEN, will retry in ${Math.round(e/1e3)}s`),void this._notifyWidgets("connection",{status:"circuit_open",reason:"Too many connection failures - circuit breaker active",retryIn:Math.round(e/1e3)})}if(this.reconnectAttempts>=this.config.reconnectOptions.maxAttempts)return console.error("[WebSocketManager] Max reconnection attempts reached"),this.metrics.failedConnections++,void this._notifyWidgets("connection",{status:"failed",error:"Max reconnection attempts reached",maxAttempts:this.config.reconnectOptions.maxAttempts,canRetry:!0});this.connectionState="reconnecting",this.reconnectAttempts++;const t=this.config.reconnectOptions.initialDelay*Math.pow(this.config.reconnectOptions.backoff,this.reconnectAttempts-1),e=Math.min(t,this.config.reconnectOptions.maxDelay),n=e*this.config.reconnectOptions.jitter,i=(2*Math.random()-1)*n,s=Math.max(0,e+i);console.log(`[WebSocketManager] Scheduling reconnect attempt ${this.reconnectAttempts}/${this.config.reconnectOptions.maxAttempts} in ${Math.round(s)}ms`),this._notifyWidgets("connection",{status:"reconnecting",attempt:this.reconnectAttempts,maxAttempts:this.config.reconnectOptions.maxAttempts,delay:Math.round(s),estimatedTime:new Date(Date.now()+s).toISOString()}),this.reconnectTimer=setTimeout((()=>{this._connect()}),s)}_resetState(){this.connectionState="disconnected",this.reconnectAttempts=0,this.connectionPromise=null,this.subscriptions&&this.subscriptions instanceof Map||(this.subscriptions=new Map),this.activeSubscriptions&&this.activeSubscriptions instanceof Set||(this.activeSubscriptions=new Set),this.messageQueue&&Array.isArray(this.messageQueue)||(this.messageQueue=[]),this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}_getTargetTypeFromErrorMessage(t){const e=t.toLowerCase();return e.includes("night session")||e.includes("blue ocean")||e.includes("bruce")||e.includes("blueocean")?e[0].toLowerCase().includes("bruce")?"querybrucel1":"queryblueoceanl1":e.includes("option chain")||e.includes("expiration date")?"queryoptionchain":e.includes("option")||e.includes("strike")||e.includes("expiration")?"queryoptionl1":e.includes("stock")||e.includes("equity")||e.includes("bid")||e.includes("ask")?"queryl1":null}async _handleSessionRevoked(t){if(this.isReloginInProgress)this.config.debug&&console.log("[WebSocketManager] Relogin already in progress, skipping...");else{this.isReloginInProgress=!0;try{if(this._notifyWidgets("session_revoked",{message:t,status:"attempting_relogin"}),this.config.debug&&console.log("[WebSocketManager] Session revoked, attempting relogin..."),this._closeConnection(),!this.reloginCallback||"function"!=typeof this.reloginCallback)throw new Error("No relogin callback provided");{const t=await this.reloginCallback();if(!(t&&"string"==typeof t&&t.length>0))throw new Error("Relogin failed: Invalid token received");this.updateToken(t),this.config.debug&&console.log("[WebSocketManager] Relogin successful, reconnecting..."),await this._reconnectAndResubscribe()}}catch(e){console.error("[WebSocketManager] Relogin failed:",e),this._notifyWidgets("session_revoked",{message:t,status:"relogin_failed",error:e.message}),this.connectionState="failed"}finally{this.isReloginInProgress=!1}}}async _reconnectAndResubscribe(){try{this.connectionState="disconnected",this.reconnectAttempts=0,this.activeSubscriptions.clear(),await this.connect(),this.config.debug&&console.log("[WebSocketManager] Reconnected successfully after relogin"),this._notifyWidgets("session_revoked",{status:"relogin_successful"})}catch(t){throw console.error("[WebSocketManager] Failed to reconnect after relogin:",t),t}}_closeConnection(){this.connection&&(this.connection.removeEventListener("open",this.handleOpen),this.connection.removeEventListener("message",this.handleMessage),this.connection.removeEventListener("close",this.handleClose),this.connection.removeEventListener("error",this.handleError),this.connection.readyState===WebSocket.OPEN&&this.connection.close(),this.connection=null),this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.connectionState="disconnected"}setReloginCallback(t){this.reloginCallback=t,this.config.debug&&console.log("[WebSocketManager] Relogin callback set")}updateToken(t){this.config.token=t,this.apiService=new Ru(this.config.token,this.config.apiBaseUrl),this.config.debug&&console.log("[WebSocketManager] Token updated")}getApiService(){return this.apiService}async manualReconnect(){this.config.debug&&console.log("[WebSocketManager] Manual reconnect initiated"),this.reconnectAttempts=0,this.connectionState="disconnected",this.isManualDisconnect=!1,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this._notifyWidgets("connection",{status:"reconnecting",attempt:1,maxAttempts:this.config.reconnectOptions.maxAttempts,manual:!0});try{return await this.connect(),!0}catch(t){return console.error("[WebSocketManager] Manual reconnect failed:",t),!1}}_initNetworkMonitoring(){"undefined"!=typeof window&&(this.onlineHandler=()=>{this.isOnline=!0,this.config.debug&&console.log("[WebSocketManager] Network online detected"),"disconnected"===this.connectionState&&this.subscriptions.size>0&&(console.log("[WebSocketManager] Network restored, attempting reconnection..."),this.reconnectAttempts=0,this._scheduleReconnect())},this.offlineHandler=()=>{this.isOnline=!1,this.config.debug&&console.log("[WebSocketManager] Network offline detected"),this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this._notifyWidgets("connection",{status:"offline",reason:"Network offline"})},window.addEventListener("online",this.onlineHandler),window.addEventListener("offline",this.offlineHandler))}_cleanupNetworkMonitoring(){"undefined"!=typeof window&&(this.onlineHandler&&(window.removeEventListener("online",this.onlineHandler),this.onlineHandler=null),this.offlineHandler&&(window.removeEventListener("offline",this.offlineHandler),this.offlineHandler=null))}_startActivityMonitoring(){this.config.enableActivityMonitoring?(this._stopActivityMonitoring(),this.activityCheckInterval=setInterval((()=>{if("connected"!==this.connectionState)return;const t=Date.now()-this.lastMessageReceived;t>this.config.timeouts.inactivity?(console.warn(`[WebSocketManager] No messages received in ${this.config.timeouts.inactivity}ms, connection may be dead`),this.connection&&this.connection.close()):this.config.debug&&t>3e4&&console.log(`[WebSocketManager] Last message: ${Math.round(t/1e3)}s ago`)}),15e3)):this.config.debug&&console.log("[WebSocketManager] Activity monitoring disabled")}_stopActivityMonitoring(){this.activityCheckInterval&&(clearInterval(this.activityCheckInterval),this.activityCheckInterval=null)}_updateCircuitBreaker(t){t?(this.circuitBreaker.failureCount=0,this.circuitBreaker.state="closed",this.circuitBreaker.resetTimer&&(clearTimeout(this.circuitBreaker.resetTimer),this.circuitBreaker.resetTimer=null),this.config.debug&&console.log("[WebSocketManager] Circuit breaker CLOSED - connection healthy")):(this.circuitBreaker.failureCount++,this.circuitBreaker.lastFailureTime=Date.now(),this.config.debug&&console.log(`[WebSocketManager] Circuit breaker failure ${this.circuitBreaker.failureCount}/${this.circuitBreaker.failureThreshold}`),this.circuitBreaker.failureCount>=this.circuitBreaker.failureThreshold&&(this.circuitBreaker.state="open",console.warn("[WebSocketManager] Circuit breaker OPEN - too many failures"),this.circuitBreaker.resetTimer=setTimeout((()=>{this.circuitBreaker.state="half-open",this.circuitBreaker.failureCount=0,console.log("[WebSocketManager] Circuit breaker HALF-OPEN - will attempt one reconnection"),this.subscriptions.size>0&&"connected"!==this.connectionState&&(this.reconnectAttempts=0,this._scheduleReconnect())}),this.circuitBreaker.timeout)))}getConnectionMetrics(){const t=this._calculateConnectionQuality();return{state:this.connectionState,quality:t,isOnline:this.isOnline,circuitBreakerState:this.circuitBreaker.state,reconnectAttempts:this.reconnectAttempts,maxReconnectAttempts:this.config.reconnectOptions.maxAttempts,successfulConnections:this.metrics.successfulConnections,failedConnections:this.metrics.failedConnections,totalReconnects:this.metrics.totalReconnects,avgConnectionTime:Math.round(this.metrics.avgConnectionTime),lastSuccessfulConnection:this.metrics.lastSuccessfulConnection?new Date(this.metrics.lastSuccessfulConnection).toISOString():null,messagesReceived:this.metrics.messagesReceived,messagesSent:this.metrics.messagesSent,activeSubscriptions:this.subscriptions.size,lastMessageReceived:this.lastMessageReceived?`${Math.round((Date.now()-this.lastMessageReceived)/1e3)}s ago`:"never"}}_calculateConnectionQuality(){if("connected"!==this.connectionState)return"poor";const t=this.lastMessageReceived?Date.now()-this.lastMessageReceived:1/0;return t<3e4&&this.metrics.avgConnectionTime<2e3?"excellent":t<6e4&&this.metrics.avgConnectionTime<5e3?"good":t<this.config.timeouts.inactivity?"fair":"poor"}enableMetricsLogging(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3e4;this.metricsInterval&&clearInterval(this.metricsInterval),this.metricsInterval=setInterval((()=>{console.log("[WebSocketManager] Metrics:",this.getConnectionMetrics())}),t),console.log("[WebSocketManager] Metrics logging enabled (every "+t/1e3+"s)")}disableMetricsLogging(){this.metricsInterval&&(clearInterval(this.metricsInterval),this.metricsInterval=null,console.log("[WebSocketManager] Metrics logging disabled"))}disconnect(){this.isManualDisconnect=!0,this._stopActivityMonitoring(),this._cleanupNetworkMonitoring(),this.circuitBreaker.resetTimer&&(clearTimeout(this.circuitBreaker.resetTimer),this.circuitBreaker.resetTimer=null),this.disableMetricsLogging(),this._closeConnection(),this._notifyWidgets("connection",{status:"disconnected",manual:!0}),this.config.debug&&console.log("[WebSocketManager] Disconnected and cleaned up")}}class Fu{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.config={apiBaseUrl:t.apiBaseUrl||"https://mdas-api-dev.viewtrade.dev",loginEndpoint:t.loginEndpoint||"/api/user/login",refreshEndpoint:t.refreshEndpoint||"/api/user/refresh",refreshBuffer:t.refreshBuffer||300,maxRetries:t.maxRetries||3,debug:t.debug||!1},this.credentials=null,this.currentToken=null,this.tokenExpiry=null,this.refreshTimer=null,this.isAuthenticating=!1,this.retryCount=0,this.authenticationPromise=null,this.listeners=new Map,this.config.debug&&console.log("[AuthManager] Initialized with config:",{...this.config,loginEndpoint:this.config.loginEndpoint})}setCredentials(t,e){this.credentials={user_name:t,password:e},this.config.debug&&console.log("[AuthManager] Credentials set for user:",t)}async authenticate(){if(this.isAuthenticating&&this.authenticationPromise)return this.config.debug&&console.log("[AuthManager] Authentication already in progress, waiting..."),await this.authenticationPromise;if(!this.credentials)throw new Error("No credentials provided. Call setCredentials() first.");this.isAuthenticating=!0,this.authenticationPromise=this._performAuthentication();try{return await this.authenticationPromise}finally{this.isAuthenticating=!1,this.authenticationPromise=null}}async getValidToken(){return this.currentToken?this._isTokenNearExpiry()?(this.config.debug&&console.log("[AuthManager] Token near expiry, refreshing..."),await this.refreshToken()):this.currentToken:await this.authenticate()}async refreshToken(){if(this.isAuthenticating)return this.currentToken;this.isAuthenticating=!0;try{const t=await this._performRefresh();return this._handleAuthSuccess(t),this.currentToken}catch(t){return this.config.debug&&console.log("[AuthManager] Token refresh failed, attempting re-login"),await this.authenticate()}finally{this.isAuthenticating=!1}}async handleAuthError(t){if(this.config.debug&&console.log("[AuthManager] Handling auth error:",t),this.retryCount>=this.config.maxRetries){const t=new Error(`Authentication failed after ${this.config.maxRetries} attempts`);throw this._notifyListeners("auth_failed",{error:t}),this.retryCount=0,t}this.retryCount++,this._clearToken();try{const t=await this.authenticate();return this.retryCount=0,this._notifyListeners("auth_recovered",{token:t}),t}catch(t){throw this._notifyListeners("auth_retry_failed",{error:t,attempt:this.retryCount}),t}}addEventListener(t,e){this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(e)}removeEventListener(t,e){this.listeners.has(t)&&this.listeners.get(t).delete(e)}destroy(){this._clearToken(),this.credentials=null,this.listeners.clear(),this.config.debug&&console.log("[AuthManager] Destroyed")}async _performLogin(){const t=`${this.config.apiBaseUrl}${this.config.loginEndpoint}`;this.config.debug&&console.log("[AuthManager] Attempting login to:",t);const e=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user_name:this.credentials.user_name,password:this.credentials.password})});if(!e.ok){const t=await e.json().catch((()=>({})));throw new Error(t.message||`Login failed: ${e.status} ${e.statusText}`)}const n=await e.json(),i=n.access_token,s=n.refresh_token,o=n.access_expiration,a=n.user_id;if(!i)throw console.error("[AuthManager] Login response missing token:",n),new Error("No token received from login response");let r=null;if(o)try{if(r=new Date(o),isNaN(r.getTime()))throw new Error("Invalid expiration date format")}catch(t){console.warn("[AuthManager] Could not parse expiration date:",n.expiration),r=new Date(Date.now()+36e5)}else r=new Date(Date.now()+18e6);return this.config.debug&&console.log("[AuthManager] Login successful:",{tokenLength:i.length,expiresAt:r.toISOString(),timeUntilExpiry:Math.round((r.getTime()-Date.now())/1e3/60)+" minutes"}),{token:i,refreshToken:s,expirationDate:r,user_id:a}}async _performRefresh(){return this.config.debug&&console.log("[AuthManager] No refresh endpoint available, performing full re-authentication"),await this._performLogin()}async _performAuthentication(){try{const t=await this._performLogin();return this._handleAuthSuccess(t),this.currentToken}catch(t){throw this._handleAuthError(t),t}}_handleAuthSuccess(t){this.currentToken=t.token,t.expirationDate&&(this.tokenExpiry=t.expirationDate),this.retryCount=0,this._scheduleTokenRefresh(),this.config.debug&&console.log("[AuthManager] Authentication successful, token expires:",this.tokenExpiry),this._notifyListeners("auth_success",{token:this.currentToken,expiresAt:this.tokenExpiry})}_handleAuthError(t){this.config.debug&&console.error("[AuthManager] Authentication failed:",t.message),this._notifyListeners("auth_error",{error:t})}_isTokenNearExpiry(){if(!this.tokenExpiry)return!0;const t=new Date,e=1e3*this.config.refreshBuffer;return t>=new Date(this.tokenExpiry.getTime()-e)}_scheduleTokenRefresh(){if(this.refreshTimer&&clearTimeout(this.refreshTimer),!this.tokenExpiry)return;const t=new Date,e=1e3*this.config.refreshBuffer,n=new Date(this.tokenExpiry.getTime()-e),i=Math.max(0,n.getTime()-t.getTime());this.config.debug&&console.log(`[AuthManager] Scheduling token refresh in ${i/1e3} seconds`),this.refreshTimer=setTimeout((async()=>{try{await this.refreshToken()}catch(t){console.error("[AuthManager] Scheduled refresh failed:",t)}}),i)}_clearToken(){this.currentToken=null,this.tokenExpiry=null,this.refreshTimer&&(clearTimeout(this.refreshTimer),this.refreshTimer=null)}_notifyListeners(t,e){this.listeners.has(t)&&this.listeners.get(t).forEach((n=>{try{n(e)}catch(e){console.error(`[AuthManager] Error in ${t} listener:`,e)}}))}}class Bu{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.config={username:t.username,password:t.password,token:t.token,authCallback:t.authCallback,wsUrl:t.wsUrl||"https://mdas-api-dev.viewtrade.dev/wss/sub",apiBaseUrl:t.apiBaseUrl||"https://mdas-api-dev.viewtrade.dev",debug:t.debug||!1,maxConnections:t.maxConnections||1,autoAuth:!1!==t.autoAuth,...t},this.stateManager=new e,this.widgetManager=new Nu(this.stateManager),this.wsManager=null,this.authManager=null,this.isInitialized=!1,this._validateAuthConfig()}async initialize(){try{return this.isInitialized?(console.warn("SDK already initialized"),this):(this.config.debug&&console.log("Initializing MDAS SDK with config:",{hasCredentials:!(!this.config.username||!this.config.password),hasToken:!!this.config.token,hasAuthCallback:!!this.config.authCallback,wsUrl:this.config.wsUrl,autoAuth:this.config.autoAuth}),this.config.username&&this.config.password&&await this._initializeBuiltInAuth(),this.isInitialized=!0,this)}catch(t){throw console.error("Failed to initialize SDK:",t),t}}async createWidget(t,e){let n,i,s,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!this.isInitialized)throw new Error("SDK not initialized. Call initialize() first.");if(this.wsManager||await this._initializeWebSocketManager(),"object"!=typeof t||null===t||Array.isArray(t))n=t,i=e,s=o||{};else if(n=t.type,s=t.options||{},t.containerEl&&1===t.containerEl.nodeType)i=t.containerEl;else if(t.containerId){const e=String(t.containerId).replace(/^#/,"");let n="undefined"!=typeof document?document.getElementById(e):null;n||"undefined"==typeof document||(n=document.createElement("div"),n.id=e,document.body.appendChild(n)),i=n}else{const t="mdas-widget";let e="undefined"!=typeof document?document.getElementById(t):null;e||"undefined"==typeof document||(e=document.createElement("div"),e.id=t,document.body.appendChild(e)),i=e}const a={...s,wsManager:this.wsManager,debug:this.config.debug};return a.reconnect=async()=>await this.manualReconnect(),this.widgetManager.createWidget(n,i,a)}async login(t,e){this.authManager||(this.authManager=new Fu({apiBaseUrl:this.config.apiBaseUrl,debug:this.config.debug})),this.authManager.setCredentials(t,e);const n=await this.authManager.authenticate();return this.wsManager&&await this._reconnectWithNewToken(n),n}async destroy(){this.authManager&&(this.authManager.destroy(),this.authManager=null),this.wsManager&&(this.wsManager.disconnect(),this.wsManager=null),this.widgetManager&&this.widgetManager.destroy(),this.isInitialized=!1}getConnectionState(){return this.wsManager?this.wsManager.getConnectionState():"disconnected"}getActiveWidgetCount(){return this.widgetManager?this.widgetManager.getWidgetCount():0}getSubscriptionCount(){return this.wsManager?this.wsManager.getSubscriptionCount():0}isAuthenticated(){return this.authManager?!!this.authManager.currentToken:!!this.config.token}disconnect(){this.wsManager&&(this.wsManager.disconnect(),this.config.debug&&console.log("[MdasSDK] WebSocket disconnected"))}async connect(){if(this.wsManager)try{await this.wsManager.connect(),this.config.debug&&console.log("[MdasSDK] WebSocket reconnected")}catch(t){throw console.error("[MdasSDK] Failed to reconnect:",t),t}else this.config.debug&&console.log("[MdasSDK] No WebSocketManager exists, initializing..."),await this._initializeWebSocketManager()}isConnected(){return!!this.wsManager&&"connected"===this.wsManager.getConnectionState()}async manualReconnect(){return!!this.wsManager&&(this.config.debug&&console.log("[MdasSDK] Manual reconnect requested"),await this.wsManager.manualReconnect())}_validateAuthConfig(){const t=this.config.username&&this.config.password,e=this.config.token,n=this.config.authCallback;if(!t&&!e&&!n)throw new Error("Authentication required: Provide username/password, token, or authCallback");[t,e,n].filter(Boolean).length>1&&console.warn("Multiple auth methods provided. Priority: credentials > token > authCallback")}async _initializeBuiltInAuth(){this.authManager=new Fu({apiBaseUrl:this.config.apiBaseUrl,debug:this.config.debug}),this.authManager.setCredentials(this.config.username,this.config.password),this.authManager.addEventListener("auth_error",(t=>{console.error("Authentication error:",t.error)})),this.authManager.addEventListener("auth_success",(t=>{this.config.debug&&console.log("Authentication successful")})),this.authManager.addEventListener("auth_failed",(t=>{console.error("Authentication failed after retries:",t.error)})),this.config.autoAuth&&await this.authManager.authenticate()}async _initializeWebSocketManager(){const t=await this._getToken();this.wsManager=new $u({debug:this.config.debug,token:t,baseUrl:this.config.wsUrl,apiBaseUrl:this.config.apiBaseUrl,maxConnections:this.config.maxConnections,reconnectOptions:{maxAttempts:5,delay:1e3,backoff:2},reloginCallback:async()=>{try{if(this.authManager){this.config.debug&&console.log("[MdasSDK] Attempting relogin after session revoked...");const t=await this.authManager.authenticate();return this.config.debug&&console.log("[MdasSDK] Relogin successful, new token obtained"),t}return this.config.authCallback?await this.config.authCallback():(console.error("[MdasSDK] No authentication method available for relogin"),null)}catch(t){return console.error("[MdasSDK] Relogin failed:",t),null}}}),this.wsManager.addEventListener=this.wsManager.addEventListener||(()=>{});try{await this.wsManager.connect(),this.config.debug&&console.log("WebSocketManager connected successfully")}catch(t){t.message.includes("401")||t.message.includes("403")?await this._handleWebSocketAuthError(t):console.error("Failed to connect WebSocketManager:",t)}}async _getToken(){if(this.authManager)return await this.authManager.getValidToken();if(this.config.authCallback){const t=await this.config.authCallback();return t.token||t}return this.config.token}async _handleWebSocketAuthError(t){if(!this.authManager)throw t;try{const e=await this.authManager.handleAuthError(t);await this._reconnectWithNewToken(e)}catch(t){throw console.error("Failed to recover from auth error:",t),t}}async _reconnectWithNewToken(t){this.wsManager&&(this.wsManager.updateToken(t),this.wsManager.disconnect(),await this.wsManager.connect())}}"undefined"!=typeof window&&(window.MdasSDK=Bu,window.MdasSDK.MdasSDK=Bu,window.MdasSDK.MarketDataModel=i,window.MdasSDK.NightSessionModel=y,window.MdasSDK.OptionsModel=v,window.MdasSDK.IntradayChartModel=P,window.MdasSDK.ONBBOLevel2Model=Iu,window.MdasSDK.TimeSalesModel=Ou,window.MdasSDK.CombinedMarketWidget=D,window.MdasSDK.IntradayChartWidget=Au,window.MdasSDK.ONBBOLevel2Widget=zu,window.MdasSDK.TimeSalesWidget=Wu),t.CombinedMarketWidget=D,t.IntradayChartModel=P,t.IntradayChartWidget=Au,t.MarketDataModel=i,t.MdasSDK=Bu,t.NightSessionModel=y,t.ONBBOLevel2Model=Iu,t.ONBBOLevel2Widget=zu,t.OptionChainWidget=C,t.OptionsModel=v,t.TimeSalesModel=Ou,t.TimeSalesWidget=Wu,t.default=Bu,Object.defineProperty(t,"__esModule",{value:!0})}));//# sourceMappingURL=mdas-sdk.min.js.map
|
|
55
|
+
*/function Eu(t,e,n,i){const s=null===e,o=null===n,a=!(!t||s&&o)&&function(t,e){const{x:n,y:i,base:s,width:o,height:a}=t.getProps(["x","low","high","width","height"],e);let r,l,c,d,h;return t.horizontal?(h=a/2,r=Math.min(n,s),l=Math.max(n,s),c=i-h,d=i+h):(h=o/2,r=n-h,l=n+h,c=Math.min(i,s),d=Math.max(i,s)),{left:r,top:c,right:l,bottom:d}}(t,i);return a&&(s||e>=a.left&&e<=a.right)&&(o||n>=a.top&&n<=a.bottom)}class Lu extends Eo{static defaults={backgroundColors:{up:"rgba(75, 192, 192, 0.5)",down:"rgba(255, 99, 132, 0.5)",unchanged:"rgba(201, 203, 207, 0.5)"},borderColors:{up:"rgb(75, 192, 192)",down:"rgb(255, 99, 132)",unchanged:"rgb(201, 203, 207)"}};height(){return this.base-this.y}inRange(t,e,n){return Eu(this,t,e,n)}inXRange(t,e){return Eu(this,t,null,e)}inYRange(t,e){return Eu(this,null,t,e)}getRange(t){return"x"===t?this.width/2:this.height/2}getCenterPoint(t){const{x:e,low:n,high:i}=this.getProps(["x","low","high"],t);return{x:e,y:(i+n)/2}}tooltipPosition(t){const{x:e,open:n,close:i}=this.getProps(["x","open","close"],t);return{x:e,y:(n+i)/2}}}const Au=ro.defaults;class Iu extends Lu{static id="ohlc";static defaults={...Lu.defaults,lineWidth:2,armLength:null,armLengthRatio:.8};draw(t){const e=this,{x:n,open:i,high:s,low:o,close:a}=e,r=wt(e.armLengthRatio,Au.elements.ohlc.armLengthRatio);let l=wt(e.armLength,Au.elements.ohlc.armLength);null===l&&(l=e.width*r*.5),t.strokeStyle=a<i?wt(e.options.borderColors?e.options.borderColors.up:void 0,Au.elements.ohlc.borderColors.up):a>i?wt(e.options.borderColors?e.options.borderColors.down:void 0,Au.elements.ohlc.borderColors.down):wt(e.options.borderColors?e.options.borderColors.unchanged:void 0,Au.elements.ohlc.borderColors.unchanged),t.lineWidth=wt(e.lineWidth,Au.elements.ohlc.lineWidth),t.beginPath(),t.moveTo(n,s),t.lineTo(n,o),t.moveTo(n-l,i),t.lineTo(n,i),t.moveTo(n+l,a),t.lineTo(n,a),t.stroke()}}class zu extends Li{static overrides={label:"",parsing:!1,hover:{mode:"label"},animations:{numbers:{type:"number",properties:["x","y","base","width","open","high","low","close"]}},scales:{x:{type:"timeseries",offset:!0,ticks:{major:{enabled:!0},source:"data",maxRotation:0,autoSkip:!0,autoSkipPadding:75,sampleSize:100}},y:{type:"linear"}},plugins:{tooltip:{intersect:!1,mode:"index",callbacks:{label(t){const e=t.parsed;if(!ft(e.y))return $e.plugins.tooltip.callbacks.label(t);const{o:n,h:i,l:s,c:o}=e;return`O: ${n} H: ${i} L: ${s} C: ${o}`}}}}};getLabelAndValue(t){const e=this,n=e.getParsed(t),i=e._cachedMeta.iScale.axis,{o:s,h:o,l:a,c:r}=n,l=`O: ${s} H: ${o} L: ${a} C: ${r}`;return{label:`${e._cachedMeta.iScale.getLabelForValue(n[i])}`,value:l}}getUserBounds(t){const{min:e,max:n,minDefined:i,maxDefined:s}=t.getUserBounds();return{min:i?e:Number.NEGATIVE_INFINITY,max:s?n:Number.POSITIVE_INFINITY}}getMinMax(t){const e=this._cachedMeta,n=e._parsed,i=e.iScale.axis,s=this._getOtherScale(t),{min:o,max:a}=this.getUserBounds(s);if(n.length<2)return{min:0,max:1};if(t===e.iScale)return{min:n[0][i],max:n[n.length-1][i]};const r=n.filter((({x:t})=>t>=o&&t<a));let l=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY;for(let t=0;t<r.length;t++){const e=r[t];l=Math.min(l,e.l),c=Math.max(c,e.h)}return{min:l,max:c}}calculateElementProperties(t,e,n,i){const s=this,o=s._cachedMeta.vScale,a=o.getBasePixel(),r=s._calculateBarIndexPixels(t,e,i),l=s.chart.data.datasets[s.index].data[t],c=o.getPixelForValue(l.o),d=o.getPixelForValue(l.h),h=o.getPixelForValue(l.l),u=o.getPixelForValue(l.c);return{base:n?a:h,x:r.center,y:(h+d)/2,width:r.size,open:c,high:d,low:h,close:u}}draw(){const t=this,e=t.chart,n=t._cachedMeta.data;Ye(e.ctx,e.chartArea);for(let e=0;e<n.length;++e)n[e].draw(t._ctx);Ue(e.ctx)}}class Ou extends Lu{static id="candlestick";static defaults={...Lu.defaults,borderWidth:1};draw(t){const e=this,{x:n,open:i,high:s,low:o,close:a}=e;let r,l=e.options.borderColors;"string"==typeof l&&(l={up:l,down:l,unchanged:l}),a<i?(r=wt(l?l.up:void 0,$e.elements.candlestick.borderColors.up),t.fillStyle=wt(e.options.backgroundColors?e.options.backgroundColors.up:void 0,$e.elements.candlestick.backgroundColors.up)):a>i?(r=wt(l?l.down:void 0,$e.elements.candlestick.borderColors.down),t.fillStyle=wt(e.options.backgroundColors?e.options.backgroundColors.down:void 0,$e.elements.candlestick.backgroundColors.down)):(r=wt(l?l.unchanged:void 0,$e.elements.candlestick.borderColors.unchanged),t.fillStyle=wt(e.backgroundColors?e.backgroundColors.unchanged:void 0,$e.elements.candlestick.backgroundColors.unchanged)),t.lineWidth=wt(e.options.borderWidth,$e.elements.candlestick.borderWidth),t.strokeStyle=r,t.beginPath(),t.moveTo(n,s),t.lineTo(n,Math.min(i,a)),t.moveTo(n,o),t.lineTo(n,Math.max(i,a)),t.stroke(),t.fillRect(n-e.width/2,a,e.width,i-a),t.strokeRect(n-e.width/2,a,e.width,i-a),t.closePath()}}class Wu extends zu{static id="candlestick";static defaults={...zu.defaults,dataElementType:Ou.id};static defaultRoutes=Li.defaultRoutes;updateElements(t,e,n,i){const s="reset"===i,o=this._getRuler(),{sharedOptions:a,includeOptions:r}=this._getSharedOptions(e,i);for(let l=e;l<e+n;l++){const e=a||this.resolveDataElementOptions(l,i),n=this.calculateElementProperties(l,o,s,e);r&&(n.options=e),this.updateElement(t[l],l,n,i)}}}ro.register(...rr,Mh,Pu,Wu,Ou);class Nu extends n{constructor(t,e,n){if(super(t,e,n),!e.symbol)throw new Error("Symbol is required for IntradayChartWidget");if(!e.wsManager)throw new Error("WebSocketManager is required for IntradayChartWidget");const i=f(e.symbol);if(!i.valid)throw new Error(`Invalid symbol: ${i.error}`);this.type="intraday-chart",this.wsManager=e.wsManager,this.symbol=i.sanitized,this.debug=e.debug||!1,this.source=e.source||"blueocean",this.rangeBack=e.rangeBack||0,this.chartType=e.chartType||"line",this.autoRefresh=void 0===e.autoRefresh||e.autoRefresh,this.refreshInterval=e.refreshInterval||6e4,this.refreshTimer=null,this.isUserInteracting=!1,this.marketIsOpen=null,this.marketStatusChecked=!1,this.chartData=null,this.chartInstance=null,this.unsubscribe=null,this.livePrice=null,this.companyName="",this.exchangeName="",this.mic="",this.symbolEditor=null,this.cached1DData=null,this.cached5DData=null,this.is5DDataLoading=!1,this.createWidgetStructure(),this.setupSymbolEditor(),this.initialize()}createWidgetStructure(){this.container.innerHTML='\n <div class="intraday-chart-widget">\n <div class="chart-header">\n <div class="chart-title-section">\n <div class="company-market-info">\n <span class="intraday-company-name"></span>\n </div>\n <h3 class="intraday-chart-symbol editable-symbol"\n title="Double-click to edit symbol"\n data-original-symbol="">AAPL</h3>\n </div>\n <div class="chart-change positive">+0.00 (+0.00%)</div>\n </div>\n\n <div class="chart-controls">\n <div class="chart-range-selector">\n <button class="range-btn active" data-range="0">1D</button>\n <button class="range-btn" data-range="5">5D</button>\n </div>\n <div class="chart-type-selector">\n <button class="type-btn active" data-type="line" title="Line Chart">Line</button>\n <button class="type-btn" data-type="area" title="Area Chart">Mountain</button>\n <button class="type-btn" data-type="candlestick" title="Candlestick Chart">Candles</button>\n </div>\n <button class="zoom-reset-btn" title="Reset Zoom">\n <svg width="16" height="16" viewBox="0 0 16 16" fill="none">\n <path d="M2 8a6 6 0 1 1 12 0A6 6 0 0 1 2 8zm6-7a7 7 0 1 0 0 14A7 7 0 0 0 8 1z" fill="currentColor"/>\n <path d="M5 8h6M8 5v6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>\n </svg>\n Reset Zoom\n </button>\n </div>\n\n <div class="chart-container">\n <canvas id="intradayChart"></canvas>\n </div>\n\n <div class="chart-stats">\n <div class="stats-header">Daily Stats</div>\n <div class="stats-grid">\n <div class="stat-item stat-open">\n <span class="stat-label">Open</span>\n <span class="stat-value">$0.00</span>\n </div>\n <div class="stat-item stat-high">\n <span class="stat-label">High</span>\n <span class="stat-value">$0.00</span>\n </div>\n <div class="stat-item stat-low">\n <span class="stat-label">Low</span>\n <span class="stat-value">$0.00</span>\n </div>\n <div class="stat-item stat-close">\n <span class="stat-label">Close</span>\n <span class="stat-value">$0.00</span>\n </div>\n <div class="stat-item stat-volume">\n <span class="stat-label">Volume</span>\n <span class="stat-value">0</span>\n </div>\n </div>\n </div>\n\n <div class="widget-loading-overlay hidden">\n <div class="loading-spinner"></div>\n <div class="loading-text">Loading chart data...</div>\n </div>\n </div>\n';const t=this.container.querySelector(".intraday-chart-symbol");t&&(t.textContent=this.symbol),this.setupRangeButtons(),this.setupChartTypeButtons(),this.addStyles()}setupSymbolEditor(){this.symbolEditor=new s(this,{maxLength:10,placeholder:"Enter symbol...",onSymbolChange:this.handleSymbolChange.bind(this),debug:this.debug,autoUppercase:!0,symbolType:"nightsession"});const t=this.container.querySelector(".intraday-chart-symbol");t&&(t.textContent=this.symbol,t.dataset.originalSymbol=this.symbol)}async handleSymbolChange(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.debug&&(console.log("[IntradayChartWidget] Symbol change requested:",t),console.log("[IntradayChartWidget] Validation data:",n));const i=f(t);if(!i.valid)return this.debug&&console.log("[IntradayChartWidget] Invalid symbol:",i.error),{success:!1,error:i.error};const s=i.sanitized;if(n&&(this.companyName=n.comp_name||"",this.exchangeName=n.market_name||"",this.mic=n.mic||"",this.debug&&console.log("[IntradayChartWidget] Extracted company info:",{companyName:this.companyName,exchangeName:this.exchangeName})),s===this.symbol)return this.debug&&console.log("[IntradayChartWidget] Same symbol, no change needed"),{success:!0};try{return this.showLoading(),this.stopAutoRefresh(),this.unsubscribe&&(this.debug&&console.log(`[IntradayChartWidget] Unsubscribing from ${e}`),this.unsubscribe(),this.unsubscribe=null),this.chartInstance&&(this.debug&&console.log("[IntradayChartWidget] Clearing chart for symbol change"),this.chartInstance.destroy(),this.chartInstance=null),this.chartData=null,this.livePrice=null,this.cached1DData=null,this.cached5DData=null,this.is5DDataLoading=!1,this.symbol=s,this.updateCompanyName(),await this.loadChartData(),this.debug&&console.log(`[IntradayChartWidget] Successfully changed symbol from ${e} to ${s}`),{success:!0}}catch(t){return console.error("[IntradayChartWidget] Error changing symbol:",t),this.showError(`Failed to load data for ${s}`),{success:!1,error:`Failed to load ${s}`}}}async initialize(){!1!==await super.validateInitialSymbol("quotel1",this.symbol,(t=>{t&&t[0]&&(this.companyName=t[0].comp_name||"",this.exchangeName=t[0].market_name||"",this.mic=t[0].mic||"")}))&&(this.updateCompanyName(),await this.loadChartData())}updateCompanyName(){const t=this.container.querySelector(".intraday-company-name");t&&(t.textContent=this.companyName||"")}setupRangeButtons(){const t=this.container.querySelectorAll(".range-btn");t.forEach((e=>{e.addEventListener("click",(async e=>{const n=parseInt(e.target.getAttribute("data-range"));t.forEach((t=>t.classList.remove("active"))),e.target.classList.add("active"),this.rangeBack=n,await this.loadChartData(),0===n?(await this.startAutoRefresh(),await this.subscribeToLivePrice()):(this.stopAutoRefresh(),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null,this.livePrice=null))}))}))}setupChartTypeButtons(){const t=this.container.querySelectorAll(".type-btn");t.forEach((e=>{e.addEventListener("click",(e=>{const n=e.target.getAttribute("data-type");t.forEach((t=>t.classList.remove("active"))),e.target.classList.add("active"),this.chartType=n,this.renderChart()}))}))}addStyles(){if(this.options.skipStyleInjection||document.querySelector('link[href*="mdas-styles.css"]'))this.debug&&console.log("[IntradayChartWidget] Skipping style injection - external styles detected");else if(!document.querySelector("#intraday-chart-styles"))try{const t=document.createElement("style");t.id="intraday-chart-styles",t.textContent="\n .intraday-chart-widget {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;\n background: white;\n border-radius: 12px;\n padding: 20px;\n box-shadow: 0 2px 8px rgba(0,0,0,0.1);\n position: relative;\n width: 100%;\n min-width: 600px;\n max-width: 1400px;\n margin: 0 auto;\n }\n\n .intraday-chart-widget .chart-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: 20px;\n padding-bottom: 15px;\n border-bottom: 1px solid #e5e7eb;\n }\n\n .intraday-chart-widget .chart-title-section {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .intraday-chart-widget .company-market-info {\n display: flex;\n gap: 8px;\n align-items: center;\n font-size: 0.75em;\n color: #6b7280;\n }\n\n .intraday-chart-widget .intraday-company-name {\n font-weight: 500;\n }\n\n .intraday-chart-widget .intraday-chart-symbol {\n font-size: 1.5em;\n font-weight: 700;\n color: #1f2937;\n margin: 0;\n }\n\n .intraday-chart-widget .intraday-chart-source {\n font-size: 0.75em;\n padding: 4px 8px;\n border-radius: 4px;\n background: #e0e7ff;\n color: #4338ca;\n font-weight: 600;\n }\n\n .intraday-chart-widget .chart-change {\n font-size: 1.1em;\n font-weight: 600;\n padding: 6px 12px;\n border-radius: 6px;\n }\n\n .intraday-chart-widget .chart-change.positive {\n color: #059669;\n background: #d1fae5;\n }\n\n .intraday-chart-widget .chart-change.negative {\n color: #dc2626;\n background: #fee2e2;\n }\n\n .intraday-chart-widget .chart-controls {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: 15px;\n }\n\n .intraday-chart-widget .chart-range-selector {\n display: flex;\n gap: 8px;\n }\n\n .intraday-chart-widget .range-btn {\n padding: 8px 16px;\n border: 1px solid #e5e7eb;\n background: white;\n border-radius: 6px;\n font-size: 0.875em;\n font-weight: 600;\n color: #6b7280;\n cursor: pointer;\n transition: all 0.2s ease;\n }\n\n .intraday-chart-widget .range-btn:hover {\n background: #f9fafb;\n border-color: #d1d5db;\n }\n\n .intraday-chart-widget .range-btn.active {\n background: #667eea;\n color: white;\n border-color: #667eea;\n }\n\n .intraday-chart-widget .range-btn:focus {\n outline: none;\n box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);\n }\n\n .intraday-chart-widget .chart-type-selector {\n display: flex;\n gap: 8px;\n }\n\n .intraday-chart-widget .type-btn {\n padding: 8px 16px;\n border: 1px solid #e5e7eb;\n background: white;\n border-radius: 6px;\n font-size: 0.875em;\n font-weight: 600;\n color: #6b7280;\n cursor: pointer;\n transition: all 0.2s ease;\n }\n\n .intraday-chart-widget .type-btn:hover {\n background: #f9fafb;\n border-color: #d1d5db;\n }\n\n .intraday-chart-widget .type-btn.active {\n background: #10b981;\n color: white;\n border-color: #10b981;\n }\n\n .intraday-chart-widget .type-btn:focus {\n outline: none;\n box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);\n }\n\n .intraday-chart-widget .zoom-reset-btn {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 8px 12px;\n border: 1px solid #e5e7eb;\n background: white;\n border-radius: 6px;\n font-size: 0.875em;\n font-weight: 500;\n color: #6b7280;\n cursor: pointer;\n transition: all 0.2s ease;\n }\n\n .intraday-chart-widget .zoom-reset-btn:hover {\n background: #f9fafb;\n border-color: #667eea;\n color: #667eea;\n }\n\n .intraday-chart-widget .zoom-reset-btn:focus {\n outline: none;\n box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);\n }\n\n .intraday-chart-widget .zoom-reset-btn svg {\n flex-shrink: 0;\n }\n\n .intraday-chart-widget .chart-container {\n height: 500px;\n margin-bottom: 20px;\n position: relative;\n }\n\n .intraday-chart-widget .chart-stats {\n padding: 15px;\n background: #f9fafb;\n border-radius: 8px;\n }\n\n .intraday-chart-widget .stats-header {\n font-size: 0.875em;\n font-weight: 700;\n color: #374151;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n margin-bottom: 12px;\n padding-bottom: 8px;\n border-bottom: 2px solid #e5e7eb;\n }\n\n .intraday-chart-widget .stats-grid {\n display: grid;\n grid-template-columns: repeat(5, 1fr);\n gap: 15px;\n }\n\n .intraday-chart-widget .stat-item {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .intraday-chart-widget .stat-label {\n font-size: 0.75em;\n color: #6b7280;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n }\n\n .intraday-chart-widget .stat-value {\n font-size: 1.1em;\n font-weight: 700;\n color: #1f2937;\n }\n\n .intraday-chart-widget .widget-loading-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(255, 255, 255, 0.4);\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n gap: 10px;\n padding: 10px 16px;\n border-radius: 12px;\n z-index: 10;\n pointer-events: none;\n backdrop-filter: blur(1px);\n }\n\n .intraday-chart-widget .widget-loading-overlay.hidden {\n display: none;\n }\n\n .intraday-chart-widget .loading-spinner {\n width: 20px;\n height: 20px;\n border: 3px solid #e5e7eb;\n border-top-color: #667eea;\n border-radius: 50%;\n animation: intraday-spin 0.8s linear infinite;\n }\n\n .intraday-chart-widget .loading-text {\n color: #6b7280;\n font-size: 0.875em;\n font-weight: 500;\n }\n\n @keyframes intraday-spin {\n to { transform: rotate(360deg); }\n }\n\n @media (max-width: 768px) {\n .intraday-chart-widget {\n min-width: unset;\n padding: 15px;\n }\n\n .intraday-chart-widget .stats-grid {\n grid-template-columns: repeat(3, 1fr);\n gap: 10px;\n }\n\n .intraday-chart-widget .stats-header {\n font-size: 0.8em;\n margin-bottom: 10px;\n }\n\n .intraday-chart-widget .chart-container {\n height: 350px;\n }\n\n .intraday-chart-widget .intraday-chart-symbol {\n font-size: 1.2em;\n }\n }\n\n .intraday-chart-widget .widget-error {\n padding: 15px;\n background: #fee2e2;\n border: 1px solid #fecaca;\n border-radius: 8px;\n color: #dc2626;\n font-size: 0.9em;\n margin-top: 10px;\n }\n",document.head.appendChild(t),this.debug&&console.log("[IntradayChartWidget] Styles injected successfully")}catch(t){console.warn("[IntradayChartWidget] Failed to inject styles:",t),console.warn('[IntradayChartWidget] Please add <link rel="stylesheet" href="mdas-styles.css"> to your HTML')}}async loadChartData(){try{this.showLoading(),this.clearError();const t=this.wsManager.getApiService();if(!t)throw new Error("API service not available");if(5===this.rangeBack)return void await this.load5DayChartData(t);if(0===this.rangeBack&&this.cached1DData)return this.debug&&console.log("[IntradayChartWidget] Using cached 1D data"),this.chartData=this.cached1DData,this.renderChart(),this.hideLoading(),await this.startAutoRefresh(),void this.subscribeToLivePrice();const e=7;let n=this.rangeBack,i=!1,s=null,o=null,a=!1;for(let r=0;r<e;r++){if(this.debug&&console.log(`[IntradayChartWidget] Loading data for ${this.symbol} from ${this.source}, range_back: ${n} (attempt ${r+1}/${e})`),s=await t.getIntradayChart(this.source,this.symbol,n),console.log("[IntradayChartWidget] API response type:",typeof s),console.log("[IntradayChartWidget] API response:",s),s&&(console.log("[IntradayChartWidget] Response keys:",Object.keys(s)),Array.isArray(s)&&(console.log("[IntradayChartWidget] Response is array, length:",s.length),s.length>0&&(console.log("[IntradayChartWidget] First item:",s[0]),console.log("[IntradayChartWidget] First item keys:",Object.keys(s[0]))))),s&&s.error)throw new Error(s.error||"Server error");if(o=s,s&&s.data&&Array.isArray(s.data)&&(console.log("[IntradayChartWidget] Found data array in response.data"),o=s.data),o&&Array.isArray(o)&&o.length>0){i=!0,n!==this.rangeBack&&(a=!0,this.debug&&console.log(`[IntradayChartWidget] Using fallback data: requested rangeBack ${this.rangeBack}, got data from rangeBack ${n}`));break}console.log(`[IntradayChartWidget] No data for rangeBack ${n}, trying ${n+1}...`),n++}if(!i||!o||0===o.length)throw new Error(`No intraday data available for ${this.symbol} in the past ${e} days`);if(console.log("[IntradayChartWidget] Processing",o.length,"data points"),this.chartData=new z(o),console.log("[IntradayChartWidget] Model created with",this.chartData.dataPoints.length,"points"),0===this.chartData.dataPoints.length)throw console.error("[IntradayChartWidget] Model has no data points after processing"),new Error(`No valid data points for ${this.symbol}`);0===this.rangeBack&&(this.cached1DData=this.chartData,this.debug&&console.log("[IntradayChartWidget] Cached 1D data for instant switching")),this.renderChart(),this.hideLoading(),this.debug&&console.log(`[IntradayChartWidget] Loaded ${o.length} data points`),0!==this.rangeBack||a?(this.stopAutoRefresh(),this.debug&&console.log("[IntradayChartWidget] Not starting auto-refresh for historical/fallback data")):(await this.startAutoRefresh(),this.subscribeToLivePrice(),this.preload5DDataInBackground())}catch(t){console.error("[IntradayChartWidget] Error loading chart data:",t),this.hideLoading();let e="Failed to load chart data";t.message.includes("No intraday data")?e=t.message:t.message.includes("API service not available")?e="Unable to connect to data service":t.message.includes("HTTP error")||t.message.includes("status: 4")?e=`Unable to load data for ${this.symbol}`:t.message.includes("status: 5")?e="Server error. Please try again later":t.message.includes("Failed to fetch")&&(e="Network error. Please check your connection"),this.showError(e)}}async load5DayChartData(t){try{if(this.cached5DData)return this.debug&&console.log("[IntradayChartWidget] Using cached 5D data"),this.chartData=this.cached5DData,this.renderChart(),this.hideLoading(),this.subscribeToLivePrice(),void this.stopAutoRefresh();const e=await this.fetch5DayData(t);if(this.chartData=new z(e),0===this.chartData.dataPoints.length)throw new Error(`No valid data points for ${this.symbol}`);this.cached5DData=this.chartData,this.renderChart(),this.hideLoading(),this.debug&&console.log(`[IntradayChartWidget] 5D chart loaded with ${this.chartData.dataPoints.length} data points`),this.subscribeToLivePrice(),this.stopAutoRefresh()}catch(t){throw console.error("[IntradayChartWidget] Error loading 5D chart data:",t),t}}async fetch5DayData(t){this.debug&&console.log("[IntradayChartWidget] Fetching 5D chart data with parallel requests (API limit: rangeback 0-6)");const e=[];for(let n=0;n<7;n++)e.push(t.getIntradayChart(this.source,this.symbol,n).then((t=>{let e=t;return t&&t.data&&Array.isArray(t.data)&&(e=t.data),{rangeBack:n,data:e}})).catch((t=>(this.debug&&console.warn(`[IntradayChartWidget] Request failed for rangeback ${n}:`,t),{rangeBack:n,data:null}))));const n=await Promise.all(e);this.debug&&console.log("[IntradayChartWidget] All parallel requests completed");const i=n.filter((t=>{const e=t.data&&Array.isArray(t.data)&&t.data.length>0;return this.debug&&(e?console.log(`[IntradayChartWidget] Rangeback ${t.rangeBack}: ${t.data.length} data points`):console.log(`[IntradayChartWidget] Rangeback ${t.rangeBack}: No data (skipped)`)),e})).slice(0,5);if(0===i.length)throw new Error(`No intraday data available for ${this.symbol} in the past 7 days`);this.debug&&(console.log(`[IntradayChartWidget] Collected ${i.length}/5 days of data`),i.length<5&&console.log(`[IntradayChartWidget] Note: Only ${i.length} days available within API limit (rangeback 0-6)`));const s=[];for(let t=i.length-1;t>=0;t--)s.push(...i[t].data);return this.debug&&console.log(`[IntradayChartWidget] Combined ${s.length} total data points from ${i.length} days`),s}preload5DDataInBackground(){this.is5DDataLoading||this.cached5DData||(this.is5DDataLoading=!0,this.debug&&console.log("[IntradayChartWidget] Starting background preload of 5D data..."),setTimeout((async()=>{try{const t=this.wsManager.getApiService();if(!t)return void(this.debug&&console.log("[IntradayChartWidget] API service not available for preload"));const e=await this.fetch5DayData(t),n=new z(e);this.cached5DData=n,this.debug&&console.log(`[IntradayChartWidget] ✓ Background preload complete: ${n.dataPoints.length} data points cached`)}catch(t){this.debug&&console.warn("[IntradayChartWidget] Background preload failed:",t)}finally{this.is5DDataLoading=!1}}),1e3))}subscribeToLivePrice(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null);const t="bruce"===this.source?"querybrucel1":"queryblueoceanl1";this.debug&&console.log(`[IntradayChartWidget] Subscribing to live price with ${t} for ${this.symbol}`),this.unsubscribe=this.wsManager.subscribe(this.widgetId,[t],this.handleMessage.bind(this),this.symbol)}handleError(t){this.debug&&console.error("[IntradayChartWidget] WebSocket error:",t.message||t)}handleData(t){console.log("[IntradayChartWidget] handleData called with:",t),console.log("[IntradayChartWidget] Looking for symbol:",this.symbol),console.log("[IntradayChartWidget] Message is array?",Array.isArray(t));let e=null;if(Array.isArray(t.data)){console.log("[IntradayChartWidget] Processing array format, length:",t.length);const n=t.data.find((t=>t.Symbol===this.symbol));console.log("[IntradayChartWidget] Found symbol data:",n),n&&!n.NotFound&&(e=n)}else t.Symbol!==this.symbol||t.NotFound||(console.log("[IntradayChartWidget] Processing direct format"),e=t);if(!e)return void console.log("[IntradayChartWidget] No matching price data found for symbol:",this.symbol);console.log("[IntradayChartWidget] Price data found:",e);let n=null;void 0!==e.LastPx&&null!==e.LastPx?(n=parseFloat(e.LastPx),console.log("[IntradayChartWidget] Price from LastPx:",n)):void 0!==e.Last&&null!==e.Last?(n=parseFloat(e.Last),console.log("[IntradayChartWidget] Price from Last:",n)):void 0!==e.last_price&&null!==e.last_price?(n=parseFloat(e.last_price),console.log("[IntradayChartWidget] Price from last_price:",n)):void 0!==e.TradePx&&null!==e.TradePx?(n=parseFloat(e.TradePx),console.log("[IntradayChartWidget] Price from TradePx:",n)):void 0!==e.Close&&null!==e.Close?(n=parseFloat(e.Close),console.log("[IntradayChartWidget] Price from Close:",n)):void 0!==e.close&&null!==e.close&&(n=parseFloat(e.close),console.log("[IntradayChartWidget] Price from close:",n)),console.log("[IntradayChartWidget] Extracted price:",n),n&&!isNaN(n)&&n>0?(this.livePrice=n,console.log("[IntradayChartWidget] Updating live price line to:",n),this.updateLivePriceLine(),console.log(`[IntradayChartWidget] Live price update: $${n.toFixed(2)}`)):console.log("[IntradayChartWidget] Invalid price, not updating:",n),this.updateStatsFromLiveData(e)}updateStatsFromLiveData(t){if(!t)return;const e={high:void 0!==t.HighPx&&null!==t.HighPx?parseFloat(t.HighPx):null,low:void 0!==t.LowPx&&null!==t.LowPx?parseFloat(t.LowPx):null,open:void 0!==t.OpenPx&&null!==t.OpenPx?parseFloat(t.OpenPx):null,close:void 0!==t.LastPx&&null!==t.LastPx?parseFloat(t.LastPx):void 0!==t.TradePx&&null!==t.TradePx?parseFloat(t.TradePx):null,volume:void 0!==t.Volume&&null!==t.Volume?parseInt(t.Volume):null,change:void 0!==t.Change&&null!==t.Change?parseFloat(t.Change):null,changePercent:void 0!==t.ChangePercent&&null!==t.ChangePercent?100*parseFloat(t.ChangePercent):null};this.debug&&console.log("[IntradayChartWidget] Updating stats from live data:",e);const n=this.container.querySelector(".stat-high .stat-value"),i=this.container.querySelector(".stat-low .stat-value"),s=this.container.querySelector(".stat-open .stat-value"),o=this.container.querySelector(".stat-close .stat-value"),a=this.container.querySelector(".stat-volume .stat-value"),r=this.container.querySelector(".chart-change");if(n&&null!==e.high&&(n.textContent=`$${e.high.toFixed(2)}`),i&&null!==e.low&&(i.textContent=`$${e.low.toFixed(2)}`),s&&null!==e.open&&(s.textContent=`$${e.open.toFixed(2)}`),o&&null!==e.close&&(o.textContent=`$${e.close.toFixed(2)}`),a&&null!==e.volume&&(a.textContent=this.formatVolume(e.volume)),r&&null!==e.change&&null!==e.changePercent){const t=e.change>=0?"positive":"negative";r.className=`chart-change ${t}`;const n=e.change>=0?"+":"";r.textContent=`${n}${e.change.toFixed(2)} (${n}${e.changePercent.toFixed(2)}%)`}}formatVolume(t){return t>=1e6?(t/1e6).toFixed(2)+"M":t>=1e3?(t/1e3).toFixed(2)+"K":t.toString()}updateLivePriceLine(){this.chartInstance&&this.livePrice?this.chartInstance.options.plugins.annotation&&(this.chartInstance.options.plugins.annotation.annotations.livePriceLine.value=this.livePrice,this.chartInstance.options.plugins.annotation.annotations.livePriceLine.label.content=`$${this.livePrice.toFixed(2)}`,this.chartInstance.options.plugins.annotation.annotations.livePriceLine.label.display=!0,this.debug&&console.log("[IntradayChartWidget] Live price line updated:",{price:this.livePrice,label:this.chartInstance.options.plugins.annotation.annotations.livePriceLine.label.content}),this.chartInstance.update("none")):this.debug&&console.log("[IntradayChartWidget] Cannot update live price line:",{hasChart:!!this.chartInstance,livePrice:this.livePrice})}async isMarketOpen(){const t=new Date,e=t.toLocaleString("en-US",{timeZone:"America/New_York",weekday:"short"}),n=parseInt(t.toLocaleString("en-US",{timeZone:"America/New_York",hour12:!1,hour:"numeric"}),10),i=parseInt(t.toLocaleString("en-US",{timeZone:"America/New_York",minute:"numeric"}),10);if("Sat"===e||"Sun"===e)return!1;const s=n>=20||n<4;if(this.debug&&console.log(`[IntradayChartWidget] Market check: ET hour=${n}, minute=${i}, day=${e}, open=${s}`),!s)return this.debug&&console.log("[IntradayChartWidget] Market is currently closed (outside 8pm-4am ET on weekdays)."),!1;if(!this.marketStatusChecked)try{const t=this.wsManager.getApiService(),e=await t.getMarketStatus(this.source);if(e&&Array.isArray(e)&&e.length>0){const t=e[0].status;return this.marketIsOpen=t&&"open"===t.toLowerCase(),this.marketStatusChecked=!0,this.debug&&console.log(`[IntradayChartWidget] Market status from API: ${t} (${this.marketIsOpen?"Open":"Closed"})`),this.marketIsOpen}}catch(t){return this.debug&&console.warn("[IntradayChartWidget] Failed to get market status from API, assuming open based on time:",t),this.marketIsOpen=!0,this.marketStatusChecked=!0,!0}return!1!==this.marketIsOpen&&(!0!==this.marketIsOpen||(!(3===n&&i>=45)||(this.debug&&console.log("[IntradayChartWidget] Approaching market close, re-checking status..."),this.marketStatusChecked=!1,await this.isMarketOpen())))}async startAutoRefresh(){if(this.stopAutoRefresh(),!this.autoRefresh)return;await this.isMarketOpen()?(this.debug&&console.log(`[IntradayChartWidget] Starting auto-refresh every ${this.refreshInterval/1e3} seconds`),this.refreshTimer=setInterval((async()=>{if(!await this.isMarketOpen())return this.debug&&console.log("[IntradayChartWidget] Market closed. Stopping auto-refresh."),void this.stopAutoRefresh();if(this.isUserInteracting)this.debug&&console.log("[IntradayChartWidget] Skipping refresh - user is interacting");else{this.debug&&console.log("[IntradayChartWidget] Auto-refreshing chart data");try{const t=this.wsManager.getApiService(),e=await t.getIntradayChart(this.source,this.symbol,this.rangeBack);e&&Array.isArray(e)&&(this.chartData=new z(e),this.renderChart(),this.debug&&console.log(`[IntradayChartWidget] Auto-refresh complete - ${e.length} data points`))}catch(t){console.error("[IntradayChartWidget] Auto-refresh failed:",t)}}}),this.refreshInterval)):this.debug&&console.log("[IntradayChartWidget] Market is closed. Auto-refresh will not start.")}stopAutoRefresh(){this.refreshTimer&&(this.debug&&console.log("[IntradayChartWidget] Stopping auto-refresh"),clearInterval(this.refreshTimer),this.refreshTimer=null)}parseTimestamp(t){return new Date(t)}renderChart(){if(console.log("[IntradayChartWidget] renderChart called"),!this.chartData||0===this.chartData.dataPoints.length)return void console.error("[IntradayChartWidget] No data to render");console.log("[IntradayChartWidget] Chart data points:",this.chartData.dataPoints.length);const t=this.container.querySelector("#intradayChart");if(console.log("[IntradayChartWidget] Canvas element:",t),!t)return void console.error("[IntradayChartWidget] Canvas element not found");if(this.chartInstance){console.log("[IntradayChartWidget] Destroying existing chart instance");try{this.chartInstance.destroy(),this.chartInstance=null}catch(t){console.error("[IntradayChartWidget] Error destroying chart:",t),this.chartInstance=null}}const e=t.getContext("2d");console.log("[IntradayChartWidget] Canvas context:",e),console.log("[IntradayChartWidget] Preparing chart data...");const n=this.chartData.getStats();console.log("[IntradayChartWidget] Stats:",n);const i=n.change>=0,s=i?"#10b981":"#ef4444";let o,a;const r=this.chartData.dataPoints;if(0===r.length)return console.error("[IntradayChartWidget] No valid data points from model"),void this.showError("No valid chart data available");if(console.log("[IntradayChartWidget] Rendering",r.length,"data points"),"candlestick"===this.chartType){if(o=this.rangeBack>0?r.map(((t,e)=>({x:e,o:t.open,h:t.high,l:t.low,c:t.close}))):r.map((t=>({x:this.parseTimestamp(t.time).getTime(),o:t.open,h:t.high,l:t.low,c:t.close}))).filter((t=>!isNaN(t.x)&&t.x>0)),0===o.length)return console.error("[IntradayChartWidget] No valid candlestick data points after date parsing"),void this.showError("Unable to parse chart data timestamps");a={label:"Price",data:o,color:{up:"#10b981",down:"#ef4444",unchanged:"#6b7280"},borderColor:{up:"#10b981",down:"#ef4444",unchanged:"#6b7280"}}}else{if(o=this.rangeBack>0?r.map(((t,e)=>({x:e,y:t.close}))):r.map((t=>({x:this.parseTimestamp(t.time),y:t.close}))).filter((t=>{const e=t.x.getTime();return!isNaN(e)&&e>0})),0===o.length)return console.error("[IntradayChartWidget] No valid chart data points after date parsing"),void this.showError("Unable to parse chart data timestamps");const t=e.createLinearGradient(0,0,0,300);i?(t.addColorStop(0,"rgba(16, 185, 129, 0.3)"),t.addColorStop(1,"rgba(16, 185, 129, 0.01)")):(t.addColorStop(0,"rgba(239, 68, 68, 0.3)"),t.addColorStop(1,"rgba(239, 68, 68, 0.01)")),a={label:"Price",data:o,borderColor:s,backgroundColor:"area"===this.chartType?t:"transparent",borderWidth:2,fill:"area"===this.chartType,tension:.4,pointRadius:0,pointHoverRadius:4,pointBackgroundColor:s,pointBorderColor:"#fff",pointBorderWidth:2}}let l,c;if(console.log("[IntradayChartWidget] Chart data points prepared:",o.length),console.log("[IntradayChartWidget] First data point - Source time:",r[0].time),console.log("[IntradayChartWidget] First chart point:",o[0]),console.log("[IntradayChartWidget] Last data point - Source time:",r[r.length-1].time),console.log("[IntradayChartWidget] Last chart point:",o[o.length-1]),0===this.rangeBack){const t=o.map((t=>"candlestick"===this.chartType?t.x:t.x.getTime()));l=Math.min(...t),c=Math.max(...t),console.log("[IntradayChartWidget] X-axis bounds:",{min:l,max:c,minDate:new Date(l),maxDate:new Date(c)})}else console.log("[IntradayChartWidget] Using linear scale with",o.length,"data points");const d={type:"candlestick"===this.chartType?"candlestick":"line",data:{datasets:[a]},options:{responsive:!0,maintainAspectRatio:!1,interaction:{intersect:!1,mode:"index"},plugins:{legend:{display:!1},decimation:{enabled:o.length>1e3,algorithm:"lttb",samples:500,threshold:1e3},tooltip:{enabled:!0,backgroundColor:"rgba(0, 0, 0, 0.8)",titleColor:"#fff",bodyColor:"#fff",borderColor:s,borderWidth:1,padding:10,displayColors:!1,callbacks:{title:t=>{const e=t[0].dataIndex,n=r[e];if(n){return new Date(n.time).toLocaleString("en-US",{month:"2-digit",day:"2-digit",year:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit",hour12:!0})}return""},label:t=>{const e=t.dataIndex,n=r[e];return n?"candlestick"===this.chartType?[`Open: $${n.open.toFixed(2)}`,`High: $${n.high.toFixed(2)}`,`Low: $${n.low.toFixed(2)}`,`Close: $${n.close.toFixed(2)}`,`Volume: ${this.chartData.formatVolume(n.volume)}`]:[`Price: $${n.close.toFixed(2)}`,`Open: $${n.open.toFixed(2)}`,`High: $${n.high.toFixed(2)}`,`Low: $${n.low.toFixed(2)}`,`Volume: ${this.chartData.formatVolume(n.volume)}`]:[]}}},zoom:{pan:{enabled:!0,mode:"x",modifierKey:"ctrl"},zoom:{wheel:{enabled:!0,speed:.1},pinch:{enabled:!0},mode:"x"},limits:{x:{min:"original",max:"original"}}},annotation:{annotations:this.createAnnotations(r,n)}},scales:{x:{type:0===this.rangeBack?"time":"linear",min:0===this.rangeBack?l:void 0,max:0===this.rangeBack?c:void 0,time:0===this.rangeBack?{unit:"hour",stepSize:1,displayFormats:{hour:"h:mm a"},tooltipFormat:"MMM d, h:mm a"}:void 0,grid:{display:!1},ticks:{maxTicksLimit:0===this.rangeBack?10:8,color:"#6b7280",autoSkip:!0,maxRotation:0,minRotation:0,callback:(t,e,n)=>{if(this.rangeBack>0){const e=Math.round(t),n=r[e];if(n){return new Date(n.time).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0})}return""}if("number"==typeof t){return new Date(t).toLocaleString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}return t}}},y:{position:"right",grid:{color:"rgba(0, 0, 0, 0.05)"},ticks:{color:"#6b7280",callback:function(t){return"$"+t.toFixed(2)}},afterDataLimits:t=>{const e=.1*(t.max-t.min);t.max+=e,t.min-=e}}}}};console.log("[IntradayChartWidget] Creating Chart.js instance with config:",d),console.log("[IntradayChartWidget] Chart available?",void 0!==ro);try{this.chartInstance=new ro(e,d),console.log("[IntradayChartWidget] Chart instance created successfully:",this.chartInstance)}catch(t){throw console.error("[IntradayChartWidget] Error creating chart:",t),t}t.addEventListener("mouseenter",(()=>{this.isUserInteracting=!0})),t.addEventListener("mouseleave",(()=>{this.isUserInteracting=!1})),this.setupZoomReset()}createAnnotations(t,e){const n={livePriceLine:{type:"line",scaleID:"y",value:this.livePrice||e.close,borderColor:"#667eea",borderWidth:2,borderDash:[5,5],label:{display:!0,content:this.livePrice?`$${this.livePrice.toFixed(2)}`:`$${e.close.toFixed(2)}`,enabled:!0,position:"end",backgroundColor:"rgb(102, 126, 234)",color:"#ffffff",font:{size:12,weight:"bold",family:"system-ui, -apple-system, sans-serif"},padding:{top:4,bottom:4,left:8,right:8},borderRadius:4,xAdjust:-10,yAdjust:0}}};if(this.rangeBack>0&&t.length>0){let e=null;t.forEach(((t,i)=>{const s=new Date(t.time).toDateString();e!==s&&null!==e&&(n[`daySeparator${i}`]={type:"line",scaleID:"x",value:i,borderColor:"rgba(0, 0, 0, 0.1)",borderWidth:1,borderDash:[3,3]}),e=s}))}return n}setupZoomReset(){const t=this.container.querySelector(".zoom-reset-btn");t&&t.addEventListener("click",(()=>{this.chartInstance&&(this.chartInstance.resetZoom(),this.debug&&console.log("[IntradayChartWidget] Zoom reset"))}))}updateStats(){if(!this.chartData)return;const t=this.chartData.getStats(),e=this.container.querySelector(".stat-high .stat-value"),n=this.container.querySelector(".stat-low .stat-value"),i=this.container.querySelector(".stat-open .stat-value"),s=this.container.querySelector(".stat-close .stat-value"),o=this.container.querySelector(".stat-volume .stat-value"),a=this.container.querySelector(".chart-change");if(e&&(e.textContent=`$${t.high.toFixed(2)}`),n&&(n.textContent=`$${t.low.toFixed(2)}`),i&&(i.textContent=`$${t.open.toFixed(2)}`),s&&(s.textContent=`$${t.close.toFixed(2)}`),o&&(o.textContent=this.chartData.formatVolume(t.volume)),a){const e=t.change>=0?"positive":"negative";a.className=`chart-change ${e}`;const n=t.change>=0?"+":"";a.textContent=`${n}${t.change.toFixed(2)} (${n}${t.changePercent.toFixed(2)}%)`}}async refreshData(){await this.loadChartData()}destroy(){this.stopAutoRefresh(),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null),this.chartInstance&&(this.chartInstance.destroy(),this.chartInstance=null),this.symbolEditor&&(this.symbolEditor.destroy(),this.symbolEditor=null),super.destroy()}}class $u{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.dataSource="",Array.isArray(t)?this.parseMMIDArray(t):(this.symbol=t.Symbol||"",this.timestamp=t.Timestamp||t.QuoteTime||"",this.dataSource=t.DataSource||"",this.bids=this.parseLevels(t.Bids||t.bids||[]),this.asks=this.parseLevels(t.Asks||t.asks||[]),0===this.bids.length&&t.BidPx&&t.BidPx>0&&(this.bids=[{mmid:t.BidExch||"BLUE",price:parseFloat(t.BidPx),size:parseInt(t.BidSz||0,10)}]),0===this.asks.length&&t.AskPx&&t.AskPx>0&&(this.asks=[{mmid:t.AskExch||"BLUE",price:parseFloat(t.AskPx),size:parseInt(t.AskSz||0,10)}])),this.bestBid=this.bids.length>0?this.bids[0].price:0,this.bestAsk=this.asks.length>0?this.asks[0].price:0,this.midPrice=this.bestBid&&this.bestAsk?(this.bestBid+this.bestAsk)/2:0,this.spread=this.bestBid&&this.bestAsk?this.bestAsk-this.bestBid:0}parseMMIDArray(t){this.symbol="",this.timestamp=t[0]?.BidTime||t[0]?.AskTime||"",this.dataSource=t[0]?.DataSource||"ONBBO",this.bids=[],this.asks=[];let e=0,n=0;t.forEach((t=>{const i=t.MMID||"";if(void 0!==t.BidPx&&null!==t.BidPx){const n=parseFloat(t.BidPx);this.bids.push({mmid:i,price:n,size:parseInt(t.BidSz||0,10)}),n>0&&e++}if(void 0!==t.AskPx&&null!==t.AskPx){const e=parseFloat(t.AskPx);this.asks.push({mmid:i,price:e,size:parseInt(t.AskSz||0,10)}),e>0&&n++}})),this.bids.sort(((t,e)=>e.price-t.price)),this.asks.sort(((t,e)=>t.price-e.price)),console.log(`[ONBBOLevel2Model] Parsed ${t.length} MMID quotes: ${e} valid bids, ${n} valid asks`)}parseLevels(t){return Array.isArray(t)?t.map((t=>({mmid:t.MMID||t.mmid||"",price:parseFloat(t.Price||t.price||0),size:parseInt(t.Size||t.size||0,10)}))).filter((t=>t.price>0)):[]}getTopBids(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;return this.bids.slice(0,t)}getTopAsks(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;return this.asks.slice(0,t)}getBidColorIntensity(t){if(!this.bestBid||0===this.bids.length)return 0;if(t===this.bestBid)return 1;const e=this.bestBid-t,n=this.bids.length>0?this.bestBid-this.bids[this.bids.length-1].price:0;return 0===n?.5:Math.max(0,1-e/n)}getAskColorIntensity(t){if(!this.bestAsk||0===this.asks.length)return 0;if(t===this.bestAsk)return 1;const e=t-this.bestAsk,n=this.asks.length>0?this.asks[this.asks.length-1].price-this.bestAsk:0;return 0===n?.5:Math.max(0,1-e/n)}formatPrice(t){return t.toFixed(2)}formatSize(t){return t.toLocaleString()}formatSpread(){return this.spread.toFixed(2)}getTotalBidSize(){return this.bids.reduce(((t,e)=>t+e.size),0)}getTotalAskSize(){return this.asks.reduce(((t,e)=>t+e.size),0)}static fromApiResponse(t){return new $u(t)}}class Ru extends n{constructor(t,e,n){if(super(t,e,n),!e.symbol)throw new Error("Symbol is required for ONBBOLevel2Widget");if(!e.wsManager)throw new Error("WebSocketManager is required for ONBBOLevel2Widget");this.type="onbbo-level2";const i=f(e.symbol);if(!i.valid)throw new Error(`Invalid symbol: ${i.error}`);this.symbol=i.sanitized,this.wsManager=e.wsManager,this.debug=e.debug||!1,this.styled=void 0===e.styled||e.styled,this.maxLevels=e.maxLevels||10,this.data=null,this.level1Data=null,this.isDestroyed=!1,this.unsubscribeL2=null,this.unsubscribeL1=null,this.symbolEditor=null,this.loadingTimeout=null,this.companyName="",this.exchangeName="",this.createWidgetStructure(),this.initialize()}createWidgetStructure(){if(this.container.innerHTML='\n<div class="onbbo-level2-widget widget">\n <div class="widget-loading-overlay hidden">\n <div class="loading-content">\n <div class="loading-spinner"></div>\n <div class="loading-text">Loading order book...</div>\n </div>\n </div>\n\n <div class="widget-header">\n <div class="symbol-section">\n <div class="company-market-info">\n <span class="l2-company-name"></span>\n <span class="l2-market-name"></span>\n </div>\n <span class="symbol editable-symbol">--</span>\n <div class="level1-info">\n <div class="l1-item">\n <span class="l1-label">Last:</span>\n <span class="l1-value l1-last-px">--</span>\n </div>\n <div class="l1-item">\n <span class="l1-label">Low:</span>\n <span class="l1-value l1-low-px">--</span>\n </div>\n <div class="l1-item">\n <span class="l1-label">High:</span>\n <span class="l1-value l1-high-px">--</span>\n </div>\n <div class="l1-item">\n <span class="l1-label">Volume:</span>\n <span class="l1-value l1-volume">--</span>\n </div>\n </div>\n </div>\n </div>\n\n <div class="orderbook-container">\n \x3c!-- Bid Panel (Left) --\x3e\n <div class="orderbook-panel bid-panel">\n <div class="panel-header">\n <div class="col-header mmid-col">MMID</div>\n <div class="col-header bid-col">BID</div>\n <div class="col-header size-col">SIZE</div>\n </div>\n <div class="panel-body bid-body">\n \x3c!-- Bid levels will be dynamically inserted here --\x3e\n </div>\n </div>\n\n \x3c!-- Ask Panel (Right) --\x3e\n <div class="orderbook-panel ask-panel">\n <div class="panel-header">\n <div class="col-header mmid-col">MMID</div>\n <div class="col-header ask-col">ASK</div>\n <div class="col-header size-col">SIZE</div>\n </div>\n <div class="panel-body ask-body">\n \x3c!-- Ask levels will be dynamically inserted here --\x3e\n </div>\n </div>\n </div>\n\n <div class="widget-footer">\n <span class="last-update">Last update: --</span>\n <span class="data-source">Source: ONBBO</span>\n </div>\n</div>\n',this.styled){const t=this.container.querySelector(".onbbo-level2-widget");t&&t.classList.add("widget-styled")}this.addStyles(),this.setupSymbolEditor()}addStyles(){if(!document.querySelector("#onbbo-level2-styles")){const t=document.createElement("style");t.id="onbbo-level2-styles",t.textContent="\n.onbbo-level2-widget {\n border: 1px solid #e5e7eb;\n border-radius: 8px;\n background: white;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n font-size: 13px;\n max-width: 100%;\n overflow: hidden;\n position: relative;\n}\n\n.onbbo-level2-widget .widget-header {\n background: white;\n padding: 16px;\n border-bottom: 1px solid #e5e7eb;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n.onbbo-level2-widget .symbol-section {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n.onbbo-level2-widget .company-market-info {\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: 0.86em;\n color: #6b7280;\n}\n\n.onbbo-level2-widget .l2-company-name {\n font-weight: 600;\n color: #374151;\n}\n\n.onbbo-level2-widget .l2-market-name {\n font-weight: 500;\n color: #6b7280;\n}\n\n.onbbo-level2-widget .l2-market-name::before {\n content: '|';\n margin-right: 8px;\n color: #d1d5db;\n}\n\n.onbbo-level2-widget .symbol {\n font-size: 1.71em;\n font-weight: 700;\n color: #111827;\n}\n\n.onbbo-level2-widget .data-type {\n background: #dbeafe;\n padding: 4px 10px;\n border-radius: 6px;\n font-size: 0.86em;\n font-weight: 600;\n color: #1e40af;\n}\n\n.onbbo-level2-widget .spread-section {\n text-align: right;\n}\n\n.onbbo-level2-widget .spread-label {\n font-size: 0.86em;\n color: #6b7280;\n font-weight: 500;\n margin-bottom: 4px;\n}\n\n.onbbo-level2-widget .spread-value {\n font-size: 1.29em;\n font-weight: 700;\n color: #111827;\n}\n\n/* ========================================\n LEVEL 1 INFO (INSIDE HEADER)\n ======================================== */\n\n.onbbo-level2-widget .level1-info {\n display: grid;\n grid-template-columns: repeat(4, 1fr);\n gap: 12px;\n margin-top: 10px;\n}\n\n.onbbo-level2-widget .l1-item {\n display: flex;\n flex-direction: column;\n gap: 3px;\n}\n\n.onbbo-level2-widget .l1-label {\n font-size: 11px;\n font-weight: 600;\n color: #6b7280;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n}\n\n.onbbo-level2-widget .l1-value {\n font-size: 15px;\n font-weight: 700;\n color: #111827;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n}\n\n/* ========================================\n ORDER BOOK CONTAINER\n ======================================== */\n\n.onbbo-level2-widget .orderbook-container {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 0;\n}\n\n.onbbo-level2-widget .orderbook-panel {\n border-right: 1px solid #e5e7eb;\n overflow: hidden;\n background: white;\n}\n\n.onbbo-level2-widget .orderbook-panel:last-child {\n border-right: none;\n}\n\n/* ========================================\n PANEL HEADERS\n ======================================== */\n\n.onbbo-level2-widget .panel-header {\n display: grid;\n grid-template-columns: 80px 1fr 80px;\n background: #f3f4f6;\n padding: 8px 4px;\n font-size: 11px;\n font-weight: 700;\n color: #374151;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n border-bottom: 2px solid #d1d5db;\n position: sticky;\n top: 0;\n z-index: 10;\n}\n\n.onbbo-level2-widget .col-header {\n text-align: center;\n padding: 0 4px;\n}\n\n/* ========================================\n PANEL BODY - SCROLLABLE AREA\n ======================================== */\n\n.onbbo-level2-widget .panel-body {\n min-height: 300px;\n max-height: 400px;\n overflow-y: auto;\n}\n\n/* Custom scrollbar */\n.onbbo-level2-widget .panel-body::-webkit-scrollbar {\n width: 6px;\n}\n\n.onbbo-level2-widget .panel-body::-webkit-scrollbar-track {\n background: #f3f4f6;\n}\n\n.onbbo-level2-widget .panel-body::-webkit-scrollbar-thumb {\n background: #9ca3af;\n border-radius: 3px;\n}\n\n.onbbo-level2-widget .panel-body::-webkit-scrollbar-thumb:hover {\n background: #6b7280;\n}\n\n/* ========================================\n ORDER BOOK ROWS\n ======================================== */\n\n.onbbo-level2-widget .level-row {\n display: grid;\n grid-template-columns: 80px 1fr 80px;\n padding: 6px 4px;\n border-bottom: 1px solid #f3f4f6;\n transition: background-color 0.15s ease;\n min-height: 32px;\n}\n\n.onbbo-level2-widget .level-row:hover {\n filter: brightness(0.95);\n}\n\n.onbbo-level2-widget .level-row > div {\n padding: 0 6px;\n text-align: center;\n font-size: 12px;\n font-weight: 400;\n display: flex;\n align-items: center;\n justify-content: center;\n color: #111827;\n}\n\n/* ========================================\n COLOR SCHEME FOR BIDS (GREEN/YELLOW)\n Based on the image provided\n ======================================== */\n\n/* Best bid - brightest yellow */\n.onbbo-level2-widget .bid-row.intensity-100 {\n background: #fef08a; /* Yellow-200 */\n color: #713f12;\n}\n\n.onbbo-level2-widget .bid-row.intensity-100 > div {\n color: #713f12;\n}\n\n/* Very competitive bids */\n.onbbo-level2-widget .bid-row.intensity-90,\n.onbbo-level2-widget .bid-row.intensity-80 {\n background: #fef9c3; /* Yellow-100 */\n color: #854d0e;\n}\n\n.onbbo-level2-widget .bid-row.intensity-90 > div,\n.onbbo-level2-widget .bid-row.intensity-80 > div {\n color: #854d0e;\n}\n\n/* Competitive bids */\n.onbbo-level2-widget .bid-row.intensity-70,\n.onbbo-level2-widget .bid-row.intensity-60 {\n background: #d9f99d; /* Lime-200 */\n color: #3f6212;\n}\n\n.onbbo-level2-widget .bid-row.intensity-70 > div,\n.onbbo-level2-widget .bid-row.intensity-60 > div {\n color: #3f6212;\n}\n\n/* Standard bids - light green */\n.onbbo-level2-widget .bid-row.intensity-50,\n.onbbo-level2-widget .bid-row.intensity-40 {\n background: #bbf7d0; /* Green-200 */\n color: #14532d;\n}\n\n.onbbo-level2-widget .bid-row.intensity-50 > div,\n.onbbo-level2-widget .bid-row.intensity-40 > div {\n color: #14532d;\n}\n\n/* Lower bids - darker green */\n.onbbo-level2-widget .bid-row.intensity-30,\n.onbbo-level2-widget .bid-row.intensity-20,\n.onbbo-level2-widget .bid-row.intensity-10 {\n background: #86efac; /* Green-300 */\n color: #14532d;\n}\n\n.onbbo-level2-widget .bid-row.intensity-30 > div,\n.onbbo-level2-widget .bid-row.intensity-20 > div,\n.onbbo-level2-widget .bid-row.intensity-10 > div {\n color: #14532d;\n}\n\n/* ========================================\n COLOR SCHEME FOR ASKS (RED/YELLOW)\n Based on the image provided\n ======================================== */\n\n/* Best ask - brightest yellow */\n.onbbo-level2-widget .ask-row.intensity-100 {\n background: #fef08a; /* Yellow-200 */\n color: #713f12;\n}\n\n.onbbo-level2-widget .ask-row.intensity-100 > div {\n color: #713f12;\n}\n\n/* Very competitive asks */\n.onbbo-level2-widget .ask-row.intensity-90,\n.onbbo-level2-widget .ask-row.intensity-80 {\n background: #fef9c3; /* Yellow-100 */\n color: #854d0e;\n}\n\n.onbbo-level2-widget .ask-row.intensity-90 > div,\n.onbbo-level2-widget .ask-row.intensity-80 > div {\n color: #854d0e;\n}\n\n/* Competitive asks */\n.onbbo-level2-widget .ask-row.intensity-70,\n.onbbo-level2-widget .ask-row.intensity-60 {\n background: #fecaca; /* Red-200 */\n color: #7f1d1d;\n}\n\n.onbbo-level2-widget .ask-row.intensity-70 > div,\n.onbbo-level2-widget .ask-row.intensity-60 > div {\n color: #7f1d1d;\n}\n\n/* Standard asks - light red */\n.onbbo-level2-widget .ask-row.intensity-50,\n.onbbo-level2-widget .ask-row.intensity-40 {\n background: #fca5a5; /* Red-300 */\n color: #7f1d1d;\n}\n\n.onbbo-level2-widget .ask-row.intensity-50 > div,\n.onbbo-level2-widget .ask-row.intensity-40 > div {\n color: #7f1d1d;\n}\n\n/* Higher asks - darker red */\n.onbbo-level2-widget .ask-row.intensity-30,\n.onbbo-level2-widget .ask-row.intensity-20,\n.onbbo-level2-widget .ask-row.intensity-10 {\n background: #f87171; /* Red-400 */\n color: #450a0a;\n}\n\n.onbbo-level2-widget .ask-row.intensity-30 > div,\n.onbbo-level2-widget .ask-row.intensity-20 > div,\n.onbbo-level2-widget .ask-row.intensity-10 > div {\n color: #450a0a;\n}\n\n/* ========================================\n PANEL FOOTERS\n ======================================== */\n\n.onbbo-level2-widget .panel-footer {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 10px 12px;\n background: #f9fafb;\n border-top: 2px solid #d1d5db;\n font-size: 11px;\n font-weight: 600;\n}\n\n.onbbo-level2-widget .bid-panel .panel-footer {\n color: #065f46;\n}\n\n.onbbo-level2-widget .ask-panel .panel-footer {\n color: #991b1b;\n}\n\n.onbbo-level2-widget .footer-label {\n font-weight: 500;\n color: #6b7280;\n}\n\n.onbbo-level2-widget .footer-value {\n font-family: 'Courier New', Courier, monospace;\n font-weight: 700;\n}\n\n/* ========================================\n WIDGET FOOTER\n ======================================== */\n\n.onbbo-level2-widget .widget-footer {\n background: #f9fafb;\n padding: 8px 16px;\n border-top: 1px solid #e5e7eb;\n display: flex;\n justify-content: space-between;\n align-items: center;\n font-size: 11px;\n color: #6b7280;\n}\n\n.onbbo-level2-widget .data-source {\n font-weight: 600;\n color: #374151;\n}\n\n/* ========================================\n NO DATA / EMPTY STATE\n ======================================== */\n\n.onbbo-level2-widget .empty-book {\n padding: 40px 20px;\n text-align: center;\n color: #6b7280;\n font-style: italic;\n}\n\n/* ========================================\n INACTIVE QUOTES (zero prices)\n ======================================== */\n\n.onbbo-level2-widget .inactive-quote {\n background: #f9fafb !important;\n opacity: 0.7;\n}\n\n.onbbo-level2-widget .inactive-quote > div {\n color: #9ca3af !important;\n font-style: italic;\n}\n\n.onbbo-level2-widget .inactive-quote:hover {\n opacity: 0.85;\n}\n\n/* ========================================\n LOADING STATE\n ======================================== */\n\n.onbbo-level2-widget .widget-loading-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(255, 255, 255, 0.9);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 20;\n}\n\n.onbbo-level2-widget .widget-loading-overlay.hidden {\n display: none;\n}\n\n.onbbo-level2-widget .loading-content {\n text-align: center;\n}\n\n.onbbo-level2-widget .loading-spinner {\n width: 32px;\n height: 32px;\n border: 3px solid #e5e7eb;\n border-top: 3px solid #3b82f6;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin: 0 auto 12px;\n}\n\n@keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n}\n\n.onbbo-level2-widget .no-data-state {\n padding: 40px;\n text-align: center;\n color: #6b7280;\n}\n\n.onbbo-level2-widget .widget-error {\n padding: 20px;\n background: #fef2f2;\n color: #dc2626;\n border: 1px solid #fecaca;\n margin: 16px;\n border-radius: 4px;\n text-align: center;\n}\n\n/* ========================================\n RESPONSIVE DESIGN\n ======================================== */\n\n@media (max-width: 768px) {\n .onbbo-level2-widget .orderbook-container {\n grid-template-columns: 1fr;\n gap: 16px;\n }\n\n .onbbo-level2-widget .panel-body {\n max-height: 250px;\n }\n\n .onbbo-level2-widget .orderbook-panel {\n border-right: none;\n border-bottom: 1px solid #e5e7eb;\n }\n\n .onbbo-level2-widget .orderbook-panel:last-child {\n border-bottom: none;\n }\n\n .onbbo-level2-widget .level1-info {\n grid-template-columns: repeat(2, 1fr);\n gap: 6px;\n }\n}\n\n@media (max-width: 480px) {\n .onbbo-level2-widget {\n font-size: 12px;\n }\n\n .onbbo-level2-widget .widget-header {\n padding: 12px;\n flex-direction: column;\n align-items: flex-start;\n gap: 8px;\n }\n\n .onbbo-level2-widget .spread-section {\n text-align: left;\n }\n\n .onbbo-level2-widget .level1-info {\n grid-template-columns: repeat(2, 1fr);\n gap: 4px;\n }\n\n .onbbo-level2-widget .l1-label {\n font-size: 9px;\n }\n\n .onbbo-level2-widget .l1-value {\n font-size: 11px;\n }\n\n .onbbo-level2-widget .panel-header {\n font-size: 10px;\n padding: 6px 2px;\n }\n\n .onbbo-level2-widget .level-row {\n grid-template-columns: 60px 1fr 60px;\n padding: 4px 2px;\n font-size: 11px;\n }\n\n .onbbo-level2-widget .level-row > div {\n padding: 0 4px;\n }\n\n .onbbo-level2-widget .panel-footer {\n font-size: 10px;\n padding: 8px 10px;\n }\n\n .onbbo-level2-widget .panel-body {\n max-height: 200px;\n }\n}\n",document.head.appendChild(t)}}setupSymbolEditor(){this.symbolEditor=new s(this,{maxLength:10,placeholder:"Enter symbol...",onSymbolChange:this.handleSymbolChange.bind(this),debug:this.debug,autoUppercase:!0,cancelOnBlur:!1,symbolType:"quotel1"})}async handleSymbolChange(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.debug&&console.log("[ONBBOLevel2Widget] Symbol change requested:",t);const i=f(t);if(!i.valid)return this.debug&&console.log("[ONBBOLevel2Widget] Invalid symbol:",i.error),{success:!1,error:i.error};const s=i.sanitized;if(n&&(this.companyName=n.comp_name||"",this.exchangeName=n.market_name||""),s===this.symbol)return this.debug&&console.log("[ONBBOLevel2Widget] Same symbol, no change needed"),{success:!0};try{return this.showLoading(),this.loadingTimeout&&this.clearTimeout(this.loadingTimeout),this.loadingTimeout=this.setTimeout((()=>{this.debug&&console.log("[ONBBOLevel2Widget] Loading timeout for symbol:",s),this.hideLoading(),this.showError(`No data received for ${s}. Please try again.`)}),1e4),this.unsubscribeL2&&(this.debug&&console.log(`[ONBBOLevel2Widget] Unsubscribing from ${this.symbol} L2`),this.wsManager.sendUnsubscribe("queryonbbol2",this.symbol),this.unsubscribeL2(),this.unsubscribeL2=null),this.unsubscribeL1&&(this.debug&&console.log(`[ONBBOLevel2Widget] Unsubscribing from ${this.symbol} L1`),this.wsManager.sendUnsubscribe("queryonbbol1",this.symbol),this.unsubscribeL1(),this.unsubscribeL1=null),this.symbol=s,this.debug&&console.log(`[ONBBOLevel2Widget] Subscribing to ${s}`),this.subscribeToData(),{success:!0}}catch(t){return console.error("[ONBBOLevel2Widget] Error changing symbol:",t),this.showError(`Failed to load data for ${s}`),{success:!1,error:`Failed to load ${s}`}}}async initialize(){this.showLoading();!1!==await super.validateInitialSymbol("quotel1",this.symbol,(t=>{t&&t[0]&&(this.companyName=t[0].comp_name||"",this.exchangeName=t[0].market_name||"")}))&&(this.loadingTimeout=setTimeout((()=>{this.debug&&console.log("[ONBBOLevel2Widget] Loading timeout - no data received for:",this.symbol),this.hideLoading(),this.showError("No Level 2 data available for this symbol")}),1e4),this.subscribeToData())}subscribeToData(){this.unsubscribeL2=this.wsManager.subscribe(`${this.widgetId}-l2`,["queryonbbol2"],(t=>{const{event:e,data:n}=t;"connection"!==e?"data"===e&&(n._dataType="level2",this.handleMessage({event:e,data:n})):this.handleConnectionStatus(n)}),this.symbol),this.unsubscribeL1=this.wsManager.subscribe(`${this.widgetId}-l1`,["queryonbbol1"],(t=>{const{event:e,data:n}=t;"connection"!==e&&"data"===e&&(n._dataType="level1",this.handleMessage({event:e,data:n}))}),this.symbol)}handleData(t){this.loadingTimeout&&(clearTimeout(this.loadingTimeout),this.loadingTimeout=null);const e=t._dataType;if(this.debug&&console.log(`[ONBBOLevel2Widget] handleData called with type: ${e}`,t),"error"===t.type||1==t.error){const e=t.message||"Server error";return this.debug&&console.log("[ONBBOLevel2Widget] Error:",e),void this.showError(e)}if("queryonbbol1"!==t.type){if(Array.isArray(t.data)){if(t.data.length>0&&t.data[0].MMID){this.debug&&console.log("[ONBBOLevel2Widget] Received MMID array:",t);const e=new $u(t.data);return e.symbol=this.symbol,this.data=e,void this.updateWidget(e)}const e=t.data.find((t=>t.Symbol===this.symbol));if(e){if(!0===e.NotFound)this.showError(`No Level 2 data available for ${this.symbol}`);else{const t=new $u(e);this.data=t,this.updateWidget(t)}return}this.showError(`No Level 2 data available for ${this.symbol}`)}}else{if(this.debug&&console.log("[ONBBOLevel2Widget] Processing Level 1 data:",t),t.data&&Array.isArray(t.data)){const e=t.data.find((t=>t.Symbol===this.symbol));e&&(this.level1Data={lastPx:e.LastPx||0,lowPx:e.LowPx||0,highPx:e.HighPx||0,volume:e.Volume||0},this.updateLevel1Display())}else if(Array.isArray(t)){const e=t.find((t=>t.Symbol===this.symbol));e&&(this.level1Data={lastPx:e.LastPx||0,lowPx:e.LowPx||0,highPx:e.HighPx||0,volume:e.Volume||0},this.updateLevel1Display())}delete t._dataType}}updateWidget(t){if(!this.isDestroyed)try{this.hideLoading(),this.clearError();const e=this.container.querySelector(".l2-company-name");e&&this.companyName&&(e.textContent=this.companyName);const n=this.container.querySelector(".l2-market-name");n&&this.exchangeName&&(n.textContent=this.exchangeName);const i=this.container.querySelector(".symbol");i&&(i.textContent=t.symbol),this.updateBidPanel(t),this.updateAskPanel(t);const s=x(new Date(t.timestamp||Date.now())),o=this.container.querySelector(".last-update");if(o&&(o.textContent=`Last update: ${s}`),t.dataSource){const e=this.container.querySelector(".data-source");e&&(e.textContent=`Source: ${t.dataSource}`)}}catch(t){console.error("[ONBBOLevel2Widget] Error updating widget:",t),this.showError("Error updating data")}}updateBidPanel(t){const e=this.container.querySelector(".bid-body");if(!e)return;e.innerHTML="";const n=t.getTopBids(this.maxLevels);0!==n.length?n.forEach((n=>{const i=t.getBidColorIntensity(n.price),s=u("div","",`level-row bid-row ${`intensity-${Math.round(100*i)}`} ${0===n.price?"inactive-quote":""}`),o=u("div",p(n.mmid)),a=u("div",t.formatPrice(n.price)),r=u("div",t.formatSize(n.size));s.appendChild(o),s.appendChild(a),s.appendChild(r),e.appendChild(s)})):e.innerHTML='<div class="empty-book">No bid data available</div>'}updateAskPanel(t){const e=this.container.querySelector(".ask-body");if(!e)return;e.innerHTML="";const n=t.getTopAsks(this.maxLevels);0!==n.length?n.forEach((n=>{const i=t.getAskColorIntensity(n.price),s=u("div","",`level-row ask-row ${`intensity-${Math.round(100*i)}`} ${0===n.price?"inactive-quote":""}`),o=u("div",p(n.mmid)),a=u("div",t.formatPrice(n.price)),r=u("div",t.formatSize(n.size));s.appendChild(o),s.appendChild(a),s.appendChild(r),e.appendChild(s)})):e.innerHTML='<div class="empty-book">No ask data available</div>'}updateLevel1Display(){if(!this.level1Data)return;const t=t=>t?t.toFixed(2):"--",e=this.container.querySelector(".l1-last-px");e&&(e.textContent=t(this.level1Data.lastPx));const n=this.container.querySelector(".l1-low-px");n&&(n.textContent=t(this.level1Data.lowPx));const i=this.container.querySelector(".l1-high-px");i&&(i.textContent=t(this.level1Data.highPx));const s=this.container.querySelector(".l1-volume");var o;s&&(s.textContent=(o=this.level1Data.volume)?o.toLocaleString():"--"),this.debug&&console.log("[ONBBOLevel2Widget] Updated Level 1 display:",this.level1Data)}showLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.remove("hidden")}hideLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.add("hidden")}showError(t){this.hideLoading(),this.clearError();const e=document.createElement("div");e.className="widget-error",e.textContent=`Error: ${t}`,e.style.cssText="\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n padding: 15px 20px;\n background: #fee;\n border: 1px solid #f5c6cb;\n border-radius: 6px;\n color: #721c24;\n text-align: center;\n font-size: 14px;\n z-index: 100;\n ",this.container.appendChild(e)}clearError(){const t=this.container.querySelector(".widget-error");t&&t.remove()}destroy(){this.isDestroyed=!0,this.loadingTimeout&&(this.clearTimeout(this.loadingTimeout),this.loadingTimeout=null),this.unsubscribeL2&&(this.unsubscribeL2(),this.unsubscribeL2=null),this.unsubscribeL1&&(this.unsubscribeL1(),this.unsubscribeL1=null),this.symbolEditor&&(this.symbolEditor.destroy(),this.symbolEditor=null),super.destroy()}}class Fu{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20;this.maxTrades=e,this.trades=[],this.dataSource="",Array.isArray(t)&&t.length>0?(this.symbol=t[0].Symbol||"",this.dataSource=t[0].DataSource||"",this.addTrades(t)):this.symbol=""}addTrades(t){if(!Array.isArray(t))return;t.length>0&&t[0].DataSource&&(this.dataSource=t[0].DataSource);const e=this.parseTrades(t);this.trades=[...e,...this.trades],this.trades.length>this.maxTrades&&(this.trades=this.trades.slice(0,this.maxTrades))}setTrades(t){Array.isArray(t)&&(this.trades=this.parseTrades(t).slice(0,this.maxTrades),t.length>0&&(this.symbol=t[0].Symbol||this.symbol))}parseTrades(t){return Array.isArray(t)?t.map((t=>{const e=t.ActivityTimestamp||t.time||"";return{time:e,price:parseFloat(t.TradePx||t.price||0),size:parseInt(t.TradeSz||t.size||0,10),source:t.TradeRegion||t.source||t.DataSource||"",timestamp:e?new Date(e).getTime():0}})).filter((t=>t.price>0)).sort(((t,e)=>e.timestamp-t.timestamp)):[]}getTrades(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return t?this.trades.slice(0,t):this.trades}formatPrice(t){return t.toFixed(2)}formatSize(t){return t.toLocaleString()}formatTime(t){if(!t)return"--";try{if(t.includes("T")){const e=t.split("T")[1];if(e){return e.split(/[+\-Z]/)[0]}}if(t.includes(" ")){const e=t.split(" ");if(e.length>=2)return e[1]}return/^\d{2}:\d{2}:\d{2}/.test(t),t}catch(e){return t}}getTotalVolume(){return this.trades.reduce(((t,e)=>t+e.size),0)}getLatestTrade(){return this.trades.length>0?this.trades[0]:null}clear(){this.trades=[]}static fromApiResponse(t){return new Fu(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:20)}}class Bu extends n{constructor(t,e,n){if(super(t,e,n),!e.symbol)throw new Error("Symbol is required for TimeSalesWidget");if(!e.wsManager)throw new Error("WebSocketManager is required for TimeSalesWidget");this.type="time-sales";const i=f(e.symbol);if(!i.valid)throw new Error(`Invalid symbol: ${i.error}`);this.symbol=i.sanitized,this.wsManager=e.wsManager,this.debug=e.debug||!1,this.styled=void 0===e.styled||e.styled,this.maxTrades=e.maxTrades||20,this.data=new Fu([],this.maxTrades),this.data.symbol=this.symbol,this.isDestroyed=!1,this.unsubscribe=null,this.symbolEditor=null,this.loadingTimeout=null,this.companyName="",this.exchangeName="",this.createWidgetStructure(),this.initializeSymbolEditor(),this.initialize()}createWidgetStructure(){if(this.container.innerHTML='\n<div class="time-sales-widget widget">\n <div class="widget-loading-overlay hidden">\n <div class="loading-content">\n <div class="loading-spinner"></div>\n <div class="loading-text">Loading Time & Sales...</div>\n </div>\n </div>\n\n <div class="widget-header">\n <div class="symbol-section">\n <div class="company-market-info">\n <span class="ts-company-name"></span>\n <span class="ts-market-name"></span>\n </div>\n <span class="symbol editable-symbol">--</span>\n </div>\n </div>\n\n <div class="trades-container">\n <div class="trades-panel">\n <div class="panel-header">\n <div class="col-header time-col">TIME</div>\n <div class="col-header price-col">PRICE</div>\n <div class="col-header size-col">SIZE</div>\n <div class="col-header source-col">SOURCE</div>\n </div>\n <div class="panel-body trades-body">\n \x3c!-- Trade rows will be dynamically inserted here --\x3e\n </div>\n </div>\n </div>\n\n <div class="widget-footer">\n <span class="last-update">Last update: --</span>\n <span class="data-source">Time & Sales</span>\n </div>\n</div>\n',this.styled){const t=this.container.querySelector(".time-sales-widget");t&&t.classList.add("widget-styled")}this.addStyles()}initializeSymbolEditor(){this.symbolEditor=new s(this,{maxLength:10,placeholder:"Enter symbol...",onSymbolChange:this.handleSymbolChange.bind(this),debug:this.debug,autoUppercase:!0,symbolType:"quotel1"});const t=this.container.querySelector(".symbol");t&&(t.textContent=this.symbol,t.dataset.originalSymbol=this.symbol)}addStyles(){if(!document.querySelector("#time-sales-styles")){const t=document.createElement("style");t.id="time-sales-styles",t.textContent="\n.time-sales-widget {\n border: 1px solid #e5e7eb;\n border-radius: 8px;\n background: white;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n font-size: 13px;\n max-width: 100%;\n overflow: hidden;\n position: relative;\n}\n\n.time-sales-widget .widget-header {\n background: white;\n padding: 16px;\n border-bottom: 1px solid #e5e7eb;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n.time-sales-widget .symbol-section {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n.time-sales-widget .company-market-info {\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: 0.86em;\n color: #6b7280;\n}\n\n.time-sales-widget .ts-company-name {\n font-weight: 600;\n color: #374151;\n}\n\n.time-sales-widget .ts-market-name {\n font-weight: 500;\n color: #6b7280;\n}\n\n.time-sales-widget .ts-market-name::before {\n content: '|';\n margin-right: 8px;\n color: #d1d5db;\n}\n\n.time-sales-widget .symbol {\n font-size: 1.71em;\n font-weight: 700;\n color: #111827;\n}\n\n/* ========================================\n TRADES CONTAINER\n ======================================== */\n\n.time-sales-widget .trades-container {\n background: white;\n margin: 0;\n padding: 0;\n}\n\n.time-sales-widget .trades-panel {\n overflow: hidden;\n margin: 0;\n padding: 0;\n}\n\n/* ========================================\n PANEL HEADER\n ======================================== */\n\n.time-sales-widget .panel-header {\n display: grid;\n grid-template-columns: 120px 1fr 100px 100px;\n background: #f3f4f6;\n padding: 8px 4px;\n font-size: 11px;\n font-weight: 700;\n color: #374151;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n border-bottom: 2px solid #d1d5db;\n position: sticky;\n top: 0;\n z-index: 10;\n}\n\n.time-sales-widget .col-header {\n text-align: center;\n padding: 0 4px;\n}\n\n/* ========================================\n PANEL BODY - SCROLLABLE AREA\n ======================================== */\n\n.time-sales-widget .panel-body {\n min-height: 300px;\n max-height: 500px;\n overflow-y: auto;\n}\n\n/* Custom scrollbar */\n.time-sales-widget .panel-body::-webkit-scrollbar {\n width: 6px;\n}\n\n.time-sales-widget .panel-body::-webkit-scrollbar-track {\n background: #f3f4f6;\n}\n\n.time-sales-widget .panel-body::-webkit-scrollbar-thumb {\n background: #9ca3af;\n border-radius: 3px;\n}\n\n.time-sales-widget .panel-body::-webkit-scrollbar-thumb:hover {\n background: #6b7280;\n}\n\n/* ========================================\n TRADE ROWS\n ======================================== */\n\n.time-sales-widget .trade-row {\n display: grid;\n grid-template-columns: 120px 1fr 100px 100px;\n padding: 8px 4px;\n border-bottom: 1px solid #f3f4f6;\n transition: background-color 0.3s ease;\n min-height: 36px;\n background: white;\n}\n\n.time-sales-widget .trade-row:hover {\n background: #f9fafb;\n}\n\n.time-sales-widget .trade-cell {\n padding: 0 8px;\n text-align: center;\n font-size: 12px;\n font-weight: 400;\n display: flex;\n align-items: center;\n justify-content: center;\n color: #111827;\n}\n\n/* Newest trade highlight */\n.time-sales-widget .trade-row.newest-trade {\n background: #dbeafe;\n animation: fadeHighlight 2s ease-out;\n}\n\n@keyframes fadeHighlight {\n 0% {\n background: #bfdbfe;\n }\n 100% {\n background: #dbeafe;\n }\n}\n\n/* Column specific styling */\n.time-sales-widget .time-cell {\n color: #6b7280;\n font-size: 0.95em;\n}\n\n.time-sales-widget .price-cell {\n color: #111827;\n font-weight: 500;\n font-size: 1.05em;\n}\n\n.time-sales-widget .price-cell.price-up {\n color: #059669;\n}\n\n.time-sales-widget .price-cell.price-down {\n color: #dc2626;\n}\n\n.time-sales-widget .size-cell {\n color: #374151;\n}\n\n.time-sales-widget .source-cell {\n color: #6b7280;\n font-size: 0.95em;\n}\n\n/* ========================================\n WIDGET FOOTER\n ======================================== */\n\n.time-sales-widget .widget-footer {\n background: #f9fafb;\n padding: 8px 16px;\n border-top: 1px solid #e5e7eb;\n display: flex;\n justify-content: space-between;\n align-items: center;\n font-size: 11px;\n color: #6b7280;\n}\n\n.time-sales-widget .data-source {\n font-weight: 600;\n color: #374151;\n}\n\n/* ========================================\n NO DATA / EMPTY STATE\n ======================================== */\n\n.time-sales-widget .empty-trades {\n padding: 40px 20px;\n text-align: center;\n color: #6b7280;\n font-style: italic;\n}\n\n/* ========================================\n LOADING STATE\n ======================================== */\n\n.time-sales-widget .widget-loading-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(255, 255, 255, 0.9);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 20;\n}\n\n.time-sales-widget .widget-loading-overlay.hidden {\n display: none;\n}\n\n.time-sales-widget .loading-content {\n text-align: center;\n}\n\n.time-sales-widget .loading-spinner {\n width: 32px;\n height: 32px;\n border: 3px solid #e5e7eb;\n border-top: 3px solid #3b82f6;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin: 0 auto 12px;\n}\n\n@keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n}\n\n.time-sales-widget .no-data-state {\n padding: 40px;\n text-align: center;\n color: #6b7280;\n}\n\n.time-sales-widget .widget-error {\n padding: 20px;\n background: #fef2f2;\n color: #dc2626;\n border: 1px solid #fecaca;\n margin: 16px;\n border-radius: 4px;\n text-align: center;\n}\n\n/* ========================================\n RESPONSIVE DESIGN\n ======================================== */\n\n@media (max-width: 768px) {\n .time-sales-widget .panel-header {\n grid-template-columns: 100px 1fr 80px 80px;\n font-size: 10px;\n }\n\n .time-sales-widget .trade-row {\n grid-template-columns: 100px 1fr 80px 80px;\n }\n\n .time-sales-widget .panel-body {\n max-height: 400px;\n }\n}\n\n@media (max-width: 480px) {\n .time-sales-widget {\n font-size: 12px;\n }\n\n .time-sales-widget .widget-header {\n padding: 12px;\n }\n\n .time-sales-widget .panel-header {\n grid-template-columns: 80px 1fr 70px 70px;\n font-size: 9px;\n padding: 6px 2px;\n }\n\n .time-sales-widget .trade-row {\n grid-template-columns: 80px 1fr 70px 70px;\n padding: 6px 2px;\n font-size: 11px;\n }\n\n .time-sales-widget .trade-cell {\n padding: 0 4px;\n }\n\n .time-sales-widget .panel-body {\n max-height: 300px;\n }\n\n .time-sales-widget .widget-footer {\n font-size: 10px;\n padding: 6px 12px;\n }\n}\n",document.head.appendChild(t)}}setupSymbolEditor(){this.symbolEditor=new s(this,{maxLength:10,placeholder:"Enter symbol...",onSymbolChange:this.handleSymbolChange.bind(this),debug:this.debug,autoUppercase:!0,cancelOnBlur:!1,symbolType:"quotel1"})}async handleSymbolChange(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.debug&&(console.log("[TimeSalesWidget] Symbol change requested:",t),console.log("[TimeSalesWidget] Validation data:",n));const i=f(t);if(!i.valid)return this.debug&&console.log("[TimeSalesWidget] Invalid symbol:",i.error),{success:!1,error:i.error};const s=i.sanitized;if(n&&(this.companyName=n.comp_name||"",this.exchangeName=n.market_name||"",this.debug&&console.log("[TimeSalesWidget] Extracted company info:",{companyName:this.companyName,exchangeName:this.exchangeName},n)),s===this.symbol)return this.debug&&console.log("[TimeSalesWidget] Same symbol, no change needed"),{success:!0};try{const t=this.symbol;return this.showLoading(),this.loadingTimeout&&this.clearTimeout(this.loadingTimeout),this.loadingTimeout=this.setTimeout((()=>{this.debug&&console.log("[TimeSalesWidget] Loading timeout for symbol:",s),this.hideLoading(),this.showError(`No data received for ${s}. Please try again.`)}),1e4),this.unsubscribe&&(this.debug&&console.log(`[TimeSalesWidget] Unsubscribing from ${t}`),this.unsubscribe(),this.unsubscribe=null),this.symbol=s,this.data.clear(),this.data.symbol=s,this.debug&&console.log(`[TimeSalesWidget] Subscribing to ${s}`),this.subscribeToData(),this.debug&&console.log(`[TimeSalesWidget] Successfully changed symbol from ${t} to ${s}`),{success:!0}}catch(t){return console.error("[TimeSalesWidget] Error changing symbol:",t),this.showError(`Failed to load data for ${s}`),{success:!1,error:`Failed to load ${s}`}}}async initialize(){this.showLoading();!1!==await super.validateInitialSymbol("quotel1",this.symbol,(t=>{t&&t[0]&&(this.companyName=t[0].comp_name||"",this.exchangeName=t[0].market_name||"")}))&&(this.loadingTimeout=setTimeout((()=>{this.debug&&console.log("[TimeSalesWidget] Loading timeout - no data received for:",this.symbol),this.hideLoading(),this.showError("No Time & Sales data available for this symbol")}),1e4),this.subscribeToData())}subscribeToData(){this.unsubscribe=this.wsManager.subscribe(this.widgetId,["queryonbbotimesale"],this.handleMessage.bind(this),this.symbol)}handleData(t){if(this.loadingTimeout&&(clearTimeout(this.loadingTimeout),this.loadingTimeout=null),"queryonbbotimesale"==t.type){if("error"===t.type){const e=t.message||"Server error";return this.debug&&console.log("[TimeSalesWidget] Error:",e),void this.showError(e)}if(Array.isArray(t.data))return this.debug&&console.log("[TimeSalesWidget] Received trades array:",t),this.data.addTrades(t.data),void this.updateWidget();this.debug&&console.log("[TimeSalesWidget] Unexpected message format:",t)}}updateWidget(){if(!this.isDestroyed)try{this.hideLoading(),this.clearError();const t=this.container.querySelector(".ts-company-name");t&&this.companyName&&(t.textContent=this.companyName);const e=this.container.querySelector(".ts-market-name");e&&this.exchangeName&&(e.textContent=this.exchangeName);const n=this.container.querySelector(".symbol");n&&(n.textContent=this.data.symbol),this.updateTradesTable();const i=this.data.getLatestTrade();if(i){const t=x(new Date(i.time)),e=this.container.querySelector(".last-update");e&&(e.textContent=`Last update: ${t}`)}if(this.data.dataSource){const t=this.container.querySelector(".data-source");t&&(t.textContent=`Source: ${this.data.dataSource}`)}}catch(t){console.error("[TimeSalesWidget] Error updating widget:",t),this.showError("Error updating data")}}updateTradesTable(){const t=this.container.querySelector(".trades-body");if(!t)return;t.innerHTML="";const e=this.data.getTrades();0!==e.length?e.forEach(((n,i)=>{const s=u("div","","trade-row");0===i&&s.classList.add("newest-trade");const o=u("div",this.data.formatTime(n.time),"trade-cell time-cell"),a=u("div",this.data.formatPrice(n.price),"trade-cell price-cell");if(i<e.length-1){const t=e[i+1],s=n.price-t.price;s>0?a.classList.add("price-up"):s<0&&a.classList.add("price-down")}const r=u("div",this.data.formatSize(n.size),"trade-cell size-cell"),l=u("div",p(n.source),"trade-cell source-cell");s.appendChild(o),s.appendChild(a),s.appendChild(r),s.appendChild(l),t.appendChild(s)})):t.innerHTML='<div class="empty-trades">No trades available</div>'}showLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.remove("hidden")}hideLoading(){const t=this.container.querySelector(".widget-loading-overlay");t&&t.classList.add("hidden")}showError(t){this.hideLoading(),this.clearError();const e=document.createElement("div");e.className="widget-error",e.textContent=`Error: ${t}`,e.style.cssText="\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n padding: 15px 20px;\n background: #fee;\n border: 1px solid #f5c6cb;\n border-radius: 6px;\n color: #721c24;\n text-align: center;\n font-size: 14px;\n z-index: 100;\n ",this.container.appendChild(e)}clearError(){const t=this.container.querySelector(".widget-error");t&&t.remove()}destroy(){this.isDestroyed=!0,this.loadingTimeout&&(this.clearTimeout(this.loadingTimeout),this.loadingTimeout=null),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null),this.symbolEditor&&(this.symbolEditor.destroy(),this.symbolEditor=null),super.destroy()}updateSymbol(t){this.handleSymbolChange(t)}}class qu{constructor(t){this.stateManager=t,this.widgets=new Map}createWidget(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=this.generateWidgetId();let s;switch(t){case"quote-level1":s=new v(e,n,i);break;case"night-session":s=new C(e,n,i);break;case"options":s=new T(e,n,i);break;case"option-chain":s=new E(e,n,i);break;case"data":s=new A(e,n,i);break;case"combined-market":s=new I(e,n,i);break;case"intraday-chart":s=new Nu(e,n,i);break;case"onbbo-level2":s=new Ru(e,n,i);break;case"onbbo-time-sale":s=new Bu(e,n,i);break;default:throw new Error(`Unknown widget type: ${t}`)}return this.widgets.set(i,s),s}generateWidgetId(){return`widget_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}destroyWidget(t){const e=this.widgets.get(t);e&&(e.destroy(),this.widgets.delete(t))}getWidgetCount(){return this.widgets.size}destroy(){this.widgets.forEach((t=>t.destroy())),this.widgets.clear()}}class Hu{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"https://mdas-api-dev.viewtrade.dev";this.token=t,this.baseUrl=e}async request(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=`${this.baseUrl}${t}`,i={method:"GET",headers:{Authorization:`Bearer ${this.token}`,"Content-Type":"application/json",...e.headers},...e};try{const t=await fetch(n,i);if(!t.ok){let e="";try{e=await t.text(),console.error(`[ApiService] HTTP ${t.status} - Response body:`,e)}catch(t){console.error("[ApiService] Could not read error response body:",t)}throw new Error(`HTTP error! status: ${t.status}, body: ${e}`)}return await t.json()}catch(t){throw console.error(`[ApiService] Request failed for ${n}:`,t),t}}async getOptionChainDates(t){return this.request(`/api/quote/option-chain-dates?symbol=${t}&response_camel_case=false`)}async quoteOptionl1(t){return this.request(`/api/quote/option-level1?option_names=${t}&response_camel_case=false`)}async quotel1(t){return this.request(`/api/quote/level1?symbols=${t}&response_camel_case=false`)}async quoteBlueOcean(t){return this.request(`/api/quote/night-session/level1/blueocean?symbols=${t}&response_camel_case=false`)}async getIntradayChart(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return this.request(`/api/quote/night-session/intraday/${t}?symbol=${e}&range_back=${n}`)}async getMarketStatus(t){return this.request(`/api/quote/night-session/market-status/${t}`)}}class Vu{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.config={debug:t.debug||!1,token:t.token,baseUrl:t.baseUrl||"ws://localhost:3000/wssub",apiBaseUrl:t.apiBaseUrl,maxConnections:t.maxConnections||1,reconnectOptions:{maxAttempts:t.reconnectOptions?.maxAttempts||10,initialDelay:t.reconnectOptions?.initialDelay||1e3,maxDelay:t.reconnectOptions?.maxDelay||3e4,backoff:t.reconnectOptions?.backoff||1.5,jitter:t.reconnectOptions?.jitter||.3},timeouts:{connection:t.timeouts?.connection||1e4,inactivity:t.timeouts?.inactivity||9e4},enableActivityMonitoring:!1},this.apiService=new Hu(this.config.token,this.config.apiBaseUrl),this.connection=null,this.connectionState="disconnected",this.reconnectAttempts=0,this.reconnectTimer=null,this.connectionStartTime=null,this.subscriptions=new Map,this.activeSubscriptions=new Set,this.messageQueue=[],this.symbolSubscriptions=new Map,this.typeSubscriptions=new Map,this.lastMessageCache=new Map,this.connectionPromise=null,this.reloginCallback=t.reloginCallback||null,this.isReloginInProgress=!1,this.lastMessageReceived=null,this.activityCheckInterval=null,this.isOnline="undefined"==typeof navigator||navigator.onLine,this.onlineHandler=null,this.offlineHandler=null,this.circuitBreaker={state:"closed",failureCount:0,failureThreshold:5,timeout:6e4,lastFailureTime:null,resetTimer:null},this.metrics={successfulConnections:0,failedConnections:0,totalReconnects:0,avgConnectionTime:0,lastSuccessfulConnection:null,messagesReceived:0,messagesSent:0},this.handleOpen=this.handleOpen.bind(this),this.handleMessage=this.handleMessage.bind(this),this.handleClose=this.handleClose.bind(this),this.handleError=this.handleError.bind(this),this.isManualDisconnect=!1,this._initNetworkMonitoring(),this.config.debug&&console.log("[WebSocketManager] Initialized with config:",this.config)}async connect(){return"connected"===this.connectionState||"connecting"===this.connectionState?Promise.resolve():new Promise(((t,e)=>{this.connectionPromise={resolve:t,reject:e},this._connect()}))}subscribe(t,e,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};Array.isArray(e)||(e=[e]);const o=this.subscriptions.get(t);if(o){if(this.config.debug&&console.log(`[WebSocketManager] Cleaning up existing subscription for widget ${t} before re-subscribing`),o.symbol){const e=this.symbolSubscriptions.get(o.symbol);e&&(e.delete(t),0===e.size&&this.symbolSubscriptions.delete(o.symbol))}o.types&&o.types.forEach((e=>{const n=this.typeSubscriptions.get(e);n&&(n.delete(t),0===n.size&&this.typeSubscriptions.delete(e))}))}const a={types:new Set(e),callback:n,symbol:i?.toUpperCase(),additionalParams:s};if(this.subscriptions.set(t,a),i){const e=i.toUpperCase();this.symbolSubscriptions.has(e)||this.symbolSubscriptions.set(e,new Set),this.symbolSubscriptions.get(e).add(t)}return e.forEach((e=>{this.typeSubscriptions.has(e)||this.typeSubscriptions.set(e,new Set),this.typeSubscriptions.get(e).add(t)})),this.config.debug&&console.log(`[WebSocketManager] Widget ${t} subscribed to:`,e,`for symbol: ${i}`,s),"connected"===this.connectionState&&(this._sendSubscriptions(e),e.forEach((e=>{const s=i?`${e}:${i}`:e,o=this.lastMessageCache.get(s);if(o&&this.activeSubscriptions.has(s)){this.config.debug&&console.log(`[WebSocketManager] Sending cached data to new widget ${t} for ${s}`);try{n({event:"data",data:o,widgetId:t})}catch(e){console.error(`[WebSocketManager] Error sending cached data to widget ${t}:`,e)}}}))),()=>this.unsubscribe(t)}unsubscribe(t){const e=this.subscriptions.get(t);if(e){if(e.symbol&&e.types&&e.types.forEach((t=>{this.sendUnsubscribe(t,e.symbol,e.additionalParams||{})})),e.symbol){const n=this.symbolSubscriptions.get(e.symbol);n&&(n.delete(t),0===n.size&&this.symbolSubscriptions.delete(e.symbol))}e.types.forEach((e=>{const n=this.typeSubscriptions.get(e);n&&(n.delete(t),0===n.size&&this.typeSubscriptions.delete(e))})),this.subscriptions.delete(t),this.config.debug&&console.log(`[WebSocketManager] Widget ${t} unsubscribed`),this._cleanupUnusedSubscriptions()}}sendUnsubscribe(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};try{let i,s;"queryoptionchain"===t?(s=`${t}:${e}:${n.date||""}`,i={type:t,underlying:e,date:n.date,unsubscribe:!0}):"queryoptionl1"===t?(s=`${t}:${e}`,i={type:t,optionName:e,unsubscribe:!0}):(s=`${t}:${e}`,i={type:t,symbol:e,unsubscribe:!0}),this.config.debug&&console.log(`[WebSocketManager] Sending unsubscribe for ${s}:`,i),this.send(i),this.activeSubscriptions.delete(s),this.config.debug&&console.log(`[WebSocketManager] Removed ${s} from active subscriptions`)}catch(t){console.error("[WebSocketManager] Error sending unsubscribe:",t)}}sendUnsubscribeAll(){try{const t={unsubscribe_all:!0};this.config.debug&&console.log("[WebSocketManager] Sending unsubscribe all"),this.send(t),this.activeSubscriptions.clear()}catch(t){console.error("[WebSocketManager] Error sending unsubscribe all:",t)}}send(t){if("connected"!==this.connectionState||!this.connection||1!==this.connection.readyState)return this.messageQueue&&Array.isArray(this.messageQueue)||(this.messageQueue=[]),this.messageQueue.push(t),this.config.debug&&console.log("[WebSocketManager] Message queued (not connected):",t),!1;try{return this.connection.send(JSON.stringify(t)),this.config.debug&&console.log("[WebSocketManager] Sent message:",t),this.metrics.messagesSent++,!0}catch(t){return console.error("[WebSocketManager] Error sending message:",t),!1}}getConnectionState(){return this.connectionState}getSubscriptionCount(){return this.subscriptions.size}_connect(){if("connecting"!==this.connectionState){this.isManualDisconnect=!1,this.connectionState="connecting",this.connectionStartTime=Date.now();try{this.connection&&(this.connection.removeEventListener("open",this.handleOpen),this.connection.removeEventListener("message",this.handleMessage),this.connection.removeEventListener("close",this.handleClose),this.connection.removeEventListener("error",this.handleError),this.connection=null);const t=`${this.config.baseUrl}?token=${this.config.token}`;this.config.debug&&console.log("[WebSocketManager] Connecting to:",t),this.connection=new WebSocket(t);const e=setTimeout((()=>{this.connection&&0===this.connection.readyState&&(console.error("[WebSocketManager] Connection timeout"),this.connection.close(),this.connectionState="disconnected",this._updateCircuitBreaker(!1),this.connectionPromise&&(this.connectionPromise.reject(new Error("Connection timeout")),this.connectionPromise=null),this._scheduleReconnect())}),this.config.timeouts.connection);this.connection.addEventListener("open",(t=>{clearTimeout(e),this.handleOpen(t)})),this.connection.addEventListener("message",this.handleMessage),this.connection.addEventListener("close",(t=>{clearTimeout(e),this.handleClose(t)})),this.connection.addEventListener("error",(t=>{clearTimeout(e),this.handleError(t)}))}catch(t){console.error("[WebSocketManager] Connection error:",t),this.connectionState="disconnected",this.connectionPromise&&(this.connectionPromise.reject(t),this.connectionPromise=null),this._scheduleReconnect()}}}handleOpen(t){const e=Date.now()-this.connectionStartTime;this.connectionState="connected",this.reconnectAttempts=0,this.lastMessageReceived=Date.now(),this.metrics.successfulConnections++,this.metrics.lastSuccessfulConnection=Date.now();const n=this.metrics.avgConnectionTime,i=this.metrics.successfulConnections;this.metrics.avgConnectionTime=(n*(i-1)+e)/i,this._updateCircuitBreaker(!0),this.config.debug&&console.log("[WebSocketManager] Connected successfully",{connectionTime:`${e}ms`,avgConnectionTime:`${Math.round(this.metrics.avgConnectionTime)}ms`,attempt:this.metrics.totalReconnects+1}),this.connectionPromise&&(this.connectionPromise.resolve(),this.connectionPromise=null);try{this._startActivityMonitoring(),this._sendAllSubscriptions(),this._processMessageQueue(),this._notifyWidgets("connection",{status:"connected"})}catch(t){console.error("[WebSocketManager] Error in handleOpen:",t)}}handleMessage(t){try{let e;this.lastMessageReceived=Date.now(),this.metrics.messagesReceived++;try{e=JSON.parse(t.data)}catch(n){const i=t.data.toString();if(this.config.debug&&console.log("[WebSocketManager] Received plain text message:",i),i.toLowerCase().includes("session revoked")||i.toLowerCase().includes("please relogin")||i.toLowerCase().includes("session expired")||i.toLowerCase().includes("unauthorized")||i.toLowerCase().includes("authentication failed"))return this.config.debug&&console.log("[WebSocketManager] Session revoked detected, attempting relogin..."),void this._handleSessionRevoked(i);const s=this._getTargetTypeFromErrorMessage(i)||"error";e=i.toLowerCase().includes("no night session")||i.toLowerCase().includes("no data")?{type:s,message:i,error:!0,noData:!0}:{type:s,message:i,error:!0}}this.config.debug&&console.log("[WebSocketManager] Processed message:",e);let n=e;this._routeMessage(n)}catch(t){console.error("[WebSocketManager] Error handling message:",t),this._notifyWidgets("error",{error:"Failed to process message",details:t.message})}}handleClose(t){const e="connected"===this.connectionState;this.connectionState="disconnected",this.activeSubscriptions.clear(),this._stopActivityMonitoring(),this.config.debug&&console.log(`[WebSocketManager] Connection closed: ${t.code} ${t.reason}`),e&&this._notifyWidgets("connection",{status:"disconnected",code:t.code,reason:t.reason}),!this.isManualDisconnect&&this.subscriptions.size>0?(this.metrics.totalReconnects++,this._scheduleReconnect()):this.isManualDisconnect&&(this.config.debug&&console.log("[WebSocketManager] Manual disconnect - skipping reconnection"),this.isManualDisconnect=!1)}handleError(t){const e=this.connection?this.connection.readyState:"no connection";console.error("[WebSocketManager] WebSocket error:",{readyState:e,stateName:{0:"CONNECTING",1:"OPEN",2:"CLOSING",3:"CLOSED"}[e]||"UNKNOWN",url:this.connection?.url,error:t}),this.connection&&(3===this.connection.readyState?(console.log("[WebSocketManager] Connection closed due to error"),this.connectionState="disconnected",!this.isManualDisconnect&&this.subscriptions.size>0?(console.log("[WebSocketManager] Attempting reconnection after error..."),this._scheduleReconnect()):this.isManualDisconnect&&console.log("[WebSocketManager] Manual disconnect - skipping reconnection after error")):2===this.connection.readyState&&console.log("[WebSocketManager] Connection closing...")),this._notifyWidgets("connection",{status:"error",error:"WebSocket connection error",readyState:e,details:"Connection failed or was closed unexpectedly"}),this.connectionPromise&&(this.connectionPromise.reject(new Error("WebSocket connection failed")),this.connectionPromise=null)}_sendAllSubscriptions(){try{const t=new Set;this.subscriptions.forEach((e=>{e&&e.types&&e.types.forEach((e=>t.add(e)))})),this._sendSubscriptions([...t])}catch(t){console.error("[WebSocketManager] Error sending subscriptions:",t)}}_sendSubscriptions(t){t.forEach((t=>{if("queryoptionchain"===t)this._sendOptionChainSubscriptions();else{this._getSymbolsForType(t).forEach((e=>{const n=`${t}:${e}`;if(this.activeSubscriptions.has(n)){this.config.debug&&console.log(`[WebSocketManager] Subscription ${n} already active, skipping server subscription`);const i=this.lastMessageCache.get(n);console.log("LAST",this.lastMessageCache),i&&(this.config.debug&&console.log(`[WebSocketManager] Sending cached data to newly subscribing widgets for ${n}`),this.subscriptions.forEach(((n,s)=>{if(n.types.has(t)&&n.symbol===e)try{n.callback({event:"data",data:i,widgetId:s})}catch(t){console.error(`[WebSocketManager] Error sending cached data to widget ${s}:`,t)}})))}else{let i;i="queryoptionl1"===t?{type:t,optionName:e}:{type:t,symbol:e},this.config.debug&&console.log(`[WebSocketManager] Sending subscription for ${n}`),this.send(i)&&this.activeSubscriptions.add(n)}}))}}))}_sendOptionChainSubscriptions(){this.subscriptions.forEach(((t,e)=>{if(t.types.has("queryoptionchain")&&t.symbol&&t.additionalParams?.date){const e=`queryoptionchain:${t.symbol}:${t.additionalParams.date}`;if(this.activeSubscriptions.has(e))this.config.debug&&console.log(`[WebSocketManager] Option chain subscription ${e} already active, skipping`);else{const n={type:"queryoptionchain",underlying:t.symbol,date:t.additionalParams.date};this.config.debug&&console.log(`[WebSocketManager] Sending option chain subscription for ${e}`),this.send(n)&&this.activeSubscriptions.add(e)}}}))}_getSymbolsForType(t){const e=new Set;return this.subscriptions.forEach(((n,i)=>{n.types.has(t)&&n.symbol&&e.add(n.symbol)})),[...e]}_normalizeMessage(t){const e=t.error,n=t.type,i=t.message||t.Message;if(!0===e||"true"===e)return this.config.debug&&console.log(`[WebSocketManager] Detected error message with type: ${n}`),{...t,...t.type||t.Type||!n?{}:{type:n}};if(i&&"string"==typeof i){const e=i.toLowerCase();if(["no data","no access","not found","invalid","unauthorized","forbidden","error","failed","unavailable"].some((t=>e.includes(t)))&&n)return this.config.debug&&console.log(`[WebSocketManager] Detected implicit error in Message field: "${i}" with type: ${n}`),{...t,...t.type||t.Type||!n?{}:{type:n},error:!0}}return t}_routeMessage(t){this._cacheMessage(t);const e=this._getRelevantWidgets(t);if(this.config.debug&&e.size>0&&console.log(`[WebSocketManager] Routing message to ${e.size} relevant widgets`),0===e.size&&this.subscriptions.size>0)return this.config.debug&&console.log("[WebSocketManager] No specific routing found, broadcasting to all widgets"),void this.subscriptions.forEach(((e,n)=>{try{e.callback({event:"data",data:t,widgetId:n})}catch(t){console.error(`[WebSocketManager] Error in widget ${n} callback:`,t)}}));e.forEach((e=>{const n=this.subscriptions.get(e);if(n)try{n.callback({event:"data",data:t,widgetId:e})}catch(t){console.error(`[WebSocketManager] Error in widget ${e} callback:`,t)}}))}_cacheMessage(t){try{let e;e=t.data?t.data:t.Data?t.Data:t;const n=this._extractSymbol(e),i=t.type;if(this.config.debug&&console.log(`[WebSocketManager] _cacheMessage - extracted symbol: "${n}", messageType: "${i}"`),i&&n){const e=`${i}:${n}`;this.lastMessageCache.set(e,t),this.config.debug&&console.log(`[WebSocketManager] Cached message for ${e}`)}else i&&(this.config.debug&&console.log(`[WebSocketManager] No symbol found in message, attempting to infer from subscriptions for type: ${i}`),this.activeSubscriptions.forEach((e=>{const[n,s]=e.split(":");if(n===i&&s){const n=e;this.lastMessageCache.set(n,t),this.config.debug&&console.log(`[WebSocketManager] Cached message for ${n} (inferred from active subscription)`)}})))}catch(t){console.error("[WebSocketManager] Error caching message:",t)}}_getRelevantWidgets(t){const e=new Set;let n=t.Data||t.data;const i=t.type||this._extractMessageType(n);return this._addRelevantWidgetsForItem(t,e,i),e}_addRelevantWidgetsForItem(t,e,n){t.Data&&Array.isArray(t.Data)?t.Data.forEach((t=>{this._processDataItem(t,e,n)})):t.data&&t.data[0]&&void 0!==t.data[0].Strike&&t.data[0].Expire&&!t.data[0].underlyingSymbol?this._processOptionChainData(t.data,e):this._processDataItem(t,e,n)}_processOptionChainData(t,e){if(!t||0===t.length)return;const n=t[0],i=this._extractUnderlyingFromOption(n.Symbol),s=n.Expire;if(this.config.debug&&console.log("[WebSocketManager] Processing option chain data:",{underlyingSymbol:i,expireDate:s,contractCount:t.length}),i){const t=this.symbolSubscriptions.get(i);t&&t.forEach((t=>{const n=this.subscriptions.get(t);if(n&&n.types.has("queryoptionchain")){let o=!0;if(n.additionalParams?.date&&s){o=this._normalizeDate(n.additionalParams.date)===this._normalizeDate(s)}o&&(e.add(t),this.config.debug&&console.log(`[WebSocketManager] Routing option chain data for ${i} (${s}) to widget ${t}`))}}))}}_processDataItem(t,e,n){const i=this._extractSymbol(t);if(this.config.debug&&console.log("[WebSocketManager] Processing data item:",{symbol:i,messageType:n,dataItem:t}),i){const t=this.symbolSubscriptions.get(i);t&&t.forEach((t=>{const s=this.subscriptions.get(t);if(s){this._isDataTypeCompatible(n,s.types)&&(e.add(t),this.config.debug&&console.log(`[WebSocketManager] Routing ${n} data for ${i} to widget ${t}`))}}))}if(n){const t=this.typeSubscriptions.get(n);t&&t.forEach((t=>{const s=this.subscriptions.get(t);!s||s.symbol&&i&&s.symbol!==i||(e.add(t),this.config.debug&&console.log(`[WebSocketManager] Routing ${n} data to type-subscribed widget ${t}`))}))}}_isDataTypeCompatible(t,e){if(e.has(t))return!0;const n={queryoptionchain:["queryoptionchain","optionchain","option-chain"],queryl1:["queryl1","stock","equity"],queryoptionl1:["queryoptionl1","option","options"],queryblueoceanl1:["queryblueoceanl1","blueoceanl1","blueocean"],querybrucel1:["querybrucel1","brucel1","bruce"],queryonbbol1:["queryonbbol1","onbbol1","onbbo"],queryonbbol2:["queryonbbol2","onbbol2","onbbo-level2"],queryonbbotimesale:["queryonbbotimesale","querytns","timesale","time-sales"]};for(const i of e){if((n[i]||[i]).includes(t))return!0}return!1}_normalizeDate(t){if(!t)return null;if(t.includes("/")){const[e,n,i]=t.split("/");return`${i}-${e.padStart(2,"0")}-${n.padStart(2,"0")}`}return t}_extractSymbol(t){return Array.isArray(t)&&t.length>0&&t[0]?this._extractSymbolFromItem(t[0]):(t._messageType,this._extractSymbolFromItem(t))}_extractSymbolFromItem(t){if(Array.isArray(t)&&t[0]&&t[0].Source&&null!==t[0].Symbol){const e=t[0].Source.toLowerCase();(e.includes("blueocean")||e.includes("bruce")||e.includes("onbbo"))&&(t=t[0])}return t.Symbol&&!t.Underlying&&t.Strike?this._extractUnderlyingFromOption(t.Symbol):t.Symbol||t.symbol||t.RootSymbol||t.rootSymbol||t.Underlying||t.underlying}_isOptionSymbol(t){return/^[A-Z]+\d{6}[CP]\d+$/.test(t)}_extractUnderlyingFromOption(t){const e=t.match(/^([A-Z]+)\d{6}[CP]\d+$/),n=e?e[1]:t;return{SPXW:"SPX$",SPX:"SPX$",NDXP:"NDX$",RUT:"RUT$",VIX:"VIX$",DJX:"DJX$"}[n]||n}_extractMessageType(t){if(Array.isArray(t)&&t.length>0&&void 0!==t[0].MMID)return"queryonbbol2";if(Array.isArray(t)&&t.length>0&&void 0!==t[0].Strike)return"queryoptionchain";if(t[0]&&t[0].Source){const e=t[0].Source.toLowerCase();if(e.includes("onbbo"))return"queryonbbol1";if(e.includes("blueocean")||e.includes("blueocean-d")||e.includes("bruce"))return e.includes("bruce")?"querybrucel1":"queryblueoceanl1"}return void 0!==t.Strike||void 0!==t.Expire||t.Symbol&&this._isOptionSymbol(t.Symbol)?"queryoptionl1":void 0!==t.BidPx||void 0!==t.AskPx?"queryl1":null}_notifyWidgets(t,e){try{this.subscriptions.forEach(((n,i)=>{try{n&&n.callback&&n.callback({event:t,data:e,widgetId:i})}catch(t){console.error(`[WebSocketManager] Error notifying widget ${i}:`,t)}}))}catch(t){console.error("[WebSocketManager] Error in _notifyWidgets:",t)}}_processMessageQueue(){if(!this.messageQueue||!Array.isArray(this.messageQueue))return this.config.debug&&console.warn("[WebSocketManager] messageQueue not properly initialized, creating new array"),void(this.messageQueue=[]);for(this.config.debug&&this.messageQueue.length>0&&console.log(`[WebSocketManager] Processing ${this.messageQueue.length} queued messages`);this.messageQueue.length>0;){const t=this.messageQueue.shift();t&&this.send(t)}}_cleanupUnusedSubscriptions(){const t=new Set;this.subscriptions.forEach((e=>{e.types.forEach((e=>t.add(e)))})),this.activeSubscriptions.forEach((e=>{const[n]=e.split(":");t.has(n)||this.activeSubscriptions.delete(e)}))}_scheduleReconnect(){if(!this.isOnline)return this.config.debug&&console.log("[WebSocketManager] Network offline, waiting for network to return..."),void this._notifyWidgets("connection",{status:"offline",reason:"Network offline - will reconnect when network returns"});if("open"===this.circuitBreaker.state){const t=Date.now()-this.circuitBreaker.lastFailureTime,e=this.circuitBreaker.timeout-t;return console.warn(`[WebSocketManager] Circuit breaker OPEN, will retry in ${Math.round(e/1e3)}s`),void this._notifyWidgets("connection",{status:"circuit_open",reason:"Too many connection failures - circuit breaker active",retryIn:Math.round(e/1e3)})}if(this.reconnectAttempts>=this.config.reconnectOptions.maxAttempts)return console.error("[WebSocketManager] Max reconnection attempts reached"),this.metrics.failedConnections++,void this._notifyWidgets("connection",{status:"failed",error:"Max reconnection attempts reached",maxAttempts:this.config.reconnectOptions.maxAttempts,canRetry:!0});this.connectionState="reconnecting",this.reconnectAttempts++;const t=this.config.reconnectOptions.initialDelay*Math.pow(this.config.reconnectOptions.backoff,this.reconnectAttempts-1),e=Math.min(t,this.config.reconnectOptions.maxDelay),n=e*this.config.reconnectOptions.jitter,i=(2*Math.random()-1)*n,s=Math.max(0,e+i);console.log(`[WebSocketManager] Scheduling reconnect attempt ${this.reconnectAttempts}/${this.config.reconnectOptions.maxAttempts} in ${Math.round(s)}ms`),this._notifyWidgets("connection",{status:"reconnecting",attempt:this.reconnectAttempts,maxAttempts:this.config.reconnectOptions.maxAttempts,delay:Math.round(s),estimatedTime:new Date(Date.now()+s).toISOString()}),this.reconnectTimer=setTimeout((()=>{this._connect()}),s)}_resetState(){this.connectionState="disconnected",this.reconnectAttempts=0,this.connectionPromise=null,this.subscriptions&&this.subscriptions instanceof Map||(this.subscriptions=new Map),this.activeSubscriptions&&this.activeSubscriptions instanceof Set||(this.activeSubscriptions=new Set),this.messageQueue&&Array.isArray(this.messageQueue)||(this.messageQueue=[]),this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}_getTargetTypeFromErrorMessage(t){const e=t.toLowerCase();return e.includes("night session")||e.includes("blue ocean")||e.includes("bruce")||e.includes("blueocean")?e[0].toLowerCase().includes("bruce")?"querybrucel1":"queryblueoceanl1":e.includes("option chain")||e.includes("expiration date")?"queryoptionchain":e.includes("option")||e.includes("strike")||e.includes("expiration")?"queryoptionl1":e.includes("stock")||e.includes("equity")||e.includes("bid")||e.includes("ask")?"queryl1":null}async _handleSessionRevoked(t){if(this.isReloginInProgress)this.config.debug&&console.log("[WebSocketManager] Relogin already in progress, skipping...");else{this.isReloginInProgress=!0;try{if(this._notifyWidgets("session_revoked",{message:t,status:"attempting_relogin"}),this.config.debug&&console.log("[WebSocketManager] Session revoked, attempting relogin..."),this._closeConnection(),!this.reloginCallback||"function"!=typeof this.reloginCallback)throw new Error("No relogin callback provided");{const t=await this.reloginCallback();if(!(t&&"string"==typeof t&&t.length>0))throw new Error("Relogin failed: Invalid token received");this.updateToken(t),this.config.debug&&console.log("[WebSocketManager] Relogin successful, reconnecting..."),await this._reconnectAndResubscribe()}}catch(e){console.error("[WebSocketManager] Relogin failed:",e),this._notifyWidgets("session_revoked",{message:t,status:"relogin_failed",error:e.message}),this.connectionState="failed"}finally{this.isReloginInProgress=!1}}}async _reconnectAndResubscribe(){try{this.connectionState="disconnected",this.reconnectAttempts=0,this.activeSubscriptions.clear(),await this.connect(),this.config.debug&&console.log("[WebSocketManager] Reconnected successfully after relogin"),this._notifyWidgets("session_revoked",{status:"relogin_successful"})}catch(t){throw console.error("[WebSocketManager] Failed to reconnect after relogin:",t),t}}_closeConnection(){this.connection&&(this.connection.removeEventListener("open",this.handleOpen),this.connection.removeEventListener("message",this.handleMessage),this.connection.removeEventListener("close",this.handleClose),this.connection.removeEventListener("error",this.handleError),this.connection.readyState===WebSocket.OPEN&&this.connection.close(),this.connection=null),this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.connectionState="disconnected"}setReloginCallback(t){this.reloginCallback=t,this.config.debug&&console.log("[WebSocketManager] Relogin callback set")}updateToken(t){this.config.token=t,this.apiService=new Hu(this.config.token,this.config.apiBaseUrl),this.config.debug&&console.log("[WebSocketManager] Token updated")}getApiService(){return this.apiService}async manualReconnect(){this.config.debug&&console.log("[WebSocketManager] Manual reconnect initiated"),this.reconnectAttempts=0,this.connectionState="disconnected",this.isManualDisconnect=!1,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this._notifyWidgets("connection",{status:"reconnecting",attempt:1,maxAttempts:this.config.reconnectOptions.maxAttempts,manual:!0});try{return await this.connect(),!0}catch(t){return console.error("[WebSocketManager] Manual reconnect failed:",t),!1}}_initNetworkMonitoring(){"undefined"!=typeof window&&(this.onlineHandler=()=>{this.isOnline=!0,this.config.debug&&console.log("[WebSocketManager] Network online detected"),"disconnected"===this.connectionState&&this.subscriptions.size>0&&(console.log("[WebSocketManager] Network restored, attempting reconnection..."),this.reconnectAttempts=0,this._scheduleReconnect())},this.offlineHandler=()=>{this.isOnline=!1,this.config.debug&&console.log("[WebSocketManager] Network offline detected"),this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this._notifyWidgets("connection",{status:"offline",reason:"Network offline"})},window.addEventListener("online",this.onlineHandler),window.addEventListener("offline",this.offlineHandler))}_cleanupNetworkMonitoring(){"undefined"!=typeof window&&(this.onlineHandler&&(window.removeEventListener("online",this.onlineHandler),this.onlineHandler=null),this.offlineHandler&&(window.removeEventListener("offline",this.offlineHandler),this.offlineHandler=null))}_startActivityMonitoring(){this.config.enableActivityMonitoring?(this._stopActivityMonitoring(),this.activityCheckInterval=setInterval((()=>{if("connected"!==this.connectionState)return;const t=Date.now()-this.lastMessageReceived;t>this.config.timeouts.inactivity?(console.warn(`[WebSocketManager] No messages received in ${this.config.timeouts.inactivity}ms, connection may be dead`),this.connection&&this.connection.close()):this.config.debug&&t>3e4&&console.log(`[WebSocketManager] Last message: ${Math.round(t/1e3)}s ago`)}),15e3)):this.config.debug&&console.log("[WebSocketManager] Activity monitoring disabled")}_stopActivityMonitoring(){this.activityCheckInterval&&(clearInterval(this.activityCheckInterval),this.activityCheckInterval=null)}_updateCircuitBreaker(t){t?(this.circuitBreaker.failureCount=0,this.circuitBreaker.state="closed",this.circuitBreaker.resetTimer&&(clearTimeout(this.circuitBreaker.resetTimer),this.circuitBreaker.resetTimer=null),this.config.debug&&console.log("[WebSocketManager] Circuit breaker CLOSED - connection healthy")):(this.circuitBreaker.failureCount++,this.circuitBreaker.lastFailureTime=Date.now(),this.config.debug&&console.log(`[WebSocketManager] Circuit breaker failure ${this.circuitBreaker.failureCount}/${this.circuitBreaker.failureThreshold}`),this.circuitBreaker.failureCount>=this.circuitBreaker.failureThreshold&&(this.circuitBreaker.state="open",console.warn("[WebSocketManager] Circuit breaker OPEN - too many failures"),this.circuitBreaker.resetTimer=setTimeout((()=>{this.circuitBreaker.state="half-open",this.circuitBreaker.failureCount=0,console.log("[WebSocketManager] Circuit breaker HALF-OPEN - will attempt one reconnection"),this.subscriptions.size>0&&"connected"!==this.connectionState&&(this.reconnectAttempts=0,this._scheduleReconnect())}),this.circuitBreaker.timeout)))}getConnectionMetrics(){const t=this._calculateConnectionQuality();return{state:this.connectionState,quality:t,isOnline:this.isOnline,circuitBreakerState:this.circuitBreaker.state,reconnectAttempts:this.reconnectAttempts,maxReconnectAttempts:this.config.reconnectOptions.maxAttempts,successfulConnections:this.metrics.successfulConnections,failedConnections:this.metrics.failedConnections,totalReconnects:this.metrics.totalReconnects,avgConnectionTime:Math.round(this.metrics.avgConnectionTime),lastSuccessfulConnection:this.metrics.lastSuccessfulConnection?new Date(this.metrics.lastSuccessfulConnection).toISOString():null,messagesReceived:this.metrics.messagesReceived,messagesSent:this.metrics.messagesSent,activeSubscriptions:this.subscriptions.size,lastMessageReceived:this.lastMessageReceived?`${Math.round((Date.now()-this.lastMessageReceived)/1e3)}s ago`:"never"}}_calculateConnectionQuality(){if("connected"!==this.connectionState)return"poor";const t=this.lastMessageReceived?Date.now()-this.lastMessageReceived:1/0;return t<3e4&&this.metrics.avgConnectionTime<2e3?"excellent":t<6e4&&this.metrics.avgConnectionTime<5e3?"good":t<this.config.timeouts.inactivity?"fair":"poor"}enableMetricsLogging(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3e4;this.metricsInterval&&clearInterval(this.metricsInterval),this.metricsInterval=setInterval((()=>{console.log("[WebSocketManager] Metrics:",this.getConnectionMetrics())}),t),console.log("[WebSocketManager] Metrics logging enabled (every "+t/1e3+"s)")}disableMetricsLogging(){this.metricsInterval&&(clearInterval(this.metricsInterval),this.metricsInterval=null,console.log("[WebSocketManager] Metrics logging disabled"))}disconnect(){this.isManualDisconnect=!0,this._stopActivityMonitoring(),this._cleanupNetworkMonitoring(),this.circuitBreaker.resetTimer&&(clearTimeout(this.circuitBreaker.resetTimer),this.circuitBreaker.resetTimer=null),this.disableMetricsLogging(),this._closeConnection(),this._notifyWidgets("connection",{status:"disconnected",manual:!0}),this.config.debug&&console.log("[WebSocketManager] Disconnected and cleaned up")}}class ju{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.config={apiBaseUrl:t.apiBaseUrl||"https://mdas-api-dev.viewtrade.dev",loginEndpoint:t.loginEndpoint||"/api/user/login",refreshEndpoint:t.refreshEndpoint||"/api/user/refresh",refreshBuffer:t.refreshBuffer||300,maxRetries:t.maxRetries||3,debug:t.debug||!1},this.credentials=null,this.currentToken=null,this.tokenExpiry=null,this.refreshTimer=null,this.isAuthenticating=!1,this.retryCount=0,this.authenticationPromise=null,this.listeners=new Map,this.config.debug&&console.log("[AuthManager] Initialized with config:",{...this.config,loginEndpoint:this.config.loginEndpoint})}setCredentials(t,e){this.credentials={user_name:t,password:e},this.config.debug&&console.log("[AuthManager] Credentials set for user:",t)}async authenticate(){if(this.isAuthenticating&&this.authenticationPromise)return this.config.debug&&console.log("[AuthManager] Authentication already in progress, waiting..."),await this.authenticationPromise;if(!this.credentials)throw new Error("No credentials provided. Call setCredentials() first.");this.isAuthenticating=!0,this.authenticationPromise=this._performAuthentication();try{return await this.authenticationPromise}finally{this.isAuthenticating=!1,this.authenticationPromise=null}}async getValidToken(){return this.currentToken?this._isTokenNearExpiry()?(this.config.debug&&console.log("[AuthManager] Token near expiry, refreshing..."),await this.refreshToken()):this.currentToken:await this.authenticate()}async refreshToken(){if(this.isAuthenticating)return this.currentToken;this.isAuthenticating=!0;try{const t=await this._performRefresh();return this._handleAuthSuccess(t),this.currentToken}catch(t){return this.config.debug&&console.log("[AuthManager] Token refresh failed, attempting re-login"),await this.authenticate()}finally{this.isAuthenticating=!1}}async handleAuthError(t){if(this.config.debug&&console.log("[AuthManager] Handling auth error:",t),this.retryCount>=this.config.maxRetries){const t=new Error(`Authentication failed after ${this.config.maxRetries} attempts`);throw this._notifyListeners("auth_failed",{error:t}),this.retryCount=0,t}this.retryCount++,this._clearToken();try{const t=await this.authenticate();return this.retryCount=0,this._notifyListeners("auth_recovered",{token:t}),t}catch(t){throw this._notifyListeners("auth_retry_failed",{error:t,attempt:this.retryCount}),t}}addEventListener(t,e){this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(e)}removeEventListener(t,e){this.listeners.has(t)&&this.listeners.get(t).delete(e)}destroy(){this._clearToken(),this.credentials=null,this.listeners.clear(),this.config.debug&&console.log("[AuthManager] Destroyed")}async _performLogin(){const t=`${this.config.apiBaseUrl}${this.config.loginEndpoint}`;this.config.debug&&console.log("[AuthManager] Attempting login to:",t);const e=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user_name:this.credentials.user_name,password:this.credentials.password})});if(!e.ok){const t=await e.json().catch((()=>({})));throw new Error(t.message||`Login failed: ${e.status} ${e.statusText}`)}const n=await e.json(),i=n.access_token,s=n.refresh_token,o=n.access_expiration,a=n.user_id;if(!i)throw console.error("[AuthManager] Login response missing token:",n),new Error("No token received from login response");let r=null;if(o)try{if(r=new Date(o),isNaN(r.getTime()))throw new Error("Invalid expiration date format")}catch(t){console.warn("[AuthManager] Could not parse expiration date:",n.expiration),r=new Date(Date.now()+36e5)}else r=new Date(Date.now()+18e6);return this.config.debug&&console.log("[AuthManager] Login successful:",{tokenLength:i.length,expiresAt:r.toISOString(),timeUntilExpiry:Math.round((r.getTime()-Date.now())/1e3/60)+" minutes"}),{token:i,refreshToken:s,expirationDate:r,user_id:a}}async _performRefresh(){return this.config.debug&&console.log("[AuthManager] No refresh endpoint available, performing full re-authentication"),await this._performLogin()}async _performAuthentication(){try{const t=await this._performLogin();return this._handleAuthSuccess(t),this.currentToken}catch(t){throw this._handleAuthError(t),t}}_handleAuthSuccess(t){this.currentToken=t.token,t.expirationDate&&(this.tokenExpiry=t.expirationDate),this.retryCount=0,this._scheduleTokenRefresh(),this.config.debug&&console.log("[AuthManager] Authentication successful, token expires:",this.tokenExpiry),this._notifyListeners("auth_success",{token:this.currentToken,expiresAt:this.tokenExpiry})}_handleAuthError(t){this.config.debug&&console.error("[AuthManager] Authentication failed:",t.message),this._notifyListeners("auth_error",{error:t})}_isTokenNearExpiry(){if(!this.tokenExpiry)return!0;const t=new Date,e=1e3*this.config.refreshBuffer;return t>=new Date(this.tokenExpiry.getTime()-e)}_scheduleTokenRefresh(){if(this.refreshTimer&&clearTimeout(this.refreshTimer),!this.tokenExpiry)return;const t=new Date,e=1e3*this.config.refreshBuffer,n=new Date(this.tokenExpiry.getTime()-e),i=Math.max(0,n.getTime()-t.getTime());this.config.debug&&console.log(`[AuthManager] Scheduling token refresh in ${i/1e3} seconds`),this.refreshTimer=setTimeout((async()=>{try{await this.refreshToken()}catch(t){console.error("[AuthManager] Scheduled refresh failed:",t)}}),i)}_clearToken(){this.currentToken=null,this.tokenExpiry=null,this.refreshTimer&&(clearTimeout(this.refreshTimer),this.refreshTimer=null)}_notifyListeners(t,e){this.listeners.has(t)&&this.listeners.get(t).forEach((n=>{try{n(e)}catch(e){console.error(`[AuthManager] Error in ${t} listener:`,e)}}))}}class Yu{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.config={username:t.username,password:t.password,token:t.token,authCallback:t.authCallback,wsUrl:t.wsUrl||"https://mdas-api-dev.viewtrade.dev/wss/sub",apiBaseUrl:t.apiBaseUrl||"https://mdas-api-dev.viewtrade.dev",debug:t.debug||!1,maxConnections:t.maxConnections||1,autoAuth:!1!==t.autoAuth,...t},this.stateManager=new e,this.widgetManager=new qu(this.stateManager),this.wsManager=null,this.authManager=null,this.isInitialized=!1,this._validateAuthConfig()}async initialize(){try{return this.isInitialized?(console.warn("SDK already initialized"),this):(this.config.debug&&console.log("Initializing MDAS SDK with config:",{hasCredentials:!(!this.config.username||!this.config.password),hasToken:!!this.config.token,hasAuthCallback:!!this.config.authCallback,wsUrl:this.config.wsUrl,autoAuth:this.config.autoAuth}),this.config.username&&this.config.password&&await this._initializeBuiltInAuth(),this.isInitialized=!0,this)}catch(t){throw console.error("Failed to initialize SDK:",t),t}}async createWidget(t,e){let n,i,s,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!this.isInitialized)throw new Error("SDK not initialized. Call initialize() first.");if(this.wsManager||await this._initializeWebSocketManager(),"object"!=typeof t||null===t||Array.isArray(t))n=t,i=e,s=o||{};else if(n=t.type,s=t.options||{},t.containerEl&&1===t.containerEl.nodeType)i=t.containerEl;else if(t.containerId){const e=String(t.containerId).replace(/^#/,"");let n="undefined"!=typeof document?document.getElementById(e):null;n||"undefined"==typeof document||(n=document.createElement("div"),n.id=e,document.body.appendChild(n)),i=n}else{const t="mdas-widget";let e="undefined"!=typeof document?document.getElementById(t):null;e||"undefined"==typeof document||(e=document.createElement("div"),e.id=t,document.body.appendChild(e)),i=e}const a={...s,wsManager:this.wsManager,debug:this.config.debug};return a.reconnect=async()=>await this.manualReconnect(),this.widgetManager.createWidget(n,i,a)}async login(t,e){this.authManager||(this.authManager=new ju({apiBaseUrl:this.config.apiBaseUrl,debug:this.config.debug})),this.authManager.setCredentials(t,e);const n=await this.authManager.authenticate();return this.wsManager&&await this._reconnectWithNewToken(n),n}async destroy(){this.authManager&&(this.authManager.destroy(),this.authManager=null),this.wsManager&&(this.wsManager.disconnect(),this.wsManager=null),this.widgetManager&&this.widgetManager.destroy(),this.isInitialized=!1}getConnectionState(){return this.wsManager?this.wsManager.getConnectionState():"disconnected"}getActiveWidgetCount(){return this.widgetManager?this.widgetManager.getWidgetCount():0}getSubscriptionCount(){return this.wsManager?this.wsManager.getSubscriptionCount():0}isAuthenticated(){return this.authManager?!!this.authManager.currentToken:!!this.config.token}disconnect(){this.wsManager&&(this.wsManager.disconnect(),this.config.debug&&console.log("[MdasSDK] WebSocket disconnected"))}async connect(){if(this.wsManager)try{await this.wsManager.connect(),this.config.debug&&console.log("[MdasSDK] WebSocket reconnected")}catch(t){throw console.error("[MdasSDK] Failed to reconnect:",t),t}else this.config.debug&&console.log("[MdasSDK] No WebSocketManager exists, initializing..."),await this._initializeWebSocketManager()}isConnected(){return!!this.wsManager&&"connected"===this.wsManager.getConnectionState()}async manualReconnect(){return!!this.wsManager&&(this.config.debug&&console.log("[MdasSDK] Manual reconnect requested"),await this.wsManager.manualReconnect())}_validateAuthConfig(){const t=this.config.username&&this.config.password,e=this.config.token,n=this.config.authCallback;if(!t&&!e&&!n)throw new Error("Authentication required: Provide username/password, token, or authCallback");[t,e,n].filter(Boolean).length>1&&console.warn("Multiple auth methods provided. Priority: credentials > token > authCallback")}async _initializeBuiltInAuth(){this.authManager=new ju({apiBaseUrl:this.config.apiBaseUrl,debug:this.config.debug}),this.authManager.setCredentials(this.config.username,this.config.password),this.authManager.addEventListener("auth_error",(t=>{console.error("Authentication error:",t.error)})),this.authManager.addEventListener("auth_success",(t=>{this.config.debug&&console.log("Authentication successful")})),this.authManager.addEventListener("auth_failed",(t=>{console.error("Authentication failed after retries:",t.error)})),this.config.autoAuth&&await this.authManager.authenticate()}async _initializeWebSocketManager(){const t=await this._getToken();this.wsManager=new Vu({debug:this.config.debug,token:t,baseUrl:this.config.wsUrl,apiBaseUrl:this.config.apiBaseUrl,maxConnections:this.config.maxConnections,reconnectOptions:{maxAttempts:5,delay:1e3,backoff:2},reloginCallback:async()=>{try{if(this.authManager){this.config.debug&&console.log("[MdasSDK] Attempting relogin after session revoked...");const t=await this.authManager.authenticate();return this.config.debug&&console.log("[MdasSDK] Relogin successful, new token obtained"),t}return this.config.authCallback?await this.config.authCallback():(console.error("[MdasSDK] No authentication method available for relogin"),null)}catch(t){return console.error("[MdasSDK] Relogin failed:",t),null}}}),this.wsManager.addEventListener=this.wsManager.addEventListener||(()=>{});try{await this.wsManager.connect(),this.config.debug&&console.log("WebSocketManager connected successfully")}catch(t){t.message.includes("401")||t.message.includes("403")?await this._handleWebSocketAuthError(t):console.error("Failed to connect WebSocketManager:",t)}}async _getToken(){if(this.authManager)return await this.authManager.getValidToken();if(this.config.authCallback){const t=await this.config.authCallback();return t.token||t}return this.config.token}async _handleWebSocketAuthError(t){if(!this.authManager)throw t;try{const e=await this.authManager.handleAuthError(t);await this._reconnectWithNewToken(e)}catch(t){throw console.error("Failed to recover from auth error:",t),t}}async _reconnectWithNewToken(t){this.wsManager&&(this.wsManager.updateToken(t),this.wsManager.disconnect(),await this.wsManager.connect())}}"undefined"!=typeof window&&(window.MdasSDK=Yu,window.MdasSDK.MdasSDK=Yu,window.MdasSDK.MarketDataModel=i,window.MdasSDK.NightSessionModel=w,window.MdasSDK.OptionsModel=_,window.MdasSDK.IntradayChartModel=z,window.MdasSDK.ONBBOLevel2Model=$u,window.MdasSDK.TimeSalesModel=Fu,window.MdasSDK.CombinedMarketWidget=I,window.MdasSDK.IntradayChartWidget=Nu,window.MdasSDK.ONBBOLevel2Widget=Ru,window.MdasSDK.TimeSalesWidget=Bu),t.CombinedMarketWidget=I,t.IntradayChartModel=z,t.IntradayChartWidget=Nu,t.MarketDataModel=i,t.MdasSDK=Yu,t.NightSessionModel=w,t.ONBBOLevel2Model=$u,t.ONBBOLevel2Widget=Ru,t.OptionChainWidget=E,t.OptionsModel=_,t.TimeSalesModel=Fu,t.TimeSalesWidget=Bu,t.default=Yu,Object.defineProperty(t,"__esModule",{value:!0})}));//# sourceMappingURL=mdas-sdk.min.js.map
|