1 line
3.0 KiB
JavaScript
1 line
3.0 KiB
JavaScript
"use strict";(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[1102],{14683:(e,t,o)=>{o.r(t),o.d(t,{CustomThemesApi:()=>c});var r=o(26028),n=o(43763);class c{async applyCustomThemes(e){const t=(0,n.getChartingLibraryGlobalContext)(),o=t.tradingViewApi.themes().getCurrentThemeName();(0,r.overrideStandardThemes)(e),await t.tradingViewApi.themes().setStdTheme(o,void 0,!0)}async resetCustomThemes(){const e=(0,n.getChartingLibraryGlobalContext)(),t=e.tradingViewApi.themes().getCurrentThemeName();(0,r.restoreStandardThemes)(),await e.tradingViewApi.themes().setStdTheme(t,void 0,!0)}}},26028:(e,t,o)=>{o.d(t,{overrideStandardThemes:()=>h,restoreStandardThemes:()=>g});var r=o(22872),n=o(28507),c=o(40520),a=o(47097),i=o(30614);const s={};for(const[e,t]of Object.entries(i))s[t]=e;function l(e,t){const o=s[e];if(void 0!==o)return function(e,t){const o=/([a-z]+[\-a-z+]+-[a-z]+)-?([0-9]+)?/.exec(e);if(null===o)return;const r=o[1],n=parseInt(o[2])/50-1;switch(r){case"color-tv-blue":return t.color1[n];case"color-cold-gray":return t.color2[n];case"color-ripe-red":return t.color3[n];case"color-minty-green":return t.color4[n];case"color-tan-orange":return t.color5[n];case"color-grapes-purple":return t.color6[n];case"color-banana-yellow":return t.color7[n];case"color-white":return t.white;case"color-black":return t.black}}(o,t)}var d=o(43763);const u="theme-custom",m="custom-theme-styles";function h(e){p(a.StdTheme.Light,e[a.StdTheme.Light]),p(a.StdTheme.Dark,e[a.StdTheme.Dark]),window.requestAnimationFrame((()=>{!function(){const e=window.document.documentElement.classList;e.contains(u)||e.add(u)}(),function(e){const t=function(){const e=(0,d.getChartingLibraryGlobalContext)().document;let t=e.getElementById(m);t||(t=function(){const e=(0,d.getChartingLibraryGlobalContext)(),t=e.document,o=t.createElement("style");o.id=m,void 0!==e.cspNonce&&o.setAttribute("nonce",e.cspNonce);return o}(),e.head.appendChild(t));return t}(),o=[f(":root",a.StdTheme.Light,e[a.StdTheme.Light]),f(".theme-dark:root",a.StdTheme.Dark,e[a.StdTheme.Dark])].join("\n\n");t.textContent=o}(e)}))}function g(){(0,n.restoreStdThemes)(),window.requestAnimationFrame((()=>{!function(){const e=(0,d.getChartingLibraryGlobalContext)().document.getElementById(m);e&&e.remove()}(),window.document.documentElement.classList.remove(u)}))}const b={color1:"tv-blue",color2:"cold-gray",color3:"ripe-red",color4:"minty-green",color5:"tan-orange",color6:"grapes-purple",color7:"banana-yellow",black:"black",white:"white"};function f(e,t,o){const r=[];for(const[e,t]of Object.entries(o)){const n=b[e];if(Array.isArray(t))for(let t=0;t<o[e].length;t++)r.push(`--color-${n}-${50*(t+1)}: ${o[e][t]};`);else r.push(`--color-${n}: ${o[e]};`)}return`${e} {\n${r.sort().join("\n")}\n}`}function p(e,t){const o=(0,c.getStdTheme)(e);(0,n.overrideStdTheme)(e,function e(o){for(const[n,c]of Object.entries(o))if((0,r.isObject)(c))e(c);else if("string"==typeof c){let e=l(c,t);"backgroundGradientStartColor"===n&&(e=l(o.backgroundGradientEndColor,t)),void 0!==e&&(o[n]=e)}return o}(o))}}}]); |