openalgo-charts
Version:
From-scratch, dependency-free canvas charting engine for OpenAlgo: professional-grade interactive rendering, advanced on-chart trading, and a one-call widget tier that adds the toolbar, drawing rail, dialogs and shortcuts.
3 lines • 509 kB
JavaScript
import{readChartSettings as e,filterLinkAppearance as t,applyChartSettings as o,DEFAULT_PRICE_SCALE_OPTIONS as n,normalizeCombo as i,isReservedCombo as a,INDICATOR_SOURCES as r,registeredIntervals as s,parseSessionSpec as l,IndicatorInputError as c,formatZonedTimeSeconds as d,formatZonedTime as u,zoneOffsetSeconds as h,marketStatusAt as p,utcSecondsToZonedParts as g,formatZonedCrosshairLabel as m,registeredChartTypes as f,registeredSeriesTransforms as b,isReplaying as v,tryResolveInterval as w,isTimeBucketed as y,startOfZonedDay as _,nextBucketStart as x,bucketStartOf as k,dataVariantKey as C,normalizeDataVariant as S,isKnownInterval as A,registeredIndicators as O,getChartType as L,getSeriesTransform as E,exportChartDataCsv as $,zonedWallClockToUtcSeconds as T,getIndicator as j,indicatorStyleInputs as P,indicatorDefaults as M,chartSettingsSchema as I,registeredBarConditions as D,alertSettingsSchema as z,getBarCondition as N,PRICE_SCALE_MODES as R,checkTradingCapability as F,DEFAULT_TIMEZONE as W,attachSessionShading as B,lightTheme as q,darkTheme as U,DataLoadingController as H,resolveInterval as K,createChart as V,AlertController as G,ChartObjects as J,publishDataContext as Z,ShortcutManager as Y,createLinkGroup as Q}from"./openalgo-charts.mjs";import{hasDrawingTool as X,getDrawingTool as ee,DRAWING_STATE_VERSION as te,chromeIconSvg as oe,CHROME_ICON_STROKE as ne,chromeIcon as ie,DRAWING_TOOL_ICONS as ae,iconUse as re,iconSprite as se,toolCursor as le,drawingShortcuts as ce,keyToDrawingAction as de,memoryDrawingStore as ue,migrateUnscopedDrawings as he,InstrumentDrawings as pe,instrumentDrawingsKey as ge,chartTypeIcon as me,readDrawingSettings as fe,drawingSettingsSchema as be,applyDrawingSettings as ve,DEFAULT_FIB as we,gannLabel as ye,formatRatio as _e,readDrawingSetting as xe,cloneLevels as ke,LEVEL_NEUTRAL as Ce,levelColor as Se,studyInputTarget as Ae,registeredDrawingTools as Oe,LINE_STYLE_OPTIONS as Le,DrawingController as Ee,DrawingLinkGroup as $e}from"./openalgo-charts.draw.mjs";const Te=Object.freeze({}),je=/\{([A-Za-z][A-Za-z0-9_]*)\}/g;function Pe(e,t,o=Te,n=t){let i=n;if(void 0!==e.translate)try{const a=e.translate(t,n,Object.freeze({...o}));if("string"==typeof a&&""!==a.trim()){const e=new Set(Array.from(n.matchAll(je),e=>e[1])),t=new Set(Array.from(a.matchAll(je),e=>e[1]));e.size===t.size&&[...e].every(e=>t.has(e))&&(i=a)}}catch{}return i.replace(je,(e,t)=>Object.prototype.hasOwnProperty.call(o,t)?String(o[t]):e)}function Me(e,t){const o="string"==typeof t?t:t?.message;return"string"==typeof o&&""!==o.trim()?o:Pe(e,"unknown error")}const Ie=e=>String(e).replace(/[&<>"]/g,e=>"&"===e?"&":"<"===e?"<":">"===e?">":""");function De(e,t,o,n){const i=e.createElement(t);if(o&&(i.className=o),n)for(const[e,t]of Object.entries(n))i.setAttribute(e,t);return i}function ze(e,t,o){const n=e.createElement("span");return n.className="oac-glyph oac-glyph--"+o,n.setAttribute("aria-hidden","true"),n.innerHTML=t,n}function Ne(e){const t=e;if(null==t)return!1;if(!0===t.isContentEditable)return!0;const o=(t.tagName??"").toUpperCase();if("TEXTAREA"===o||"SELECT"===o)return!0;if("INPUT"!==o)return!1;const n=(t.type??"text").toLowerCase();return!["checkbox","radio","button","submit","reset","range","color"].includes(n)}function Re(e){if(null===e)return!1;const t=e;if(!0===t.disabled)return!1;const o=t.getAttribute("tabindex");if(null!==o&&Number(o)<0)return!1;const n=t.tagName;if(!("BUTTON"===n||"INPUT"===n||"SELECT"===n||"TEXTAREA"===n||"A"===n&&t.hasAttribute("href"))&&null===o)return!1;for(let e=t;null!==e;e=e.parentElement)if(e.hidden)return!1;return!0}const Fe=e=>Array.from(e.querySelectorAll("*")).filter(Re);function We(e,t,o,n=6,i=8){let a=e.right+n,r="right";a+t.width>o.width-i&&e.left-n-t.width>=i&&(a=e.left-n-t.width,r="left"),a=Math.max(i,Math.min(a,o.width-t.width-i));return{left:a,top:Math.max(i,Math.min(e.top,o.height-t.height-i)),side:r}}function Be(e,t,o,n=4,i=8){let a=e.bottom+n;return a+t.height>o.height-i&&e.top-n-t.height>=i&&(a=e.top-n-t.height),{left:Math.max(i,Math.min(e.left,o.width-t.width-i)),top:Math.max(i,Math.min(a,o.height-t.height-i))}}function qe(e,t,o,n="right",i=8,a=6){let r,s;if("right"===n||"left"===n){const l="right"===n;r=l?e.right+i:e.left-i-t.width,(l?r+t.width>o.width-a:r<a)&&(r=l?e.left-i-t.width:e.right+i),s=e.top+e.height/2-t.height/2}else{const l="top"!==n;s=l?e.bottom+i:e.top-i-t.height,(l?s+t.height>o.height-a:s<a)&&(s=l?e.top-i-t.height:e.bottom+i),r=e.left+e.width/2-t.width/2}return{left:Math.max(a,Math.min(r,o.width-t.width-a)),top:Math.max(a,Math.min(s,o.height-t.height-a))}}function Ue(e,t){const o=e.getBoundingClientRect(),n=t.getBoundingClientRect();return{left:n.left-o.left,top:n.top-o.top,right:n.right-o.left,bottom:n.bottom-o.top,width:n.width,height:n.height}}function He(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const Ke="oac-widget:";class Ve{constructor(e,t,o={}){Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_async",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_ns",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_journalKey",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_onError",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_mirror",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"_pending",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"_sending",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"_refused",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"_loading",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_loaded",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_memoryOnly",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_drain",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_queued",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_journaled",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_heard",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"_unsubscribe",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_closed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),this._ns=Ke+e+":",this._journalKey="oac-widget-journal:"+e;const n=null!==t&&"function"==typeof t.entries;this._store=n?null:t,this._async=n?t:null,this._loaded=!n,this._onError=o.onError}key(e){return this._ns+e}get(e){if(null!==this._async){const t=this._mirror.get(this.key(e));try{return void 0===t?null:JSON.parse(t)}catch{return null}}if(null===this._store)return null;try{const t=this._store.getItem(this.key(e));return null===t?null:JSON.parse(t)}catch{return null}}set(e,t){if(null!==this._async){let o;try{o=JSON.stringify(t)}catch{return!1}return this._queue(this.key(e),o??null),!0}if(null===this._store)return!1;try{return this._store.setItem(this.key(e),JSON.stringify(t)),!0}catch{return!1}}remove(e){if(null===this._async){if(null!==this._store)try{this._store.removeItem(this.key(e))}catch{}}else this._queue(this.key(e),null)}get enabled(){return null!==this._store||null!==this._async}get loaded(){return this._loaded}load(){return null===this._loading&&(this._loading=null===this._async?Promise.resolve():this._read(this._async)),this._loading}close(){this._closed=!0;const e=this._unsubscribe;this._unsubscribe=null;try{e?.()}catch{}}async flush(){if(null!==this._async){this._writeJournal(this._async.journal),this._requeue();do{await this._send()}while(this._pending.size>0&&!this._memoryOnly)}}_queue(e,t){null===t?this._mirror.delete(e):this._mirror.set(e,t),this._refused.delete(e),this._pending.set(e,t),this._queued||(this._queued=!0,queueMicrotask(()=>{this._queued=!1,this._send()}))}_requeue(){for(const[e,t]of this._refused)this._pending.has(e)||this._pending.set(e,t);this._refused.clear()}async _read(e){if(!this._closed&&"function"==typeof e.subscribe)try{this._unsubscribe=e.subscribe((e,t)=>this._hear(e,t))}catch{}let t=[];try{t=await(o=Promise.resolve().then(()=>e.entries(this._ns)),n=4e3,new Promise((e,t)=>{const i=setTimeout(()=>t(new Error(`no answer within ${n} ms`)),n);o.then(t=>{clearTimeout(i),e(t)},e=>{clearTimeout(i),t(e)})}))}catch(e){this._memoryOnly=!0,this._report("load",this._ns,e)}var o,n;if(!this._memoryOnly){const o=Ge(e.journal,this._journalKey,this._ns);if(null!==o){this._journaled=!0;for(const[e,t]of o)this._pending.has(e)||(null===t?this._mirror.delete(e):this._mirror.set(e,t),this._pending.set(e,t))}for(const e of Array.isArray(t)?t:[]){const[t,o]=e;"string"==typeof t&&t.startsWith(this._ns)&&"string"==typeof o&&!this._pending.has(t)&&this._mirror.set(t,o)}for(const[e,t]of this._heard)this._pending.has(e)||(null===t?this._mirror.delete(e):this._mirror.set(e,t))}this._heard.clear(),this._loaded=!0,!this._memoryOnly&&(this._pending.size>0||this._journaled)&&this._send()}_send(){const e=this._async;if(null!==this._drain||null===e)return this._drain??Promise.resolve();const t=(async()=>{for(await this.load();this._pending.size>0&&!this._memoryOnly;){const t=[...this._pending];this._pending.clear();for(const[e,o]of t)this._sending.set(e,o);(await Promise.allSettled(t.map(([t,o])=>Promise.resolve().then(()=>null===o?e.removeItem(t):e.setItem(t,o))))).forEach((e,o)=>{const[n,i]=t[o];this._sending.delete(n),"fulfilled"!==e.status&&(this._pending.has(n)||this._refused.set(n,i),this._report(null===i?"remove":"write",n,e.reason))})}if(this._journaled&&!this._memoryOnly&&0===this._pending.size&&0===this._sending.size&&0===this._refused.size){this._journaled=!1;try{e.journal?.removeItem(this._journalKey)}catch{}}})();return this._drain=t,t.finally(()=>{this._drain=null,this._pending.size>0&&!this._memoryOnly&&this._send()}),t}_hear(e,t){this._closed||this._memoryOnly||"string"!=typeof e||!e.startsWith(this._ns)||null!==t&&"string"!=typeof t||this._pending.has(e)||this._sending.has(e)||this._refused.has(e)||(this._loaded?null===t?this._mirror.delete(e):this._mirror.set(e,t):this._heard.set(e,t))}_writeJournal(e){if(null==e||this._memoryOnly)return;const t={};let o=!1;const n=this._loaded?[]:Ge(e,this._journalKey,this._ns)??[];for(const e of[n,this._refused,this._sending,this._pending])for(const[n,i]of e)t[n]=i,o=!0;if(o)try{e.setItem(this._journalKey,JSON.stringify({version:1,entries:t})),this._journaled=!0}catch{}}_report(e,t,o){try{this._onError?.({operation:e,key:t,error:o})}catch{}}}function Ge(e,t,o){if(null==e)return null;let n;try{n=e.getItem(t)}catch{return null}if(null===n)return null;try{const e=JSON.parse(n);return He(e)&&1===e.version&&He(e.entries)?Object.entries(e.entries).filter(e=>e[0].startsWith(o)&&("string"==typeof e[1]||null===e[1])):[]}catch{return[]}}function Je(){try{const e=globalThis;return void 0!==e.localStorage&&"function"==typeof e.localStorage.getItem?e.localStorage:null}catch{return null}}function Ze(e,t){const o=De(t,"div","oac-layer");e.appendChild(o);const n=[],i=()=>[...n].reverse().find(e=>0===e.suspended),a=e=>{if(e.closed)return;e.closed=!0;const o=n.indexOf(e);o>=0&&n.splice(o,1);const i=t.activeElement,a=null!==i&&e.el.contains(i);e.el.remove(),e.scrim?.remove(),e.opts.anchor?.setAttribute("aria-expanded","false");const r=null===i||i===t.body||a;!1!==e.opts.restoreFocus&&r&&null!==e.restore&&e.restore.isConnected&&e.restore.focus(),e.opts.onClose?.(),0===n.length&&c()},r=e=>{const o=i();if(void 0===o)return;if("Escape"===e.key){if(!1===o.opts.dismissOnEscape)return;return e.preventDefault(),e.stopImmediatePropagation(),void a(o)}if("Tab"!==e.key)return;const n=Fe(o.el);if(0===n.length)return void e.preventDefault();const r=n.indexOf(t.activeElement);let s=null;e.shiftKey?r<=0&&(s=n.length-1):(-1===r||r>=n.length-1)&&(s=0),null!==s&&(e.preventDefault(),n[s].focus())},s=e=>{const t=e.target;for(let e=n.length-1;e>=0;e--){const o=n[e];if(!(void 0===o||o.suspended>0)){if(null!==t&&(o.el.contains(t)||!0===o.opts.anchor?.contains(t)))break;if(!1===o.opts.dismissOnOutside||!0===o.opts.modal&&!0!==o.opts.dismissOnOutside)break;a(o)}}};let l=!1;const c=()=>{l&&(l=!1,t.removeEventListener("keydown",r,!0),t.removeEventListener("pointerdown",s,!0))};return{open:(i,c={})=>{const d=c.placement??(c.anchor?"below":"center"),u=c.modal??"center"===d,h=t.activeElement,p=null===h||h===t.body||i.contains(h)?c.anchor??null:h;let g=null;const m={el:i,opts:{...c,modal:u},scrim:null,restore:p,closed:!1,suspended:0};if(u&&(g=De(t,"div","oac-scrim"),!0===c.dismissOnOutside&&g.addEventListener("pointerdown",()=>a(m)),o.appendChild(g),m.scrim=g),i.addEventListener("pointerdown",e=>e.stopPropagation()),"center"===d?(i.classList.add("oac-dialog"),i.hasAttribute("role")||i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true")):i.classList.add("oac-pop"),i.hasAttribute("tabindex")||(i.tabIndex=-1),o.appendChild(i),"center"!==d&&c.anchor){const t=e.getBoundingClientRect();let o=Ue(e,c.anchor);if("beside"===d&&c.edge){const t=Ue(e,c.edge),n=Math.max(o.right,t.right);o={...o,right:n,width:n-o.left}}const n={width:i.offsetWidth,height:i.offsetHeight},a="beside"===d?We(o,n,t):Be(o,n,t);i.style.left=a.left+"px",i.style.top=a.top+"px",c.anchor.setAttribute("aria-expanded","true")}if(n.push(m),l||(l=!0,t.addEventListener("keydown",r,!0),t.addEventListener("pointerdown",s,!0)),null!==c.initialFocus){(c.initialFocus??function(e){const t=Fe(e);return t.find(e=>null===e.closest(".oac-dialog__head"))??t[0]??null}(i)??i).focus()}return()=>a(m)},suspend:e=>{const o=n.find(t=>t.el===e);if(!o||o.closed)return()=>{};0===o.suspended&&(o.suspension={hidden:o.el.hidden,scrimHidden:o.scrim?.hidden??!1,focus:t.activeElement}),o.suspended++,o.el.hidden=!0,o.scrim&&(o.scrim.hidden=!0);let i=!1;return()=>{if(i)return;if(i=!0,o.suspended--,o.closed||o.suspended>0)return;const e=o.suspension;o.suspension=void 0,o.el.hidden=e.hidden,o.scrim&&(o.scrim.hidden=e.scrimHidden),!e.hidden&&e.focus?.isConnected&&o.el.contains(e.focus)&&e.focus.focus()}},closeTop:()=>{const e=i();return void 0!==e&&(a(e),!0)},closeAll:()=>{for(const e of n.slice().reverse())a(e)},top:()=>i()?.el??null,size:()=>n.length,layer:o,destroy:()=>{for(const e of n.slice().reverse())a(e);c(),o.remove()}}}const Ye=600;function Qe(e,t,o){const n=new WeakMap;let i=null,a=0,r=null;const s=e=>"function"==typeof e?e():e,l=()=>{0!==a&&clearTimeout(a),a=0,r=null,i?.classList.remove("is-on")},c=a=>{const c=n.get(a);if(void 0===c||!a.isConnected)return;const d=s(c);if(null===d||!d.title)return void l();if("function"==typeof c&&a.setAttribute("aria-label",d.label??d.title),null===i&&(i=De(o,"div","oac-tip",{role:"presentation"})),i.parentNode!==t&&t.appendChild(i),r=a,i.textContent="",i.appendChild(o.createTextNode(d.title)),d.chord){const e=De(o,"kbd","oac-tip__chord");e.textContent=d.chord,i.appendChild(e)}if(d.sub){const e=De(o,"span","oac-tip__sub");e.textContent=d.sub,i.appendChild(e)}const u=e.getBoundingClientRect(),h=qe(Ue(e,a),{width:i.offsetWidth,height:i.offsetHeight},u,d.side??"right");i.style.left=h.left+"px",i.style.top=h.top+"px",i.classList.add("is-on")};return{attach:(e,t,o=0)=>{n.set(e,t);const i=s(t);null!==i&&i.title&&!e.getAttribute("aria-label")&&e.setAttribute("aria-label",i.label??i.title),e.removeAttribute("title");const r=()=>{0!==a&&clearTimeout(a),o>0?a=setTimeout(()=>c(e),o):c(e)};e.addEventListener("pointerenter",r),e.addEventListener("focus",r),e.addEventListener("pointerleave",l),e.addEventListener("blur",l),e.addEventListener("pointerdown",l),e.addEventListener("keydown",l)},refreshLabel:e=>{const t=n.get(e);if("function"!=typeof t)return;const o=t();null!==o&&o.title&&e.setAttribute("aria-label",o.label??o.title)},show:c,hide:l,target:()=>r,destroy:()=>{l(),i?.remove(),i=null}}}function Xe(e,t){return t.filter(t=>!1!==e.get(t)?.policy?.editable)}function et(e){return X(e)?ee(e):null}function tt(e,t){const o=e.history;return void 0===o||o.isDestroyed?"undo"===t?e.draw.undo():e.draw.redo():"undo"===t?o.undo():o.redo()}function ot(e,t,o){void 0!==e.history?e.history.transact(o,t):o()}function nt(e,t){const o=e.history;return void 0===o||o.isDestroyed?"undo"===t?e.draw.canUndo():e.draw.canRedo():"undo"===t?o.canUndo():o.canRedo()}class it{constructor(){Object.defineProperty(this,"_handlers",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}on(e,t){let o=this._handlers.get(e);return void 0===o&&(o=new Set,this._handlers.set(e,o)),o.add(t),()=>this.off(e,t)}off(e,t){void 0!==t?this._handlers.get(e)?.delete(t):this._handlers.delete(e)}emit(e,t){const o=this._handlers.get(e);if(void 0===o)return;const n=[];for(const e of Array.from(o))try{e(t)}catch(e){n.push(e)}if(n.length>0)throw n[0]}clear(){this._handlers.clear()}}const at=new Map;function rt(e,t){return at.set(e,t),()=>{at.get(e)===t&&at.delete(e)}}function st(e){const t=Object.entries(e).map(([e,t])=>rt(e,t));return()=>{for(const e of t)e()}}function lt(e){return at.delete(e)}function ct(e){return at.get(e)??null}function dt(){return Array.from(at.keys())}function ut(e){let t=null;const o={now:null,load:()=>t??(t=e().then(e=>o.now=e,e=>{throw t=null,e}))};return o}function ht(e,t,o,n,i){if(null!==e.now)return void t(e.now);let a=()=>!!n()||null;if(void 0!==i){const{slot:e,doc:t,from:o}=i,r=e.waiting={},s=t.activeElement;let l=!1;const c=e=>{!0!==o?.contains(e.target)&&(l=!0)},d=e=>{"Escape"===e.key&&(l=!0)};t.addEventListener("pointerdown",c,!0),t.addEventListener("keydown",d,!0),a=()=>{if(t.removeEventListener("pointerdown",c,!0),t.removeEventListener("keydown",d,!0),e.waiting!==r)return null;if(e.waiting=null,!n())return null;const o=t.activeElement;return!(l||o!==s&&Ne(o))}}e.load().then(e=>{!0===a()&&t(e)},e=>{null!==a()&&o(e)})}function pt(e,t,o){return Pe(e,"{name} could not load: {error}",{name:t,error:Me(e,o)})}const gt="openalgo-charts-widget",mt=ut(()=>import("./openalgo-charts.widget.storage-idb-WH_o01Wj.mjs"));function ft(e,t){let o=null,n=!1;const i=new Map,a=t=>{if(null!==o)return o;const a=o=e(t);for(const e of i.keys())i.set(e,a.subscribe?.(e));return n&&a.close?.(),a},r=()=>o??(null===mt.now?null:a(mt.now)),s=e=>{const t=r();return null!==t?e(t):mt.load().then(t=>e(a(t)))};return null===r()&&mt.load().then(a,()=>{}),{journal:t,entries:e=>s(t=>t.entries(e)),setItem:(e,t)=>s(o=>o.setItem(e,t)),removeItem:e=>s(t=>t.removeItem(e)),subscribe:e=>(i.set(e,r()?.subscribe?.(e)),()=>{i.get(e)?.(),i.delete(e)}),close(){n=!0,o?.close?.()}}}function bt(e,t=gt,o={}){const n=void 0===o.journal?Je():o.journal;return ft(i=>i.openIndexedDbStore(e,t,{...o,journal:n}),n)}let vt=null;function wt(){let e;try{e=globalThis.indexedDB??void 0}catch{e=void 0}if(void 0===e||"function"!=typeof e.open)return Je();const t=e;return null!==vt&&vt.factory===t||(vt={factory:t,store:ft(e=>e.openPageDefault(t),Je())}),vt.store}function yt(e,t){if(Object.is(e,t))return!0;if("number"==typeof e&&"number"==typeof t)return Math.abs(e-t)<1e-9;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((e,o)=>yt(e,t[o]));if(!He(e)||!He(t))return!1;const o=new Set([...Object.keys(e),...Object.keys(t)]);for(const n of o)if(!yt(e[n],t[n]))return!1;return!0}const _t=e=>He(e)&&"indicator"===e.kind&&"string"==typeof e.instanceId;function xt(e,t){const o={};for(const[n,i]of Object.entries(e))o[n]=_t(i)?{...i,instanceId:t(i.instanceId)}:Array.isArray(i)?i.map(e=>He(e)?{...e}:e):He(i)?{...i}:i;return o}function kt(e,t){const o=e.seriesType(t),n=e.seriesTransform(t);return null===o||null===n?o:`${o}+${n.type}`}const Ct=["mode","inverted","marginTop","marginBottom"],St=new Set(["scales.mode","scales.inverted","scales.autoScale"]),At=["objects:change","indicatorRemoved","paneAdded","paneRemoved","paneMoved","paneCollapsed","paneResized","priceAxisMoved","priceAxisPlacementChanged","layout:change"];function Ot(e,t,o){const n={type:!1,scale:!1,settings:[],defaults:[],studies:new Map,kinds:new Set,order:!1,paneOrder:!1,panes:new Map,born:[],gone:[]};if(e.type!==t.type&&(n.type=!0,n.kinds.add("chart-type")),e.scale!==t.scale&&(n.scale=!0,n.kinds.add("series-scale")),e.settings&&t.settings)for(const o of new Set([...Object.keys(e.settings),...Object.keys(t.settings)]))!St.has(o)&&o in e.settings&&o in t.settings&&!yt(e.settings[o],t.settings[o])&&n.settings.push(o);n.defaults=Ct.filter(o=>!yt(e.defaults[o],t.defaults[o])),(n.settings.length||n.defaults.length)&&n.kinds.add("settings");const i=new Map(e.studies.map(e=>[e.id,e])),a=new Map(t.studies.map(e=>[e.id,e])),r={presence:!0,keys:[],visible:!0,scale:!0,pane:!0};for(const[e,t]of i){if(void 0!==o&&!o.present(e))continue;const i=a.get(e),s=o?.policy(e)??{};if(void 0===i){!1!==s.removable&&(n.studies.set(e,r),n.kinds.add("study-remove"));continue}const l=!1===s.configurable?[]:[...new Set([...Object.keys(t.settings),...Object.keys(i.settings)])].filter(e=>!yt(t.settings[e],i.settings[e])),c={presence:!1,keys:l,visible:t.visible!==i.visible,scale:!1!==s.configurable&&(t.scale!==i.scale||!yt(t.plots,i.plots)),pane:!1!==s.movable&&t.pane!==i.pane};l.length&&n.kinds.add("study-settings"),c.visible&&n.kinds.add("study-visibility"),c.scale&&n.kinds.add("study-scale"),c.pane&&n.kinds.add("study-pane"),(l.length||c.visible||c.scale||c.pane)&&n.studies.set(e,c)}for(const e of a.keys())i.has(e)||(void 0===o||!o.present(e)&&o.returns(e))&&(n.studies.set(e,r),n.kinds.add("study-add"));const s=(e,t)=>e.studies.filter(e=>e.pane===t&&i.has(e.id)&&a.has(e.id)).map(e=>e.id);for(const i of new Set(t.studies.map(e=>e.pane)))yt(s(e,i),s(t,i))||void 0!==o&&!o.order(t,i)||(n.order=!0);n.order&&n.kinds.add("study-order");const l=new Map(e.panes.map(e=>[e.key,e])),c=new Set(t.panes.map(e=>e.key)),d=(e,t)=>t.studies.some(t=>t.pane===e.key&&n.studies.has(t.id)),u=(e,t)=>d(e,t)||0===e.series&&!0!==e.host;n.gone=e.panes.filter(t=>!c.has(t.key)&&u(t,e)).map(e=>e.key),n.born=t.panes.filter(e=>!l.has(e.key)&&u(e,t)).map(e=>e.key),e.panes.some(t=>n.gone.includes(t.key)&&!d(t,e))&&n.kinds.add("pane-remove"),t.panes.some(e=>n.born.includes(e.key)&&!d(e,t))&&n.kinds.add("pane-add");const h=t.panes.filter(e=>l.has(e.key));yt(e.panes.filter(e=>h.some(t=>t.key===e.key)).map(e=>e.key),h.map(e=>e.key))||(n.paneOrder=!0,n.kinds.add("pane-order"));for(const e of h){const t=l.get(e.key),o={weight:!yt(e.weight,t.weight),collapsed:e.collapsed!==t.collapsed,axes:new Map};o.weight&&n.kinds.add("pane-weight"),o.collapsed&&n.kinds.add("pane-collapse");for(const[i,a]of Object.entries(e.axes)){const e=t.axes[i];if(void 0===e)continue;const r=Object.keys(a).filter(t=>t in e&&!yt(a[t],e[t]));r.length&&(o.axes.set(i,r),n.kinds.add("axis"))}(o.weight||o.collapsed||o.axes.size)&&n.panes.set(e.key,o)}return n}const Lt=e=>0===e.kinds.size,Et={"study-add":"study-remove","study-remove":"study-add","pane-add":"pane-remove","pane-remove":"pane-add"};function $t(e){const t=e.id,o={...e.policy()};return{id:t,policy:()=>o}}class Tt extends Error{}const jt=e=>{throw new Tt(e)};class Pt{constructor(e,t={}){Object.defineProperty(this,"_chart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_draw",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_opts",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_limit",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_undo",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_redo",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_base",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_epoch",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_pending",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_applying",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_ignoring",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_restoring",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_tx",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_styled",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_drawings",{enumerable:!0,configurable:!0,writable:!0,value:{version:te,drawings:[]}}),Object.defineProperty(this,"_group",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_dragging",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_deferred",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_dropped",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_orphans",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_keys",{enumerable:!0,configurable:!0,writable:!0,value:new WeakMap}),Object.defineProperty(this,"_nextKey",{enumerable:!0,configurable:!0,writable:!0,value:1}),Object.defineProperty(this,"_seen",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"_hostPanes",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"_names",{enumerable:!0,configurable:!0,writable:!0,value:new WeakMap}),Object.defineProperty(this,"_known",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"_lastNames",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"_hostRemoved",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"_listeners",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"_off",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_release",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_nextHolder",{enumerable:!0,configurable:!0,writable:!0,value:1}),Object.defineProperty(this,"_heard",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),this._chart=e,this._draw=t.draw??null,this._opts=t,this._limit=Math.max(1,Math.floor(t.limit??100)),this._base=this._shot(!1),this._drawings=this._document(),this._listen(),this._claim()}get isDestroyed(){return this._destroyed}attach(e,t=this._draw){if(this._destroyed)return;for(const e of this._off.splice(0))e();const o=this._base.panes.map(e=>e.key),n=new Map(this._base.studies.map(e=>[this._liveId(e.id),e.id]));t!==this._draw&&this._detachSteps();const i=this._chart;if(this._chart=e,this._draw=t,this._claim(),this._drawings=this._document(),e.panes().forEach((e,t)=>{void 0!==o[t]&&this._keys.set(e,o[t])}),!e.isDestroyed)for(const t of e.indicators()){const e=n.get(t.id);void 0!==e&&this._bind(e,t)}if(e!==i){const t=new Set(e.isDestroyed?[]:e.indicators());for(const[e,o]of this._known)t.has(o)||this._known.set(e,$t(o))}this._pending=!1,this._dragging=!1,this._deferred=!1;const a=this._base;this._rebase(),this._took(a,this._base),this._prune(),this._listen(),this._notify()}canUndo(){return this._undo.some(e=>this._reachable(e,"undo"))}canRedo(){return this._redo.some(e=>this._reachable(e,"redo"))}peekUndo(){return this._peek(this._undo,"undo")}peekRedo(){return this._peek(this._redo,"redo")}undo(){return this._move("undo")}redo(){return this._move("redo")}transact(e,t){if(this._destroyed||this._chart.isDestroyed||this._applying>0||this._ignoring>0||null!==this._tx)return e();const o=this.group(t);this._flush();const n=this._tx={label:t,before:this._shot(!0),steps:[],commands:[]};try{return e()}finally{this._cut(n),this._tx=null,o()}}_cut(e){this._pending=!1;const t=this._shot(!0);this._base=t;const o=this._styled;this._styled=!1,this._record({label:e.label,before:e.before,after:t,steps:e.steps.splice(0),commands:e.commands.splice(0),orphans:this._takeOrphans(),linked:o})}_rebase(){this._epoch++,this._base=this._shot(!1)}group(e){if(this._destroyed)return()=>{};if(null!==this._group)return this._group.depth++,this._closer(this._group);this._flush();const t=this._group={entry:null,label:e,depth:1};return this._closer(t)}ignore(e){if(this._destroyed||this._applying>0)return e();const t=0===this._ignoring?this._tx:null;null!==t?this._cut(t):this._flush(),this._ignoring++;try{return this._untracked(e)}finally{if(0===--this._ignoring){this._pending=!1,this._orphans=[],this._styled=!1;const e=this._base;this._rebase(),this._took(e,this._base),null!==t&&this._tx===t&&(this._base=t.before=this._shot(!0)),this._prune()}}}_untracked(e){const t=this._draw;return null===t||t.isDestroyed?e():t.untracked(e)}push(e){this._destroyed||this._applying>0||this._ignoring>0||(null===this._tx?(this._flush(),this._record({label:e.label,commands:[e]})):this._tx.commands.push(e))}clear(){this._undo.length=0,this._redo.length=0,null!==this._group&&(this._group.entry=null),this._pending=!1,this._orphans=[],this._dropped=[],this._hostRemoved.clear(),this._lastNames.clear();const e=new Set(this._chart.isDestroyed?[]:this._chart.indicators());for(const[t,o]of this._known)e.has(o)||this._known.delete(t);this._destroyed||(this._drawings=this._document(),this._rebase()),this._notify()}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}destroy(){if(!this._destroyed){this.clear(),this._destroyed=!0;for(const e of this._off.splice(0))e();this._release?.(),this._release=null,this._listeners.clear()}}_claim(){this._release?.(),this._release=null;const e=this._draw;null===e||e.isDestroyed||(this._release=e.delegateInputAnchorSteps(()=>this._anchorMoved()))}_anchorMoved(){this._destroyed||this._applying>0||this._ignoring>0||this._restoring>0||null!==this._tx||this._flush()}_listen(){const e=this._chart;if(e.isDestroyed)return;const t=(t,o)=>{this._off.push(e.on(t,o))};for(const e of At)t(e,()=>this._observe(e));t("drag:start",()=>this._flush()),t("draw:preview",()=>{this._dragging=!0}),t("draw:preview-clear",()=>{this._dragging=!1,this._deferred&&(this._deferred=!1,this._observe("objects:change"))}),t("style:change",()=>{null!==this._tx&&0===this._applying&&0===this._ignoring&&0===this._restoring&&(this._styled=!0)}),t("draw:remove",e=>{const t=e?.drawing;void 0!==t&&0===this._applying&&this._dropped.push(t)}),t("drawing:change",e=>this._drawingChange(e)),t("draw:restore",()=>this._forgetDrawings()),t("draw:destroy",e=>{e?.controller===this._draw&&(this._detachSteps(),this._draw=null,this._release=null)}),t("state:restore:start",()=>{this._restoring++,this._pending=!1}),t("state:restore:end",()=>{0===--this._restoring&&this.clear()}),t("destroy",()=>{if(this._chart===e)for(const e of this._off.splice(0))e()})}_observe(e){this._destroyed||this._applying>0||this._ignoring>0||this._restoring>0||null!==this._tx||("objects:change"===e&&this._dragging?this._deferred=!0:this._pending||(this._pending=!0,queueMicrotask(()=>{this._pending&&this._flush()})))}_flush(){if(!this._pending||this._destroyed)return;this._pending=!1;const e=this._group?.entry?.changes,t=void 0===e?void 0:e[e.length-1],o=this._shot(!0===t?.before.full&&t.epoch===this._epoch),n=this._base;this._base=o,this._record({before:n,after:o,orphans:this._takeOrphans()})}_drawingChange(e){const t=this._dropped;if(this._dropped=[],this._destroyed||this._applying>0)return;const o=this._drawings;if(this._drawings=this._document(),void 0!==e.step){if(this._ignoring>0)return;const t={id:e.step,before:o,after:this._drawings,detached:!1};return null!==this._tx?void this._tx.steps.push(t):(this._flush(),void this._record({steps:[t]}))}if("update"===e.kind&&!0!==e.linked&&t.length>0&&(this._pending||null!==this._tx||this._paneGone())){const e=this._base.panes.map(e=>e.key);for(const o of t){const t=e[o.paneIndex];void 0!==t&&this._orphans.push({pane:t,drawing:o})}return}"undo"!==e.kind&&"redo"!==e.kind||this._follow(e.kind)}_document(){return this._draw?.toJSON()??{version:te,drawings:[]}}_forgetDrawings(){if(this._destroyed||this._applying>0)return;const e=this._group,t=e=>e.changes.length>0||e.commands.length>0;for(const t of[...this._undo,...this._redo,...e?.redo??[],e?.entry,e?.shifted])t&&(t.steps=[],t.orphans=[]);null!==this._tx&&(this._tx.steps=[]),this._undo=this._undo.filter(t),this._redo=this._redo.filter(t),e?.entry&&!t(e.entry)&&(e.entry=null),this._orphans=[],this._dropped=[],this._prune(),this._notify()}_paneGone(){const e=new Set(this._chart.panes().map(e=>this._keys.get(e)));return this._base.panes.some(t=>!e.has(t.key))}_detachSteps(){for(const e of[...this._undo,...this._redo])for(const t of e.steps)t.detached=!0;if(null!==this._tx)for(const e of this._tx.steps)e.detached=!0}_takeOrphans(){const e=this._orphans;return this._orphans=[],e}_record(e){const t=void 0!==e.before&&void 0!==e.after&&!Lt(Ot(e.before,e.after)),o=t&&!Lt(Ot(e.after,e.before,this._rules));if(t&&!o&&(this._epoch++,this._took(e.before,e.after)),!o&&!e.steps?.length&&!e.commands?.length)return t&&this._prune(),void this._notifyIfMoved();let n;const i=this._group;if(null!==i&&null!==i.entry)n=i.entry;else{n={label:i?.label,changes:[],steps:[],commands:[],orphans:[]},this._undo.push(n);const e=this._undo.length>this._limit?this._undo.shift():void 0;null!==i&&Object.assign(i,{entry:n,redo:this._redo,shifted:e})}this._merge(n,e,o),this._redo=[],this._prune(),this._notify()}_merge(e,t,o){if(e.label??(e.label=t.label),!0===t.linked&&(e.linked=!0),o){const o=t.before,a=t.after,r=e.changes[e.changes.length-1];void 0===r||r.epoch!==this._epoch?e.changes.push({before:o,after:a,epoch:this._epoch}):(!r.before.full&&o.full&&(r.before={...r.before,full:!0,settings:o.settings,panes:(n=r.before.panes,i=o.panes,n.map(e=>{const t=i.find(t=>t.key===e.key);if(void 0===t)return e;const o={};for(const[n,i]of Object.entries(e.axes)){const e=t.axes[n];o[n]=void 0===e?i:{...i,auto:e.auto,lock:e.lock}}return{...e,axes:o}}))}),r.after=a),e.orphans.push(...t.orphans??[])}var n,i;e.steps.push(...t.steps??[]),e.commands.push(...t.commands??[])}_closer(e){let t=!1;return()=>{if(t)return;if(t=!0,--e.depth>0||this._group!==e)return;this._flush(),this._group=null;const o=e.entry,n=o?.changes??[];if(null!==o&&!o.steps.length&&!o.commands.length&&(!n.length||Lt(Ot(n[0].before,n[n.length-1].after)))){const t=this._undo.lastIndexOf(o);t>=0&&(this._undo.splice(t,1),void 0!==e.shifted&&this._undo.unshift(e.shifted),this._redo.length||void 0===e.redo||(this._redo=e.redo))}this._prune(),this._notify()}}_keyOf(e){let t=this._keys.get(e);return void 0===t&&(t=this._nextKey++,this._keys.set(e,t)),t}_nameOf(e){let t=this._names.get(e);if(void 0!==t)return t;t=e.id;const o=this._known.get(t);if(void 0!==o&&o!==e)do{t=`${e.id}~${this._nextHolder++}`}while(this._known.has(t));return this._bind(t,e),t}_bind(e,t){this._names.set(t,e),this._known.set(e,t)}_liveId(e){return this._known.get(e)?.id??e}_policyOf(e){return this._known.get(e)?.policy()??{}}_took(e,t){const o=new Set(t.studies.map(e=>e.id));for(const t of e.studies)o.has(t.id)||this._hostRemoved.add(t.id)}_prune(){const e=this._chart,t=new Set(e.isDestroyed?[]:e.indicators()),o=new Set;if(!e.isDestroyed)for(const t of e.panes()){const e=this._keys.get(t);void 0!==e&&o.add(e)}if(0===this._hostRemoved.size&&this._lastNames.size<=t.size&&this._seen.size<=o.size&&[...this._known.values()].every(e=>t.has(e)))return;const n=new Set,i=e=>{for(const t of e.panes)o.add(t.key);for(const t of e.studies){n.add(t.id);for(const e of Object.values(t.settings))_t(e)&&n.add(e.instanceId)}},a=e=>{if(null!=e){for(const t of e.changes)i(t.before),i(t.after);for(const t of e.orphans)o.add(t.pane)}};for(const e of this._undo)a(e);for(const e of this._redo)a(e);const r=this._group;null!==r&&(a(r.entry),r.redo?.forEach(a),a(r.shifted)),null!==this._tx&&i(this._tx.before),i(this._base);for(const e of this._orphans)o.add(e.pane);for(const[e,o]of this._known)n.has(e)||t.has(o)||this._known.delete(e);for(const e of this._hostRemoved)this._known.has(e)||this._hostRemoved.delete(e);for(const[e,t]of this._lastNames)this._known.has(t)||this._lastNames.delete(e);for(const e of this._seen)o.has(e)||this._seen.delete(e);for(const e of this._hostPanes)o.has(e)||this._hostPanes.delete(e)}_view(){const e={order:[],pane:new Map};if(this._chart.isDestroyed)return e;const t=this._chart.panes();for(const o of this._chart.indicators()){const n=this._nameOf(o);e.order.push(n),e.pane.set(n,this._keys.get(t[o.paneIndex])??-1)}return e}_series(){return(this._opts.series?this._opts.series():this._chart.primarySeries())??null}_shot(t){const o=this._chart,n={full:t,type:null,scale:null,studies:[],panes:[],defaults:{}};if(o.isDestroyed)return n;const i=0===this._seen.size,a=o.panes(),r=a.map(e=>this._keyOf(e)),s=this._series(),l=s?.priceScale();s&&(n.type=kt(o,s)),a.forEach((e,i)=>{const a={};for(const[r,s]of Object.entries(e.scaleStates())){if(void 0===s)continue;const c=r;void 0!==l&&e.scaleFor(c)===l&&(n.scale=c);const d=o.priceAxisPlacement(i,c),u={side:d?.side??("left"===c||"right"===c?c:"hidden"),order:d?.order??0,mode:s.mode,inverted:s.inverted,marginTop:s.marginTop,marginBottom:s.marginBottom};t&&(u.auto=s.autoScale,u.lock=e.ratioLocked(c)),a[r]=u}const s={key:r[i],weight:o.paneWeight(i),collapsed:o.paneCollapsed(i),series:e.series().length,axes:a};if(0===s.series){s.ranges={};for(const t of Object.keys(a)){const o=e.scaleFor(t);o.scaled&&(s.ranges[t]=o.priceRange())}}n.panes.push(s)});const c=o.indicators(),d=c.map(e=>this._nameOf(e));c.forEach((e,t)=>this._lastNames.set(e.id,d[t]));const u=e=>this._lastNames.get(e)??e;n.studies=c.map((e,t)=>({id:d[t],indicatorId:e.indicatorId,settings:xt(e.settings(),u),pane:r[e.paneIndex]??-1,visible:e.visible(),scale:e.priceScaleId(),plots:{...e.plotPriceScaleIds()}}));for(const e of n.panes)this._seen.has(e.key)||(this._seen.add(e.key),i||n.studies.some(t=>t.pane===e.key)||this._hostPanes.add(e.key)),this._hostPanes.has(e.key)&&(e.host=!0);const h=o.priceScaleDefaults();for(const e of Ct)void 0!==h[e]&&(n.defaults[e]=h[e]);return t&&(n.settings=e(o)),n}_peek(e,t){for(let o=e.length-1;o>=0;o--)if(this._reachable(e[o],t))return this._describe(e[o],t);return null}_describe(e,t){const o=new Set,n=e=>"redo"===t?e:Et[e]??e;for(const i of this._moves(e,t))for(const e of i.delta.kinds)o.add(n(e));return e.steps.length&&o.add("drawing"),e.commands.length&&o.add("command"),{...void 0===e.label?{}:{label:e.label},changes:[...o]}}_moves(e,t){const o="undo"===t,n=this._view(),i=[];for(const t of o?e.changes.slice().reverse():e.changes){const e=o?t.after:t.before,a=o?t.before:t.after,r=Ot(e,a,this._rulesFor(n));Lt(r)||(i.push({from:e,to:a,delta:r}),this._project(n,a,r))}return i}_project(e,t,o){const n=new Map(t.studies.map(e=>[e.id,e]));let i=!1;for(const[t,a]of o.studies){const o=n.get(t);void 0!==o?(a.presence&&!e.pane.has(t)&&(e.order.push(t),i=!0),(a.presence||a.pane)&&e.pane.set(t,o.pane)):(e.order=e.order.filter(e=>e!==t),e.pane.delete(t))}if(o.order||i)for(const o of t.panes){const n=this._plan(e,t,o.key);if(null===n||n.blocked)continue;let i=0;e.order=e.order.map(t=>e.pane.get(t)===o.key?n.desired[i++]:t)}}_plan(e,t,o){const n=e.order.filter(t=>e.pane.get(t)===o),i=t.studies.filter(e=>e.pane===o).map(e=>e.id).filter(e=>n.includes(e)),a=n.slice();let r=0;if(n.forEach((e,t)=>{i.includes(e)&&(a[t]=i[r++])}),yt(a,n))return null;const s=e=>!1===this._policyOf(e).movable;return{now:n,desired:a,blocked:!yt(n.filter(s),a.filter(s))}}_reachable(e,t){if(e.commands.length||this._moves(e,t).length)return!0;const o=this._draw?.historySteps()[t]??[];return e.steps.some(e=>e.detached||o.includes(e.id))}_move(e){if(this._destroyed||this._applying>0||this._chart.isDestroyed)return!1;this._flush(),null!==this._group&&(this._group.entry=null);const t="undo"===e?this._undo:this._redo,o="undo"===e?this._redo:this._undo;for(let n=t.pop();void 0!==n;n=t.pop()){const i=this._run(n,e);if("skip"!==i)return"done"===i?o.push(n):t.length=0,this._prune(),this._notify(),"done"===i}return this._prune(),this._notify(),!1}_run(e,t){const o="undo"===t,n=this._draw?.historySteps();e.steps=e.steps.filter(e=>e.detached||void 0!==n&&(n.undo.includes(e.id)||n.redo.includes(e.id)));const i=this._moves(e,t);if(!e.commands.length&&!i.length&&!e.steps.length)return"skip";const a={steps:[],moves:0,commands:0},r=!0===e.linked?this._look():null;this._applying++;try{if(this._untracked(()=>{if(!o)for(const t of e.commands)!1===t.redo()&&jt("command"),a.commands++;o&&this._drawSteps(e.steps.slice().reverse(),"undo",a.steps);for(const e of i)a.moves++,this._apply(e.to,e.delta);if(o&&this._restoreOrphans(e.orphans),o||this._drawSteps(e.steps,"redo",a.steps),o)for(const t of e.commands.slice().reverse())!1===t.undo()&&jt("command"),a.commands++}),null!==r&&!this._chart.isDestroyed){const e=this._look(),t=Object.fromEntries(Object.entries(e).filter(([e,t])=>!yt(r[e],t)));Object.keys(t).length&&this._chart.emit("style:change",t)}return"done"}catch(o){this._rollback(e,t,a,i);try{this._opts.onError?.({direction:t,step:this._describe(e,t),error:o})}catch{}return"fail"}finally{this._applying--,this._pending=!1,this._dropped=[],this._orphans=[],this._drawings=this._document(),this._rebase()}}_rollback(e,t,o,n){const i="undo"===t,a=e=>{try{this._untracked(e)}catch{}},r=i?e.commands.slice().reverse():e.commands;for(const e of r.slice(0,o.commands).reverse())a(()=>{i?e.redo():e.undo()});for(const e of n.slice(0,o.moves).reverse())a(()=>this._apply(e.from,Ot(e.to,e.from,this._rules)));a(()=>this._drawSteps(o.steps.slice().reverse(),i?"redo":"undo",[]))}_look(){return this._chart.isDestroyed?{}:t(e(this._chart))}_drawSteps(e,t,o){const n=this._draw;if(null!==n)for(const i of e){const e=n.historySteps()[t];if(!i.detached&&e.includes(i.id)&&e[e.length-1]!==i.id&&(i.detached=!0),i.detached){const[e,a]="undo"===t?[i.after,i.before]:[i.before,i.after],r=new Map(e.drawings.map(e=>[e.id,e])),s=new Map(a.drawings.map(e=>[e.id,e]));for(const e of new Set([...r.keys(),...s.keys()]))yt(r.get(e),s.get(e))||n.applyLinkedDrawing(e,s.get(e)??null);o.push(i);continue}for(let e=0;n.historySteps()[t].includes(i.id)&&e<1e3&&("undo"===t?n.undo():n.redo());e++);n.historySteps()[t].includes(i.id)&&jt("drawing"),o.push(i)}else e.length&&jt("drawing")}_follow(e){const t=this._draw?.historySteps();if(void 0===t)return;const o="undo"===e?this._undo:this._redo,n="undo"===e?this._redo:this._undo,i="undo"===e?t.redo:t.undo;for(let e=o[o.length-1];void 0!==e&&(!e.commands.length&&!e.changes.length&&e.steps.length&&e.steps.every(e=>!e.detached&&i.includes(e.id)));e=o[o.length-1])n.push(o.pop());this._notify()}_restoreOrphans(e){const t=this._draw;if(null!==t)for(const{pane:o,drawing:n}of e){const e=this._slot(o);e>=0&&void 0===t.get(n.id)&&t.applyLinkedDrawing(n.id,{...n,paneIndex:e})}}_slot(e){return this._chart.panes().findIndex(t=>this._keys.get(t)===e)}_find(e){const t=this._known.get(e);return void 0===t||this._chart.isDestroyed?void 0:this._chart.indicators().find(e=>e===t)}_rulesFor(e){return{policy:e=>this._policyOf(e),present:t=>e.pane.has(t),returns:e=>!this._hostRemoved.has(e)&&!1!==this._policyOf(e).removable,order:(t,o)=>{const n=this._plan(e,t,o);return null!==n&&!n.blocked}}}get _rules(){return this._rulesFor(this._view())}_apply(t,i){const a=this._chart,r=new Map(t.studies.map(e=>[e.id,e]));for(const e of i.studies.keys()){if(r.has(e))continue;const t=this._find(e);void 0===t||a.removeIndicator(t.id)||jt("remove")}const s=t.studies.filter(e=>{const t=i.studies.get(e.id);return void 0!==t&&(t.presence||t.pane)&&this._find(e.id)?.paneIndex!==this._slot(e.pane)}),l=[];for(;s.length;){const e=e=>Object.values(e.settings).some(t=>_t(t)&&s.some(o=>o!==e&&o.id===t.instanceId)),t=Math.max(0,s.findIndex(t=>!e(t)));l.push(...s.splice(t,1))}const c=new Set;for(const e of i.born){if(this._slot(e)>=0)continue;const t=a.panes().length,o={zOrder:()=>"bottom",draw:()=>{}};a.addPrimitive(o,t),a.removePrimitive(o);const n=a.panes()[t];void 0===n&&jt("pane"),this._keys.set(n,e),c.add(e)}let d=!1;for(const e of l){let o=this._slot(e.pane);const n=o<0;n&&(o=a.panes().length);const i=this._find(e.id);void 0===i?(this._add(e,o,t),d=!0):i.paneIndex===o||a.moveIndicator(i.id,o)||jt("move");const r=a.panes()[o];n&&void 0!==r&&(this._keys.set(r,e.pane),c.add(e.pane))}for(const e of i.gone){const t=this._slot(e);t>=0&&0===a.panes()[t].series().length&&!a.removePane(t)&&jt("pane")}(i.paneOrder||c.size)&&this._arrange(t);for(const e of t.panes){const t=i.panes.get(e.key),o=c.has(e.key),n=void 0!==t||o?this._slot(e.key):-1;n<0||(!o&&!t.weight||yt(a.paneWeight(n),e.weight)||a.setPaneWeight(n,e.weight),!o&&!t.collapsed||a.paneCollapsed(n)===e.collapsed||a.setPaneCollapsed(n,e.collapsed)||jt("collapse"))}for(const e of t.studies){const t=i.studies.get(e.id);void 0===t||t.presence||this._fit(e,t)}(i.order||d)&&this._stack(t);const u=this._series();if(i.type&&null!==t.type&&null!==u&&kt(a,u)!==t.type&&(!function(e,t,o,n){const[i,a]=o.split("+");void 0===n?(e.setSeriesTransform(t,void 0===a?null:{type:a}),e.setSeriesType(t,i)):n(a??i)}(a,u,t.type,this._opts.setChartType),kt(a,u)!==t.type&&jt("chart type")),i.scale&&null!==t.scale&&null!==u&&a.setSeriesPriceScale(u,t.scale),i.settings.length&&t.settings){const n=e(a),r={};for(const e of i.settings)e in t.settings&&!yt(n[e],t.settings[e])&&(r[e]=t.settings[e]);Object.keys(r).length&&o(a,r)}if(i.defaults.length){const e=a.priceScaleDefaults(),o={};for(const a of i.defaults){const i=t.defaults[a]??n[a];yt(e[a]??n[a],i)||(o[a]=i)}Object.keys(o).length&&a.setPriceScaleOptions(o)}for(const e of t.panes){const t=c.has(e.key)?null:i.panes.get(e.key)?.axes;if(null!==t&&!t?.size)continue;const o=this._slot(e.key);o>=0&&this._axes(o,e,t??null);const n=a.panes()[o];if(null===t&&void 0!==n&&0===n.series().length)for(const[t,o]of Object.entries(e.ranges??{}))n.scaleFor(t).setComputedRange(o)}this._check(t,i)}_add(e,t,o){const n=this._chart,i=this._liveId(e.id),a={paneIndex:t,instanceId:i};null!==e.scale&&(a.priceScaleId=e.scale),Object.keys(e.plots).length&&(a.plotPriceScaleIds=e.plots);const r=this._policyOf(e.id);Object.keys(r).length&&(a.policy={...r});const s=this._liveSettings(e.settings);let l;try{l=n.addIndicator(e.indicatorId,s,a)}catch(t){if(!n.indicators().some(e=>e.id===i))throw t;const o={...a};delete o.instanceId,l=n.addIndicator(e.indicatorId,s,o)}if(this._bind(e.id,l),this._lastNames.set(l.id,e.id),l.id!==i)for(const t of o.studies){const o=Object.keys(t.settings).filter(o=>_t(t.settings[o])&&t.settings[o].instanceId===e.id),n=o.length?this._find(t.id):void 0;if(void 0===n)continue;const i=n.settings(),a={};for(const e of o){const t=i[e];_t(t)&&t.instanceId!==l.id&&(a[e]={...t,instanceId:l.id})}Object.keys(a).length&&n.setSettings(a)}e.visible||l.setVisible(!1)}_liveSettings(e){return xt(e,e=>this._liveId(e))}_fit(e,t){const o=this._find(e.id);if(void 0===o)return;const n=this._liveSettings(e.settings),i=o.settings(),a={};for(const e of t.keys)e in n&&!yt(i[e],n[e])&&(a[e]=n[e]);if(Object.keys(a).length&&o.setSettings(a),t.visible&&o.visible()!==e.visible&&o.setVisible(e.visible),!t.scale)return;o.priceScaleId()===e.scale||o.setPriceScale(e.scale)||jt("scale");const r=o.plotPriceScaleIds(),s={};for(const[t,o]of Object.entries(e.plots))r[t]!==o&&(s[t]=o);for(const t of Object.keys(r))t in e.plots||(s[t]=null);Object.keys(s).length&&!o.setPlotPriceScales(s)&&jt("scale")}_arrange(e){const t=this._chart,o=()=>t.panes().map(e=>this._keyOf(e)),n=e.panes.map(e=>e.key).filter(e=>o().includes(e)),i=o(),a=i.slice();let r=0;i.forEach((e,t)=>{n.includes(e)&&(a[t]=n[r++])});for(let e=0;e<a.length;e++)for(let n=o().indexOf(a[e]);n>e;n--)t.movePane(n,-1)||jt("pane order")}_stack(e){const t=this._chart;for(const o of e.panes){const n=this._plan(this._view(),e,o.key);if(null===n||n.blocked)continue;const i=this._slot(o.key),{desired:a}=n,r=()=>t.indicators().filter(e=>e.paneIndex===i).map(e=>this._nameOf(e));for(let e=0;e<a.length;e++)for(let o=r().indexOf(a[e]);o>e;o--){(!1!==this._policyOf(a[e]).movable?t.reorderIndicator(this._liveId(a[e]),-1):t.reorderIndicator(this._liveId(r()[o-1]),1))||jt("study order")}}}_axes(e,t,o){const n=this._chart,i=n.panes()[e],a=i.scaleStates();for(const[r,s]of Object.entries(t.axes)){const t=a[r],l=o?.get(r);if(void 0===t||null!==o&&void 0===l)continue;const c=e=>void 0===l||l.includes(e),d=r,u=n.priceAxisPlacement(e,d);!c("side")&&!c("order")||null===u||u.side===s.side&&u.order===s.order||n.setPriceAxisPlacement(e,d,s.side,s.order);const h={};c("mode")&&t.mode!==s.mode&&(h.mode=s.mode),c("inverted")&&t.inverted!==s.inverted&&(h.inverted=s.inverted),c("marginTop")&&!yt(t.marginTop,s.marginTop)&&(h.marginTop=s.marginTop),c("marginBottom")&&!yt(t.marginBottom,s.marginBottom)&&(h.marginBottom=s.marginBottom),Object.keys(h).length&&n.setPriceAxisOptions(e,d,h),c("auto")&&void 0!==s.auto&&t.autoScale!==s.auto&&n.setPriceAxisAutoFit(e,d,s.auto),c("lock")&&void 0!==s.lock&&i.ratioLocked(d)!==s.lock&&n.setPriceAxisLockRatio(e,d,s.lock)}}_check(e,t){const o=new Map(e.studies.map(e=>[e.id,e]));for(const[e,n]of t.studies){const t=o.get(e),i=this._find(e);void 0===t!=(void 0===i)&&jt("study"),(n.presence||n.pane)&&void 0!==t&&void 0!==i&&this._slot(t.pane)!==i.paneIndex&&jt("study pane")}if(t.paneOrder){const t=this._chart.panes().map(e=>this._keys.get(e)),o=e.panes.map(e=>e.key).filter(e=>t.includes(e));yt(t.filter(e=>void 0!==e&&o.includes(e)),o)||jt("pane order")}}_notify(){this._heard=this._ready();for(const e of[...this._listeners])try{e()}catch{}}_ready(){return this._destroyed?"":JSON.stringify([this.peekUndo(),this.peekRedo()])}_notifyIfMoved(){this._listeners.size>0&&this._ready()!==this._heard&&this._notify()}}function Mt(){return"undefined"!=typeof navigator&&/mac|iphone|ipad/i.test(navigator.platform||navigator.userAgent||"")}new Set(["Mod","Ctrl","Meta","Alt","Shift"]);new Set([{command:"panLeft",label:"Pan left",combos:["ArrowLeft"]},{command:"panRight",label:"Pan right",combos:["ArrowRight"]},{command:"panLeftFast",label:"Pan left (fast)",combos:["Mod+ArrowLeft"]},{command:"panRightFast",label:"Pan right (fast)",combos:["Mod+ArrowRight"]},{command:"panUp",label:"Pan up",combos:["ArrowUp"]},{command:"panDown",label:"Pan down",combos:["ArrowDown"]},{command:"zoomIn",label:"Zoom in",combos:["Equal","Shift+Equal","NumpadAdd"]},{command:"zoomOut",label:"Zoom out",combos:["Minus","NumpadSubtract"]},{command:"resetScale",label:"Reset view",combos:["Home","Digit0"]},{command:"fitContent",label:"Fit all bars",combos:["Alt+KeyF"]},{command:"screenshot",label:"Screenshot (PNG)",combos:["Alt+Shift+KeyS"]},{command:"toggleGridVert",label:"Toggle vertical grid",combos:["Alt+KeyV"]},{command:"toggleGridHorz",label:"Toggle horizontal grid",combos:["Alt+KeyH"]},{command:"toggleCrosshairMagnet",label:"Toggle crosshair magnet",combos:["Alt+KeyM"]}].map(e=>e.command));const It="keymap",Dt="chart:",zt={mod:"Mod",ctrl:"Mod",control:"Mod",cmd:"Mod",command:"Mod",meta:"Mod",win:"Mod",alt:"Alt",option:"Alt",opt:"Alt",shift:"Shift"},Nt={esc:"Escape",escape:"Escape",del:"Delete",delete:"Delete",backspace:"Backspace",enter:"Enter",return:"Enter",tab:"Tab",space:"Space",spacebar:"Space",left:"ArrowLeft",right:"ArrowRight",up:"ArrowUp",down:"ArrowDown",arrowleft:"ArrowLeft",arrowright:"ArrowRight",arrowup:"ArrowUp",arrowdown:"ArrowDown",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown",insert:"Insert",plus:"+",minus:"-",question:"?",slash:"/",period:".",comma:","},Rt=new Set(["Shift","Control","Alt","Meta","OS","AltGraph","CapsLock","Fn"]),Ft=["Mod","Alt","Shift"];function Wt(e){const t=e.trim();if(""===t)return"";let o,n;if("+"===t)o="+",n=[];else if(t.endsWith("++"))o="+",n=t.slice(0,-2).split("+").map(e=>e.trim());else{const e=t.split("+").map(e=>e.trim());o=e[e.length-1],n=e.slice(0,-1)}if(""===o||void 0!==zt[o.toLowerCase()])return"";const i=new Set;for(const e of n){const t=zt[e.toLowerCase()];if(void 0===t)return"";i.add(t)}o=function(e){const t=e.toLowerCase();return void 0!==Nt[t]?Nt[t]:/^f([1-9]|1[0-2])$/.test(t)?t.toUpperCase():1===e.length&&/[a-z]/i.test(e)?t:e}(o),1!==o.length||/[a-z]/.test(o)||i.delete("Shift");return[...Ft.filter(e=>i.has(e)),o].join("+")}function Bt(e){let t=e.key??"";if(""===t||"Unidentified"===t||Rt.has(t))return"";" "!==t&&"Spacebar"!==t||(t="Space"),"Esc"===t&&(t="Escape"),"Del"===t&&(t="Delete");const o=e.code??"";!0===e.altKey&&/^Key[A-Z]$/.test(o)&&(t=o.slice(3).toLowerCase());const n=[];return!0!==e.ctrlKey&&!0!==e.metaKey||n.push("Mod"),!0===e.altKey&&n.push("Alt"),1===t.length?/[a-z]/i.test(t)&&(t=t.toLowerCase(),!0===e.shiftKey&&n.push("Shift")):!0===e.shiftKey&&n.push("Shift"),[...n,t].join("+")}const qt={Escape:"Esc",Delete:"Del",ArrowLeft:"Left",ArrowRight:"Right",ArrowUp:"Up",ArrowDown:"Down"};function Ut(e,t=Mt()){const o=Wt(e);if(""===o)return"";const n=o.split("+"),i=n[n.length-1];return[...n.slice(0,-1).map(e=>"Mod"===e?t?"Cmd":"Ctrl":"Alt"===e?t?"Opt":"Alt":"Shift"),qt[i]??(1===i.length?i.toUpperCase():i)].join("+")}const Ht={Equal:"=+",Minus:"-_",Slash:"/?",Comma:",<",Period:".>",Semicolon:";:",Quote:"'\"",BracketLeft:"[{",BracketRight:"]}",Backslash:"\\|",Backquote:"`~",Digit1:"1!",Digit2:"2@",Digit3:"3#",Digit4:"4$",Digit5:"5%",Digit6:"6^",Digit7:"7&",Digit8:"8*",Digit9:"9(",Digit0:"0)",NumpadAdd:"++",NumpadSubtract:"--",NumpadMultiply:"**",NumpadDivide:"//",NumpadDecimal:".."};function Kt(e){const t=e.split("+").map(e=>e.trim()).filter(e=>""!==e);if(0===t.length)return"";const o=t[t.length-1],n=t.slice(0,-1).map(e=>"Alt"===e?"Alt":"Shift"===e?"Shift":"Mod");let i;const a=/^Key([A-Z])$/.exec(o),r=/^Numpad([0-9])$/.exec(o);return i=null!==a?a[1].toLowerCase():null!==r?r[1]:void 0!==Ht[o]?Ht[o][n.includes("Shift")?1:0]:"NumpadEnter"===o?"Enter":o,Wt([...n,i].join("+"))}function Vt(e){const t=e.split("+"),o=t.pop()??"";return/^[a-z]$/.test(o)&&a([...t,"Key"+o.toUpperCase()].join("+"))}const Gt=new Set(["global","widget","chart"]),Jt=(e,t)=>e===t||Gt.has(e)&&Gt.has(t),Zt=e=>"rail"!==e&&"overlay"!==e,Yt=new Set,Qt=(e,t=[])=>({ok:!1,reason:e,conflicts:t}),Xt=(e,t)=>e===t||null!==e&&null!==t&&e.length===t.length&&e.every((e,o)=>e===t[o]);class eo{constructor(e={}){Object.defineProperty(this,"_isMac",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_chart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_scopes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_bindings",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_byCombo",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"_conflictListeners",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"_changeListeners",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"_overrides",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"_chartOverrides",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"_chartBaseline",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_capture",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_detach",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_target",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_nextId",{enumerable:!0,configurable:!0,writable:!0,value:1}),this._isMac=e.isMac??Mt(),this._chart=e.chart??null,this._scopes=e.scopes??(()=>["global"])}get isMac(){return this._isMac}setScopes(e){this._scopes=e}activeScopes(){return this._scopes()}register(e,t,o="global",n={}){const i=Wt(e);if(""===i)throw new Error(`openalgo-charts widget: "${e}" is not a key binding`);const a=n.command??null;if(null!==a&&(""===a||a.startsWith(Dt)||this._bindings.some(e=>e.command===a)))throw new Error(`openalgo-charts widget: "${a}" is not a free command name`);const r=null!==a&&!1!==n.rebindable,s=null!==a&&r?this._overrides.get(a):void 0,l={id:this._nextId++,combo:void 0===s?i:s??"",defaultCombo:i,command:a,rebindable:r,scope:o,label:n.label??Ut(i,this._isMac),group:n.group??"Widget",hidden:!0===n.hidden,inText:!0===n.inText,layered:!0===n.layered,action:t,when:n.when},c=this._conflictKeys();return this._bindings.push(l),this._index(l),null!==c&&this._announce(c),()=>this._unregister(l)}_index(e){if(""===e.combo)return;const t=this._byCombo.get(e.combo)??[];let o=t.length;for(;o>0&&t[o-1].id>e.id;)o--;t.splice(o,0,e),this._byCombo.set(e.combo,t)}_unindex(e){const t=this._byCombo.get(e.combo);if(void 0===t)return;const o=t.indexOf(e);o>=0&&t.splice(o,1),0===t.length&&this._byCombo.delete(e.combo)}_unregister(e){const t=this._bindings.indexOf(e);t>=0&&this._bindings.splice(t,1),this._unindex(e)}_widgetConflicts(){const e=[];for(const t of this._bindings){if(t.layered||""===t.combo)continue;const o=this._byCombo.get(t.combo)??[],n=o.slice(0,o.indexOf(t)).find(e=>e.scope===t.scope);void 0!==n&&e.push({combo:t.combo,scope:t.scope,kept:n.label,shadowed:t.label,source:"widget"})}return e}_conflictKeys(){return 0===this._conflictListeners.size?null:new Set(this._widgetConflicts().map(e=>`${e.combo}|${e.scope}|${e.kept}|${e.shadowed}`))}_announce(e){for(const t of this._widgetConflicts())if(!e.has(`${t.combo}|${t.scope}|${t.kept}|${t.shadowed}`))for(const e of this._conflictListeners)e(t)}onConflict(e){return this._conflictListeners.add(e),()=>this._conflictListeners.delete(e)}onChange(e){return this._changeListeners.add(e),()=>this._changeListeners.delete(e)}_emit(e){const t=Array.from(new Set(Array.from(e).filter(e=>null!==e)));if(0!==t.length)for(const e of this._changeListeners)e({commands:t})}capture(e){return this._capture=e,Yt.add(this),()=>{this._capture===e&&(this._capture=null,Yt.delete(this))}}get capturing(){return null!==this._capture}handle(e){if(null!==this._capture)return!1!==this._capture(e)&&(e.preventDefault?.(),void 0!==e.stopImmediatePropagation?e.stopImmediatePropagation():e.stopPropagation?.(),!0);if(null!==this._target)for(const e of Yt)if(e!==this&&e._target===this._target)return!1;const t=Bt(e);if(""===t)return!1;const o=this._byCombo.get(t);if(void 0===o)return!1;const n=Ne(e.target);for(const t of this._scopes())for(const i of o.slice())if(i.scope===t&&(!n||i.inText)&&(void 0===i.when||i.when())&&!1!==i.action(e))return e.preventDefault?.(),e.stopPropagation?.(),!0;return!1}attach(e){this._detach?.();const t=e=>{this.handle(e)};return e.addEventListener("keydown",t,!0),this._target=e,this._detach=()=>{e.removeEventListener("keydown",t,!0),this._detach=null,this._target=null},this._detach}list(){return this._bindings.slice()}conflicts(){const e=this._widgetConflicts();if(null!==this._chart)for(const t of this._chart.list())if(!t.isDisabled)for(const o of t.combos){const n=Kt(o),i=(this._byCombo.get(n)??[]).find(e=>Zt(e.scope)&&!e.layered);void 0!==i&&e.push({combo:n,scope:i.scope,kept:i.label,shadowed:t.label,source:"chart"})}return e}format(e){return Ut(e,this._isMac)}_use(e){return{command:e.command,label:e.label,group:e.group,source:"widget",rebindable:e.rebindable}}_chartEditable(){const e=this._chart;return null!==e&&"function"==typeof e.setBinding&&"function"==typeof e.disable&&"function"==typeof e.resetBinding}_chartUse(e){return{command:Dt+e.command,label:e.label,group:"Chart",source:"chart",rebindable:this._chartEditable()}}_holders(e,t,o){const n=[];for(const i of this._byCombo.get(e)??[])null!==o&&i.command===o||!Jt(i.scope,t)||n.push(this._use(i));if(null!==this._chart&&Zt(t))for(const t of this._chart.list())t.isDisabled||Dt+t.command===o||t.combos.some(t=>Kt(t)===e)&&n.push(this._chartUse(t));return n}_chartHolders(e,t){const o=[],n=this._chart;if(null===n)return o;for(const i of n.list())i.isDisabled||i.command===t||i.combos.some(t=>e.includes(t))&&o.push(this._chartUse(i));const i=new Set;for(const t of e)for(const e of this._byCombo.get(Kt(t))??[])e.layered||!Zt(e.scope)||i.has(e)||(i.add(e),o.push(this._use(e)));return o}conflictsFor(e,t="widget"){const o=Wt(e);return""===o?[]:this._holders(o,t,null)}chord(e){if(e.startsWith(Dt)){const t=this._chart?.list().find(t=>Dt+t.command===e);return void 0===t?null:t.isDisabled||0===t.combos.length?"":Kt(t.combos[0])}const t=this._bindings.find(t=>t.command===e);return void 0===t?null:t.combo}_setWidget(e,t){e.combo!==t&&(this._unindex(e),e.combo=t,this._index(e));const o=e.command;t===e.defaultCombo?this._overrides.delete(o):this._overrides.set(o,""===t?null:t)}_chartNow(e){const t=this._chart?.list().find(t=>t.command===e);return void 0===t?void 0:t.isDisabled?null:t.combos.slice()}_base(e){const t=this._chartBaseline??(this._chartBaseline=new Map);return t.has(e)||t.set(e,this._chartNow(e)??null),t.get(e)}_setChart(e,t){const o=this._chart,n=this._base(e),i=()=>{null===t?o.disable(e):o.setBinding(e,t)};if(Xt(n,t))return o.resetBinding(e),Xt(this._chartNow(e)??null,t)||i(),void this._chartOverrides.delete(e);i(),this._chartOverrides.set(e,t)}_dropChart(e,t){const o=e.command.slice(6),n=(this._chartNow(o)??[]).filter(e=>!t(e));this._setChart(o,n.length>0?n:null)}_dropWidget(e){const t=this._bindings.find(t=>t.command===e.command);void 0!==t&&this._setWidget(t,"")}rebind(e,t,o={}){return this._rebind(e,t,!0===o.replace,!1)}reset(e,t={}){return this._rebind(e,void 0,!0===t.replace,!0)}resetAll(){const e=this._clearAll();this._emit(e)}_clearAll(){const e=[];for(const t of Array.from(this._overrides.keys())){const o=this._bindings.find(e=>e.command===t);void 0!==o&&this._setWidget(o,o.defaultCombo),this._overrides.delete(t),e.push(t)}for(const t of Array.from(this._chartOverrides.keys()))this._setChart(t,this._base(t)),e.push(Dt+t);return e}_rebind(e,t,o,n){if(e.startsWith(Dt))return this._rebindChart(e.slice(6),t,o,n);const i=this._bindings.find(t=>t.command===e);if(void 0===i)return n&&this._overrides.delete(e)&&this._emit([e]),n?{ok:!0,conflicts:[]}:Qt("unknown");if(!i.rebindable)return Qt("fixed");let a=i.defaultCombo;if(!n&&(a="",null!=t)){const e="string"==typeof t?[t]:t;if(a=1===e.length?Wt(e[0]):"",""===a)return Qt("invalid");if(Vt(a))return Qt("reserved")}if(a===i.combo)return{ok:!0,conflicts:[]};const r=""===a?[]:this._holders(a,i.scope,e).filter(e=>!n||"widget"===e.source);if(r.length>0){if(!o||r.some(e=>!e.rebindable))return Qt("taken",r);for(const e of r)"chart"===e.source?this._dropChart(e,e=>Kt(e)===a):this._dropWidget(e)}return this._setWidget(i,a),this._emit([e,...r.map(e=>e.command)]),{ok:!0,conflicts:r}}_rebindChart(e,t,o,n){const r=null===this._chart?void 0:this._chartNow(e);if(void 0===r)return Qt("unknown");if(!this._chartEditable())return Qt("fixed");let s=null;if(n)s=this._base(e);else if(null!=t){const e=("string"==typeof t?[t]:Array.from(t)).map(i);if(0===e.length||e.includes(""))return Qt("invalid");if(e.some(e=>a(e)))return Qt("reserved");s=Array.from(new Set(e))}if(Xt(s,r))return n&&this._chartOverrides.delete(e)&&this._emit([Dt+e]),{ok:!0,conflicts:[]};const l=null===s?[]:this._chartHolders(s,e).filter(e=>!n||"chart"===e.source);if(l.length>0){if(!o||l.some(e=>!e.rebindable))return Qt("taken",l);const e=s;for(const t of l)"chart"===t.source?this._dropChart(t,t=>e.includes(t)):this._dropWidget(t)}return this._setChart(e,s),this._emit([Dt+e,...l.map(e=>e.command)]),{ok:!0,conflicts:l}}overrides(){const e={};for(const[t,o]of this._overrides)e[t]=o;for(const[t,o]of this._chartOverrides)e[Dt+t]=null===o?null:o.slice();return e}applyOverrides(e){const t=new Map,o=new Map;if(null!==e&&"object"==typeof e&&!Array.isArray(e))for(const[n,r]of Object.entries(e))if(n.startsWith(Dt)){const e=n.slice(6),t=null===r?null:(Array.isArray(r)?r:[r]).map(e=>"string"==typeof e?i(e):"");if(""===e||null!==t&&(0===t.length||t.some(e=>""===e||a(e))))continue;o.set(e,t)}else if(""!==n&&(null===r||"string"==typeof r)){const e=null===r?null:Wt(r);if(""===e||null!==e&&Vt(e))continue;const o=this._bindings.find(e=>e.command===n);if(void 0!==o&&!o.rebindable)continue;t.set(n,e)}const n=this._conflictKeys(),r=new Map(this._bindings.map(e=>[e,e.combo])),s=this.overrides();this._clearAll();for(const[e,o]of t){const t=this._bindings.find(t=>t.command===e);void 0===t?this._overrides.set(e,o):this._setWidget(t,o??"")}if(this._chartEditable())for(const[e,t]of o)void 0!==this._chartNow(e)&&this._setChart(e,t);null!==n&&this._announce(n);const l=this.overrides(),c=this._bindings.filter(e=>null!==e.command&&r.get(e)!==e.combo).map(e=>e.command);for(const e of new Set([...Object.keys(s),...Object.keys(l)]))JSON.stringify(s[e])!==JSON.stringify(l[e])&&c.push(e);this._emit(c)}_chartDefault(e,t){const o=this._chartBaseline?.get(e),n=void 0===o?t:o??[];return 0===n.length?"":Kt(n[0])}describe(){const e=new Map;for(const t of this._bindings){if(t.hidden)continue;const o=e.get(t.group)??[],n={label:t.label,combo:t.combo,display:this.format(t.combo)};null!==t.command&&(n.command=t.command,n.rebindable=t.rebindable,n.defaultCombo=t.defaultCombo,n.changed=t.combo!==t.defaultCombo),o.push(n),e.set(t.group,o)}const t=Array.from(e,([e,t])=>({group:e,rows:t}));if(null!==this._chart){const e=new Map;for(const t of this.conflicts())"chart"===t.source&&e.set(t.shadowed+"|"+t.combo,t.kept);const o=this._chartEditable(),n=[];for(const t of this._chart.list()){const i=this._chartOverrides.has(t.command);if((t.isDisabled||0===t.combos.length)&&!i)continue;const a=t.isDisabled||0===t.combos.length?"":Kt(t.combos[0]),r={label:t.label,combo:a,display:this.format(a),command:Dt+t.command,rebindable:o,defaultCombo:this._chartDefault(t.command,t.combos),changed:i},s=e.get(t.label+"|"+a);void 0!==s&&(r.shadowedBy=s),n.push(r)}n.length>0&&t.push({group:"Chart",rows:n})}return t}destroy(){this._detach?.(),this._capture=null,Yt.delete(this),this._bindings.length=0,this._byCombo.clear(),this._overrides.clear(),this._chartOverrides.clear(),this._conflictListeners.clear(),this._changeListeners.clear()}}function to(e){const t={Ctrl:"Control",Cmd:"Meta",Opt:"Alt",Del:"Delete",Esc:"Escape",Left:"ArrowLeft",Right:"ArrowRight",Up:"ArrowUp",Down:"ArrowDown"};return e.split("+").map(e=>t[e]??e).join("+")}function oo(e,t,o){const n=e,i=("function"==typeof n?.chord?n.chord(t):null)??o;if(void 0!==i&&""!==i)return"function"==typeof n?.format?n.format(i):Ut(i)}const no=new WeakSet;const io=ut(()=>import("./openalgo-charts.widget.keymap-editor-Uozy6qFE.mjs")),ao=new WeakMap;function ro(e,t={}){let o=null,n=!0,i=ao.get(e);return void 0===i&&ao.set(e,i={waiting:null}),ht(io,n=>{o=n.mountShortcutsPanel(e,t.edit??!no.has(e.keymap))},t=>e.toast(pt(e,Pe(e,"Keyboard shortcuts"),t),"error"),()=>n&&!e.chart.isDestroyed,{slot:i,doc:e.document}),()=>{n=!1,o?.()}}const so=["#4f8cff","#26a69a","#ef5350","#f4b740","#ab79df","#22a8bd","#e88555","#9aa6b2","#ffffff","#000000"],lo=[];function co(e){if("string"!=typeof e||e.length>256)return null;const t=e.trim(),o=/^#([\da-f]{3}|[\da-f]{4}|[\da-f]{6}|[\da-f]{8})$/i.exec(t);if(null!==o){let e=o[1].toLowerCase();e.length<=4&&(e=e.split("").map(e=>e+e).join(""));const t=8===e.length?parseInt(e.slice(6),16)/255:1;return{hex:`#${e.slice(0,6)}`,alpha:t,format:8===e.length?"hexAlpha":"hex"}}const n=t.toLowerCase(),i=n.startsWith("rgba(")?5:n.startsWith("rgb(")?4:0;if(0===i||!t.endsWith(")"))return null;const a=t.slice(i,-1);let r,s;if(a.includes(",")){const e=a.split(",").map(e=>e.trim());if(3!==e.length&&4!==e.length)return null;r=e.slice(0,3),s=e[3]}else{const e=a.split("/");if(e.length>2)return null;r=e[0].trim().split(/\s+/),s=e[1]?.trim()}if(3!==r.length||r.some(e=>!/^\d{1,3}$/.test(e)))return null;const l=r.map(Number);if(l.some(e=>e>255))return null;if(void 0!==s){const e=s.split(".");if(e.length>2||e.every(e=>""===e)||e.some(e=>/\D/.test(e)))return null}const c=void 0===s?1:Number(s);return!Number.isFinite(c)||c<0||c>1?null:{hex:`#${l.map(e=>e.toString(16).padStart(2,"0")).join("")}`,alpha:c,format:void 0===s?"hex":"rgba"}}function uo(e,t,o){if("hex"===o)return e;if("hexAlpha"===o)return`${e}${Math.round(255*t).toString(16).padStart(2,"0")}`;return`rgba(${[1,3,5].map(t=>parseInt(e.slice(t,t+2),16)).join(",")},${Number(t.toFixed(3))})`}function ho(e,t){const o=(t,o)=>{const n=e.createElement(t);return n.className=o,n},n=e=>Pe(t,`schema.ui.colorPicker.${e}`,{},e),i=o("span","oac-color"),a=o("input","oac-swatch-input");a.type="color",a.id=t.id,a.tabIndex=-1,a.setAttribute("aria-hidden","true"),a.setAttribute("aria-label",t.label);const r=o("button","oac-color__trigger");r.type="button",r.id=`${t.id}-trigger`,r.setAttribute("aria-label",t.label),r.setAttribute("aria-haspopup","dialog"),r.setAttribute("aria-expanded","false"),null!==t.disabledReason&&void 0!==t.disabledReason?(r.disabled=!0,a.disabled=!0,r.title=t.disabledReason,a.title=t.disabledReason):(r.title=t.label,a.title=t.label),i.appendChild(a),i.appendChild(r);const s=o("div","oac-color__popover");s.hidden=!0,s.setAttribute("role","dialog"),s.setAttribute("aria-label",n("Color"));const l=o("div","oac-color__palette");l.setAttribute("aria-label",n("Palette"));const c=o("div","oac-color__recent");c.setAttribute("aria-label",n("Recent"));const d=o("button","oac-color__custom");d.type="button",d.textContent=n("Custom"),d.addEventListener("click",()=>{v||a.click()}),s.appendChild(l),s.appendChild(c),s.appendChild(d),i.appendChild(s);let u,h,p,g=t.value,m=co(g),f=m?.alpha??1,b=!1,v=!1;const w=()=>{a.value=m?.hex??"#000000",r.style.backgroundColor=null===m?"#000000":uo(m.hex,f,m.format),void 0!==h&&(h.value=String(Math.round(100*f)),void 0!==p&&(p.textContent=`${h.value}%`))},y=(e,o=f)=>{if(v||r.disabled||!/^#[\da-f]{6}$/i.test(e))return;const n=m?.format??"hex";g=uo(e.toLowerCase(),o,n),m={hex:e.toLowerCase(),alpha:o,format:n},f=o,w(),function(e){const t=lo.indexOf(e);t>=0&&lo.splice(t,1),lo.unshift(e),lo.length=Math.min(lo.length,6)}(m.hex),t.onChange(g)},_=(e,t)=>{e.innerHTML="";for(const n of t){const t=o("button","oac-color__choice");t.type="button",t.setAttribute("aria-label",n),t.title=n,t.style.backgroundColor=n,t.addEventListener("click",()=>{y(n),C(),r.focus()}),e.appendChild(t)}},x=e=>{i.contains(e.target)||s.contains(e.target)||C()},k=()=>{b&&(u=void 0,b=!1,s.hidden=!0,r.setAttribute("aria-expanded","false"),e.removeEventListener("pointerdown",x,!0),m=co(g),f=m?.alpha??1,w(),v||s.parentNode===i||i.appendChild(s))},C=()=>{const e=u;u=void 0,e?.(),k()},S=()=>{if(!(v||b||r.disabled))if(b=!0,function(){if(void 0!==h||null===m||"hex"===m.format)return;const i=o("label","oac-color__opacity");i.appendChild(e.createTextNode(n("Opacity"))),h=o("input","oac-color__range"),h.type="range",h.min="0",h.max="100",h.step="1",p=o("output","oac-color__percent");const r=h,l=p;r.addEventListener("input",()=>{f=Number(r.value)/100,l.textContent=`${r.value}%`,t.live&&y(a.value,f)}),r.addEventListener("change",()=>y(a.value,Number(r.value)/100)),i.appendChild(r),i.appendChild(l),s.appendChild(i)}(),w(),_(l,so),_(c,lo),c.hidden=0===lo.length,s.hidden=!1,r.setAttribute("aria-expanded","true"),t.openOverlay){s.classList.remove("oac-color__popover--above"),r.focus();const e=t.openOverlay(s,{anchor:r,placement:"below",modal:!1,initialFocus:l.querySelector("button"),onClose:k});b?u=e:e()}else{const t=i.closest(".oac-widget");if(null!==t){const e=t.getBoundingClientRect().bottom;s.classList.toggle("oac-color__popover--above",r.getBoundingClientRect().bottom+s.offsetHeight>e)}e.addEventListener("pointerdown",x,!0),l.querySelector("button")?.focus()}};r.addEventListener("click",()=>b?C():S());const A=e=>{"Escape"===e.key&&b&&(e.preventDefault(),e.stopPropagation(),C(),r.focus())};return i.addEventListener("keydown",A),s.addEventListener("keydown",A),s.addEventListener("pointerdown",e=>e.stopPropagation()),a.addEventListener("input",()=>{t.live&&y(a.value)}),a.addEventListener("change",()=>y(a.value)),w(),{el:i,input:a,trigger:r,read:()=>g,write:e=>{g=e,m=co(e),f=m?.alpha??1,w()},destroy:()=>{v||(v=!0,C(),s.remove(),i.removeEventListener("keydown",A),s.removeEventListener("keydown",A))}}}const po="\n.oac-widget .oac-color { position: relative; display: inline-flex; width: 27px; height: 27px; flex: 0 0 27px; }\n.oac-widget .oac-color > .oac-swatch-input { position: absolute; inset: 0; width: 27px; height: 27px; padding: 0; opacity: 0; pointer-events: none; }\n.oac-widget .oac-color__trigger { position: absolute; inset: 0; width: 27px; height: 27px; border: 1px solid var(--oac-bd); border-radius: 5px; background: transparent; cursor: pointer; }\n.oac-widget .oac-color__trigger:focus-visible { outline: 2px solid var(--oac-ring); outline-offset: 2px; }\n.oac-widget .oac-color__trigger:disabled { cursor: not-allowed; opacity: .5; }\n.oac-widget .oac-color__popover { position: absolute; z-index: 80; top: 30px; right: 0; width: 188px; padding: 9px; border: 1px solid var(--oac-bd); border-radius: 7px; background: var(--oac-elev); color: var(--oac-tx); box-shadow: var(--oac-shadow); }\n.oac-widget .oac-color__popover--above { top: auto; bottom: 30px; }\n.oac-widget .oac-color__popover.oac-pop { right: auto; bottom: auto; min-width: 0; max-width: calc(100% - 16px); max-height: calc(100% - 16px); overflow: auto; }\n.oac-widget .oac-color__popover[hidden], .oac-widget .oac-color__recent[hidden] { display: none; }\n.oac-widget .oac-color__palette, .oac-widget .oac-color__recent { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin-bottom: 7px; }\n.oac-widget .oac-color__choice { width: 28px; height: 28px; padding: 0; border: 1px solid var(--oac-bd); border-radius: 5px; background: transparent; overflow: hidden; cursor: pointer; }\n.oac-widget .oac-color__custom { width: 100%; padding: 5px; border: 1px solid var(--oac-bd); border-radius: 4px; background: transparent; color: inherit; cursor: pointer; }\n.oac-widget .oac-color__opacity { display: flex; align-items: center; gap: 5px; margin-top: 7px; font-size: 11px; }\n.oac-widget .oac-color__range { min-width: 0; flex: 1; }\n.oac-widget .oac-color__percent { min-width: 30px; text-align: right; }\n";function go(e,t){if(null===e||"object"!=typeof e)return!0;const o=e;if(Array.isArray(o.all))return o.all.every(e=>go(e,t));if(Array.isArray(o.any))return o.any.some(e=>go(e,t));if("string"!=typeof o.key)return!0;const n=((e,t)=>Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0)(t,o.key),i=e=>(Array.isArray(e)?e:[e]).includes(n);return"is"in o?i(o.is):!("isNot"in o)||!i(o.isNot)}function mo(e,t=[]){if(null===e||"object"!=typeof e)return t;const o=e,n=Array.isArray(o.all)?o.all:Array.isArray(o.any)?o.any:null;if(null!==n)for(const e of n)mo(e,t);else"string"!=typeof o.key||t.includes(o.key)||t.push(o.key);return t}function fo(e,t){const o=new Map;for(const t of e){const e=t.pair??t;for(const n of[e.enabled,e.up,e.down])"string"==typeof n?.key&&o.set(n.key,t)}for(const t of e)o.set(t.key,t);const n=new Map,i=new Set,a=e=>{const r=o.get(e);if(void 0===r||i.has(r))return;let s=n.get(r.key);if(void 0!==s)return s;i.add(r);const l=mo(r.activeWhen),c=go(r.visibleWhen,t)&&mo(r.visibleWhen).every(e=>!1!==a(e)?.visible),d=go(r.activeWhen,t)&&l.every(e=>{const t=a(e);return void 0===t||t.visible&&t.active});return i.delete(r),s={visible:c,active:d,dependsOn:l},n.set(r.key,s),s};for(const t of e)a(t.key);return n}const bo=["1m","3m","5m","15m","30m","1h","2h","4h","1d","1w"];function vo(e){const t=new Set,o=[{label:"Chart",value:""}];for(const n of e??[...bo,...s().map(e=>e.code)]){const e=n.toLowerCase();t.has(e)||(t.add(e),o.push({label:n,value:n}))}return o}function wo(e,t,o){const n=[];for(const t of e){const e=n.length;switch(t.type){case"colorPair":n.push({key:t.key,kind:"colorPair",label:t.label,group:t.group,pair:{enabled:void 0===t.enabled?void 0:{key:t.enabled.key},up:{key:t.up.key,label:t.up.label},down:{key:t.down.key,label:t.down.label}}});break;case"number":n.push({key:t.key,kind:"number",label:t.label,group:t.group,min:t.min,max:t.max,step:t.step});break;case"price":case"timestamp":n.push({key:t.key,kind:t.type,label:t.label,group:t.group,min:t.min,max:t.max,step:t.step});break;case"select":n.push({key:t.key,kind:"select",label:t.label,group:t.group,options:t.options});break;case"source":n.push({key:t.key,kind:"select",label:t.label,group:t.group,options:r});break;case"interval":n.push({key:t.key,kind:"select",label:t.label,group:t.group,options:vo(o)});break;case"time":n.push({key:t.key,kind:"text",label:t.label,group:t.group});break;case"boolean":case"color":case"text":case"symbol":case"session":case"multiline":n.push({key:t.key,kind:t.type,label:t.label,group:t.group})}if(n.length>e){const o=n[e];void 0!==t.tooltip&&(o.tooltip=t.tooltip),void 0!==t.activeWhen&&(o.activeWhen=t.activeWhen),void 0!==t.visibleWhen&&(o.visibleWhen=t.visibleWhen),"colorPair"!==t.type&&void 0!==t.inline&&(o.inline=t.inline)}}return yo(n,t)}function yo(e,t){if(void 0===t?.translate)return e;const o=(e,o)=>Pe(t,`schema.${t.scope}.${e}`,{},o);return e.map(e=>({...e,label:o(`${e.key}.label`,e.label),group:void 0===e.group?void 0:o(`group.${e.group}`,e.group),tooltip:void 0===e.tooltip?void 0:o(`${e.key}.tooltip`,e.tooltip),options:e.options?.map(t=>({...t,label:t.label===t.value?t.label:o(`${e.key}.option.${t.value}`,t.label)})),pair:void 0===e.pair?void 0:{...e.pair,up:{...e.pair.up,label:o(`${e.pair.up.key}.label`,e.pair.up.label)},down:{...e.pair.down,label:o(`${e.pair.down.key}.label`,e.pair.down.label)}}}))}const _o={line:"Line",fill:"Fill",text:"Text",levels:"Levels",behavior:"Behavior"};function xo(e,t){const o=[];for(const t of e){const e=void 0===t.group?void 0:_o[t.group]??t.group,n={key:t.path,label:t.label,group:e};switch(t.kind){case"color":o.push({...n,kind:"color"});break;case"number":o.push({...n,kind:"number",min:t.min,max:t.max,step:t.step});break;case"opacity":o.push({...n,kind:"opacity"});break;case"boolean":o.push({...n,kind:"boolean"});break;case"select":case"lineStyle":o.push(void 0===t.options?{...n,kind:"text"}:{...n,kind:"select",options:t.options});break;case"text":o.push({...n,kind:"text.value"===t.path?"multiline":"text"});break;case"levels":o.push({...n,kind:"custom",custom:"levels"})}}return yo(o,t)}function ko(e,t,o,n){const i=De(e,t,o);return void 0!==n&&(i.textContent=n),i}function Co(e){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="${ne}" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${e}"/></svg>`}function So(e,t){return ze(e,oe(t),"chrome")}function Ao(e,t){const o=ko(e,"button");o.type="button";const n=["oac-btn"];if(!0===t.iconOnly&&n.push("oac-btn--icon"),"primary"===t.variant&&n.push("oac-btn--primary"),"danger"===t.variant&&n.push("oac-btn--danger"),o.className=n.join(" "),void 0!==t.icon&&o.appendChild(So(e,t.icon)),!0===t.iconOnly?(o.setAttribute("aria-label",t.label),o.title=void 0===t.chord?t.label:`${t.label} (${t.chord})`):(o.appendChild(e.createTextNode(t.label)),void 0!==t.chord&&(o.title=t.chord)),void 0!==t.onClick){const e=t.onClick;o.addEventListener("click",t=>{t.stopPropagation(),e(t)})}return o}function Oo(e){const t=ko(e,"span","oac-select"),o=ko(e,"select");t.appendChild(o);const n=ko(e,"span","oac-chev");return n.innerHTML=oe("chevron-down"),t.appendChild(n),{wrap:t,select:o}}function Lo(e){e.addEventListener("keydown",e=>{const t=e.key;"Escape"!==t&&"Tab"!==t&&e.stopPropagation()}),e.addEventListener("pointerdown",e=>{e.stopPropagation()})}let Eo=0;function $o(e,t){const o=ko(e,"div","oac-panel"+(void 0===t.className?"":" "+t.className));o.setAttribute("role","dialog"),o.tabIndex=-1;const n="oac-dlg-title-"+ ++Eo;o.setAttribute("aria-labelledby",n);const i=ko(e,"div","oac-dialog__head"),a=ko(e,"span","oac-dialog__title",t.title);a.id=n;const r=Ao(e,{label:Pe(t,"Close"),...!0===t.closeText?{}:{icon:"close",iconOnly:!0},onClick:()=>t.onClose()});i.appendChild(a),i.appendChild(r);const s=ko(e,"div","oac-dialog__body"),l=ko(e,"div","oac-dialog__foot"),c=ko(e,"div","oac-dialog__lead"),d=ko(e,"div","oac-spacer"),u=ko(e,"div","oac-dialog__actions");return l.appendChild(c),l.appendChild(d),l.appendChild(u),o.appendChild(i),o.appendChild(s),o.appendChild(l),Lo(o),{el:o,head:i,body:s,foot:l,lead:c,actions:u,closeButton:r,setTitle:e=>{a.textContent=e}}}function To(e,t){return e.toast(t,"info"),{el:e.document.createElement("div"),close:()=>{},isOpen:()=>!1}}function jo(e,t,o,n){let i,a=!1,r=!1;const s=e.openOverlay(t,{...o,onClose:()=>{o.onClose?.(),a||(r=!0,n(),d())}}),l=t.closest(".oac-widget"),c=t.querySelectorAll(".oac-tabs--rail");if(null!==l&&c.length>0){const e=()=>{const e=l.getBoundingClientRect().width<=720?"horizontal":"vertical";c.forEach(t=>t.setAttribute("aria-orientation",e))};e();const o=t.ownerDocument.defaultView?.ResizeObserver;void 0!==o&&(i=new o(e),i.observe(l))}function d(){a||(a=!0,i?.disconnect(),r||s(),t.remove())}return{el:t,close:d,isOpen:()=>!a}}function Po(e,t,o,n){const i=t.panes()[0]?.element.parentElement??null,a=null===i?{left:0,top:0}:Ue(e,i);let r=1/0,s=-1/0;for(const e of o){const o=(void 0!==n&&void 0!==e.id?n(e.id):null)??e.points.map(o=>({x:t.timeToCoordinate(o.time),y:t.priceToCoordinate(o.price,e.paneIndex)}));for(const{x:e,y:t}of o)Number.isFinite(e)&&null!==t&&Number.isFinite(t)&&(r=Math.min(r,e),s=Math.max(s,t))}return Number.isFinite(r)&&Number.isFinite(s)?{x:a.left+r,y:a.top+s+12}:{x:a.left+60,y:a.top+60}}function Mo(e,t,o,n,i){const a=ko(e,"div",`oac-tabs oac-tabs--${n}`);a.setAttribute("role","tablist"),a.setAttribute("aria-orientation","rail"===n?"vertical":"horizontal");const r=[],s=e=>{t.forEach((t,o)=>{const n=t.id===e;r[o].setAttribute("aria-selected",n?"true":"false"),r[o].tabIndex=n?0:-1})},l=e=>{s(e),i(e)};return t.forEach((o,n)=>{const i=ko(e,"button","oac-tab");i.type="button",i.setAttribute("role","tab"),i.dataset.tab=o.id,void 0!==o.icon&&i.appendChild(So(e,o.icon)),i.appendChild(ko(e,"span","oac-tab__label",o.label)),i.addEventListener("click",e=>{e.stopPropagation(),l(o.id)}),i.addEventListener("keydown",e=>{const o=e.key,i="vertical"===a.getAttribute("aria-orientation"),s=i?"ArrowUp":"ArrowLeft";let c=-1;o===(i?"ArrowDown":"ArrowRight")?c=(n+1)%t.length:o===s?c=(n-1+t.length)%t.length:"Home"===o?c=0:"End"===o&&(c=t.length-1),c<0||(e.preventDefault(),r[c].focus(),r[c].scrollIntoView?.({block:"nearest",inline:"nearest"}),l(t[c].id))}),r.push(i),a.appendChild(i)}),s(o),{el:a,setActive:s}}function Io(e,t,o){const n=e.getBoundingClientRect(),i=t.offsetWidth||200,a=t.offsetHeight||100;let r=4,s=4;if(void 0!==o.anchor){const e=o.anchor.getBoundingClientRect();r=e.left-n.left,s=e.bottom-n.top+6,s+a>n.height-4&&(s=Math.max(4,e.top-n.top-a-6))}else void 0!==o.point&&(r=o.point.x,s=o.point.y,s+a>n.height-4&&(s=Math.max(4,n.height-a-4)));r=Math.max(4,Math.min(r,n.width-i-4)),s=Math.max(4,Math.min(s,n.height-a-4)),t.style.left=`${Math.round(r)}px`,t.style.top=`${Math.round(s)}px`}const Do=new WeakMap;function zo(e,t,o){Do.get(e)?.();let n=!1;const i=[],a=e.ownerDocument;e.innerHTML="",e.classList.add("oac-form");const r=[],s=[],c=o.unavailable??(()=>null),d=e=>`${o.idPrefix}-${e.replace(/[^A-Za-z0-9_-]/g,"-")}`,u=new Map,h=new Map,p=new Map,g={...o.values},m=(e,t)=>{Object.defineProperty(g,e,{value:t,writable:!0,enumerable:!0,configurable:!0})},f=t.some(e=>void 0!==e.activeWhen||void 0!==e.visibleWhen);let b,v=null;const w=e=>h.has(e)&&!1!==p.get(e)?.member?.shown,y=(e,t)=>{const o=p.get(e);null===t?h.delete(e):(h.set(e,t),u.delete(e)),o&&(o.control.setAttribute("aria-invalid",String(null!==t)),o.error.textContent=t??"",o.error.hidden=!w(e))},_=(e,n)=>{const i=t.find(t=>t.key===e);if("price"===i?.kind||"timestamp"===i?.kind){if("number"!=typeof n||!Number.isFinite(n))return Pe(o,"Enter a finite number");if(void 0!==i.min&&n<i.min)return Pe(o,"Minimum: {value}",{value:i.min});if(void 0!==i.max&&n>i.max)return Pe(o,"Maximum: {value}",{value:i.max})}return"session"!==i?.kind||"string"==typeof n&&null!==l(n)?null:Pe(o,"Use HHMM-HHMM with optional :days (1 to 7)")},x=(e,t)=>{if(n)return;const i=_(e,t);if(y(e,i),!(null!==i||u.has(e)&&Object.is(u.get(e),t))){u.set(e,t),m(e,t),b=e;try{o.onChange(e,t)}finally{b=void 0}n||D(e)}};function k(e,t,n,r){const s=e=>e??"";let l,h;switch(t){case"price":case"timestamp":{const t=ko(a,"input","oac-input--num");t.type="text",t.inputMode="decimal",void 0!==n.min&&(t.min=String(n.min)),void 0!==n.max&&(t.max=String(n.max)),void 0!==n.step&&(t.step=String(n.step));const o=e=>{t.value="number"==typeof e?String(e):""},i=()=>""===t.value.trim()?void 0:Number(t.value);o(r),t.addEventListener("change",()=>x(e,i())),l=t,h={key:e,control:t,read:i,write:o,title:s};break}case"boolean":{const t=ko(a,"input");t.type="checkbox",t.checked=!0===r,t.addEventListener("change",()=>x(e,t.checked)),l=t,h={key:e,control:t,read:()=>t.checked,write:e=>{t.checked=!0===e},title:s};break}case"number":{const t=ko(a,"input","oac-input--num");t.type="number",void 0!==n.min&&(t.min=String(n.min)),void 0!==n.max&&(t.max=String(n.max)),void 0!==n.step&&(t.step=String(n.step));const i=e=>{var o;t.value="number"==typeof e&&Number.isFinite(e)?(o=e,Number.isInteger(o)?String(o):String(Math.round(1e3*o)/1e3)):""};i(r),t.addEventListener("change",()=>{const a=t.value.trim(),s=""===a?NaN:Number(a);if(!Number.isFinite(s))return void(o.preserveInvalidNumbers?x(e,void 0):i(u.has(e)?u.get(e):r));const l=n.min??-1/0,c=n.max??1/0,d=Math.min(c,Math.max(l,s));d!==s&&i(d),x(e,d)}),l=t,h={key:e,control:t,read:()=>{const e=Number(t.value);return""!==t.value.trim()&&Number.isFinite(e)?e:void 0},write:i,title:s};break}case"color":{const t=ho(a,{id:d(e),label:n.label,value:r,live:o.live,translate:o.translate,openOverlay:o.openOverlay,onChange:t=>x(e,t)});return i.push(t.destroy),l=t.el,h={key:e,control:t.input,focus:t.trigger,read:t.read,write:t.write,title:e=>e??n.label},{ctl:l,b:h}}case"opacity":{const t=ko(a,"input","oac-range");t.type="range",t.min="0",t.max="100",t.step="1";const n=ko(a,"output","oac-out"),i=e=>Math.round(100*("number"==typeof e?Math.min(1,Math.max(0,e)):0)),c=e=>{t.value=String(i(e)),n.textContent=`${i(e)}%`};c(r),t.addEventListener("input",()=>{n.textContent=`${t.value}%`,!0===o.live&&x(e,Number(t.value)/100)}),t.addEventListener("change",()=>x(e,Number(t.value)/100));const d=ko(a,"span","oac-opacity");return d.appendChild(t),d.appendChild(n),l=d,h={key:e,control:t,read:()=>Number(t.value)/100,write:c,title:s},{ctl:l,b:h}}case"select":{const{wrap:t,select:i}=Oo(a),d=n.options??[],u=t=>{i.innerHTML="";const n=d.slice(),r="string"==typeof t?t:void 0===t?void 0:String(t);void 0===r||""===r||n.some(e=>e.value===r)||n.push({value:r,label:Pe(o,"Custom")});for(const t of n){const o=ko(a,"option",void 0,t.label);o.value=t.value;const n=c(e,t.value);null!==n&&(o.disabled=!0,o.title=n),i.appendChild(o)}i.value=void 0===r||""===r?n[0]?.value??"":r};return u(r),i.addEventListener("change",()=>x(e,i.value)),l=t,h={key:e,control:i,read:()=>i.value,write:u,title:s},{ctl:l,b:h}}case"multiline":{const t=ko(a,"textarea","oac-input--multi");t.rows=3,t.setAttribute("spellcheck","false");const o=e=>{t.value=null==e?"":String(e)};o(r),t.addEventListener("change",()=>x(e,t.value)),l=t,h={key:e,control:t,read:()=>t.value,write:o,title:s};break}default:{const t=ko(a,"input");t.type="text",t.setAttribute("spellcheck","false");const o=e=>{t.value=null==e?"":String(e)};o(r),t.addEventListener("change",()=>x(e,t.value)),l=t,h={key:e,control:t,read:()=>t.value,write:o,title:s};break}}return{ctl:l,b:h}}const C=(e,t)=>{const n=ko(a,"label",t,"timestamp"===e.kind?Pe(o,"{label} (UTC seconds)",{label:e.label}):e.label);if(void 0!==e.tooltip&&""!==e.tooltip){const t=ko(a,"span","oac-help","?");t.title=e.tooltip,t.setAttribute("aria-hidden","true"),n.appendChild(t)}return n},S=(e,t,o)=>{e.htmlFor=t.id,void 0!==o.tooltip&&""!==o.tooltip&&t.setAttribute("aria-description",o.tooltip)},A=(e,t,o,n,i)=>{const a={control:e,fields:n,parts:i,offKeys:n.map(e=>e.key),offEl:t,offClass:"oac-row--off",titles:[t],row:t,head:o,shown:!0,enabled:!0};for(const e of n)e.member=a;return s.push(a),a},O=(e,t,o)=>{const n=ko(a,"div","oac-input-error");return n.id=`${d(e)}-error`,n.hidden=!0,n.setAttribute("role","status"),t.control.setAttribute("aria-describedby",n.id),o.appendChild(n),p.set(e,{control:t.control,error:n}),n},L=e=>void 0!==e.inline&&"custom"!==e.kind&&"colorPair"!==e.kind&&"multiline"!==e.kind;let E,$,T=e,j=null;for(const n of t){if(void 0!==n.group&&n.group!==E&&($=ko(a,"div","oac-head",n.group),e.appendChild($),$.id=d(`group-${s.length}`),T=ko(a,"div","oac-form__group"),T.setAttribute("role","group"),T.setAttribute("aria-labelledby",$.id),e.appendChild(T),j=null),E=n.group??E,null===j||L(n)&&n.inline===j.id||(j=null),null!==j){const e=k(n.key,n.kind,n,o.values[n.key]);e.b.control.id=d(n.key);const t=C(n,"oac-inline__label");S(t,e.b.focus??e.b.control,n),r.push(e.b);const i=ko(a,"span","oac-inline__item");i.dataset.key=n.key,"boolean"===n.kind?(i.appendChild(e.ctl),i.appendChild(t)):(i.appendChild(t),i.appendChild(e.ctl)),j.ctl.appendChild(i),O(n.key,e.b,j.row);const s=A(n,j.row,$,[e.b],[i]);s.offEl=i,s.offClass="oac-inline__item--off",s.titles=[i],p.get(n.key).member=s;continue}const t=ko(a,"div","oac-row");t.dataset.key=n.key;const i=C(n,"oac-row__label");if("custom"===n.kind){const e=void 0===o.custom?null:o.custom(n,t);if(null===e)continue;t.appendChild(ko(a,"span","oac-row__sw")),t.appendChild(i);const r=ko(a,"div","oac-row__ctl");r.appendChild(e),t.appendChild(r),T.appendChild(t),A(n,t,$,[],[t]).offEl=null;continue}if("colorPair"===n.kind&&void 0!==n.pair){const e=n.pair,s=[];if(void 0!==e.enabled){const a=k(e.enabled.key,"boolean",n,o.values[e.enabled.key]);a.ctl.classList.add("oac-row__sw"),a.ctl.id=d(e.enabled.key),S(i,a.ctl,n),r.push(a.b),s.push(a.b),t.appendChild(a.ctl)}else t.appendChild(ko(a,"span","oac-row__sw"));t.appendChild(i);const l=ko(a,"div","oac-row__ctl");let c;for(const t of[e.up,e.down]){const e=k(t.key,"color",n,o.values[t.key]);c??(c=e.b.focus??e.b.control),e.b.control.id=d(t.key),e.b.title=e=>null===e?t.label:`${t.label}: ${e}`,e.b.control.setAttribute("aria-label",`${n.label} ${t.label}`),e.b.focus?.setAttribute("aria-label",`${n.label} ${t.label}`),r.push(e.b),s.push(e.b),l.appendChild(e.ctl)}void 0===e.enabled&&void 0!==c&&S(i,c,n),t.appendChild(l),T.appendChild(t),A(n,t,$,s,[t]).offKeys=[e.up.key,e.down.key];continue}const l=k(n.key,n.kind,n,o.values[n.key]);l.b.control.id=d(n.key),S(i,l.b.focus??l.b.control,n),r.push(l.b);let c=[t],u=[t];if("boolean"===n.kind)l.ctl.classList.add("oac-row__sw"),t.appendChild(l.ctl),t.appendChild(i),L(n)&&(t.appendChild(ko(a,"div","oac-row__ctl")),c=[l.ctl,i],u=[i]);else if("multiline"===n.kind)t.classList.add("oac-row--block"),t.appendChild(i),t.appendChild(l.ctl);else{t.appendChild(ko(a,"span","oac-row__sw")),t.appendChild(i);const e=ko(a,"div","oac-row__ctl");if(L(n)){const t=ko(a,"span","oac-inline__item");t.dataset.key=n.key,t.appendChild(l.ctl),e.appendChild(t),c=[i,t],u=[i,t]}else e.appendChild(l.ctl);t.appendChild(e)}L(n)&&(t.classList.add("oac-row--inline"),t.dataset.inline=n.inline,j={id:n.inline,row:t,ctl:t.lastChild}),O(n.key,l.b,t),T.appendChild(t);const h=A(n,t,$,[l.b],c);h.titles=u,p.get(n.key).member=h}f&&(v=ko(a,"div","oac-sr"),v.setAttribute("role","status"),v.setAttribute("aria-live","polite"),e.appendChild(v));const P=e=>t.find(t=>t.key===e||[t.pair?.enabled,t.pair?.up,t.pair?.down].some(t=>t?.key===e))?.label,M=e=>!1!==e.member?.shown&&!e.control.disabled,I=()=>{if(n)return!1;for(const e of r)if(M(e))return(e.focus??e.control).focus(),!0;return!1};function D(n=b,i=!0){const l=a.activeElement,d=f?fo(t,g):null,u={shown:[],hidden:[],on:[],off:[]};for(const e of s){const t=d?.get(e.control.key),n=t?.visible??!0;let i=null;if(void 0!==t&&!t.active){const e=t.dependsOn.map(P).filter(e=>void 0!==e);i=e.length>0?Pe(o,"Depends on {inputs}",{inputs:e.join(", ")}):Pe(o,"Not used with the current settings")}for(const t of e.parts)t.hidden=!n;const a=new Map;for(const t of e.fields){const e=c(t.key)??i;a.set(t.key,e);for(const o of[t.control,t.focus])void 0!==o&&(o.disabled=null!==e,o.title=t.title(e))}const r=e.fields.length>0&&e.offKeys.every(e=>null!==a.get(e));if(null!==e.offEl){e.offEl.classList.toggle(e.offClass,r);const t=a.get(e.offKeys[0])??null;for(const o of e.titles)o.title=r?t??"":""}const s=e.control.label;e.shown!==n?u[n?"shown":"hidden"].push(s):n&&e.enabled===r&&u[r?"off":"on"].push(s),e.shown=n,e.enabled=!r}for(const e of[e=>e.row,e=>e.head]){const t=new Map;for(const o of s){const n=e(o);void 0!==n&&t.set(n,(t.get(n)??!1)||o.shown)}for(const[e,o]of t)e.hidden=!o}for(const[e,t]of p)t.error.hidden=!w(e);if(null!==l&&e.contains(l)&&(s.some(e=>!e.shown&&e.parts.some(e=>e.contains(l)))||l.disabled)){const e=void 0===n?void 0:r.find(e=>e.key===n);void 0!==e&&M(e)?(e.focus??e.control).focus():I()}if(!i||null===v)return;const h=[];if(u.shown.length>0&&h.push(Pe(o,"Shown: {inputs}",{inputs:u.shown.join(", ")})),u.hidden.length>0&&h.push(Pe(o,"Hidden: {inputs}",{inputs:u.hidden.join(", ")})),u.on.length>0&&h.push(Pe(o,"Available: {inputs}",{inputs:u.on.join(", ")})),u.off.length>0&&h.push(Pe(o,"Unavailable: {inputs}",{inputs:u.off.join(", ")})),0===h.length)return;const m=h.join(". ");v.textContent=v.textContent===m?`${m} `:m}D(void 0,!1);const z=()=>{if(!n){n=!0;for(const e of i.splice(0))e();Do.get(e)===z&&Do.delete(e)}};return Do.set(e,z),{el:e,destroy:z,setError:y,validate:()=>{const e=new Set(r.filter(e=>!M(e)).map(e=>e.key));for(const t of r){if(e.has(t.key))continue;const o=_(t.key,t.read());null===o&&h.has(t.key)||y(t.key,o)}return[...h.keys()].every(t=>e.has(t))},sync:e=>{if(n)return;for(const t of Object.keys(e))m(t,e[t]);const t=a.activeElement;for(const o of r)o.control!==t&&(h.has(o.key)||o.key in e&&(o.write(e[o.key]),u.has(o.key)&&u.set(o.key,o.read())));D()},values:()=>{const e={};for(const t of r)e[t.key]=t.read();return e},focusFirst:I}}const No=e=>void 0!==e&&void 0!==ie(e)?oe(e):'<svg aria-hidden="true"></svg>';function Ro(e,t,o,n={}){const i=e.document,a=De(i,"div","oac-menu",{role:"menu"});n.ariaLabel&&a.setAttribute("aria-label",n.ariaLabel);let r=null;if(n.find){const e=De(i,"div","oac-menu__find");r=De(i,"input",void 0,{type:"text",placeholder:n.find,"aria-label":n.find}),e.appendChild(r),a.appendChild(e)}const s=De(i,"div","oac-menu__body");a.appendChild(s);let l=()=>{};const c=o.some(e=>"string"!=typeof e&&void 0!==e.icon),d=t=>{const n=t.trim().toLowerCase();s.textContent="";let a=0,r=null;for(const e of o){if("string"==typeof e){r=e;continue}if(""!==n&&!e.label.toLowerCase().includes(n)&&!(e.sub??"").toLowerCase().includes(n))continue;if(null!==r){const e=De(i,"div","oac-head");e.textContent=r,s.appendChild(e),r=null}const t=De(i,"button","oac-menu__row"+(e.danger?" is-danger":""),{type:"button",role:void 0===e.on?"menuitem":"menuitemradio","aria-disabled":String(!0===e.disabled)});void 0!==e.on&&t.setAttribute("aria-checked",String(e.on)),c&&t.appendChild(ze(i,No(e.icon),"chrome"));const o=De(i,"span","oac-menu__label");if(o.textContent=e.label,t.appendChild(o),e.sub){const o=De(i,"span","oac-menu__sub");o.textContent=e.sub,t.appendChild(o)}if(e.key){const o=De(i,"kbd","oac-menu__key",{"aria-hidden":"true"});o.textContent=e.key,t.appendChild(o),t.setAttribute("aria-keyshortcuts",to(e.key))}t.addEventListener("click",t=>{t.stopPropagation(),e.disabled||(l(),e.onSelect())}),s.appendChild(t),a++}if(0===a){const t=De(i,"div","oac-menu__empty");t.textContent=Pe(e,"No match"),s.appendChild(t)}};if(d(""),null!==r){const e=r;e.addEventListener("input",()=>d(e.value)),e.addEventListener("keydown",e=>{if("Enter"!==e.key)return;e.preventDefault();const t=s.querySelectorAll(".oac-menu__row");1===t.length&&t[0].click()})}return a.addEventListener("keydown",e=>{const t=e,o=Array.from(s.querySelectorAll(".oac-menu__row")),n=o.indexOf(i.activeElement);"ArrowDown"===t.key?(o[(n+1)%o.length]?.focus(),t.preventDefault(),t.stopPropagation()):"ArrowUp"===t.key&&(o[(n-1+o.length)%o.length]?.focus(),t.preventDefault(),t.stopPropagation())}),l=e.openOverlay(a,{anchor:t,placement:n.placement??"below",edge:n.edge,initialFocus:r??s.querySelector('.oac-menu__row[aria-checked="true"]')??void 0}),l}function Fo(e,t,o,n){const i=globalThis;if(void 0===i.Blob||void 0===i.URL||"function"!=typeof i.URL.createObjectURL)return!1;const a=e.createElement("a"),r=i.URL.createObjectURL(new i.Blob([o],{type:n}));try{a.href=r,a.download=t,(e.body??e.documentElement).appendChild(a),a.click()}finally{a.remove(),setTimeout(()=>i.URL?.revokeObjectURL(r),0)}return!0}function Wo(e,t,o=new Date){const n=o.toISOString().slice(0,16).replace(/[:T]/g,"-");return`${(e||"chart").replace(/[^A-Za-z0-9._-]/g,"")}-${t||"chart"}-${n}`}function Bo(e,t){const{draw:o}=e,n=Xe(o,t),i=n.map(e=>o.get(e)).filter(e=>void 0!==e),a=i.filter(e=>!0===e.locked).length,r=new Set(t.map(e=>o.get(e)).filter(e=>void 0!==e).map(t=>void 0!==t.stackAbove&&e.chart.seriesStack(t.paneIndex).includes(t.stackAbove)?null:t.zIndex<0?"behind":"above")),[s]=r;return{editable:n,locked:i.length>0&&a===i.length,partlyLocked:a>0&&a<i.length,hidden:i.length>0&&i.every(e=>!1===e.visible),side:1===r.size&&void 0!==s?s:null}}function qo(e,t){const o=Bo(e,t),n=t.length>0&&0===o.editable.length?Pe(e,"read-only"):null;return{...o,readOnly:n,noDelete:n??(o.locked?Pe(e,"locked"):null)}}function Uo(e,t,o){const{draw:n}=e,i=Bo(e,o);("delete"!==t||0!==i.editable.length&&!i.locked)&&ot(e,t,()=>{switch(t){case"lock":n.updateMany(i.editable.map(e=>({id:e,patch:{locked:!i.locked}})));break;case"visible":n.updateMany(i.editable.map(e=>({id:e,patch:{visible:i.hidden}})));break;case"front":for(const e of o)n.bringToFront(e);break;case"back":for(const e of o)n.sendToBack(e);break;case"above":for(const e of o)n.bringAboveSeries(e);break;case"behind":for(const e of o)n.sendBehindSeries(e);break;case"duplicate":n.duplicate(o);break;case"delete":n.removeMany(i.editable)}})}const Ho=["off","weak","strong"],Ko=[{id:"lines",title:"Lines",items:[{head:"Lines"},{tool:"trend-line"},{tool:"ray"},{tool:"extended-line"},{tool:"arrow"},{tool:"info-line"},{tool:"trend-angle"},{head:"Horizontal and vertical"},{tool:"horizontal-line"},{tool:"horizontal-ray"},{tool:"vertical-line"},{tool:"cross-line"}]},{id:"channels",title:"Channels",items:[{head:"Channels"},{tool:"parallel-channel"},{tool:"fib-channel"},{tool:"disjoint-channel"},{tool:"flat-top-bottom"},{tool:"regression-channel"},{head:"Pitchforks"},{tool:"pitchfork"},{tool:"schiff-pitchfork"},{tool:"modified-schiff-pitchfork"},{tool:"inside-pitchfork"}]},{id:"fib",title:"Fibonacci and Gann",items:[{head:"Fibonacci"},{tool:"fib-retracement"},{tool:"fib-extension"},{tool:"fib-time-zone"},{tool:"fib-fan"},{tool:"fib-extension-two-point"},{tool:"fib-speed-resistance-fan"},{tool:"trend-fib-time"},{tool:"fib-circles"},{tool:"fib-speed-resistance-arcs"},{tool:"fib-wedge"},{tool:"fib-spiral"},{head:"Gann"},{tool:"gann-fan"},{tool:"gann-box"},{tool:"gann-square"}]},{sep:!0},{id:"shapes",title:"Shapes",items:[{head:"Shapes"},{tool:"rectangle"},{tool:"rotated-rectangle"},{tool:"ellipse"},{tool:"circle"},{tool:"triangle"},{head:"Paths"},{tool:"path"},{tool:"polyline"},{tool:"arc"},{tool:"curve"},{tool:"double-curve"}]},{id:"cycles",title:"Cycles",items:[{head:"Cycles"},{tool:"cyclic-lines"},{tool:"time-cycles"},{tool:"sine-line"}]},{id:"patterns",title:"Patterns",items:[{head:"Patterns and waves"},{tool:"xabcd-pattern"},{tool:"abcd-pattern"},{tool:"head-shoulders"},{tool:"elliott-impulse"},{tool:"elliott-correction"},{head:"Harmonic patterns"},{tool:"gartley"},{tool:"bat"},{tool:"butterfly"},{tool:"crab"},{tool:"shark"},{tool:"cypher"}]},{id:"geometry",title:"Geometric studies",items:[{head:"Geometric studies"},{tool:"dedekind-tessellation"},{tool:"sonic"},{tool:"supersonic"},{tool:"golden-sonic"},{tool:"golden-supersonic"}]},{id:"marks",title:"Arrows and marks",items:[{head:"Arrows"},{tool:"arrow-up"},{tool:"arrow-down"},{tool:"arrow-left"},{tool:"arrow-right"},{head:"Marks"},{tool:"flag-mark"},{tool:"icon-stamp"},{tool:"price-label"},{tool:"signpost"}]},{sep:!0},{id:"forecast",title:"Forecasting",items:[{head:"Forecasting"},{tool:"long-position"},{tool:"short-position"},{tool:"forecast"}]},{id:"analysis",title:"Volume studies",items:[{head:"Volume studies"},{tool:"anchored-vwap"},{tool:"fixed-range-volume-profile"}]},{id:"measure",title:"Measurers",items:[{head:"Measurers"},{tool:"price-range"},{tool:"date-range"},{tool:"measure"}]},{sep:!0},{id:"text",title:"Text and notes",items:[{head:"Text and notes"},{tool:"text"},{tool:"note"},{tool:"callout"},{tool:"balloon"},{tool:"comment"},{tool:"price-note"},{tool:"table"},{head:"Brushes"},{tool:"brush"},{tool:"highlighter"}]}],Vo=e=>(null===e?null:et(e))?.name??String(e??"Cursor"),Go="rail",Jo="oac-rail-sprite";function Zo(e,t){if(void 0!==ae[t])return ze(e,re(t),"tool");const o=De(e,"span","oac-glyph oac-glyph--text",{"aria-hidden":"true"});return o.textContent=String(t).charAt(0).toUpperCase(),o}function Yo(e,t,o){const n={favorites:[],magnet:"off",stay:!1,last:{}};if(null===e||"object"!=typeof e)return n;const i=e;if(Array.isArray(i.favorites)&&(n.favorites=i.favorites.filter((e,t,o)=>"string"==typeof e&&X(e)&&o.indexOf(e)===t)),"string"==typeof i.magnet&&Ho.includes(i.magnet)&&(n.magnet=i.magnet),n.stay=!0===i.stay,null!==i.last&&"object"==typeof i.last){const e=i.last;for(const i of t)void 0!==i.id&&"string"==typeof e[i.id]&&o(i).includes(e[i.id])&&(n.last[i.id]=e[i.id])}return n}function Qo(e,t,o={}){const n=e.document,i=t=>Pe(e,`schema.drawing.${t??"cursor"}.name`,{},Vo(t)),a=e.draw,r=e.chart;!function(e){if(null!==e.getElementById(Jo))return;const t=e.createElement("div");t.id=Jo,t.hidden=!0,t.innerHTML=se(),(e.body??e.documentElement).appendChild(t)}(n);const s=void 0===o.tools?null:new Set(o.tools),l=e=>(e.items??[]).filter(e=>void 0!==e.tool&&X(e.tool)&&(null===s||s.has(e.tool))).map(e=>e.tool),c=e=>Ko.find(t=>t.id===e);let d=Yo(e.storage.get(Go),Ko,l);null===e.storage.get(Go)&&o.favorites&&(d.favorites=o.favorites.filter((e,t,o)=>X(e)&&o.indexOf(e)===t));let u=!1;const h=()=>{e.storage.set(Go,d)},p=e=>d.last[e.id??""]??l(e)[0]??null;let g=null;const m=(t,o)=>oo(e.keymap,t,o),f=e=>{if(null!==e)return null===g&&(g=ce()),m(`tool:${e}`,g[e])},b=()=>a.selection().slice(),v=t=>qo(e,t),w=e=>{const t=o.cursorTarget;t&&(null!==e&&void 0!==ae[e]?t.style.setProperty("--oac-tool-cursor",le(e)):t.style.removeProperty("--oac-tool-cursor"))},y=()=>{a.setOptions({magnet:d.magnet})},_=()=>{a.setOptions({stayInDrawingMode:d.stay||u})},x=e=>{if(!Ho.includes(e))throw new Error(`openalgo-charts widget: unknown magnet mode "${String(e)}"`);d.magnet=e,h(),y(),R()},k=()=>{const t=Ho[(Ho.indexOf(d.magnet)+1)%Ho.length];return x(t),e.status(Pe(e,"off"===t?"Magnet off":"weak"===t?"Magnet weak: snaps when a bar or study value is within a few pixels":"Magnet strong: every anchor lands on the nearest bar or study value")),t},C=t=>{d.stay=!0===t,h(),_(),R(),e.status(d.stay?Pe(e,"Tools stay active after each drawing"):Pe(e,"One drawing per pick"))},S=e=>{u=!0===e,_(),V(a.activeTool())},A=e=>{a.setTool(e),V(e)},O=t=>{S(!0),A(t),e.status(Pe(e,"{name} stays active until Escape",{name:i(t)}))};t.classList.add("oac-rail"),t.setAttribute("role","toolbar"),t.setAttribute("aria-orientation","vertical"),t.setAttribute("aria-label",Pe(e,"Drawing tools"));const L=t=>{const o=De(n,"button","oac-rail__btn"+(t.cls?" "+t.cls:""),{type:"button"});return o.tabIndex=-1,o.appendChild(t.glyphEl),e.tips.attach(o,t.tip,600),o.addEventListener("click",e=>{o.classList.contains("is-off")||t.onClick(e)}),t.onContext&&o.addEventListener("contextmenu",e=>{e.preventDefault(),e.stopPropagation(),t.onContext?.(e)}),o},E=(e,t)=>{const o=e.querySelector(".oac-glyph");o?o.replaceWith(t):e.insertBefore(t,e.firstChild)},$=()=>De(n,"div","oac-rail__sep",{role:"separator"}),T=t=>{const o=L({cls:"oac-rail__tool oac-rail__fav",glyphEl:Zo(n,t),tip:()=>({title:Pe(e,"{name} (pinned)",{name:i(t)}),chord:f(t),sub:Pe(e,"Pinned. Right-click to unpin"),side:"right"}),onClick:e=>{e.detail>=2&&!d.stay?O(t):(S(!1),A(t))},onContext:()=>D(o,[{label:Pe(e,"Unpin from rail"),icon:"star",onSelect:()=>q(t,!1)}])});return o.dataset.tools=t,o},j=t=>{const o=l(t);let r=!1;const s=L({cls:"oac-rail__tool oac-rail__group",glyphEl:Zo(n,p(t)??o[0]),tip:()=>({title:i(p(t)),chord:f(p(t)),sub:Pe(e,d.stay?"{group}: chevron for the rest":"{group}: chevron for the rest. Double-click keeps it active",{group:void 0===t.title?"":Pe(e,`schema.rail.${t.id}.title`,{},t.title)}),side:"right"}),onClick:e=>{const o=r&&0!==e.detail;if(r=!1,null===P||"true"!==s.getAttribute("aria-expanded"))if(o)I(t,s,!1);else{if(e.detail>=2&&!d.stay){const e=p(t);return void(null!==e&&O(e))}a.activeTool()!==p(t)?(S(!1),A(p(t))):I(t,s,!1)}else M()},onContext:()=>I(t,s,!1)});s.addEventListener("pointerdown",e=>{const t=e.target;r="touch"!==e.pointerType&&"function"==typeof t?.closest&&null!==t.closest(".oac-rail__chev")}),s.dataset.tools=o.join(","),s.dataset.group=t.id??"",s.dataset.face=p(t)??"",s.setAttribute("aria-haspopup","menu"),s.setAttribute("aria-expanded","false");const c=De(n,"span","oac-rail__chev",{"aria-hidden":"true"});return c.innerHTML=oe("chevron-right"),s.appendChild(c),s};let P=null;const M=()=>{P?.close()},I=(o,r,l)=>{M(),e.tips.hide();const c=De(n,"div","oac-fly",{role:"menu","aria-label":void 0===o.title?Pe(e,"Tools"):Pe(e,`schema.rail.${o.id}.title`,{},o.title)}),u=a.activeTool(),p=[];for(const t of o.items??[]){if(void 0!==t.head){const i=De(n,"div","oac-head");i.textContent=Pe(e,`schema.rail.${o.id}.group.${t.head}`,{},t.head),c.appendChild(i);continue}const a=t.tool;if(void 0===a||!X(a)||null!==s&&!s.has(a))continue;const l=De(n,"div","oac-fly__row",{role:"menuitemradio","aria-checked":String(u===a)});l.tabIndex=-1,l.dataset.tool=a,l.appendChild(Zo(n,a));const d=De(n,"span","oac-fly__name");d.textContent=i(a),l.appendChild(d);const h=W(a),m=De(n,"button","oac-fly__star",{type:"button","aria-pressed":String(h),"aria-label":Pe(e,"Pin to rail")});m.tabIndex=-1,m.innerHTML=oe(h?"star-filled":"star"),l.appendChild(m);const b=De(n,"kbd","oac-fly__chord");b.textContent=f(a)??"",l.appendChild(b);const v=()=>{const e=!W(a);q(a,e),m.setAttribute("aria-pressed",String(e)),m.innerHTML=oe(e?"star-filled":"star")};m.addEventListener("click",e=>{e.stopPropagation(),v()}),l.addEventListener("click",e=>{e.stopPropagation(),g(a)}),l.addEventListener("keydown",e=>{const t=e;"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),t.stopPropagation(),null!==t.target.closest(".oac-fly__star")?v():(g(a),r.focus()))}),p.push(l),c.appendChild(l)}const g=e=>{void 0!==o.id&&(d.last[o.id]=e,h()),M(),S(!1),A(e)};c.addEventListener("keydown",e=>{const t=e,o=t.target.closest(".oac-fly__row"),n=null===o?-1:p.indexOf(o),i=e=>{p[(e+p.length)%p.length]?.focus()};switch(t.key){case"ArrowDown":i(n+1);break;case"ArrowUp":i(n-1);break;case"Home":i(0);break;case"End":i(p.length-1);break;case"ArrowRight":o?.querySelector(".oac-fly__star")?.focus();break;case"ArrowLeft":o?.focus();break;default:return}t.preventDefault(),t.stopPropagation()});const m=p.find(e=>"true"===e.getAttribute("aria-checked"))??p[0]??null,b=e.openOverlay(c,{anchor:r,placement:"beside",edge:t,initialFocus:l?m:c,onClose:()=>{null!==P&&P.el===c&&(P=null)}});P={el:c,close:b}},D=(o,n)=>{e.tips.hide(),Ro(e,o,n,{placement:"beside",edge:t})},z={},N=(e,t)=>{void 0!==e&&(e.classList.toggle("is-on",!0===t.on),e.classList.toggle("is-off",!0===t.off),e.setAttribute("aria-disabled",!0===t.off?"true":"false"),void 0!==t.pressed&&e.setAttribute("aria-pressed",String(t.pressed)),void 0!==t.glyph&&e.dataset.glyph!==t.glyph&&(e.dataset.glyph=t.glyph,E(e,So(n,t.glyph))))},R=()=>{if(void 0===z.magnet)return;N(z.magnet,{on:"strong"===d.magnet,pressed:"off"!==d.magnet}),z.magnet.classList.toggle("is-weak","weak"===d.magnet),z.magnet.dataset.mode=d.magnet,N(z.stay,{on:d.stay,pressed:d.stay});const t=v(b()),o=0===t.editable.length;N(z.lock,{off:o,on:t.locked,pressed:t.locked,glyph:t.locked?"lock":"unlock"}),N(z.eye,{off:o,on:t.hidden,pressed:t.hidden,glyph:t.hidden?"eye-off":"eye"}),N(z.trash,{off:null!==t.noDelete||o}),N(z.undo,{off:!nt(e,"undo")}),N(z.redo,{off:!nt(e,"redo")});for(const t of Object.values(z))e.tips.refreshLabel(t)};let F=null;const W=e=>d.favorites.includes(e),B=()=>{if(null===F)return;F.textContent="";const e=d.favorites.filter(e=>X(e));if(0!==e.length){F.appendChild($());for(const t of e)F.appendChild(T(t))}},q=(e,t=!W(e))=>{if(!X(e))return;const o=W(e);t&&!o&&d.favorites.push(e),!t&&o&&d.favorites.splice(d.favorites.indexOf(e),1),h(),B(),V(a.activeTool())},U=()=>Array.from(t.querySelectorAll(".oac-rail__btn")),H=e=>{for(const t of U())t.tabIndex=t===e?0:-1},K=()=>{t.textContent="",t.appendChild((()=>{const t=L({cls:"oac-rail__tool",glyphEl:Zo(n,"cursor"),tip:()=>({title:Pe(e,"Cursor"),chord:"Esc",side:"right"}),onClick:()=>{S(!1),A(null)}});return t.dataset.tools="",t})()),F=De(n,"div","oac-rail__favs"),t.appendChild(F),B(),t.appendChild($());for(const e of Ko)e.sep?t.appendChild($()):l(e).length>0&&t.appendChild(j(e));t.appendChild((()=>{const t=De(n,"div","oac-rail__ctl");return z.magnet=L({cls:"oac-rail__btn--magnet",glyphEl:Zo(n,"magnet"),tip:()=>({title:Pe(e,"Magnet: {mode}",{mode:Pe(e,`schema.magnet.${d.magnet}`,{},d.magnet)}),sub:"off"===d.magnet?Pe(e,"Click for weak: snaps when a bar or study value is within a few pixels"):"weak"===d.magnet?Pe(e,"Click for strong: every anchor lands on the nearest bar or study value"):Pe(e,"Click to switch the magnet off"),side:"right"}),onClick:()=>{k()}}),t.appendChild(z.magnet),z.stay=L({cls:"oac-rail__btn--chrome",glyphEl:So(n,"link"),tip:()=>({title:Pe(e,"Keep tool active"),sub:d.stay?Pe(e,"On: the tool stays active after each drawing"):Pe(e,"Off: one drawing per pick"),side:"right"}),onClick:()=>C(!d.stay)}),t.appendChild(z.stay),t.appendChild($()),z.lock=L({cls:"oac-rail__btn--chrome",glyphEl:So(n,"unlock"),tip:()=>{const t=b();return{title:Pe(e,"Lock drawing"),sub:0===t.length?Pe(e,"Select a drawing first"):v(t).readOnly??void 0,side:"right"}},onClick:()=>{Uo(e,"lock",b()),R()}}),t.appendChild(z.lock),z.eye=L({cls:"oac-rail__btn--chrome",glyphEl:So(n,"eye"),tip:()=>{const t=b(),o=v(t);return{title:Pe(e,"Hide drawing"),side:"right",sub:0===t.length?Pe(e,"Select a drawing first"):o.readOnly??(o.hidden?void 0:Pe(e,"Stays selected, so the eye brings it back"))}},onClick:()=>{Uo(e,"visible",b()),R()}}),t.appendChild(z.eye),z.trash=L({cls:"oac-rail__btn--chrome oac-rail__btn--danger",glyphEl:So(n,"trash"),tip:()=>{const t=b(),o=v(t),n=o.editable.length,i=o.noDelete??void 0;return t.length>0?{title:n>1?Pe(e,"Delete {count} drawings",{count:n}):Pe(e,"Delete drawing"),chord:m("delete","Delete"),sub:i??Pe(e,"Right-click to remove all"),side:"right"}:{title:Pe(e,"Delete drawing"),chord:m("delete","Delete"),sub:Pe(e,"Select one first. Right-click to remove all"),side:"right"}},onClick:()=>{Uo(e,"delete",b()),R()},onContext:()=>{const t=a.drawings(),o=t.filter(e=>!1!==e.policy?.selectable).length,n=Xe(a,t.map(e=>e.id)).length;D(z.trash,[{label:Pe(e,"Select all ({count})",{count:o}),icon:"cursor",disabled:0===o,onSelect:()=>{a.select(t.map(e=>e.id)),R()}},{label:Pe(e,"Remove all drawings ({count})",{count:n}),icon:"trash",danger:!0,disabled:0===n,onSelect:()=>{a.clear(),R(),e.status(n>0?Pe(e,1===n?"Removed {count} drawing":"Removed {count} drawings",{count:n}):Pe(e,"No drawings to remove"))}}])}}),t.appendChild(z.trash),t.appendChild($()),z.undo=L({cls:"oac-rail__btn--chrome",glyphEl:So(n,"undo"),tip:()=>({title:Pe(e,"Undo"),chord:m("undo","Mod+Z"),side:"right"}),onClick:()=>{tt(e,"undo"),R()}}),t.appendChild(z.undo),z.redo=L({cls:"oac-rail__btn--chrome",glyphEl:So(n,"redo"),tip:()=>({title:Pe(e,"Redo"),chord:m("redo-alt","Mod+Y")??m("redo",void 0),side:"right"}),onClick:()=>{tt(e,"redo"),R()}}),t.appendChild(z.redo),t})()),V(a.activeTool())},V=o=>{const i=o??null;let a=null;for(const o of Array.from(t.querySelectorAll(".oac-rail__tool"))){const t=(o.dataset.tools??"").split(",").filter(Boolean),r=null===i?0===t.length:t.includes(i);o.classList.toggle("is-on",r),o.classList.toggle("is-held",r&&u&&t.length>0),o.setAttribute("aria-pressed",String(r)),r&&null===a&&(a=o),r&&o.dataset.group&&t.length>0&&null!==i&&(d.last[o.dataset.group]!==i&&(d.last[o.dataset.group]=i,h()),o.dataset.face!==i&&(o.dataset.face=i,E(o,Zo(n,i)))),e.tips.refreshLabel(o)}const r=n.activeElement;null===a||null!==r&&t.contains(r)||H(a),w(i),R()},G=()=>{const e=n.activeElement;return null!==e&&t.contains(e)?e.closest(".oac-rail__btn"):null},J=e=>{const t=U();if(0===t.length)return;const o=t[(e%t.length+t.length)%t.length];H(o),o.focus()},Z=[],Y=(t,o,n)=>{Z.push(e.keymap.register(t,o,"rail",{label:n,group:"Tool rail"}))};Y("ArrowDown",()=>{J(U().indexOf(G())+1)},"Next tool"),Y("ArrowUp",()=>{J(U().indexOf(G())-1)},"Previous tool"),Y("Home",()=>{J(0)},"First tool"),Y("End",()=>{J(U().length-1)},"Last tool"),Y("ArrowRight",()=>{const e=G(),t=e?.dataset.group?c(e.dataset.group):void 0;return null!==e&&void 0!==t&&(I(t,e,!0),!0)},"Open the group"),Y("Escape",()=>{const t=null!==P;M(),e.tips.hide();const n=o.cursorTarget;return void 0!==n&&"function"==typeof n.focus?n.focus():G()?.blur(),t},"Back to the chart");const Q=e=>{const t=e.target,o=null!==t&&"function"==typeof t.closest?t.closest(".oac-rail__btn"):null;null!==o&&H(o)};t.addEventListener("focusin",Q);const ee=[];ee.push(r.on("draw:tool",e=>{V(e.tool)}));for(const e of["draw:select","drawing:select","drawing:change","draw:add","draw:remove","draw:update","draw:paste","draw:cut"])ee.push(r.on(e,R));return void 0!==e.history&&ee.push(e.history.subscribe(R)),y(),_(),K(),{el:t,sync:V,refresh:R,prefs:()=>({favorites:d.favorites.slice(),magnet:d.magnet,stay:d.stay,last:{...d.last}}),restorePrefs:e=>{d=Yo(e,Ko,l),h(),y(),_(),K()},magnetMode:()=>d.magnet,setMagnetMode:x,cycleMagnet:k,stayMode:()=>d.stay,setStayMode:C,favorites:()=>d.favorites.slice(),isFavorite:W,toggleFavorite:q,setDrawLock:S,drawLocked:()=>u,openGroup:(e,o=!1)=>{const n=c(e),i=t.querySelector(`.oac-rail__group[data-group="${e}"]`);void 0!==n&&null!==i&&I(n,i,o)},closeFlyout:M,flyoutOpen:()=>null!==P,destroy:()=>{M();for(const e of ee)e();for(const e of Z)e();t.removeEventListener("focusin",Q),w(null),t.textContent=""}}}function Xo(e,t,o){if(void 0===t)return"";const n={regular:Pe(e,"Regular hours"),extended:Pe(e,"Extended hours"),adjusted:Pe(e,"Adjusted prices"),raw:Pe(e,"Raw prices")},i=[];for(const e of["session","adjustment","currency","unit"]){const a=t[e];void 0===a||void 0!==o&&o!==e||i.push("session"===e||"adjustment"===e?n[a]:a)}return i.join(" ")}const en={regular:"Market open",pre:"Pre-open",post:"Post-close",extended:"Extended hours",closed:"Market closed",holiday:"Holiday"},tn={regular:"market-open",pre:"market-pre",post:"market-post",extended:"market-post",closed:"market-closed",holiday:"market-holiday"};function on(e,t){const o=Math.round(h(e,t)/60);if(0===o)return"UTC";const n=Math.abs(o),i=n%60;return`UTC${o<0?"-":"+"}${Math.floor(n/60)}${0===i?"":":"+String(i).padStart(2,"0")}`}function nn(e,t,o=!0){return o?d(Math.floor(e),t):u(Math.floor(e),t)}const an=new Map;function rn(e,t,o,n){const i=t.phase,a=Pe(e,`schema.ui.market.${i}`,{},en[i]),r=t=>null===t?"":function(e,t,o,n){const i=u(e,o),a=g(e,o),r=g(t,o);if(a.year===r.year&&a.month===r.month&&a.day===r.day)return i;const s=`${n??""}\0${o}`;let l=an.get(s);if(void 0===l){try{l=new Intl.DateTimeFormat(n,{timeZone:o,weekday:"short"})}catch{l=new Intl.DateTimeFormat(void 0,{timeZone:o,weekday:"short"})}an.set(s,l)}return`${l.format(new Date(1e3*e))} ${i}`}(t,o,n,e.locale);let s="";return"regular"===i&&null!==t.closesAt?s=Pe(e,"schema.ui.market.closes",{time:r(t.closesAt)},"closes {time}"):"post"!==i&&"extended"!==i||null===t.changesAt?"regular"!==i&&null!==t.opensAt&&(s=Pe(e,"schema.ui.market.opens",{time:r(t.opensAt)},"opens {time}")):s=Pe(e,"schema.ui.market.until",{time:r(t.changesAt)},"until {time}"),{phase:i,label:a,detail:s}}class sn{constructor(){Object.defineProperty(this,"_calendar",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_status",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_from",{enumerable:!0,configurable:!0,writable:!0,value:1/0}),Object.defineProperty(this,"_until",{enumerable:!0,configurable:!0,writable:!0,value:-1/0})}read(e,t){if(e!==this._calendar||t<this._from||t>=this._until){this._calendar=e,this._from=t;try{this._status=p(e,t)}catch{this._status=null}this._until=this._status?.changesAt??t+86400}return this._status}until(){return this._until}}function ln(e){return!1!==e.statusLineOptions().marketStatus}const cn=2;function dn(e){const t=e.panes()[e.primaryPaneIndex()];if(void 0===t)return 2;const o=t.priceScale.precision();return Number.isFinite(o)?Math.max(2,Math.min(8,Math.round(o))):2}function un(e,t,o){let n=o.get(t);return void 0===n&&(n=new Intl.NumberFormat(e,{minimumFractionDigits:t,maximumFractionDigits:t}),o.set(t,n)),n}function hn(e,t,o={}){const n=e.document,i=e.chart,a=o.locale??e.locale;t.classList.add("oac-statusline"),t.setAttribute("role","status"),t.setAttribute("aria-live","polite");const r=De(n,"span","oac-statusline__title"),s=De(n,"span","oac-statusline__sym"),l=De(n,"span","oac-statusline__iv"),c=De(n,"span","oac-statusline__iv oac-statusline__variant");r.appendChild(s),r.appendChild(l),r.appendChild(c),t.appendChild(r);const d=(e,o)=>{const i=De(n,"span","oac-statusline__field "+o),a=De(n,"i");a.textContent=e;const r=De(n,"b");return i.appendChild(a),i.appendChild(r),i.hidden=!0,t.appendChild(i),{el:i,val:r}},u=d(Pe(e,"O"),"oac-statusline__o"),h=d(Pe(e,"H"),"oac-statusline__h"),p=d(Pe(e,"L"),"oac-statusline__l"),g=d(Pe(e,"C"),"oac-statusline__c"),f=d("","oac-statusline__chg"),b=d(Pe(e,"Vol"),"oac-statusline__vol"),v=d(Pe(e,"OI"),"oac-statusline__oi"),w=De(n,"span","oac-statusline__time");t.appendChild(w);const y=De(n,"span","oac-statusline__market");y.hidden=!0,t.appendChild(y);const _=De(n,"span","oac-statusline__msg");t.appendChild(_);const x=De(n,"span","oac-statusline__tz");t.appendChild(x);const k=new Map,C=new Intl.NumberFormat(a,{minimumFractionDigits:2,maximumFractionDigits:2}),S=new Intl.NumberFormat(a,{notation:"compact",maximumFractionDigits:2});let A=null,O=null,L=!0,E=!1,$=!1;const T=(e,t)=>{e.textContent!==t&&(e.textContent=t)},j=(e,t)=>{e.hidden===t&&(e.hidden=!t)},P=()=>{const t=i.statusLineOptions();j(r,!1!==t.title);const o=Xo(e,i.getDataContext()?.variant);T(c,o),j(c,""!==o);const n=!1!==t.chartValues&&null!==A;for(const e of[u,h,p,g])j(e.el,n);const s=dn(i);if(n&&null!==A){const e=un(a,s,k);T(u.val,e.format(A.open)),T(h.val,e.format(A.high)),T(p.val,e.format(A.low)),T(g.val,e.format(A.close))}const l=!1!==t.barChange&&null!==A;if(j(f.el,l),l&&null!==A){const e=A.close-A.open,t=0!==A.open?e/A.open*100:0,o=e>0?"+":"";T(f.val,`${o}${un(a,s,k).format(e)} (${o}${C.format(t)}%)`),f.el.classList.toggle("is-up",e>0),f.el.classList.toggle("is-down",e<0)}const d=!1!==t.volume&&null!==A&&"number"==typeof A.volume;j(b.el,d),d&&null!==A&&T(b.val,S.format(A.volume));const y=!0===t.openInterest&&!1!==i.hasOpenInterest&&void 0!==A?.oi&&Number.isFinite(A.oi);j(v.el,y),y&&void 0!==A?.oi&&T(v.val,S.format(A.oi)),T(w,null!==O&&null!==A?m(O,i.timezone()):""),T(x,i.timezone()),N()},M=new sn;let I=0,D=0,z=!1;function N(){if(!0!==o.marketStatus||z)return;const t=(o.now??Date.now)()/1e3,n=ln(i)?M.read(i.dataLayer.sessionCalendar,t):null,r=null===n?null:rn({translate:e.translate,locale:a},n,t,i.timezone());j(y,null!==r),null!==r&&(T(y,""===r.detail?r.label:`${r.label} · ${r.detail}`),y.dataset.phase!==r.phase&&(y.dataset.phase=r.phase));const s=Math.floor(null===n?t+60:Math.min(M.until(),t+3600));s!==D&&(0!==I&&clearTimeout(I),I=0,D=s,0!==s&&(I=setTimeout(()=>{I=0,D=0,N()},1e3*Math.max(1,s-t)+50)))}const R=()=>{if(E)return{bar:null,time:null};const e=i.primaryBars(),t=e[e.length-1];return void 0===t?{bar:null,time:null}:{bar:t,time:t.time}},F=(e,t)=>{e===A&&t===O||(A=e,O=t,P())},W=()=>{const e=R();F(e.bar,e.time)},B=i.on("crosshair:move",e=>{const t=e;if(null!==t.bar&&void 0!==t.bar)return L=!1,void F(t.bar,t.time);L=!0,W()}),q=i.on("data:context",P),U=i.on("data:update",e=>{const t=e?.kind;if("reset"===t&&(E=!1),L)return void W();const o=R();null!==o.bar&&o.time===O&&F(o.bar,o.time)}),H=i.on("resize",()=>{L&&W()}),K=i.on("timezone:changed",P),V={el:t,setMessage:(e,t="info")=>{T(_,e),_.classList.toggle("is-error","error"===t)},setSymbol:(e,t,o)=>{const n=t?`${t}:${e}`:e;$&&n===s.textContent&&o===l.textContent||(T(s,n),T(l,o),E=$,$=!0,L=!0,E?F(null,null):W())},setBar:(e,t)=>{L=null===e,F(e,t)},refresh:()=>{if(L){const e=R();A=e.bar,O=e.time}P()},destroy:()=>{z=!0,0!==I&&clearTimeout(I),B(),q(),U(),H(),K(),t.textContent=""}};return P(),V}function pn(e){return"string"==typeof e&&(f().includes(e)||b().includes(e))}const gn=150;function mn(e){if("string"!=typeof e)return null;const t=e.trim();if(/^https:\/\/[^\s]+$/i.test(t))try{const e=new URL(t);return e.username||e.password?null:e.href}catch{return null}return/^\/(?!\/)[\w./%-]+(?:\?[\w=&.%-]+)?$/.test(t)?t:null}let fn=0;function bn(e,t,o){const n=e.document,i="mobile"===o.variant;let a,r=!1,s=0,l=null,c=null,d=null,u=null,h=null,p=[],g="",m=null,f=[],b=0,v="",w=!1;const y=()=>{s++,null!==l&&(clearTimeout(l),l=null),c?.abort(),c=null},_=()=>{y();const e=h;h=null,d=null,u=null,p=[],f=[],m=null,g="",w=!1,t.setAttribute("aria-expanded","false"),t.removeAttribute("aria-controls"),e?.()},x=e=>{if(r||w||!f.includes(e)||t.value.trim()!==v||(void 0===o.context?void 0:JSON.stringify(o.context()))!==a)return;const n=e.symbol.trim();""!==n&&(t.blur(),_(),o.onSelect(n,e.exchange))},k=()=>{if(null===d||null===u)return;const t=d.querySelector(".oac-symbol-picker__categories");t.textContent="";const o=Array.from(new Set(p.map(e=>e.assetClass?.trim()).filter(e=>Boolean(e))));if(o.length>1)for(const i of["",...o]){const o=De(n,"button","oac-symbol-picker__category",{type:"button","aria-pressed":String(g===i)});o.textContent=i||Pe(e,"schema.ui.allAssets",{},"All"),o.addEventListener("click",()=>{y(),g=i,m=null,b=0,k()}),t.appendChild(o)}u.textContent="";const a=p.filter(e=>""===g||e.assetClass===g),r=m?.contractGroup;if(f=void 0===r?a.slice():r.contracts.filter(e=>"string"==typeof e.symbol),void 0!==r){const t=De(n,"button","oac-symbol-picker__back",{type:"button"});if(t.textContent=Pe(e,"schema.ui.backToSymbols",{},"Back to symbols"),t.addEventListener("click",()=>{m=null,b=0,k()}),u.appendChild(t),r.label){const e=De(n,"div","oac-head");e.textContent=r.label,u.appendChild(e)}}if(f.forEach((t,o)=>{if("string"!=typeof t.symbol)return;const a=De(n,"button","oac-symbol-picker__row oac-menu__row"+(o===b?" is-active":""),{type:"button",role:"option"});i&&(a.dataset.mobileAction="pick-symbol");const r=mn(t.iconUrl);if(null!==r){const e=De(n,"img","oac-symbol-picker__icon",{src:r,alt:""});a.appendChild(e)}const s=De(n,"span","oac-menu__label");if(s.textContent=t.exchange?`${t.exchange}:${t.symbol}`:t.symbol,a.appendChild(s),t.name){const e=De(n,"span","oac-menu__sub");e.textContent=t.name,a.appendChild(e)}if(t.contractGroup){const t=De(n,"span","oac-symbol-picker__group");t.textContent=Pe(e,"schema.ui.showContracts",{},"Contracts"),a.appendChild(t)}a.addEventListener("click",e=>{e.stopPropagation(),t.contractGroup?(m=t,b=0,k()):x(t)}),u?.appendChild(a)}),0===f.length){const t=De(n,"div","oac-symbol-picker__empty",{role:"status"});t.textContent=Pe(e,"schema.ui.noSymbols",{},"No symbols found"),u.appendChild(t)}},C=x=>{if(y(),v=x.trim(),""===v)return void _();g="",m=null,p=[],f=[],b=0,a=void 0===o.context?void 0:JSON.stringify(o.context());const C=s;w=!0,(()=>{if(null!==d)return;if(d=De(n,"div","oac-symbol-picker "+(i?"oac-mobile-results":"oac-menu oac-sym__results"),{role:i?"region":"listbox","aria-label":Pe(e,"schema.ui.symbolResults",{},"Symbols")}),d.addEventListener("mousedown",e=>e.preventDefault()),i){const t=De(n,"div","oac-mobile-results__head"),o=De(n,"strong");o.textContent=Pe(e,"schema.ui.symbolResults",{},"Symbols");const i=De(n,"button","oac-mobile__action",{type:"button"});i.dataset.mobileAction="close-search",i.textContent=Pe(e,"schema.ui.closeSearch",{},"Close"),i.addEventListener("click",_),t.append(o,i),d.appendChild(t)}const o=De(n,"div","oac-symbol-picker__categories");d.appendChild(o),u=De(n,"div",i?"oac-mobile-results__list":"oac-menu__body"),u.setAttribute("role","listbox"),u.id="oac-symbol-picker-"+ ++fn,d.appendChild(u),t.setAttribute("aria-controls",u.id),t.setAttribute("aria-expanded","true");const a=d;h=e.openOverlay(d,{anchor:t,placement:"below",initialFocus:null,dismissOnOutside:!0,onClose:()=>{d===a&&_()}})})(),null!==d&&(d.querySelector(".oac-symbol-picker__categories").textContent="");const S=(t,o)=>{if(null===u)return;const i=De(n,"div","oac-symbol-picker__status",{role:"status"});i.textContent=Pe(e,t,{},o),u.textContent="",u.appendChild(i)};S("schema.ui.searchingSymbols","Searching");const A=()=>{C===s&&(w=!1,S("schema.ui.symbolSearchFailed","Search unavailable"))};l=setTimeout(()=>{let e;l=null,c=new AbortController;try{e=Promise.resolve(o.search(v,{signal:c.signal}))}catch{return void A()}e.then(e=>{r||C!==s||null===d||t.value.trim()!==v||(void 0===o.context?void 0:JSON.stringify(o.context()))!==a||(w=!1,p=e.filter(e=>"string"==typeof e.symbol&&""!==e.symbol.trim()),0!==p.length?(b=0,k()):_())},A)},150)},S=()=>C(t.value),A=e=>{if(!e.isComposing&&229!==e.keyCode)if("Escape"!==e.key){if(!w&&t.value.trim()===v&&(void 0===o.context?void 0:JSON.stringify(o.context()))===a)if("ArrowDown"===e.key||"ArrowUp"===e.key){if(0===f.length)return;e.preventDefault(),e.stopImmediatePropagation(),b=(b+("ArrowDown"===e.key?1:-1)+f.length)%f.length,k()}else if("Enter"===e.key&&void 0!==f[b]){e.preventDefault(),e.stopImmediatePropagation();const t=f[b];t.contractGroup?(m=t,b=0,k()):x(t)}}else null!==d&&(e.preventDefault(),_())},O=e=>{const t=e.relatedTarget;t&&!0===d?.contains(t)||_()};t.addEventListener("input",S),t.addEventListener("keydown",A),t.addEventListener("blur",O),t.setAttribute("aria-autocomplete","list"),t.setAttribute("aria-haspopup","listbox"),t.setAttribute("aria-expanded","false");const L=e.bus.on("symbol",_),E=e.bus.on("interval",_);return{open:e=>{r||(t.focus(),void 0!==e&&(t.value=e),""!==t.value.trim()&&C(t.value))},canCommitRaw:()=>!w&&0===f.length,close:_,destroy:()=>{r||(r=!0,_(),L(),E(),t.removeEventListener("input",S),t.removeEventListener("keydown",A),t.removeEventListener("blur",O))}}}const vn="\n.oac-widget .oac-symbol-picker{min-width:250px;max-width:min(420px,calc(100vw - 24px))}\n.oac-widget .oac-symbol-picker__categories{display:flex;gap:4px;overflow-x:auto;padding:5px 7px;scrollbar-color:var(--oac-sb-thumb) var(--oac-panel);scrollbar-width:thin}\n.oac-widget .oac-symbol-picker__categories::-webkit-scrollbar{height:6px}\n.oac-widget .oac-symbol-picker__categories::-webkit-scrollbar-track{background:var(--oac-panel)}\n.oac-widget .oac-symbol-picker__categories::-webkit-scrollbar-thumb{background:var(--oac-sb-thumb);border-radius:3px}\n.oac-widget .oac-symbol-picker__categories::-webkit-scrollbar-thumb:hover{background:var(--oac-sb-thumb-hover)}\n.oac-widget .oac-symbol-picker__categories:empty{display:none}\n.oac-widget .oac-symbol-picker__category,.oac-widget .oac-symbol-picker__back{background:transparent;border:0;color:inherit;cursor:pointer;padding:4px 7px;font:inherit}\n.oac-widget .oac-symbol-picker__category[aria-pressed=true]{background:var(--oac-elev);border-radius:4px}\n.oac-widget .oac-symbol-picker__row{display:flex;align-items:center;gap:7px;width:100%;text-align:left}\n.oac-widget .oac-symbol-picker__icon{width:18px;height:18px;object-fit:contain}\n.oac-widget .oac-symbol-picker__group{margin-left:auto;opacity:.7}\n.oac-widget .oac-symbol-picker__empty,.oac-widget .oac-symbol-picker__status{padding:9px;color:var(--oac-mut)}\n";function wn(e){const t=void 0===e?null:w(e);return null!==t&&y(t.bucketing)?t.bucketing:null}const yn=()=>({status:"cancelled"});function _n(e){const t=e.getDataContext();return`${t?.symbol}\0${t?.exchange}\0${t?.interval}`}function xn(e,t){return new Promise((o,n)=>{const i=()=>n(t.reason);t.aborted?i():(t.addEventListener("abort",i,{once:!0}),e.then(o,n).finally(()=>t.removeEventListener("abort",i)))})}function kn(e,t){let o=0,n=e;for(;o<n;){const e=o+n>>1;t(e)?n=e:o=e+1}return o}class Cn{constructor(e){Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_abort",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),this._options=e}goTo(e){if(this.cancel(),this._destroyed)return Promise.resolve({status:"cancelled"});const t=new AbortController;return this._abort=t,this._run(e,t.signal).catch(e=>t.signal.aborted?{status:"cancelled"}:{status:"error",error:e instanceof Error?e:new Error(String(e))}).finally(()=>{this._abort===t&&(this._abort=null)})}cancel(){const e=this._abort;this._abort=null,e?.abort()}destroy(){this._destroyed=!0,this.cancel()}_chart(){const e=this._options.chart,t="function"==typeof e?e():e;return null===t||t.isDestroyed?null:t}async _run(e,t){const{from:o,to:n}=e;if(!Number.isFinite(o)||void 0!==n&&!(Number.isFinite(n)&&n>=o))return{status:"invalid"};let i=this._chart();if(null===i)return{status:"cancelled"};const a=_n(i),r=wn(this._options.interval?.()??i.getDataContext()?.interval);if(null===r)return{status:"unsupported"};const s=function(e,t){if("interval"===e.mode){if(e.seconds<86400)return{open:e=>e,close:t=>t+e.seconds};const o=e=>_(e,t);return{open:o,close:n=>_(o(n)+e.seconds+43200,t)}}return{open:o=>k(e,o,t),close:o=>x(e,o,t)??o}}(r,i.timezone()),l=i.primaryBars();if(0===l.length||s.close(l[l.length-1].time)<=o)return{status:"no-data"};const c=i.getVisibleLogicalRange(),d=o-(void 0===n?Math.ceil(Math.max(0,c.to-c.from)/2):0)*(s.close(o)-s.open(o));let u,h=l[0].time;for(;s.open(h)>d;){const e=this._options.loadHistory;if(void 0===e||v(i)){u="unavailable";break}if(u=await xn(e(d,t),t),i=this._chart(),t.aborted||null===i||_n(i)!==a)return yn();const o=i.primaryBars()[0]?.time;if("loaded"!==u)break;if(void 0===o||o>=h){u="empty";break}h=o}return function(e,t,o,n,i){const a=e.primaryBars(),r=a.length,s=void 0!==i&&"loaded"!==i&&r>0&&t.open(a[0].time)>o?i:void 0,l=kn(r,e=>t.close(a[e].time)>o),c=void 0===n?l:kn(r,e=>t.open(a[e].time)>n)-1;if(l>=r||c<l)return void 0===s?{status:"no-data"}:{status:"no-data",history:s};const d=t=>e.dataLayer.timeToIndex(a[t].time)??t;let u,h,p=c,g=!1;if(void 0===n){const t=e.getVisibleLogicalRange(),o=(t.to-t.from)/2,n=d(l),i=Math.max(0,n+o-d(r-1)-4);u=n-o-i,h=n+o-i}else{u=d(l)-.5,h=d(c)+.5;const t=e.timeScale.width;if(t>0){const o=t/e.timeScale.constrainBarSpacing(t/(h-u));if(o<h-u-1e-9)for(h=u+o,g=!0;p>l&&d(p)>h-.5;)p--;else u-=(o-(h-u))/2,h=u+o}}e.setVisibleLogicalRange({from:u,to:h});const m={status:void 0!==s||g?"partial":"placed",from:a[l].time,to:a[p].time};return void 0!==s&&(m.history=s),g&&(m.clipped=!0),m}(i,s,o,n,u)}}const Sn=()=>{},An=e=>e instanceof Error&&"WorkspaceConflictError"===e.name,On=(e,t)=>e?.workspaces.find(e=>e.id===t),Ln=e=>void 0===e?"":JSON.stringify([e.layout,e.panes,e.activePaneId,e.sync]);function En(e,t,o={}){const n=Number.isFinite(o.autosaveDelay)?Math.min(Math.max(0,o.autosaveDelay),2147483647):1e3;let i,a=null,r=null,s=null,l=null,c="",d=!1,u=!1,h=!1,p=null,g=!1,m=!1,f=!1,b=0,v=0,w=Promise.resolve(),y=!1,_="";const x=new Set,k=()=>{try{return!0===t.suspended?.()}catch{return!1}},C=()=>({catalog:a,layoutId:s,revision:r,dirty:d,busy:b>0,suspended:k(),conflict:u,autosave:a?.autosave&&null!==s?g?"saving":h||u?"failed":void 0!==i||y||d?"pending":"saved":"off",error:p}),S=()=>{if(f)return;const e=C(),t=JSON.stringify([a?.revision,r,s,d,e.busy,e.suspended,u,e.autosave,null===p]);if(t!==_){_=t;for(const t of Array.from(x))try{t(e)}catch(e){queueMicrotask(()=>{throw e})}}},A=()=>null!==s&&Ln(On(a,s))!==c,O=e=>{p=e,_=""},L=()=>!(null===a||null===r||a.revision<=r||A())&&(r=a.revision,!0),E=()=>{s=null,l=null,c="",d=!1,u=!1},$=()=>{u=!0,l=null,d=!0};async function T(){const t=await e.load();(null===a||t.revision>a.revision)&&(a=t),A()&&$(),L(),S()}async function j(e,t){const o=t?.();for(let n=0;;n++){const i=void 0===t?r:a.revision;try{const o=await e(i);return void 0===t&&(r=Math.max(r,i+1)),h=!1,L(),o}catch(e){if(!An(e)||3===n)throw e;if(await T(),void 0===t?r===i:t()!==o)throw e}}}const P=e=>()=>JSON.stringify(On(a,e)??null),M=e=>()=>Ln(On(a,e)),I=()=>"";async function D(){const t=await e.load();return(null===a||t.revision>=a.revision)&&(a=t),h=!1,null!==s&&void 0===On(a,s)&&E(),A()?$():(u=!1,r=a.revision),t}const z=async()=>{null===r&&await D()},N=e=>{m=!0;try{return t.apply(e)}catch(e){return{applied:!1,reason:e instanceof Error?e.message:String(e)}}finally{m=!1}},R=(e,t,o)=>{c=Ln(e),l=t,d=v!==o,d||void 0===i||(clearTimeout(i),i=void 0),u=!1,p=null,L()};async function F(o){const n=t.capture(),i=JSON.stringify(n),a=v;g=!0,S();try{const t=await j(t=>e.saveWorkspace(o,n,{expectedRevision:t}));return R(t,i,a),t}catch(e){throw h=!0,e}finally{g=!1}}function W(e){if(f)return Promise.reject(new Error("The layouts controller is destroyed"));b++,S();const t=w.then(()=>{if(f)throw new Error("The layouts controller is destroyed");return e()});return w=t.then(Sn,Sn),t.then(e=>(b--,p=null,U(),S(),e),e=>{throw b--,O(e),U(),S(),e})}async function B(){if(y=!1,f||null===s)return S();const o=s;try{const n=t.capture(),i=JSON.stringify(n),r=v;if(d=i!==l,!d||!a?.autosave||u||h||k())return S();g=!0,S();const c=await j(t=>e.saveWorkspace(o,n,{expectedRevision:t}));g=!1,s===o&&R(c,i,r)}catch(e){g=!1,h=!0,O(e)}S()}const q=()=>{y||f||(y=!0,w=w.then(B).then(Sn,Sn))};function U(){!a?.autosave||null===s||!d||u||h||g||void 0!==i||q()}const H=()=>{f||m||(v++,void 0!==i&&clearTimeout(i),i=setTimeout(()=>{i=void 0,q()},n),S())},K=t.subscribe?.(H),V=e.subscribe(e=>{f||null!==a&&e.revision<=a.revision||(a=e,L(),U(),S())});return{store:e,state:C,subscribe:e=>(x.add(e),()=>{x.delete(e)}),reload:()=>W(async()=>JSON.parse(JSON.stringify(await D()))),open:o=>W(async()=>{if(k())throw new Error("A layout cannot open while the chart is suspended, as during a replay");const n=h;if(await(async()=>{(void 0!==i||y)&&(void 0!==i&&(clearTimeout(i),i=void 0),await B())})(),h&&!n)throw p;await D();const r=On(a,o);if(void 0===r)throw new Error("The saved layout no longer exists");const l=t.capture(),c=v,d=N((e=>JSON.parse(JSON.stringify({layout:e.layout,panes:e.panes,activePaneId:e.activePaneId,sync:e.sync})))(r));if(!d.applied)return d;const u=JSON.stringify(t.capture()),g=a;let m=r;if(g.activeWorkspaceId!==o||g.recentWorkspaceIds[0]!==o)try{m=await j(t=>e.openWorkspace(o,{expectedRevision:t}),M(o))}catch(e){throw N(l).applied||E(),e}return s=m.id,R(m,u,c),d}),save:()=>W(async()=>{if(await z(),null===s)throw new Error("No saved layout is held: save it under a name first");return F(s)}),saveAs:o=>W(async()=>{await D();const n=t.capture(),i=JSON.stringify(n),a=v,r=await j(t=>e.createWorkspace(o,n,{expectedRevision:t}),I);return s=r.id,R(r,i,a),await j(t=>e.openWorkspace(r.id,{expectedRevision:t}),M(r.id)),r}),overwrite:()=>W(async()=>{if(await D(),null===s)throw new Error("The saved layout no longer exists: save it under a name");return c=Ln(On(a,s)),r=a.revision,F(s)}),rename:(t,o)=>W(async()=>{await z(),await j(n=>e.rename("workspace",t,o,{expectedRevision:n}),P(t))}),duplicate:(t,o)=>W(async()=>(await z(),await j(n=>e.duplicate("workspace",t,o,{expectedRevision:n}),P(t)))),remove:t=>W(async()=>{await z(),await j(o=>e.remove("workspace",t,{expectedRevision:o}),P(t)),t===s&&(E(),L())}),setAutosave:t=>W(async()=>{await z(),await j(o=>e.setAutosave(t,{expectedRevision:o}),I),t&&q()}),changed:H,async flush(){f||(void 0!==i&&(clearTimeout(i),i=void 0),q(),await w)},destroy(){f||(f=!0,void 0!==i&&clearTimeout(i),V(),K?.(),x.clear())}}}const $n=240,Tn=["data","objects","watchlist","news"],jn={data:"Data",objects:"Objects",watchlist:"Watchlist",news:"News"};function Pn(e){const t="object"==typeof e&&null!==e?e:{};return{panel:Tn.includes(t.panel)?t.panel:null,width:"number"==typeof t.width&&Number.isFinite(t.width)?Math.round(Math.max($n,Math.min(480,t.width))):300}}function Mn(e,t,o){const n=e.document,i=(t,o)=>Pe(e,`schema.ui.dock.${t}`,{},o),a=ko(n,"aside","oac-panel-dock");a.hidden=!0,a.setAttribute("aria-label",i("title","Chart information"));const r=ko(n,"div","oac-panel-dock__resize");r.setAttribute("role","separator"),r.setAttribute("aria-orientation","vertical"),r.setAttribute("aria-label",i("resize","Resize information panel")),r.tabIndex=0;const s=ko(n,"div","oac-panel-dock__header"),l=ko(n,"div","oac-panel-dock__tabs");l.setAttribute("role","group"),l.setAttribute("aria-label",i("panels","Information panels"));const c=Tn.filter(e=>"function"==typeof o[e]),d=new Map(c.map(e=>[e,Ao(n,{label:i(e,jn[e]),onClick:()=>E(e)})])),u=e=>{for(const[t,o]of d)o.setAttribute("aria-pressed",String(t===e))},h=Ao(n,{label:i("close","Close"),onClick:()=>L()});h.classList.add("oac-panel-dock__close"),l.append(...d.values()),s.append(l,h);const p=ko(n,"div","oac-panel-dock__body");a.append(r,s,p),t.appendChild(a);const g=Pn(o.state);let m=null,f=null,b=!1,v=!1,w=null,y=null;const _=()=>e.root.getBoundingClientRect().width||e.root.clientWidth||1e3,x=()=>_()<=640,k=()=>Math.max($n,Math.min(480,_()-320)),C=()=>{o.onChange?.({...g})},S=e=>{g.width=Math.round(Math.max($n,Math.min(k(),e))),a.style.width=`${g.width}px`,r.setAttribute("aria-valuemin",String($n)),r.setAttribute("aria-valuemax",String(k())),r.setAttribute("aria-valuenow",String(g.width))},A=()=>{if(!f)return;v=!0;const e=f;f=null,e(),v=!1},O=(o=!1)=>{if(b||null===g.panel)return;const i=null!==n.activeElement&&a.contains(n.activeElement)?n.activeElement:null,s=x();s!==("true"===a.dataset.sheet)&&A(),a.dataset.sheet=String(s),r.hidden=s,s&&!f?f=e.openOverlay(a,{placement:"center",modal:!0,initialFocus:i??m?.initialFocus??h,restoreFocus:!1,onClose:()=>{f=null,v||L()}}):s||(a.parentElement!==t&&t.appendChild(a),a.classList.remove("oac-dialog"),a.removeAttribute("aria-modal"),a.removeAttribute("role"),a.style.position="",a.style.left="",a.style.top="",a.style.transform="",S(g.width),o?(m?.initialFocus??h).focus():i?.focus())};function L(){if(null===g.panel)return;g.panel=null,y=null,A(),m?.destroy(),m=null,p.textContent="",a.hidden=!0,t.appendChild(a),u(null);const e=n.activeElement;w?.isConnected&&(null===e||e===n.body||a.contains(e))&&w.focus(),w=null,C()}function E(e,t=!0){if(b)return;const i=o[e];c.includes(e)&&void 0!==i&&(g.panel!==e||null===m?(null!==g.panel&&null!==m||(w=n.activeElement),m?.destroy(),p.textContent="",g.panel=e,a.hidden=!1,u(e),m=i(p),O(t),C()):t&&(m.initialFocus??h).focus())}const $=t=>{"Escape"===t.key&&0===e.overlays.size()&&(t.preventDefault(),t.stopPropagation(),L()),t.target===r&&["ArrowLeft","ArrowRight","Home","End"].includes(t.key)&&(t.preventDefault(),t.stopPropagation(),S("Home"===t.key?$n:"End"===t.key?k():g.width+("ArrowLeft"===t.key?10:-10)*(t.shiftKey?5:1)),C())},T=e=>{0!==e.button||x()||(e.preventDefault(),e.stopPropagation(),y={x:e.clientX,width:g.width,pointer:e.pointerId},r.setPointerCapture?.(e.pointerId),r.focus())},j=e=>{y&&y.pointer===e.pointerId&&(e.preventDefault(),S(y.width+y.x-e.clientX))},P=e=>{if(y&&y.pointer===e.pointerId){y=null,C();try{r.releasePointerCapture?.(e.pointerId)}catch{}}};a.addEventListener("keydown",$),r.addEventListener("pointerdown",T),r.addEventListener("pointermove",j),r.addEventListener("pointerup",P),r.addEventListener("pointercancel",P);const M=n.defaultView,I=()=>{x()||S(g.width),O()};M?.addEventListener?.("resize",I);const D=M?.ResizeObserver,z=D?new D(I):null;z?.observe(e.root),S(g.width);const N=g.panel;return g.panel=null,null!==N&&E(N,!1),{el:a,open:E,close:L,toggle:e=>{g.panel===e?L():E(e)},state:()=>({...g}),restore:e=>{const t=Pn(e);S(t.width),null!==t.panel&&c.includes(t.panel)?E(t.panel,!1):L()},destroy:()=>{b||(L(),b=!0,z?.disconnect(),M?.removeEventListener?.("resize",I),a.removeEventListener("keydown",$),r.removeEventListener("pointerdown",T),r.removeEventListener("pointermove",j),r.removeEventListener("pointerup",P),r.removeEventListener("pointercancel",P),a.remove())}}}const In='\n.oac-widget .oac-panel-dock { position: relative; flex: none; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--oac-panel); border-left: 1px solid var(--oac-bd); }\n.oac-widget .oac-panel-dock__header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 10px; border-bottom: 1px solid var(--oac-bd-soft); flex: none; }\n.oac-widget .oac-panel-dock__tabs { display: flex; flex-wrap: wrap; gap: 3px; min-width: 0; }\n.oac-widget .oac-panel-dock__tabs .oac-btn, .oac-widget .oac-panel-dock__close { padding: 0 6px; }\n.oac-widget .oac-panel-dock__tabs .oac-btn { border-color: transparent; background: transparent; }\n.oac-widget .oac-panel-dock__tabs .oac-btn[aria-pressed="true"] { background: var(--oac-elev); color: var(--oac-tx); border-color: var(--oac-bd); }\n.oac-widget .oac-panel-dock__close { color: var(--oac-mut); }\n.oac-widget .oac-panel-dock__body { overflow: auto; min-height: 0; flex: 1 1 auto; overscroll-behavior: contain; }\n.oac-widget .oac-panel-dock__resize { position: absolute; z-index: 2; top: 0; bottom: 0; left: -4px; width: 8px; cursor: col-resize; touch-action: none; }\n.oac-widget .oac-panel-dock__resize:hover, .oac-widget .oac-panel-dock__resize:focus-visible { background: var(--oac-ring-soft); }\n.oac-widget .oac-panel-dock[data-sheet="true"] { position: absolute !important; inset: 0 !important; width: 100% !important; max-width: none !important; height: 100%; max-height: none; transform: none !important; border: 0; border-radius: 0; }\n.oac-widget .oac-panel-dock[data-sheet="true"] .oac-panel-dock__header { padding: 12px; }\n.oac-widget .oac-panel-dock[data-sheet="true"] .oac-btn { min-height: 40px; }\n.oac-widget .oac-panel-dock__body > .oac-objects { width: auto; max-width: none; border: 0; box-shadow: none; }\n';function Dn(){if(this.context.overlays.size()>0)return["overlay"];const e=[],t=this._doc.activeElement,o=this._opts.keyboardRoute?.();if(!1===o||null!==t&&this._dataStatus.el.contains(t))return[];const n=null!==t&&this.root.contains(t)?t.closest("[data-key-scope]")?.getAttribute("data-key-scope"):null;return n&&e.push(n),null!==this._rail&&null!==t&&this._rail.el.contains(t)&&e.push("rail"),(o||this._inChart())&&e.push("chart"),(o||this._pointerInside||null!==t&&this.root.contains(t))&&e.push("widget"),e.push("global"),e}function zn(){const e=this._keymap,t=this.draw,o=()=>({hasSelection:null!==t.selected(),hasTarget:null!==t.hovered(),editingText:!1,placing:null!==t.activeTool()}),n=()=>{const e=t.selection();if(e.length>0)return e.slice();const o=t.hovered();return null===o?[]:[o]},i=()=>(this._rail?.refresh(),!0),a=()=>{const e=this.alerts.hovered();return void 0!==e&&null===t.activeTool()&&(this.alerts.remove(e),i())},r=e=>{const r=de(e,o());if(null===r)return("Delete"===e.key||"Backspace"===e.key)&&a();switch(r.type){case"delete":Uo(this.context,"delete",n());break;case"nudge":t.nudge(n(),r.dx,r.dy);break;case"cancel":t.cancel(),null===t.activeTool()&&this._rail?.setDrawLock(!1);break;case"finish":t.finish();break;case"popAnchor":t.popAnchor();break;default:return!1}return i()},s=()=>{const e=o();return e.hasSelection||e.hasTarget},l=e=>()=>!!s()&&(e(n()),i()),c=(t,o,n,i,a={})=>{e.register(t,o,"widget",{label:n,group:a.group??"Drawing",hidden:a.hidden,layered:a.layered,command:i,rebindable:!0!==a.fixed})},d=e=>()=>(tt(this.context,e),i());c("Mod+Z",d("undo"),"Undo","undo",{group:"Widget"}),c("Mod+Shift+Z",d("redo"),"Redo","redo",{group:"Widget"}),c("Mod+Y",d("redo"),"Redo","redo-alt",{group:"Widget",hidden:!0}),c("Mod+C",l(e=>t.copy(e)),"Copy the selected drawing","copy"),c("Mod+X",l(e=>null===qo(this.context,e).noDelete&&t.cut(e)),"Cut the selected drawing","cut"),c("Mod+V",()=>(t.paste(),i()),"Paste drawings","paste"),c("Mod+D",l(e=>t.duplicate(e)),"Duplicate the selected drawing","duplicate"),c("Delete",()=>s()?(Uo(this.context,"delete",n()),i()):a(),"Delete the selected drawing","delete"),c("Backspace",r,"Delete, or drop the last anchor while placing","delete-back",{fixed:!0}),c("Enter",r,"Finish the drawing being placed","finish",{fixed:!0});for(const[e,t]of[["left","ArrowLeft"],["right","ArrowRight"],["up","ArrowUp"],["down","ArrowDown"]])c(t,r,`Nudge the selection ${e} (Shift: ten pixels)`,`nudge-${e}`,{layered:!0,fixed:!0});for(const e of["left","right","up","down"])c(`Shift+Arrow${e[0].toUpperCase()}${e.slice(1)}`,r,"Nudge ten pixels",`nudge-${e}-far`,{hidden:!0,layered:!0,fixed:!0});c("Escape",e=>null!==t.activeTool()?(r(e)||(t.setTool(null),this._rail?.setDrawLock(!1)),!0):t.selection().length>0&&(t.select(null),this._rail?.refresh(),!0),"Leave the tool, then clear the selection","leave",{fixed:!0});for(const[e,o]of Object.entries(ce()))c(o,()=>(this._rail?.setDrawLock(!1),t.setTool(e),!0),Vo(e),`tool:${e}`,{group:"Drawing tools"});const u=!1!==this._opts.shortcutsEditor;if(c("?",()=>(ro(this.context,{edit:u}),!0),"Keyboard shortcuts","shortcuts",{group:"Widget",fixed:!0}),!u)return h=e,void no.add(h);var h;const p=this.context.storage;Nn.call(this),this._cleanups.push(e.onChange(()=>{const t=e.overrides();0===Object.keys(t).length?p.remove(It):p.set(It,t)}))}function Nn(){!1!==this._opts.shortcutsEditor&&this._keymap.applyOverrides(this.context.storage.get(It))}function Rn(){const e=this.root,t=this._chartEl,o=()=>{this._pointerInside=!0},n=()=>{this._pointerInside=!1,this._pointerInChart=!1},i=()=>{this._pointerInChart=!0},a=()=>{this._pointerInChart=!1};e.addEventListener("pointerenter",o),e.addEventListener("pointerleave",n),t.addEventListener("pointerenter",i),t.addEventListener("pointerleave",a),this._cleanups.push(()=>{e.removeEventListener("pointerenter",o),e.removeEventListener("pointerleave",n),t.removeEventListener("pointerenter",i),t.removeEventListener("pointerleave",a)})}const Fn="state",Wn="drawings:";function Bn(e){const t={...e};delete t.viewport,delete t.barSpacing;const o=e=>{if(!He(e))return e;const t={...e,autoScale:!0};return delete t.range,delete t.ratioLock,t};return Array.isArray(t.panes)&&(t.panes=t.panes.map(e=>{if(!He(e))return e;const t={...e};return He(e.priceScale)&&(t.priceScale=o(e.priceScale)),He(e.scales)&&(t.scales=Object.fromEntries(Object.entries(e.scales).map(([e,t])=>[e,o(t)]))),t})),t}function qn(e){if(void 0!==e?.chart){const t=e.symbol===this._symbol&&e.exchange===this._exchange&&e.interval===this._interval&&C(e.variant)===C(this._variant);let o=t?e.chart:Bn(e.chart);null!==this.instrumentDrawings&&null!==Gn(e)&&(o={...o,drawings:this.draw.toJSON()});const n=this.chart.restoreState(o);n.applied?(this._keepView=t,this._pendingView=t?e.chart.viewport??null:null):this._toasts.toast(Pe(this.context,"The saved layout could not be restored: {error}",{error:n.reason??"unknown reason"}),"error")}e?.rail&&null!==this._rail&&this._rail.restorePrefs(e.rail),e?.panels&&this._dock?.restore(e.panels)}function Un(e){const t=this._storage,o=this._opts.drawingStore??(t.enabled?Hn(t):ue());return void 0!==e?.chart?.drawings&&he(o,Gn(e),e.chart.drawings),new pe(this.chart,this.draw,{store:o,...this._holdDrawings?{key:e=>this._holdDrawings?null:ge(e)}:{},onError:({operation:e,key:t})=>{if("read"===e||this._destroyed)return;const o=Pe(this._opts,"The drawings for {instrument} could not be saved",{instrument:decodeURIComponent(t)});this._statusline?.setMessage(o,"error"),this._bus.emit("status",{text:o,kind:"error"})}})}function Hn(e){return{get:t=>e.get(Wn+t),set:(t,o)=>e.set(Wn+t,o),remove:t=>e.remove(Wn+t)}}function Kn(){this._holdDrawings&&(this._holdDrawings=!1,this.instrumentDrawings?.setInstrument({symbol:this._symbol,exchange:this._exchange}))}function Vn(){this._restoring&&(this._stateGiven=!0,Kn.call(this))}function Gn(e){return ge({symbol:e.symbol.toUpperCase(),exchange:e.exchange})}function Jn(e){if(!He(e))return{applied:!1,reason:"not a widget state object"};if(void 0!==e.version&&1!==e.version)return{applied:!1,reason:`widget state version ${String(e.version)} is not 1`};let t;try{t=S(e.variant)}catch(e){return{applied:!1,reason:e instanceof Error?e.message:"invalid data variant"}}"dark"!==e.theme&&"light"!==e.theme||this.setTheme(e.theme),pn(e.chartType)&&this._selectChartType(e.chartType,He(e.chart)?e.chart:void 0),void 0!==e.rail&&null!==this._rail&&this._rail.restorePrefs(e.rail),void 0!==e.panels&&this._dock?.restore(e.panels);const o="string"==typeof e.symbol?e.symbol.toUpperCase():this._symbol,n="string"==typeof e.exchange?e.exchange:this._exchange,i="string"==typeof e.interval&&A(e.interval)?e.interval:this._interval,a=C(t)===C(this._variant),r=o===this._symbol&&n===this._exchange&&i===this._interval&&a;let s;if(He(e.chart)){let t=e.chart;const i=this.instrumentDrawings,a=null!==i&&(o!==this._symbol||n!==this._exchange)&&null!==ge({symbol:o,exchange:n}),l=t.drawings;if(a&&(t={...t,drawings:this.draw.toJSON()}),s=this.chart.restoreState(r?t:Bn(t)),!s.applied)return{applied:!1,reason:s.reason,chart:s};Vn.call(this),a&&null!==i&&i.setDocument({symbol:o,exchange:n},l??[]),this._keepView=r,this._pendingView=r?t.viewport??null:null}return Vn.call(this),r||(this._cancelNavigation(),i!==this._interval&&(this._interval=i,this._bus.emit("interval",{interval:i})),o===this._symbol&&n===this._exchange||(this._symbol=o,this._exchange=n,this._bus.emit("symbol",{symbol:o,exchange:n})),a||(this._variant=t,this._bus.emit("variant",{variant:t})),this._statusline?.setSymbol(this._symbol,this._exchange,this._interval),this._topbar?.refresh(),this._mobile?.refresh(),this._opts.feed?this.reload():(this._series.setData([]),this._publishDataContext())),this._rail?.refresh(),this._statusline?.refresh(),this._bus.emit("layout",{reason:"restore",chartType:this.chartType()}),this._scheduleSave(),void 0===s?{applied:!0}:{applied:!0,chart:s}}function Zn(){const e=this._storage.get(Fn);if(!He(e)||1!==e.version)return null;const t=function(e){try{return S(e)}catch{return null}}(e.variant),o=He(e.chart)?e.chart:void 0;return{version:1,symbol:"string"==typeof e.symbol?e.symbol:"",exchange:"string"==typeof e.exchange?e.exchange:"",interval:"string"==typeof e.interval&&""!==e.interval?e.interval:"1d",chartType:"string"==typeof e.chartType?e.chartType:"candlestick",theme:"light"===e.theme?"light":"dark",...t?{variant:t}:{},chart:o&&null===t?Bn(o):o,rail:He(e.rail)?e.rail:null,panels:Pn(e.panels)}}function Yn(){this._storage.enabled&&!this._destroyed&&(this._restoring?this._saveWanted=!0:(0!==this._saveTimer&&clearTimeout(this._saveTimer),this._saveTimer=setTimeout(()=>{this._saveTimer=0,this._saveNow()},250)))}function Qn(){if(this._storage.enabled&&!this._destroyed)if(this._restoring)this._saveWanted=!0;else{0!==this._saveTimer&&(clearTimeout(this._saveTimer),this._saveTimer=0);try{this._storage.set(Fn,this.getState())||this.context.status(Pe(this.context,"The chart layout could not be saved"),"error")}catch(e){this.context.status(Pe(this.context,"The chart layout could not be saved: {error}",{error:e instanceof Error?e.message:"invalid state"}),"error")}}}function Xn(){const e=this._doc.defaultView,t=!this._storage.loaded;if(null!=e&&"function"==typeof e.addEventListener){const o=t?()=>{this._saveNow(),this._storage.flush()}:()=>this._saveNow();e.addEventListener("pagehide",o),this._cleanups.push(()=>e.removeEventListener("pagehide",o))}if(t){const e=this._doc,t=()=>{"hidden"===e.visibilityState&&(0!==this._saveTimer&&this._saveNow(),this._storage.flush())};e.addEventListener("visibilitychange",t),this._cleanups.push(()=>e.removeEventListener("visibilitychange",t))}}function ei(){const e={symbol:this._symbol,exchange:this._exchange,interval:this._interval,variant:this._variant,chartType:this.chartType(),theme:this._themeName};return this.root.style.visibility="hidden",this._storage.load().then(()=>{if(!this._destroyed)try{this._bus.shelter(()=>ni.call(this,e))}catch(e){this._restoring=!1,this._toasts.toast(Pe(this.context,"The saved layout could not be restored: {error}",{error:Me(this.context,e)}),"error");try{Kn.call(this),oi.call(this)}catch{}}finally{this._restoring=!1,this._holdDrawings=!1,this.root.style.visibility=""}})}class ti extends it{constructor(){super(...arguments),Object.defineProperty(this,"_sheltered",{enumerable:!0,configurable:!0,writable:!0,value:!1})}emit(e,t){if(this._sheltered)try{super.emit(e,t)}catch{}else super.emit(e,t)}shelter(e){const t=this._sheltered;this._sheltered=!0;try{e()}finally{this._sheltered=t}}}function oi(){const e=this.dataController,t=e?.getState().request??null,o=null!==t&&t.symbol===this._symbol&&t.exchange===this._exchange&&t.interval===this._interval&&C(t.variant)===C(this._variant);null===e||""===this._symbol||o||this.reload()}function ni(e){const t=this._saveWanted,o=this._stateGiven?null:Zn.call(this),n=this._opts,i={symbol:this._symbol,exchange:this._exchange,interval:this._interval,variant:this._variant};if(null!==o){const t=this._symbol===e.symbol&&this._exchange===e.exchange;t&&void 0===n.symbol&&(this._symbol=o.symbol.toUpperCase()),t&&void 0===n.exchange&&(this._exchange=o.exchange),void 0===n.interval&&this._interval===e.interval&&A(o.interval)&&(this._interval=o.interval),void 0===n.variant&&C(this._variant)===C(e.variant)&&(this._variant=o.variant)}const a=this._symbol!==i.symbol||this._exchange!==i.exchange;(a||this._interval!==i.interval||C(this._variant)!==C(i.variant))&&(null===this.dataController&&this._series.setData([]),this._publishDataContext(),this._statusline?.setSymbol(this._symbol,this._exchange,this._interval),this._topbar?.refresh(),this._mobile?.refresh()),this.history.ignore(()=>{null!==o&&null!==this.instrumentDrawings&&void 0!==o.chart?.drawings&&he(n.drawingStore??Hn(this._storage),Gn(o),o.chart.drawings),Kn.call(this);const t=this._storage.get(Go);if(null!==t&&null!==this._rail&&this._rail.restorePrefs(t),Nn.call(this),null===o)return;const i=o.chartType;void 0===n.chartType&&this.chartType()===e.chartType&&i!==e.chartType&&pn(i)&&this._selectChartType(i,o.chart),void 0===n.theme&&this._themeName===e.theme&&o.theme!==e.theme&&this.setTheme(o.theme),qn.call(this,o)}),null!==o&&(this._rail?.refresh(),this._statusline?.refresh()),this._restoring=!1,this._saveWanted=!1,t&&this._scheduleSave(),oi.call(this),this._interval!==i.interval&&this._bus.emit("interval",{interval:this._interval}),a&&(this._bus.emit("symbol",{symbol:this._symbol,exchange:this._exchange}),this.chart.emit("symbol",{symbol:this._symbol,exchange:this._exchange})),C(this._variant)!==C(i.variant)&&this._bus.emit("variant",{variant:this._variant}),null!==o&&this._bus.emit("layout",{reason:"restore",chartType:this.chartType()})}function ii(e){if(this._destroyed)return;const t=Me(this.context,e.error);if("load"!==e.operation)return void this.context.status(Pe(this.context,"Saved chart settings could not be written: {error}",{error:t}),"error");const o=Pe(this.context,"Saved chart settings could not be read, so changes are kept for this session only: {error}",{error:t});this.context.status(o,"error"),this._toasts.toast(o,"error")}const ai="widget.theme",ri="p0",si=["symbol","interval","variant","theme","layout"],li=["alert:created","alert:updated","alert:removed","alert:triggered","alert:expired","replay:start","replay:stop","replay:end"],ci=["lastClosedTime","lastTouchedTime","lastTriggeredAt","lastTriggeredTime"];function di(e){const t=Bn(e),o=t.alerts;return void 0!==o&&Array.isArray(o.alerts)?{...t,alerts:{...o,alerts:o.alerts.map(e=>{const t={...e};for(const e of ci)delete t[e];return t})}}:t}function ui(e,t,o){return{id:e,symbol:t.symbol,exchange:t.exchange,interval:t.interval,...t.variant?{variant:t.variant}:{},chartType:t.chartType,chart:o,settings:{[ai]:t.theme},volume:!1,magnet:t.rail?.magnet??"off",stay:t.rail?.stay??!1,comparisons:[],comparisonMode:"percent"}}function hi(e,t,o){const n=o?t.settings[ai]:void 0,i=e.getState().rail;return e.restoreState({version:1,symbol:t.symbol,exchange:t.exchange,interval:t.interval,chartType:t.chartType,chart:t.chart,..."dark"===n||"light"===n?{theme:n}:{},...t.variant?{variant:t.variant}:{},...null===i?{}:{rail:{...i,magnet:t.magnet,stay:t.stay}}})}function pi(e){return{capture(){const t=JSON.parse(JSON.stringify(e.getState())),o=ui(ri,t,di(t.chart));return{layout:{rows:1,columns:1,slots:[{paneId:ri,row:0,column:0,rowSpan:1,columnSpan:1}]},panes:[o],activePaneId:ri,sync:{crosshair:!0,viewport:!0,symbol:!1,interval:!1}}},apply(t){const o=function(e){if(1!==e.panes.length)return`a layout of ${e.panes.length} charts needs a chart grid`;const[t]=e.panes;if(!A(t.interval))return`unknown interval ${t.interval}`;if(!pn(t.chartType))return`unknown chart type ${t.chartType}`;if(t.comparisons.length>0)return"comparison symbols are not supported in a widget chart";const o=new Set(O().map(e=>e.id)),n=(t.chart.indicators??[]).find(e=>!o.has(e.indicatorId));return void 0===n?"":`unavailable study ${n.indicatorId}`}(t);if(""!==o)return{applied:!1,reason:o};const[n]=t.panes,i=hi(e,n,!0);return i.applied?{applied:!0}:{applied:!1,reason:i.reason??"the chart state could not be restored"}},subscribe(t){const o=[...si.map(o=>e.on(o,t)),...li.map(o=>e.chart.on(o,t)),e.history.subscribe(t)];return()=>{for(const e of o)e()}},suspended:()=>v(e.chart)}}function gi(e){return!1===e?.removable||!1===e?.listed}const mi=new WeakMap;function fi(e,t){void 0===t?mi.delete(e):mi.set(e,t)}const bi=(e,t,o,n)=>({version:void 0!==o&&o>0?2:1,indicators:e??[],panes:t,...void 0===o?{}:{primaryPane:o},...n});function vi(e,t){const o=t.panes??[];return{preserveScaleFormats:(e.restoreOptions?.preserveScaleFormats??[]).filter(({paneIndex:e,scaleId:t})=>void 0!==o[e]&&("right"===t||Object.prototype.hasOwnProperty.call(o[e].scales??{},t)))}}function wi(e,t,o,n,i){const{chart:a}=e;if(void 0===t.planIndicatorTemplateState)throw new Error("This template store cannot apply templates");if(v(a))throw new Error("Stop the replay before applying a template");const r=a.getState(),s=t.planIndicatorTemplateState(a,o,n);if("append"===n&&s.indicators.length===(r.indicators??[]).length)return!1;const l={drawings:r.drawings,alerts:r.alerts},c=void 0!==r.sourceAbove&&s.indicators.some(e=>e.instanceId===r.sourceAbove)?{sourceAbove:r.sourceAbove}:{};let d=!1;const u=a.on("state:restore:start",()=>{d=!0});try{const e=a.restoreState(bi(s.indicators,s.panes??("append"===n?r.panes:r.panes?.slice(0,1)),s.primaryPane,{...l,...c}),s.restoreOptions??{});if(!e.applied)throw new Error(e.reason??"The template could not be applied");if(e.indicators!==s.indicators.length)throw new Error("The chart did not restore every study")}catch(e){throw d&&a.restoreState(bi(r.indicators,r.panes,r.primaryPane,{...l,...void 0===r.sourceAbove?{}:{sourceAbove:r.sourceAbove},viewport:r.viewport,barSpacing:r.barSpacing}),vi(s,a.getState())),e}finally{u()}const h=a.getState(),p=e=>{const t=a.getState();return a.restoreState(bi(e.indicators,e.panes,e.primaryPane,{...void 0===e.sourceAbove?{}:{sourceAbove:e.sourceAbove},drawings:t.drawings,alerts:t.alerts}),vi(s,t)).applied};return e.history?.push({label:i,undo:()=>p(r),redo:()=>p(h)}),!0}function yi(e,t,o){let n;try{n=t.captureIndicatorTemplate?.(e.chart)??(e.chart.getState().indicators??[]).filter(e=>!gi(e.policy))}catch(e){return Promise.reject(e)}return 0===(Array.isArray(n)?n:n.indicators).length?Promise.reject(new Error("The chart has no studies of yours to save")):t.createTemplate(o,n)}const _i=e=>(t,o,n={})=>Pe(e,`schema.ui.layouts.${t}`,n,o);function xi(e,t){const o=_i(e);return null===t.layoutId?o("unsaved","This chart is not saved as a layout"):t.conflict?o("conflict","Changed in another window"):t.catalog?.autosave?"saving"===t.autosave?o("saving","Saving"):"failed"===t.autosave?o("failed","Could not save"):"pending"===t.autosave?t.suspended?o("suspended","Autosave waits for the replay to end"):o("pending","Waiting to save"):o("saved","Saved"):t.dirty?o("dirty","Unsaved changes"):o("saved","Saved")}function ki(e,t,o){let n=!1;return e.subscribe(e=>{const i="failed"===e.autosave&&!e.conflict;n||!i&&!e.conflict||o(i?t("autosaveStopped","Autosave stopped: the layout could not be saved"):t("conflictStatus","The layout was changed in another window")),n=i||e.conflict})}function Ci(e){return null!==e.layoutId&&(e.conflict||"failed"===e.autosave||e.dirty&&!e.catalog?.autosave)}const Si=ut(()=>import("./openalgo-charts.widget.layouts-menu-B7XYKPAW.mjs"));function Ai(e,t,o){return Si.load().then(n=>{if(e.chart.isDestroyed)throw new Error("The widget was destroyed before its Layouts menu opened");return n.mountLayoutsMenu(e,t,o)})}function Oi(e,t,o,n,i){n.handle?.isOpen()?n.handle.el.focus():ht(Si,i=>{n.handle=i.mountLayoutsMenu(e,t,o)},t=>e.toast(pt(e,_i(e)("title","Layouts"),t),"error"),i,{slot:n,doc:e.document,from:o})}function Li(e,t,o){try{const n=t();if(null===n)return!1;const i=n.toDataURL("image/png"),a=e.createElement("a");return a.href=i,a.download=o,(e.body??e.documentElement).appendChild(a),a.click(),a.remove(),!0}catch{return!1}}function Ei(){const e=globalThis;return void 0!==e.navigator?.clipboard?.write&&void 0!==e.ClipboardItem}function $i(e,t,o,n){const i=t=>n(Pe(e,"Copy failed: {error}",{error:Me(e,t)}),"error");try{t.toBlob(t=>{if(null===t)return void n(Pe(e,"The canvas produced no image"),"error");const a=globalThis.ClipboardItem;globalThis.navigator.clipboard.write([new a({"image/png":t})]).then(()=>n(o,"info"),i)},"image/png")}catch(e){i(e)}}const Ti=ut(()=>import("./openalgo-charts.widget.chart-data-export-dialog-CX6h5-cp.mjs")),ji={candlestick:"Candles","hollow-candle":"Hollow candles",bar:"Bars","high-low":"High-low","volume-candle":"Volume candles",line:"Line","line-markers":"Line with markers",step:"Step line",area:"Area","hlc-area":"HLC area",baseline:"Baseline","point-figure":"Point and figure",kagi:"Kagi"};function Pi(e){const t=ji[e]??(b().includes(e)?E(e).name:void 0);return void 0!==t?t:e.replace(/[-_]+/g," ").replace(/^\w/,e=>e.toUpperCase())}function Mi(){const e=b();return[...f().filter(t=>{try{return!e.includes(t)&&L(t).isPriceSeries}catch{return!1}}),...e]}function Ii(e){const t=/^(\d*)\s*([smhdwSMHDW])$/.exec(e.trim());if(null===t)return e.toUpperCase();const o=""===t[1]||"1"===t[1]?"":t[1],n=t[2];return"m"===n?`${""===t[1]?"1":t[1]}m`:"s"===n?`${""===t[1]?"1":t[1]}s`:"h"===n||"H"===n?`${""===t[1]?"1":t[1]}h`:o+n.toUpperCase()}function Di(e,t={}){const o=e.brandingOptions();if(!o||"string"!=typeof o.href||!/^https?:\/\//i.test(o.href))return null;const n="string"==typeof o.label&&""!==o.label.trim()?o.label.trim():Pe(t,"Chart branding");return{href:o.href,label:n}}function zi(e,t,o){const n=e.document;t.classList.add("oac-topbar"),t.setAttribute("role","toolbar"),t.setAttribute("aria-label",Pe(e,"Chart toolbar"));const i=(e,t="")=>De(n,"button","oac-btn"+(t?" "+t:""),{type:"button","aria-label":e}),a=()=>De(n,"span","oac-sep",{role:"separator"}),r=(e,t)=>{e.classList.toggle("is-off",t),e.setAttribute("aria-disabled",String(t))},s=De(n,"div","oac-sym");s.appendChild(ze(n,oe("search"),"chrome"));const l=De(n,"input","oac-sym__input",{type:"text","aria-label":Pe(e,"Symbol"),placeholder:Pe(e,"Symbol"),autocomplete:"off",spellcheck:"false"});s.appendChild(l);const c=De(n,"span","oac-sym__ex");s.appendChild(c),t.appendChild(s),t.appendChild(a());let d=null;const u=(e,t)=>{d?.close();const n=e.trim().toUpperCase();""!==n?(o.onSymbol(n,t),l.blur()):j()};o.search&&(d=bn(e,l,{search:o.search,onSelect:u,context:()=>`${o.state().exchange}:${o.state().symbol}:${o.state().interval}`})),l.addEventListener("keydown",e=>{const t=e;"Enter"===t.key?(t.preventDefault(),(null===d||d.canCommitRaw())&&u(l.value)):"Escape"===t.key&&(j(),l.blur())}),l.addEventListener("focus",()=>{l.select()}),l.addEventListener("blur",()=>{j()});const h=De(n,"div","oac-pills",{role:"radiogroup","aria-label":Pe(e,"Interval")}),p=new Map;for(const t of o.intervals){const i=De(n,"button",void 0,{type:"button",role:"radio","aria-pressed":"false","aria-label":Pe(e,"Interval {code}",{code:Ii(t)})});i.textContent=Ii(t),i.dataset.interval=t,i.addEventListener("click",()=>o.onInterval(t)),h.appendChild(i),p.set(t,i)}t.appendChild(h),t.appendChild(a());const g=i(Pe(e,"Chart type"),"oac-topbar__type"),m=ze(n,"","chrome"),f=De(n,"span");g.append(m,f),g.appendChild((()=>{const e=De(n,"span","oac-chev",{"aria-hidden":"true"});return e.innerHTML=oe("chevron-down"),e})()),g.setAttribute("aria-haspopup","menu"),g.addEventListener("click",()=>{const t=o.state().chartType,n=b()[0];Ro(e,g,Mi().flatMap(i=>[...i===n?[Pe(e,"schema.chartType.group.transforms",{},"Transforms")]:[],{label:Pe(e,`schema.chartType.${i}`,{},Pi(i)),icon:`chart-${i}`,on:i===t,onSelect:()=>o.onChartType(i)}]),{ariaLabel:Pe(e,"Chart type")})}),t.appendChild(g);let v=null;if(!1!==o.indicators){v=i(Pe(e,"Indicators")),v.appendChild(ze(n,oe("plus"),"chrome"));const a=De(n,"span");a.textContent=Pe(e,"Indicators"),v.appendChild(a),v.addEventListener("click",()=>{null!==v&&v.classList.contains("is-off")||null!==v&&o.onIndicators(v)}),t.appendChild(v)}t.appendChild(De(n,"span","oac-topbar__spacer"));const w=De(n,"span","oac-topbar__branding-slot");let y=null;t.appendChild(w);let _=null;const x=o.layouts;if(void 0!==x&&o.onLayouts){const a=Pe(e,"schema.ui.layouts.title",{},"Layouts"),r=()=>{const e=x.state();return null===e.layoutId?null:e.catalog?.workspaces.find(t=>t.id===e.layoutId)?.name??null},s=i(a,"oac-topbar__layouts");s.setAttribute("aria-haspopup","dialog"),s.appendChild(ze(n,oe("layout"),"chrome"));const l=De(n,"span","oac-topbar__layouts-name");s.appendChild(l),e.tips.attach(s,()=>{const t=r(),o=x.state(),n=null===t?a:`${a}: ${t}`,i=xi(e,o);return{title:n,label:Ci(o)?`${n}, ${i}`:void 0,sub:i,side:"bottom"}});const c=()=>{l.textContent=r()??a,s.dataset.attention=String(Ci(x.state())),e.tips.refreshLabel(s)};_=x.subscribe(c),c(),s.addEventListener("click",()=>{o.onLayouts?.(s)}),t.appendChild(s),t.classList.add("has-layouts")}const k=o.onGoTo?i(Pe(e,"Go to"),"oac-topbar__goto"):null;if(null!==k&&(k.textContent=Pe(e,"Go to"),k.setAttribute("aria-haspopup","dialog"),e.tips.attach(k,()=>({title:Pe(e,"Go to"),sub:null===wn(o.state().interval)?Pe(e,"Go to needs a time-based interval"):void 0,side:"bottom"})),k.addEventListener("click",()=>{k.classList.contains("is-off")||o.onGoTo?.(k)}),t.appendChild(k)),o.onObjects){const n=i(Pe(e,"Objects"),"oac-topbar__objects");n.textContent=Pe(e,"Objects"),n.setAttribute("aria-haspopup","dialog"),n.addEventListener("click",()=>{o.onObjects?.(n)}),t.appendChild(n)}if(o.onDataWindow){const n=i(Pe(e,"schema.ui.dataWindow",{},"Data"),"oac-topbar__data");n.textContent=Pe(e,"schema.ui.dataWindow",{},"Data"),n.addEventListener("click",()=>{o.onDataWindow?.(n)}),t.appendChild(n)}for(const[n,a,r]of[["watchlist","Watchlist",o.onWatchlist],["news","News",o.onNews]]){if(!r)continue;const o=i(Pe(e,`schema.ui.dock.${n}`,{},a),`oac-topbar__${n}`);o.textContent=Pe(e,`schema.ui.dock.${n}`,{},a),o.addEventListener("click",()=>{r(o)}),t.appendChild(o)}if(o.onAlerts){const n=i(Pe(e,"Alerts"),"oac-topbar__alerts");n.textContent=Pe(e,"Alerts"),n.setAttribute("aria-haspopup","dialog"),n.addEventListener("click",()=>{o.onAlerts?.(n)}),t.appendChild(n)}const C=i(Pe(e,"Capture chart"),"oac-btn--icon");C.appendChild(ze(n,oe("camera"),"chrome")),C.setAttribute("aria-haspopup","menu"),e.tips.attach(C,{title:Pe(e,"Capture"),sub:Pe(e,"PNG, SVG, CSV or the clipboard"),side:"bottom"});let S=null;const A={waiting:null},O=i=>{const a={...o.state()},r=e.chart,s=r.primarySeries(),l=r.getDataContext(),c=()=>!r.isDestroyed&&!1!==o.dataAvailable?.()&&r.primaryBars().length>0,d=()=>{const t=o.state(),n=e.chart.getDataContext();if(e.chart!==r||r.primarySeries()!==s||t.symbol!==a.symbol||t.exchange!==a.exchange||t.interval!==a.interval||t.chartType!==a.chartType||n!==l)throw new Error(Pe(e,"The chart changed; reopen Capture for its current source"));if(!c())throw new Error(Pe(e,"Wait for this chart to finish loading its data"))},u=Ei();Ro(e,i,[{label:Pe(e,"Download PNG"),onSelect:()=>{const t=Li(n,()=>e.chart.takeScreenshot(),Wo(a.symbol,a.interval)+".png");e.status(Pe(e,t?"Saved a PNG of the chart":"This runtime cannot save files"),t?"info":"error")}},{label:Pe(e,"Download SVG"),sub:Pe(e,"text stays text"),onSelect:()=>{const t=Fo(n,Wo(a.symbol,a.interval)+".svg",e.chart.exportSVG(),"image/svg+xml");e.status(Pe(e,t?"Saved an SVG of the chart":"This runtime cannot save files"),t?"info":"error")}},{label:Pe(e,"Copy image"),sub:Pe(e,u?"paste it anywhere":"needs https or localhost"),disabled:!u,onSelect:()=>{$i(e,e.chart.takeScreenshot(),Pe(e,"Chart copied"),(t,o)=>e.status(t,o))}},{label:Pe(e,"Download chart data (CSV)"),disabled:!c(),onSelect:()=>{ht(Ti,t=>{try{d(),S?.close(),S=t.openChartDataExportDialog(e,i,t=>{d();const o=$(r,t);if(d(),!Fo(n,Wo(a.symbol,a.interval)+".csv",o,"text/csv;charset=utf-8"))throw new Error(Pe(e,"This runtime cannot save files"));e.status(Pe(e,"Chart data download started"))})}catch(t){(t=>{e.status(Pe(e,"Data export failed: {error}",{error:Me(e,t)}),"error")})(t)}},t=>e.status(pt(e,Pe(e,"Download chart data (CSV)"),t),"error"),()=>t.isConnected,{slot:A,doc:n,from:i})}},...o.captureRows?.()??[]],{ariaLabel:Pe(e,"Capture")})};C.addEventListener("click",()=>O(C)),t.appendChild(C);const L=i(Pe(e,"Chart settings"),"oac-btn--icon");L.appendChild(ze(n,oe("settings"),"chrome")),e.tips.attach(L,()=>({title:Pe(e,"Chart settings"),sub:o.settingsAvailable()?void 0:Pe(e,"The settings dialog is not in this build"),side:"bottom"})),L.addEventListener("click",()=>{L.classList.contains("is-off")||o.onSettings(L)}),t.appendChild(L);const E=i(Pe(e,"Theme"),"oac-btn--icon oac-topbar__theme"),T=ze(n,"","chrome");E.appendChild(T),e.tips.attach(E,()=>({title:"dark"===o.state().theme?Pe(e,"Switch to the light theme"):Pe(e,"Switch to the dark theme"),side:"bottom"})),E.addEventListener("click",()=>o.onTheme("dark"===o.state().theme?"light":"dark")),t.appendChild(E),null!==v&&e.tips.attach(v,()=>({title:Pe(e,"Indicators"),sub:o.indicatorsAvailable()?Pe(e,"Add a study to the chart"):Pe(e,"The indicator picker is not in this build"),side:"bottom"}));const j=()=>{const t=o.state();n.activeElement!==l&&(l.value=t.symbol),c.textContent=t.exchange,c.hidden=""===t.exchange;for(const[e,o]of p){const n=e===t.interval;o.setAttribute("aria-pressed",String(n)),o.setAttribute("aria-checked",String(n))}m.dataset.type!==t.chartType&&(m.dataset.type=t.chartType,m.hidden=void 0===me(t.chartType),m.innerHTML=m.hidden?"":oe(`chart-${t.chartType}`)),f.textContent=Pe(e,`schema.chartType.${t.chartType}`,{},Pi(t.chartType)),r(L,!o.settingsAvailable()),null!==v&&r(v,!o.indicatorsAvailable()),null!==k&&r(k,null===wn(t.interval)),E.dataset.theme!==t.theme&&(E.dataset.theme=t.theme,T.innerHTML=oe("dark"===t.theme?"sun":"moon")),e.tips.refreshLabel(E),e.tips.refreshLabel(L),null!==v&&e.tips.refreshLabel(v);const i=Di(e.chart,e);null===i?(y?.remove(),y=null):(null===y&&(y=De(n,"a","oac-topbar__branding",{target:"_blank",rel:"noopener noreferrer"}),w.appendChild(y)),y.setAttribute("href",i.href),y.textContent=i.label,y.setAttribute("aria-label",i.label))},P=e.chart.on("branding:changed",j);return j(),{el:t,openCapture:O,refresh:j,focusSymbol:()=>{l.focus()},destroy:()=>{S?.close(),_?.(),P(),d?.destroy(),t.textContent=""}}}const Ni={info:4e3,success:3500,error:0},Ri=5,Fi=160;function Wi(e,t=e.ownerDocument,o={}){e.classList.add("oac-toasts"),e.setAttribute("role","status"),e.setAttribute("aria-live","polite");const n=new Set;return{toast:(i,a="info",r={})=>{const s=a in Ni?a:"info",l=t.createElement("div");l.className="oac-toast oac-toast--"+s;const c=t.createElement("span");c.className="oac-toast__msg",c.textContent=i;const d=t.createElement("button");d.type="button",d.className="oac-toast__x",d.setAttribute("aria-label",Pe(o,"Dismiss")),d.innerHTML=oe("close"),l.appendChild(c),l.appendChild(d);const u=void 0!==r.ms?r.ms:Ni[s];let h=0,p=!1;const g={node:l,dismiss:()=>{p||(p=!0,0!==h&&clearTimeout(h),n.delete(g),l.classList.add("is-out"),setTimeout(()=>l.remove(),160))}},m=()=>{u>0&&(h=setTimeout(g.dismiss,u))};for(d.addEventListener("click",g.dismiss),l.addEventListener("pointerenter",()=>{0!==h&&clearTimeout(h),h=0}),l.addEventListener("pointerleave",m),e.appendChild(l),n.add(g);n.size>5;){const e=n.values().next().value;n.delete(e),e.node.remove()}return m(),g},clear:()=>{for(const e of Array.from(n))e.dismiss()},count:()=>n.size,destroy:()=>{for(const e of Array.from(n))e.node.remove();n.clear(),e.remove()}}}const Bi=e=>{const t=e/255;return t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)};const qi="--oac-",Ui=e=>e<0?0:e>1?1:e;function Hi(e){const t=e.trim(),o=/^#([0-9a-f]{3,8})$/i.exec(t);if(null!==o){const e=o[1];if(3===e.length||4===e.length){return Hi("#"+e.split("").map(e=>e+e).join(""))}if(6!==e.length&&8!==e.length)return null;return{r:parseInt(e.slice(0,2),16),g:parseInt(e.slice(2,4),16),b:parseInt(e.slice(4,6),16),a:8===e.length?parseInt(e.slice(6,8),16)/255:1}}const n=/^rgba?\(\s*([\d.]+)(?:\s*,\s*|\s+)([\d.]+)(?:\s*,\s*|\s+)([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/i.exec(t);if(null!==n){let e=1;return void 0!==n[4]&&(e=n[4].endsWith("%")?Number(n[4].slice(0,-1))/100:Number(n[4])),{r:Number(n[1]),g:Number(n[2]),b:Number(n[3]),a:Ui(e)}}return null}const Ki=e=>Math.round(Math.max(0,Math.min(255,e))).toString(16).padStart(2,"0");function Vi(e){return e.a>=1?`#${Ki(e.r)}${Ki(e.g)}${Ki(e.b)}`:`rgba(${Math.round(e.r)},${Math.round(e.g)},${Math.round(e.b)},${Math.round(1e3*e.a)/1e3})`}function Gi(e){const t=Hi(e);return null===t?.5:function(e){return.2126*Bi(e.r)+.7152*Bi(e.g)+.0722*Bi(e.b)}(t)}function Ji(e,t){const o=Gi(e),n=Gi(t);return(Math.max(o,n)+.05)/(Math.min(o,n)+.05)}const Zi=4.5;function Yi(e,t,o,n=4.5){const i=e=>t.every(t=>Ji(e,t)>=n);if(i(e))return e;if(!i(o))return o;let a=0,r=1;for(let t=0;t<20;t++){const t=(a+r)/2;i(Xi(e,o,t))?r=t:a=t}for(let t=r;t<=1;t+=1/256){const n=Xi(e,o,t);if(i(n))return n}return o}function Qi(e){return Gi(e.background)<.35?"dark":"light"}function Xi(e,t,o){const n=Hi(e),i=Hi(t);if(null===n||null===i)return e;const a=Ui(o);return Vi({r:n.r+(i.r-n.r)*a,g:n.g+(i.g-n.g)*a,b:n.b+(i.b-n.b)*a,a:n.a+(i.a-n.a)*a})}function ea(e,t){const o=Hi(e);return null===o?e:Vi({...o,a:Ui(t)})}const ta='ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',oa="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",na=42,ia=40,aa=24;function ra(e,t=Qi(e)){const o="dark"===t,n=e.background,i=o?"#ffffff":"#0c1120",a=e=>Xi(n,i,e),r=e.lineColor,s=Xi(e.axisText,i,o?.55:.6),l=a(o?.035:.02),c=a(o?.02:.045),d=a(o?.07:.06),u=a(o?.11:.1),h=[n,l,c,d],p=(e,t=h)=>Yi(e,t,i),g={bg:n,panel:l,"panel-2":c,elev:d,"elev-2":u,"elev-3":a(o?.18:.16),bd:e.axisLine,"bd-soft":e.paneSeparator,"bd-hover":Xi(e.axisLine,i,.25),tx:s,"tx-strong":Xi(s,i,.5),mut:p(e.axisText,[...h,u]),faint:p(Xi(e.axisText,n,.4)),acc:r,"acc-2":Xi(r,i,o?.2:.1),"on-bg":ea(r,.16),"on-bd":Xi(r,n,.45),ring:r,"ring-soft":ea(r,.2),buy:e.upColor,sell:e.downColor,up:p(e.upColor),down:p(e.downColor),amber:p(o?"#e6b53c":"#b8860b"),danger:p(Xi(e.downColor,i,o?.3:.1),[...h,u]),scrim:o?"rgba(6,8,12,0.55)":"rgba(24,30,40,0.38)",shadow:o?"0 14px 40px rgba(0,0,0,0.55)":"0 14px 40px rgba(24,32,48,0.16)","sb-thumb":a(o?.16:.2),"sb-thumb-hover":a(o?.24:.3),font:ta,mono:oa,fs:"12.5px",radius:"7px","rail-w":"42px","topbar-h":"40px","status-h":"24px","ctl-h":"28px"},m={};for(const[e,t]of Object.entries(g))m[qi+e]=t;return m}function sa(e,t){for(const[o,n]of Object.entries(t))e.style.setProperty(o,n)}const la=e=>`var(${qi}${e})`,ca="oac-widget-css",da=`\n.oac-widget { position: relative; display: grid; grid-template-rows: auto 1fr auto; width: 100%; height: 100%;\n min-height: 0; min-width: 0; background: ${la("bg")}; color: ${la("tx")}; font: ${la("fs")}/1.35 ${la("font")};\n -webkit-font-smoothing: antialiased; overflow: hidden; }\n.oac-widget, .oac-widget * { box-sizing: border-box; }\n.oac-widget.oac-alert-host { position: absolute; inset: 0; display: block; background: transparent; pointer-events: none; z-index: 40; }\n.oac-widget[data-theme="dark"] { color-scheme: dark; }\n.oac-widget[data-theme="light"] { color-scheme: light; }\n.oac-widget button, .oac-widget input, .oac-widget select, .oac-widget textarea { font: inherit; color: inherit; }\n.oac-widget button { cursor: pointer; }\n.oac-widget kbd { font: 11px/1 ${la("mono")}; font-variant-numeric: tabular-nums; }\n.oac-widget [hidden] { display: none !important; }\n.oac-widget .oac-row:has(> .oac-input-error:not([hidden])) { flex-wrap: wrap; }\n.oac-widget .oac-input-error { flex-basis: 100%; min-width: 0; color: ${la("danger")}; font-size: 11px; overflow-wrap: anywhere; }\n.oac-widget .oac-row__ctl:has([data-input-action]) { flex-wrap: wrap; }\n.oac-widget .oac-row__ctl [data-input-action] { font-size: 11px; padding: 3px 7px; }\n.oac-widget [aria-invalid="true"] { border-color: ${la("danger")}; }\n.oac-widget .oac-input-pick { position: absolute; top: 8px; left: 50%; transform: translateX(-50%);\n display: flex; align-items: center; gap: 8px; max-width: calc(100% - 16px); padding: 8px;\n color: ${la("tx")}; background: ${la("panel")}; border: 1px solid ${la("bd")}; border-radius: 6px; pointer-events: auto; }\n\n/* Scrollbars: a thumb one step lighter than its panel, and no visible track. */\n.oac-widget * { scrollbar-width: thin; scrollbar-color: ${la("sb-thumb")} transparent; }\n.oac-widget ::-webkit-scrollbar { width: 10px; height: 10px; }\n.oac-widget ::-webkit-scrollbar-track { background: transparent; }\n.oac-widget ::-webkit-scrollbar-thumb { background: ${la("sb-thumb")}; border: 2px solid transparent;\n background-clip: padding-box; border-radius: 999px; }\n.oac-widget ::-webkit-scrollbar-thumb:hover { background: ${la("sb-thumb-hover")}; background-clip: padding-box; }\n.oac-widget ::-webkit-scrollbar-corner { background: transparent; }\n\n/* Focus: one ring, keyboard only. Text fields glow on the border instead. */\n.oac-widget :focus-visible { outline: 2px solid ${la("ring")}; outline-offset: 2px; }\n.oac-widget :focus:not(:focus-visible) { outline: none; }\n.oac-widget input:not([type=checkbox]):not([type=color]):not([type=range]):focus-visible,\n.oac-widget select:focus-visible, .oac-widget textarea:focus-visible {\n outline: none; border-color: ${la("acc")}; box-shadow: 0 0 0 3px ${la("ring-soft")}; }\n.oac-widget .oac-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;\n overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }\n\n/* Form controls: nothing left to the browser on a themed panel. */\n.oac-widget input[type=checkbox] { appearance: none; -webkit-appearance: none; flex: none; margin: 0;\n width: 15px; height: 15px; border: 1px solid ${la("bd")}; border-radius: 4px; background: ${la("elev")};\n cursor: pointer; display: inline-grid; place-content: center; transition: background .12s, border-color .12s; }\n.oac-widget input[type=checkbox]:hover { border-color: ${la("bd-hover")}; }\n.oac-widget input[type=checkbox]:checked { background: ${la("acc")}; border-color: ${la("acc")}; }\n.oac-widget input[type=checkbox]:checked::after { content: ''; width: 4px; height: 8px; margin-top: -2px;\n border: solid ${la("bg")}; border-width: 0 2px 2px 0; transform: rotate(45deg); }\n.oac-widget input[type=checkbox]:disabled { opacity: .4; cursor: not-allowed; }\n.oac-widget select { appearance: none; -webkit-appearance: none; height: ${la("ctl-h")}; padding: 0 24px 0 8px;\n background: ${la("elev")}; border: 1px solid ${la("bd")}; border-radius: ${la("radius")}; cursor: pointer; }\n.oac-widget .oac-select { position: relative; display: inline-flex; }\n/* The chevron overlays the select rather than sitting beside it. selectBox\n wraps the glyph in an oac-chev span, and this rule used to name\n .oac-select > svg, which that markup has never had: the span stayed an\n ordinary flex item, so it took eleven pixels of the row and left the select\n eleven pixels short of every input beside it, with its arrow outside its own\n box. Sized here rather than left to .oac-chev, whose inline-grid is right\n where a chevron follows a word, as it does in the top bar. */\n.oac-widget .oac-select > .oac-chev { position: absolute; right: 7px; top: 50%; width: 11px; height: 11px;\n transform: translateY(-50%); pointer-events: none; display: block; color: ${la("mut")}; }\n.oac-widget select option, .oac-widget select optgroup { background: ${la("panel")}; color: ${la("tx")}; }\n.oac-widget input[type=color] { width: 26px; height: 26px; padding: 0; flex: none; cursor: pointer; appearance: none;\n -webkit-appearance: none; background-color: ${la("elev")}; border: 1px solid ${la("bd")}; border-radius: ${la("radius")}; }\n.oac-widget input[type=color]:hover { border-color: ${la("bd-hover")}; }\n.oac-widget input[type=color]::-webkit-color-swatch-wrapper { padding: 3px; }\n.oac-widget input[type=color]::-webkit-color-swatch { border: 1px solid rgba(0,0,0,.35); border-radius: 4px; }\n.oac-widget input[type=color]::-moz-color-swatch { border: 1px solid rgba(0,0,0,.35); border-radius: 4px; }\n.oac-widget .oac-swatch { width: 20px; height: 20px; border-radius: 5px; border: 1px solid rgba(0,0,0,.35); }\n.oac-widget input[type=number] { -moz-appearance: textfield; appearance: textfield; }\n.oac-widget input[type=number]::-webkit-inner-spin-button, .oac-widget input[type=number]::-webkit-outer-spin-button {\n -webkit-appearance: none; margin: 0; }\n.oac-widget input[type=text], .oac-widget input[type=number], .oac-widget input[type=search], .oac-widget textarea {\n height: ${la("ctl-h")}; padding: 0 8px; background: ${la("elev")}; border: 1px solid ${la("bd")}; border-radius: ${la("radius")};\n transition: border-color .15s, box-shadow .15s; }\n.oac-widget textarea { height: auto; padding: 6px 8px; }\n.oac-widget input::placeholder { color: ${la("faint")}; }\n.oac-widget input:hover, .oac-widget select:hover { border-color: ${la("bd-hover")}; }\n.oac-widget input[type=range] { appearance: none; -webkit-appearance: none; height: 22px; margin: 0;\n background: transparent; cursor: pointer; }\n.oac-widget input[type=range]::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: ${la("elev-3")}; }\n.oac-widget input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px;\n margin-top: -4.5px; border-radius: 50%; background: ${la("acc")}; border: 0; }\n.oac-widget input[type=range]::-moz-range-track { height: 3px; border-radius: 2px; background: ${la("elev-3")}; }\n.oac-widget input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: ${la("acc")}; border: 0; }\n\n/* Section heads and rows shared by every panel. */\n.oac-widget .oac-head { padding: 8px 10px 4px; color: ${la("faint")}; font-size: 10px; font-weight: 600;\n text-transform: uppercase; letter-spacing: .7px; }\n.oac-widget .oac-row { display: flex; align-items: center; gap: 8px; min-height: 26px; padding: 2px 0; }\n.oac-widget .oac-row > label { flex: 1 1 auto; min-width: 0; color: ${la("tx")}; }\n\n/* Help mark: a 13px ring after a label, muted until pointed at. It must not\n grow the row, so it sits on the label's own line box and never wraps away\n from the words it belongs to. */\n.oac-widget .oac-help { display: inline-flex; align-items: center; justify-content: center;\n width: 13px; height: 13px; margin-left: 5px; vertical-align: -2px; flex: none;\n border: 1px solid ${la("bd")}; border-radius: 50%; color: ${la("faint")};\n font-size: 9px; font-weight: 600; line-height: 1; cursor: help; user-select: none; }\n.oac-widget .oac-help:hover { color: ${la("tx")}; border-color: ${la("bd-hover")}; }\n/* A heading's rows as one named group, laid out as if the box were not there. */\n.oac-widget .oac-form__group { display: contents; }\n\n/* Buttons: flat, 28px tall, a tint when pressed or active. */\n.oac-widget .oac-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;\n height: ${la("ctl-h")}; padding: 0 9px; background: transparent; border: 1px solid transparent;\n border-radius: ${la("radius")}; color: ${la("tx")}; white-space: nowrap; transition: background .1s, border-color .1s, color .1s; }\n.oac-widget .oac-btn:hover { background: ${la("elev")}; border-color: ${la("bd-soft")}; }\n.oac-widget .oac-btn.is-on, .oac-widget .oac-btn[aria-pressed="true"], .oac-widget .oac-btn[aria-expanded="true"] {\n background: ${la("on-bg")}; border-color: ${la("on-bd")}; color: ${la("acc-2")}; }\n.oac-widget .oac-btn.is-off, .oac-widget .oac-btn[aria-disabled="true"], .oac-widget .oac-btn:disabled {\n color: ${la("faint")}; cursor: default; }\n.oac-widget .oac-btn.is-off:hover, .oac-widget .oac-btn[aria-disabled="true"]:hover, .oac-widget .oac-btn:disabled:hover {\n background: transparent; border-color: transparent; }\n.oac-widget .oac-btn--icon { width: ${la("ctl-h")}; padding: 0; }\n.oac-widget .oac-btn--primary { background: ${la("acc")}; color: ${la("bg")}; border-color: transparent; font-weight: 600; }\n.oac-widget .oac-btn--primary:hover { background: ${la("acc-2")}; border-color: transparent; }\n.oac-widget .oac-btn--danger:not(.is-off):hover { color: ${la("danger")}; }\n.oac-widget .oac-btn > b { font-weight: 700; letter-spacing: .3px; }\n.oac-widget .oac-glyph { display: inline-grid; place-items: center; line-height: 0; flex: none; }\n.oac-widget .oac-glyph > svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }\n.oac-widget .oac-glyph--tool > svg { width: 24px; height: 24px; stroke-width: 2; }\n.oac-widget .oac-glyph--chrome > svg { width: 16px; height: 16px; stroke-width: 2; }\n.oac-widget .oac-glyph--text { display: inline-grid; place-items: center; width: 24px; height: 24px;\n font-size: 12px; font-weight: 600; }\n.oac-widget .oac-chev { display: inline-grid; place-items: center; line-height: 0; color: ${la("mut")}; }\n.oac-widget .oac-chev > svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 1.5;\n stroke-linecap: round; stroke-linejoin: round; }\n.oac-widget .oac-sep { width: 1px; height: 20px; background: ${la("bd-soft")}; margin: 0 2px; flex: none; }\n\n/* Top bar */\n.oac-widget .oac-topbar { grid-row: 1; display: flex; align-items: center; gap: 4px; min-height: ${la("topbar-h")};\n padding: 5px 8px; background: ${la("panel")}; border-bottom: 1px solid ${la("bd-soft")}; flex-wrap: wrap; }\n.oac-widget .oac-topbar__spacer { flex: 1 1 auto; }\n.oac-widget .oac-topbar__branding-slot { display: inline-flex; align-items: center; }\n.oac-widget .oac-topbar__branding { color: ${la("mut")}; font-size: 11px; text-decoration: none; white-space: nowrap; }\n.oac-widget .oac-topbar__branding:hover { color: ${la("tx")}; text-decoration: underline; }\n.oac-widget .oac-sym { position: relative; display: inline-flex; align-items: center; }\n.oac-widget .oac-sym > input { width: 132px; height: ${la("ctl-h")}; padding: 0 8px 0 28px; font-weight: 600;\n letter-spacing: .3px; text-transform: uppercase; }\n.oac-widget .oac-sym > .oac-glyph { position: absolute; left: 8px; color: ${la("mut")}; pointer-events: none; }\n.oac-widget .oac-sym__ex { margin-left: 6px; color: ${la("faint")}; font-size: 11px; font-weight: 600; letter-spacing: .5px; }\n.oac-widget .oac-pills { display: inline-flex; background: ${la("elev")}; border: 1px solid ${la("bd-soft")};\n border-radius: 7px; padding: 2px; }\n.oac-widget .oac-pills > button { height: 22px; padding: 0 8px; background: transparent; border: 0; border-radius: 5px;\n color: ${la("mut")}; font-weight: 600; font-size: 11.5px; letter-spacing: .2px; }\n.oac-widget .oac-pills > button:hover { color: ${la("tx")}; }\n.oac-widget .oac-pills > button[aria-pressed="true"] { background: ${la("elev-2")}; color: ${la("acc-2")}; }\n.oac-widget .oac-pills > button:focus-visible { outline-offset: -1px; }\n\n/* Popup menu (chart types, screenshot, symbol results) */\n.oac-widget .oac-menu { min-width: 190px; max-width: 320px; max-height: 60vh; overflow-y: auto; padding: 5px;\n background: ${la("panel")}; border: 1px solid ${la("bd")}; border-radius: 9px; box-shadow: ${la("shadow")}; outline: none; }\n.oac-widget .oac-menu__find { padding: 3px 3px 6px; }\n.oac-widget .oac-menu__find > input { width: 100%; }\n.oac-widget .oac-menu__row { display: flex; align-items: center; gap: 9px; width: 100%; padding: 6px 8px;\n background: transparent; border: 0; border-radius: 6px; color: ${la("tx")}; text-align: left; white-space: nowrap; }\n.oac-widget .oac-menu__row:hover, .oac-widget .oac-menu__row:focus-visible, .oac-widget .oac-menu__row.is-active {\n background: ${la("elev-2")}; outline: none; }\n.oac-widget .oac-menu__row[aria-checked="true"] { color: ${la("acc-2")}; }\n.oac-widget .oac-menu__row[aria-checked="true"]::before { content: ''; width: 6px; height: 6px; border-radius: 50%;\n background: ${la("acc-2")}; margin: 0 2px 0 -2px; flex: none; }\n.oac-widget .oac-menu__row[aria-checked="false"]::before { content: ''; width: 6px; height: 6px; margin: 0 2px 0 -2px; flex: none; }\n.oac-widget .oac-menu__row[aria-disabled="true"] { color: ${la("faint")}; cursor: default; background: transparent; }\n.oac-widget .oac-menu__row.is-danger:hover { color: ${la("danger")}; }\n.oac-widget .oac-menu__label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }\n.oac-widget .oac-menu__sub { color: ${la("faint")}; font-size: 11px; }\n.oac-widget .oac-menu__key { margin-left: auto; color: ${la("faint")}; }\n.oac-widget .oac-menu__empty { padding: 8px 10px; color: ${la("faint")}; }\n/* A hovered row is elev-2, where faint text no longer reads: its hints brighten with it. */\n.oac-widget .oac-menu__row:is(:hover, :focus-visible, .is-active) :is(.oac-menu__sub, .oac-menu__key),\n.oac-widget .oac-fly__row:is(:hover, :focus-visible) .oac-fly__chord { color: ${la("mut")}; }\n\n/* Stage: the rail on the left, the chart filling the rest. */\n.oac-widget .oac-stage { grid-row: 2; position: relative; min-height: 0; min-width: 0; display: flex; }\n.oac-widget .oac-chart { position: relative; flex: 1 1 auto; min-width: 0; min-height: 0;\n cursor: var(--oac-tool-cursor, crosshair); }\n.oac-widget .oac-chart:focus-visible { outline-offset: -2px; }\n\n/* Data state stays compact inside a chart, including narrow embedded widgets. */\n.oac-widget .oac-data-status { position: absolute; top: 8px; right: 8px; z-index: 30;\n max-width: calc(100% - 16px); width: max-content; max-height: 45%; overflow-y: auto;\n display: flex; flex-direction: column; gap: 4px; pointer-events: none; font-size: 12px; }\n.oac-widget .oac-data-status__row { display: flex; align-items: center; gap: 8px;\n max-width: 320px; padding: 4px 6px 4px 10px; background: ${la("panel")}; color: ${la("tx")};\n border: 1px solid ${la("bd")}; border-radius: 6px; pointer-events: auto; }\n.oac-widget .oac-data-status__text { min-width: 0; overflow-wrap: anywhere; }\n.oac-widget .oac-data-status__row > button { flex: none; color: ${la("acc-2")}; }\n\n/* Rail */\n.oac-widget .oac-rail { flex: none; width: ${la("rail-w")}; display: flex; flex-direction: column; align-items: center;\n gap: 2px; padding: 6px 0 0; background: ${la("panel-2")}; border-right: 1px solid ${la("bd-soft")};\n overflow-y: auto; overflow-x: hidden; scrollbar-width: none; }\n.oac-widget .oac-rail::-webkit-scrollbar { width: 0; height: 0; }\n.oac-widget .oac-rail__btn { position: relative; width: 32px; height: 32px; padding: 0; display: grid; place-items: center;\n flex: none; background: transparent; border: 1px solid transparent; border-radius: 7px; color: ${la("mut")};\n transition: background .1s, color .1s, border-color .1s; }\n.oac-widget .oac-rail__btn:hover { background: ${la("elev")}; color: ${la("tx")}; }\n.oac-widget .oac-rail__btn:focus-visible { outline: 2px solid ${la("acc-2")}; outline-offset: -2px; }\n.oac-widget .oac-rail__btn.is-on { background: ${la("on-bg")}; border-color: ${la("on-bd")}; color: ${la("acc-2")}; }\n.oac-widget .oac-rail__btn.is-weak { color: ${la("acc-2")}; }\n.oac-widget .oac-rail__btn.is-off { color: ${la("faint")}; cursor: default; }\n.oac-widget .oac-rail__btn.is-off:hover { background: transparent; color: ${la("faint")}; }\n.oac-widget .oac-rail__btn--danger:not(.is-off):hover { color: ${la("danger")}; }\n.oac-widget .oac-rail__chev { position: absolute; right: 0; bottom: 0; width: 13px; height: 13px; display: grid;\n place-items: center; border-radius: 5px 0 6px 0; color: ${la("mut")}; opacity: 0; transition: opacity .1s, background .1s; }\n.oac-widget .oac-rail__chev > svg { width: 9px; height: 9px; fill: none; stroke: currentColor; stroke-width: 2.2;\n stroke-linecap: round; stroke-linejoin: round; }\n.oac-widget .oac-rail__btn:hover .oac-rail__chev, .oac-widget .oac-rail__btn:focus-visible .oac-rail__chev,\n.oac-widget .oac-rail__btn[aria-expanded="true"] .oac-rail__chev { opacity: 1; }\n.oac-widget .oac-rail__chev:hover { background: ${la("elev-2")}; color: ${la("tx")}; }\n.oac-widget .oac-rail__btn.is-held::after, .oac-widget .oac-rail__btn[data-mode="weak"]::after,\n.oac-widget .oac-rail__btn[data-mode="strong"]::after { content: ''; position: absolute; top: 3px; right: 3px;\n width: 5px; height: 5px; border-radius: 50%; }\n.oac-widget .oac-rail__btn.is-held::after, .oac-widget .oac-rail__btn[data-mode="strong"]::after { background: ${la("acc-2")}; }\n.oac-widget .oac-rail__btn[data-mode="weak"]::after { border: 1.5px solid ${la("acc-2")}; width: 4px; height: 4px; }\n.oac-widget .oac-rail__sep { width: 22px; height: 1px; background: ${la("bd-soft")}; margin: 4px 0; flex: none; }\n.oac-widget .oac-rail__favs { display: contents; }\n.oac-widget .oac-rail__ctl { margin-top: auto; position: sticky; bottom: 0; display: flex; flex-direction: column;\n align-items: center; gap: 2px; width: 100%; padding: 4px 0 6px; background: ${la("panel-2")};\n border-top: 1px solid ${la("bd-soft")}; flex: none; }\n.oac-widget .oac-rail__ctl .oac-rail__sep { margin: 3px 0; }\n\n/* Rail flyout: a group's tools, with a pin star and the chord on each row. */\n.oac-widget .oac-fly { min-width: 244px; max-width: 320px; max-height: calc(100% - 16px); overflow-y: auto; padding: 6px;\n background: ${la("panel")}; border: 1px solid ${la("bd")}; border-radius: 10px; box-shadow: ${la("shadow")}; outline: none; }\n.oac-widget .oac-fly__row { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 8px; border-radius: 7px;\n color: ${la("tx")}; font-size: 13px; cursor: pointer; outline: none; user-select: none; }\n.oac-widget .oac-fly__row:hover, .oac-widget .oac-fly__row:focus-visible { background: ${la("elev-2")}; }\n.oac-widget .oac-fly__row[aria-checked="true"] { background: ${la("on-bg")}; color: ${la("acc-2")}; }\n.oac-widget .oac-fly__name { flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.oac-widget .oac-fly__chord { min-width: 40px; text-align: right; color: ${la("faint")}; }\n.oac-widget .oac-fly__star { width: 22px; height: 22px; display: grid; place-items: center; padding: 0; border: 0;\n border-radius: 5px; background: transparent; color: ${la("faint")}; opacity: 0; transition: opacity .1s, color .1s; }\n.oac-widget .oac-fly__row:hover .oac-fly__star, .oac-widget .oac-fly__row:focus-within .oac-fly__star,\n.oac-widget .oac-fly__star[aria-pressed="true"] { opacity: 1; }\n.oac-widget .oac-fly__star:hover { background: ${la("elev")}; color: ${la("tx")}; }\n.oac-widget .oac-fly__star:focus-visible { outline: 2px solid ${la("acc-2")}; outline-offset: -1px; opacity: 1; }\n.oac-widget .oac-fly__star[aria-pressed="true"] { color: ${la("amber")}; }\n.oac-widget .oac-fly__star > svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.5;\n stroke-linecap: round; stroke-linejoin: round; }\n.oac-widget .oac-fly__star[aria-pressed="false"] > svg { fill: none; }\n\n/* Tooltip */\n.oac-widget .oac-tip-spot { position: absolute; width: 1px; height: 1px; pointer-events: none; }\n.oac-widget .oac-tip { position: absolute; z-index: 200; left: 0; top: 0; max-width: 260px; pointer-events: none;\n padding: 5px 9px; border-radius: 6px; background: ${la("elev-2")}; color: ${la("tx")}; border: 1px solid ${la("bd")};\n box-shadow: ${la("shadow")}; font-size: 12px; line-height: 1.4; opacity: 0; transition: opacity .09s ease; }\n.oac-widget .oac-tip.is-on { opacity: 1; }\n.oac-widget .oac-tip__chord { margin-left: 10px; color: ${la("mut")}; }\n/* The tip sits on elev-2, a step above the surfaces faint text is measured on. */\n.oac-widget .oac-tip__sub { display: block; margin-top: 2px; color: ${la("mut")}; font-size: 11px; }\n\n/* Status line */\n.oac-widget .oac-statusline { grid-row: 3; display: flex; align-items: center; gap: 12px; height: ${la("status-h")}; padding: 0 10px;\n background: ${la("panel")}; border-top: 1px solid ${la("bd-soft")}; color: ${la("mut")}; font-size: 11.5px;\n font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; }\n.oac-widget .oac-statusline__sym { color: ${la("tx-strong")}; font-weight: 600; letter-spacing: .3px; }\n.oac-widget .oac-statusline__iv { color: ${la("faint")}; margin-left: 4px; font-weight: 600; }\n.oac-widget .oac-statusline__field { display: inline-flex; align-items: center; gap: 4px; }\n.oac-widget .oac-statusline__field > i { font-style: normal; color: ${la("faint")}; }\n.oac-widget .oac-statusline__field > b { font-weight: 500; color: ${la("tx")}; }\n.oac-widget .oac-statusline .is-up > b { color: ${la("up")}; }\n.oac-widget .oac-statusline .is-down > b { color: ${la("down")}; }\n.oac-widget .oac-statusline__msg { margin-left: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: ${la("mut")}; }\n.oac-widget .oac-statusline__msg.is-error { color: ${la("danger")}; }\n.oac-widget .oac-statusline__tz { color: ${la("faint")}; }\n\n/* Narrow widget chrome */\n.oac-widget .oac-mobile { display: none; }\n.oac-widget.is-mobile { grid-template-rows: auto minmax(0, 1fr) auto; }\n.oac-widget.is-mobile > .oac-topbar, .oac-widget.is-mobile > .oac-statusline,\n.oac-widget.is-mobile > .oac-stage > .oac-rail { display: none; }\n.oac-widget.is-mobile > .oac-stage { grid-row: 2; }\n.oac-widget.is-mobile > .oac-mobile { display: contents; }\n.oac-widget .oac-mobile__header { grid-row: 1; z-index: 40; display: grid; grid-template-columns: minmax(0, 1fr) auto;\n gap: 8px; min-height: 52px; padding: calc(4px + env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 4px\n max(8px, env(safe-area-inset-left)); background: ${la("panel")}; border-bottom: 1px solid ${la("bd-soft")}; }\n.oac-widget .oac-mobile__symbol { width: 100%; min-width: 0; height: 44px; text-transform: uppercase; font-weight: 600; }\n.oac-widget .oac-mobile__footer { grid-row: 3; z-index: 40; min-width: 0; padding-bottom: env(safe-area-inset-bottom);\n background: ${la("panel")}; border-top: 1px solid ${la("bd-soft")}; }\n.oac-widget .oac-mobile__bar, .oac-widget .oac-mobile__selection { display: grid; grid-auto-flow: column;\n grid-auto-columns: minmax(0, 1fr); min-width: 0; }\n.oac-widget .oac-mobile__selection { border-bottom: 1px solid ${la("bd-soft")}; }\n.oac-widget .oac-mobile__action { min-width: 0; min-height: 44px; padding: 6px 10px; border: 0; border-radius: 0;\n background: transparent; color: ${la("tx")}; overflow-wrap: anywhere; touch-action: manipulation; }\n.oac-widget .oac-mobile__action:hover, .oac-widget .oac-mobile__action:focus-visible { background: ${la("elev")}; }\n.oac-widget .oac-mobile__action[aria-pressed="true"] { color: ${la("acc-2")}; background: ${la("on-bg")}; }\n.oac-widget .oac-mobile__action[aria-disabled="true"] { color: ${la("faint")}; cursor: default; background: transparent; }\n.oac-widget .oac-mobile__branding { display: flex; align-items: center; width: 100%; min-height: 44px; text-decoration: none; }\n.oac-widget .oac-mobile-sheet.oac-dialog { left: 0; right: 0; top: auto; bottom: 0; transform: none; width: 100%;\n max-width: 100%; max-height: calc(100% - env(safe-area-inset-top) - 12px); border-radius: 14px 14px 0 0;\n padding-bottom: env(safe-area-inset-bottom); }\n.oac-widget .oac-mobile-sheet__head { flex: none; display: flex; align-items: center; gap: 8px;\n min-height: 52px; padding: 4px 8px 4px 14px; border-bottom: 1px solid ${la("bd-soft")}; }\n.oac-widget .oac-mobile-sheet__title { flex: 1 1 auto; color: ${la("tx-strong")}; font-size: 14px; }\n.oac-widget .oac-mobile-sheet__body { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain;\n display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; padding: 8px; }\n.oac-widget .oac-mobile-sheet__body > .oac-head { grid-column: 1 / -1; }\n.oac-widget .oac-mobile-sheet__controls { grid-column: 1 / -1; display: grid;\n grid-template-columns: repeat(3, minmax(0, 1fr)); border-bottom: 1px solid ${la("bd-soft")}; margin-bottom: 6px; }\n.oac-widget .oac-mobile-sheet__body small { display: block; color: ${la("faint")}; }\n/* A sheet row with a glyph (a chart type): the glyph sits on the middle of its label, not the baseline. */\n.oac-widget .oac-mobile-sheet .oac-mobile__action > .oac-glyph { vertical-align: middle; margin: -2px 8px 0 0; }\n.oac-widget .oac-mobile-results { width: min(360px, calc(100% - 16px)); max-height: min(50%, 360px); overflow: hidden;\n display: flex; flex-direction: column; background: ${la("panel")}; border: 1px solid ${la("bd")}; border-radius: 10px; box-shadow: ${la("shadow")}; }\n.oac-widget .oac-mobile-results__head { flex: none; display: flex; align-items: center; gap: 8px; min-height: 44px;\n padding-left: 12px; border-bottom: 1px solid ${la("bd-soft")}; }\n.oac-widget .oac-mobile-results__head > strong { flex: 1 1 auto; color: ${la("tx-strong")}; }\n.oac-widget .oac-mobile-results__list { flex: 1 1 auto; min-height: 0; max-height: min(42vh, 300px);\n overflow-y: auto; overscroll-behavior: contain; }\n.oac-widget .oac-mobile-results__list > .oac-mobile__action { display: block; width: 100%; text-align: left; }\n.oac-widget .oac-mobile-results__list small { display: block; color: ${la("faint")}; }\n.oac-widget .oac-mobile-results__status { min-height: 44px; padding: 13px 12px; color: ${la("mut")}; }\n.oac-widget.is-mobile .oac-toasts { bottom: calc(54px + env(safe-area-inset-bottom)); }\n\n/* Toasts */\n.oac-widget .oac-toasts { position: absolute; right: 12px; bottom: calc(${la("status-h")} + 10px); z-index: 90; display: flex;\n flex-direction: column; gap: 8px; width: min(340px, calc(100% - 24px)); pointer-events: none; }\n.oac-widget .oac-toast { display: flex; align-items: flex-start; gap: 8px; padding: 8px 6px 8px 12px; border-radius: 8px;\n background: ${la("panel")}; color: ${la("tx")}; border: 1px solid ${la("bd")}; border-left: 3px solid ${la("acc")};\n box-shadow: ${la("shadow")}; font-size: 12.5px; line-height: 1.45; pointer-events: auto; animation: oac-toast-in .16s ease-out; }\n.oac-widget .oac-toast--success { border-left-color: ${la("buy")}; }\n.oac-widget .oac-toast--error { border-left-color: ${la("sell")}; }\n.oac-widget .oac-toast__msg { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; padding-top: 2px; }\n.oac-widget .oac-toast__x { flex: none; width: 26px; height: 26px; border: 0; border-radius: 6px; background: transparent;\n color: ${la("faint")}; padding: 0; display: grid; place-items: center; }\n.oac-widget .oac-toast__x:hover { background: ${la("elev-2")}; color: ${la("tx")}; }\n.oac-widget .oac-toast__x > svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.5; }\n.oac-widget .oac-toast.is-out { opacity: 0; transform: translateY(6px); transition: opacity .16s, transform .16s; }\n@keyframes oac-toast-in { from { opacity: 0; transform: translateY(6px); } }\n\n/* Overlay layer: popovers anchored to a control, dialogs centred over a scrim. */\n.oac-widget .oac-layer { container: oac-widget / inline-size; position: absolute; inset: 0; z-index: 60; pointer-events: none; }\n.oac-widget .oac-layer > * { pointer-events: auto; }\n.oac-widget .oac-scrim { position: absolute; inset: 0; background: ${la("scrim")}; }\n.oac-widget .oac-pop { position: absolute; left: 0; top: 0; }\n.oac-widget .oac-dialog { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);\n min-width: 0; max-width: calc(100% - 24px); max-height: calc(100% - 24px); display: flex; flex-direction: column;\n background: ${la("panel")}; border: 1px solid ${la("bd")}; border-radius: 12px; box-shadow: ${la("shadow")}; outline: none; }\n.oac-widget .oac-dialog__head { flex: none; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 12px 14px 8px; }\n.oac-widget .oac-dialog__title { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; font-size: 14px; font-weight: 700; color: ${la("tx-strong")}; }\n.oac-widget .oac-dialog__body { flex: 1 1 auto; min-height: 0; min-width: 0; overflow: auto; overscroll-behavior: contain; padding: 4px 14px 10px; }\n.oac-widget .oac-dialog__foot { flex: none; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px 12px;\n border-top: 1px solid ${la("bd-soft")}; }\n.oac-widget .oac-dialog__foot > .oac-spacer { flex: 1 1 auto; }\n.oac-widget .oac-csv { width: 490px; }\n.oac-widget .oac-csv__ranges, .oac-widget .oac-csv .oac-dialog__actions { display: flex; flex-wrap: wrap; gap: 8px; }\n.oac-widget .oac-csv__hint { color: ${la("mut")}; line-height: 1.5; }\n.oac-widget .oac-csv__error { color: ${la("danger")}; overflow-wrap: anywhere; }\n.oac-widget .oac-csv__error:empty { display: none; }\n\n/* Shortcuts panel */\n.oac-widget .oac-keys { columns: 2; column-gap: 24px; min-width: 520px; }\n.oac-widget .oac-keys__group { break-inside: avoid; margin-bottom: 8px; }\n.oac-widget .oac-keys__row { display: flex; align-items: center; gap: 10px; padding: 3px 0; }\n.oac-widget .oac-keys__row > span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }\n.oac-widget .oac-keys__row > kbd { flex: none; padding: 2px 6px; border-radius: 4px; background: ${la("elev")};\n border: 1px solid ${la("bd-soft")}; color: ${la("mut")}; }\n.oac-widget .oac-keys__row.is-shadowed > span, .oac-widget .oac-keys__row.is-shadowed > kbd { color: ${la("faint")}; text-decoration: line-through; }\n.oac-widget .oac-keys__note { color: ${la("faint")}; font-size: 11px; padding: 4px 0 0; }\n\n@container oac-widget (max-width: 720px) {\n .oac-widget .oac-keys { columns: 1; min-width: 0; }\n}\n@media (max-width: 720px) {\n .oac-widget .oac-sym > input { width: 104px; }\n}\n@media (prefers-reduced-motion: reduce) {\n .oac-widget .oac-rail__btn, .oac-widget .oac-rail__chev, .oac-widget .oac-tip, .oac-widget .oac-fly__star,\n .oac-widget .oac-btn, .oac-widget .oac-toast.is-out { transition: none; }\n .oac-widget .oac-toast { animation: none; }\n .oac-widget .oac-mobile__action { transition: none; }\n}\n`;function ua(e,t="",o){const n=e.getElementById(ca);if(n?.textContent?.trim())return n;const i=n??e.createElement("style");return i.id=ca,i.nonce||void 0===o||(i.nonce=o),i.textContent=da+t,null===n&&(e.head??e.body??e.documentElement).appendChild(i),i}function ha(e,t){const o=e.getElementById(ca);null===o||(o.textContent??"").includes(t)||o.appendChild(e.createTextNode(t))}const pa=/^(style|text|props)\./;function ga(e){return"string"==typeof e||"boolean"==typeof e||"number"==typeof e&&Number.isFinite(e)||Array.isArray(e)}function ma(e,t){const{draw:o,chart:n}=e;let i=null,a=!1;const r=new Set,s=e=>{a||null!==i&&e.revision<i.revision||(i=e,(()=>{for(const e of Array.from(r))e()})())},l=t.subscribe(s);t.load().then(s,()=>{a||e.status(Pe(e,"Drawing templates could not be loaded"),"error")});const c=e=>i?.defaults.find(t=>t.tool===e)?.values;function d(e){const t={};for(const[o,n]of Object.entries(fe(e,be(e.tool))))pa.test(o)&&"text.value"!==o&&ga(n)&&(t[o]=n);return t}function u(e,t){const n=[];for(const i of Xe(o,e)){const e=o.get(i);if(void 0===e)continue;const a=ve(e,t,be(e.tool));Object.keys(a).length>0&&n.push({id:i,patch:a})}return n}let h=null;const p=[n.on("drawing:change",e=>{h=null;const t=e;if(a||"add"!==t.kind||void 0===t.step||!0===t.linked||1!==t.ids.length)return;const n=o.get(t.ids[0]);if(void 0===n||o.activeTool()!==n.tool||void 0===c(n.tool))return;const i=n.id;h=i,queueMicrotask(()=>{h===i&&(h=null)})}),n.on("draw:tool",()=>{const t=h;h=null;const n=null===t||a?void 0:o.get(t),i=void 0===n?void 0:c(n.tool);if(void 0===n||void 0===i)return;const r=u([n.id],i);if(0===r.length)return;const s=()=>{o.updateMany(r)};void 0===e.history||e.history.isDestroyed?o.untracked(s):e.history.ignore(s)})],g=async(t,o)=>{try{const n=await t();return a||e.toast(o,"success"),n}catch(t){throw a||e.toast(Pe(e,"The drawing template could not be saved: {error}",{error:Me(e,t)}),"error"),t}},m=t=>{const n=o.get(t);if(void 0===n)throw new Error(Pe(e,"Select a drawing first"));return n},f=t=>Pe(e,`schema.drawing.${t}.name`,{},et(t)?.name??t);return{store:t,catalog:()=>i,templatesFor:e=>i?.templates.filter(t=>t.tool===e)??[],defaultFor:c,capture:d,apply:function(e,t){const n=u(e,t);return n.length>0&&o.updateMany(n),n.length},saveDefault:async o=>{const n=m(o);await g(()=>t.setDefault(n.tool,d(n)),Pe(e,"New {tool} drawings start with this look",{tool:f(n.tool)}))},clearDefault:async o=>{await g(()=>t.setDefault(o,null),Pe(e,"New {tool} drawings start with the standard look",{tool:f(o)}))},saveTemplate:async(o,n)=>{const i=m(o);return g(()=>t.saveTemplate(n,i.tool,d(i)),Pe(e,"Saved the template {name}",{name:n.trim()}))},removeTemplate:async o=>{await g(()=>t.removeTemplate(o),Pe(e,"Removed the template"))},subscribe:e=>(r.add(e),()=>{r.delete(e)}),destroy:()=>{if(!a){a=!0;for(const e of p)e();l(),r.clear()}}}}function fa(e,t,o,n){const i=o.map(t=>e.draw.get(t)).filter(e=>void 0!==e),a=1===new Set(i.map(e=>e.tool)).size?i[0].tool:null,r=i[0],s=Xe(e.draw,o).length>0,l=[Pe(e,"Templates")],c=e=>{e().catch(()=>{})};l.push({label:Pe(e,"Save as default for this tool"),sub:null===a?Pe(e,"one tool at a time"):void 0,disabled:null===a,onSelect:()=>{void 0!==r&&c(()=>t.saveDefault(r.id))}}),null!==a&&void 0!==t.defaultFor(a)&&l.push({label:Pe(e,"Forget the default for this tool"),onSelect:()=>c(()=>t.clearDefault(a))}),l.push({label:Pe(e,"Save as template..."),disabled:null===a,onSelect:()=>{void 0!==r&&va(e,n,e=>t.saveTemplate(r.id,e))}});const d=null===a?[]:t.templatesFor(a);for(const n of d)l.push({label:Pe(e,"Apply {name}",{name:n.name}),disabled:!s,sub:s?void 0:Pe(e,"read-only"),onSelect:()=>{ot(e,"template",()=>t.apply(o,n.values))}});return l}let ba=0;function va(e,t,o){const n=e.document,i=$o(n,{translate:e.translate,title:Pe(e,"Save as template"),className:"oac-template-name",onClose:()=>d.close()}),a=ko(n,"label","oac-template-name__label",Pe(e,"Template name")),r=ko(n,"input","oac-template-name__input");r.type="text",r.maxLength=120,r.id="oac-template-name-"+ ++ba,a.htmlFor=r.id;const s=ko(n,"p","oac-input-error");s.setAttribute("role","alert"),s.hidden=!0,i.body.append(a,r,s);let l=!1;const c=async()=>{const t=r.value.trim();if(!l){if(""===t)return s.textContent=Pe(e,"Enter a name"),s.hidden=!1,r.setAttribute("aria-invalid","true"),void r.focus();l=!0;try{await o(t),d.close()}catch(t){s.textContent=Me(e,t),s.hidden=!1,r.setAttribute("aria-invalid","true")}finally{l=!1}}};r.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),c())}),r.addEventListener("input",()=>{s.hidden=!0,r.removeAttribute("aria-invalid")}),i.actions.appendChild(Ao(n,{label:Pe(e,"Cancel"),onClick:()=>d.close()}));i.actions.appendChild(Ao(n,{label:Pe(e,"Save"),variant:"primary",onClick:()=>{c()}})).dataset.action="save-template";const d=jo(e,i.el,void 0===t?{placement:"center",modal:!0,initialFocus:r}:{anchor:t,placement:"below",initialFocus:r},()=>{});return d}const wa="\n.oac-widget .oac-template-name { width: 300px; }\n.oac-widget .oac-template-name .oac-dialog__body { display: flex; flex-direction: column; gap: 6px; padding-top: 8px; }\n.oac-widget .oac-template-name__label { color: var(--oac-mut); font-size: 11px; }\n.oac-widget .oac-template-name__input { width: 100%; }\n",ya=/^(\d{4})-(\d{2})-(\d{2})$/,_a=/^(\d{2}):(\d{2})(?::(\d{2}))?$/,xa=e=>String(e).padStart(2,"0");function ka(e,t,o){const n=g(e,t),i=o??0!==n.second;return{date:`${n.year}-${xa(n.month)}-${xa(n.day)}`,time:`${xa(n.hour)}:${xa(n.minute)}${i?`:${xa(n.second)}`:""}`,seconds:i}}function Ca(e,t,o,n={}){const i=ya.exec(e.trim()),a=t.trim(),r=_a.exec(a);if(null===i||null===r&&(""!==a||void 0===n.blank))return null;const[s,l,c]=[Number(i[1]),Number(i[2]),Number(i[3])],d=new Date(Date.UTC(s,l-1,c));if(d.getUTCMonth()!==l-1||d.getUTCDate()!==c)return null;if(null===r){const e="end"===n.blank?T(s,l,c+1,0,0,0,o)-1:T(s,l,c,0,0,0,o);return Number.isFinite(e)?e:null}const[u,h]=[Number(r[1]),Number(r[2])],p=void 0!==r[3]?Number(r[3]):!0===n.end?59:0;if(u>23||h>59||p>59)return null;const g=T(s,l,c,u,h,p,o);if(!Number.isFinite(g))return null;if(!0===n.rejectSkipped){const e=ka(g,o,!0);if(e.date!==`${i[1]}-${i[2]}-${i[3]}`||e.time!==`${xa(u)}:${xa(h)}:${xa(p)}`)return null}return g}let Sa=0;function Aa(e,t,o,n){const{chart:i,draw:a}=e,r=e.document,s=ko(r,"div","oac-coords");t.appendChild(s);const l=new Map;let c=i.timezone(),d=!1;function u(e,t,o){const n=ka(o.time,c),a=function(e,t){const o=e.toFixed(Math.max(0,Math.min(10,t)));return Number(o)===e?o:String(Number(e.toFixed(10)))}(o.price,(e=>{const t=i.panes()[e.paneIndex]?.priceScale.precision();return Math.max(2,void 0!==t&&Number.isFinite(t)?Math.round(t):0)})(t));e.date.value=n.date,e.time.step=n.seconds?"1":"60",e.time.value=n.time,e.price.value=a,e.shown={date:n.date,time:n.time,price:a},e.error.hidden=!0,e.error.textContent="";for(const t of[e.date,e.time,e.price])t.removeAttribute("aria-invalid")}function h(e,t,o){e.error.textContent=o,e.error.hidden=!1,t.setAttribute("aria-invalid","true")}function p(t,o,r){const s=a.get(t),l=s?.points[o];if(d||void 0===s||void 0===l||null!==n())return;for(const e of[r.date,r.time,r.price])e.removeAttribute("aria-invalid");r.error.hidden=!0;let p=l.time;if(r.date.value!==r.shown.date||r.time.value!==r.shown.time){const t=Ca(r.date.value,r.time.value,c);if(null===t){return void h(r,null!==Ca(r.date.value,"00:00",c)?r.time:r.date,Pe(e,"Enter a date and a time on the chart clock"))}p=t}let g=l.price;if(r.price.value!==r.shown.price){const t=function(e){const t=e.trim().replace(/[\s,]/g,"");if(!/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[-+]?\d+)?$/i.test(t))return null;const o=Number(t);return Number.isFinite(o)?o:null}(r.price.value);if(null===t)return void h(r,r.price,Pe(e,"Enter a price as a number"));if(t<=0&&(e=>"logarithmic"===i.panes()[e.paneIndex]?.priceScale.options.mode)(s))return void h(r,r.price,Pe(e,"A logarithmic scale needs a price above zero"));g=t}if(p===l.time&&g===l.price)return;const m=s.points.map((e,t)=>t===o?{...e,time:p,price:g}:{...e});a.update(t,{points:m});const f=a.get(t),b=f?.points[o];void 0!==f&&void 0!==b&&u(r,f,b)}function g(t,o){const n=ko(r,"div","oac-coords__row");n.dataset.anchor=`${t}:${o}`;const i="oac-coords-"+ ++Sa,a=ko(r,"label","oac-coords__label",Pe(e,"Point {number}",{number:o+1}));a.htmlFor=`${i}-date`;const s=ko(r,"input","oac-coords__date");s.type="date",s.id=`${i}-date`;const l=ko(r,"input","oac-coords__time");l.type="time";const c=ko(r,"input","oac-coords__price");c.type="text",c.setAttribute("inputmode","decimal"),c.setAttribute("spellcheck","false"),c.autocomplete="off";const d=ko(r,"p","oac-input-error");d.setAttribute("role","alert"),d.hidden=!0;const u={el:n,date:s,time:l,price:c,error:d,shown:{date:"",time:"",price:""}},h=t=>Pe(e,"{field} of point {number}",{field:t,number:o+1});s.setAttribute("aria-label",h(Pe(e,"Date"))),l.setAttribute("aria-label",h(Pe(e,"Time"))),c.setAttribute("aria-label",h(Pe(e,"Price")));for(const e of[s,l,c])e.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),p(t,o,u))});n.addEventListener("focusout",e=>{const i=e.relatedTarget;null!==i&&n.contains(i)||p(t,o,u)});const g=ko(r,"div","oac-coords__fields");return g.append(s,l,c),n.append(a,g,d),u}function m(e){s.appendChild(ko(r,"p","oac-coords__note",e))}let f="";function b(){if(d)return;const t=r.activeElement,h=null!==t&&s.contains(t),p=h?t.closest("[data-anchor]")?.dataset.anchor:void 0;c=i.timezone();const b=n(),v=o().map(e=>a.get(e)).filter(e=>void 0!==e),w=JSON.stringify([c,v.map(e=>[e.id,e.tool,e.space??"data",e.points.length])]),y=w!==f;f=w;const _=new Set;if(y){s.replaceChildren();const t=ko(r,"div","oac-coords__head");t.append(ko(r,"span","",Pe(e,"Date")),ko(r,"span","",Pe(e,"Time")),ko(r,"span","",Pe(e,"Price"))),s.append(t,ko(r,"p","oac-coords__zone",Pe(e,"Times are on the chart clock, {zone}.",{zone:c})))}for(const t of v){const o=et(t.tool);if(y&&v.length>1&&s.appendChild(ko(r,"div","oac-head",Pe(e,`schema.drawing.${t.tool}.name`,{},o?.name??t.tool))),"viewport"===t.space){y&&m(Pe(e,"Pinned to the screen: its anchors are not a time and a price."));continue}if(!0===o?.freehand){y&&m(Pe(e,"A freehand stroke has {count} points. Move it on the chart.",{count:t.points.length}));continue}const n=null!==b||0===Xe(a,[t.id]).length;t.points.forEach((o,i)=>{const a=`${t.id}:${i}`;_.add(a);let r=l.get(a);void 0===r&&(r=g(t.id,i),l.set(a,r)),a!==p&&u(r,t,o);for(const t of[r.date,r.time,r.price])t.disabled=n,t.title=n?b??Pe(e,"read-only"):"";y&&s.appendChild(r.el)})}for(const e of[...l.keys()])_.has(e)||l.delete(e);if(h&&!s.contains(t)&&void 0!==p){const e=l.get(p),o=void 0===e?void 0:[e.date,e.time,e.price].find(e=>e.className===t.className);o?.focus()}}const v=[i.on("timezone:changed",b)];return b(),{el:s,refresh:b,destroy:()=>{if(!d){d=!0;for(const e of v)e();l.clear(),s.remove()}}}}const Oa="\n.oac-widget .oac-coords { display: flex; flex-direction: column; gap: 4px; min-width: 0; }\n.oac-widget .oac-coords__head, .oac-widget .oac-coords__fields { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 6px; }\n.oac-widget .oac-coords__head { order: -1; color: var(--oac-faint); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; padding: 2px 0 0; }\n.oac-widget .oac-coords__zone { margin: 0 0 4px; color: var(--oac-faint); font-size: 11px; }\n.oac-widget .oac-coords__row { display: flex; flex-direction: column; gap: 3px; }\n.oac-widget .oac-coords__label { color: var(--oac-mut); font-size: 11px; }\n.oac-widget .oac-coords input { min-width: 0; width: 100%; height: var(--oac-ctl-h); padding: 0 6px; border: 1px solid var(--oac-bd);\n border-radius: var(--oac-radius); background: var(--oac-elev); color: var(--oac-tx); color-scheme: inherit; font-variant-numeric: tabular-nums; }\n.oac-widget .oac-coords input:disabled { opacity: .6; cursor: not-allowed; }\n.oac-widget .oac-coords .oac-input-error { margin: 0; }\n.oac-widget .oac-coords__note { margin: 4px 0; color: var(--oac-mut); font-size: 12px; overflow-wrap: anywhere; }\n",La=[0,.236,.382,.5,.618,.786,1,1.272,1.414,1.618,2,2.618,3.618,4.236],Ea=(e,t)=>e.some(e=>Math.abs(e.ratio-t)<=1e-6);function $a(e,t,o={}){const n=e.document,i=o.ids??e.draw.selection(),{drawings:a,schema:r}=function(e,t){const o=[];for(const n of t){const t=e.draw.get(n);void 0!==t&&!1!==t.policy?.editable&&be(t.tool).fields.some(e=>"levels"===e.kind)&&o.push(t)}return{drawings:o,schema:0===o.length?null:be(o[0].tool)}}(e,i);if(null===r)return To(e,Pe(e,"Select a drawing with levels first"));const s=a[0],l=et(s.tool),c=r.fields.find(e=>"levels"===e.kind),d=r.fields.find(e=>"style.showLabels"===e.path),u=c?.path??"style.levels",h=l?.defaultStyle?.levels??we,p="gann-fan"===(g=s.tool)?ye:"fib-time-zone"===g?e=>String(e):_e;var g;const m=()=>{const e=xe(s,u);return Array.isArray(e)?ke(e):ke(h)},f=()=>{const e=xe(s,"style.showLabels");return void 0===e?!0===l?.defaultStyle?.showLabels:!0===e};let b=m();function v(t){const o=[];for(const n of a){const i=e.draw.get(n.id);if(void 0===i)continue;const a=ve(i,t,r);Object.keys(a).length>0&&o.push({id:n.id,patch:a})}o.length>0&&e.draw.updateMany(o)}const w=()=>v({[u]:ke(b)}),y=ko(n,"div","oac-panel oac-levels");y.setAttribute("role","dialog"),y.setAttribute("aria-label",Pe(e,"Levels")),y.tabIndex=-1,Lo(y);const _=ko(n,"div","oac-levels__head");_.appendChild(ko(n,"b","oac-levels__title",Pe(e,"Levels")));let x=null;if(void 0!==d){const t=ko(n,"label","oac-levels__labels");x=ko(n,"input"),x.type="checkbox",x.checked=f(),x.dataset.path=d.path;const o=x;o.addEventListener("change",()=>v({[d.path]:o.checked})),t.appendChild(o),t.appendChild(ko(n,"span",void 0,Pe(e,"Show labels"))),_.appendChild(t)}_.appendChild(Ao(n,{label:Pe(e,"Close"),icon:"close",iconOnly:!0,onClick:()=>$.close()})),y.appendChild(_);const k=ko(n,"div","oac-levels__rows");y.appendChild(k);let C=[];function S(){C.forEach(e=>e.destroy()),C=[],k.innerHTML="",0!==b.length?b.forEach((t,o)=>k.appendChild(function(t,o){const i=ko(n,"div","oac-levels__row"+(!1===t.enabled?" is-off":"")),a=ko(n,"input");a.type="checkbox",a.checked=!1!==t.enabled,a.addEventListener("change",()=>{a.checked?delete b[o].enabled:b[o].enabled=!1,i.classList.toggle("is-off",!a.checked),w()}),i.appendChild(a);const r=ko(n,"input");r.type="number",r.step="0.001",r.value=String(t.ratio),r.addEventListener("change",()=>{const e=Number(r.value);""!==r.value.trim()&&Number.isFinite(e)?(b[o].ratio=e,void 0===b[o].label&&(c.placeholder=p(e)),u(),w()):r.value=String(b[o].ratio)}),i.appendChild(r);const l=ho(n,{id:`oac-level-${s.id}-${o}`,label:Pe(e,"Level {level} color",{level:p(t.ratio)}),value:t.color??s.style.color??Se(t.ratio)??Ce,translate:e.translate,openOverlay:e.openOverlay,onChange:e=>{b[o].color=e,w()}});C.push(l),i.appendChild(l.el);const c=ko(n,"input");c.type="text",c.value=t.label??"",c.placeholder=p(t.ratio),c.setAttribute("spellcheck","false"),c.addEventListener("change",()=>{const e=c.value.trim();""===e?delete b[o].label:b[o].label=e,w()}),i.appendChild(c);const d=ko(n,"button","oac-levels__x");function u(){const t=p(b[o].ratio);a.setAttribute("aria-label",Pe(e,"Level {level} enabled",{level:t})),r.setAttribute("aria-label",Pe(e,"Level {level} ratio",{level:t})),l.trigger.setAttribute("aria-label",Pe(e,"Level {level} color",{level:t})),c.setAttribute("aria-label",Pe(e,"Level {level} label",{level:t})),d.setAttribute("aria-label",Pe(e,"Remove level {level}",{level:t}))}return d.type="button",d.appendChild(So(n,"close")),d.addEventListener("click",e=>{e.stopPropagation(),b.splice(o,1),S(),w()}),i.appendChild(d),u(),i}(t,o))):k.appendChild(ko(n,"div","oac-empty",Pe(e,"No levels. Add one, or reset to the defaults.")))}S();const A=ko(n,"div","oac-levels__foot");A.appendChild(Ao(n,{label:Pe(e,"Add level"),icon:"plus",onClick:()=>{const e=function(e){for(const t of La)if(!Ea(e,t))return t;let t=0;for(const o of e)Number.isFinite(o.ratio)&&(t=Math.max(t,o.ratio));return t+1}(b),t={ratio:e},o=Se(e);o!==Ce&&(t.color=o),b.push(t),S(),w()}})),A.appendChild(ko(n,"span","oac-spacer")),A.appendChild(Ao(n,{label:Pe(e,"Reset"),onClick:()=>{b=ke(h),S(),w()}})),y.appendChild(A);const O=e.chart.on("draw:update",()=>{if(!$.isOpen())return;if(void 0===e.draw.get(s.id))return void $.close();const t=m();JSON.stringify(t)===JSON.stringify(b)||y.contains(n.activeElement)||(b=t,S()),null!==x&&x!==n.activeElement&&(x.checked=f())}),L=e.chart.on("draw:remove",()=>{$.isOpen()&&void 0===e.draw.get(s.id)&&$.close()}),E=()=>{C.forEach(e=>e.destroy()),O(),L()},$=jo(e,y,void 0===t?{placement:"below",dismissOnOutside:!0}:{anchor:t,placement:"below"},E);void 0===t&&Io(e.root,y,{point:Po(e.root,e.chart,a)});const T=$.close;return{el:y,isOpen:$.isOpen,close:()=>{E(),T()}}}function Ta(e,t){const o=!0===e.bold?"700 ":"";return`${!0===e.italic?"italic ":""}${o}${t}px ${void 0===e.fontFamily||""===e.fontFamily?"ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif":e.fontFamily}`}function ja(e,t,o,n){const i=o.split("\n");if(!0!==t.wrap)return i;const a=[];for(const t of i){const o=t.split(/\s+/).filter(e=>""!==e);if(0===o.length){a.push("");continue}let i=o[0];for(let t=1;t<o.length;t++){const r=`${i} ${o[t]}`;e(r)>n?(a.push(i),i=o[t]):i=r}a.push(i)}return a}function Pa(e){let t="",o=!1;const n=e=>{for(const i of Array.from(e.childNodes??[])){if(3===i.nodeType){t+=i.nodeValue??"",o=!1;continue}if(1!==i.nodeType)continue;const e=String(i.nodeName).toUpperCase();"BR"!==e?("DIV"!==e&&"P"!==e||""===t||t.endsWith("\n")||(t+="\n"),o=!1,n(i)):(t+="\n",o=!0)}};return n(e),o?t.slice(0,-1):t}function Ma(e){return e.panes()[0]?.element.parentElement??null}function Ia(e){return void 0!==e&&!0===be(e.tool).textIsContent}function Da(e,t,o){const n=To(e,t);return o?.(!1),{...n,commit:()=>{},cancel:()=>{}}}function za(e,t,o={}){const n=e.document,{chart:i,draw:a}=e,r=a.selection(),s=o.id??(1===r.length?r[0]:void 0),l=void 0===s?void 0:a.get(s);if(!Ia(l))return Da(e,Pe(e,"Select a text drawing first"),o.onDone);if(!1===l.policy?.editable)return Da(e,Pe(e,"read-only"),o.onDone);const c=et(l.tool),d=void 0!==c?.defaultText?.value&&""!==c.defaultText.value?c.defaultText.value:Pe(e,"Text"),u=l.text??{value:""},h=u.fontSize??14,p=Ta(u,h),g=function(e,t,o){let n=null;try{const t=e.createElement("canvas");n="function"==typeof t.getContext?t.getContext("2d"):null}catch{n=null}if(null!==n&&"function"==typeof n.measureText){n.font=t;const e=n;return t=>e.measureText(t).width}return e=>e.length*o*.6}(n,p,h),m=function(e,t,o,n="Text",i){const a=t.points[0],r=i??(void 0===a?null:{x:e.timeToCoordinate(a.time),y:e.priceToCoordinate(a.price,t.paneIndex)});if(null===r)return null;const{x:s,y:l}=r;if(!Number.isFinite(s)||null===l||!Number.isFinite(l))return null;const c=t.text??{value:""},d=c.fontSize??14,u=Ta(c,d),h=ja(o,c,void 0===c.value||""===c.value?n:c.value,c.wrapWidth??220);let p=0;for(const e of h)p=Math.max(p,o(e));const g=1.35*d,m=h.length*g+10,f=c.valign??"top";return{x:s,y:"middle"===f?l-m/2:"bottom"===f?l-m:l,width:p+10,height:m,lineHeight:g,lines:h,font:u,size:d}}(i,l,g,d,"viewport"===l.space?a.screenPoints(l.id)?.[0]??null:void 0),f=Ma(i);if(null===m||null===f)return Da(e,Pe(e,"That text is off the chart"),o.onDone);const b=Ue(e.root,f),v=ko(n,"div","oac-textedit");v.setAttribute("contenteditable","plaintext-only"),v.setAttribute("spellcheck","false"),v.setAttribute("role","textbox"),v.setAttribute("aria-multiline","true"),v.setAttribute("aria-label",Pe(e,"Drawing text")),v.tabIndex=0;const w=v.style;w.left=`${Math.round(m.x+b.left)}px`,w.top=`${Math.round(m.y+b.top)}px`,w.font=p,w.lineHeight=`${m.lineHeight}px`,w.color=u.color??l.style.color??"inherit",w.textAlign=u.align??"left",w.minWidth=`${Math.ceil(m.width)}px`,w.minHeight=`${Math.ceil(m.height)}px`;const y=!0===u.wrap,_=u.wrapWidth??220;w.whiteSpace=y?"pre-wrap":"pre",y&&(w.width=`${Math.ceil(m.width)}px`);const x=u.value??"";v.textContent=x;let k=!1;const C=e=>{k||(k=!0,O.close(),o.onDone?.(e))},S=()=>{if(k)return;const e=Pa(v),t=e!==x;t&&void 0!==a.get(l.id)&&a.update(l.id,{text:{...a.get(l.id)?.text??{value:""},value:e}}),C(t)},A=()=>C(!1);for(const e of["pointerdown","pointermove","pointerup","click","dblclick","contextmenu","keyup","keypress"])v.addEventListener(e,e=>{e.stopPropagation()});v.addEventListener("keydown",e=>{const t=e.key;if("Tab"!==t&&e.stopPropagation(),"Escape"===t)return e.preventDefault(),void A();"Enter"===t&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),S())}),v.addEventListener("blur",()=>S()),y&&v.addEventListener("input",()=>{const e=ja(g,u,Pa(v)||d,_);let t=0;for(const o of e)t=Math.max(t,g(o));w.width=`${Math.ceil(t+10)}px`});const O=jo(e,v,{placement:"below",modal:!1,dismissOnOutside:!1,initialFocus:v},A);try{const e=n.defaultView;if(null!==e&&"function"==typeof e.getSelection&&"function"==typeof n.createRange){const t=n.createRange();t.selectNodeContents(v),t.collapse(!1);const o=e.getSelection();o?.removeAllRanges(),o?.addRange(t)}}catch{}return{el:v,isOpen:O.isOpen,close:()=>S(),commit:S,cancel:A}}function Na(e){const t=e.map(e=>be(e));if(0===t.length)return{fields:[]};const[o,...n]=t,i=o.fields.filter(e=>n.every(t=>t.fields.some(t=>t.path===e.path&&t.kind===e.kind)));return t.every(e=>!0===e.textIsContent)?{fields:i,textIsContent:!0}:{fields:i}}const Ra={"style.lineWidth":1.5,"style.lineStyle":"solid","style.fillOpacity":.12,"text.fontSize":14,"text.wrapWidth":220,"text.backgroundOpacity":1,"text.align":"left","text.valign":"top","text.position":"inside"};function Fa(e,t,o){const n={};for(const i of t.fields){const[t,a]=i.path.split("."),r="style"===t?e?.defaultStyle:"text"===t?e?.defaultText:void 0;let s=void 0===r||void 0===a?void 0:r[a];void 0===s&&(s=Ra[i.path]),void 0===s&&"boolean"===i.kind&&(s=!1),void 0===s&&"style.color"===i.path&&(s=o),void 0!==s&&(n[i.path]=s)}return n}function Wa(e,t,o,n){const i=Fa(o,t,n);for(const[o,n]of Object.entries(fe(e,t)))void 0!==n&&(i[o]=n);for(const e of["text.color","style.fillColor","text.borderColor"])void 0===i[e]&&t.fields.some(t=>t.path===e)&&(i[e]=i["style.color"]);return i}const Ba=(e,t)=>e.length===t.length&&e.every((e,o)=>e===t[o]);function qa(e,t,o={}){const{draw:n,chart:i}=e,a=e.document;void 0!==o.ids&&o.ids.length>0&&!Ba(o.ids,n.selection())&&n.select(o.ids.slice());let r=n.selection().slice();const s=()=>r.map(e=>n.get(e)).filter(e=>void 0!==e);let l=s();if(0===l.length)return To(e,Pe(e,"Select a drawing first"));let c=Na(l.map(e=>e.tool)),d=et(l[0].tool),u=null,h=null;const p=()=>1===l.length?Pe(e,`schema.drawing.${l[0].tool}.name`,{},d?.name??l[0].tool):Pe(e,"{count} drawings",{count:l.length}),g=()=>0===Xe(n,r).length?Pe(e,"read-only"):null,m=()=>Wa(l[0],c,d,e.chartTheme.lineColor);function f(t){const o=[];for(const e of l){const i=n.get(e.id);if(void 0===i)continue;const a=ve(i,t,c);Object.keys(a).length>0&&o.push({id:e.id,patch:a})}o.length>0&&n.updateMany(o),"string"==typeof t.space&&l.some(e=>(n.get(e.id)?.space??"data")!==t.space)&&e.toast(Pe(e,"The anchor changes only while the drawing's pane is on screen"),"info")}const b=$o(a,{translate:e.translate,title:p(),className:"oac-props",onClose:()=>M.close()}),v=ko(a,"div","oac-props__tools");v.setAttribute("role","toolbar"),v.setAttribute("aria-label",Pe(e,"Drawing actions")),b.el.insertBefore(v,b.body);const w=ko(a,"div","oac-props__pane"),y=ko(a,"div","oac-props__pane oac-props__anchors");let _=o.tab??"style";const x=Mo(a,[{id:"style",label:Pe(e,"Style"),icon:"brush"},{id:"coordinates",label:Pe(e,"Coordinates"),icon:"coordinates"}],_,"row",e=>{_=e,C()});b.body.append(x.el,w,y);let k=null;function C(){w.hidden="style"!==_,y.hidden="coordinates"!==_,"coordinates"===_&&null===k&&(k=Aa(e,y,()=>r,g))}function S(){v.innerHTML="";const t=qo(e,r),o=(t,o,n,i=null)=>{const s=Ao(a,{...t,iconOnly:!0,onClick:()=>{Uo(e,o,r)}});s.dataset.act=o,void 0!==n&&s.setAttribute("aria-pressed",n?"true":"false"),null!==i&&(s.disabled=!0,s.title+=` (${i})`),v.appendChild(s)},n=()=>{v.appendChild(ko(a,"span","oac-sep"))};o({label:Pe(e,"Lock"),icon:t.locked?"lock":"unlock"},"lock",t.locked,t.readOnly),o({label:Pe(e,"Hide"),icon:t.hidden?"eye-off":"eye"},"visible",t.hidden,t.readOnly),n(),o({label:Pe(e,"Bring to front"),icon:"front"},"front"),o({label:Pe(e,"Send to back"),icon:"back"},"back"),o({label:Pe(e,"In front of the series"),icon:"above-series"},"above","above"===t.side),o({label:Pe(e,"Behind the series"),icon:"behind-series"},"behind","behind"===t.side),n(),o({label:Pe(e,"Duplicate"),icon:"duplicate",chord:oo(e.keymap,"duplicate","Mod+D")},"duplicate"),o({label:Pe(e,"Delete"),icon:"trash",chord:oo(e.keymap,"delete","Delete"),variant:"danger"},"delete",void 0,t.noDelete),O.disabled=null!==t.readOnly}function A(){u?.destroy(),w.innerHTML="";const t=xo(c.fields,{translate:e.translate,scope:`drawing.${l[0].tool}`});if(0===t.length)return w.appendChild(ko(a,"div","oac-empty",Pe(e,"These drawings share no settings."))),void(u=null);const o=h=g();if(u=zo(w,t,{values:m(),translate:e.translate,openOverlay:e.openOverlay,idPrefix:"oac-props",unavailable:()=>o,onChange:(e,t)=>{f({[e]:t}),u?.sync(m())},custom:t=>{if("levels"!==t.custom)return null;const n=Ao(a,{label:Pe(e,"Edit levels..."),onClick:t=>{$a(e,t.currentTarget,{ids:r})}});return n.dataset.act="edit-levels",n.disabled=null!==o,n}}),!0===c.textIsContent&&1===l.length){const t=w.querySelector('[data-key="text.value"]');if(null!==t){const n=Ao(a,{label:Pe(e,"Edit text"),icon:"text",onClick:()=>{za(e,0,{id:l[0].id})}});n.dataset.act="edit-text",n.disabled=null!==o,t.appendChild(n)}}}const O=b.lead.appendChild(Ao(a,{label:Pe(e,"Restore defaults"),onClick:()=>{const t={},o=Fa(d,{fields:c.fields},e.chartTheme.lineColor);for(const e of c.fields){if("levels"===e.kind)continue;const[n,i]=e.path.split("."),a="style"===n?d?.defaultStyle:"text"===n?d?.defaultText:void 0,r=void 0===a||void 0===i?void 0:a[i];t[e.path]=void 0===r?void 0:o[e.path]}f(t),u?.sync(m())}})),L=e.drawingTemplates;if(void 0!==L){const t=b.lead.appendChild(Ao(a,{label:Pe(e,"Templates"),onClick:()=>{Ro(e,t,fa(e,L,r,t),{ariaLabel:Pe(e,"Templates")})}}));t.dataset.act="templates",t.setAttribute("aria-haspopup","menu")}function E(){if(!M.isOpen())return;const e=n.selection().slice();if(0!==e.length){if(Ba(e,r))return l=s(),0===l.length?void M.close():(g()!==h?A():u?.sync(m()),S(),void k?.refresh());r=e,l=s(),0!==l.length?(c=Na(l.map(e=>e.tool)),d=et(l[0].tool),b.setTitle(p()),S(),A(),k?.refresh()):M.close()}else M.close()}b.actions.appendChild(Ao(a,{label:Pe(e,"Done"),variant:"primary",onClick:()=>M.close()})),S(),A(),C();const $=[i.on("draw:update",E),i.on("draw:select",E),i.on("draw:remove",E)];let T=!1;const j=()=>{if(!T){T=!0,u?.destroy(),k?.destroy();for(const e of $)e();o.onClose?.()}},P=jo(e,b.el,{...void 0===t?{placement:"below",dismissOnOutside:!0}:{anchor:t,placement:"below"},onClose:j},j);void 0===t&&Io(e.root,b.el,{point:Po(e.root,i,l,e=>n.screenPoints(e))});const M={el:b.el,isOpen:P.isOpen,close:()=>{u?.destroy(),P.close(),j()}};return M}const Ua=ut(()=>import("./openalgo-charts.widget.layouts-templates-menu-DmYVzrWk.mjs"));function Ha(e,t,o={}){const{chart:n}=e,i=e.document,a=O(),r=$o(i,{translate:e.translate,title:Pe(e,"Indicators"),className:"oac-pick",onClose:()=>S.close()}),s=ko(i,"input","oac-pick__find");s.type="search",s.placeholder=Pe(e,"Search indicators"),s.setAttribute("aria-label",Pe(e,"Search indicators")),s.setAttribute("spellcheck","false");const l=ko(i,"div","oac-pick__findwrap");l.appendChild(s);const c=ko(i,"div","oac-pick__list");c.setAttribute("role","listbox"),c.setAttribute("aria-label",Pe(e,"Indicators")),r.body.appendChild(l),r.body.appendChild(c);const d=ko(i,"div","oac-head oac-pick__running-head",Pe(e,"schema.ui.indicatorPicker.running",{},"Running studies")),u=ko(i,"div","oac-pick__running");u.setAttribute("aria-label",Pe(e,"schema.ui.indicatorPicker.running",{},"Running studies")),r.body.appendChild(d),r.body.appendChild(u),r.actions.appendChild(Ao(i,{label:Pe(e,"Done"),variant:"primary",onClick:()=>S.close()}));const h=void 0===o.templates?function(e){return mi.get(e)}(e):o.templates??void 0;let p=null;if(void 0!==h?.planIndicatorTemplateState){const t={waiting:null},o=Ao(i,{label:Pe(e,"Templates"),icon:"template",onClick:()=>{ht(Ua,t=>{p?.close(),p=t.openTemplatesMenu(e,o,h)},t=>e.toast(pt(e,Pe(e,"Templates"),t),"error"),()=>S.isOpen(),{slot:t,doc:i,from:o})}});o.dataset.action="templates",o.setAttribute("aria-haspopup","dialog"),r.lead.appendChild(o)}let g=[],m=-1;const f=e=>n.indicators().filter(t=>t.indicatorId===e).length,b=e=>{0!==g.length?(m=Math.max(0,Math.min(g.length-1,e)),g.forEach((e,t)=>{e.classList.toggle("is-active",t===m),e.setAttribute("aria-selected",t===m?"true":"false")})):m=-1},v=t=>{const i=n.addIndicator(t.id);e.toast(Pe(e,"Added {name}",{name:i.name}),"success"),o.onAdd?.(i),!0!==o.closeOnAdd?(w(),s.focus()):S.close()};function w(){!function(){u.innerHTML="";const t=n.indicators().filter(e=>!1!==e.policy().listed);if(0===t.length)return void u.appendChild(ko(i,"div","oac-empty oac-pick__running-empty",Pe(e,"schema.ui.indicatorPicker.empty",{},"No running studies")));const o=new Map;for(const a of t){const t=(o.get(a.indicatorId)??0)+1;o.set(a.indicatorId,t);const r=ko(i,"div","oac-pick__running-row");r.dataset.instanceId=a.id,r.appendChild(ko(i,"span","oac-pick__running-name",a.name)),r.appendChild(ko(i,"span","oac-pick__running-number",String(t)));const l=Pe(e,"schema.ui.indicatorPicker.remove",{},"Remove"),c=Ao(i,{label:l,onClick:()=>{n.removeIndicator(a.id),w(),s.focus()}});c.classList.add("oac-pick__remove"),c.setAttribute("aria-label",`${l} ${a.name} ${t}`),!1===a.policy().removable&&(c.disabled=!0,c.title=Pe(e,"protected"),c.setAttribute("aria-label",`${l} ${a.name} ${t}, ${Pe(e,"protected")}`)),r.appendChild(c),u.appendChild(r)}}();const t=s.value;if(c.innerHTML="",g=[],0===a.length)return void c.appendChild(ko(i,"div","oac-empty",Pe(e,"No indicators are registered. Import the indicators tier to fill this list.")));const o=function(e,t){const o=t.trim().toLowerCase();return e.filter(e=>""===o||e.name.toLowerCase().includes(o)||e.id.toLowerCase().includes(o)||(e.category??"").toLowerCase().includes(o)).sort((e,t)=>e.name.localeCompare(t.name))}(a.map(t=>({...t,name:Pe(e,`schema.indicator.${t.id}.name`,{},t.name),category:void 0===t.category?void 0:Pe(e,`schema.indicator.category.${t.category}`,{},t.category)})),t);if(0!==o.length){for(const[t,n]of function(e){const t=new Map;for(const o of e){const e=o.category??"Other",n=t.get(e);void 0===n?t.set(e,[o]):n.push(o)}return Array.from(t.entries()).sort((e,t)=>e[0].localeCompare(t[0]))}(o)){c.appendChild(ko(i,"div","oac-head","Other"===t?Pe(e,"Other"):t));for(const t of n){const o=ko(i,"button","oac-pick__row");o.type="button",o.setAttribute("role","option"),o.dataset.id=t.id,o.appendChild(ko(i,"span","oac-pick__name",t.name));const n=f(t.id);if(n>0){const t=ko(i,"span","oac-pick__count",1===n?Pe(e,"on chart"):Pe(e,"on chart x{count}",{count:n}));t.setAttribute("aria-label",1===n?Pe(e,"one instance on the chart"):Pe(e,"{count} instances on the chart",{count:n})),o.appendChild(t)}o.addEventListener("click",e=>{e.stopPropagation(),v(t)}),c.appendChild(o),g.push(o)}}b(m<0?0:m)}else c.appendChild(ko(i,"div","oac-empty",Pe(e,"No match")))}s.addEventListener("input",()=>{m=0,w()}),s.addEventListener("keydown",e=>{const t=e.key;if("ArrowDown"===t)e.preventDefault(),b(m+1);else if("ArrowUp"===t)e.preventDefault(),b(m-1);else if("Enter"===t){e.preventDefault();const t=g[m],o=t?.dataset.id,n=a.find(e=>e.id===o);void 0!==n&&v(n)}}),w();const y=n.on("objects:change",w),_=n.on("indicatorRemoved",w),x=n.on("state:restore:end",w),k=()=>{y(),_(),x(),p?.close()},C=jo(e,r.el,void 0===t?{placement:"center",modal:!0,initialFocus:s}:{anchor:t,placement:"below",initialFocus:s},k),S={el:C.el,isOpen:C.isOpen,close:()=>{C.isOpen()&&(k(),C.close())}};return S}const Ka=e=>e.disabled?e.title:null;function Va(e,t){let o=!1;const n=[],i=[],a=[],r=[],s=t.instance,l=()=>!o&&!e.chart.isDestroyed&&e.chart.indicators().includes(s)&&(t.current?.()??!0);let c=()=>{};const d=()=>{c();const t=e=>{e.detail>0&&(e.preventDefault(),e.stopImmediatePropagation(),c())},o=()=>{e.document.removeEventListener("click",t,!0),e.document.removeEventListener("pointerdown",o,!0),e.document.removeEventListener("keydown",o,!0),c===o&&(c=()=>{})};c=o,e.document.addEventListener("click",t,!0),e.document.addEventListener("pointerdown",o,!0),e.document.addEventListener("keydown",o,!0)};let u=null;const h=()=>{const e=u;e&&(e.finish(),e.cancel?.())},p=e=>{if(!l()||!t.onPatch(e)||!l())return!1;for(const[o,n]of Object.entries(e)){const e=t.field(o);e&&(e.value=String(n??""))}return!0},g=t=>Pe(e,`schema.indicator.${s.indicatorId}.${t.key}.label`,{},t.label);for(const o of t.inputs){const c=t.field(o.key);if(!c)continue;if("symbol"===o.type){const t=Ao(e.document,{label:Pe(e,"Search"),onClick:()=>{l()&&d?.open(c.value)}});t.setAttribute("aria-label",Pe(e,"Search {label}",{label:g(o)})),t.dataset.inputAction=o.key,c.parentElement?.appendChild(t),n.push(t),a.push(()=>{const o=Ka(c)??(void 0===e.symbolSearch?Pe(e,"Symbol search is not configured; enter an instrument manually"):null);t.disabled=null!==o,t.title=o??""});const d=void 0===e.symbolSearch?null:bn(e,c,{search:e.symbolSearch,context:()=>l()?[s.id,e.symbol(),e.interval(),e.chart.getDataContext()]:null,onSelect:(e,t)=>{const n=void 0===o.exchangeKey?{[o.key]:e}:{[o.key]:e,[o.exchangeKey]:t??""};p(n)}});if(d){i.push(d);const e=e=>{d.canCommitRaw()||e.stopImmediatePropagation()};c.addEventListener("change",e,!0),r.push(()=>c.removeEventListener("change",e,!0))}}if("price"!==o.type&&"timestamp"!==o.type||!o.pick)continue;const m=()=>{const n=Ka(c);return null!==n?n:null!==e.draw.activeTool()?Pe(e,"Finish or cancel the active drawing before picking"):t.suspend||e.overlays.suspend?"price"===o.type&&null===Ae(e.chart,s,o.key)?Pe(e,"Choose an explicit pane and scale for this price input"):null:Pe(e,"This host cannot suspend the settings dialog")},f="price"===o.type&&void 0!==o.timeKey?t.inputs.find(e=>e.key===o.timeKey&&"timestamp"===e.type):void 0,b=f?Pe(e,"Pick {time} and {price} on the chart",{time:g(f),price:g(o)}):Pe(e,"Pick {label} on the chart",{label:g(o)}),v=Ao(e.document,{label:Pe(e,f?"Pick point on chart":"Pick on chart"),onClick:()=>{if(!l())return;const n=m();if(null!==n)return void e.toast(n,"info");h();for(const e of i)e.close();const a="price"===o.type?Ae(e.chart,s,o.key):void 0,r=t.suspend?.()??e.overlays.suspend(t.panel),c=ko(e.document,"div","oac-input-pick");c.appendChild(ko(e.document,"span",void 0,b));const g=Ao(e.document,{label:Pe(e,"Cancel pick"),onClick:h});c.appendChild(g),c.addEventListener("pointerdown",e=>e.stopPropagation()),e.overlays.layer.appendChild(c);let w=()=>{};const y=e=>{"Escape"===e.key&&(e.preventDefault(),e.stopImmediatePropagation(),h())},_={cancel:null,finish:()=>{u===_&&(u=null,w(),c.remove(),e.document.removeEventListener("keydown",y,!0),r(),l()&&v.isConnected&&v.focus())}};u=_;let x=!0;e.document.addEventListener("keydown",y,!0),w=e.chart.on("pick:end",e=>{x||(null===e.value?_.finish():queueMicrotask(()=>{u===_&&_.cancel&&!_.cancel.active()&&(d(),_.finish())}))}),g.focus();try{const t=e=>{u===_&&(d(),_.finish(),p(e))},n=f?e.chart.beginPick("point",e=>t({[o.key]:e.price,[f.key]:e.time}),a):e.chart.beginPick("price"===o.type?"price":"time",e=>t({[o.key]:e}),a);_.cancel=n,x=!1,u!==_?n():n.active()||_.finish()}catch(t){_.finish(),e.toast(t instanceof Error?t.message:Pe(e,"The value could not be picked"),"error")}}});v.setAttribute("aria-label",b),v.dataset.inputAction=o.key,c.parentElement?.appendChild(v),n.push(v),a.push(()=>{const e=m();v.disabled=null!==e,v.title=e??""})}const m=()=>{if(!o)for(const e of a)e()},f=e.chart.on("objects:change",()=>{h(),m()}),b=e.chart.on("draw:tool",()=>{h(),m()}),v=e.chart.on("data:context",()=>{h();for(const e of i)e.close()}),w=e.chart.on("indicatorRemoved",()=>{l()||h()}),y=e.chart.on("state:restore:start",h),_=e.chart.on("destroy",h);return m(),{cancelPick:h,refresh:m,destroy:()=>{if(!o){o=!0,h(),c(),f(),b(),v(),w(),y(),_();for(const e of r)e();for(const e of i)e.destroy();for(const e of n)e.remove()}}}}const Ga={source:"Source",indicator:"Indicator",drawing:"Drawing",profile:"Profile",group:"Group"},Ja=["visibility","lock","settings","focus","remove"],Za={loading:"Loading",ready:"Ready",empty:"No data",unsupported:"Unsupported",error:"Could not load"},Ya={select:"Could not select {name}",visibility:"Could not change visibility for {name}",lock:"Could not change lock for {name}",settings:"Could not open settings for {name}",focus:"Could not focus {name}",remove:"Could not remove {name}"};let Qa=0;function Xa(e,t,o=()=>!0){const n=e=>{const o=new Map;for(const n of e)o.set(t(n),(o.get(t(n))??0)+1);return o},i=e.filter(o),a=e.filter(e=>!o(e)),r=n(i),s=n(e),l=new Map;return new Map([...i,...a].map(e=>{const n=t(e),i=(l.get(n)??0)+1;return l.set(n,i),[e.id,((o(e)?r:s).get(n)??0)>1?`${n} (${i})`:n]}))}const er=e=>Xa(e.indicators(),e=>e.name,e=>!1!==e.policy().listed);function tr(e,t={}){const o=t.objects??e.objects;if(void 0===o)throw new Error(Pe(e,"Objects panel requires an object model"));const n=o,i=t=>t===n.primaryPaneIndex()?Pe(e,"Price pane"):Pe(e,"Pane {number}",{number:t+1}),a=e=>i(e.paneIndex),r=t=>Pe(e,`schema.object.kind.${t.kind}`,{},Ga[t.kind]),s=e.document;let l=!1,c=[];const d=new Map,u=ko(s,"div","oac-objects-content"),h=e=>e.stopPropagation();u.addEventListener("pointerdown",h);const p=new Map;let g=null;const m=(t,o,n={})=>Pe(e,`schema.ui.objects.${t}`,n,o),f=ko(s,"input","oac-objects__find");f.type="search",f.placeholder=Pe(e,"Search name, type or pane"),f.setAttribute("aria-label",Pe(e,"Search objects")),f.setAttribute("spellcheck","false");const b=ko(s,"div","oac-objects__list");b.setAttribute("role","list"),b.setAttribute("aria-label",Pe(e,"Chart objects"));const v=ko(s,"div","oac-empty");v.setAttribute("role","status");const w=ko(s,"span","oac-objects__count");w.setAttribute("role","status");const y=ko(s,"p","oac-objects__hint",m("orderHint","Each pane lists back to front. Drag a row, or press Alt with an arrow key, to move it."));u.append(f,y,b,v,w);const _=ko(s,"input","oac-objects__group-name");_.type="text",_.dataset.action="group-name",_.placeholder=m("groupName","Group name"),_.setAttribute("aria-label",m("groupName","Group name"));const x=Ao(s,{label:m("group","Group selected"),onClick:()=>{if(l)return;const e=c.filter(e=>"drawing"===e.kind&&e.selected).map(e=>e.id);n.createGroup(_.value,e)&&(_.value=""),$()}});if(x.dataset.action="group",n.canGroup()){const e=ko(s,"div","oac-objects__grouping");e.append(_,x),u.insertBefore(e,b)}const k=()=>{x.disabled=!_.value.trim()||!c.some(e=>"drawing"===e.kind&&e.selected&&e.capabilities.lock)};function C(t,o){l||(n.move(t,o)||e.toast(m("moveFailed","Could not move object"),"error"),$())}function S(e,t,o){const i=e.getBoundingClientRect();if(i.height>0)return t.clientY<i.top+i.height/2?"below":"above";const a=n.stack(n.get(o)?.paneIndex??-1);return a.findIndex(e=>e.id===g)>a.findIndex(e=>e.id===o)?"below":"above"}function A(){for(const e of d.values())e.el.classList.remove("is-drop-before","is-drop-after")}function O(e,t){const o=n.stack(e.paneIndex),i=o.findIndex(t=>t.id===e.id);if(i<0)return null;if("drawing"===e.kind){const e=o[i+t];return e?{target:e.id,where:1===t?"above":"below"}:null}const a=e=>void 0!==e&&"drawing"!==e.kind;if(-1===t){let e=i-1;for(;e>=0&&!a(o[e])&&"series"===o[e].band;)e--;return a(o[e])?{target:o[e].id,where:"below"}:null}let r=i+1;for(;r<o.length&&"series"===o[r].band&&!a(o[r]);)r++;if(!a(o[r]))return null;let s=r;for(;"series"===o[s+1]?.band&&!a(o[s+1]);)s++;return{target:o[s].id,where:"above"}}function L(t,o,i){if(l)return;const a=n.get(o);let r=!1;try{if(a?.capabilities[t])switch(t){case"select":r=n.select(o,!0===i?.ctrlKey||!0===i?.metaKey);break;case"visibility":r=n.setVisible(o,!a.visible);break;case"lock":r=n.setLocked(o,!a.locked);break;case"settings":r=n.openSettings(o);break;case"focus":r=n.focus(o);break;case"remove":r=n.remove(o)}}catch{}r||e.toast(Pe(e,Ya[t],{name:a?.name??Pe(e,"object")}),"error")}function E(t){const o=ko(s,"div","oac-objects__row");o.dataset.objectId=t.id,o.setAttribute("role","listitem"),o.addEventListener("dragstart",e=>{const o=n.get(t.id);l||!o?.capabilities.place&&!o?.capabilities.reorder?e.preventDefault():(e.stopPropagation(),g=t.id,e.dataTransfer?.setData("text/plain",t.id),e.dataTransfer&&(e.dataTransfer.effectAllowed="move"))}),o.addEventListener("dragend",()=>{g=null,A()}),o.addEventListener("dragleave",()=>{o.classList.remove("is-drop-before","is-drop-after")}),o.addEventListener("dragover",e=>{if(e.stopPropagation(),null===g||g===t.id)return;const i=n.get(g),a=S(o,e,t.id),r=void 0!==i&&(i.paneIndex!==t.paneIndex?!0===i.capabilities.move:n.canPlace(i.id,t.id,a)||void 0===i.band&&i.kind===t.kind&&!0===i.capabilities.reorder);A(),r&&(e.preventDefault(),o.classList.add("below"===a?"is-drop-before":"is-drop-after"))}),o.addEventListener("drop",i=>{i.preventDefault(),i.stopPropagation(),function(t,o){if(A(),l||null===g||g===t)return;const i=n.get(g),a=n.get(t);if(i&&a&&(i.paneIndex===a.paneIndex||i.capabilities.move&&n.move(i.id,a.paneIndex)))if(n.canPlace(i.id,a.id,o))n.place(i.id,a.id,o)||e.toast(m("reorderFailed","Could not reorder object"),"error");else if(i.kind===a.kind&&void 0===i.band)for(let e=0;e<c.length;e++){const e=n.list().filter(e=>e.kind===i.kind&&e.paneIndex===n.get(i.id)?.paneIndex),t=e.findIndex(e=>e.id===i.id),o=e.findIndex(e=>e.id===a.id);if(t<0||o<0||t===o||!n.reorder(i.id,t<o?1:-1))break;if(1===Math.abs(t-o))break}}(t.id,S(o,i,t.id)),g=null}),o.addEventListener("keydown",e=>{const o=e.key;if(!e.altKey||"ArrowUp"!==o&&"ArrowDown"!==o)return;const n=d.get(t.id)?.buttons.get("ArrowUp"===o?"earlier":"later");void 0!==n&&(e.preventDefault(),e.stopPropagation(),n.disabled||n.click())});const i=ko(s,"span","oac-objects__grip");i.setAttribute("aria-hidden","true"),i.innerHTML=oe("grip"),o.appendChild(i);const a=t.capabilities.select?Ao(s,{label:"",onClick:e=>L("select",t.id,e)}):ko(s,"div");a.classList.add("oac-objects__summary"),t.capabilities.select&&(a.dataset.action="select");const r=ko(s,"span","oac-objects__name"),u=ko(s,"span","oac-objects__meta"),h=ko(s,"span","oac-objects__status"),p="oac-object-"+ ++Qa;u.id=`${p}-meta`,h.id=`${p}-status`,t.capabilities.select&&a.setAttribute("aria-describedby",`${u.id} ${h.id}`),a.append(r,u,h);const f=ko(s,"div","oac-objects__actions");o.append(a,f);const b="group"===t.kind?ko(s,"div","oac-objects__members"):void 0;return b&&(b.setAttribute("role","list"),o.appendChild(b)),{el:o,summary:a,name:r,meta:u,status:h,actions:f,selectable:t.capabilities.select,buttons:new Map,members:b}}function $(){if(l)return;const t=f.value.trim().toLowerCase(),o=new Set(c.filter(e=>`${e.name} ${r(e)} ${a(e)}`.toLowerCase().includes(t)).map(e=>e.id));for(const e of c)e.groupId&&o.has(e.groupId)&&o.add(e.id);const u=c.filter(e=>o.has(e.id)||c.some(t=>t.groupId===e.id&&o.has(t.id))),h=new Set(u.map(e=>e.id)),y=s.activeElement,_=null!==y&&b.contains(y);for(const[e,t]of d)h.has(e)||(t.el.remove(),d.delete(e));const x=[...new Set(u.map(e=>e.paneIndex))].sort((e,t)=>e-t);for(const[e,t]of p)x.includes(e)||(t.element.remove(),p.delete(e));x.forEach((e,t)=>{let o=p.get(e);if(!o){const t=ko(s,"section","oac-objects__pane");t.dataset.paneIndex=String(e);const i=ko(s,"h3","oac-objects__pane-title"),a=ko(s,"div");t.append(i,a),t.addEventListener("dragover",e=>{null!==g&&n.get(g)?.capabilities.move&&e.preventDefault()}),t.addEventListener("drop",t=>{t.preventDefault(),null!==g&&n.get(g)?.capabilities.move&&C(g,e),g=null}),o={element:t,rows:a,heading:i},p.set(e,o)}const a=i(e);o.heading.textContent!==a&&(o.heading.textContent=a,o.element.setAttribute("aria-label",a)),b.children[t]!==o.element&&b.insertBefore(o.element,b.children[t]??null)});const S=new Map;for(const e of x)n.stack(e).forEach((e,t)=>S.set(e.id,t));const A=e=>{if(S.has(e.id))return S.get(e.id);const t=c.filter(t=>t.groupId===e.id&&S.has(t.id)).map(e=>S.get(e.id));return t.length?Math.min(...t)-.5:Number.MAX_SAFE_INTEGER},$=u.map((e,t)=>({item:e,index:t})).sort((e,t)=>A(e.item)-A(t.item)||e.index-t.index).map(e=>e.item),T=new Map;$.forEach(t=>{let o=d.get(t.id);void 0!==o&&o.selectable===t.capabilities.select||(o?.el.remove(),o=E(t),d.set(t.id,o)),function(t,o){t.name.textContent=o.name,t.el.draggable=!0===o.capabilities.reorder||!0===o.capabilities.place,t.el.dataset.groupId=o.groupId??"",t.el.classList.toggle("is-group-member",void 0!==o.groupId);const d=[r(o),a(o),o.visible?Pe(e,"Visible"):Pe(e,"Hidden")];if("drawing"===o.kind&&"below"===o.band&&d.push(m("behind","Behind the series")),"drawing"===o.kind&&"series"===o.band){const e=c.find(e=>e.id===o.stackAbove);d.push(m("above","Above {name}",{name:e?.name??m("hidden","a hidden study")}))}if(void 0!==o.locked&&d.push(o.locked?Pe(e,"Locked"):Pe(e,"Unlocked")),o.selected&&d.push(Pe(e,"Selected")),o.groupId){const e=c.find(e=>e.id===o.groupId);e&&d.push(e.name)}t.meta.textContent=d.join(", "),t.el.classList.toggle("is-selected",o.selected),t.selectable&&(t.summary.setAttribute("aria-label",Pe(e,"Select {name}",{name:o.name})),t.summary.setAttribute("aria-pressed",String(o.selected))),t.status.textContent=void 0===o.dataStatus?"":Pe(e,`schema.dataStatus.${o.dataStatus.state}`,{},Za[o.dataStatus.state]),t.status.hidden=void 0===o.dataStatus,t.status.dataset.state=o.dataStatus?.state??"";let u=0;for(const n of Ja){let i=t.buttons.get(n);if(!o.capabilities[n]){i?.remove(),t.buttons.delete(n);continue}void 0===i&&(i=Ao(s,{label:"",variant:"remove"===n?"danger":"ghost",onClick:()=>L(n,o.id)}),i.dataset.action=n,t.buttons.set(n,i));const a="visibility"===n?o.visible?Pe(e,"Hide"):Pe(e,"Show"):"lock"===n?o.locked?Pe(e,"Unlock"):Pe(e,"Lock"):"settings"===n?Pe(e,"Settings"):"focus"===n?Pe(e,"Focus"):"drawing"===o.kind?Pe(e,"Delete"):Pe(e,"Remove");i.textContent=a,i.setAttribute("aria-label",Pe(e,"visibility"===n?o.visible?"Hide {name}":"Show {name}":"lock"===n?o.locked?"Unlock {name}":"Lock {name}":"settings"===n?"Settings for {name}":"focus"===n?"Focus {name}":"drawing"===o.kind?"Delete {name}":"Remove {name}",{name:o.name})),t.actions.children[u]!==i&&t.actions.insertBefore(i,t.actions.children[u]??null),u++}if("drawing"===o.kind&&o.id==="drawing:"+o.sourceId&&n.canGroup()){let e=t.buttons.get("add-selection");e||(e=Ao(s,{label:"",variant:"ghost",onClick:()=>{l||n.select(o.id,!0)}}),e.dataset.action="add-selection",t.buttons.set("add-selection",e)),e.textContent=m(o.selected?"deselect":"selectMore",o.selected?"Deselect":"Select"),e.setAttribute("aria-label",m(o.selected?"deselectLabel":"selectMoreLabel",o.selected?"Remove {name} from selection":"Add {name} to selection",{name:o.name})),t.actions.children[u]!==e&&t.actions.insertBefore(e,t.actions.children[u]??null),u++}for(const[i,a]of[["earlier",-1],["later",1]]){let r=t.buttons.get(i);if(!o.capabilities.reorder&&!o.capabilities.place){r?.remove(),t.buttons.delete(i);continue}r||(r=Ao(s,{label:"",variant:"ghost",onClick:()=>{if(l)return;const t=n.get(o.id),i=void 0!==t?.band?O(t,a):null;(void 0!==t?.band?null!==i&&n.place(o.id,i.target,i.where):n.reorder(o.id,a))||e.toast(m("reorderFailed","Could not reorder object"),"error")}}),r.dataset.action=i,t.buttons.set(i,r)),r.textContent=m(i,-1===a?"Earlier":"Later"),r.setAttribute("aria-label",m(i+"Label",-1===a?"Move {name} earlier":"Move {name} later",{name:o.name}));const c=void 0!==o.band?O(o,a):null;r.disabled=void 0!==o.band?null===c||!n.canPlace(o.id,c.target,c.where):!n.canReorder(o.id,a),t.actions.children[u]!==r&&t.actions.insertBefore(r,t.actions.children[u]??null),u++}if(o.capabilities.move){t.move||(t.move=ko(s,"select","oac-objects__move"),t.move.dataset.action="move",t.move.addEventListener("change",()=>C(o.id,Number(t.move.value)))),t.move.setAttribute("aria-label",m("movePane","Move {name} to pane",{name:o.name}));const e=n.paneCount(),a=Array.from({length:e+1},(t,o)=>o===e?m("newPane","New pane"):i(o));(t.move.children.length!==a.length||a.some((e,o)=>t.move.children[o]?.textContent!==e))&&(t.move.replaceChildren(),a.forEach((e,o)=>{const n=ko(s,"option");n.value=String(o),n.textContent=e,t.move.appendChild(n)})),t.move.value=String(o.paneIndex),t.actions.children[u]!==t.move&&t.actions.insertBefore(t.move,t.actions.children[u]??null),u++}else t.move?.remove(),t.move=void 0;t.actions.hidden=0===u}(o,t);const u=t.groupId?c.find(e=>e.id===t.groupId&&e.paneIndex===t.paneIndex):void 0,h=(u?d.get(u.id)?.members:void 0)??p.get(t.paneIndex).rows,g=T.get(h)??0;h.children[g]!==o.el&&h.insertBefore(o.el,h.children[g]??null),T.set(h,g+1)}),k(),v.hidden=u.length>0,v.textContent=0===c.length?Pe(e,"No objects on this chart."):Pe(e,"No objects match your search.");const j=1===c.length;w.textContent=""===t?Pe(e,j?"{count} object":"{count} objects",{count:c.length}):Pe(e,j?"{shown} of {count} object":"{shown} of {count} objects",{shown:u.length,count:c.length}),_&&(b.contains(y)?s.activeElement!==y&&y.focus():f.focus())}_.addEventListener("input",k),f.addEventListener("input",$);const T=n.subscribe(t=>{if(l)return;const o=new Map((e.draw?.drawings()??[]).map((e,t)=>[e.id,t])),n=e=>"drawing"===e.kind?o.get(e.sourceId)??o.size:-1,i=Xa([...t].sort((e,t)=>n(e)-n(t)),e=>e.name);c=t.map(e=>i.get(e.id)===e.name?e:{...e,name:i.get(e.id)}),$()});return{element:u,initialFocus:f,destroy:()=>{l||(l=!0,T(),u.removeEventListener("pointerdown",h),f.removeEventListener("input",$),_.removeEventListener("input",k),d.clear(),p.clear(),g=null,c=[],t.onClose?.())}}}function or(e,t,o={}){const n=tr(e,o),i=$o(e.document,{translate:e.translate,title:Pe(e,"Objects"),className:"oac-objects",onClose:()=>a.close(),closeText:!0});i.body.appendChild(n.element),i.actions.appendChild(Ao(e.document,{label:Pe(e,"Done"),variant:"primary",onClick:()=>a.close()}));const a=jo(e,i.el,{...void 0===t?{placement:"center",modal:!0}:{anchor:t,placement:"below"},initialFocus:n.initialFocus,onClose:()=>n.destroy()},()=>{});return a}const nr='\n.oac-widget .oac-objects { width: 440px; min-width: 0; }\n.oac-widget .oac-objects .oac-dialog__body { display: flex; flex-direction: column; gap: 8px; overflow: hidden; }\n.oac-widget .oac-objects-content { display: flex; flex-direction: column; min-height: 0; gap: 8px; }\n.oac-widget .oac-objects__pane-title { margin: 6px 2px; color: var(--oac-mut); font-size: 11px; text-transform: uppercase; }\n.oac-widget .oac-objects__grouping { display: flex; gap: 4px; }\n.oac-widget .oac-objects__group-name { min-width: 0; width: 100%; }\n.oac-widget .oac-objects__move { min-width: 90px; max-width: 130px; height: 26px; font-size: 11px; }\n.oac-widget .oac-objects__row.is-group-member { margin-left: 10px; border: 0; border-left: 1px solid var(--oac-bd-soft); border-radius: 0; }\n.oac-widget .oac-objects__members { min-width: 0; }\n.oac-widget .oac-objects__list { scrollbar-width: thin; scrollbar-color: var(--oac-bd-soft) var(--oac-bg); }\n.oac-widget .oac-objects__list::-webkit-scrollbar { width: 6px; }\n.oac-widget .oac-objects__list::-webkit-scrollbar-track { background: var(--oac-bg); }\n.oac-widget .oac-objects__list::-webkit-scrollbar-thumb { background: var(--oac-bd-soft); border-radius: 3px; }\n.oac-widget .oac-objects__list::-webkit-scrollbar-thumb:hover { background: var(--oac-mut); }\n.oac-widget .oac-objects__find { width: 100%; min-width: 0; flex: none; }\n.oac-widget .oac-objects__list { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 2px; }\n.oac-widget .oac-objects__row { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 6px; margin-bottom: 4px;\n border: 1px solid var(--oac-bd-soft); border-radius: 6px; min-width: 0; }\n.oac-widget .oac-objects__row[draggable="true"] { cursor: grab; }\n.oac-widget .oac-objects__grip { display: none; position: absolute; top: 7px; right: 6px; color: var(--oac-faint); line-height: 0; pointer-events: none; }\n.oac-widget .oac-objects__row[draggable="true"] > .oac-objects__grip { display: block; }\n.oac-widget .oac-objects__grip > svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }\n.oac-widget .oac-objects__row[draggable="true"] > .oac-objects__summary { padding-right: 18px; }\n.oac-widget .oac-objects__hint { margin: 0 2px; color: var(--oac-faint); font-size: 11px; line-height: 1.4; }\n.oac-widget .oac-objects__row.is-selected { border-color: var(--oac-acc); background: var(--oac-elev); }\n.oac-widget .oac-objects__row.is-drop-before { box-shadow: inset 0 2px 0 var(--oac-acc); }\n.oac-widget .oac-objects__row.is-drop-after { box-shadow: inset 0 -2px 0 var(--oac-acc); }\n.oac-widget .oac-objects__summary { display: flex; flex-direction: column; align-items: flex-start; justify-content: center;\n gap: 2px; width: 100%; min-width: 0; height: auto; padding: 3px 4px; text-align: left; white-space: normal; }\n.oac-widget .oac-objects__name { font-weight: 600; overflow-wrap: anywhere; }\n.oac-widget .oac-objects__meta, .oac-widget .oac-objects__status { font-size: 11px; color: var(--oac-mut); overflow-wrap: anywhere; }\n.oac-widget .oac-objects__status[data-state="error"] { color: var(--oac-danger); }\n.oac-widget .oac-objects__actions { display: flex; flex-wrap: wrap; gap: 3px; }\n.oac-widget .oac-objects__actions .oac-btn { height: 26px; padding: 0 6px; font-size: 11px; }\n.oac-widget .oac-objects__count { color: var(--oac-mut); font-size: 11px; }\n',ir="@bars";function ar(e){if(null===e||"object"!=typeof e)return!1;const t=e;return"indicator"===t.kind&&"string"==typeof t.instanceId&&"string"==typeof t.plotKey}const rr=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,ar(t)?{...t}:t]));function sr(e){const t=Object.fromEntries(e.map(e=>[e.key,e.default]));for(const o of e)"symbol"!==o.type||void 0===o.exchangeKey||Object.prototype.hasOwnProperty.call(t,o.exchangeKey)||Object.defineProperty(t,o.exchangeKey,{value:"",writable:!0,configurable:!0,enumerable:!0});return t}function lr(e,t,o={}){const n=e.document,i=function(e,t,o){const n=e.chart.indicators(),i=o.instanceId??t?.dataset.instanceId;if(void 0!==i){const t=n.find(e=>e.id===i)??null;return null===t?{inst:null,why:Pe(e,"That indicator is no longer on the chart")}:{inst:t,why:null}}return 1===n.length?{inst:n[0],why:null}:{inst:null,why:0===n.length?Pe(e,"No indicator on the chart to configure"):Pe(e,"Pick an indicator from the legend first")}}(e,t,o);if(null===i.inst)return To(e,i.why??Pe(e,"No indicator to configure"));const a=i.inst;if(!1===a.policy().configurable)return To(e,Pe(e,"{name} settings are protected",{name:a.name}));const r=j(a.indicatorId),s=[],l=e.chart,c=l.primarySeries?.()??null,d=null===c||null===(l.seriesTransform?.(c)??null)?[]:[{key:ir,type:"select",label:"Compute on",default:"chart",options:[{label:"Chart bars",value:"chart"},{label:"Underlying bars",value:"underlying"}]}],u=[...d,...r.inputs];u.length>0&&s.push({id:"inputs",label:Pe(e,"Inputs"),icon:"settings",inputs:u});const h=P(r);if(h.length>0&&s.push({id:"style",label:Pe(e,"Style"),icon:"brush",inputs:h}),0===s.length)return To(e,Pe(e,"{name} has nothing to configure",{name:a.name}));const p=rr(a.settings()),g=d.length>0?a.barSource():"chart",m=new Set,f=e.history?.group("Study settings")??(()=>{});let b=s.some(e=>e.id===o.tab)?o.tab:s[0].id,v=null,w=null,y=null,_=!1,x=()=>{},k=()=>{};const C=()=>!e.chart.isDestroyed&&e.chart.indicators().includes(a),S=t=>{e.toast(t instanceof Error?t.message:Pe(e,"The study settings could not be applied"),"error")},A=()=>Pe(e,"{name} settings are protected",{name:a.name}),O=t=>{if(y=null,!C())return I(),!1;try{const{[ir]:o,...n}=t;if(void 0!==o&&o!==a.barSource()&&!a.setBarSource(o)||Object.keys(n).length>0&&!1===a.setSettings(rr(n)))return y=A(),e.toast(y,"error"),!1}catch(t){return y=t instanceof Error?t.message:Pe(e,"The study settings could not be applied"),S(t),!1}for(const e of Object.keys(t))m.add(e);return o.onChange?.(a),!0},L=$o(n,{translate:e.translate,title:Pe(e,"{name} settings",{name:a.name}),className:"oac-indset",onClose:()=>I()}),E=ko(n,"div","oac-indset__pane");if(s.length>1){const e=Mo(n,s.map(e=>({id:e.id,label:e.label,icon:e.icon})),b,"row",t=>{!v||v.validate()?(b=t,$()):e.setActive(b)});L.body.appendChild(e.el)}function $(){w?.destroy(),w=null,v?.destroy();const t=s.find(e=>e.id===b)??s[0];E.innerHTML="";const o=wo(t.inputs,{translate:e.translate,scope:`indicator.${r.id}`},e.intervals),i=new Map;for(const n of t.inputs){if("source"!==n.type)continue;const t=o.find(e=>e.key===n.key),r=[...t.options??[]],s=new Map,l=er(e.chart);if(n.allowStudyOutputs)for(const t of e.chart.indicators())if(t.id!==a.id)for(const o of j(t.indicatorId).plots){if(o.ohlc)continue;const n=`study-output:${s.size}`;s.set(n,{kind:"indicator",instanceId:t.id,plotKey:o.key});const i=Pe(e,`schema.indicator.${t.indicatorId}.plot.${o.key}`,{},o.title??o.key);r.push({value:n,label:`${l.get(t.id)} / ${i}`})}t.options=r,i.set(n.key,s)}const l=()=>{const t={...M(r),...sr(h),...a.settings(),...d.length>0?{[ir]:a.barSource()}:{}};for(const[n,a]of i){const i=t[n];if(!ar(i))continue;let r=[...a].find(([,e])=>e.instanceId===i.instanceId&&e.plotKey===i.plotKey)?.[0];if(void 0===r){r=`study-output:${a.size}`,a.set(r,{...i});o.find(e=>e.key===n).options.push({value:r,label:Pe(e,"Unavailable study output: {instanceId} / {plotKey}",{instanceId:i.instanceId,plotKey:i.plotKey})})}t[n]=r}return t};v=zo(E,o,{values:l(),translate:e.translate,openOverlay:e.openOverlay,idPrefix:`oac-ind-${a.id}`,live:!0,onChange:(e,o)=>{const a="string"==typeof o?i.get(e)?.get(o):void 0;if(!O({[e]:a?{...a}:o})){if(!C())return;if(t.inputs.some(t=>t.key===e&&["symbol","session","multiline","price","timestamp"].includes(t.type)))return void v?.setError(e,y);const o=n.activeElement?.id;return $(),void(o&&n.getElementById(o)?.focus())}v?.sync(l()),w?.refresh()}}),w=Va(e,{instance:a,inputs:t.inputs,panel:L.el,field:e=>Array.from(E.querySelectorAll("input")).find(t=>t.id===`oac-ind-${a.id}-${e.replace(/[^A-Za-z0-9_-]/g,"-")}`)??null,onPatch:e=>{if(!O(e)){for(const t of Object.keys(e))v?.setError(t,y);return!1}for(const t of Object.keys(e))v?.setError(t,null);return v?.sync(l()),w?.refresh(),!0}})}L.body.appendChild(E),$(),L.lead.appendChild(Ao(n,{label:Pe(e,"Defaults"),onClick:()=>{const e=s.find(e=>e.id===b)??s[0];O(sr(e.inputs))&&$()}})),L.actions.appendChild(Ao(n,{label:Pe(e,"Cancel"),onClick:()=>I()})),L.actions.appendChild(Ao(n,{label:Pe(e,"OK"),variant:"primary",onClick:()=>D()})),L.el.addEventListener("keydown",e=>{"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),I())});const T=jo(e,L.el,{placement:"center",modal:!0,dismissOnEscape:!1,onClose:()=>{x(),k(),w?.destroy(),v?.destroy(),f()}},()=>{I(),T.isOpen()&&(v?.destroy(),T.close(),o.onClose?.(!1))});function I(){T.isOpen()&&function(){if(!C())return e.toast(Pe(e,"That indicator is no longer on the chart"),"info"),!0;if(_||0===m.size)return!0;const t=Object.fromEntries([...m].filter(e=>e!==ir).map(e=>[e,p[e]]));try{(m.has(ir)&&a.barSource()!==g&&!a.setBarSource(g)||Object.keys(t).length>0&&!1===a.setSettings(rr(t)))&&e.toast(A(),"error")}catch(e){return S(e),$(),!1}return m.clear(),o.onChange?.(a),!0}()&&(w?.destroy(),v?.destroy(),T.close(),o.onClose?.(!1))}function D(){T.isOpen()&&(v&&!v.validate()||(_=!0,w?.destroy(),v?.destroy(),T.close(),o.onClose?.(!0)))}return x=e.chart.on("indicatorRemoved",()=>{C()?v?.validate()&&$():I()}),k=e.chart.on("destroy",I),{el:L.el,isOpen:T.isOpen,close:()=>D()}}const cr={price:"chart-candlestick",readout:"legend",axes:"axes",appearance:"panels",trading:"trading"};function dr(t,n,i={}){const{chart:a}=t,r=t.document,s=I(a).filter(e=>e.inputs.length>0),l=e(a),c=new Set;let d=s.some(e=>e.id===i.tab)?i.tab:s[0]?.id??"price",u=null,h=!1;const p=t.history?.group("Chart settings")??(()=>{}),g=e=>{ot(t,void 0,()=>o(a,e))},m=e=>{for(const t of Object.keys(e))c.add(t);g(e),i.onApply?.(e)},f=$o(r,{translate:t.translate,title:Pe(t,"Chart settings"),className:"oac-settings",onClose:()=>k()}),b=ko(r,"div","oac-settings__main"),v=ko(r,"div","oac-settings__pane");f.body.appendChild(b);const w=Mo(r,s.map(e=>({id:e.id,label:Pe(t,`schema.settings.tab.${e.id}`,{},e.label),icon:cr[e.id]})),d,"rail",e=>{d=e,y()});function y(){u?.destroy();const o=s.find(e=>e.id===d);v.innerHTML="",u=null,void 0!==o?u=zo(v,wo(o.inputs,{translate:t.translate,scope:"settings"}),{values:e(a),translate:t.translate,openOverlay:t.openOverlay,idPrefix:"oac-cset",live:!0,unavailable:(e,o)=>"statusLine.openInterest"===e&&!1===a.hasOpenInterest?Pe(t,"Open interest is unavailable for this instrument."):i.unavailable?.(e,o)??null,onChange:(t,o)=>{m({[t]:o}),u?.sync(e(a))}}):v.appendChild(ko(r,"div","oac-empty",Pe(t,"Nothing to configure on this chart yet.")))}b.appendChild(w.el),b.appendChild(v),y(),f.lead.appendChild(Ao(r,{label:Pe(t,"Restore this tab"),onClick:()=>{const e=s.find(e=>e.id===d);void 0!==e&&(m(function(e){const t={};for(const o of e.inputs)"colorPair"===o.type?(t[o.up.key]=o.up.default,t[o.down.key]=o.down.default,void 0!==o.enabled&&(t[o.enabled.key]=o.enabled.default)):t[o.key]=o.default;return t}(e)),y())}})),f.actions.appendChild(Ao(r,{label:Pe(t,"Cancel"),onClick:()=>k()})),f.actions.appendChild(Ao(r,{label:Pe(t,"OK"),variant:"primary",onClick:()=>C()}));const _=a.on("data:context",y),x=jo(t,f.el,{placement:"center",modal:!0,onClose:()=>{_(),u?.destroy(),p()}},()=>k());function k(){x.isOpen()&&(!function(){if(h||0===c.size)return;const e={};for(const t of c){const o=l[t];void 0!==o&&(e[t]=o)}c.clear(),g(e),i.onApply?.(e)}(),u?.destroy(),x.close(),i.onClose?.(!1))}function C(){x.isOpen()&&(h=!0,u?.destroy(),x.close(),i.onClose?.(!0))}return{el:f.el,isOpen:x.isOpen,close:()=>C()}}const ur=[{value:"price",label:"Price"},{value:"indicator",label:"Study plot"},{value:"drawing",label:"Drawing level"},{value:"barCondition",label:"Candle condition"}],hr=(e,t,o)=>({key:e,label:t,kind:"select",options:o}),pr=e=>e.chart.primaryPaneIndex(),gr=(e,t,o)=>t?j(t.indicatorId).plots.filter(n=>void 0===o||(n.overlay?pr(e):t.paneIndex)===o).map(o=>({value:o.key,label:Pe(e,`schema.indicator.${t.indicatorId}.plot.${o.key}`,{},o.title)})):[];function mr(e,t){const o=[hr("kind",Pe(e,"Source"),ur.map(t=>({...t,label:Pe(e,`schema.alert.kind.${t.value}`,{},t.label)})))],n=e.chart.indicators().filter(e=>!1!==e.policy().listed||e.id===t.instanceId||e.id===t.inputInstanceId),i=e.chart.primaryBars(),a=i.length-1,r=(e,o)=>(void 0===t[e]&&(t[e]=o[0]?.value??""),String(t[e])),s=er(e.chart),l=e=>e.map(e=>({value:e.id,label:s.get(e.id)??e.name})),c=t.kind;if("barCondition"===c){const t=D().map(t=>({value:t.id,label:Pe(e,`schema.barCondition.${t.id}.title`,{},t.title)})),n=r("barConditionId",t);return o.push(hr("barConditionId",Pe(e,"Candle condition"),t)),{source:{kind:c,id:n},controls:o,reason:t.some(e=>e.value===n)?void 0:Pe(e,"Candle condition is unavailable")}}if("indicator"===c){const i=r("instanceId",l(n)),s=n.find(e=>e.id===i),d=gr(e,s),u=r("plotKey",d);o.push(hr("instanceId",Pe(e,"Study"),l(n)),hr("plotKey",Pe(e,"Plot"),d));const h=s?.values()[u]?.[a];return"value"in t||(t.value=h??void 0),{source:{kind:c,instanceId:i,plotKey:u,value:t.value,upperValue:t.upperValue},controls:o,reason:s?s.series(u)?void 0:Pe(e,"Study plot is unavailable"):Pe(e,"Study instance is unavailable"),hint:Number.isFinite(h)?void 0:Pe(e,"The current plot value is unavailable. The alert waits for observed values.")}}if("drawing"===c){const i=e.draw.drawings(),a=e=>!1!==e.policy?.listed,s=Xa(i,t=>Pe(e,`schema.drawing.${t.tool}.name`,{},Vo(t.tool)),a),d=i.filter(e=>a(e)||e.id===t.drawingId).map(e=>({value:e.id,label:s.get(e.id)})),u=r("drawingId",d),h=e.draw.alertInfo(u),p=h.levels.map(e=>({value:e.id,label:e.title})),g=r("level",p);o.push(hr("drawingId",Pe(e,"Drawing"),d),hr("level",Pe(e,"Level"),p));const m=n.filter(t=>gr(e,t,h.paneIndex).length>0),f=l(m);h.paneIndex===pr(e)&&f.unshift({value:"",label:Pe(e,"Price")});const b=r("inputInstanceId",f);o.push(hr("inputInstanceId",Pe(e,"Compare with"),f));const v=m.find(e=>e.id===b);let w;if(b){const t=gr(e,v,h.paneIndex),n=r("inputPlotKey",t);w={instanceId:b,plotKey:n},o.push(hr("inputPlotKey",Pe(e,"Input plot"),t))}const y=h.available?p.some(e=>e.value===g)?w?gr(e,v,h.paneIndex).some(e=>e.value===w.plotKey)?void 0:Pe(e,"Select an input plot on the drawing pane"):h.paneIndex!==pr(e)?Pe(e,"Select an input plot on the drawing pane"):void 0:Pe(e,"Drawing level is unavailable"):h.reason;return{source:{kind:c,drawingId:u,level:g,...w?{input:w}:{}},controls:o,reason:y}}return"price"in t||(t.price=i[a]?.close),{source:{kind:"price",price:t.price,upperPrice:t.upperPrice},controls:o}}let fr=0;const br=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/;function vr(e,t){if(void 0===e)return"";const o=ka(e,t,!1);return`${o.date}T${o.time}`}function wr(e,t){if(e)return vr(e.expiresAt,t);const o=g(Math.floor(Date.now()/1e3),t),n=o.month-1+2,i=Math.min(o.day,new Date(Date.UTC(o.year,n+1,0)).getUTCDate()),a=Date.UTC(o.year,n,i,o.hour,o.minute)/1e3,r=a-h(a,t),s=a-h(r,t);return vr(s+h(s,t)===a?s:Math.max(r,s),t)}const yr=e=>{try{return C(e)}catch{return"invalid"}};function _r(e,t,o={}){const n=e.alerts,i=n?.list().find(e=>e.id===o.alertId),a=e.chart.timezone(),r=e.chart.getDataContext(),s=e=>JSON.stringify([e?.symbol,e?.exchange,e?.interval,yr(e?.variant)]),l=s(r),c=e.chart.primaryBars(),d=i?.source??o.source??{kind:"price",price:c[c.length-1]?.close};let u,h=!1,p=!1;const g="oac-alert-"+ ++fr,m=[];let f={...i,...d,..."drawing"===d.kind?{inputInstanceId:d.input?.instanceId,inputPlotKey:d.input?.plotKey}:{},..."barCondition"===d.kind?{barConditionId:d.id}:{},enabled:!i||"armed"===i.state,expiresAt:wr(i,a)};function b(){if(!h){h=!0;for(const e of m.splice(0))e();u?.destroy(),L?.close(),o.onClose?.()}}const v=$o(e.document,{translate:e.translate,title:Pe(e,i?"Edit alert":"Create alert"),className:"oac-alert-editor",onClose:b}),w=ko(e.document,"p","oac-alert-context",[r?.symbol,r?.exchange,r?.interval].filter(Boolean).join(" / ")),y=ko(e.document,"div"),_=ko(e.document,"p","oac-alert-help"),x=ko(e.document,"p","oac-alert-help",Pe(e,"Bar close evaluates confirmed values. Intrabar touch can fire on a wick that is absent from final history.")),k=ko(e.document,"p","oac-alert-error");k.setAttribute("role","status"),v.body.append(w,y,_,x,k);const C=Ao(e.document,{label:Pe(e,"Save"),variant:"primary",onClick:function(){if(h)return;try{const t=A();if(t)throw new Error(t);f={...f,...u.values()};const o=String(f.title??"").trim();if(""===o)throw new Error(Pe(e,"Enter a name"));const r=f.condition,s="enteringRange"===r||"leavingRange"===r,l=mr(e,f).source,c={source:"price"===l.kind?{kind:"price",price:f.price,...s?{upperPrice:f.upperPrice}:{}}:"indicator"===l.kind?{...l,value:f.value,upperValue:s?f.upperValue:void 0}:l,condition:r,title:o,message:String(f.message??"")||void 0,policy:f.policy,repeat:f.repeat,cooldownSeconds:f.cooldownSeconds};i&&f.expiresAt===vr(i.expiresAt,a)||(c.expiresAt=function(e,t,o){if(""===t)return;const n=Pe(e,"Enter an expiry date and time");if("string"!=typeof t||!br.test(t))throw new Error(n);const[i,a]=t.split("T"),r=Ca(i,a,o,{rejectSkipped:!0});if(null===r)throw new Error(n);return r}(e,f.expiresAt,a)),i&&!p||(c.state=f.enabled?"armed":"disabled"),i?n.update(i.id,c):n.add(c),b()}catch(t){k.textContent=t instanceof Error?t.message:Pe(e,"Could not save this alert")}}});C.dataset.action="save-alert";const S=Ao(e.document,{label:Pe(e,"Cancel"),onClick:b});function A(){return n?o.alertId&&!n.list().some(e=>e.id===o.alertId)?Pe(e,"This alert was removed"):s(e.chart.getDataContext())!==l||i&&s(i.scope)!==l?Pe(e,"The instrument context changed. Reopen the editor for the intended instrument."):mr(e,f).reason:Pe(e,"Alerts are unavailable in this host")}function O(){const t=A();k.textContent=t??"",C.disabled=void 0!==t,_.textContent=mr(e,f).hint??""}S.dataset.action="cancel-alert",v.actions.append(S,C),function t(){u?.destroy();const o=mr(e,f),n=z(o.source,f.condition);for(const e of n)e.key in f||(f[e.key]=e.default);f.condition=n.find(e=>"condition"===e.key).default;const i=wo(n,{translate:e.translate,scope:"alert"}),r=i.find(e=>"expiresAt"===e.key);r&&(r.label+=` (${a})`),u=zo(y,[...o.controls,...i],{idPrefix:g,values:f,translate:e.translate,openOverlay:e.openOverlay,preserveInvalidNumbers:!0,onChange:(o,n)=>{f={...f,...u.values(),[o]:n},"enabled"===o&&(p=!0);const i=["kind","instanceId","plotKey","drawingId","level","inputInstanceId"].includes(o);if("kind"===o)for(const e of["price","value","upperPrice","upperValue","condition"])delete f[e];if("instanceId"===o&&(delete f.plotKey,delete f.value,delete f.upperValue),"plotKey"===o&&(delete f.value,delete f.upperValue),"drawingId"===o&&(delete f.level,delete f.inputInstanceId,delete f.inputPlotKey),"inputInstanceId"===o&&delete f.inputPlotKey,"condition"===o||i){const n=null!==e.document.activeElement&&y.contains(e.document.activeElement);t(),n&&y.querySelector(`[data-key="${o}"] select`)?.focus()}O()}});const s=y.querySelector('[data-key="expiresAt"] input');s&&(s.type="datetime-local",s.step="60")}(),O();for(const t of["data:context","data:update","objects:change","alert:removed","alerts:restored"])m.push(e.chart.on(t,O));m.push(e.chart.on("destroy",b));const L=jo(e,v.el,{anchor:t,modal:!0,placement:"center"},b);return{el:v.el,close:b,isOpen:()=>!h&&L.isOpen()}}function xr(e,t,o={}){const n=e.alerts;let i=!1,a=!1;const r=[],s=new Map;function l(){if(!i){i=!0;for(const e of r.splice(0))e();v?.close(),o.onClose?.()}}const c=$o(e.document,{translate:e.translate,title:Pe(e,"Alerts"),className:"oac-alerts",onClose:l,closeText:!0}),d=ko(e.document,"div","oac-alerts__list");d.setAttribute("role","list"),d.setAttribute("aria-label",Pe(e,"Chart alerts"));const u=ko(e.document,"p","oac-empty",Pe(e,n?"No alerts. Create an alert for this chart.":"Alerts are unavailable in this host")),h=ko(e.document,"span","oac-alert-context");h.setAttribute("role","status");const p=Ao(e.document,{label:Pe(e,"Create alert"),variant:"primary",onClick:()=>{_r(e)}});p.dataset.action="create-alert",p.disabled=!n,c.body.append(d,u),c.lead.appendChild(h),c.actions.appendChild(p);const g={armed:Pe(e,"Active"),triggered:Pe(e,"Triggered"),expired:Pe(e,"Expired"),disabled:Pe(e,"Disabled")},m=(e,t,o)=>e.find(e=>e.key===t)?.options?.find(e=>e.value===o)?.label;function f(t){const o=t.source;if("price"===o.kind){const t=t=>e.chart.panes()[e.chart.primaryPaneIndex()]?.readoutScale().format(t)??String(t);return void 0===o.upperPrice?Pe(e,"Price {price}",{price:t(o.price)}):Pe(e,"Price {price} to {upper}",{price:t(o.price),upper:t(o.upperPrice)})}if("barCondition"===o.kind)return N(o.id)?.title??Pe(e,"Unavailable candle condition");if("drawing"===o.kind){const{controls:t}=mr(e,{...o,inputInstanceId:o.input?.instanceId,inputPlotKey:o.input?.plotKey});return`${m(t,"drawingId",o.drawingId)??Pe(e,"Unavailable drawing")} / ${m(t,"level",o.level)??o.level??Pe(e,"Default level")}`}const n=e.chart.indicators().find(e=>e.id===o.instanceId),{controls:i}=mr(e,{kind:"indicator",instanceId:o.instanceId,plotKey:o.plotKey,value:o.value}),a=m(i,"plotKey",o.plotKey)??o.plotKey,r=n?.series(o.plotKey)?.priceScale(),s=e=>r?.format(e)??String(e);return Pe(e,void 0===o.upperValue?"{name} / {plot}: {value}":"{name} / {plot}: {value} to {upper}",{name:m(i,"instanceId",o.instanceId)??Pe(e,"Unavailable study"),plot:a,value:s(o.value),upper:void 0===o.upperValue?"":s(o.upperValue)})}function b(){if(!i&&!a){a=!0;try{const t=n?.list()??[],o=new Set(t.map(e=>e.id));for(const[e,t]of s)o.has(e)||(t.el.remove(),s.delete(e));for(const o of t){let t=s.get(o.id);if(!t){const i=ko(e.document,"div","oac-alerts__row");i.dataset.alertId=o.id,i.setAttribute("role","listitem");const a=ko(e.document,"div","oac-alerts__summary"),r=ko(e.document,"div","oac-alerts__status"),l=ko(e.document,"div","oac-alerts__actions"),c=Ao(e.document,{label:Pe(e,"Edit"),onClick:()=>{_r(e,void 0,{alertId:o.id})}});c.dataset.action="edit-alert";const u=Ao(e.document,{label:Pe(e,"Disable"),onClick:()=>{const e=n?.list().find(e=>e.id===o.id);"armed"===e?.state?n?.disable(o.id):n?.enable(o.id)}});u.dataset.action="toggle-alert";const h=Ao(e.document,{label:Pe(e,"Delete"),onClick:()=>{n?.remove(o.id)}});h.dataset.action="delete-alert",l.append(c,u,h),i.append(a,r,l),d.appendChild(i),t={el:i,summary:a,status:r,toggle:u},s.set(o.id,t)}const i=[o.scope.symbol,o.scope.exchange,o.scope.interval,Xo(e,o.scope.variant)].filter(Boolean).join(" / ");t.summary.textContent=`${o.title}\n${i}\n${f(o)}`,t.el.dataset.state=o.state;const a=n.availability(o.id);t.status.textContent=[g[o.state],"onBarClose"===o.policy?Pe(e,"Bar close"):Pe(e,"Intrabar touch"),"once"===o.repeat?Pe(e,"Once"):Pe(e,"Every match"),o.cooldownSeconds?Pe(e,"{seconds}s cooldown",{seconds:o.cooldownSeconds}):"",void 0===o.expiresAt?"":Pe(e,"Expires {time}",{time:vr(o.expiresAt,e.chart.timezone()).replace("T"," ")}),void 0===o.lastTriggeredAt?"":Pe(e,"Last fired {time}",{time:vr(o.lastTriggeredAt,e.chart.timezone()).replace("T"," ")}),a.available?"":a.reason].filter(Boolean).join(" / "),t.toggle.textContent="armed"===o.state?Pe(e,"Disable"):Pe(e,"Enable"),t.toggle.setAttribute("aria-label",Pe(e,"armed"===o.state?"Disable {name}":"Enable {name}",{name:o.title})),t.toggle.disabled="armed"!==o.state&&void 0!==o.expiresAt&&o.expiresAt<=Date.now()/1e3,t.toggle.title=t.toggle.disabled?Pe(e,"Edit the expiry before enabling this alert"):""}u.hidden=t.length>0,h.textContent=Pe(e,1===t.length?"{count} alert":"{count} alerts",{count:t.length})}finally{a=!1}}}for(const t of["alert:created","alert:updated","alert:removed","alert:triggered","alert:expired","alerts:restored","data:context","data:update","data:range","objects:change","replay:start","replay:stop"])r.push(e.chart.on(t,b));r.push(e.chart.on("destroy",l)),b();const v=jo(e,c.el,{anchor:t,modal:!0,placement:"center"},l);return{el:c.el,close:l,isOpen:()=>!i&&v.isOpen()}}const kr={kind:"separator"},Cr=e=>({kind:"header",label:e}),Sr={linear:"Linear",logarithmic:"Logarithmic",percentage:"Percent","indexed-to-100":"Indexed to 100"};function Ar(e,t,o){const n=e.panes()[t];return void 0===n?String(o):n.readoutScale().format(o)}function Or(e,t,o={}){const{chart:n,draw:i}=e,a=t.target,r=[],s=()=>{r.length>0&&"separator"!==r[r.length-1].kind&&r.push(kr)};if("price-scale"===a.kind)return r.push(...function(e,t,o){const{chart:n}=e,i=()=>n.priceAxisState(t,o),a=i();if(null===a)return[];const r=[];r.push({id:"axis-autofit",label:Pe(e,"Auto-fit to the data"),mark:"check",on:a.autoFit,keepOpen:!0,run:()=>{const e=i();null!==e&&n.setPriceAxisAutoFit(t,o,!e.autoFit)}});const s=()=>{const e=n.primarySeries?.();return null!=e&&e.priceScale()===n.panes()[t]?.scaleFor(o)};s()&&r.push({id:"axis-price-only",label:Pe(e,"Fit primary prices only"),mark:"check",on:n.priceOnlyAutoScale(),keepOpen:!0,run:()=>{s()&&n.setPriceOnlyAutoScale(!n.priceOnlyAutoScale())}}),r.push({id:"axis-invert",label:Pe(e,"Invert"),mark:"check",on:a.inverted,keepOpen:!0,run:()=>{const e=i();null!==e&&n.setPriceAxisOptions(t,o,{inverted:!e.inverted})}}),r.push({id:"axis-lock",label:Pe(e,"Pin price per bar"),mark:"check",on:a.lockRatio,keepOpen:!0,disabled:!a.scaled,note:a.scaled?void 0:Pe(e,"nothing measured"),run:()=>{const a=i();null!==a&&(n.setPriceAxisLockRatio(t,o,!a.lockRatio)||e.toast(Pe(e,"Nothing measured on this scale yet"),"info"))}}),r.push(kr),r.push(Cr(Pe(e,"Scale")));for(const i of R)r.push({id:`axis-mode-${i}`,label:Pe(e,`schema.scaleMode.${i}`,{},Sr[i]),mark:"radio",on:a.mode===i,keepOpen:!0,run:()=>{n.setPriceAxisOptions(t,o,{mode:i})}});const l=n.priceAxisPlacement(t,o),c=e=>n.priceAxisLayout(t).filter(t=>t.side===e).sort((e,t)=>e.order-t.order);if(null!==l&&"hidden"!==l.side){r.push(kr),r.push({id:"axis-move",label:"right"===l.side?Pe(e,"Move the scale to the left"):Pe(e,"Move the scale to the right"),disabled:!a.active,note:a.active?void 0:Pe(e,"nothing on this side"),run:()=>{const a=n.priceAxisPlacement(t,o);i()?.active&&null!==a&&"hidden"!==a.side&&(n.setPriceAxisPlacement(t,o,"right"===a.side?"left":"right")||e.toast(Pe(e,"The scale could not be moved"),"info"))}});const s=c(l.side),d=s.findIndex(e=>e.scaleId===o);if(d>=0&&s.length>1)for(const a of[-1,1])r.push({id:a<0?"axis-closer":"axis-further",label:Pe(e,a<0?"Move the scale closer to the plot":"Move the scale further from the plot"),disabled:void 0===s[d+a],keepOpen:!0,run:()=>{const r=n.priceAxisPlacement(t,o);if(!i()?.active||null===r||"hidden"===r.side)return;const s=c(r.side),l=s.findIndex(e=>e.scaleId===o),d=l<0?void 0:s[l+a];d&&!n.setPriceAxisPlacement(t,o,r.side,d.order)&&e.toast(Pe(e,"The scale could not be moved"),"info")}})}return r.push(kr),r.push({id:"axis-settings",label:Pe(e,"Axis settings..."),icon:"settings",run:()=>{dr(e,0,{tab:"axes"})}}),r}(e,t.paneIndex,a.scaleId??a.side??"right")),r;const l=n.primaryPaneIndex(),c=o.onOrder;if(void 0!==c&&"time-scale"!==a.kind){const i=t.paneIndex===l?t.price:null,a={...e.symbol(),interval:e.interval()},s=t=>F(o.tradingCapabilities,{operation:"place",type:t,mode:o.tradingMode,...e.symbol()}),d=()=>{if(v(n))return Pe(e,"Order entry is locked during replay");try{if(o.tradingLocked?.())return Pe(e,"Order entry is locked by the host")}catch{return Pe(e,"Order entry is unavailable")}},u=d(),h=(o,r)=>({id:`order-${o.toLowerCase()}-${r.toLowerCase()}`,icon:"BUY"===o?"buy":"sell",label:"MARKET"===r?Pe(e,"BUY"===o?"Buy market":"Sell market"):Pe(e,"BUY"===o?"LIMIT"===r?"Buy limit at {price}":"Buy stop at {price}":"LIMIT"===r?"Sell limit at {price}":"Sell stop at {price}",{price:Ar(n,t.paneIndex,i)}),disabled:void 0!==u,note:u,run:()=>{if(n.isDestroyed)return;const l=e.symbol();if(l.symbol!==a.symbol||l.exchange!==a.exchange||e.interval()!==a.interval)return void e.status(Pe(e,"The chart changed; reopen the menu before placing an order"),"error");const u=d();if(void 0!==u)return void e.status(u,"error");const h=s(r);h.supported?c({side:o,type:r,price:"MARKET"===r?null:i,paneIndex:t.paneIndex}):e.status(Pe(e,"Order entry is unavailable: {reason}",{reason:h.reason}),"error")}}),p=(null===i?["MARKET"]:["MARKET","LIMIT","SL"]).map(e=>({type:e,result:s(e)})),g=p.filter(e=>e.result.supported);if(g.length>0){r.push(Cr(Pe(e,"Trade")));for(const{type:e}of g)r.push(h("BUY",e),h("SELL",e))}else{const t=p[0].result;r.push({id:"trading-unavailable",label:Pe(e,"Order entry is unavailable"),disabled:!0,note:t.supported?void 0:t.reason})}}const d=function(e){if("drawing"!==e.kind||null===e.id||!e.id.startsWith("draw:"))return null;const t=e.id.slice(5),o=t.indexOf("#");return o<0?t:t.slice(0,o)}(a),u=null===d?void 0:i.get(d);if(e.alerts&&"time-scale"!==a.kind){if(s(),u){const t=i.alertInfo(u.id);r.push({id:"alert-drawing",label:Pe(e,"Create drawing alert..."),icon:"bell",disabled:!t.available,note:t.reason,run:()=>{_r(e,void 0,{source:{kind:"drawing",drawingId:u.id}})}})}else if("indicator"===a.kind&&a.instanceId){const o=n.indicators().find(e=>e.id===a.instanceId),i=o&&j(o.indicatorId).plots.find(e=>(e.overlay?l:o.paneIndex)===t.paneIndex&&(void 0===a.plotKey||e.key===a.plotKey));o&&i&&r.push({id:"alert-indicator",label:Pe(e,"Create study alert..."),icon:"bell",run:()=>{const a=o.values()[i.key],r=a?.[t.index??n.primaryBars().length-1];_r(e,void 0,{source:{kind:"indicator",instanceId:o.id,plotKey:i.key,value:r??NaN}})}})}else t.paneIndex===l&&null!==t.price&&Number.isFinite(t.price)&&r.push({id:"alert-create",label:Pe(e,"Create alert at {price}...",{price:Ar(n,l,t.price)}),icon:"bell",run:()=>{_r(e,void 0,{source:{kind:"price",price:t.price}})}});r.push({id:"chart-alerts",label:Pe(e,"Alerts..."),run:()=>{xr(e)}})}if(void 0!==u){i.selection().includes(u.id)||i.select(u.id);const t=i.selection().includes(u.id)?i.selection().slice():[u.id];s(),r.push(...function(e,t,o){const{draw:n}=e,i=be(t.tool),a=[],r=qo(e,o),s=t=>()=>{Uo(e,t,o)},l=o.length>1,c=r.editable.length,d=0===c,u=r.readOnly??void 0,h=r.noDelete??void 0;return a.push({id:"draw-props",label:Pe(e,l?"Properties of the selection...":"Properties..."),icon:"settings",run:()=>{qa(e,void 0,{ids:o})}}),!l&&Ia(t)&&a.push({id:"draw-text",label:Pe(e,"Edit text"),icon:"text",disabled:d,note:u,run:()=>{za(e,0,{id:t.id})}}),i.fields.some(e=>"levels"===e.kind)&&a.push({id:"draw-levels",label:Pe(e,"Edit levels..."),disabled:d,note:u,run:()=>{$a(e,void 0,{ids:o})}}),a.push(kr),a.push({id:"draw-copy",label:l?Pe(e,"Copy {count} drawings",{count:o.length}):Pe(e,"Copy drawing"),icon:"copy",chord:oo(e.keymap,"copy","Mod+C"),run:()=>{n.copy(o)}}),a.push({id:"draw-cut",label:c>1?Pe(e,"Cut {count} drawings",{count:c}):Pe(e,"Cut drawing"),chord:oo(e.keymap,"cut","Mod+X"),disabled:void 0!==h,note:h,run:()=>{n.cut(o)}}),a.push({id:"draw-duplicate",label:Pe(e,"Duplicate"),icon:"duplicate",chord:oo(e.keymap,"duplicate","Mod+D"),run:s("duplicate")}),a.push(kr),a.push({id:"draw-lock",label:Pe(e,"Lock"),icon:r.locked?"lock":"unlock",mark:"check",on:r.locked,disabled:d,note:u,run:s("lock")}),a.push({id:"draw-hide",label:Pe(e,"Hide"),icon:r.hidden?"eye-off":"eye",mark:"check",on:r.hidden,disabled:d,note:u,run:s("visible")}),a.push(kr),a.push(Cr(Pe(e,"Order"))),a.push({id:"draw-front",label:Pe(e,"Bring to front"),icon:"front",run:s("front")}),a.push({id:"draw-back",label:Pe(e,"Send to back"),icon:"back",run:s("back")}),a.push({id:"draw-above",label:Pe(e,"In front of the series"),icon:"above-series",mark:"radio",on:"above"===r.side,run:s("above")}),a.push({id:"draw-behind",label:Pe(e,"Behind the series"),icon:"behind-series",mark:"radio",on:"behind"===r.side,run:s("behind")}),a.push(kr),a.push({id:"draw-delete",label:c>1?Pe(e,"Delete {count} drawings",{count:c}):Pe(e,"Delete"),icon:"trash",chord:oo(e.keymap,"delete","Delete"),danger:!0,disabled:void 0!==h,note:h,run:s("delete")}),a}(e,u,t))}if("indicator"===a.kind&&void 0!==a.instanceId){const t=n.indicators().find(e=>e.id===a.instanceId);if(void 0!==t){s();const o=t.policy(),i=t=>!1===o[t]?Pe(e,"protected"):void 0;r.push({id:"ind-settings",label:Pe(e,"{name} settings...",{name:t.name}),icon:"settings",disabled:void 0!==i("configurable"),note:i("configurable"),run:()=>{lr(e,void 0,{instanceId:t.id})}}),r.push({id:"ind-visible",label:t.visible()?Pe(e,"Hide {name}",{name:t.name}):Pe(e,"Show {name}",{name:t.name}),icon:t.visible()?"eye":"eye-off",run:()=>{t.setVisible(!t.visible())}}),r.push({id:"ind-remove",label:Pe(e,"Remove {name}",{name:t.name}),icon:"trash",danger:!0,disabled:void 0!==i("removable"),note:i("removable"),run:()=>{n.removeIndicator(t.id)}})}}if("time-scale"!==a.kind&&!Lr.has(t)){const o=n.panes().length,i=t.paneIndex;if(o>1&&i>=0&&i<o){s();const t=e=>!n.movablePrimaryPane()&&(i===l||e===l),a=(o,a,r,s,l)=>{const c=s?Pe(e,l):t(i+r)?Pe(e,"price pane stays on top"):void 0;return{id:o,label:Pe(e,a),disabled:void 0!==c,note:c,run:()=>{n.movePane(i,r)}}};r.push(a("pane-up","Move pane up",-1,0===i,"at the top")),r.push(a("pane-down","Move pane down",1,i===o-1,"at the bottom"))}if(i!==l&&i>=0&&i<o){const t=n.paneCollapsed(i);s(),r.push({id:"pane-collapse",label:Pe(e,t?"Expand pane":"Collapse pane"),run:()=>{n.setPaneCollapsed(i,!t)}})}}if("time-scale"!==a.kind){s(),r.push({id:"draw-paste",label:Pe(e,"Paste"),icon:"paste",chord:oo(e.keymap,"paste","Mod+V"),run:()=>{i.paste().then(t=>{0===t.length&&e.toast(Pe(e,"Nothing to paste"),"info")})}});const t=i.drawings().filter(e=>!1!==e.policy?.editable).length;t>0&&r.push({id:"draw-clear",label:Pe(e,"Remove all drawings ({count})",{count:t}),icon:"trash",danger:!0,run:()=>{i.clear()}})}s(),r.push({id:"chart-fit",label:Pe(e,"Fit all bars"),icon:"fit",chord:oo(e.keymap,"chart:fitContent"),disabled:!1===n.navigationOptions().zoomEnabled,run:()=>{!1!==n.navigationOptions().zoomEnabled&&n.fitContent()}}),"time-scale"!==a.kind&&r.push({id:"chart-indicators",label:Pe(e,"Indicators..."),icon:"indicators",run:()=>{Ha(e)}}),r.push({id:"chart-settings",label:Pe(e,"Settings..."),icon:"settings",run:()=>{dr(e)}});const h=o.items?.(t)??[];return h.length>0&&(s(),r.push(...h)),r}const Lr=new WeakSet;const Er=new WeakMap;function $r(e,t,o={}){const n=e.document;Er.get(e.root)?.close();const i=o.event??function(e){const t={paneIndex:e.primaryPaneIndex(),point:{x:0,y:0},price:null,time:null,index:null,target:{kind:"empty",id:null},preventDefault:()=>{}};return Lr.add(t),t}(e.chart),a=o.hooks??{},r=ko(n,"div","oac-panel oac-ctx");r.setAttribute("role","menu"),r.setAttribute("aria-label",Pe(e,"Chart menu")),r.tabIndex=-1,Lo(r);let s=[];const l=e=>{const t=s.filter(e=>"true"!==e.getAttribute("aria-disabled"));0!==t.length&&t[(e%t.length+t.length)%t.length].focus()};!function t(o=-1){r.innerHTML="",s=[];const l=Or(e,i,a);for(const o of l){if("separator"===o.kind){r.appendChild(ko(n,"div","oac-ctx__hr"));continue}if("header"===o.kind){r.appendChild(ko(n,"div","oac-head",o.label));continue}const i=o,a=ko(n,"button","oac-ctx__row"+(!0===i.danger?" is-danger":""));a.type="button",a.setAttribute("role","check"===i.mark?"menuitemcheckbox":"radio"===i.mark?"menuitemradio":"menuitem"),void 0!==i.mark&&a.setAttribute("aria-checked",!0===i.on?"true":"false"),void 0!==i.id&&(a.dataset.act=i.id),a.tabIndex=-1;const l=ko(n,"span","oac-ctx__mark");if("radio"===i.mark&&!0===i.on)l.appendChild(ko(n,"span","oac-ctx__dot"));else if("check"===i.mark&&!0===i.on)l.appendChild(So(n,"check"));else if(void 0!==i.icon)if(i.icon.startsWith("<svg")){const e=ko(n,"span","oac-glyph oac-glyph--chrome");e.innerHTML=i.icon,l.appendChild(e)}else l.appendChild(So(n,i.icon));if(a.appendChild(l),a.appendChild(ko(n,"span","oac-ctx__label",i.label)),void 0!==i.note&&""!==i.note&&a.appendChild(ko(n,"span","oac-ctx__note",i.note)),void 0!==i.chord){a.appendChild(ko(n,"kbd","oac-ctx__key",i.chord)).setAttribute("aria-hidden","true"),a.setAttribute("aria-keyshortcuts",to(i.chord))}!0===i.disabled?a.setAttribute("aria-disabled","true"):a.addEventListener("click",o=>{o.stopPropagation(),void 0!==i.run&&ot(e,i.id,i.run),!0===i.keepOpen?t(s.indexOf(a)):d.close()}),r.appendChild(a),s.push(a)}o>=0&&void 0!==s[o]&&s[o].focus()}(),r.addEventListener("keydown",e=>{const t=e.key,o=s.filter(e=>"true"!==e.getAttribute("aria-disabled")),i=o.indexOf(n.activeElement);"ArrowDown"===t?(e.preventDefault(),l(i+1)):"ArrowUp"===t?(e.preventDefault(),l(i<=0?o.length-1:i-1)):"Home"===t?(e.preventDefault(),l(0)):"End"===t&&(e.preventDefault(),l(o.length-1))});const c=s.find(e=>"true"!==e.getAttribute("aria-disabled"))??r,d=jo(e,r,void 0!==t&&void 0===o.event?{anchor:t,placement:"below",initialFocus:c}:{placement:"below",modal:!1,dismissOnOutside:!0,initialFocus:c},()=>{});if(void 0===t||void 0!==o.event){const t=Ma(e.chart),o=null===t?{left:0,top:0}:Ue(e.root,t);Io(e.root,r,{point:{x:i.point.x+o.left,y:i.point.y+o.top}})}return Er.set(e.root,d),d}function Tr(e,t={}){return e.chart.on("contextmenu",o=>{const n=o;n.preventDefault(),$r(e,void 0,{event:n,hooks:t})})}const jr={settings:dr,indicatorPicker:Ha,indicatorSettings:lr,drawingProperties:qa,contextMenu:$r,levelEditor:$a,textEditor:za,alertEditor:_r,alerts:xr};st(jr);const Pr=`\n.oac-widget .oac-alert-editor { width: 480px; }\n.oac-widget .oac-alerts { width: 560px; }\n.oac-widget .oac-alerts__row { padding: 10px 0; border-bottom: 1px solid ${la("bd-soft")}; }\n.oac-widget .oac-alerts__summary { white-space: pre-line; overflow-wrap: anywhere; line-height: 1.5; }\n.oac-widget .oac-alerts__status { color: ${la("mut")}; font-size: 11px; line-height: 1.5; margin: 4px 0 8px; overflow-wrap: anywhere; }\n.oac-widget .oac-alerts__actions { display: flex; flex-wrap: wrap; gap: 6px; }\n.oac-widget .oac-alert-context { margin: 0 0 8px; color: ${la("mut")}; overflow-wrap: anywhere; }\n.oac-widget .oac-alert-help { color: ${la("mut")}; font-size: 11px; line-height: 1.5; margin: 10px 0 0; }\n.oac-widget .oac-alert-error { color: ${la("danger")}; font-size: 12px; margin: 6px 0 0; overflow-wrap: anywhere; }\n.oac-widget .oac-alert-editor input[type=datetime-local] { width: 100%; min-width: 0; color-scheme: inherit;\n height: ${la("ctl-h")}; padding: 0 8px; border: 1px solid ${la("bd")}; border-radius: ${la("radius")};\n background: ${la("elev")}; color: ${la("tx")}; font: inherit; }\n/* Panels: the card a dialog or a popover is built on. */\n.oac-widget .oac-panel { display: flex; flex-direction: column; min-width: 0; max-width: calc(100% - 24px);\n max-height: calc(100% - 24px); background: ${la("panel")}; border: 1px solid ${la("bd")}; border-radius: 12px;\n box-shadow: ${la("shadow")}; outline: none; }\n.oac-widget .oac-dialog__lead, .oac-widget .oac-dialog__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }\n.oac-widget .oac-dialog__actions .oac-btn:not(.oac-btn--primary) { border-color: ${la("bd-soft")}; }\n.oac-widget .oac-empty { padding: 10px 6px; color: ${la("faint")}; }\n\n/* Generated forms: switch column, label, control column. */\n.oac-widget .oac-form { min-width: 0; display: grid; gap: 1px; align-content: start; }\n.oac-widget .oac-form > .oac-head { padding: 10px 0 3px; }\n.oac-widget .oac-form > .oac-head:first-child { padding-top: 2px; }\n.oac-widget .oac-form .oac-row { gap: 8px; min-height: 30px; padding: 1px 0; }\n.oac-widget .oac-row__sw { width: 15px; flex: none; }\n.oac-widget .oac-row__label { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; color: ${la("mut")}; cursor: pointer; }\n/* Every row's control occupies the same column, and the column is one width.\n It was not: a select filled it, a lone number sat at 72px against its right\n edge, and one row widened the column for itself. Reading down the form, the\n left edge of the controls stepped in and out by ninety pixels, which is the\n kind of wrongness a reader feels before they can name it. The column is wide\n enough for a date and time, which is the widest control any of these forms\n puts in it. */\n.oac-widget .oac-row__ctl { display: flex; align-items: center; justify-content: flex-end; gap: 6px; width: min(232px, 58%); min-width: 0; flex: none; }\n/* A number that is the only thing in its column fills it like every other\n control, keeping its digits right aligned. One paired with a slider keeps\n its own width, because there the narrow box is the point. */\n.oac-widget .oac-row__ctl input[type=number] { width: 72px; max-width: 100%; min-width: 0; text-align: right; font-variant-numeric: tabular-nums; }\n.oac-widget .oac-row__ctl > input[type=number]:only-child { width: 100%; }\n.oac-widget .oac-row__ctl input[type=text] { width: 100%; min-width: 0; }\n.oac-widget .oac-row__ctl .oac-select, .oac-widget .oac-row__ctl select { width: 100%; min-width: 0; max-width: 100%; }\n.oac-widget .oac-opacity { min-width: 0; max-width: 100%; display: inline-flex; align-items: center; gap: 6px; }\n.oac-widget .oac-opacity input[type=range] { width: 110px; min-width: 0; }\n.oac-widget .oac-out { min-width: 36px; text-align: right; color: ${la("mut")}; font-variant-numeric: tabular-nums; }\n.oac-widget .oac-row--block { flex-direction: column; align-items: stretch; gap: 4px; }\n.oac-widget .oac-row--block > .oac-row__ctl { width: 100%; }\n.oac-widget .oac-row--block > .oac-row__label { padding-top: 4px; }\n.oac-widget .oac-row--block textarea { width: 100%; min-height: 56px; resize: vertical; }\n.oac-widget .oac-row--off > .oac-row__label { color: ${la("faint")}; cursor: not-allowed; }\n.oac-widget .oac-row input:disabled, .oac-widget .oac-row select:disabled { opacity: .45; pointer-events: none; }\n/* Inline rows: the lead label, then each member's own label and control. The\n control column takes what the label leaves and wraps inside itself, so a\n narrow panel stacks the members rather than scrolling sideways. */\n.oac-widget .oac-row--inline { flex-wrap: wrap; row-gap: 4px; }\n.oac-widget .oac-row--inline > .oac-row__label { flex: 0 1 auto; }\n.oac-widget .oac-row--inline > .oac-row__ctl { width: auto; flex: 1 1 0; min-width: min(100%, 150px); flex-wrap: wrap; row-gap: 4px; }\n.oac-widget .oac-inline__item { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }\n.oac-widget .oac-inline__label { color: ${la("mut")}; white-space: nowrap; cursor: pointer; }\n.oac-widget .oac-inline__item--off > .oac-inline__label { color: ${la("faint")}; cursor: not-allowed; }\n.oac-widget .oac-row--inline .oac-select, .oac-widget .oac-row--inline select { width: auto; }\n.oac-widget .oac-row--inline input[type=text] { width: 96px; }\n\n/* Tab lists: a rail down the left of a settings dialog, or a row above a form. */\n.oac-widget .oac-tabs { min-width: 0; display: flex; gap: 2px; }\n.oac-widget .oac-tabs--rail { flex-direction: column; min-width: 138px; padding: 2px 10px 2px 0; border-right: 1px solid ${la("bd-soft")}; }\n.oac-widget .oac-tabs--row { overflow-x: auto; flex: none; padding: 0 0 6px; margin-bottom: 6px; border-bottom: 1px solid ${la("bd-soft")}; }\n.oac-widget .oac-tab { flex: none; display: flex; align-items: center; gap: 9px; height: 30px; padding: 0 10px; background: transparent;\n border: 1px solid transparent; border-radius: 7px; color: ${la("mut")}; text-align: left; white-space: nowrap; }\n.oac-widget .oac-tab:hover { background: ${la("elev")}; color: ${la("tx")}; }\n.oac-widget .oac-tab[aria-selected="true"] { background: ${la("on-bg")}; border-color: ${la("on-bd")}; color: ${la("acc-2")}; }\n.oac-widget .oac-tabs--row .oac-tab { height: 28px; border-radius: 6px; }\n\n/* Chart settings and indicator settings */\n.oac-widget .oac-settings { width: 600px; }\n.oac-widget .oac-settings__main { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 12px; min-height: 0; }\n.oac-widget .oac-settings__pane { min-width: 0; min-height: 0; padding: 2px 4px 4px 0; }\n.oac-widget .oac-indset { width: 440px; }\n.oac-widget .oac-indset__pane { min-width: 0; padding-right: 4px; }\n\n/* Indicator picker */\n.oac-widget .oac-pick { width: 380px; }\n.oac-widget .oac-pick__findwrap { padding: 2px 0 8px; }\n.oac-widget .oac-pick__find { width: 100%; }\n.oac-widget .oac-pick__list { min-height: 0; display: grid; gap: 1px; align-content: start; }\n.oac-widget .oac-pick__list > .oac-head { padding: 8px 8px 3px; }\n.oac-widget .oac-pick__row { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; background: transparent;\n border: 0; border-radius: 6px; color: ${la("tx")}; text-align: left; }\n.oac-widget .oac-pick__row:hover, .oac-widget .oac-pick__row.is-active { background: ${la("elev-2")}; }\n.oac-widget .oac-pick__name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.oac-widget .oac-pick__count { color: ${la("acc-2")}; font-size: 11px; }\n\n/* Level editor */\n.oac-widget .oac-levels { width: 340px; min-width: 0; padding: 10px 12px 12px; gap: 6px; }\n.oac-widget .oac-levels__head { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }\n.oac-widget .oac-levels__title { flex: 1 1 auto; font-weight: 650; color: ${la("tx-strong")}; }\n.oac-widget .oac-levels__labels { display: inline-flex; align-items: center; gap: 6px; color: ${la("mut")}; cursor: pointer; }\n.oac-widget .oac-levels__rows { min-height: 0; overflow-y: auto; display: grid; gap: 3px; }\n.oac-widget .oac-levels__row { display: grid; grid-template-columns: 15px minmax(48px, 74px) 26px minmax(0, 1fr) 24px; align-items: center; gap: 6px; min-height: 28px; }\n.oac-widget .oac-levels__row input[type=number], .oac-widget .oac-levels__row input[type=text] { width: 100%; height: 26px; }\n.oac-widget .oac-levels__row.is-off input:not([type=checkbox]) { opacity: .45; }\n.oac-widget .oac-levels__x { width: 24px; height: 24px; display: grid; place-items: center; padding: 0; background: transparent;\n border: 0; border-radius: 5px; color: ${la("faint")}; }\n.oac-widget .oac-levels__x:hover { background: ${la("elev-2")}; color: ${la("danger")}; }\n/* A row's remove cross stays a size under the panel's close, so the two do not read as one control. */\n.oac-widget .oac-levels__x > .oac-glyph > svg { width: 12px; height: 12px; }\n.oac-widget .oac-levels__foot { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }\n.oac-widget .oac-levels__foot .oac-spacer { flex: 1 1 auto; }\n\n/* Inline text editor, laid over the painted text. */\n.oac-widget .oac-textedit { position: absolute; z-index: 70; box-sizing: border-box; margin: 0; outline: none; padding: 4px;\n border: 1px solid ${la("acc")}; border-radius: 4px; background: color-mix(in srgb, ${la("bg")} 58%, transparent);\n box-shadow: 0 0 0 3px ${la("ring-soft")}; caret-color: ${la("acc-2")}; cursor: text; overflow: hidden; }\n\n/* Drawing properties */\n.oac-widget .oac-props { width: 340px; }\n.oac-widget .oac-props__tools { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 0 10px 6px; }\n.oac-widget .oac-props__tools .oac-sep { margin: 0 4px; }\n.oac-widget .oac-props__pane { min-width: 0; padding-right: 4px; }\n.oac-widget .oac-props__inline { display: inline-flex; align-items: center; gap: 6px; }\n\n/* Context menu */\n.oac-widget .oac-ctx { min-width: 220px; max-width: 320px; padding: 5px; }\n.oac-widget .oac-ctx > .oac-head { padding: 6px 10px 2px; }\n.oac-widget .oac-ctx__row { display: flex; align-items: center; gap: 8px; width: 100%; padding: 5px 8px; background: transparent;\n border: 0; border-radius: 6px; color: ${la("tx")}; text-align: left; white-space: nowrap; }\n.oac-widget .oac-ctx__row:hover, .oac-widget .oac-ctx__row:focus-visible { background: ${la("elev-2")}; outline: none; }\n.oac-widget .oac-ctx__row:is(:hover, :focus-visible) :is(.oac-ctx__note, .oac-ctx__key) { color: ${la("mut")}; }\n.oac-widget .oac-ctx__row[aria-disabled="true"] { color: ${la("faint")}; cursor: default; background: transparent; }\n.oac-widget .oac-ctx__row.is-danger:not([aria-disabled="true"]):hover { color: ${la("danger")}; }\n.oac-widget .oac-ctx__row[aria-checked="true"] { color: ${la("acc-2")}; }\n.oac-widget .oac-ctx__mark { width: 16px; height: 16px; display: inline-grid; place-items: center; flex: none; color: ${la("mut")}; }\n.oac-widget .oac-ctx__row[aria-checked="true"] .oac-ctx__mark { color: ${la("acc-2")}; }\n.oac-widget .oac-ctx__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }\n.oac-widget .oac-ctx__label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }\n.oac-widget .oac-ctx__note { color: ${la("faint")}; font-size: 11px; }\n.oac-widget .oac-ctx__key { margin-left: 8px; color: ${la("faint")}; }\n.oac-widget .oac-ctx__hr { height: 1px; background: ${la("bd-soft")}; margin: 4px 6px; }\n\n@container oac-widget (max-width: 720px) {\n .oac-widget .oac-settings__main { grid-template-columns: 1fr; }\n .oac-widget .oac-tabs--rail { flex-direction: row; overflow-x: auto; min-width: 0; padding: 0 0 6px; border-right: 0;\n border-bottom: 1px solid ${la("bd-soft")}; }\n .oac-widget .oac-dialog__foot { gap: 6px; }\n .oac-widget .oac-dialog__foot > .oac-spacer { display: none; }\n .oac-widget .oac-dialog__actions { margin-left: auto; }\n}\n`;let Mr=0;function Ir(e,t,o){switch(t.status){case"partial":return t.clipped?Pe(e,"The range is wider than the chart. Showing {from} to {to}",o):"exhausted"===t.history?Pe(e,"History starts at {date}",{date:o.from}):"limited"===t.history?Pe(e,"The history limit stops at {date}",{date:o.from}):"empty"===t.history?Pe(e,"No older bars were found before {date}",{date:o.from}):Pe(e,"Older history cannot load now. Showing from {date}",{date:o.from});case"unsupported":return Pe(e,"Go to needs a time-based interval");case"error":return Pe(e,"Could not load history: {error}",{error:t.error?.message??""});default:return null}}function Dr(e,t,o){const n=e.document,i=e.chart,a=i.timezone(),r=e.interval(),s=wn(r),l="interval"===s?.mode&&s.seconds<86400,c=new Intl.DateTimeFormat(e.locale,{timeZone:a,dateStyle:"medium",...l?{timeStyle:"short"}:{}}),d=e=>c.format(new Date(1e3*e));let u=!1,h=!1,p=!1,g=0,m=null;const f="oac-goto-"+ ++Mr,b=$o(n,{translate:e.translate,title:Pe(e,"Go to"),className:"oac-goto",onClose:D}),v=ko(n,"div","oac-goto__modes");v.setAttribute("role","group"),v.setAttribute("aria-label",Pe(e,"Go to"));const w=(e,t)=>{const o=Ao(n,{label:t,onClick:()=>j("range"===e)});return o.dataset.mode=e,v.appendChild(o),o},y=w("date",Pe(e,"Date")),_=w("range",Pe(e,"Range")),x=e=>{const t=ko(n,"div","oac-goto__row"),o=ko(n,"label","oac-goto__label");o.htmlFor=`${f}-${e}`;const i=ko(n,"input");i.type="date",i.id=`${f}-${e}`;const a=ko(n,"input");return a.type="time",a.hidden=!l,t.append(o,i,a),{row:t,label:o,date:i,time:a}},k=x("from"),C=x("to");l||b.el.classList.add("oac-goto--days");const S=ko(n,"p","oac-goto__hint",Pe(e,l?"Times are in {zone}. A blank time is the start of the day, or its end for To.":"Dates are in {zone}.",{zone:a})),A=ko(n,"p","oac-goto__message");A.setAttribute("role","status"),A.setAttribute("aria-live","polite"),b.body.append(v,k.row,C.row,S,A);const O=Ao(n,{label:Pe(e,"Go"),variant:"primary",onClick:()=>{M()}});O.dataset.action="go-to",b.actions.appendChild(O);for(const e of[k.date,k.time,C.date,C.time])e.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),M())}),e.addEventListener("input",()=>{A.textContent=""});const L=i.getVisibleLogicalRange(),E=[i.dataLayer.indexToTime(Math.max(0,Math.ceil(L.from))),i.dataLayer.indexToTime(Math.min(i.dataLayer.length-1,Math.floor(L.to)))],$=(e,t)=>{if(void 0===t)return;const o=ka(t,a,!1);e.date.value=o.date,e.time.value=l?o.time:""},T=o.pending;function j(t){u=t,C.row.hidden=!t,k.label.textContent=Pe(e,t?"From":"Date"),C.label.textContent=Pe(e,"To"),k.time.setAttribute("aria-label",Pe(e,t?"From time":"Time")),C.time.setAttribute("aria-label",Pe(e,"To time")),y.setAttribute("aria-pressed",String(!t)),_.setAttribute("aria-pressed",String(t)),A.textContent=""}function P(e,t){return Ca(e.date.value,e.time.value,a,t?{blank:"end",end:!0}:{blank:"start"})}async function M(){if(h)return;const t=P(k,!1),n=u?P(C,!0):void 0;if(null===t||null===n)return void(A.textContent=Pe(e,"Enter a valid date"));if(void 0!==n&&n<t)return void(A.textContent=Pe(e,"The end must not be before the start"));const i=void 0===n?{from:t}:{from:t,to:n};await I(i,o.navigate(i))}async function I(t,o){const n=++g;let i;A.textContent=Pe(e,"Loading history"),O.disabled=p=!0;try{i=await o}finally{n===g&&(O.disabled=p=!1)}if(h||n!==g)return;if("cancelled"===i.status)return void(A.textContent="");const a=function(t,o){const n={from:d(t.from??o.from),to:d(t.to??o.to??o.from)};switch(t.status){case"placed":return u?Pe(e,"Showing {from} to {to}",n):Pe(e,"Showing {date}",{date:n.from});case"no-data":return void 0===o.to?Pe(e,"No bars at or after {date}",{date:d(o.from)}):Pe(e,"No bars between {from} and {to}",{from:d(o.from),to:d(o.to)});case"invalid":return Pe(e,"Enter a valid date");default:return Ir(e,t,n)??""}}(i,t),r="error"===i.status||"unsupported"===i.status;e.status(a,r?"error":"info"),"placed"===i.status?D():A.textContent=a}function D(){if(!h){h=!0;for(const e of z)e();m?.close(),o.onClose?.(),p&&Promise.resolve().then(()=>{i.isDestroyed||o.cancel?.()})}}$(k,T?.target.from??E[0]),$(C,void 0===T?E[1]:T.target.to??T.target.from),j(void 0!==T?.target.to);const z=[i.on("destroy",D),i.on("timezone:changed",D),i.on("data:context",()=>{e.interval()!==r&&D()})];return m=jo(e,b.el,{anchor:t,placement:"below",initialFocus:k.date},D),h?m.close():void 0!==T&&I(T.target,T.result),{el:b.el,close:D,isOpen:()=>!h&&m.isOpen()}}const zr=`\n.oac-widget .oac-goto { width: 340px; }\n.oac-widget .oac-goto__modes { display: flex; gap: 4px; margin-bottom: 10px; }\n.oac-widget .oac-goto__row { display: grid; grid-template-columns: 44px minmax(0, 1fr) 96px; align-items: center; gap: 6px; margin: 0 0 6px; }\n.oac-widget .oac-goto--days .oac-goto__row { grid-template-columns: 44px minmax(0, 1fr); }\n.oac-widget .oac-goto__label { color: ${la("mut")}; font-size: 12px; }\n.oac-widget .oac-goto input[type=date], .oac-widget .oac-goto input[type=time] { min-width: 0; height: ${la("ctl-h")}; padding: 0 6px;\n border: 1px solid ${la("bd")}; border-radius: ${la("radius")}; background: ${la("elev")}; color: ${la("tx")}; color-scheme: inherit; }\n.oac-widget .oac-goto__hint { margin: 4px 0 0; color: ${la("faint")}; font-size: 11px; line-height: 1.4; }\n.oac-widget .oac-goto__message { min-height: 16px; margin: 6px 0 0; color: ${la("mut")}; font-size: 12px; overflow-wrap: anywhere; }\n`,Nr=86400,Rr=e=>Object.freeze({...e}),Fr=Object.freeze([Rr({id:"1D",label:"1D",interval:"1m",unit:"session",count:1}),Rr({id:"5D",label:"5D",interval:"5m",unit:"session",count:5}),Rr({id:"1M",label:"1M",interval:"30m",unit:"month",count:1}),Rr({id:"3M",label:"3M",interval:"1h",unit:"month",count:3}),Rr({id:"6M",label:"6M",interval:"1d",unit:"month",count:6}),Rr({id:"YTD",label:"YTD",interval:"1d",unit:"ytd"}),Rr({id:"1Y",label:"1Y",interval:"1d",unit:"year",count:1}),Rr({id:"5Y",label:"5Y",interval:"1w",unit:"year",count:5}),Rr({id:"ALL",label:"All",interval:"1w",unit:"all"})]);function Wr(e){const t=w(e);if(null===t)return null;const o=t.bucketing;if("interval"===o.mode)return o.seconds;if("calendar"!==o.mode)return null;return 30.44*(("year"===o.unit?12:"quarter"===o.unit?3:1)*Math.max(1,Math.floor(o.count??1)))*Nr}function Br(e,t){if(t.includes(e.interval))return e.interval;const o=Wr(e.interval);if(null===o)return e.interval;let n=null,i=1/0,a=0;for(const e of t){const t=Wr(e);if(null===t)continue;const r=Math.abs(Math.log(t/o));(r<i-1e-9||Math.abs(r-i)<=1e-9&&t>a)&&(n=e,i=r,a=t)}return n??e.interval}function qr(e,t){for(let o=1;o<=21;o++){let n=e.sessionFrom(t-o*Nr);if(null===n)return null;if(!(n.open>=t)){for(let o=e.sessionFrom(n.close);null!==o&&o.open<t&&o.open>n.open;o=e.sessionFrom(o.close))n=o;return n}}return null}function Ur(e,t,o){const n=g(e,t);return T(n.year,n.month,n.day-o,0,0,0,t)}function Hr(e,t,o){const n=g(e,t),i=new Date(Date.UTC(n.year,n.month-1-o,1)),a=i.getUTCFullYear(),r=i.getUTCMonth()+1,s=new Date(Date.UTC(a,r,0)).getUTCDate();return T(a,r,Math.min(n.day,s),0,0,0,t)}function Kr(e,t){const o=t.end,n=t.zone??W,i=void 0!==t.bars&&t.bars.length>0?t.bars:null,a=Math.max(1,Math.min(400,Math.floor(e.count??1)));let r;switch(e.unit){case"session":{let e=null;if(t.calendar)try{e=function(e,t,o){let n=e.sessionFrom(t);if((null===n||n.open>t)&&(n=qr(e,t)),null===n)return null;let i=n.date,a=n.open,r=1;for(let t=0;t<12*o+12;t++){const t=qr(e,a);if(null===t)break;if(t.date!==i){if(r>=o)break;r++,i=t.date,a=t.open}else a=t.open}if(e.phaseSpans)try{const t=e.phaseSpans(a-Nr,a),o=t[t.length-1];void 0!==o&&"pre"===o.phase&&o.end===a&&(a=o.start)}catch{}return a}(t.calendar,o,a)}catch{e=null}r=e??(null!==i?function(e,t,o){let n=0,i=NaN,a=e[e.length-1].time;for(let r=e.length-1;r>=0;r--){const s=Ur(e[r].time,t,0);if(s!==i){if(n===o)break;n++,i=s}a=e[r].time}return a}(i,n,a):function(e,t,o){let n=0;for(let i=o,a=g(e,t).weekday;i>0;)n++,a=(a+6)%7,0!==a&&6!==a&&i--;return Ur(e,t,n)}(o,n,a));break}case"month":r=Hr(o,n,a);break;case"year":r=Hr(o,n,12*a);break;case"ytd":{const e=g(o,n);r=T(e.year,1,1,0,0,0,n);break}default:r=null!==i?i[0].time:Hr(o,n,360)}return{from:Math.min(r,o),to:o}}const Vr=28,Gr=[{id:"auto",icon:"scale-auto",key:"schema.ui.bottombar.auto",label:"Auto-fit to the data"},{id:"log",icon:"scale-log",key:"schema.ui.bottombar.log",label:"Logarithmic scale"},{id:"percent",icon:"scale-percent",key:"schema.ui.bottombar.percent",label:"Percent scale"}];function Jr(e){const t=function(e){if(e.isDestroyed)return null;const t=e.primaryPaneIndex(),o=e.panes()[t];if(void 0===o)return null;const n=e.primarySeries();for(const e of["right","left"])if(null!==n&&n.priceScale()===o.scaleFor(e))return{pane:t,id:e};return{pane:t,id:"right"}}(e),o=null===t?null:e.priceAxisState(t.pane,t.id);return null!==t&&null!==o&&o.active?{state:o,...t}:null}function Zr(e,t){const o=Math.max(1,Math.floor(t.count??1));switch(t.unit){case"session":return 1===o?Pe(e,"schema.ui.rangeSpan.session",{},"One trading session"):Pe(e,"schema.ui.rangeSpan.sessions",{count:o},"{count} trading sessions");case"month":return 1===o?Pe(e,"schema.ui.rangeSpan.month",{},"One month"):Pe(e,"schema.ui.rangeSpan.months",{count:o},"{count} months");case"year":return 1===o?Pe(e,"schema.ui.rangeSpan.year",{},"One year"):Pe(e,"schema.ui.rangeSpan.years",{count:o},"{count} years");case"ytd":return Pe(e,"schema.ui.rangeSpan.ytd",{},"Year to date");default:return Pe(e,"schema.ui.rangeSpan.all",{},"All history")}}function Yr(e,t,o={}){const n=e.document,i=()=>(o.now??Date.now)()/1e3,a=o.ranges??Fr,r=()=>o.target?o.target():e.chart?{chart:e.chart}:null,s=()=>{if(h)return null;const e=r()?.chart??null;return null===e||e.isDestroyed?null:e},l=new Set,c=()=>{for(const e of Array.from(l))try{e()}catch{}},d=()=>{N(),c()},u=new sn;let h=!1,p=0;const g={ranges:()=>r()?.setRange?a:[],range:()=>r()?.range?.()??null,setRange:t=>{const o=h?null:r(),n=a.find(e=>e.id===t);if(void 0===o?.setRange||void 0===n||o.chart.isDestroyed)return;const i=++p;let s;try{s=o.setRange(t)}catch(t){return void e.status(Pe(e,"Could not load history: {error}",{error:Me(e,t)}),"error")}d(),Promise.resolve(s).then(t=>{if(h||i!==p||!t||"cancelled"===t.status)return;const a=function(e,t,o,n){const i=t.timezone(),a=t.primaryBars().length>1&&t.primaryBars()[1].time-t.primaryBars()[0].time<86400;let r;try{r=new Intl.DateTimeFormat(e.locale,{timeZone:i,dateStyle:"medium",...a?{timeStyle:"short"}:{}})}catch{r=new Intl.DateTimeFormat(void 0,{timeZone:i,dateStyle:"medium"})}const s=e=>void 0===e?"":r.format(new Date(1e3*e)),l={range:o,from:s(n.from),to:s(n.to)};switch(n.status){case"placed":return Pe(e,"schema.ui.rangeResult.placed",l,"{range}: {from} to {to}");case"no-data":return Pe(e,"schema.ui.rangeResult.empty",{range:o},"No bars for {range}");default:return Ir(e,n,l)??""}}(e,o.chart,n.label,t);""!==a&&e.status(a,"error"===t.status||"unsupported"===t.status?"error":"info"),d()},t=>{h||i!==p||e.status(Pe(e,"Could not load history: {error}",{error:Me(e,t)}),"error")})},marketStatus:()=>{const t=s();if(null===t||!ln(t))return null;const o=i(),n=u.read(t.dataLayer.sessionCalendar,o);return null===n?null:rn(e,n,o,t.timezone())},clock:()=>{const e=s();if(null===e)return"";const t=i();return`${nn(t,e.timezone(),!1)} ${on(t,e.timezone())}`},timezone:()=>s()?.timezone()??"",timezones:()=>{const e=s();if(null===e)return[];const t=o.timezones?[...o.timezones]:function(e){try{for(const t of I(e)){const e=t.inputs.find(e=>"time.timezone"===e.key),o=e?.options;if(o)return o.map(e=>String(e.value))}}catch{}return[e.timezone()]}(e);return t.includes(e.timezone())||t.push(e.timezone()),t},setTimezone:t=>{const n=s();if(null!==n&&t!==n.timezone()){try{n.setTimezone(t)}catch{return void e.status(Pe(e,"schema.ui.bottombar.badZone",{zone:t},"Unknown timezone: {zone}"),"error")}o.onTimezone?.(t),d()}},scale:()=>{const e=s(),t=null===e?null:Jr(e);return null===t?null:{auto:t.state.autoFit,log:"logarithmic"===t.state.mode,percent:"percentage"===t.state.mode}},toggleScale:e=>{const t=s(),o=null===t?null:Jr(t);if(null!==t&&null!==o){if("auto"===e)t.setPriceAxisAutoFit(o.pane,o.id,!o.state.autoFit);else{const n="log"===e?"logarithmic":"percentage";t.setPriceAxisOptions(o.pane,o.id,{mode:o.state.mode===n?"linear":n})}d()}},subscribe:e=>(l.add(e),()=>{l.delete(e)})};t.classList.add("oac-bottombar"),t.setAttribute("role","toolbar"),t.setAttribute("aria-label",Pe(e,"schema.ui.bottombar.label",{},"Range, time and scale"));const m=e=>{e.stopPropagation()};t.addEventListener("pointerdown",m);const f=(e,t)=>De(n,"button",e,{type:"button","aria-label":t}),b=(e,t)=>{e.getAttribute("aria-disabled")!==String(t)&&e.setAttribute("aria-disabled",String(t))},v=(e,t)=>{e.textContent!==t&&(e.textContent=t)},w=new Map;if(a.length>0){const o=De(n,"div","oac-bottombar__group oac-bottombar__ranges",{role:"group","aria-label":Pe(e,"schema.ui.bottombar.ranges",{},"Range")});for(const t of a){const n=Pe(e,`schema.ui.range.${t.id}`,{},t.label),i=Pe(e,"schema.ui.rangeName",{range:n},"Range {range}"),a=f("oac-bottombar__range",i);a.textContent=n,a.dataset.range=t.id,a.setAttribute("aria-pressed","false"),e.tips.attach(a,()=>({title:i,sub:r()?.setRange?Zr(e,t):Pe(e,"schema.ui.bottombar.noRanges",{},"This chart takes no preset ranges"),side:"top"})),a.addEventListener("click",()=>{"true"!==a.getAttribute("aria-disabled")&&g.setRange(t.id)}),o.appendChild(a),w.set(t.id,a)}o.addEventListener("focusin",e=>{e.target.scrollIntoView?.({block:"nearest",inline:"nearest"})}),t.appendChild(o)}let y=null;if(o.onGoTo){a.length>0&&t.appendChild(De(n,"span","oac-sep",{role:"separator"}));const i=f("oac-bottombar__goto",Pe(e,"Go to"));i.appendChild(ze(n,oe("calendar"),"chrome"));const r=De(n,"span");r.textContent=Pe(e,"Go to"),i.appendChild(r),i.setAttribute("aria-haspopup","dialog"),e.tips.attach(i,()=>({title:Pe(e,"Go to"),sub:null===wn(T())?Pe(e,"Go to needs a time-based interval"):void 0,side:"top"})),i.addEventListener("click",()=>{"true"!==i.getAttribute("aria-disabled")&&o.onGoTo?.(i)}),t.appendChild(i),y=i}t.appendChild(De(n,"span","oac-bottombar__spacer"));const _=De(n,"span","oac-bottombar__status",{role:"status"}),x=De(n,"span","oac-bottombar__phase"),k=De(n,"b"),C=De(n,"span","oac-bottombar__detail");_.append(x,k,C),_.hidden=!0,t.appendChild(_);const S=De(n,"span","oac-sep",{role:"separator"});S.hidden=!0,t.appendChild(S);const A=f("oac-bottombar__clock",Pe(e,"schema.ui.bottombar.timezone",{zone:""},"Timezone: {zone}")),O=De(n,"span","oac-bottombar__time"),L=De(n,"small");A.append(O,L),A.setAttribute("aria-haspopup","menu"),e.tips.attach(A,()=>({title:Pe(e,"schema.ui.bottombar.timezone",{zone:g.timezone()},"Timezone: {zone}"),sub:Pe(e,"schema.ui.bottombar.timezoneHint",{},"The zone the time axis and the sessions are read in"),side:"top"})),A.addEventListener("click",()=>function(t){const o=s();if(null===o)return;const n=o.timezone(),a=i(),r=g.timezones(),l=e=>{let t="";try{t=on(a,e)}catch{}return{label:e,sub:t,on:e===n,onSelect:()=>g.setTimezone(e)}},c=function(){const e=Intl;try{return e.supportedValuesOf?.("timeZone")??[]}catch{return[]}}().filter(e=>!r.includes(e)),d=[...r.map(l)];c.length>0&&d.push(Pe(e,"schema.ui.bottombar.allZones",{},"All zones"),...c.map(l));j=Ro(e,t,d,{find:Pe(e,"schema.ui.bottombar.findZone",{},"Find a zone"),ariaLabel:Pe(e,"schema.ui.bottombar.timezones",{},"Timezone")})}(A)),t.appendChild(A),t.appendChild(De(n,"span","oac-sep",{role:"separator"}));const E=De(n,"div","oac-bottombar__group oac-bottombar__scale",{role:"group","aria-label":Pe(e,"schema.ui.bottombar.scale",{},"Price scale")}),$=new Map;for(const t of Gr){const o=Pe(e,t.key,{},t.label),i=f("oac-bottombar__icon",o);i.dataset.scale=t.id,i.setAttribute("aria-pressed","false"),i.appendChild(ze(n,oe(t.icon),"chrome")),e.tips.attach(i,()=>({title:o,sub:null===g.scale()?Pe(e,"schema.ui.bottombar.noScale",{},"Nothing is plotted on the price scale yet"):void 0,side:"top"})),i.addEventListener("click",()=>{"true"!==i.getAttribute("aria-disabled")&&g.toggleScale(t.id)}),E.appendChild(i),$.set(t.id,i)}function T(){const e=r();return e?.interval?.()??e?.chart.getDataContext()?.interval}t.appendChild(E);let j=null;let P="";let M=null;const D=()=>{const e=g.marketStatus();if(_.hidden=null===e,S.hidden=null===e,null===e)return void(M=null);e.phase!==M&&(null!==M&&queueMicrotask(c),M=e.phase,_.dataset.phase=e.phase,x.textContent="",x.appendChild(ze(n,oe(tn[e.phase]),"chrome"))),v(k,e.label),v(C,e.detail);const t=""===e.detail?e.label:`${e.label}, ${e.detail}`;_.getAttribute("aria-label")!==t&&_.setAttribute("aria-label",t)},z=()=>{const e=g.scale();for(const[t,o]of $){const n=null!==e&&e[t];o.getAttribute("aria-pressed")!==String(n)&&o.setAttribute("aria-pressed",String(n)),b(o,null===e)}},N=()=>{h||(!function(){const e=s();if(e===R)return;for(const e of F.splice(0))e();if(R=e,null===e)return;const t=()=>{h||z()},o=()=>{h||(N(),c())};F=[e.on("data:context",o),e.on("timezone:changed",o),e.on("state:restore:end",o),e.on("layout:change",()=>{h||(z(),D())}),e.on("zoom",t),e.on("pan",t),e.on("dblclick",t),e.on("destroy",()=>{h||queueMicrotask(N)})]}(),(()=>{const e=r(),t=e?.range?.()??null;for(const[o,n]of w){const i=o===t;n.getAttribute("aria-pressed")!==String(i)&&n.setAttribute("aria-pressed",String(i)),b(n,void 0===e?.setRange)}null!==y&&b(y,null===e||null===wn(T()))})(),D(),(()=>{const t=s(),o=i(),n=t?.timezone()??"";v(O,null===t?"":nn(o,n)),v(L,null===t?"":on(o,n)),n!==P&&(P=n,e.tips.refreshLabel(A),A.setAttribute("aria-label",Pe(e,"schema.ui.bottombar.timezone",{zone:n},"Timezone: {zone}"))),b(A,null===t)})(),z())};let R=null,F=[];const W=()=>{h||z()};n.addEventListener("pointerup",W,!0);let B=0;const q=()=>{if(0!==B&&clearTimeout(B),B=0,h||!0===n.hidden)return;const e=(o.now??Date.now)();B=setTimeout(U,1e3-(e%1e3+1e3)%1e3+5)};function U(){B=0,h||(N(),q())}const H=()=>{!0!==n.hidden&&N(),q()};return n.addEventListener("visibilitychange",H),N(),q(),{el:t,controls:g,refresh:N,destroy:()=>{if(!h){h=!0,p++,j?.(),null!==e.tips.target()&&t.contains(e.tips.target())&&e.tips.hide(),0!==B&&clearTimeout(B),B=0;for(const e of F.splice(0))e();n.removeEventListener("pointerup",W,!0),n.removeEventListener("visibilitychange",H),t.removeEventListener("pointerdown",m),l.clear(),t.textContent=""}}}}const Qr=`\n.oac-widget.has-bottombar { grid-template-rows: auto minmax(0, 1fr) auto auto; }\n.oac-widget.has-bottombar > .oac-bottombar { grid-row: 3; }\n.oac-widget.has-bottombar > .oac-statusline { grid-row: 4; }\n.oac-widget.has-bottombar:not(.is-mobile) > .oac-toasts { bottom: calc(${la("status-h")} + 38px); }\n.oac-widget.is-mobile > .oac-bottombar:not(.is-kept) { display: none; }\n.oac-widget.is-mobile:has(> .oac-bottombar.is-kept) .oac-mobile__footer { grid-row: 4; }\n.oac-widget.is-mobile:has(> .oac-bottombar.is-kept) > .oac-toasts { bottom: calc(82px + env(safe-area-inset-bottom)); }\n.oac-widget .oac-bottombar { container: oac-bottombar / inline-size; display: flex; align-items: center; gap: 2px;\n height: 28px; min-width: 0; padding: 0 6px; background: ${la("panel")}; border-top: 1px solid ${la("bd-soft")};\n color: ${la("mut")}; font-size: 11.5px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; }\n.oac-widget .oac-bottombar .oac-sep { height: 16px; }\n.oac-widget .oac-bottombar__group { display: inline-flex; align-items: center; gap: 1px; min-width: 0; }\n.oac-widget .oac-bottombar__ranges { flex: 0 1 auto; min-width: 56px; overflow-x: auto; scrollbar-width: none; }\n.oac-widget .oac-bottombar__scale { flex: none; }\n.oac-widget .oac-bottombar__ranges::-webkit-scrollbar { width: 0; height: 0; }\n.oac-widget .oac-bottombar button { display: inline-flex; align-items: center; gap: 5px; flex: none; height: 22px;\n padding: 0 7px; background: transparent; border: 1px solid transparent; border-radius: 5px; color: ${la("mut")};\n font-size: 11.5px; font-weight: 600; letter-spacing: .2px; transition: background .1s, color .1s, border-color .1s; }\n.oac-widget .oac-bottombar button:hover { background: ${la("elev")}; color: ${la("tx")}; }\n.oac-widget .oac-bottombar button[aria-pressed="true"] { background: ${la("on-bg")}; border-color: ${la("on-bd")}; color: ${la("acc-2")}; }\n.oac-widget .oac-bottombar button[aria-disabled="true"] { background: transparent; border-color: transparent; color: ${la("faint")}; cursor: default; }\n.oac-widget .oac-bottombar button:focus-visible { outline-offset: -1px; }\n.oac-widget .oac-bottombar .oac-glyph > svg { width: 14px; height: 14px; }\n.oac-widget .oac-bottombar__icon { width: 24px; padding: 0; justify-content: center; }\n.oac-widget .oac-bottombar__spacer { flex: 1 1 auto; min-width: 6px; }\n.oac-widget .oac-bottombar__status { display: inline-flex; flex: none; align-items: center; gap: 5px; padding: 0 5px; }\n.oac-widget .oac-bottombar__status > b { flex: none; color: ${la("tx")}; font-weight: 600; }\n.oac-widget .oac-bottombar__phase { display: inline-grid; flex: none; color: ${la("faint")}; }\n.oac-widget .oac-bottombar__status[data-phase="regular"] .oac-bottombar__phase { color: ${la("up")}; }\n.oac-widget .oac-bottombar__status:is([data-phase="pre"], [data-phase="post"], [data-phase="extended"]) .oac-bottombar__phase { color: ${la("amber")}; }\n.oac-widget .oac-bottombar__detail { color: ${la("faint")}; }\n.oac-widget .oac-bottombar__clock { color: ${la("tx")}; }\n.oac-widget .oac-bottombar__time { font-weight: 500; }\n.oac-widget .oac-bottombar__clock > small { color: ${la("faint")}; font-size: 10.5px; font-weight: 600; }\n.oac-widget .oac-mobile-sheet__note { grid-column: 1 / -1; margin: 0; padding: 8px 10px 10px; color: ${la("mut")};\n border-bottom: 1px solid ${la("bd-soft")}; margin-bottom: 6px; font-variant-numeric: tabular-nums; }\n.oac-widget .oac-mobile-sheet__note > b { color: ${la("tx")}; font-weight: 600; }\n.oac-widget .oac-mobile-sheet__body > [data-mobile-action="timezone"] { grid-column: 1 / -1; }\n.oac-widget .oac-mobile-sheet__ranges, .oac-widget .oac-mobile-sheet__scales { grid-column: 1 / -1; display: grid; }\n.oac-widget .oac-mobile-sheet__ranges { grid-template-columns: repeat(5, minmax(0, 1fr)); }\n.oac-widget .oac-mobile-sheet__scales { grid-template-columns: repeat(3, minmax(0, 1fr)); }\n.oac-widget .oac-statusline__market[data-phase="regular"] { color: ${la("up")}; }\n@container oac-bottombar (max-width: 760px) {\n .oac-widget .oac-bottombar__detail, .oac-widget .oac-bottombar__goto > span:not(.oac-glyph) { display: none; }\n}\n@container oac-bottombar (max-width: 600px) {\n .oac-widget .oac-bottombar__clock > small { display: none; }\n}\n@container oac-bottombar (max-width: 360px) {\n .oac-widget .oac-bottombar__status > b { display: none; }\n}\n@media (prefers-reduced-motion: reduce) {\n .oac-widget .oac-bottombar button { transition: none; }\n}\n`;const Xr=["tool","interval","chartType","range","scale","zone"];function es(e,t){const o=e.document,n=t.mode??"auto",i=De(o,"div","oac-mobile");e.root.appendChild(i);let a=!1,r=!1,s=!1,l=null,c=null,d=null;const u=[],h=e=>{e.stopPropagation()};i.addEventListener("pointerdown",h);const p=(e,t,n)=>{const i=De(o,"button","oac-mobile__action",{type:"button"});return i.dataset.mobileAction=e,i.textContent=t,i.addEventListener("click",()=>{"true"!==i.getAttribute("aria-disabled")&&n(i)}),i},g=()=>["undo","redo"].map(t=>{const o=p(t,Pe(e,"undo"===t?"Undo":"Redo"),()=>{tt(e,t),O()});return o.setAttribute("aria-disabled",String(!nt(e,t))),o}),m=()=>{const e=d;d=null,e?.close()},f=()=>l?.close(),b=(t,n,i,r=void 0)=>{m();const s=De(o,"section","oac-mobile-sheet",{"aria-label":t}),l=De(o,"div","oac-mobile-sheet__head oac-dialog__head"),c=De(o,"strong","oac-mobile-sheet__title");c.textContent=t;const u=p("close",Pe(e,"Close"),()=>m());l.append(c,u);const h=De(o,"div","oac-mobile-sheet__body");s.append(l,h);const g=()=>{if(a||d?.repaint!==g)return;const e=o.activeElement,t=null!==e&&h.contains(e),n=t?(e=>{const t=e.closest("[data-mobile-action]"),o=t?.dataset.mobileAction;if(null===t||void 0===o)return null;const n={action:o};for(const e of Xr)void 0!==t.dataset[e]&&(n[e]=t.dataset[e]);return n})(e):null,r=h.scrollTop;if(h.textContent="",i(h,m),h.scrollTop=r,t){const e=null===n?null:((e,t)=>Array.from(e.querySelectorAll("[data-mobile-action]")).find(e=>e.dataset.mobileAction===t.action&&Xr.every(o=>e.dataset[o]===t[o]))??null)(h,n);(e??h.querySelector("[data-mobile-action]"))?.focus()}};let f=()=>{};const b={close:()=>f(),repaint:g};d=b,i(h,m),f=e.openOverlay(s,{anchor:n,placement:"center",dismissOnOutside:!0,initialFocus:r,onClose:()=>{d===b&&(d=null)}})};let v=null;if(t.topbar){const n=De(o,"div","oac-mobile__header",{role:"toolbar","aria-label":Pe(e,"Chart header")});c=De(o,"input","oac-mobile__symbol",{type:"text","aria-label":Pe(e,"Symbol"),placeholder:Pe(e,"Symbol"),autocomplete:"off",spellcheck:"false"}),v=p("interval","",o=>{b(Pe(e,"Interval"),o,(e,o)=>{for(const n of t.intervals){const i=p("pick-interval",Ii(n),()=>{t.onInterval(n),o()});i.dataset.interval=n;const a=t.state().interval===n;i.setAttribute("aria-pressed",String(a)),e.appendChild(i)}})});const a=(e,o)=>{const n=e.trim().toUpperCase();f(),""!==n&&t.onSymbol(n,o),O(),c?.blur()};void 0!==t.search&&(l=bn(e,c,{search:t.search,onSelect:a,context:()=>`${t.state().exchange}:${t.state().symbol}:${t.state().interval}`,variant:"mobile"})),c.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),(null===l||l.canCommitRaw())&&a(c?.value??""))}),n.append(c,v),i.appendChild(n)}const w=De(o,"div","oac-mobile__footer"),y=De(o,"div","oac-mobile__selection",{role:"toolbar","aria-label":Pe(e,"Selected drawing")});let _=null,x=null,k=null;null!==t.rail&&(_=p("properties",Pe(e,"Properties"),e=>{t.onProperties(e)}),x=p("lock",Pe(e,"Lock"),()=>{Uo(e,"lock",e.draw.selection()),O()}),k=p("delete",Pe(e,"Delete"),()=>{Uo(e,"delete",e.draw.selection()),O()}),y.append(_,x,k),w.appendChild(y));const C=De(o,"nav","oac-mobile__bar",{"aria-label":Pe(e,"Chart controls")});let S=null,A=null;function O(){if(a)return;const n=t.state();if(null!==c&&o.activeElement!==c&&(c.value=n.symbol),null!==v&&(v.textContent=Ii(n.interval)),null!==S&&S.setAttribute("aria-pressed",String(null!==e.draw.activeTool())),null!==A&&A.setAttribute("aria-disabled",String(!t.indicatorsAvailable())),null!==y.parentNode){const t=e.draw.selection();y.hidden=0===t.length;const o=qo(e,t);t.length>0&&null!==x&&(x.setAttribute("aria-pressed",String(o.locked)),x.setAttribute("aria-disabled",String(0===o.editable.length))),null!==_&&_.setAttribute("aria-disabled",String(0===t.length)),null!==k&&k.setAttribute("aria-disabled",String(null!==o.noDelete||0===o.editable.length))}d?.repaint()}null!==t.rail&&(S=p("draw",Pe(e,"Draw"),n=>{b(Pe(e,"Drawing"),n,n=>{const i=e.draw.activeTool();if(null!==i){const i=De(o,"div","oac-mobile-sheet__controls");i.append(p("finish",Pe(e,"Finish"),()=>{e.draw.finish(),O()}),p("cancel",Pe(e,"Cancel"),()=>{e.draw.cancel(),O()}),...g(),p("magnet",Pe(e,"Magnet: {mode}",{mode:Pe(e,`schema.magnet.${t.rail?.magnetMode()??"off"}`,{},t.rail?.magnetMode()??"off")}),()=>{t.rail?.cycleMagnet(),O()}),p("stay",Pe(e,"Keep tool active: {mode}",{mode:t.rail?.stayMode()?Pe(e,"on"):Pe(e,"off")}),()=>{null!==t.rail&&t.rail.setStayMode(!t.rail.stayMode()),O()})),n.appendChild(i)}const a=void 0===t.tools?null:new Set(t.tools);for(const t of Oe()){if(null!==a&&!a.has(t.id))continue;const o=p("tool",Pe(e,`schema.drawing.${t.id}.name`,{},t.name),()=>{e.draw.setTool(t.id),m()});o.classList.add("oac-mobile__tool"),o.dataset.tool=t.id,o.setAttribute("aria-pressed",String(i===t.id)),n.appendChild(o)}})}),C.appendChild(S)),t.topbar&&t.indicators&&(A=p("studies",Pe(e,"Indicators"),e=>{t.onIndicators(e)}),C.appendChild(A)),t.topbar&&(C.appendChild(p("objects",Pe(e,"Objects"),e=>{t.onObjects(e)})),t.onDataWindow&&C.appendChild(p("data-window",Pe(e,"schema.ui.dataWindow",{},"Data"),e=>{t.onDataWindow?.(e)})),C.appendChild(p("more",Pe(e,"More"),n=>{b(Pe(e,"More"),n,(i,a)=>{const r=t.bottombar;void 0!==r&&i.appendChild(function(e){const t=De(o,"p","oac-mobile-sheet__note"),n=e.marketStatus();if(null!==n){const e=De(o,"b");e.textContent=n.label,t.append(e,o.createTextNode(""===n.detail?" · ":` ${n.detail} · `))}return t.appendChild(o.createTextNode(e.clock())),t}(r)),i.append(...g()),t.onCapture&&i.appendChild(p("capture",Pe(e,"Capture"),()=>{a(),t.onCapture?.(n)})),t.onLayouts&&i.appendChild(p("layouts",Pe(e,"schema.ui.layouts.title",{},"Layouts"),()=>{a(),t.onLayouts?.(n)}));for(const[o,r,s]of[["watchlist","Watchlist",t.onWatchlist],["news","News",t.onNews]])s&&i.appendChild(p(o,Pe(e,`schema.ui.dock.${o}`,{},r),()=>{a(),s(n)}));if(t.onAlerts&&i.appendChild(p("alerts",Pe(e,"Alerts"),()=>{a(),t.onAlerts?.(n)})),t.onGoTo){const o=p("go-to",Pe(e,"Go to"),()=>{a(),t.onGoTo?.(n)});o.setAttribute("aria-disabled",String(null===wn(t.state().interval))),i.appendChild(o)}const s=p("theme","dark"===t.state().theme?Pe(e,"Switch to the light theme"):Pe(e,"Switch to the dark theme"),()=>{t.onTheme(),a()});i.appendChild(s);const l=p("settings",Pe(e,"Chart settings"),()=>{a(),t.onSettings(n)});l.setAttribute("aria-disabled",String(!t.settingsAvailable())),i.appendChild(l);const c=Di(e.chart,e);if(null!==c){const e=De(o,"a","oac-mobile__action oac-mobile__branding",{href:c.href,target:"_blank",rel:"noopener noreferrer","aria-label":c.label});e.dataset.mobileAction="branding",e.textContent=c.label,i.appendChild(e)}void 0!==r&&function(t,n,i,a){const r=e=>{const n=De(o,"div","oac-head");n.textContent=e,t.appendChild(n)},s=(e,n)=>{r(n);const i=De(o,"div",e,{role:"group","aria-label":n});return t.appendChild(i),i},l=n.ranges();if(l.length>0){const t=s("oac-mobile-sheet__ranges",Pe(e,"schema.ui.bottombar.ranges",{},"Range")),o=n.range();for(const i of l){const r=p("range",Pe(e,`schema.ui.range.${i.id}`,{},i.label),()=>{n.setRange(i.id),a()});r.dataset.range=i.id,r.setAttribute("aria-pressed",String(o===i.id)),t.appendChild(r)}}const c=s("oac-mobile-sheet__scales",Pe(e,"schema.ui.bottombar.scale",{},"Price scale")),d=n.scale();for(const t of Gr){const o=p("scale",Pe(e,t.key,{},t.label),()=>{n.toggleScale(t.id),O()});o.dataset.scale=t.id,o.setAttribute("aria-pressed",String(null!==d&&d[t.id])),o.setAttribute("aria-disabled",String(null===d)),c.appendChild(o)}r(Pe(e,"schema.ui.bottombar.timezones",{},"Timezone"));const u=p("timezone",n.timezone(),()=>{b(Pe(e,"schema.ui.bottombar.timezones",{},"Timezone"),i,(e,t)=>{const o=n.timezone();for(const i of n.timezones()){const a=p("pick-zone",i,()=>{n.setTimezone(i),t()});a.dataset.zone=i,a.setAttribute("aria-pressed",String(i===o)),e.appendChild(a)}})});u.setAttribute("aria-label",Pe(e,"schema.ui.bottombar.timezone",{zone:n.timezone()},"Timezone: {zone}")),u.setAttribute("aria-haspopup","dialog"),t.appendChild(u)}(i,r,n,a);const d=De(o,"div","oac-head");d.textContent=Pe(e,"Chart type"),i.appendChild(d);for(const n of Mi()){const r=p("chart-type",Pe(e,`schema.chartType.${n}`,{},Pi(n)),()=>{t.onChartType(n),a()});void 0!==me(n)&&r.prepend(ze(o,oe(`chart-${n}`),"chrome")),r.dataset.chartType=n,r.setAttribute("aria-pressed",String(t.state().chartType===n)),i.appendChild(r)}})}))),C.children.length>0&&w.appendChild(C),w.children.length>0&&i.appendChild(w);const L="auto"===n?o.defaultView?.matchMedia?.("(pointer: coarse)")??null:null,E=t=>null!==t&&e.root.contains(t)&&(/^(INPUT|TEXTAREA)$/.test(t.tagName)||!0===t.isContentEditable);let $=!1;const T=a=>{const l=t.container.getBoundingClientRect(),c=l.width||t.container.clientWidth,d=l.height||t.container.clientHeight;if(s&&!(c*d>0))return;const u=function(e,t,o,n){return"auto"!==e?"always"===e:t>0&&(t<=640||n&&t<=960&&o>0&&o<600)}(n,c,d,!0===L?.matches);s&&u===r?$=!1:s&&!a&&E(o.activeElement)?$=!0:($=!1,s=!0,r=u,e.root.classList.toggle("is-mobile",r),e.root.dataset.mobile=String(r),i.hidden=!r,r||(m(),f()))},j=()=>T(!1),P=o.defaultView?.ResizeObserver;let M=null;if("auto"===n){const t=e=>{$&&!E(e.relatedTarget)&&T(!0)};e.root.addEventListener("focusout",t),u.push(()=>e.root.removeEventListener("focusout",t))}if("auto"===n&&void 0!==P)M=new P(j),M.observe(t.container);else if("auto"===n){const e=o.defaultView;null!==e&&"function"==typeof e.addEventListener&&(e.addEventListener("resize",j),u.push(()=>e.removeEventListener("resize",j)))}null!==L&&("function"==typeof L.addEventListener?(L.addEventListener("change",j),u.push(()=>L.removeEventListener("change",j))):(L.addListener(j),u.push(()=>L.removeListener(j))));for(const t of["draw:tool","draw:select","drawing:select","drawing:change","draw:add","draw:remove","draw:update"])u.push(e.chart.on(t,O));return void 0!==e.history&&u.push(e.history.subscribe(O)),u.push(e.bus.on("symbol",O)),u.push(e.bus.on("interval",O)),u.push(e.bus.on("theme",O)),u.push(e.chart.on("branding:changed",O)),void 0!==t.bottombar&&u.push(t.bottombar.subscribe(O)),j(),O(),{el:i,active:()=>r,refresh:O,destroy:()=>{if(!a){a=!0,l?.destroy(),m(),M?.disconnect(),M=null;for(const e of u.splice(0))e();i.removeEventListener("pointerdown",h),i.remove(),e.root.classList.remove("is-mobile"),delete e.root.dataset.mobile}}}}const ts=[1,1.5,2,3,4],os={solid:"minus",dashed:"line-dashed",dotted:"line-dotted",mixed:"line-mixed"},ns=Symbol("mixed");function is(e,t,o){let n,i=!1;for(const a of e){const e=Wa(a,{fields:[t]},et(a.tool),o)[t.path];if(i){if(JSON.stringify(e)!==JSON.stringify(n))return ns}else n=e,i=!0}return i?n:void 0}let as=0;function rs(e,t,o={}){const{draw:n,chart:i}=e,a=e.document,r="oac-drawbar-"+ ++as,s=ko(a,"div","oac-drawbar");s.setAttribute("role","toolbar"),s.setAttribute("aria-label",Pe(e,"Drawing toolbar")),s.dataset.keyScope="drawing-toolbar",s.hidden=!0;const l=()=>o.chart??Ma(i),c=l(),d=Array.from(t.children),u=null===c?-1:d.indexOf(c);t.insertBefore(s,u<0?null:d[u+1]??null);const h=e=>{e.stopPropagation()};s.addEventListener("pointerdown",h),s.addEventListener("dblclick",h);let p=[],g=[],m=new Map,f=!1,b=!1;const v=(t,o=p)=>{Uo(e,t,o),W()},w=(t,o)=>{if(void 0===m.get(t))return;const i=Xe(n,p).flatMap(e=>{const i=n.get(e),a=void 0===i?{}:ve(i,{[t]:o},be(i.tool));return Object.keys(a).length>0?[{id:e,patch:a}]:[]});ot(e,t,()=>{i.length>0&&n.updateMany(i)}),W()},y=ho(a,{id:`${r}-color`,label:Pe(e,"Color"),value:"#000000",translate:e.translate,openOverlay:e.openOverlay,onChange:e=>{w("style.color",e)}});y.el.classList.add("oac-drawbar__color");const _=y.trigger,x=Ao(a,{label:"",onClick:()=>function(){const t=m.get("style.lineWidth");if(void 0===t)return;const o=is(g,t,e.chartTheme.lineColor);z(x,ts.map(t=>({label:Pe(e,"{value} px",{value:t}),on:o===t,onSelect:()=>w("style.lineWidth",t)})),Pe(e,"Line width"))}()});x.classList.add("oac-drawbar__width"),x.setAttribute("aria-haspopup","menu");const k=Ao(a,{label:"",iconOnly:!0,onClick:()=>function(){const t=m.get("style.lineStyle");if(void 0===t)return;const o=is(g,t,e.chartTheme.lineColor);z(k,Le.map(e=>({label:N(e.value),icon:os[e.value],on:o===e.value,onSelect:()=>w("style.lineStyle",e.value)})),Pe(e,"Line style"))}()});k.setAttribute("aria-haspopup","menu");const C=ko(a,"span","oac-glyph oac-glyph--chrome");k.appendChild(C);const S=Ao(a,{label:Pe(e,"Lock"),icon:"lock",iconOnly:!0,onClick:()=>{v("lock")}}),A=Ao(a,{label:Pe(e,"Delete"),icon:"trash",iconOnly:!0,variant:"danger",onClick:()=>{v("delete")}}),O=Ao(a,{label:Pe(e,"More drawing actions"),icon:"more",iconOnly:!0,onClick:()=>function(){const t=p.slice(),{hidden:n,readOnly:i}=qo(e,t),a=[{label:Pe(e,"Properties..."),icon:"settings",onSelect:()=>{qa(e,void 0,{ids:t})}},{label:Pe(e,"Duplicate"),icon:"duplicate",key:oo(e.keymap,"duplicate","Mod+D"),onSelect:()=>{v("duplicate",t)}},{label:Pe(e,n?"Show":"Hide"),icon:n?"eye-off":"eye",disabled:null!==i,sub:i??void 0,onSelect:()=>{v("visible",t)}},Pe(e,"Order"),{label:Pe(e,"Bring to front"),icon:"front",onSelect:()=>{v("front",t)}},{label:Pe(e,"Send to back"),icon:"back",onSelect:()=>{v("back",t)}},{label:Pe(e,"In front of the series"),icon:"above-series",onSelect:()=>{v("above",t)}},{label:Pe(e,"Behind the series"),icon:"behind-series",onSelect:()=>{v("behind",t)}}];o.templates&&a.push(...fa(e,o.templates,t,O));z(O,a,Pe(e,"More drawing actions"))}()});O.setAttribute("aria-haspopup","menu");const L=()=>ko(a,"span","oac-sep"),E=L();s.append(y.el,x,k,E,S,A,L(),O);for(const[e,t]of[["color",_],["width",x],["style",k],["lock",S],["delete",A],["more",O]])t.dataset.drawbar=e;const $=()=>[_,x,k,S,A,O].filter(e=>!(e.disabled||e.hidden||e===_&&y.el.hidden));let T=O;const j=e=>{T=e;for(const t of[_,x,k,S,A,O])t.tabIndex=t===e?0:-1};s.addEventListener("focusin",e=>{const t=e.target?.closest?.("[data-drawbar]");null!==t&&s.contains(t)&&j(t)});const P=e=>{const t=$();if(0===t.length)return;const o=t[(e%t.length+t.length)%t.length];j(o),o.focus()},M=()=>$().indexOf(a.activeElement),I=(t,o,n,i=!1)=>e.keymap.register(t,o,"drawing-toolbar",{label:n,group:"Drawing toolbar",layered:!0,hidden:i}),D=[I("ArrowRight",()=>{P(M()+1)},"Next control"),I("ArrowLeft",()=>{P(M()-1)},"Previous control"),I("Home",()=>{P(0)},"First control"),I("End",()=>{P($().length-1)},"Last control"),I("ArrowDown",()=>{P(M()+1)},"Next control",!0),I("ArrowUp",()=>{P(M()-1)},"Previous control",!0),I("Shift+ArrowRight",()=>{P(M()+1)},"Next control",!0),I("Shift+ArrowDown",()=>{P(M()+1)},"Next control",!0),I("Shift+ArrowLeft",()=>{P(M()-1)},"Previous control",!0),I("Shift+ArrowUp",()=>{P(M()-1)},"Previous control",!0),I("Escape",()=>{l()?.focus()},"Back to the chart")],z=(t,o,n)=>{Ro(e,t,o,{ariaLabel:n})};const N=t=>Pe(e,"dashed"===t?"Dashed":"dotted"===t?"Dotted":"Solid");const R=()=>{if(s.hidden)return;const e=s.contains(a.activeElement);s.hidden=!0,e&&l()?.focus()};function F(){const e=l();if(null===e||s.hidden)return;const o=Ue(t,e);let i=1/0,a=-1/0,r=1/0,c=-1/0;for(const e of p)for(const t of n.screenPoints(e)??[])Number.isFinite(t.x)&&Number.isFinite(t.y)&&(i=Math.min(i,t.x),a=Math.max(a,t.x),r=Math.min(r,t.y),c=Math.max(c,t.y));const d=s.offsetWidth,u=s.offsetHeight,h=o.left+6,g=Math.max(h,o.right-6-d),m=o.top+6,f=Math.max(m,o.bottom-6-u);let b,v;if(Number.isFinite(i)){const e=o.right-o.left,t=Math.max(0,Math.min(e,i)),n=Math.max(0,Math.min(e,a));b=o.left+(t+n)/2-d/2;const s=o.top+r-10-u,l=o.top+c+10;v=s>=m?s:l<=f?l:s}else b=o.left+(o.right-o.left-d)/2,v=m;s.style.left=`${Math.round(Math.min(g,Math.max(h,b)))}px`,s.style.top=`${Math.round(Math.min(f,Math.max(m,v)))}px`}function W(){b||(p=n.selection().slice(),g=p.map(e=>n.get(e)).filter(e=>void 0!==e),0===g.length||null!==n.activeTool()||f?R():(m=new Map(Na(g.map(e=>e.tool)).fields.map(e=>[e.path,e])),function(){const t=qo(e,p),o=t.readOnly,n=e.chartTheme.lineColor,i=m.get("style.color");if(y.el.hidden=void 0===i,void 0!==i){const t=is(g,i,n);y.el.classList.toggle("is-mixed",t===ns),t!==ns&&y.write(t);const[a,r]=[...new Set(g.map(e=>String(Wa(e,{fields:[i]},et(e.tool),n)["style.color"])))];_.style.backgroundImage=t===ns?`linear-gradient(135deg, ${a} 0 50%, ${r??a} 50% 100%)`:"",_.setAttribute("aria-label",Pe(e,"Color: {value}",t===ns?{value:Pe(e,"mixed")}:{value:String(t??"")})),_.disabled=null!==o,_.title=null===o?Pe(e,"Color"):`${Pe(e,"Color")} (${o})`}const r=m.get("style.lineWidth");if(x.hidden=void 0===r,void 0!==r){const t=is(g,r,n),i=t===ns?Pe(e,"Mixed"):Pe(e,"{value} px",{value:Number(t??1)});x.textContent=i,x.setAttribute("aria-label",Pe(e,"Line width: {value}",{value:t===ns?Pe(e,"mixed"):i})),x.classList.toggle("is-mixed",t===ns),x.disabled=null!==o,x.title=null===o?Pe(e,"Line width"):`${Pe(e,"Line width")} (${o})`}const s=m.get("style.lineStyle");if(k.hidden=void 0===s,void 0!==s){const t=is(g,s,n),i=t===ns?"mixed":"string"==typeof t?t:"solid";C.innerHTML=oe(os[i]??"minus"),k.classList.toggle("is-mixed",t===ns);const a=t===ns?Pe(e,"mixed"):N(i);k.setAttribute("aria-label",Pe(e,"Line style: {style}",{style:a})),k.disabled=null!==o,k.title=null===o?Pe(e,"Line style: {style}",{style:a}):`${Pe(e,"Line style")} (${o})`}E.hidden=y.el.hidden&&x.hidden&&k.hidden,S.replaceChildren(So(a,t.locked?"lock":"unlock")),S.setAttribute("aria-label",Pe(e,"Lock")),S.setAttribute("aria-pressed",t.locked?"true":t.partlyLocked?"mixed":"false"),S.disabled=null!==o,S.title=null===o?Pe(e,"Lock"):`${Pe(e,"Lock")} (${o})`;const l=t.noDelete;A.disabled=null!==l;const c=l??oo(e.keymap,"delete","Delete");A.title=void 0===c?Pe(e,"Delete"):`${Pe(e,"Delete")} (${c})`,$().includes(T)?j(T):j($()[0]??O)}(),s.hidden=!1,F()))}const B=()=>{b||s.hidden||F()},q=[];for(const e of["draw:select","drawing:select","draw:update","draw:remove","draw:add","draw:restore","drawing:change","draw:tool"])q.push(i.on(e,W));for(const e of["pan","zoom","resize","paneResized","paneMoved","paneCollapsed","paneMaximized","paneAdded","paneRemoved","data:update","layout:change"])q.push(i.on(e,B));if(null!==c){const e=e=>{0!==e.buttons&&B()},t={passive:!0};c.addEventListener("pointermove",e,t);for(const e of["pointerup","wheel","dblclick"])c.addEventListener(e,B,t);q.push(()=>{c.removeEventListener("pointermove",e,t);for(const e of["pointerup","wheel","dblclick"])c.removeEventListener(e,B,t)})}q.push(i.on("draw:preview",()=>{f||(f=!0,R())}));for(const e of["draw:preview-clear","drag:end","drag:cancel"])q.push(i.on(e,()=>{f&&(f=!1,W())}));q.push(e.bus.on("theme",W)),void 0!==e.history&&q.push(e.history.subscribe(W));const U=a.defaultView?.ResizeObserver;let H=null;return void 0!==U&&null!==c&&(H=new U(B),H.observe(c)),W(),{el:s,refresh:W,destroy:()=>{if(!b){b=!0;for(const e of q.splice(0))e();for(const e of D.splice(0))e();H?.disconnect(),y.destroy(),s.removeEventListener("pointerdown",h),s.removeEventListener("dblclick",h),s.remove()}}}}const ss='\n.oac-widget .oac-drawbar { position: absolute; z-index: 25; display: flex; align-items: center; gap: 2px; padding: 3px;\n background: var(--oac-panel); border: 1px solid var(--oac-bd); border-radius: 9px; box-shadow: var(--oac-shadow); }\n.oac-widget .oac-drawbar .oac-btn { height: 28px; }\n.oac-widget .oac-drawbar .oac-sep { height: 18px; margin: 0 3px; }\n.oac-widget .oac-drawbar__color { margin: 0 2px; }\n.oac-widget .oac-drawbar__width { min-width: 44px; padding: 0 7px; font-size: 11.5px; font-variant-numeric: tabular-nums; color: var(--oac-tx); }\n.oac-widget .oac-drawbar .is-mixed { color: var(--oac-mut); font-style: italic; }\n.oac-widget .oac-drawbar .oac-btn[aria-pressed="mixed"] { border-color: var(--oac-on-bd); border-style: dashed; }\n.oac-widget.is-mobile .oac-drawbar { display: none; }\n/* The properties dialog edits the same selection in full; two surfaces for it would sit on each other. */\n.oac-widget:has(.oac-layer > .oac-props) .oac-drawbar { visibility: hidden; }\n',ls=(e,t)=>Array.from(e,e=>{const o=e.charCodeAt(0);return o>=32&&127!==o||t&&"\n"===e?e:" "}).join(""),cs=(e,t)=>ls(e,!1).replace(/\s+/g," ").trim().slice(0,t);function ds(e){if(null===e||"object"!=typeof e)return null;const{id:t,time:o}=e,n="string"==typeof e.headline?cs(e.headline,500):"";if("string"!=typeof t||""===t||t.length>256||""===n||"number"!=typeof o||!Number.isFinite(o)||o<=0)return null;const i={id:t,headline:n,time:o},a="string"==typeof e.source?cs(e.source,120):"";""!==a&&(i.source=a);const r="string"==typeof e.summary?(s=e.summary,l=4e3,ls(s.replace(/\r\n?/g,"\n"),!0).trim().slice(0,l)):"";var s,l;return""!==r&&(i.summary=r),"string"==typeof e.url&&e.url.length<=2048&&(i.url=e.url.trim()),i}class us{constructor(e){Object.defineProperty(this,"_feed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pageSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_staleAfter",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_maxItems",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_now",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_onChange",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_instrument",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_status",{enumerable:!0,configurable:!0,writable:!0,value:"idle"}),Object.defineProperty(this,"_items",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_cursor",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_loadingMore",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_refreshFailed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_error",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_loadedAt",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_generation",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_controllers",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"_staleTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),this._feed=e.feed,this._pageSize=Math.max(1,Math.min(100,Math.round(e.pageSize??20))),this._staleAfter=Math.max(0,e.staleAfterMs??3e5),this._maxItems=Math.max(1,Math.round(e.maxItems??500)),this._now=e.now??Date.now,this._onChange=t=>{this._destroyed||e.onChange?.(t)}}setInstrument(e){if(this._destroyed)return;const t=null===e?null:{symbol:e.symbol,exchange:e.exchange},o=this._instrument;t?.symbol===o?.symbol&&t?.exchange===o?.exchange||(this._cancel(),this._instrument=t,this._items=[],this._cursor=null,this._error=null,this._refreshFailed=!1,this._loadedAt=null,this._status="idle",null!==t?this.refresh():this._emit())}async refresh(){if(this._destroyed||null===this._instrument)return;this._cancel(),this._status="loading",this._emit();const e=await this._request();void 0!==e&&(e instanceof Error?(this._error=e.message,this._items.length>0?(this._status="ready",this._refreshFailed=!0):this._status="error"):(this._items=[],this._cursor=this._take(e.items)>0?this._nextCursor(e,void 0):null,this._status=this._items.length>0?"ready":"empty",this._error=null,this._refreshFailed=!1,this._loadedAt=this._now(),this._scheduleStale()),this._emit())}async loadMore(){if(this._destroyed||"ready"!==this._status||null===this._cursor||this._loadingMore)return;const e=this._cursor;this._loadingMore=!0,this._emit();const t=await this._request(e);void 0!==t&&(this._loadingMore=!1,t instanceof Error?this._error=t.message:(this._cursor=this._take(t.items)>0?this._nextCursor(t,e):null,this._error=null),this._emit())}snapshot(){const e=null===this._loadedAt?0:this._now()-this._loadedAt;return{instrument:null===this._instrument?null:{...this._instrument},status:this._status,items:this._items.slice(),hasMore:null!==this._cursor,loadingMore:this._loadingMore,stale:this._refreshFailed||null!==this._loadedAt&&e>this._staleAfter,refreshFailed:this._refreshFailed,error:this._error,loadedAt:this._loadedAt}}destroy(){this._destroyed||(this._cancel(),this._destroyed=!0)}async _request(e){const t=this._instrument,o=this._generation,n=new AbortController;this._controllers.add(n);try{const i=await this._feed.getNews({symbol:t.symbol,exchange:t.exchange,limit:this._pageSize,...void 0===e?{}:{cursor:e},signal:n.signal});if(o!==this._generation||this._destroyed)return;return null!==i&&"object"==typeof i&&Array.isArray(i.items)?i:new Error("The news source returned no page")}catch(e){return o!==this._generation||this._destroyed?void 0:new Error((e=>Me({},e))(e))}finally{this._controllers.delete(n)}}_take(e){const t=new Set(this._items.map(e=>e.id));let o=0;for(const n of e){const e=ds(n);null===e||t.has(e.id)||(t.add(e.id),this._items.push(e),o++)}return this._items.sort((e,t)=>t.time-e.time),this._items.length>=this._maxItems?(this._items.length=this._maxItems,0):o}_nextCursor(e,t){const o=e.nextCursor;return"string"==typeof o&&""!==o&&o!==t?o:null}_cancel(){this._generation++;for(const e of this._controllers)e.abort();this._controllers.clear(),this._loadingMore=!1,null!==this._staleTimer&&(clearTimeout(this._staleTimer),this._staleTimer=null)}_scheduleStale(){null!==this._staleTimer&&clearTimeout(this._staleTimer),this._staleTimer=setTimeout(()=>{this._staleTimer=null,this._emit()},this._staleAfter+1)}_emit(){this._onChange(this.snapshot())}}function hs(e){if("string"!=typeof e)return null;const t=e.trim();if(!/^https?:\/\//i.test(t))return null;try{const e=new URL(t);return"http:"!==e.protocol&&"https:"!==e.protocol||""!==e.username||""!==e.password?null:e.href}catch{return null}}function ps(e,t,o){const n=e.document,i=(t,o,n={})=>Pe(e,`schema.ui.news.${t}`,n,o),a=ko(n,"div","oac-news");a.setAttribute("aria-label",i("title","News"));const r=ko(n,"div","oac-news__bar"),s=ko(n,"div","oac-news__heading"),l=ko(n,"span","oac-news__instrument"),c=ko(n,"span","oac-news__exchange");s.append(l,c);const d=Ao(n,{label:i("refresh","Refresh"),onClick:()=>{$.refresh()}});d.setAttribute("aria-label",i("refreshNews","Refresh news")),r.append(s,d);const u=ko(n,"div","oac-news__status");u.setAttribute("role","status"),u.setAttribute("aria-live","polite");const h=ko(n,"ul","oac-news__list");h.setAttribute("aria-label",i("headlines","Headlines"));const p=ko(n,"div","oac-news__more"),g=ko(n,"p","oac-news__more-error"),m=Ao(n,{label:"",onClick:()=>{$.loadMore()}}),f=ko(n,"span","oac-news__end");p.append(g,m,f);const b=ko(n,"article","oac-news__detail");b.hidden=!0;const v=Ao(n,{label:i("back","Back to news"),onClick:()=>P()}),w=ko(n,"h3","oac-news__detail-headline"),y=ko(n,"p","oac-news__detail-meta"),_=ko(n,"p","oac-news__detail-summary"),x=ko(n,"div","oac-news__detail-link");b.append(v,w,y,_,x),a.append(r,u,h,p,b),t.appendChild(a);let k=!1,C=null,S=null;const A=new Map,O=()=>{try{return e.chart.timezone()}catch{return W}},L=t=>{try{return new Intl.DateTimeFormat(e.locale,{timeZone:O(),...t})}catch{return new Intl.DateTimeFormat("en-US",{timeZone:"UTC",...t})}};let E=null;const $=new us({feed:o.feed,pageSize:o.pageSize,staleAfterMs:o.staleAfterMs,maxItems:o.maxItems,onChange:e=>{C=e,j()}}),T=(e,t)=>{t.textContent="",void 0!==e.source&&t.appendChild(ko(n,"span","oac-news__source",e.source));const o=ko(n,"time","oac-news__time",(i=e.time,E?.zone!==O()&&(E={zone:O(),format:L({dateStyle:"medium",timeStyle:"short"})}),E.format.format(new Date(1e3*i))));var i;o.setAttribute("datetime",(e=>{try{return new Date(1e3*e).toISOString()}catch{return""}})(e.time)),t.appendChild(o)};function j(){if(k||null===C)return;const e=C;l.textContent=e.instrument?.symbol??"",c.textContent=e.instrument?.exchange??"",d.disabled=null===e.instrument||"loading"===e.status;const t=function(e){const t=e.instrument?.symbol??"";if(null===e.instrument)return{text:i("status.none","Choose a symbol to see its news"),kind:"idle"};if("loading"===e.status)return e.items.length>0?{text:i("status.refreshing","Refreshing news for {symbol}",{symbol:t}),kind:"loading"}:{text:i("status.loading","Loading news for {symbol}",{symbol:t}),kind:"loading"};if("empty"===e.status)return{text:i("status.empty","No news for {symbol}",{symbol:t}),kind:"empty"};if("error"===e.status)return{text:i("status.error","News could not load: {error}",{error:e.error??""}),kind:"error"};if(e.refreshFailed)return{text:i("status.staleFailed","Showing earlier news. Refresh failed: {error}",{error:e.error??""}),kind:"stale"};const o=null===e.loadedAt?"":L({timeStyle:"short"}).format(new Date(e.loadedAt));return e.stale?{text:i("status.stale","Updated {time}. Refresh for newer news.",{time:o}),kind:"stale"}:{text:i("status.ready","Updated {time}",{time:o}),kind:"ready"}}(e);u.textContent=t.text,u.dataset.state=t.kind;const o=new Set(e.items.map(e=>e.id));for(const[e,t]of A)o.has(e)||(t.li.remove(),A.delete(e));e.items.forEach((e,t)=>{let o=A.get(e.id);if(!o){const t=ko(n,"li","oac-news__item"),a=ko(n,"button","oac-news__open");a.type="button",a.dataset.id=e.id,a.addEventListener("click",()=>function(e){const t=A.get(e);if(!t)return;S=e;const o=t.item;w.textContent=o.headline,T(o,y),_.textContent=o.summary??"",_.hidden=void 0===o.summary,x.textContent="";const a=hs(o.url);if(null!==a){const e=ko(n,"a","oac-btn oac-btn--primary oac-news__article",i("openArticle","Open article"));e.setAttribute("href",a),e.setAttribute("target","_blank"),e.setAttribute("rel","noopener noreferrer"),e.setAttribute("referrerpolicy","no-referrer"),x.appendChild(e)}else x.appendChild(ko(n,"p","oac-news__no-link",i("noLink","No article link")));b.hidden=!1,h.hidden=p.hidden=!0,v.focus()}(e.id)),t.appendChild(a),o={li:t,open:a,item:e},A.set(e.id,o)}o.item=e,o.open.textContent="";const a=ko(n,"span","oac-news__meta");T(e,a),o.open.append(ko(n,"span","oac-news__headline",e.headline),a),h.children[t]!==o.li&&h.insertBefore(o.li,h.children[t]??null)});const a=e.hasMore&&null!==e.error&&!e.loadingMore&&"ready"===e.status&&!e.refreshFailed;g.hidden=!a,g.textContent=a?i("moreFailed","Older news could not load: {error}",{error:e.error??""}):"",m.hidden=!e.hasMore,m.textContent=e.loadingMore?i("loadingMore","Loading older news"):i("loadMore","Load older news"),m.disabled=e.loadingMore||"ready"!==e.status;const r=!e.hasMore&&e.items.length>0&&"ready"===e.status;f.hidden=!r,f.textContent=r?i("end","No older news"):"",null===S||A.has(S)||P(!1),h.hidden=p.hidden=null!==S}function P(e=!0){const t=S;S=null,b.hidden=!0,h.hidden=p.hidden=!1,e&&null!==t&&A.get(t)?.open.focus()}const M=()=>{const t=(()=>{const t=e.symbol();return""===t.symbol?null:{symbol:t.symbol,exchange:t.exchange}})(),o=C?.instrument??null;t?.symbol===o?.symbol&&t?.exchange===o?.exchange&&null!==C||(null!==S&&P(!1),$.setInstrument(t))},I=e=>{e.stopPropagation()};a.addEventListener("pointerdown",I);const D=[e.chart.on("data:context",M),e.chart.on("timezone:changed",()=>{j();const e=null===S?void 0:A.get(S);e&&T(e.item,y)})];return C=$.snapshot(),M(),j(),{el:a,initialFocus:d,refresh:()=>$.refresh(),destroy:()=>{if(!k){k=!0,$.destroy();for(const e of D)e();a.removeEventListener("pointerdown",I),A.clear(),a.remove()}}}}const gs='\n.oac-widget .oac-news { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px 10px; font-size: 12px; min-height: 0; }\n.oac-widget .oac-news__bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }\n.oac-widget .oac-news__heading { display: flex; align-items: baseline; gap: 5px; min-width: 0; }\n.oac-widget .oac-news__instrument { font-weight: 600; color: var(--oac-tx); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.oac-widget .oac-news__exchange { font-size: 10px; color: var(--oac-mut); }\n.oac-widget .oac-news .oac-btn { height: 26px; padding: 0 8px; font-size: 11px; }\n.oac-widget .oac-news__status { font-size: 11px; color: var(--oac-mut); overflow-wrap: anywhere; }\n.oac-widget .oac-news__status[data-state="error"], .oac-widget .oac-news__more-error { color: var(--oac-danger); }\n.oac-widget .oac-news__status[data-state="stale"] { color: var(--oac-warn, var(--oac-mut)); }\n.oac-widget .oac-news__list { list-style: none; margin: 0; padding: 0; }\n.oac-widget .oac-news__list[hidden], .oac-widget .oac-news__more[hidden], .oac-widget .oac-news__detail[hidden], .oac-widget .oac-news__more > [hidden] { display: none; }\n.oac-widget .oac-news__item { border-bottom: 1px solid var(--oac-bd-soft); }\n.oac-widget .oac-news__open { display: flex; flex-direction: column; gap: 3px; width: 100%; padding: 7px 2px; border: 0; background: none; color: var(--oac-tx); font: inherit; text-align: left; cursor: pointer; }\n.oac-widget .oac-news__open:hover, .oac-widget .oac-news__open:focus-visible { background: var(--oac-elev); }\n.oac-widget .oac-news__headline { font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }\n.oac-widget .oac-news__meta, .oac-widget .oac-news__detail-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 11px; color: var(--oac-mut); }\n.oac-widget .oac-news__source { overflow-wrap: anywhere; }\n.oac-widget .oac-news__more { display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding-top: 4px; font-size: 11px; color: var(--oac-mut); text-align: center; }\n.oac-widget .oac-news__more-error { margin: 0; text-align: left; overflow-wrap: anywhere; }\n.oac-widget .oac-news__detail { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }\n.oac-widget .oac-news__detail-headline { margin: 0; font: 600 14px/1.35 var(--oac-font); color: var(--oac-tx); overflow-wrap: anywhere; }\n.oac-widget .oac-news__detail-meta { margin: 0; }\n.oac-widget .oac-news__detail-summary { margin: 0; white-space: pre-line; line-height: 1.5; color: var(--oac-tx); overflow-wrap: anywhere; }\n.oac-widget .oac-news__article { display: inline-flex; align-items: center; text-decoration: none; }\n.oac-widget .oac-news__no-link { margin: 0; font-size: 11px; color: var(--oac-mut); }\n.oac-widget .oac-panel-dock[data-sheet="true"] .oac-news__open { padding: 10px 2px; }\n';function ms(e){return Array.isArray(e)?e.map(ms):function(e){if(null===e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(e)?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,ms(t)])):e}function fs(e){return{...e,..."object"==typeof e.details?{details:ms(e.details)}:{}}}const bs='\n.oac-event-layer{position:absolute;inset:0;pointer-events:none;z-index:50}\n.oac-event-details{position:absolute;pointer-events:auto;box-sizing:border-box;width:340px;max-width:calc(100% - 16px);max-height:calc(100% - 16px);overflow:auto;background:var(--oac-panel,#171b23);color:var(--oac-tx,#d9dfe8);border:1px solid var(--oac-bd,#343b48);border-radius:8px;box-shadow:var(--oac-shadow,0 12px 32px #0005);font:12px/1.5 var(--oac-font,system-ui,sans-serif);scrollbar-width:thin;scrollbar-color:var(--oac-sb-thumb,#414958) var(--oac-panel,#171b23)}\n.oac-event-details::-webkit-scrollbar{width:6px;height:6px}\n.oac-event-details::-webkit-scrollbar-track{background:var(--oac-panel,#171b23)}\n.oac-event-details::-webkit-scrollbar-thumb{background:var(--oac-sb-thumb,#414958);border-radius:3px}\n.oac-event-details::-webkit-scrollbar-thumb:hover{background:var(--oac-sb-thumb-hover,#586276)}\n.oac-event-details__header{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 12px;border-bottom:1px solid var(--oac-bd,#343b48)}\n.oac-event-details__heading{margin:0;font:600 12px/1.5 var(--oac-font,system-ui,sans-serif)}\n.oac-event-details button{font:inherit;cursor:pointer;border:1px solid var(--oac-bd,#343b48);border-radius:4px;padding:4px 8px;background:var(--oac-elev,#252c37);color:inherit;text-align:left}\n.oac-event-details button:hover{background:var(--oac-elev-2,#333d4b)}\n.oac-event-details button:focus-visible{outline:2px solid var(--oac-ring,#74a7fa);outline-offset:2px}\n.oac-event-details__members{display:flex;flex-wrap:wrap;gap:6px;padding:10px 12px 0}\n.oac-event-details__members button{max-width:100%;overflow-wrap:anywhere}\n.oac-event-details__members button[aria-pressed="true"]{border-color:var(--oac-acc,#74a7fa);background:var(--oac-on-bg,#274263)}\n.oac-event-details__content{padding:12px;overflow-wrap:anywhere}\n.oac-event-details__title{margin:0 0 4px;font-size:14px;font-weight:600}\n.oac-event-details__time,.oac-event-details__status{color:var(--oac-mut,#a0aabc)}\n.oac-event-details__summary{white-space:pre-wrap;margin:10px 0 0}\n.oac-event-details__fields{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:5px 12px;margin:10px 0 0}\n.oac-event-details__fields dt{color:var(--oac-mut,#a0aabc)}\n.oac-event-details__fields dd{margin:0;text-align:right;white-space:pre-wrap}\n.oac-event-details__status{padding:0 12px 10px}\n.oac-event-details__status:empty{display:none}\n.oac-event-details__subhead{margin:10px 0 0;font-size:12px;font-weight:600}\n.oac-event-details__text,.oac-event-details__list{margin:6px 0 0}\n.oac-event-details__list{padding-left:18px}\n.oac-event-details a{color:var(--oac-acc,#74a7fa)}\n.oac-event-details__actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:6px;padding:0 12px 12px}\n.oac-event-details__actions:empty{display:none}\n';function vs(e){return{title:Pe(e,"Event details"),close:Pe(e,"Close"),events:Pe(e,"Events"),loading:Pe(e,"Loading details..."),empty:Pe(e,"No additional details."),error:Pe(e,"Unable to load additional details.")}}class ws{constructor(e,t={}){Object.defineProperty(this,"_container",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"element",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_doc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_overlays",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_ownOverlays",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_labels",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_formatTime",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_close",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_abort",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_revision",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_disposed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_events",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_members",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_actions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_anchor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._doc=e.ownerDocument,this._labels={...vs({}),...t.labels};const o=new Intl.DateTimeFormat(void 0,{timeZone:W,dateStyle:"medium",timeStyle:"short"});if(this._formatTime=t.formatTime??(e=>{const t=new Date(1e3*e);return Number.isFinite(t.getTime())?o.format(t):String(e)}),this._ownOverlays=void 0===t.overlays,this._overlays=t.overlays??Ze(e,this._doc),this._ownOverlays&&this._overlays.layer.classList.add("oac-event-layer"),!1!==t.injectStyles&&null===this._doc.getElementById("oac-event-details-style")){const e=De(this._doc,"style",void 0,{id:"oac-event-details-style"});void 0!==t.styleNonce&&e.setAttribute("nonce",t.styleNonce),e.textContent=bs,this._doc.head.appendChild(e)}this.element=De(this._doc,"section","oac-event-details",{role:"dialog","aria-label":this._labels.title});for(const e of["pointerdown","pointerup","click","dblclick","wheel","keydown"])this.element.addEventListener(e,e=>e.stopPropagation());this._content=De(this._doc,"div","oac-event-details__content"),this._status=De(this._doc,"div","oac-event-details__status",{role:"status","aria-live":"polite"}),this._actions=De(this._doc,"div","oac-event-details__actions")}open(e,t){if(this._disposed)return;if(this.close(),0===e.events.length)return;this._events=e.events.map(fs),this._anchor=void 0===t?void 0:{...t};const o=De(this._doc,"header","oac-event-details__header"),n=De(this._doc,"h2","oac-event-details__heading");n.textContent=this._labels.title;const i=De(this._doc,"button",void 0,{type:"button","data-action":"close-event-details"});if(i.textContent=this._labels.close,i.addEventListener("click",()=>this.close()),o.append(n,i),this.element.replaceChildren(o),this._members=[],this._events.length>1){const e=De(this._doc,"div","oac-event-details__members",{role:"group","aria-label":this._labels.events});this._members=this._events.map((t,o)=>{const n=De(this._doc,"button",void 0,{type:"button","data-event-index":String(o)});return n.textContent=t.title??t.label,n.addEventListener("click",()=>this._select(o)),e.appendChild(n),n}),this.element.appendChild(e)}this.element.append(this._content,this._status,this._actions),this._close=this._overlays.open(this.element,{placement:"below",modal:!1,initialFocus:i,onClose:()=>{this._close=null,this._cancel()}}),this._select(0),this._position()}close(){this._cancel(),this._close?.(),this._close=null}destroy(){this._disposed||(this._disposed=!0,this.close(),this._events=[],this._members=[],this._ownOverlays&&this._overlays.destroy())}_cancel(){this._revision++,this._abort?.abort(),this._abort=null}_select(e){this._cancel();const t=this._events[e];this._members.forEach((t,o)=>t.setAttribute("aria-pressed",String(o===e))),this._render(t,t.details),this._actions.replaceChildren(...(this._options.actions?.(fs(t))??[]).map(e=>{const o=De(this._doc,"button",void 0,{type:"button"});return o.textContent=e.label,o.addEventListener("click",()=>{const o=fs(t);this.close(),e.run(o)}),o})),this._status.textContent="",this.element.removeAttribute("aria-busy");const o=this._options.loadDetails;if(void 0===o)return;const n=this._revision,i=new AbortController;this._abort=i,this._status.textContent=this._labels.loading,this.element.setAttribute("aria-busy","true");const a=()=>!this._disposed&&null!==this._close&&n===this._revision&&!i.signal.aborted,r=()=>{a()&&(this.element.removeAttribute("aria-busy"),this._status.textContent=this._labels.error,this._position())};try{Promise.resolve(o(fs(t),{signal:i.signal})).then(e=>{a()&&(this._status.textContent="",this.element.removeAttribute("aria-busy"),this._render(t,e??t.details))},r)}catch{r()}}_render(e,t){const o=De(this._doc,"h3","oac-event-details__title");o.textContent=e.title??e.label;const n=De(this._doc,"div","oac-event-details__time");n.textContent=this._formatTime(e.time),this._content.replaceChildren(o,n);const i="string"==typeof t?t:t?.summary;if(i){const e=De(this._doc,"p","oac-event-details__summary");e.textContent=i,this._content.appendChild(e)}const a="object"==typeof t?t.fields:void 0;if(a?.length){const e=De(this._doc,"dl","oac-event-details__fields");for(const t of a){const o=De(this._doc,"dt"),n=De(this._doc,"dd");o.textContent=t.label,n.textContent=t.value,e.append(o,n)}this._content.appendChild(e)}let r=!1;const s="object"==typeof t&&Array.isArray(t.blocks)?t.blocks:[];for(const e of s){const{type:t,text:o,items:n}=e??{},i="heading"===t?De(this._doc,"h4","oac-event-details__subhead"):"paragraph"===t?De(this._doc,"p","oac-event-details__text"):"list"===t?De(this._doc,"ul","oac-event-details__list"):null;if(null!==i){if("list"!==t)this._inline(i,o);else if(Array.isArray(n))for(const e of n)this._inline(i.appendChild(De(this._doc,"li")),e);i.textContent&&(this._content.appendChild(i),r=!0)}}if(!i&&!a?.length&&!r){const e=De(this._doc,"p","oac-event-details__summary");e.textContent=this._labels.empty,this._content.appendChild(e)}this._position()}_inline(e,t){if("string"!=typeof t){if(Array.isArray(t))for(const o of t){if("string"!=typeof o?.text)continue;const t=hs(o.href);let n=null===t?De(this._doc,"span"):De(this._doc,"a",void 0,{href:t,target:"_blank",rel:"noopener noreferrer",referrerpolicy:"no-referrer"});n.textContent=o.text;for(const e of["em","strong"]){if(!0!==o[e])continue;const t=De(this._doc,e);t.appendChild(n),n=t}e.appendChild(n)}}else e.append(t)}_position(){const e=this._container.getBoundingClientRect(),t=this._overlays.layer.getBoundingClientRect(),o=this._ownOverlays?0:e.left-t.left,n=this._ownOverlays?0:e.top-t.top;this.element.style.maxWidth=`${Math.max(0,e.width-16)}px`,this.element.style.maxHeight=`${Math.max(0,e.height-16)}px`;const i=this.element.offsetWidth,a=this.element.offsetHeight,r=this._anchor?.x,s=this._anchor?.y;this.element.style.left=`${o+Math.max(0,Math.min(Number.isFinite(r)?r:e.width-i-8,e.width-i-8))}px`,this.element.style.top=`${n+Math.max(0,Math.min(Number.isFinite(s)?s-a-12:8,e.height-a-8))}px`}}function ys(e,t,o={}){const n=e.primaryBars();return _s(e,n,t,o,n.some(e=>Number.isFinite(e.oi)))}function _s(e,t,o,n,i){const a=(e,t)=>Pe(n,`schema.ui.data.${e}`,{},t),r=a("unavailable","Unavailable");let s=t.length-1;if(void 0!==o){let e=0,n=t.length;for(;e<n;){const i=e+n>>>1;t[i].time<o?e=i+1:n=i}s=t[e]?.time===o?e:-1}const l=t[s],c=void 0===o?l?.time??null:Number.isFinite(o)?o:null;let d;try{d=new Intl.NumberFormat(n.locale,{maximumFractionDigits:8})}catch{d=new Intl.NumberFormat("en-US",{maximumFractionDigits:8})}const u=(t,o,n=!1)=>{try{if("custom"===o?.type)return String(o.formatter(t));if("percent"===o?.type)return`${t.toFixed(o.precision??2)}%`;if("price"===o?.type)return t.toFixed(o.precision??2);if(n)return e.primarySeries()?.priceScale().format(t)??t.toFixed(2)}catch{}return d.format(t)},h=(e,t,o,n=!1,i)=>{const a="number"==typeof o&&Number.isFinite(o)?o:null;return{key:e,label:t,raw:a,value:null===a?r:u(a,i,n)}},p=["open","high","low","close"].map(e=>h(e,a(e,e[0].toUpperCase()+e.slice(1)),l?.[e],!0));p.push(h("volume",a("volume","Volume"),l?.volume));!1!==e.hasOpenInterest&&(!0===e.hasOpenInterest||i)&&p.push(h("oi",a("oi","Open interest"),l?.oi));const g=[{id:"price",title:a("price","Price"),rows:p}];for(const t of e.indicators()){const e=j(t.indicatorId),o=t.values(),n=(e?.plots??[]).map(e=>h(`${t.id}:${e.key}`,e.title,s<0?null:o[e.ohlc?.close??e.key]?.[s-(e.offset??0)],!1,e.priceFormat));n.length>0&&g.push({id:t.id,title:t.name,rows:n})}const f=e.getDataContext();let b=r;if(null!==c)try{b=`${m(c,e.timezone())} (${e.timezone()})`}catch{}return{symbol:f?.symbol??"",exchange:f?.exchange??"",time:c,timestamp:b,sections:g}}function xs(e,t){const o=e.document;t.classList.add("oac-data-window"),t.setAttribute("aria-label",Pe(e,"schema.ui.data.title",{},"Data window"));const n=ko(o,"div","oac-data-window__instrument"),i=ko(o,"div","oac-data-window__time"),a=ko(o,"div","oac-data-window__sections");let r;t.append(n,i,a);let s=!1,l=!1,c=!1,d=!0,u=!1,h=[];const p=new Map,g=(e,t)=>{e.textContent!==t&&(e.textContent=t)},m=()=>{if(l)return;d&&(h=e.chart.primaryBars(),u=h.some(e=>Number.isFinite(e.oi)),d=!1);const t=_s(e.chart,h,c?NaN:r,e,u);g(n,[t.exchange,t.symbol].filter(Boolean).join(":")),g(i,t.timestamp);const s=new Set(t.sections.map(e=>e.id));for(const[e,t]of p)s.has(e)||(t.el.remove(),p.delete(e));for(const[e,n]of t.sections.entries()){let t=p.get(n.id);if(!t){const e=ko(o,"section","oac-data-window__section"),i=ko(o,"h3","oac-data-window__title");e.appendChild(i),a.appendChild(e),t={el:e,title:i,rows:new Map},p.set(n.id,t)}a.children[e]!==t.el&&a.insertBefore(t.el,a.children[e]??null),g(t.title,n.title);const i=new Set(n.rows.map(e=>e.key));for(const[e,o]of t.rows)i.has(e)||(o.el.remove(),t.rows.delete(e));for(const e of n.rows){let n=t.rows.get(e.key);if(!n){const i=ko(o,"div","oac-data-window__row");i.dataset.key=e.key;const a=ko(o,"span","oac-data-window__label"),r=ko(o,"span","oac-data-window__value");i.append(a,r),t.el.appendChild(i),n={el:i,label:a,value:r},t.rows.set(e.key,n)}g(n.label,e.label),g(n.value,e.value),n.value.classList.toggle("is-unavailable",null===e.raw)}}},f=()=>{s||l||(s=!0,Promise.resolve().then(()=>{s=!1,m()}))},b=[e.chart.on("crosshair:readout",e=>{const t=e;r=null===t.index&&null===t.point?void 0:t.time??NaN,f()}),e.chart.on("data:context",()=>{r=void 0,c=!0,d=!0,f()}),e.chart.on("data:range",()=>{c=!1,d=!0,f()}),...["objects:change","indicatorSettings","indicatorRemoved","indicator:data-status","paneMoved","resize","timezone:changed"].map(t=>e.chart.on(t,f))],v=()=>{if(!l){l=!0;for(const e of b)e();p.clear(),t.textContent="",t.classList.remove("oac-data-window"),t.removeAttribute("aria-label")}};return b.push(e.chart.on("destroy",v)),m(),{el:t,refresh:f,destroy:v}}const ks="\n.oac-widget .oac-data-window { padding: 12px; font-size: 12px; user-select: text; -webkit-user-select: text; }\n.oac-widget .oac-data-window__instrument { font-weight: 600; color: var(--oac-tx); overflow-wrap: anywhere; }\n.oac-widget .oac-data-window__time { font-size: 11px; color: var(--oac-mut); margin: 4px 0 14px; line-height: 1.5; }\n.oac-widget .oac-data-window__section + .oac-data-window__section { margin-top: 16px; }\n.oac-widget .oac-data-window__title { margin: 0 0 6px; padding: 0; font: 600 11px/1.4 var(--oac-font); color: var(--oac-mut); text-transform: uppercase; letter-spacing: .04em; }\n.oac-widget .oac-data-window__row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; min-height: 26px; padding: 4px 0; }\n.oac-widget .oac-data-window__label { min-width: 0; overflow-wrap: anywhere; }\n.oac-widget .oac-data-window__value { font-variant-numeric: tabular-nums; text-align: right; overflow-wrap: anywhere; }\n.oac-widget .oac-data-window__value.is-unavailable { font-size: 11px; color: var(--oac-mut); }\n";function Cs(e,t){const o=e.document;let n=!1,i=null,a=null,r=null,s=null;const l=()=>{const e=i;i=null,s?.destroy(),s=null,a=null,r=null,e?.()},c=c=>{if(n||c.defaultPrevented||c.isComposing||c.ctrlKey||c.metaKey||c.altKey||c.repeat)return;if(!/^[a-zA-Z0-9]$/.test(c.key))return;const d=c.target,u=o.activeElement;if(null===d||!e.root.contains(d)||null===u||!e.root.contains(u)||function(e){for(let t=e;null!==t;t=t.parentElement)if(t.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(t.tagName))return!0;return!1}(d))return;if(e.overlays.size()>0||null!==e.draw.activeTool()||!t.enabled())return;const h=Bt(c);e.keymap.list().some(t=>t.combo===h&&e.keymap.activeScopes().includes(t.scope))||e.chart.shortcuts?.list().some(e=>!e.isDisabled&&e.combos.some(e=>Kt(e)===h))||(c.preventDefault(),c.stopPropagation(),((n,c)=>{l(),a=De(o,"section","oac-quick-entry",{role:"dialog","aria-label":Pe(e,"symbol"===n?"schema.ui.enterSymbol":"schema.ui.enterInterval",{},"symbol"===n?"Enter symbol":"Enter interval")}),r=De(o,"input","oac-quick-entry__input",{type:"text",autocomplete:"off",spellcheck:"false","aria-label":Pe(e,"symbol"===n?"schema.ui.symbol":"schema.ui.interval",{},"symbol"===n?"Symbol":"Interval")}),r.value=c;const d=De(o,"div","oac-quick-entry__message",{role:"alert"});a.append(r,d);const u=r;u.addEventListener("input",()=>{d.textContent=""});const h=a;i=e.openOverlay(a,{placement:"center",initialFocus:u,onClose:()=>{a===h&&l()}}),"symbol"===n&&t.search&&(s=bn(e,u,{search:t.search,onSelect:(e,o)=>{l(),t.onSymbol(e,o)},context:()=>`${e.symbol().exchange}:${e.symbol().symbol}:${e.interval()}`}),s.open(c)),u.addEventListener("keydown",o=>{if("Enter"!==o.key||o.isComposing)return;o.preventDefault(),o.stopPropagation();const i=u.value.trim();if("symbol"===n){if(null!==s&&!s.canCommitRaw())return;if(""===i)return void(d.textContent=Pe(e,"schema.ui.symbolRequired",{},"Enter a symbol"));l(),t.onSymbol(i.toUpperCase())}else{const o=w(i)??(/^[0-9]+$/.test(i)?w(`${i}m`):null);if(null===o)return void(d.textContent=Pe(e,"schema.ui.invalidInterval",{},"Enter a recognized interval"));l(),t.onInterval(o.code)}})})(/[0-9]/.test(c.key)?"interval":"symbol",c.key))};o.addEventListener("keydown",c,!0);const d=e.bus.on("symbol",l),u=e.bus.on("interval",l);return{close:l,destroy:()=>{n||(n=!0,l(),d(),u(),o.removeEventListener("keydown",c,!0))}}}const Ss="\n.oac-widget .oac-quick-entry{width:min(330px,calc(100vw - 32px));padding:12px}\n.oac-widget .oac-quick-entry__input{width:100%;box-sizing:border-box;background:var(--oac-panel);color:var(--oac-tx);border:1px solid var(--oac-bd);border-radius:4px;padding:9px;font:inherit}\n.oac-widget .oac-quick-entry__message{min-height:20px;padding-top:5px;color:var(--oac-danger)}\n",As=(e,t)=>[..."ABCDEFGHIJKLMNOP"].map((o,n)=>`.oac-grid[data-theme="${e}"] [data-group="${o}"] { --oac-group: ${t[n%t.length]}; }`).join("\n"),Os=`\n.oac-grid { position: relative; display: flex; flex-direction: column; width: 100%; height: 100%; min-width: 0; min-height: 0;\n background: var(--oac-bg); color: var(--oac-tx); font: var(--oac-fs)/1.35 var(--oac-font); }\n.oac-grid [hidden] { display: none !important; }\n.oac-grid__tabs { display: flex; gap: 2px; padding: 4px; overflow-x: auto; flex: none; background: var(--oac-panel);\n border-bottom: 1px solid var(--oac-bd-soft); scrollbar-width: thin; scrollbar-color: var(--oac-sb-thumb) transparent; }\n.oac-grid__tabs::-webkit-scrollbar { height: 6px; }\n.oac-grid__tabs::-webkit-scrollbar-thumb { background: var(--oac-sb-thumb); border-radius: 999px; }\n.oac-grid__tab { flex: none; height: 26px; padding: 0 10px; border: 1px solid transparent; border-radius: var(--oac-radius);\n background: transparent; color: var(--oac-mut); font: inherit; cursor: pointer; white-space: nowrap; }\n.oac-grid__tab:hover { color: var(--oac-tx); background: var(--oac-elev); }\n.oac-grid__tab[aria-selected="true"] { color: var(--oac-tx-strong); background: var(--oac-on-bg); border-color: var(--oac-on-bd); }\n.oac-grid__tab:focus-visible, .oac-grid__split:focus-visible { outline: 2px solid var(--oac-ring); outline-offset: -2px; }\n.oac-grid__cells { position: relative; flex: 1; display: grid; min-height: 0; background: var(--oac-bd-soft); }\n.oac-grid__cell { position: relative; min-width: 0; min-height: 0; overflow: hidden; }\n.oac-grid__cell::after { content: ''; position: absolute; inset: 0; border: 1px solid transparent; pointer-events: none; z-index: 30; }\n.oac-grid[data-single="false"][data-compact="false"]:not([data-maximized="true"]) .oac-grid__cell[data-active="true"]::after { border-color: var(--oac-acc); }\n.oac-grid__split { position: relative; z-index: 31; touch-action: none; transition: background .12s; }\n.oac-grid__split::before { content: ''; position: absolute; inset: 0 -3px; }\n.oac-grid__split[data-axis="row"]::before { inset: -3px 0; }\n.oac-grid__split[data-axis="column"] { cursor: col-resize; }\n.oac-grid__split[data-axis="row"] { cursor: row-resize; }\n.oac-grid__split:hover, .oac-grid__split.is-drag { background: var(--oac-acc); }\n.oac-grid:is([data-compact="true"], [data-maximized="true"]) .oac-grid__cells { grid-template: minmax(0,1fr) / minmax(0,1fr) !important; }\n.oac-grid:is([data-compact="true"], [data-maximized="true"]) .oac-grid__cell { grid-area: 1 / 1 / 2 / 2 !important; }\n\n/* Dragging a chart by its bar onto another's place. */\n.oac-grid[data-single="false"][data-compact="false"]:not([data-maximized="true"]) .oac-grid__cell .oac-topbar { cursor: grab; }\n.oac-grid[data-single="false"][data-compact="false"]:not([data-maximized="true"]) .oac-grid__cell .oac-topbar input { cursor: text; }\n.oac-grid[data-dragging="true"], .oac-grid[data-dragging="true"] * { cursor: grabbing !important; user-select: none; }\n.oac-grid__cell[data-dragging="true"] { opacity: .55; }\n.oac-grid__cell[data-drop="true"]::after { border: 2px dashed var(--oac-acc); background: var(--oac-on-bg); }\n\n/* Dense cells: a chart a few hundred pixels across keeps its plot and the\n controls a chart needs every minute; the rest waits for maximize. */\n/* One row that scrolls sideways rather than a bar wrapped over a third of the plot. */\n.oac-grid__cell[data-dense="true"] .oac-rail { display: none; }\n.oac-grid__cell[data-dense="true"] .oac-topbar { gap: 2px; padding: 3px 5px; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden;\n scrollbar-width: none; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 18px), transparent);\n mask-image: linear-gradient(to right, #000 calc(100% - 18px), transparent); }\n.oac-grid__cell[data-dense="true"] .oac-topbar::-webkit-scrollbar { display: none; }\n.oac-grid__cell[data-dense="true"] .oac-topbar > * { flex-shrink: 0; }\n.oac-grid__cell[data-dense="true"] .oac-sym > input { width: 96px; }\n.oac-grid__cell[data-dense="true"] .oac-sym__ex { display: none; }\n.oac-grid__cell[data-dense="true"] :is(.oac-topbar__goto, .oac-topbar__objects, .oac-topbar__data, .oac-topbar__watchlist,\n .oac-topbar__news, .oac-topbar__alerts, .oac-topbar__theme, .oac-topbar__branding-slot, .oac-topbar__spacer + .oac-sep) { display: none; }\n/* A label goes where its glyph shows: a host's chart type with none keeps its name. */\n.oac-grid__cell[data-dense="true"] .oac-topbar > .oac-btn > span:not(.oac-glyph):not(.oac-chev):not([hidden] + span) { display: none; }\n\n/* The grid's own chrome takes the widget's controls; these rules only place it. The bar's strip\n holds its height (a control and its padding) before the bar loads into it (grid-bar.ts). */\n.oac-widget.oac-grid__bar { position: relative; display: flex; align-items: center; gap: 4px; flex: none; height: auto;\n min-height: calc(var(--oac-ctl-h) + 9px); padding: 4px 6px; background: var(--oac-panel); border-bottom: 1px solid var(--oac-bd-soft);\n overflow: visible; container: oac-grid-bar / inline-size; }\n/* One bar under the charts: the widget's own strip, acting on the active chart. */\n.oac-widget.oac-grid__foot { display: block; flex: none; height: auto; min-height: 0; }\n.oac-widget.oac-grid__overlay { position: absolute; inset: 0; display: block; background: transparent; pointer-events: none;\n z-index: 80; overflow: visible; }\n/* A link group mark: the letter on a panel, the group's hue as a stripe. */\n.oac-grid__chip { display: inline-flex; align-items: center; justify-content: center; min-width: 17px; height: 17px;\n padding: 0 4px 0 6px; border-radius: 4px; background: var(--oac-elev-2); color: var(--oac-tx-strong);\n box-shadow: inset 3px 0 0 var(--oac-group, var(--oac-faint)); font: 700 10.5px/1 var(--oac-font); flex: none; }\n.oac-grid__chip[data-group="none"] { padding: 0 3px; box-shadow: none; background: transparent; color: var(--oac-faint); }\n.oac-grid__chip[data-group="none"] > svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2;\n stroke-linecap: round; stroke-linejoin: round; }\n.oac-grid__mark { display: inline-flex; align-items: center; justify-content: center; height: 24px; min-width: 24px; padding: 0 3px;\n margin-right: 2px; border: 1px solid transparent; border-radius: 6px; background: transparent; cursor: pointer; flex: none; }\n.oac-grid__mark:hover { background: var(--oac-elev); border-color: var(--oac-bd-soft); }\n.oac-grid__mark:focus-visible { outline: 2px solid var(--oac-ring); outline-offset: -1px; }\n.oac-grid__mark--float { position: absolute; top: 6px; left: 6px; z-index: 32; background: var(--oac-panel); border-color: var(--oac-bd-soft); }\n${As("dark",["#5b9cf6","#f0a445","#4cc38a","#d673d1","#3fc1c9","#d9c34a","#ef6a6a","#9d85f2"])}\n${As("light",["#1f63c9","#b8660b","#17864f","#a23c9e","#0e7f86","#8a7300","#c0392b","#6247c4"])}\n@media (prefers-reduced-motion: reduce) {\n .oac-grid__split { transition: none; }\n}\n`,Ls=2147483647,Es=e=>JSON.stringify([e.symbol,e.exchange]),$s=e=>Me({},e),Ts=e=>"number"==typeof e&&Number.isFinite(e);function js(e){const t=e.previousClose;if(!Ts(t)||t<=0||!Ts(e.last))return null;const o=e.last-t;return{change:o,percent:o/t*100}}function Ps(e,t){if(null===e||"object"!=typeof e||e.symbol!==t.symbol||(e.exchange??"")!==t.exchange||!Ts(e.last))return null;const o={symbol:t.symbol,exchange:t.exchange,last:e.last};for(const t of["previousClose","bid","ask","volume","time"])Ts(e[t])&&(o[t]=e[t]);return!0===e.delayed&&(o.delayed=!0),o}class Ms{constructor(e){Object.defineProperty(this,"_feed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_staleAfter",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pollMs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_now",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_onChange",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_entries",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"_visible",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"_requests",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"_seq",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_error",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_poll",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_stale",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_resync",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),this._feed=e.feed??null,this._staleAfter=Math.max(0,e.staleAfterMs??6e4),this._pollMs=Math.max(0,e.pollMs??15e3),this._now=e.now??Date.now,this._onChange=()=>{this._destroyed||e.onChange?.()}}setVisible(e){if(this._destroyed)return;const t=new Map;for(const o of e)t.set(Es(o),{symbol:o.symbol,exchange:o.exchange});for(const e of this._visible)t.has(e)||this._hide(e);const o=[],n=this._visible;this._visible=new Set(t.keys());for(const[e,i]of t)n.has(e)||(this._show(e,i),o.push(i));for(const e of this._requests)[...e.ids].some(e=>this._visible.has(e))||(e.controller.abort(),this._requests.delete(e));this._trim(),o.length>0&&this._snapshot(o),this._schedulePoll(),this._scheduleStale(),this._onChange()}row(e){const t={symbol:e.symbol,exchange:e.exchange},o=this._entries.get(Es(t)),n=e=>({instrument:t,quote:o?.quote?{...o.quote}:null,status:e,receivedAt:o?.receivedAt??null});if(null===this._feed)return n("unavailable");if(!o?.quote)return n(o?.error?"error":o?.missing?"unavailable":"loading");const i=!0===o.quote.delayed;if(!o.fresh||!this._visible.has(Es(t)))return n("stale");const a=o.stream?.status;return"live"===a?n(i?"delayed":"live"):"reconnecting"===a||"disconnected"===a||this._now()-(o.receivedAt??0)>this._staleAfter?n("stale"):n(i?"delayed":"snapshot")}status(){if(null===this._feed)return"unavailable";const e=[...this._visible].map(e=>this._entries.get(e)?.stream).filter(e=>!!e&&!e.closed);if(0===e.length)return null!==this._error?"error":this._visible.size>0&&!this._feed.subscribeQuotes?"snapshot":"idle";for(const t of["disconnected","reconnecting","connecting"])if(e.some(e=>e.status===t))return t;return"live"}error(){return this._error}subscribed(){return[...this._visible].map(e=>this._entries.get(e)).filter(e=>!!e?.stream&&!e.stream.closed).map(e=>({...e.key}))}destroy(){if(!this._destroyed){this._destroyed=!0;for(const e of this._entries.values())e.stream?.stop();for(const e of this._requests)e.controller.abort();this._requests.clear(),null!==this._poll&&clearTimeout(this._poll),null!==this._stale&&clearTimeout(this._stale),this._entries.clear(),this._visible.clear()}}_show(e,t){let o=this._entries.get(e);o?(this._entries.delete(e),this._entries.set(e,o)):(o={key:t,quote:null,receivedAt:null,pushed:0,fresh:!1,missing:!1,error:null,stream:null},this._entries.set(e,o)),o.fresh=!1,o.missing=!1,o.error=null;const n=this._feed;if(!n?.subscribeQuotes)return;const i={status:"connecting",closed:!1,stop:()=>{}};o.stream=i;const a=o;try{const e=n.subscribeQuotes([{...t}],{onQuote:e=>{if(i.closed||this._destroyed)return;const o=Ps(e,t);null!==o&&("connecting"===i.status&&(i.status="live"),a.pushed=++this._seq,this._accept(a,o),this._scheduleStale(),this._onChange())},onStatus:e=>{if(i.closed||this._destroyed)return;const o=i.status;i.status=e,"live"!==e||"reconnecting"!==o&&"disconnected"!==o||(a.fresh=!1,this._queueResync(t)),this._scheduleStale(),this._onChange()}});i.stop=()=>{i.closed=!0;try{e()}catch{}}}catch(e){i.closed=!0,o.stream=null,o.error=$s(e)}}_hide(e){const t=this._entries.get(e);t&&(t.stream?.stop(),t.stream=null,t.fresh=!1)}_trim(){for(const[e]of this._entries){if(this._entries.size<=1e3)break;this._visible.has(e)||this._entries.delete(e)}}_accept(e,t){e.quote=t,e.receivedAt=this._now(),e.fresh=!0,e.missing=!1,e.error=null}_queueResync(e){null===this._resync?(this._resync=[e],queueMicrotask(()=>{const e=(this._resync??[]).filter(e=>this._visible.has(Es(e)));this._resync=null,e.length>0&&!this._destroyed&&this._snapshot(e)})):this._resync.push(e)}_snapshot(e){const t=this._feed;if(null===t||this._destroyed)return;const o={controller:new AbortController,ids:new Set(e.map(Es)),seq:++this._seq};let n;this._requests.add(o);try{n=Promise.resolve(t.getQuotes({instruments:e.map(e=>({...e})),signal:o.controller.signal}))}catch(e){n=Promise.reject(e)}n.then(e=>{if(!this._requests.delete(o)||this._destroyed)return;const t=new Set;for(const n of Array.isArray(e)?e:[]){const e=n&&"object"==typeof n?Es({symbol:n.symbol,exchange:n.exchange??""}):"",i=this._entries.get(e);if(!i||!o.ids.has(e)||!this._visible.has(e))continue;const a=Ps(n,i.key);null!==a&&(t.add(e),i.pushed>o.seq||this._accept(i,a))}for(const e of o.ids){const o=this._entries.get(e);o&&!t.has(e)&&this._visible.has(e)&&!o.quote&&(o.missing=!0)}this._error=null,this._scheduleStale(),this._onChange()},e=>{if(this._requests.delete(o)&&!this._destroyed){this._error=$s(e);for(const e of o.ids){const t=this._entries.get(e);t&&!t.quote&&this._visible.has(e)&&(t.error=this._error)}this._onChange()}})}_schedulePoll(){null!==this._poll&&(clearTimeout(this._poll),this._poll=null),this._destroyed||null===this._feed||this._feed.subscribeQuotes||0===this._pollMs||0===this._visible.size||(this._poll=setTimeout(()=>{this._poll=null,this._snapshot([...this._visible].map(e=>this._entries.get(e).key)),this._schedulePoll()},Math.min(this._pollMs,Ls)))}_expires(e){const t=this._entries.get(e);if(!t?.fresh||null===t.quote||null===t.receivedAt)return null;const o=t.stream?.status;return"live"===o||"reconnecting"===o||"disconnected"===o?null:t.receivedAt+this._staleAfter}_scheduleStale(){if(null!==this._stale&&(clearTimeout(this._stale),this._stale=null),this._destroyed)return;const e=this._now();let t=1/0;for(const o of this._visible){const n=this._expires(o);null!==n&&n>=e&&(t=Math.min(t,n))}t!==1/0&&(this._stale=setTimeout(()=>{this._stale=null,this._now()>t&&this._onChange(),this._scheduleStale()},Math.min(t-e+1,Ls)))}}const Is=[["symbol","Symbol"],["last","Last"],["change","Chg"],["percent","Chg%"]],Ds="watchlist-sort",zs=e=>JSON.stringify([e.symbol,e.exchange]),Ns=(e,t)=>e.symbol===t.symbol&&e.exchange===t.exchange,Rs=new WeakMap;function Fs(e,t,o){const n=e.document,i=o.store,a=(t,o,n={})=>Pe(e,`schema.ui.watchlist.${t}`,n,o),r=e=>""===e.exchange?e.symbol:a("entry","{symbol} on {exchange}",{symbol:e.symbol,exchange:e.exchange}),s=ko(n,"div","oac-watchlist");s.setAttribute("aria-label",a("title","Watchlist"));const l=ko(n,"div","oac-watchlist__bar"),{wrap:c,select:d}=Oo(n);d.setAttribute("aria-label",a("list","Watchlist"));const u=(e,t,o)=>{const i=Ao(n,{label:e,onClick:o});return i.setAttribute("aria-label",t),i},h=u(a("new","New"),a("newList","New list"),()=>Ce("create")),p=u(a("rename","Rename"),a("renameList","Rename list"),()=>Ce("rename")),g=u(a("delete","Delete"),a("deleteList","Delete list"),()=>function(){const e=te();if(null===e)return;ke(),y.textContent=a("confirmDelete","Delete {name} and its {count} symbols?",{name:e.name,count:e.entries.length}),x.textContent=a("deleteNamed","Delete {name}",{name:e.name}),w.hidden=!1,_.focus()}());l.append(c,h,p,g);const m=ko(n,"form","oac-watchlist__name");m.hidden=!0;const f=ko(n,"input");f.type="text",f.maxLength=120,f.setAttribute("aria-label",a("name","List name")),f.autocomplete="off";const b=Ao(n,{label:a("save","Save"),variant:"primary",onClick:()=>{Se()}}),v=Ao(n,{label:a("cancel","Cancel"),onClick:()=>ke()});m.append(f,v,b);const w=ko(n,"div","oac-watchlist__confirm");w.hidden=!0;const y=ko(n,"span","oac-watchlist__confirm-text"),_=Ao(n,{label:a("keep","Keep list"),onClick:()=>ke()}),x=Ao(n,{label:"",variant:"danger",onClick:()=>{!async function(){const e=te();if(ke(),null===e)return;de("");try{await i.removeList(e.id)}catch(e){ue(e)}}()}});w.append(y,_,x);const k=ko(n,"div","oac-watchlist__add"),C=ko(n,"input");C.type="search",C.placeholder=a("addPlaceholder","Add symbol"),C.setAttribute("aria-label",a("addSymbol","Add symbol")),C.autocomplete="off";const S=Ao(n,{label:"",onClick:()=>{const t=e.symbol();""!==t.symbol&&xe({...t})}});S.classList.add("oac-watchlist__add-current"),k.append(C,S);const A=ko(n,"div","oac-watchlist__status");A.setAttribute("role","status"),A.setAttribute("aria-live","polite");const O=ko(n,"div","oac-watchlist__message");O.setAttribute("role","alert"),O.hidden=!0;const L=ko(n,"p","oac-watchlist__empty");L.hidden=!0;const E=ko(n,"div","oac-watchlist__scroll"),$=ko(n,"table","oac-watchlist__table"),T=ko(n,"caption","oac-sr"),j=ko(n,"thead"),P=ko(n,"tr"),M=new Map;for(const[e,t]of Is){const o=ko(n,"th",`oac-watchlist__col oac-watchlist__col--${e}`);o.setAttribute("scope","col"),o.dataset.sort=e;const i=ko(n,"button","oac-watchlist__sort",a(`column.${e}`,t));i.type="button",i.addEventListener("click",()=>be(e)),o.appendChild(i),P.appendChild(o),M.set(e,o)}const I=ko(n,"th","oac-watchlist__col oac-watchlist__col--actions");I.appendChild(ko(n,"span","oac-sr",a("actions","Actions"))),P.appendChild(I),j.appendChild(P);const D=ko(n,"tbody");$.append(T,j,D),E.appendChild($),s.append(l,m,w,k,A,O,L,E),t.appendChild(s);let z=null,N=null,R=function(e){const t=e,o=t?.key;return"symbol"===o||"last"===o||"change"===o||"percent"===o?{key:o,direction:"ascending"===t?.direction?"ascending":"descending"}:{key:"list",direction:"ascending"}}(e.storage?.get(Ds)??Rs.get(i)??null),F=null,W=!1,B=!1,q=[],U=!1,H=!1,K=!1;const V=new Map,G=new Set;let J,Z;try{J=new Intl.NumberFormat(e.locale,{minimumFractionDigits:2,maximumFractionDigits:6}),Z=new Intl.NumberFormat(e.locale,{minimumFractionDigits:2,maximumFractionDigits:2})}catch{J=new Intl.NumberFormat("en-US",{minimumFractionDigits:2,maximumFractionDigits:6}),Z=new Intl.NumberFormat("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}const Y=new Ms({feed:o.quotes,staleAfterMs:o.staleAfterMs,pollMs:o.pollMs,onChange:()=>le()}),Q=n.defaultView,X=Q?.IntersectionObserver,ee=X?new X(e=>{for(const t of e)t.isIntersecting?G.add(t.target):G.delete(t.target);ce()},{root:E}):null,te=()=>z?.lists.find(e=>e.id===N)??null,oe=e=>{if(o.normalize)try{const t=o.normalize({symbol:e.symbol,exchange:e.exchange});if("string"==typeof t?.symbol&&"string"==typeof t.exchange)return{symbol:t.symbol,exchange:t.exchange}}catch{}return{symbol:e.symbol,exchange:e.exchange}},ne=(e,t)=>{if(o.formatPrice)try{return String(o.formatPrice(e,{...t}))}catch{}return J.format(e)},ie=(e,t)=>(e>0?"+":e<0?"-":"")+t(Math.abs(e));let ae=null;const re=t=>{const o=e.chart.timezone();if(ae?.zone!==o){let t=null;try{t=new Intl.DateTimeFormat(e.locale,{timeZone:o,timeStyle:"medium"})}catch{}ae={zone:o,format:t}}try{if(null!==ae.format)return ae.format.format(new Date(t))}catch{}return new Date(t).toISOString()},se=(e,t)=>{e.textContent!==t&&(e.textContent=t)};function le(){U||H||(U=!0,queueMicrotask(()=>{U=!1,ye()}))}function ce(){if(H)return;const e=!0===n.hidden;Y.setVisible(e?[]:q.map(e=>V.get(e)).filter(e=>null===ee||G.has(e.el)).map(e=>e.entry))}function de(e){O.textContent=e,O.hidden=""===e}function ue(t){de(t instanceof Error&&"WatchlistConflictError"===t.name?a("conflict","The watchlists changed in another session. The saved lists are shown."):Me(e,t)),_e()}function he(e,t=!1){if(H||!t&&null!==z&&e.revision<z.revision)return;z=e,K=!1;const o=new Set(e.lists.map(e=>e.id));N=null!==e.activeListId&&o.has(e.activeListId)?e.activeListId:null!==N&&o.has(N)?N:e.lists[0]?.id??null,pe()}function pe(){const e=te()?.entries??[],t=new Set(e.map(zs));for(const[e,o]of V)t.has(e)||(ee?.unobserve(o.el),G.delete(o.el),o.el.remove(),V.delete(e));for(const t of e){const e=zs(t);V.has(e)?V.get(e).entry=t:V.set(e,ge(t))}q=q.filter(e=>t.has(e));for(const t of e)q.includes(zs(t))||q.push(zs(t));ye(),ce()}function ge(e){const t=ko(n,"tr","oac-watchlist__row");t.dataset.symbol=e.symbol,t.dataset.exchange=e.exchange;const s=ko(n,"th","oac-watchlist__instrument");s.setAttribute("scope","row");const l=ko(n,"button","oac-watchlist__open");l.type="button",l.setAttribute("aria-label",r(e)),l.appendChild(ko(n,"span","oac-watchlist__symbol",e.symbol)),""!==e.exchange&&l.appendChild(ko(n,"span","oac-watchlist__exchange",e.exchange));const c={entry:e,el:t,open:l,last:ko(n,"td","oac-watchlist__last"),change:ko(n,"td","oac-watchlist__change"),percent:ko(n,"td","oac-watchlist__percent")};l.addEventListener("click",()=>o.onSelect?.({...c.entry})),l.addEventListener("keydown",e=>function(e,t){if("ArrowDown"!==e.key&&"ArrowUp"!==e.key)return;e.preventDefault(),e.stopPropagation();const o="ArrowDown"===e.key?1:-1;if(e.altKey)return void("list"===R.key&&function(e,t){me=me.then(async()=>{const o=te();if(H||null===o||null===z||"list"!==R.key)return;const n=o.entries.findIndex(t=>Ns(t,e)),a=n+t;if(!(n<0||a<0||a>=o.entries.length)){de("");try{await i.moveEntry(o.id,e,a,{expectedRevision:z.revision})}catch(e){ue(e)}}}).catch(()=>{})}(t.entry,o));const n=q.indexOf(zs(t.entry));V.get(q[n+o])?.open.focus()}(e,c)),s.appendChild(l);const d=ko(n,"td","oac-watchlist__actions");return d.appendChild(Ao(n,{label:a("remove","Remove {name}",{name:r(e)}),icon:"close",iconOnly:!0,onClick:()=>{!async function(e){const t=te();if(null===t)return;de("");try{await i.removeEntry(t.id,e)}catch(e){ue(e)}}(c.entry)}})),t.append(s,c.last,c.change,c.percent,d),D.appendChild(t),ee?.observe(t),c}let me=Promise.resolve();function fe(){const e=te()?.entries??[];if("list"===R.key)return e.map(zs);const t="ascending"===R.direction?1:-1,o=e=>{if("symbol"===R.key)return e.symbol;const t=Y.row(e).quote;return null===t?null:"last"===R.key?t.last:js(t)?.["change"===R.key?"change":"percent"]??null};return e.map((e,t)=>({key:zs(e),index:t,value:o(e)})).sort((e,o)=>{if(null===e.value||null===o.value)return e.value===o.value?e.index-o.index:null===e.value?1:-1;const n="string"==typeof e.value?e.value.localeCompare(o.value):e.value-o.value;return 0!==n?n*t:e.index-o.index}).map(e=>e.key)}function be(t){const o="symbol"===t?"ascending":"descending";R=R.key!==t?{key:t,direction:o}:R.direction===o?{key:t,direction:"ascending"===o?"descending":"ascending"}:{key:"list",direction:"ascending"},e.storage?.set(Ds,R),Rs.set(i,R),ye(),ce()}function ve(e){return{loading:a("state.loading","Loading"),live:a("state.live","Live"),delayed:a("state.delayed","Delayed"),snapshot:a("state.snapshot","Snapshot"),stale:a("state.stale","Stale"),unavailable:a("state.unavailable","No quote"),error:a("state.error","Could not load")}[e]}const we=()=>[...V.values()].some(e=>null!==Y.row(e.entry).quote);function ye(){if(H)return;const t=te(),o=z?.lists??[],i=JSON.stringify(o.map(e=>[e.id,e.name]));if(d.dataset.signature!==i){d.dataset.signature=i,d.textContent="";for(const e of o){const t=ko(n,"option",void 0,e.name);t.value=e.id,d.appendChild(t)}if(0===o.length){const e=ko(n,"option",void 0,a("noLists","No lists"));e.value="",d.appendChild(e)}}d.value=t?.id??"",d.disabled=0===o.length||K,p.disabled=g.disabled=null===t||K,h.disabled=K||o.length>=100,T.textContent=t?.name??a("title","Watchlist");const r=e.symbol(),l=!0===t?.entries.some(e=>Ns(oe(e),r));S.textContent=""===r.symbol?a("addChart","Add chart symbol"):a("addCurrent","Add {symbol}",{symbol:r.symbol}),S.disabled=""===r.symbol||l||K,S.title=l?a("inList","Already in this list"):"",C.disabled=K;for(const e of V.values()){const t=Y.row(e.entry),o=t.quote;e.el.dataset.state=t.status,Ns(oe(e.entry),r)?e.el.setAttribute("aria-current","true"):e.el.removeAttribute("aria-current");const n=null===o?null:js(o);se(e.last,null!==o?ne(o.last,e.entry):"loading"===t.status?a("quoteLoading","..."):a("noQuote","n/a")),se(e.change,null===n?"":ie(n.change,t=>ne(t,e.entry))),se(e.percent,null===n?"":`${ie(n.percent,e=>Z.format(e))}%`);for(const t of[e.change,e.percent])t.classList.toggle("is-up",null!==n&&n.change>0),t.classList.toggle("is-down",null!==n&&n.change<0);const i=void 0!==o?.time?1e3*o.time:t.receivedAt,s=null===i?ve(t.status):`${ve(t.status)} ${re(i)}`;e.last.title!==s&&(e.last.title=s)}const c="list"!==R.key&&(W||B)?q.concat(fe().filter(e=>!q.includes(e))).filter(e=>V.has(e)):fe(),u=n.activeElement;c.forEach((e,t)=>{const o=V.get(e).el;D.children[t]!==o&&D.insertBefore(o,D.children[t]??null)}),null!==u&&s.contains(u)&&n.activeElement!==u&&u.focus();const m=c.join("\n")!==q.join("\n");q=c,m&&queueMicrotask(ce);for(const[e,t]of M)t.setAttribute("aria-sort",R.key===e?R.direction:"none");const f=Y.status(),b=function(e){switch(e){case"unavailable":return a("status.unavailable","No quote source. Rows show symbols only.");case"snapshot":return a("status.snapshot","Snapshot quotes");case"connecting":return a("status.connecting","Connecting to quotes");case"live":return a("status.live","Live quotes");case"reconnecting":return we()?a("status.reconnecting","Reconnecting. Quotes shown may be stale."):a("status.reconnectingEmpty","Reconnecting to quotes.");case"disconnected":return we()?a("status.disconnected","Quotes disconnected. Values shown are stale."):a("status.disconnectedEmpty","Quotes disconnected.");case"error":return a("status.error","Quotes could not refresh: {error}",{error:Y.error()??""});default:return""}}(f);se(A,b),A.hidden=""===b,A.dataset.state=f,L.hidden=K||o.length>0&&(t?.entries.length??0)>0,se(L,0===o.length?a("empty.none","No watchlists yet. Add a symbol to start one."):a("empty.list","This list is empty. Add the chart symbol or type one above.")),E.hidden=0===(t?.entries.length??0)}async function _e(){try{he(await i.load(),!0)}catch(t){if(H)return;K=!0,de(a("loadFailed","Watchlists could not load: {error}",{error:Me(e,t)})),ye()}}async function xe(e){de("");const t=oe(e),o=te();if(o?.entries.some(e=>Ns(oe(e),t)))de(a("duplicate","{name} is already in this list",{name:r(t)}));else try{if(null===o){const e=await i.createList(a("defaultName","Watchlist"),[t]);await i.setActiveList(e.id)}else await i.addEntry(o.id,t)}catch(e){ue(e)}}function ke(){F=null,m.hidden=!0,w.hidden=!0}function Ce(e){ke(),F=e,f.value="rename"===e?te()?.name??"":a("newName","List {number}",{number:(z?.lists.length??0)+1}),m.hidden=!1,f.focus(),f.select?.()}async function Se(){const e=f.value.trim(),t=F;if(""===e||null===t)return;const o=te();ke(),de("");try{if("create"===t){const t=await i.createList(e);await i.setActiveList(t.id)}else null!==o&&await i.renameList(o.id,e)}catch(e){ue(e)}}const Ae=()=>{const e=d.value;""!==e&&e!==N&&null!==z&&(N=e,ke(),pe(),i.setActiveList(e).catch(ue))};d.addEventListener("change",Ae);const Oe=e=>{e.preventDefault(),Se()};m.addEventListener("submit",Oe);const Le=e=>{"Escape"!==e.key||m.hidden||(e.stopPropagation(),ke())};m.addEventListener("keydown",Le);let Ee=null;e.symbolSearch&&(Ee=bn(e,C,{search:e.symbolSearch,onSelect:(t,o)=>{C.value="",xe({symbol:t,exchange:o??e.symbol().exchange})}}));const $e=t=>{if("Enter"!==t.key||t.defaultPrevented)return;t.preventDefault();const o=C.value.trim().toUpperCase();""===o||null!==Ee&&!Ee.canCommitRaw()||(Ee?.close(),C.value="",xe({symbol:o,exchange:e.symbol().exchange}))};C.addEventListener("keydown",$e);const Te=()=>{W=!0},je=()=>{W=!1,le()};D.addEventListener("pointerenter",Te),D.addEventListener("pointerleave",je);const Ie=()=>{B=!0},De=e=>{const t=e.relatedTarget;null!==t&&D.contains(t)||(B=!1,le())};D.addEventListener("focusin",Ie),D.addEventListener("focusout",De);const ze=e=>{"Escape"!==e.key&&"Tab"!==e.key&&e.stopPropagation()},Ne=e=>{e.stopPropagation()};s.addEventListener("keydown",ze),s.addEventListener("pointerdown",Ne);const Re=()=>ce();n.addEventListener("visibilitychange",Re);const Fe=e.chart.on("data:context",()=>le()),We=e.chart.on("timezone:changed",()=>le()),Be=i.subscribe(e=>he(e));return ye(),_e(),{el:s,initialFocus:d,reload:_e,destroy:()=>{H||(H=!0,Y.destroy(),ee?.disconnect(),Ee?.destroy(),Be(),Fe(),We(),n.removeEventListener("visibilitychange",Re),d.removeEventListener("change",Ae),m.removeEventListener("submit",Oe),m.removeEventListener("keydown",Le),C.removeEventListener("keydown",$e),D.removeEventListener("pointerenter",Te),D.removeEventListener("pointerleave",je),D.removeEventListener("focusin",Ie),D.removeEventListener("focusout",De),s.removeEventListener("keydown",ze),s.removeEventListener("pointerdown",Ne),V.clear(),G.clear(),s.remove())}}}const Ws='\n.oac-widget .oac-watchlist { display: flex; flex-direction: column; gap: 6px; height: 100%; min-height: 0; padding: 8px 10px 0; box-sizing: border-box; font-size: 12px; }\n.oac-widget .oac-watchlist__bar, .oac-widget .oac-watchlist__add, .oac-widget .oac-watchlist__name, .oac-widget .oac-watchlist__confirm { display: flex; align-items: center; gap: 4px; flex: none; min-width: 0; }\n.oac-widget .oac-watchlist__bar .oac-select { flex: 1 1 auto; min-width: 0; }\n.oac-widget .oac-watchlist__bar .oac-select select { width: 100%; min-width: 0; }\n.oac-widget .oac-watchlist .oac-btn { height: 26px; padding: 0 7px; font-size: 11px; flex: none; }\n.oac-widget .oac-watchlist__name[hidden], .oac-widget .oac-watchlist__confirm[hidden], .oac-widget .oac-watchlist__scroll[hidden] { display: none; }\n.oac-widget .oac-watchlist__name input, .oac-widget .oac-watchlist__add input { flex: 1 1 auto; min-width: 0; height: 26px; }\n.oac-widget .oac-watchlist__confirm { flex-wrap: wrap; }\n.oac-widget .oac-watchlist__confirm-text { flex: 1 1 100%; color: var(--oac-tx); overflow-wrap: anywhere; }\n.oac-widget .oac-watchlist__add-current { max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.oac-widget .oac-watchlist__status { flex: none; font-size: 11px; color: var(--oac-mut); }\n.oac-widget .oac-watchlist__status[data-state="live"] { color: var(--oac-tx); }\n.oac-widget .oac-watchlist__status[data-state="reconnecting"], .oac-widget .oac-watchlist__status[data-state="disconnected"], .oac-widget .oac-watchlist__status[data-state="error"] { color: var(--oac-danger); }\n.oac-widget .oac-watchlist__message { flex: none; font-size: 11px; color: var(--oac-danger); overflow-wrap: anywhere; }\n.oac-widget .oac-watchlist__empty { margin: 6px 0; font-size: 11px; color: var(--oac-mut); }\n.oac-widget .oac-watchlist__scroll { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; margin: 0 -10px; }\n/* Numbers take the width they need and the symbol the rest, so a price is never the part cut short. */\n.oac-widget .oac-watchlist__table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }\n.oac-widget .oac-watchlist__table thead th { position: sticky; top: 0; z-index: 1; background: var(--oac-panel); border-bottom: 1px solid var(--oac-bd-soft); padding: 0; }\n.oac-widget .oac-watchlist__sort { width: 100%; height: 24px; padding: 0 6px; border: 0; background: none; color: var(--oac-mut); font: 600 10px/1 var(--oac-font); text-transform: uppercase; letter-spacing: .04em; text-align: right; white-space: nowrap; cursor: pointer; }\n.oac-widget .oac-watchlist__col--symbol .oac-watchlist__sort { text-align: left; padding-left: 10px; }\n.oac-widget .oac-watchlist__sort:hover, .oac-widget th[aria-sort="ascending"] .oac-watchlist__sort, .oac-widget th[aria-sort="descending"] .oac-watchlist__sort { color: var(--oac-tx); }\n.oac-widget th[aria-sort="ascending"] .oac-watchlist__sort::after { content: " \\2191"; }\n.oac-widget th[aria-sort="descending"] .oac-watchlist__sort::after { content: " \\2193"; }\n.oac-widget .oac-watchlist__col--symbol { width: 100%; }\n.oac-widget .oac-watchlist__col--actions { width: 26px; min-width: 26px; }\n.oac-widget .oac-watchlist__row { height: 28px; border-bottom: 1px solid var(--oac-bd-soft); }\n.oac-widget .oac-watchlist__row:hover, .oac-widget .oac-watchlist__row:focus-within { background: var(--oac-elev); }\n/* On the cell: some engines paint no shadow on a table row. */\n.oac-widget .oac-watchlist__row[aria-current="true"] > th { box-shadow: inset 2px 0 0 var(--oac-acc); }\n.oac-widget .oac-watchlist__row td, .oac-widget .oac-watchlist__row th { padding: 0 6px; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 400; }\n.oac-widget .oac-watchlist__row .oac-watchlist__instrument { padding: 0; max-width: 0; text-align: left; }\n.oac-widget .oac-watchlist__open { display: block; width: 100%; height: 28px; line-height: 28px; padding: 0 6px 0 10px; border: 0; background: none; color: var(--oac-tx); font: inherit; text-align: left; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.oac-widget .oac-watchlist__symbol { font-weight: 600; }\n.oac-widget .oac-watchlist__exchange { margin-left: 5px; font-size: 10px; color: var(--oac-mut); }\n.oac-widget .oac-watchlist__last { color: var(--oac-tx); }\n/* The theme\'s own pair, lifted to read as text. A fallback colour here would pin one palette. */\n.oac-widget .oac-watchlist .is-up { color: var(--oac-up); }\n.oac-widget .oac-watchlist .is-down { color: var(--oac-down); }\n.oac-widget .oac-watchlist__row[data-state="stale"] td, .oac-widget .oac-watchlist__row[data-state="unavailable"] td, .oac-widget .oac-watchlist__row[data-state="error"] td, .oac-widget .oac-watchlist__row[data-state="loading"] td { color: var(--oac-mut); }\n.oac-widget .oac-watchlist__row[data-state="stale"] .oac-watchlist__last { text-decoration: underline dotted; text-underline-offset: 3px; }\n.oac-widget .oac-watchlist__actions { padding: 0 4px 0 0 !important; }\n.oac-widget .oac-watchlist__actions .oac-btn { width: 22px; height: 22px; padding: 0; border-color: transparent; background: transparent; color: var(--oac-mut); opacity: 0; }\n.oac-widget .oac-watchlist__row:hover .oac-watchlist__actions .oac-btn, .oac-widget .oac-watchlist__row:focus-within .oac-watchlist__actions .oac-btn { opacity: 1; }\n.oac-widget .oac-panel-dock[data-sheet="true"] .oac-watchlist__actions .oac-btn { opacity: 1; width: 32px; height: 32px; }\n.oac-widget .oac-panel-dock[data-sheet="true"] .oac-watchlist__row, .oac-widget .oac-panel-dock[data-sheet="true"] .oac-watchlist__open { height: 40px; line-height: 40px; }\n@media (hover: none) { .oac-widget .oac-watchlist__actions .oac-btn { opacity: 1; } }\n';function Bs(e,t,o){const n=e.document,i=o.source,a=o.locale??e.locale,r=De(n,"span","oac-account",{role:"group","aria-label":Pe(e,"Account")}),s=De(n,"button","oac-account__pick",{type:"button","aria-haspopup":"menu"}),l=De(n,"span","oac-account__name"),c=De(n,"span","oac-chev");c.innerHTML=oe("chevron-down"),s.appendChild(l),s.appendChild(c),r.appendChild(s);const d=(e,t)=>{const o=De(n,"span",`oac-account__field ${e}`),i=De(n,"i");i.textContent=t;const a=De(n,"b");return o.appendChild(i),o.appendChild(a),r.appendChild(o),{el:o,val:a}},u=d("oac-account__equity",Pe(e,"Equity")),h=d("oac-account__used",Pe(e,"Margin used")),p=d("oac-account__available",Pe(e,"Available")),g=De(n,"span","oac-account__state");r.appendChild(g);const m=t.querySelector(".oac-statusline__tz");null!==m&&m.parentNode===t?t.insertBefore(r,m):t.appendChild(r),t.classList.add("oac-has-account");const f=new Map,b=(e,t)=>{e.textContent!==t&&(e.textContent=t)},v=(e,t)=>{e.hidden===t&&(e.hidden=!t)},w=(e,t,o)=>{v(e.el,null!==o&&void 0!==t),null!==o&&void 0!==t&&b(e.val,((e,t)=>{const o=t??"";let n=f.get(o);if(void 0===n){const e={minimumFractionDigits:2,maximumFractionDigits:2};try{n=new Intl.NumberFormat(a,void 0===t?e:{...e,style:"currency",currency:t})}catch{n=new Intl.NumberFormat(a,e)}f.set(o,n)}return n.format(e)})(t,o.currency))};let y=null;const _=()=>{const t=i.getState();r.dataset.status=t.status;const o="unsupported"===t.status;r.classList.toggle("is-disabled",o),o?r.setAttribute("aria-disabled","true"):r.removeAttribute("aria-disabled");const a=t.accounts.find(e=>e.id===t.selectedId),c=void 0===a?Pe(e,"Account"):a.name??a.id;b(l,c),s.setAttribute("aria-label",void 0===a?c:Pe(e,"Account: {name}",{name:c})),s.disabled=o||0===t.accounts.length;const d=!o&&"analyzer"===t.mode;d&&null===y?(y=De(n,"span","oac-account__tag"),y.textContent=Pe(e,"Analyzer"),r.insertBefore(y,u.el)):d||null===y||(y.remove(),y=null);const m=o?null:t.snapshot;w(u,m?.equity,m),w(h,m?.marginUsed,m),w(p,m?.marginAvailable,m),s.title=[u,h,p].filter(e=>!e.el.hidden).map(e=>`${e.el.firstChild?.textContent??""} ${e.val.textContent??""}`).join(", ");const f=o||"error"===t.status?t.reason??"":"stale"===t.status?Pe(e,"Stale"):"loading"===t.status?Pe(e,"Loading account"):"";b(g,f),g.title=t.reason??"",g.classList.toggle("is-error","error"===t.status),g.classList.toggle("is-stale","stale"===t.status),v(g,""!==f)},x=()=>{const t=i.getState();"unsupported"!==t.status&&0!==t.accounts.length&&Ro(e,s,t.accounts.map(o=>({label:o.name??o.id,sub:o.id,on:o.id===t.selectedId,onSelect:()=>{const t=t=>{e.toast(Pe(e,"Could not switch account: {error}",{error:t}),"error")};i.select(o.id).then(e=>{e.ok||!0===e.cancelled||t(e.reason)},o=>t(Me(e,o)))}})),{ariaLabel:Pe(e,"Accounts")})};s.addEventListener("click",x);const k=i.subscribe(_);return _(),{el:r,refresh:_,destroy:()=>{k(),s.removeEventListener("click",x),t.classList.remove("oac-has-account"),r.remove()}}}const qs='\n.oac-widget .oac-statusline.oac-has-account{container:oac-status/inline-size}\n.oac-widget .oac-statusline.oac-has-account .oac-statusline__time{flex:0 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis}\n.oac-widget .oac-statusline .oac-account{flex:none}\n.oac-widget .oac-account>.oac-account__pick,.oac-widget .oac-account>.oac-account__tag,.oac-widget .oac-account>.oac-account__field{flex:none}\n.oac-widget .oac-account{display:inline-flex;align-items:center;gap:10px;min-width:0;white-space:nowrap;font-variant-numeric:tabular-nums}\n.oac-widget .oac-account__pick{display:inline-flex;align-items:center;gap:4px;max-width:180px;height:20px;padding:0 6px;border:1px solid var(--oac-bd);border-radius:5px;background:var(--oac-elev);color:var(--oac-tx-strong);font-size:11.5px;font-weight:600}\n.oac-widget .oac-account__pick:hover:not(:disabled){border-color:var(--oac-bd-hover)}\n.oac-widget .oac-account__pick:disabled{cursor:not-allowed;color:var(--oac-faint)}\n.oac-widget .oac-account__name{min-width:0;overflow:hidden;text-overflow:ellipsis}\n.oac-widget .oac-account__pick .oac-chev{display:inline-grid;width:10px;height:10px;color:var(--oac-mut)}\n.oac-widget .oac-account__tag{padding:0 5px;border:1px solid var(--oac-bd-soft);border-radius:4px;color:var(--oac-amber);font-size:10px;font-weight:600;letter-spacing:.5px;text-transform:uppercase}\n.oac-widget .oac-account__field{display:inline-flex;align-items:center;gap:4px}\n.oac-widget .oac-account__field>i{font-style:normal;color:var(--oac-faint)}\n.oac-widget .oac-account__field>b{font-weight:500;color:var(--oac-tx)}\n.oac-widget .oac-account__state{min-width:0;max-width:320px;overflow:hidden;text-overflow:ellipsis;color:var(--oac-mut)}\n.oac-widget .oac-account__state.is-stale{color:var(--oac-amber)}\n.oac-widget .oac-account__state.is-error{color:var(--oac-danger)}\n.oac-widget .oac-account.is-disabled .oac-account__state{color:var(--oac-faint)}\n.oac-widget .oac-account[data-status="stale"] .oac-account__field>b{color:var(--oac-mut)}\n@container oac-status (max-width:1180px){.oac-widget .oac-account__used{display:none}}\n@container oac-status (max-width:1000px){.oac-widget .oac-account__equity{display:none}}\n@container oac-status (max-width:860px){.oac-widget .oac-account__available{display:none}\n.oac-widget .oac-statusline .oac-statusline__title{order:-2}.oac-widget .oac-statusline .oac-account{order:-1}}\n',Us=Pr+nr+bs+ks+In+vn+Ss+po+"\n.oac-widget .oac-pick__running-head { margin-top: 10px; border-top: 1px solid var(--oac-bd); padding-top: 9px; }\n.oac-widget .oac-pick__running { display: grid; gap: 1px; max-height: 132px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--oac-sb-thumb) transparent; }\n.oac-widget .oac-pick__running::-webkit-scrollbar { width: 6px; }\n.oac-widget .oac-pick__running::-webkit-scrollbar-thumb { background: var(--oac-sb-thumb); border-radius: 3px; }\n.oac-widget .oac-pick__running-row { display: flex; align-items: center; gap: 7px; min-height: 29px; padding: 2px 6px; }\n.oac-widget .oac-pick__running-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.oac-widget .oac-pick__running-number { min-width: 16px; color: var(--oac-mut); font-size: 11px; text-align: right; }\n.oac-widget .oac-pick__running-row .oac-pick__remove { height: 23px; min-height: 23px; padding: 2px 6px; }\n"+zr+Os+Ws+gs+qs+ss+wa+Oa+Qr+"\n.oac-widget .oac-topbar__layouts { max-width: 190px; }\n.oac-widget .oac-topbar__layouts-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n/* The name gives way before the bar wraps to a second row: the glyph, the unsaved mark, the tip and the\n accessible name still carry it. Measured on the default bar, which needs about 1000 px on one row. */\n.oac-widget .oac-topbar.has-layouts { container: oac-topbar / inline-size; }\n@container oac-topbar (max-width: 1199px) { .oac-widget .oac-topbar__layouts-name { max-width: 96px; } }\n@container oac-topbar (max-width: 1139px) { .oac-widget .oac-topbar__layouts-name { display: none; } }\n.oac-widget .oac-topbar__layouts[data-attention=\"true\"]::after { content: ''; width: 6px; height: 6px; flex: none; border-radius: 50%; background: var(--oac-amber); }\n",Hs=e=>e instanceof Error?e:new Error(String(e));function Ks(e){return function(e,t){const o=e._opts,n=e.chart,i=o.ranges??Fr,a=o.sessionCalendar;let r=null,s=null;const l=(e,t)=>{if("function"!=typeof a)return a??null;const o=`${t}\0${e}`;if(o!==r){r=o;try{s=""===e?null:a({symbol:e,exchange:t})??null}catch{s=null}}return s},c=()=>void 0===a?n.dataLayer.sessionCalendar:l(e._symbol,e._exchange);if(void 0!==a){const t=()=>{n.isDestroyed||(n.setSessionCalendar(l(e._symbol,e._exchange)),e._statusline?.refresh())};t(),e._cleanups.push(e._bus.on("symbol",t))}if(!1!==o.sessionShading){const t=B(n);e._cleanups.push(()=>t.destroy())}e._cleanups.push(n.on("timezone:changed",()=>{e._destroyed||(e._scheduleSave(),e._bus.emit("layout",{reason:"timezone"}))}));let d=null,u=!1,h=0;const p=()=>{const t=d;return null===t||t.interval!==e._interval?null:i.find(e=>e.id===t.id)??null},g=e=>{const t=n.primaryBars(),o=t[t.length-1];if(void 0===o)return e;const i=n.dataLayer.timeToIndex(o.time)??t.length-1,a=n.getVisibleLogicalRange(),r=i+.5-(a.to-a.from);return n.setVisibleLogicalRange({from:r,to:i+.5}),{...e,from:n.dataLayer.indexToTime(Math.ceil(r+.5))??e.from,to:o.time}},m=async(t,o)=>{for(let t=0;t<4&&null!==e._loading;t++){try{await e._loading}catch{}if(o!==h||e._destroyed)return{status:"cancelled"}}if(o!==h||e._destroyed)return{status:"cancelled"};const i=n.primaryBars();if(0===i.length)return{status:"no-data"};const a="all"===t.unit,r=Kr(t,{end:i[i.length-1].time,zone:n.timezone(),calendar:c(),bars:a?void 0:i});let s=await e.goTo(r);return o!==h||e._destroyed?s:(!a||"partial"!==s.status||"exhausted"!==s.history&&"empty"!==s.history||(s={status:!0===s.clipped?"partial":"placed",from:s.from,to:s.to,...!0===s.clipped?{clipped:!0}:{}}),"partial"===s.status&&!0===s.clipped?g(s):s)},f=async t=>{const o=i.find(e=>e.id===t);if(void 0===o||e._destroyed)return{status:"invalid"};const n=++h,a=Br(o,e._intervals);d={id:t,interval:a},u=!0;try{e.setInterval(a)}catch(e){return d=null,{status:"error",error:Hs(e)}}finally{u=!1}return m(o,n)};e._cleanups.push(e._bus.on("interval",()=>{u||(d=null,h++)}));const b=()=>{const e=p();null!==e&&m(e,++h)};e._cleanups.push(e._bus.on("symbol",b)),e._cleanups.push(e._bus.on("variant",b));const v=(e,t)=>{const o=p();if(null===o)return e;const i=Kr(o,{end:t,zone:n.timezone(),calendar:c()});return{from:Math.min(i.from,e.from),to:e.to}};let w;if(!1!==o.bottombar){const a=De(e.context.document,"div","oac-bottombar");!1===o.topbar&&a.classList.add("is-kept"),e.root.insertBefore(a,t),e.root.classList.add("has-bottombar");const r=Yr(e.context,a,{target:()=>({chart:n,interval:()=>e._interval,range:()=>p()?.id??null,setRange:f}),ranges:i,onGoTo:t=>e._openGoTo(t),now:()=>(o.now??Date.now)()});w=r.controls,e._cleanups.push(()=>{r.destroy(),a.remove(),e.root.classList.remove("has-bottombar")})}return{setRange:f,range:()=>p()?.id??null,fetchWindow:v,controls:w}}(this,e)}const Vs=["1m","5m","15m","1h","1d","1w"],Gs=500,Js=250,Zs="state",Ys="drawings:",Qs=1,Xs=new WeakMap,el=["feed","symbol","exchange","interval","variant","intervals","chartType","theme","rail","topbar","statusline","mobile","loading","persist","storage","drawingScope","drawingStore","locale","translate","indicators","symbolSearch","lookbackBars","now","onOrder","styleNonce","tradingCapabilities","tradingMode","tradingLocked","account","eventDetails","captureRows","panels","typingNavigation","keyboardRoute","watchlist","news","drawingTemplates","drawingToolbar","shortcutsEditor","workspaces","layouts","bottombar","ranges","sessionCalendar","sessionShading"];function tl(e){return Bn(e)}function ol(e){return"light"===e?{theme:q,name:"light"}:"dark"===e||void 0===e?{theme:U,name:"dark"}:{theme:e,name:Qi(e)}}function nl(e,t,o){const n=w(e),i=null!==n&&"interval"===n.bucketing.mode?n.bucketing.seconds:null;return{from:o-(null===i?15768e4:Math.max(1,Math.round(t))*i),to:o}}class il{constructor(e,t){Object.defineProperty(this,"chart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"draw",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"objects",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"alerts",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"history",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"drawingTemplates",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"root",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"document",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"keymap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"bus",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"storage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"locale",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"translate",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"symbolSearch",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"toast",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"openOverlay",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tips",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"overlays",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"symbol",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"interval",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"intervals",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_source",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._source=e,this.chart=t.chart,this.draw=t.draw,this.objects=t.objects,this.alerts=t.alerts,this.history=t.history,this.root=t.root,this.document=t.document,this.keymap=t.keymap,this.bus=t.bus,this.storage=t.storage,this.locale=t.locale,this.translate=t.translate,this.symbolSearch=t.symbolSearch,this.toast=t.toast,this.openOverlay=t.openOverlay,this.status=t.status,this.tips=t.tips,this.overlays=t.overlays,this.symbol=t.symbol,this.interval=t.interval,this.intervals=t.intervals}get theme(){return this._source.theme()}get chartTheme(){return this._source.chartThemeInUse()}}function al(e,t,o){const n={...e};for(const e of el)delete n[e];void 0===e.navigation?.defaultVisibleBars&&void 0===e.navigation?.defaultBarSpacing&&(n.navigation={...e.navigation,defaultBarSpacing:e.timeScale?.barSpacing??8});const i=!0===t.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches;i&&void 0===n.animZoom&&(n.animZoom=!1),i&&void 0===n.animAutoscale&&(n.animAutoscale=!1);const a=e.keyboardRoute,r=e.shortcuts;if(void 0!==a&&!1!==r){const e=r instanceof Y?r:new Y(r);n.shortcuts=new Proxy(e,{get:(e,t)=>{if("scope"===t)return"global";if("resolve"===t)return t=>a()??("global"===e.scope||o())?e.resolve(t):null;const n=Reflect.get(e,t);return"function"==typeof n?n.bind(e):n}})}return n}function rl(e,t){const o=De(e.document,"span","oac-tip-spot",{"aria-hidden":"true"});e.root.appendChild(o);let n=null;e.tips.attach(o,()=>null===n?null:{title:n,side:"bottom"});const i=t=>{const n=e.root.getBoundingClientRect();o.style.left=t.clientX-n.left+"px",o.style.top=t.clientY-n.top+"px"};t.addEventListener("pointermove",i);const a=e.chart.on("hover",t=>{const i=t.id;n=null===i?null:(t=>{const o=t.lastIndexOf("::");if(o<0)return null;const n=t.slice(0,o),i=t.slice(o+2);if(/^(?:ord|order):/.test(n))return"close"===i?Pe(e,"Cancel order"):null;if(/^(?:pos|position):/.test(n))return"close"===i?Pe(e,"Close position"):null;const a=n.startsWith("indicator:")?e.chart.indicators().find(e=>e.id===n.slice(10)):void 0;if(void 0===a)return null;const r=a.name;return"hide"===i?Pe(e,a.visible()?"Hide {name}":"Show {name}",{name:r}):"settings"===i?Pe(e,"Settings for {name}",{name:r}):"close"===i?Pe(e,"Remove {name}",{name:r}):null})(i),null!==n?e.tips.show(o):e.tips.target()===o&&e.tips.hide()});return()=>{a(),t.removeEventListener("pointermove",i),o.remove()}}class sl{constructor(e,t){Object.defineProperty(this,"dataController",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"chart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"draw",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"instrumentDrawings",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"drawingTemplates",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"objects",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"alerts",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"history",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"root",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"context",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ready",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_series",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_doc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_opts",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_bus",{enumerable:!0,configurable:!0,writable:!0,value:new ti}),Object.defineProperty(this,"_storage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_keymap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_toasts",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_chartEl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_rail",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_topbar",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_statusline",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_mobile",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_drawbar",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_objectsPanel",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_dock",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_quickEntry",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_alertsPanel",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_goToPanel",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_layouts",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_navigator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_bottombar",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_navigation",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_loading",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_anchoring",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_intervals",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_symbol",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_exchange",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_interval",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_variant",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_chartType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_chartTypeRequest",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_themeName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_chartTheme",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pointerInside",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_pointerInChart",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_dataStatus",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_displayedBars",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_dataState",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_initialView",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"_pendingView",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_keepView",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_saveTimer",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_restoring",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_holdDrawings",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_saveWanted",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_stateGiven",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_cleanups",{enumerable:!0,configurable:!0,writable:!0,value:[]}),this._opts=t,this.dataController=t.feed?new H(t.feed,{now:()=>Math.floor((t.now??Date.now)()/1e3),...t.loading}):null,this._navigator=new Cn({chart:()=>this.chart,loadHistory:e=>this._loadHistory(e)});const o=t.document??e.ownerDocument;this._doc=o,ua(o,Us,t.styleNonce);const n="string"==typeof t.persist?t.persist:"default",i=t.persist?void 0===t.storage?wt():t.storage:null;this._storage=new Ve(n,i,{onError:e=>ii.call(this,e)}),this._restoring=!this._storage.loaded,this._holdDrawings=this._restoring;const a=Zn.call(this);this._symbol=(t.symbol??a?.symbol??"").toUpperCase(),this._exchange=t.exchange??a?.exchange??"",void 0!==t.interval&&K(t.interval);for(const e of t.intervals??[])K(e);const r=null!==a&&A(a.interval)?a.interval:"1d";this._interval=t.interval??r,this._variant=void 0!==t.variant?S(t.variant):a?.variant;const l=t.chartType??a?.chartType??"candlestick";if(void 0!==t.chartType&&!pn(t.chartType))throw new Error(`openalgo-charts widget: "${t.chartType}" is not a registered chart type`);this._chartType=pn(l)?l:"candlestick";const d=ol(t.theme??a?.theme);this._themeName=d.name,this._chartTheme=d.theme;const u=new Set(t.intervals??[...Vs,...s().map(e=>e.code)]);u.add(this._interval),this._intervals=Array.from(u);const h=De(o,"div","oac-widget");h.dataset.theme=this._themeName,sa(h,ra(this._chartTheme,this._themeName)),this.root=h;const p=De(o,"div","oac-topbar");!1===t.topbar&&(p.hidden=!0),h.appendChild(p);const g=De(o,"div","oac-stage");h.appendChild(g);const m=De(o,"div","oac-rail");!1===t.rail&&(m.hidden=!0),g.appendChild(m);const f=De(o,"div","oac-chart");this._chartEl=f,g.appendChild(f);const b=De(o,"div","oac-statusline");!1===t.statusline&&(b.hidden=!0),h.appendChild(b);const v=De(o,"div","oac-toasts");h.appendChild(v),e.appendChild(h),this.chart=V(f,{...al(t,o,()=>this._inChart()),theme:this._chartTheme,document:o}),f.setAttribute("aria-label",t.ariaLabel??Pe(t,"Price chart"));const w=this._transformFor(this._chartType,void 0===t.chartType?a?.chart:void 0);this._series=this.chart.addSeries(null===w?this._chartType:E(w.type).renderer,null===w?{}:{transform:w}),this._publishDataContext(),this.draw=new Ee(this.chart,{}),this.instrumentDrawings="chart"===t.drawingScope?null:Un.call(this,a),this.alerts=new G(this.chart,{drawings:this.draw}),this.objects=new J(this.chart,{drawings:this.draw,drawingName:e=>Pe(t,`schema.drawing.${e}.name`,{},Vo(e)),onSettings:e=>{"source"===e.kind?this.openSettings():"indicator"===e.kind?lr(this.context,void 0,{instanceId:e.sourceId}):"drawing"===e.kind&&qa(this.context,void 0,{ids:[e.sourceId]})}}),this.history=new Pt(this.chart,{draw:this.draw,series:()=>this._series,setChartType:e=>this.setChartType(e),onError:({direction:e,error:t})=>{const o=Me(this.context,t);this._toasts.toast(Pe(this.context,"undo"===e?"That step could not be undone: {error}":"That step could not be redone: {error}",{error:o}),"error")}});const y=Ze(h,o),_=Qe(h,y.layer,o);this._toasts=Wi(v,o,t);const x=this.chart.shortcuts;this._keymap=new eo({chart:x,scopes:()=>Dn.call(this)}),this._keymap.onConflict(e=>this._bus.emit("keymap:conflict",{combo:e.combo,kept:e.kept,shadowed:e.shadowed}));const k=t.symbolSearch??function(e,t){if("function"==typeof e?.searchSymbols)return async(o,n)=>{const i=await e.searchSymbols({query:o,signal:n?.signal}),a=o.trim().toUpperCase(),r=i.findIndex(e=>!e.contractGroup&&e.exchange===t()&&e.symbol.toUpperCase()===a);return r>0?[i[r],...i.slice(0,r),...i.slice(r+1)]:i}}(t.feed,()=>this._exchange);if(this.context=new il(this,{chart:this.chart,draw:this.draw,objects:this.objects,alerts:this.alerts,history:this.history,root:h,document:o,keymap:this._keymap,bus:this._bus,storage:this._storage,locale:t.locale,translate:t.translate,symbolSearch:k,toast:(e,t)=>this._toasts.toast(e,t),openOverlay:(e,t)=>y.open(e,t),status:(e,t="info")=>{this._statusline?.setMessage(e,t),this._bus.emit("status",{text:e,kind:t})},tips:_,overlays:y,symbol:()=>({symbol:this._symbol,exchange:this._exchange}),interval:()=>this._interval,intervals:void 0===t.intervals?void 0:this._intervals}),this._cleanups.push(()=>{_.destroy(),y.destroy()}),this._cleanups.push(rl(this.context,f)),!1!==t.eventDetails&&this._cleanups.push(function(e,t,o){const n=e.chart,i=!1===o.eventDetails?void 0:o.eventDetails,a=new ws(t,{styleNonce:o.styleNonce,overlays:e.overlays,formatTime:e=>{const t=new Date(1e3*e);return Number.isFinite(t.getTime())?new Intl.DateTimeFormat(o.locale,{timeZone:n.timezone(),dateStyle:"medium",timeStyle:"short"}).format(t):String(e)},...i,labels:{...vs(e),...i?.labels},injectStyles:!1}),r=[n.on("event:click",e=>{const t=e;a.open(t,t.point)}),n.on("data:context",()=>a.close()),n.on("events:change",()=>a.close())];return()=>{for(const e of r)e();a.destroy()}}(this.context,f,t)),this._dataStatus=function(e,t,o,n){const i=De(e.document,"div","oac-data-status");i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),i.setAttribute("aria-atomic","true"),i.hidden=!0,t.appendChild(i);let a=o?.getState()??null,r="",s=!1;const l=e=>e.stopPropagation();for(const e of["pointerdown","wheel","keydown"])i.addEventListener(e,l);const d=()=>{if(s)return;const t=[];if(null!==a){const i=a.request?.symbol??"",r=a.request?.interval??"";switch(a.status){case"loading":t.push({text:Pe(e,"Loading {symbol} {interval}",{symbol:i,interval:r})});break;case"refreshing":t.push({text:Pe(e,"Refreshing {symbol} {interval}",{symbol:i,interval:r})});break;case"empty":t.push({text:Pe(e,"No bars for {symbol} {interval}",{symbol:i,interval:r}),label:Pe(e,"Retry chart data"),retry:n});break;case"stale":t.push({text:Pe(e,"History is stale for {symbol} {interval}",{symbol:i,interval:r}),label:Pe(e,"Retry chart data"),retry:n});break;case"error":t.push({text:Pe(e,"Could not load {symbol} {interval}",{symbol:i,interval:r}),label:Pe(e,"Retry chart data"),retry:n});break;case"unsupported":t.push({text:Pe(e,"Not available from this source: {variant}",{variant:Xo(e,a.request?.variant,a.unsupported)})})}"limited"===a.historyStatus?t.push({text:Pe(e,"History retention limit reached")}):"loading"===a.historyStatus?t.push({text:Pe(e,"Loading older history")}):"error"===a.historyStatus&&t.push({text:Pe(e,"Could not load older history"),label:Pe(e,"Retry older history"),retry:()=>{o?.loadMore()}})}for(const o of e.chart.indicators()){const n=o.dataStatus();if(null===n||"ready"===n.state)continue;if("error"===n.state&&n.error instanceof c){const i=Me(e,n.error);t.push({text:i.startsWith(`${o.name}: `)?i:Pe(e,"{name}: {error}",{name:o.name,error:i})});continue}const i={loading:Pe(e,"Loading"),empty:Pe(e,"No data"),unsupported:Pe(e,"Unsupported"),error:Pe(e,"Could not load")}[n.state];t.push({text:`${o.name}: ${i}`,label:Pe(e,"Retry {name}",{name:o.name}),retry:"loading"===n.state?void 0:()=>o.retryData()})}const l=JSON.stringify(t.map(e=>[e.text,e.label,!!e.retry]));if(r!==l){r=l,i.textContent="",i.hidden=0===t.length;for(const o of t){const t=De(e.document,"div","oac-data-status__row"),n=De(e.document,"span","oac-data-status__text");if(n.textContent=o.text,t.appendChild(n),o.retry){const n=De(e.document,"button","oac-btn");n.textContent=Pe(e,"Retry"),n.type="button",n.setAttribute("aria-label",o.label),n.addEventListener("click",o.retry),t.appendChild(n)}i.appendChild(t)}}},u=()=>{d(),queueMicrotask(d)},h=["indicator:data-status","indicatorRemoved"].map(t=>e.chart.on(t,u));return d(),{el:i,update:e=>{a=e,d()},destroy:()=>{s=!0;for(const e of h)e();for(const e of["pointerdown","wheel","keydown"])i.removeEventListener(e,l);i.remove()}}}(this.context,g,this.dataController,()=>{this.reload()}),!1!==t.panels&&(this._dock=Mn(this.context,g,{data:e=>xs(this.context,e),objects:e=>{const t=tr(this.context);return e.appendChild(t.element),t},...t.watchlist?{watchlist:e=>Fs(this.context,e,{...t.watchlist,onSelect:e=>this.setSymbol(e.symbol,e.exchange),normalize:e=>({symbol:e.symbol.trim().toUpperCase(),exchange:e.exchange})})}:{},...t.news?{news:e=>ps(this.context,e,t.news)}:{},onChange:()=>{this._bus.emit("layout",{reason:"panels"}),this._scheduleSave()}})),this._cleanups.push(Tr(this.context,{...t.onOrder?{onOrder:t.onOrder}:{},tradingCapabilities:t.tradingCapabilities,tradingMode:t.tradingMode,...t.tradingLocked?{tradingLocked:t.tradingLocked}:{}})),!1!==t.rail){const e={..."object"==typeof t.rail?t.rail:{},cursorTarget:f};this._rail=Qo(this.context,m,e)}this.drawingTemplates=t.drawingTemplates?ma(this.context,t.drawingTemplates):null,this.context.drawingTemplates=this.drawingTemplates??void 0,(t.drawingToolbar??!1!==t.rail)&&(this._drawbar=rs(this.context,g,{chart:f,templates:this.drawingTemplates}));const C=Xs.has(t),O=!1===t.bottombar&&!C;if(!1!==t.statusline&&(this._statusline=hn(this.context,b,{locale:t.locale,marketStatus:O,now:t.now}),this._statusline.setSymbol(this._symbol,this._exchange,this._interval),void 0!==t.account)){const e=Bs(this.context,b,{source:t.account,locale:t.locale});this._cleanups.push(()=>e.destroy())}if(this._bottombar=Ks.call(this,b),this._layouts=function(e,t){const o=t.workspaces,n=!1===t.layouts?null:t.layouts??null;if(void 0===o&&null===n)return null;const i=e.context,a=_i(i);fi(i,o);const r=null===n&&!1!==t.layouts&&void 0!==o?En(o,pi(e)):null,s=n??r,l={handle:null,waiting:null};let c=!1;const d=null===r?void 0:ki(r,a,e=>i.status(e,"error")),u=i.document,h=u.defaultView,p=()=>{"hidden"===u.visibilityState&&r?.flush()},g=()=>{r?.flush()};return null!==r&&(u.addEventListener("visibilitychange",p),h?.addEventListener("pagehide",g),r.reload().then(async e=>{if(c||null===e.activeWorkspaceId)return;const t=await r.open(e.activeWorkspaceId);t.applied||c||i.status(a("notReopened","The last layout could not open here: {error}",{error:t.reason??""}),"error")}).catch(e=>{c||i.status(a("notLoaded","Saved layouts could not be read: {error}",{error:Me(i,e)}),"error")})),{controller:s,open:e=>!c&&null!==s&&(Oi(i,s,e,l,()=>!c),!0),destroy(){c||(c=!0,l.handle?.close(),d?.(),u.removeEventListener("visibilitychange",p),h?.removeEventListener("pagehide",g),r?.destroy(),fi(i,void 0))}}}(this,t),!1!==t.topbar&&(this._topbar=zi(this.context,p,{intervals:this._intervals,indicators:t.indicators,search:k,state:()=>({symbol:this._symbol,exchange:this._exchange,interval:this._interval,chartType:this.chartType(),theme:this._themeName}),onSymbol:(e,t)=>this.setSymbol(e,t),onInterval:e=>this.setInterval(e),onChartType:e=>this.setChartType(e),onTheme:e=>this.setTheme(e),onSettings:e=>this._openDialog("settings",e),onIndicators:e=>this._openDialog("indicatorPicker",e),onObjects:e=>this._openObjects(e),...!1===t.panels?{}:{onDataWindow:()=>this._dock?.toggle("data")},onAlerts:e=>this._openAlerts(e),...this._docked("watchlist")?{onWatchlist:()=>this._dock?.toggle("watchlist")}:{},...this._docked("news")?{onNews:()=>this._dock?.toggle("news")}:{},...O?{onGoTo:e=>this._openGoTo(e)}:{},layouts:this._layouts?.controller??void 0,onLayouts:e=>this._layouts?.open(e),settingsAvailable:()=>null!==ct("settings"),indicatorsAvailable:()=>null!==ct("indicatorPicker"),dataAvailable:()=>null===this.dataController||"ready"===this._dataState?.status||"stale"===this._dataState?.status,captureRows:t.captureRows})),this._mobile=es(this.context,{mode:t.mobile,container:e,intervals:this._intervals,topbar:!1!==t.topbar,rail:this._rail,tools:"object"==typeof t.rail?t.rail.tools:void 0,indicators:!1!==t.indicators,search:k,state:()=>({symbol:this._symbol,exchange:this._exchange,interval:this._interval,chartType:this.chartType(),theme:this._themeName}),onSymbol:(e,t)=>this.setSymbol(e,t),onInterval:e=>this.setInterval(e),onChartType:e=>this.setChartType(e),onTheme:()=>this.setTheme("dark"===this._themeName?"light":"dark"),onSettings:e=>this._openDialog("settings",e),onIndicators:e=>this._openDialog("indicatorPicker",e),onObjects:e=>this._openObjects(e),...!1===t.panels?{}:{onDataWindow:()=>this._dock?.toggle("data")},onAlerts:e=>this._openAlerts(e),...this._docked("watchlist")?{onWatchlist:()=>this._dock?.open("watchlist")}:{},...this._docked("news")?{onNews:()=>this._dock?.open("news")}:{},...C?{}:{onGoTo:e=>this._openGoTo(e)},onProperties:e=>this._openDialog("drawingProperties",e),onCapture:e=>this._topbar?.openCapture(e),bottombar:this._bottombar.controls,...this._layouts?.controller?{onLayouts:()=>this._layouts?.open()}:{},settingsAvailable:()=>null!==ct("settings"),indicatorsAvailable:()=>null!==ct("indicatorPicker")}),zn.call(this),this._keymap.attach(o),!1!==t.typingNavigation&&(this._quickEntry=Cs(this.context,{enabled:()=>!this._destroyed&&null!==this._doc.activeElement&&this._chartEl.contains(this._doc.activeElement)&&0===this.draw.selection().length,onSymbol:(e,t)=>this.setSymbol(e,t),onInterval:e=>this.setInterval(e),search:k})),Rn.call(this),this._followChart(),qn.call(this,a),null!==this.dataController){this._cleanups.push(this.dataController.subscribe(e=>this._applyData(e))),this.chart.setHistoryLoader(()=>{this.dataController.loadMore().finally(()=>{this._destroyed||this.chart.historyLoadComplete()})});const e=()=>this.dataController.setVisible(!o.hidden);o.addEventListener("visibilitychange",e),this._cleanups.push(()=>o.removeEventListener("visibilitychange",e)),o.hidden&&e(),""===this._symbol||this._restoring||this.reload()}this.ready=this._restoring?ei.call(this):Promise.resolve()}get series(){return this._series}get layouts(){return this._layouts?.controller??null}get isDestroyed(){return this._destroyed}symbol(){return this._symbol}exchange(){return this._exchange}interval(){return this._interval}variant(){return this._variant}chartType(){return this.chart.seriesTransform(this._series)?.type??this.chart.seriesType(this._series)??this._chartType}_transformFor(e,t){if(!b().includes(e)||void 0===this._opts.feed&&f().includes(e))return null;const o=Array.isArray(t?.series)?t.series:[],n=o.find(t=>t?.transform?.type===e)?.transform?.options;if(void 0===n)return{type:e};try{return E(e).create(n),{type:e,options:n}}catch{return{type:e}}}theme(){return this._themeName}chartThemeInUse(){return this._chartTheme}on(e,t){return this._bus.on(e,t)}off(e,t){this._bus.off(e,t)}setSymbol(e,t){const o=e.trim().toUpperCase(),n=t??this._exchange;if(o===this._symbol&&n===this._exchange)return this._topbar?.refresh(),void this._mobile?.refresh();this._symbol=o,this._exchange=n,this._cancelNavigation(),this._keepView=!1,this._pendingView=null,null===this.dataController&&(this._series.setData([]),this._publishDataContext()),this._statusline?.setSymbol(o,n,this._interval),this._topbar?.refresh(),this._mobile?.refresh(),this._scheduleSave(),this._opts.feed&&this.reload(),this._bus.emit("symbol",{symbol:o,exchange:n}),this.chart.emit("symbol",{symbol:o,exchange:n})}setInterval(e){const t=e.trim();if(""===t)throw new Error("openalgo-charts widget: interval code must not be empty");if(K(t),t===this._interval)return this._topbar?.refresh(),void this._mobile?.refresh();this._interval=t,this._cancelNavigation(),this._keepView=!1,this._pendingView=null,null===this.dataController&&(this._series.setData([]),this._publishDataContext()),this._statusline?.setSymbol(this._symbol,this._exchange,t),this._topbar?.refresh(),this._mobile?.refresh(),this._scheduleSave(),this._opts.feed&&this.reload(),this._bus.emit("interval",{interval:t})}setDataVariant(e){const t=S(e);C(t)!==C(this._variant)&&(this._variant=t,this._cancelNavigation(),this._keepView=!1,this._pendingView=null,null===this.dataController&&(this._series.setData([]),this._publishDataContext()),this._scheduleSave(),this._opts.feed&&this.reload(),this._bus.emit("variant",{variant:t}))}setChartType(e){this._selectChartType(e)}_selectChartType(e,t){if(!pn(e))throw new Error(`openalgo-charts widget: "${e}" is not a registered chart type`);if(e===this.chartType()&&void 0===t)return;const o=this._transformFor(e,t),n=++this._chartTypeRequest;let i=this.chart.setSeriesTransform(this._series,o);n===this._chartTypeRequest&&(null===o&&(i=this.chart.setSeriesType(this._series,e)||i),i&&n===this._chartTypeRequest&&this.chartType()===e&&(this._scheduleSave(),this._bus.emit("layout",{reason:"chartType",chartType:e})))}setTheme(e){const t=ol(e);this._themeName=t.name,this._chartTheme=t.theme,this.chart.setTheme(t.theme),this.root.dataset.theme=t.name,sa(this.root,ra(t.theme,t.name)),this._topbar?.refresh(),this._mobile?.refresh(),this._scheduleSave(),this._bus.emit("theme",{theme:t.name,chartTheme:t.theme})}openSettings(){return this._openDialog("settings")}openIndicatorPicker(){return this._openDialog("indicatorPicker")}openObjects(){return this._openObjects()}openDataWindow(){return!(this._destroyed||!this._dock)&&(this._dock.open("data"),!0)}openAlerts(){return this._openAlerts()}openWatchlist(){return this._openDocked("watchlist")}openNews(){return this._openDocked("news")}openLayouts(){return!this._destroyed&&(this._layouts?.open()??!1)}_docked(e){return!1!==this._opts.panels&&void 0!==this._opts[e]}_openDocked(e){return!(this._destroyed||!this._dock||!this._docked(e))&&(this._dock.open(e),!0)}openDateNavigation(){return this._openGoTo()}setRange(e){return this._bottombar.setRange(e)}range(){return this._bottombar.range()}_openGoTo(e){if(this._destroyed||null===wn(this._interval))return!1;if(this._goToPanel?.isOpen())return this._goToPanel.el.focus(),!0;let t=0;return this._goToPanel=Dr(Xs.get(this._opts)?.(this.context)??this.context,e,{navigate:e=>{const o=this.goTo(e);return t=this._navigation,o},cancel:()=>{t===this._navigation&&this._cancelNavigation()},onClose:()=>{this._goToPanel=null}}),!0}_openAlerts(e){return!this._destroyed&&(this._alertsPanel?.isOpen()?(this._alertsPanel.el.focus(),!0):(this._alertsPanel=xr(this.context,e,{onClose:()=>{this._alertsPanel=null}}),!0))}_openObjects(e){return!this._destroyed&&(this._dock?(this._dock.open("objects"),!0):this._objectsPanel?.isOpen()?(this._objectsPanel.el.focus(),!0):(this._objectsPanel=or(this.context,e,{onClose:()=>{this._objectsPanel=null}}),!0))}_openDialog(e,t){const o=ct(e);return null!==o&&(o(this.context,t),!0)}_publishDataContext(){const e=this.chart.getDataContext(),t=e?.symbol===this._symbol&&e.exchange===this._exchange;Z(this.chart,{symbol:this._symbol,exchange:this._exchange,interval:this._interval,...t&&void 0!==e.hasOpenInterest?{hasOpenInterest:e.hasOpenInterest}:{},...this._variant?{variant:this._variant}:{}})}async reload(){const e=this.dataController;if(null===e||this._destroyed)return;if(this._restoring)return await this.ready,void await this._loading;const t=e.getState().request;if(t?.symbol===this._symbol&&t.exchange===this._exchange&&t.interval===this._interval&&C(t.variant)===C(this._variant))return void await e.refresh();const o=this._opts.loading?.now?.()??Math.floor((this._opts.now??Date.now)()/1e3),n={symbol:this._symbol,exchange:this._exchange,interval:this._interval,...this._bottombar.fetchWindow(nl(this._interval,this._opts.lookbackBars??500,o),o),...this._variant?{variant:this._variant}:{}};this._initialView=!0,this._displayedBars=null,this._series.setData([]),this._publishDataContext();const i=e.load(n);this._loading=i,await i,this._loading===i&&(this._loading=null)}async goTo(e){const t=++this._navigation;return this._navigator.cancel(),this._restoring&&await this.ready,null!==this._loading&&await this._loading,t!==this._navigation||this._destroyed?{status:"cancelled"}:this._navigator.goTo(e)}_cancelNavigation(){this._navigation++,this._navigator.cancel()}async _loadHistory(e){const t=this.dataController,o=t?.getState();if(null==t||void 0===o||o.paused||null===o.request)return"unavailable";if(!1===o.hasMore)return"exhausted";const n=t.bars()[0]?.time,i=()=>{this._anchoring||this._cancelNavigation()},a=[this.chart.on("pan",i),this.chart.on("zoom",i)];try{await t.loadMore(e)}finally{for(const e of a)e()}const r=t.getState();if("error"===r.historyStatus)throw r.historyError??new Error("Older history failed to load");if("limited"===r.historyStatus)return"limited";const s=t.bars()[0]?.time;return void 0!==s&&(void 0===n||s<n)?"loaded":!1===r.hasMore?"exhausted":"empty"}_applyData(e){if(this._destroyed||null===e.request)return;const t=this._dataState;this._dataState=e,this._dataStatus.update(e);const{symbol:o,interval:n}=e.request;if(!e.paused&&e.bars!==this._displayedBars){const t=this._series.getData(),o=this.chart.getVisibleLogicalRange(),n=null!==this.chart.seriesTransform(this._series),i=n?this.chart.primaryBars():t,a=i[Math.max(0,Math.min(i.length-1,Math.round(o.from)))],r=void 0===a?-1:i.findIndex(e=>e.time===a.time),s=e.bars[e.bars.length-1];if("live"!==e.reason||void 0===s||t[0]?.time!==e.bars[0]?.time||t.length!==e.bars.length&&t.length+1!==e.bars.length){const i=t[0],s=n&&"prepend"===e.reason&&void 0!==i?e.bars.filter(e=>e.time<i.time):[];if(s.length>0&&s.length+t.length===e.bars.length?this._series.prependData(s):this._series.setData(e.bars),this._anchoring=!0,e.bars.length>0)if(this._initialView)this._pendingView?this.chart.setVisibleLogicalRange(this._pendingView):this._keepView||this.chart.resetScale(),this._pendingView=null,this._initialView=!1,this._keepView=!1;else{const t=n?this.chart.primaryBars():e.bars,i=void 0===a?-1:n?t.filter(e=>e.time<=a.time).length-1:t.findIndex(e=>e.time===a.time),s=i<0||r<0?0:i-r;this.chart.setVisibleLogicalRange({from:o.from+s,to:o.to+s})}this._anchoring=!1}else this._series.update(s);this._displayedBars=e.bars,this._statusline?.refresh()}if(t?.status!==e.status||t.error!==e.error||["load","refresh","prepend","resume"].includes(e.reason))if("unsupported"===e.status){const t=Xo(this.context,e.request.variant,e.unsupported);this.context.status(Pe(this.context,"Not available from this source: {variant}",{variant:t}),"error"),this._bus.emit("data",{symbol:o,interval:n,bars:0,error:e.error?.message})}else"loading"===e.status?this.context.status(Pe(this.context,"Loading {symbol} {interval}",{symbol:o,interval:n})):"refreshing"===e.status?this.context.status(Pe(this.context,"History is stale. Refreshing {symbol} {interval}",{symbol:o,interval:n})):"error"===e.status||"stale"===e.status?(this.context.status("stale"===e.status?Pe(this.context,"History is stale for {symbol} {interval}",{symbol:o,interval:n}):Pe(this.context,"Could not load {symbol} {interval}",{symbol:o,interval:n}),"error"),e.error&&e.error!==t?.error&&(this._toasts.toast(Pe(this.context,"Could not load {symbol} {interval}: {error}",{symbol:o,interval:n,error:e.error.message}),"error"),this._bus.emit("data",{symbol:o,interval:n,bars:0,error:e.error.message}))):"ready"!==e.status&&"empty"!==e.status||(this.context.status(0===e.bars.length?Pe(this.context,"No bars for {symbol} {interval}",{symbol:o,interval:n}):Pe(this.context,1===e.bars.length?"{count} bar":"{count} bars",{count:e.bars.length})),this._bus.emit("data",{symbol:o,interval:n,bars:e.bars.length}))}getState(){return{version:1,symbol:this._symbol,exchange:this._exchange,interval:this._interval,chartType:this.chartType(),theme:this._themeName,...this._variant?{variant:this._variant}:{},chart:this.chart.getState(),rail:this._rail?.prefs()??null,panels:this._dock?.state()}}restoreState(e){const t=this.history.ignore(()=>Jn.call(this,e));return t.applied&&this.history.clear(),t}_scheduleSave(){Yn.call(this)}_saveNow(){Qn.call(this)}_inChart(){const e=this._doc.activeElement;return this._pointerInChart||null!==e&&this._chartEl.contains(e)}_followChart(){const e=["paneAdded","paneResized","paneMoved","paneMaximized","paneCollapsed","paneRemoved","indicatorRemoved","indicatorSettings","priceAxisMoved","objects:change"];for(const t of e)this._cleanups.push(this.chart.on(t,()=>{"objects:change"===t&&this.chartType()!==this._chartType&&(this._chartType=this.chartType(),this._topbar?.refresh(),this._mobile?.refresh(),this._statusline?.refresh()),this._bus.emit("layout",{reason:t}),this._scheduleSave()}));for(const e of["draw:add","draw:remove","draw:update","draw:paste","draw:cut","alert:created","alert:updated","alert:removed","alert:triggered","alert:expired","alerts:restored","alerts:checkpoint"])this._cleanups.push(this.chart.on(e,()=>this._scheduleSave()));this._cleanups.push(this.history.subscribe(()=>this._scheduleSave())),this._cleanups.push(this.chart.on("alert:triggered",e=>{const t=e;this.context.toast(t.message??t.title,"success")})),Xn.call(this)}destroy(){if(!this._destroyed){this._saveNow(),this._storage.flush(),this._storage.close(),this._destroyed=!0,this._cancelNavigation(),this._navigator.destroy(),this._goToPanel?.close(),this._quickEntry?.destroy(),this._dock?.destroy(),this.dataController?.destroy(),this._dataStatus.destroy(),this._layouts?.destroy(),this._mobile?.destroy(),this._mobile=null,this._drawbar?.destroy(),this.drawingTemplates?.destroy(),0!==this._saveTimer&&(clearTimeout(this._saveTimer),this._saveTimer=0);for(const e of this._cleanups.splice(0))e();this._topbar?.destroy(),this._rail?.destroy(),this._statusline?.destroy(),this._toasts.destroy(),this._keymap.destroy(),this.history.destroy(),this.objects.destroy(),this.alerts.destroy(),this.instrumentDrawings?.destroy(),this.draw.destroy(),this.chart.destroy(),this.root.remove(),this._bus.clear()}}}function ll(e,t={}){let o;if("string"==typeof e){const n=t.document??globalThis.document;if(void 0===n)throw new Error("openalgo-charts widget: a selector needs a document");if(o=n.querySelector(e)??n.getElementById(e),null===o)throw new Error(`openalgo-charts widget: no element matches "${e}"`)}else o=e;return new sl(o,t)}const cl="ABCDEFGHIJKLMNOP",dl={crosshair:!1,viewport:!1,symbol:!1,interval:!1,chartType:!1,appearance:!1,drawings:!1,whenMissing:"nearest"},ul=(e,t)=>JSON.stringify([e,t]);function hl(e){return{crosshair:e.crosshair,viewport:e.viewport,symbol:e.symbol,interval:e.interval,appearance:e.appearance,...e.chartType?{chartType:!0}:{},...e.drawings?{drawings:!0}:{},..."hide"===e.whenMissing?{whenMissing:"hide"}:{}}}function pl(e){return{crosshair:!0===e.crosshair,viewport:!0===e.viewport,symbol:!0===e.symbol,interval:!0===e.interval,chartType:!0===e.chartType,appearance:!0===e.appearance,drawings:!0===e.drawings,whenMissing:"hide"===e.whenMissing?"hide":"nearest"}}class gl{constructor(e={}){Object.defineProperty(this,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"groups",{enumerable:!0,configurable:!0,writable:!0,value:[]})}create(e={}){const t=e=>!this.groups.some(t=>t.letter===e),o=void 0!==e.id&&/^[a-p]$/.test(e.id)?e.id.toUpperCase():"",n=""!==o&&t(o)?o:[...cl].find(t);if(void 0===n)return null;let i=e.id??n.toLowerCase();for(let e=2;this.groups.some(e=>e.id===i);e++)i=`${n.toLowerCase()}${e}`;const a={id:i,letter:n,name:e.name??null,links:Q({...this.defaults,...e.links}),drawings:new $e({enabled:!0}),view:null,keeper:null};return this.groups.push(a),a}find(e){return this.groups.find(t=>t.id===e)}join(t,n){t.group!==n&&(this.leave(t),t.group=n,n.links.add(t.member,function(t,n){const{widget:i}=t,a=i.chart;return{symbol:ul(i.symbol(),i.exchange()),interval:i.interval(),chartType:i.chartType(),onSymbol:e=>{const[t,o]=JSON.parse(e);i.setSymbol(t,o)},onInterval:e=>!!A(e)&&(i.setInterval(e),!0),onChartType:e=>!!pn(e)&&(i.history.ignore(()=>i.setChartType(e)),i.chartType()===e),appearance:{read:()=>e(a),apply:e=>i.history.ignore(()=>o(a,e))},drawings:{join:()=>n.drawings.add(a,i.draw,()=>({symbol:i.symbol(),exchange:i.exchange()||"-"})),leave:()=>n.drawings.remove(a)}}}(t,n)))}leave(e){const t=e.group;null!==t&&(e.group=null,t.links.remove(e.member),t.keeper===e&&(t.view=null,t.keeper=null))}prune(e){for(const t of this.groups.slice())e.some(e=>e.group===t)||(this.groups.splice(this.groups.indexOf(t),1),t.links.destroy(),t.drawings.destroy())}destroy(){for(const e of this.groups.splice(0))e.links.destroy(),e.drawings.destroy()}trivial(e){return 1===this.groups.length&&null===this.groups[0].name&&e.every(e=>e.group===this.groups[0])}optionsOf(e){return e?.group?.links.options()??{...dl}}sync(e,t){if(this.trivial(e))return hl(this.groups[0].links.options());const o=this.groups.find(t=>e.every(e=>e.group===t));return{...hl(o?.links.options()??dl),groups:this.groups.filter(t=>e.some(e=>e.group===t)).map(e=>({id:e.id,name:t(e),...hl(e.links.options())}))}}}function ml(e,t){return{get:o=>t.get(e)?.get(o)??null,set:(o,n)=>{let i=t.get(e);void 0===i&&t.set(e,i=new Map),i.set(o,JSON.parse(JSON.stringify(n)))},remove:o=>{t.get(e)?.delete(o)}}}const fl=(e,t,o)=>Number.isInteger(e)&&e>=t&&e<=o;function bl(e){if(!(He(e)&&He(e.layout)&&Array.isArray(e.layout.slots)&&Array.isArray(e.panes)&&He(e.sync)))return"not a workspace payload";const{rows:t,columns:o,slots:n}=e.layout;if(!fl(t,1,8)||!fl(o,1,8)||!fl(e.panes.length,1,16))return"unsupported grid size";for(const[n,i]of[[e.layout.rowWeights,t],[e.layout.columnWeights,o]])if(!(void 0===n||Array.isArray(n)&&n.length===i&&n.every(e=>"number"==typeof e&&e>0&&e<=1e3)))return"invalid track weights";const i=new Set(O().map(e=>e.id)),a=new Set;for(const t of e.panes){if(!He(t)||"string"!=typeof t.id||""===t.id||a.has(t.id))return"invalid or duplicate chart id";if(a.add(t.id),"string"!=typeof t.symbol||"string"!=typeof t.exchange||!He(t.chart)||!["string","undefined"].includes(typeof t.historyPeriod))return`${t.id}: invalid chart`;if(!A(t.interval))return`${t.id}: unknown interval ${String(t.interval)}`;if(!pn(t.chartType))return`${t.id}: unknown chart type ${String(t.chartType)}`;if(Array.isArray(t.comparisons)&&t.comparisons.length>0)return`${t.id}: comparison symbols are not supported in a grid chart`;for(const e of Array.isArray(t.chart.indicators)?t.chart.indicators:[])if(!i.has(e?.indicatorId))return`${t.id}: unavailable study ${String(e?.indicatorId)}`}const r=new Set,s=new Set;for(const e of n){const n=e?.rowSpan??1,i=e?.columnSpan??1;if(!He(e)||!a.has(e.paneId)||r.has(e.paneId)||!fl(e.row,0,t-1)||!fl(e.column,0,o-1)||!fl(n,1,t-e.row)||!fl(i,1,o-e.column))return"invalid layout slot";r.add(e.paneId);for(let t=e.row;t<e.row+n;t++)for(let n=e.column;n<e.column+i;n++){if(s.has(t*o+n))return"layout slots overlap";s.add(t*o+n)}}return r.size!==a.size?"every chart needs one layout slot":a.has(e.activePaneId)?function(e){const t=e.sync,o=e.panes,n=[];if(void 0===t.groups)n.push({channels:t,panes:o});else{if(!Array.isArray(t.groups)||t.groups.length>16)return"invalid link groups";const e=new Set;for(const i of t.groups){if("object"!=typeof i||null===i||"string"!=typeof i.id||""===i.id||e.has(i.id))return"invalid or duplicate link group id";e.add(i.id),n.push({channels:i,panes:o.filter(e=>e.linkGroup===i.id)})}for(const t of o)if(void 0!==t.linkGroup&&!e.has(t.linkGroup))return`${t.id}: undeclared link group ${String(t.linkGroup)}`}for(const{channels:e,panes:t}of n){const o=e=>new Set(t.map(e)).size>1;if(!0===e.symbol&&o(e=>ul(e.symbol,e.exchange)))return"linked symbols differ between charts";if(!0===e.interval&&o(e=>e.interval))return"linked intervals differ between charts";if(!0===e.chartType&&o(e=>e.chartType))return"linked chart types differ between charts"}return""}(e):"the active chart is missing"}const vl={"1x1":[1,1],"1x2":[1,2],"1x3":[1,3],"2x1":[2,1],"3x1":[3,1],"2x2":[2,2],"1x4":[1,4],"4x1":[4,1],"2x3":[2,3],"3x2":[3,2],"2x4":[2,4],"4x2":[4,2],"3x3":[3,3],"3x4":[3,4],"4x3":[4,3],"4x4":[4,4]},wl=(e,t,o=1,n=1)=>({row:e,column:t,rowSpan:o,columnSpan:n}),yl=e=>Array.from({length:e},()=>1);function _l(e,t){const o=[];for(let n=0;n<e;n++)for(let e=0;e<t;e++)o.push(wl(n,e));return{rows:e,columns:t,slots:o,rowWeights:yl(e),columnWeights:yl(t)}}function xl(e,t,o,n=yl(e),i=yl(t)){return{rows:e,columns:t,slots:o,rowWeights:n,columnWeights:i}}const kl=(e,t)=>xl(2,e,[wl(0,0,1,e),...Array.from({length:e},(e,t)=>wl(1,t))],t,yl(e));function Cl(e){const t=[wl(0,0,e-1,e-1)];for(let o=0;o<e-1;o++)t.push(wl(o,e-1));for(let o=0;o<e;o++)t.push(wl(e-1,o));return xl(e,e,t)}const Sl={"1x1":_l(1,1),"1x2":_l(1,2),"2x1":_l(2,1),"1x3":_l(1,3),"3x1":_l(3,1),"left-2":xl(2,2,[wl(0,0,2),wl(0,1),wl(1,1)]),"right-2":xl(2,2,[wl(0,0),wl(0,1,2),wl(1,0)]),"top-2":xl(2,2,[wl(0,0,1,2),wl(1,0),wl(1,1)]),"bottom-2":xl(2,2,[wl(0,0),wl(0,1),wl(1,0,1,2)]),"2x2":_l(2,2),"1x4":_l(1,4),"4x1":_l(4,1),"left-3":(Al=3,Ol=[2,1],xl(Al,2,[wl(0,0,Al),...Array.from({length:Al},(e,t)=>wl(t,1))],yl(Al),Ol)),"top-3":kl(3,[2,1]),"left-4":xl(2,3,[wl(0,0,2),wl(0,1),wl(0,2),wl(1,1),wl(1,2)],yl(2),[2,1,1]),"top-4":kl(4,[2,1]),"2x3":_l(2,3),"3x2":_l(3,2),"corner-5":Cl(3),"2x4":_l(2,4),"4x2":_l(4,2),"corner-7":Cl(4),"3x3":_l(3,3),"3x4":_l(3,4),"4x3":_l(4,3),"4x4":_l(4,4)};var Al,Ol;function Ll(e){return"string"==typeof e&&Object.prototype.hasOwnProperty.call(Sl,e)}const El=(e,t,o)=>{let n=0;for(let i=t;i<t+o;i++)n+=e[i];return n},$l="grid",Tl="grid-drawings";function jl(e){e.held=!1,e.storage.enabled&&!e.destroyed&&(0!==e.saveTimer&&clearTimeout(e.saveTimer),e.saveTimer=setTimeout(()=>Ml(e),250))}function Pl(e){e.held=!1,!e.storage.enabled||e.destroyed||e.saveQueued||(e.saveQueued=!0,queueMicrotask(()=>{e.saveQueued=!1,Ml(e)}))}function Ml(e){if(0!==e.saveTimer&&(clearTimeout(e.saveTimer),e.saveTimer=0),!e.storage.enabled||e.destroyed||e.held||e.restoring||null===e.active)return;const t=e.storage.set($l,e.grid.getWorkspace()),o={};for(const t of e.cells){const n=e.drawings.get(t.id);void 0!==n&&n.size>0&&(o[t.id]=Object.fromEntries(n))}const n=e.storage.set(Tl,{version:1,charts:o}),i=!t||!n;i&&!e.saveRefused&&e.active.widget.context.status(Pe(e.text,"The chart layout could not be saved"),"error"),e.saveRefused=i}function Il(e){if(!1!==e.options.shortcutsEditor){e.sharing=!0;try{for(const t of e.cells)t.widget.context.keymap.applyOverrides(e.chords)}finally{e.sharing=!1}}}function Dl(e,t){t&&0===e.saveTimer||Ml(e),e.storage.flush(),e.saved?.flush()}function zl(e,t,o){const{storage:n,options:i}=e;if(e.chords=n.get(It),e.given)return Il(e),void Pl(e);const a=n.get($l);if(e.restored=null===a?null:o(a,function(e){const t=new Map;if(!He(e)||1!==e.version||!He(e.charts))return t;for(const[o,n]of Object.entries(e.charts)){if(!He(n))continue;const e=new Map;for(const[t,o]of Object.entries(n))He(o)&&e.set(t,o);t.set(o,e)}return t}(n.get(Tl))),!0!==e.restored?.applied){if(t){if(Il(e),void 0!==i.symbol)for(const t of e.cells)t.widget.setSymbol(i.symbol,i.exchange)}else e.grid.setPreset(i.preset??"1x1");null!==e.restored&&(e.held=!0,e.grid.active().widget.context.toast(Pe(e.text,"The saved layout could not be restored: {error}",{error:e.restored.reason??""}),"error"))}}const Nl=e=>Math.round(1e4*e)/1e4,Rl=e=>e.map(e=>`minmax(0,${e}fr)`).join(" 4px "),Fl=e=>e.compact||e.maxed;function Wl(e){for(const t of e.cells){const e=t.element.getBoundingClientRect();e.width>0&&e.height>0&&(t.element.dataset.dense=String(e.width<560||e.height<340))}}function Bl(e,t){const o="column"===t.dataset.axis?e.colW:e.rowW,n=Number(t.dataset.index);t.setAttribute("aria-valuenow",String(Math.round(o[n]/(o[n]+o[n+1])*100)))}function ql(e,t,o,n,i=!1){const a=("column"===t?e.colW:e.rowW).slice(),r=a[o]+a[o+1],s=Nl(Math.min(.85*r,Math.max(.15*r,n)));s!==a[o]&&(a[o]=s,a[o+1]=Nl(r-s),"column"===t?(e.colW=a,e.body.style.gridTemplateColumns=Rl(a)):(e.rowW=a,e.body.style.gridTemplateRows=Rl(a)),e.splits.forEach(t=>Bl(e,t)),Wl(e),i?jl(e):Pl(e),e.bus.emit("layout",{reason:"weights"}))}function Ul(e,t,o,n){const{doc:i,body:a}=e,r="column"===t,s=De(i,"div","oac-grid__split",{role:"separator",tabindex:"0","aria-orientation":r?"vertical":"horizontal","aria-label":Pe(e.text,r?"Resize columns {first} and {second}":"Resize rows {first} and {second}",{first:o+1,second:o+2}),"aria-valuemin":"15","aria-valuemax":"85"});s.dataset.axis=t,s.dataset.index=String(o),s.style.gridArea=n;const l=()=>r?e.colW:e.rowW;s.addEventListener("pointerdown",n=>{if(0!==n.button)return;n.preventDefault();const i=a.getBoundingClientRect(),c=l(),d=(r?i.width:i.height)-4*(c.length-1),u=c.reduce((e,t)=>e+t,0),h=r?n.clientX:n.clientY,p=c[o];s.setPointerCapture?.(n.pointerId),s.classList.add("is-drag");const g=n=>{d>0&&ql(e,t,o,p+((r?n.clientX:n.clientY)-h)/d*u,!0)},m=()=>{0!==e.saveTimer&&Ml(e),s.classList.remove("is-drag"),s.removeEventListener("pointermove",g),s.removeEventListener("pointerup",m),s.removeEventListener("pointercancel",m)};s.addEventListener("pointermove",g),s.addEventListener("pointerup",m),s.addEventListener("pointercancel",m)}),s.addEventListener("keydown",n=>{const i=(r?["ArrowLeft","ArrowRight"]:["ArrowUp","ArrowDown"]).indexOf(n.key);if(i<0)return;n.preventDefault(),n.stopPropagation();const a=l();ql(e,t,o,a[o]+(2*i-1)*(a[o]+a[o+1])*(n.shiftKey?.2:.05))}),s.addEventListener("dblclick",()=>{const n=l();ql(e,t,o,(n[o]+n[o+1])/2)}),s.hidden=Fl(e),a.appendChild(s),e.splits.push(s),Bl(e,s)}function Hl(e,t){const o="column"===t,n=o?e.rows:e.cols;for(let i=0;i<(o?e.cols:e.rows)-1;i++){let a=-1;for(let r=0;r<=n;r++){const s=r<n&&!e.cells.some(e=>{const[t,n,a,s]=o?[e.column,e.columnSpan,e.row,e.rowSpan]:[e.row,e.rowSpan,e.column,e.columnSpan];return t<=i&&t+n>i+1&&a<=r&&a+s>r});if(s&&a<0&&(a=r),!s&&a>=0){const[n,s,l]=[2*a+1,2*r,2*i+2];Ul(e,t,i,(o?[n,l,s,l+1]:[l,n,l+1,s]).join(" / ")),a=-1}}}}const Kl=e=>e.cells.length<2||!Fl(e)?null:Pe(e.text,e.compact?"The grid shows one chart at a time at this width":"Show every chart to capture them together"),Vl=(e,t,o="info")=>{e.active?.widget.context.toast(t,o)},Gl=e=>{const{text:t}=e;e.grid.downloadScreenshot()?Vl(e,Pe(t,"Saved a PNG of every chart")):Vl(e,Pe(t,"The image could not be saved: {error}",{error:Kl(e)??Pe(t,"This runtime cannot save files")}),"error")},Jl=e=>{const t=e.grid.takeScreenshot();null!==t&&$i(e.text,t,Pe(e.text,"Every chart copied"),(t,o)=>Vl(e,t,o))};function Zl(e){if(e.destroyed||null!==Kl(e))return null;const{doc:t}=e,o=e.body.getBoundingClientRect(),n=e=>{const t=e?.getBoundingClientRect();return void 0===t?{left:0,top:0,width:0,height:0}:{left:t.left-o.left,top:t.top-o.top,width:t.width,height:t.height}},i=e.cells.map(e=>({cell:n(e.element),chart:n(e.widget.root.querySelector(".oac-chart")),image:e.widget.chart.takeScreenshot(),label:`${e.widget.symbol()} ${e.widget.interval()}`.trim()})),a=e.options.pixelRatio?.()??t.defaultView?.devicePixelRatio??1,r=ra(ol(e.theme).theme,ol(e.theme).name),s=e=>r[qi+e];return function(e,t,o,n,i){const a=e.createElement("canvas"),r=e=>Math.round(e*o);a.width=Math.max(1,r(t.width)),a.height=Math.max(1,r(t.height));const s=a.getContext("2d");if(null===s)return a;s.fillStyle=i.gutter,s.fillRect(0,0,a.width,a.height);for(const e of n){const{cell:t,chart:o}=e;s.fillStyle=i.panel,s.fillRect(r(t.left),r(t.top),r(t.left+t.width)-r(t.left),r(t.top+t.height)-r(t.top));const n=o.top-t.top;n>=14&&""!==e.label&&(s.fillStyle=i.text,s.font=`600 ${r(12)}px ${i.font}`,s.textBaseline="middle",s.fillText(e.label,r(t.left+8),r(t.top+n/2),r(Math.max(0,t.width-16)))),null===e.image||e.image.width<=1||o.width<=0||o.height<=0||s.drawImage(e.image,r(o.left),r(o.top),r(o.left+o.width)-r(o.left),r(o.top+o.height)-r(o.top))}return a}(t,{width:o.width,height:o.height},function(e,t){for(const o of e)if(!(null===o.image||o.image.width<=1||o.chart.width<=0))return t>0&&Math.abs(o.image.width-o.chart.width*t)<=1?t:o.image.width/o.chart.width;return t>0?t:1}(i,a),i,{gutter:s("bd-soft"),panel:s("panel"),text:s("tx"),font:ta})}const Yl=(e,t)=>Li(e.doc,()=>e.grid.takeScreenshot(),t??(e=>Wo("charts",e.preset??`${e.rows}x${e.cols}`)+".png")(e));function Ql(e,t){const o=De(e,"span","oac-grid__chip",{"aria-hidden":"true"});return null===t?(o.dataset.group="none",o.innerHTML=oe("unlink")):(o.dataset.group=t.letter,o.textContent=t.letter),o}function Xl(e,t,o){const n="left"===o||"right"===o,[i,a]=n?[t.row,t.rowSpan]:[t.column,t.columnSpan],r=e=>Math.abs((n?e.row:e.column)-i);return e.filter(e=>e!==t&&(e=>"right"===o?e.column===t.column+t.columnSpan:"left"===o?e.column+e.columnSpan===t.column:"down"===o?e.row===t.row+t.rowSpan:e.row+e.rowSpan===t.row)(e)&&(e=>{const[t,o]=n?[e.row,e.rowSpan]:[e.column,e.columnSpan];return t<i+a&&t+o>i})(e)).sort((e,t)=>r(e)-r(t))[0]}const ec={left:"ArrowLeft",right:"ArrowRight",up:"ArrowUp",down:"ArrowDown"},tc={left:"Make the chart to the left active",right:"Make the chart to the right active",up:"Make the chart above active",down:"Make the chart below active"},oc={left:"Swap with the chart to the left",right:"Swap with the chart to the right",up:"Swap with the chart above",down:"Swap with the chart below"};function nc(e){const{doc:t,body:o,root:n}=e;let i=null;const a=t=>{const o=t;if(null===o||"function"!=typeof o.closest||null!==o.closest('button, input, select, textarea, a, label, [role="button"], [role="radio"], [role="tab"], [contenteditable="true"]'))return;const n=o.closest(".oac-topbar");if(null===n)return;const i=e.cells().find(e=>e.element.contains(n));return void 0===i?void 0:{cell:i,head:n}},r=o=>{const a=i;if(null!==a&&(i=null,t.removeEventListener("pointermove",s,!0),t.removeEventListener("pointerup",l,!0),t.removeEventListener("pointercancel",c,!0),t.removeEventListener("keydown",d,!0),a.moving)){a.over?.element.removeAttribute("data-drop"),a.cell.element.removeAttribute("data-dragging"),n.removeAttribute("data-dragging");try{a.head.releasePointerCapture?.(a.pointer)}catch{}o&&null!==a.over&&e.swap(a.cell,a.over)}},s=t=>{const o=i;if(null!==o&&t.pointerId===o.pointer){if(!o.moving){if(Math.hypot(t.clientX-o.x,t.clientY-o.y)<6)return;if(!e.enabled())return void r(!1);o.moving=!0,n.setAttribute("data-dragging","true"),o.cell.element.setAttribute("data-dragging","true");try{o.head.setPointerCapture?.(o.pointer)}catch{}}var a;t.preventDefault(),a=e.cells().find(e=>e!==o.cell&&((e,t,o)=>{const n=e.element.getBoundingClientRect();return n.width>0&&t>=n.left&&t<n.left+n.width&&o>=n.top&&o<n.top+n.height})(e,t.clientX,t.clientY))??null,null!==i&&(i.over?.element.removeAttribute("data-drop"),i.over=a,a?.element.setAttribute("data-drop","true"))}},l=e=>{null!==i&&e.pointerId===i.pointer&&r(!0)},c=()=>r(!1),d=e=>{"Escape"===e.key&&null!==i&&(i.moving&&(e.preventDefault(),e.stopPropagation()),r(!1))},u=o=>{if(0!==o.button||null!==i||!e.enabled())return;const n=a(o.target);void 0!==n&&(i={...n,x:o.clientX,y:o.clientY,pointer:o.pointerId,moving:!1,over:null},t.addEventListener("pointermove",s,!0),t.addEventListener("pointerup",l,!0),t.addEventListener("pointercancel",c,!0),t.addEventListener("keydown",d,!0))},h=t=>{const o=a(t.target);void 0!==o&&e.toggleMaximize(o.cell)};return o.addEventListener("pointerdown",u),o.addEventListener("dblclick",h),()=>{r(!1),o.removeEventListener("pointerdown",u),o.removeEventListener("dblclick",h)}}function ic(e,t,o,n,i=!1){return 0===o||t<0&&!i?-1:e===n[1]?(t+1)%o:e===n[0]?t<0?o-1:(t-1+o)%o:"Home"===e?0:"End"===e?o-1:-1}const ac=ut(()=>import("./openalgo-charts.widget.grid-bar-Cm_CyA2j.mjs")),rc=ut(()=>import("./openalgo-charts.widget.grid-menus-CPZWEiD3.mjs")),sc=["preset","links","compactWidth","persist","storage","drawingStore","toolbar","presets"],lc=e=>Array.from({length:e},()=>1);function cc(e,t={}){if("string"==typeof e){const o=(t.document??globalThis.document)?.querySelector(e);if(!o)throw new Error(`openalgo-charts grid: no element matches "${e}"`);e=o}const o=t.document??e.ownerDocument,n=t,i={...t};for(const e of sc)delete i[e];Object.assign(i,{document:o,mobile:t.mobile??"never",captureRows:()=>function(e){if(e.cells.length<2)return[];const{text:t}=e,o=Kl(e);return[Pe(t,"Every chart"),{label:Pe(t,"Download PNG of every chart"),sub:o??void 0,disabled:null!==o,onSelect:()=>Gl(e)},{label:Pe(t,"Copy image of every chart"),sub:o??void 0,disabled:null!==o||!Ei(),onSelect:()=>Jl(e)}]}(d)}),i.bottombar=!1,i.layouts=!0!==t.toolbar&&(t.layouts??!1);const a=De(o,"div","oac-grid"),r=De(o,"div","oac-grid__tabs",{role:"tablist","aria-label":Pe(n,"Charts")}),s=De(o,"div","oac-grid__cells");r.hidden=!0;const l=!0===t.toolbar?De(o,"div","oac-widget oac-grid__bar",{role:"toolbar","aria-label":Pe(n,"Chart grid")}):null,c=!0===t.bottombar?De(o,"div","oac-widget oac-grid__foot"):null;a.append(...null===l?[]:[l],r,s,...null===c?[]:[c]);const d={doc:o,options:t,text:n,cellOptions:i,bus:new it,links:new gl(t.links),offs:[],root:a,tabs:r,body:s,barEl:l,footEl:c,splits:[],given:!1,cells:[],chords:null,sharing:!1,active:null,rows:1,cols:1,rowW:[1],colW:[1],preset:null,theme:t.theme??"dark",themeSync:!1,compact:!1,maxed:!1,pointerIn:!1,destroyed:!1,syncing:!1,nextId:0,saveTimer:0,saveQueued:!1,saveRefused:!1,held:!1,restored:null,drawings:new Map,chromeLayer:null,bar:null,foot:null,saved:null,ready:Promise.resolve()};d.storage=function(e){const{options:t,text:o}=e,n=t.persist?void 0===t.storage?wt():t.storage:null;return new Ve("string"==typeof t.persist?t.persist:"default",n,{onError:t=>{if(e.destroyed||null===e.active)return;const n=Me(o,t.error),i=e.active.widget.context;if("load"!==t.operation)return void i.status(Pe(o,"Saved chart settings could not be written: {error}",{error:n}),"error");const a=Pe(o,"Saved chart settings could not be read, so changes are kept for this session only: {error}",{error:n});i.status(a,"error"),i.toast(a,"error")}})}(d),d.restoring=!d.storage.loaded;const u=d.grid=function(e){const{links:t}=e,o={root:e.root,get ready(){return e.ready},get isDestroyed(){return e.destroyed},restored:()=>e.restored,cells:()=>e.cells.slice(),active:()=>e.active,theme:()=>ol(e.theme).name,compact:()=>e.compact,maximized:()=>e.maxed&&null!==e.active?e.active.id:null,linkOptions:()=>t.optionsOf(e.active),linkGroups:()=>_c(e),layout:()=>({rows:e.rows,columns:e.cols,preset:e.preset,rowWeights:e.rowW.slice(),columnWeights:e.colW.slice()}),on:(t,o)=>e.bus.on(t,o),setActive:(t,o)=>function(e,t,o={}){const n=e.cells.find(e=>e.id===t);if(void 0===n||e.destroyed)return!1;const i=n!==e.active,a=e.active?.group??null;e.active=n,mc(e),o.focus&&n.widget.root.querySelector(".oac-chart")?.focus({preventScroll:!0});i&&(e.held||Pl(e),dc(e,"active",{id:t}),a!==n.group&&dc(e,"links",e.grid.linkOptions()));return!0}(e,t,o),setPreset:t=>function(e,t){if(!Ll(t))throw new Error(`openalgo-charts grid: "${String(t)}" is not a preset or layout`);if(e.destroyed)return;const{links:o}=e,n=Sl[t],i=n.slots.length,a=e.cells.slice(0,i),r=function(e){const t=e.slots.map(t=>El(e.rowWeights,t.row,t.rowSpan)*El(e.columnWeights,t.column,t.columnSpan)),o=Math.max(...t);return t.every(e=>e===o)?-1:t.indexOf(o)}(n);r>=0&&null!==e.active&&!a.includes(e.active)&&a.splice(i-1,1,e.active);const s=e.active,l=null===s?o.groups[0]??o.create():s.group,c=e.active?.widget,d=void 0===c?e.options:{symbol:c.symbol(),exchange:c.exchange(),interval:c.interval(),variant:c.variant(),chartType:c.chartType(),historyPeriod:e.active?.historyPeriod},u=[];try{for(;a.length+u.length<i;){let t;do{t="p"+e.nextId++}while(e.cells.some(e=>e.id===t));u.push(Ac(e,t,d,e.body,e.theme,e.drawings))}}catch(t){throw u.forEach(t=>Tc(e,t)),t}e.maxed=!1,e.root.dataset.maximized="false";for(const t of e.cells.filter(e=>!a.includes(e)))Tc(e,t),e.drawings.delete(t.id);null!==e.active&&a.includes(e.active)||(e.active=a[0]??u[0]);const h=[...a,...u];r>=0&&(h.splice(h.indexOf(e.active),1),h.splice(r,0,e.active));if(h.forEach((e,t)=>Object.assign(e,n.slots[t])),e.cells=h,u.forEach(t=>$c(e,t)),null!==l)for(const e of u)o.join(e,l);o.prune(e.cells),e.rows=n.rows,e.cols=n.columns,e.rowW=n.rowWeights.slice(),e.colW=n.columnWeights.slice(),e.preset=t,Sc(e),Pl(e),dc(e,"layout",{reason:"preset"}),e.active!==s&&dc(e,"active",{id:e.active.id})}(e,t),maximize(t){const n=void 0===t?e.active:e.cells.find(e=>e.id===t);return!(e.destroyed||null==n||e.cells.length<2)&&(o.setActive(n.id),bc(e,!0),!0)},restore(){e.destroyed||bc(e,!1)},swap:(t,o)=>function(e,t,o){const n=e.cells.find(e=>e.id===t),i=e.cells.find(e=>e.id===o);if(e.destroyed||void 0===n||void 0===i||n===i)return!1;const a=e=>({row:e.row,column:e.column,rowSpan:e.rowSpan,columnSpan:e.columnSpan}),[r,s]=[a(n),a(i)];return Object.assign(n,s),Object.assign(i,r),e.cells.sort((e,t)=>e.row-t.row||e.column-t.column),Sc(e),Pl(e),dc(e,"layout",{reason:"swap"}),!0}(e,t,o),setLinks(n){const i=null!=e.active?.group?[e.active.group]:t.groups;for(const t of i)Ic(e,t,n);Pl(e),kc(e),dc(e,"links",o.linkOptions())},setLinkGroup(o,n){const i=e.cells.find(e=>e.id===o),a=null===n?null:t.find(n);return!e.destroyed&&void 0!==i&&void 0!==a&&(null===a?t.leave(i):t.join(i,a),Cc(e),!0)},addLinkGroup(o,n={}){const i=e.cells.find(e=>e.id===o);if(e.destroyed||void 0===i)return null;const a=n.name?.trim(),r=t.create({name:void 0===a||""===a?null:a.slice(0,120),links:n.links});return null===r?null:(t.join(i,r),Cc(e),r.id)},setGroupLinks(n,i){const a=t.find(n);return!e.destroyed&&void 0!==a&&(Ic(e,a,i),Pl(e),kc(e),dc(e,"links",o.linkOptions()),!0)},renameLinkGroup(o,n){const i=t.find(o),a=n.trim();return!(e.destroyed||void 0===i||""===a||a.length>120)&&(i.name=a,Cc(e),!0)},shareDrawings(t){const o=e.cells.find(e=>e.id===t),n=o?.group;return e.destroyed||void 0===o||null==n||!n.links.options().drawings?0:n.drawings.share(o.widget.chart)},setTheme(t){e.theme=t,hc(e),e.themeSync=!0;try{for(const o of e.cells)o.widget.setTheme(t)}finally{e.themeSync=!1}Pl(e),dc(e,"theme",{theme:ol(t).name})},takeScreenshot:()=>Zl(e),downloadScreenshot:t=>Yl(e,t),getWorkspace:()=>function(e){const t=e.links.trivial(e.cells),o={layout:{rows:e.rows,columns:e.cols,slots:e.cells.map(e=>({paneId:e.id,row:e.row,column:e.column,rowSpan:e.rowSpan,columnSpan:e.columnSpan})),...null===e.preset?{}:{preset:e.preset},rowWeights:e.rowW.slice(),columnWeights:e.colW.slice()},panes:e.cells.map(e=>{const o=e.widget.getState();return{...ui(e.id,o,o.chart),historyPeriod:e.historyPeriod,...t||null===e.group?{}:{linkGroup:e.group.id}}}),activePaneId:e.active.id,sync:e.links.sync(e.cells,t=>yc(e,t))};return JSON.parse(JSON.stringify(o))}(e),applyWorkspace(t){const o=Dc(e,t,new Map);return o.applied&&(e.given=!0),o},destroy:()=>function(e){if(e.destroyed)return;Ml(e),e.storage.flush(),e.storage.close(),e.destroyed=!0;for(const t of e.offs.splice(0))t();e.saved?.destroy(),e.foot?.destroy(),e.chromeLayer?.overlays.destroy(),e.chromeLayer?.tips.destroy(),e.bar?.destroy(),e.cells.splice(0).forEach(t=>Tc(e,t)),e.links.destroy(),e.root.remove(),e.bus.clear()}(e)};return o}(d);if(d.barHost=function(e){const{doc:t,text:o,options:n}=e,i={waiting:null},a={doc:t,text:o,get overlays(){return uc(e).overlays},get tips(){return uc(e).tips},layouts:(n.presets??Object.keys(Sl)).filter(Ll),layout:()=>e.preset,setLayout:t=>e.grid.setPreset(t),maximized:()=>e.maxed,maximizeBlocked:()=>vc(e),toggleMaximize:()=>wc(e),links:{groups:()=>_c(e),current:()=>xc(e,e.active?.group??null),setGroup:t=>{null!==e.active&&e.grid.setLinkGroup(e.active.id,t)},newGroup:()=>{null!==e.active&&e.grid.addLinkGroup(e.active.id)},rename:(t,o)=>e.grid.renameLinkGroup(t,o),setChannel:(t,o)=>{const n=e.active?.group;null!=n&&e.grid.setGroupLinks(n.id,"nearest"===t?{whenMissing:o?"nearest":"hide"}:{[t]:o})},share:()=>{const t=null===e.active?0:e.grid.shareDrawings(e.active.id);return Vl(e,t>0?Pe(o,1===t?"Shared {count} drawing":"Shared {count} drawings",{count:t}):Pe(o,"No drawing here can be shared")),t}},capture:{blocked:()=>Kl(e),download:()=>Gl(e),copy:()=>Jl(e),canCopy:Ei},get saved(){return e.saved??void 0},openMenu:(n,r)=>ht(rc,e=>{"layouts"===n?e.openLayoutPicker(a,r):"link"===n?e.openLinkMenu(a,r):e.openCaptureMenu(a,r)},t=>Vl(e,pt(o,Pe(o,"layouts"===n?"Arrange charts":"link"===n?"Linking":"Capture every chart"),t),"error"),()=>!e.destroyed&&r.isConnected,{slot:i,doc:t,from:r})};return a}(d),hc(d),e.appendChild(a),function(e){const{doc:t,root:o,tabs:n,offs:i}=e,a=(e,t,o,n=!1)=>{e.addEventListener(t,o,n),i.push(()=>e.removeEventListener(t,o,n))};a(n,"keydown",o=>{const i=Array.from(n.children),a=ic(o.key,i.indexOf(t.activeElement),i.length,["ArrowLeft","ArrowRight"]),r=e.cells[a];a<0||void 0===r||(o.preventDefault(),o.stopPropagation(),e.grid.setActive(r.id),n.children[a]?.focus())}),a(o,"pointerdown",t=>jc(e,t.target),!0),a(o,"focusin",t=>jc(e,t.target)),a(o,"pointerenter",()=>{e.pointerIn=!0}),a(o,"pointerleave",()=>{e.pointerIn=!1}),i.push(nc({doc:t,body:e.body,root:o,cells:()=>e.cells,enabled:()=>!Fl(e)&&e.cells.length>1,swap:(t,o)=>e.grid.swap(t.id,o.id),toggleMaximize:t=>{e.cells.length>1&&!e.compact&&(e.grid.setActive(t.id),wc(e,t))}}));const r=t.defaultView,s=r?.ResizeObserver;if(void 0!==s){const t=new s(()=>fc(e));t.observe(o),i.push(()=>t.disconnect())}null!=r&&"function"==typeof r.addEventListener&&(void 0===s&&a(r,"resize",()=>fc(e)),a(r,"pagehide",()=>Dl(e,!1)));a(t,"visibilitychange",()=>{"hidden"===t.visibilityState&&Dl(e,!0)})}(d),function(e,t){e.restoring?(e.grid.setPreset(e.options.preset??"1x1"),e.root.style.visibility="hidden",e.ready=e.storage.load().then(()=>{if(!e.destroyed){e.restoring=!1;try{zl(e,!0,t)}catch(t){e.grid.active().widget.context.toast(Pe(e.text,"The saved layout could not be restored: {error}",{error:Me(e.text,t)}),"error")}finally{e.root.style.visibility=""}}})):zl(e,!1,t)}(d,(e,t)=>Dc(d,e,t)),null!==c){const{tips:e,overlays:n}=uc(d),i=c.appendChild(De(o,"div"));d.foot=Yr({document:o,locale:t.locale,translate:t.translate,tips:e,openOverlay:n.open,status:(e,t)=>d.active?.widget.context.status(e,t)},i,{target:()=>d.active?.widget??null,ranges:t.ranges,now:t.now,onGoTo:()=>d.active?.widget.openDateNavigation()}),d.offs.push(d.bus.on("active",()=>d.foot?.refresh()))}return null!==l&&ht(ac,e=>{d.saved=e.attachGridSaved({grid:u,ready:d.ready,workspaces:t.workspaces,layouts:t.layouts,context:()=>pc(d,d.active.widget.context),opened:()=>d.given}),d.bar=e.mountGridBar(d.barHost,l)},e=>Vl(d,pt(n,Pe(n,"Chart grid"),e),"error"),()=>!d.destroyed),fc(d),u}const dc=(e,t,o)=>e.bus.emit(t,o);function uc(e){if(null===e.chromeLayer){const t=De(e.doc,"div","oac-widget oac-grid__overlay");t.dataset.theme=ol(e.theme).name,e.root.appendChild(t);const o=Ze(t,e.doc);e.chromeLayer={el:t,overlays:o,tips:Qe(t,o.layer,e.doc)}}return e.chromeLayer}function hc(e){const t=ol(e.theme);e.root.dataset.theme=t.name;for(const o of[e.chromeLayer?.el,e.barEl,e.footEl])null!=o&&(o.dataset.theme=t.name);sa(e.root,ra(t.theme,t.name))}const pc=(e,t,o)=>Object.create(t,{root:{value:uc(e).el},openOverlay:{value:(t,n={})=>uc(e).overlays.open(t,{...n,anchor:n.anchor??o?.()??void 0})}});function gc(e){const{doc:t,tabs:o}=e;for(const t of e.cells)t.element.hidden=Fl(e)&&t!==e.active;for(const t of e.splits)t.hidden=Fl(e);o.hidden=!Fl(e)||e.cells.length<2;const n=e=>`${e.widget.symbol()} ${e.widget.interval()}`.trim();o.replaceChildren(...o.hidden?[]:e.cells.map((o,i)=>{const a=De(t,"button","oac-grid__tab",{type:"button",role:"tab","aria-selected":String(o===e.active),tabindex:o===e.active?"0":"-1"});return a.textContent=n(o),e.cells.some(e=>e!==o&&n(e)===n(o))&&a.setAttribute("aria-label",`${n(o)} (${i+1})`),a.addEventListener("click",()=>e.grid.setActive(o.id,{focus:!0})),a})),e.bar?.refresh()}function mc(e){for(const t of e.cells)t.element.dataset.active=String(t===e.active),t===e.active?t.element.setAttribute("aria-current","true"):t.element.removeAttribute("aria-current");gc(e)}function fc(e){if(e.destroyed)return;Wl(e);const t=e.root.getBoundingClientRect().width,o=e.options.compactWidth??640,n=o>0&&t>0&&t<=o;e.root.dataset.compact=String(n),n!==e.compact&&(e.compact=n,gc(e),Wl(e),dc(e,"layout",{reason:"compact"}))}function bc(e,t){return t!==e.maxed&&(e.maxed=t,null!==e.active&&(e.active.hold=!0),e.root.dataset.maximized=String(t),gc(e),Wl(e),dc(e,"layout",{reason:"maximize"}),!0)}function vc(e){return e.cells.length<2?Pe(e.text,"There is only one chart"):e.compact?Pe(e.text,"The grid shows one chart at a time at this width"):null}function wc(e,t=e.active){null!==t&&(e.maxed&&t===e.active?e.grid.restore():e.grid.maximize(t.id))}const yc=(e,t)=>t.name??Pe(e.text,"Group {letter}",{letter:t.letter}),_c=e=>{return t=e.links,o=e.cells,n=t=>yc(e,t),t.groups.map(e=>({id:e.id,name:n(e),letter:e.letter,links:e.links.options(),cells:o.filter(t=>t.group===e).map(e=>e.id)}));var t,o,n},xc=(e,t)=>_c(e).find(e=>e.id===t?.id)??null;function kc(e){const{doc:t,text:o}=e,n=e.links.trivial(e.cells);e.cells.forEach((i,a)=>{const r=a+1;if(i.element.setAttribute("aria-label",n?Pe(o,"Chart {index}",{index:r}):null===i.group?Pe(o,"Chart {index}, not linked",{index:r}):Pe(o,"Chart {index}, linked in {name}",{index:r,name:yc(e,i.group)})),n)return i.mark?.remove(),void(i.mark=null);if(null===i.mark){const o=i.mark=De(t,"button","oac-grid__mark",{type:"button","aria-haspopup":"menu"});o.addEventListener("click",()=>{e.grid.setActive(i.id),e.barHost.openMenu("link",o)});const n=i.widget.root.querySelector(".oac-topbar");null!==n?n.prepend(o):(o.classList.add("oac-grid__mark--float"),i.element.appendChild(o))}i.mark.replaceChildren(Ql(t,xc(e,i.group)));const s=null===i.group?Pe(o,"Not linked"):Pe(o,"Linked in {name}",{name:yc(e,i.group)});i.mark.setAttribute("aria-label",s),i.mark.title=s,null===i.group?delete i.mark.dataset.group:i.mark.dataset.group=i.group.letter}),e.bar?.refresh()}function Cc(e){e.links.prune(e.cells),kc(e),Pl(e),dc(e,"links",e.grid.linkOptions())}function Sc(e){const{doc:t,body:o}=e;o.style.gridTemplateColumns=Rl(e.colW),o.style.gridTemplateRows=Rl(e.rowW);for(const t of e.splits.splice(0))t.remove();const n=t.activeElement;e.cells.forEach((e,t)=>{e.element.style.gridArea=`${2*e.row+1} / ${2*e.column+1} / ${2*(e.row+e.rowSpan)} / ${2*(e.column+e.columnSpan)}`;const n=o.children[t]??null;n!==e.element&&o.insertBefore(e.element,n)}),null!==n&&n!==t.activeElement&&e.cells.some(e=>e.element.contains(n))&&n.focus({preventScroll:!0}),Hl(e,"column"),Hl(e,"row"),e.root.dataset.single=String(1===e.cells.length),kc(e),mc(e),Wl(e)}function Ac(e,t,o,n,i,a){const{footEl:r}=e,s=De(e.doc,"div","oac-grid__cell",{role:"group"});s.dataset.paneId=t,n.appendChild(s);const{historyPeriod:l}=o,c=e.options.feed,d={id:t,element:s,row:0,column:0,rowSpan:1,columnSpan:1,offs:[],span:0,hold:!1,historyPeriod:l,group:null,mark:null,type:""},u={...e.cellOptions,theme:i,symbol:e.restoring?void 0:o.symbol,exchange:o.exchange,interval:o.interval,variant:o.variant,chartType:o.chartType,keyboardRoute:()=>function(e,t){if(t!==e.active)return!1;const o=e.doc.activeElement;return null===o||o===e.doc.body||o===e.doc.documentElement?!!e.pointerIn||void 0:!(e.root.contains(o)&&!e.cells.some(e=>e.element.contains(o)))&&void 0}(e,d),feed:"function"==typeof c?c({id:t,historyPeriod:l}):c,drawingStore:ml(t,a)};null!==r&&Xs.set(u,t=>pc(e,t,()=>r.querySelector(".oac-bottombar__goto")));try{d.widget=ll(s,u)}catch(e){throw s.remove(),e}return d.type=d.widget.chartType(),Object.defineProperty(d,"linkGroup",{enumerable:!0,get:()=>d.group?.id??null}),d}const Oc=e=>{const t=e.widget.chart.getVisibleLogicalRange();return t.to-t.from},Lc=e=>{const t=e.group;if(null===t)return;const o=e.widget.chart,n=o.getVisibleLogicalRange(),i=o.dataLayer,a=i.indexToTimeFloat(n.from),r=i.indexToTimeFloat(n.to);r>a&&(t.view={from:a,to:r},t.keeper=e)},Ec=e=>{null!==e&&(e.view=null,e.keeper=null)};function $c(e,t){const{widget:o}=t,n=o.chart;!function(e,t){if(!1===e.options.shortcutsEditor)return;const o=t.widget.context.keymap;o.applyOverrides(e.chords),t.offs.push(o.onChange(()=>{if(!e.sharing){e.sharing=!0;try{const n=o.overrides();e.chords=n;for(const o of e.cells)o!==t&&o.widget.context.keymap.applyOverrides(n);0===Object.keys(n).length?e.storage.remove(It):e.storage.set(It,n)}finally{e.sharing=!1}}}))}(e,t);let i=!1,a=!1;const r=()=>i||e.syncing||a;t.offs.push(n.on("data:update",()=>{i=!0,queueMicrotask(()=>{i=!1}),t.span=Oc(t),t===t.group?.keeper&&Lc(t)})),t.member=function(e,t,o){return{on:(o,n)=>e.on(o,"pan"===o||"zoom"===o?e=>{t()||n(e)}:"symbol"===o?e=>{const t=e;n({symbol:ul(t.symbol,t.exchange)})}:n),getVisibleLogicalRange:()=>e.getVisibleLogicalRange(),setVisibleLogicalRange:t=>o(()=>e.setVisibleLogicalRange(t)),get dataLayer(){return e.dataLayer},get isDestroyed(){return e.isDestroyed},panes:()=>e.panes(),addPrimitive:(t,o)=>e.addPrimitive(t,o),removePrimitive:t=>e.removePrimitive(t),setLinkedCrosshairIndex:t=>e.setLinkedCrosshairIndex(t)}}(n,r,e=>{a=!0;try{e()}finally{a=!1}});const s=()=>{t===t.group?.keeper&&Ec(t.group),gc(e),Pl(e)},l=()=>{const o=!r();t.span=Oc(t),(o||t===t.group?.keeper)&&Lc(t),!o&&e.held||jl(e)},c=()=>Pl(e),d=()=>jl(e);t.offs.push(o.on("interval",({interval:e})=>t.group?.links.setInterval(t.member,e)),o.on("theme",({chartTheme:t})=>{e.themeSync||e.grid.setTheme(t)}),o.on("symbol",s),o.on("interval",s),o.on("variant",s),o.on("layout",()=>{const e=o.chartType();e!==t.type&&(t.type=e,t.group?.links.setChartType(t.member,e))}),o.on("layout",d),n.on("pan",l),n.on("zoom",l),n.on("resize",()=>function(e,t){const o=t.widget.chart,n=o.getVisibleLogicalRange(),i=o.dataLayer,a=t.span,r=t.group,s=null!==r&&r.links.options().viewport?r.view:null,l=t.hold&&a>0;if(t.hold=!1,l||null!==s&&(a>0||t!==r?.keeper)){e.syncing=!0;try{o.setVisibleLogicalRange(a>0||null===s?{from:n.to-a,to:n.to}:{from:i.timeToIndexFloat(s.from),to:i.timeToIndexFloat(s.to)})}finally{e.syncing=!1}}t.span=Oc(t),(t===r?.keeper||null!==s&&0===a)&&Lc(t)}(e,t)),...function(e){const t=e.keymap,o=e.text,n="Chart grid",i=[t.register("Alt+Enter",()=>e.toggleMaximize(),"widget",{label:Pe(o,"Maximize or restore the chart"),group:n}),t.register("Escape",()=>!!e.maximized()&&(e.restore(),!0),"widget",{label:Pe(o,"Restore the grid"),group:n,layered:!0})];for(const a of["left","right","up","down"])i.push(t.register(`Alt+Shift+${ec[a]}`,()=>e.focus(a),"widget",{label:Pe(o,tc[a]),group:n}),t.register(`Mod+Shift+${ec[a]}`,()=>e.swap(a),"widget",{label:Pe(o,oc[a]),group:n}));return i}({keymap:o.context.keymap,text:e.text,maximized:()=>e.maxed,toggleMaximize:()=>!(!e.maxed&&null!==vc(e))&&(wc(e,t),!0),restore:()=>bc(e,!1),focus:o=>{const n=Xl(e.cells,t,o);return void 0!==n&&(queueMicrotask(()=>{e.destroyed||e.grid.setActive(n.id,{focus:!0})}),!0)},swap:o=>{const n=Xl(e.cells,t,o);return void 0!==n&&!Fl(e)&&(e.grid.swap(t.id,n.id),!0)}}));for(const e of["draw:add","draw:remove","alert:created","alert:removed"])t.offs.push(n.on(e,c));for(const e of["draw:update","alert:updated","objects:change"])t.offs.push(n.on(e,d))}function Tc(e,t){t===t.group?.keeper&&Ec(t.group);for(const e of t.offs.splice(0))e();void 0!==t.member&&e.links.leave(t),t.widget.destroy(),t.element.remove()}function jc(e,t){const o=e.cells.find(e=>e.element.contains(t));void 0!==o&&e.grid.setActive(o.id)}const Pc=(e,t)=>e.active?.group===t?e.active:e.cells.find(e=>e.group===t);function Mc(e,t,o){const n=Pc(e,t);void 0!==n&&(o.symbol&&t.links.setSymbol(n.member,ul(n.widget.symbol(),n.widget.exchange())),o.interval&&t.links.setInterval(n.member,n.widget.interval()),o.chartType&&t.links.setChartType(n.member,n.widget.chartType()))}function Ic(e,t,o){o.viewport&&!t.links.options().viewport&&Ec(t),Mc(e,t,o),t.links.setOptions(o)}function Dc(e,t,o){if(e.destroyed)return{applied:!1,reason:"the grid is destroyed"};const n=bl(t);if(""!==n)return{applied:!1,reason:n};const{links:i}=e,a=t.panes.find(e=>e.id===t.activePaneId)?.settings?.[ai],r="dark"===a||"light"===a?a:e.theme,s=e.doc.createElement("div"),l=[];try{for(const n of t.layout.slots.slice().sort((e,t)=>e.row-t.row||e.column-t.column)){const i=t.panes.find(e=>e.id===n.paneId),a=Ac(e,i.id,i,s,r,o);l.push(a),Object.assign(a,{row:n.row,column:n.column,rowSpan:n.rowSpan??1,columnSpan:n.columnSpan??1});const c=hi(a.widget,i,!1);if(!c.applied)throw new Error(`${i.id}: ${c.reason??"the chart state could not be restored"}`);a.type=a.widget.chartType()}}catch(t){return l.reverse().forEach(t=>Tc(e,t)),{applied:!1,reason:t instanceof Error?t.message:String(t)}}e.maxed=!1,e.root.dataset.maximized="false",e.cells.forEach(t=>Tc(e,t)),i.destroy(),e.cells=l,e.drawings=o;const{layout:c,sync:d}=t;e.rows=c.rows,e.cols=c.columns,e.rowW=c.rowWeights?.slice()??lc(e.rows),e.colW=c.columnWeights?.slice()??lc(e.cols),e.preset=c.preset??null,e.theme=r,hc(e),e.active=l.find(e=>e.id===t.activePaneId),l.forEach(t=>$c(e,t));const u=void 0===d.groups?[{id:void 0,name:null,channels:pl(d),panes:t.panes}]:d.groups.map(e=>({id:e.id,name:e.name,channels:pl(e),panes:t.panes.filter(t=>t.linkGroup===e.id)}));for(const t of u){const o=i.create({id:t.id,name:t.name,links:dl});o.name===Pe(e.text,"Group {letter}",{letter:o.letter})&&(o.name=null);for(const e of t.panes)i.join(l.find(t=>t.id===e.id),o);Mc(e,o,{symbol:!0,interval:!0,chartType:!0}),o.links.setOptions(t.channels)}return i.prune(e.cells),Sc(e),Pl(e),dc(e,"layout",{reason:"workspace"}),dc(e,"active",{id:e.active.id}),dc(e,"links",e.grid.linkOptions()),{applied:!0}}const zc={"1x1":"One chart","1x2":"Two columns","2x1":"Two rows","1x3":"Three columns","3x1":"Three rows","left-2":"Large left, two on the right","right-2":"Large right, two on the left","top-2":"Large top, two below","bottom-2":"Large bottom, two above","2x2":"Two by two","1x4":"Four columns","4x1":"Four rows","left-3":"Large left, three on the right","top-3":"Large top, three below","left-4":"Large left, four on the right","top-4":"Large top, four below","2x3":"Two rows of three","3x2":"Three rows of two","corner-5":"Large corner, five around","2x4":"Two rows of four","4x2":"Four rows of two","corner-7":"Large corner, seven around","3x3":"Three by three","3x4":"Three rows of four","4x3":"Four rows of three","4x4":"Four by four"};function Nc(e,t){return Pe(e,zc[t])}function Rc(e,t){return 1===t?Pe(e,"1 chart"):Pe(e,"{count} charts",{count:t})}function Fc(e,t){const o=e.ownerDocument;ua(o,Us,t.styleNonce);const n=De(o,"div","oac-widget oac-alert-host");e.appendChild(n);const i=Ze(n,o),a=Qe(n,i.layer,o),r=De(o,"div","oac-toasts");n.appendChild(r);const s=Wi(r,o,t);let l=t.theme??"dark",c=t.chartTheme??("light"===l?q:U),d=!1,u=!1,h=null;function p(){const e=i.size()>0;e!==u&&(u=e,t.onOpenChange?.(u))}const g={chart:t.chart,draw:t.draw,alerts:t.alerts,root:n,document:o,get theme(){return l},get chartTheme(){return c},keymap:new eo,bus:new it,storage:new Ve("alert-ui",null),locale:t.locale,translate:t.translate,tips:a,overlays:i,toast:(e,t)=>s.toast(e,t),status:(e,t)=>{s.toast(e,t)},symbol:()=>({symbol:t.chart.getDataContext()?.symbol??"",exchange:t.chart.getDataContext()?.exchange??""}),interval:()=>t.chart.getDataContext()?.interval??"",openOverlay:(e,t)=>{const o=i.open(e,{...t,onClose:()=>{t?.onClose?.(),p()}});return p(),o}},m=e=>{e.stopPropagation()};n.addEventListener("keydown",m);const f=t.chart.on("destroy",()=>b.destroy()),b={root:n,context:g,openList:e=>!d&&(h?.isOpen()?(h.el.focus(),!0):(h=xr(g,e,{onClose:()=>{h=null}}),!0)),openEditor:e=>!d&&(_r(g,void 0,e),!0),isOpen:()=>!d&&i.size()>0,close:()=>i.closeAll(),setTheme:(e,t)=>{d||(l=e,c=t??("light"===e?q:U),n.dataset.theme=e,sa(n,ra(c,e)))},destroy:()=>{d||(d=!0,f(),i.destroy(),a.destroy(),s.destroy(),g.keymap.destroy(),g.bus.clear(),n.removeEventListener("keydown",m),n.remove())}};return b.setTheme(l,c),b}const Wc="widget";export{qs as ACCOUNT_SUMMARY_CSS,Qr as BOTTOMBAR_CSS,Vr as BOTTOMBAR_HEIGHT,Os as CHART_GRID_CSS,Sl as CHART_GRID_LAYOUTS,zc as CHART_GRID_LAYOUT_NAMES,vl as CHART_GRID_PRESETS,ji as CHART_TYPE_LABELS,po as COLOR_PICKER_CSS,Pt as ChartHistory,gt as D,ks as DATA_WINDOW_CSS,zr as DATE_NAVIGATION_CSS,Vs as DEFAULT_INTERVALS,Gs as DEFAULT_LOOKBACK_BARS,Fr as DEFAULT_RANGES,Pr as DIALOG_CSS,Ys as DRAWINGS_KEY_PREFIX,Oa as DRAWING_COORDINATES_CSS,wa as DRAWING_TEMPLATES_CSS,ss as DRAWING_TOOLBAR_CSS,Cn as DateNavigator,bs as EVENT_DETAILS_CSS,ws as EventDetailsPopup,It as KEYMAP_KEY,eo as Keymap,Ho as MAGNET_MODES,cn as MIN_PRICE_DIGITS,gs as NEWS_PANEL_CSS,us as NewsReader,nr as OBJECTS_PANEL_CSS,In as PANEL_DOCK_CSS,Ss as QUICK_ENTRY_CSS,Ms as QuoteBoard,Ko as RAIL_GROUPS,Go as RAIL_PREFS_KEY,na as RAIL_WIDTH,Js as SAVE_DEBOUNCE_MS,gn as SEARCH_DEBOUNCE_MS,Zs as STATE_KEY,aa as STATUSLINE_HEIGHT,Ke as STORAGE_PREFIX,vn as SYMBOL_PICKER_CSS,Zi as TEXT_CONTRAST,Ye as TIP_DWELL_MS,Fi as TOAST_LEAVE_MS,Ri as TOAST_MAX,Ni as TOAST_MS,qi as TOKEN_PREFIX,ts as TOOLBAR_LINE_WIDTHS,ia as TOPBAR_HEIGHT,Ws as WATCHLIST_PANEL_CSS,Us as WIDGET_COMPONENT_CSS,da as WIDGET_CSS,jr as WIDGET_DIALOGS,ta as WIDGET_FONT,oa as WIDGET_MONO,Qs as WIDGET_STATE_VERSION,ca as WIDGET_STYLE_ID,Wc as WIDGET_TIER,it as WidgetBus,Ve as WidgetStorage,ha as a,wi as applyIndicatorTemplate,sa as applyTokens,Tr as attachContextMenu,xi as b,Ue as boxIn,Rc as c,Wo as captureName,Mi as chartTypeChoices,Pi as chartTypeLabel,Or as contextMenuEntries,Ji as contrastRatio,xo as controlsFromFields,wo as controlsFromInputs,Fc as createAlertUi,cc as createChartGrid,ho as createColorPicker,ma as createDrawingTemplates,bt as createIndexedDbWidgetStorage,En as createLayoutsController,tr as createObjectsPanelContent,Ze as createOverlayStack,Qe as createTipController,ll as createWidget,Oi as d,Je as defaultStorage,Fo as downloadText,Me as e,Ie as esc,Bt as eventKeyCombo,di as f,Re as focusable,Fe as focusables,Vi as formatColor,Ut as formatKeyCombo,Kt as fromChartCombo,Ql as g,ze as glyph,De as h,tt as historyPress,nt as historyReady,Ll as i,Ne as inTextField,ua as injectWidgetStyles,go as inputConditionMet,fo as inputStates,Ii as intervalLabel,Co as j,Ci as k,Nc as l,nl as loadWindow,Gi as luminance,$o as m,Xi as mix,Bs as mountAccountSummary,_r as mountAlertEditor,xr as mountAlertsPanel,Yr as mountBottombar,$r as mountContextMenu,xs as mountDataWindow,Aa as mountDrawingCoordinates,qa as mountDrawingProperties,rs as mountDrawingToolbar,Va as mountIndicatorInputControls,Ha as mountIndicatorPicker,lr as mountIndicatorSettings,$a as mountLevelEditor,es as mountMobile,ps as mountNewsPanel,or as mountObjectsPanel,Mn as mountPanelDock,Cs as mountQuickEntry,Qo as mountRail,dr as mountSettingsDialog,hn as mountStatusline,bn as mountSymbolPicker,za as mountTextEditor,Wi as mountToasts,zi as mountTopbar,Fs as mountWatchlistPanel,ko as n,Ao as o,Dr as openDateNavigation,Ai as openLayoutsMenu,Ro as openMenu,ro as openShortcutsPanel,jo as p,Hi as parseColor,Wt as parseKeyCombo,Be as placeBelow,We as placeBeside,qe as placeTip,dn as priceDigits,_i as q,js as quoteChange,ic as r,Br as rangeInterval,Kr as rangeWindow,ys as readDataWindow,Yi as readableOn,rt as registerWidgetDialog,st as registerWidgetDialogs,dt as registeredWidgetDialogs,zo as renderForm,ol as resolveTheme,ki as s,hs as safeNewsUrl,mn as safeSymbolIconUrl,Pn as sanitizePanelDockState,Yo as sanitizeRailPrefs,yi as saveIndicatorTemplate,tl as stripView,er as t,Qi as themeMode,la as token,Zo as toolGlyph,Vo as toolName,Ca as u,lt as unregisterWidgetDialog,ka as v,Lo as w,ct as widgetDialog,pi as widgetLayoutTarget,Pe as widgetText,ra as widgetTokens,ea as withAlpha,va as x,gi as y};
//# sourceMappingURL=openalgo-charts.widget.mjs.map