1import{CIQ as r}from"./CZBXhu2K.js";r.UI=r.UI||{};r.ClassRegistryMap.set("UI",new Map);r.UI.keyboardClaims=r.UI.keyboardClaims||new Set;r.UI.activateShadowRoots=void 0;r.UI.shadowComponents=r.UI.shadowComponents||new Map;r.UI.addAttributeOnPropertyChange=!1;r.UI.classDefinitionAccessor=n=>(r.UI.components(n)[0]||{}).classDefinition||r.UI[n];r.UI.stxtap=function(n,t,e){n&&(r.installTapEvent(n),typeof e=="string"&&(n=n.querySelector(e)),n&&(n.selectFC&&n.removeEventListener("stxtap",n.selectFC),t&&n.addEventListener("stxtap",t)))};r.UI.addResizeListener=function(n,t){r.UI.getUIManager(n).registerForResize(n),n.resizeHandle=r.resizeObserver(n,t,null)};r.UI.removeResizeListener=function(n){r.UI.getUIManager(n).unregisterForResize(n),r.resizeObserver(n,null,n.resizeHandle)};r.UI.containerExecute=function(n,t,e){var i=e;e&&i.constructor!==Array&&(i=Array.prototype.slice.call(arguments,2));for(var o=n.parentElement;o;){if(o[t]&&o[t].constructor==Function)return o[t].apply(o,i);o=o.parentElement||o.getRootNode().host}return null};r.UI.keepConnected=(n,t)=>{if(t!==void 0)return n.doNotDisconnect=t,t;if(n.doNotDisconnect)return!0;let e=n.parentElement;for(;e;){if(e.doNotDisconnect)return!0;e=e.parentElement||e.getRootNode().host}return!1};r.UI.animatePrice=function(n,t,e,i){n[0]&&(n=n[0]),n.timeoutHandle&&(clearTimeout(n.timeoutHandle),n.timeoutHandle=null),n.classList.remove("cq-stable","cq-up","cq-down"),t>e?n.classList.add("cq-up"):t<e&&n.classList.add("cq-down"),i&&(n.timeoutHandle=setTimeout(function(){n.classList.add("cq-stable"),n.classList.remove("cq-up","cq-down")},0))};r.UI.makeFromTemplate=function(n,t){typeof n=="string"&&(n=document.querySelector(n)),n[0]&&r.UI.$(n)[0]==n[0]&&(n=n[0]);var e=n.content,i;function o(c){return function(l){c.appendChild(l.cloneNode(!0))}}function s(c){return function(l){c===!0?n.parentElement.appendChild(l):c[0]?c[0].appendChild(l):c.appendChild(l)}}e.childNodes.length?i=document.importNode(e,!0):(e=document.createElement("DIV"),Array.from(n.children).forEach(o(e)),i=e.cloneNode(!0));var a=Array.from(i.children);return t&&a.forEach(s(t)),r.UI.$(a)};r.UI.splitMethod=function(n){if(!n)return null;var t=n.indexOf("("),e=n.lastIndexOf(")");if(t==-1||e==-1)return console.log("malformed stxtap attribute: "+n),null;var i=null,o,s=n.substring(0,t),a=s.indexOf(".");a==-1?o=s:(i=s.substring(0,a),o=n.substring(a+1,t));var c=n.substring(t+1,e),l=c.match(/('[^']+'|[^,]+)/g),h=new RegExp("^[0-9]+([,.][0-9]+)?$","g"),f=new RegExp("^\\d+$"),u=[];if(l)for(var p=0;p<l.length;p++){for(var d=l[p];d.charAt(0)==" ";)d=d.substring(1);if(d.indexOf('"')!=-1||d.indexOf("'")!=-1)u.push(d.substring(1,d.length-1));else if(d=="true")u.push(!0);else if(d=="false")u.push(!1);else if(d=="null")u.push(null);else if(f.test(d))u.push(parseInt(d,10));else if(h.test(d))u.push(parseFloat(d));else{for(var g=d.split("."),y=window,C=0;C<g.length;C++)y=y[g[C]];u.push(y)}}return{helperName:i,functionName:o,args:u}};r.UI.observeProperty=function(n,t,e){if(!t||!n||!e)return;n in t||(t[n]=void 0),r.UI.observables||(r.UI.observables={});const{observables:i}=r.UI;i[n]||(i[n]=[]);let o=i[n].find(s=>s.obj==t);return o||(o={obj:t,value:t[n],listeners:[]},i[n].push(o)),o.listeners.push(e),e({obj:t,property:n,value:o.value}),Object.defineProperty(t,n,{enumerable:!0,configurable:!0,get:()=>o.value,set:s=>{if(o.value!==s){const a=o.value;o.value=s,o.listeners.forEach(c=>c({obj:t,property:n,value:s,oldValue:a}))}}}),()=>r.UI.unobserveProperty(n,t,e)};r.UI.unobserveProperty=function(n,t,e){if(!(!n||!t||!r.UI.observables)){var i=r.UI.observables[n];if(i){for(var o=i.length-1;o>=0;o--){var s=i[o];if(s.obj==t){if(e)for(var a=s.listeners,c=a.length-1;c>=0;c--)a[c]===e&&a.splice(c,1);(!e||!s.listeners.length)&&(Object.defineProperty(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s.value}),i.splice(o,1))}}i.length||delete r.UI.observables[n]}}};r.ChartEngine.prototype.addObservableProperty=function(n,t,e){this.observables||(this.observables=[]),this.observables.push(r.UI.observeProperty(n,t,e))};r.UI.getMyContext=function(n,t){for(t&&(n=r.UI.closestContextContainer(n)||n);n;){if(n.context)return n.context;if(n.CIQ&&n.CIQ.UI)return n.CIQ.UI.context;n=n.parentElement||n.getRootNode().host}return null};r.UI.contextsForEach=function(n,t){var e=((t||{}).ownerDocument||document).querySelectorAll("cq-context,*[cq-context]");e.forEach(function(i){i.CIQ&&i.CIQ.UI&&i.CIQ.UI.context&&n.apply(i.CIQ.UI.context)})};r.UI.release=!1;r.UI.bypassBindings=!1;r.UI.begin=function(n){r.UI.release=!0,setTimeout(function(){b.nextTick(),n&&n()},0)};r.UI.activatePluginUI=function(n,t){const{uiContext:e={},container:i}=n,o=e.topNode||i.closest("cq-context")||i,s=t.toLowerCase()+"-feature";
1o.setAttribute(s,""),r.UI.shadowComponents.forEach((a,c)=>{a===o&&c.setAttribute(s,"")})};r.UI._webcomponents={list:{}};r.UI.addComponentDefinition=function(n,t){const e=!!r.UI.registerComponentsImmediately;r.ensureDefaults(r.UI._webcomponents,{registered:e}),r.UI._webcomponents.list[n]={tag:n,name:n.split("-").map(i=>r.capitalize(i)).splice(1).join(""),classDefinition:t,registered:e},e&&customElements.define(n,t)};r.UI.registerComponents=function({except:n=[]}={}){const{exceptions:t={}}=r.UI._webcomponents;n.forEach(o=>t[o]=!0),r.UI._webcomponents.exceptions=t;const{list:e}=r.UI._webcomponents;Object.keys(e).filter(o=>!n.includes[o]).forEach(o=>{const s=e[o];s&&!s.registered&&!t[o]&&(customElements.define(o,s.classDefinition),s.registered=!0)})};r.UI.registerSingleComponent=function(n){const t=r.UI._webcomponents.list[n.toLowerCase()];if(t)return t.registered||(customElements.define(n,t.classDefinition),t.registered=!0),t.classDefinition};r.UI.ensureComponentsRegistered=function(){r.UI.registerComponents()};r.UI.components=function(n){return Object.values(r.UI._webcomponents.list).filter(({tag:e,name:i,classDefinition:o})=>!n||n===e||n===i||n===o)};r.UI.componentMarkup=function(n,t){const e=this.components(n);if(t===void 0){if(!e.length)return;const s=e.map(o);return n?s[0]:s}const[i]=e;if(!i||!i.classDefinition.markup)return;return i.classDefinition.markup=t,o(i);function o(s){const{tag:a,registered:c,classDefinition:{markup:l,name:h}}=s;return{tag:a,name:h,registered:c,markup:l}}};r.UI.markupDependencies=function(){const n=r.UI.componentMarkup(),t={};n.forEach(i=>{if(i.markup)for(let o in r.UI._webcomponents.list){const s=r.UI._webcomponents.list[o];i.markup.indexOf("</"+s.tag+">")>-1&&(t[i.tag]||(t[i.tag]=[]),t[i.tag].push(s.tag))}});const e={};for(let i in t)t[i].forEach(o=>{e[o]=(e[o]||0)+1});return{dependencies:t,timesNeeded:e}};r.UI.addInheritance=function(n,t){for(var e in t.prototype)try{n.prototype[e]=t.prototype[e]}catch{}};var D={};r.UI.supportedInputType=function(n){if(!D[n]){var t=document.createElement("input");t.setAttribute("type",n),D[n]=t.type}return D[n]};r.UI.flattenInheritance=function(n,t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{const i=s=>Object.getOwnPropertyDescriptor(s.prototype,e),o=i(t);o&&!i(n.constructor)&&Object.defineProperty(n,e,o)})};r.UI.Context=function(n,t,e){this.params=e||{},this.stx=n,this.node=r.UI.$(t),this.lookupDriver=void 0,this.config={},this.topNode=t,r.isMobile&&t.setAttribute("ciq-mobile","");const i=r.UI.Context.assembleContext(t);this.advertised={};const o=t.CIQ.UI.context=this,s=new Map;i.Components.forEach(a=>{const c=a.closest("cq-context, *[cq-context]")||a.getRootNode();s.has(c)||s.set(c,[]),s.set(c,s.get(c).concat([a.tagName]))}),s.forEach((a,c)=>{c.querySelectorAll(a.join(",")).forEach(function(l){l.context!==o&&l.setContextPrivate&&l.setContextPrivate(o)})}),n&&(n.uiContext=this)};r.UI.closestContextContainer=function(n,{isWrapper:t,includeSelf:e}={}){const i=t?"cq-context-wrapper":"cq-context,*[cq-context]";return e&&n.matches(i)?n:n&&!n.defaultView&&!n.window&&(n.closest(i)||r.UI.closestContextContainer(n.getRootNode().host,{isWrapper:t}))};r.UI.makeShadow=function(n){r.UI.activateShadowRoots&&(n.attachShadow({mode:"open",delegatesFocus:!0}),n.isShadowComponent=!0),n.root=n.shadowRoot||n};var S=r.UI.Context;S.assembleContext=function(n){return n.CIQ||(n.CIQ={}),n.CIQ.UI||(n.CIQ.UI={}),n.CIQ.UI.Components||(n.CIQ.UI.Components=[]),n.CIQ.UI};S.prototype.changeSymbol=function(n,t){console.log("Please implement CIQ.UI.Context.prototype.changeSymbol")};S.prototype.setLookupDriver=function(n){this.lookupDriver=n,n.deprecated&&console.warn("Using deprecated Lookup Driver, please see documentation: CIQ.ChartEngine.Driver.Lookup")};S.prototype.advertiseAs=function(n,t){this.advertised[t]=n};S.prototype.getAdvertised=function(n){return this.advertised[n]};S.prototype.setLoader=function(n){this.loader=n};S.prototype.isModal=function(){return this.stx.openDialog!==""};S.prototype.isLegendKeyboardActive=function(){const{topNode:n}=this;return[...(r.UI.closestContextContainer(n)||n).querySelectorAll("cq-study-legend.ciq-active, cq-menu.cq-comparison-new.stxMenuActive")].includes(e=>{if(e.classList.contains("ciq-active")&&e.keyboardNavigation||e.classList.contains("stxMenuActive")&&e.parentElement.keyboardNavigation)return!0})};class b extends HTMLElement{static get name(){return"BaseComponent"}static get className(){return r.UI.components(this).concat(this)[0].name}constructor(){super(),this.node=r.UI.$(this),this.eventListeners=[],this.constructor.observedAttributes&&this.constructor.observedAttributes.forEac
1h(t=>{const e={get:()=>this[`_${t}`],set:i=>{if(this[`_${t}`]===i)return;let o=this[`_${t}`];this[`_${t}`]=i,typeof o=="object"&&(o=JSON.stringify(o)),i&&typeof i=="object"&&(i=JSON.stringify(i)),r.UI.addAttributeOnPropertyChange||this.hasAttribute(t)?this.getAttribute(t)!==i&&this.setAttribute(t,i):this.attributeChangedCallback(t,o,i)}};Object.defineProperty(this,t,e),t.includes("-")&&Object.defineProperty(this,r.makeCamelCase(t),e),r.UI.addAttributeOnPropertyChange&&this[`_${t}`]!==void 0&&this.setAttribute(t,this[`_${t}`])})}connectedCallback(){!this.isConnected||this.attached||((this.constructor.observedAttributes||[]).forEach(t=>{if(t in this){const e=this[t];e!=null&&!this.hasAttribute(t)&&this.setAttribute(t,e)}}),b.buildReverseBindings(this),this.attached=!0)}adoptedCallback(){r.UI.flattenInheritance(this,b)}disconnectedCallback(){if(!r.UI.keepConnected(this)){if(this.attached=!1,this.context){for(var t=0;t<this.eventListeners.length;t++)this.context.stx.removeEventListener(this.eventListeners[t]);this.eventListeners=[]}this.copyStylesheetListener&&this.ownerDocument.head.removeEventListener(this.copyStylesheetListener),r.UI.shadowComponents.delete(this)}}attributeChangedCallback(t,e,i){if(this.handlePropertyChange)this.handlePropertyChange(t,e,i);else{if(e===i)return;this[t]=i}}addDefaultMarkup(t,e){const i=t||this;if((a=>a.children.length===0&&!a.innerText.trim())(i)&&(i.constructor.markup||e)){const a=+new Date,c=e||i.constructor.markup;if(i.ownerDocument!==document){const l=document.createElement("template");r.safeAssign(l,c),document.body.append(l),i.append(document.importNode(l.content,!0)),l.remove()}else r.safeAssign(i,c);if(b.buildReverseBindings(i),r.debug){const l=+new Date-a;b.createMarkupTime=l+(b.createMarkupTime||0),console.log("Building markup "+this.constructor.name+" "+(this.getAttribute("cq-name")||"")+" built in="+l,"total="+b.createMarkupTime)}if(r.I18N&&r.I18N.localized){const l=r.getFromNS(this,"context.stx.preferences.language");r.I18N.translateUI(l,i)}}const s=this.root||this.shadowRoot||this;i!==t&&i!==s&&[...i.children].forEach(a=>s.append(a))}emitCustomEvent({cause:t,effect:e,action:i="click",detail:o={}}){const s=r.UI.components(this.nodeName.toLowerCase())[0].name;i&&!t&&(t="useraction");const a={bubbles:!0,cancelable:!0,composed:!0,detail:r.extend({emitter:this,action:i,cause:t,effect:e},o)};i&&this.dispatchEvent(new CustomEvent(i,a)),this.dispatchEvent(new CustomEvent(s,a))}channelWrite(t,e,i){const{obj:o,prop:s}=r.UI.BaseComponent.getChannel(t,i,this);o&&(o[s]=e)}channelMergeObject(t,e,i){const{obj:o,prop:s}=r.UI.BaseComponent.getChannel(t,i,this);o&&(o[s]=Object.assign({},o[s],e))}channelRead(t,e){const{obj:i,prop:o}=r.UI.BaseComponent.getChannel(t,e,this);if(i)return i&&i[o]}channelSubscribe(t,e,i){const{obj:o,prop:s}=r.UI.BaseComponent.getChannel(t,i,this);if(!o)return;function a({value:l}){e(l)}const c=r.UI.observeProperty(s,o,a);return(i||this.stx).addEventListener("destroy",c),c}qs(t,e){return e==="thisChart"&&(e=this.getContextContainer()),(e||document).querySelector(t)}qsa(t,e,i){if(e==="thisChart"&&(e=this.getContextContainer()),!i)return[...(e||document).querySelectorAll(t)];const o=[],s=a=>{const c=a.ownerDocument.createTreeWalker(a,NodeFilter.SHOW_ELEMENT);let l=c.currentNode;for(l.matches||(l=c.nextNode());l;)l!==a&&l.matches(t)&&o.push(l),l.shadowRoot&&s(l.shadowRoot),l=c.nextNode()};return s(e||document.body),o}getContextContainer(t){return t?r.UI.closestContextContainer(t,{includeSelf:!0}):(this.contextContainer||(this.contextContainer=r.UI.closestContextContainer(this,{includeSelf:!0})),this.contextContainer)}getChartContainer(t){return b.selfOrParentElement(t||this,"ciq-chart")}static getHelper(t,e,i){if(!t)return;if(!e&&(e=t.getAttribute(i)||t[i],!e))return null;let o;const s=e.indexOf("("),a=e.substring(0,s),c=e.indexOf(".");if(s==-1||a.indexOf(".")!=-1){const l=c===-1?e:e.substring(0,c);let{context:h}=t;if(!h){if(!t.isConnected)return null;h=t.context=r.UI.getMyContext(t)}
1if(!h){const f=r.UI.closestContextContainer(t);return f?(f.bindingInitiated&&console.log("No context attached to "+t.tagName+". A context is required when binding to a helper."),null):(console.log(t.tagName+" is not inside cq-context element. A context element is required when binding to a helper."),null)}o=r.UI.getMyContext(t,!0).getAdvertised(l)}else{const l=e.substring(0,s),h=r.climbUpDomTree(t.parentElement,null,!0);for(let f of h)if(typeof f[l]=="function")return f}return o}static activate(t,e,i,o){if(t.justActivated){e.stopPropagation();return}var s=o?"stxsetget":"stxtap",a=r.UI.splitMethod(t.getAttribute(s));if(a){var c=a.helperName,l=a.functionName;o&&(l="set"+l);var h=[{node:t,e,params:i}].concat(a.args);if(c){var f=b.getHelper(t,null,s);if(!f[l]){console.log("Method '"+l+"' not found in helper",f);return}f[l].apply(f,h)}else{var u=r.climbUpDomTree(t.parentElement,null,!0);for(var p of u)typeof p[l]=="function"&&p[l].apply(p,h)}t.justActivated=!0,setTimeout(function(){delete t.justActivated},100)}}makeTap(t,e){b.makeTap(t,e)}static makeTap(t,e){r.UI.stxtap(t,e),t.selectFC=e}static bindNode(t,e){var i,o=t.getAttribute("stxbind"),s=t.getAttribute("stxtap"),a=t.getAttribute("stxsetget");function c(f){var u,p=o.indexOf("(");u=o.substring(o.indexOf(".")+1),p!==-1&&(u=o.substring(0,p)),f&&f[u](t)}if(t.bindingFC&&(i=b.getHelper(t,t.bindingFC,"stxbind"),i&&i.removeObservers&&i.removeObservers(t)),o)if(i=b.getHelper(t,o,"stxbind"),i)c(i);else return!1;t.bindingFC=o;function l(f){return function(u){b.activate(f,u,e,!1)}}t.tagName=="INPUT"&&(t.type==="text"||t.type==="number")?b.inputEntry(t,s&&l(t)):b.makeTap(t,s&&l(t));function h(f){function u(){return function(y){b.activate(t,y,e,!0)}}if(a){var p=r.UI.splitMethod(a);if(!p){console.log("Syntax error "+a);return}var d=[t].concat(p.args).concat(e),g="get"+p.functionName;f&&f[g]&&f[g].apply(f,d)}t.type==="text"||t.type==="number"?b.inputEntry(t,a&&u()):b.makeTap(t,a&&u())}if(!o){if(t.bindingFC&&(i=b.getHelper(t,t.bindingFC,"stxsetget"),i&&i.removeObservers&&i.removeObservers(t)),a)if(i=b.getHelper(t,a,"stxsetget"),i)h(i);else return!1;t.bindingFC=a}return!0}static scheduleForBinding(t,e){const i=b.scheduledBindings.find(({node:o})=>o===t);i?i.parentTag=e:b.scheduledBindings.push({node:t,parentTag:e}),b.timeout&&clearTimeout(b.timeout),b.timeout=setTimeout(b.nextTick,
10)}inputEntry(t,e){b.inputEntry(t,e),t.inputFC=e}static inputEntry(t,e){t.inputFC&&t.removeEventListener("keypress",t.inputFC),t.addEventListener("keypress",function(i){switch(i.which){case 13:case 9:e()}})}trimInnerHTMLWhitespace(){return(this.root||this).innerHTML.trim()}setupShadow(){const t=this.root;if(this===t)return;this.setAttribute("interactable","");const e=o=>{[...o].reverse().forEach(s=>{if(s.tagName==="LINK"){const a=document.createElement("link"),{type:c,media:l,href:h}=s;Object.assign(a,{rel:"stylesheet",type:c,media:l,href:h}),a.onload=()=>{this.resize&&setTimeout(this.resize.bind(this))},a.setAttribute("copied",""),t.insertBefore(a,t.firstChild)}else if(s.tagName==="STYLE"){const a=s.cloneNode(!0);a.setAttribute("copied",""),t.insertBefore(a,t.firstChild)}})};t.querySelectorAll("link[copied], style[copied]").forEach(o=>o.remove()),e(this.ownerDocument.head.querySelectorAll("link:not([no-shadowdom-import]), style:not([no-shadowdom-import])")),this.copyStylesheetListener||(this.copyStylesheetListener=this.ownerDocument.head.addEventListener("stylesheetload",o=>{e([o.detail.link])}));const i=r.UI.closestContextContainer(this);r.UI.shadowComponents.set(this,i),this.getAttributeNames().filter(o=>/-feature$/.test(o)).forEach(o=>this.removeAttribute(o)),i.getAttributeNames().filter(o=>/-feature$/.test(o)).forEach(o=>this.setAttribute(o,i.getAttribute(o))),i.currentTheme&&this.classList.add(i.currentTheme),i.classList.contains("full-screen")&&this.classList.add("full-screen")}addClaim(){r.UI.keyboardClaims.add(this)}removeClaim(){r.UI.keyboardClaims.delete(this)}static buildReverseBindings(t){if(!r.UI.bypassBindings){var e=function(s){if(s.hasAttribute("stxbind")||s.hasAttribute("stxtap")||s.hasAttribute("stxsetget"))return NodeFilter.FILTER_ACCEPT},i=t.ownerDocument.createNodeIterator(t,NodeFilter.SHOW_ELEMENT,r.isIE?e:{acceptNode:e}),o;for(o=i.nextNode();o;)o.handlesBindings||b.scheduleForBinding(o,t),o=i.nextNode()}}static nextTick(){if(!r.UI.release)return;clearTimeout(b.timeout);const{scheduledBindings:t}=b;t.reverse().forEach(e=>{const{node:i}=e;(!i.ciqAlreadyBound||i.getAttribute("stxbind")!==i.bindingFC)&&(i.ciqAlreadyBound=!i.isConnected||b.bindNode(i,{parent:e.parentTag}))}),b.scheduledBindings=t.filter(e=>!e.node.ciqAlreadyBound)}static selfOrParentElement(t,e){let i=t;for(;i;){if(i.classList.contains(e)||i.getAttribute(e)!==null||i.nodeName.toLowerCase()===e)return i;i=i.parentElement}}static toPropAndObject(t,e){const i=t.split("."),o=i.pop(),s=i.reduce((a,c)=>a[c]!==void 0?a[c]:a[c]={},e);return{prop:o,obj:s}}static getChannel(t,e,i){if(!t)return console.warn("Missing channel path"),{};if(!e&&!i)return console.warn("Chart engine not provided while retrieving ",t),{};if(!e&&i.stx&&i.stx.destroyed&&(delete i.stx,delete i.container),!e&&!i.stx){if(i.container||(i.container=r.UI.getMyContext(i)),!i.container)return{};i.stx=i.container.stx}const{obj:o,prop:s}=b.toPropAndObject(t,e||i.stx);return{obj:o,prop:s}}findFocused(t){return Array.from(t||[]).filter(e=>e.matches("[cq-focused]")||e===document.activeElement)}findKeyboardActive(t){return Array.from(t).filter(e=>e.matches("[cq-keyboard-active]"))}focusNextItem(t,e,i){if(!t.length)return;const o=this.findFocused(t);let s=-1;if(o.length)for(s=0;s<t.length&&t[s]!==o[0];s++);const a=s;if(e)do{if(s--,s<0)if(i)s=t.length-1;else break;if(s==a)break}while(!r.trulyVisible(t[s])||t[s].getAttribute("keyboard-selectable")==="false");else do{if(s++,s>=t.length)if(i)s=0;else break;if(s==a)break}while(!r.trulyVisible(t[s])||t[s].getAttribute("keyboard-selectable")==="false");if(s>-1&&s<t.length&&t[s]!==o[0])return this.removeFocused(t),this.focusItem(t[s]),t[s]}focusItem(t){this.scrollToElement&&this.scrollToElement(t),t.setAttribute("cq-focused","true"),this.activeElementName=t.getAttribute("name"),this.highlightItem(t),t.tagName=="INPUT"||t.tagName=="TEXTAREA"?this.clickItem(t):t.focus()}removeFocused(t){t||(t=this.qsa?this.qsa("[cq-focused]",this,!0):this.querySelectorAll("[cq-focused]")),[...t].forEach(e=>{e.removeAttribute("cq-focused"),e.blur()})}highlightItem(t,e){if(!t||!this.keyboardNavigation||!this.keyboardNavigation.highlightPosition)return;const i=this.keyboardNavigation,o=()=>{const{x:s,y:a,width:c,height:l}=t.getBoundingClientRect();i.highlightPosition({element:t,position:{x:s,y:a,width:c,height:l}})};clearTimeout(this.highlightDelayTimeout),this.highlightDelayTimeout=setTimeout(o,e||0)}highlightFocusedItem(t){let e=this.findFocused(t);e.length&&this.highlightItem(e[0])}clickItem(t,e,i){if(t)return t.focus(),t.setAttribute("cq-keyboard-active","true"),i&&(t.keyboardOriginationElement=i),t.selectFC?t.selectFC.call(t,e):t.dispatchEvent(new Event("click",{bubbles:!0,cancelable:!0,composed:!0})),!0}deactivateItem(t){t.blur(),t.removeAttribute("cq-keyboard-active")}clickFocusedItem(t,e){let i=this.findFocused(t);i.length&&this.clickItem(i[0],e)}}b.scheduledBindings=[];r.UI.BaseComponent=b;class N extends b{static get name(){return"ContextTag"}constructor(){super(),this.injections=[],this.context=null}connectedCallback(){!this.isConnected||this.attached||(this.setContextHolder(),super.connectedCallback())}adoptedCallback(){super.adoptedCallback(),r.UI.flattenInheritance(this,N)}disconnectedCallback(){if(!r.UI.keepConnected(this)){if(this.attached=!1,this.context){var t;for(t=0;t<this.injections.length;t++)this.context.stx.removeInjection(this.injections[t]);for(this.injections=[],t=0;t<this.eventListeners.length;t++)this.context.stx.removeEventListener(this.eventListeners[t]);this.eventListeners=[];
1const e=S.assembleContext(this.context.topNode);e.Components=e.Components.filter(i=>i!==this)}this.marker&&this.marker.remove(),this.marker=null,delete this.context,r.UI.shadowComponents.delete(this)}}setContextHolder(){let t=r.UI.closestContextContainer(this);if(!t){const o=r.climbUpDomTree(this,"cq-dialog",!0)[0];o&&(t=o.firstElementChild.context||o.context)}if(!t){this.parentElement&&console.log("No cq-context found for "+this.tagName);return}var e=t.topNode||t,i=S.assembleContext(e);i.Components.push(this),i.context&&this.setContextPrivate(i.context)}setContext(t){}setContextPrivate(t){if(t.stx.destroyed){delete this.context;return}if(this.context=t,this.uiManager=r.UI.getUIManager(t.topNode),!this.convertedToMarker&&!this.dormant&&this.matches("cq-marker,[cq-marker]")){this.convertedToMarker=!0;const o=this.cloneNode(!0);o.dormant=o.hidden=!0,this.insertAdjacentElement("afterend",o),t.stx.addEventListener("destroy",()=>{o.dormant=o.hidden=!1}),r.I18N&&r.I18N.localized&&r.I18N.translateUI(t.stx.preferences.language,this),this.marker=new r.Marker({stx:t.stx,node:this,xPositioner:"none",yPositioner:"none",label:"component",permanent:!0})}const e=t.contextsToSet;e||(t.contextsToSet=[]);const i=function(o,s){return function(){const{contextsToSet:a}=s;if(a){for(;a.length&&(setTimeout(a.shift()),!(s.isAsyncLoad&&!s.stx.displayInitialized)););a.length||delete s.contextsToSet}o.isConnected&&o.attached&&!o.dormant&&!s.stx.destroyed&&(o.setContext(s),o.emitCustomEvent({effect:"contextinitialized",action:null,cause:"timeout"}))}}(this,t);t.isAsyncLoad?(t.contextsToSet.push(i),e||t.stx.ownerWindow.requestAnimationFrame(t.contextsToSet.shift())):setTimeout(i)}addInjection(t,e,i){this.injections.push(this.context.stx[t](e,i))}}r.UI.ContextTag=N;class M extends N{static get name(){return"ModalTag"}constructor(){super()}connectedCallback(){!this.isConnected||this.attached||(this.onpointerover=function(){this.modalBegin()},this.onpointerout=function(){this.modalEnd()},super.connectedCallback())}adoptedCallback(){super.adoptedCallback(),r.UI.flattenInheritance(this,M)}modalBegin(){this.context&&this.context.stx.modalBegin()}modalEnd(){this.context&&(this.uiManager.activeMenuStack.length||this.context.stx.modalEnd())}}r.UI.ModalTag=M;class O extends b{static get name(){return"DialogContentTag"}constructor(){super()}adoptedCallback(){super.adoptedCallback(),r.UI.flattenInheritance(this,O)}close(){var t=this.closest("cq-dialog");t&&t.close(),Array.from(this.querySelectorAll("cq-swatch")).forEach(function(e){e.colorPicker&&e.colorPicker.close()})}naturalTabElements(t){return t||(t=this),Array.from(t.querySelectorAll("input, button, select, [tabindex='0']"))}open(t){t&&t.context&&this.setContext(t.context);var e=this.tagName.toLowerCase(),i=this.closest("cq-dialog");i&&(i.addActiveAttribute(e),i.open(t))}setContext(t){[...this.querySelectorAll("[stxtap],[stxbind],[stxsetget]")].forEach(e=>e.context=t),this.context=t}}r.UI.DialogContentTag=O;r.UI.defaultSwatchColors=["#8ec648","#00afed","#ee652e","#912a8e","#fff126","#e9088c","#ea1d2c","#00a553","#00a99c","#0056a4","#f4932f","#0073ba","#66308f","#323390"];r.UI.pickSwatchColor=function(n,t){if(!n.context||!t)return;const{stx:e}=n.context,{chart:i,crossSection:o}=e,{usedColors:s=new Set}=n;let a=t.getAttribute("color")||"";if(a&&a!=="initial"&&(a=r.colorToHex(a)),o)for(const h in o.curves){let f=o.curves[h];s.add(r.convertToNativeColor(f.color))}else for(const h in i.series){var c=i.series[h];s.add(r.convertToNativeColor(c.parameters.color)),s.add(r.colorToHex(c.parameters.color))}if(n.usedColors||(n.usedColors=s),!(a!==""&&a!=="initial"&&!s.has(a)))for(var l=0;l<n.swatchColors.length;l++){const h=n.swatchColors[l];if(!s.has(h)){t.setAttribute("color",h),r.UI.usingLegacyComponents&&(t.style.background=h,t.value=h);return}}};r.UI.Helper=function(n,t){this.node=n,this.context=t};r.UI.Helper.prototype.addInjection=function(n,t,e){this.injections=this.injections||[],this.injections.push(this.context.stx[n](t,e))};r.UI.Helper.prototype.addObserver=function({node:n,base:t,path:e,listener:i}){const o=t instanceof r.ChartEngine,{obj:s,member:a}=r.deriveFromObjectChain(t,e);r.UI.observeProperty(a,s,i),this.observers=this.observers||[],this.observers.push({node:n,base:t,path:e,listener:i,isEngine:o}),o&&t.addEventListener("destroy",()=>{const c=this.observers.find(f=>f.path===e&&f.node);
1if(!c)return;const{obj:l,member:h}=r.deriveFromObjectChain(c.base,e);r.UI.unobserveProperty(h,l,i)})};r.UI.Helper.prototype.removeObservers=function(n){this.observers&&(this.observers.filter(t=>t.node===n).forEach(t=>{const{obj:e,member:i}=r.deriveFromObjectChain(t.base,t.path);r.UI.unobserveProperty(i,e,t.listener)}),this.observers=this.observers.filter(t=>t.node!==n))};r.UI.Helper.prototype.changeContext=function(n){this.implementation&&this.implementation.stx&&(this.implementation.stx=n.stx),(this.observers||[]).forEach(i=>{const{path:o,listener:s,isEngine:a}=i;t(i.base,o,s),i.base=a?n.stx:n,e(i.base,o,s)}),this.stx&&(this.stx=n.stx),this.context&&(this.context=n);function t(i,o,s){let{obj:a,member:c}=r.deriveFromObjectChain(i,o);r.UI.unobserveProperty(c,a,s)}function e(i,o,s){let{obj:a,member:c}=r.deriveFromObjectChain(i,o);r.UI.observeProperty(c,a,s)}};r.UI.Helper.prototype.setCheckedState=function(n,t){const{activeClassName:e,params:i={}}=this;n.classList[t?"add":"remove"](i.activeClassName||e),n.ariaChecked=t?"true":"false"};r.UI.Helper.prototype.destroy=function(){if(this.injections)for(var n=0;n<this.injections.length;n++)this.context.stx.removeInjection(this.injections[n]);this.injections=[],(this.observers||[]).forEach(({base:t,path:e,listener:i})=>{const{obj:o,member:s}
1=r.deriveFromObjectChain(t,e);r.UI.unobserveProperty(s,o,i)}),this.observers=[]};r.UI.HeadsUp=function(n,t,e){this.params=e||{},typeof this.params.autoStart>"u"&&(this.params.autoStart=!0),this.node=n,n.doNotDisconnect=!0,n.remove(),n.doNotDisconnect=!1,this.context=t,this.injections=[],this.maxVolume={lastCheckDate:null,value:0},this.params.autoStart&&this.begin()};r.inheritsFrom(r.UI.HeadsUp,r.UI.Helper);r.UI.HeadsUp.prototype.begin=function(){if(!this.injections.length&&r.Marker){r.Marker.HeadsUp||(r.Marker.HeadsUp=function(t,e){this.className||(this.className="CIQ.Marker.HeadsUp"),r.Marker.call(this,t),this.prevTick=null,this.showClass=e},r.inheritsFrom(r.Marker.HeadsUp,r.Marker,!1),r.Marker.HeadsUp.placementFunction=function(t){function e(v,I,w,x){return Math.round(w-v.pixelFromPrice(x,I))}var i=t.panel,o=i.chart,s=t.stx,a=s.chart.highLowBars;t.showClass||(t.showClass="stx-show");for(var c=0;c<t.arr.length;++c){var l=t.arr[c],h=l.node,f=h.classList;if(i.hidden||!s.insideChart){f.remove(t.showClass);return}if(l.params.x<0||l.params.x>=o.dataSet.length){f.remove(t.showClass);return}if(s.currentVectorParameters.vectorType){f.remove(t.showClass);return}var u=o.dataSet[l.params.x],p=s.pixelFromTick(l.params.x);if(!u||p<o.left||p>o.right){f.remove(t.showClass);return}if(!u[s.chart.defaultPlotField]&&u[s.chart.defaultPlotField]!==0){f.remove(t.showClass);return}f.add(t.showClass);var d=r.elementDimensions(h);l.clientWidth||(l.clientWidth=d.width),l.clientHeight||(l.clientHeight=d.height),l.clientWidth>p?(f.remove("stx-left"),f.add("stx-right"),Object.assign(l.node.style,{left:p+"px",right:"auto"})):(f.add("stx-left"),f.remove("stx-right"),Object.assign(l.node.style,{right:s.chart.canvasWidth-p+"px",left:"auto"}));var g,y=l.params.chartContainer?s.chart.canvasHeight:i.bottom;a?g=e(s,i,y,s.getBarBounds(u)[i.yAxis.flipped?"low":"high"]):g=e(s,i,y,u[s.chart.defaultPlotField]);var C=y-g-l.clientHeight;C<0?(f.add("stx-below"),g=(a?e(s,i,y,s.getBarBounds(u).low):g)-l.clientHeight):f.remove("stx-below");var m=g+"px";l.node.style.bottom!=m&&(l.node.style.bottom=m)}}),this.context.stx.translateUI&&this.context.stx.translateUI(this.node);var n;this.params.followMouse?(this.node.style.top="auto",n={stx:this.context.stx,label:"headsup",xPositioner:"bar",chartContainer:!0,x:0,node:this.node},this.marker=new r.Marker.HeadsUp(n,this.params.showClass),this.addInjection("append","handleMouseOut",function(t){return function(){t.followMouse(-1)}}(this))):this.params.staticNode||(Object.assign(this.node.style,{top:"",left:""}),n={stx:this.context.stx,label:"headsup",xPositioner:"none",yPositioner:"none",chartContainer:!1,node:this.node},r.extend(n,this.params),this.marker=new r.Marker(n),this.marker.makeDraggable()),this.calculateMaxVolume(),this.addInjection("prepend","headsUpHR",function(t){return function(){t.position()}}(this)),this.addInjection("append","createXAxis",function(t){return function(){t.position()}}(this)),this.addInjection("append","createDataSet",function(t){return function(e,i,o){t.calculateMaxVolume(o.appending)}}(this))}};r.UI.HeadsUp.prototype.end=function(){this.marker&&this.marker.remove(),this.destroy(),this.marker=null};r.UI.HeadsUp.prototype.calculateMaxVolume=function(n){n||(this.maxVolume={lastCheckDate:null,value:0});var t=this.context.stx.chart.dataSet;if(!(!t||!t.length)){for(var e=t.length-1;e>=0;e--){var i=t[e];if(i.DT<this.maxVolume.lastCheckDate)break;i.Volume>this.maxVolume.value&&(this.maxVolume.value=i.Volume)}this.maxVolume.lastCheckDate=t[t.length-1].DT}};r.UI.HeadsUp.prototype.position=function(){var n=this.context.stx,t=n.barFromPixel(n.cx);this.tick=n.tickFromPixel(n.cx);var e=n.chart.xaxis[t],i=n.chart.defaultPlotField,o=n.chart.highLowBars;(!i||o)&&(i="Close");var s=this.node,a=this;function c(h){var f="",u=n.layout.chartScale,p=n.chart.panel,d=n.chart.yAxis;return d.originalPriceFormatter&&d.originalPriceFormatter.func?f=d.originalPriceFormatter.func(n,p,h):d.priceFormatter&&u!="percent"&&u!="relative"?f=d.priceFormatter(n,p,h):f=n.formatYAxisPrice(h,p),f.replace(/(\.[0-9]*[1-9])0+$|\.0*$/,"$1")}function l(){var h={};["price","open","close","high","low","date","volume"].forEach(function(m){h[m]=s.querySelector("cq-hu-"+m)||document.createElement("div"),h[m].innerText="N/A",h[m].setAttribute("no-translate","")}),h.rollup=s.querySelector("cq-volume-rollup"),h.rollup&&(h.rollup.innerText="",h.rollup.setAttribute("no-translate","")),a.timeout=null;function f(m){return r.isValidNumber(parseFloat(m))?m:"N/A"}if(e&&e.data){var u=r.clone(e.data);u.Open===void 0&&(u.Open=u.Close),u.High===void 0&&(u.High=Math.max(u.Open,u.Close)),u.Low===void 0&&(u.Low=Math.min(u.Open,u.Close)),h.open.innerText=c(f(u.Open)),h.price.innerText=c(f(u[i])),h.close.innerText=c(f(u.Close)),h.high.innerText=c(f(u.High)),h.low.innerText=c(f(u.Low));var p=r.condenseInt(u.Volume),d=p.charAt(p.length-1);d>"9"&&(p=p.substring(0,p.length-1),h.rollup&&(h.rollup.innerText=d.toUpperCase())),h.volume.innerText=p;var g=u.displayDate;g||(g=u.DT),n.internationalizer?r.ChartEngine.isDailyInterval(n.layout.interval)?h.date.innerText=n.internationalizer.yearMonthDay.format(g):h.date.innerText=n.internationalizer.yearMonthDay.format(g)+" "+n.internationalizer.hourMinute.format(g):r.ChartEngine.isDailyInterval(n.layout.interval)?h.date.innerText=r.mmddyyyy(r.yyyymmddhhmm
1(g)):h.date.innerText=r.mmddhhmm(r.yyyymmddhhmmssmmm(g));var y=s.querySelector("cq-volume-visual");if(y){var C=a.maxVolume.value?u.Volume/a.maxVolume.value:0;y.style.width=Math.round(C*100)+"%"}}}(this.tick!=this.prevTick||e&&+e.DT==+n.chart.endPoints.end)&&(this.timeout&&clearTimeout(this.timeout),this.timeout=setTimeout(l,0)),this.prevTick=this.tick,this.params.followMouse&&(n.openDialog&&(this.tick=-1),this.followMouse(this.tick))};r.UI.HeadsUp.prototype.followMouse=function(n){this.marker.params.x=n;var t=this;t.marker.render()};r.UI.DrawingEdit=E;function E(n,t){const{stx:e}=t;if(this.node=n||t.topNode,this.context=t,this.editing=null,Object.defineProperty(this,"drawingContext",{get(){return t.topNode.querySelector("cq-drawing-context")||this.node.ownerDocument.querySelector("cq-drawing-context")}}),this.toolbar=this.node.querySelector("cq-toolbar"),this.toolbar||(this.toolbar=this.node.querySelector("cq-drawing-settings")),!this.toolbar){const o=this.node.parentElement.closest("cq-context");o&&(this.toolbar=o.querySelector("cq-drawing-settings"))}if(this.toolbar){const o=j(e,this);this.toolbar.addEventListener("change",o),e.addEventListener("destroy",()=>{this.toolbar.removeEventListener("change",o)})}this.count=e.drawingObjects.length,t.advertiseAs(this,"DrawingEdit"),e.addEventListener("drawing",R(this)),e.addEventListener("drawingEdit",F(this));const i=(t.config.channels||{}).drawing||"channel.drawing";r.UI.BaseComponent.prototype.channelSubscribe(i,o=>{o||this.setDrawingEditMode()},e),[...this.node.querySelectorAll("cq-toolbar .ciq-drawing-edit-only")].forEach(o=>{o.querySelector(".ciq-btn")&&["mouseenter","mouseleave"].forEach(s=>{o.addEventListener(s,K(e,this))})})}r.inheritsFrom(E,r.UI.Helper);function j(n,t){return function(){if(n.activeDrawing&&n.editingAnnotation&&(n.activeDrawing.copyConfig(),n.activeDrawing.adjust(),n.draw()),!!t.editing){if(t.editing.name!==n.currentVectorParameters.vectorType){t.endEdit(null,"tool");return}t.editing.copyConfig(),t.editing.adjust(),n.draw(),n.changeOccurred("vector")}}}function R(n){return function(t){var e=t.drawings.length;n.count!==e&&(n.endEdit(null,"count"),n.count=e)}}function F(n){return function(t){t.forceEdit===!0?(n.endEdit(null,"edit"),n.showToolbar(t.drawing),n.beginEdit(t.drawing)):t.forceText===!0?n.text(t.drawing):n.showContext(t)}}function K(n,t){return function(e){var i=e.type==="mouseenter";t.editing&&t.editing.highlighted!==i&&(t.editing.highlighted=i,n.draw())}}E.prototype.showContext=function(n){n.context=this.context,n.x=r.ChartEngine.crosshairX,n.y=r.ChartEngine.crosshairY,this.count=this.context.stx.drawingObjects.length;const{context:t}=this;if(t.config){const{channelWrite:e}=r.UI.BaseComponent.prototype,i=(t.config.channels||{}).dialog||"channel.dialog";e(i,{type:"drawingContext",params:n},t.stx)}else this.drawingContext&&this.drawingContext.open&&this.drawingContext.open(n)};E.prototype.getToolActivator=function(n){return{node:this.toolbar.querySelector('cq-item[cq-tool="'+n+'"]')||this.toolbar.querySelector(`cq-item[stxtap="tool('`+n+`')"]`)}};E.prototype.showToolbar=function(n){var t=this,e=t.getToolActivator(n.name),i=this.toolbar,o=n.lineWidth,s=n.pattern,a=n.parameters&&n.parameters.fibs;a&&(o=n.parameters.fibs[0].parameters.lineWidth,s=n.parameters.fibs[0].parameters.pattern),i.tool(e,n.name),i.sync(Object.assign({},n,{lineWidth:o,pattern:s,annotation:{font:n.font?r.clone(n.font):{}},currentColor:n.color})),i.dirty(!1),a&&(i.context.stx.currentVectorParameters.fibonacci=r.clone(n.parameters)),new Set(["measurementline","trendline","arrowline"]).has(n.name)&&(i.context.stx.currentVectorParameters[n.name]=r.clone(n.parameters)),n.name==="volumeprofile"&&(i.context.stx.currentVectorParameters.volumeProfile.priceBuckets=n.priceBuckets)};E.prototype.setDrawingEditMode=function(n){const{context:t,context:{stx:e}}=this;e.chart.canvas&&e.chart.canvas.classList.toggle("cq-editing-drawing",!!n);const{multiChartContainer:i}=t.topNode;if(i&&!i.getCharts)return;(i?i.getCharts():[e]).forEach(a=>{a&&(a.editingDrawing=n)});const s=i||t.topNode;n?(this.clickListener=a=>{const c=a.target.closest("cq-drawing-settings")||a.target.closest("cq-drawing-palette")||a.target.closest("cq-dialog-overlay")||a.target.closest("cq-color-picker"),l=e.uiContext.isModal();!c&&!l&&this.endEdit({},"close")},setTimeout(()=>{s.addEventListener("click",this.clickListener)})):this.clickListener&&(s.removeEventListener("click",this.clickListener),this.clickListener=null)};E.prototype.beginEdit=function(n){this.editing=n,this.beforeEdit=n.serialize(),this.toolbar.setAttribute("cq-drawing-edit",n.name),this.setDrawingEditMode(n),this.context.stx.draw();var t=new CustomEvent("drawing-edit-begin",{bubbles:!0,cancelable:!0,detail:{drawing:n,tool:n.name}});this.node.dispatchEvent(t)};E.prototype.endEdit=function(n,t){const e=function(s,a){const c=this.context.stx;let l=null,h=null;
1if(this.editing){h=this.editing.name,l=new CustomEvent("drawing-edit-end",{bubbles:!0,cancelable:!0,detail:{action:a,drawing:this.editing,tool:h}});const f=c.drawingObjects.indexOf(this.editing),u=c.exportDrawings();f>-1&&this.beforeEdit&&(u[f]=this.beforeEdit,c.undoStamp(u,c.exportDrawings())),f===-1&&(a="close"),a==="close"&&this.editing.highlighted&&(this.editing.highlighted=!1,c.draw())}this.editing=null,this.setDrawingEditMode(),c.draw(),this.beforeEdit=null,this.toolbar.setAttribute("cq-drawing-edit","none"),a==="close"&&(this.toolbar.tool({},"notool"),c.changeVectorType("")),l&&this.node.dispatchEvent(l)},{multiChartContainer:i}=this.node;(i?i.getCharts().map(s=>s.uiContext.getAdvertised("DrawingEdit")):[this]).forEach(s=>{e.call(s,n,t)})};E.prototype.edit=function(){if(this.drawingContext){const n=this.drawingContext.drawing,t=this.context.topNode,e=(t.querySelector("cq-drawing-context")||t.ownerDocument.querySelector("cq-drawing-context")).parentNode;let i=t.querySelector("cq-drawing-settings")||t.ownerDocument.querySelector("cq-drawing-settings");!i&&t.multiChartContainer&&(i=t.multiChartContainer.querySelector("cq-drawing-settings"));const o={left:e.offsetLeft,top:e.offsetTop};if(this.drawingContext.close(),this.node&&this.node.multiChartContainer){const a=this.node.multiChartContainer.context.getAdvertised("DrawingEdit");this.endEdit(null,"edit"),a.showToolbar(n,o),this.beginEdit(n)}else this.endEdit(null,"edit"),this.showToolbar(n,o),this.beginEdit(n);const s=this.node.multiChartContainer||this.node;if(i&&!/break.*sm\b/.test(s.className)){i.docked==="true"&&(i.restoreDocked=!0);let{left:a,top:c}=o;(n.name==="annotation"||n.name==="callout")&&(c+=i.clientHeight/3),i.detach(a,c)}this.drawingContext.postProcess&&this.drawingContext.postProcess("editsettings")}};E.prototype.text=function(n){let t=this.drawingContext;if(t){t.close();let e=n instanceof r.Drawing?n:t.drawing;this.endEdit(null,"text"),e.edit&&e.edit(null,!0),t.postProcess&&t.postProcess("edittext")}};E.prototype.clone=function(){var n=this,t=this.context.stx;if(this.endEdit(null,"clone"),this.drawingContext){this.drawingContext.close();var e=this.drawingContext.drawing,i=new r.Drawing[e.name],o=e.serialize();i.reconstruct(t,o),e.name=="measurementline"&&(e.repositioner={action:"move",p0:i.p0,p1:i.p1,tick:i.p1[0],value:i.p1[1]}),i.repositioner=e.repositioner,i.highlighted=!0,e.highlighted=!1,n.count+=1,t.addDrawing(i),t.activateRepositioning(i),this.drawingContext.postProcess&&this.drawingContext.postProcess("clone")}};E.prototype.reorderLayer=function(n,t){var e=this.context.stx;if(this.endEdit(null,"reorderLayer"),this.drawingContext){this.drawingContext.close();var i=e.drawingObjects.length-1,o=e.drawingObjects.indexOf(this.drawingContext.drawing),s=NaN;if(o===-1)return;switch(t){case"up":o<i&&(s=o+1);break;case"down":o>0&&(s=o-1);break;case"top":o<i&&(s=i);break;case"bottom":o>0&&(s=0);break}if(s!==s)return;var a=e.exportDrawings();e.drawingObjects.splice(o,1),e.drawingObjects.splice(s,0,this.drawingContext.drawing),e.undoStamp(a,e.exportDrawings()),e.draw(),e.changeOccurred("vector"),this.drawingContext.postProcess&&this.drawingContext.postProcess("layer"+t)}};E.prototype.remove=function(){var n=this,t=this.context.stx;if(this.endEdit(null,"remove"),this.drawingContext){if(this.drawingContext.drawing.permanent)return;var e=t.exportDrawings();n.count-=1,t.removeDrawing(this.drawingContext.drawing),t.undoStamp(e,t.exportDrawings()),this.drawingContext.close(),this.drawingContext.postProcess&&this.drawingContext.postProcess("remove")}};r.UI.StudyEdit=function(n,t){const e=this instanceof r.UI.StudyEdit?this:Object.create(r.UI.StudyEdit.prototype);return e.context=t,e.node=n||t.topNode,t.advertiseAs(e,"StudyEdit"),Object.defineProperty(e,"contextDialog",{get(){return this.node.ownerDocument.querySelectorAll("cq-study-context")}}),e.initialize(),e};r.inheritsFrom(r.UI.StudyEdit,r.UI.Helper);r.UI.StudyEdit.prototype.remove=function({params:n}){const{sd:t}=this.params;r.Studies.removeStudy(this.params.stx,this.params.sd),this.contextDialog.forEach(e=>{e.close&&e.close()}),n.parent.postProcess&&n.parent.postProcess("remove",t)};r.UI.StudyEdit.prototype.edit=function({params:n}){this.contextDialog.forEach(t=>{t.close&&t.close()}),this.editPanel(this.params),n.parent.postProcess&&n.parent.postProcess("edit",this.params.sd)};r.UI.StudyEdit.prototype.editPanel=function(n){const{stx:t,config:e}=this.context;n.context=this.context,n.x=null,n.y=null;const{channelWrite:i}=r.UI.BaseComponent.prototype;if(e){const o=(e.channels||{}).dialog||"channel.dialog";i(o,{type:"study",params:n},t)}else n.context.topNode.ownerDocument.querySelector("cq-study-dialog").open(n)};r.UI.StudyEdit.prototype.editOverlay=function(n){if(this.params=n,n.context=this.context,n.forceEdit){this.editPanel(n);return}const{context:t}=this;if(n.x=r.ChartEngine.crosshairX,n.y=r.ChartEngine.crosshairY,t.config){const{channelWrite:e}=r.UI.BaseComponent.prototype,i=(t.config.channels||{}).dialog||"channel.dialog";e(i,{type:"studyContext",params:n},t.stx)}
1else this.contextDialog.forEach(e=>{e.open&&e.open(n)})};r.UI.StudyEdit.prototype.initialize=function(){var n=this.context.stx,t=this;function e(i){return function(){i.apply(t,arguments)}}n.addEventListener("studyOverlayEdit",e(t.editOverlay)),n.addEventListener("studyPanelEdit",e(t.editPanel))};r.UI.Layout=function(n,t){const e=this instanceof r.UI.Layout?this:Object.create(r.UI.Layout.prototype);return e.params=t||{},e.params.activeClassName||(e.params.activeClassName="ciq-active"),e.context=n,n.advertiseAs(e,"Layout"),e};r.inheritsFrom(r.UI.Layout,r.UI.Helper);r.UI.Layout.prototype.getChartType=function(n,t){const{stx:e}=this.context;typeof t!="string"&&(t=n.dataset.value||"");const i=o=>{const s=o.obj;s.aggregationType&&s.aggregationType!="ohlc"?this.setCheckedState(n,t===s.aggregationType):this.setCheckedState(n,t===s.chartType)};this.addObserver({node:n,base:e,path:"layout.chartType",listener:i}),this.addObserver({node:n,base:e,path:"layout.aggregationType",listener:i})};r.UI.Layout.prototype.setChartType=function(n,t){var e={heikinashi:!0,kagi:!0,linebreak:!0,pandf:!0,rangebars:!0,renko:!0};typeof t!="string"&&(t=n.node.dataset.value||""),e[t]?this.context.stx.setAggregationType(t):this.context.stx.setChartType(t)};r.UI.Layout.prototype.getChartScale=function(n,t){const e=i=>{this.setCheckedState(n,i.value==t)};this.addObserver({node:n,base:this.context.stx,path:"layout.chartScale",listener:e})};r.UI.Layout.prototype.setChartScale=function(n,t){var e=this.context.stx,i=e.layout.chartScale;i==t?e.setChartScale(null):(!i||i=="linear")&&e.setChartScale(t)};r.UI.Layout.prototype.getFlippedChart=function(n){const t=e=>{this.setCheckedState(n,e.value)};this.addObserver({node:n,base:this.context.stx,path:"layout.flipped",listener:t})};r.UI.Layout.prototype.setFlippedChart=function(n){var t=this.context.stx;t.flipChart(!t.layout.flipped)};r.UI.Layout.prototype.getExtendedHours=function(n){const t=e=>{this.setCheckedState(n,e.value)};this.addObserver({node:n,base:this.context.stx,path:"layout.extended",listener:t})};r.UI.Layout.prototype.setExtendedHours=function(n){const{stx:t,loader:e,config:{addOns:i},stx:{extendedHours:o,chart:{market:{market_def:s,sessions:a}}}}=this.context;if(t.layout.extended=!t.layout.extended,t.changeOccurred("layout"),t.layout.extended&&!(s&&a.length)&&r.alert("There are no Extended Hours for this instrument."),o){const c=t.drawingObjects.map(l=>l.serialize());e&&e.show(!0),o.set(t.layout.extended,i.extendedHours.sessions,()=>{o.filter||(t.importDrawings(c),t.draw()),e&&e.hide()})}};r.UI.Layout.prototype.getAnimation=function(n){const t=e=>{this.setCheckedState(n,e.value)};this.addObserver({node:n,base:this.context.stx,path:"layout.animation",listener:t})};r.UI.Layout.prototype.setAnimation=function(n){const{stx:t}=this.context;t.layout.animation=!t.layout.animation,t.changeOccurred("layout")};r.UI.Layout.prototype.getRangeSlider=function(n){const t=e=>{this.setCheckedState(n,e.value)};this.addObserver({node:n,base:this.context.stx,path:"layout.rangeSlider",listener:t})};r.UI.Layout.prototype.setRangeSlider=function(n){var t=this.context.stx;t.layout.rangeSlider=!t.layout.rangeSlider,t.slider&&t.slider.display(t.layout.rangeSlider),t.changeOccurred("layout")};r.UI.Layout.prototype.getZoomControls=function(n){const t=e=>{this.setCheckedState(n,e.value)};this.addObserver({node:n,base:this.context.stx,path:"preferences.zoomControlsOn",listener:t})};r.UI.Layout.prototype.setZoomControls=function(n){const{stx:t}=this.context,{preferences:e,controls:i,chart:o,layout:s,continuousZoom:a}=t;e.zoomControlsOn=!e.zoomControlsOn,i&&i.chartControls&&(i.chartControls.style.display=t.manageTouchAndMouse&&e.zoomControlsOn&&i.chartControls.style.visibility!=="hidden"?"block":"none",e.zoomControlsOn&&r.efficie
1ntDOMUpdate(i.chartControls.style,"left",`${o.left+o.width/2}px`)),!e.zoomControlsOn&&s.smartzoom&&a&&t.dispatch("notification","smartZoomHiddenControls"),t.changeOccurred("preferences")};r.UI.Layout.prototype.getOutliers=function(n){const t=e=>{this.setCheckedState(n,e.value)};this.addObserver({node:n,base:this.context.stx,path:"layout.outliers",listener:t})};r.UI.Layout.prototype.setOutliers=function(n){var t=this.context.stx;t.layout.outliers=!t.layout.outliers,t.draw(),t.changeOccurred("layout")};r.UI.Layout.prototype.getHideGaps=function(n){const t=i=>{this.setCheckedState(n,i.value)};this.addObserver({node:n,base:this.context.stx,path:"layout.hideGaps",listener:t});const e=i=>{n.style.display=i.value?"":"none"};this.addObserver({node:n,base:this.context.stx,path:"cleanupGaps",listener:e})};r.UI.Layout.prototype.setHideGaps=function(n){var t=this.context.stx;t.layout.hideGaps=!t.layout.hideGaps,t.createDataSet(),t.draw(),t.changeOccurred("layout")};r.UI.Layout.prototype.getHeadsUp=function(n,t){const{multiChartContainer:e}=this.context.topNode,{stx:i}=e?e.CIQ.UI.context:this.context,o=s=>{s.value||(s.value={}),typeof s.value=="string"&&(s.value={[s.value]:!0});const a=t==="crosshair"?!s.value.static&&!s.value.crosssection&&s.obj.crosshair:s.value[t];this.setCheckedState(n,a),["static","dynamic"].includes(t)&&(this[t]||(this[t]=!0,i.uiContext.topNode.querySelectorAll(".ciq-chart-area").forEach(c=>{c.querySelector("cq-hu-"+t)||c.append(document.createElement("cq-hu-"+t))})))};this.addObserver({node:n,base:i,path:"layout.headsUp",listener:o})};r.UI.Layout.prototype.setHeadsUp=function({node:n},t){const{multiChartContainer:e}=this.context.topNode;(e?e.getCharts():[this.context.stx]).forEach((o,s)=>{const{layout:a}=o;let{headsUp:c}=a;switch(!c||typeof c!="object"?c={}:c=Object.assign({},c),t){case"crosshair":c.static=!1,a.crosshair=!0,c.crosssection=!1;break;case"dynamic":c.dynamic=!0,c.floating=!1;break;case"floating":c.dynamic=!1,c.floating=!0;break;case"static":c.static=!0,a.crosshair=!0;break;case"crosssection":c.crosssection=!0,a.crosshair=!0;break}a.headsUp=c,o.draw(),o.changeOccurred("layout"),s===0&&a.crosshair&&(o.centerCrosshairs(),o.doDisplayCrosshairs())})};r.UI.Layout.prototype.getAggregationType=function(n,t){const e=i=>{this.setCheckedState(n,i.value==t)};this.addObserver({node:n,base:this.context.stx,path:"layout.aggregationType",listener:e})};r.UI.Layout.prototype.setAggregationType=function(n,t){this.context.stx.layout.aggregationType==t?this.context.stx.setAggregationType(null):this.context.stx.setAggregationType(t)};r.UI.Layout.prototype.getAggregationEdit=function(n,t){const{stx:e}=this.context,i=o=>{n.value=e.chart.defaultChartStyleConfig[n.name]||o.value};this.addObserver({node:n,base:e,path:"layout."+r.deriveFromObjectChain(e.layout,t).member,listener:i})};r.UI.Layout.prototype.setAggregationEdit=function(n,t){const{stx:e}=this.context,{layout:i}=e;function o(s,a){e.changeOccurred("layout"),n.params.parent.postProcess&&n.params.parent.postProcess({aggregationType:i.aggregationType,box:s||null,reversal:a||null}),e.createDataSet(),e.draw()}if(t==="auto"){i.aggregationType==="kagi"?i.kagi=null:i.aggregationType==="renko"?i.renko=null:i.aggregationType==="linebreak"?i.priceLines=null:i.aggregationType==="rangebars"?i.rangebars=null:i.aggregationType==="pandf"&&(i.pandf||(i.pandf={box:null,reversal:null}),i.pandf.box=null,i.pandf.reversal=null),o("auto","auto");const{parent:s}=n.params;if(!s)return;Array.from(s.querySelectorAll(".ciq"+i.aggregationType+" input")).forEach(function(a){const{name:c}=a,l=c=="box"||c=="reversal"?"pandf."+c:c,h=r.deriveFromObjectChain(i,l);h&&!h.obj[h.member]&&e.chart.defaultChartStyleConfig[c]&&(a.value=e.chart.defaultChartStyleConfig[c])})}else{const s=r.deriveFromObjectChain(i,t),{name:a,value:c}=n.node;s.obj[s.member]=c,o(a==="box"?c:null,a==="reversal"?c:null)}};r.UI.Layout.prototype.showAggregationEdit=function(n,t){const{context:e}=this;if(e.config){const{channelWrite:i}=r.UI.BaseComponent.prototype,o=(e.config.channels||{}).dialog||"channel.dialog";i(o,{type:"aggregation",params:{context:e,aggregationType:t}},e.stx)}else n.ownerDocument.querySelector("cq-aggregation-dialog").open({context:this.context,aggregationType:t})};r.UI.Layout.prototype.clearStudies=function(n){if(r.Studies){var t=this.context.stx;for(var e in t.layout.studies){var i=t.layout.studies[e];!i.customLegend&&!i.permanent&&!i.signalData&&r.Studies.removeStudy(t,i)}t.draw()}};r.UI.Layout.prototype.setPeriodicity=function(n,t,e,i){var o=this;o.context.loader&&o.context.loader.show(!0),o.context.stx.setPeriodicity({period:t,interval:e,timeUnit:i},function(){o.context.loader&&o.context.loader.hide()})};r.UI.Layout.prototype.showPeriodicity=function(n,t){var e="",{period:i,interval:o,timeUnit:s}=n.getPeriodicity();i*=o,e=i,s=="day"?e+="D":s=="week"?e+="W":s=="month"?e+="M":s=="second"?e+="s":s=="millisecond"?e+="ms":i>=60&&i%15===0?e=i/60+"H":s=="tick"?e=(i>1?i:"")+"T":e+="m",r.makeTranslatableElement(t.selector,n,e)};r.UI.Layout.prototype.periodicity=function(n){const{stx:t}=this.context,e=n.label||n,i=()=>{this.showPeriodicity(this.context.stx,{selector:e})};this.addObserver({node:n,base:t,path:"layout.interval",listener:i}),this.addObserver({node:n,base:t,path:"layout.periodicity",listener:i}),this.addObserver({node:n,base:t,path:"layout.timeUnit",listener:i})};r.UI.Layout.prototype.chartType=function(n){const{stx:t,stx:e}
1=this.context,i=n.closest("cq-menu")||n.getRootNode(),{qsa:o}=r.UI.BaseComponent.prototype,s=o(".icon",i,!0)[0],a=o("[label]",i,!0)[0],c=o("[cq-tooltip]",i,!0)[0],l=({obj:{chartType:h,aggregationType:f}})=>{const u=f==="ohlc"?h:f;let p=u;if(s&&(s.className=`icon generic ${s.classList.contains("hidden")?"hidden ":""}${u.replace(/_| /g,"-")} ciq-icon-${u.replace(/_| /g,"-")}`.trim()),a){const g=r.climbUpDomTree(n,"cq-menu",!0)[0],y=g?g.qsa("cq-dropdown",g,!0)[0]:null,C=y?y.qsa(`*[data-value="${u}"] [label]`,y,!0)[0]:null;p=C?C.getAttribute("cq-translate-original")||C.innerText:u}const d=p.split(" ").map(g=>r.capitalize(g.replace(/-|_/," "))).join(" ");if(a&&r.makeTranslatableElement(a,t,d),c&&r.makeTranslatableElement(c,t,d),!a&&!s){const g=r.climbUpDomTree(n,"cq-menu",!0)[0].querySelector(`*[data-value='${u}'] *[ciq-label]`),y=n.querySelector("*[ciq-menu-icon]"),C=n.querySelector("cq-tooltip"),m=r.getFromNS(this,"context.config.displayStyleIcons"),v=g?(g.closest("cq-item").querySelector("[ciq-menu-icon]")||{}).className:`ciq-icon-${u.replace(/_/,"-")}`;C&&(C.innerText=g?g.innerText:r.capitalize(u.replace(/-|_/," "))),m&&y&&(n.classList.add("ciq-menu-icon"),y.className=v)}};this.addObserver({node:n,base:e,path:"layout.chartType",listener:l}),this.addObserver({node:n,base:e,path:"layout.aggregationType",listener:l})};r.UI.Layout.prototype.setLanguage=function(n){const{config:t,stx:e}=this.context;if(t){const{channelWrite:i}=r.UI.BaseComponent.prototype,o=(t.channels||{}).dialog||"channel.dialog",s={context:e.uiContext};i(o,{type:"language",params:s},e)}else n.node.ownerDocument.querySelector("cq-language-dialog").open()};r.UI.Layout.prototype.getLanguage=function(n){const{stx:t}=this.context,e=i=>{if(!r.I18N)return;r.I18N.languages||(r.I18N.languages={en:"English"});const o=n.querySelector("cq-language-name, [label]");if(o){const s=t.preferences.language||r.I18N.language;r.makeTranslatableElement(o,t,r.I18N.languages[s],s);const a=n.querySelector(".flag, cq-flag");a&&a.setAttribute("cq-lang",s)}};this.addObserver({node:n,base:t,path:"preferences.language",listener:e})};r.UI.Layout.prototype.addChart=function(n,t){const e=this.context.topNode;(r.UI.closestContextContainer(e.parentNode)||e).addChart(null,t)};r.UI.Layout.prototype.removeChart=function(n){const t=this.context.topNode;(r.UI.closestContextContainer(t.parentNode)||t).removeChart()};class W extends r.UI.Helper{constructor(t){super(),this.context=t,t.advertiseAs(this,"Channel")}write(t,e,i){b.prototype.channelWrite(`channel.${e}`,i,this.context.stx)}}r.UI.Channel=function(...n){return new W(...n)};r.UI.Layout.prototype.toggleHelp=function({node:n}){let{topNode:t,stx:e}=this.context;const i="ciq-show-help";if(t.classList.contains(i)){t.classList.remove(i),n.classList.remove(i),r.UI.shadowComponents.forEach((o,s)=>{o===t&&s.classList.remove(i)});return}
1r.UI.BaseComponent.prototype.qsa("cq-help",t,!0).forEach(o=>o.verifyHelpContent()),t.classList.add(i),n.classList.add(i),r.UI.shadowComponents.forEach((o,s)=>{o===t&&s.classList.add(i)}),r.Help.MessageShown||(e.dispatch("notification",{message:r.Help.Message,displayTime:10,position:"bottom"}),r.Help.MessageShown=!0)};r.UI.Markers=function(n,t){const e=this instanceof r.UI.Markers?this:Object.create(r.UI.Markers.prototype);return e.context=n,t||(t={}),e.menuItemSelector=t.menuItemSelector,e.activeClassName=t.activeClassName||"ciq-active",e.implementation=t.implementation,n.advertiseAs(e,"Markers"),e};r.inheritsFrom(r.UI.Markers,r.UI.Helper);r.UI.Markers.prototype.showMarkers=function(n,t,e){const{activeClassName:i,context:o,implementation:s}=this;let{topNode:a}=o;!s||!a.parentElement||n.node===null||(a=a.multiChartContainer||a,t&&(s.activeLabels.includes(t)?(s.hideMarkers(t),n.node.classList.remove(i)):(s.showMarkers(t,e),n.node.classList.add(i))))};r.UI.Markers.prototype.removeMarkers=function(n,t){const{stx:e}=this.context,i=e.getMarkerArray("label",t);i.length&&(i[0].constructor.removeByLabel?i[0].constructor.removeByLabel(e,t):r.Marker.removeByLabel(e,t),e.draw())};r.UI.Markers.prototype.getMarkerSwitch=function(n,t){const e=i=>{this.setCheckedState(n,i.value)};this.addObserver({node:n,base:this.context.stx,path:`uiState.eventSwitches.${t}`,listener:e})};r.UI.Markers.prototype.setMarkerSwitch=function(n,t){const{context:e}=this,{stx:i}=e,o=t;this.showMarkers(n,o),i.uiState.eventSwitches[o]=!i.uiState.eventSwitches[o]};r.UI.Keystroke=function(n,{keysToRepeat:t=[],node:e={}}={}){this.cb=n,this.shift=!1,this.ctrl=!1,this.cmd=!1,this.alt=!1,this.capsLock=!1,this.downValue="",this.keysToRepeat=t,this.recentKeys={},this.commandKeys={},this.initialize(e)};r.UI.Keystroke.noKeyCapture=!1;r.UI.Keystroke.prototype.androidWorkaroundKeyup=function(n){var t=n.target.value,e;t.length>this.downValue.length?e=t.charAt(t.length-1):e="Delete",this.key=e,this.cb({key:e,e:n,keystroke:this})};r.UI.Keystroke.prototype.mapKey=function(n){return{Shift:"shift",Control:"ctrl",Alt:"alt",Meta:"cmd",Win:"cmd"}[n]||n};r.UI.Keystroke.prototype.keyup=function(n){if(this.implementAndroidWorkaround){this.androidWorkaroundKeyup(n),this.implementAndroidWorkaround=!1;return}const{recentKeys:t}=this,{key:e,code:i}=n,o=this.mapKey(e),s=e!==o,a=new Date().getTime();if(t[i]||(t[i]={}),t[i].keyup=a,s)return this.commandKeys[i]?(this.commandKeys[i].pressed=!1,Object.values(this.commandKeys).some(({command:l,pressed:h})=>h&&l===o)||(this[o]=!1),this.cb({key:e,e:n,keystroke:this})):void 0;let c=[];Object.entries(this.commandKeys).forEach(([l,{command:h}])=>{let f=t[l]||{},u=t[i]||{};f.keydown<u.keydown&&u.keydown<f.keyup&&f.keyup+500>a&&(c.push(l),this[h]=!0)}),c.length&&setTimeout(()=>{c.forEach(l=>{t[l].keydown<a&&(this[this.commandKeys[l].command]=!1)})}),this.keysToRepeat.includes(e)?this.key=null:(this.key=e,this.cb({key:e,e:n,keystroke:this}))};r.UI.Keystroke.prototype.keydown=function(n){if(this.noKeyCapture)return;if(n.which==229&&r.isAndroid){this.implementAndroidWorkaround=!0;return}const{key:t,code:e}=n,i=this.mapKey(t),o=t!==i;if(this.recentKeys[e]||(this.recentKeys[e]={}),this.recentKeys[e].keydown=new Date().getTime(),o&&(this.commandKeys[e]={command:i,pressed:!0}),t=="Tab"){const s=document.querySelector("[cq-keyboardnavigation-active]");if(s){const{uiManager:a}=r.UI.getMyContext(s);if(a){const c=a.topMenu();(!c||!c.hasAttribute("native-tabbing"))&&n.preventDefault()}}else if(n.target.hasAttribute("cq-exit")){let a=n.target.getAttribute("cq-exit");(a=="head"&&!n.shiftKey||a=="foot"&&n.shiftKey)&&(n.target.setAttribute("cq-keyboardnavigation-active",""),n.preventDefault()),n.target.removeAttribute("cq-exit")}}this.key=t,o?this[i]=!0:t==="CapsLock"?this.capsLock=!this.capsLock:this.keysToRepeat.includes(t)&&(this.key=null,this.cb({key:t,e:n,keystroke:this}))};r.UI.Keystroke.prototype.keypress=function(n){if(!this.noKeyCapture){var t=n.which;t<32||t>222||(this.key=n.key)}};r.UI.Keystroke.prototype.initialize=function(n){var t=this;this.doc=(n||{}).ownerDocument||document,this.registeredEvents={},["keyup","keydown","keypress"].forEach(function(e){t.registeredEvents[e]=function(i){e==="keydown"&&(t.downValue=i.target.value),t[e](i)},t.doc.addEventListener(e,t.registeredEvents[e])}),this.blurEvent=function(e){t.ctrl=!1,t.cb({key:"Control",e,keystroke:t})},this.doc.defaultView.addEventListener("blur",this.blurEvent)};r.UI.Keystroke.prototype.destroy=function(){Object.entries(this.registeredEvents).forEac
1h(([n,t])=>{this.doc.removeEventListener(n,t)}),this.doc.defaultView.removeEventListener("blur",this.blurEvent)};r.UI.KeystrokeHub=function(n,t,e){n||(n=t.topNode.ownerDocument),this.infocus=!1;var i=this;[void 0,"#document","BODY"].indexOf(n.nodeName)>-1?this.infocus=!0:(n.addEventListener("mouseout",function(){i.infocus=!1}),n.addEventListener("mouseover",function(){i.infocus=!0})),this.context=t,this.params=e||{},{hotkeyConfig:this.hotkeyConfig}=t.config||{},this.uiManager=r.UI.getUIManager(t.topNode),this.uiManager.keystrokeHub=this;function o(){return function(){i.handler.apply(i,arguments)}}this.keystroke=new r.UI.Keystroke(o(),{keysToRepeat:this.hotkeyConfig.keysToRepeat,node:n}),this.tabOrder=[null],this.tabIndex=0,this.yNormalizationThreshold=this.context.topNode.getBoundingClientRect().height/25,this.tabElementSelectors=["cq-clickable.symbol-search","cq-lookup","cq-comparison[cq-marker]","cq-study-legend[chart-legend]","cq-menu.ciq-menu","cq-menu.nav-dropdown",".ciq-nav cq-toggle",".chart-control-group cq-toggle",".chartControls .chartSize span",".home",".ciq-footer cq-toggle","cq-show-range > div","cq-show-range .item-item","cq-share-button","ciq-data-table-container button",".stx-yaxis-menu","canvas[role=img]","[keyboard-navigation='true']"],this.tabActiveElement=null,this.tabActiveModals=[],this.keyControlElement=null,this.highlightElement=null;const{channelSubscribe:s}=r.UI.BaseComponent.prototype,a=(this.context.config.channels||{}).keyboardNavigation||"channel.keyboardNavigation";s(a,c=>{c&&c.action==="registerElements"&&this.setTabOrderElements()},this.context.stx)};r.inheritsFrom(r.UI.KeystrokeHub,r.UI.Helper);r.UI.KeystrokeHub.defaultHotKeys=function(n,t,e={}){const{hotkeyConfig:i={},keystroke:o,context:s}=t,{hotkeys:a=[]}=i,{stx:c}=s,{code:l,keyCode:h,shiftKey:f}=e||{},u=l&&l.includes("Numpad");return n=="Unidentified"&&(n=String.fromCharCode(h)),o.shift=f,a.slice().reverse().reduce(function(d,{action:g,commands:y,options:C}){return d.concat(y.map(m=>({action:g,command:m,options:C})))},[]).map(function({action:d,command:g,options:y}){return g==="+"?g=["+"]:g.slice(-2)==="++"?g=g.slice(0,-2).split("+").concat("+"):g=g.split("+"),{action:d,options:y,modifiers:g.slice(0,-1),commandKey:g.slice(-1)[0],specificity:g.length}}).filter(function({modifiers:d,commandKey:g}){let y=(u?[l]:[l,n]).includes(g),C=!d.length||d.every(m=>o[o.mapKey(m)]);return y&&C}).sort(function(d,g){return g.specificity-d.specificity}).some(function({action:d,options:g}){if(typeof d=="string")return r.UI.KeystrokeHub.executeHotkeyCommand({stx:c,action:d,options:g});if(typeof d=="function")return d({stx:c,options:g})!==!1})};r.UI.KeystrokeHub.addHotKeyHandler=function(n,t,e){const i=({value:o})=>{o&&setTimeout(()=>{const s=r.getFromNS(o.config,"hotkeyConfig.hotkeys",[]).find(({action:a})=>a===n);s&&(s.action=t)})};e.addEventListener("destroy",r.UI.observeProperty("uiContext",e,i))};r.UI.KeystrokeHub.executeHotkeyCommand=function({stx:n,action:t,options:e={}}){const{crosshair:i,candleWidth:o}=n.layout,{left:s,right:a,panel:c}=n.chart,l=n.height-n.xaxisHeight,{percent:h=0,bars:f=0}=e,{topNode:u}=n.uiContext,p=u.ownerDocument.body.keystrokeHub;if(p.disableHotKeys===!0&&e.alwaysEnabled!==!0)return!1;const d=({axis:m,direction:v=1}={})=>{const{cx:I,cy:w}=n;let x=0;if(m==="x"&&(x=o*f),m==="y"&&(x=l*h),n.crossSection&&n.crossSection.crosshairBreakDistance&&(x=n.crossSection.crosshairBreakDistance),I||I===0||(n.cx=Math.round(n.width/2)),w||w===0||(n.cy=Math.round(l/2)),x){let k=n["c"+m]+x*v;k=Math.max(k,m==="x"?s+1:0),k=Math.min(k,m==="x"?a-1:l),n["c"+m]=Math.round(k)}n.mousemoveinner(n.resolveX(n.cx),n.resolveY(n.cy)),n.draw()},g=({direction:m=1,page:v}={})=>{const{dataSet:I,scroll:w,maxTicks:x}=n.chart;let k=v?x:f;k*=m,w+k>=I.length?n.chart.scroll=I.length:n.chart.scroll+=k,n.draw(),n.headsUpHR()},y=(m=1)=>{let v=l*h*m;n.chart.yAxis.scroll+=v,n.draw()},C=(m=1)=>{[...c.yaxisLHS,...c.yaxisRHS].forEach(I=>{let w=I.zoom+25*m;w<I.height&&(I.zoom=w)}),n.draw()};switch(t){case"up":i?d({axis:"y",direction:-1}):y();break;case"down":i?d({axis:"y"}):y(-1);break;case"right":i?d({axis:"x"}):g({direction:-1});break;case"left":i?d({axis:"x",direction:-1}):g();break;case"pageRight":g({direction:-1,page:!0});break;case"pageLeft":g({page:!0});break;case"zoomInXAxis":if(!n.allowZoom||n.activeDrawing&&!n.allowDrawingZoom)return;n.zoomIn();break;case"zoomOutXAxis":if(!n.allowZoom||n.activeDrawing&&!n.allowDrawingZoom)return;n.zoomOut();break;case"zoomInYAxis":C(-1);break;case"zoomOutYAxis":C();break;case"toggleCrosshairs":const m=u.querySelector('cq-toggle[member="crosshair"], cq-toggle[cq-member="crosshair"]');m?m.dispatchEvent(new Event("stxtap")):n.layout.crosshair=!n.layout.crosshair,d();break;case"toggleContinuousZoom":n.continuousZoom&&n.continuousZoom.smartZoomToggle();break;case"symbolLookup":const{multiChartContainer:v}=u;let I=(v||u).querySelector(".ciq-search cq-lookup cq-lookup-input input");if(I)I.focus();else{const x=r.UI.getMyContext(u);r.UI.BaseComponent.prototype.channelWrite("channel.dialog",{type:"lookup",params:{context:x}},n)}break;case"home":n.home(),n.headsUpHR();break;case"end":n.chart.scroll=n.chart.dataSet.length,n.draw(),n.headsUpHR();break;case"delete":if(r.ChartEngine.drawingLine)n.undo();else if(n.anyHighlighted)n.deleteHighlighted();else return!1;break;case"escape":if(r.ChartEngine.drawingLine)n.currentVectorParameters.vectorType=="continuous"&&r.ChartEngine.completeDrawing(n),n.undo();else if(n.repositioningAnchorSelector)r.Studies.cancelRepositionAnchor(n);else{const x=r.UI.getUIManager(u);
1if(p.tabActiveModals.length){if(p.tabActiveModals[0].processEsc&&p.tabActiveModals[0].processEsc(p))break;x&&x.closeMenu(p.tabActiveModals[0]),p.tabActiveModals[0]&&p.setKeyControlElement(p.tabActiveModals[0])}else x&&x.closeMenu()}break;case"keyboardNavigateDeselect":p.tabOrderDeselect();break;case"keyboardNavigateNext":if(p.tabActiveModals.length)return!1;p.tabIndexNext();break;case"keyboardNavigatePrevious":if(p.tabActiveModals.length)return!1;p.tabIndexNext(!0);break;case"keyboardNavigateClick":if(p.tabActiveModals.length)return!1;p.tabOrderClickSelected();break;case"toggleDrawings":const w=n.uiContext.topNode.querySelector('cq-toggle[member="chart.hideDrawings"]');w?w.dispatchEvent(new Event("stxtap")):n.chart.hideDrawings=!n.chart.hideDrawings;break;default:return!1}return!0};r.UI.KeystrokeHub.prototype.resetTabNavigation=function(){const{topNode:n}=this.context;this.tabOrder=[null],this.tabIndex=0,this.yNormalizationThreshold=n.getBoundingClientRect().height/25,this.tabActiveElement=null,this.tabActiveModals=[],this.keyControlElement=null,this.highlightElement&&this.highlightElement.parentElement!==n?(this.highlightElement.remove(),n.append(this.highlightElement)):this.highlightHide();const t={pointerdown:()=>this.tabOrderDeselect(),pointermove:()=>n.classList.remove("disable-mouse-pointer")};for(const e in t)n.pointerHandlers&&n.removeEventListener(e,n.pointerHandlers[e]),n.addEventListener(e,t[e]);n.pointerHandlers=t,this.context.stx.append("resizeChart",()=>{this.setTabOrderElements(),this.highlightAlign()}),this.setTabOrderElements()};r.UI.KeystrokeHub.prototype.setTabOrderElements=function(){let n=null;if(this.tabIndex!==0){let e=this.tabOrder[Math.abs(this.tabIndex)];e?n=e.element:this.tabIndex=0}this.tabOrder=[null];const t=r.UI.BaseComponent.prototype.qsa(this.tabElementSelectors.join(","),this.context.topNode,!0);for(let e=0;e<t.length;e++){const i=t[e];i.getAttribute("keyboard-navigation")!=="false"&&(i.tabListenerAdded||(i.addEventListener("stxtap",(function(o){let s=this.tabOrder.findIndex(a=>a&&a.element===o);return s!=this.tabIndex&&(this.tabOrderDeselect(),this.tabIndex=-s),!0}).bind(this,i)),i.addEventListener("blur",this.highlightHide.bind(this)),i.addEventListener("focus",this.highlightAlign.bind(this)),i.tabListenerAdded=!0),this.tabOrder.push({element:i}))}this.sortTabOrderElements(n)};r.UI.KeystrokeHub.prototype.sortTabOrderElements=function(n){const t=this.tabIndex<0;!n&&this.tabIndex!==0&&this.tabOrder[Math.abs(this.tabIndex)]&&(n=this.tabOrder[Math.abs(this.tabIndex)].element),this.tabOrder.forEach(e=>{if(!e)return;const{x:i,y:o,width:s,height:a}=e.element.getBoundingClientRect();e.position={x:i,y:o,width:s,height:a}}),this.tabOrder.sort((e,i)=>{if(!(e===null||i===null))return Math.floor(e.position.y/this.yNormalizationThreshold)-Math.floor(i.position.y/this.yNormalizationThreshold)||e.position.x-i.position.x}),n&&this.tabOrder.forEach((e,i)=>{e&&e.element==n&&(this.tabIndex=t?-i:i)})};r.UI.KeystrokeHub.prototype.setKeyControlElement=function(n,t){!this.keyControlElement&&!n||(this.disableKeyControlElement(this.keyControlElement,t),n&&(this.keyControlElement=n,this.keyControlElement.keyboardNavigation=this,typeof this.keyControlElement.onKeyboardSelection=="function"&&this.keyControlElement.onKeyboardSelection()))};r.UI.KeystrokeHub.prototype.disableKeyControlElement=function(n,t){n&&(!t&&typeof n.onKeyboardDeselection=="function"&&n.onKeyboardDeselection(),n.keyboardNavigation=null)};r.UI.KeystrokeHub.prototype.tabOrderDeselect=function(n){const{tabOrder:t,tabIndex:e}=this;e<=0||(t[e]&&this.disableKeyControlElement(t[e].element),n||(this.tabActiveElement=null,this.tabIndex=-this.tabIndex,this.highlightHide(),this.context.topNode.classList.remove("disable-mouse-pointer")))};r.UI.KeystrokeHub.prototype.tabOrderSelect=function(){this.tabActiveElement&&clearTimeout(this.tabActiveElement.element.highlightDelayTimeout);const{tabOrder:n,tabIndex:t}=this;t<=0?this.highlightHide():this.highlightPosition(n[t])};r.UI.KeystrokeHub.prototype.tabOrderClickSelected=function(){const{tabOrder:n,tabIndex:t}=this;
1n.length<=1||t<=0||(this.setKeyControlElement(n[t].element),n[t].element.dispatchEvent(new Event("stxtap")))};r.UI.KeystrokeHub.prototype.tabIndexNext=function(n){if(!this.context.stx.uiContext.topNode.hasAttribute("cq-keyboardnavigation-active")||this.tabOrder.length<=1)return;this.context.stx.uiContext.topNode.focus(),this.sortTabOrderElements(),this.tabIndex<0?this.tabIndex=Math.abs(this.tabIndex):this.tabOrderDeselect(!0),(this.tabIndex<1||this.tabIndex>=this.tabOrder.length)&&(this.tabIndex=n?this.tabOrder.length:1);let t=this.tabIndex,e=!1;do if(n===!0?t--:t++,this.tabOrder[t]&&r.trulyVisible(this.tabOrder[t].element)&&this.tabOrder[t].element.getAttribute("keyboard-selectable")!=="false")if(!e)this.tabIndex=t,e=!0;else break;while(t<this.tabOrder.length&&t>0);(t>=this.tabOrder.length||t<=1)&&(t>=this.tabOrder.length?this.context.topNode.setAttribute("cq-exit","foot"):t<=1&&this.context.topNode.setAttribute("cq-exit","head"),this.context.topNode.removeAttribute("cq-keyboardnavigation-active")),this.tabOrderSelect(),this.uiManager.closeMenu()};r.UI.KeystrokeHub.prototype.addActiveModal=function(n){this.tabActiveModals.indexOf(n)>-1||(this.tabActiveModals.unshift(n),this.tabOrderDeselect(),n.hasAttribute("native-tabbing")||this.setKeyControlElement(n))};r.UI.KeystrokeHub.prototype.removeActiveModal=function(n){let{tabActiveModals:t}=this,e=t.indexOf(n);e>-1&&(t.splice(e,1),t[0]?this.setKeyControlElement(t[0]):this.setKeyControlElement())};r.UI.KeystrokeHub.prototype.highlightPosition=function(n){if(!n||!n.element||!n.position){const{tabOrder:e,tabIndex:i}=this;if(i<=0)return;n=e[i]}this.tabActiveElement=n,this.highlightAlign();const t=n.element.querySelector("[tabindex]")||n.element;t.tabIndex="-1",t.focus(),setTimeout(()=>t.focus(),100)};r.UI.KeystrokeHub.prototype.highlightAlign=function(){if(this.tabActiveElement){const n=this.tabActiveElement.element.getBoundingClientRect(),t=this.context.topNode.getBoundingClientRect();if(n.width<=0||n.height<=0){this.highlightHide();return}this.highlightCreate(),Object.assign(this.highlightElement.style,{top:n.top-t.top+"px",left:n.left-t.left+"px",width:n.width+"px",height:n.height+"px"})}};r.UI.KeystrokeHub.prototype.highlightCreate=function(){return this.highlightElement?this.highlightElement.classList.remove("disabled"):(this.highlightElement=document.createElement("div"),this.highlightElement.classList.add("cq-keyboard-selected-highlight"),this.context.topNode.appendChild(this.highlightElement)),this.context.topNode.classList.add("disable-mouse-pointer"),this.context.topNode.classList.add("cq-navigation-highlight-visible"),this.highlightElement};r.UI.KeystrokeHub.prototype.highlightHide=function(){this.highlightElement&&this.highlightElement.classList.add("disabled"),this.context.topNode.classList.remove("cq-navigation-highlight-visible")};r.UI.KeystrokeHub.prototype.setActiveContext=function(n){n.topNode.querySelector("cq-context")||(this.context=n)};r.UI.KeystrokeHub.prototype.processKeyStrokeClaims=function(n,t,e,i){for(let s of Array.from(r.UI.keyboardClaims).reverse())if(s.ownerDocument===e.target.ownerDocument){var o=s.keyStroke(n,t,e,i);if(o)return o.allowDefault||e.preventDefault(),!0}return!1};r.UI.KeystrokeHub.prototype.handler=function(n){const{stx:t}=this.context;if(t.editingAnnotation)return;const{e,key:i,keystroke:o}=n;if(!this.infocus&&i!=="Tab")return;const s=(e.composedPath()[0]||e.target).tagName;switch(i){case"Shift":t.shift=o.shift;break;case"Control":case"Alt":t.ctrl=o.ctrl;break;case"Meta":case"Win":t.cmd=o.cmd;break;case"CapsLock":this.capsLock=!this.capsLock;break}const a=e.key==="Escape"||e.key==="Esc"||e.key==="Tab",c=s==="INPUT"||s==="TEXTAREA",l=this.uiManager.activeMenuStack.length;if(this.params.cb&&!this.context.isLegendKeyboardActive()&&(a||!c&&!l)&&this.params.cb(i,this,e))return e.preventDefault();!r.ChartEngine.drawingLine&&this.processKeyStrokeClaims(this,i,e,o)};class z extends HTMLElement{constructor(){super(),this.activeMenuStack=[],this.registeredForResize=[],this.keystrokeHub=null}getColorPicker(t){let{topNode:e}=r.UI.getMyContext(t)||{};if(!e)return;e=e.multiChartContainer||e,t.closest(".cq-dialogs")&&(e=t.closest(".cq-dialogs"));let i=e.querySelector("cq-color-picker");
1return i||(i=document.createElement("cq-color-picker"),i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),e.appendChild(i)),i}closeOpenColorPicker(){this.activeMenuStack.forEach(t=>{t.matches("cq-color-picker")&&t.close()})}connectedCallback(){var t=this;this.resize=function(){for(var i=t.registeredForResize,o=0;o<i.length;o++)typeof i[o].resize=="function"&&i[o].resize();t.closeOpenColorPicker()};var e=this.document||document;this.handleTap=function(i){i.ciqStamp>(e.lastTap||0)&&t.closeTopMenu()},e.body.addEventListener("stxtap",this.handleTap),r.installTapEvent(e.body,{preventUnderlayClick:!1,preventClickEvent:!0,absorbDownEvent:!1}),e.defaultView.addEventListener("resize",this.resize),e.body.contains(this)&&(r.UI.registerComponentsImmediately=!0,r.UI.ensureComponentsRegistered())}disconnectedCallback(){var t=this.document||document;t.defaultView&&t.defaultView.removeEventListener("resize",this.resize),t.body.removeEventListener("stxtap",this.handleTap),r.clearSafeClickTouches(t.body),r.UI._uiManagers.delete(t)}closeMenu(t,e){const{activeMenuStack:i}=this;let o=[];if(e=(e||"").split(",").map(s=>s.toUpperCase().trim()).filter(s=>s),t)for(o.push(t),t=t.parentElement;t;)t.matches("cq-menu")&&t.active&&o.push(t),t=t.parentElement;else o=i;for(let s=0;s<o.length;s++){const a=o[s];e.length&&!e.includes(a.tagName)||a.hide&&a.hide()}this.activeMenuStack=i.filter(s=>s.active),this.ifAllClosed()}closeTopMenu(){const{activeMenuStack:t}=this;if(!t.length)return;const e=t[t.length-1];(!e.isDialog||e.active)&&(t.pop(),e.hide(),e.onClose&&e.onClose(),setTimeout(()=>this.ifAllClosed(),0));const i=e.getAttribute("cq-close-top");i&&r.climbUpDomTree(e.parentElement,i).forEach(o=>this.closeMenu(o))}ifAllClosed(){this.activeMenuStack.length||Array.from((this.document||document).querySelectorAll("cq-context,*[cq-context]")).forEach(function(t){t.CIQ&&t.CIQ.UI&&t.CIQ.UI.context&&t.CIQ.UI.context.stx&&t.CIQ.UI.context.stx.modalEnd()})}initializeMenuListeners(t){t.callbackListeners.menu=[]}lift(t){var e=t;if(e){var i=e.ownerDocument;e.remember={parentNode:e.parentNode,css:{position:e.style.position,display:e.style.display,left:e.style.left,top:e.style.top,height:e.style.height,width:e.style.width,opacity:e.style.opacity}};var o=e.getBoundingClientRect(),s=e.scrollHeight,a=i.defaultView.innerHeight-o.top-20;s>a&&(s=a),e.doNotDisconnect=!0,e.context=r.UI.getMyContext(e.parentNode),e.remove(),Object.assign(e.style,{position:"fixed",display:"block",left:o.left+"px",top:o.top+"px",height:s+"px",opacity:1}),i.body.appendChild(e),delete e.doNotDisconnect,typeof e.resize<"u"&&e.resize(),Array.from(e.querySelectorAll("cq-scroll")).forEac
1h(function(c){c.resize()})}}openMenu(t,e){const{activeMenuStack:i}=this;i.includes(t)||(setTimeout(()=>{const o=t.querySelector("input:first-child");o&&r.climbUpDomTree(o,"[aria-hidden='true']",!0).length===0&&o.focus()},10),i.push(t),t.show(e),t.ownerDocument.querySelectorAll("cq-context,*[cq-context]").forEach(o=>{const s=r.getFromNS(o,"CIQ.UI.context.stx");s&&(s.modalBegin(),s.callbackListeners.menu&&s.dispatch("menu",{stx:s,menu:t}))}))}registerForResize(t){this.registeredForResize.push(t)}topMenu(){var t=this.activeMenuStack;return t.length?t[t.length-1]:null}unregisterForResize(t){for(var e=this.registeredForResize,i=0;i<e.length;i++)if(e[i]===t){e.splice(i,1);return}}}r.UI.UIManager=z;r.ChartEngine.registerGlobalEvent("beforeunload",function(){if(r.UI._uiManagers){const n=r.UI._uiManagers.get(this.document);if(n){r.UI._uiManagers.delete(this.document);try{n.disconnectedCallback()}catch{}}}},!1,!0);r.UI.getUIManager=function(n){let t=document;if(n){const o=r.UI.closestContextContainer(n);o?t=o.portalDoc||t:t=n.ownerDocument||t}r.UI._uiManagers||(r.UI._uiManagers=new WeakMap);const e=r.UI._uiManagers.get(t);if(e)return e;let i=t.querySelector("cq-ui-manager");return i||(i=new r.UI.UIManager,i.document=t,i.connectedCallback()),r.UI._uiManagers.set(t,i),i};r.UI.removeUIManager=function(n){if(!n||n.querySelector("cq-context"))return;const t=r.UI._uiManagers.get(n);t&&(t.disconnectedCallback(),r.UI._uiManagers.delete(n))};customElements.define("cq-ui-manager",z);class B extends HTMLElement{connectedCallback(){this.doc=this.ownerDocument}disconnectedCallback(){if(r.UI.keepConnected(this))return;const t=r.getFromNS(this,"CIQ.UI.context.stx");r.UI.BaseComponent.scheduledBindings=r.UI.BaseComponent.scheduledBindings.filter(e=>e.node.closest("cq-context")!==this),t&&!t.destroyed&&t.destroy&&t.destroy()}}r.UI.addComponentDefinition("cq-context",B);const{qs:U,qsa:Z,channelWrite:L,channelRead:H,channelSubscribe:q}=r.UI.BaseComponent.prototype;class Q{createChartAndUI({container:t,config:e,isAsync:i,callback:o}){t||(t=document.body),e&&!e.chartId&&(e.chartId=t.id);const s=y(t),a=U("cq-context",s),c=r.getFromNS(a,"CIQ.UI.context"),l=U(c?"[cq-context-engine]":".chartContainer",s);c&&(l.parentElement.style.display="none",l.dimensionlessCanvas=!0);const h=l.stx&&!l.stx.destroyed?l.stx:r.ChartEngine.create({container:l,config:e,deferLoad:!0});h.deferResizeCount=0,l.stx=h;const f=h.container.closest("cq-context-wrapper");if(f&&e.multiChartCopySymbol===null&&!e.initialSymbol){const{onChartReady:C,onMultiChartEvent:m}=e;e.onChartReady=function(v){C&&C.call(e,v),m&&m("chartReady",{stx:v}),v.chart.symbolObject.symbol===null&&(r.newChild(v.container,"div","ciq-empty-message",e.multiChartLoadMsg),f&&(f.classList.add("ciq-empty-chart"),f.removeEmptyMsg=()=>{f.querySelector(".ciq-empty-message").remove(),f.classList.remove("ciq-empty-chart"),delete f.removeEmptyMsg}))}}const{multiChartContainer:u}=t,p=!u||u===t;this.portalizeContainerIfInDifferentDocument(u||t);const d=new r.UI.Context(h,s);return d.config=e,d.isAsyncLoad=i,t.context=d,r.UI.Layout(d),r.UI.Channel(d),r.UI.StudyEdit(null,d),this.initLookup(d),c||(r.Renderer.Aggregations&&(r.Advanced=function(){}),this.initExtensions({stx:h,uiContext:d,type:"plugins"}),this.initPluginChannelListeners(h,d),this.initDefaultTheme(d,t),e.onEngineReady&&e.onEngineReady(h),this.loadChart(d)),(i?setTimeout:C=>C())(()=>{r.UI.scrollbarStyling=e.scrollbarStyling,p&&r.UI.ensureComponentsRegistered(),d.topNode.hasAttribute("tabindex")||d.topNode.setAttribute("tabindex","0"),this.initDialogHandler(d),this.initContainerListeners(d),this.initEventMarkers(d),this.initDrawingTools(d),this.initDrawingEditListeners(d),this.initMenusAndToggles(d),e.language&&(e.setHtmlLang&&document.documentElement.setAttribute("lang",e.language),r.I18N&&r.I18N.localize(h,e.language)),this.loadPreferences(d),h.deferResizeCount>0&&(delete h.deferResizeCount,h.resizeChart()),r.UI.BaseComponent.buildReverseBindings(s),c||(s.bindingInitiated=!0,r.UI.begin(),d.uiManager=r.UI.getUIManager(d.topNode),d.uiManager.initializeMenuListeners(h),setTimeout(()=>{!d.topNode.isConnected||d.stx.destroyed||(d.topNode.ownerDocument.body.keystrokeHub.resetTabNavigation(),r.UI.setDefaultStates(d))},0)),p&&e.onWebComponentsReady&&setTimeout(()=>e.onWebComponentsReady()),o&&(i?setTimeout(o):o())}),d;function y(C){return C.matches("cq-context")||C.getAttribute("cq-container")?C:C.querySelector("cq-context, [cq-context]")}}initContainerListeners(t){const{config:{channels:{className:e="channel.componentClass",breakpoint:i="channel.breakpoint",sidenavSize:o="channel.sidenavSize",sidepanelSize:s="channel.sidepanelSize",drawingPalettes:a="channel.drawingPalettes"}={}}={},stx:c,topNode:l}=t;r.UI.addResizeListener(l,()=>this.notifySizeChanges(t)),c.addEventListener("destroy",()=>{r.UI.removeResizeListener(l);const u=t.topNode.ownerDocument;r.UI.getUIManager(u).closeMenu(),u.querySelectorAll("body > .cq-dialogs, body > cq-dialog").forEach(d=>d.remove()),u.querySelectorAll(".ciq-window").forEach(d=>{d.uiContext&&d.uiContext===t&&d.remove()}),r.ChartEngine.registeredContainers.find(d=>d.isConnected&&d.stx.uiContext&&d.ownerDocument===u)||u.body.keystrokeHub&&(u.body.keystrokeHub.ke
1ystroke.destroy(),delete u.body.keystrokeHub),setTimeout(()=>{r.UI.removeUIManager(u)})}),q(e,this.classSetter(t),c),q(i,this.breakpointSetter(t),c),q(o,this.sidenavSizeSetter(t),c),q(s,this.sidepanelSizeSetter(t),c),q(a,this.chartPositionSetter(t),c),this.notifySizeChanges(t);const h=this.initKeystrokeHub(t),f=this.getKeystrokeHubSetter(t,h);l.addEventListener("mouseover",f),l.addEventListener("focus",u=>{u.target.hasAttribute("cq-keyboardnavigation-active")||(f(u),u.target.setAttribute("cq-keyboardnavigation-active",""),h.resetTabNavigation())}),l.addEventListener("blur",u=>{const p=document.querySelector(".cq-dialogs"),d=u.relatedTarget?u.relatedTarget.closest("[cq-lift]"):null;u.relatedTarget&&(l.contains(u.relatedTarget)||p&&p.contains(u.relatedTarget)||d)||(u.target.removeAttribute("cq-keyboardnavigation-active"),h.tabOrderDeselect(),h.highlightHide())})}initLookup(t){const{config:e,stx:i}=t,{channels:{lookup:o}={},dialogs:{lookup:s}={}}=e;if(o&&s){const{channelSubscribe:a,channelWrite:c}=r.UI.BaseComponent.prototype;a(o,l=>{c("channel.dialog",l?{type:"lookup",params:{stx:i,context:t}}:{},i)},i)}t.changeSymbol=function(a,c){const{stx:l,loader:h}=t;h&&h.show(!0);const{removeSeries:f,loadError:u}
1=e.onNewSymbolLoad||{};if(f&&Object.values(l.chart.series).filter(f).forEach(p=>{p.parameters.isEvent?l.removeEvent(p.id):l.removeSeries(p.id)}),l.loadChart(a,{masterData:a._masterData},function(p){if(h&&h.hide(),p){u&&u(p,t);return}c&&c(l),e.restore&&r.ChartEngine.restoreDrawings(l,l.chart.symbol,e.chartId)}),a.symbol){const p=t.topNode.closest("cq-context-wrapper");p&&p.removeEmptyMsg&&p.removeEmptyMsg()}},e.lookupDriver&&t.setLookupDriver(new e.lookupDriver)}initDefaultTheme(t,e){if(r.UI.usingLegacyComponents||!e.isMultiChartHost&&e.multiChartContainer)return;const{themes:i}=t.config;if(!i)return;let o=r.UI.registerSingleComponent("cq-themes");if(!o)return;const{defaultTheme:s,initializeDefault:a}=i;o=new o,o.context=t,a?o.loadBuiltIn(s):(o.initParams(i),o.getStoredTheme(c=>{o.setAttribute("theme",c||s)}))}initKeystrokeHub(t){let e=document;if(t&&(e=t.topNode.portalDoc||e),e.body.keystrokeHub)return e.body.keystrokeHub;const i=r.climbUpDomTree(t.topNode,"cq-context",!0).pop();return e.body.keystrokeHub=new r.UI.KeystrokeHub(i.parentElement||e.body,t,{cb:r.UI.KeystrokeHub.defaultHotKeys}),e.body.keystrokeHub}getKeystrokeHubSetter(t,e){return function(){e.context!==t&&e.setActiveContext(t)}}initDialogHandler(t){const{config:{channels:e={},dialogs:i={}}={},stx:o}=t;q(e.dialog||"channel.dialog",s,o);function s({type:a=null,params:c={}}={}){if(!a)return;const l=i[a]||i[r.makeCamelCase(a)];if(!l)return;const h=c.context.topNode.ownerDocument;let f=U(l.tag,t.topNode)||U(l.tag,h);if(!f){f=document.createElement(l.tag);const d=p(h),g=document.createElement("cq-dialog");g.append(f),d.append(g)}const u=f.parentElement;u.context=c.context,u.setAttribute("role","dialog"),u.setAttribute("aria-modal","true"),u.setAttribute("aria-labelledby",l.tag+"-title"),u.setAttribute("aria-describedby",l.tag+"-description"),Object.entries(l.attributes||{}).forEach(([d,g=""])=>{typeof g=="function"&&(g=g(f)),["cq-title","cq-close-button","cq-description"].includes(d)?u.setAttribute(d,g):f.setAttribute(d,g)}),u.wraps=f.tagName.toLowerCase(),f&&f.open&&f.open(c);function p(d){let g=U(".cq-dialogs",d);return g||(g=document.createElement("div"),g.classList.add("cq-dialogs"),d.body.append(g),g)}}}initDrawingTools(t){const{stx:e,config:{channels:i={}}={},topNode:o}=t;q(i.drawing||"channel.drawing",s,e);function s(a){o.classList[a?"add":"remove"]("toolbar-on"),e.resizeChart()}}initDrawingEditListeners(t){const{config:{channels:e={}}={},stx:i}=t,o=new r.UI.DrawingEdit(null,t);let s=!0;const a=e.drawing||"channel.drawing";o.node.addEventListener("drawing-edit-begin",function(c){H(a,i)||(s=!1,L(a,!0,i))},!1),o.node.addEventListener("drawing-edit-end",function({detail:c}){s||(c.action!=="edit"&&(s=!0),c.action==="close"&&L(a,!1,i))},!1)}initColorPicker(t){let e=document;t&&(e=t.topNode||e);let i=e.querySelector("cq-color-picker");i||(e=e.ownerDocument||e,i=e.querySelector("body > cq-color-picker"),!i&&(i=document.createElement("cq-color-picker"),i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),document.body.append(i),e.ownerDocument&&e.ownerDocument.body.append(i)))}loadPreferences(t){const{stx:e,topNode:i,config:{chartId:o,multiChartId:s,restore:a}={}}=t;a&&r.ChartEngine.restorePreferences(e,s||o||i.id)}loadChart(t){const{stx:e,config:{chartId:i,initialSymbol:o,restore:s,onChartReady:a,initialData:c}={},loader:l}=t;l&&l.show(!0),s?r.ChartEngine.restoreLayout(e,function(u){if(l&&l.hide(),!u&&!e.chart.symbol){h();return}f()},i,t.config):h();function h(){if(e.crossSection){let p=e.layout.chartType.includes("crosssection")?e.layout.chartType:e.crossSection.initialSettings.chartType||"crosssection";e.setChartType(p)}if(!o){f();return}const u=typeof o=="string"?{symbol:o}:o;u._masterData=c,t.changeSymbol(u,f)}function f(){a&&setTimeout(()=>a(e))}}notifySizeChanges(t){if(!t.topNode.isConnected)return;const{stx:e,topNode:{clientWidth:i,clientHeight:o,classList:s},config:{channels:a={}}={}}=t;if(e.destroyed)return;const c=H(a.containerSize||"channel.containerSize",e);if(c&&c.width===i&&c.height===o)return;const l=this.getBreakpoint(i,o);s.contains(l[1])||L(a.breakpoint||"channel.breakpoint",l[1],e),l[0]!==e.chart.breakpoint&&window.setTimeout(()=>{L(a.breakpoint||"channel.breakpoint",l[0],e),e.notifyBreakpoint(l[0]),e.resizeChart()}),L(a.containerSize||"channel.containerSize",{width:i,height:o},e),e.resizeChart()}
1getBreakpoint(t,e){let i="break-sm";if(t>768?i="break-lg":t>584&&(i="break-md"),typeof e>"u")return i;let o="break-height-sm";return e>768?o="break-height-lg":e>350&&(o="break-height-md"),[i,o]}initEventMarkers(t){const e=t.config;if(e.eventMarkersImplementation&&r.UI.Markers){const i=e.eventMarkersImplementation&&new e.eventMarkersImplementation(t.stx),o=e.selector.markersMenuItem;r.UI.Markers(t,{menuItemSelector:o,implementation:i})}}initExtensions({stx:t,uiContext:e,type:i}){const{config:o}=e,s=o[i];Object.entries(s).filter(([,a])=>!!a).forEach(([a,c])=>{this.constructor.applyPlugin(t,a,c)})}static applyPlugin(t,e,i){const{uiContext:o}=t,s=i.moduleName||r.capitalize(e);try{if(!r[s]){if(i.load&&i.toggleMarkup&&i.container&&(typeof i.container=="string"&&(i.container=o.topNode.querySelector(i.container)),i.container)){const l=document.createElement("div");r.safeAssign(l,i.toggleMarkup),Array.from(l.childNodes,h=>{i.container.appendChild(h.cloneNode(!0))}),r.UI.activatePluginUI(t,s)}r.debug&&console.log(`${s} not available for ${e} with params:`,i);return}const a=Object.assign({stx:t,context:o},i),c=new r[s](a);r.UI.activatePluginUI(t,e),i.postInstall&&i.postInstall({uiContext:o,extension:c}),i.init=!0}catch(a){r.debug&&console.error("Error configuring "+e+" using params ",i,"error",a)}}static loadPlugin(t,e){const i=t.uiContext.config.plugins[e],o=i.moduleName||r.capitalize(e);if(i.init)return Promise.resolve();r[o]?this.applyPlugin(t,e,i):i.load&&i.load().then(s=>{r.UI.registerComponents(),this.applyPlugin(t,e,i)})}initPluginChannelListeners(t,e){Object.entries(e.config.plugins).forEach(([i,o])=>{o&&(o.init||!o.channel||!o.load||b.prototype.channelSubscribe(o.channel,s=>{s&&this.constructor.loadPlugin(t,i)},t))})}initMenusAndToggles(t){const{config:e}=t;e.toggles=e.toggles||{},t.advertiseAs(e.toggles,"ToggleConfig"),e.menus=e.menus||{},t.advertiseAs(e.menus,"MenuConfig"),e.groups=e.groups||{},t.advertiseAs(e.groups,"GroupConfig");const i=r.UI.activateShadowRoots?r.UI.shadowComponents.keys():t.topNode.querySelectorAll("[config]");t.topNode.parentElement&&[...i].forEach(o=>o.fireConfigChange&&o.fireConfigChange())}addPluginContainer(t){if(!t.topNode.parentNode)return;const{multiChartContainer:e}=t.topNode,i=e||t.topNode,o=i.querySelector(".cq-plugin-container");if(o)return o;const s=document.createElement("div"),a=i.querySelector(".ciq-nav");s.classList.add("cq-plugin-container"),a?i.insertBefore(s,a.nextElementSibling):i.appendChild(s);const c=e?U(".ciq-multi-chart-container-wrapper",e):U(".ciq-chart-area",t.topNode),l=r.resizeObserver(s,()=>{const{height:h}=getComputedStyle(s);c.style.marginTop=h,t.stx.resizeChart()});return t.stx.addEventListener("destroy",()=>{r.resizeObserver(s,null,l)}),s}chartPositionSetter(t){let e=U(".ciq-multi-chart-container",t.topNode);return e||(e=t.stx.container),function(o){if(!o)return;const{top:s,left:a}=o;Object.assign(e.style,{top:s+"px",marginLeft:a+"px",height:`calc(100% - ${s}px)`})}}sidenavSizeSetter(t){const e=U(".ciq-multi-chart-container-wrapper, .ciq-chart-area",t.topNode);return t.stx,function(o){e.style.left=o+"px",r.getFnFromNS(t,"topNode.getCharts",[t.stx])().forEach(s=>s.resizeChart())}}chartAreaTopSetter(t){const e=U(".ciq-chart-area",t.topNode);return function(o){let s=Object.values(o||{}).reduce((c,l)=>c+l,0);const a=t.topNode.querySelector(".cq-plugin-container");a&&(s=a.offsetHeight),e.style.marginTop=s+"px",t.stx.resizeChart()}}sidepanelSizeSetter(t){const{multiChartContainer:e}=t.topNode,i=U(".ciq-multi-chart-container, .ciq-chart-area",e||t.topNode),o=t.stx;return function(s){i.style.marginRight=s+"px";const a=U(".cq-plugin-container",t.topNode);a&&(a.style.marginRight=s+"px"),o.resizeChart()}}breakpointSetter(t){return function(i){let o=[["break-lg","break-md","break-sm"],["break-height-lg","break-height-md","break-height-sm"]];const s=[t.topNode];r.UI.shadowComponents.forEach((a,c)=>{a===t.topNode&&s.push(c)}),s.forEach(a=>{o.forEach(c=>{c.includes(i)&&(a.classList.remove(...c),a.classList.add(i))})})}}classSetter(t){return function(i){i&&r.UI.shadowComponents.forEac
1h((o,s)=>{for(const[a,c]of Object.entries(i))o===t.topNode&&s.classList[c](a)})}}portalizeContainerIfInDifferentDocument(t){if(t.ownerDocument===document||t.ownerDocument.portalized)return;const e=Object.keys(r.UI._webcomponents.list).filter(a=>a!=="cq-context").join(","),i=Array.from(t.querySelectorAll(e)),o=i.filter(a=>!i.some(l=>l!==a&&l.contains(a)));t.matches("cq-context")||(t=t.querySelector("cq-context")),(t||{}).portalDoc=t.ownerDocument,o.forEach(a=>{s(a);const c=document.createElement("div");r.safeAssign(c,a.outerHTML),a.parentElement.replaceChild(c.firstChild,a)});function s(a){a.querySelectorAll("template").forEach(c=>{for(;c.firstChild;)c.content.append(c.firstChild)})}t.ownerDocument.portalized=!0}}r.UI.Chart=Q;class V{createCharts({containerId:t,chartsConfig:e},i){const o=!t||typeof t=="string"?document.querySelector(t||"cq-context"):t;o.styles={},o.isMultiChartHost=!0;const s=Array.from(o.querySelectorAll("cq-context-wrapper"));if(!s.length)throw"cq-context-wrapper element is required for multichart template setup";const a=s[0].outerHTML;let{charts:c,colCount:l,rowCount:h,gridTemplate:f,offgridCharts:u=[]}=e;c.slice(0,c.length-s.length).forEach(()=>{r.safeAssign(s[0].parentElement,a,"html","beforeend")});const p=o.querySelectorAll("cq-context");i.root=null,i.multiChartCopySymbol===null&&(i.initialSymbol=""),i.hotkeyConfig.hotkeys=i.hotkeyConfig.hotkeys.filter(({action:v,label:I})=>!/\btab\b/i.test(I)&&v!=="toggleDrawings");const d=new r.UI.Chart,g=c.map(({symbol:v,chartId:I},w)=>{const x=r.clone(i);x.initialSymbol=typeof v<"u"?v:x.initialSymbol,x.chartId=I||(i.chartId||"")+"_c"+r.uniqueID();const k=p[w];x.root=k,k.multiChartContainer=o;const{stx:A}=d.createChartAndUI({container:k,config:x,isAsync:!0});return this.initChart(k,x,A),A}),y=()=>{const v=o.querySelector("cq-grid-size-picker");v&&v.setGridUI(l,h,f);const I=o.querySelector("cq-context");o.switchContext(I.CIQ.UI.context)};d.createChartAndUI({container:o,config:i,isAsync:!0,callback:y}),this.initContainer(o,i,a),d.initDefaultTheme(o.context,o),g.forEach(v=>{v.setDrawingContainer(o.context.stx.drawingContainer),v.currentVectorParameters=o.context.stx.currentVectorParameters,v.preferences.drawings=o.context.stx.preferences.drawings});let C;q(i.channels.drawing||"channel.drawing",m,o.context.stx);function m(v){o.classList[v?"add":"remove"]("toolbar-on");const{onDraw:I}=i.soloActive||{},{shouldSolo:w}=I||{},x=o.querySelector("cq-context-wrapper.active cq-context");if(o.activeRequests&&v&&(C=null),I&&o.soloActive&&x){const{stx:k}=x.CIQ.UI.context,A=typeof w!="function"||v&&w(k);(A||!v&&C===k)&&o.soloActive(v,"onDraw"),A&&(C=k)}o.context.stx.resizeChart()}return o.colCount=l,o.rowCount=h,o.gridTemplate=f,o.offgridCharts=u,o.updateLayout(),g}initContainer(t,e,i){const o=t.querySelector("cq-context");t.plugins=t.plugins||[],this.contextSwitcher(t),this.addChart(t,e,i),this.moveChart(t,e),this.removeChart(t,e),this.solo(t,e),this.toggleSolo(t,e),this.setColCount(t),this.setRowCount(t),this.setGridTemplate(t),this.cleanGridStyles(t),this.fillLayoutWithCharts(t),this.updateGridListener(t),this.updateLayout(t,e),this.utils(t),this.copyAttributes(o,t)}initChart(t,e,i){const o=r.UI.closestContextContainer(t.parentElement);i.keepDrawingToolSelected=e.keepDrawingToolSelected;let s;t.addEventListener("stxtap",c=>{if(a())return;const l=c.target.closest("cq-context");if(l){const h=l.CIQ.UI.context;o.switchContext(h,c)}},!0);function a(){const c=+new Date,l=c-s;if(s&&l<10)return!0;s=c}e.onMultiChartEvent&&i.addEventListener("destroy",()=>e.onMultiChartEvent("chartDestroy",{stx:i})),i.keepDrawingToolSelected===void 0&&(i.keepDrawingToolSelected=!0),i.preserveCandleWidthOnResize===null&&(i.preserveCandleWidthOnResize=!0),i.prepend("mousemoveinner",()=>{if(i.__notifiedExit||!o.getCharts)return;o.getCharts().forEach(l=>{l!==i&&(l.insideChart=l.overYAxis=l.overXAxis=!1,l.undisplayCrosshairs(),l.draw(),l.__notifiedExit=!1)}),i.__notifiedExit=!0}),r.UI.closestContextContainer(t,{isWrapper:!0}).close=function(){o.activeRequests&&o.toggleSolo({node:this}),o.removeChart(this)},r.UI.closestContextContainer(t,{isWrapper:!0}).move=function(c,l="after"){o.activeRequests&&o.toggleSolo({node:this}),o.moveChart(this,l)}}addChart(t,e,i){t.addChart=(o,s="after")=>{t.activeRequests&&t.toggleSolo({node:t.querySelector("cq-context-wrapper.active .ciq
1-solo-toggle")});let{node:a,symbol:c,chartId:l}=o||{};const h=a?r.UI.closestContextContainer(a,{isWrapper:!0}):t.querySelector("cq-context-wrapper.active");e.multiChartCopySymbol?c={...r.getFromNS(h.querySelector("cq-context"),"CIQ.UI.context.stx.chart.symbolObject")}:e.multiChartCopySymbol===null&&(c="");const{crosshair:f,headsUp:u}=h.querySelector("cq-context").CIQ.UI.context.stx.layout;let p;s==="after"?(r.safeAssign(h,i,"html","afterend"),p=h.nextSibling):s==="before"&&(r.safeAssign(h,i,"html","beforebegin"),p=h.previousSibling);const d=p.querySelector("cq-context");d.multiChartContainer=t,p.ownerDocument.portalized=!1,r.UI.Chart.prototype.portalizeContainerIfInDifferentDocument(p),r.UI.BaseComponent.buildReverseBindings(p);const g=r.clone(e);g.initialSymbol=typeof c<"u"?c:g.initialSymbol,g.chartId=l||`_c${r.uniqueID()}`,g.root=d;const y=g.createChartAsync(d);y.layout.crosshair=f,y.layout.headsUp=Object.assign({},u),t.setCurrentThemeClass&&t.setCurrentThemeClass(d,y),this.initChart(d,g,y),y.setDrawingContainer(t.context.stx.drawingContainer),y.currentVectorParameters=t.context.stx.currentVectorParameters,y.preferences.drawings=t.context.stx.preferences.drawings,t.updateLayout(),t.querySelectorAll("cq-info-toggle-dropdown").forEach(m=>m.initInfoComponents(t));const C=y.container.closest(".ciq-chart-area");["static","dynamic"].forEach(m=>{const[v]=t.getCharts().slice(-1);v.uiContext.getAdvertised("Layout")[m]&&!C.querySelector("cq-hu-"+m)&&C.appendChild(document.createElement("cq-hu-"+m))})}}moveChart(t,e){t.moveChart=(i,o="after")=>{const s=i||t.querySelector("cq-context-wrapper.active");let a=o=="before"?s.previousElementSibling:s.nextElementSibling;a&&(o=="after"&&(a=a.nextElementSibling),s.doNotDisconnect=!0,s.parentElement.insertBefore(s,a),delete s.doNotDisconnect),t.updateLayout()}}removeChart(t,e){t.removeChart=function(o){const s=o||t.querySelector("cq-context-wrapper:last-of-type"),a=s.classList.contains("active"),c=s.nextElementSibling||s.previousElementSibling;if(!c)return;a&&c.querySelector("cq-context").dispatchEvent(new Event("stxtap")),s.querySelector("cq-context").CIQ.UI.context.stx.destroy(),s.remove();const l=e.nameValueStore||r.NameValueStore,h=new l,f=r.getFromNS(s.querySelector("cq-context")||{},"CIQ.UI.context.config.chartId");if(r.getFromNS(s.querySelector("cq-context")||{},"CIQ.UI.context.config.chartId"),f){h.remove(`myChartLayout${f}`);const u=`${f||""}_drawings`;h.get(u,(p,d)=>{p||!d||(Object.keys(d).forEach(g=>{h.remove(g)}),h.remove(u))}),t.updateLayout()}t.switchContext(c.querySelector("cq-context").CIQ.UI.context)}}contextSwitcher(t){t.activeContext=t.CIQ.UI.context;const e=t.CIQ.UI.context;t.switchContext=(s,a)=>{if(l(a),s===t.activeContext)return;this.getCommonUI(t).forEach(h=>i(h,s)),o(s),t.plugins.forEach(h=>{h.switchContext&&h.switchContext(s)}),Array.from(t.querySelectorAll("cq-context-wrapper")).forEach(h=>{const f=h.querySelector("cq-context").CIQ.UI.context;h.classList.toggle("active",s===f)}),t.activeContext=s,s.stx.layout.crosshair&&(s.stx.centerCrosshairs(),s.stx.doDisplayCrosshairs()),r.getFnFromNS(s,"config.onMultiChartEvent")("contextSwitch",{prev:t.activeContext,context:s});function l(h){if(h&&!s.stx.chart.symbolObject.symbol){if(h.target.closest("cq-menu"))return;r.UI.getUIManager(h.target).closeTopMenu(),h.stopPropagation();const u=t.querySelector(".ciq-search cq-lookup cq-lookup-input input");if(u){setTimeout(()=>{u.click(),u.focus()});return}const p=(s.config.channels||{}).dialog||"channel.dialog",{channelWrite:d}=r.UI.BaseComponent.prototype;d(p,{type:"lookup",params:{context:s}},s.stx)}}};function i(s,a){if(s.changeContext){s.changeContext(a);return}s.stx&&(s.stx=a.stx),s.context&&(s.context=a)}function o(s){Object.values(e.advertised).forEach(a=>{a.changeContext&&a.changeContext(s)})}}solo(t,e){const{freezeEngineRendering:i,transitionToSolo:o,transitionFromSolo:s}=this;t.resized=-1,t.soloActive=(a,c)=>{let{activeRequests:l=0}=t;const h=l;if(!a&&c!=="toggle"&&t.soloType==="toggle")return;a&&l===0&&(t.soloType=c),l+=a?1:l?-1:0,c==="toggle"&&!a&&(l=0),Object.assign(t,{activeRequests:l});const f=t.querySelector("cq-context-wrapper.active");if(!f)return;a&&l===1?setTimeout(()=>{o(t,i)},100):l===0&&s(t);const u=f.querySelector("cq-context").context.stx;if(a){const p=r.getFromNS(e,`soloActive.${c}.notify`);!h&&p&&t.classList.contains("ciq-multi-chart")&&u.dispatch("notification",p)}else l||(Object.values(e.soloActive||{}).filter(p=>
1p.notify).forEach(({notify:p})=>{u.dispatch("notification",Object.assign({},p,{remove:!0}))}),t.plugins.forEach(p=>{p.deactivateOnGrid&&p.deactivateOnGrid()}))}}freezeEngineRendering(t){const e={draw(){},resizeChart(){}};function i(u){const{draw:p,resizeChart:d}=u;return Object.assign(u,e),{draw:p,resizeChart:d}}let o=0;const{quoteDriver:s}=t;s&&(o=s.behavior.refreshInterval,s.resetRefreshInterval(s.behavior.backgroundRefreshInterval||0));const{slider:a}=t.slider||{},{marketDepth:c}=t.marketDepth||{},l=i(t),h=i(a||{}),f=i(c||{});return()=>{Object.assign(t,l),s&&s.resetRefreshInterval(o),a&&Object.assign(a,h),c&&Object.assign(c,f),t.draw()}}transitionToSolo(t,e){const i=t.querySelector(".ciq-multi-chart-container"),{top:o,left:s}=i.getBoundingClientRect(),a=[];t.querySelectorAll("cq-context-wrapper").forEach(c=>{const l=c.classList.contains("active");if(!l){const d=c.querySelector("cq-context").CIQ.UI.context.stx;c.restoreDraw=e(d),setTimeout(()=>{c.style.visibility="hidden"},550)}const{height:h,width:f,top:u,left:p}=c.getBoundingClientRect();a.push({el:c,style:{height:h+"px",width:f+"px",top:u-o+"px",left:p-s+"px"},className:l?"ciq-solo":"ciq-solo-minimized"})}),t.classList.add("ciq-solo"),a.forEach(({el:c,style:l,className:h})=>{Object.assign(c.style,l),setTimeout(()=>{c.classList.add(h)},50)}),t.rHandle=r.resizeObserver(t,()=>{t.resized+=1})}transitionFromSolo(t){const e=t.querySelectorAll("cq-context-wrapper");e.forEach(i=>{i.classList.remove("ciq-solo-minimized","ciq-solo"),t.resized||(i.style.visibility="")}),setTimeout(()=>{t.classList.remove("ciq-solo"),e.forEach(i=>{i.classList.remove("ciq-solo-minimized","ciq-solo"),Object.assign(i.style,{height:"",width:"",top:"",left:"",visibility:""}),i.restoreDraw&&(i.restoreDraw(),delete i.restoreDraw)})},t.resized?0:350),r.resizeObserver(t,null,t.rHandle),t.resized=-1}toggleSolo(t,e){t.toggleSolo=({node:i})=>{const o=r.UI.closestContextContainer(i,{isWrapper:!0}),a=o.querySelector("cq-context").CIQ.UI.context;if(t.activeRequests){const{drawing:c="channel.drawing",tfc:l="channel.tfc"}=e.channels||{},{channelWrite:h}=r.UI.BaseComponent.prototype;h(c,!1,a.stx),h(l,!1,a.stx),t.soloActive(!1,"toggle")}else o.classList.contains("active")||t.switchContext(a),t.soloActive(!0,"toggle")}}setColCount(t){t.setColCount=function(i){t.gridTemplate="",t.colCount=i,t.updateLayout()}}setRowCount(t){t.setRowCount=function(i){t.gridTemplate="",t.rowCount=i,t.updateLayout()}}setGridTemplate(t){t.setGridTemplate=function(i){t.colCount="",t.rowCount="",t.gridTemplate=i,t.updateLayout()}}cleanGridStyles(t){t.cleanGridStyles=function(i){const o=t.querySelector("cq-grid-size-picker");if(!o||!o.attached)return;const s=o.templates.split(" "),a=t.querySelector(".ciq-multi-chart-container");a.style.gridTemplateRows="",a.style.gridTemplateColumns="",a.className=a.className.split(" ").filter(c=>!s.includes(c)).join(" ")}}fillLayoutWithCharts(t){t.fillLayoutWithCharts=function(){const i=t.querySelector(".ciq-multi-chart-container");if(!i)return;const o=getComputedStyle(i);let s=0;o.gridTemplateAreas&&o.gridTemplateAreas!="none"?s=[...new Set(o.gridTemplateAreas.match(/([a-z])+/gi))].length:o.getPropertyValue("--grid-dimension")?(s=parseInt(o.getPropertyValue("--grid-dimension"))||0,s++):s=parseInt(t.rowCount)*parseInt(t.colCount);const{restoreOffgridCharts:a}=t.CIQ.UI.context.config;let{offgridCharts:c}=t;
1for(;s&&i.childElementCount!==s;)if(i.childElementCount>s){const l=t.querySelector("cq-context-wrapper:last-of-type").querySelector("cq-context").CIQ.UI.context.config,h=l.chartId;a&&c.push(h),l.chartId="",t.removeChart()}else{const l=i.querySelector("cq-context-wrapper:last-of-type cq-context"),h=a?c.pop():void 0;if(t.addChart({node:l,chartId:h}),i.childElementCount>=25)break}a&&t.updateLayout()}}updateGridListener(t){t.addEventListener("update-grid",({detail:{columns:e,rows:i,template:o,container:s}})=>{s===t&&(o?t.setGridTemplate(o):e&&i&&(t.setColCount(e),t.setRowCount(i)),t.fillLayoutWithCharts())})}updateLayout(t,e){t.updateLayout=function(){const i=e.nameValueStore||r.NameValueStore,o=new i,s=Array.from(t.querySelectorAll("cq-context-wrapper"),p=>{const d=r.getFromNS(p.querySelector("cq-context")||{},"CIQ.UI.context.config.chartId");if(d)return{chartId:d}}).filter(p=>p);o.set("multiCharts"+(e.multiChartId||""),{charts:s,colCount:t.colCount,rowCount:t.rowCount,gridTemplate:t.gridTemplate,offgridCharts:t.offgridCharts}),t.classList[s.length>1?"add":"remove"]("ciq-multi-chart"),t.cleanGridStyles();const a=t.querySelector(".ciq-multi-chart-container");t.gridTemplate?a.classList.add(t.gridTemplate):t.rowCount&&t.colCount&&(a.style.gridTemplateColumns=Array(parseInt(t.colCount)).fill("1fr").join(" ")),a.style.setProperty("--orphan-span-start","1");const c=getComputedStyle(a),l=a.childElementCount,f=c.gridAutoFlow=="column"?c.gridTemplateRows.split(" ").length:c.gridTemplateColumns.split(" ").length,u=l%f||f;a.style.setProperty("--orphan-span-start",u)}}copyAttributes(t,e){t.getAttributeNames().filter(i=>/-feature$/.test(i)).forEach(i=>e.setAttribute(i,t.getAttribute(i)))}getCommonUI(t){return e(".ciq-nav, .ciq-footer",t).filter(i=>i.localName.indexOf("cq-")===0&&i.localName!=="cq-themes"&&i.localName!=="cq-info-toggle-dropdown"&&i.localName!=="cq-side-nav"&&!i.classList.contains("ciq-sidenav")&&!i.classList.contains("ciq-draw")&&!i.classList.contains("ciq-shortcut-button")&&!i.matches("cq-toggle[member=tfc], cq-toggle[cq-member=tfc]"));function e(i,o){return i.split(/, |,/g).reduce((s,a)=>{const c=o.querySelector(a);if(!c)return s;const l=Array.from(c.querySelectorAll("*"));return s.concat(l)},[])}}utils(t){t.getChartContainers=()=>Array.from(t.querySelectorAll("cq-context")).map(e=>e.querySelector(".chartContainer")).concat(t.CIQ.UI.context.stx.container),t.getCharts=()=>t.getChartContainers().map(({stx:e})=>e)}}r.UI.Multichart=V;r.UI.setDefaultStates=function(n){const t=n.config.ariaActive;if(t===null)return;t&&t.length?t.forEach(i=>{let o=n.topNode.querySelector(i);o&&e(o)}):n.topNode.ariaHidden="true";function e(i){const o=i.parentElement;o&&([...o.children].forEach(s=>{s.ariaHidden=i!==s&&s.ariaHidden!=="false"}),!(o.ariaHidden==="false"||o.matches("cq-context"))&&e(o))}};class T{constructor(t,e){e!==void 0&&console.log("CIQ.UI.$() only accepts one input parameter.");let i=[];if(t instanceof T)return t;Array.isArray(t)&&(i=t),typeof t=="object"?t.ownerDocument?i.push(t):(t.toString()==="[object NodeList]"||t.toString()==="[object HTMLCollection]")&&(i=Array.from(t)):typeof t=="string"&&(console.log("Note: string argument for CIQ.UI.$(element) deprecated and may be removed in the future"),i=i=Array.from(document.querySelectorAll(t)));const o=this.length=i.length;for(let s=0;s<o;s++)this[s]=i[s]}_(t,e){const i=[],o=s=>{(!e||s.matches(e))&&(i.includes(s)||i.push(s))};for(let s=0;s<this.length;s++){const a=this[s];Array.from(t(a)).forEach(o)}return new T(i)}addClass(t){return typeof t=="string"&&(t=t.split(" ")),t.forEach(e=>this._(i=>(i.classList.add(e),[i]))),this}append(t,e){if(typeof e<"u"&&console.log("CIQ.UI.$#append only accepts one argument."),t instanceof Array)for(let i=0;i<t.length;i++)this.append(t[i]);else{if(typeof t=="string")return this._(i=>(t[0]==="<"?r.safeAssign(i,t,"html","beforeend"):i.innerText+=t,[i]));if(t.ownerDocument){const i=this._(s=>(s.appendChild(t.cloneNode(!0)),[s])),o=i[i.length-1];return o.replaceChild(t,o.lastChild),i}else if(t[0])return this.append(Array.from(t))}return this}attr(t,e){if(typeof t=="object")return this._(i=>(Object.keys(t).forEach(o=>i.setAttribute(o,t[o])),[i]));if(typeof e>"u"){if(!this[0])return;const i=this[0].getAttribute(t);return i===null?void 0:i}return this._(i=>(i.setAttribute(t,e),[i]))}children(t){return this._(e=>e.children,t)}css(t,e){return typeof t=="object"?this._(i=>(Object.assign(i.style,t),[i])):typeof e>"u"?this[0]?getComputedStyle(this[0])[t]:void 0:this._(i=>(i.style[t]=e,[i]))}each(t){for(let e=0;e<this.length;e++)t.call(this[e],e,this[e]);return this}empty(){return this._(t=>(t.textContent="",[t]))}find(t){return t?this._(e=>e.querySelectorAll(t)):new T([])}hasClass(t){return this._(e=>e.classList.contains(t)&&[e]).length>0}hide(){return this._(t=>(t.style.display!=="none"&&(t.style.displayCache=t.style.display,t.style.display="none"),[t]))}html(t){return this.prop("innerHTML",t)}nextAll(t){return this._(e=>{const i=Array.from(e.parentNode.children);return i.slice(i.indexOf(e)+1)},t)}not(t){return this._(e=>!e.matches(t)&&[e])}parent(t){return this._(e=>[e.parentNode],t)}parents(t){return this._(e=>r.climbUpDomTree(e.parentElement,t)||[])}prop(t,e){return typeof t=="object"?this._(i=>(Object.keys(t).forEach(o=>
1i[o]=t[o]),[i])):typeof e>"u"?this[0]?this[0][t]:void 0:this._(i=>(i[t]=e,[i]))}remove(t){return Array.from(this).forEach(e=>{(!t||e.matches(t))&&e.parentNode.removeChild(e)}),this}removeAttr(t){return typeof t=="string"&&(t=t.split(" ")),t.forEach(e=>this._(i=>(i.removeAttribute(e),[i]))),this}removeClass(t){return typeof t=="string"&&(t=t.split(" ")),t?t.forEach(e=>this._(i=>(i.classList.remove(e),[i]))):this._(e=>(e.className="",[e])),this}show(){return this._(t=>(t.style.display==="none"&&(t.style.displayCache===void 0?t.style.display="block":(t.style.display=t.style.displayCache,t.style.displayCache=void 0)),[t]))}text(t){return this.prop("innerText",t)}val(t){return this.prop("value",t)}}r.UI.$=function(n,t){return!t&&typeof $=="function"&&$.fn?(P||(console.log("Using jQuery."),P=!0),$(n)):new T(n)};let P=!1;class _{constructor(t,e){this.pluginName=e,this.params=t,this.addToDom(),this.subscribe()}addToDom(){const{params:t,pluginName:e}=this,{topNode:i,topNode:{multiChartContainer:o}}=t.context,s=o||i;if(!s.querySelector(`div.${e}-container`)){const a=document.createElement("div");a.classList.add("ciq-"+e,t.location),a.setAttribute("disabled","");let c=t.location==="right"?s.querySelector("cq-side-panel"):s.querySelector(".cq-plugin-container");!c&&t.location!=="right"&&(c=r.UI.Chart.prototype.addPluginContainer(t.context)),c.appendChild(a),this.node=a}if(typeof t.container=="string"&&(t.container=s.querySelector(t.container)),t.container&&!t.container.querySelector(`[member=${e}]`)){const a=document.createElement("div");r.safeAssign(a,t.toggleMarkup),[...a.childNodes].map(c=>t.container.appendChild(c.cloneNode(!0)))}}subscribe(){const{params:t,pluginName:e}=this,{config:i}=t.context;i&&!i.channels[e]&&(i.channels[e]=`channel.${e}`);const o=(i.channels||{})[e]||`channel.${e}`;this.activationSubscription=b.prototype.channelSubscribe(o,s=>{this.node&&(s?(this.render&&this.render(),this.node.removeAttribute("disabled")):(this.node.setAttribute("disabled",""),this.unrender&&this.unrender()))},t.context.stx)}}r.UI.SidePanelPlugin=_;export{r as CIQ};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.