@363045841yyt/klinechart 0.6.3 → 0.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(e&&(t=e(e=0)),t),s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),c=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},l=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},u=(n,r,a)=>(a=n==null?{}:e(i(n)),l(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)),d=e=>a.call(e,`module.exports`)?e[`module.exports`]:l(t({},`__esModule`,{value:!0}),e);let f=require(`vue`);var p=class{listeners=new Map;on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}off(e,t){let n=this.listeners.get(e);n&&n.delete(t)}emit(e,t){let n=this.listeners.get(e);n&&n.forEach(n=>{try{n(t)}catch(t){console.error(`[EventBus] Error in handler for "${e}":`,t)}})}once(e,t){let n=r=>{this.off(e,n),t(r)};this.on(e,n)}clear(){this.listeners.clear()}listenerCount(e){return this.listeners.get(e)?.size??0}};function m(e,t){return function(){return e.apply(t,arguments)}}var{toString:h}=Object.prototype,{getPrototypeOf:g}=Object,{iterator:_,toStringTag:v}=Symbol,y=(e=>t=>{let n=h.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),b=e=>(e=e.toLowerCase(),t=>y(t)===e),x=e=>t=>typeof t===e,{isArray:S}=Array,C=x(`undefined`);function w(e){return e!==null&&!C(e)&&e.constructor!==null&&!C(e.constructor)&&O(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var T=b(`ArrayBuffer`);function E(e){let t;return t=typeof ArrayBuffer<`u`&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&T(e.buffer),t}var D=x(`string`),O=x(`function`),k=x(`number`),A=e=>typeof e==`object`&&!!e,j=e=>e===!0||e===!1,M=e=>{if(y(e)!==`object`)return!1;let t=g(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(v in e)&&!(_ in e)},N=e=>{if(!A(e)||w(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},ee=b(`Date`),P=b(`File`),F=e=>!!(e&&e.uri!==void 0),te=e=>e&&e.getParts!==void 0,ne=b(`Blob`),re=b(`FileList`),ie=e=>A(e)&&O(e.pipe);function ae(){return typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{}}var oe=ae(),se=oe.FormData===void 0?void 0:oe.FormData,ce=e=>{if(!e)return!1;if(se&&e instanceof se)return!0;let t=g(e);if(!t||t===Object.prototype||!O(e.append))return!1;let n=y(e);return n===`formdata`||n===`object`&&O(e.toString)&&e.toString()===`[object FormData]`},le=b(`URLSearchParams`),[ue,de,fe,pe]=[`ReadableStream`,`Request`,`Response`,`Headers`].map(b),me=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,``);function he(e,t,{allOwnKeys:n=!1}={}){if(e==null)return;let r,i;if(typeof e!=`object`&&(e=[e]),S(e))for(r=0,i=e.length;r<i;r++)t.call(null,e[r],r,e);else{if(w(e))return;let i=n?Object.getOwnPropertyNames(e):Object.keys(e),a=i.length,o;for(r=0;r<a;r++)o=i[r],t.call(null,e[o],o,e)}}function ge(e,t){if(w(e))return null;t=t.toLowerCase();let n=Object.keys(e),r=n.length,i;for(;r-- >0;)if(i=n[r],t===i.toLowerCase())return i;return null}var _e=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:global,ve=e=>!C(e)&&e!==_e;function ye(...e){let{caseless:t,skipUndefined:n}=ve(this)&&this||{},r={},i=(e,i)=>{if(i===`__proto__`||i===`constructor`||i===`prototype`)return;let a=t&&ge(r,i)||i,o=I(r,a)?r[a]:void 0;M(o)&&M(e)?r[a]=ye(o,e):M(e)?r[a]=ye({},e):S(e)?r[a]=e.slice():(!n||!C(e))&&(r[a]=e)};for(let t=0,n=e.length;t<n;t++)e[t]&&he(e[t],i);return r}var be=(e,t,n,{allOwnKeys:r}={})=>(he(t,(t,r)=>{n&&O(t)?Object.defineProperty(e,r,{__proto__:null,value:m(t,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,r,{__proto__:null,value:t,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),e),xe=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Se=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),Object.defineProperty(e.prototype,`constructor`,{__proto__:null,value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,`super`,{__proto__:null,value:t.prototype}),n&&Object.assign(e.prototype,n)},Ce=(e,t,n,r)=>{let i,a,o,s={};if(t||={},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)o=i[a],(!r||r(o,e,t))&&!s[o]&&(t[o]=e[o],s[o]=!0);e=n!==!1&&g(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},we=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;let r=e.indexOf(t,n);return r!==-1&&r===n},Te=e=>{if(!e)return null;if(S(e))return e;let t=e.length;if(!k(t))return null;let n=Array(t);for(;t-- >0;)n[t]=e[t];return n},Ee=(e=>t=>e&&t instanceof e)(typeof Uint8Array<`u`&&g(Uint8Array)),De=(e,t)=>{let n=(e&&e[_]).call(e),r;for(;(r=n.next())&&!r.done;){let n=r.value;t.call(e,n[0],n[1])}},Oe=(e,t)=>{let n,r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},ke=b(`HTMLFormElement`),Ae=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),I=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),je=b(`RegExp`),L=(e,t)=>{let n=Object.getOwnPropertyDescriptors(e),r={};he(n,(n,i)=>{let a;(a=t(n,i,e))!==!1&&(r[i]=a||n)}),Object.defineProperties(e,r)},Me=e=>{L(e,(t,n)=>{if(O(e)&&[`arguments`,`caller`,`callee`].includes(n))return!1;let r=e[n];if(O(r)){if(t.enumerable=!1,`writable`in t){t.writable=!1;return}t.set||=()=>{throw Error(`Can not rewrite read-only method '`+n+`'`)}}})},Ne=(e,t)=>{let n={},r=e=>{e.forEach(e=>{n[e]=!0})};return S(e)?r(e):r(String(e).split(t)),n},Pe=()=>{},Fe=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Ie(e){return!!(e&&O(e.append)&&e[v]===`FormData`&&e[_])}var Le=e=>{let t=Array(10),n=(e,r)=>{if(A(e)){if(t.indexOf(e)>=0)return;if(w(e))return e;if(!(`toJSON`in e)){t[r]=e;let i=S(e)?[]:{};return he(e,(e,t)=>{let a=n(e,r+1);!C(a)&&(i[t]=a)}),t[r]=void 0,i}}return e};return n(e,0)},Re=b(`AsyncFunction`),ze=e=>e&&(A(e)||O(e))&&O(e.then)&&O(e.catch),Be=((e,t)=>e?setImmediate:t?((e,t)=>(_e.addEventListener(`message`,({source:n,data:r})=>{n===_e&&r===e&&t.length&&t.shift()()},!1),n=>{t.push(n),_e.postMessage(e,`*`)}))(`axios@${Math.random()}`,[]):e=>setTimeout(e))(typeof setImmediate==`function`,O(_e.postMessage)),R={isArray:S,isArrayBuffer:T,isBuffer:w,isFormData:ce,isArrayBufferView:E,isString:D,isNumber:k,isBoolean:j,isObject:A,isPlainObject:M,isEmptyObject:N,isReadableStream:ue,isRequest:de,isResponse:fe,isHeaders:pe,isUndefined:C,isDate:ee,isFile:P,isReactNativeBlob:F,isReactNative:te,isBlob:ne,isRegExp:je,isFunction:O,isStream:ie,isURLSearchParams:le,isTypedArray:Ee,isFileList:re,forEach:he,merge:ye,extend:be,trim:me,stripBOM:xe,inherits:Se,toFlatObject:Ce,kindOf:y,kindOfTest:b,endsWith:we,toArray:Te,forEachEntry:De,matchAll:Oe,isHTMLForm:ke,hasOwnProperty:I,hasOwnProp:I,reduceDescriptors:L,freezeMethods:Me,toObjectSet:Ne,toCamelCase:Ae,noop:Pe,toFiniteNumber:Fe,findKey:ge,global:_e,isContextDefined:ve,isSpecCompliantForm:Ie,toJSONObject:Le,isAsyncFn:Re,isThenable:ze,setImmediate:Be,asap:typeof queueMicrotask<`u`?queueMicrotask.bind(_e):typeof process<`u`&&process.nextTick||Be,isIterable:e=>e!=null&&O(e[_])},Ve=R.toObjectSet([`age`,`authorization`,`content-length`,`content-type`,`etag`,`expires`,`from`,`host`,`if-modified-since`,`if-unmodified-since`,`last-modified`,`location`,`max-forwards`,`proxy-authorization`,`referer`,`retry-after`,`user-agent`]),He=e=>{let t={},n,r,i;return e&&e.split(`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(e&&(t=e(e=0)),t),s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),c=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},l=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},u=(n,r,a)=>(a=n==null?{}:e(i(n)),l(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)),d=e=>a.call(e,`module.exports`)?e[`module.exports`]:l(t({},`__esModule`,{value:!0}),e);let f=require(`vue`);var p=class{listeners=new Map;on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}off(e,t){let n=this.listeners.get(e);n&&n.delete(t)}emit(e,t){let n=this.listeners.get(e);n&&n.forEach(n=>{try{n(t)}catch(t){console.error(`[EventBus] Error in handler for "${e}":`,t)}})}once(e,t){let n=r=>{this.off(e,n),t(r)};this.on(e,n)}clear(){this.listeners.clear()}listenerCount(e){return this.listeners.get(e)?.size??0}};function m(e,t){return function(){return e.apply(t,arguments)}}var{toString:h}=Object.prototype,{getPrototypeOf:g}=Object,{iterator:_,toStringTag:v}=Symbol,y=(e=>t=>{let n=h.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),b=e=>(e=e.toLowerCase(),t=>y(t)===e),x=e=>t=>typeof t===e,{isArray:S}=Array,C=x(`undefined`);function w(e){return e!==null&&!C(e)&&e.constructor!==null&&!C(e.constructor)&&O(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var T=b(`ArrayBuffer`);function E(e){let t;return t=typeof ArrayBuffer<`u`&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&T(e.buffer),t}var D=x(`string`),O=x(`function`),k=x(`number`),A=e=>typeof e==`object`&&!!e,j=e=>e===!0||e===!1,M=e=>{if(y(e)!==`object`)return!1;let t=g(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(v in e)&&!(_ in e)},N=e=>{if(!A(e)||w(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},ee=b(`Date`),te=b(`File`),P=e=>!!(e&&e.uri!==void 0),ne=e=>e&&e.getParts!==void 0,re=b(`Blob`),ie=b(`FileList`),ae=e=>A(e)&&O(e.pipe);function oe(){return typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{}}var se=oe(),ce=se.FormData===void 0?void 0:se.FormData,le=e=>{if(!e)return!1;if(ce&&e instanceof ce)return!0;let t=g(e);if(!t||t===Object.prototype||!O(e.append))return!1;let n=y(e);return n===`formdata`||n===`object`&&O(e.toString)&&e.toString()===`[object FormData]`},ue=b(`URLSearchParams`),[de,fe,pe,me]=[`ReadableStream`,`Request`,`Response`,`Headers`].map(b),he=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,``);function ge(e,t,{allOwnKeys:n=!1}={}){if(e==null)return;let r,i;if(typeof e!=`object`&&(e=[e]),S(e))for(r=0,i=e.length;r<i;r++)t.call(null,e[r],r,e);else{if(w(e))return;let i=n?Object.getOwnPropertyNames(e):Object.keys(e),a=i.length,o;for(r=0;r<a;r++)o=i[r],t.call(null,e[o],o,e)}}function _e(e,t){if(w(e))return null;t=t.toLowerCase();let n=Object.keys(e),r=n.length,i;for(;r-- >0;)if(i=n[r],t===i.toLowerCase())return i;return null}var ve=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:global,ye=e=>!C(e)&&e!==ve;function be(...e){let{caseless:t,skipUndefined:n}=ye(this)&&this||{},r={},i=(e,i)=>{if(i===`__proto__`||i===`constructor`||i===`prototype`)return;let a=t&&_e(r,i)||i,o=F(r,a)?r[a]:void 0;M(o)&&M(e)?r[a]=be(o,e):M(e)?r[a]=be({},e):S(e)?r[a]=e.slice():(!n||!C(e))&&(r[a]=e)};for(let t=0,n=e.length;t<n;t++)e[t]&&ge(e[t],i);return r}var xe=(e,t,n,{allOwnKeys:r}={})=>(ge(t,(t,r)=>{n&&O(t)?Object.defineProperty(e,r,{__proto__:null,value:m(t,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,r,{__proto__:null,value:t,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),e),Se=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Ce=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),Object.defineProperty(e.prototype,`constructor`,{__proto__:null,value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,`super`,{__proto__:null,value:t.prototype}),n&&Object.assign(e.prototype,n)},we=(e,t,n,r)=>{let i,a,o,s={};if(t||={},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)o=i[a],(!r||r(o,e,t))&&!s[o]&&(t[o]=e[o],s[o]=!0);e=n!==!1&&g(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Te=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;let r=e.indexOf(t,n);return r!==-1&&r===n},Ee=e=>{if(!e)return null;if(S(e))return e;let t=e.length;if(!k(t))return null;let n=Array(t);for(;t-- >0;)n[t]=e[t];return n},De=(e=>t=>e&&t instanceof e)(typeof Uint8Array<`u`&&g(Uint8Array)),Oe=(e,t)=>{let n=(e&&e[_]).call(e),r;for(;(r=n.next())&&!r.done;){let n=r.value;t.call(e,n[0],n[1])}},ke=(e,t)=>{let n,r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Ae=b(`HTMLFormElement`),je=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),F=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Me=b(`RegExp`),I=(e,t)=>{let n=Object.getOwnPropertyDescriptors(e),r={};ge(n,(n,i)=>{let a;(a=t(n,i,e))!==!1&&(r[i]=a||n)}),Object.defineProperties(e,r)},Ne=e=>{I(e,(t,n)=>{if(O(e)&&[`arguments`,`caller`,`callee`].includes(n))return!1;let r=e[n];if(O(r)){if(t.enumerable=!1,`writable`in t){t.writable=!1;return}t.set||=()=>{throw Error(`Can not rewrite read-only method '`+n+`'`)}}})},Pe=(e,t)=>{let n={},r=e=>{e.forEach(e=>{n[e]=!0})};return S(e)?r(e):r(String(e).split(t)),n},Fe=()=>{},L=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Ie(e){return!!(e&&O(e.append)&&e[v]===`FormData`&&e[_])}var Le=e=>{let t=Array(10),n=(e,r)=>{if(A(e)){if(t.indexOf(e)>=0)return;if(w(e))return e;if(!(`toJSON`in e)){t[r]=e;let i=S(e)?[]:{};return ge(e,(e,t)=>{let a=n(e,r+1);!C(a)&&(i[t]=a)}),t[r]=void 0,i}}return e};return n(e,0)},Re=b(`AsyncFunction`),ze=e=>e&&(A(e)||O(e))&&O(e.then)&&O(e.catch),Be=((e,t)=>e?setImmediate:t?((e,t)=>(ve.addEventListener(`message`,({source:n,data:r})=>{n===ve&&r===e&&t.length&&t.shift()()},!1),n=>{t.push(n),ve.postMessage(e,`*`)}))(`axios@${Math.random()}`,[]):e=>setTimeout(e))(typeof setImmediate==`function`,O(ve.postMessage)),R={isArray:S,isArrayBuffer:T,isBuffer:w,isFormData:le,isArrayBufferView:E,isString:D,isNumber:k,isBoolean:j,isObject:A,isPlainObject:M,isEmptyObject:N,isReadableStream:de,isRequest:fe,isResponse:pe,isHeaders:me,isUndefined:C,isDate:ee,isFile:te,isReactNativeBlob:P,isReactNative:ne,isBlob:re,isRegExp:Me,isFunction:O,isStream:ae,isURLSearchParams:ue,isTypedArray:De,isFileList:ie,forEach:ge,merge:be,extend:xe,trim:he,stripBOM:Se,inherits:Ce,toFlatObject:we,kindOf:y,kindOfTest:b,endsWith:Te,toArray:Ee,forEachEntry:Oe,matchAll:ke,isHTMLForm:Ae,hasOwnProperty:F,hasOwnProp:F,reduceDescriptors:I,freezeMethods:Ne,toObjectSet:Pe,toCamelCase:je,noop:Fe,toFiniteNumber:L,findKey:_e,global:ve,isContextDefined:ye,isSpecCompliantForm:Ie,toJSONObject:Le,isAsyncFn:Re,isThenable:ze,setImmediate:Be,asap:typeof queueMicrotask<`u`?queueMicrotask.bind(ve):typeof process<`u`&&process.nextTick||Be,isIterable:e=>e!=null&&O(e[_])},Ve=R.toObjectSet([`age`,`authorization`,`content-length`,`content-type`,`etag`,`expires`,`from`,`host`,`if-modified-since`,`if-unmodified-since`,`last-modified`,`location`,`max-forwards`,`proxy-authorization`,`referer`,`retry-after`,`user-agent`]),He=e=>{let t={},n,r,i;return e&&e.split(`
2
2
  `).forEach(function(e){i=e.indexOf(`:`),n=e.substring(0,i).trim().toLowerCase(),r=e.substring(i+1).trim(),!(!n||t[n]&&Ve[n])&&(n===`set-cookie`?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+`, `+r:r)}),t},Ue=Symbol(`internals`),We=/[^\x09\x20-\x7E\x80-\xFF]/g;function Ge(e){let t=0,n=e.length;for(;t<n;){let n=e.charCodeAt(t);if(n!==9&&n!==32)break;t+=1}for(;n>t;){let t=e.charCodeAt(n-1);if(t!==9&&t!==32)break;--n}return t===0&&n===e.length?e:e.slice(t,n)}function Ke(e){return e&&String(e).trim().toLowerCase()}function qe(e){return Ge(e.replace(We,``))}function Je(e){return e===!1||e==null?e:R.isArray(e)?e.map(Je):qe(String(e))}function Ye(e){let t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}var Xe=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ze(e,t,n,r,i){if(R.isFunction(r))return r.call(this,t,n);if(i&&(t=n),R.isString(t)){if(R.isString(r))return t.indexOf(r)!==-1;if(R.isRegExp(r))return r.test(t)}}function Qe(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}function $e(e,t){let n=R.toCamelCase(` `+t);[`get`,`set`,`has`].forEach(r=>{Object.defineProperty(e,r+n,{__proto__:null,value:function(e,n,i){return this[r].call(this,t,e,n,i)},configurable:!0})})}var z=class{constructor(e){e&&this.set(e)}set(e,t,n){let r=this;function i(e,t,n){let i=Ke(t);if(!i)throw Error(`header name must be a non-empty string`);let a=R.findKey(r,i);(!a||r[a]===void 0||n===!0||n===void 0&&r[a]!==!1)&&(r[a||t]=Je(e))}let a=(e,t)=>R.forEach(e,(e,n)=>i(e,n,t));if(R.isPlainObject(e)||e instanceof this.constructor)a(e,t);else if(R.isString(e)&&(e=e.trim())&&!Xe(e))a(He(e),t);else if(R.isObject(e)&&R.isIterable(e)){let n={},r,i;for(let t of e){if(!R.isArray(t))throw TypeError(`Object iterator must return a key-value pair`);n[i=t[0]]=(r=n[i])?R.isArray(r)?[...r,t[1]]:[r,t[1]]:t[1]}a(n,t)}else e!=null&&i(t,e,n);return this}get(e,t){if(e=Ke(e),e){let n=R.findKey(this,e);if(n){let e=this[n];if(!t)return e;if(t===!0)return Ye(e);if(R.isFunction(t))return t.call(this,e,n);if(R.isRegExp(t))return t.exec(e);throw TypeError(`parser must be boolean|regexp|function`)}}}has(e,t){if(e=Ke(e),e){let n=R.findKey(this,e);return!!(n&&this[n]!==void 0&&(!t||Ze(this,this[n],n,t)))}return!1}delete(e,t){let n=this,r=!1;function i(e){if(e=Ke(e),e){let i=R.findKey(n,e);i&&(!t||Ze(n,n[i],i,t))&&(delete n[i],r=!0)}}return R.isArray(e)?e.forEach(i):i(e),r}clear(e){let t=Object.keys(this),n=t.length,r=!1;for(;n--;){let i=t[n];(!e||Ze(this,this[i],i,e,!0))&&(delete this[i],r=!0)}return r}normalize(e){let t=this,n={};return R.forEach(this,(r,i)=>{let a=R.findKey(n,i);if(a){t[a]=Je(r),delete t[i];return}let o=e?Qe(i):String(i).trim();o!==i&&delete t[i],t[o]=Je(r),n[o]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){let t=Object.create(null);return R.forEach(this,(n,r)=>{n!=null&&n!==!1&&(t[r]=e&&R.isArray(n)?n.join(`, `):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+`: `+t).join(`
3
3
  `)}getSetCookie(){return this.get(`set-cookie`)||[]}get[Symbol.toStringTag](){return`AxiosHeaders`}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){let n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){let t=(this[Ue]=this[Ue]={accessors:{}}).accessors,n=this.prototype;function r(e){let r=Ke(e);t[r]||($e(n,e),t[r]=!0)}return R.isArray(e)?e.forEach(r):r(e),this}};z.accessor([`Content-Type`,`Content-Length`,`Accept`,`Accept-Encoding`,`User-Agent`,`Authorization`]),R.reduceDescriptors(z.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),R.freezeMethods(z);var et=`[REDACTED ****]`;function tt(e){if(R.hasOwnProp(e,`toJSON`))return!0;let t=Object.getPrototypeOf(e);for(;t&&t!==Object.prototype;){if(R.hasOwnProp(t,`toJSON`))return!0;t=Object.getPrototypeOf(t)}return!1}function nt(e,t){let n=new Set(t.map(e=>String(e).toLowerCase())),r=[],i=e=>{if(typeof e!=`object`||!e||R.isBuffer(e))return e;if(r.indexOf(e)!==-1)return;e instanceof z&&(e=e.toJSON()),r.push(e);let t;if(R.isArray(e))t=[],e.forEach((e,n)=>{let r=i(e);R.isUndefined(r)||(t[n]=r)});else{if(!R.isPlainObject(e)&&tt(e))return r.pop(),e;t=Object.create(null);for(let[r,a]of Object.entries(e)){let e=n.has(r.toLowerCase())?et:i(a);R.isUndefined(e)||(t[r]=e)}}return r.pop(),t};return i(e)}var B=class e extends Error{static from(t,n,r,i,a,o){let s=new e(t.message,n||t.code,r,i,a);return s.cause=t,s.name=t.name,t.status!=null&&s.status==null&&(s.status=t.status),o&&Object.assign(s,o),s}constructor(e,t,n,r,i){super(e),Object.defineProperty(this,`message`,{__proto__:null,value:e,enumerable:!0,writable:!0,configurable:!0}),this.name=`AxiosError`,this.isAxiosError=!0,t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status)}toJSON(){let e=this.config,t=e&&R.hasOwnProp(e,`redact`)?e.redact:void 0,n=R.isArray(t)&&t.length>0?nt(e,t):R.toJSONObject(e);return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:n,code:this.code,status:this.status}}};B.ERR_BAD_OPTION_VALUE=`ERR_BAD_OPTION_VALUE`,B.ERR_BAD_OPTION=`ERR_BAD_OPTION`,B.ECONNABORTED=`ECONNABORTED`,B.ETIMEDOUT=`ETIMEDOUT`,B.ECONNREFUSED=`ECONNREFUSED`,B.ERR_NETWORK=`ERR_NETWORK`,B.ERR_FR_TOO_MANY_REDIRECTS=`ERR_FR_TOO_MANY_REDIRECTS`,B.ERR_DEPRECATED=`ERR_DEPRECATED`,B.ERR_BAD_RESPONSE=`ERR_BAD_RESPONSE`,B.ERR_BAD_REQUEST=`ERR_BAD_REQUEST`,B.ERR_CANCELED=`ERR_CANCELED`,B.ERR_NOT_SUPPORT=`ERR_NOT_SUPPORT`,B.ERR_INVALID_URL=`ERR_INVALID_URL`,B.ERR_FORM_DATA_DEPTH_EXCEEDED=`ERR_FORM_DATA_DEPTH_EXCEEDED`;function rt(e){return R.isPlainObject(e)||R.isArray(e)}function it(e){return R.endsWith(e,`[]`)?e.slice(0,-2):e}function at(e,t,n){return e?e.concat(t).map(function(e,t){return e=it(e),!n&&t?`[`+e+`]`:e}).join(n?`.`:``):t}function ot(e){return R.isArray(e)&&!e.some(rt)}var st=R.toFlatObject(R,{},null,function(e){return/^is[A-Z]/.test(e)});function ct(e,t,n){if(!R.isObject(e))throw TypeError(`target must be an object`);t||=new FormData,n=R.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!R.isUndefined(t[e])});let r=n.metaTokens,i=n.visitor||d,a=n.dots,o=n.indexes,s=n.Blob||typeof Blob<`u`&&Blob,c=n.maxDepth===void 0?100:n.maxDepth,l=s&&R.isSpecCompliantForm(t);if(!R.isFunction(i))throw TypeError(`visitor must be a function`);function u(e){if(e===null)return``;if(R.isDate(e))return e.toISOString();if(R.isBoolean(e))return e.toString();if(!l&&R.isBlob(e))throw new B(`Blob is not supported. Use a Buffer instead.`);return R.isArrayBuffer(e)||R.isTypedArray(e)?l&&typeof Blob==`function`?new Blob([e]):Buffer.from(e):e}function d(e,n,i){let s=e;if(R.isReactNative(t)&&R.isReactNativeBlob(e))return t.append(at(i,n,a),u(e)),!1;if(e&&!i&&typeof e==`object`){if(R.endsWith(n,`{}`))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(R.isArray(e)&&ot(e)||(R.isFileList(e)||R.endsWith(n,`[]`))&&(s=R.toArray(e)))return n=it(n),s.forEach(function(e,r){!(R.isUndefined(e)||e===null)&&t.append(o===!0?at([n],r,a):o===null?n:n+`[]`,u(e))}),!1}return rt(e)?!0:(t.append(at(i,n,a),u(e)),!1)}let f=[],p=Object.assign(st,{defaultVisitor:d,convertValue:u,isVisitable:rt});function m(e,n,r=0){if(!R.isUndefined(e)){if(r>c)throw new B(`Object is too deeply nested (`+r+` levels). Max depth: `+c,B.ERR_FORM_DATA_DEPTH_EXCEEDED);if(f.indexOf(e)!==-1)throw Error(`Circular reference detected in `+n.join(`.`));f.push(e),R.forEach(e,function(e,a){(!(R.isUndefined(e)||e===null)&&i.call(t,e,R.isString(a)?a.trim():a,n,p))===!0&&m(e,n?n.concat(a):[a],r+1)}),f.pop()}}if(!R.isObject(e))throw TypeError(`data must be an object`);return m(e),t}function lt(e){let t={"!":`%21`,"'":`%27`,"(":`%28`,")":`%29`,"~":`%7E`,"%20":`+`};return encodeURIComponent(e).replace(/[!'()~]|%20/g,function(e){return t[e]})}function ut(e,t){this._pairs=[],e&&ct(e,this,t)}var dt=ut.prototype;dt.append=function(e,t){this._pairs.push([e,t])},dt.toString=function(e){let t=e?function(t){return e.call(this,t,lt)}:lt;return this._pairs.map(function(e){return t(e[0])+`=`+t(e[1])},``).join(`&`)};function ft(e){return encodeURIComponent(e).replace(/%3A/gi,`:`).replace(/%24/g,`$`).replace(/%2C/gi,`,`).replace(/%20/g,`+`)}function pt(e,t,n){if(!t)return e;let r=n&&n.encode||ft,i=R.isFunction(n)?{serialize:n}:n,a=i&&i.serialize,o;if(o=a?a(t,i):R.isURLSearchParams(t)?t.toString():new ut(t,i).toString(r),o){let t=e.indexOf(`#`);t!==-1&&(e=e.slice(0,t)),e+=(e.indexOf(`?`)===-1?`?`:`&`)+o}return e}var mt=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&=[]}forEach(e){R.forEach(this.handlers,function(t){t!==null&&e(t)})}},ht={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},gt={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<`u`?URLSearchParams:ut,FormData:typeof FormData<`u`?FormData:null,Blob:typeof Blob<`u`?Blob:null},protocols:[`http`,`https`,`file`,`blob`,`url`,`data`]},_t=c({hasBrowserEnv:()=>vt,hasStandardBrowserEnv:()=>bt,hasStandardBrowserWebWorkerEnv:()=>xt,navigator:()=>yt,origin:()=>St}),vt=typeof window<`u`&&typeof document<`u`,yt=typeof navigator==`object`&&navigator||void 0,bt=vt&&(!yt||[`ReactNative`,`NativeScript`,`NS`].indexOf(yt.product)<0),xt=typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope&&typeof self.importScripts==`function`,St=vt&&window.location.href||`http://localhost`,V={..._t,...gt};function Ct(e,t){return ct(e,new V.classes.URLSearchParams,{visitor:function(e,t,n,r){return V.isNode&&R.isBuffer(e)?(this.append(t,e.toString(`base64`)),!1):r.defaultVisitor.apply(this,arguments)},...t})}function wt(e){return R.matchAll(/\w+|\[(\w*)]/g,e).map(e=>e[0]===`[]`?``:e[1]||e[0])}function Tt(e){let t={},n=Object.keys(e),r,i=n.length,a;for(r=0;r<i;r++)a=n[r],t[a]=e[a];return t}function Et(e){function t(e,n,r,i){let a=e[i++];if(a===`__proto__`)return!0;let o=Number.isFinite(+a),s=i>=e.length;return a=!a&&R.isArray(r)?r.length:a,s?(R.hasOwnProp(r,a)?r[a]=R.isArray(r[a])?r[a].concat(n):[r[a],n]:r[a]=n,!o):((!r[a]||!R.isObject(r[a]))&&(r[a]=[]),t(e,n,r[a],i)&&R.isArray(r[a])&&(r[a]=Tt(r[a])),!o)}if(R.isFormData(e)&&R.isFunction(e.entries)){let n={};return R.forEachEntry(e,(e,r)=>{t(wt(e),r,n,0)}),n}return null}var Dt=(e,t)=>e!=null&&R.hasOwnProp(e,t)?e[t]:void 0;function Ot(e,t,n){if(R.isString(e))try{return(t||JSON.parse)(e),R.trim(e)}catch(e){if(e.name!==`SyntaxError`)throw e}return(n||JSON.stringify)(e)}var kt={transitional:ht,adapter:[`xhr`,`http`,`fetch`],transformRequest:[function(e,t){let n=t.getContentType()||``,r=n.indexOf(`application/json`)>-1,i=R.isObject(e);if(i&&R.isHTMLForm(e)&&(e=new FormData(e)),R.isFormData(e))return r?JSON.stringify(Et(e)):e;if(R.isArrayBuffer(e)||R.isBuffer(e)||R.isStream(e)||R.isFile(e)||R.isBlob(e)||R.isReadableStream(e))return e;if(R.isArrayBufferView(e))return e.buffer;if(R.isURLSearchParams(e))return t.setContentType(`application/x-www-form-urlencoded;charset=utf-8`,!1),e.toString();let a;if(i){let t=Dt(this,`formSerializer`);if(n.indexOf(`application/x-www-form-urlencoded`)>-1)return Ct(e,t).toString();if((a=R.isFileList(e))||n.indexOf(`multipart/form-data`)>-1){let n=Dt(this,`env`),r=n&&n.FormData;return ct(a?{"files[]":e}:e,r&&new r,t)}}return i||r?(t.setContentType(`application/json`,!1),Ot(e)):e}],transformResponse:[function(e){let t=Dt(this,`transitional`)||kt.transitional,n=t&&t.forcedJSONParsing,r=Dt(this,`responseType`),i=r===`json`;if(R.isResponse(e)||R.isReadableStream(e))return e;if(e&&R.isString(e)&&(n&&!r||i)){let n=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(e,Dt(this,`parseReviver`))}catch(e){if(n)throw e.name===`SyntaxError`?B.from(e,B.ERR_BAD_RESPONSE,this,null,Dt(this,`response`)):e}}return e}],timeout:0,xsrfCookieName:`XSRF-TOKEN`,xsrfHeaderName:`X-XSRF-TOKEN`,maxContentLength:-1,maxBodyLength:-1,env:{FormData:V.classes.FormData,Blob:V.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:`application/json, text/plain, */*`,"Content-Type":void 0}}};R.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`,`query`],e=>{kt.headers[e]={}});function At(e,t){let n=this||kt,r=t||n,i=z.from(r.headers),a=r.data;return R.forEach(e,function(e){a=e.call(n,a,i.normalize(),t?t.status:void 0)}),i.normalize(),a}function jt(e){return!!(e&&e.__CANCEL__)}var Mt=class extends B{constructor(e,t,n){super(e??`canceled`,B.ERR_CANCELED,t,n),this.name=`CanceledError`,this.__CANCEL__=!0}};function Nt(e,t,n){let r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new B(`Request failed with status code `+n.status,n.status>=400&&n.status<500?B.ERR_BAD_REQUEST:B.ERR_BAD_RESPONSE,n.config,n.request,n))}function Pt(e){let t=/^([-+\w]{1,25}):(?:\/\/)?/.exec(e);return t&&t[1]||``}function Ft(e,t){e||=10;let n=Array(e),r=Array(e),i=0,a=0,o;return t=t===void 0?1e3:t,function(s){let c=Date.now(),l=r[a];o||=c,n[i]=s,r[i]=c;let u=a,d=0;for(;u!==i;)d+=n[u++],u%=e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),c-o<t)return;let f=l&&c-l;return f?Math.round(d*1e3/f):void 0}}function It(e,t){let n=0,r=1e3/t,i,a,o=(t,r=Date.now())=>{n=r,i=null,a&&=(clearTimeout(a),null),e(...t)};return[(...e)=>{let t=Date.now(),s=t-n;s>=r?o(e,t):(i=e,a||=setTimeout(()=>{a=null,o(i)},r-s))},()=>i&&o(i)]}var Lt=(e,t,n=3)=>{let r=0,i=Ft(50,250);return It(n=>{let a=n.loaded,o=n.lengthComputable?n.total:void 0,s=o==null?a:Math.min(a,o),c=Math.max(0,s-r),l=i(c);r=Math.max(r,s),e({loaded:s,total:o,progress:o?s/o:void 0,bytes:c,rate:l||void 0,estimated:l&&o?(o-s)/l:void 0,event:n,lengthComputable:o!=null,[t?`download`:`upload`]:!0})},n)},Rt=(e,t)=>{let n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},zt=e=>(...t)=>R.asap(()=>e(...t)),Bt=V.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,V.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(V.origin),V.navigator&&/(msie|trident)/i.test(V.navigator.userAgent)):()=>!0,Vt=V.hasStandardBrowserEnv?{write(e,t,n,r,i,a,o){if(typeof document>`u`)return;let s=[`${e}=${encodeURIComponent(t)}`];R.isNumber(n)&&s.push(`expires=${new Date(n).toUTCString()}`),R.isString(r)&&s.push(`path=${r}`),R.isString(i)&&s.push(`domain=${i}`),a===!0&&s.push(`secure`),R.isString(o)&&s.push(`SameSite=${o}`),document.cookie=s.join(`; `)},read(e){if(typeof document>`u`)return null;let t=document.cookie.split(`;`);for(let n=0;n<t.length;n++){let r=t[n].replace(/^\s+/,``),i=r.indexOf(`=`);if(i!==-1&&r.slice(0,i)===e)return decodeURIComponent(r.slice(i+1))}return null},remove(e){this.write(e,``,Date.now()-864e5,`/`)}}:{write(){},read(){return null},remove(){}};function Ht(e){return typeof e==`string`?/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e):!1}function Ut(e,t){return t?e.replace(/\/?\/$/,``)+`/`+t.replace(/^\/+/,``):e}function Wt(e,t,n){let r=!Ht(t);return e&&(r||n===!1)?Ut(e,t):t}var Gt=e=>e instanceof z?{...e}:e;function Kt(e,t){t||={};let n=Object.create(null);Object.defineProperty(n,`hasOwnProperty`,{__proto__:null,value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function r(e,t,n,r){return R.isPlainObject(e)&&R.isPlainObject(t)?R.merge.call({caseless:r},e,t):R.isPlainObject(t)?R.merge({},t):R.isArray(t)?t.slice():t}function i(e,t,n,i){if(!R.isUndefined(t))return r(e,t,n,i);if(!R.isUndefined(e))return r(void 0,e,n,i)}function a(e,t){if(!R.isUndefined(t))return r(void 0,t)}function o(e,t){if(!R.isUndefined(t))return r(void 0,t);if(!R.isUndefined(e))return r(void 0,e)}function s(n,i,a){if(R.hasOwnProp(t,a))return r(n,i);if(R.hasOwnProp(e,a))return r(void 0,n)}let c={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,allowedSocketPaths:o,responseEncoding:o,validateStatus:s,headers:(e,t,n)=>i(Gt(e),Gt(t),n,!0)};return R.forEach(Object.keys({...e,...t}),function(r){if(r===`__proto__`||r===`constructor`||r===`prototype`)return;let a=R.hasOwnProp(c,r)?c[r]:i,o=a(R.hasOwnProp(e,r)?e[r]:void 0,R.hasOwnProp(t,r)?t[r]:void 0,r);R.isUndefined(o)&&a!==s||(n[r]=o)}),n}var qt=[`content-type`,`content-length`];function Jt(e,t,n){if(n!==`content-only`){e.set(t);return}Object.entries(t).forEach(([t,n])=>{qt.includes(t.toLowerCase())&&e.set(t,n)})}var Yt=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(e,t)=>String.fromCharCode(parseInt(t,16))),Xt=e=>{let t=Kt({},e),n=e=>R.hasOwnProp(t,e)?t[e]:void 0,r=n(`data`),i=n(`withXSRFToken`),a=n(`xsrfHeaderName`),o=n(`xsrfCookieName`),s=n(`headers`),c=n(`auth`),l=n(`baseURL`),u=n(`allowAbsoluteUrls`),d=n(`url`);if(t.headers=s=z.from(s),t.url=pt(Wt(l,d,u),e.params,e.paramsSerializer),c&&s.set(`Authorization`,`Basic `+btoa((c.username||``)+`:`+(c.password?Yt(c.password):``))),R.isFormData(r)&&(V.hasStandardBrowserEnv||V.hasStandardBrowserWebWorkerEnv?s.setContentType(void 0):R.isFunction(r.getHeaders)&&Jt(s,r.getHeaders(),n(`formDataHeaderPolicy`))),V.hasStandardBrowserEnv&&(R.isFunction(i)&&(i=i(t)),i===!0||i==null&&Bt(t.url))){let e=a&&o&&Vt.read(o);e&&s.set(a,e)}return t},Zt=typeof XMLHttpRequest<`u`&&function(e){return new Promise(function(t,n){let r=Xt(e),i=r.data,a=z.from(r.headers).normalize(),{responseType:o,onUploadProgress:s,onDownloadProgress:c}=r,l,u,d,f,p;function m(){f&&f(),p&&p(),r.cancelToken&&r.cancelToken.unsubscribe(l),r.signal&&r.signal.removeEventListener(`abort`,l)}let h=new XMLHttpRequest;h.open(r.method.toUpperCase(),r.url,!0),h.timeout=r.timeout;function g(){if(!h)return;let r=z.from(`getAllResponseHeaders`in h&&h.getAllResponseHeaders());Nt(function(e){t(e),m()},function(e){n(e),m()},{data:!o||o===`text`||o===`json`?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:r,config:e,request:h}),h=null}`onloadend`in h?h.onloadend=g:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.startsWith(`file:`))||setTimeout(g)},h.onabort=function(){h&&=(n(new B(`Request aborted`,B.ECONNABORTED,e,h)),m(),null)},h.onerror=function(t){let r=new B(t&&t.message?t.message:`Network Error`,B.ERR_NETWORK,e,h);r.event=t||null,n(r),m(),h=null},h.ontimeout=function(){let t=r.timeout?`timeout of `+r.timeout+`ms exceeded`:`timeout exceeded`,i=r.transitional||ht;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new B(t,i.clarifyTimeoutError?B.ETIMEDOUT:B.ECONNABORTED,e,h)),m(),h=null},i===void 0&&a.setContentType(null),`setRequestHeader`in h&&R.forEach(a.toJSON(),function(e,t){h.setRequestHeader(t,e)}),R.isUndefined(r.withCredentials)||(h.withCredentials=!!r.withCredentials),o&&o!==`json`&&(h.responseType=r.responseType),c&&([d,p]=Lt(c,!0),h.addEventListener(`progress`,d)),s&&h.upload&&([u,f]=Lt(s),h.upload.addEventListener(`progress`,u),h.upload.addEventListener(`loadend`,f)),(r.cancelToken||r.signal)&&(l=t=>{h&&=(n(!t||t.type?new Mt(null,e,h):t),h.abort(),m(),null)},r.cancelToken&&r.cancelToken.subscribe(l),r.signal&&(r.signal.aborted?l():r.signal.addEventListener(`abort`,l)));let _=Pt(r.url);if(_&&!V.protocols.includes(_)){n(new B(`Unsupported protocol `+_+`:`,B.ERR_BAD_REQUEST,e));return}h.send(i||null)})},Qt=(e,t)=>{let{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n=new AbortController,r,i=function(e){if(!r){r=!0,o();let t=e instanceof Error?e:this.reason;n.abort(t instanceof B?t:new Mt(t instanceof Error?t.message:t))}},a=t&&setTimeout(()=>{a=null,i(new B(`timeout of ${t}ms exceeded`,B.ETIMEDOUT))},t),o=()=>{e&&=(a&&clearTimeout(a),a=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener(`abort`,i)}),null)};e.forEach(e=>e.addEventListener(`abort`,i));let{signal:s}=n;return s.unsubscribe=()=>R.asap(o),s}},$t=function*(e,t){let n=e.byteLength;if(!t||n<t){yield e;return}let r=0,i;for(;r<n;)i=r+t,yield e.slice(r,i),r=i},en=async function*(e,t){for await(let n of tn(e))yield*$t(n,t)},tn=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}},nn=(e,t,n,r)=>{let i=en(e,t),a=0,o,s=e=>{o||(o=!0,r&&r(e))};return new ReadableStream({async pull(e){try{let{done:t,value:r}=await i.next();if(t){s(),e.close();return}let o=r.byteLength;n&&n(a+=o),e.enqueue(new Uint8Array(r))}catch(e){throw s(e),e}},cancel(e){return s(e),i.return()}},{highWaterMark:2})};function rn(e){if(!e||typeof e!=`string`||!e.startsWith(`data:`))return 0;let t=e.indexOf(`,`);if(t<0)return 0;let n=e.slice(5,t),r=e.slice(t+1);if(/;base64/i.test(n)){let e=r.length,t=r.length;for(let n=0;n<t;n++)if(r.charCodeAt(n)===37&&n+2<t){let t=r.charCodeAt(n+1),i=r.charCodeAt(n+2);(t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102)&&(i>=48&&i<=57||i>=65&&i<=70||i>=97&&i<=102)&&(e-=2,n+=2)}let n=0,i=t-1,a=e=>e>=2&&r.charCodeAt(e-2)===37&&r.charCodeAt(e-1)===51&&(r.charCodeAt(e)===68||r.charCodeAt(e)===100);i>=0&&(r.charCodeAt(i)===61?(n++,i--):a(i)&&(n++,i-=3)),n===1&&i>=0&&(r.charCodeAt(i)===61||a(i))&&n++;let o=Math.floor(e/4)*3-(n||0);return o>0?o:0}if(typeof Buffer<`u`&&typeof Buffer.byteLength==`function`)return Buffer.byteLength(r,`utf8`);let i=0;for(let e=0,t=r.length;e<t;e++){let n=r.charCodeAt(e);if(n<128)i+=1;else if(n<2048)i+=2;else if(n>=55296&&n<=56319&&e+1<t){let t=r.charCodeAt(e+1);t>=56320&&t<=57343?(i+=4,e++):i+=3}else i+=3}return i}var an=`1.16.0`,on=64*1024,{isFunction:sn}=R,cn=(e,...t)=>{try{return!!e(...t)}catch{return!1}},ln=e=>{let t=R.global??globalThis,{ReadableStream:n,TextEncoder:r}=t;e=R.merge.call({skipUndefined:!0},{Request:t.Request,Response:t.Response},e);let{fetch:i,Request:a,Response:o}=e,s=i?sn(i):typeof fetch==`function`,c=sn(a),l=sn(o);if(!s)return!1;let u=s&&sn(n),d=s&&(typeof r==`function`?(e=>t=>e.encode(t))(new r):async e=>new Uint8Array(await new a(e).arrayBuffer())),f=c&&u&&cn(()=>{let e=!1,t=new a(V.origin,{body:new n,method:`POST`,get duplex(){return e=!0,`half`}}),r=t.headers.has(`Content-Type`);return t.body!=null&&t.body.cancel(),e&&!r}),p=l&&u&&cn(()=>R.isReadableStream(new o(``).body)),m={stream:p&&(e=>e.body)};s&&[`text`,`arrayBuffer`,`blob`,`formData`,`stream`].forEach(e=>{!m[e]&&(m[e]=(t,n)=>{let r=t&&t[e];if(r)return r.call(t);throw new B(`Response type '${e}' is not supported`,B.ERR_NOT_SUPPORT,n)})});let h=async e=>{if(e==null)return 0;if(R.isBlob(e))return e.size;if(R.isSpecCompliantForm(e))return(await new a(V.origin,{method:`POST`,body:e}).arrayBuffer()).byteLength;if(R.isArrayBufferView(e)||R.isArrayBuffer(e))return e.byteLength;if(R.isURLSearchParams(e)&&(e+=``),R.isString(e))return(await d(e)).byteLength},g=async(e,t)=>R.toFiniteNumber(e.getContentLength())??h(t);return async e=>{let{url:t,method:n,data:s,signal:l,cancelToken:u,timeout:d,onDownloadProgress:h,onUploadProgress:_,responseType:v,headers:y,withCredentials:b=`same-origin`,fetchOptions:x,maxContentLength:S,maxBodyLength:C}=Xt(e),w=R.isNumber(S)&&S>-1,T=R.isNumber(C)&&C>-1,E=i||fetch;v=v?(v+``).toLowerCase():`text`;let D=Qt([l,u&&u.toAbortSignal()],d),O=null,k=D&&D.unsubscribe&&(()=>{D.unsubscribe()}),A;try{if(w&&typeof t==`string`&&t.startsWith(`data:`)&&rn(t)>S)throw new B(`maxContentLength size of `+S+` exceeded`,B.ERR_BAD_RESPONSE,e,O);if(T&&n!==`get`&&n!==`head`){let t=await g(y,s);if(typeof t==`number`&&isFinite(t)&&t>C)throw new B(`Request body larger than maxBodyLength limit`,B.ERR_BAD_REQUEST,e,O)}if(_&&f&&n!==`get`&&n!==`head`&&(A=await g(y,s))!==0){let e=new a(t,{method:`POST`,body:s,duplex:`half`}),n;if(R.isFormData(s)&&(n=e.headers.get(`content-type`))&&y.setContentType(n),e.body){let[t,n]=Rt(A,Lt(zt(_)));s=nn(e.body,on,t,n)}}R.isString(b)||(b=b?`include`:`omit`);let i=c&&`credentials`in a.prototype;if(R.isFormData(s)){let e=y.getContentType();e&&/^multipart\/form-data/i.test(e)&&!/boundary=/i.test(e)&&y.delete(`content-type`)}y.set(`User-Agent`,`axios/`+an,!1);let l={...x,signal:D,method:n.toUpperCase(),headers:y.normalize().toJSON(),body:s,duplex:`half`,credentials:i?b:void 0};O=c&&new a(t,l);let u=await(c?E(O,x):E(t,l));if(w){let t=R.toFiniteNumber(u.headers.get(`content-length`));if(t!=null&&t>S)throw new B(`maxContentLength size of `+S+` exceeded`,B.ERR_BAD_RESPONSE,e,O)}let d=p&&(v===`stream`||v===`response`);if(p&&u.body&&(h||w||d&&k)){let t={};[`status`,`statusText`,`headers`].forEach(e=>{t[e]=u[e]});let n=R.toFiniteNumber(u.headers.get(`content-length`)),[r,i]=h&&Rt(n,Lt(zt(h),!0))||[],a=0;u=new o(nn(u.body,on,t=>{if(w&&(a=t,a>S))throw new B(`maxContentLength size of `+S+` exceeded`,B.ERR_BAD_RESPONSE,e,O);r&&r(t)},()=>{i&&i(),k&&k()}),t)}v||=`text`;let j=await m[R.findKey(m,v)||`text`](u,e);if(w&&!p&&!d){let t;if(j!=null&&(typeof j.byteLength==`number`?t=j.byteLength:typeof j.size==`number`?t=j.size:typeof j==`string`&&(t=typeof r==`function`?new r().encode(j).byteLength:j.length)),typeof t==`number`&&t>S)throw new B(`maxContentLength size of `+S+` exceeded`,B.ERR_BAD_RESPONSE,e,O)}return!d&&k&&k(),await new Promise((t,n)=>{Nt(t,n,{data:j,headers:z.from(u.headers),status:u.status,statusText:u.statusText,config:e,request:O})})}catch(t){if(k&&k(),D&&D.aborted&&D.reason instanceof B){let n=D.reason;throw n.config=e,O&&(n.request=O),t!==n&&(n.cause=t),n}throw t&&t.name===`TypeError`&&/Load failed|fetch/i.test(t.message)?Object.assign(new B(`Network Error`,B.ERR_NETWORK,e,O,t&&t.response),{cause:t.cause||t}):B.from(t,t&&t.code,e,O,t&&t.response)}}},un=new Map,dn=e=>{let t=e&&e.env||{},{fetch:n,Request:r,Response:i}=t,a=[r,i,n],o=a.length,s,c,l=un;for(;o--;)s=a[o],c=l.get(s),c===void 0&&l.set(s,c=o?new Map:ln(t)),l=c;return c};dn();var fn={http:null,xhr:Zt,fetch:{get:dn}};R.forEach(fn,(e,t)=>{if(e){try{Object.defineProperty(e,`name`,{__proto__:null,value:t})}catch{}Object.defineProperty(e,`adapterName`,{__proto__:null,value:t})}});var pn=e=>`- ${e}`,mn=e=>R.isFunction(e)||e===null||e===!1;function hn(e,t){e=R.isArray(e)?e:[e];let{length:n}=e,r,i,a={};for(let o=0;o<n;o++){r=e[o];let n;if(i=r,!mn(r)&&(i=fn[(n=String(r)).toLowerCase()],i===void 0))throw new B(`Unknown adapter '${n}'`);if(i&&(R.isFunction(i)||(i=i.get(t))))break;a[n||`#`+o]=i}if(!i){let e=Object.entries(a).map(([e,t])=>`adapter ${e} `+(t===!1?`is not supported by the environment`:`is not available in the build`));throw new B(`There is no suitable adapter to dispatch the request `+(n?e.length>1?`since :
4
4
  `+e.map(pn).join(`
@@ -7,13 +7,13 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
7
7
  `),r=t===-1?-1:n.indexOf(`
8
8
  `,t+1),i=r===-1?``:n.slice(r+1);String(e.stack).endsWith(i)||(e.stack+=`
9
9
  `+n)}}catch{}}throw e}}_request(e,t){typeof e==`string`?(t||={},t.url=e):t=e||{},t=Kt(this.defaults,t);let{transitional:n,paramsSerializer:r,headers:i}=t;n!==void 0&&Sn.assertOptions(n,{silentJSONParsing:Cn.transitional(Cn.boolean),forcedJSONParsing:Cn.transitional(Cn.boolean),clarifyTimeoutError:Cn.transitional(Cn.boolean),legacyInterceptorReqResOrdering:Cn.transitional(Cn.boolean)},!1),r!=null&&(R.isFunction(r)?t.paramsSerializer={serialize:r}:Sn.assertOptions(r,{encode:Cn.function,serialize:Cn.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls===void 0?t.allowAbsoluteUrls=!0:t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls),Sn.assertOptions(t,{baseUrl:Cn.spelling(`baseURL`),withXsrfToken:Cn.spelling(`withXSRFToken`)},!0),t.method=(t.method||this.defaults.method||`get`).toLowerCase();let a=i&&R.merge(i.common,i[t.method]);i&&R.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`,`query`,`common`],e=>{delete i[e]}),t.headers=z.concat(a,i);let o=[],s=!0;this.interceptors.request.forEach(function(e){if(typeof e.runWhen==`function`&&e.runWhen(t)===!1)return;s&&=e.synchronous;let n=t.transitional||ht;n&&n.legacyInterceptorReqResOrdering?o.unshift(e.fulfilled,e.rejected):o.push(e.fulfilled,e.rejected)});let c=[];this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let l,u=0,d;if(!s){let e=[vn.bind(this),void 0];for(e.unshift(...o),e.push(...c),d=e.length,l=Promise.resolve(t);u<d;)l=l.then(e[u++],e[u++]);return l}d=o.length;let f=t;for(;u<d;){let e=o[u++],t=o[u++];try{f=e(f)}catch(e){t.call(this,e);break}}try{l=vn.call(this,f)}catch(e){return Promise.reject(e)}for(u=0,d=c.length;u<d;)l=l.then(c[u++],c[u++]);return l}getUri(e){return e=Kt(this.defaults,e),pt(Wt(e.baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}};R.forEach([`delete`,`get`,`head`,`options`],function(e){wn.prototype[e]=function(t,n){return this.request(Kt(n||{},{method:e,url:t,data:(n||{}).data}))}}),R.forEach([`post`,`put`,`patch`,`query`],function(e){function t(t){return function(n,r,i){return this.request(Kt(i||{},{method:e,headers:t?{"Content-Type":`multipart/form-data`}:{},url:n,data:r}))}}wn.prototype[e]=t(),e!==`query`&&(wn.prototype[e+`Form`]=t(!0))});var Tn=class e{constructor(e){if(typeof e!=`function`)throw TypeError(`executor must be a function.`);let t;this.promise=new Promise(function(e){t=e});let n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t,r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,i){n.reason||(n.reason=new Mt(e,r,i),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){let e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e(function(e){t=e}),cancel:t}}};function En(e){return function(t){return e.apply(null,t)}}function Dn(e){return R.isObject(e)&&e.isAxiosError===!0}var On={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(On).forEach(([e,t])=>{On[t]=e});function kn(e){let t=new wn(e),n=m(wn.prototype.request,t);return R.extend(n,wn.prototype,t,{allOwnKeys:!0}),R.extend(n,t,null,{allOwnKeys:!0}),n.create=function(t){return kn(Kt(e,t))},n}var H=kn(kt);H.Axios=wn,H.CanceledError=Mt,H.CancelToken=Tn,H.isCancel=jt,H.VERSION=an,H.toFormData=ct,H.AxiosError=B,H.Cancel=H.CanceledError,H.all=function(e){return Promise.all(e)},H.spread=En,H.isAxiosError=Dn,H.mergeConfig=Kt,H.AxiosHeaders=z,H.formToJSON=e=>Et(R.isHTMLForm(e)?new FormData(e):e),H.getAdapter=gn.getAdapter,H.HttpStatusCode=On,H.default=H;function An(e){if(/^\d{8}$/.test(e))return`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`;if(/^\d{4}-\d{2}-\d{2}T/.test(e))return e.slice(0,10);if(/^\d{4}-\d{2}-\d{2}$/.test(e))return e;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().slice(0,10)}function jn(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)throw Error(`无法解析日期: ${e}`);let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]);return Date.UTC(n,r-1,i,-8,0,0,0)}function Mn(e){return e&&{daily:`d`,weekly:`w`,monthly:`m`,5:`5`,15:`15`,30:`30`,60:`60`}[e]||`d`}function Nn(e){return e&&{qfq:`2`,hfq:`1`,none:`3`}[e]||`3`}function Pn(e){let t=An(e.date),n=e=>{let t=parseFloat(e);return Number.isNaN(t)?0:t};return{timestamp:jn(t),stockCode:e.code,open:n(e.open),high:n(e.high),low:n(e.low),close:n(e.close),volume:n(e.volume),turnover:n(e.amount),changePercent:n(e.pctChg),turnoverRate:n(e.turn)}}var Fn=``,In=`/api/stock/kdata`;async function Ln(e){if(typeof window<`u`&&window.location.hostname.includes(`github.io`)){let e=await(await fetch(`mock-stock-data.json`)).json();if(e.success&&e.data)return e.data.map(Pn).sort((e,t)=>e.timestamp-t.timestamp);throw Error(`Mock data failed`)}let{timeout:t,...n}=e,r=`${Fn}${In}`,i={stock_code:n.symbol,start_date:n.start_date,end_date:n.end_date,frequency:Mn(n.period),adjustflag:Nn(n.adjust),timeout:t};try{let e=(await H.get(r,{params:i,timeout:t?t*1e3:void 0})).data;if(!e.success)throw Error(`获取K线数据失败: ${e.error_msg||`未知错误`} (code: ${e.error_code})`);return!e.data||e.data.length===0?[]:e.data.map(Pn).sort((e,t)=>e.timestamp-t.timestamp)}catch(e){try{console.log(`fetch mock-stock-data.json`);let e=await fetch(`mock-stock-data.json`);if(e.ok){let t=await e.json();if(t.success&&t.data)return t.data.map(Pn).sort((e,t)=>e.timestamp-t.timestamp)}}catch{}throw H.isAxiosError(e)?Error(`获取K线数据失败: ${e.message}`):e}}function Rn(e){return e.map(e=>({timestamp:e.timestamp,open:e.open,high:e.high,low:e.low,close:e.close,stockCode:e.stockCode,volume:e.volume,turnover:e.turnover,amplitude:e.amplitude,changePercent:e.changePercent,changeAmount:e.changeAmount,turnoverRate:e.turnoverRate})).sort((e,t)=>e.timestamp-t.timestamp)}var zn=`/api/public/stock_zh_a_hist`;function Bn(e){if(/^\d{8}$/.test(e))return`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`;if(/^\d{4}-\d{2}-\d{2}T/.test(e))return e.slice(0,10);if(/^\d{4}-\d{2}-\d{2}$/.test(e))return e;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().slice(0,10)}function Vn(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)throw Error(`无法解析日期: ${e}`);let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]);return Date.UTC(n,r-1,i,-8,0,0,0)}function Hn(e){return{timestamp:Vn(Bn(e.日期)),stockCode:e.股票代码,open:e.开盘,close:e.收盘,high:e.最高,low:e.最低,volume:e.成交量,turnover:e.成交额,amplitude:e.振幅,changePercent:e.涨跌幅,changeAmount:e.涨跌额,turnoverRate:e.换手率}}async function Un(e){try{let{timeout:t,...n}=e;return(await H.get(zn,{params:n,timeout:t?t*1e3:void 0})).data.map(Hn)}catch(e){throw H.isAxiosError(e)?Error(`获取K线数据失败: ${e.message}`):e}}var Wn=new class{set(e,t){let n={data:t,timestamp:Date.now()};localStorage.setItem(e,JSON.stringify(n))}get(e,t=3600*1e3){let n=localStorage.getItem(e);if(!n)return null;try{let r=JSON.parse(n);return Date.now()-r.timestamp>t?(localStorage.removeItem(e),null):r.data}catch{return localStorage.removeItem(e),null}}remove(e){localStorage.removeItem(e)}clear(){localStorage.clear()}generateKey(e,t){return`${e}:${Object.keys(t).sort().map(e=>`${e}:${t[e]}`).join(`|`)}`}},Gn=class{name=`baostock`;async fetchKLineData(e){return Ln({symbol:this.addMarketPrefix(e.symbol),start_date:e.startDate,end_date:e.endDate,period:{daily:`daily`,weekly:`weekly`,monthly:`monthly`,"5min":`5`,"15min":`15`,"30min":`30`,"60min":`60`}[e.period]||`daily`,adjust:e.adjust,timeout:e.timeout})}addMarketPrefix(e){return/^(6|68)\d{5}$/.test(e)?`sh.${e}`:/^(0|3)\d{5}$/.test(e)?`sz.${e}`:e}},Kn=class{name=`dongcai`;async fetchKLineData(e){let t=e.startDate.replace(/-/g,``),n=e.endDate.replace(/-/g,``),r={daily:`daily`,weekly:`weekly`,monthly:`monthly`}[e.period];if(!r)throw Error(`东财数据源不支持周期: ${e.period}`);return Rn(await Un({symbol:e.symbol,start_date:t,end_date:n,period:r,adjust:e.adjust===`none`?void 0:e.adjust,timeout:e.timeout}))}},qn=class{static instances=new Map;static create(e){if(!this.instances.has(e))switch(e){case`baostock`:this.instances.set(e,new Gn);break;case`dongcai`:this.instances.set(e,new Kn);break;default:throw Error(`未知的数据源类型: ${e}`)}return this.instances.get(e)}},Jn=3600*1e3;function Yn(e,t){return Wn.generateKey(`kline:${e}`,{symbol:t.symbol,startDate:t.startDate,endDate:t.endDate,period:t.period,adjust:t.adjust})}async function Xn(e,t,n=!0){let r=Yn(e,t);if(n){let e=Wn.get(r,Jn);if(e)return console.log(`[KLineCache] 命中缓存: ${r}`),e}let i=await qn.create(e).fetchKLineData(t);return n&&i.length>0&&(Wn.set(r,i),console.log(`[KLineCache] 写入缓存: ${r}, ${i.length} 条数据`)),i}var Zn=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;var a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),Qn=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;var t=Zn(),n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;var o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),U=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;var t=Zn(),n=Qn(),r=Zn();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,`strConcat`,{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,`getProperty`,{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,`regexpCode`,{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return r.Name}});var i=Qn();Object.defineProperty(e,`Scope`,{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,`ValueScope`,{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,`ValueScopeName`,{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,`varKinds`,{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=k(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=k(this.rhs,e,n),this}get names(){return O(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=k(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(A(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>D(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(j(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=k(this.condition,e,t),this}get names(){let e=super.names;return O(e,this.condition),this.else&&D(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=k(this.iteration,e,t),this}get names(){return D(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return O(O(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=k(this.iterable,e,t),this}get names(){return D(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var w=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&D(e,this.catch.names),this.finally&&D(e,this.finally.names),e}},T=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};T.kind=`catch`;var E=class extends m{render(e){return`finally`+super.render(e)}};E.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
10
- `:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new o(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new s(e,t,n))}add(t,n){return this._leafNode(new c(t,e.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new f(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new _(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new _(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(_,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new y(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new b(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new x(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new x(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){let t=new C;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(C)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new w;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new T(e),t(e)}return n&&(this._currNode=r.finally=new E,this.code(n)),this._endBlockNode(T,E)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new S(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(S)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof _))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function D(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function O(e,n){return n instanceof t._CodeOrName?D(e,n.names):e}function k(e,n,r){if(e instanceof t.Name)return i(e);if(!a(e))return e;return new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[]));function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function A(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function j(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${te(e)}`}e.not=j;var M=F(e.operators.AND);function N(...e){return e.reduce(M)}e.and=N;var ee=F(e.operators.OR);function P(...e){return e.reduce(ee)}e.or=P;function F(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${te(n)} ${e} ${te(r)}`}function te(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),W=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;var t=U(),n=Zn();function r(e){let t={};for(let n of e)t[n]=!0;return t}e.toHash=r;function i(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0?!0:(a(e,t),!o(t,e.self.RULES.all))}e.alwaysValidSchema=i;function a(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||x(e,`unknown keyword: "${n}"`)}e.checkUnknownRules=a;function o(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}e.schemaHasRules=o;function s(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}e.schemaHasRulesButRef=s;function c({topSchemaRef:e,schemaPath:n},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,t._)`${r}`}return(0,t._)`${e}${n}${(0,t.getProperty)(i)}`}e.schemaRefOrVal=c;function l(e){return f(decodeURIComponent(e))}e.unescapeFragment=l;function u(e){return encodeURIComponent(d(e))}e.escapeFragment=u;function d(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.escapeJsonPointer=d;function f(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}e.unescapeJsonPointer=f;function p(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}e.eachItem=p;function m({mergeNames:e,mergeToName:n,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof t.Name?(o instanceof t.Name?e(a,o,s):n(a,o,s),s):o instanceof t.Name?(n(a,s,o),o):r(o,s);return c===t.Name&&!(l instanceof t.Name)?i(a,l):l}}e.mergeEvaluated={props:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>{e.if((0,t._)`${n} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,t._)`${r} || {}`).code((0,t._)`Object.assign(${r}, ${n})`))}),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>{n===!0?e.assign(r,!0):(e.assign(r,(0,t._)`${r} || {}`),g(e,r,n))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:h}),items:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>e.assign(r,(0,t._)`${n} === true ? true : ${r} > ${n} ? ${r} : ${n}`)),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>e.assign(r,n===!0?!0:(0,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function h(e,n){if(n===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,t._)`{}`);return n!==void 0&&g(e,r,n),r}e.evaluatedPropsToName=h;function g(e,n,r){Object.keys(r).forEach(r=>e.assign((0,t._)`${n}${(0,t.getProperty)(r)}`,!0))}e.setEvaluated=g;var _={};function v(e,t){return e.scopeValue(`func`,{ref:t,code:_[t.code]||(_[t.code]=new n._Code(t.code))})}e.useFunc=v;var y;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(y||(e.Type=y={}));function b(e,n,r){if(e instanceof t.Name){let i=n===y.Num;return r?i?(0,t._)`"[" + ${e} + "]"`:(0,t._)`"['" + ${e} + "']"`:i?(0,t._)`"/" + ${e}`:(0,t._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,t.getProperty)(e).toString():`/`+d(e)}e.getErrorPath=b;function x(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}e.checkStrictMode=x})),$n=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U();e.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),er=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;var t=U(),n=W(),r=$n();e.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function i(n,r=e.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:u,allErrors:f}=o,p=d(n,r,i);a??(u||f)?c(s,p):l(o,(0,t._)`[${p}]`)}e.reportError=i;function a(t,n=e.keywordError,i){let{it:a}=t,{gen:o,compositeRule:s,allErrors:u}=a;c(o,d(t,n,i)),s||u||l(a,r.default.vErrors)}e.reportExtraError=a;function o(e,n){e.assign(r.default.errors,n),e.if((0,t._)`${r.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${r.default.vErrors}.length`,n),()=>e.assign(r.default.vErrors,null)))}e.resetErrorsCount=o;function s({gen:e,keyword:n,schemaValue:i,data:a,errsCount:o,it:s}){if(o===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,o,r.default.errors,o=>{e.const(c,(0,t._)`${r.default.vErrors}[${o}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(r.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,i),e.assign((0,t._)`${c}.data`,a))})}e.extendErrors=s;function c(e,n){let i=e.const(`err`,n);e.if((0,t._)`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,(0,t._)`[${i}]`),(0,t._)`${r.default.vErrors}.push(${i})`),e.code((0,t._)`${r.default.errors}++`)}function l(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}var u={keyword:new t.Name(`keyword`),schemaPath:new t.Name(`schemaPath`),params:new t.Name(`params`),propertyName:new t.Name(`propertyName`),message:new t.Name(`message`),schema:new t.Name(`schema`),parentSchema:new t.Name(`parentSchema`)};function d(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:f(e,n,r)}function f(e,t,n={}){let{gen:r,it:i}=e,a=[p(i,n),m(e,n)];return h(e,t,a),r.object(...a)}function p({errorPath:e},{instancePath:i}){let a=i?(0,t.str)`${e}${(0,n.getErrorPath)(i,n.Type.Str)}`:e;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,a)]}function m({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[u.schemaPath,o]}function h(e,{params:n,message:i},a){let{keyword:o,data:s,schemaValue:c,it:l}=e,{opts:d,propertyName:f,topSchemaRef:p,schemaPath:m}=l;a.push([u.keyword,o],[u.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),d.messages&&a.push([u.message,typeof i==`function`?i(e):i]),d.verbose&&a.push([u.schema,c],[u.parentSchema,(0,t._)`${p}${m}`],[r.default.data,s]),f&&a.push([u.propertyName,f])}})),tr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;var t=er(),n=U(),r=$n(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?s(e,!1):typeof i==`object`&&i.$async===!0?t.return(r.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}e.topBoolOrEmptySchema=a;function o(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),s(e)):n.var(t,!0)}e.boolOrEmptySchema=o;function s(e,n){let{gen:r,data:a}=e,o={gen:r,keyword:`false schema`,data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(o,i,void 0,n)}})),nr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRules=e.isJSONType=void 0;var t=new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}e.isJSONType=n;function r(){let e={number:{type:`number`,rules:[]},string:{type:`string`,rules:[]},array:{type:`array`,rules:[]},object:{type:`object`,rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}e.getRules=r})),rr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}e.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}e.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}e.shouldUseRule=r})),ir=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;var t=nr(),n=rr(),r=er(),i=U(),a=W(),o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o||(e.DataType=o={}));function s(e){let t=c(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}e.getSchemaTypes=s;function c(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}e.getJSONTypes=c;function l(e,t){let{gen:r,data:i,opts:a}=e,s=d(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=h(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?f(e,t,s):_(e)})}return c}e.coerceAndCheckDataType=l;var u=new Set([`string`,`number`,`integer`,`boolean`,`null`]);function d(e,t){return t?e.filter(e=>u.has(e)||t===`array`&&e===`array`):[]}function f(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(h(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(u.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),_(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),p(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
10
+ `:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new o(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new s(e,t,n))}add(t,n){return this._leafNode(new c(t,e.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new f(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new _(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new _(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(_,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new y(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new b(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new x(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new x(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){let t=new C;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(C)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new w;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new T(e),t(e)}return n&&(this._currNode=r.finally=new E,this.code(n)),this._endBlockNode(T,E)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new S(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(S)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof _))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function D(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function O(e,n){return n instanceof t._CodeOrName?D(e,n.names):e}function k(e,n,r){if(e instanceof t.Name)return i(e);if(!a(e))return e;return new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[]));function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function A(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function j(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${ne(e)}`}e.not=j;var M=P(e.operators.AND);function N(...e){return e.reduce(M)}e.and=N;var ee=P(e.operators.OR);function te(...e){return e.reduce(ee)}e.or=te;function P(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${ne(n)} ${e} ${ne(r)}`}function ne(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),W=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;var t=U(),n=Zn();function r(e){let t={};for(let n of e)t[n]=!0;return t}e.toHash=r;function i(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0?!0:(a(e,t),!o(t,e.self.RULES.all))}e.alwaysValidSchema=i;function a(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||x(e,`unknown keyword: "${n}"`)}e.checkUnknownRules=a;function o(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}e.schemaHasRules=o;function s(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}e.schemaHasRulesButRef=s;function c({topSchemaRef:e,schemaPath:n},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,t._)`${r}`}return(0,t._)`${e}${n}${(0,t.getProperty)(i)}`}e.schemaRefOrVal=c;function l(e){return f(decodeURIComponent(e))}e.unescapeFragment=l;function u(e){return encodeURIComponent(d(e))}e.escapeFragment=u;function d(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.escapeJsonPointer=d;function f(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}e.unescapeJsonPointer=f;function p(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}e.eachItem=p;function m({mergeNames:e,mergeToName:n,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof t.Name?(o instanceof t.Name?e(a,o,s):n(a,o,s),s):o instanceof t.Name?(n(a,s,o),o):r(o,s);return c===t.Name&&!(l instanceof t.Name)?i(a,l):l}}e.mergeEvaluated={props:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>{e.if((0,t._)`${n} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,t._)`${r} || {}`).code((0,t._)`Object.assign(${r}, ${n})`))}),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>{n===!0?e.assign(r,!0):(e.assign(r,(0,t._)`${r} || {}`),g(e,r,n))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:h}),items:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>e.assign(r,(0,t._)`${n} === true ? true : ${r} > ${n} ? ${r} : ${n}`)),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>e.assign(r,n===!0?!0:(0,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function h(e,n){if(n===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,t._)`{}`);return n!==void 0&&g(e,r,n),r}e.evaluatedPropsToName=h;function g(e,n,r){Object.keys(r).forEach(r=>e.assign((0,t._)`${n}${(0,t.getProperty)(r)}`,!0))}e.setEvaluated=g;var _={};function v(e,t){return e.scopeValue(`func`,{ref:t,code:_[t.code]||(_[t.code]=new n._Code(t.code))})}e.useFunc=v;var y;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(y||(e.Type=y={}));function b(e,n,r){if(e instanceof t.Name){let i=n===y.Num;return r?i?(0,t._)`"[" + ${e} + "]"`:(0,t._)`"['" + ${e} + "']"`:i?(0,t._)`"/" + ${e}`:(0,t._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,t.getProperty)(e).toString():`/`+d(e)}e.getErrorPath=b;function x(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}e.checkStrictMode=x})),$n=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U();e.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),er=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;var t=U(),n=W(),r=$n();e.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function i(n,r=e.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:u,allErrors:f}=o,p=d(n,r,i);a??(u||f)?c(s,p):l(o,(0,t._)`[${p}]`)}e.reportError=i;function a(t,n=e.keywordError,i){let{it:a}=t,{gen:o,compositeRule:s,allErrors:u}=a;c(o,d(t,n,i)),s||u||l(a,r.default.vErrors)}e.reportExtraError=a;function o(e,n){e.assign(r.default.errors,n),e.if((0,t._)`${r.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${r.default.vErrors}.length`,n),()=>e.assign(r.default.vErrors,null)))}e.resetErrorsCount=o;function s({gen:e,keyword:n,schemaValue:i,data:a,errsCount:o,it:s}){if(o===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,o,r.default.errors,o=>{e.const(c,(0,t._)`${r.default.vErrors}[${o}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(r.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,i),e.assign((0,t._)`${c}.data`,a))})}e.extendErrors=s;function c(e,n){let i=e.const(`err`,n);e.if((0,t._)`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,(0,t._)`[${i}]`),(0,t._)`${r.default.vErrors}.push(${i})`),e.code((0,t._)`${r.default.errors}++`)}function l(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}var u={keyword:new t.Name(`keyword`),schemaPath:new t.Name(`schemaPath`),params:new t.Name(`params`),propertyName:new t.Name(`propertyName`),message:new t.Name(`message`),schema:new t.Name(`schema`),parentSchema:new t.Name(`parentSchema`)};function d(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:f(e,n,r)}function f(e,t,n={}){let{gen:r,it:i}=e,a=[p(i,n),m(e,n)];return h(e,t,a),r.object(...a)}function p({errorPath:e},{instancePath:i}){let a=i?(0,t.str)`${e}${(0,n.getErrorPath)(i,n.Type.Str)}`:e;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,a)]}function m({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[u.schemaPath,o]}function h(e,{params:n,message:i},a){let{keyword:o,data:s,schemaValue:c,it:l}=e,{opts:d,propertyName:f,topSchemaRef:p,schemaPath:m}=l;a.push([u.keyword,o],[u.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),d.messages&&a.push([u.message,typeof i==`function`?i(e):i]),d.verbose&&a.push([u.schema,c],[u.parentSchema,(0,t._)`${p}${m}`],[r.default.data,s]),f&&a.push([u.propertyName,f])}})),tr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;var t=er(),n=U(),r=$n(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?s(e,!1):typeof i==`object`&&i.$async===!0?t.return(r.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}e.topBoolOrEmptySchema=a;function o(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),s(e)):n.var(t,!0)}e.boolOrEmptySchema=o;function s(e,n){let{gen:r,data:a}=e,o={gen:r,keyword:`false schema`,data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(o,i,void 0,n)}})),nr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRules=e.isJSONType=void 0;var t=new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}e.isJSONType=n;function r(){let e={number:{type:`number`,rules:[]},string:{type:`string`,rules:[]},array:{type:`array`,rules:[]},object:{type:`object`,rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}e.getRules=r})),rr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}e.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}e.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}e.shouldUseRule=r})),ir=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;var t=nr(),n=rr(),r=er(),i=U(),a=W(),o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o||(e.DataType=o={}));function s(e){let t=c(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}e.getSchemaTypes=s;function c(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}e.getJSONTypes=c;function l(e,t){let{gen:r,data:i,opts:a}=e,s=d(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=h(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?f(e,t,s):_(e)})}return c}e.coerceAndCheckDataType=l;var u=new Set([`string`,`number`,`integer`,`boolean`,`null`]);function d(e,t){return t?e.filter(e=>u.has(e)||t===`array`&&e===`array`):[]}function f(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(h(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(u.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),_(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),p(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
11
11
  || (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
12
12
  || (${s} === "string" && ${a} && ${a} == +${a} && !(${a} % 1))`).assign(c,(0,i._)`+${a}`);return;case`boolean`:r.elseIf((0,i._)`${a} === "false" || ${a} === 0 || ${a} === null`).assign(c,!1).elseIf((0,i._)`${a} === "true" || ${a} === 1`).assign(c,!0);return;case`null`:r.elseIf((0,i._)`${a} === "" || ${a} === 0 || ${a} === false`),r.assign(c,null);return;case`array`:r.elseIf((0,i._)`${s} === "string" || ${s} === "number"
13
- || ${s} === "boolean" || ${a} === null`).assign(c,(0,i._)`[${a}]`)}}}function p({gen:e,parentData:t,parentDataProperty:n},r){e.if((0,i._)`${t} !== undefined`,()=>e.assign((0,i._)`${t}[${n}]`,r))}function m(e,t,n,r=o.Correct){let a=r===o.Correct?i.operators.EQ:i.operators.NEQ,s;switch(e){case`null`:return(0,i._)`${t} ${a} null`;case`array`:s=(0,i._)`Array.isArray(${t})`;break;case`object`:s=(0,i._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case`integer`:s=c((0,i._)`!(${t} % 1) && !isNaN(${t})`);break;case`number`:s=c();break;default:return(0,i._)`typeof ${t} ${a} ${e}`}return r===o.Correct?s:(0,i.not)(s);function c(e=i.nil){return(0,i.and)((0,i._)`typeof ${t} == "number"`,e,n?(0,i._)`isFinite(${t})`:i.nil)}}e.checkDataType=m;function h(e,t,n,r){if(e.length===1)return m(e[0],t,n,r);let o,s=(0,a.toHash)(e);if(s.array&&s.object){let e=(0,i._)`typeof ${t} != "object"`;o=s.null?e:(0,i._)`!${t} || ${e}`,delete s.null,delete s.array,delete s.object}else o=i.nil;s.number&&delete s.integer;for(let e in s)o=(0,i.and)(o,m(e,t,n,r));return o}e.checkDataTypes=h;var g={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e==`string`?(0,i._)`{type: ${e}}`:(0,i._)`{type: ${t}}`};function _(e){let t=v(e);(0,r.reportError)(t,g)}e.reportTypeError=_;function v(e){let{gen:t,data:n,schema:r}=e,i=(0,a.schemaRefOrVal)(e,r,`type`);return{gen:t,keyword:`type`,data:n,schema:r.type,schemaCode:i,schemaValue:i,parentSchema:r,params:{},it:e}}})),ar=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.assignDefaults=void 0;var t=U(),n=W();function r(e,t){let{properties:n,items:r}=e.schema;if(t===`object`&&n)for(let t in n)i(e,t,n[t].default);else t===`array`&&Array.isArray(r)&&r.forEach((t,n)=>i(e,n,t.default))}e.assignDefaults=r;function i(e,r,i){let{gen:a,compositeRule:o,data:s,opts:c}=e;if(i===void 0)return;let l=(0,t._)`${s}${(0,t.getProperty)(r)}`;if(o){(0,n.checkStrictMode)(e,`default is ignored for: ${l}`);return}let u=(0,t._)`${l} === undefined`;c.useDefaults===`empty`&&(u=(0,t._)`${u} || ${l} === null || ${l} === ""`),a.if(u,(0,t._)`${l} = ${(0,t.stringify)(i)}`)}})),or=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateUnion=e.validateArray=e.usePattern=e.callValidateCode=e.schemaProperties=e.allSchemaProperties=e.noPropertyInData=e.propertyInData=e.isOwnProperty=e.hasPropFunc=e.reportMissingProp=e.checkMissingProp=e.checkReportMissingProp=void 0;var t=U(),n=W(),r=$n(),i=W();function a(e,n){let{gen:r,data:i,it:a}=e;r.if(d(r,i,n,a.opts.ownProperties),()=>{e.setParams({missingProperty:(0,t._)`${n}`},!0),e.error()})}e.checkReportMissingProp=a;function o({gen:e,data:n,it:{opts:r}},i,a){return(0,t.or)(...i.map(i=>(0,t.and)(d(e,n,i,r.ownProperties),(0,t._)`${a} = ${i}`)))}e.checkMissingProp=o;function s(e,t){e.setParams({missingProperty:t},!0),e.error()}e.reportMissingProp=s;function c(e){return e.scopeValue(`func`,{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}e.hasPropFunc=c;function l(e,n,r){return(0,t._)`${c(e)}.call(${n}, ${r})`}e.isOwnProperty=l;function u(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} !== undefined`;return i?(0,t._)`${a} && ${l(e,n,r)}`:a}e.propertyInData=u;function d(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} === undefined`;return i?(0,t.or)(a,(0,t.not)(l(e,n,r))):a}e.noPropertyInData=d;function f(e){return e?Object.keys(e).filter(e=>e!==`__proto__`):[]}e.allSchemaProperties=f;function p(e,t){return f(t).filter(r=>!(0,n.alwaysValidSchema)(e,t[r]))}e.schemaProperties=p;function m({schemaCode:e,data:n,it:{gen:i,topSchemaRef:a,schemaPath:o,errorPath:s},it:c},l,u,d){let f=d?(0,t._)`${e}, ${n}, ${a}${o}`:n,p=[[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,s)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&p.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);let m=(0,t._)`${f}, ${i.object(...p)}`;return u===t.nil?(0,t._)`${l}(${m})`:(0,t._)`${l}.call(${u}, ${m})`}e.callValidateCode=m;var h=(0,t._)`new RegExp`;function g({gen:e,it:{opts:n}},r){let a=n.unicodeRegExp?`u`:``,{regExp:o}=n.code,s=o(r,a);return e.scopeValue(`pattern`,{key:s.toString(),ref:s,code:(0,t._)`${o.code===`new RegExp`?h:(0,i.useFunc)(e,o)}(${r}, ${a})`})}e.usePattern=g;function _(e){let{gen:r,data:i,keyword:a,it:o}=e,s=r.name(`valid`);if(o.allErrors){let e=r.let(`valid`,!0);return c(()=>r.assign(e,!1)),e}return r.var(s,!0),c(()=>r.break()),s;function c(o){let c=r.const(`len`,(0,t._)`${i}.length`);r.forRange(`i`,0,c,i=>{e.subschema({keyword:a,dataProp:i,dataPropType:n.Type.Num},s),r.if((0,t.not)(s),o)})}}e.validateArray=_;function v(e){let{gen:r,schema:i,keyword:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(i.some(e=>(0,n.alwaysValidSchema)(o,e))&&!o.opts.unevaluated)return;let s=r.let(`valid`,!1),c=r.name(`_valid`);r.block(()=>i.forEach((n,i)=>{let o=e.subschema({keyword:a,schemaProp:i,compositeRule:!0},c);r.assign(s,(0,t._)`${s} || ${c}`),e.mergeValidEvaluated(o,c)||r.if((0,t.not)(s))})),e.result(s,()=>e.reset(),()=>e.error(!0))}e.validateUnion=v})),sr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;var t=U(),n=$n(),r=or(),i=er();function a(e,n){let{gen:r,keyword:i,schema:a,parentSchema:o,it:s}=e,c=n.macro.call(s.self,a,o,s),l=u(r,i,c);s.opts.validateSchema!==!1&&s.self.validateSchema(c,!0);let d=r.name(`valid`);e.subschema({schema:c,schemaPath:t.nil,errSchemaPath:`${s.errSchemaPath}/${i}`,topSchemaRef:l,compositeRule:!0},d),e.pass(d,()=>e.error(!0))}e.macroKeywordCode=a;function o(e,i){let{gen:a,keyword:o,schema:d,parentSchema:f,$data:p,it:m}=e;l(m,i);let h=u(a,o,!p&&i.compile?i.compile.call(m.self,d,f,m):i.validate),g=a.let(`valid`);e.block$data(g,_),e.ok(i.valid??g);function _(){if(i.errors===!1)b(),i.modifying&&s(e),x(()=>e.error());else{let t=i.async?v():y();i.modifying&&s(e),x(()=>c(e,t))}}function v(){let e=a.let(`ruleErrs`,null);return a.try(()=>b((0,t._)`await `),n=>a.assign(g,!1).if((0,t._)`${n} instanceof ${m.ValidationError}`,()=>a.assign(e,(0,t._)`${n}.errors`),()=>a.throw(n))),e}function y(){let e=(0,t._)`${h}.errors`;return a.assign(e,null),b(t.nil),e}function b(o=i.async?(0,t._)`await `:t.nil){let s=m.opts.passContext?n.default.this:n.default.self,c=!(`compile`in i&&!p||i.schema===!1);a.assign(g,(0,t._)`${o}${(0,r.callValidateCode)(e,h,s,c)}`,i.modifying)}function x(e){a.if((0,t.not)(i.valid??g),e)}}e.funcKeywordCode=o;function s(e){let{gen:n,data:r,it:i}=e;n.if(i.parentData,()=>n.assign(r,(0,t._)`${i.parentData}[${i.parentDataProperty}]`))}function c(e,r){let{gen:a}=e;a.if((0,t._)`Array.isArray(${r})`,()=>{a.assign(n.default.vErrors,(0,t._)`${n.default.vErrors} === null ? ${r} : ${n.default.vErrors}.concat(${r})`).assign(n.default.errors,(0,t._)`${n.default.vErrors}.length`),(0,i.extendErrors)(e)},()=>e.error())}function l({schemaEnv:e},t){if(t.async&&!e.$async)throw Error(`async keyword in sync schema`)}function u(e,n,r){if(r===void 0)throw Error(`keyword "${n}" failed to compile`);return e.scopeValue(`keyword`,typeof r==`function`?{ref:r}:{ref:r,code:(0,t.stringify)(r)})}function d(e,t,n=!1){return!t.length||t.some(t=>t===`array`?Array.isArray(e):t===`object`?e&&typeof e==`object`&&!Array.isArray(e):typeof e==t||n&&e===void 0)}e.validSchemaType=d;function f({schema:e,opts:t,self:n,errSchemaPath:r},i,a){if(Array.isArray(i.keyword)?!i.keyword.includes(a):i.keyword!==a)throw Error(`ajv implementation error`);let o=i.dependencies;if(o?.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw Error(`parent schema must have dependencies of ${a}: ${o.join(`,`)}`);if(i.validateSchema&&!i.validateSchema(e[a])){let e=`keyword "${a}" value is invalid at path "${r}": `+n.errorsText(i.validateSchema.errors);if(t.validateSchema===`log`)n.logger.error(e);else throw Error(e)}}e.validateKeywordUsage=f})),cr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;var t=U(),n=W();function r(e,{keyword:r,schemaProp:i,schema:a,schemaPath:o,errSchemaPath:s,topSchemaRef:c}){if(r!==void 0&&a!==void 0)throw Error(`both "keyword" and "schema" passed, only one allowed`);if(r!==void 0){let a=e.schema[r];return i===void 0?{schema:a,schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${r}`}:{schema:a[i],schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}${(0,t.getProperty)(i)}`,errSchemaPath:`${e.errSchemaPath}/${r}/${(0,n.escapeFragment)(i)}`}}if(a!==void 0){if(o===void 0||s===void 0||c===void 0)throw Error(`"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"`);return{schema:a,schemaPath:o,topSchemaRef:c,errSchemaPath:s}}throw Error(`either "keyword" or "schema" must be passed`)}e.getSubschema=r;function i(e,r,{dataProp:i,dataPropType:a,data:o,dataTypes:s,propertyName:c}){if(o!==void 0&&i!==void 0)throw Error(`both "data" and "dataProp" passed, only one allowed`);let{gen:l}=r;if(i!==void 0){let{errorPath:o,dataPathArr:s,opts:c}=r;u(l.let(`data`,(0,t._)`${r.data}${(0,t.getProperty)(i)}`,!0)),e.errorPath=(0,t.str)`${o}${(0,n.getErrorPath)(i,a,c.jsPropertySyntax)}`,e.parentDataProperty=(0,t._)`${i}`,e.dataPathArr=[...s,e.parentDataProperty]}o!==void 0&&(u(o instanceof t.Name?o:l.let(`data`,o,!0)),c!==void 0&&(e.propertyName=c)),s&&(e.dataTypes=s);function u(t){e.data=t,e.dataLevel=r.dataLevel+1,e.dataTypes=[],r.definedProperties=new Set,e.parentData=r.data,e.dataNames=[...r.dataNames,t]}}e.extendSubschemaData=i;function a(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:r,createErrors:i,allErrors:a}){r!==void 0&&(e.compositeRule=r),i!==void 0&&(e.createErrors=i),a!==void 0&&(e.allErrors=a),e.jtdDiscriminator=t,e.jtdMetadata=n}e.extendSubschemaMode=a})),lr=s(((e,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),ur=s(((e,t)=>{var n=t.exports=function(e,t,n){typeof t==`function`&&(n=t,t={}),n=t.cb||n;var i=typeof n==`function`?n:n.pre||function(){},a=n.post||function(){};r(t,i,a,e,``,e)};n.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},n.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},n.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},n.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function r(e,t,a,o,s,c,l,u,d,f){if(o&&typeof o==`object`&&!Array.isArray(o)){for(var p in t(o,s,c,l,u,d,f),o){var m=o[p];if(Array.isArray(m)){if(p in n.arrayKeywords)for(var h=0;h<m.length;h++)r(e,t,a,m[h],s+`/`+p+`/`+h,c,s,p,o,h)}else if(p in n.propsKeywords){if(m&&typeof m==`object`)for(var g in m)r(e,t,a,m[g],s+`/`+p+`/`+i(g),c,s,p,o,g)}else (p in n.keywords||e.allKeys&&!(p in n.skipKeywords))&&r(e,t,a,m,s+`/`+p,c,s,p,o)}a(o,s,c,l,u,d,f)}}function i(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}})),dr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;var t=W(),n=lr(),r=ur(),i=new Set([`type`,`format`,`pattern`,`maxLength`,`minLength`,`maxProperties`,`minProperties`,`maxItems`,`minItems`,`maximum`,`minimum`,`uniqueItems`,`multipleOf`,`required`,`enum`,`const`]);function a(e,t=!0){return typeof e==`boolean`?!0:t===!0?!s(e):t?c(e)<=t:!1}e.inlineRef=a;var o=new Set([`$ref`,`$recursiveRef`,`$recursiveAnchor`,`$dynamicRef`,`$dynamicAnchor`]);function s(e){for(let t in e){if(o.has(t))return!0;let n=e[t];if(Array.isArray(n)&&n.some(s)||typeof n==`object`&&s(n))return!0}return!1}function c(e){let n=0;for(let r in e)if(r===`$ref`||(n++,!i.has(r)&&(typeof e[r]==`object`&&(0,t.eachItem)(e[r],e=>n+=c(e)),n===1/0)))return 1/0;return n}function l(e,t=``,n){return n!==!1&&(t=f(t)),u(e,e.parse(t))}e.getFullPath=l;function u(e,t){return e.serialize(t).split(`#`)[0]+`#`}e._getFullPath=u;var d=/#\/?$/;function f(e){return e?e.replace(d,``):``}e.normalizeId=f;function p(e,t,n){return n=f(n),e.resolve(t,n)}e.resolveUrl=p;var m=/^[a-z_][-a-z0-9._]*$/i;function h(e,t){if(typeof e==`boolean`)return{};let{schemaId:i,uriResolver:a}=this.opts,o=f(e[i]||t),s={"":o},c=l(a,o,!1),u={},d=new Set;return r(e,{allKeys:!0},(e,t,n,r)=>{if(r===void 0)return;let a=c+t,o=s[r];typeof e[i]==`string`&&(o=l.call(this,e[i])),g.call(this,e.$anchor),g.call(this,e.$dynamicAnchor),s[t]=o;function l(t){let n=this.opts.uriResolver.resolve;if(t=f(o?n(o,t):t),d.has(t))throw h(t);d.add(t);let r=this.refs[t];return typeof r==`string`&&(r=this.refs[r]),typeof r==`object`?p(e,r.schema,t):t!==f(a)&&(t[0]===`#`?(p(e,u[t],t),u[t]=e):this.refs[t]=a),t}function g(e){if(typeof e==`string`){if(!m.test(e))throw Error(`invalid anchor "${e}"`);l.call(this,`#${e}`)}}}),u;function p(e,t,r){if(t!==void 0&&!n(e,t))throw h(r)}function h(e){return Error(`reference "${e}" resolves to more than one schema`)}}e.getSchemaRefs=h})),fr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;var t=tr(),n=ir(),r=rr(),i=ir(),a=ar(),o=sr(),s=cr(),c=U(),l=$n(),u=dr(),d=W(),f=er();function p(e){if(S(e)&&(w(e),x(e))){_(e);return}m(e,()=>(0,t.topBoolOrEmptySchema)(e))}e.validateFunctionCode=p;function m({gen:e,validateName:t,schema:n,schemaEnv:r,opts:i},a){i.code.es5?e.func(t,(0,c._)`${l.default.data}, ${l.default.valCxt}`,r.$async,()=>{e.code((0,c._)`"use strict"; ${y(n,i)}`),g(e,i),e.code(a)}):e.func(t,(0,c._)`${l.default.data}, ${h(i)}`,r.$async,()=>e.code(y(n,i)).code(a))}function h(e){return(0,c._)`{${l.default.instancePath}="", ${l.default.parentData}, ${l.default.parentDataProperty}, ${l.default.rootData}=${l.default.data}${e.dynamicRef?(0,c._)`, ${l.default.dynamicAnchors}={}`:c.nil}}={}`}function g(e,t){e.if(l.default.valCxt,()=>{e.var(l.default.instancePath,(0,c._)`${l.default.valCxt}.${l.default.instancePath}`),e.var(l.default.parentData,(0,c._)`${l.default.valCxt}.${l.default.parentData}`),e.var(l.default.parentDataProperty,(0,c._)`${l.default.valCxt}.${l.default.parentDataProperty}`),e.var(l.default.rootData,(0,c._)`${l.default.valCxt}.${l.default.rootData}`),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`${l.default.valCxt}.${l.default.dynamicAnchors}`)},()=>{e.var(l.default.instancePath,(0,c._)`""`),e.var(l.default.parentData,(0,c._)`undefined`),e.var(l.default.parentDataProperty,(0,c._)`undefined`),e.var(l.default.rootData,l.default.data),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`{}`)})}function _(e){let{schema:t,opts:n,gen:r}=e;m(e,()=>{n.$comment&&t.$comment&&A(e),D(e),r.let(l.default.vErrors,null),r.let(l.default.errors,0),n.unevaluated&&v(e),T(e),j(e)})}function v(e){let{gen:t,validateName:n}=e;e.evaluated=t.const(`evaluated`,(0,c._)`${n}.evaluated`),t.if((0,c._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,c._)`${e.evaluated}.props`,(0,c._)`undefined`)),t.if((0,c._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,c._)`${e.evaluated}.items`,(0,c._)`undefined`))}function y(e,t){let n=typeof e==`object`&&e[t.schemaId];return n&&(t.code.source||t.code.process)?(0,c._)`/*# sourceURL=${n} */`:c.nil}function b(e,n){if(S(e)&&(w(e),x(e))){C(e,n);return}(0,t.boolOrEmptySchema)(e,n)}function x({schema:e,self:t}){if(typeof e==`boolean`)return!e;for(let n in e)if(t.RULES.all[n])return!0;return!1}function S(e){return typeof e.schema!=`boolean`}function C(e,t){let{schema:n,gen:r,opts:i}=e;i.$comment&&n.$comment&&A(e),O(e),k(e);let a=r.const(`_errs`,l.default.errors);T(e,a),r.var(t,(0,c._)`${a} === ${l.default.errors}`)}function w(e){(0,d.checkUnknownRules)(e),E(e)}function T(e,t){if(e.opts.jtd)return N(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);N(e,r,!(0,n.coerceAndCheckDataType)(e,r),t)}function E(e){let{schema:t,errSchemaPath:n,opts:r,self:i}=e;t.$ref&&r.ignoreKeywordsWithRef&&(0,d.schemaHasRulesButRef)(t,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function D(e){let{schema:t,opts:n}=e;t.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,d.checkStrictMode)(e,`default is ignored in the schema root`)}function O(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,u.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function k(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(`async schema in sync schema`)}function A({gen:e,schemaEnv:t,schema:n,errSchemaPath:r,opts:i}){let a=n.$comment;if(i.$comment===!0)e.code((0,c._)`${l.default.self}.logger.log(${a})`);else if(typeof i.$comment==`function`){let n=(0,c.str)`${r}/$comment`,i=e.scopeValue(`root`,{ref:t.root});e.code((0,c._)`${l.default.self}.opts.$comment(${a}, ${n}, ${i}.schema)`)}}function j(e){let{gen:t,schemaEnv:n,validateName:r,ValidationError:i,opts:a}=e;n.$async?t.if((0,c._)`${l.default.errors} === 0`,()=>t.return(l.default.data),()=>t.throw((0,c._)`new ${i}(${l.default.vErrors})`)):(t.assign((0,c._)`${r}.errors`,l.default.vErrors),a.unevaluated&&M(e),t.return((0,c._)`${l.default.errors} === 0`))}function M({gen:e,evaluated:t,props:n,items:r}){n instanceof c.Name&&e.assign((0,c._)`${t}.props`,n),r instanceof c.Name&&e.assign((0,c._)`${t}.items`,r)}function N(e,t,n,a){let{gen:o,schema:s,data:u,allErrors:f,opts:p,self:m}=e,{RULES:h}=m;if(s.$ref&&(p.ignoreKeywordsWithRef||!(0,d.schemaHasRulesButRef)(s,h))){o.block(()=>ce(e,`$ref`,h.all.$ref.definition));return}p.jtd||P(e,t),o.block(()=>{for(let e of h.rules)g(e);g(h.post)});function g(d){(0,r.shouldUseGroup)(s,d)&&(d.type?(o.if((0,i.checkDataType)(d.type,u,p.strictNumbers)),ee(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):ee(e,d),f||o.if((0,c._)`${l.default.errors} === ${a||0}`))}}function ee(e,t){let{gen:n,schema:i,opts:{useDefaults:o}}=e;o&&(0,a.assignDefaults)(e,t.type),n.block(()=>{for(let n of t.rules)(0,r.shouldUseRule)(i,n)&&ce(e,n.keyword,n.definition,t.type)})}function P(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(F(e,t),e.opts.allowUnionTypes||te(e,t),ne(e,e.dataTypes))}function F(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{ie(e.dataTypes,t)||oe(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),ae(e,t)}}function te(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&oe(e,`use allowUnionTypes to allow union type keyword`)}function ne(e,t){let n=e.self.RULES.all;for(let i in n){let a=n[i];if(typeof a==`object`&&(0,r.shouldUseRule)(e.schema,a)){let{type:n}=a.definition;n.length&&!n.some(e=>re(t,e))&&oe(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function re(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function ie(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function ae(e,t){let n=[];for(let r of e.dataTypes)ie(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function oe(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,d.checkStrictMode)(e,t,e.opts.strictTypes)}var se=class{constructor(e,t,n){if((0,o.validateKeywordUsage)(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,d.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const(`vSchema`,de(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,o.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);(`code`in t?t.trackErrors:t.errors!==!1)&&(this.errsCount=e.gen.const(`_errs`,l.default.errors))}result(e,t,n){this.failResult((0,c.not)(e),t,n)}failResult(e,t,n){this.gen.if(e),n?n():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,c.not)(e),void 0,t)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:t}=this;this.fail((0,c._)`${t} !== undefined && (${(0,c.or)(this.invalid$data(),e)})`)}error(e,t,n){if(t){this.setParams(t),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,t){(e?f.reportExtraError:f.reportError)(this,this.def.error,t)}$dataError(){(0,f.reportError)(this,this.def.$dataError||f.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error(`add "trackErrors" to keyword definition`);(0,f.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,n=c.nil){this.gen.block(()=>{this.check$data(e,n),t()})}check$data(e=c.nil,t=c.nil){if(!this.$data)return;let{gen:n,schemaCode:r,schemaType:i,def:a}=this;n.if((0,c.or)((0,c._)`${r} === undefined`,t)),e!==c.nil&&n.assign(e,!0),(i.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==c.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:t,schemaType:n,def:r,it:a}=this;return(0,c.or)(o(),s());function o(){if(n.length){if(!(t instanceof c.Name))throw Error(`ajv implementation error`);let e=Array.isArray(n)?n:[n];return(0,c._)`${(0,i.checkDataTypes)(e,t,a.opts.strictNumbers,i.DataType.Wrong)}`}return c.nil}function s(){if(r.validateSchema){let n=e.scopeValue(`validate$data`,{ref:r.validateSchema});return(0,c._)`!${n}(${t})`}return c.nil}}subschema(e,t){let n=(0,s.getSubschema)(this.it,e);(0,s.extendSubschemaData)(n,this.it,e),(0,s.extendSubschemaMode)(n,e);let r={...this.it,...n,items:void 0,props:void 0};return b(r,t),r}mergeEvaluated(e,t){let{it:n,gen:r}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=d.mergeEvaluated.props(r,e.props,n.props,t)),n.items!==!0&&e.items!==void 0&&(n.items=d.mergeEvaluated.items(r,e.items,n.items,t)))}mergeValidEvaluated(e,t){let{it:n,gen:r}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return r.if(t,()=>this.mergeEvaluated(e,c.Name)),!0}};e.KeywordCxt=se;function ce(e,t,n,r){let i=new se(e,n,t);`code`in n?n.code(i,r):i.$data&&n.validate?(0,o.funcKeywordCode)(i,n):`macro`in n?(0,o.macroKeywordCode)(i,n):(n.compile||n.validate)&&(0,o.funcKeywordCode)(i,n)}var le=/^\/(?:[^~]|~0|~1)*$/,ue=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function de(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return l.default.rootData;if(e[0]===`/`){if(!le.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=l.default.rootData}else{let o=ue.exec(e);if(!o)throw Error(`Invalid JSON-pointer: ${e}`);let s=+o[1];if(i=o[2],i===`#`){if(s>=t)throw Error(u(`property/index`,s));return r[t-s]}if(s>t)throw Error(u(`data`,s));if(a=n[t-s],!i)return a}let o=a,s=i.split(`/`);for(let e of s)e&&(a=(0,c._)`${a}${(0,c.getProperty)((0,d.unescapeJsonPointer)(e))}`,o=(0,c._)`${o} && ${a}`);return o;function u(e,n){return`Cannot access ${e} ${n} levels up, current level is ${t}`}}e.getData=de})),pr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=class extends Error{constructor(e){super(`validation failed`),this.errors=e,this.ajv=this.validation=!0}}})),mr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=dr();e.default=class extends Error{constructor(e,n,r,i){super(i||`can't resolve reference ${r} from id ${n}`),this.missingRef=(0,t.resolveUrl)(e,n,r),this.missingSchema=(0,t.normalizeId)((0,t.getFullPath)(e,this.missingRef))}}})),hr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;var t=U(),n=pr(),r=$n(),i=dr(),a=W(),o=fr(),s=class{constructor(e){this.refs={},this.dynamicAnchors={};let t;typeof e.schema==`object`&&(t=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=e.baseId??(0,i.normalizeId)(t?.[e.schemaId||`$id`]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=t?.$async,this.refs={}}};e.SchemaEnv=s;function c(e){let a=d.call(this,e);if(a)return a;let s=(0,i.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:c,lines:l}=this.opts.code,{ownProperties:u}=this.opts,f=new t.CodeGen(this.scope,{es5:c,lines:l,ownProperties:u}),p;e.$async&&(p=f.scopeValue(`Error`,{ref:n.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));let m=f.scopeName(`validate`);e.validateName=m;let h={gen:f,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[t.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:f.scopeValue(`schema`,this.opts.code.source===!0?{ref:e.schema,code:(0,t.stringify)(e.schema)}:{ref:e.schema}),validateName:m,ValidationError:p,schema:e.schema,schemaEnv:e,rootId:s,baseId:e.baseId||s,schemaPath:t.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?``:`#`),errorPath:(0,t._)`""`,opts:this.opts,self:this},g;try{this._compilations.add(e),(0,o.validateFunctionCode)(h),f.optimize(this.opts.code.optimize);let n=f.toString();g=`${f.scopeRefs(r.default.scope)}return ${n}`,this.opts.code.process&&(g=this.opts.code.process(g,e));let i=Function(`${r.default.self}`,`${r.default.scope}`,g)(this,this.scope.get());if(this.scope.value(m,{ref:i}),i.errors=null,i.schema=e.schema,i.schemaEnv=e,e.$async&&(i.$async=!0),this.opts.code.source===!0&&(i.source={validateName:m,validateCode:n,scopeValues:f._values}),this.opts.unevaluated){let{props:e,items:n}=h;i.evaluated={props:e instanceof t.Name?void 0:e,items:n instanceof t.Name?void 0:n,dynamicProps:e instanceof t.Name,dynamicItems:n instanceof t.Name},i.source&&(i.source.evaluated=(0,t.stringify)(i.evaluated))}return e.validate=i,e}catch(t){throw delete e.validate,delete e.validateName,g&&this.logger.error(`Error compiling schema, function code:`,g),t}finally{this._compilations.delete(e)}}e.compileSchema=c;function l(e,t,n){n=(0,i.resolveUrl)(this.opts.uriResolver,t,n);let r=e.refs[n];if(r)return r;let a=p.call(this,e,n);if(a===void 0){let r=e.localRefs?.[n],{schemaId:i}=this.opts;r&&(a=new s({schema:r,schemaId:i,root:e,baseId:t}))}if(a!==void 0)return e.refs[n]=u.call(this,a)}e.resolveRef=l;function u(e){return(0,i.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:c.call(this,e)}function d(e){for(let t of this._compilations)if(f(t,e))return t}e.getCompilingSchema=d;function f(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function p(e,t){let n;for(;typeof(n=this.refs[t])==`string`;)t=n;return n||this.schemas[t]||m.call(this,e,t)}function m(e,t){let n=this.opts.uriResolver.parse(t),r=(0,i._getFullPath)(this.opts.uriResolver,n),a=(0,i.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&r===a)return g.call(this,n,e);let o=(0,i.normalizeId)(r),l=this.refs[o]||this.schemas[o];if(typeof l==`string`){let t=m.call(this,e,l);return typeof t?.schema==`object`?g.call(this,n,t):void 0}if(typeof l?.schema==`object`){if(l.validate||c.call(this,l),o===(0,i.normalizeId)(t)){let{schema:t}=l,{schemaId:n}=this.opts,r=t[n];return r&&(a=(0,i.resolveUrl)(this.opts.uriResolver,a,r)),new s({schema:t,schemaId:n,root:e,baseId:a})}return g.call(this,n,l)}}e.resolveSchema=m;var h=new Set([`properties`,`patternProperties`,`enum`,`dependencies`,`definitions`]);function g(e,{baseId:t,schema:n,root:r}){if(e.fragment?.[0]!==`/`)return;for(let r of e.fragment.slice(1).split(`/`)){if(typeof n==`boolean`)return;let e=n[(0,a.unescapeFragment)(r)];if(e===void 0)return;n=e;let o=typeof n==`object`&&n[this.opts.schemaId];!h.has(r)&&o&&(t=(0,i.resolveUrl)(this.opts.uriResolver,t,o))}let o;if(typeof n!=`boolean`&&n.$ref&&!(0,a.schemaHasRulesButRef)(n,this.RULES)){let e=(0,i.resolveUrl)(this.opts.uriResolver,t,n.$ref);o=m.call(this,r,e)}let{schemaId:c}=this.opts;if(o||=new s({schema:n,schemaId:c,root:r,baseId:t}),o.schema!==o.root.schema)return o}})),gr=c({$id:()=>_r,additionalProperties:()=>!1,default:()=>Sr,description:()=>vr,properties:()=>xr,required:()=>br,type:()=>yr}),_r,vr,yr,br,xr,Sr,Cr=o((()=>{_r=`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`,vr=`Meta-schema for $data reference (JSON AnySchema extension proposal)`,yr=`object`,br=[`$data`],xr={$data:{type:`string`,anyOf:[{format:`relative-json-pointer`},{format:`json-pointer`}]}},Sr={$id:_r,description:vr,type:yr,required:br,properties:xr,additionalProperties:!1}})),wr=s(((e,t)=>{var n=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),r=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),i=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),a=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),o=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function s(e){let t=``,n=0,r=0;for(r=0;r<e.length;r++)if(n=e[r].charCodeAt(0),n!==48){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r];break}for(r+=1;r<e.length;r++){if(n=e[r].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r]}return t}var c=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function l(e){return e.length=0,!0}function u(e,t,n){if(e.length){let r=s(e);if(r!==``)t.push(r);else return n.error=!0,!1;e.length=0}return!0}function d(e){let t=0,n={error:!1,address:``,zone:``},r=[],i=[],a=!1,o=!1,c=u;for(let s=0;s<e.length;s++){let u=e[s];if(!(u===`[`||u===`]`))if(u===`:`){if(a===!0&&(o=!0),!c(i,r,n))break;if(++t>7){n.error=!0;break}s>0&&e[s-1]===`:`&&(a=!0),r.push(`:`);continue}else if(u===`%`){if(!c(i,r,n))break;c=l}else{i.push(u);continue}}return i.length&&(c===l?n.zone=i.join(``):o?r.push(i.join(``)):r.push(s(i))),n.address=r.join(``),n}function f(e){if(p(e,`:`)<2)return{host:e,isIPV6:!1};let t=d(e);if(t.error)return{host:e,isIPV6:!1};{let e=t.address,n=t.address;return t.zone&&(e+=`%`+t.zone,n+=`%25`+t.zone),{host:e,isIPV6:!0,escapedHost:n}}}function p(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function m(e){let t=e,n=[],r=-1,i=0;for(;i=t.length;){if(i===1){if(t===`.`)break;if(t===`/`){n.push(`/`);break}else{n.push(t);break}}else if(i===2){if(t[0]===`.`){if(t[1]===`.`)break;if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&(t[1]===`.`||t[1]===`/`)){n.push(`/`);break}}else if(i===3&&t===`/..`){n.length!==0&&n.pop(),n.push(`/`);break}if(t[0]===`.`){if(t[1]===`.`){if(t[2]===`/`){t=t.slice(3);continue}}else if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&t[1]===`.`){if(t[2]===`/`){t=t.slice(2);continue}else if(t[2]===`.`&&t[3]===`/`){t=t.slice(3),n.length!==0&&n.pop();continue}}if((r=t.indexOf(`/`,1))===-1){n.push(t);break}else n.push(t.slice(0,r)),t=t.slice(r)}return n.join(``)}var h={"@":`%40`,"/":`%2F`,"?":`%3F`,"#":`%23`,":":`%3A`},g=/[@/?#:]/g,_=/[@/?#]/g;function v(e,t){let n=t?_:g;return n.lastIndex=0,e.replace(n,e=>h[e])}function y(e,t=!1){if(e.indexOf(`%`)===-1)return e;let n=``;for(let r=0;r<e.length;r++){if(e[r]===`%`&&r+2<e.length){let o=e.slice(r+1,r+3);if(i(o)){let e=o.toUpperCase(),i=String.fromCharCode(parseInt(e,16));t&&a(i)?n+=i:n+=`%`+e,r+=2;continue}}n+=e[r]}return n}function b(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(i(r)){let e=r.toUpperCase(),i=String.fromCharCode(parseInt(e,16));i!==`.`&&a(i)?t+=i:t+=`%`+e,n+=2;continue}}o(e[n])?t+=e[n]:t+=escape(e[n])}return t}function x(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(i(r)){t+=`%`+r.toUpperCase(),n+=2;continue}}t+=escape(e[n])}return t}function S(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push(`@`)),e.host!==void 0){let n=unescape(e.host);if(!r(n)){let e=f(n);n=e.isIPV6===!0?`[${e.escapedHost}]`:v(n,!1)}t.push(n)}return(typeof e.port==`number`||typeof e.port==`string`)&&(t.push(`:`),t.push(String(e.port))),t.length?t.join(``):void 0}t.exports={nonSimpleDomain:c,recomposeAuthority:S,reescapeHostDelimiters:v,normalizePercentEncoding:y,normalizePathEncoding:b,escapePreservingEscapes:x,removeDotSegments:m,isIPv4:r,isUUID:n,normalizeIPv6:f,stringArrayToHexStripped:s}})),Tr=s(((e,t)=>{var{isUUID:n}=wr(),r=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,i=[`http`,`https`,`ws`,`wss`,`urn`,`urn:uuid`];function a(e){return i.indexOf(e)!==-1}function o(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]===`w`||e.scheme[0]===`W`)&&(e.scheme[1]===`s`||e.scheme[1]===`S`)&&(e.scheme[2]===`s`||e.scheme[2]===`S`):!1}function s(e){return e.host||(e.error=e.error||`HTTP URIs must have a host.`),e}function c(e){let t=String(e.scheme).toLowerCase()===`https`;return(e.port===(t?443:80)||e.port===``)&&(e.port=void 0),e.path||=`/`,e}function l(e){return e.secure=o(e),e.resourceName=(e.path||`/`)+(e.query?`?`+e.query:``),e.path=void 0,e.query=void 0,e}function u(e){if((e.port===(o(e)?443:80)||e.port===``)&&(e.port=void 0),typeof e.secure==`boolean`&&(e.scheme=e.secure?`wss`:`ws`,e.secure=void 0),e.resourceName){let[t,n]=e.resourceName.split(`?`);e.path=t&&t!==`/`?t:void 0,e.query=n,e.resourceName=void 0}return e.fragment=void 0,e}function d(e,t){if(!e.path)return e.error=`URN can not be parsed`,e;let n=e.path.match(r);if(n){let r=t.scheme||e.scheme||`urn`;e.nid=n[1].toLowerCase(),e.nss=n[2];let i=y(`${r}:${t.nid||e.nid}`);e.path=void 0,i&&(e=i.parse(e,t))}else e.error=e.error||`URN can not be parsed.`;return e}function f(e,t){if(e.nid===void 0)throw Error(`URN without nid cannot be serialized`);let n=t.scheme||e.scheme||`urn`,r=e.nid.toLowerCase(),i=y(`${n}:${t.nid||r}`);i&&(e=i.serialize(e,t));let a=e,o=e.nss;return a.path=`${r||t.nid}:${o}`,t.skipEscape=!0,a}function p(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!n(r.uuid))&&(r.error=r.error||`UUID is not valid.`),r}function m(e){let t=e;return t.nss=(e.uuid||``).toLowerCase(),t}var h={scheme:`http`,domainHost:!0,parse:s,serialize:c},g={scheme:`https`,domainHost:h.domainHost,parse:s,serialize:c},_={scheme:`ws`,domainHost:!0,parse:l,serialize:u},v={http:h,https:g,ws:_,wss:{scheme:`wss`,domainHost:_.domainHost,parse:_.parse,serialize:_.serialize},urn:{scheme:`urn`,parse:d,serialize:f,skipNormalize:!0},"urn:uuid":{scheme:`urn:uuid`,parse:p,serialize:m,skipNormalize:!0}};Object.setPrototypeOf(v,null);function y(e){return e&&(v[e]||v[e.toLowerCase()])||void 0}t.exports={wsIsSecure:o,SCHEMES:v,isValidSchemeName:a,getSchemeHandler:y}})),Er=s(((e,t)=>{var{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizePercentEncoding:a,normalizePathEncoding:o,escapePreservingEscapes:s,reescapeHostDelimiters:c,isIPv4:l,nonSimpleDomain:u}=wr(),{SCHEMES:d,getSchemeHandler:f}=Tr();function p(e,t){return typeof e==`string`?e=S(e,t):typeof e==`object`&&(e=x(_(e,t),t)),e}function m(e,t,n){let r=n?Object.assign({scheme:`null`},n):{scheme:`null`},i=h(x(e,r),x(t,r),r,!0);return r.skipEscape=!0,_(i,r)}function h(e,t,n,i){let a={};return i||(e=x(_(e,n),n),t=x(_(t,n),n)),n||={},!n.tolerant&&t.scheme?(a.scheme=t.scheme,a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.path?(t.path[0]===`/`?a.path=r(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?a.path=`/`+t.path:e.path?a.path=e.path.slice(0,e.path.lastIndexOf(`/`)+1)+t.path:a.path=t.path,a.path=r(a.path)),a.query=t.query):(a.path=e.path,t.query===void 0?a.query=e.query:a.query=t.query),a.userinfo=e.userinfo,a.host=e.host,a.port=e.port),a.scheme=e.scheme),a.fragment=t.fragment,a}function g(e,t,n){let r=w(e,n),i=w(t,n);return r!==void 0&&i!==void 0&&r.toLowerCase()===i.toLowerCase()}function _(e,t){let n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:``},o=Object.assign({},t),c=[],l=f(o.scheme||n.scheme);l&&l.serialize&&l.serialize(n,o),n.path!==void 0&&(o.skipEscape?n.path=a(n.path):(n.path=s(n.path),n.scheme!==void 0&&(n.path=n.path.split(`%3A`).join(`:`)))),o.reference!==`suffix`&&n.scheme&&c.push(n.scheme,`:`);let u=i(n);if(u!==void 0&&(o.reference!==`suffix`&&c.push(`//`),c.push(u),n.path&&n.path[0]!==`/`&&c.push(`/`)),n.path!==void 0){let e=n.path;!o.absolutePath&&(!l||!l.absolutePath)&&(e=r(e)),u===void 0&&e[0]===`/`&&e[1]===`/`&&(e=`/%2F`+e.slice(2)),c.push(e)}return n.query!==void 0&&c.push(`?`,n.query),n.fragment!==void 0&&c.push(`#`,n.fragment),c.join(``)}var v=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function y(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!==`/`)return`URI path must start with "/" when authority is present.`;if(typeof e.port==`number`&&(e.port<0||e.port>65535))return`URI port is malformed.`}function b(e,t){let r=Object.assign({},t),i={scheme:void 0,userinfo:void 0,host:``,port:void 0,path:``,query:void 0,fragment:void 0},a=!1,s=!1;r.reference===`suffix`&&(e=r.scheme?r.scheme+`:`+e:`//`+e);let d=e.match(v);if(d){i.scheme=d[1],i.userinfo=d[3],i.host=d[4],i.port=parseInt(d[5],10),i.path=d[6]||``,i.query=d[7],i.fragment=d[8],isNaN(i.port)&&(i.port=d[5]);let t=y(i,d);if(t!==void 0&&(i.error=i.error||t,a=!0),i.host)if(l(i.host)===!1){let e=n(i.host);i.host=e.host.toLowerCase(),s=e.isIPV6}else s=!0;i.scheme===void 0&&i.userinfo===void 0&&i.host===void 0&&i.port===void 0&&i.query===void 0&&!i.path?i.reference=`same-document`:i.scheme===void 0?i.reference=`relative`:i.fragment===void 0?i.reference=`absolute`:i.reference=`uri`,r.reference&&r.reference!==`suffix`&&r.reference!==i.reference&&(i.error=i.error||`URI is not a `+r.reference+` reference.`);let p=f(r.scheme||i.scheme);if(!r.unicodeSupport&&(!p||!p.unicodeSupport)&&i.host&&(r.domainHost||p&&p.domainHost)&&s===!1&&u(i.host))try{i.host=URL.domainToASCII(i.host.toLowerCase())}catch(e){i.error=i.error||`Host's domain name can not be converted to ASCII: `+e}if((!p||p&&!p.skipNormalize)&&(e.indexOf(`%`)!==-1&&(i.scheme!==void 0&&(i.scheme=unescape(i.scheme)),i.host!==void 0&&(i.host=c(unescape(i.host),s))),i.path&&=o(i.path),i.fragment))try{i.fragment=encodeURI(decodeURIComponent(i.fragment))}catch{i.error=i.error||`URI malformed`}p&&p.parse&&p.parse(i,r)}else i.error=i.error||`URI can not be parsed.`;return{parsed:i,malformedAuthorityOrPort:a}}function x(e,t){return b(e,t).parsed}function S(e,t){return C(e,t).normalized}function C(e,t){let{parsed:n,malformedAuthorityOrPort:r}=b(e,t);return{normalized:r?e:_(n,t),malformedAuthorityOrPort:r}}function w(e,t){if(typeof e==`string`){let{normalized:n,malformedAuthorityOrPort:r}=C(e,t);return r?void 0:n}if(typeof e==`object`)return _(e,t)}var T={SCHEMES:d,normalize:p,resolve:m,resolveComponent:h,equal:g,serialize:_,parse:x};t.exports=T,t.exports.default=T,t.exports.fastUri=T})),Dr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=Er();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),Or=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=fr();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return t.KeywordCxt}});var n=U();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return n.Name}}),Object.defineProperty(e,`CodeGen`,{enumerable:!0,get:function(){return n.CodeGen}});var r=pr(),i=mr(),a=nr(),o=hr(),s=U(),c=dr(),l=ir(),u=W(),f=(Cr(),d(gr).default),p=Dr(),m=(e,t)=>new RegExp(e,t);m.code=`new RegExp`;var h=[`removeAdditional`,`useDefaults`,`coerceTypes`],g=new Set([`validate`,`serialize`,`parse`,`wrapper`,`root`,`schema`,`keyword`,`pattern`,`formats`,`validate$data`,`func`,`obj`,`Error`]),_={errorDataPath:``,format:"`validateFormats: false` can be used instead.",nullable:`"nullable" keyword is supported by default.`,jsonPointers:`Deprecated jsPropertySyntax can be used instead.`,extendRefs:`Deprecated ignoreKeywordsWithRef can be used instead.`,missingRefs:`Pass empty schema with $id that should be ignored to ajv.addSchema.`,processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:`"uniqueItems" keyword is always validated.`,unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:`Map is used as cache, schema object as key.`,serialize:`Map is used as cache, schema object as key.`,ajvErrors:`It is default now.`},v={ignoreKeywordsWithRef:``,jsPropertySyntax:``,unicode:`"minLength"/"maxLength" account for unicode characters by default.`},y=200;function b(e){let t=e.strict,n=e.code?.optimize,r=n===!0||n===void 0?1:n||0,i=e.code?.regExp??m,a=e.uriResolver??p.default;return{strictSchema:e.strictSchema??t??!0,strictNumbers:e.strictNumbers??t??!0,strictTypes:e.strictTypes??t??`log`,strictTuples:e.strictTuples??t??`log`,strictRequired:e.strictRequired??t??!1,code:e.code?{...e.code,optimize:r,regExp:i}:{optimize:r,regExp:i},loopRequired:e.loopRequired??y,loopEnum:e.loopEnum??y,meta:e.meta??!0,messages:e.messages??!0,inlineRefs:e.inlineRefs??!0,schemaId:e.schemaId??`$id`,addUsedSchema:e.addUsedSchema??!0,validateSchema:e.validateSchema??!0,validateFormats:e.validateFormats??!0,unicodeRegExp:e.unicodeRegExp??!0,int32range:e.int32range??!0,uriResolver:a}}var x=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...b(e)};let{es5:t,lines:n}=this.opts.code;this.scope=new s.ValueScope({scope:{},prefixes:g,es5:t,lines:n}),this.logger=k(e.logger);let r=e.validateFormats;e.validateFormats=!1,this.RULES=(0,a.getRules)(),S.call(this,_,e,`NOT SUPPORTED`),S.call(this,v,e,`DEPRECATED`,`warn`),this._metaOpts=D.call(this),e.formats&&T.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&E.call(this,e.keywords),typeof e.meta==`object`&&this.addMetaSchema(e.meta),w.call(this),e.validateFormats=r}_addVocabularies(){this.addKeyword(`$async`)}_addDefaultMetaSchema(){let{$data:e,meta:t,schemaId:n}=this.opts,r=f;n===`id`&&(r={...f},r.id=r.$id,delete r.$id),t&&e&&this.addMetaSchema(r,r[n],!1)}defaultMeta(){let{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta=typeof e==`object`?e[t]||e:void 0}validate(e,t){let n;if(typeof e==`string`){if(n=this.getSchema(e),!n)throw Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let r=n(t);return`$async`in n||(this.errors=n.errors),r}compile(e,t){let n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if(typeof this.opts.loadSchema!=`function`)throw Error(`options.loadSchema should be a function`);let{loadSchema:n}=this.opts;return r.call(this,e,t);async function r(e,t){await a.call(this,e.$schema);let n=this._addSchema(e,t);return n.validate||o.call(this,n)}async function a(e){e&&!this.getSchema(e)&&await r.call(this,{$ref:e},!0)}async function o(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof i.default))throw t;return s.call(this,t),await c.call(this,t.missingSchema),o.call(this,e)}}function s({missingSchema:e,missingRef:t}){if(this.refs[e])throw Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){let n=await l.call(this,e);this.refs[e]||await a.call(this,n.$schema),this.refs[e]||this.addSchema(n,e,t)}async function l(e){let t=this._loading[e];if(t)return t;try{return await(this._loading[e]=n(e))}finally{delete this._loading[e]}}}addSchema(e,t,n,r=this.opts.validateSchema){if(Array.isArray(e)){for(let t of e)this.addSchema(t,void 0,n,r);return this}let i;if(typeof e==`object`){let{schemaId:t}=this.opts;if(i=e[t],i!==void 0&&typeof i!=`string`)throw Error(`schema ${t} must be string`)}return t=(0,c.normalizeId)(t||i),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,r,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if(typeof e==`boolean`)return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!=`string`)throw Error(`$schema must be a string`);if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn(`meta-schema not available`),this.errors=null,!0;let r=this.validate(n,e);if(!r&&t){let e=`schema is invalid: `+this.errorsText();if(this.opts.validateSchema===`log`)this.logger.error(e);else throw Error(e)}return r}getSchema(e){let t;for(;typeof(t=C.call(this,e))==`string`;)e=t;if(t===void 0){let{schemaId:n}=this.opts,r=new o.SchemaEnv({schema:{},schemaId:n});if(t=o.resolveSchema.call(this,r,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case`undefined`:return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case`string`:{let t=C.call(this,e);return typeof t==`object`&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case`object`:{let t=e;this._cache.delete(t);let n=e[this.opts.schemaId];return n&&(n=(0,c.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw Error(`ajv.removeSchema: invalid parameter`)}}addVocabulary(e){for(let t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if(typeof e==`string`)n=e,typeof t==`object`&&(this.logger.warn(`these parameters are deprecated, see docs for addKeyword`),t.keyword=n);else if(typeof e==`object`&&t===void 0){if(t=e,n=t.keyword,Array.isArray(n)&&!n.length)throw Error(`addKeywords: keyword must be string or non-empty array`)}else throw Error(`invalid addKeywords parameters`);if(j.call(this,n,t),!t)return(0,u.eachItem)(n,e=>M.call(this,e)),this;ee.call(this,t);let r={...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)};return(0,u.eachItem)(n,r.type.length===0?e=>M.call(this,e,r):e=>r.type.forEach(t=>M.call(this,e,r,t))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t==`object`?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let n of t.rules){let t=n.rules.findIndex(t=>t.keyword===e);t>=0&&n.rules.splice(t,1)}return this}addFormat(e,t){return typeof t==`string`&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=`, `,dataVar:n=`data`}={}){return!e||e.length===0?`No errors`:e.map(e=>`${n}${e.instancePath} ${e.message}`).reduce((e,n)=>e+t+n)}$dataMetaSchema(e,t){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let r of t){let t=r.split(`/`).slice(1),i=e;for(let e of t)i=i[e];for(let e in n){let t=n[e];if(typeof t!=`object`)continue;let{$data:r}=t.definition,a=i[e];r&&a&&(i[e]=F(a))}}return e}_removeAllSchemas(e,t){for(let n in e){let r=e[n];(!t||t.test(n))&&(typeof r==`string`?delete e[n]:r&&!r.meta&&(this._cache.delete(r.schema),delete e[n]))}}_addSchema(e,t,n,r=this.opts.validateSchema,i=this.opts.addUsedSchema){let a,{schemaId:s}=this.opts;if(typeof e==`object`)a=e[s];else if(this.opts.jtd)throw Error(`schema must be object`);else if(typeof e!=`boolean`)throw Error(`schema must be object or boolean`);let l=this._cache.get(e);if(l!==void 0)return l;n=(0,c.normalizeId)(a||n);let u=c.getSchemaRefs.call(this,e,n);return l=new o.SchemaEnv({schema:e,schemaId:s,meta:t,baseId:n,localRefs:u}),this._cache.set(l.schema,l),i&&!n.startsWith(`#`)&&(n&&this._checkUnique(n),this.refs[n]=l),r&&this.validateSchema(e,!0),l}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):o.compileSchema.call(this,e),!e.validate)throw Error(`ajv implementation error`);return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{o.compileSchema.call(this,e)}finally{this.opts=t}}};x.ValidationError=r.default,x.MissingRefError=i.default,e.default=x;function S(e,t,n,r=`error`){for(let i in e){let a=i;a in t&&this.logger[r](`${n}: option ${i}. ${e[a]}`)}}function C(e){return e=(0,c.normalizeId)(e),this.schemas[e]||this.refs[e]}function w(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function T(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function E(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn(`keywords option as map is deprecated, pass array`);for(let t in e){let n=e[t];n.keyword||=t,this.addKeyword(n)}}function D(){let e={...this.opts};for(let t of h)delete e[t];return e}var O={log(){},warn(){},error(){}};function k(e){if(e===!1)return O;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw Error(`logger must implement log, warn and error methods`)}var A=/^[a-z_$][a-z0-9_$:-]*$/i;function j(e,t){let{RULES:n}=this;if((0,u.eachItem)(e,e=>{if(n.keywords[e])throw Error(`Keyword ${e} is already defined`);if(!A.test(e))throw Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!(`code`in t||`validate`in t))throw Error(`$data keyword must have "code" or "validate" function`)}function M(e,t,n){var r;let i=t?.post;if(n&&i)throw Error(`keyword with "post" flag cannot have "type"`);let{RULES:a}=this,o=i?a.post:a.rules.find(({type:e})=>e===n);if(o||(o={type:n,rules:[]},a.rules.push(o)),a.keywords[e]=!0,!t)return;let s={keyword:e,definition:{...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)}};t.before?N.call(this,o,s,t.before):o.rules.push(s),a.all[e]=s,(r=t.implements)==null||r.forEach(e=>this.addKeyword(e))}function N(e,t,n){let r=e.rules.findIndex(e=>e.keyword===n);r>=0?e.rules.splice(r,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function ee(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=F(t)),e.validateSchema=this.compile(t,!0))}var P={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function F(e){return{anyOf:[e,P]}}})),kr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),Ar=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.callRef=e.getValidate=void 0;var t=mr(),n=or(),r=U(),i=$n(),a=hr(),o=W(),s={keyword:`$ref`,schemaType:`string`,code(e){let{gen:n,schema:i,it:o}=e,{baseId:s,schemaEnv:u,validateName:d,opts:f,self:p}=o,{root:m}=u;if((i===`#`||i===`#/`)&&s===m.baseId)return g();let h=a.resolveRef.call(p,m,s,i);if(h===void 0)throw new t.default(o.opts.uriResolver,s,i);if(h instanceof a.SchemaEnv)return _(h);return v(h);function g(){if(u===m)return l(e,d,u,u.$async);let t=n.scopeValue(`root`,{ref:m});return l(e,(0,r._)`${t}.validate`,m,m.$async)}function _(t){l(e,c(e,t),t,t.$async)}function v(t){let a=n.scopeValue(`schema`,f.code.source===!0?{ref:t,code:(0,r.stringify)(t)}:{ref:t}),o=n.name(`valid`),s=e.subschema({schema:t,dataTypes:[],schemaPath:r.nil,topSchemaRef:a,errSchemaPath:i},o);e.mergeEvaluated(s),e.ok(o)}}};function c(e,t){let{gen:n}=e;return t.validate?n.scopeValue(`validate`,{ref:t.validate}):(0,r._)`${n.scopeValue(`wrapper`,{ref:t})}.validate`}e.getValidate=c;function l(e,t,a,s){let{gen:c,it:l}=e,{allErrors:u,schemaEnv:d,opts:f}=l,p=f.passContext?i.default.this:r.nil;s?m():h();function m(){if(!d.$async)throw Error(`async schema referenced by sync schema`);let i=c.let(`valid`);c.try(()=>{c.code((0,r._)`await ${(0,n.callValidateCode)(e,t,p)}`),_(t),u||c.assign(i,!0)},e=>{c.if((0,r._)`!(${e} instanceof ${l.ValidationError})`,()=>c.throw(e)),g(e),u||c.assign(i,!1)}),e.ok(i)}function h(){e.result((0,n.callValidateCode)(e,t,p),()=>_(t),()=>g(t))}function g(e){let t=(0,r._)`${e}.errors`;c.assign(i.default.vErrors,(0,r._)`${i.default.vErrors} === null ? ${t} : ${i.default.vErrors}.concat(${t})`),c.assign(i.default.errors,(0,r._)`${i.default.vErrors}.length`)}function _(e){if(!l.opts.unevaluated)return;let t=a?.validate?.evaluated;if(l.props!==!0)if(t&&!t.dynamicProps)t.props!==void 0&&(l.props=o.mergeEvaluated.props(c,t.props,l.props));else{let t=c.var(`props`,(0,r._)`${e}.evaluated.props`);l.props=o.mergeEvaluated.props(c,t,l.props,r.Name)}if(l.items!==!0)if(t&&!t.dynamicItems)t.items!==void 0&&(l.items=o.mergeEvaluated.items(c,t.items,l.items));else{let t=c.var(`items`,(0,r._)`${e}.evaluated.items`);l.items=o.mergeEvaluated.items(c,t,l.items,r.Name)}}}e.callRef=l,e.default=s})),jr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=kr(),n=Ar();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),Mr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U(),n=t.operators,r={maximum:{okStr:`<=`,ok:n.LTE,fail:n.GT},minimum:{okStr:`>=`,ok:n.GTE,fail:n.LT},exclusiveMaximum:{okStr:`<`,ok:n.LT,fail:n.GTE},exclusiveMinimum:{okStr:`>`,ok:n.GT,fail:n.LTE}};e.default={keyword:Object.keys(r),type:`number`,schemaType:`number`,$data:!0,error:{message:({keyword:e,schemaCode:n})=>(0,t.str)`must be ${r[e].okStr} ${n}`,params:({keyword:e,schemaCode:n})=>(0,t._)`{comparison: ${r[e].okStr}, limit: ${n}}`},code(e){let{keyword:n,data:i,schemaCode:a}=e;e.fail$data((0,t._)`${i} ${r[n].fail} ${a} || isNaN(${i})`)}}})),Nr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U();e.default={keyword:`multipleOf`,type:`number`,schemaType:`number`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,t._)`{multipleOf: ${e}}`},code(e){let{gen:n,data:r,schemaCode:i,it:a}=e,o=a.opts.multipleOfPrecision,s=n.let(`res`),c=o?(0,t._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,t._)`${s} !== parseInt(${s})`;e.fail$data((0,t._)`(${i} === 0 || (${s} = ${r}/${i}, ${c}))`)}}})),Pr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r<t;)n++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<t&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return n}e.default=t,t.code=`require("ajv/dist/runtime/ucs2length").default`})),Fr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U(),n=W(),r=Pr();e.default={keyword:[`maxLength`,`minLength`],type:`string`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxLength`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} characters`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:i,data:a,schemaCode:o,it:s}=e,c=i===`maxLength`?t.operators.GT:t.operators.LT,l=s.opts.unicode===!1?(0,t._)`${a}.length`:(0,t._)`${(0,n.useFunc)(e.gen,r.default)}(${a})`;e.fail$data((0,t._)`${l} ${c} ${o}`)}}})),Ir=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=or(),n=W(),r=U();e.default={keyword:`pattern`,type:`string`,schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,r.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,r._)`{pattern: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e,u=l.opts.unicodeRegExp?`u`:``;if(o){let{regExp:t}=l.opts.code,o=t.code===`new RegExp`?(0,r._)`new RegExp`:(0,n.useFunc)(i,t),s=i.let(`valid`);i.try(()=>i.assign(s,(0,r._)`${o}(${c}, ${u}).test(${a})`),()=>i.assign(s,!1)),e.fail$data((0,r._)`!${s}`)}else{let n=(0,t.usePattern)(e,s);e.fail$data((0,r._)`!${n}.test(${a})`)}}}})),Lr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U();e.default={keyword:[`maxProperties`,`minProperties`],type:`object`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxProperties`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} properties`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxProperties`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`Object.keys(${r}).length ${a} ${i}`)}}})),Rr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=or(),n=U(),r=W();e.default={keyword:`required`,type:`object`,schemaType:`array`,$data:!0,error:{message:({params:{missingProperty:e}})=>(0,n.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,n._)`{missingProperty: ${e}}`},code(e){let{gen:i,schema:a,schemaCode:o,data:s,$data:c,it:l}=e,{opts:u}=l;if(!c&&a.length===0)return;let d=a.length>=u.loopRequired;if(l.allErrors?f():p(),u.strictRequired){let t=e.parentSchema.properties,{definedProperties:n}=e.it;for(let e of a)if(t?.[e]===void 0&&!n.has(e)){let t=`required property "${e}" is not defined at "${l.schemaEnv.baseId+l.errSchemaPath}" (strictRequired)`;(0,r.checkStrictMode)(l,t,l.opts.strictRequired)}}function f(){if(d||c)e.block$data(n.nil,m);else for(let n of a)(0,t.checkReportMissingProp)(e,n)}function p(){let n=i.let(`missing`);if(d||c){let t=i.let(`valid`,!0);e.block$data(t,()=>h(n,t)),e.ok(t)}else i.if((0,t.checkMissingProp)(e,a,n)),(0,t.reportMissingProp)(e,n),i.else()}function m(){i.forOf(`prop`,o,n=>{e.setParams({missingProperty:n}),i.if((0,t.noPropertyInData)(i,s,n,u.ownProperties),()=>e.error())})}function h(r,a){e.setParams({missingProperty:r}),i.forOf(r,o,()=>{i.assign(a,(0,t.propertyInData)(i,s,r,u.ownProperties)),i.if((0,n.not)(a),()=>{e.error(),i.break()})},n.nil)}}}})),zr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U();e.default={keyword:[`maxItems`,`minItems`],type:`array`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxItems`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} items`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxItems`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`${r}.length ${a} ${i}`)}}})),Br=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=lr();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),Vr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=ir(),n=U(),r=W(),i=Br();e.default={keyword:`uniqueItems`,type:`array`,schemaType:`boolean`,$data:!0,error:{message:({params:{i:e,j:t}})=>(0,n.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,n._)`{i: ${e}, j: ${t}}`},code(e){let{gen:a,data:o,$data:s,schema:c,parentSchema:l,schemaCode:u,it:d}=e;if(!s&&!c)return;let f=a.let(`valid`),p=l.items?(0,t.getSchemaTypes)(l.items):[];e.block$data(f,m,(0,n._)`${u} === false`),e.ok(f);function m(){let t=a.let(`i`,(0,n._)`${o}.length`),r=a.let(`j`);e.setParams({i:t,j:r}),a.assign(f,!0),a.if((0,n._)`${t} > 1`,()=>(h()?g:_)(t,r))}function h(){return p.length>0&&!p.some(e=>e===`object`||e===`array`)}function g(r,i){let s=a.name(`item`),c=(0,t.checkDataTypes)(p,s,d.opts.strictNumbers,t.DataType.Wrong),l=a.const(`indices`,(0,n._)`{}`);a.for((0,n._)`;${r}--;`,()=>{a.let(s,(0,n._)`${o}[${r}]`),a.if(c,(0,n._)`continue`),p.length>1&&a.if((0,n._)`typeof ${s} == "string"`,(0,n._)`${s} += "_"`),a.if((0,n._)`typeof ${l}[${s}] == "number"`,()=>{a.assign(i,(0,n._)`${l}[${s}]`),e.error(),a.assign(f,!1).break()}).code((0,n._)`${l}[${s}] = ${r}`)})}function _(t,s){let c=(0,r.useFunc)(a,i.default),l=a.name(`outer`);a.label(l).for((0,n._)`;${t}--;`,()=>a.for((0,n._)`${s} = ${t}; ${s}--;`,()=>a.if((0,n._)`${c}(${o}[${t}], ${o}[${s}])`,()=>{e.error(),a.assign(f,!1).break(l)})))}}}})),Hr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U(),n=W(),r=Br();e.default={keyword:`const`,$data:!0,error:{message:`must be equal to constant`,params:({schemaCode:e})=>(0,t._)`{allowedValue: ${e}}`},code(e){let{gen:i,data:a,$data:o,schemaCode:s,schema:c}=e;o||c&&typeof c==`object`?e.fail$data((0,t._)`!${(0,n.useFunc)(i,r.default)}(${a}, ${s})`):e.fail((0,t._)`${c} !== ${a}`)}}})),Ur=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U(),n=W(),r=Br();e.default={keyword:`enum`,schemaType:`array`,$data:!0,error:{message:`must be equal to one of the allowed values`,params:({schemaCode:e})=>(0,t._)`{allowedValues: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e;if(!o&&s.length===0)throw Error(`enum must have non-empty array`);let u=s.length>=l.opts.loopEnum,d,f=()=>d??=(0,n.useFunc)(i,r.default),p;if(u||o)p=i.let(`valid`),e.block$data(p,m);else{if(!Array.isArray(s))throw Error(`ajv implementation error`);let e=i.const(`vSchema`,c);p=(0,t.or)(...s.map((t,n)=>h(e,n)))}e.pass(p);function m(){i.assign(p,!1),i.forOf(`v`,c,e=>i.if((0,t._)`${f()}(${a}, ${e})`,()=>i.assign(p,!0).break()))}function h(e,n){let r=s[n];return typeof r==`object`&&r?(0,t._)`${f()}(${a}, ${e}[${n}])`:(0,t._)`${a} === ${r}`}}}})),Wr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=Mr(),n=Nr(),r=Fr(),i=Ir(),a=Lr(),o=Rr(),s=zr(),c=Vr(),l=Hr(),u=Ur();e.default=[t.default,n.default,r.default,i.default,a.default,o.default,s.default,c.default,{keyword:`type`,schemaType:[`string`,`array`]},{keyword:`nullable`,schemaType:`boolean`},l.default,u.default]})),Gr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateAdditionalItems=void 0;var t=U(),n=W(),r={keyword:`additionalItems`,type:`array`,schemaType:[`boolean`,`object`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{parentSchema:t,it:r}=e,{items:a}=t;if(!Array.isArray(a)){(0,n.checkStrictMode)(r,`"additionalItems" is ignored when "items" is not an array of schemas`);return}i(e,a)}};function i(e,r){let{gen:i,schema:a,data:o,keyword:s,it:c}=e;c.items=!0;let l=i.const(`len`,(0,t._)`${o}.length`);if(a===!1)e.setParams({len:r.length}),e.pass((0,t._)`${l} <= ${r.length}`);else if(typeof a==`object`&&!(0,n.alwaysValidSchema)(c,a)){let n=i.var(`valid`,(0,t._)`${l} <= ${r.length}`);i.if((0,t.not)(n),()=>u(n)),e.ok(n)}function u(a){i.forRange(`i`,r.length,l,r=>{e.subschema({keyword:s,dataProp:r,dataPropType:n.Type.Num},a),c.allErrors||i.if((0,t.not)(a),()=>i.break())})}}e.validateAdditionalItems=i,e.default=r})),Kr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateTuple=void 0;var t=U(),n=W(),r=or(),i={keyword:`items`,type:`array`,schemaType:[`object`,`array`,`boolean`],before:`uniqueItems`,code(e){let{schema:t,it:i}=e;if(Array.isArray(t))return a(e,`additionalItems`,t);i.items=!0,!(0,n.alwaysValidSchema)(i,t)&&e.ok((0,r.validateArray)(e))}};function a(e,r,i=e.schema){let{gen:a,parentSchema:o,data:s,keyword:c,it:l}=e;f(o),l.opts.unevaluated&&i.length&&l.items!==!0&&(l.items=n.mergeEvaluated.items(a,i.length,l.items));let u=a.name(`valid`),d=a.const(`len`,(0,t._)`${s}.length`);i.forEach((r,i)=>{(0,n.alwaysValidSchema)(l,r)||(a.if((0,t._)`${d} > ${i}`,()=>e.subschema({keyword:c,schemaProp:i,dataProp:i},u)),e.ok(u))});function f(e){let{opts:t,errSchemaPath:a}=l,o=i.length,s=o===e.minItems&&(o===e.maxItems||e[r]===!1);if(t.strictTuples&&!s){let e=`"${c}" is ${o}-tuple, but minItems or maxItems/${r} are not specified or different at path "${a}"`;(0,n.checkStrictMode)(l,e,t.strictTuples)}}}e.validateTuple=a,e.default=i})),qr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=Kr();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),Jr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U(),n=W(),r=or(),i=Gr();e.default={keyword:`items`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{schema:t,parentSchema:a,it:o}=e,{prefixItems:s}=a;o.items=!0,!(0,n.alwaysValidSchema)(o,t)&&(s?(0,i.validateAdditionalItems)(e,s):e.ok((0,r.validateArray)(e)))}}})),Yr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U(),n=W();e.default={keyword:`contains`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,trackErrors:!0,error:{message:({params:{min:e,max:n}})=>n===void 0?(0,t.str)`must contain at least ${e} valid item(s)`:(0,t.str)`must contain at least ${e} and no more than ${n} valid item(s)`,params:({params:{min:e,max:n}})=>n===void 0?(0,t._)`{minContains: ${e}}`:(0,t._)`{minContains: ${e}, maxContains: ${n}}`},code(e){let{gen:r,schema:i,parentSchema:a,data:o,it:s}=e,c,l,{minContains:u,maxContains:d}=a;s.opts.next?(c=u===void 0?1:u,l=d):c=1;let f=r.const(`len`,(0,t._)`${o}.length`);if(e.setParams({min:c,max:l}),l===void 0&&c===0){(0,n.checkStrictMode)(s,`"minContains" == 0 without "maxContains": "contains" keyword ignored`);return}if(l!==void 0&&c>l){(0,n.checkStrictMode)(s,`"minContains" > "maxContains" is always invalid`),e.fail();return}if((0,n.alwaysValidSchema)(s,i)){let n=(0,t._)`${f} >= ${c}`;l!==void 0&&(n=(0,t._)`${n} && ${f} <= ${l}`),e.pass(n);return}s.items=!0;let p=r.name(`valid`);l===void 0&&c===1?h(p,()=>r.if(p,()=>r.break())):c===0?(r.let(p,!0),l!==void 0&&r.if((0,t._)`${o}.length > 0`,m)):(r.let(p,!1),m()),e.result(p,()=>e.reset());function m(){let e=r.name(`_valid`),t=r.let(`count`,0);h(e,()=>r.if(e,()=>g(t)))}function h(t,i){r.forRange(`i`,0,f,r=>{e.subschema({keyword:`contains`,dataProp:r,dataPropType:n.Type.Num,compositeRule:!0},t),i()})}function g(e){r.code((0,t._)`${e}++`),l===void 0?r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0).break()):(r.if((0,t._)`${e} > ${l}`,()=>r.assign(p,!1).break()),c===1?r.assign(p,!0):r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0)))}}}})),Xr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;var t=U(),n=W(),r=or();e.error={message:({params:{property:e,depsCount:n,deps:r}})=>{let i=n===1?`property`:`properties`;return(0,t.str)`must have ${i} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:n,deps:r,missingProperty:i}})=>(0,t._)`{property: ${e},
13
+ || ${s} === "boolean" || ${a} === null`).assign(c,(0,i._)`[${a}]`)}}}function p({gen:e,parentData:t,parentDataProperty:n},r){e.if((0,i._)`${t} !== undefined`,()=>e.assign((0,i._)`${t}[${n}]`,r))}function m(e,t,n,r=o.Correct){let a=r===o.Correct?i.operators.EQ:i.operators.NEQ,s;switch(e){case`null`:return(0,i._)`${t} ${a} null`;case`array`:s=(0,i._)`Array.isArray(${t})`;break;case`object`:s=(0,i._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case`integer`:s=c((0,i._)`!(${t} % 1) && !isNaN(${t})`);break;case`number`:s=c();break;default:return(0,i._)`typeof ${t} ${a} ${e}`}return r===o.Correct?s:(0,i.not)(s);function c(e=i.nil){return(0,i.and)((0,i._)`typeof ${t} == "number"`,e,n?(0,i._)`isFinite(${t})`:i.nil)}}e.checkDataType=m;function h(e,t,n,r){if(e.length===1)return m(e[0],t,n,r);let o,s=(0,a.toHash)(e);if(s.array&&s.object){let e=(0,i._)`typeof ${t} != "object"`;o=s.null?e:(0,i._)`!${t} || ${e}`,delete s.null,delete s.array,delete s.object}else o=i.nil;s.number&&delete s.integer;for(let e in s)o=(0,i.and)(o,m(e,t,n,r));return o}e.checkDataTypes=h;var g={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e==`string`?(0,i._)`{type: ${e}}`:(0,i._)`{type: ${t}}`};function _(e){let t=v(e);(0,r.reportError)(t,g)}e.reportTypeError=_;function v(e){let{gen:t,data:n,schema:r}=e,i=(0,a.schemaRefOrVal)(e,r,`type`);return{gen:t,keyword:`type`,data:n,schema:r.type,schemaCode:i,schemaValue:i,parentSchema:r,params:{},it:e}}})),ar=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.assignDefaults=void 0;var t=U(),n=W();function r(e,t){let{properties:n,items:r}=e.schema;if(t===`object`&&n)for(let t in n)i(e,t,n[t].default);else t===`array`&&Array.isArray(r)&&r.forEach((t,n)=>i(e,n,t.default))}e.assignDefaults=r;function i(e,r,i){let{gen:a,compositeRule:o,data:s,opts:c}=e;if(i===void 0)return;let l=(0,t._)`${s}${(0,t.getProperty)(r)}`;if(o){(0,n.checkStrictMode)(e,`default is ignored for: ${l}`);return}let u=(0,t._)`${l} === undefined`;c.useDefaults===`empty`&&(u=(0,t._)`${u} || ${l} === null || ${l} === ""`),a.if(u,(0,t._)`${l} = ${(0,t.stringify)(i)}`)}})),or=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateUnion=e.validateArray=e.usePattern=e.callValidateCode=e.schemaProperties=e.allSchemaProperties=e.noPropertyInData=e.propertyInData=e.isOwnProperty=e.hasPropFunc=e.reportMissingProp=e.checkMissingProp=e.checkReportMissingProp=void 0;var t=U(),n=W(),r=$n(),i=W();function a(e,n){let{gen:r,data:i,it:a}=e;r.if(d(r,i,n,a.opts.ownProperties),()=>{e.setParams({missingProperty:(0,t._)`${n}`},!0),e.error()})}e.checkReportMissingProp=a;function o({gen:e,data:n,it:{opts:r}},i,a){return(0,t.or)(...i.map(i=>(0,t.and)(d(e,n,i,r.ownProperties),(0,t._)`${a} = ${i}`)))}e.checkMissingProp=o;function s(e,t){e.setParams({missingProperty:t},!0),e.error()}e.reportMissingProp=s;function c(e){return e.scopeValue(`func`,{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}e.hasPropFunc=c;function l(e,n,r){return(0,t._)`${c(e)}.call(${n}, ${r})`}e.isOwnProperty=l;function u(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} !== undefined`;return i?(0,t._)`${a} && ${l(e,n,r)}`:a}e.propertyInData=u;function d(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} === undefined`;return i?(0,t.or)(a,(0,t.not)(l(e,n,r))):a}e.noPropertyInData=d;function f(e){return e?Object.keys(e).filter(e=>e!==`__proto__`):[]}e.allSchemaProperties=f;function p(e,t){return f(t).filter(r=>!(0,n.alwaysValidSchema)(e,t[r]))}e.schemaProperties=p;function m({schemaCode:e,data:n,it:{gen:i,topSchemaRef:a,schemaPath:o,errorPath:s},it:c},l,u,d){let f=d?(0,t._)`${e}, ${n}, ${a}${o}`:n,p=[[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,s)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&p.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);let m=(0,t._)`${f}, ${i.object(...p)}`;return u===t.nil?(0,t._)`${l}(${m})`:(0,t._)`${l}.call(${u}, ${m})`}e.callValidateCode=m;var h=(0,t._)`new RegExp`;function g({gen:e,it:{opts:n}},r){let a=n.unicodeRegExp?`u`:``,{regExp:o}=n.code,s=o(r,a);return e.scopeValue(`pattern`,{key:s.toString(),ref:s,code:(0,t._)`${o.code===`new RegExp`?h:(0,i.useFunc)(e,o)}(${r}, ${a})`})}e.usePattern=g;function _(e){let{gen:r,data:i,keyword:a,it:o}=e,s=r.name(`valid`);if(o.allErrors){let e=r.let(`valid`,!0);return c(()=>r.assign(e,!1)),e}return r.var(s,!0),c(()=>r.break()),s;function c(o){let c=r.const(`len`,(0,t._)`${i}.length`);r.forRange(`i`,0,c,i=>{e.subschema({keyword:a,dataProp:i,dataPropType:n.Type.Num},s),r.if((0,t.not)(s),o)})}}e.validateArray=_;function v(e){let{gen:r,schema:i,keyword:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(i.some(e=>(0,n.alwaysValidSchema)(o,e))&&!o.opts.unevaluated)return;let s=r.let(`valid`,!1),c=r.name(`_valid`);r.block(()=>i.forEach((n,i)=>{let o=e.subschema({keyword:a,schemaProp:i,compositeRule:!0},c);r.assign(s,(0,t._)`${s} || ${c}`),e.mergeValidEvaluated(o,c)||r.if((0,t.not)(s))})),e.result(s,()=>e.reset(),()=>e.error(!0))}e.validateUnion=v})),sr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;var t=U(),n=$n(),r=or(),i=er();function a(e,n){let{gen:r,keyword:i,schema:a,parentSchema:o,it:s}=e,c=n.macro.call(s.self,a,o,s),l=u(r,i,c);s.opts.validateSchema!==!1&&s.self.validateSchema(c,!0);let d=r.name(`valid`);e.subschema({schema:c,schemaPath:t.nil,errSchemaPath:`${s.errSchemaPath}/${i}`,topSchemaRef:l,compositeRule:!0},d),e.pass(d,()=>e.error(!0))}e.macroKeywordCode=a;function o(e,i){let{gen:a,keyword:o,schema:d,parentSchema:f,$data:p,it:m}=e;l(m,i);let h=u(a,o,!p&&i.compile?i.compile.call(m.self,d,f,m):i.validate),g=a.let(`valid`);e.block$data(g,_),e.ok(i.valid??g);function _(){if(i.errors===!1)b(),i.modifying&&s(e),x(()=>e.error());else{let t=i.async?v():y();i.modifying&&s(e),x(()=>c(e,t))}}function v(){let e=a.let(`ruleErrs`,null);return a.try(()=>b((0,t._)`await `),n=>a.assign(g,!1).if((0,t._)`${n} instanceof ${m.ValidationError}`,()=>a.assign(e,(0,t._)`${n}.errors`),()=>a.throw(n))),e}function y(){let e=(0,t._)`${h}.errors`;return a.assign(e,null),b(t.nil),e}function b(o=i.async?(0,t._)`await `:t.nil){let s=m.opts.passContext?n.default.this:n.default.self,c=!(`compile`in i&&!p||i.schema===!1);a.assign(g,(0,t._)`${o}${(0,r.callValidateCode)(e,h,s,c)}`,i.modifying)}function x(e){a.if((0,t.not)(i.valid??g),e)}}e.funcKeywordCode=o;function s(e){let{gen:n,data:r,it:i}=e;n.if(i.parentData,()=>n.assign(r,(0,t._)`${i.parentData}[${i.parentDataProperty}]`))}function c(e,r){let{gen:a}=e;a.if((0,t._)`Array.isArray(${r})`,()=>{a.assign(n.default.vErrors,(0,t._)`${n.default.vErrors} === null ? ${r} : ${n.default.vErrors}.concat(${r})`).assign(n.default.errors,(0,t._)`${n.default.vErrors}.length`),(0,i.extendErrors)(e)},()=>e.error())}function l({schemaEnv:e},t){if(t.async&&!e.$async)throw Error(`async keyword in sync schema`)}function u(e,n,r){if(r===void 0)throw Error(`keyword "${n}" failed to compile`);return e.scopeValue(`keyword`,typeof r==`function`?{ref:r}:{ref:r,code:(0,t.stringify)(r)})}function d(e,t,n=!1){return!t.length||t.some(t=>t===`array`?Array.isArray(e):t===`object`?e&&typeof e==`object`&&!Array.isArray(e):typeof e==t||n&&e===void 0)}e.validSchemaType=d;function f({schema:e,opts:t,self:n,errSchemaPath:r},i,a){if(Array.isArray(i.keyword)?!i.keyword.includes(a):i.keyword!==a)throw Error(`ajv implementation error`);let o=i.dependencies;if(o?.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw Error(`parent schema must have dependencies of ${a}: ${o.join(`,`)}`);if(i.validateSchema&&!i.validateSchema(e[a])){let e=`keyword "${a}" value is invalid at path "${r}": `+n.errorsText(i.validateSchema.errors);if(t.validateSchema===`log`)n.logger.error(e);else throw Error(e)}}e.validateKeywordUsage=f})),cr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;var t=U(),n=W();function r(e,{keyword:r,schemaProp:i,schema:a,schemaPath:o,errSchemaPath:s,topSchemaRef:c}){if(r!==void 0&&a!==void 0)throw Error(`both "keyword" and "schema" passed, only one allowed`);if(r!==void 0){let a=e.schema[r];return i===void 0?{schema:a,schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${r}`}:{schema:a[i],schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}${(0,t.getProperty)(i)}`,errSchemaPath:`${e.errSchemaPath}/${r}/${(0,n.escapeFragment)(i)}`}}if(a!==void 0){if(o===void 0||s===void 0||c===void 0)throw Error(`"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"`);return{schema:a,schemaPath:o,topSchemaRef:c,errSchemaPath:s}}throw Error(`either "keyword" or "schema" must be passed`)}e.getSubschema=r;function i(e,r,{dataProp:i,dataPropType:a,data:o,dataTypes:s,propertyName:c}){if(o!==void 0&&i!==void 0)throw Error(`both "data" and "dataProp" passed, only one allowed`);let{gen:l}=r;if(i!==void 0){let{errorPath:o,dataPathArr:s,opts:c}=r;u(l.let(`data`,(0,t._)`${r.data}${(0,t.getProperty)(i)}`,!0)),e.errorPath=(0,t.str)`${o}${(0,n.getErrorPath)(i,a,c.jsPropertySyntax)}`,e.parentDataProperty=(0,t._)`${i}`,e.dataPathArr=[...s,e.parentDataProperty]}o!==void 0&&(u(o instanceof t.Name?o:l.let(`data`,o,!0)),c!==void 0&&(e.propertyName=c)),s&&(e.dataTypes=s);function u(t){e.data=t,e.dataLevel=r.dataLevel+1,e.dataTypes=[],r.definedProperties=new Set,e.parentData=r.data,e.dataNames=[...r.dataNames,t]}}e.extendSubschemaData=i;function a(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:r,createErrors:i,allErrors:a}){r!==void 0&&(e.compositeRule=r),i!==void 0&&(e.createErrors=i),a!==void 0&&(e.allErrors=a),e.jtdDiscriminator=t,e.jtdMetadata=n}e.extendSubschemaMode=a})),lr=s(((e,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),ur=s(((e,t)=>{var n=t.exports=function(e,t,n){typeof t==`function`&&(n=t,t={}),n=t.cb||n;var i=typeof n==`function`?n:n.pre||function(){},a=n.post||function(){};r(t,i,a,e,``,e)};n.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},n.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},n.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},n.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function r(e,t,a,o,s,c,l,u,d,f){if(o&&typeof o==`object`&&!Array.isArray(o)){for(var p in t(o,s,c,l,u,d,f),o){var m=o[p];if(Array.isArray(m)){if(p in n.arrayKeywords)for(var h=0;h<m.length;h++)r(e,t,a,m[h],s+`/`+p+`/`+h,c,s,p,o,h)}else if(p in n.propsKeywords){if(m&&typeof m==`object`)for(var g in m)r(e,t,a,m[g],s+`/`+p+`/`+i(g),c,s,p,o,g)}else (p in n.keywords||e.allKeys&&!(p in n.skipKeywords))&&r(e,t,a,m,s+`/`+p,c,s,p,o)}a(o,s,c,l,u,d,f)}}function i(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}})),dr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;var t=W(),n=lr(),r=ur(),i=new Set([`type`,`format`,`pattern`,`maxLength`,`minLength`,`maxProperties`,`minProperties`,`maxItems`,`minItems`,`maximum`,`minimum`,`uniqueItems`,`multipleOf`,`required`,`enum`,`const`]);function a(e,t=!0){return typeof e==`boolean`?!0:t===!0?!s(e):t?c(e)<=t:!1}e.inlineRef=a;var o=new Set([`$ref`,`$recursiveRef`,`$recursiveAnchor`,`$dynamicRef`,`$dynamicAnchor`]);function s(e){for(let t in e){if(o.has(t))return!0;let n=e[t];if(Array.isArray(n)&&n.some(s)||typeof n==`object`&&s(n))return!0}return!1}function c(e){let n=0;for(let r in e)if(r===`$ref`||(n++,!i.has(r)&&(typeof e[r]==`object`&&(0,t.eachItem)(e[r],e=>n+=c(e)),n===1/0)))return 1/0;return n}function l(e,t=``,n){return n!==!1&&(t=f(t)),u(e,e.parse(t))}e.getFullPath=l;function u(e,t){return e.serialize(t).split(`#`)[0]+`#`}e._getFullPath=u;var d=/#\/?$/;function f(e){return e?e.replace(d,``):``}e.normalizeId=f;function p(e,t,n){return n=f(n),e.resolve(t,n)}e.resolveUrl=p;var m=/^[a-z_][-a-z0-9._]*$/i;function h(e,t){if(typeof e==`boolean`)return{};let{schemaId:i,uriResolver:a}=this.opts,o=f(e[i]||t),s={"":o},c=l(a,o,!1),u={},d=new Set;return r(e,{allKeys:!0},(e,t,n,r)=>{if(r===void 0)return;let a=c+t,o=s[r];typeof e[i]==`string`&&(o=l.call(this,e[i])),g.call(this,e.$anchor),g.call(this,e.$dynamicAnchor),s[t]=o;function l(t){let n=this.opts.uriResolver.resolve;if(t=f(o?n(o,t):t),d.has(t))throw h(t);d.add(t);let r=this.refs[t];return typeof r==`string`&&(r=this.refs[r]),typeof r==`object`?p(e,r.schema,t):t!==f(a)&&(t[0]===`#`?(p(e,u[t],t),u[t]=e):this.refs[t]=a),t}function g(e){if(typeof e==`string`){if(!m.test(e))throw Error(`invalid anchor "${e}"`);l.call(this,`#${e}`)}}}),u;function p(e,t,r){if(t!==void 0&&!n(e,t))throw h(r)}function h(e){return Error(`reference "${e}" resolves to more than one schema`)}}e.getSchemaRefs=h})),fr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;var t=tr(),n=ir(),r=rr(),i=ir(),a=ar(),o=sr(),s=cr(),c=U(),l=$n(),u=dr(),d=W(),f=er();function p(e){if(S(e)&&(w(e),x(e))){_(e);return}m(e,()=>(0,t.topBoolOrEmptySchema)(e))}e.validateFunctionCode=p;function m({gen:e,validateName:t,schema:n,schemaEnv:r,opts:i},a){i.code.es5?e.func(t,(0,c._)`${l.default.data}, ${l.default.valCxt}`,r.$async,()=>{e.code((0,c._)`"use strict"; ${y(n,i)}`),g(e,i),e.code(a)}):e.func(t,(0,c._)`${l.default.data}, ${h(i)}`,r.$async,()=>e.code(y(n,i)).code(a))}function h(e){return(0,c._)`{${l.default.instancePath}="", ${l.default.parentData}, ${l.default.parentDataProperty}, ${l.default.rootData}=${l.default.data}${e.dynamicRef?(0,c._)`, ${l.default.dynamicAnchors}={}`:c.nil}}={}`}function g(e,t){e.if(l.default.valCxt,()=>{e.var(l.default.instancePath,(0,c._)`${l.default.valCxt}.${l.default.instancePath}`),e.var(l.default.parentData,(0,c._)`${l.default.valCxt}.${l.default.parentData}`),e.var(l.default.parentDataProperty,(0,c._)`${l.default.valCxt}.${l.default.parentDataProperty}`),e.var(l.default.rootData,(0,c._)`${l.default.valCxt}.${l.default.rootData}`),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`${l.default.valCxt}.${l.default.dynamicAnchors}`)},()=>{e.var(l.default.instancePath,(0,c._)`""`),e.var(l.default.parentData,(0,c._)`undefined`),e.var(l.default.parentDataProperty,(0,c._)`undefined`),e.var(l.default.rootData,l.default.data),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`{}`)})}function _(e){let{schema:t,opts:n,gen:r}=e;m(e,()=>{n.$comment&&t.$comment&&A(e),D(e),r.let(l.default.vErrors,null),r.let(l.default.errors,0),n.unevaluated&&v(e),T(e),j(e)})}function v(e){let{gen:t,validateName:n}=e;e.evaluated=t.const(`evaluated`,(0,c._)`${n}.evaluated`),t.if((0,c._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,c._)`${e.evaluated}.props`,(0,c._)`undefined`)),t.if((0,c._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,c._)`${e.evaluated}.items`,(0,c._)`undefined`))}function y(e,t){let n=typeof e==`object`&&e[t.schemaId];return n&&(t.code.source||t.code.process)?(0,c._)`/*# sourceURL=${n} */`:c.nil}function b(e,n){if(S(e)&&(w(e),x(e))){C(e,n);return}(0,t.boolOrEmptySchema)(e,n)}function x({schema:e,self:t}){if(typeof e==`boolean`)return!e;for(let n in e)if(t.RULES.all[n])return!0;return!1}function S(e){return typeof e.schema!=`boolean`}function C(e,t){let{schema:n,gen:r,opts:i}=e;i.$comment&&n.$comment&&A(e),O(e),k(e);let a=r.const(`_errs`,l.default.errors);T(e,a),r.var(t,(0,c._)`${a} === ${l.default.errors}`)}function w(e){(0,d.checkUnknownRules)(e),E(e)}function T(e,t){if(e.opts.jtd)return N(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);N(e,r,!(0,n.coerceAndCheckDataType)(e,r),t)}function E(e){let{schema:t,errSchemaPath:n,opts:r,self:i}=e;t.$ref&&r.ignoreKeywordsWithRef&&(0,d.schemaHasRulesButRef)(t,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function D(e){let{schema:t,opts:n}=e;t.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,d.checkStrictMode)(e,`default is ignored in the schema root`)}function O(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,u.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function k(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(`async schema in sync schema`)}function A({gen:e,schemaEnv:t,schema:n,errSchemaPath:r,opts:i}){let a=n.$comment;if(i.$comment===!0)e.code((0,c._)`${l.default.self}.logger.log(${a})`);else if(typeof i.$comment==`function`){let n=(0,c.str)`${r}/$comment`,i=e.scopeValue(`root`,{ref:t.root});e.code((0,c._)`${l.default.self}.opts.$comment(${a}, ${n}, ${i}.schema)`)}}function j(e){let{gen:t,schemaEnv:n,validateName:r,ValidationError:i,opts:a}=e;n.$async?t.if((0,c._)`${l.default.errors} === 0`,()=>t.return(l.default.data),()=>t.throw((0,c._)`new ${i}(${l.default.vErrors})`)):(t.assign((0,c._)`${r}.errors`,l.default.vErrors),a.unevaluated&&M(e),t.return((0,c._)`${l.default.errors} === 0`))}function M({gen:e,evaluated:t,props:n,items:r}){n instanceof c.Name&&e.assign((0,c._)`${t}.props`,n),r instanceof c.Name&&e.assign((0,c._)`${t}.items`,r)}function N(e,t,n,a){let{gen:o,schema:s,data:u,allErrors:f,opts:p,self:m}=e,{RULES:h}=m;if(s.$ref&&(p.ignoreKeywordsWithRef||!(0,d.schemaHasRulesButRef)(s,h))){o.block(()=>le(e,`$ref`,h.all.$ref.definition));return}p.jtd||te(e,t),o.block(()=>{for(let e of h.rules)g(e);g(h.post)});function g(d){(0,r.shouldUseGroup)(s,d)&&(d.type?(o.if((0,i.checkDataType)(d.type,u,p.strictNumbers)),ee(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):ee(e,d),f||o.if((0,c._)`${l.default.errors} === ${a||0}`))}}function ee(e,t){let{gen:n,schema:i,opts:{useDefaults:o}}=e;o&&(0,a.assignDefaults)(e,t.type),n.block(()=>{for(let n of t.rules)(0,r.shouldUseRule)(i,n)&&le(e,n.keyword,n.definition,t.type)})}function te(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(P(e,t),e.opts.allowUnionTypes||ne(e,t),re(e,e.dataTypes))}function P(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{ae(e.dataTypes,t)||se(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),oe(e,t)}}function ne(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&se(e,`use allowUnionTypes to allow union type keyword`)}function re(e,t){let n=e.self.RULES.all;for(let i in n){let a=n[i];if(typeof a==`object`&&(0,r.shouldUseRule)(e.schema,a)){let{type:n}=a.definition;n.length&&!n.some(e=>ie(t,e))&&se(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function ie(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function ae(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function oe(e,t){let n=[];for(let r of e.dataTypes)ae(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function se(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,d.checkStrictMode)(e,t,e.opts.strictTypes)}var ce=class{constructor(e,t,n){if((0,o.validateKeywordUsage)(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,d.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const(`vSchema`,fe(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,o.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);(`code`in t?t.trackErrors:t.errors!==!1)&&(this.errsCount=e.gen.const(`_errs`,l.default.errors))}result(e,t,n){this.failResult((0,c.not)(e),t,n)}failResult(e,t,n){this.gen.if(e),n?n():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,c.not)(e),void 0,t)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:t}=this;this.fail((0,c._)`${t} !== undefined && (${(0,c.or)(this.invalid$data(),e)})`)}error(e,t,n){if(t){this.setParams(t),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,t){(e?f.reportExtraError:f.reportError)(this,this.def.error,t)}$dataError(){(0,f.reportError)(this,this.def.$dataError||f.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error(`add "trackErrors" to keyword definition`);(0,f.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,n=c.nil){this.gen.block(()=>{this.check$data(e,n),t()})}check$data(e=c.nil,t=c.nil){if(!this.$data)return;let{gen:n,schemaCode:r,schemaType:i,def:a}=this;n.if((0,c.or)((0,c._)`${r} === undefined`,t)),e!==c.nil&&n.assign(e,!0),(i.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==c.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:t,schemaType:n,def:r,it:a}=this;return(0,c.or)(o(),s());function o(){if(n.length){if(!(t instanceof c.Name))throw Error(`ajv implementation error`);let e=Array.isArray(n)?n:[n];return(0,c._)`${(0,i.checkDataTypes)(e,t,a.opts.strictNumbers,i.DataType.Wrong)}`}return c.nil}function s(){if(r.validateSchema){let n=e.scopeValue(`validate$data`,{ref:r.validateSchema});return(0,c._)`!${n}(${t})`}return c.nil}}subschema(e,t){let n=(0,s.getSubschema)(this.it,e);(0,s.extendSubschemaData)(n,this.it,e),(0,s.extendSubschemaMode)(n,e);let r={...this.it,...n,items:void 0,props:void 0};return b(r,t),r}mergeEvaluated(e,t){let{it:n,gen:r}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=d.mergeEvaluated.props(r,e.props,n.props,t)),n.items!==!0&&e.items!==void 0&&(n.items=d.mergeEvaluated.items(r,e.items,n.items,t)))}mergeValidEvaluated(e,t){let{it:n,gen:r}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return r.if(t,()=>this.mergeEvaluated(e,c.Name)),!0}};e.KeywordCxt=ce;function le(e,t,n,r){let i=new ce(e,n,t);`code`in n?n.code(i,r):i.$data&&n.validate?(0,o.funcKeywordCode)(i,n):`macro`in n?(0,o.macroKeywordCode)(i,n):(n.compile||n.validate)&&(0,o.funcKeywordCode)(i,n)}var ue=/^\/(?:[^~]|~0|~1)*$/,de=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function fe(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return l.default.rootData;if(e[0]===`/`){if(!ue.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=l.default.rootData}else{let o=de.exec(e);if(!o)throw Error(`Invalid JSON-pointer: ${e}`);let s=+o[1];if(i=o[2],i===`#`){if(s>=t)throw Error(u(`property/index`,s));return r[t-s]}if(s>t)throw Error(u(`data`,s));if(a=n[t-s],!i)return a}let o=a,s=i.split(`/`);for(let e of s)e&&(a=(0,c._)`${a}${(0,c.getProperty)((0,d.unescapeJsonPointer)(e))}`,o=(0,c._)`${o} && ${a}`);return o;function u(e,n){return`Cannot access ${e} ${n} levels up, current level is ${t}`}}e.getData=fe})),pr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=class extends Error{constructor(e){super(`validation failed`),this.errors=e,this.ajv=this.validation=!0}}})),mr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=dr();e.default=class extends Error{constructor(e,n,r,i){super(i||`can't resolve reference ${r} from id ${n}`),this.missingRef=(0,t.resolveUrl)(e,n,r),this.missingSchema=(0,t.normalizeId)((0,t.getFullPath)(e,this.missingRef))}}})),hr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;var t=U(),n=pr(),r=$n(),i=dr(),a=W(),o=fr(),s=class{constructor(e){this.refs={},this.dynamicAnchors={};let t;typeof e.schema==`object`&&(t=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=e.baseId??(0,i.normalizeId)(t?.[e.schemaId||`$id`]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=t?.$async,this.refs={}}};e.SchemaEnv=s;function c(e){let a=d.call(this,e);if(a)return a;let s=(0,i.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:c,lines:l}=this.opts.code,{ownProperties:u}=this.opts,f=new t.CodeGen(this.scope,{es5:c,lines:l,ownProperties:u}),p;e.$async&&(p=f.scopeValue(`Error`,{ref:n.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));let m=f.scopeName(`validate`);e.validateName=m;let h={gen:f,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[t.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:f.scopeValue(`schema`,this.opts.code.source===!0?{ref:e.schema,code:(0,t.stringify)(e.schema)}:{ref:e.schema}),validateName:m,ValidationError:p,schema:e.schema,schemaEnv:e,rootId:s,baseId:e.baseId||s,schemaPath:t.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?``:`#`),errorPath:(0,t._)`""`,opts:this.opts,self:this},g;try{this._compilations.add(e),(0,o.validateFunctionCode)(h),f.optimize(this.opts.code.optimize);let n=f.toString();g=`${f.scopeRefs(r.default.scope)}return ${n}`,this.opts.code.process&&(g=this.opts.code.process(g,e));let i=Function(`${r.default.self}`,`${r.default.scope}`,g)(this,this.scope.get());if(this.scope.value(m,{ref:i}),i.errors=null,i.schema=e.schema,i.schemaEnv=e,e.$async&&(i.$async=!0),this.opts.code.source===!0&&(i.source={validateName:m,validateCode:n,scopeValues:f._values}),this.opts.unevaluated){let{props:e,items:n}=h;i.evaluated={props:e instanceof t.Name?void 0:e,items:n instanceof t.Name?void 0:n,dynamicProps:e instanceof t.Name,dynamicItems:n instanceof t.Name},i.source&&(i.source.evaluated=(0,t.stringify)(i.evaluated))}return e.validate=i,e}catch(t){throw delete e.validate,delete e.validateName,g&&this.logger.error(`Error compiling schema, function code:`,g),t}finally{this._compilations.delete(e)}}e.compileSchema=c;function l(e,t,n){n=(0,i.resolveUrl)(this.opts.uriResolver,t,n);let r=e.refs[n];if(r)return r;let a=p.call(this,e,n);if(a===void 0){let r=e.localRefs?.[n],{schemaId:i}=this.opts;r&&(a=new s({schema:r,schemaId:i,root:e,baseId:t}))}if(a!==void 0)return e.refs[n]=u.call(this,a)}e.resolveRef=l;function u(e){return(0,i.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:c.call(this,e)}function d(e){for(let t of this._compilations)if(f(t,e))return t}e.getCompilingSchema=d;function f(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function p(e,t){let n;for(;typeof(n=this.refs[t])==`string`;)t=n;return n||this.schemas[t]||m.call(this,e,t)}function m(e,t){let n=this.opts.uriResolver.parse(t),r=(0,i._getFullPath)(this.opts.uriResolver,n),a=(0,i.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&r===a)return g.call(this,n,e);let o=(0,i.normalizeId)(r),l=this.refs[o]||this.schemas[o];if(typeof l==`string`){let t=m.call(this,e,l);return typeof t?.schema==`object`?g.call(this,n,t):void 0}if(typeof l?.schema==`object`){if(l.validate||c.call(this,l),o===(0,i.normalizeId)(t)){let{schema:t}=l,{schemaId:n}=this.opts,r=t[n];return r&&(a=(0,i.resolveUrl)(this.opts.uriResolver,a,r)),new s({schema:t,schemaId:n,root:e,baseId:a})}return g.call(this,n,l)}}e.resolveSchema=m;var h=new Set([`properties`,`patternProperties`,`enum`,`dependencies`,`definitions`]);function g(e,{baseId:t,schema:n,root:r}){if(e.fragment?.[0]!==`/`)return;for(let r of e.fragment.slice(1).split(`/`)){if(typeof n==`boolean`)return;let e=n[(0,a.unescapeFragment)(r)];if(e===void 0)return;n=e;let o=typeof n==`object`&&n[this.opts.schemaId];!h.has(r)&&o&&(t=(0,i.resolveUrl)(this.opts.uriResolver,t,o))}let o;if(typeof n!=`boolean`&&n.$ref&&!(0,a.schemaHasRulesButRef)(n,this.RULES)){let e=(0,i.resolveUrl)(this.opts.uriResolver,t,n.$ref);o=m.call(this,r,e)}let{schemaId:c}=this.opts;if(o||=new s({schema:n,schemaId:c,root:r,baseId:t}),o.schema!==o.root.schema)return o}})),gr=c({$id:()=>_r,additionalProperties:()=>!1,default:()=>Sr,description:()=>vr,properties:()=>xr,required:()=>br,type:()=>yr}),_r,vr,yr,br,xr,Sr,Cr=o((()=>{_r=`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`,vr=`Meta-schema for $data reference (JSON AnySchema extension proposal)`,yr=`object`,br=[`$data`],xr={$data:{type:`string`,anyOf:[{format:`relative-json-pointer`},{format:`json-pointer`}]}},Sr={$id:_r,description:vr,type:yr,required:br,properties:xr,additionalProperties:!1}})),wr=s(((e,t)=>{var n=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),r=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),i=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),a=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),o=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function s(e){let t=``,n=0,r=0;for(r=0;r<e.length;r++)if(n=e[r].charCodeAt(0),n!==48){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r];break}for(r+=1;r<e.length;r++){if(n=e[r].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r]}return t}var c=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function l(e){return e.length=0,!0}function u(e,t,n){if(e.length){let r=s(e);if(r!==``)t.push(r);else return n.error=!0,!1;e.length=0}return!0}function d(e){let t=0,n={error:!1,address:``,zone:``},r=[],i=[],a=!1,o=!1,c=u;for(let s=0;s<e.length;s++){let u=e[s];if(!(u===`[`||u===`]`))if(u===`:`){if(a===!0&&(o=!0),!c(i,r,n))break;if(++t>7){n.error=!0;break}s>0&&e[s-1]===`:`&&(a=!0),r.push(`:`);continue}else if(u===`%`){if(!c(i,r,n))break;c=l}else{i.push(u);continue}}return i.length&&(c===l?n.zone=i.join(``):o?r.push(i.join(``)):r.push(s(i))),n.address=r.join(``),n}function f(e){if(p(e,`:`)<2)return{host:e,isIPV6:!1};let t=d(e);if(t.error)return{host:e,isIPV6:!1};{let e=t.address,n=t.address;return t.zone&&(e+=`%`+t.zone,n+=`%25`+t.zone),{host:e,isIPV6:!0,escapedHost:n}}}function p(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function m(e){let t=e,n=[],r=-1,i=0;for(;i=t.length;){if(i===1){if(t===`.`)break;if(t===`/`){n.push(`/`);break}else{n.push(t);break}}else if(i===2){if(t[0]===`.`){if(t[1]===`.`)break;if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&(t[1]===`.`||t[1]===`/`)){n.push(`/`);break}}else if(i===3&&t===`/..`){n.length!==0&&n.pop(),n.push(`/`);break}if(t[0]===`.`){if(t[1]===`.`){if(t[2]===`/`){t=t.slice(3);continue}}else if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&t[1]===`.`){if(t[2]===`/`){t=t.slice(2);continue}else if(t[2]===`.`&&t[3]===`/`){t=t.slice(3),n.length!==0&&n.pop();continue}}if((r=t.indexOf(`/`,1))===-1){n.push(t);break}else n.push(t.slice(0,r)),t=t.slice(r)}return n.join(``)}var h={"@":`%40`,"/":`%2F`,"?":`%3F`,"#":`%23`,":":`%3A`},g=/[@/?#:]/g,_=/[@/?#]/g;function v(e,t){let n=t?_:g;return n.lastIndex=0,e.replace(n,e=>h[e])}function y(e,t=!1){if(e.indexOf(`%`)===-1)return e;let n=``;for(let r=0;r<e.length;r++){if(e[r]===`%`&&r+2<e.length){let o=e.slice(r+1,r+3);if(i(o)){let e=o.toUpperCase(),i=String.fromCharCode(parseInt(e,16));t&&a(i)?n+=i:n+=`%`+e,r+=2;continue}}n+=e[r]}return n}function b(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(i(r)){let e=r.toUpperCase(),i=String.fromCharCode(parseInt(e,16));i!==`.`&&a(i)?t+=i:t+=`%`+e,n+=2;continue}}o(e[n])?t+=e[n]:t+=escape(e[n])}return t}function x(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(i(r)){t+=`%`+r.toUpperCase(),n+=2;continue}}t+=escape(e[n])}return t}function S(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push(`@`)),e.host!==void 0){let n=unescape(e.host);if(!r(n)){let e=f(n);n=e.isIPV6===!0?`[${e.escapedHost}]`:v(n,!1)}t.push(n)}return(typeof e.port==`number`||typeof e.port==`string`)&&(t.push(`:`),t.push(String(e.port))),t.length?t.join(``):void 0}t.exports={nonSimpleDomain:c,recomposeAuthority:S,reescapeHostDelimiters:v,normalizePercentEncoding:y,normalizePathEncoding:b,escapePreservingEscapes:x,removeDotSegments:m,isIPv4:r,isUUID:n,normalizeIPv6:f,stringArrayToHexStripped:s}})),Tr=s(((e,t)=>{var{isUUID:n}=wr(),r=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,i=[`http`,`https`,`ws`,`wss`,`urn`,`urn:uuid`];function a(e){return i.indexOf(e)!==-1}function o(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]===`w`||e.scheme[0]===`W`)&&(e.scheme[1]===`s`||e.scheme[1]===`S`)&&(e.scheme[2]===`s`||e.scheme[2]===`S`):!1}function s(e){return e.host||(e.error=e.error||`HTTP URIs must have a host.`),e}function c(e){let t=String(e.scheme).toLowerCase()===`https`;return(e.port===(t?443:80)||e.port===``)&&(e.port=void 0),e.path||=`/`,e}function l(e){return e.secure=o(e),e.resourceName=(e.path||`/`)+(e.query?`?`+e.query:``),e.path=void 0,e.query=void 0,e}function u(e){if((e.port===(o(e)?443:80)||e.port===``)&&(e.port=void 0),typeof e.secure==`boolean`&&(e.scheme=e.secure?`wss`:`ws`,e.secure=void 0),e.resourceName){let[t,n]=e.resourceName.split(`?`);e.path=t&&t!==`/`?t:void 0,e.query=n,e.resourceName=void 0}return e.fragment=void 0,e}function d(e,t){if(!e.path)return e.error=`URN can not be parsed`,e;let n=e.path.match(r);if(n){let r=t.scheme||e.scheme||`urn`;e.nid=n[1].toLowerCase(),e.nss=n[2];let i=y(`${r}:${t.nid||e.nid}`);e.path=void 0,i&&(e=i.parse(e,t))}else e.error=e.error||`URN can not be parsed.`;return e}function f(e,t){if(e.nid===void 0)throw Error(`URN without nid cannot be serialized`);let n=t.scheme||e.scheme||`urn`,r=e.nid.toLowerCase(),i=y(`${n}:${t.nid||r}`);i&&(e=i.serialize(e,t));let a=e,o=e.nss;return a.path=`${r||t.nid}:${o}`,t.skipEscape=!0,a}function p(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!n(r.uuid))&&(r.error=r.error||`UUID is not valid.`),r}function m(e){let t=e;return t.nss=(e.uuid||``).toLowerCase(),t}var h={scheme:`http`,domainHost:!0,parse:s,serialize:c},g={scheme:`https`,domainHost:h.domainHost,parse:s,serialize:c},_={scheme:`ws`,domainHost:!0,parse:l,serialize:u},v={http:h,https:g,ws:_,wss:{scheme:`wss`,domainHost:_.domainHost,parse:_.parse,serialize:_.serialize},urn:{scheme:`urn`,parse:d,serialize:f,skipNormalize:!0},"urn:uuid":{scheme:`urn:uuid`,parse:p,serialize:m,skipNormalize:!0}};Object.setPrototypeOf(v,null);function y(e){return e&&(v[e]||v[e.toLowerCase()])||void 0}t.exports={wsIsSecure:o,SCHEMES:v,isValidSchemeName:a,getSchemeHandler:y}})),Er=s(((e,t)=>{var{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizePercentEncoding:a,normalizePathEncoding:o,escapePreservingEscapes:s,reescapeHostDelimiters:c,isIPv4:l,nonSimpleDomain:u}=wr(),{SCHEMES:d,getSchemeHandler:f}=Tr();function p(e,t){return typeof e==`string`?e=S(e,t):typeof e==`object`&&(e=x(_(e,t),t)),e}function m(e,t,n){let r=n?Object.assign({scheme:`null`},n):{scheme:`null`},i=h(x(e,r),x(t,r),r,!0);return r.skipEscape=!0,_(i,r)}function h(e,t,n,i){let a={};return i||(e=x(_(e,n),n),t=x(_(t,n),n)),n||={},!n.tolerant&&t.scheme?(a.scheme=t.scheme,a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.path?(t.path[0]===`/`?a.path=r(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?a.path=`/`+t.path:e.path?a.path=e.path.slice(0,e.path.lastIndexOf(`/`)+1)+t.path:a.path=t.path,a.path=r(a.path)),a.query=t.query):(a.path=e.path,t.query===void 0?a.query=e.query:a.query=t.query),a.userinfo=e.userinfo,a.host=e.host,a.port=e.port),a.scheme=e.scheme),a.fragment=t.fragment,a}function g(e,t,n){let r=w(e,n),i=w(t,n);return r!==void 0&&i!==void 0&&r.toLowerCase()===i.toLowerCase()}function _(e,t){let n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:``},o=Object.assign({},t),c=[],l=f(o.scheme||n.scheme);l&&l.serialize&&l.serialize(n,o),n.path!==void 0&&(o.skipEscape?n.path=a(n.path):(n.path=s(n.path),n.scheme!==void 0&&(n.path=n.path.split(`%3A`).join(`:`)))),o.reference!==`suffix`&&n.scheme&&c.push(n.scheme,`:`);let u=i(n);if(u!==void 0&&(o.reference!==`suffix`&&c.push(`//`),c.push(u),n.path&&n.path[0]!==`/`&&c.push(`/`)),n.path!==void 0){let e=n.path;!o.absolutePath&&(!l||!l.absolutePath)&&(e=r(e)),u===void 0&&e[0]===`/`&&e[1]===`/`&&(e=`/%2F`+e.slice(2)),c.push(e)}return n.query!==void 0&&c.push(`?`,n.query),n.fragment!==void 0&&c.push(`#`,n.fragment),c.join(``)}var v=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function y(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!==`/`)return`URI path must start with "/" when authority is present.`;if(typeof e.port==`number`&&(e.port<0||e.port>65535))return`URI port is malformed.`}function b(e,t){let r=Object.assign({},t),i={scheme:void 0,userinfo:void 0,host:``,port:void 0,path:``,query:void 0,fragment:void 0},a=!1,s=!1;r.reference===`suffix`&&(e=r.scheme?r.scheme+`:`+e:`//`+e);let d=e.match(v);if(d){i.scheme=d[1],i.userinfo=d[3],i.host=d[4],i.port=parseInt(d[5],10),i.path=d[6]||``,i.query=d[7],i.fragment=d[8],isNaN(i.port)&&(i.port=d[5]);let t=y(i,d);if(t!==void 0&&(i.error=i.error||t,a=!0),i.host)if(l(i.host)===!1){let e=n(i.host);i.host=e.host.toLowerCase(),s=e.isIPV6}else s=!0;i.scheme===void 0&&i.userinfo===void 0&&i.host===void 0&&i.port===void 0&&i.query===void 0&&!i.path?i.reference=`same-document`:i.scheme===void 0?i.reference=`relative`:i.fragment===void 0?i.reference=`absolute`:i.reference=`uri`,r.reference&&r.reference!==`suffix`&&r.reference!==i.reference&&(i.error=i.error||`URI is not a `+r.reference+` reference.`);let p=f(r.scheme||i.scheme);if(!r.unicodeSupport&&(!p||!p.unicodeSupport)&&i.host&&(r.domainHost||p&&p.domainHost)&&s===!1&&u(i.host))try{i.host=URL.domainToASCII(i.host.toLowerCase())}catch(e){i.error=i.error||`Host's domain name can not be converted to ASCII: `+e}if((!p||p&&!p.skipNormalize)&&(e.indexOf(`%`)!==-1&&(i.scheme!==void 0&&(i.scheme=unescape(i.scheme)),i.host!==void 0&&(i.host=c(unescape(i.host),s))),i.path&&=o(i.path),i.fragment))try{i.fragment=encodeURI(decodeURIComponent(i.fragment))}catch{i.error=i.error||`URI malformed`}p&&p.parse&&p.parse(i,r)}else i.error=i.error||`URI can not be parsed.`;return{parsed:i,malformedAuthorityOrPort:a}}function x(e,t){return b(e,t).parsed}function S(e,t){return C(e,t).normalized}function C(e,t){let{parsed:n,malformedAuthorityOrPort:r}=b(e,t);return{normalized:r?e:_(n,t),malformedAuthorityOrPort:r}}function w(e,t){if(typeof e==`string`){let{normalized:n,malformedAuthorityOrPort:r}=C(e,t);return r?void 0:n}if(typeof e==`object`)return _(e,t)}var T={SCHEMES:d,normalize:p,resolve:m,resolveComponent:h,equal:g,serialize:_,parse:x};t.exports=T,t.exports.default=T,t.exports.fastUri=T})),Dr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=Er();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),Or=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=fr();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return t.KeywordCxt}});var n=U();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return n.Name}}),Object.defineProperty(e,`CodeGen`,{enumerable:!0,get:function(){return n.CodeGen}});var r=pr(),i=mr(),a=nr(),o=hr(),s=U(),c=dr(),l=ir(),u=W(),f=(Cr(),d(gr).default),p=Dr(),m=(e,t)=>new RegExp(e,t);m.code=`new RegExp`;var h=[`removeAdditional`,`useDefaults`,`coerceTypes`],g=new Set([`validate`,`serialize`,`parse`,`wrapper`,`root`,`schema`,`keyword`,`pattern`,`formats`,`validate$data`,`func`,`obj`,`Error`]),_={errorDataPath:``,format:"`validateFormats: false` can be used instead.",nullable:`"nullable" keyword is supported by default.`,jsonPointers:`Deprecated jsPropertySyntax can be used instead.`,extendRefs:`Deprecated ignoreKeywordsWithRef can be used instead.`,missingRefs:`Pass empty schema with $id that should be ignored to ajv.addSchema.`,processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:`"uniqueItems" keyword is always validated.`,unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:`Map is used as cache, schema object as key.`,serialize:`Map is used as cache, schema object as key.`,ajvErrors:`It is default now.`},v={ignoreKeywordsWithRef:``,jsPropertySyntax:``,unicode:`"minLength"/"maxLength" account for unicode characters by default.`},y=200;function b(e){let t=e.strict,n=e.code?.optimize,r=n===!0||n===void 0?1:n||0,i=e.code?.regExp??m,a=e.uriResolver??p.default;return{strictSchema:e.strictSchema??t??!0,strictNumbers:e.strictNumbers??t??!0,strictTypes:e.strictTypes??t??`log`,strictTuples:e.strictTuples??t??`log`,strictRequired:e.strictRequired??t??!1,code:e.code?{...e.code,optimize:r,regExp:i}:{optimize:r,regExp:i},loopRequired:e.loopRequired??y,loopEnum:e.loopEnum??y,meta:e.meta??!0,messages:e.messages??!0,inlineRefs:e.inlineRefs??!0,schemaId:e.schemaId??`$id`,addUsedSchema:e.addUsedSchema??!0,validateSchema:e.validateSchema??!0,validateFormats:e.validateFormats??!0,unicodeRegExp:e.unicodeRegExp??!0,int32range:e.int32range??!0,uriResolver:a}}var x=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...b(e)};let{es5:t,lines:n}=this.opts.code;this.scope=new s.ValueScope({scope:{},prefixes:g,es5:t,lines:n}),this.logger=k(e.logger);let r=e.validateFormats;e.validateFormats=!1,this.RULES=(0,a.getRules)(),S.call(this,_,e,`NOT SUPPORTED`),S.call(this,v,e,`DEPRECATED`,`warn`),this._metaOpts=D.call(this),e.formats&&T.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&E.call(this,e.keywords),typeof e.meta==`object`&&this.addMetaSchema(e.meta),w.call(this),e.validateFormats=r}_addVocabularies(){this.addKeyword(`$async`)}_addDefaultMetaSchema(){let{$data:e,meta:t,schemaId:n}=this.opts,r=f;n===`id`&&(r={...f},r.id=r.$id,delete r.$id),t&&e&&this.addMetaSchema(r,r[n],!1)}defaultMeta(){let{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta=typeof e==`object`?e[t]||e:void 0}validate(e,t){let n;if(typeof e==`string`){if(n=this.getSchema(e),!n)throw Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let r=n(t);return`$async`in n||(this.errors=n.errors),r}compile(e,t){let n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if(typeof this.opts.loadSchema!=`function`)throw Error(`options.loadSchema should be a function`);let{loadSchema:n}=this.opts;return r.call(this,e,t);async function r(e,t){await a.call(this,e.$schema);let n=this._addSchema(e,t);return n.validate||o.call(this,n)}async function a(e){e&&!this.getSchema(e)&&await r.call(this,{$ref:e},!0)}async function o(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof i.default))throw t;return s.call(this,t),await c.call(this,t.missingSchema),o.call(this,e)}}function s({missingSchema:e,missingRef:t}){if(this.refs[e])throw Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){let n=await l.call(this,e);this.refs[e]||await a.call(this,n.$schema),this.refs[e]||this.addSchema(n,e,t)}async function l(e){let t=this._loading[e];if(t)return t;try{return await(this._loading[e]=n(e))}finally{delete this._loading[e]}}}addSchema(e,t,n,r=this.opts.validateSchema){if(Array.isArray(e)){for(let t of e)this.addSchema(t,void 0,n,r);return this}let i;if(typeof e==`object`){let{schemaId:t}=this.opts;if(i=e[t],i!==void 0&&typeof i!=`string`)throw Error(`schema ${t} must be string`)}return t=(0,c.normalizeId)(t||i),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,r,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if(typeof e==`boolean`)return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!=`string`)throw Error(`$schema must be a string`);if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn(`meta-schema not available`),this.errors=null,!0;let r=this.validate(n,e);if(!r&&t){let e=`schema is invalid: `+this.errorsText();if(this.opts.validateSchema===`log`)this.logger.error(e);else throw Error(e)}return r}getSchema(e){let t;for(;typeof(t=C.call(this,e))==`string`;)e=t;if(t===void 0){let{schemaId:n}=this.opts,r=new o.SchemaEnv({schema:{},schemaId:n});if(t=o.resolveSchema.call(this,r,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case`undefined`:return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case`string`:{let t=C.call(this,e);return typeof t==`object`&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case`object`:{let t=e;this._cache.delete(t);let n=e[this.opts.schemaId];return n&&(n=(0,c.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw Error(`ajv.removeSchema: invalid parameter`)}}addVocabulary(e){for(let t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if(typeof e==`string`)n=e,typeof t==`object`&&(this.logger.warn(`these parameters are deprecated, see docs for addKeyword`),t.keyword=n);else if(typeof e==`object`&&t===void 0){if(t=e,n=t.keyword,Array.isArray(n)&&!n.length)throw Error(`addKeywords: keyword must be string or non-empty array`)}else throw Error(`invalid addKeywords parameters`);if(j.call(this,n,t),!t)return(0,u.eachItem)(n,e=>M.call(this,e)),this;ee.call(this,t);let r={...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)};return(0,u.eachItem)(n,r.type.length===0?e=>M.call(this,e,r):e=>r.type.forEach(t=>M.call(this,e,r,t))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t==`object`?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let n of t.rules){let t=n.rules.findIndex(t=>t.keyword===e);t>=0&&n.rules.splice(t,1)}return this}addFormat(e,t){return typeof t==`string`&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=`, `,dataVar:n=`data`}={}){return!e||e.length===0?`No errors`:e.map(e=>`${n}${e.instancePath} ${e.message}`).reduce((e,n)=>e+t+n)}$dataMetaSchema(e,t){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let r of t){let t=r.split(`/`).slice(1),i=e;for(let e of t)i=i[e];for(let e in n){let t=n[e];if(typeof t!=`object`)continue;let{$data:r}=t.definition,a=i[e];r&&a&&(i[e]=P(a))}}return e}_removeAllSchemas(e,t){for(let n in e){let r=e[n];(!t||t.test(n))&&(typeof r==`string`?delete e[n]:r&&!r.meta&&(this._cache.delete(r.schema),delete e[n]))}}_addSchema(e,t,n,r=this.opts.validateSchema,i=this.opts.addUsedSchema){let a,{schemaId:s}=this.opts;if(typeof e==`object`)a=e[s];else if(this.opts.jtd)throw Error(`schema must be object`);else if(typeof e!=`boolean`)throw Error(`schema must be object or boolean`);let l=this._cache.get(e);if(l!==void 0)return l;n=(0,c.normalizeId)(a||n);let u=c.getSchemaRefs.call(this,e,n);return l=new o.SchemaEnv({schema:e,schemaId:s,meta:t,baseId:n,localRefs:u}),this._cache.set(l.schema,l),i&&!n.startsWith(`#`)&&(n&&this._checkUnique(n),this.refs[n]=l),r&&this.validateSchema(e,!0),l}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):o.compileSchema.call(this,e),!e.validate)throw Error(`ajv implementation error`);return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{o.compileSchema.call(this,e)}finally{this.opts=t}}};x.ValidationError=r.default,x.MissingRefError=i.default,e.default=x;function S(e,t,n,r=`error`){for(let i in e){let a=i;a in t&&this.logger[r](`${n}: option ${i}. ${e[a]}`)}}function C(e){return e=(0,c.normalizeId)(e),this.schemas[e]||this.refs[e]}function w(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function T(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function E(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn(`keywords option as map is deprecated, pass array`);for(let t in e){let n=e[t];n.keyword||=t,this.addKeyword(n)}}function D(){let e={...this.opts};for(let t of h)delete e[t];return e}var O={log(){},warn(){},error(){}};function k(e){if(e===!1)return O;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw Error(`logger must implement log, warn and error methods`)}var A=/^[a-z_$][a-z0-9_$:-]*$/i;function j(e,t){let{RULES:n}=this;if((0,u.eachItem)(e,e=>{if(n.keywords[e])throw Error(`Keyword ${e} is already defined`);if(!A.test(e))throw Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!(`code`in t||`validate`in t))throw Error(`$data keyword must have "code" or "validate" function`)}function M(e,t,n){var r;let i=t?.post;if(n&&i)throw Error(`keyword with "post" flag cannot have "type"`);let{RULES:a}=this,o=i?a.post:a.rules.find(({type:e})=>e===n);if(o||(o={type:n,rules:[]},a.rules.push(o)),a.keywords[e]=!0,!t)return;let s={keyword:e,definition:{...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)}};t.before?N.call(this,o,s,t.before):o.rules.push(s),a.all[e]=s,(r=t.implements)==null||r.forEach(e=>this.addKeyword(e))}function N(e,t,n){let r=e.rules.findIndex(e=>e.keyword===n);r>=0?e.rules.splice(r,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function ee(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=P(t)),e.validateSchema=this.compile(t,!0))}var te={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function P(e){return{anyOf:[e,te]}}})),kr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),Ar=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.callRef=e.getValidate=void 0;var t=mr(),n=or(),r=U(),i=$n(),a=hr(),o=W(),s={keyword:`$ref`,schemaType:`string`,code(e){let{gen:n,schema:i,it:o}=e,{baseId:s,schemaEnv:u,validateName:d,opts:f,self:p}=o,{root:m}=u;if((i===`#`||i===`#/`)&&s===m.baseId)return g();let h=a.resolveRef.call(p,m,s,i);if(h===void 0)throw new t.default(o.opts.uriResolver,s,i);if(h instanceof a.SchemaEnv)return _(h);return v(h);function g(){if(u===m)return l(e,d,u,u.$async);let t=n.scopeValue(`root`,{ref:m});return l(e,(0,r._)`${t}.validate`,m,m.$async)}function _(t){l(e,c(e,t),t,t.$async)}function v(t){let a=n.scopeValue(`schema`,f.code.source===!0?{ref:t,code:(0,r.stringify)(t)}:{ref:t}),o=n.name(`valid`),s=e.subschema({schema:t,dataTypes:[],schemaPath:r.nil,topSchemaRef:a,errSchemaPath:i},o);e.mergeEvaluated(s),e.ok(o)}}};function c(e,t){let{gen:n}=e;return t.validate?n.scopeValue(`validate`,{ref:t.validate}):(0,r._)`${n.scopeValue(`wrapper`,{ref:t})}.validate`}e.getValidate=c;function l(e,t,a,s){let{gen:c,it:l}=e,{allErrors:u,schemaEnv:d,opts:f}=l,p=f.passContext?i.default.this:r.nil;s?m():h();function m(){if(!d.$async)throw Error(`async schema referenced by sync schema`);let i=c.let(`valid`);c.try(()=>{c.code((0,r._)`await ${(0,n.callValidateCode)(e,t,p)}`),_(t),u||c.assign(i,!0)},e=>{c.if((0,r._)`!(${e} instanceof ${l.ValidationError})`,()=>c.throw(e)),g(e),u||c.assign(i,!1)}),e.ok(i)}function h(){e.result((0,n.callValidateCode)(e,t,p),()=>_(t),()=>g(t))}function g(e){let t=(0,r._)`${e}.errors`;c.assign(i.default.vErrors,(0,r._)`${i.default.vErrors} === null ? ${t} : ${i.default.vErrors}.concat(${t})`),c.assign(i.default.errors,(0,r._)`${i.default.vErrors}.length`)}function _(e){if(!l.opts.unevaluated)return;let t=a?.validate?.evaluated;if(l.props!==!0)if(t&&!t.dynamicProps)t.props!==void 0&&(l.props=o.mergeEvaluated.props(c,t.props,l.props));else{let t=c.var(`props`,(0,r._)`${e}.evaluated.props`);l.props=o.mergeEvaluated.props(c,t,l.props,r.Name)}if(l.items!==!0)if(t&&!t.dynamicItems)t.items!==void 0&&(l.items=o.mergeEvaluated.items(c,t.items,l.items));else{let t=c.var(`items`,(0,r._)`${e}.evaluated.items`);l.items=o.mergeEvaluated.items(c,t,l.items,r.Name)}}}e.callRef=l,e.default=s})),jr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=kr(),n=Ar();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),Mr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U(),n=t.operators,r={maximum:{okStr:`<=`,ok:n.LTE,fail:n.GT},minimum:{okStr:`>=`,ok:n.GTE,fail:n.LT},exclusiveMaximum:{okStr:`<`,ok:n.LT,fail:n.GTE},exclusiveMinimum:{okStr:`>`,ok:n.GT,fail:n.LTE}};e.default={keyword:Object.keys(r),type:`number`,schemaType:`number`,$data:!0,error:{message:({keyword:e,schemaCode:n})=>(0,t.str)`must be ${r[e].okStr} ${n}`,params:({keyword:e,schemaCode:n})=>(0,t._)`{comparison: ${r[e].okStr}, limit: ${n}}`},code(e){let{keyword:n,data:i,schemaCode:a}=e;e.fail$data((0,t._)`${i} ${r[n].fail} ${a} || isNaN(${i})`)}}})),Nr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U();e.default={keyword:`multipleOf`,type:`number`,schemaType:`number`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,t._)`{multipleOf: ${e}}`},code(e){let{gen:n,data:r,schemaCode:i,it:a}=e,o=a.opts.multipleOfPrecision,s=n.let(`res`),c=o?(0,t._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,t._)`${s} !== parseInt(${s})`;e.fail$data((0,t._)`(${i} === 0 || (${s} = ${r}/${i}, ${c}))`)}}})),Pr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r<t;)n++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<t&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return n}e.default=t,t.code=`require("ajv/dist/runtime/ucs2length").default`})),Fr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U(),n=W(),r=Pr();e.default={keyword:[`maxLength`,`minLength`],type:`string`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxLength`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} characters`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:i,data:a,schemaCode:o,it:s}=e,c=i===`maxLength`?t.operators.GT:t.operators.LT,l=s.opts.unicode===!1?(0,t._)`${a}.length`:(0,t._)`${(0,n.useFunc)(e.gen,r.default)}(${a})`;e.fail$data((0,t._)`${l} ${c} ${o}`)}}})),Ir=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=or(),n=W(),r=U();e.default={keyword:`pattern`,type:`string`,schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,r.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,r._)`{pattern: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e,u=l.opts.unicodeRegExp?`u`:``;if(o){let{regExp:t}=l.opts.code,o=t.code===`new RegExp`?(0,r._)`new RegExp`:(0,n.useFunc)(i,t),s=i.let(`valid`);i.try(()=>i.assign(s,(0,r._)`${o}(${c}, ${u}).test(${a})`),()=>i.assign(s,!1)),e.fail$data((0,r._)`!${s}`)}else{let n=(0,t.usePattern)(e,s);e.fail$data((0,r._)`!${n}.test(${a})`)}}}})),Lr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U();e.default={keyword:[`maxProperties`,`minProperties`],type:`object`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxProperties`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} properties`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxProperties`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`Object.keys(${r}).length ${a} ${i}`)}}})),Rr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=or(),n=U(),r=W();e.default={keyword:`required`,type:`object`,schemaType:`array`,$data:!0,error:{message:({params:{missingProperty:e}})=>(0,n.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,n._)`{missingProperty: ${e}}`},code(e){let{gen:i,schema:a,schemaCode:o,data:s,$data:c,it:l}=e,{opts:u}=l;if(!c&&a.length===0)return;let d=a.length>=u.loopRequired;if(l.allErrors?f():p(),u.strictRequired){let t=e.parentSchema.properties,{definedProperties:n}=e.it;for(let e of a)if(t?.[e]===void 0&&!n.has(e)){let t=`required property "${e}" is not defined at "${l.schemaEnv.baseId+l.errSchemaPath}" (strictRequired)`;(0,r.checkStrictMode)(l,t,l.opts.strictRequired)}}function f(){if(d||c)e.block$data(n.nil,m);else for(let n of a)(0,t.checkReportMissingProp)(e,n)}function p(){let n=i.let(`missing`);if(d||c){let t=i.let(`valid`,!0);e.block$data(t,()=>h(n,t)),e.ok(t)}else i.if((0,t.checkMissingProp)(e,a,n)),(0,t.reportMissingProp)(e,n),i.else()}function m(){i.forOf(`prop`,o,n=>{e.setParams({missingProperty:n}),i.if((0,t.noPropertyInData)(i,s,n,u.ownProperties),()=>e.error())})}function h(r,a){e.setParams({missingProperty:r}),i.forOf(r,o,()=>{i.assign(a,(0,t.propertyInData)(i,s,r,u.ownProperties)),i.if((0,n.not)(a),()=>{e.error(),i.break()})},n.nil)}}}})),zr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U();e.default={keyword:[`maxItems`,`minItems`],type:`array`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxItems`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} items`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxItems`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`${r}.length ${a} ${i}`)}}})),Br=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=lr();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),Vr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=ir(),n=U(),r=W(),i=Br();e.default={keyword:`uniqueItems`,type:`array`,schemaType:`boolean`,$data:!0,error:{message:({params:{i:e,j:t}})=>(0,n.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,n._)`{i: ${e}, j: ${t}}`},code(e){let{gen:a,data:o,$data:s,schema:c,parentSchema:l,schemaCode:u,it:d}=e;if(!s&&!c)return;let f=a.let(`valid`),p=l.items?(0,t.getSchemaTypes)(l.items):[];e.block$data(f,m,(0,n._)`${u} === false`),e.ok(f);function m(){let t=a.let(`i`,(0,n._)`${o}.length`),r=a.let(`j`);e.setParams({i:t,j:r}),a.assign(f,!0),a.if((0,n._)`${t} > 1`,()=>(h()?g:_)(t,r))}function h(){return p.length>0&&!p.some(e=>e===`object`||e===`array`)}function g(r,i){let s=a.name(`item`),c=(0,t.checkDataTypes)(p,s,d.opts.strictNumbers,t.DataType.Wrong),l=a.const(`indices`,(0,n._)`{}`);a.for((0,n._)`;${r}--;`,()=>{a.let(s,(0,n._)`${o}[${r}]`),a.if(c,(0,n._)`continue`),p.length>1&&a.if((0,n._)`typeof ${s} == "string"`,(0,n._)`${s} += "_"`),a.if((0,n._)`typeof ${l}[${s}] == "number"`,()=>{a.assign(i,(0,n._)`${l}[${s}]`),e.error(),a.assign(f,!1).break()}).code((0,n._)`${l}[${s}] = ${r}`)})}function _(t,s){let c=(0,r.useFunc)(a,i.default),l=a.name(`outer`);a.label(l).for((0,n._)`;${t}--;`,()=>a.for((0,n._)`${s} = ${t}; ${s}--;`,()=>a.if((0,n._)`${c}(${o}[${t}], ${o}[${s}])`,()=>{e.error(),a.assign(f,!1).break(l)})))}}}})),Hr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U(),n=W(),r=Br();e.default={keyword:`const`,$data:!0,error:{message:`must be equal to constant`,params:({schemaCode:e})=>(0,t._)`{allowedValue: ${e}}`},code(e){let{gen:i,data:a,$data:o,schemaCode:s,schema:c}=e;o||c&&typeof c==`object`?e.fail$data((0,t._)`!${(0,n.useFunc)(i,r.default)}(${a}, ${s})`):e.fail((0,t._)`${c} !== ${a}`)}}})),Ur=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U(),n=W(),r=Br();e.default={keyword:`enum`,schemaType:`array`,$data:!0,error:{message:`must be equal to one of the allowed values`,params:({schemaCode:e})=>(0,t._)`{allowedValues: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e;if(!o&&s.length===0)throw Error(`enum must have non-empty array`);let u=s.length>=l.opts.loopEnum,d,f=()=>d??=(0,n.useFunc)(i,r.default),p;if(u||o)p=i.let(`valid`),e.block$data(p,m);else{if(!Array.isArray(s))throw Error(`ajv implementation error`);let e=i.const(`vSchema`,c);p=(0,t.or)(...s.map((t,n)=>h(e,n)))}e.pass(p);function m(){i.assign(p,!1),i.forOf(`v`,c,e=>i.if((0,t._)`${f()}(${a}, ${e})`,()=>i.assign(p,!0).break()))}function h(e,n){let r=s[n];return typeof r==`object`&&r?(0,t._)`${f()}(${a}, ${e}[${n}])`:(0,t._)`${a} === ${r}`}}}})),Wr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=Mr(),n=Nr(),r=Fr(),i=Ir(),a=Lr(),o=Rr(),s=zr(),c=Vr(),l=Hr(),u=Ur();e.default=[t.default,n.default,r.default,i.default,a.default,o.default,s.default,c.default,{keyword:`type`,schemaType:[`string`,`array`]},{keyword:`nullable`,schemaType:`boolean`},l.default,u.default]})),Gr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateAdditionalItems=void 0;var t=U(),n=W(),r={keyword:`additionalItems`,type:`array`,schemaType:[`boolean`,`object`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{parentSchema:t,it:r}=e,{items:a}=t;if(!Array.isArray(a)){(0,n.checkStrictMode)(r,`"additionalItems" is ignored when "items" is not an array of schemas`);return}i(e,a)}};function i(e,r){let{gen:i,schema:a,data:o,keyword:s,it:c}=e;c.items=!0;let l=i.const(`len`,(0,t._)`${o}.length`);if(a===!1)e.setParams({len:r.length}),e.pass((0,t._)`${l} <= ${r.length}`);else if(typeof a==`object`&&!(0,n.alwaysValidSchema)(c,a)){let n=i.var(`valid`,(0,t._)`${l} <= ${r.length}`);i.if((0,t.not)(n),()=>u(n)),e.ok(n)}function u(a){i.forRange(`i`,r.length,l,r=>{e.subschema({keyword:s,dataProp:r,dataPropType:n.Type.Num},a),c.allErrors||i.if((0,t.not)(a),()=>i.break())})}}e.validateAdditionalItems=i,e.default=r})),Kr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateTuple=void 0;var t=U(),n=W(),r=or(),i={keyword:`items`,type:`array`,schemaType:[`object`,`array`,`boolean`],before:`uniqueItems`,code(e){let{schema:t,it:i}=e;if(Array.isArray(t))return a(e,`additionalItems`,t);i.items=!0,!(0,n.alwaysValidSchema)(i,t)&&e.ok((0,r.validateArray)(e))}};function a(e,r,i=e.schema){let{gen:a,parentSchema:o,data:s,keyword:c,it:l}=e;f(o),l.opts.unevaluated&&i.length&&l.items!==!0&&(l.items=n.mergeEvaluated.items(a,i.length,l.items));let u=a.name(`valid`),d=a.const(`len`,(0,t._)`${s}.length`);i.forEach((r,i)=>{(0,n.alwaysValidSchema)(l,r)||(a.if((0,t._)`${d} > ${i}`,()=>e.subschema({keyword:c,schemaProp:i,dataProp:i},u)),e.ok(u))});function f(e){let{opts:t,errSchemaPath:a}=l,o=i.length,s=o===e.minItems&&(o===e.maxItems||e[r]===!1);if(t.strictTuples&&!s){let e=`"${c}" is ${o}-tuple, but minItems or maxItems/${r} are not specified or different at path "${a}"`;(0,n.checkStrictMode)(l,e,t.strictTuples)}}}e.validateTuple=a,e.default=i})),qr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=Kr();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),Jr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U(),n=W(),r=or(),i=Gr();e.default={keyword:`items`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{schema:t,parentSchema:a,it:o}=e,{prefixItems:s}=a;o.items=!0,!(0,n.alwaysValidSchema)(o,t)&&(s?(0,i.validateAdditionalItems)(e,s):e.ok((0,r.validateArray)(e)))}}})),Yr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U(),n=W();e.default={keyword:`contains`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,trackErrors:!0,error:{message:({params:{min:e,max:n}})=>n===void 0?(0,t.str)`must contain at least ${e} valid item(s)`:(0,t.str)`must contain at least ${e} and no more than ${n} valid item(s)`,params:({params:{min:e,max:n}})=>n===void 0?(0,t._)`{minContains: ${e}}`:(0,t._)`{minContains: ${e}, maxContains: ${n}}`},code(e){let{gen:r,schema:i,parentSchema:a,data:o,it:s}=e,c,l,{minContains:u,maxContains:d}=a;s.opts.next?(c=u===void 0?1:u,l=d):c=1;let f=r.const(`len`,(0,t._)`${o}.length`);if(e.setParams({min:c,max:l}),l===void 0&&c===0){(0,n.checkStrictMode)(s,`"minContains" == 0 without "maxContains": "contains" keyword ignored`);return}if(l!==void 0&&c>l){(0,n.checkStrictMode)(s,`"minContains" > "maxContains" is always invalid`),e.fail();return}if((0,n.alwaysValidSchema)(s,i)){let n=(0,t._)`${f} >= ${c}`;l!==void 0&&(n=(0,t._)`${n} && ${f} <= ${l}`),e.pass(n);return}s.items=!0;let p=r.name(`valid`);l===void 0&&c===1?h(p,()=>r.if(p,()=>r.break())):c===0?(r.let(p,!0),l!==void 0&&r.if((0,t._)`${o}.length > 0`,m)):(r.let(p,!1),m()),e.result(p,()=>e.reset());function m(){let e=r.name(`_valid`),t=r.let(`count`,0);h(e,()=>r.if(e,()=>g(t)))}function h(t,i){r.forRange(`i`,0,f,r=>{e.subschema({keyword:`contains`,dataProp:r,dataPropType:n.Type.Num,compositeRule:!0},t),i()})}function g(e){r.code((0,t._)`${e}++`),l===void 0?r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0).break()):(r.if((0,t._)`${e} > ${l}`,()=>r.assign(p,!1).break()),c===1?r.assign(p,!0):r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0)))}}}})),Xr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;var t=U(),n=W(),r=or();e.error={message:({params:{property:e,depsCount:n,deps:r}})=>{let i=n===1?`property`:`properties`;return(0,t.str)`must have ${i} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:n,deps:r,missingProperty:i}})=>(0,t._)`{property: ${e},
14
14
  missingProperty: ${i},
15
15
  depsCount: ${n},
16
- deps: ${r}}`};var i={keyword:`dependencies`,type:`object`,schemaType:`object`,error:e.error,code(e){let[t,n]=a(e);o(e,t),s(e,n)}};function a({schema:e}){let t={},n={};for(let r in e){if(r===`__proto__`)continue;let i=Array.isArray(e[r])?t:n;i[r]=e[r]}return[t,n]}function o(e,n=e.schema){let{gen:i,data:a,it:o}=e;if(Object.keys(n).length===0)return;let s=i.let(`missing`);for(let c in n){let l=n[c];if(l.length===0)continue;let u=(0,r.propertyInData)(i,a,c,o.opts.ownProperties);e.setParams({property:c,depsCount:l.length,deps:l.join(`, `)}),o.allErrors?i.if(u,()=>{for(let t of l)(0,r.checkReportMissingProp)(e,t)}):(i.if((0,t._)`${u} && (${(0,r.checkMissingProp)(e,l,s)})`),(0,r.reportMissingProp)(e,s),i.else())}}e.validatePropertyDeps=o;function s(e,t=e.schema){let{gen:i,data:a,keyword:o,it:s}=e,c=i.name(`valid`);for(let l in t)(0,n.alwaysValidSchema)(s,t[l])||(i.if((0,r.propertyInData)(i,a,l,s.opts.ownProperties),()=>{let t=e.subschema({keyword:o,schemaProp:l},c);e.mergeValidEvaluated(t,c)},()=>i.var(c,!0)),e.ok(c))}e.validateSchemaDeps=s,e.default=i})),Zr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U(),n=W();e.default={keyword:`propertyNames`,type:`object`,schemaType:[`object`,`boolean`],error:{message:`property name must be valid`,params:({params:e})=>(0,t._)`{propertyName: ${e.propertyName}}`},code(e){let{gen:r,schema:i,data:a,it:o}=e;if((0,n.alwaysValidSchema)(o,i))return;let s=r.name(`valid`);r.forIn(`key`,a,n=>{e.setParams({propertyName:n}),e.subschema({keyword:`propertyNames`,data:n,dataTypes:[`string`],propertyName:n,compositeRule:!0},s),r.if((0,t.not)(s),()=>{e.error(!0),o.allErrors||r.break()})}),e.ok(s)}}})),Qr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=or(),n=U(),r=$n(),i=W();e.default={keyword:`additionalProperties`,type:[`object`],schemaType:[`boolean`,`object`],allowUndefined:!0,trackErrors:!0,error:{message:`must NOT have additional properties`,params:({params:e})=>(0,n._)`{additionalProperty: ${e.additionalProperty}}`},code(e){let{gen:a,schema:o,parentSchema:s,data:c,errsCount:l,it:u}=e;if(!l)throw Error(`ajv implementation error`);let{allErrors:d,opts:f}=u;if(u.props=!0,f.removeAdditional!==`all`&&(0,i.alwaysValidSchema)(u,o))return;let p=(0,t.allSchemaProperties)(s.properties),m=(0,t.allSchemaProperties)(s.patternProperties);h(),e.ok((0,n._)`${l} === ${r.default.errors}`);function h(){a.forIn(`key`,c,e=>{!p.length&&!m.length?v(e):a.if(g(e),()=>v(e))})}function g(r){let o;if(p.length>8){let e=(0,i.schemaRefOrVal)(u,s.properties,`properties`);o=(0,t.isOwnProperty)(a,e,r)}else o=p.length?(0,n.or)(...p.map(e=>(0,n._)`${r} === ${e}`)):n.nil;return m.length&&(o=(0,n.or)(o,...m.map(i=>(0,n._)`${(0,t.usePattern)(e,i)}.test(${r})`))),(0,n.not)(o)}function _(e){a.code((0,n._)`delete ${c}[${e}]`)}function v(t){if(f.removeAdditional===`all`||f.removeAdditional&&o===!1){_(t);return}if(o===!1){e.setParams({additionalProperty:t}),e.error(),d||a.break();return}if(typeof o==`object`&&!(0,i.alwaysValidSchema)(u,o)){let r=a.name(`valid`);f.removeAdditional===`failing`?(y(t,r,!1),a.if((0,n.not)(r),()=>{e.reset(),_(t)})):(y(t,r),d||a.if((0,n.not)(r),()=>a.break()))}}function y(t,n,r){let a={keyword:`additionalProperties`,dataProp:t,dataPropType:i.Type.Str};r===!1&&Object.assign(a,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(a,n)}}}})),$r=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=fr(),n=or(),r=W(),i=Qr();e.default={keyword:`properties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,parentSchema:s,data:c,it:l}=e;l.opts.removeAdditional===`all`&&s.additionalProperties===void 0&&i.default.code(new t.KeywordCxt(l,i.default,`additionalProperties`));let u=(0,n.allSchemaProperties)(o);for(let e of u)l.definedProperties.add(e);l.opts.unevaluated&&u.length&&l.props!==!0&&(l.props=r.mergeEvaluated.props(a,(0,r.toHash)(u),l.props));let d=u.filter(e=>!(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0)return;let f=a.name(`valid`);for(let t of d)p(t)?m(t):(a.if((0,n.propertyInData)(a,c,t,l.opts.ownProperties)),m(t),l.allErrors||a.else().var(f,!0),a.endIf()),e.it.definedProperties.add(t),e.ok(f);function p(e){return l.opts.useDefaults&&!l.compositeRule&&o[e].default!==void 0}function m(t){e.subschema({keyword:`properties`,schemaProp:t,dataProp:t},f)}}}})),ei=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=or(),n=U(),r=W(),i=W();e.default={keyword:`patternProperties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,data:s,parentSchema:c,it:l}=e,{opts:u}=l,d=(0,t.allSchemaProperties)(o),f=d.filter(e=>(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0||f.length===d.length&&(!l.opts.unevaluated||l.props===!0))return;let p=u.strictSchema&&!u.allowMatchingProperties&&c.properties,m=a.name(`valid`);l.props!==!0&&!(l.props instanceof n.Name)&&(l.props=(0,i.evaluatedPropsToName)(a,l.props));let{props:h}=l;g();function g(){for(let e of d)p&&_(e),l.allErrors?v(e):(a.var(m,!0),v(e),a.if(m))}function _(e){for(let t in p)new RegExp(e).test(t)&&(0,r.checkStrictMode)(l,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function v(r){a.forIn(`key`,s,o=>{a.if((0,n._)`${(0,t.usePattern)(e,r)}.test(${o})`,()=>{let t=f.includes(r);t||e.subschema({keyword:`patternProperties`,schemaProp:r,dataProp:o,dataPropType:i.Type.Str},m),l.opts.unevaluated&&h!==!0?a.assign((0,n._)`${h}[${o}]`,!0):!t&&!l.allErrors&&a.if((0,n.not)(m),()=>a.break())})})}}}})),ti=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W();e.default={keyword:`not`,schemaType:[`object`,`boolean`],trackErrors:!0,code(e){let{gen:n,schema:r,it:i}=e;if((0,t.alwaysValidSchema)(i,r)){e.fail();return}let a=n.name(`valid`);e.subschema({keyword:`not`,compositeRule:!0,createErrors:!1,allErrors:!1},a),e.failResult(a,()=>e.reset(),()=>e.error())},error:{message:`must NOT be valid`}}})),ni=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:or().validateUnion,error:{message:`must match a schema in anyOf`}}})),ri=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U(),n=W();e.default={keyword:`oneOf`,schemaType:`array`,trackErrors:!0,error:{message:`must match exactly one schema in oneOf`,params:({params:e})=>(0,t._)`{passingSchemas: ${e.passing}}`},code(e){let{gen:r,schema:i,parentSchema:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(o.opts.discriminator&&a.discriminator)return;let s=i,c=r.let(`valid`,!1),l=r.let(`passing`,null),u=r.name(`_valid`);e.setParams({passing:l}),r.block(d),e.result(c,()=>e.reset(),()=>e.error(!0));function d(){s.forEach((i,a)=>{let s;(0,n.alwaysValidSchema)(o,i)?r.var(u,!0):s=e.subschema({keyword:`oneOf`,schemaProp:a,compositeRule:!0},u),a>0&&r.if((0,t._)`${u} && ${c}`).assign(c,!1).assign(l,(0,t._)`[${l}, ${a}]`).else(),r.if(u,()=>{r.assign(c,!0),r.assign(l,a),s&&e.mergeEvaluated(s,t.Name)})})}}}})),ii=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W();e.default={keyword:`allOf`,schemaType:`array`,code(e){let{gen:n,schema:r,it:i}=e;if(!Array.isArray(r))throw Error(`ajv implementation error`);let a=n.name(`valid`);r.forEach((n,r)=>{if((0,t.alwaysValidSchema)(i,n))return;let o=e.subschema({keyword:`allOf`,schemaProp:r},a);e.ok(a),e.mergeEvaluated(o)})}}})),ai=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U(),n=W(),r={keyword:`if`,schemaType:[`object`,`boolean`],trackErrors:!0,error:{message:({params:e})=>(0,t.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,t._)`{failingKeyword: ${e.ifClause}}`},code(e){let{gen:r,parentSchema:a,it:o}=e;a.then===void 0&&a.else===void 0&&(0,n.checkStrictMode)(o,`"if" without "then" and "else" is ignored`);let s=i(o,`then`),c=i(o,`else`);if(!s&&!c)return;let l=r.let(`valid`,!0),u=r.name(`_valid`);if(d(),e.reset(),s&&c){let t=r.let(`ifClause`);e.setParams({ifClause:t}),r.if(u,f(`then`,t),f(`else`,t))}else s?r.if(u,f(`then`)):r.if((0,t.not)(u),f(`else`));e.pass(l,()=>e.error(!0));function d(){let t=e.subschema({keyword:`if`,compositeRule:!0,createErrors:!1,allErrors:!1},u);e.mergeEvaluated(t)}function f(n,i){return()=>{let a=e.subschema({keyword:n},u);r.assign(l,u),e.mergeValidEvaluated(a,l),i?r.assign(i,(0,t._)`${n}`):e.setParams({ifClause:n})}}}};function i(e,t){let r=e.schema[t];return r!==void 0&&!(0,n.alwaysValidSchema)(e,r)}e.default=r})),oi=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W();e.default={keyword:[`then`,`else`],schemaType:[`object`,`boolean`],code({keyword:e,parentSchema:n,it:r}){n.if===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "if" is ignored`)}}})),si=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=Gr(),n=qr(),r=Kr(),i=Jr(),a=Yr(),o=Xr(),s=Zr(),c=Qr(),l=$r(),u=ei(),d=ti(),f=ni(),p=ri(),m=ii(),h=ai(),g=oi();function _(e=!1){let _=[d.default,f.default,p.default,m.default,h.default,g.default,s.default,c.default,o.default,l.default,u.default];return e?_.push(n.default,i.default):_.push(t.default,r.default),_.push(a.default),_}e.default=_})),ci=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U();e.default={keyword:`format`,type:[`number`,`string`],schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,t._)`{format: ${e}}`},code(e,n){let{gen:r,data:i,$data:a,schema:o,schemaCode:s,it:c}=e,{opts:l,errSchemaPath:u,schemaEnv:d,self:f}=c;if(!l.validateFormats)return;a?p():m();function p(){let a=r.scopeValue(`formats`,{ref:f.formats,code:l.code.formats}),o=r.const(`fDef`,(0,t._)`${a}[${s}]`),c=r.let(`fType`),u=r.let(`format`);r.if((0,t._)`typeof ${o} == "object" && !(${o} instanceof RegExp)`,()=>r.assign(c,(0,t._)`${o}.type || "string"`).assign(u,(0,t._)`${o}.validate`),()=>r.assign(c,(0,t._)`"string"`).assign(u,o)),e.fail$data((0,t.or)(p(),m()));function p(){return l.strictSchema===!1?t.nil:(0,t._)`${s} && !${u}`}function m(){let e=d.$async?(0,t._)`(${o}.async ? await ${u}(${i}) : ${u}(${i}))`:(0,t._)`${u}(${i})`,r=(0,t._)`(typeof ${u} == "function" ? ${e} : ${u}.test(${i}))`;return(0,t._)`${u} && ${u} !== true && ${c} === ${n} && !${r}`}}function m(){let a=f.formats[o];if(!a){m();return}if(a===!0)return;let[s,c,p]=h(a);s===n&&e.pass(g());function m(){if(l.strictSchema===!1){f.logger.warn(e());return}throw Error(e());function e(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function h(e){let n=e instanceof RegExp?(0,t.regexpCode)(e):l.code.formats?(0,t._)`${l.code.formats}${(0,t.getProperty)(o)}`:void 0,i=r.scopeValue(`formats`,{key:o,ref:e,code:n});return typeof e==`object`&&!(e instanceof RegExp)?[e.type||`string`,e.validate,(0,t._)`${i}.validate`]:[`string`,e,i]}function g(){if(typeof a==`object`&&!(a instanceof RegExp)&&a.async){if(!d.$async)throw Error(`async format in sync schema`);return(0,t._)`await ${p}(${i})`}return typeof c==`function`?(0,t._)`${p}(${i})`:(0,t._)`${p}.test(${i})`}}}}})),li=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=[ci().default]})),ui=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.contentVocabulary=e.metadataVocabulary=void 0,e.metadataVocabulary=[`title`,`description`,`default`,`deprecated`,`readOnly`,`writeOnly`,`examples`],e.contentVocabulary=[`contentMediaType`,`contentEncoding`,`contentSchema`]})),di=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=jr(),n=Wr(),r=si(),i=li(),a=ui();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),fi=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DiscrError=void 0;var t;(function(e){e.Tag=`tag`,e.Mapping=`mapping`})(t||(e.DiscrError=t={}))})),pi=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U(),n=fi(),r=hr(),i=mr(),a=W();e.default={keyword:`discriminator`,type:`object`,schemaType:`object`,error:{message:({params:{discrError:e,tagName:t}})=>e===n.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:n,tagName:r}})=>(0,t._)`{error: ${e}, tag: ${r}, tagValue: ${n}}`},code(e){let{gen:o,data:s,schema:c,parentSchema:l,it:u}=e,{oneOf:d}=l;if(!u.opts.discriminator)throw Error(`discriminator: requires discriminator option`);let f=c.propertyName;if(typeof f!=`string`)throw Error(`discriminator: requires propertyName`);if(c.mapping)throw Error(`discriminator: mapping is not supported`);if(!d)throw Error(`discriminator: requires oneOf keyword`);let p=o.let(`valid`,!1),m=o.const(`tag`,(0,t._)`${s}${(0,t.getProperty)(f)}`);o.if((0,t._)`typeof ${m} == "string"`,()=>h(),()=>e.error(!1,{discrError:n.DiscrError.Tag,tag:m,tagName:f})),e.ok(p);function h(){let r=_();o.if(!1);for(let e in r)o.elseIf((0,t._)`${m} === ${e}`),o.assign(p,g(r[e]));o.else(),e.error(!1,{discrError:n.DiscrError.Mapping,tag:m,tagName:f}),o.endIf()}function g(n){let r=o.name(`valid`),i=e.subschema({keyword:`oneOf`,schemaProp:n},r);return e.mergeEvaluated(i,t.Name),r}function _(){let e={},t=o(l),n=!0;for(let e=0;e<d.length;e++){let c=d[e];if(c?.$ref&&!(0,a.schemaHasRulesButRef)(c,u.self.RULES)){let e=c.$ref;if(c=r.resolveRef.call(u.self,u.schemaEnv.root,u.baseId,e),c instanceof r.SchemaEnv&&(c=c.schema),c===void 0)throw new i.default(u.opts.uriResolver,u.baseId,e)}let l=c?.properties?.[f];if(typeof l!=`object`)throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${f}"`);n&&=t||o(c),s(l,e)}if(!n)throw Error(`discriminator: "${f}" must be required`);return e;function o({required:e}){return Array.isArray(e)&&e.includes(f)}function s(e,t){if(e.const)c(e.const,t);else if(e.enum)for(let n of e.enum)c(n,t);else throw Error(`discriminator: "properties/${f}" must have "const" or "enum"`)}function c(t,n){if(typeof t!=`string`||t in e)throw Error(`discriminator: "${f}" values must be unique strings`);e[t]=n}}}}})),mi=c({$id:()=>gi,$schema:()=>hi,default:()=>xi,definitions:()=>vi,properties:()=>bi,title:()=>_i,type:()=>yi}),hi,gi,_i,vi,yi,bi,xi,Si=o((()=>{hi=`http://json-schema.org/draft-07/schema#`,gi=`http://json-schema.org/draft-07/schema#`,_i=`Core schema meta-schema`,vi={schemaArray:{type:`array`,minItems:1,items:{$ref:`#`}},nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:`#/definitions/nonNegativeInteger`},{default:0}]},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}},yi=[`object`,`boolean`],bi={$id:{type:`string`,format:`uri-reference`},$schema:{type:`string`,format:`uri`},$ref:{type:`string`,format:`uri-reference`},$comment:{type:`string`},title:{type:`string`},description:{type:`string`},default:!0,readOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/definitions/nonNegativeInteger`},minLength:{$ref:`#/definitions/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},additionalItems:{$ref:`#`},items:{anyOf:[{$ref:`#`},{$ref:`#/definitions/schemaArray`}],default:!0},maxItems:{$ref:`#/definitions/nonNegativeInteger`},minItems:{$ref:`#/definitions/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},contains:{$ref:`#`},maxProperties:{$ref:`#/definitions/nonNegativeInteger`},minProperties:{$ref:`#/definitions/nonNegativeIntegerDefault0`},required:{$ref:`#/definitions/stringArray`},additionalProperties:{$ref:`#`},definitions:{type:`object`,additionalProperties:{$ref:`#`},default:{}},properties:{type:`object`,additionalProperties:{$ref:`#`},default:{}},patternProperties:{type:`object`,additionalProperties:{$ref:`#`},propertyNames:{format:`regex`},default:{}},dependencies:{type:`object`,additionalProperties:{anyOf:[{$ref:`#`},{$ref:`#/definitions/stringArray`}]}},propertyNames:{$ref:`#`},const:!0,enum:{type:`array`,items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:`#/definitions/simpleTypes`},{type:`array`,items:{$ref:`#/definitions/simpleTypes`},minItems:1,uniqueItems:!0}]},format:{type:`string`},contentMediaType:{type:`string`},contentEncoding:{type:`string`},if:{$ref:`#`},then:{$ref:`#`},else:{$ref:`#`},allOf:{$ref:`#/definitions/schemaArray`},anyOf:{$ref:`#/definitions/schemaArray`},oneOf:{$ref:`#/definitions/schemaArray`},not:{$ref:`#`}},xi={$schema:hi,$id:gi,title:_i,definitions:vi,type:yi,properties:bi,default:!0}})),Ci=u(s(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv=void 0;var n=Or(),r=di(),i=pi(),a=(Si(),d(mi).default),o=[`/properties`],s=`http://json-schema.org/draft-07/schema`,c=class extends n.default{_addVocabularies(){super._addVocabularies(),r.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(a,o):a;this.addMetaSchema(e,s,!1),this.refs[`http://json-schema.org/schema`]=s}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(s)?s:void 0)}};e.Ajv=c,t.exports=e=c,t.exports.Ajv=c,Object.defineProperty(e,`__esModule`,{value:!0}),e.default=c;var l=fr();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return l.KeywordCxt}});var u=U();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return u._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(e,`CodeGen`,{enumerable:!0,get:function(){return u.CodeGen}});var f=pr();Object.defineProperty(e,`ValidationError`,{enumerable:!0,get:function(){return f.default}});var p=mr();Object.defineProperty(e,`MissingRefError`,{enumerable:!0,get:function(){return p.default}})}))(),1),wi={$schema:`http://json-schema.org/draft-07/schema#`,$id:`https://kmap.dev/schemas/semantic-chart-config/1.0.0`,title:`SemanticChartConfig`,description:`Agent 语义化图表配置`,type:`object`,required:[`version`,`data`],additionalProperties:!1,properties:{version:{type:`string`,pattern:`^[0-9]+\\.[0-9]+\\.[0-9]+$`,description:`semver 版本号`},data:{$ref:`#/$defs/DataConfig`},indicators:{$ref:`#/$defs/IndicatorsConfig`},markers:{$ref:`#/$defs/MarkersConfig`},chart:{$ref:`#/$defs/ChartOptions`},theme:{$ref:`#/$defs/ThemeConfig`}},$defs:{DataConfig:{type:`object`,required:[`source`,`symbol`,`startDate`,`endDate`,`period`,`adjust`],additionalProperties:!1,properties:{source:{type:`string`,enum:[`baostock`,`dongcai`]},symbol:{type:`string`,pattern:`^[0-9]{6}$`},exchange:{type:`string`,enum:[`SH`,`SZ`,`BJ`]},startDate:{type:`string`,format:`date`},endDate:{type:`string`,format:`date`},period:{type:`string`,enum:[`daily`,`weekly`,`monthly`,`5min`,`15min`,`30min`,`60min`]},adjust:{type:`string`,enum:[`qfq`,`hfq`,`none`]}}},IndicatorsConfig:{type:`object`,additionalProperties:!1,properties:{main:{type:`array`,items:{$ref:`#/$defs/MainIndicatorConfig`},maxItems:5},sub:{type:`array`,items:{$ref:`#/$defs/SubIndicatorConfig`},maxItems:5}}},MainIndicatorConfig:{type:`object`,required:[`type`,`enabled`],additionalProperties:!1,properties:{type:{type:`string`,enum:[`MA`,`BOLL`]},enabled:{type:`boolean`},params:{type:`object`}},allOf:[{if:{properties:{type:{const:`MA`}},required:[`type`]},then:{properties:{params:{type:`object`,additionalProperties:!1,properties:{periods:{type:`array`,items:{type:`integer`,minimum:1,maximum:250},minItems:1,maxItems:5}}}}},else:{properties:{params:{type:`object`,additionalProperties:!1,properties:{period:{type:`integer`,minimum:1,maximum:100},multiplier:{type:`number`,minimum:.1,maximum:5}}}}}}]},SubIndicatorConfig:{type:`object`,required:[`type`,`enabled`],additionalProperties:!1,properties:{type:{type:`string`,enum:[`VOLUME`,`MACD`,`RSI`,`CCI`,`STOCH`,`MOM`,`WMSR`,`KST`,`FASTK`]},enabled:{type:`boolean`},params:{type:`object`}},allOf:[{if:{properties:{type:{const:`MACD`}}},then:{properties:{params:{type:`object`,additionalProperties:!1,properties:{fast:{type:`integer`,minimum:1,maximum:50},slow:{type:`integer`,minimum:1,maximum:100},signal:{type:`integer`,minimum:1,maximum:50}}}}}},{if:{properties:{type:{const:`RSI`}}},then:{properties:{params:{type:`object`,additionalProperties:!1,properties:{period1:{type:`integer`,minimum:1,maximum:100},period2:{type:`integer`,minimum:1,maximum:100},period3:{type:`integer`,minimum:1,maximum:100}}}}}}]},MarkersConfig:{type:`object`,additionalProperties:!1,properties:{showVolumePriceMarkers:{type:`boolean`},showExtremaMarkers:{type:`boolean`},customMarkers:{type:`array`,items:{$ref:`#/$defs/CustomMarker`},maxItems:100},legend:{$ref:`#/$defs/LegendConfig`}}},CustomMarker:{type:`object`,required:[`id`,`date`,`shape`],additionalProperties:!1,properties:{id:{type:`string`,maxLength:64},date:{type:`string`,description:`日期时间字符串,日K用 YYYY-MM-DD,分钟K用 YYYY-MM-DD HH:mm`,pattern:`^[0-9]{4}-[0-9]{2}-[0-9]{2}( [0-9]{2}:[0-9]{2})?$`},shape:{type:`string`,enum:[`arrow_up`,`arrow_down`,`flag`,`circle`,`rectangle`,`diamond`]},groupKey:{type:`string`,maxLength:32},offset:{type:`object`,additionalProperties:!1,properties:{x:{type:`number`,minimum:-500,maximum:500},y:{type:`number`,minimum:-500,maximum:500}}},style:{$ref:`#/$defs/MarkerStyle`},label:{$ref:`#/$defs/MarkerLabel`},metadata:{type:`object`,maxProperties:20,additionalProperties:{type:[`string`,`number`,`boolean`,`null`],maxLength:200}}}},MarkerStyle:{type:`object`,additionalProperties:!1,properties:{fillColor:{type:`string`,pattern:`^(#[0-9a-fA-F]{3,8}|rgb\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*\\)|rgba\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*[\\d.]+\\s*\\))$`},strokeColor:{type:`string`,pattern:`^(#[0-9a-fA-F]{3,8}|rgb\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*\\)|rgba\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*[\\d.]+\\s*\\))$`},textColor:{type:`string`,pattern:`^(#[0-9a-fA-F]{3,8}|rgb\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*\\)|rgba\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*[\\d.]+\\s*\\))$`},size:{type:`number`,minimum:4,maximum:50},lineWidth:{type:`number`,minimum:.5,maximum:10},opacity:{type:`number`,minimum:0,maximum:1}}},MarkerLabel:{type:`object`,required:[`text`],additionalProperties:!1,properties:{text:{type:`string`,maxLength:50},position:{type:`string`,enum:[`left`,`right`,`top`,`bottom`,`inside`]},align:{type:`string`,enum:[`start`,`center`,`end`]},fontSize:{type:`number`,minimum:8,maximum:24},offset:{type:`object`,additionalProperties:!1,properties:{x:{type:`number`,minimum:-500,maximum:500},y:{type:`number`,minimum:-500,maximum:500}}}}},LegendConfig:{type:`object`,additionalProperties:!1,properties:{enabled:{type:`boolean`},position:{type:`string`,enum:[`bottom-right`,`bottom-left`,`top-right`,`top-left`]},onClick:{type:`string`,enum:[`highlight`,`toggle`,`none`]}}},ChartOptions:{type:`object`,additionalProperties:!1,properties:{kWidth:{type:`number`,minimum:2,maximum:50},kGap:{type:`number`,minimum:0,maximum:20},autoScrollToRight:{type:`boolean`}}},ThemeConfig:{type:`object`,additionalProperties:!1,properties:{priceUpColor:{type:`string`,pattern:`^#[0-9a-fA-F]{6}$`},priceDownColor:{type:`string`,pattern:`^#[0-9a-fA-F]{6}$`}}}}},Ti=[`__proto__`,`constructor`,`prototype`],Ei=/^(#[0-9a-fA-F]{3,8}|rgb\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*\)|rgba\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*[\d.]+\s*\))$/,Di={SH:/^(600|601|603|605|688)\d{3}$/,SZ:/^(000|001|002|003|300|301)\d{3}$/,BJ:/^(83|87|43|82)\d{4}$/};function Oi(e){return{"5min":30,"15min":60,"30min":90,"60min":180,daily:365*3,weekly:365*5,monthly:365*10}[e]??365}var ki=(typeof document<`u`?document.createElement(`canvas`):null)?.getContext(`2d`)??null,Ai=class e{ajv;limits;constructor(){this.ajv=new Ci.default({allErrors:!0,allowUnionTypes:!0}),this.ajv.addFormat(`date`,{type:`string`,validate:e=>/^\d{4}-\d{2}-\d{2}$/.test(e)}),this.ajv.addSchema(wi),this.limits={maxJsonSize:64*1024,maxIndicators:10,maxCustomMarkers:100}}validateRawInput(e){return(typeof TextEncoder<`u`?new TextEncoder().encode(e).byteLength:e.length*3)>this.limits.maxJsonSize?{valid:!1,errors:[`JSON payload too large (max 64KB)`]}:{valid:!0}}validate(e){if(!e||typeof e!=`object`)return{valid:!1,errors:[`Config must be an object`]};let t=this.checkPrototypePollution(e);return t.valid?this.ajv.validate(`https://kmap.dev/schemas/semantic-chart-config/1.0.0`,e)?{valid:!0}:{valid:!1,errors:this.ajv.errors?.map(e=>`${e.instancePath} ${e.message}`)||[`Schema validation failed`]}:t}securityCheck(e){let t=[],n=this.checkDateRange(e.data);n.valid||t.push(...n.errors||[]);let r=this.checkSymbol(e.data);if(r.valid||t.push(...r.errors||[]),e.indicators&&(e.indicators.main?.length||0)+(e.indicators.sub?.length||0)>this.limits.maxIndicators&&t.push(`Too many indicators (max ${this.limits.maxIndicators})`),(e.markers?.customMarkers?.length||0)>this.limits.maxCustomMarkers&&t.push(`Too many custom markers (max ${this.limits.maxCustomMarkers})`),e.markers?.customMarkers)for(let n of e.markers.customMarkers){if(n.style){let e=this.checkMarkerStyle(n.style,n.id);t.push(...e)}let e=this.checkMarkerDate(n.date,n.id);t.push(...e)}return{passed:t.length===0,violations:t.length>0?t:void 0}}checkPrototypePollution(e,t=``){if(!e||typeof e!=`object`)return{valid:!0};let n=[];for(let r of Object.keys(e))Ti.includes(r)&&n.push(`Forbidden key "${r}" found at ${t}`);return n.length>0?{valid:!1,errors:n}:{valid:!0}}checkDateRange(e){let t=[],n=new Date(e.startDate),r=new Date(e.endDate);if(isNaN(n.getTime())&&t.push(`Invalid startDate: ${e.startDate}`),isNaN(r.getTime())&&t.push(`Invalid endDate: ${e.endDate}`),t.length>0)return{valid:!1,errors:t};let i=Oi(e.period),a=Math.ceil((r.getTime()-n.getTime())/(1e3*60*60*24));return a>i&&t.push(`Date range exceeds maximum for period "${e.period}" (max ${i} days, got ${a})`),a<0&&t.push(`endDate must be after startDate`),t.length>0?{valid:!1,errors:t}:{valid:!0}}checkSymbol(e){let{symbol:t,exchange:n}=e;if(n){if(!Di[n].test(t))return{valid:!1,errors:[`Invalid symbol "${t}" for exchange "${n}"`]}}else if(!Object.values(Di).some(e=>e.test(t)))return{valid:!1,errors:[`Invalid symbol format: "${t}"`]};return{valid:!0}}checkMarkerStyle(e,t){let n=[],r=[`fillColor`,`strokeColor`,`textColor`];for(let i of r){let r=e[i];typeof r==`string`&&!Ei.test(r)&&n.push(`Invalid ${i} in marker "${t}": ${r}`)}if(ki)for(let i of r){let r=e[i];typeof r==`string`&&(ki.fillStyle=`#000000`,ki.fillStyle=r,ki.fillStyle===`#000000`&&r!==`#000000`&&!r.startsWith(`#000`)&&n.push(`Potentially unsafe ${i} in marker "${t}": ${r}`))}return n}static DATE_PATTERN=/^\d{4}-\d{2}-\d{2}( \d{2}:\d{2})?$/;checkMarkerDate(t,n){let r=[];if(!e.DATE_PATTERN.test(t))return r.push(`Invalid date format in marker "${n}": ${t} (expected YYYY-MM-DD or YYYY-MM-DD HH:mm)`),r;let i=t.includes(` `),a;if(i)a=new Date(t);else{let[e,n,r]=t.split(`-`).map(Number);a=new Date(Date.UTC(e,n-1,r))}return isNaN(a.getTime())&&r.push(`Invalid date value in marker "${n}": ${t}`),r}},ji=class{chart;validator;events;constructor(e){this.chart=e,this.validator=new Ai,this.events=new p}async applyConfig(e){let t=this.validator.validate(e);if(!t.valid)return{success:!1,errors:t.errors};let n=this.validator.securityCheck(e);if(!n.passed)return{success:!1,errors:n.violations};this.events.emit(`config:loading`,void 0);try{return await this.doApplyConfig(e),this.events.emit(`config:ready`,void 0),{success:!0}}catch(e){return this.events.emit(`config:error`,e),{success:!1,errors:[e instanceof Error?e.message:String(e)]}}}on(e,t){this.events.on(e,t)}off(e,t){this.events.off(e,t)}async doApplyConfig(e){console.log(`[Semantic] doApplyConfig start, data config:`,e.data);let t=await Xn(e.data.source,{symbol:e.data.symbol,startDate:e.data.startDate,endDate:e.data.endDate,period:e.data.period,adjust:e.data.adjust});console.log(`[Semantic] fetched data:`,t.length,`items`),this.chart.updateData(t),e.indicators&&(console.log(`[Semantic] applying indicators:`,e.indicators),this.applyIndicators(e.indicators.main,e.indicators.sub)),e.markers&&(console.log(`[Semantic] applying markers:`,e.markers.customMarkers?.length,`markers`),this.applyMarkers(e.markers.customMarkers,e.data.period)),e.chart&&this.applyChartOptions(e.chart),console.log(`[Semantic] doApplyConfig done`)}applyIndicators(e,t){if(e){for(let t of e)if(t.enabled)switch(t.type){case`MA`:this.applyMAIndicator(t);break;case`BOLL`:this.applyBOLLIndicator(t);break;case`EXPMA`:this.applyEXPMAIndicator(t);break;case`ENE`:this.applyENEIndicator(t);break}}if(this.chart.clearSubPanes(),t)for(let e of t)this.applySubIndicator(e)}applyMAIndicator(e){let t=e.params?.periods||[5,10,20,30,60],n={};for(let e of t)e===5?n.ma5=!0:e===10?n.ma10=!0:e===20?n.ma20=!0:e===30?n.ma30=!0:e===60&&(n.ma60=!0);console.log(`[Semantic] applyMAIndicator, periods:`,t,`maFlags:`,n),this.chart.updateRendererConfig(`ma`,n)}applyBOLLIndicator(e){let t={period:e.params?.period||20,multiplier:e.params?.multiplier||2};this.chart.updateRendererConfig(`boll`,t)}applyEXPMAIndicator(e){let t={fastPeriod:e.params?.fastPeriod||12,slowPeriod:e.params?.slowPeriod||50};this.chart.updateRendererConfig(`expma`,t)}applyENEIndicator(e){let t={period:e.params?.period||10,deviation:e.params?.deviation||11};this.chart.updateRendererConfig(`ene`,t)}applySubIndicator(e){if(!e.enabled)return;let{type:t,params:n}=e;this.chart.createSubPane(t,n)||console.warn(`[Semantic] Failed to create sub pane for ${t}`)}applyMarkers(e,t){if(!e||e.length===0){this.chart.clearCustomMarkers();return}let n=e.map(e=>({id:e.id,date:e.date,timestamp:Mi(e.date,t||`daily`),shape:e.shape,groupKey:e.groupKey,offset:e.offset,style:e.style,label:e.label,metadata:e.metadata}));this.chart.updateCustomMarkers(n)}applyChartOptions(e){e.autoScrollToRight}};function Mi(e,t){if(e.includes(` `)){let[t,n]=e.split(` `),r=t.split(`-`).map(Number),i=r[0],a=r[1],o=r[2],s=n.split(`:`).map(Number),c=s[0],l=s[1];return Date.UTC(i,a-1,o,c-8,l,0,0)}else{let t=e.split(`-`).map(Number),n=t[0],r=t[1],i=t[2];return Date.UTC(n,r-1,i,-8,0,0,0)}}var Ni={arrow_up:16,arrow_down:16,flag:14,circle:12,rectangle:14,diamond:12};function Pi(e,t,n,r,i,a){let o=a.fillColor||`#000000`,s=a.strokeColor||o,c=i||Ni[t];switch(e.fillStyle=o,e.strokeStyle=s,e.lineWidth=a.lineWidth||1,a.opacity!==void 0&&(e.globalAlpha=a.opacity),t){case`arrow_up`:zi(e,n,r,c);break;case`arrow_down`:Bi(e,n,r,c);break;case`circle`:Vi(e,n,r,c);break;case`rectangle`:Hi(e,n,r,c);break;case`diamond`:Ui(e,n,r,c);break;case`flag`:Wi(e,n,r,c);break}e.globalAlpha=1}var Fi=2.5,Ii=4;function Li(e,t,n,r,i,a,o=!1){let s=t.fontSize||12,c=a.textColor||`#333333`,l=i/2;e.font=`${s}px sans-serif`,e.fillStyle=c,e.textBaseline=`middle`;let u=i*Fi,d=Ri(e,t.text,u),f=e.measureText(d).width,p=n,m=r;switch(t.position){case`left`:p=n-l-f/2-Ii;break;case`right`:p=n+l+f/2+Ii;break;case`top`:m=r-l-s/2-Ii;break;case`bottom`:m=r+l+s/2+Ii;break;default:m=o?r-l-s/2-Ii:r+l+s/2+Ii;break}t.offset&&(p+=t.offset.x||0,m+=t.offset.y||0),e.textAlign=t.align||`center`,e.fillText(d,p,m)}function Ri(e,t,n){if(e.measureText(t).width<=n)return t;let r=e.measureText(`…`).width,i=0,a=t.length;for(;i<a;){let o=Math.ceil((i+a)/2),s=t.slice(0,o);e.measureText(s).width+r<=n?i=o:a=o-1}return t.slice(0,i)+`…`}function zi(e,t,n,r){e.beginPath(),e.moveTo(t,n-r/2),e.lineTo(t-r/2,n+r/2),e.lineTo(t+r/2,n+r/2),e.closePath(),e.fill()}function Bi(e,t,n,r){e.beginPath(),e.moveTo(t,n+r/2),e.lineTo(t-r/2,n-r/2),e.lineTo(t+r/2,n-r/2),e.closePath(),e.fill()}function Vi(e,t,n,r){e.beginPath(),e.arc(t,n,r/2,0,Math.PI*2),e.fill()}function Hi(e,t,n,r){e.fillRect(t-r/2,n-r/2,r,r)}function Ui(e,t,n,r){e.beginPath(),e.moveTo(t,n-r/2),e.lineTo(t+r/2,n),e.lineTo(t,n+r/2),e.lineTo(t-r/2,n),e.closePath(),e.fill()}function Wi(e,t,n,r){e.beginPath(),e.moveTo(t-r/4,n+r/2),e.lineTo(t-r/4,n-r/2),e.stroke(),e.beginPath(),e.moveTo(t-r/4,n-r/2),e.lineTo(t+r/2,n-r/4),e.lineTo(t-r/4,n),e.closePath(),e.fill()}function Gi(e,t,n,r,i,a){let o=a/2;switch(n){case`circle`:let n=e-r,a=t-i;return n*n+a*a<=o*o;default:return e>=r-o&&e<=r+o&&t>=i-o&&t<=i+o}}var Ki=function(e){return e.Registered=`registered`,e.Installed=`installed`,e.Error=`error`,e}({});function qi(e){return{id:e.id,role:e.role,capabilities:{...e.capabilities},top:e.top,height:e.height,yAxis:{priceToY:t=>e.yAxis.priceToY(t),yToPrice:t=>e.yAxis.yToPrice(t),getPaddingTop:()=>e.yAxis.getPaddingTop(),getPaddingBottom:()=>e.yAxis.getPaddingBottom(),getPriceOffset:()=>e.yAxis.getPriceOffset(),getDisplayRange:t=>e.yAxis.getDisplayRange(t),getScaleType:()=>e.yAxis.getScaleType()},priceRange:e.priceRange}}var Ji=Symbol(`global-pane`),G={LAST_PRICE_LABEL:-25,SYSTEM_YAXIS:-20,SYSTEM_XAXIS:-20,BACKGROUND:0,GRID:10,INDICATOR:30,MAIN:50,INDICATOR_SCALE:55,OVERLAY:80,FOREGROUND:100,SYSTEM_BORDER:120,SYSTEM_CROSSHAIR:150},Yi=class{plugins=new Map;register(e,t){if(this.plugins.has(e.name))throw Error(`Plugin "${e.name}" is already registered`);let n={plugin:e,config:{enabled:!0,priority:0,...t},state:`registered`};return this.plugins.set(e.name,n),n}unregister(e){return this.plugins.delete(e)}get(e){return this.plugins.get(e)}getPlugin(e){return this.plugins.get(e)?.plugin}getAll(){return Array.from(this.plugins.values())}getEnabled(){return this.getAll().filter(e=>e.config?.enabled!==!1)}updateState(e,t,n){let r=this.plugins.get(e);r&&(r.state=t,n&&(r.error=n))}has(e){return this.plugins.has(e)}clear(){this.plugins.clear()}},Xi=class{hooks=new Map;tap(e,t,n=0){this.hooks.has(e)||this.hooks.set(e,[]);let r=this.hooks.get(e);r.push({name:e,fn:t,priority:n}),r.sort((e,t)=>e.priority-t.priority)}untap(e,t){let n=this.hooks.get(e);if(n){let e=n.findIndex(e=>e.fn===t);e!==-1&&n.splice(e,1)}}async call(e,t,n){let r=this.hooks.get(e);if(!r||r.length===0)return[];let i=[];for(let{fn:a}of r)try{let e=await a(t);i.push(e)}catch(t){if(console.error(`[HookSystem] Error in hook "${e}":`,t),n?.throwOnError)throw t}return i}callSync(e,t,n){let r=this.hooks.get(e);if(!r||r.length===0)return[];let i=[];for(let{fn:a}of r)try{let e=a(t);i.push(e)}catch(t){if(console.error(`[HookSystem] Error in hook "${e}":`,t),n?.throwOnError)throw t}return i}clear(){this.hooks.clear()}hookCount(e){return this.hooks.get(e)?.length??0}},Zi=class{configs=new Map;defaults=new Map;registerDefaults(e,t){this.defaults.set(e,{...t}),this.configs.has(e)||this.configs.set(e,new Map);let n=this.configs.get(e);for(let[e,r]of Object.entries(t))n.has(e)||n.set(e,r)}get(e,t,n){let r=this.configs.get(e);if(r?.has(t))return r.get(t);let i=this.defaults.get(e);return i&&t in i?i[t]:n}set(e,t,n){this.configs.has(e)||this.configs.set(e,new Map),this.configs.get(e).set(t,n)}setAll(e,t){for(let[n,r]of Object.entries(t))this.set(e,n,r)}getAll(e){let t=this.configs.get(e);return{...this.defaults.get(e)||{},...t?Object.fromEntries(t):{}}}clear(e){e?(this.configs.delete(e),this.defaults.delete(e)):(this.configs.clear(),this.defaults.clear())}},Qi=class{states=new Map;ownerNamespaces=new Map;setState(e,t,n){this.states.set(e,t)}getState(e){return this.states.get(e)}clearState(e){this.states.delete(e)}registerStateOwner(e,t){this.ownerNamespaces.set(e,new Set(t))}clearByOwner(e){let t=this.ownerNamespaces.get(e);t&&(t.forEach(e=>{this.states.delete(e)}),this.ownerNamespaces.delete(e))}clear(){this.states.clear(),this.ownerNamespaces.clear()}},$i=class{registry;eventBus;hookSystem;configManager;stateStore;isDestroyed=!1;logger;constructor(e){this.registry=new Yi,this.eventBus=new p,this.hookSystem=new Xi,this.configManager=new Zi,this.stateStore=new Qi,this.logger=e??console}events={on:(e,t)=>{this.eventBus.on(e,t)},off:(e,t)=>{this.eventBus.off(e,t)},emit:(e,t)=>{this.eventBus.emit(e,t)},once:(e,t)=>{this.eventBus.once(e,t)}};hooks={tap:(e,t,n=0)=>{this.hookSystem.tap(e,t,n)},untap:(e,t)=>{this.hookSystem.untap(e,t)},call:async(e,t,n)=>this.hookSystem.call(e,t,n),callSync:(e,t,n)=>this.hookSystem.callSync(e,t,n)};getConfig(e,t,n){return this.configManager.get(e,t,n)}setConfig(e,t,n){this.configManager.set(e,t,n)}getPlugin(e){return this.registry.getPlugin(e)}log(e,t,...n){let r=`[${new Date().toISOString()}] [${e.toUpperCase()}]`;this.logger[e](`${r} ${t}`,...n)}setSharedState(e,t,n){this.stateStore.setState(e,t,n)}getSharedState(e){return this.stateStore.getState(e)}clearSharedState(e){this.stateStore.clearState(e)}registerStateOwner(e,t){this.stateStore.registerStateOwner(e,t)}clearByOwner(e){this.stateStore.clearByOwner(e)}async use(e,t){if(this.ensureNotDestroyed(),this.registry.has(e.name))throw Error(`Plugin "${e.name}" is already installed`);try{let n=this.registry.register(e,t);t&&this.configManager.setAll(e.name,t),await this.hooks.call(`plugin:beforeInstall`,{plugin:e,config:t},{throwOnError:!0}),await e.install(this,n.config),this.registry.updateState(e.name,`installed`),await this.hooks.call(`plugin:afterInstall`,{plugin:e,config:t},{throwOnError:!0}),this.log(`info`,`Plugin "${e.name}" installed successfully`)}catch(t){throw this.registry.updateState(e.name,`error`,t instanceof Error?t:Error(String(t))),this.log(`error`,`Failed to install plugin "${e.name}":`,t),t}}async remove(e){this.ensureNotDestroyed();let t=this.registry.get(e);if(!t)throw Error(`Plugin "${e}" is not installed`);try{await this.hooks.call(`plugin:beforeUninstall`,{name:e},{throwOnError:!0}),t.plugin.uninstall&&await t.plugin.uninstall(),this.registry.unregister(e),this.configManager.clear(e),await this.hooks.call(`plugin:afterUninstall`,{name:e},{throwOnError:!0}),this.log(`info`,`Plugin "${e}" removed successfully`)}catch(t){throw this.log(`error`,`Failed to remove plugin "${e}":`,t),t}}getPlugins(){return this.registry.getAll()}getState(e){return this.registry.get(e)?.state}async destroy(){if(!this.isDestroyed){for(let e of this.registry.getAll())try{e.plugin.uninstall&&await e.plugin.uninstall()}catch(t){this.log(`error`,`Error uninstalling "${e.plugin.name}":`,t)}this.registry.clear(),this.eventBus.clear(),this.hookSystem.clear(),this.configManager.clear(),this.stateStore.clear(),this.isDestroyed=!0,this.log(`info`,`PluginHost destroyed`)}}ensureNotDestroyed(){if(this.isDestroyed)throw Error(`PluginHost has been destroyed`)}};function ea(e){return new $i(e)}function ta(e,t){let n=Math.round(e*t);return n%2==0&&(n+=1),Math.max(1,n)}function na(e,t,n){let r=ta(e,n),i=Math.round(t*n),a=r+i,o=i;return{kWidthPx:r,kGapPx:i,unitPx:a,startXPx:o,kWidthLogical:r/n,kGapLogical:i/n,unitLogical:a/n,startXLogical:o/n}}function ra(e,t,n,r,i,a=1){let{unitPx:o,startXPx:s}=na(n,r,a),c=e*a,l=t*a;return{start:Math.max(0,Math.floor((c-s)/o)-1),end:Math.min(i,Math.ceil((c+l-s)/o)+1)}}function ia(e,t,n){let r=-1/0,i=1/0;for(let a=t;a<n&&a<e.length;a++){let t=e[a];t&&(t.high>r&&(r=t.high),t.low<i&&(i=t.low))}return!Number.isFinite(r)||!Number.isFinite(i)?{maxPrice:100,minPrice:0}:{maxPrice:r,minPrice:i}}var aa={logicalOffset:4,coordOffset:1e-4};function oa(e){return Math.abs(e)<1e-15}function K(e,t){let n=Math.abs(e);if(oa(n))return 0;let r=Math.log10(n+t.coordOffset)+t.logicalOffset;return e<0?-r:r}function sa(e,t){let n=Math.abs(e);if(oa(n))return 0;let r=10**(n-t.logicalOffset)-t.coordOffset;return e<0?-r:r}function ca(e){if(e===null)return{...aa};let t=Math.abs(e.maxPrice-e.minPrice);if(t>=1||t<1e-15)return{...aa};let n=Math.ceil(Math.abs(Math.log10(t))),r=aa.logicalOffset+n;return{logicalOffset:r,coordOffset:1/10**r}}function la(e,t){return e.logicalOffset===t.logicalOffset&&e.coordOffset===t.coordOffset}var ua=class{range={maxPrice:100,minPrice:0};height=1;paddingTop=0;paddingBottom=0;priceOffset=0;verticalScale=1;scaleType=`linear`;logFormula=ca(null);setRange(e){if(this.range=e,this.scaleType===`log`&&e.minPrice>0){let t=ca(e);if(!la(t,this.logFormula)){let n=K(e.minPrice,this.logFormula),r=(K(e.maxPrice,this.logFormula)+n)/2+this.priceOffset;this.logFormula=t;let i=K(e.minPrice,this.logFormula),a=(K(e.maxPrice,this.logFormula)+i)/2;this.priceOffset=this.clampOffset(r-a)}}}setHeight(e){this.height=Math.max(1,e)}setPadding(e,t){this.paddingTop=Math.max(0,e),this.paddingBottom=Math.max(0,t)}getRange(){return this.range}getPaddingTop(){return this.paddingTop}getPaddingBottom(){return this.paddingBottom}setPriceOffset(e){this.priceOffset=this.clampOffset(e)}getPriceOffset(){return this.priceOffset}resetPriceOffset(){this.priceOffset=0}clampOffset(e){if(this.scaleType===`log`&&this.range.minPrice>0){let t=K(this.range.minPrice,this.logFormula),n=K(this.range.maxPrice,this.logFormula)-t;if(n<=0)return 0;let r=n*(1+1/this.verticalScale)/2;return Math.max(-r,Math.min(r,e))}let t=this.range.maxPrice-this.range.minPrice;if(t<=0)return 0;let n=t*(1+1/this.verticalScale)/2;return Math.max(-n,Math.min(n,e))}scaleByDelta(e){if(!Number.isFinite(e)||e===0)return;let t=Math.exp(-e*.01),n=this.verticalScale*t;this.verticalScale=Math.min(8,Math.max(.2,n)),this.priceOffset=this.clampOffset(this.priceOffset)}getVerticalScale(){return this.verticalScale}setScaleType(e){if(e!==this.scaleType){if(e===`log`&&this.range.minPrice>0){this.logFormula=ca(this.range);let e=(this.range.maxPrice+this.range.minPrice)/2,t=e+this.priceOffset;this.priceOffset=K(t,this.logFormula)-K(e,this.logFormula),this.priceOffset=this.clampOffset(this.priceOffset)}else if(e===`linear`&&this.scaleType===`log`){let e=K(this.range.minPrice,this.logFormula),t=sa((K(this.range.maxPrice,this.logFormula)+e)/2+this.priceOffset,this.logFormula),n=(this.range.maxPrice+this.range.minPrice)/2;this.priceOffset=t-n,this.priceOffset=this.clampOffset(this.priceOffset)}this.scaleType=e}}getScaleType(){return this.scaleType}getDisplayRange(e){let{minPrice:t,maxPrice:n}=e??this.range;if(this.scaleType===`log`&&t>0){let e=K(t,this.logFormula),r=K(n,this.logFormula),i=r-e||1,a=(r+e)/2+this.priceOffset,o=i/(2*this.verticalScale);return{maxPrice:sa(a+o,this.logFormula),minPrice:sa(a-o,this.logFormula)}}let r=n-t||1,i=(n+t)/2+this.priceOffset,a=r/(2*this.verticalScale);return{maxPrice:i+a,minPrice:i-a}}priceToY(e){let{maxPrice:t,minPrice:n}=this.getDisplayRange(),r=Math.max(1,this.height-this.paddingTop-this.paddingBottom),i;if(this.scaleType===`log`&&n>0){let r=K(n,this.logFormula),a=K(t,this.logFormula);i=(K(e,this.logFormula)-r)/(a-r||1)}else i=(e-n)/(t-n||1);return this.paddingTop+r*(1-i)}yToPrice(e){let{maxPrice:t,minPrice:n}=this.getDisplayRange(),r=Math.max(1,this.height-this.paddingTop-this.paddingBottom),i=1-(e-this.paddingTop)/r;if(this.scaleType===`log`&&n>0){let e=K(n,this.logFormula);return sa(e+i*(K(t,this.logFormula)-e),this.logFormula)}return n+i*(t-n)}deltaYToPriceOffset(e){let t=Math.max(1,this.height-this.paddingTop-this.paddingBottom);if(this.scaleType===`log`&&this.range.minPrice>0){let n=K(this.range.minPrice,this.logFormula);return e*((K(this.range.maxPrice,this.logFormula)-n)/t)}return e*((this.range.maxPrice-this.range.minPrice||1)/t)}},q=function(e){return e.Main=`main`,e.Overlay=`overlay`,e.All=`all`,e}({});function da(e){return e===`price`?{showPriceAxisTicks:!0,showCrosshairPriceLabel:!0,candleHitTest:!0,supportsPriceTranslate:!0}:e===`indicator`?{showPriceAxisTicks:!1,showCrosshairPriceLabel:!0,candleHitTest:!1,supportsPriceTranslate:!0}:{showPriceAxisTicks:!1,showCrosshairPriceLabel:!1,candleHitTest:!1,supportsPriceTranslate:!1}}var fa=class{id;role;capabilities;top=0;height=0;priceRange={maxPrice:100,minPrice:0};yAxis=new ua;renderers=[];constructor(e,t={}){this.id=e,this.role=t.role??(e===`main`?`price`:`indicator`),this.capabilities={...da(this.role),...t.capabilities??{}}}setLayout(e,t){this.top=e,this.height=Math.max(1,t),this.yAxis.setHeight(this.height)}setPadding(e,t){this.yAxis.setPadding(e,t)}addRenderer(e){this.renderers.push(e)}updateRange(e,t,n){this.priceRange=ia(e,t.start,t.end),n&&Number.isFinite(n.min)&&Number.isFinite(n.max)&&(this.priceRange.minPrice=Math.min(this.priceRange.minPrice,n.min),this.priceRange.maxPrice=Math.max(this.priceRange.maxPrice,n.max)),this.yAxis.setRange(this.priceRange)}},pa=Symbol(`renderer:global-cache`),ma=class{plugins=new Map;pluginHost=null;enabledState=new Map;groupCache=new Map;mergedCache=new Map;knownPaneIds=new Set;cacheInvalid=!0;onInvalidate=null;setInvalidateCallback(e){this.onInvalidate=e}setPluginHost(e){this.pluginHost=e}addKnownPaneId(e){this.knownPaneIds.add(e),this.cacheInvalid=!0}removeKnownPaneId(e){this.knownPaneIds.delete(e),this.cacheInvalid=!0}setKnownPaneIds(e){this.knownPaneIds=new Set(e),this.cacheInvalid=!0}register(e){if(this.plugins.has(e.name)){console.warn(`Renderer plugin "${e.name}" already registered`);return}this.plugins.set(e.name,e),e.enabled!==void 0&&this.enabledState.set(e.name,e.enabled),this.cacheInvalid=!0;let t=e;if(t.onInstall&&this.pluginHost)try{t.onInstall(this.pluginHost)}catch(t){console.error(`[RendererPlugin] ${e.name} onInstall error:`,t)}let n=t.getDeclaredNamespaces?.();n&&this.pluginHost&&this.pluginHost.registerStateOwner(e.name,n),this.onInvalidate?.()}unregister(e){let t=this.plugins.get(e);if(t){if(this.pluginHost?.clearByOwner(e),t.onUninstall)try{t.onUninstall()}catch(e){console.error(`[RendererPlugin] ${t.name} onUninstall error:`,e)}this.plugins.delete(e),this.enabledState.delete(e),this.cacheInvalid=!0,this.onInvalidate?.()}}clear(){for(let e of this.plugins.values())if(e.onUninstall)try{e.onUninstall()}catch(t){console.error(`[RendererPlugin] ${e.name} onUninstall error:`,t)}this.plugins.clear(),this.enabledState.clear(),this.groupCache.clear(),this.mergedCache.clear(),this.cacheInvalid=!1}mergeSorted(e,t){let n=[],r=0,i=0;for(;r<e.length&&i<t.length;)e[r].priority<=t[i].priority?n.push(e[r++]):n.push(t[i++]);return[...n,...e.slice(r),...t.slice(i)]}rebuildCache(){if(!this.cacheInvalid)return;this.groupCache.clear(),this.mergedCache.clear();for(let e of this.plugins.values()){let t=typeof e.paneId==`symbol`?pa:e.paneId;this.groupCache.has(t)||this.groupCache.set(t,[]),this.groupCache.get(t).push(e)}for(let[,e]of this.groupCache)e.sort((e,t)=>e.priority-t.priority);let e=this.groupCache.get(pa)??[];for(let t of this.knownPaneIds){let n=this.groupCache.get(t)??[],r=this.mergeSorted(n,e);this.mergedCache.set(t,r)}this.mergedCache.set(pa,[...e]),this.cacheInvalid=!1}isRendererEnabled(e){let t=this.enabledState.get(e.name);return t===void 0?e.enabled!==!1:t}getMergedRenderers(e){this.rebuildCache();let t=this.mergedCache.get(e);if(!t){let n=this.groupCache.get(e)??[],r=this.groupCache.get(pa)??[];t=this.mergeSorted(n,r),this.mergedCache.set(e,t)}return t}getRenderers(e){return this.getMergedRenderers(e).filter(e=>e.isSystem?!1:this.isRendererEnabled(e))}render(e,t,n){let r=this.getRenderers(e),i=[];for(let e of r){if(n){let t=e.layer??`main`;if(n===q.Overlay&&t!==`overlay`||n===q.Main&&t===`overlay`)continue}try{e.draw(t)}catch(n){let r=n instanceof Error?n:Error(String(n));console.error(`[RendererPlugin] ${e.name} draw error:`,r),i.push({name:e.name,error:{message:r.message,stack:r.stack},paneId:t.pane.id,timestamp:Date.now()})}}return i}renderPlugin(e,t){let n=this.plugins.get(e);if(!n||!this.isRendererEnabled(n))return[];let r=[];try{n.draw(t)}catch(n){let i=n instanceof Error?n:Error(String(n));console.error(`[RendererPlugin] ${e} draw error:`,i),r.push({name:e,error:{message:i.message,stack:i.stack},paneId:t.pane.id,timestamp:Date.now()})}return r}setEnabled(e,t){this.plugins.has(e)&&(this.enabledState.set(e,t),this.onInvalidate?.())}updateConfig(e,t){let n=this.plugins.get(e);return n?.setConfig?(n.setConfig(t),this.onInvalidate?.(),!0):!1}getAllPlugins(){return Array.from(this.plugins.values())}getPlugin(e){return this.plugins.get(e)}notifyDataUpdate(e,t){for(let n of this.plugins.values())if(n.onDataUpdate&&this.isRendererEnabled(n))try{n.onDataUpdate(e,t)}catch(e){console.error(`[RendererPlugin] ${n.name} onDataUpdate error:`,e)}}notifyResize(e,t){let n=this.getMergedRenderers(e).filter(e=>this.isRendererEnabled(e));for(let e of n)if(e.onResize)try{e.onResize(t)}catch(t){console.error(`[RendererPlugin] ${e.name} onResize error:`,t)}}},ha={PRIMARY:`hsl(210, 9%, 31%)`,SECONDARY:`hsl(210, 9%, 35%)`,TERTIARY:`hsl(210, 8%, 50%)`,WEAK:`hsl(210, 7%, 65%)`,WHITE:`rgba(255, 255, 255, 0.92)`},J={UP:`rgba(214, 10, 34, 1)`,UP_LIGHT:`rgba(214, 10, 34, 0.92)`,UP_TICK:`hsl(0, 60%, 50%)`,DOWN:`rgba(3, 123, 102, 1)`,DOWN_LIGHT:`rgba(3, 123, 102, 0.92)`,DOWN_TICK:`hsl(150, 30%, 60%)`,NEUTRAL:`rgba(0, 0, 0, 0.78)`,LAST_PRICE:`rgba(196, 74, 86, 0.95)`},ga={WHITE:`rgb(255, 255, 255)`,LIGHT_GRAY:`rgba(255, 255, 255, 0.92)`,PURE_WHITE:`#ffffff`,TRANSPARENT:`transparent`,ACTIVE:`#1890ff`,ACTIVE_HOVER:`#40a9ff`,HOVER:`#f0f0f0`},_a={DARK:`rgba(0, 0, 0, 0.12)`,MEDIUM:`rgba(0, 0, 0, 0.10)`,LIGHT:`rgba(0, 0, 0, 0.08)`,SEPARATOR:`rgba(0, 0, 0, 0.10)`,BUTTON:`#d0d0d0`},va={HORIZONTAL:`rgba(0, 0, 0, 0.06)`,VERTICAL:`rgba(0, 0, 0, 0.12)`},ya={MA5:`rgba(255, 193, 37, 1)`,MA10:`rgba(190, 131, 12, 1)`,MA20:`rgba(69, 112, 249, 1)`,MA30:`rgba(76, 175, 80, 1)`,MA60:`rgba(156, 39, 176, 1)`},ba={UPPER:`rgba(178, 34, 34, 1)`,MIDDLE:`rgba(69, 112, 249, 1)`,LOWER:`rgba(34, 139, 34, 1)`,BAND_FILL:`rgba(100, 149, 237, 0.1)`},Y={DIF:`rgba(69, 112, 249, 1)`,DEA:`rgba(255, 152, 0, 1)`,BAR_UP:`#ff5252`,BAR_UP_LIGHT:`#fccbcd`,BAR_DOWN:`#22ab94`,BAR_DOWN_LIGHT:`#ace5dc`},xa={UP:`#ff5252`,DOWN:`#22ab94`,NEUTRAL:`rgba(0, 0, 0, 0.78)`},Sa={RSI1:`rgba(69, 112, 249, 1)`,RSI2:`rgba(255, 152, 0, 1)`,RSI3:`rgba(156, 39, 176, 1)`},Ca={CCI:`rgba(69, 112, 249, 1)`,OVERBOUGHT:`rgba(214, 10, 34, 0.5)`,OVERSOLD:`rgba(3, 123, 102, 0.5)`},wa={K:`rgba(69, 112, 249, 1)`,D:`rgba(255, 152, 0, 1)`,J:`rgba(156, 39, 176, 1)`},Ta={MOM:`rgba(69, 112, 249, 1)`,ZERO:`rgba(0, 0, 0, 0.2)`},Ea={WMSR:`rgba(69, 112, 249, 1)`,OVERBOUGHT:`rgba(214, 10, 34, 0.5)`,OVERSOLD:`rgba(3, 123, 102, 0.5)`},Da={KST:`rgba(69, 112, 249, 1)`,SIGNAL:`rgba(255, 152, 0, 1)`},Oa={FAST:`rgba(255, 152, 0, 1)`,SLOW:`rgba(69, 112, 249, 1)`},ka={UPPER:`rgba(214, 10, 34, 1)`,MIDDLE:`rgba(69, 112, 249, 1)`,LOWER:`rgba(3, 123, 102, 1)`,BAND_FILL:`rgba(69, 112, 249, 0.08)`},Aa={LINE:`rgba(0, 0, 0, 0.28)`,LABEL_BG:`rgb(0, 0, 0)`,LABEL_TEXT:`rgba(255, 255, 255, 0.92)`};function X(e,t){return Math.round(e*t)/t}function Z(e,t){return(Math.floor(e*t)+.5)/t}function ja(e,t,n,r){if(t===n)return null;let i=Math.min(t,n),a=Math.max(t,n),o=Math.round(e*r),s=Math.round(i*r),c=Math.round(a*r);return{x:o/r,y:s/r,width:1/r,height:Math.max(1,c-s)/r}}function Ma(e,t,n,r){if(e===t)return null;let i=Math.min(e,t),a=Math.max(e,t),o=Math.round(i*r),s=Math.round(a*r),c=Math.round(n*r);return{x:o/r,y:c/r,width:Math.max(1,s-o)/r,height:1/r}}function Na(e,t,n,r,i){let a=e+n,o=n,s=Math.round(t*i),c=Math.round((t+r)*i),l=Math.max(1,c-s),u=e+(n-1)/2,d=u,f=o%2==1;return{bodyRect:{x:e/i,y:s/i,width:n/i,height:l/i},physBodyLeft:e,physBodyRight:a,physBodyWidth:o,physBodyCenter:d,physWickX:u,wickRect:{x:u/i,width:1/i},isPerfectlyAligned:f}}var Pa=1.2,Fa=24,Ia=6;function La(e){switch(e){case`arrow_up`:case`flag`:return!0;default:return!1}}function Ra(){return{name:`customMarkers`,version:`1.0.0`,description:`自定义标记渲染器`,debugName:`自定义标记`,paneId:Ji,priority:G.OVERLAY,draw(e){let{ctx:t,pane:n,data:r,range:i,scrollLeft:a,kWidth:o,kLineCenters:s,dpr:c,markerManager:l}=e;if(!l)return;let u=l.getCustomMarkers();if(!u||u.length===0)return;let d=r;if(d.length&&n.role===`price`){t.save(),t.translate(-a,0);for(let e of u){let r=Ba(d,e.timestamp);if(r===-1||r<i.start||r>=i.end)continue;let u=r-i.start;if(u<0||u>=s.length)continue;let f=s[u],p=d[r],m=e.style?.size,h=za(o,m),g=(e.offset?.y??0)<0?!0:(e.offset?.y??0)>0?!1:La(e.shape),_;_=g?n.yAxis.priceToY(p.high)-h/2-4+(e.offset?.y??0):n.yAxis.priceToY(p.low)+h/2+4+(e.offset?.y??0);let v=f+(e.offset?.x??0),y=_,b=v,x=y,S=Math.round(h*c/2)*2/c;Pi(t,e.shape,b,x,S,e.style||{}),e.label&&Li(t,e.label,b,x,S,e.style||{},g),l.setCustomMarkerPosition(e.id,b-a,x,S,e.shape)}t.restore()}}}}function za(e,t){let n=e*Pa;return Math.max(Ia,Math.min(n,t??Fa))}function Ba(e,t){let n=0,r=e.length-1;for(;n<=r;){let i=Math.floor((n+r)/2),a=e[i]?.timestamp;if(a===void 0)break;if(a===t)return i;a<t?n=i+1:r=i-1}return-1}function Va(e){let t=new Intl.DateTimeFormat(`zh-CN`,{timeZone:`Asia/Shanghai`,year:`numeric`,month:`2-digit`,day:`2-digit`}).formatToParts(new Date(e)).reduce((e,t)=>(t.type!==`literal`&&(e[t.type]=t.value),e),{});return`${t.year}-${t.month}-${t.day}`}function Ha(e){let t=new Date(e),n=t.getFullYear(),r=t.getMonth()+1;return r===1?{text:String(n),isYear:!0}:{text:`${r}月`,isYear:!1}}function Ua(e){let t=new Date(e);return`${t.getFullYear()}-${t.getMonth()}`}var Wa=Va,Ga=Va;function Ka(e){if(e.length===0)return[];let t=[0],n=Ua(e[0].timestamp);for(let r=1;r<e.length;r++){let i=e[r];if(!i)continue;let a=Ua(i.timestamp);a!==n&&(t.push(r),n=a)}return t}var qa=J.UP,Ja=J.DOWN,Ya=J.NEUTRAL;function Xa(e){return e>0?qa:e<0?Ja:Ya}function Za(e,t=2){let n=Math.abs(e);return n>=1e8?`${(e/1e8).toFixed(t)}亿`:n>=1e4?`${(e/1e4).toFixed(t)}万`:`${Math.round(e)}`}function Qa(e,t=2){return`${e>0?`+`:``}${e.toFixed(t)}`}function $a(e,t=2){return`${e.toFixed(t)}%`}function eo(e,t=2){return`${e>0?`+`:``}${e.toFixed(t)}%`}function to(e,t){let n=t?.close??e.open;return Xa(e.open-n)}function no(e){return Xa(e.close-e.open)}function ro(e){return typeof e.changePercent==`number`?Xa(e.changePercent):typeof e.changeAmount==`number`?Xa(e.changeAmount):Ya}var io={class:`kline-tooltip__title`},ao={key:0},oo={class:`kline-tooltip__grid`},so={class:`row`},co={class:`row`},lo={class:`row`},uo={class:`row`},fo={key:0,class:`row`},po={key:1,class:`row`},mo={key:2,class:`row`},ho={key:3,class:`row`},go={key:4,class:`row`},_o={key:5,class:`row`},vo=(0,f.defineComponent)({__name:`KLineTooltip`,props:{k:{},index:{},data:{},pos:{},useAnchor:{type:Boolean},anchorPlacement:{},setEl:{type:Function}},setup(e){let t=e,n=(0,f.computed)(()=>t.useAnchor===!0),r=(0,f.computed)(()=>t.anchorPlacement===`left-bottom`?`anchor-left-bottom`:`anchor-right-bottom`);function i(e){t.setEl?.(e)}let a=(0,f.computed)(()=>{let e=t.k;if(!e)return Ya;let n=t.index;return to(e,typeof n==`number`&&n>0?t.data[n-1]:void 0)}),o=(0,f.computed)(()=>{let e=t.k;return e?no(e):Ya}),s=(0,f.computed)(()=>{let e=t.k;return e?ro(e):Ya});return(t,c)=>e.k?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:0,ref:i,class:(0,f.normalizeClass)([`kline-tooltip`,[{"use-anchor":n.value},r.value]]),style:(0,f.normalizeStyle)(n.value?void 0:{left:`${e.pos.x}px`,top:`${e.pos.y}px`})},[(0,f.createElementVNode)(`div`,io,[e.k.stockCode?((0,f.openBlock)(),(0,f.createElementBlock)(`span`,ao,(0,f.toDisplayString)(e.k.stockCode),1)):(0,f.createCommentVNode)(``,!0),(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)((0,f.unref)(Wa)(e.k.timestamp)),1)]),(0,f.createElementVNode)(`div`,oo,[(0,f.createElementVNode)(`div`,so,[c[0]||=(0,f.createElementVNode)(`span`,null,`开`,-1),(0,f.createElementVNode)(`span`,{style:(0,f.normalizeStyle)({color:a.value})},(0,f.toDisplayString)(e.k.open.toFixed(2)),5)]),(0,f.createElementVNode)(`div`,co,[c[1]||=(0,f.createElementVNode)(`span`,null,`高`,-1),(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)(e.k.high.toFixed(2)),1)]),(0,f.createElementVNode)(`div`,lo,[c[2]||=(0,f.createElementVNode)(`span`,null,`低`,-1),(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)(e.k.low.toFixed(2)),1)]),(0,f.createElementVNode)(`div`,uo,[c[3]||=(0,f.createElementVNode)(`span`,null,`收`,-1),(0,f.createElementVNode)(`span`,{style:(0,f.normalizeStyle)({color:o.value})},(0,f.toDisplayString)(e.k.close.toFixed(2)),5)]),typeof e.k.volume==`number`?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,fo,[c[4]||=(0,f.createElementVNode)(`span`,null,`成交量`,-1),(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)((0,f.unref)(Za)(e.k.volume)),1)])):(0,f.createCommentVNode)(``,!0),typeof e.k.turnover==`number`?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,po,[c[5]||=(0,f.createElementVNode)(`span`,null,`成交额`,-1),(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)((0,f.unref)(Za)(e.k.turnover)),1)])):(0,f.createCommentVNode)(``,!0),typeof e.k.amplitude==`number`?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,mo,[c[6]||=(0,f.createElementVNode)(`span`,null,`振幅`,-1),(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)(e.k.amplitude)+`%`,1)])):(0,f.createCommentVNode)(``,!0),typeof e.k.changePercent==`number`?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,ho,[c[7]||=(0,f.createElementVNode)(`span`,null,`涨跌幅`,-1),(0,f.createElementVNode)(`span`,{style:(0,f.normalizeStyle)({color:s.value})},(0,f.toDisplayString)((0,f.unref)(eo)(e.k.changePercent)),5)])):(0,f.createCommentVNode)(``,!0),typeof e.k.changeAmount==`number`?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,go,[c[8]||=(0,f.createElementVNode)(`span`,null,`涨跌额`,-1),(0,f.createElementVNode)(`span`,{style:(0,f.normalizeStyle)({color:s.value})},(0,f.toDisplayString)((0,f.unref)(Qa)(e.k.changeAmount)),5)])):(0,f.createCommentVNode)(``,!0),typeof e.k.turnoverRate==`number`?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,_o,[c[9]||=(0,f.createElementVNode)(`span`,null,`换手率`,-1),(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)((0,f.unref)($a)(e.k.turnoverRate)),1)])):(0,f.createCommentVNode)(``,!0)])],6)):(0,f.createCommentVNode)(``,!0)}}),yo=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},bo=yo(vo,[[`__scopeId`,`data-v-d0fe85e6`]]),xo={RISE_WITH_VOLUME:`量价齐升`,RISE_WITHOUT_VOLUME:`量缩价升`,FALL_WITH_VOLUME:`量价齐缩`,FALL_WITHOUT_VOLUME:`量升价缩`},So=class{markers=new Map;hoveredMarkerId=null;lastHoveredId=null;customMarkers=new Map;customMarkerPositions=new Map;clear(){this.markers.clear()}register(e){this.markers.set(e.id,e)}getState(e){return this.hoveredMarkerId===e?`hovered`:`normal`}hitTest(e,t,n=3){for(let r of this.markers.values())if(e>=r.x-n&&e<=r.x+r.width+n&&t>=r.y-n&&t<=r.y+r.height+n)return r;return null}setHover(e){this.hoveredMarkerId=e,this.lastHoveredId=e}validateHoverState(){this.hoveredMarkerId!==null&&!this.markers.has(this.hoveredMarkerId)&&(this.hoveredMarkerId=null)}getHoveredMarker(){return this.hoveredMarkerId===null?null:this.markers.get(this.hoveredMarkerId)||null}getLastHoverId(){return this.lastHoveredId}getAllMarkers(){return Array.from(this.markers.values())}registerCustomMarker(e){this.customMarkers.set(e.id,e)}setCustomMarkers(e){this.clearCustomMarkers();for(let t of e)this.customMarkers.set(t.id,t)}clearCustomMarkers(){this.customMarkers.clear(),this.customMarkerPositions.clear()}getCustomMarkers(){return Array.from(this.customMarkers.values())}setCustomMarkerPosition(e,t,n,r,i){this.customMarkerPositions.set(e,{x:t,y:n,size:r,shape:i})}hitTestCustomMarker(e,t){for(let n of this.customMarkers.values()){let r=this.customMarkerPositions.get(n.id);if(r&&Gi(e,t,r.shape,r.x,r.y,r.size))return n}return null}},Co={class:`marker-tooltip__title`},wo={key:0,class:`marker-tooltip__content`},To=yo((0,f.defineComponent)({__name:`MarkerTooltip`,props:{marker:{},pos:{},useAnchor:{type:Boolean},anchorPlacement:{},setEl:{type:Function}},setup(e){let t=e,n=(0,f.computed)(()=>t.useAnchor===!0),r=(0,f.computed)(()=>t.anchorPlacement===`left-bottom`?`anchor-left-bottom`:`anchor-right-bottom`);function i(e){t.setEl?.(e)}let a=(0,f.computed)(()=>t.marker&&`date`in t.marker),o=(0,f.computed)(()=>{if(!t.marker)return``;if(a.value){let e=t.marker;return e.label?.text||e.shape}let e=t.marker;return xo[e.markerType]||e.markerType}),s=(0,f.computed)(()=>{if(!t.marker)return{};if(a.value){let e=t.marker;return{日期:e.date,...e.metadata}}return t.marker.metadata}),c=(0,f.computed)(()=>Object.keys(s.value).length>0);function l(e){return typeof e==`number`?e.toFixed(2):String(e)}return(t,a)=>e.marker?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:0,ref:i,class:(0,f.normalizeClass)([`marker-tooltip`,[{"use-anchor":n.value},r.value]]),style:(0,f.normalizeStyle)(n.value?void 0:{left:`${e.pos.x+12}px`,top:`${e.pos.y+12}px`})},[(0,f.createElementVNode)(`div`,Co,(0,f.toDisplayString)(o.value),1),c.value?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,wo,[((0,f.openBlock)(!0),(0,f.createElementBlock)(f.Fragment,null,(0,f.renderList)(s.value,(e,t)=>((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:t,class:`row`},[(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)(t),1),(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)(l(e)),1)]))),128))])):(0,f.createCommentVNode)(``,!0)],6)):(0,f.createCommentVNode)(``,!0)}}),[[`__scopeId`,`data-v-5574cc25`]]),Eo=Symbol(`fullscreen-teleport-target`);function Do(){let e=(0,f.inject)(Eo,null);return(0,f.computed)(()=>e?.value??`body`)}var Oo={class:`params-header`},ko={class:`header-left`},Ao={class:`params-title`},jo={class:`header-right`},Mo={key:0,class:`indicator-description`},No={class:`params-body`},Po={class:`param-header`},Fo={class:`param-label`},Io={class:`param-label-text`},Lo={key:0,class:`param-range`},Ro={class:`input-wrapper`},zo=[`disabled`,`onClick`],Bo=[`value`,`min`,`max`,`step`,`onInput`],Vo=[`disabled`,`onClick`],Ho={key:0,class:`param-description`},Uo={class:`params-footer`},Wo={class:`footer-right`},Go=yo((0,f.defineComponent)({__name:`IndicatorParams`,props:{visible:{type:Boolean},indicatorId:{},indicatorName:{},indicatorDescription:{},params:{},values:{}},emits:[`close`,`confirm`],setup(e,{emit:t}){let n=e,r=t,i=(0,f.ref)({...n.values}),a=(0,f.ref)(!0),o=Do();(0,f.watch)(()=>n.values,e=>{i.value={...e}},{deep:!0,immediate:!0}),(0,f.watch)(()=>n.visible,e=>{e&&(i.value={...n.values})});function s(e,t){let n=t.target,r=parseFloat(n.value);isNaN(r)||(i.value[e]=r)}function c(e,t){let n=e.step||1,r=(i.value[e.key]||0)+t*n;e.min!==void 0&&(r=Math.max(e.min,r)),e.max!==void 0&&(r=Math.min(e.max,r)),i.value[e.key]=parseFloat(r.toFixed(10))}function l(){let e={};n.params.forEach(t=>{e[t.key]=t.default??n.values[t.key]??0}),i.value=e}function u(){r(`confirm`,{...i.value})}return(t,n)=>((0,f.openBlock)(),(0,f.createBlock)(f.Teleport,{to:(0,f.unref)(o)},[(0,f.createVNode)(f.Transition,{name:`overlay`},{default:(0,f.withCtx)(()=>[e.visible?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:0,class:`params-overlay`,onClick:n[4]||=e=>t.$emit(`close`)},[(0,f.createVNode)(f.Transition,{name:`modal`},{default:(0,f.withCtx)(()=>[(0,f.createElementVNode)(`div`,{class:`indicator-params`,onClick:n[3]||=(0,f.withModifiers)(()=>{},[`stop`])},[(0,f.createElementVNode)(`div`,Oo,[(0,f.createElementVNode)(`div`,ko,[(0,f.createElementVNode)(`span`,Ao,(0,f.toDisplayString)(e.indicatorName),1),n[5]||=(0,f.createElementVNode)(`span`,{class:`params-subtitle`},`参数设置`,-1)]),(0,f.createElementVNode)(`div`,jo,[(0,f.createElementVNode)(`button`,{class:(0,f.normalizeClass)([`toggle-desc-btn`,{active:a.value}]),onClick:n[0]||=e=>a.value=!a.value,title:`显示/隐藏说明`},[...n[6]||=[(0,f.createElementVNode)(`svg`,{viewBox:`0 0 1024 1024`},[(0,f.createElementVNode)(`path`,{d:`M512 97.52381c228.912762 0 414.47619 185.563429 414.47619 414.47619s-185.563429 414.47619-414.47619 414.47619S97.52381 740.912762 97.52381 512 283.087238 97.52381 512 97.52381z m0 73.142857C323.486476 170.666667 170.666667 323.486476 170.666667 512s152.81981 341.333333 341.333333 341.333333 341.333333-152.81981 341.333333-341.333333S700.513524 170.666667 512 170.666667z m36.571429 268.190476v292.571428h-73.142858V438.857143h73.142858z m0-121.904762v73.142857h-73.142858v-73.142857h73.142858z`,fill:`currentColor`})],-1)]],2),(0,f.createElementVNode)(`button`,{class:`params-close`,onClick:n[1]||=e=>t.$emit(`close`)},[...n[7]||=[(0,f.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`},[(0,f.createElementVNode)(`path`,{d:`M18 6L6 18M6 6l12 12`})],-1)]])])]),(0,f.createVNode)(f.Transition,{name:`slide`},{default:(0,f.withCtx)(()=>[a.value&&e.indicatorDescription?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,Mo,[(0,f.createElementVNode)(`p`,null,(0,f.toDisplayString)(e.indicatorDescription),1)])):(0,f.createCommentVNode)(``,!0)]),_:1}),(0,f.createElementVNode)(`div`,No,[((0,f.openBlock)(!0),(0,f.createElementBlock)(f.Fragment,null,(0,f.renderList)(e.params,e=>((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:e.key,class:(0,f.normalizeClass)([`param-item`,{"has-desc":a.value&&e.description}])},[(0,f.createElementVNode)(`div`,Po,[(0,f.createElementVNode)(`label`,Fo,[(0,f.createElementVNode)(`span`,Io,(0,f.toDisplayString)(e.label),1),e.min!==void 0||e.max!==void 0?((0,f.openBlock)(),(0,f.createElementBlock)(`span`,Lo,(0,f.toDisplayString)(e.min??`-∞`)+` ~ `+(0,f.toDisplayString)(e.max??`+∞`),1)):(0,f.createCommentVNode)(``,!0)]),(0,f.createElementVNode)(`div`,Ro,[(0,f.createElementVNode)(`button`,{class:`stepper-btn`,disabled:e.min!==void 0&&(i.value[e.key]??0)<=e.min,onClick:t=>c(e,-1)},` − `,8,zo),e.type===`number`?((0,f.openBlock)(),(0,f.createElementBlock)(`input`,{key:0,type:`number`,class:`param-input`,value:i.value[e.key],min:e.min,max:e.max,step:e.step||1,onInput:t=>s(e.key,t)},null,40,Bo)):(0,f.createCommentVNode)(``,!0),(0,f.createElementVNode)(`button`,{class:`stepper-btn`,disabled:e.max!==void 0&&(i.value[e.key]??0)>=e.max,onClick:t=>c(e,1)},` + `,8,Vo)])]),(0,f.createVNode)(f.Transition,{name:`slide`},{default:(0,f.withCtx)(()=>[a.value&&e.description?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,Ho,(0,f.toDisplayString)(e.description),1)):(0,f.createCommentVNode)(``,!0)]),_:2},1024)],2))),128))]),(0,f.createElementVNode)(`div`,Uo,[(0,f.createElementVNode)(`button`,{class:`params-btn reset`,onClick:l},[...n[8]||=[(0,f.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`},[(0,f.createElementVNode)(`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}),(0,f.createElementVNode)(`path`,{d:`M3 3v5h5`})],-1),(0,f.createTextVNode)(` 重置 `,-1)]]),(0,f.createElementVNode)(`div`,Wo,[(0,f.createElementVNode)(`button`,{class:`params-btn cancel`,onClick:n[2]||=e=>t.$emit(`close`)},`取消`),(0,f.createElementVNode)(`button`,{class:`params-btn confirm`,onClick:u},[...n[9]||=[(0,f.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.5`},[(0,f.createElementVNode)(`path`,{d:`M20 6L9 17l-5-5`})],-1),(0,f.createTextVNode)(` 确定 `,-1)]])])])])]),_:1})])):(0,f.createCommentVNode)(``,!0)]),_:1})],8,[`to`]))}}),[[`__scopeId`,`data-v-bb1d1eb3`]]),Ko={class:`indicator-selector`},qo={class:`indicator-scroll-container`},Jo={class:`indicator-list`},Yo={key:0,class:`indicator-divider`,"aria-hidden":`true`},Xo=[`draggable`,`onDragstart`,`onDragover`,`onDrop`],Zo=[`onMouseenter`],Qo={class:`btn-content`},$o={key:0,class:`param-hint`},es={key:0,class:`hover-overlay`},ts=[`onClick`],ns={key:1,class:`divider`},rs=[`onClick`],is={class:`indicator-item`},as={class:`menu-section`},os={class:`menu-items`},ss=[`disabled`,`onClick`],cs={class:`param-hint`},ls={key:0,class:`active-tag`},us={class:`menu-section`},ds={class:`menu-items`},fs=[`disabled`,`onClick`],ps={class:`param-hint`},ms={key:0,class:`active-tag`},hs=yo((0,f.defineComponent)({__name:`IndicatorSelector`,props:{activeIndicators:{},indicatorParams:{}},emits:[`toggle`,`updateParams`,`reorderSubIndicators`],setup(e,{emit:t}){let n=[{id:`MA`,label:`MA`,name:`均线`,pane:`main`},{id:`VOLUME`,label:`VOL`,name:`成交量`,pane:`sub`,description:`成交量反映市场活跃度,柱状图显示每根K线的交易量。上涨时柱子为红色,下跌时为绿色。`},{id:`BOLL`,label:`BOLL`,name:`布林带`,pane:`main`,description:`布林带由三条轨道线组成,用于判断价格的波动范围和趋势强度。价格触及上轨可能超买,触及下轨可能超卖。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:20,description:`计算移动平均线的周期数,周期越长轨道越平滑`},{key:`multiplier`,label:`倍数`,type:`number`,min:.1,max:5,step:.1,default:2,description:`标准差倍数,决定轨道宽度,通常为 2`}]},{id:`EXPMA`,label:`EXPMA`,name:`指数平滑移动平均线`,pane:`main`,description:`EXPMA 对近期价格给予更高权重,比普通 MA 更敏感。快线上穿慢线为金叉看涨,下穿为死叉看跌。`,params:[{key:`fastPeriod`,label:`快线`,type:`number`,min:2,max:100,step:1,default:12,description:`快线周期,对价格变化更敏感`},{key:`slowPeriod`,label:`慢线`,type:`number`,min:2,max:200,step:1,default:50,description:`慢线周期,用于判断趋势方向`}]},{id:`ENE`,label:`ENE`,name:`轨道线`,pane:`main`,description:`ENE 轨道线由三条轨道组成,价格突破上轨可能超买,突破下轨可能超卖,适合判断震荡行情的买卖点。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:10,description:`计算中轨的周期数`},{key:`deviation`,label:`偏离率`,type:`number`,min:1,max:30,step:.5,default:11,description:`轨道偏离率百分比,决定轨道宽度`}]},{id:`MACD`,label:`MACD`,name:`指数平滑异同移动平均线`,pane:`sub`,description:`MACD 通过快慢均线的交叉判断趋势方向和动量。DIF 上穿 DEA 为金叉看涨,下穿为死叉看跌。`,params:[{key:`fastPeriod`,label:`快线`,type:`number`,min:2,max:50,step:1,default:12,description:`快线 EMA 周期,对价格变化更敏感`},{key:`slowPeriod`,label:`慢线`,type:`number`,min:2,max:100,step:1,default:26,description:`慢线 EMA 周期,用于计算 DIF`},{key:`signalPeriod`,label:`信号`,type:`number`,min:2,max:50,step:1,default:9,description:`DEA 的 EMA 周期,用于生成买卖信号`}]},{id:`RSI`,label:`RSI`,name:`相对强弱指标`,pane:`sub`,description:`RSI 衡量价格变动的速度和幅度,判断超买超卖状态。RSI > 70 超买,RSI < 30 超卖。`,params:[{key:`period1`,label:`周期 1`,type:`number`,min:2,max:100,step:1,default:6,description:`第一条 RSI 周期,通常为 6(快线)`},{key:`period2`,label:`周期 2`,type:`number`,min:2,max:100,step:1,default:12,description:`第二条 RSI 周期,通常为 12(中线)`},{key:`period3`,label:`周期 3`,type:`number`,min:2,max:100,step:1,default:24,description:`第三条 RSI 周期,通常为 24(慢线)`}]},{id:`CCI`,label:`CCI`,name:`顺势指标`,pane:`sub`,description:`CCI 衡量价格与统计平均值的偏离程度。CCI > 100 超买,CCI < -100 超卖,适合捕捉趋势反转。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:14,description:`计算周期,周期越短信号越灵敏`}]},{id:`STOCH`,label:`STOCH`,name:`随机指标`,pane:`sub`,description:`KDJ 随机指标通过比较收盘价与价格区间判断超买超卖。K > 80 超买,K < 20 超卖,K 上穿 D 金叉。`,params:[{key:`n`,label:`K 周期`,type:`number`,min:2,max:100,step:1,default:9,description:`计算 K 值的周期,统计 N 日内价格区间`},{key:`m`,label:`D 周期`,type:`number`,min:1,max:50,step:1,default:3,description:`D 值是 K 的 M 日移动平均,使信号更平滑`}]},{id:`MOM`,label:`MOM`,name:`动量指标`,pane:`sub`,description:`动量指标衡量价格变化的速度,MOM > 0 表示上涨动能,MOM < 0 表示下跌动能。适合判断趋势强度。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:10,description:`与多少日前价格比较,周期越短越灵敏`}]},{id:`WMSR`,label:`WMSR`,name:`威廉指标`,pane:`sub`,description:`威廉指标衡量超买超卖程度,范围为 -100 到 0。WMSR > -20 超买,WMSR < -80 超卖。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:14,description:`回溯周期,统计周期内最高最低价`}]},{id:`KST`,label:`KST`,name:`确然指标`,pane:`sub`,description:`KST 综合多个 ROC 判断长期趋势,KST 上穿信号线看涨,下穿看跌。适合捕捉主要趋势转换。`,params:[{key:`roc1`,label:`ROC1`,type:`number`,min:2,max:100,step:1,default:10,description:`短期变化率周期`},{key:`roc2`,label:`ROC2`,type:`number`,min:2,max:100,step:1,default:15,description:`中短期变化率周期`},{key:`roc3`,label:`ROC3`,type:`number`,min:2,max:100,step:1,default:20,description:`中长期变化率周期`},{key:`roc4`,label:`ROC4`,type:`number`,min:2,max:100,step:1,default:30,description:`长期变化率周期`},{key:`signalPeriod`,label:`信号`,type:`number`,min:2,max:50,step:1,default:9,description:`信号线的 SMA 周期`}]},{id:`FASTK`,label:`FASTK`,name:`快速随机指标`,pane:`sub`,description:`FASTK 是未经过平滑处理的随机指标,比普通 KDJ 更敏感,能更快捕捉价格转折点,但假信号也更多。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:9,description:`计算周期,周期越短越敏感`}]}],r=n.filter(e=>e.pane===`main`),i=n.filter(e=>e.pane===`sub`),a=e,o=t,s=(0,f.ref)(null),c=(0,f.ref)(null),l=(0,f.ref)(!1),u=(0,f.ref)(null),d=(0,f.ref)(null),p=(0,f.ref)(!1),m=(0,f.ref)({left:`0`,bottom:`0`}),h=(0,f.ref)(!1),g=(0,f.ref)(null),_=(0,f.ref)(null),v=Do(),y=(0,f.computed)(()=>a.activeIndicators?.length?a.activeIndicators.map(e=>n.find(t=>t.id===e)).filter(e=>e!==void 0).sort((e,t)=>e.pane===t.pane?0:e.pane===`main`?-1:1):[]),b=(0,f.computed)(()=>y.value.some(e=>e.pane===`main`)?y.value.find(e=>e.pane===`sub`)?.id??null:null),x=(0,f.computed)(()=>u.value&&n.find(e=>e.id===u.value)||null);function S(e){return a.activeIndicators?.includes(e)??!1}function C(e){if(S(e))return;let t=n.find(t=>t.id===e);t&&(t.pane===`main`&&n.filter(t=>t.pane===`main`&&t.id!==e&&S(t.id)).forEach(e=>o(`toggle`,e.id,!1)),o(`toggle`,e,!0),p.value=!1)}function w(e){o(`toggle`,e,!1)}function T(e){u.value=e,l.value=!0}function E(e){let t=n.find(t=>t.id===e);if(!t?.params)return{};let r={};for(let e of t.params)r[e.key]=e.default??e.min??1;let i=a.indicatorParams?.[e]||{},o={...r};for(let[e,t]of Object.entries(i))typeof t==`number`&&(o[e]=t);return o}function D(e){let t=E(e.id);return e.params?e.params.map(e=>t[e.key]??``).join(`,`):``}function O(e){u.value&&o(`updateParams`,u.value,e),l.value=!1}function k(e){return n.find(t=>t.id===e)?.pane===`sub`}function A(e,t){if(!k(t)){e.preventDefault();return}_.value=t,g.value=null,e.dataTransfer?.setData(`text/plain`,t),e.dataTransfer&&(e.dataTransfer.effectAllowed=`move`)}function j(e,t){!_.value||!k(t)||_.value===t||(g.value=t,e.dataTransfer&&(e.dataTransfer.dropEffect=`move`))}function M(e,t){let n=_.value||e.dataTransfer?.getData(`text/plain`)||``;if(!n||n===t){N();return}if(!k(n)||!k(t)){N();return}let r=y.value.findIndex(e=>e.id===n),i=y.value.findIndex(e=>e.id===t);if(r<0||i<0){N();return}let a=[...y.value.map(e=>e.id)],[s]=a.splice(r,1);if(!s){N();return}a.splice(i,0,s),o(`reorderSubIndicators`,a.filter(e=>k(e))),N()}function N(){g.value=null,_.value=null}function ee(){if(!p.value&&s.value&&!h.value){let e=s.value.getBoundingClientRect(),t=window.innerWidth,n=e.left+e.width/2;n+160>t-8&&(n=t-160-8),n-160<8&&(n=168),m.value={left:`${n}px`,bottom:`${window.innerHeight-e.top+8}px`}}p.value=!p.value}function P(e){let t=c.value&&!c.value.contains(e.target),n=s.value&&!s.value.contains(e.target);t&&n&&(p.value=!1)}function F(){p.value&&=!1}return(0,f.onMounted)(()=>{h.value=typeof CSS<`u`&&CSS.supports(`anchor-name: --kmap-anchor`)&&CSS.supports(`position-anchor: --kmap-anchor`),document.addEventListener(`click`,P),window.addEventListener(`resize`,F)}),(0,f.onUnmounted)(()=>{document.removeEventListener(`click`,P),window.removeEventListener(`resize`,F)}),(e,t)=>((0,f.openBlock)(),(0,f.createElementBlock)(`div`,Ko,[(0,f.createElementVNode)(`div`,qo,[(0,f.createElementVNode)(`div`,Jo,[((0,f.openBlock)(!0),(0,f.createElementBlock)(f.Fragment,null,(0,f.renderList)(y.value,e=>((0,f.openBlock)(),(0,f.createElementBlock)(f.Fragment,{key:e.id},[e.id===b.value?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,Yo)):(0,f.createCommentVNode)(``,!0),(0,f.createElementVNode)(`div`,{class:(0,f.normalizeClass)([`indicator-item`,{draggable:k(e.id),"drag-over":g.value===e.id,"is-dragging":_.value===e.id}]),draggable:k(e.id),onDragstart:t=>A(t,e.id),onDragover:(0,f.withModifiers)(t=>j(t,e.id),[`prevent`]),onDrop:(0,f.withModifiers)(t=>M(t,e.id),[`prevent`]),onDragend:N},[(0,f.createElementVNode)(`div`,{class:`indicator-btn-wrapper`,onMouseenter:t=>d.value=e.id,onMouseleave:t[0]||=e=>d.value=null},[(0,f.createElementVNode)(`button`,{class:(0,f.normalizeClass)([`indicator-btn`,{active:!0,hovering:d.value===e.id}])},[(0,f.createElementVNode)(`span`,Qo,[(0,f.createTextVNode)((0,f.toDisplayString)(e.label)+` `,1),e.params?((0,f.openBlock)(),(0,f.createElementBlock)(`span`,$o,` (`+(0,f.toDisplayString)(D(e))+`) `,1)):(0,f.createCommentVNode)(``,!0)]),(0,f.createVNode)(f.Transition,{name:`fade`},{default:(0,f.withCtx)(()=>[d.value===e.id?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,es,[e.params?((0,f.openBlock)(),(0,f.createElementBlock)(`button`,{key:0,class:`action-btn settings-btn`,onClick:(0,f.withModifiers)(t=>T(e.id),[`stop`]),title:`编辑参数`},[...t[2]||=[(0,f.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`currentColor`},[(0,f.createElementVNode)(`path`,{d:`M19.14 12.94c.04-.31.06-.63.06-.94 0-.31-.02-.63-.06-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.04.31-.06.63-.06.94s.02.63.06.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z`})],-1)]],8,ts)):(0,f.createCommentVNode)(``,!0),e.params?((0,f.openBlock)(),(0,f.createElementBlock)(`span`,ns)):(0,f.createCommentVNode)(``,!0),(0,f.createElementVNode)(`button`,{class:`action-btn remove-btn`,onClick:(0,f.withModifiers)(t=>w(e.id),[`stop`]),title:`移除指标`},[...t[3]||=[(0,f.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`currentColor`},[(0,f.createElementVNode)(`path`,{d:`M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z`})],-1)]],8,rs)])):(0,f.createCommentVNode)(``,!0)]),_:2},1024)],2)],40,Zo)],42,Xo)],64))),128)),(0,f.createElementVNode)(`div`,is,[(0,f.createElementVNode)(`button`,{ref_key:`addBtnRef`,ref:s,class:`add-btn`,onClick:ee,title:`添加指标`},[...t[4]||=[(0,f.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`currentColor`},[(0,f.createElementVNode)(`path`,{d:`M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z`})],-1)]],512)])])]),((0,f.openBlock)(),(0,f.createBlock)(f.Teleport,{to:(0,f.unref)(v)},[(0,f.createVNode)(f.Transition,{name:`slide`},{default:(0,f.withCtx)(()=>[p.value?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:0,class:(0,f.normalizeClass)([`add-menu`,{"use-anchor":h.value}]),ref_key:`addMenuRef`,ref:c,style:(0,f.normalizeStyle)(h.value?void 0:m.value)},[(0,f.createElementVNode)(`div`,as,[t[6]||=(0,f.createElementVNode)(`div`,{class:`menu-title`},`主图指标`,-1),(0,f.createElementVNode)(`div`,os,[((0,f.openBlock)(!0),(0,f.createElementBlock)(f.Fragment,null,(0,f.renderList)((0,f.unref)(r),e=>((0,f.openBlock)(),(0,f.createElementBlock)(`button`,{key:e.id,class:(0,f.normalizeClass)([`menu-item`,{disabled:S(e.id)}]),disabled:S(e.id),onClick:t=>C(e.id)},[(0,f.createTextVNode)((0,f.toDisplayString)(e.label)+` `,1),(0,f.createElementVNode)(`span`,cs,` (`+(0,f.toDisplayString)(e.name)+`) `,1),S(e.id)?((0,f.openBlock)(),(0,f.createElementBlock)(`span`,ls,[...t[5]||=[(0,f.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`currentColor`},[(0,f.createElementVNode)(`path`,{d:`M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z`})],-1)]])):(0,f.createCommentVNode)(``,!0)],10,ss))),128))])]),(0,f.createElementVNode)(`div`,us,[t[8]||=(0,f.createElementVNode)(`div`,{class:`menu-title`},`副图指标`,-1),(0,f.createElementVNode)(`div`,ds,[((0,f.openBlock)(!0),(0,f.createElementBlock)(f.Fragment,null,(0,f.renderList)((0,f.unref)(i),e=>((0,f.openBlock)(),(0,f.createElementBlock)(`button`,{key:e.id,class:(0,f.normalizeClass)([`menu-item`,{disabled:S(e.id)}]),disabled:S(e.id),onClick:t=>C(e.id)},[(0,f.createTextVNode)((0,f.toDisplayString)(e.label)+` `,1),(0,f.createElementVNode)(`span`,ps,` (`+(0,f.toDisplayString)(e.name)+`) `,1),S(e.id)?((0,f.openBlock)(),(0,f.createElementBlock)(`span`,ms,[...t[7]||=[(0,f.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`currentColor`},[(0,f.createElementVNode)(`path`,{d:`M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z`})],-1)]])):(0,f.createCommentVNode)(``,!0)],10,fs))),128))])])],6)):(0,f.createCommentVNode)(``,!0)]),_:1})],8,[`to`])),x.value?((0,f.openBlock)(),(0,f.createBlock)(Go,{key:0,visible:l.value,"indicator-id":x.value.id,"indicator-name":x.value.name,"indicator-description":x.value.description,params:x.value.params||[],values:E(x.value.id),onClose:t[1]||=e=>l.value=!1,onConfirm:O},null,8,[`visible`,`indicator-id`,`indicator-name`,`indicator-description`,`params`,`values`])):(0,f.createCommentVNode)(``,!0)]))}}),[[`__scopeId`,`data-v-f3fbebbd`]]),gs={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function _s(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,gs,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 7h16m-10 4v6m4-6v6M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2l1-12M9 7V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v3`},null,-1)]])}var vs=(0,f.markRaw)({name:`tabler-trash`,render:_s}),ys={class:`toolbar-item color-item`,title:`颜色`},bs=[`value`],xs=[`value`],Ss=[`value`],Cs=yo((0,f.defineComponent)({__name:`DrawingStyleToolbar`,props:{drawing:{}},emits:[`updateStyle`,`delete`],setup(e,{emit:t}){let n=t;function r(e){e.key===`Delete`&&(e.preventDefault(),n(`delete`))}(0,f.onMounted)(()=>document.addEventListener(`keydown`,r)),(0,f.onUnmounted)(()=>document.removeEventListener(`keydown`,r));function i(e){n(`updateStyle`,{stroke:e})}function a(e){n(`updateStyle`,{strokeWidth:e})}function o(e){n(`updateStyle`,{strokeStyle:e})}return(t,n)=>((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{class:`drawing-style-toolbar`,onPointerdown:n[4]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointermove:n[5]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointerup:n[6]||=(0,f.withModifiers)(()=>{},[`stop`])},[(0,f.createElementVNode)(`div`,ys,[(0,f.createElementVNode)(`span`,{class:`color-swatch`,style:(0,f.normalizeStyle)({background:e.drawing.style.stroke??`#2962ff`})},null,4),(0,f.createElementVNode)(`input`,{type:`color`,class:`color-input`,value:e.drawing.style.stroke??`#2962ff`,onInput:n[0]||=e=>i(e.target.value)},null,40,bs)]),(0,f.createElementVNode)(`select`,{class:`toolbar-select`,value:e.drawing.style.strokeWidth??1,onChange:n[1]||=e=>a(Number(e.target.value)),title:`线宽`},[...n[7]||=[(0,f.createElementVNode)(`option`,{value:1},`1px`,-1),(0,f.createElementVNode)(`option`,{value:2},`2px`,-1),(0,f.createElementVNode)(`option`,{value:3},`3px`,-1),(0,f.createElementVNode)(`option`,{value:4},`4px`,-1)]],40,xs),(0,f.createElementVNode)(`select`,{class:`toolbar-select`,value:e.drawing.style.strokeStyle??`solid`,onChange:n[2]||=e=>o(e.target.value),title:`线型`},[...n[8]||=[(0,f.createElementVNode)(`option`,{value:`solid`},`实线`,-1),(0,f.createElementVNode)(`option`,{value:`dashed`},`虚线`,-1),(0,f.createElementVNode)(`option`,{value:`dotted`},`点线`,-1)]],40,Ss),(0,f.createElementVNode)(`button`,{type:`button`,class:`toolbar-btn delete-btn`,title:`删除`,onClick:n[3]||=e=>t.$emit(`delete`)},[(0,f.createVNode)((0,f.unref)(vs),{class:`delete-icon`,"aria-hidden":`true`})])],32))}}),[[`__scopeId`,`data-v-92699cb2`]]),ws=class{chart;isDragging=!1;dragMode=`none`;dragStartX=0;scrollStartX=0;applyPanScroll(e,t){let n=Math.max(0,e.scrollWidth-e.clientWidth),r=Math.min(Math.max(0,t),n),i=this.chart.getCurrentDpr();e.scrollLeft=Math.round(r*i)/i}dragStartY=0;activePaneIdOnDrag=null;activeSeparatorUpperPaneId=null;hoveredSeparatorUpperPaneId=null;hoveredRightAxisPaneId=null;isTouchSession=!1;activePointers=new Map;lastPinchDistance=0;pinchCenter={x:0,y:0};isPinching=!1;onPinchZoomCallback;crosshairPos=null;crosshairIndex=null;crosshairPrice=null;hoveredIndex=null;activePaneId=null;tooltipPos={x:0,y:0};tooltipSize={width:220,height:180};tooltipAnchorPlacement=`right-bottom`;useTooltipAnchorPositioning=!1;onInteractionChangeCallback;settings={};hoveredMarkerId=null;clickedMarkerId=null;hoveredMarkerData=null;clickedMarkerData=null;onMarkerHoverCallback;onMarkerClickCallback;hoveredCustomMarker=null;onCustomMarkerHoverCallback;onCustomMarkerClickCallback;kLinePositions=null;visibleRange=null;lastHoverRenderKey=``;kWidthPx=null;constructor(e){this.chart=e}setOnPinchZoom(e){this.onPinchZoomCallback=e}updateSettings(e){let t=this.settings.disableMainPaneVerticalScroll;this.settings={...e},!t&&this.settings.disableMainPaneVerticalScroll&&this.chart.resetPriceOffset(`main`)}getInteractionSnapshot(){return{crosshairPos:this.crosshairPos?{...this.crosshairPos}:null,crosshairIndex:this.crosshairIndex,crosshairPrice:this.crosshairPrice,hoveredIndex:this.hoveredIndex,activePaneId:this.activePaneId,tooltipPos:{...this.tooltipPos},tooltipAnchorPlacement:this.tooltipAnchorPlacement,hoveredMarkerData:this.hoveredMarkerData,hoveredCustomMarker:this.hoveredCustomMarker,isDragging:this.isDragging,isResizingPaneBoundary:this.dragMode===`resize-separator`,isHoveringPaneBoundary:this.hoveredSeparatorUpperPaneId!==null,hoveredPaneBoundaryId:this.hoveredSeparatorUpperPaneId,isHoveringRightAxis:this.hoveredRightAxisPaneId!==null}}setOnInteractionChange(e){this.onInteractionChangeCallback=e}notifyInteractionChange(){this.onInteractionChangeCallback?.(this.getInteractionSnapshot())}getHoverRenderKey(){let e=this.crosshairPos?Math.round(this.crosshairPos.x*this.chart.getCurrentDpr()):`n`,t=this.crosshairPos?Math.round(this.crosshairPos.y*this.chart.getCurrentDpr()):`n`;return[this.crosshairIndex??`n`,this.hoveredIndex??`n`,this.activePaneId??`n`,this.hoveredRightAxisPaneId??`n`,this.hoveredSeparatorUpperPaneId??`n`,this.hoveredMarkerId??`n`,this.hoveredCustomMarker?.id??`n`,e,t].join(`|`)}onPointerDown(e){if(this.isTouchSession=e.pointerType===`touch`,this.activePointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this.activePointers.size===2&&this.isTouchSession){this.isPinching=!0,this.isDragging=!1,this.dragMode=`none`;let e=Array.from(this.activePointers.values()),t=e[0],n=e[1];this.lastPinchDistance=Math.hypot(n.x-t.x,n.y-t.y),this.pinchCenter={x:(t.x+n.x)/2,y:(t.y+n.y)/2};return}if(e.isPrimary===!1||this.isPinching||this.activePointers.size>1)return;let t=this.getPlotPointerLocation(e.clientX,e.clientY);if(!t)return;let{mouseX:n,mouseY:r}=t,i=this.chart.getCachedScrollLeft(),a=this.chart.getMarkerManager(),o=i+n,s=a.hitTest(o,r,3);if(s){this.clickedMarkerId=s.id,this.clickedMarkerData=s,this.onMarkerClickCallback&&this.onMarkerClickCallback(s);return}let c=this.hitTestPaneSeparator(r);if(c){this.isDragging=!0,this.dragMode=`resize-separator`,this.dragStartY=e.clientY,this.activeSeparatorUpperPaneId=c,this.hoveredSeparatorUpperPaneId=c,this.clearHover(),this.chart.scheduleDraw();return}let l=this.getPaneByY(r);this.isDragging=!0,this.dragMode=`pan`,this.updatePlotHoverFromPoint(e.clientX,e.clientY),this.dragStartX=e.clientX,this.dragStartY=e.clientY,this.scrollStartX=this.chart.getCachedScrollLeft(),this.activePaneIdOnDrag=l?.id||null,this.chart.scheduleDraw()}setTooltipSize(e){this.tooltipSize=e}setTooltipAnchorPositioning(e){this.useTooltipAnchorPositioning=e}onPointerUp(e){this.activePointers.delete(e.pointerId),this.isPinching&&this.activePointers.size<2&&(this.isPinching=!1,this.lastPinchDistance=0),e.isPrimary!==!1&&(this.isDragging=!1,this.dragMode=`none`,this.activePaneIdOnDrag=null,this.activeSeparatorUpperPaneId=null,this.notifyInteractionChange())}onPointerLeave(e){this.activePointers.delete(e.pointerId),this.activePointers.size<2&&(this.isPinching=!1,this.lastPinchDistance=0),e.isPrimary!==!1&&(this.isDragging=!1,this.dragMode=`none`,this.activePaneIdOnDrag=null,this.clearSeparatorState(),this.isTouchSession=!1,this.clearHover(),this.chart.scheduleDraw(),this.notifyInteractionChange())}onScroll(){this.kLinePositions=null,this.visibleRange=null,this.clearHover(),this.chart.scheduleDraw(),this.notifyInteractionChange()}onPointerMove(e){if(this.activePointers.has(e.pointerId)&&this.activePointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this.isPinching&&this.activePointers.size===2){let e=Array.from(this.activePointers.values()),t=e[0],n=e[1],r=Math.hypot(n.x-t.x,n.y-t.y),i=r-this.lastPinchDistance;if(Math.abs(i)>10){let e=i>0?1:-1,a=(t.x+n.x)/2;this.onPinchZoomCallback?.(e,a),this.lastPinchDistance=r}return}if(!e.isPrimary)return;e.pointerType===`touch`&&(this.isTouchSession=!0);let t=this.chart.getDom().container;if(this.isDragging){if(this.dragMode===`resize-separator`){let t=e.clientY-this.dragStartY;t!==0&&this.activeSeparatorUpperPaneId&&this.chart.resizePaneBoundary(this.activeSeparatorUpperPaneId,t)&&(this.dragStartY=e.clientY);return}if(this.dragMode===`scale-price`){let t=e.clientY-this.dragStartY;t!==0&&this.activePaneIdOnDrag&&(this.chart.scalePrice(this.activePaneIdOnDrag,t),this.dragStartY=e.clientY);return}if(this.dragMode===`pan`){let n=this.dragStartX-e.clientX;this.applyPanScroll(t,this.scrollStartX+n);let r=e.clientY-this.dragStartY;this.dragStartY=e.clientY,r!==0&&this.activePaneIdOnDrag===`main`&&(this.settings.disableMainPaneVerticalScroll||this.chart.translatePrice(this.activePaneIdOnDrag,r))}return}let n=this.getPlotPointerLocation(e.clientX,e.clientY);if(!n)return;this.hoveredSeparatorUpperPaneId=this.hitTestPaneSeparator(n.mouseY),this.updatePlotHoverFromPoint(e.clientX,e.clientY);let r=this.getHoverRenderKey();r!==this.lastHoverRenderKey&&(this.lastHoverRenderKey=r,this.chart.scheduleDraw(q.Overlay)),this.notifyInteractionChange()}setKLinePositions(e,t,n){this.kLinePositions=e,this.visibleRange=t,n!==void 0&&(this.kWidthPx=n)}onRightAxisPointerDown(e){if(e.isPrimary===!1)return;this.isTouchSession=e.pointerType===`touch`;let t=this.getRightAxisPointerLocation(e.clientX,e.clientY);t&&this.beginScalePriceDrag(e.clientY,t.mouseY)&&(this.chart.scheduleDraw(),this.notifyInteractionChange())}onRightAxisPointerMove(e){if(!e.isPrimary)return;if(e.pointerType===`touch`&&(this.isTouchSession=!0),this.isDragging&&this.dragMode===`scale-price`){let t=e.clientY-this.dragStartY;t!==0&&this.activePaneIdOnDrag&&(this.chart.scalePrice(this.activePaneIdOnDrag,t),this.dragStartY=e.clientY);return}this.updateRightAxisHoverFromPoint(e.clientX,e.clientY);let t=this.getHoverRenderKey();t!==this.lastHoverRenderKey&&(this.lastHoverRenderKey=t,this.chart.scheduleDraw(q.Overlay)),this.notifyInteractionChange()}onRightAxisPointerUp(e){this.onPointerUp(e)}onRightAxisPointerLeave(e){e.isPrimary!==!1&&(this.isDragging&&this.dragMode===`scale-price`||(this.hoveredRightAxisPaneId=null,this.notifyInteractionChange()))}isDraggingState(){return this.isDragging}setOnMarkerHover(e){this.onMarkerHoverCallback=e}setOnMarkerClick(e){this.onMarkerClickCallback=e}setOnCustomMarkerHover(e){this.onCustomMarkerHoverCallback=e}setOnCustomMarkerClick(e){this.onCustomMarkerClickCallback=e}hitTestPaneSeparator(e){let t=this.chart.getPaneRenderers();if(t.length<2)return null;for(let n=0;n<t.length-1;n++){let r=t[n]?.getPane(),i=t[n+1]?.getPane();if(!r||!i)continue;let a=r.top+r.height;if(Math.abs(e-a)<=5)return r.id}return null}getPaneByY(e){return this.chart.getPaneRenderers().find(t=>{let n=t.getPane();return e>=n.top&&e<=n.top+n.height})?.getPane()||null}getPlotPointerLocation(e,t){let n=this.chart.getDom().container.getBoundingClientRect();return{mouseX:e-n.left,mouseY:t-n.top}}getRightAxisPointerLocation(e,t){let n=this.chart.getDom().rightAxisLayer.getBoundingClientRect();return{mouseX:e-n.left,mouseY:t-n.top}}beginScalePriceDrag(e,t){let n=this.getPaneByY(t);return!n||n.id===`main`&&this.settings.disableMainPaneVerticalScroll?!1:(this.isDragging=!0,this.dragMode=`scale-price`,this.dragStartY=e,this.activePaneIdOnDrag=n.id,this.hoveredRightAxisPaneId=n.id,this.hoveredSeparatorUpperPaneId=null,this.crosshairPos=null,this.crosshairIndex=null,this.crosshairPrice=null,this.hoveredIndex=null,this.activePaneId=n.id,!0)}clearHover(){this.lastHoverRenderKey=``,this.hoveredRightAxisPaneId=null,this.crosshairPos=null,this.crosshairIndex=null,this.crosshairPrice=null,this.hoveredIndex=null,this.activePaneId=null,this.hoveredMarkerId===null?this.hoveredMarkerData=null:(this.hoveredMarkerId=null,this.hoveredMarkerData=null,this.chart.getMarkerManager().setHover(null),this.onMarkerHoverCallback&&this.onMarkerHoverCallback(null)),this.hoveredCustomMarker!==null&&(this.hoveredCustomMarker=null,this.onCustomMarkerHoverCallback&&this.onCustomMarkerHoverCallback(null))}clearSeparatorState(){this.activeSeparatorUpperPaneId=null,this.hoveredSeparatorUpperPaneId=null,this.hoveredRightAxisPaneId=null}updateRightAxisHoverFromPoint(e,t){let n=this.getRightAxisPointerLocation(e,t);if(!n)return;let{mouseY:r}=n,i=this.chart.getViewport()?.plotHeight??Math.max(1,Math.round(this.chart.getDom().container.clientHeight));if(r<0||r>i){this.hoveredRightAxisPaneId=null;return}let a=this.getPaneByY(r);this.hoveredRightAxisPaneId=a?.id||null,this.hoveredSeparatorUpperPaneId=null,this.crosshairPos=null,this.crosshairIndex=null,this.crosshairPrice=null,this.hoveredIndex=null,this.activePaneId=a?.id||null}updatePlotHoverFromPoint(e,t){let n=this.getPlotPointerLocation(e,t);if(!n)return;let{mouseX:r,mouseY:i}=n,a=this.chart.getDom().container,o=this.chart.getViewport(),s=o?.viewWidth??Math.max(1,Math.round(a.clientWidth)),c=o?.viewHeight??Math.max(1,Math.round(a.clientHeight)),l=o?.plotWidth??s,u=o?.plotHeight??c;if(r<0||i<0||r>l||i>u){this.clearHover();return}this.hoveredRightAxisPaneId=null;let d=this.chart.getCachedScrollLeft(),f=this.chart.getCurrentDpr(),p=this.hitTestPaneSeparator(i);if(this.hoveredSeparatorUpperPaneId=p,p){this.clearHover();return}let m=this.chart.getMarkerManager(),h=d+r,g=m.hitTest(h,i,3);if(g){this.hoveredMarkerId!==g.id&&(this.hoveredMarkerId=g.id,this.hoveredMarkerData=g,m.setHover(g.id),this.onMarkerHoverCallback&&this.onMarkerHoverCallback(g)),this.hoveredCustomMarker!==null&&(this.hoveredCustomMarker=null,this.onCustomMarkerHoverCallback&&this.onCustomMarkerHoverCallback(null)),this.crosshairPos=null,this.crosshairIndex=null,this.crosshairPrice=null,this.hoveredIndex=null;return}else this.hoveredMarkerId!==null&&(this.hoveredMarkerId=null,this.hoveredMarkerData=null,m.setHover(null),this.onMarkerHoverCallback&&this.onMarkerHoverCallback(null));let _=m.hitTestCustomMarker(r,i);if(_){this.hoveredCustomMarker?.id!==_.id&&(this.hoveredCustomMarker=_,this.onCustomMarkerHoverCallback&&this.onCustomMarkerHoverCallback(_)),this.hoveredMarkerId!==null&&(this.hoveredMarkerId=null,this.hoveredMarkerData=null,m.setHover(null),this.onMarkerHoverCallback&&this.onMarkerHoverCallback(null)),this.crosshairPos=null,this.crosshairIndex=null,this.crosshairPrice=null,this.hoveredIndex=null;return}else this.hoveredCustomMarker!==null&&(this.hoveredCustomMarker=null,this.onCustomMarkerHoverCallback&&this.onCustomMarkerHoverCallback(null));if(!this.kLinePositions||!this.visibleRange||!this.kWidthPx){this.clearHover();return}let v=this.kWidthPx/f,y=0,b=this.kLinePositions.length;for(;y<b;){let e=y+b>>1;this.kLinePositions[e]<h?y=e+1:b=e}let x=y;if(y>0&&y<this.kLinePositions.length){let e=this.kLinePositions[y-1]+v/2,t=this.kLinePositions[y]+v/2;Math.abs(h-e)<Math.abs(h-t)&&(x=y-1)}else y===this.kLinePositions.length&&this.kLinePositions.length>0&&(x=this.kLinePositions.length-1);let S=x+this.visibleRange.start,C=this.chart.getData(),w=this.getPaneByY(i);if(this.activePaneId=w?.id||null,S>=0&&S<(C?.length??0)){this.crosshairIndex=S;let e=this.kLinePositions[x],t=(Math.round(e*f)+(this.kWidthPx-1)/2)/f-d;if(this.crosshairPos={x:Math.min(Math.max(t,0),l),y:Math.min(Math.max(i,0),u)},w){let e=i-w.top;this.crosshairPrice=w.yAxis.yToPrice(e)}else this.crosshairPrice=null}else this.crosshairIndex=null,this.crosshairPos=null,this.crosshairPrice=null;let T=typeof this.crosshairIndex==`number`?C[this.crosshairIndex]:void 0;if(!T||!w||!w.capabilities.candleHitTest){this.hoveredIndex=null;return}let E=i-w.top,D=w.yAxis.priceToY(T.open),O=w.yAxis.priceToY(T.close),k=w.yAxis.priceToY(T.high),A=w.yAxis.priceToY(T.low),j=Math.min(D,O),M=Math.max(D,O),N=h-this.kLinePositions[x],ee=v/2,P=Math.abs(M-j),F=P<8?(j+M)/2-8/2:j,te=P<8?(j+M)/2+8/2:M,ne=E>=F&&E<=te&&N>=0&&N<=v,re=Math.abs(N-ee)<=3&&E>=Math.min(k,A)&&E<=Math.max(k,A);if(!ne&&!re){this.hoveredIndex=null;return}if(this.hoveredIndex=this.crosshairIndex,this.useTooltipAnchorPositioning){let e=this.tooltipSize.width,t=r+14+e+12>l;this.tooltipAnchorPlacement=t?`left-bottom`:`right-bottom`,this.tooltipPos={x:Math.min(Math.max(r,12),Math.max(12,l-12)),y:Math.min(Math.max(i,12),Math.max(12,u-12))};return}let ie=this.tooltipSize.width,ae=this.tooltipSize.height,oe=r+14,se=r-14-ie,ce=oe+ie+12<=s?oe:se,le=i+14,ue=Math.max(12,s-ie-12),de=Math.max(12,c-ae-12);this.tooltipPos={x:Math.min(Math.max(ce,12),ue),y:Math.min(Math.max(le,12),de)}}reset(){this.isDragging=!1,this.dragMode=`none`,this.dragStartX=0,this.dragStartY=0,this.scrollStartX=0,this.activePaneIdOnDrag=null,this.clearSeparatorState(),this.isTouchSession=!1,this.activePointers.clear(),this.isPinching=!1,this.lastPinchDistance=0,this.crosshairPos=null,this.crosshairIndex=null,this.crosshairPrice=null,this.hoveredIndex=null,this.activePaneId=null,this.hoveredMarkerId=null,this.clickedMarkerId=null,this.hoveredMarkerData=null,this.clickedMarkerData=null,this.hoveredCustomMarker=null,this.kLinePositions=null,this.visibleRange=null,this.lastHoverRenderKey=``,this.kWidthPx=null}getCrosshairIndex(){return this.crosshairIndex}},Ts=`#version 300 es
16
+ deps: ${r}}`};var i={keyword:`dependencies`,type:`object`,schemaType:`object`,error:e.error,code(e){let[t,n]=a(e);o(e,t),s(e,n)}};function a({schema:e}){let t={},n={};for(let r in e){if(r===`__proto__`)continue;let i=Array.isArray(e[r])?t:n;i[r]=e[r]}return[t,n]}function o(e,n=e.schema){let{gen:i,data:a,it:o}=e;if(Object.keys(n).length===0)return;let s=i.let(`missing`);for(let c in n){let l=n[c];if(l.length===0)continue;let u=(0,r.propertyInData)(i,a,c,o.opts.ownProperties);e.setParams({property:c,depsCount:l.length,deps:l.join(`, `)}),o.allErrors?i.if(u,()=>{for(let t of l)(0,r.checkReportMissingProp)(e,t)}):(i.if((0,t._)`${u} && (${(0,r.checkMissingProp)(e,l,s)})`),(0,r.reportMissingProp)(e,s),i.else())}}e.validatePropertyDeps=o;function s(e,t=e.schema){let{gen:i,data:a,keyword:o,it:s}=e,c=i.name(`valid`);for(let l in t)(0,n.alwaysValidSchema)(s,t[l])||(i.if((0,r.propertyInData)(i,a,l,s.opts.ownProperties),()=>{let t=e.subschema({keyword:o,schemaProp:l},c);e.mergeValidEvaluated(t,c)},()=>i.var(c,!0)),e.ok(c))}e.validateSchemaDeps=s,e.default=i})),Zr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U(),n=W();e.default={keyword:`propertyNames`,type:`object`,schemaType:[`object`,`boolean`],error:{message:`property name must be valid`,params:({params:e})=>(0,t._)`{propertyName: ${e.propertyName}}`},code(e){let{gen:r,schema:i,data:a,it:o}=e;if((0,n.alwaysValidSchema)(o,i))return;let s=r.name(`valid`);r.forIn(`key`,a,n=>{e.setParams({propertyName:n}),e.subschema({keyword:`propertyNames`,data:n,dataTypes:[`string`],propertyName:n,compositeRule:!0},s),r.if((0,t.not)(s),()=>{e.error(!0),o.allErrors||r.break()})}),e.ok(s)}}})),Qr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=or(),n=U(),r=$n(),i=W();e.default={keyword:`additionalProperties`,type:[`object`],schemaType:[`boolean`,`object`],allowUndefined:!0,trackErrors:!0,error:{message:`must NOT have additional properties`,params:({params:e})=>(0,n._)`{additionalProperty: ${e.additionalProperty}}`},code(e){let{gen:a,schema:o,parentSchema:s,data:c,errsCount:l,it:u}=e;if(!l)throw Error(`ajv implementation error`);let{allErrors:d,opts:f}=u;if(u.props=!0,f.removeAdditional!==`all`&&(0,i.alwaysValidSchema)(u,o))return;let p=(0,t.allSchemaProperties)(s.properties),m=(0,t.allSchemaProperties)(s.patternProperties);h(),e.ok((0,n._)`${l} === ${r.default.errors}`);function h(){a.forIn(`key`,c,e=>{!p.length&&!m.length?v(e):a.if(g(e),()=>v(e))})}function g(r){let o;if(p.length>8){let e=(0,i.schemaRefOrVal)(u,s.properties,`properties`);o=(0,t.isOwnProperty)(a,e,r)}else o=p.length?(0,n.or)(...p.map(e=>(0,n._)`${r} === ${e}`)):n.nil;return m.length&&(o=(0,n.or)(o,...m.map(i=>(0,n._)`${(0,t.usePattern)(e,i)}.test(${r})`))),(0,n.not)(o)}function _(e){a.code((0,n._)`delete ${c}[${e}]`)}function v(t){if(f.removeAdditional===`all`||f.removeAdditional&&o===!1){_(t);return}if(o===!1){e.setParams({additionalProperty:t}),e.error(),d||a.break();return}if(typeof o==`object`&&!(0,i.alwaysValidSchema)(u,o)){let r=a.name(`valid`);f.removeAdditional===`failing`?(y(t,r,!1),a.if((0,n.not)(r),()=>{e.reset(),_(t)})):(y(t,r),d||a.if((0,n.not)(r),()=>a.break()))}}function y(t,n,r){let a={keyword:`additionalProperties`,dataProp:t,dataPropType:i.Type.Str};r===!1&&Object.assign(a,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(a,n)}}}})),$r=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=fr(),n=or(),r=W(),i=Qr();e.default={keyword:`properties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,parentSchema:s,data:c,it:l}=e;l.opts.removeAdditional===`all`&&s.additionalProperties===void 0&&i.default.code(new t.KeywordCxt(l,i.default,`additionalProperties`));let u=(0,n.allSchemaProperties)(o);for(let e of u)l.definedProperties.add(e);l.opts.unevaluated&&u.length&&l.props!==!0&&(l.props=r.mergeEvaluated.props(a,(0,r.toHash)(u),l.props));let d=u.filter(e=>!(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0)return;let f=a.name(`valid`);for(let t of d)p(t)?m(t):(a.if((0,n.propertyInData)(a,c,t,l.opts.ownProperties)),m(t),l.allErrors||a.else().var(f,!0),a.endIf()),e.it.definedProperties.add(t),e.ok(f);function p(e){return l.opts.useDefaults&&!l.compositeRule&&o[e].default!==void 0}function m(t){e.subschema({keyword:`properties`,schemaProp:t,dataProp:t},f)}}}})),ei=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=or(),n=U(),r=W(),i=W();e.default={keyword:`patternProperties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,data:s,parentSchema:c,it:l}=e,{opts:u}=l,d=(0,t.allSchemaProperties)(o),f=d.filter(e=>(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0||f.length===d.length&&(!l.opts.unevaluated||l.props===!0))return;let p=u.strictSchema&&!u.allowMatchingProperties&&c.properties,m=a.name(`valid`);l.props!==!0&&!(l.props instanceof n.Name)&&(l.props=(0,i.evaluatedPropsToName)(a,l.props));let{props:h}=l;g();function g(){for(let e of d)p&&_(e),l.allErrors?v(e):(a.var(m,!0),v(e),a.if(m))}function _(e){for(let t in p)new RegExp(e).test(t)&&(0,r.checkStrictMode)(l,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function v(r){a.forIn(`key`,s,o=>{a.if((0,n._)`${(0,t.usePattern)(e,r)}.test(${o})`,()=>{let t=f.includes(r);t||e.subschema({keyword:`patternProperties`,schemaProp:r,dataProp:o,dataPropType:i.Type.Str},m),l.opts.unevaluated&&h!==!0?a.assign((0,n._)`${h}[${o}]`,!0):!t&&!l.allErrors&&a.if((0,n.not)(m),()=>a.break())})})}}}})),ti=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W();e.default={keyword:`not`,schemaType:[`object`,`boolean`],trackErrors:!0,code(e){let{gen:n,schema:r,it:i}=e;if((0,t.alwaysValidSchema)(i,r)){e.fail();return}let a=n.name(`valid`);e.subschema({keyword:`not`,compositeRule:!0,createErrors:!1,allErrors:!1},a),e.failResult(a,()=>e.reset(),()=>e.error())},error:{message:`must NOT be valid`}}})),ni=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:or().validateUnion,error:{message:`must match a schema in anyOf`}}})),ri=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U(),n=W();e.default={keyword:`oneOf`,schemaType:`array`,trackErrors:!0,error:{message:`must match exactly one schema in oneOf`,params:({params:e})=>(0,t._)`{passingSchemas: ${e.passing}}`},code(e){let{gen:r,schema:i,parentSchema:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(o.opts.discriminator&&a.discriminator)return;let s=i,c=r.let(`valid`,!1),l=r.let(`passing`,null),u=r.name(`_valid`);e.setParams({passing:l}),r.block(d),e.result(c,()=>e.reset(),()=>e.error(!0));function d(){s.forEach((i,a)=>{let s;(0,n.alwaysValidSchema)(o,i)?r.var(u,!0):s=e.subschema({keyword:`oneOf`,schemaProp:a,compositeRule:!0},u),a>0&&r.if((0,t._)`${u} && ${c}`).assign(c,!1).assign(l,(0,t._)`[${l}, ${a}]`).else(),r.if(u,()=>{r.assign(c,!0),r.assign(l,a),s&&e.mergeEvaluated(s,t.Name)})})}}}})),ii=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W();e.default={keyword:`allOf`,schemaType:`array`,code(e){let{gen:n,schema:r,it:i}=e;if(!Array.isArray(r))throw Error(`ajv implementation error`);let a=n.name(`valid`);r.forEach((n,r)=>{if((0,t.alwaysValidSchema)(i,n))return;let o=e.subschema({keyword:`allOf`,schemaProp:r},a);e.ok(a),e.mergeEvaluated(o)})}}})),ai=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U(),n=W(),r={keyword:`if`,schemaType:[`object`,`boolean`],trackErrors:!0,error:{message:({params:e})=>(0,t.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,t._)`{failingKeyword: ${e.ifClause}}`},code(e){let{gen:r,parentSchema:a,it:o}=e;a.then===void 0&&a.else===void 0&&(0,n.checkStrictMode)(o,`"if" without "then" and "else" is ignored`);let s=i(o,`then`),c=i(o,`else`);if(!s&&!c)return;let l=r.let(`valid`,!0),u=r.name(`_valid`);if(d(),e.reset(),s&&c){let t=r.let(`ifClause`);e.setParams({ifClause:t}),r.if(u,f(`then`,t),f(`else`,t))}else s?r.if(u,f(`then`)):r.if((0,t.not)(u),f(`else`));e.pass(l,()=>e.error(!0));function d(){let t=e.subschema({keyword:`if`,compositeRule:!0,createErrors:!1,allErrors:!1},u);e.mergeEvaluated(t)}function f(n,i){return()=>{let a=e.subschema({keyword:n},u);r.assign(l,u),e.mergeValidEvaluated(a,l),i?r.assign(i,(0,t._)`${n}`):e.setParams({ifClause:n})}}}};function i(e,t){let r=e.schema[t];return r!==void 0&&!(0,n.alwaysValidSchema)(e,r)}e.default=r})),oi=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W();e.default={keyword:[`then`,`else`],schemaType:[`object`,`boolean`],code({keyword:e,parentSchema:n,it:r}){n.if===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "if" is ignored`)}}})),si=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=Gr(),n=qr(),r=Kr(),i=Jr(),a=Yr(),o=Xr(),s=Zr(),c=Qr(),l=$r(),u=ei(),d=ti(),f=ni(),p=ri(),m=ii(),h=ai(),g=oi();function _(e=!1){let _=[d.default,f.default,p.default,m.default,h.default,g.default,s.default,c.default,o.default,l.default,u.default];return e?_.push(n.default,i.default):_.push(t.default,r.default),_.push(a.default),_}e.default=_})),ci=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U();e.default={keyword:`format`,type:[`number`,`string`],schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,t._)`{format: ${e}}`},code(e,n){let{gen:r,data:i,$data:a,schema:o,schemaCode:s,it:c}=e,{opts:l,errSchemaPath:u,schemaEnv:d,self:f}=c;if(!l.validateFormats)return;a?p():m();function p(){let a=r.scopeValue(`formats`,{ref:f.formats,code:l.code.formats}),o=r.const(`fDef`,(0,t._)`${a}[${s}]`),c=r.let(`fType`),u=r.let(`format`);r.if((0,t._)`typeof ${o} == "object" && !(${o} instanceof RegExp)`,()=>r.assign(c,(0,t._)`${o}.type || "string"`).assign(u,(0,t._)`${o}.validate`),()=>r.assign(c,(0,t._)`"string"`).assign(u,o)),e.fail$data((0,t.or)(p(),m()));function p(){return l.strictSchema===!1?t.nil:(0,t._)`${s} && !${u}`}function m(){let e=d.$async?(0,t._)`(${o}.async ? await ${u}(${i}) : ${u}(${i}))`:(0,t._)`${u}(${i})`,r=(0,t._)`(typeof ${u} == "function" ? ${e} : ${u}.test(${i}))`;return(0,t._)`${u} && ${u} !== true && ${c} === ${n} && !${r}`}}function m(){let a=f.formats[o];if(!a){m();return}if(a===!0)return;let[s,c,p]=h(a);s===n&&e.pass(g());function m(){if(l.strictSchema===!1){f.logger.warn(e());return}throw Error(e());function e(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function h(e){let n=e instanceof RegExp?(0,t.regexpCode)(e):l.code.formats?(0,t._)`${l.code.formats}${(0,t.getProperty)(o)}`:void 0,i=r.scopeValue(`formats`,{key:o,ref:e,code:n});return typeof e==`object`&&!(e instanceof RegExp)?[e.type||`string`,e.validate,(0,t._)`${i}.validate`]:[`string`,e,i]}function g(){if(typeof a==`object`&&!(a instanceof RegExp)&&a.async){if(!d.$async)throw Error(`async format in sync schema`);return(0,t._)`await ${p}(${i})`}return typeof c==`function`?(0,t._)`${p}(${i})`:(0,t._)`${p}.test(${i})`}}}}})),li=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=[ci().default]})),ui=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.contentVocabulary=e.metadataVocabulary=void 0,e.metadataVocabulary=[`title`,`description`,`default`,`deprecated`,`readOnly`,`writeOnly`,`examples`],e.contentVocabulary=[`contentMediaType`,`contentEncoding`,`contentSchema`]})),di=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=jr(),n=Wr(),r=si(),i=li(),a=ui();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),fi=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DiscrError=void 0;var t;(function(e){e.Tag=`tag`,e.Mapping=`mapping`})(t||(e.DiscrError=t={}))})),pi=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=U(),n=fi(),r=hr(),i=mr(),a=W();e.default={keyword:`discriminator`,type:`object`,schemaType:`object`,error:{message:({params:{discrError:e,tagName:t}})=>e===n.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:n,tagName:r}})=>(0,t._)`{error: ${e}, tag: ${r}, tagValue: ${n}}`},code(e){let{gen:o,data:s,schema:c,parentSchema:l,it:u}=e,{oneOf:d}=l;if(!u.opts.discriminator)throw Error(`discriminator: requires discriminator option`);let f=c.propertyName;if(typeof f!=`string`)throw Error(`discriminator: requires propertyName`);if(c.mapping)throw Error(`discriminator: mapping is not supported`);if(!d)throw Error(`discriminator: requires oneOf keyword`);let p=o.let(`valid`,!1),m=o.const(`tag`,(0,t._)`${s}${(0,t.getProperty)(f)}`);o.if((0,t._)`typeof ${m} == "string"`,()=>h(),()=>e.error(!1,{discrError:n.DiscrError.Tag,tag:m,tagName:f})),e.ok(p);function h(){let r=_();o.if(!1);for(let e in r)o.elseIf((0,t._)`${m} === ${e}`),o.assign(p,g(r[e]));o.else(),e.error(!1,{discrError:n.DiscrError.Mapping,tag:m,tagName:f}),o.endIf()}function g(n){let r=o.name(`valid`),i=e.subschema({keyword:`oneOf`,schemaProp:n},r);return e.mergeEvaluated(i,t.Name),r}function _(){let e={},t=o(l),n=!0;for(let e=0;e<d.length;e++){let c=d[e];if(c?.$ref&&!(0,a.schemaHasRulesButRef)(c,u.self.RULES)){let e=c.$ref;if(c=r.resolveRef.call(u.self,u.schemaEnv.root,u.baseId,e),c instanceof r.SchemaEnv&&(c=c.schema),c===void 0)throw new i.default(u.opts.uriResolver,u.baseId,e)}let l=c?.properties?.[f];if(typeof l!=`object`)throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${f}"`);n&&=t||o(c),s(l,e)}if(!n)throw Error(`discriminator: "${f}" must be required`);return e;function o({required:e}){return Array.isArray(e)&&e.includes(f)}function s(e,t){if(e.const)c(e.const,t);else if(e.enum)for(let n of e.enum)c(n,t);else throw Error(`discriminator: "properties/${f}" must have "const" or "enum"`)}function c(t,n){if(typeof t!=`string`||t in e)throw Error(`discriminator: "${f}" values must be unique strings`);e[t]=n}}}}})),mi=c({$id:()=>gi,$schema:()=>hi,default:()=>xi,definitions:()=>vi,properties:()=>bi,title:()=>_i,type:()=>yi}),hi,gi,_i,vi,yi,bi,xi,Si=o((()=>{hi=`http://json-schema.org/draft-07/schema#`,gi=`http://json-schema.org/draft-07/schema#`,_i=`Core schema meta-schema`,vi={schemaArray:{type:`array`,minItems:1,items:{$ref:`#`}},nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:`#/definitions/nonNegativeInteger`},{default:0}]},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}},yi=[`object`,`boolean`],bi={$id:{type:`string`,format:`uri-reference`},$schema:{type:`string`,format:`uri`},$ref:{type:`string`,format:`uri-reference`},$comment:{type:`string`},title:{type:`string`},description:{type:`string`},default:!0,readOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/definitions/nonNegativeInteger`},minLength:{$ref:`#/definitions/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},additionalItems:{$ref:`#`},items:{anyOf:[{$ref:`#`},{$ref:`#/definitions/schemaArray`}],default:!0},maxItems:{$ref:`#/definitions/nonNegativeInteger`},minItems:{$ref:`#/definitions/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},contains:{$ref:`#`},maxProperties:{$ref:`#/definitions/nonNegativeInteger`},minProperties:{$ref:`#/definitions/nonNegativeIntegerDefault0`},required:{$ref:`#/definitions/stringArray`},additionalProperties:{$ref:`#`},definitions:{type:`object`,additionalProperties:{$ref:`#`},default:{}},properties:{type:`object`,additionalProperties:{$ref:`#`},default:{}},patternProperties:{type:`object`,additionalProperties:{$ref:`#`},propertyNames:{format:`regex`},default:{}},dependencies:{type:`object`,additionalProperties:{anyOf:[{$ref:`#`},{$ref:`#/definitions/stringArray`}]}},propertyNames:{$ref:`#`},const:!0,enum:{type:`array`,items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:`#/definitions/simpleTypes`},{type:`array`,items:{$ref:`#/definitions/simpleTypes`},minItems:1,uniqueItems:!0}]},format:{type:`string`},contentMediaType:{type:`string`},contentEncoding:{type:`string`},if:{$ref:`#`},then:{$ref:`#`},else:{$ref:`#`},allOf:{$ref:`#/definitions/schemaArray`},anyOf:{$ref:`#/definitions/schemaArray`},oneOf:{$ref:`#/definitions/schemaArray`},not:{$ref:`#`}},xi={$schema:hi,$id:gi,title:_i,definitions:vi,type:yi,properties:bi,default:!0}})),Ci=u(s(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv=void 0;var n=Or(),r=di(),i=pi(),a=(Si(),d(mi).default),o=[`/properties`],s=`http://json-schema.org/draft-07/schema`,c=class extends n.default{_addVocabularies(){super._addVocabularies(),r.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(a,o):a;this.addMetaSchema(e,s,!1),this.refs[`http://json-schema.org/schema`]=s}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(s)?s:void 0)}};e.Ajv=c,t.exports=e=c,t.exports.Ajv=c,Object.defineProperty(e,`__esModule`,{value:!0}),e.default=c;var l=fr();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return l.KeywordCxt}});var u=U();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return u._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(e,`CodeGen`,{enumerable:!0,get:function(){return u.CodeGen}});var f=pr();Object.defineProperty(e,`ValidationError`,{enumerable:!0,get:function(){return f.default}});var p=mr();Object.defineProperty(e,`MissingRefError`,{enumerable:!0,get:function(){return p.default}})}))(),1),wi={$schema:`http://json-schema.org/draft-07/schema#`,$id:`https://kmap.dev/schemas/semantic-chart-config/1.0.0`,title:`SemanticChartConfig`,description:`Agent 语义化图表配置`,type:`object`,required:[`version`,`data`],additionalProperties:!1,properties:{version:{type:`string`,pattern:`^[0-9]+\\.[0-9]+\\.[0-9]+$`,description:`semver 版本号`},data:{$ref:`#/$defs/DataConfig`},indicators:{$ref:`#/$defs/IndicatorsConfig`},markers:{$ref:`#/$defs/MarkersConfig`},chart:{$ref:`#/$defs/ChartOptions`},theme:{$ref:`#/$defs/ThemeConfig`}},$defs:{DataConfig:{type:`object`,required:[`source`,`symbol`,`startDate`,`endDate`,`period`,`adjust`],additionalProperties:!1,properties:{source:{type:`string`,enum:[`baostock`,`dongcai`]},symbol:{type:`string`,pattern:`^[0-9]{6}$`},exchange:{type:`string`,enum:[`SH`,`SZ`,`BJ`]},startDate:{type:`string`,format:`date`},endDate:{type:`string`,format:`date`},period:{type:`string`,enum:[`daily`,`weekly`,`monthly`,`5min`,`15min`,`30min`,`60min`]},adjust:{type:`string`,enum:[`qfq`,`hfq`,`none`]}}},IndicatorsConfig:{type:`object`,additionalProperties:!1,properties:{main:{type:`array`,items:{$ref:`#/$defs/MainIndicatorConfig`},maxItems:5},sub:{type:`array`,items:{$ref:`#/$defs/SubIndicatorConfig`},maxItems:5}}},MainIndicatorConfig:{type:`object`,required:[`type`,`enabled`],additionalProperties:!1,properties:{type:{type:`string`,enum:[`MA`,`BOLL`]},enabled:{type:`boolean`},params:{type:`object`}},allOf:[{if:{properties:{type:{const:`MA`}},required:[`type`]},then:{properties:{params:{type:`object`,additionalProperties:!1,properties:{periods:{type:`array`,items:{type:`integer`,minimum:1,maximum:250},minItems:1,maxItems:5}}}}},else:{properties:{params:{type:`object`,additionalProperties:!1,properties:{period:{type:`integer`,minimum:1,maximum:100},multiplier:{type:`number`,minimum:.1,maximum:5}}}}}}]},SubIndicatorConfig:{type:`object`,required:[`type`,`enabled`],additionalProperties:!1,properties:{type:{type:`string`,enum:[`VOLUME`,`MACD`,`RSI`,`CCI`,`STOCH`,`MOM`,`WMSR`,`KST`,`FASTK`]},enabled:{type:`boolean`},params:{type:`object`}},allOf:[{if:{properties:{type:{const:`MACD`}}},then:{properties:{params:{type:`object`,additionalProperties:!1,properties:{fast:{type:`integer`,minimum:1,maximum:50},slow:{type:`integer`,minimum:1,maximum:100},signal:{type:`integer`,minimum:1,maximum:50}}}}}},{if:{properties:{type:{const:`RSI`}}},then:{properties:{params:{type:`object`,additionalProperties:!1,properties:{period1:{type:`integer`,minimum:1,maximum:100},period2:{type:`integer`,minimum:1,maximum:100},period3:{type:`integer`,minimum:1,maximum:100}}}}}}]},MarkersConfig:{type:`object`,additionalProperties:!1,properties:{showVolumePriceMarkers:{type:`boolean`},showExtremaMarkers:{type:`boolean`},customMarkers:{type:`array`,items:{$ref:`#/$defs/CustomMarker`},maxItems:100},legend:{$ref:`#/$defs/LegendConfig`}}},CustomMarker:{type:`object`,required:[`id`,`date`,`shape`],additionalProperties:!1,properties:{id:{type:`string`,maxLength:64},date:{type:`string`,description:`日期时间字符串,日K用 YYYY-MM-DD,分钟K用 YYYY-MM-DD HH:mm`,pattern:`^[0-9]{4}-[0-9]{2}-[0-9]{2}( [0-9]{2}:[0-9]{2})?$`},shape:{type:`string`,enum:[`arrow_up`,`arrow_down`,`flag`,`circle`,`rectangle`,`diamond`]},groupKey:{type:`string`,maxLength:32},offset:{type:`object`,additionalProperties:!1,properties:{x:{type:`number`,minimum:-500,maximum:500},y:{type:`number`,minimum:-500,maximum:500}}},style:{$ref:`#/$defs/MarkerStyle`},label:{$ref:`#/$defs/MarkerLabel`},metadata:{type:`object`,maxProperties:20,additionalProperties:{type:[`string`,`number`,`boolean`,`null`],maxLength:200}}}},MarkerStyle:{type:`object`,additionalProperties:!1,properties:{fillColor:{type:`string`,pattern:`^(#[0-9a-fA-F]{3,8}|rgb\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*\\)|rgba\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*[\\d.]+\\s*\\))$`},strokeColor:{type:`string`,pattern:`^(#[0-9a-fA-F]{3,8}|rgb\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*\\)|rgba\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*[\\d.]+\\s*\\))$`},textColor:{type:`string`,pattern:`^(#[0-9a-fA-F]{3,8}|rgb\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*\\)|rgba\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*[\\d.]+\\s*\\))$`},size:{type:`number`,minimum:4,maximum:50},lineWidth:{type:`number`,minimum:.5,maximum:10},opacity:{type:`number`,minimum:0,maximum:1}}},MarkerLabel:{type:`object`,required:[`text`],additionalProperties:!1,properties:{text:{type:`string`,maxLength:50},position:{type:`string`,enum:[`left`,`right`,`top`,`bottom`,`inside`]},align:{type:`string`,enum:[`start`,`center`,`end`]},fontSize:{type:`number`,minimum:8,maximum:24},offset:{type:`object`,additionalProperties:!1,properties:{x:{type:`number`,minimum:-500,maximum:500},y:{type:`number`,minimum:-500,maximum:500}}}}},LegendConfig:{type:`object`,additionalProperties:!1,properties:{enabled:{type:`boolean`},position:{type:`string`,enum:[`bottom-right`,`bottom-left`,`top-right`,`top-left`]},onClick:{type:`string`,enum:[`highlight`,`toggle`,`none`]}}},ChartOptions:{type:`object`,additionalProperties:!1,properties:{kWidth:{type:`number`,minimum:2,maximum:50},kGap:{type:`number`,minimum:0,maximum:20},autoScrollToRight:{type:`boolean`}}},ThemeConfig:{type:`object`,additionalProperties:!1,properties:{priceUpColor:{type:`string`,pattern:`^#[0-9a-fA-F]{6}$`},priceDownColor:{type:`string`,pattern:`^#[0-9a-fA-F]{6}$`}}}}},Ti=[`__proto__`,`constructor`,`prototype`],Ei=/^(#[0-9a-fA-F]{3,8}|rgb\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*\)|rgba\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*[\d.]+\s*\))$/,Di={SH:/^(600|601|603|605|688)\d{3}$/,SZ:/^(000|001|002|003|300|301)\d{3}$/,BJ:/^(83|87|43|82)\d{4}$/};function Oi(e){return{"5min":30,"15min":60,"30min":90,"60min":180,daily:365*3,weekly:365*5,monthly:365*10}[e]??365}var ki=(typeof document<`u`?document.createElement(`canvas`):null)?.getContext(`2d`)??null,Ai=class e{ajv;limits;constructor(){this.ajv=new Ci.default({allErrors:!0,allowUnionTypes:!0}),this.ajv.addFormat(`date`,{type:`string`,validate:e=>/^\d{4}-\d{2}-\d{2}$/.test(e)}),this.ajv.addSchema(wi),this.limits={maxJsonSize:64*1024,maxIndicators:10,maxCustomMarkers:100}}validateRawInput(e){return(typeof TextEncoder<`u`?new TextEncoder().encode(e).byteLength:e.length*3)>this.limits.maxJsonSize?{valid:!1,errors:[`JSON payload too large (max 64KB)`]}:{valid:!0}}validate(e){if(!e||typeof e!=`object`)return{valid:!1,errors:[`Config must be an object`]};let t=this.checkPrototypePollution(e);return t.valid?this.ajv.validate(`https://kmap.dev/schemas/semantic-chart-config/1.0.0`,e)?{valid:!0}:{valid:!1,errors:this.ajv.errors?.map(e=>`${e.instancePath} ${e.message}`)||[`Schema validation failed`]}:t}securityCheck(e){let t=[],n=this.checkDateRange(e.data);n.valid||t.push(...n.errors||[]);let r=this.checkSymbol(e.data);if(r.valid||t.push(...r.errors||[]),e.indicators&&(e.indicators.main?.length||0)+(e.indicators.sub?.length||0)>this.limits.maxIndicators&&t.push(`Too many indicators (max ${this.limits.maxIndicators})`),(e.markers?.customMarkers?.length||0)>this.limits.maxCustomMarkers&&t.push(`Too many custom markers (max ${this.limits.maxCustomMarkers})`),e.markers?.customMarkers)for(let n of e.markers.customMarkers){if(n.style){let e=this.checkMarkerStyle(n.style,n.id);t.push(...e)}let e=this.checkMarkerDate(n.date,n.id);t.push(...e)}return{passed:t.length===0,violations:t.length>0?t:void 0}}checkPrototypePollution(e,t=``){if(!e||typeof e!=`object`)return{valid:!0};let n=[];for(let r of Object.keys(e))Ti.includes(r)&&n.push(`Forbidden key "${r}" found at ${t}`);return n.length>0?{valid:!1,errors:n}:{valid:!0}}checkDateRange(e){let t=[],n=new Date(e.startDate),r=new Date(e.endDate);if(isNaN(n.getTime())&&t.push(`Invalid startDate: ${e.startDate}`),isNaN(r.getTime())&&t.push(`Invalid endDate: ${e.endDate}`),t.length>0)return{valid:!1,errors:t};let i=Oi(e.period),a=Math.ceil((r.getTime()-n.getTime())/(1e3*60*60*24));return a>i&&t.push(`Date range exceeds maximum for period "${e.period}" (max ${i} days, got ${a})`),a<0&&t.push(`endDate must be after startDate`),t.length>0?{valid:!1,errors:t}:{valid:!0}}checkSymbol(e){let{symbol:t,exchange:n}=e;if(n){if(!Di[n].test(t))return{valid:!1,errors:[`Invalid symbol "${t}" for exchange "${n}"`]}}else if(!Object.values(Di).some(e=>e.test(t)))return{valid:!1,errors:[`Invalid symbol format: "${t}"`]};return{valid:!0}}checkMarkerStyle(e,t){let n=[],r=[`fillColor`,`strokeColor`,`textColor`];for(let i of r){let r=e[i];typeof r==`string`&&!Ei.test(r)&&n.push(`Invalid ${i} in marker "${t}": ${r}`)}if(ki)for(let i of r){let r=e[i];typeof r==`string`&&(ki.fillStyle=`#000000`,ki.fillStyle=r,ki.fillStyle===`#000000`&&r!==`#000000`&&!r.startsWith(`#000`)&&n.push(`Potentially unsafe ${i} in marker "${t}": ${r}`))}return n}static DATE_PATTERN=/^\d{4}-\d{2}-\d{2}( \d{2}:\d{2})?$/;checkMarkerDate(t,n){let r=[];if(!e.DATE_PATTERN.test(t))return r.push(`Invalid date format in marker "${n}": ${t} (expected YYYY-MM-DD or YYYY-MM-DD HH:mm)`),r;let i=t.includes(` `),a;if(i)a=new Date(t);else{let[e,n,r]=t.split(`-`).map(Number);a=new Date(Date.UTC(e,n-1,r))}return isNaN(a.getTime())&&r.push(`Invalid date value in marker "${n}": ${t}`),r}},ji=class{chart;validator;events;constructor(e){this.chart=e,this.validator=new Ai,this.events=new p}async applyConfig(e){let t=this.validator.validate(e);if(!t.valid)return{success:!1,errors:t.errors};let n=this.validator.securityCheck(e);if(!n.passed)return{success:!1,errors:n.violations};this.events.emit(`config:loading`,void 0);try{return await this.doApplyConfig(e),this.events.emit(`config:ready`,void 0),{success:!0}}catch(e){return this.events.emit(`config:error`,e),{success:!1,errors:[e instanceof Error?e.message:String(e)]}}}on(e,t){this.events.on(e,t)}off(e,t){this.events.off(e,t)}async doApplyConfig(e){console.log(`[Semantic] doApplyConfig start, data config:`,e.data);let t=await Xn(e.data.source,{symbol:e.data.symbol,startDate:e.data.startDate,endDate:e.data.endDate,period:e.data.period,adjust:e.data.adjust});console.log(`[Semantic] fetched data:`,t.length,`items`),this.chart.updateData(t),e.indicators&&(console.log(`[Semantic] applying indicators:`,e.indicators),this.applyIndicators(e.indicators.main,e.indicators.sub)),e.markers&&(console.log(`[Semantic] applying markers:`,e.markers.customMarkers?.length,`markers`),this.applyMarkers(e.markers.customMarkers,e.data.period)),e.chart&&this.applyChartOptions(e.chart),console.log(`[Semantic] doApplyConfig done`)}applyIndicators(e,t){if(e){for(let t of e)if(t.enabled)switch(t.type){case`MA`:this.applyMAIndicator(t);break;case`BOLL`:this.applyBOLLIndicator(t);break;case`EXPMA`:this.applyEXPMAIndicator(t);break;case`ENE`:this.applyENEIndicator(t);break}}if(this.chart.clearSubPanes(),t)for(let e of t)this.applySubIndicator(e)}applyMAIndicator(e){let t=e.params?.periods||[5,10,20,30,60],n={};for(let e of t)e===5?n.ma5=!0:e===10?n.ma10=!0:e===20?n.ma20=!0:e===30?n.ma30=!0:e===60&&(n.ma60=!0);console.log(`[Semantic] applyMAIndicator, periods:`,t,`maFlags:`,n),this.chart.updateRendererConfig(`ma`,n)}applyBOLLIndicator(e){let t={period:e.params?.period||20,multiplier:e.params?.multiplier||2};this.chart.updateRendererConfig(`boll`,t)}applyEXPMAIndicator(e){let t={fastPeriod:e.params?.fastPeriod||12,slowPeriod:e.params?.slowPeriod||50};this.chart.updateRendererConfig(`expma`,t)}applyENEIndicator(e){let t={period:e.params?.period||10,deviation:e.params?.deviation||11};this.chart.updateRendererConfig(`ene`,t)}applySubIndicator(e){if(!e.enabled)return;let{type:t,params:n}=e;this.chart.createSubPane(t,n)||console.warn(`[Semantic] Failed to create sub pane for ${t}`)}applyMarkers(e,t){if(!e||e.length===0){this.chart.clearCustomMarkers();return}let n=e.map(e=>({id:e.id,date:e.date,timestamp:Mi(e.date,t||`daily`),shape:e.shape,groupKey:e.groupKey,offset:e.offset,style:e.style,label:e.label,metadata:e.metadata}));this.chart.updateCustomMarkers(n)}applyChartOptions(e){e.autoScrollToRight}};function Mi(e,t){if(e.includes(` `)){let[t,n]=e.split(` `),r=t.split(`-`).map(Number),i=r[0],a=r[1],o=r[2],s=n.split(`:`).map(Number),c=s[0],l=s[1];return Date.UTC(i,a-1,o,c-8,l,0,0)}else{let t=e.split(`-`).map(Number),n=t[0],r=t[1],i=t[2];return Date.UTC(n,r-1,i,-8,0,0,0)}}var Ni={arrow_up:16,arrow_down:16,flag:14,circle:12,rectangle:14,diamond:12};function Pi(e,t,n,r,i,a){let o=a.fillColor||`#000000`,s=a.strokeColor||o,c=i||Ni[t];switch(e.fillStyle=o,e.strokeStyle=s,e.lineWidth=a.lineWidth||1,a.opacity!==void 0&&(e.globalAlpha=a.opacity),t){case`arrow_up`:zi(e,n,r,c);break;case`arrow_down`:Bi(e,n,r,c);break;case`circle`:Vi(e,n,r,c);break;case`rectangle`:Hi(e,n,r,c);break;case`diamond`:Ui(e,n,r,c);break;case`flag`:Wi(e,n,r,c);break}e.globalAlpha=1}var Fi=2.5,Ii=4;function Li(e,t,n,r,i,a,o=!1){let s=t.fontSize||12,c=a.textColor||`#333333`,l=i/2;e.font=`${s}px sans-serif`,e.fillStyle=c,e.textBaseline=`middle`;let u=i*Fi,d=Ri(e,t.text,u),f=e.measureText(d).width,p=n,m=r;switch(t.position){case`left`:p=n-l-f/2-Ii;break;case`right`:p=n+l+f/2+Ii;break;case`top`:m=r-l-s/2-Ii;break;case`bottom`:m=r+l+s/2+Ii;break;default:m=o?r-l-s/2-Ii:r+l+s/2+Ii;break}t.offset&&(p+=t.offset.x||0,m+=t.offset.y||0),e.textAlign=t.align||`center`,e.fillText(d,p,m)}function Ri(e,t,n){if(e.measureText(t).width<=n)return t;let r=e.measureText(`…`).width,i=0,a=t.length;for(;i<a;){let o=Math.ceil((i+a)/2),s=t.slice(0,o);e.measureText(s).width+r<=n?i=o:a=o-1}return t.slice(0,i)+`…`}function zi(e,t,n,r){e.beginPath(),e.moveTo(t,n-r/2),e.lineTo(t-r/2,n+r/2),e.lineTo(t+r/2,n+r/2),e.closePath(),e.fill()}function Bi(e,t,n,r){e.beginPath(),e.moveTo(t,n+r/2),e.lineTo(t-r/2,n-r/2),e.lineTo(t+r/2,n-r/2),e.closePath(),e.fill()}function Vi(e,t,n,r){e.beginPath(),e.arc(t,n,r/2,0,Math.PI*2),e.fill()}function Hi(e,t,n,r){e.fillRect(t-r/2,n-r/2,r,r)}function Ui(e,t,n,r){e.beginPath(),e.moveTo(t,n-r/2),e.lineTo(t+r/2,n),e.lineTo(t,n+r/2),e.lineTo(t-r/2,n),e.closePath(),e.fill()}function Wi(e,t,n,r){e.beginPath(),e.moveTo(t-r/4,n+r/2),e.lineTo(t-r/4,n-r/2),e.stroke(),e.beginPath(),e.moveTo(t-r/4,n-r/2),e.lineTo(t+r/2,n-r/4),e.lineTo(t-r/4,n),e.closePath(),e.fill()}function Gi(e,t,n,r,i,a){let o=a/2;switch(n){case`circle`:let n=e-r,a=t-i;return n*n+a*a<=o*o;default:return e>=r-o&&e<=r+o&&t>=i-o&&t<=i+o}}var Ki=function(e){return e.Registered=`registered`,e.Installed=`installed`,e.Error=`error`,e}({});function qi(e){return{id:e.id,role:e.role,capabilities:{...e.capabilities},top:e.top,height:e.height,yAxis:{priceToY:t=>e.yAxis.priceToY(t),yToPrice:t=>e.yAxis.yToPrice(t),getPaddingTop:()=>e.yAxis.getPaddingTop(),getPaddingBottom:()=>e.yAxis.getPaddingBottom(),getPriceOffset:()=>e.yAxis.getPriceOffset(),getDisplayRange:t=>e.yAxis.getDisplayRange(t),getScaleType:()=>e.yAxis.getScaleType()},priceRange:e.priceRange}}var Ji=Symbol(`global-pane`),G={LAST_PRICE_LABEL:-25,SYSTEM_YAXIS:-20,SYSTEM_XAXIS:-20,BACKGROUND:0,GRID:10,INDICATOR:30,MAIN:50,INDICATOR_SCALE:55,OVERLAY:80,FOREGROUND:100,SYSTEM_BORDER:120,SYSTEM_CROSSHAIR:150},Yi=class{plugins=new Map;register(e,t){if(this.plugins.has(e.name))throw Error(`Plugin "${e.name}" is already registered`);let n={plugin:e,config:{enabled:!0,priority:0,...t},state:`registered`};return this.plugins.set(e.name,n),n}unregister(e){return this.plugins.delete(e)}get(e){return this.plugins.get(e)}getPlugin(e){return this.plugins.get(e)?.plugin}getAll(){return Array.from(this.plugins.values())}getEnabled(){return this.getAll().filter(e=>e.config?.enabled!==!1)}updateState(e,t,n){let r=this.plugins.get(e);r&&(r.state=t,n&&(r.error=n))}has(e){return this.plugins.has(e)}clear(){this.plugins.clear()}},Xi=class{hooks=new Map;tap(e,t,n=0){this.hooks.has(e)||this.hooks.set(e,[]);let r=this.hooks.get(e);r.push({name:e,fn:t,priority:n}),r.sort((e,t)=>e.priority-t.priority)}untap(e,t){let n=this.hooks.get(e);if(n){let e=n.findIndex(e=>e.fn===t);e!==-1&&n.splice(e,1)}}async call(e,t,n){let r=this.hooks.get(e);if(!r||r.length===0)return[];let i=[];for(let{fn:a}of r)try{let e=await a(t);i.push(e)}catch(t){if(console.error(`[HookSystem] Error in hook "${e}":`,t),n?.throwOnError)throw t}return i}callSync(e,t,n){let r=this.hooks.get(e);if(!r||r.length===0)return[];let i=[];for(let{fn:a}of r)try{let e=a(t);i.push(e)}catch(t){if(console.error(`[HookSystem] Error in hook "${e}":`,t),n?.throwOnError)throw t}return i}clear(){this.hooks.clear()}hookCount(e){return this.hooks.get(e)?.length??0}},Zi=class{configs=new Map;defaults=new Map;registerDefaults(e,t){this.defaults.set(e,{...t}),this.configs.has(e)||this.configs.set(e,new Map);let n=this.configs.get(e);for(let[e,r]of Object.entries(t))n.has(e)||n.set(e,r)}get(e,t,n){let r=this.configs.get(e);if(r?.has(t))return r.get(t);let i=this.defaults.get(e);return i&&t in i?i[t]:n}set(e,t,n){this.configs.has(e)||this.configs.set(e,new Map),this.configs.get(e).set(t,n)}setAll(e,t){for(let[n,r]of Object.entries(t))this.set(e,n,r)}getAll(e){let t=this.configs.get(e);return{...this.defaults.get(e)||{},...t?Object.fromEntries(t):{}}}clear(e){e?(this.configs.delete(e),this.defaults.delete(e)):(this.configs.clear(),this.defaults.clear())}},Qi=class{states=new Map;ownerNamespaces=new Map;setState(e,t,n){this.states.set(e,t)}getState(e){return this.states.get(e)}clearState(e){this.states.delete(e)}registerStateOwner(e,t){this.ownerNamespaces.set(e,new Set(t))}clearByOwner(e){let t=this.ownerNamespaces.get(e);t&&(t.forEach(e=>{this.states.delete(e)}),this.ownerNamespaces.delete(e))}clear(){this.states.clear(),this.ownerNamespaces.clear()}},$i=class{registry;eventBus;hookSystem;configManager;stateStore;isDestroyed=!1;logger;constructor(e){this.registry=new Yi,this.eventBus=new p,this.hookSystem=new Xi,this.configManager=new Zi,this.stateStore=new Qi,this.logger=e??console}events={on:(e,t)=>{this.eventBus.on(e,t)},off:(e,t)=>{this.eventBus.off(e,t)},emit:(e,t)=>{this.eventBus.emit(e,t)},once:(e,t)=>{this.eventBus.once(e,t)}};hooks={tap:(e,t,n=0)=>{this.hookSystem.tap(e,t,n)},untap:(e,t)=>{this.hookSystem.untap(e,t)},call:async(e,t,n)=>this.hookSystem.call(e,t,n),callSync:(e,t,n)=>this.hookSystem.callSync(e,t,n)};getConfig(e,t,n){return this.configManager.get(e,t,n)}setConfig(e,t,n){this.configManager.set(e,t,n)}getPlugin(e){return this.registry.getPlugin(e)}log(e,t,...n){let r=`[${new Date().toISOString()}] [${e.toUpperCase()}]`;this.logger[e](`${r} ${t}`,...n)}setSharedState(e,t,n){this.stateStore.setState(e,t,n)}getSharedState(e){return this.stateStore.getState(e)}clearSharedState(e){this.stateStore.clearState(e)}registerStateOwner(e,t){this.stateStore.registerStateOwner(e,t)}clearByOwner(e){this.stateStore.clearByOwner(e)}async use(e,t){if(this.ensureNotDestroyed(),this.registry.has(e.name))throw Error(`Plugin "${e.name}" is already installed`);try{let n=this.registry.register(e,t);t&&this.configManager.setAll(e.name,t),await this.hooks.call(`plugin:beforeInstall`,{plugin:e,config:t},{throwOnError:!0}),await e.install(this,n.config),this.registry.updateState(e.name,`installed`),await this.hooks.call(`plugin:afterInstall`,{plugin:e,config:t},{throwOnError:!0}),this.log(`info`,`Plugin "${e.name}" installed successfully`)}catch(t){throw this.registry.updateState(e.name,`error`,t instanceof Error?t:Error(String(t))),this.log(`error`,`Failed to install plugin "${e.name}":`,t),t}}async remove(e){this.ensureNotDestroyed();let t=this.registry.get(e);if(!t)throw Error(`Plugin "${e}" is not installed`);try{await this.hooks.call(`plugin:beforeUninstall`,{name:e},{throwOnError:!0}),t.plugin.uninstall&&await t.plugin.uninstall(),this.registry.unregister(e),this.configManager.clear(e),await this.hooks.call(`plugin:afterUninstall`,{name:e},{throwOnError:!0}),this.log(`info`,`Plugin "${e}" removed successfully`)}catch(t){throw this.log(`error`,`Failed to remove plugin "${e}":`,t),t}}getPlugins(){return this.registry.getAll()}getState(e){return this.registry.get(e)?.state}async destroy(){if(!this.isDestroyed){for(let e of this.registry.getAll())try{e.plugin.uninstall&&await e.plugin.uninstall()}catch(t){this.log(`error`,`Error uninstalling "${e.plugin.name}":`,t)}this.registry.clear(),this.eventBus.clear(),this.hookSystem.clear(),this.configManager.clear(),this.stateStore.clear(),this.isDestroyed=!0,this.log(`info`,`PluginHost destroyed`)}}ensureNotDestroyed(){if(this.isDestroyed)throw Error(`PluginHost has been destroyed`)}};function ea(e){return new $i(e)}function ta(e,t){let n=Math.round(e*t);return n%2==0&&(n+=1),Math.max(1,n)}function na(e,t,n){let r=ta(e,n),i=Math.round(t*n),a=r+i,o=i;return{kWidthPx:r,kGapPx:i,unitPx:a,startXPx:o,kWidthLogical:r/n,kGapLogical:i/n,unitLogical:a/n,startXLogical:o/n}}function ra(e,t,n,r,i,a=1){let{unitPx:o,startXPx:s}=na(n,r,a),c=e*a,l=t*a;return{start:Math.max(0,Math.floor((c-s)/o)-1),end:Math.min(i,Math.ceil((c+l-s)/o)+1)}}function ia(e,t,n){let r=-1/0,i=1/0;for(let a=t;a<n&&a<e.length;a++){let t=e[a];t&&(t.high>r&&(r=t.high),t.low<i&&(i=t.low))}return!Number.isFinite(r)||!Number.isFinite(i)?{maxPrice:100,minPrice:0}:{maxPrice:r,minPrice:i}}var aa={logicalOffset:4,coordOffset:1e-4};function oa(e){return Math.abs(e)<1e-15}function K(e,t){let n=Math.abs(e);if(oa(n))return 0;let r=Math.log10(n+t.coordOffset)+t.logicalOffset;return e<0?-r:r}function sa(e,t){let n=Math.abs(e);if(oa(n))return 0;let r=10**(n-t.logicalOffset)-t.coordOffset;return e<0?-r:r}function ca(e){if(e===null)return{...aa};let t=Math.abs(e.maxPrice-e.minPrice);if(t>=1||t<1e-15)return{...aa};let n=Math.ceil(Math.abs(Math.log10(t))),r=aa.logicalOffset+n;return{logicalOffset:r,coordOffset:1/10**r}}function la(e,t){return e.logicalOffset===t.logicalOffset&&e.coordOffset===t.coordOffset}var ua=class{range={maxPrice:100,minPrice:0};height=1;paddingTop=0;paddingBottom=0;priceOffset=0;verticalScale=1;scaleType=`linear`;logFormula=ca(null);setRange(e){if(this.range=e,this.scaleType===`log`&&e.minPrice>0){let t=ca(e);if(!la(t,this.logFormula)){let n=K(e.minPrice,this.logFormula),r=(K(e.maxPrice,this.logFormula)+n)/2+this.priceOffset;this.logFormula=t;let i=K(e.minPrice,this.logFormula),a=(K(e.maxPrice,this.logFormula)+i)/2;this.priceOffset=this.clampOffset(r-a)}}}setHeight(e){this.height=Math.max(1,e)}setPadding(e,t){this.paddingTop=Math.max(0,e),this.paddingBottom=Math.max(0,t)}getRange(){return this.range}getPaddingTop(){return this.paddingTop}getPaddingBottom(){return this.paddingBottom}setPriceOffset(e){this.priceOffset=this.clampOffset(e)}getPriceOffset(){return this.priceOffset}resetPriceOffset(){this.priceOffset=0}clampOffset(e){if(this.scaleType===`log`&&this.range.minPrice>0){let t=K(this.range.minPrice,this.logFormula),n=K(this.range.maxPrice,this.logFormula)-t;if(n<=0)return 0;let r=n*(1+1/this.verticalScale)/2;return Math.max(-r,Math.min(r,e))}let t=this.range.maxPrice-this.range.minPrice;if(t<=0)return 0;let n=t*(1+1/this.verticalScale)/2;return Math.max(-n,Math.min(n,e))}scaleByDelta(e){if(!Number.isFinite(e)||e===0)return;let t=Math.exp(-e*.01),n=this.verticalScale*t;this.verticalScale=Math.min(8,Math.max(.2,n)),this.priceOffset=this.clampOffset(this.priceOffset)}getVerticalScale(){return this.verticalScale}setScaleType(e){if(e!==this.scaleType){if(e===`log`&&this.range.minPrice>0){this.logFormula=ca(this.range);let e=(this.range.maxPrice+this.range.minPrice)/2,t=e+this.priceOffset;this.priceOffset=K(t,this.logFormula)-K(e,this.logFormula),this.priceOffset=this.clampOffset(this.priceOffset)}else if(e===`linear`&&this.scaleType===`log`){let e=K(this.range.minPrice,this.logFormula),t=sa((K(this.range.maxPrice,this.logFormula)+e)/2+this.priceOffset,this.logFormula),n=(this.range.maxPrice+this.range.minPrice)/2;this.priceOffset=t-n,this.priceOffset=this.clampOffset(this.priceOffset)}this.scaleType=e}}getScaleType(){return this.scaleType}getDisplayRange(e){let{minPrice:t,maxPrice:n}=e??this.range;if(this.scaleType===`log`&&t>0){let e=K(t,this.logFormula),r=K(n,this.logFormula),i=r-e||1,a=(r+e)/2+this.priceOffset,o=i/(2*this.verticalScale);return{maxPrice:sa(a+o,this.logFormula),minPrice:sa(a-o,this.logFormula)}}let r=n-t||1,i=(n+t)/2+this.priceOffset,a=r/(2*this.verticalScale);return{maxPrice:i+a,minPrice:i-a}}priceToY(e){let{maxPrice:t,minPrice:n}=this.getDisplayRange(),r=Math.max(1,this.height-this.paddingTop-this.paddingBottom),i;if(this.scaleType===`log`&&n>0){let r=K(n,this.logFormula),a=K(t,this.logFormula);i=(K(e,this.logFormula)-r)/(a-r||1)}else i=(e-n)/(t-n||1);return this.paddingTop+r*(1-i)}yToPrice(e){let{maxPrice:t,minPrice:n}=this.getDisplayRange(),r=Math.max(1,this.height-this.paddingTop-this.paddingBottom),i=1-(e-this.paddingTop)/r;if(this.scaleType===`log`&&n>0){let e=K(n,this.logFormula);return sa(e+i*(K(t,this.logFormula)-e),this.logFormula)}return n+i*(t-n)}deltaYToPriceOffset(e){let t=Math.max(1,this.height-this.paddingTop-this.paddingBottom);if(this.scaleType===`log`&&this.range.minPrice>0){let n=K(this.range.minPrice,this.logFormula);return e*((K(this.range.maxPrice,this.logFormula)-n)/t)}return e*((this.range.maxPrice-this.range.minPrice||1)/t)}},q=function(e){return e.Main=`main`,e.Overlay=`overlay`,e.All=`all`,e}({});function da(e){return e===`price`?{showPriceAxisTicks:!0,showCrosshairPriceLabel:!0,candleHitTest:!0,supportsPriceTranslate:!0}:e===`indicator`?{showPriceAxisTicks:!1,showCrosshairPriceLabel:!0,candleHitTest:!1,supportsPriceTranslate:!0}:{showPriceAxisTicks:!1,showCrosshairPriceLabel:!1,candleHitTest:!1,supportsPriceTranslate:!1}}var fa=class{id;role;capabilities;top=0;height=0;priceRange={maxPrice:100,minPrice:0};yAxis=new ua;renderers=[];constructor(e,t={}){this.id=e,this.role=t.role??(e===`main`?`price`:`indicator`),this.capabilities={...da(this.role),...t.capabilities??{}}}setLayout(e,t){this.top=e,this.height=Math.max(1,t),this.yAxis.setHeight(this.height)}setPadding(e,t){this.yAxis.setPadding(e,t)}addRenderer(e){this.renderers.push(e)}updateRange(e,t,n){this.priceRange=ia(e,t.start,t.end),n&&Number.isFinite(n.min)&&Number.isFinite(n.max)&&(this.priceRange.minPrice=Math.min(this.priceRange.minPrice,n.min),this.priceRange.maxPrice=Math.max(this.priceRange.maxPrice,n.max)),this.yAxis.setRange(this.priceRange)}},pa=Symbol(`renderer:global-cache`),ma=class{plugins=new Map;pluginHost=null;enabledState=new Map;groupCache=new Map;mergedCache=new Map;knownPaneIds=new Set;cacheInvalid=!0;onInvalidate=null;setInvalidateCallback(e){this.onInvalidate=e}setPluginHost(e){this.pluginHost=e}addKnownPaneId(e){this.knownPaneIds.add(e),this.cacheInvalid=!0}removeKnownPaneId(e){this.knownPaneIds.delete(e),this.cacheInvalid=!0}setKnownPaneIds(e){this.knownPaneIds=new Set(e),this.cacheInvalid=!0}register(e){if(this.plugins.has(e.name)){console.warn(`Renderer plugin "${e.name}" already registered`);return}this.plugins.set(e.name,e),e.enabled!==void 0&&this.enabledState.set(e.name,e.enabled),this.cacheInvalid=!0;let t=e;if(t.onInstall&&this.pluginHost)try{t.onInstall(this.pluginHost)}catch(t){console.error(`[RendererPlugin] ${e.name} onInstall error:`,t)}let n=t.getDeclaredNamespaces?.();n&&this.pluginHost&&this.pluginHost.registerStateOwner(e.name,n),this.onInvalidate?.()}unregister(e){let t=this.plugins.get(e);if(t){if(this.pluginHost?.clearByOwner(e),t.onUninstall)try{t.onUninstall()}catch(e){console.error(`[RendererPlugin] ${t.name} onUninstall error:`,e)}this.plugins.delete(e),this.enabledState.delete(e),this.cacheInvalid=!0,this.onInvalidate?.()}}clear(){for(let e of this.plugins.values())if(e.onUninstall)try{e.onUninstall()}catch(t){console.error(`[RendererPlugin] ${e.name} onUninstall error:`,t)}this.plugins.clear(),this.enabledState.clear(),this.groupCache.clear(),this.mergedCache.clear(),this.cacheInvalid=!1}mergeSorted(e,t){let n=[],r=0,i=0;for(;r<e.length&&i<t.length;)e[r].priority<=t[i].priority?n.push(e[r++]):n.push(t[i++]);return[...n,...e.slice(r),...t.slice(i)]}rebuildCache(){if(!this.cacheInvalid)return;this.groupCache.clear(),this.mergedCache.clear();for(let e of this.plugins.values()){let t=typeof e.paneId==`symbol`?pa:e.paneId;this.groupCache.has(t)||this.groupCache.set(t,[]),this.groupCache.get(t).push(e)}for(let[,e]of this.groupCache)e.sort((e,t)=>e.priority-t.priority);let e=this.groupCache.get(pa)??[];for(let t of this.knownPaneIds){let n=this.groupCache.get(t)??[],r=this.mergeSorted(n,e);this.mergedCache.set(t,r)}this.mergedCache.set(pa,[...e]),this.cacheInvalid=!1}isRendererEnabled(e){let t=this.enabledState.get(e.name);return t===void 0?e.enabled!==!1:t}getMergedRenderers(e){this.rebuildCache();let t=this.mergedCache.get(e);if(!t){let n=this.groupCache.get(e)??[],r=this.groupCache.get(pa)??[];t=this.mergeSorted(n,r),this.mergedCache.set(e,t)}return t}getRenderers(e){return this.getMergedRenderers(e).filter(e=>e.isSystem?!1:this.isRendererEnabled(e))}render(e,t,n){let r=this.getRenderers(e),i=[];for(let e of r){if(n){let t=e.layer??`main`;if(n===q.Overlay&&t!==`overlay`||n===q.Main&&t===`overlay`)continue}try{e.draw(t)}catch(n){let r=n instanceof Error?n:Error(String(n));console.error(`[RendererPlugin] ${e.name} draw error:`,r),i.push({name:e.name,error:{message:r.message,stack:r.stack},paneId:t.pane.id,timestamp:Date.now()})}}return i}renderPlugin(e,t){let n=this.plugins.get(e);if(!n||!this.isRendererEnabled(n))return[];let r=[];try{n.draw(t)}catch(n){let i=n instanceof Error?n:Error(String(n));console.error(`[RendererPlugin] ${e} draw error:`,i),r.push({name:e,error:{message:i.message,stack:i.stack},paneId:t.pane.id,timestamp:Date.now()})}return r}setEnabled(e,t){this.plugins.has(e)&&(this.enabledState.set(e,t),this.onInvalidate?.())}updateConfig(e,t){let n=this.plugins.get(e);return n?.setConfig?(n.setConfig(t),this.onInvalidate?.(),!0):!1}getAllPlugins(){return Array.from(this.plugins.values())}getPlugin(e){return this.plugins.get(e)}notifyDataUpdate(e,t){for(let n of this.plugins.values())if(n.onDataUpdate&&this.isRendererEnabled(n))try{n.onDataUpdate(e,t)}catch(e){console.error(`[RendererPlugin] ${n.name} onDataUpdate error:`,e)}}notifyResize(e,t){let n=this.getMergedRenderers(e).filter(e=>this.isRendererEnabled(e));for(let e of n)if(e.onResize)try{e.onResize(t)}catch(t){console.error(`[RendererPlugin] ${e.name} onResize error:`,t)}}},ha={PRIMARY:`hsl(210, 9%, 31%)`,SECONDARY:`hsl(210, 9%, 35%)`,TERTIARY:`hsl(210, 8%, 50%)`,WEAK:`hsl(210, 7%, 65%)`,WHITE:`rgba(255, 255, 255, 0.92)`},J={UP:`rgba(214, 10, 34, 1)`,UP_LIGHT:`rgba(214, 10, 34, 0.92)`,UP_TICK:`hsl(0, 60%, 50%)`,DOWN:`rgba(3, 123, 102, 1)`,DOWN_LIGHT:`rgba(3, 123, 102, 0.92)`,DOWN_TICK:`hsl(150, 30%, 60%)`,NEUTRAL:`rgba(0, 0, 0, 0.78)`,LAST_PRICE:`rgba(196, 74, 86, 0.95)`},ga={WHITE:`rgb(255, 255, 255)`,LIGHT_GRAY:`rgba(255, 255, 255, 0.92)`,PURE_WHITE:`#ffffff`,TRANSPARENT:`transparent`,ACTIVE:`#1890ff`,ACTIVE_HOVER:`#40a9ff`,HOVER:`#f0f0f0`},_a={DARK:`rgba(0, 0, 0, 0.12)`,MEDIUM:`rgba(0, 0, 0, 0.10)`,LIGHT:`rgba(0, 0, 0, 0.08)`,SEPARATOR:`rgba(0, 0, 0, 0.10)`,BUTTON:`#d0d0d0`},va={HORIZONTAL:`rgba(0, 0, 0, 0.06)`,VERTICAL:`rgba(0, 0, 0, 0.12)`},ya={MA5:`rgba(255, 193, 37, 1)`,MA10:`rgba(190, 131, 12, 1)`,MA20:`rgba(69, 112, 249, 1)`,MA30:`rgba(76, 175, 80, 1)`,MA60:`rgba(156, 39, 176, 1)`},ba={UPPER:`rgba(178, 34, 34, 1)`,MIDDLE:`rgba(69, 112, 249, 1)`,LOWER:`rgba(34, 139, 34, 1)`,BAND_FILL:`rgba(100, 149, 237, 0.1)`},Y={DIF:`rgba(69, 112, 249, 1)`,DEA:`rgba(255, 152, 0, 1)`,BAR_UP:`#ff5252`,BAR_UP_LIGHT:`#fccbcd`,BAR_DOWN:`#22ab94`,BAR_DOWN_LIGHT:`#ace5dc`},xa={UP:`#ff5252`,DOWN:`#22ab94`,NEUTRAL:`rgba(0, 0, 0, 0.78)`},Sa={RSI1:`rgba(69, 112, 249, 1)`,RSI2:`rgba(255, 152, 0, 1)`,RSI3:`rgba(156, 39, 176, 1)`},Ca={CCI:`rgba(69, 112, 249, 1)`,OVERBOUGHT:`rgba(214, 10, 34, 0.5)`,OVERSOLD:`rgba(3, 123, 102, 0.5)`},wa={K:`rgba(69, 112, 249, 1)`,D:`rgba(255, 152, 0, 1)`,J:`rgba(156, 39, 176, 1)`},Ta={MOM:`rgba(69, 112, 249, 1)`,ZERO:`rgba(0, 0, 0, 0.2)`},Ea={WMSR:`rgba(69, 112, 249, 1)`,OVERBOUGHT:`rgba(214, 10, 34, 0.5)`,OVERSOLD:`rgba(3, 123, 102, 0.5)`},Da={KST:`rgba(69, 112, 249, 1)`,SIGNAL:`rgba(255, 152, 0, 1)`},Oa={FAST:`rgba(255, 152, 0, 1)`,SLOW:`rgba(69, 112, 249, 1)`},ka={UPPER:`rgba(214, 10, 34, 1)`,MIDDLE:`rgba(69, 112, 249, 1)`,LOWER:`rgba(3, 123, 102, 1)`,BAND_FILL:`rgba(69, 112, 249, 0.08)`},Aa={LINE:`rgba(0, 0, 0, 0.28)`,LABEL_BG:`rgb(0, 0, 0)`,LABEL_TEXT:`rgba(255, 255, 255, 0.92)`};function X(e,t){return Math.round(e*t)/t}function Z(e,t){return(Math.floor(e*t)+.5)/t}function ja(e,t,n,r){if(t===n)return null;let i=Math.min(t,n),a=Math.max(t,n),o=Math.round(e*r),s=Math.round(i*r),c=Math.round(a*r);return{x:o/r,y:s/r,width:1/r,height:Math.max(1,c-s)/r}}function Ma(e,t,n,r){if(e===t)return null;let i=Math.min(e,t),a=Math.max(e,t),o=Math.round(i*r),s=Math.round(a*r),c=Math.round(n*r);return{x:o/r,y:c/r,width:Math.max(1,s-o)/r,height:1/r}}function Na(e,t,n,r,i){let a=e+n,o=n,s=Math.round(t*i),c=Math.round((t+r)*i),l=Math.max(1,c-s),u=e+(n-1)/2,d=u,f=o%2==1;return{bodyRect:{x:e/i,y:s/i,width:n/i,height:l/i},physBodyLeft:e,physBodyRight:a,physBodyWidth:o,physBodyCenter:d,physWickX:u,wickRect:{x:u/i,width:1/i},isPerfectlyAligned:f}}var Pa=1.2,Fa=24,Ia=6;function La(e){switch(e){case`arrow_up`:case`flag`:return!0;default:return!1}}function Ra(){return{name:`customMarkers`,version:`1.0.0`,description:`自定义标记渲染器`,debugName:`自定义标记`,paneId:Ji,priority:G.OVERLAY,draw(e){let{ctx:t,pane:n,data:r,range:i,scrollLeft:a,kWidth:o,kLineCenters:s,dpr:c,markerManager:l}=e;if(!l)return;let u=l.getCustomMarkers();if(!u||u.length===0)return;let d=r;if(d.length&&n.role===`price`){t.save(),t.translate(-a,0);for(let e of u){let r=Ba(d,e.timestamp);if(r===-1||r<i.start||r>=i.end)continue;let u=r-i.start;if(u<0||u>=s.length)continue;let f=s[u],p=d[r],m=e.style?.size,h=za(o,m),g=(e.offset?.y??0)<0?!0:(e.offset?.y??0)>0?!1:La(e.shape),_;_=g?n.yAxis.priceToY(p.high)-h/2-4+(e.offset?.y??0):n.yAxis.priceToY(p.low)+h/2+4+(e.offset?.y??0);let v=f+(e.offset?.x??0),y=_,b=v,x=y,S=Math.round(h*c/2)*2/c;Pi(t,e.shape,b,x,S,e.style||{}),e.label&&Li(t,e.label,b,x,S,e.style||{},g),l.setCustomMarkerPosition(e.id,b-a,x,S,e.shape)}t.restore()}}}}function za(e,t){let n=e*Pa;return Math.max(Ia,Math.min(n,t??Fa))}function Ba(e,t){let n=0,r=e.length-1;for(;n<=r;){let i=Math.floor((n+r)/2),a=e[i]?.timestamp;if(a===void 0)break;if(a===t)return i;a<t?n=i+1:r=i-1}return-1}function Va(e){let t=new Intl.DateTimeFormat(`zh-CN`,{timeZone:`Asia/Shanghai`,year:`numeric`,month:`2-digit`,day:`2-digit`}).formatToParts(new Date(e)).reduce((e,t)=>(t.type!==`literal`&&(e[t.type]=t.value),e),{});return`${t.year}-${t.month}-${t.day}`}function Ha(e){let t=new Date(e),n=t.getFullYear(),r=t.getMonth()+1;return r===1?{text:String(n),isYear:!0}:{text:`${r}月`,isYear:!1}}function Ua(e){let t=new Date(e);return t.getFullYear()*12+t.getMonth()}var Wa=Va,Ga=Va,Ka=null,qa=0,Ja=0,Ya=0,Xa=[];function Za(e){if(e.length===0)return[];if(Ka===e&&qa===e.length){let t=e[0]?.timestamp,n=e[e.length-1]?.timestamp;if(t===Ja&&n===Ya)return Xa}let t=[0],n=Ua(e[0].timestamp);for(let r=1;r<e.length;r++){let i=e[r];if(!i)continue;let a=Ua(i.timestamp);a!==n&&(t.push(r),n=a)}return Ka=e,qa=e.length,Ja=e[0]?.timestamp??0,Ya=e[e.length-1]?.timestamp??0,Xa=t,t}var Qa=J.UP,$a=J.DOWN,eo=J.NEUTRAL;function to(e){return e>0?Qa:e<0?$a:eo}function no(e,t=2){let n=Math.abs(e);return n>=1e8?`${(e/1e8).toFixed(t)}亿`:n>=1e4?`${(e/1e4).toFixed(t)}万`:`${Math.round(e)}`}function ro(e,t=2){return`${e>0?`+`:``}${e.toFixed(t)}`}function io(e,t=2){return`${e.toFixed(t)}%`}function ao(e,t=2){return`${e>0?`+`:``}${e.toFixed(t)}%`}function oo(e,t){let n=t?.close??e.open;return to(e.open-n)}function so(e){return to(e.close-e.open)}function co(e){return typeof e.changePercent==`number`?to(e.changePercent):typeof e.changeAmount==`number`?to(e.changeAmount):eo}var lo={class:`kline-tooltip__title`},uo={key:0},fo={class:`kline-tooltip__grid`},po={class:`row`},mo={class:`row`},ho={class:`row`},go={class:`row`},_o={key:0,class:`row`},vo={key:1,class:`row`},yo={key:2,class:`row`},bo={key:3,class:`row`},xo={key:4,class:`row`},So={key:5,class:`row`},Co=(0,f.defineComponent)({__name:`KLineTooltip`,props:{k:{},index:{},data:{},pos:{},useAnchor:{type:Boolean},anchorPlacement:{},setEl:{type:Function}},setup(e){let t=e,n=(0,f.computed)(()=>t.useAnchor===!0),r=(0,f.computed)(()=>t.anchorPlacement===`left-bottom`?`anchor-left-bottom`:`anchor-right-bottom`);function i(e){t.setEl?.(e)}let a=(0,f.computed)(()=>{let e=t.k;if(!e)return eo;let n=t.index;return oo(e,typeof n==`number`&&n>0?t.data[n-1]:void 0)}),o=(0,f.computed)(()=>{let e=t.k;return e?so(e):eo}),s=(0,f.computed)(()=>{let e=t.k;return e?co(e):eo});return(t,c)=>e.k?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:0,ref:i,class:(0,f.normalizeClass)([`kline-tooltip`,[{"use-anchor":n.value},r.value]]),style:(0,f.normalizeStyle)(n.value?void 0:{left:`${e.pos.x}px`,top:`${e.pos.y}px`})},[(0,f.createElementVNode)(`div`,lo,[e.k.stockCode?((0,f.openBlock)(),(0,f.createElementBlock)(`span`,uo,(0,f.toDisplayString)(e.k.stockCode),1)):(0,f.createCommentVNode)(``,!0),(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)((0,f.unref)(Wa)(e.k.timestamp)),1)]),(0,f.createElementVNode)(`div`,fo,[(0,f.createElementVNode)(`div`,po,[c[0]||=(0,f.createElementVNode)(`span`,null,`开`,-1),(0,f.createElementVNode)(`span`,{style:(0,f.normalizeStyle)({color:a.value})},(0,f.toDisplayString)(e.k.open.toFixed(2)),5)]),(0,f.createElementVNode)(`div`,mo,[c[1]||=(0,f.createElementVNode)(`span`,null,`高`,-1),(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)(e.k.high.toFixed(2)),1)]),(0,f.createElementVNode)(`div`,ho,[c[2]||=(0,f.createElementVNode)(`span`,null,`低`,-1),(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)(e.k.low.toFixed(2)),1)]),(0,f.createElementVNode)(`div`,go,[c[3]||=(0,f.createElementVNode)(`span`,null,`收`,-1),(0,f.createElementVNode)(`span`,{style:(0,f.normalizeStyle)({color:o.value})},(0,f.toDisplayString)(e.k.close.toFixed(2)),5)]),typeof e.k.volume==`number`?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,_o,[c[4]||=(0,f.createElementVNode)(`span`,null,`成交量`,-1),(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)((0,f.unref)(no)(e.k.volume)),1)])):(0,f.createCommentVNode)(``,!0),typeof e.k.turnover==`number`?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,vo,[c[5]||=(0,f.createElementVNode)(`span`,null,`成交额`,-1),(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)((0,f.unref)(no)(e.k.turnover)),1)])):(0,f.createCommentVNode)(``,!0),typeof e.k.amplitude==`number`?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,yo,[c[6]||=(0,f.createElementVNode)(`span`,null,`振幅`,-1),(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)(e.k.amplitude)+`%`,1)])):(0,f.createCommentVNode)(``,!0),typeof e.k.changePercent==`number`?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,bo,[c[7]||=(0,f.createElementVNode)(`span`,null,`涨跌幅`,-1),(0,f.createElementVNode)(`span`,{style:(0,f.normalizeStyle)({color:s.value})},(0,f.toDisplayString)((0,f.unref)(ao)(e.k.changePercent)),5)])):(0,f.createCommentVNode)(``,!0),typeof e.k.changeAmount==`number`?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,xo,[c[8]||=(0,f.createElementVNode)(`span`,null,`涨跌额`,-1),(0,f.createElementVNode)(`span`,{style:(0,f.normalizeStyle)({color:s.value})},(0,f.toDisplayString)((0,f.unref)(ro)(e.k.changeAmount)),5)])):(0,f.createCommentVNode)(``,!0),typeof e.k.turnoverRate==`number`?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,So,[c[9]||=(0,f.createElementVNode)(`span`,null,`换手率`,-1),(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)((0,f.unref)(io)(e.k.turnoverRate)),1)])):(0,f.createCommentVNode)(``,!0)])],6)):(0,f.createCommentVNode)(``,!0)}}),wo=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},To=wo(Co,[[`__scopeId`,`data-v-d0fe85e6`]]),Eo={RISE_WITH_VOLUME:`量价齐升`,RISE_WITHOUT_VOLUME:`量缩价升`,FALL_WITH_VOLUME:`量价齐缩`,FALL_WITHOUT_VOLUME:`量升价缩`},Do=class{markers=new Map;hoveredMarkerId=null;lastHoveredId=null;customMarkers=new Map;customMarkerPositions=new Map;clear(){this.markers.clear()}register(e){this.markers.set(e.id,e)}getState(e){return this.hoveredMarkerId===e?`hovered`:`normal`}hitTest(e,t,n=3){for(let r of this.markers.values())if(e>=r.x-n&&e<=r.x+r.width+n&&t>=r.y-n&&t<=r.y+r.height+n)return r;return null}setHover(e){this.hoveredMarkerId=e,this.lastHoveredId=e}validateHoverState(){this.hoveredMarkerId!==null&&!this.markers.has(this.hoveredMarkerId)&&(this.hoveredMarkerId=null)}getHoveredMarker(){return this.hoveredMarkerId===null?null:this.markers.get(this.hoveredMarkerId)||null}getLastHoverId(){return this.lastHoveredId}getAllMarkers(){return Array.from(this.markers.values())}registerCustomMarker(e){this.customMarkers.set(e.id,e)}setCustomMarkers(e){this.clearCustomMarkers();for(let t of e)this.customMarkers.set(t.id,t)}clearCustomMarkers(){this.customMarkers.clear(),this.customMarkerPositions.clear()}getCustomMarkers(){return Array.from(this.customMarkers.values())}setCustomMarkerPosition(e,t,n,r,i){this.customMarkerPositions.set(e,{x:t,y:n,size:r,shape:i})}hitTestCustomMarker(e,t){for(let n of this.customMarkers.values()){let r=this.customMarkerPositions.get(n.id);if(r&&Gi(e,t,r.shape,r.x,r.y,r.size))return n}return null}},Oo={class:`marker-tooltip__title`},ko={key:0,class:`marker-tooltip__content`},Ao=wo((0,f.defineComponent)({__name:`MarkerTooltip`,props:{marker:{},pos:{},useAnchor:{type:Boolean},anchorPlacement:{},setEl:{type:Function}},setup(e){let t=e,n=(0,f.computed)(()=>t.useAnchor===!0),r=(0,f.computed)(()=>t.anchorPlacement===`left-bottom`?`anchor-left-bottom`:`anchor-right-bottom`);function i(e){t.setEl?.(e)}let a=(0,f.computed)(()=>t.marker&&`date`in t.marker),o=(0,f.computed)(()=>{if(!t.marker)return``;if(a.value){let e=t.marker;return e.label?.text||e.shape}let e=t.marker;return Eo[e.markerType]||e.markerType}),s=(0,f.computed)(()=>{if(!t.marker)return{};if(a.value){let e=t.marker;return{日期:e.date,...e.metadata}}return t.marker.metadata}),c=(0,f.computed)(()=>Object.keys(s.value).length>0);function l(e){return typeof e==`number`?e.toFixed(2):String(e)}return(t,a)=>e.marker?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:0,ref:i,class:(0,f.normalizeClass)([`marker-tooltip`,[{"use-anchor":n.value},r.value]]),style:(0,f.normalizeStyle)(n.value?void 0:{left:`${e.pos.x+12}px`,top:`${e.pos.y+12}px`})},[(0,f.createElementVNode)(`div`,Oo,(0,f.toDisplayString)(o.value),1),c.value?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,ko,[((0,f.openBlock)(!0),(0,f.createElementBlock)(f.Fragment,null,(0,f.renderList)(s.value,(e,t)=>((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:t,class:`row`},[(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)(t),1),(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)(l(e)),1)]))),128))])):(0,f.createCommentVNode)(``,!0)],6)):(0,f.createCommentVNode)(``,!0)}}),[[`__scopeId`,`data-v-5574cc25`]]),jo=Symbol(`fullscreen-teleport-target`);function Mo(){let e=(0,f.inject)(jo,null);return(0,f.computed)(()=>e?.value??`body`)}var No={class:`params-header`},Po={class:`header-left`},Fo={class:`params-title`},Io={class:`header-right`},Lo={key:0,class:`indicator-description`},Ro={class:`params-body`},zo={class:`param-header`},Bo={class:`param-label`},Vo={class:`param-label-text`},Ho={key:0,class:`param-range`},Uo={class:`input-wrapper`},Wo=[`disabled`,`onClick`],Go=[`value`,`min`,`max`,`step`,`onInput`],Ko=[`disabled`,`onClick`],qo={key:0,class:`param-description`},Jo={class:`params-footer`},Yo={class:`footer-right`},Xo=wo((0,f.defineComponent)({__name:`IndicatorParams`,props:{visible:{type:Boolean},indicatorId:{},indicatorName:{},indicatorDescription:{},params:{},values:{}},emits:[`close`,`confirm`],setup(e,{emit:t}){let n=e,r=t,i=(0,f.ref)({...n.values}),a=(0,f.ref)(!0),o=Mo();(0,f.watch)(()=>n.values,e=>{i.value={...e}},{deep:!0,immediate:!0}),(0,f.watch)(()=>n.visible,e=>{e&&(i.value={...n.values})});function s(e,t){let n=t.target,r=parseFloat(n.value);isNaN(r)||(i.value[e]=r)}function c(e,t){let n=e.step||1,r=(i.value[e.key]||0)+t*n;e.min!==void 0&&(r=Math.max(e.min,r)),e.max!==void 0&&(r=Math.min(e.max,r)),i.value[e.key]=parseFloat(r.toFixed(10))}function l(){let e={};n.params.forEach(t=>{e[t.key]=t.default??n.values[t.key]??0}),i.value=e}function u(){r(`confirm`,{...i.value})}return(t,n)=>((0,f.openBlock)(),(0,f.createBlock)(f.Teleport,{to:(0,f.unref)(o)},[(0,f.createVNode)(f.Transition,{name:`overlay`},{default:(0,f.withCtx)(()=>[e.visible?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:0,class:`params-overlay`,onClick:n[4]||=e=>t.$emit(`close`)},[(0,f.createVNode)(f.Transition,{name:`modal`},{default:(0,f.withCtx)(()=>[(0,f.createElementVNode)(`div`,{class:`indicator-params`,onClick:n[3]||=(0,f.withModifiers)(()=>{},[`stop`])},[(0,f.createElementVNode)(`div`,No,[(0,f.createElementVNode)(`div`,Po,[(0,f.createElementVNode)(`span`,Fo,(0,f.toDisplayString)(e.indicatorName),1),n[5]||=(0,f.createElementVNode)(`span`,{class:`params-subtitle`},`参数设置`,-1)]),(0,f.createElementVNode)(`div`,Io,[(0,f.createElementVNode)(`button`,{class:(0,f.normalizeClass)([`toggle-desc-btn`,{active:a.value}]),onClick:n[0]||=e=>a.value=!a.value,title:`显示/隐藏说明`},[...n[6]||=[(0,f.createElementVNode)(`svg`,{viewBox:`0 0 1024 1024`},[(0,f.createElementVNode)(`path`,{d:`M512 97.52381c228.912762 0 414.47619 185.563429 414.47619 414.47619s-185.563429 414.47619-414.47619 414.47619S97.52381 740.912762 97.52381 512 283.087238 97.52381 512 97.52381z m0 73.142857C323.486476 170.666667 170.666667 323.486476 170.666667 512s152.81981 341.333333 341.333333 341.333333 341.333333-152.81981 341.333333-341.333333S700.513524 170.666667 512 170.666667z m36.571429 268.190476v292.571428h-73.142858V438.857143h73.142858z m0-121.904762v73.142857h-73.142858v-73.142857h73.142858z`,fill:`currentColor`})],-1)]],2),(0,f.createElementVNode)(`button`,{class:`params-close`,onClick:n[1]||=e=>t.$emit(`close`)},[...n[7]||=[(0,f.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`},[(0,f.createElementVNode)(`path`,{d:`M18 6L6 18M6 6l12 12`})],-1)]])])]),(0,f.createVNode)(f.Transition,{name:`slide`},{default:(0,f.withCtx)(()=>[a.value&&e.indicatorDescription?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,Lo,[(0,f.createElementVNode)(`p`,null,(0,f.toDisplayString)(e.indicatorDescription),1)])):(0,f.createCommentVNode)(``,!0)]),_:1}),(0,f.createElementVNode)(`div`,Ro,[((0,f.openBlock)(!0),(0,f.createElementBlock)(f.Fragment,null,(0,f.renderList)(e.params,e=>((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:e.key,class:(0,f.normalizeClass)([`param-item`,{"has-desc":a.value&&e.description}])},[(0,f.createElementVNode)(`div`,zo,[(0,f.createElementVNode)(`label`,Bo,[(0,f.createElementVNode)(`span`,Vo,(0,f.toDisplayString)(e.label),1),e.min!==void 0||e.max!==void 0?((0,f.openBlock)(),(0,f.createElementBlock)(`span`,Ho,(0,f.toDisplayString)(e.min??`-∞`)+` ~ `+(0,f.toDisplayString)(e.max??`+∞`),1)):(0,f.createCommentVNode)(``,!0)]),(0,f.createElementVNode)(`div`,Uo,[(0,f.createElementVNode)(`button`,{class:`stepper-btn`,disabled:e.min!==void 0&&(i.value[e.key]??0)<=e.min,onClick:t=>c(e,-1)},` − `,8,Wo),e.type===`number`?((0,f.openBlock)(),(0,f.createElementBlock)(`input`,{key:0,type:`number`,class:`param-input`,value:i.value[e.key],min:e.min,max:e.max,step:e.step||1,onInput:t=>s(e.key,t)},null,40,Go)):(0,f.createCommentVNode)(``,!0),(0,f.createElementVNode)(`button`,{class:`stepper-btn`,disabled:e.max!==void 0&&(i.value[e.key]??0)>=e.max,onClick:t=>c(e,1)},` + `,8,Ko)])]),(0,f.createVNode)(f.Transition,{name:`slide`},{default:(0,f.withCtx)(()=>[a.value&&e.description?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,qo,(0,f.toDisplayString)(e.description),1)):(0,f.createCommentVNode)(``,!0)]),_:2},1024)],2))),128))]),(0,f.createElementVNode)(`div`,Jo,[(0,f.createElementVNode)(`button`,{class:`params-btn reset`,onClick:l},[...n[8]||=[(0,f.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`},[(0,f.createElementVNode)(`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}),(0,f.createElementVNode)(`path`,{d:`M3 3v5h5`})],-1),(0,f.createTextVNode)(` 重置 `,-1)]]),(0,f.createElementVNode)(`div`,Yo,[(0,f.createElementVNode)(`button`,{class:`params-btn cancel`,onClick:n[2]||=e=>t.$emit(`close`)},`取消`),(0,f.createElementVNode)(`button`,{class:`params-btn confirm`,onClick:u},[...n[9]||=[(0,f.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.5`},[(0,f.createElementVNode)(`path`,{d:`M20 6L9 17l-5-5`})],-1),(0,f.createTextVNode)(` 确定 `,-1)]])])])])]),_:1})])):(0,f.createCommentVNode)(``,!0)]),_:1})],8,[`to`]))}}),[[`__scopeId`,`data-v-bb1d1eb3`]]),Zo={class:`indicator-selector`},Qo={class:`indicator-scroll-container`},$o={class:`indicator-list`},es={key:0,class:`indicator-divider`,"aria-hidden":`true`},ts=[`draggable`,`onDragstart`,`onDragover`,`onDrop`],ns=[`onMouseenter`],rs={class:`btn-content`},is={key:0,class:`param-hint`},as={key:0,class:`hover-overlay`},os=[`onClick`],ss={key:1,class:`divider`},cs=[`onClick`],ls={class:`indicator-item`},us={class:`menu-section`},ds={class:`menu-items`},fs=[`disabled`,`onClick`],ps={class:`param-hint`},ms={key:0,class:`active-tag`},hs={class:`menu-section`},gs={class:`menu-items`},_s=[`disabled`,`onClick`],vs={class:`param-hint`},ys={key:0,class:`active-tag`},bs=wo((0,f.defineComponent)({__name:`IndicatorSelector`,props:{activeIndicators:{},indicatorParams:{}},emits:[`toggle`,`updateParams`,`reorderSubIndicators`],setup(e,{emit:t}){let n=[{id:`MA`,label:`MA`,name:`均线`,pane:`main`},{id:`VOLUME`,label:`VOL`,name:`成交量`,pane:`sub`,description:`成交量反映市场活跃度,柱状图显示每根K线的交易量。上涨时柱子为红色,下跌时为绿色。`},{id:`BOLL`,label:`BOLL`,name:`布林带`,pane:`main`,description:`布林带由三条轨道线组成,用于判断价格的波动范围和趋势强度。价格触及上轨可能超买,触及下轨可能超卖。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:20,description:`计算移动平均线的周期数,周期越长轨道越平滑`},{key:`multiplier`,label:`倍数`,type:`number`,min:.1,max:5,step:.1,default:2,description:`标准差倍数,决定轨道宽度,通常为 2`}]},{id:`EXPMA`,label:`EXPMA`,name:`指数平滑移动平均线`,pane:`main`,description:`EXPMA 对近期价格给予更高权重,比普通 MA 更敏感。快线上穿慢线为金叉看涨,下穿为死叉看跌。`,params:[{key:`fastPeriod`,label:`快线`,type:`number`,min:2,max:100,step:1,default:12,description:`快线周期,对价格变化更敏感`},{key:`slowPeriod`,label:`慢线`,type:`number`,min:2,max:200,step:1,default:50,description:`慢线周期,用于判断趋势方向`}]},{id:`ENE`,label:`ENE`,name:`轨道线`,pane:`main`,description:`ENE 轨道线由三条轨道组成,价格突破上轨可能超买,突破下轨可能超卖,适合判断震荡行情的买卖点。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:10,description:`计算中轨的周期数`},{key:`deviation`,label:`偏离率`,type:`number`,min:1,max:30,step:.5,default:11,description:`轨道偏离率百分比,决定轨道宽度`}]},{id:`MACD`,label:`MACD`,name:`指数平滑异同移动平均线`,pane:`sub`,description:`MACD 通过快慢均线的交叉判断趋势方向和动量。DIF 上穿 DEA 为金叉看涨,下穿为死叉看跌。`,params:[{key:`fastPeriod`,label:`快线`,type:`number`,min:2,max:50,step:1,default:12,description:`快线 EMA 周期,对价格变化更敏感`},{key:`slowPeriod`,label:`慢线`,type:`number`,min:2,max:100,step:1,default:26,description:`慢线 EMA 周期,用于计算 DIF`},{key:`signalPeriod`,label:`信号`,type:`number`,min:2,max:50,step:1,default:9,description:`DEA 的 EMA 周期,用于生成买卖信号`}]},{id:`RSI`,label:`RSI`,name:`相对强弱指标`,pane:`sub`,description:`RSI 衡量价格变动的速度和幅度,判断超买超卖状态。RSI > 70 超买,RSI < 30 超卖。`,params:[{key:`period1`,label:`周期 1`,type:`number`,min:2,max:100,step:1,default:6,description:`第一条 RSI 周期,通常为 6(快线)`},{key:`period2`,label:`周期 2`,type:`number`,min:2,max:100,step:1,default:12,description:`第二条 RSI 周期,通常为 12(中线)`},{key:`period3`,label:`周期 3`,type:`number`,min:2,max:100,step:1,default:24,description:`第三条 RSI 周期,通常为 24(慢线)`}]},{id:`CCI`,label:`CCI`,name:`顺势指标`,pane:`sub`,description:`CCI 衡量价格与统计平均值的偏离程度。CCI > 100 超买,CCI < -100 超卖,适合捕捉趋势反转。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:14,description:`计算周期,周期越短信号越灵敏`}]},{id:`STOCH`,label:`STOCH`,name:`随机指标`,pane:`sub`,description:`KDJ 随机指标通过比较收盘价与价格区间判断超买超卖。K > 80 超买,K < 20 超卖,K 上穿 D 金叉。`,params:[{key:`n`,label:`K 周期`,type:`number`,min:2,max:100,step:1,default:9,description:`计算 K 值的周期,统计 N 日内价格区间`},{key:`m`,label:`D 周期`,type:`number`,min:1,max:50,step:1,default:3,description:`D 值是 K 的 M 日移动平均,使信号更平滑`}]},{id:`MOM`,label:`MOM`,name:`动量指标`,pane:`sub`,description:`动量指标衡量价格变化的速度,MOM > 0 表示上涨动能,MOM < 0 表示下跌动能。适合判断趋势强度。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:10,description:`与多少日前价格比较,周期越短越灵敏`}]},{id:`WMSR`,label:`WMSR`,name:`威廉指标`,pane:`sub`,description:`威廉指标衡量超买超卖程度,范围为 -100 到 0。WMSR > -20 超买,WMSR < -80 超卖。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:14,description:`回溯周期,统计周期内最高最低价`}]},{id:`KST`,label:`KST`,name:`确然指标`,pane:`sub`,description:`KST 综合多个 ROC 判断长期趋势,KST 上穿信号线看涨,下穿看跌。适合捕捉主要趋势转换。`,params:[{key:`roc1`,label:`ROC1`,type:`number`,min:2,max:100,step:1,default:10,description:`短期变化率周期`},{key:`roc2`,label:`ROC2`,type:`number`,min:2,max:100,step:1,default:15,description:`中短期变化率周期`},{key:`roc3`,label:`ROC3`,type:`number`,min:2,max:100,step:1,default:20,description:`中长期变化率周期`},{key:`roc4`,label:`ROC4`,type:`number`,min:2,max:100,step:1,default:30,description:`长期变化率周期`},{key:`signalPeriod`,label:`信号`,type:`number`,min:2,max:50,step:1,default:9,description:`信号线的 SMA 周期`}]},{id:`FASTK`,label:`FASTK`,name:`快速随机指标`,pane:`sub`,description:`FASTK 是未经过平滑处理的随机指标,比普通 KDJ 更敏感,能更快捕捉价格转折点,但假信号也更多。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:9,description:`计算周期,周期越短越敏感`}]}],r=n.filter(e=>e.pane===`main`),i=n.filter(e=>e.pane===`sub`),a=e,o=t,s=(0,f.ref)(null),c=(0,f.ref)(null),l=(0,f.ref)(!1),u=(0,f.ref)(null),d=(0,f.ref)(null),p=(0,f.ref)(!1),m=(0,f.ref)({left:`0`,bottom:`0`}),h=(0,f.ref)(!1),g=(0,f.ref)(null),_=(0,f.ref)(null),v=Mo(),y=(0,f.computed)(()=>a.activeIndicators?.length?a.activeIndicators.map(e=>n.find(t=>t.id===e)).filter(e=>e!==void 0).sort((e,t)=>e.pane===t.pane?0:e.pane===`main`?-1:1):[]),b=(0,f.computed)(()=>y.value.some(e=>e.pane===`main`)?y.value.find(e=>e.pane===`sub`)?.id??null:null),x=(0,f.computed)(()=>u.value&&n.find(e=>e.id===u.value)||null);function S(e){return a.activeIndicators?.includes(e)??!1}function C(e){if(S(e))return;let t=n.find(t=>t.id===e);t&&(t.pane===`main`&&n.filter(t=>t.pane===`main`&&t.id!==e&&S(t.id)).forEach(e=>o(`toggle`,e.id,!1)),o(`toggle`,e,!0),p.value=!1)}function w(e){o(`toggle`,e,!1)}function T(e){u.value=e,l.value=!0}function E(e){let t=n.find(t=>t.id===e);if(!t?.params)return{};let r={};for(let e of t.params)r[e.key]=e.default??e.min??1;let i=a.indicatorParams?.[e]||{},o={...r};for(let[e,t]of Object.entries(i))typeof t==`number`&&(o[e]=t);return o}function D(e){let t=E(e.id);return e.params?e.params.map(e=>t[e.key]??``).join(`,`):``}function O(e){u.value&&o(`updateParams`,u.value,e),l.value=!1}function k(e){return n.find(t=>t.id===e)?.pane===`sub`}function A(e,t){if(!k(t)){e.preventDefault();return}_.value=t,g.value=null,e.dataTransfer?.setData(`text/plain`,t),e.dataTransfer&&(e.dataTransfer.effectAllowed=`move`)}function j(e,t){!_.value||!k(t)||_.value===t||(g.value=t,e.dataTransfer&&(e.dataTransfer.dropEffect=`move`))}function M(e,t){let n=_.value||e.dataTransfer?.getData(`text/plain`)||``;if(!n||n===t){N();return}if(!k(n)||!k(t)){N();return}let r=y.value.findIndex(e=>e.id===n),i=y.value.findIndex(e=>e.id===t);if(r<0||i<0){N();return}let a=[...y.value.map(e=>e.id)],[s]=a.splice(r,1);if(!s){N();return}a.splice(i,0,s),o(`reorderSubIndicators`,a.filter(e=>k(e))),N()}function N(){g.value=null,_.value=null}function ee(){if(!p.value&&s.value&&!h.value){let e=s.value.getBoundingClientRect(),t=window.innerWidth,n=e.left+e.width/2;n+160>t-8&&(n=t-160-8),n-160<8&&(n=168),m.value={left:`${n}px`,bottom:`${window.innerHeight-e.top+8}px`}}p.value=!p.value}function te(e){let t=c.value&&!c.value.contains(e.target),n=s.value&&!s.value.contains(e.target);t&&n&&(p.value=!1)}function P(){p.value&&=!1}return(0,f.onMounted)(()=>{h.value=typeof CSS<`u`&&CSS.supports(`anchor-name: --kmap-anchor`)&&CSS.supports(`position-anchor: --kmap-anchor`),document.addEventListener(`click`,te),window.addEventListener(`resize`,P)}),(0,f.onUnmounted)(()=>{document.removeEventListener(`click`,te),window.removeEventListener(`resize`,P)}),(e,t)=>((0,f.openBlock)(),(0,f.createElementBlock)(`div`,Zo,[(0,f.createElementVNode)(`div`,Qo,[(0,f.createElementVNode)(`div`,$o,[((0,f.openBlock)(!0),(0,f.createElementBlock)(f.Fragment,null,(0,f.renderList)(y.value,e=>((0,f.openBlock)(),(0,f.createElementBlock)(f.Fragment,{key:e.id},[e.id===b.value?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,es)):(0,f.createCommentVNode)(``,!0),(0,f.createElementVNode)(`div`,{class:(0,f.normalizeClass)([`indicator-item`,{draggable:k(e.id),"drag-over":g.value===e.id,"is-dragging":_.value===e.id}]),draggable:k(e.id),onDragstart:t=>A(t,e.id),onDragover:(0,f.withModifiers)(t=>j(t,e.id),[`prevent`]),onDrop:(0,f.withModifiers)(t=>M(t,e.id),[`prevent`]),onDragend:N},[(0,f.createElementVNode)(`div`,{class:`indicator-btn-wrapper`,onMouseenter:t=>d.value=e.id,onMouseleave:t[0]||=e=>d.value=null},[(0,f.createElementVNode)(`button`,{class:(0,f.normalizeClass)([`indicator-btn`,{active:!0,hovering:d.value===e.id}])},[(0,f.createElementVNode)(`span`,rs,[(0,f.createTextVNode)((0,f.toDisplayString)(e.label)+` `,1),e.params?((0,f.openBlock)(),(0,f.createElementBlock)(`span`,is,` (`+(0,f.toDisplayString)(D(e))+`) `,1)):(0,f.createCommentVNode)(``,!0)]),(0,f.createVNode)(f.Transition,{name:`fade`},{default:(0,f.withCtx)(()=>[d.value===e.id?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,as,[e.params?((0,f.openBlock)(),(0,f.createElementBlock)(`button`,{key:0,class:`action-btn settings-btn`,onClick:(0,f.withModifiers)(t=>T(e.id),[`stop`]),title:`编辑参数`},[...t[2]||=[(0,f.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`currentColor`},[(0,f.createElementVNode)(`path`,{d:`M19.14 12.94c.04-.31.06-.63.06-.94 0-.31-.02-.63-.06-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.04.31-.06.63-.06.94s.02.63.06.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z`})],-1)]],8,os)):(0,f.createCommentVNode)(``,!0),e.params?((0,f.openBlock)(),(0,f.createElementBlock)(`span`,ss)):(0,f.createCommentVNode)(``,!0),(0,f.createElementVNode)(`button`,{class:`action-btn remove-btn`,onClick:(0,f.withModifiers)(t=>w(e.id),[`stop`]),title:`移除指标`},[...t[3]||=[(0,f.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`currentColor`},[(0,f.createElementVNode)(`path`,{d:`M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z`})],-1)]],8,cs)])):(0,f.createCommentVNode)(``,!0)]),_:2},1024)],2)],40,ns)],42,ts)],64))),128)),(0,f.createElementVNode)(`div`,ls,[(0,f.createElementVNode)(`button`,{ref_key:`addBtnRef`,ref:s,class:`add-btn`,onClick:ee,title:`添加指标`},[...t[4]||=[(0,f.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`currentColor`},[(0,f.createElementVNode)(`path`,{d:`M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z`})],-1)]],512)])])]),((0,f.openBlock)(),(0,f.createBlock)(f.Teleport,{to:(0,f.unref)(v)},[(0,f.createVNode)(f.Transition,{name:`slide`},{default:(0,f.withCtx)(()=>[p.value?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:0,class:(0,f.normalizeClass)([`add-menu`,{"use-anchor":h.value}]),ref_key:`addMenuRef`,ref:c,style:(0,f.normalizeStyle)(h.value?void 0:m.value)},[(0,f.createElementVNode)(`div`,us,[t[6]||=(0,f.createElementVNode)(`div`,{class:`menu-title`},`主图指标`,-1),(0,f.createElementVNode)(`div`,ds,[((0,f.openBlock)(!0),(0,f.createElementBlock)(f.Fragment,null,(0,f.renderList)((0,f.unref)(r),e=>((0,f.openBlock)(),(0,f.createElementBlock)(`button`,{key:e.id,class:(0,f.normalizeClass)([`menu-item`,{disabled:S(e.id)}]),disabled:S(e.id),onClick:t=>C(e.id)},[(0,f.createTextVNode)((0,f.toDisplayString)(e.label)+` `,1),(0,f.createElementVNode)(`span`,ps,` (`+(0,f.toDisplayString)(e.name)+`) `,1),S(e.id)?((0,f.openBlock)(),(0,f.createElementBlock)(`span`,ms,[...t[5]||=[(0,f.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`currentColor`},[(0,f.createElementVNode)(`path`,{d:`M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z`})],-1)]])):(0,f.createCommentVNode)(``,!0)],10,fs))),128))])]),(0,f.createElementVNode)(`div`,hs,[t[8]||=(0,f.createElementVNode)(`div`,{class:`menu-title`},`副图指标`,-1),(0,f.createElementVNode)(`div`,gs,[((0,f.openBlock)(!0),(0,f.createElementBlock)(f.Fragment,null,(0,f.renderList)((0,f.unref)(i),e=>((0,f.openBlock)(),(0,f.createElementBlock)(`button`,{key:e.id,class:(0,f.normalizeClass)([`menu-item`,{disabled:S(e.id)}]),disabled:S(e.id),onClick:t=>C(e.id)},[(0,f.createTextVNode)((0,f.toDisplayString)(e.label)+` `,1),(0,f.createElementVNode)(`span`,vs,` (`+(0,f.toDisplayString)(e.name)+`) `,1),S(e.id)?((0,f.openBlock)(),(0,f.createElementBlock)(`span`,ys,[...t[7]||=[(0,f.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`currentColor`},[(0,f.createElementVNode)(`path`,{d:`M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z`})],-1)]])):(0,f.createCommentVNode)(``,!0)],10,_s))),128))])])],6)):(0,f.createCommentVNode)(``,!0)]),_:1})],8,[`to`])),x.value?((0,f.openBlock)(),(0,f.createBlock)(Xo,{key:0,visible:l.value,"indicator-id":x.value.id,"indicator-name":x.value.name,"indicator-description":x.value.description,params:x.value.params||[],values:E(x.value.id),onClose:t[1]||=e=>l.value=!1,onConfirm:O},null,8,[`visible`,`indicator-id`,`indicator-name`,`indicator-description`,`params`,`values`])):(0,f.createCommentVNode)(``,!0)]))}}),[[`__scopeId`,`data-v-f3fbebbd`]]),xs={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Ss(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,xs,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 7h16m-10 4v6m4-6v6M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2l1-12M9 7V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v3`},null,-1)]])}var Cs=(0,f.markRaw)({name:`tabler-trash`,render:Ss}),ws={class:`toolbar-item color-item`,title:`颜色`},Ts=[`value`],Es=[`value`],Ds=[`value`],Os=wo((0,f.defineComponent)({__name:`DrawingStyleToolbar`,props:{drawing:{}},emits:[`updateStyle`,`delete`],setup(e,{emit:t}){let n=t;function r(e){e.key===`Delete`&&(e.preventDefault(),n(`delete`))}(0,f.onMounted)(()=>document.addEventListener(`keydown`,r)),(0,f.onUnmounted)(()=>document.removeEventListener(`keydown`,r));function i(e){n(`updateStyle`,{stroke:e})}function a(e){n(`updateStyle`,{strokeWidth:e})}function o(e){n(`updateStyle`,{strokeStyle:e})}return(t,n)=>((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{class:`drawing-style-toolbar`,onPointerdown:n[4]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointermove:n[5]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointerup:n[6]||=(0,f.withModifiers)(()=>{},[`stop`])},[(0,f.createElementVNode)(`div`,ws,[(0,f.createElementVNode)(`span`,{class:`color-swatch`,style:(0,f.normalizeStyle)({background:e.drawing.style.stroke??`#2962ff`})},null,4),(0,f.createElementVNode)(`input`,{type:`color`,class:`color-input`,value:e.drawing.style.stroke??`#2962ff`,onInput:n[0]||=e=>i(e.target.value)},null,40,Ts)]),(0,f.createElementVNode)(`select`,{class:`toolbar-select`,value:e.drawing.style.strokeWidth??1,onChange:n[1]||=e=>a(Number(e.target.value)),title:`线宽`},[...n[7]||=[(0,f.createElementVNode)(`option`,{value:1},`1px`,-1),(0,f.createElementVNode)(`option`,{value:2},`2px`,-1),(0,f.createElementVNode)(`option`,{value:3},`3px`,-1),(0,f.createElementVNode)(`option`,{value:4},`4px`,-1)]],40,Es),(0,f.createElementVNode)(`select`,{class:`toolbar-select`,value:e.drawing.style.strokeStyle??`solid`,onChange:n[2]||=e=>o(e.target.value),title:`线型`},[...n[8]||=[(0,f.createElementVNode)(`option`,{value:`solid`},`实线`,-1),(0,f.createElementVNode)(`option`,{value:`dashed`},`虚线`,-1),(0,f.createElementVNode)(`option`,{value:`dotted`},`点线`,-1)]],40,Ds),(0,f.createElementVNode)(`button`,{type:`button`,class:`toolbar-btn delete-btn`,title:`删除`,onClick:n[3]||=e=>t.$emit(`delete`)},[(0,f.createVNode)((0,f.unref)(Cs),{class:`delete-icon`,"aria-hidden":`true`})])],32))}}),[[`__scopeId`,`data-v-92699cb2`]]),ks=class{chart;isDragging=!1;dragMode=`none`;dragStartX=0;scrollStartX=0;applyPanScroll(e,t){let n=Math.max(0,e.scrollWidth-e.clientWidth),r=Math.min(Math.max(0,t),n),i=this.chart.getCurrentDpr();e.scrollLeft=Math.round(r*i)/i}dragStartY=0;activePaneIdOnDrag=null;activeSeparatorUpperPaneId=null;hoveredSeparatorUpperPaneId=null;hoveredRightAxisPaneId=null;isTouchSession=!1;activePointers=new Map;lastPinchDistance=0;pinchCenter={x:0,y:0};isPinching=!1;onPinchZoomCallback;crosshairPos=null;crosshairIndex=null;crosshairPrice=null;hoveredIndex=null;activePaneId=null;tooltipPos={x:0,y:0};tooltipSize={width:220,height:180};tooltipAnchorPlacement=`right-bottom`;useTooltipAnchorPositioning=!1;onInteractionChangeCallback;settings={};hoveredMarkerId=null;clickedMarkerId=null;hoveredMarkerData=null;clickedMarkerData=null;onMarkerHoverCallback;onMarkerClickCallback;hoveredCustomMarker=null;onCustomMarkerHoverCallback;onCustomMarkerClickCallback;kLinePositions=null;visibleRange=null;lastHoverRenderKey=``;kWidthPx=null;constructor(e){this.chart=e}setOnPinchZoom(e){this.onPinchZoomCallback=e}updateSettings(e){let t=this.settings.disableMainPaneVerticalScroll;this.settings={...e},!t&&this.settings.disableMainPaneVerticalScroll&&this.chart.resetPriceOffset(`main`)}getInteractionSnapshot(){return{crosshairPos:this.crosshairPos?{...this.crosshairPos}:null,crosshairIndex:this.crosshairIndex,crosshairPrice:this.crosshairPrice,hoveredIndex:this.hoveredIndex,activePaneId:this.activePaneId,tooltipPos:{...this.tooltipPos},tooltipAnchorPlacement:this.tooltipAnchorPlacement,hoveredMarkerData:this.hoveredMarkerData,hoveredCustomMarker:this.hoveredCustomMarker,isDragging:this.isDragging,isResizingPaneBoundary:this.dragMode===`resize-separator`,isHoveringPaneBoundary:this.hoveredSeparatorUpperPaneId!==null,hoveredPaneBoundaryId:this.hoveredSeparatorUpperPaneId,isHoveringRightAxis:this.hoveredRightAxisPaneId!==null}}setOnInteractionChange(e){this.onInteractionChangeCallback=e}notifyInteractionChange(){this.onInteractionChangeCallback?.(this.getInteractionSnapshot())}getHoverRenderKey(){let e=this.crosshairPos?Math.round(this.crosshairPos.x*this.chart.getCurrentDpr()):`n`,t=this.crosshairPos?Math.round(this.crosshairPos.y*this.chart.getCurrentDpr()):`n`;return[this.crosshairIndex??`n`,this.hoveredIndex??`n`,this.activePaneId??`n`,this.hoveredRightAxisPaneId??`n`,this.hoveredSeparatorUpperPaneId??`n`,this.hoveredMarkerId??`n`,this.hoveredCustomMarker?.id??`n`,e,t].join(`|`)}onPointerDown(e){if(this.isTouchSession=e.pointerType===`touch`,this.activePointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this.activePointers.size===2&&this.isTouchSession){this.isPinching=!0,this.isDragging=!1,this.dragMode=`none`;let e=Array.from(this.activePointers.values()),t=e[0],n=e[1];this.lastPinchDistance=Math.hypot(n.x-t.x,n.y-t.y),this.pinchCenter={x:(t.x+n.x)/2,y:(t.y+n.y)/2};return}if(e.isPrimary===!1||this.isPinching||this.activePointers.size>1)return;let t=this.getPlotPointerLocation(e.clientX,e.clientY);if(!t)return;let{mouseX:n,mouseY:r}=t,i=this.chart.getCachedScrollLeft(),a=this.chart.getMarkerManager(),o=i+n,s=a.hitTest(o,r,3);if(s){this.clickedMarkerId=s.id,this.clickedMarkerData=s,this.onMarkerClickCallback&&this.onMarkerClickCallback(s);return}let c=this.hitTestPaneSeparator(r);if(c){this.isDragging=!0,this.dragMode=`resize-separator`,this.dragStartY=e.clientY,this.activeSeparatorUpperPaneId=c,this.hoveredSeparatorUpperPaneId=c,this.clearHover(),this.chart.scheduleDraw();return}let l=this.getPaneByY(r);this.isDragging=!0,this.dragMode=`pan`,this.updatePlotHoverFromPoint(e.clientX,e.clientY),this.dragStartX=e.clientX,this.dragStartY=e.clientY,this.scrollStartX=this.chart.getCachedScrollLeft(),this.activePaneIdOnDrag=l?.id||null,this.chart.scheduleDraw()}setTooltipSize(e){this.tooltipSize=e}setTooltipAnchorPositioning(e){this.useTooltipAnchorPositioning=e}onPointerUp(e){this.activePointers.delete(e.pointerId),this.isPinching&&this.activePointers.size<2&&(this.isPinching=!1,this.lastPinchDistance=0),e.isPrimary!==!1&&(this.isDragging=!1,this.dragMode=`none`,this.activePaneIdOnDrag=null,this.activeSeparatorUpperPaneId=null,this.notifyInteractionChange())}onPointerLeave(e){this.activePointers.delete(e.pointerId),this.activePointers.size<2&&(this.isPinching=!1,this.lastPinchDistance=0),e.isPrimary!==!1&&(this.isDragging=!1,this.dragMode=`none`,this.activePaneIdOnDrag=null,this.clearSeparatorState(),this.isTouchSession=!1,this.clearHover(),this.chart.scheduleDraw(),this.notifyInteractionChange())}onScroll(){this.kLinePositions=null,this.visibleRange=null,this.clearHover(),this.chart.scheduleDraw(),this.notifyInteractionChange()}onPointerMove(e){if(this.activePointers.has(e.pointerId)&&this.activePointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this.isPinching&&this.activePointers.size===2){let e=Array.from(this.activePointers.values()),t=e[0],n=e[1],r=Math.hypot(n.x-t.x,n.y-t.y),i=r-this.lastPinchDistance;if(Math.abs(i)>10){let e=i>0?1:-1,a=(t.x+n.x)/2;this.onPinchZoomCallback?.(e,a),this.lastPinchDistance=r}return}if(!e.isPrimary)return;e.pointerType===`touch`&&(this.isTouchSession=!0);let t=this.chart.getDom().container;if(this.isDragging){if(this.dragMode===`resize-separator`){let t=e.clientY-this.dragStartY;t!==0&&this.activeSeparatorUpperPaneId&&this.chart.resizePaneBoundary(this.activeSeparatorUpperPaneId,t)&&(this.dragStartY=e.clientY);return}if(this.dragMode===`scale-price`){let t=e.clientY-this.dragStartY;t!==0&&this.activePaneIdOnDrag&&(this.chart.scalePrice(this.activePaneIdOnDrag,t),this.dragStartY=e.clientY);return}if(this.dragMode===`pan`){let n=this.dragStartX-e.clientX;this.applyPanScroll(t,this.scrollStartX+n);let r=e.clientY-this.dragStartY;this.dragStartY=e.clientY,r!==0&&this.activePaneIdOnDrag===`main`&&(this.settings.disableMainPaneVerticalScroll||this.chart.translatePrice(this.activePaneIdOnDrag,r))}return}let n=this.getPlotPointerLocation(e.clientX,e.clientY);if(!n)return;this.hoveredSeparatorUpperPaneId=this.hitTestPaneSeparator(n.mouseY),this.updatePlotHoverFromPoint(e.clientX,e.clientY);let r=this.getHoverRenderKey();r!==this.lastHoverRenderKey&&(this.lastHoverRenderKey=r,this.chart.scheduleDraw(q.Overlay)),this.notifyInteractionChange()}setKLinePositions(e,t,n){this.kLinePositions=e,this.visibleRange=t,n!==void 0&&(this.kWidthPx=n)}onRightAxisPointerDown(e){if(e.isPrimary===!1)return;this.isTouchSession=e.pointerType===`touch`;let t=this.getRightAxisPointerLocation(e.clientX,e.clientY);t&&this.beginScalePriceDrag(e.clientY,t.mouseY)&&(this.chart.scheduleDraw(),this.notifyInteractionChange())}onRightAxisPointerMove(e){if(!e.isPrimary)return;if(e.pointerType===`touch`&&(this.isTouchSession=!0),this.isDragging&&this.dragMode===`scale-price`){let t=e.clientY-this.dragStartY;t!==0&&this.activePaneIdOnDrag&&(this.chart.scalePrice(this.activePaneIdOnDrag,t),this.dragStartY=e.clientY);return}this.updateRightAxisHoverFromPoint(e.clientX,e.clientY);let t=this.getHoverRenderKey();t!==this.lastHoverRenderKey&&(this.lastHoverRenderKey=t,this.chart.scheduleDraw(q.Overlay)),this.notifyInteractionChange()}onRightAxisPointerUp(e){this.onPointerUp(e)}onRightAxisPointerLeave(e){e.isPrimary!==!1&&(this.isDragging&&this.dragMode===`scale-price`||(this.hoveredRightAxisPaneId=null,this.notifyInteractionChange()))}isDraggingState(){return this.isDragging}setOnMarkerHover(e){this.onMarkerHoverCallback=e}setOnMarkerClick(e){this.onMarkerClickCallback=e}setOnCustomMarkerHover(e){this.onCustomMarkerHoverCallback=e}setOnCustomMarkerClick(e){this.onCustomMarkerClickCallback=e}hitTestPaneSeparator(e){let t=this.chart.getPaneRenderers();if(t.length<2)return null;for(let n=0;n<t.length-1;n++){let r=t[n]?.getPane(),i=t[n+1]?.getPane();if(!r||!i)continue;let a=r.top+r.height;if(Math.abs(e-a)<=5)return r.id}return null}getPaneByY(e){return this.chart.getPaneRenderers().find(t=>{let n=t.getPane();return e>=n.top&&e<=n.top+n.height})?.getPane()||null}getPlotPointerLocation(e,t){let n=this.chart.getDom().container.getBoundingClientRect();return{mouseX:e-n.left,mouseY:t-n.top}}getRightAxisPointerLocation(e,t){let n=this.chart.getDom().rightAxisLayer.getBoundingClientRect();return{mouseX:e-n.left,mouseY:t-n.top}}beginScalePriceDrag(e,t){let n=this.getPaneByY(t);return!n||n.id===`main`&&this.settings.disableMainPaneVerticalScroll?!1:(this.isDragging=!0,this.dragMode=`scale-price`,this.dragStartY=e,this.activePaneIdOnDrag=n.id,this.hoveredRightAxisPaneId=n.id,this.hoveredSeparatorUpperPaneId=null,this.crosshairPos=null,this.crosshairIndex=null,this.crosshairPrice=null,this.hoveredIndex=null,this.activePaneId=n.id,!0)}clearHover(){this.lastHoverRenderKey=``,this.hoveredRightAxisPaneId=null,this.crosshairPos=null,this.crosshairIndex=null,this.crosshairPrice=null,this.hoveredIndex=null,this.activePaneId=null,this.hoveredMarkerId===null?this.hoveredMarkerData=null:(this.hoveredMarkerId=null,this.hoveredMarkerData=null,this.chart.getMarkerManager().setHover(null),this.onMarkerHoverCallback&&this.onMarkerHoverCallback(null)),this.hoveredCustomMarker!==null&&(this.hoveredCustomMarker=null,this.onCustomMarkerHoverCallback&&this.onCustomMarkerHoverCallback(null))}clearSeparatorState(){this.activeSeparatorUpperPaneId=null,this.hoveredSeparatorUpperPaneId=null,this.hoveredRightAxisPaneId=null}updateRightAxisHoverFromPoint(e,t){let n=this.getRightAxisPointerLocation(e,t);if(!n)return;let{mouseY:r}=n,i=this.chart.getViewport()?.plotHeight??Math.max(1,Math.round(this.chart.getDom().container.clientHeight));if(r<0||r>i){this.hoveredRightAxisPaneId=null;return}let a=this.getPaneByY(r);this.hoveredRightAxisPaneId=a?.id||null,this.hoveredSeparatorUpperPaneId=null,this.crosshairPos=null,this.crosshairIndex=null,this.crosshairPrice=null,this.hoveredIndex=null,this.activePaneId=a?.id||null}updatePlotHoverFromPoint(e,t){let n=this.getPlotPointerLocation(e,t);if(!n)return;let{mouseX:r,mouseY:i}=n,a=this.chart.getDom().container,o=this.chart.getViewport(),s=o?.viewWidth??Math.max(1,Math.round(a.clientWidth)),c=o?.viewHeight??Math.max(1,Math.round(a.clientHeight)),l=o?.plotWidth??s,u=o?.plotHeight??c;if(r<0||i<0||r>l||i>u){this.clearHover();return}this.hoveredRightAxisPaneId=null;let d=this.chart.getCachedScrollLeft(),f=this.chart.getCurrentDpr(),p=this.hitTestPaneSeparator(i);if(this.hoveredSeparatorUpperPaneId=p,p){this.clearHover();return}let m=this.chart.getMarkerManager(),h=d+r,g=m.hitTest(h,i,3);if(g){this.hoveredMarkerId!==g.id&&(this.hoveredMarkerId=g.id,this.hoveredMarkerData=g,m.setHover(g.id),this.onMarkerHoverCallback&&this.onMarkerHoverCallback(g)),this.hoveredCustomMarker!==null&&(this.hoveredCustomMarker=null,this.onCustomMarkerHoverCallback&&this.onCustomMarkerHoverCallback(null)),this.crosshairPos=null,this.crosshairIndex=null,this.crosshairPrice=null,this.hoveredIndex=null;return}else this.hoveredMarkerId!==null&&(this.hoveredMarkerId=null,this.hoveredMarkerData=null,m.setHover(null),this.onMarkerHoverCallback&&this.onMarkerHoverCallback(null));let _=m.hitTestCustomMarker(r,i);if(_){this.hoveredCustomMarker?.id!==_.id&&(this.hoveredCustomMarker=_,this.onCustomMarkerHoverCallback&&this.onCustomMarkerHoverCallback(_)),this.hoveredMarkerId!==null&&(this.hoveredMarkerId=null,this.hoveredMarkerData=null,m.setHover(null),this.onMarkerHoverCallback&&this.onMarkerHoverCallback(null)),this.crosshairPos=null,this.crosshairIndex=null,this.crosshairPrice=null,this.hoveredIndex=null;return}else this.hoveredCustomMarker!==null&&(this.hoveredCustomMarker=null,this.onCustomMarkerHoverCallback&&this.onCustomMarkerHoverCallback(null));if(!this.kLinePositions||!this.visibleRange||!this.kWidthPx){this.clearHover();return}let v=this.kWidthPx/f,y=0,b=this.kLinePositions.length;for(;y<b;){let e=y+b>>1;this.kLinePositions[e]<h?y=e+1:b=e}let x=y;if(y>0&&y<this.kLinePositions.length){let e=this.kLinePositions[y-1]+v/2,t=this.kLinePositions[y]+v/2;Math.abs(h-e)<Math.abs(h-t)&&(x=y-1)}else y===this.kLinePositions.length&&this.kLinePositions.length>0&&(x=this.kLinePositions.length-1);let S=x+this.visibleRange.start,C=this.chart.getData(),w=this.getPaneByY(i);if(this.activePaneId=w?.id||null,S>=0&&S<(C?.length??0)){this.crosshairIndex=S;let e=this.kLinePositions[x],t=(Math.round(e*f)+(this.kWidthPx-1)/2)/f-d;if(this.crosshairPos={x:Math.min(Math.max(t,0),l),y:Math.min(Math.max(i,0),u)},w){let e=i-w.top;this.crosshairPrice=w.yAxis.yToPrice(e)}else this.crosshairPrice=null}else this.crosshairIndex=null,this.crosshairPos=null,this.crosshairPrice=null;let T=typeof this.crosshairIndex==`number`?C[this.crosshairIndex]:void 0;if(!T||!w||!w.capabilities.candleHitTest){this.hoveredIndex=null;return}let E=i-w.top,D=w.yAxis.priceToY(T.open),O=w.yAxis.priceToY(T.close),k=w.yAxis.priceToY(T.high),A=w.yAxis.priceToY(T.low),j=Math.min(D,O),M=Math.max(D,O),N=h-this.kLinePositions[x],ee=v/2,te=Math.abs(M-j),P=te<8?(j+M)/2-8/2:j,ne=te<8?(j+M)/2+8/2:M,re=E>=P&&E<=ne&&N>=0&&N<=v,ie=Math.abs(N-ee)<=3&&E>=Math.min(k,A)&&E<=Math.max(k,A);if(!re&&!ie){this.hoveredIndex=null;return}if(this.hoveredIndex=this.crosshairIndex,this.useTooltipAnchorPositioning){let e=this.tooltipSize.width,t=r+14+e+12>l;this.tooltipAnchorPlacement=t?`left-bottom`:`right-bottom`,this.tooltipPos={x:Math.min(Math.max(r,12),Math.max(12,l-12)),y:Math.min(Math.max(i,12),Math.max(12,u-12))};return}let ae=this.tooltipSize.width,oe=this.tooltipSize.height,se=r+14,ce=r-14-ae,le=se+ae+12<=s?se:ce,ue=i+14,de=Math.max(12,s-ae-12),fe=Math.max(12,c-oe-12);this.tooltipPos={x:Math.min(Math.max(le,12),de),y:Math.min(Math.max(ue,12),fe)}}reset(){this.isDragging=!1,this.dragMode=`none`,this.dragStartX=0,this.dragStartY=0,this.scrollStartX=0,this.activePaneIdOnDrag=null,this.clearSeparatorState(),this.isTouchSession=!1,this.activePointers.clear(),this.isPinching=!1,this.lastPinchDistance=0,this.crosshairPos=null,this.crosshairIndex=null,this.crosshairPrice=null,this.hoveredIndex=null,this.activePaneId=null,this.hoveredMarkerId=null,this.clickedMarkerId=null,this.hoveredMarkerData=null,this.clickedMarkerData=null,this.hoveredCustomMarker=null,this.kLinePositions=null,this.visibleRange=null,this.lastHoverRenderKey=``,this.kWidthPx=null}getCrosshairIndex(){return this.crosshairIndex}},As=`#version 300 es
17
17
  precision mediump float;
18
18
 
19
19
  in vec2 a_unit;
@@ -35,7 +35,7 @@ void main() {
35
35
  );
36
36
 
37
37
  gl_Position = vec4(clip, 0.0, 1.0);
38
- }`,Es=`#version 300 es
38
+ }`,js=`#version 300 es
39
39
  precision mediump float;
40
40
 
41
41
  in vec2 a_position;
@@ -52,7 +52,7 @@ void main() {
52
52
  );
53
53
 
54
54
  gl_Position = vec4(clip, 0.0, 1.0);
55
- }`,Ds=`#version 300 es
55
+ }`,Ms=`#version 300 es
56
56
  precision mediump float;
57
57
 
58
58
  uniform vec4 u_color;
@@ -60,4 +60,4 @@ out vec4 outColor;
60
60
 
61
61
  void main() {
62
62
  outColor = u_color;
63
- }`,Os=new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),ks=class{canvas;handles=null;logicalWidth=0;logicalHeight=0;available=!1;constructor(e){this.canvas=e??document.createElement(`canvas`),this.handles=this.initRectHandles(),this.available=this.handles!==null}isAvailable(){return this.available}getCanvas(){return this.canvas}resize(e,t,n){this.logicalWidth=e,this.logicalHeight=t;let r=Math.max(1,Math.round(e*n)),i=Math.max(1,Math.round(t*n));this.canvas.width!==r&&(this.canvas.width=r),this.canvas.height!==i&&(this.canvas.height=i)}clear(){let e=this.handles?.gl;!e||this.logicalWidth<=0||this.logicalHeight<=0||(e.viewport(0,0,this.canvas.width,this.canvas.height),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT))}drawRects(e,t,n){let r=this.handles;if(!r||!e.length||this.logicalWidth<=0||this.logicalHeight<=0)return!1;let i=Ps(t);if(!i)return!1;let a=new Float32Array(e.length*4);for(let t=0;t<e.length;t++){let n=e[t],r=t*4;a[r]=n.x,a[r+1]=n.y,a[r+2]=n.width,a[r+3]=n.height}let{gl:o}=r;return o.viewport(0,0,this.canvas.width,this.canvas.height),o.useProgram(r.program),o.bindVertexArray(r.vao),o.bindBuffer(o.ARRAY_BUFFER,r.rectBuffer),o.bufferData(o.ARRAY_BUFFER,a,o.DYNAMIC_DRAW),o.uniform2f(r.resolutionLocation,this.logicalWidth,this.logicalHeight),o.uniform1f(r.scrollXLocation,n),o.uniform4f(r.colorLocation,i[0],i[1],i[2],i[3]),o.drawArraysInstanced(o.TRIANGLES,0,6,e.length),o.bindVertexArray(null),o.flush(),!0}destroy(){let e=this.handles;if(!e)return;let{gl:t,program:n,vao:r,unitBuffer:i,rectBuffer:a}=e;t.deleteBuffer(i),t.deleteBuffer(a),t.deleteVertexArray(r),t.deleteProgram(n),this.handles=null,this.available=!1}initRectHandles(){let e=null;try{e=this.canvas.getContext(`webgl2`,{alpha:!0,antialias:!1,depth:!1,stencil:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1})}catch{e=null}if(!e)return null;let t=Ms(e,e.VERTEX_SHADER,Ts),n=Ms(e,e.FRAGMENT_SHADER,Ds);if(!t||!n)return t&&e.deleteShader(t),n&&e.deleteShader(n),null;let r=Ns(e,t,n);if(e.deleteShader(t),e.deleteShader(n),!r)return null;let i=e.createVertexArray(),a=e.createBuffer(),o=e.createBuffer();if(!i||!a||!o)return i&&e.deleteVertexArray(i),a&&e.deleteBuffer(a),o&&e.deleteBuffer(o),e.deleteProgram(r),null;let s=e.getUniformLocation(r,`u_resolution`),c=e.getUniformLocation(r,`u_scrollX`),l=e.getUniformLocation(r,`u_color`);if(!s||!c||!l)return e.deleteBuffer(a),e.deleteBuffer(o),e.deleteVertexArray(i),e.deleteProgram(r),null;let u=e.getAttribLocation(r,`a_unit`),d=e.getAttribLocation(r,`a_rect`);return u<0||d<0?(e.deleteBuffer(a),e.deleteBuffer(o),e.deleteVertexArray(i),e.deleteProgram(r),null):(e.bindVertexArray(i),e.bindBuffer(e.ARRAY_BUFFER,a),e.bufferData(e.ARRAY_BUFFER,Os,e.STATIC_DRAW),e.enableVertexAttribArray(u),e.vertexAttribPointer(u,2,e.FLOAT,!1,0,0),e.vertexAttribDivisor(u,0),e.bindBuffer(e.ARRAY_BUFFER,o),e.enableVertexAttribArray(d),e.vertexAttribPointer(d,4,e.FLOAT,!1,16,0),e.vertexAttribDivisor(d,1),e.bindVertexArray(null),e.enable(e.BLEND),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA),{gl:e,program:r,vao:i,unitBuffer:a,rectBuffer:o,resolutionLocation:s,scrollXLocation:c,colorLocation:l})}},As=class{canvas;handles=null;logicalWidth=0;logicalHeight=0;dpr=1;available=!1;constructor(e){this.canvas=e??document.createElement(`canvas`),this.handles=this.initLineHandles(),this.available=this.handles!==null}isAvailable(){return this.available}getCanvas(){return this.canvas}resize(e,t,n){this.logicalWidth=e,this.logicalHeight=t,this.dpr=n;let r=Math.max(1,Math.round(e*n)),i=Math.max(1,Math.round(t*n));this.canvas.width!==r&&(this.canvas.width=r),this.canvas.height!==i&&(this.canvas.height=i)}clear(){let e=this.handles?.gl;!e||this.logicalWidth<=0||this.logicalHeight<=0||(e.viewport(0,0,this.canvas.width,this.canvas.height),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT))}drawLineStrip(e,t,n){let r=this.handles;if(!r||e.points.length<2||this.logicalWidth<=0||this.logicalHeight<=0)return!1;let i=Ps(t);if(!i)return!1;let a=js(e.points,e.width*this.dpr/2);if(!a)return!1;let{gl:o}=r;return o.viewport(0,0,this.canvas.width,this.canvas.height),o.useProgram(r.program),o.bindVertexArray(r.vao),o.bindBuffer(o.ARRAY_BUFFER,r.vertexBuffer),o.bufferData(o.ARRAY_BUFFER,a.vertices,o.DYNAMIC_DRAW),o.uniform2f(r.resolutionLocation,this.logicalWidth,this.logicalHeight),o.uniform1f(r.scrollXLocation,n),o.uniform4f(r.colorLocation,i[0],i[1],i[2],i[3]),o.drawArrays(o.TRIANGLES,0,a.vertexCount),o.bindVertexArray(null),o.flush(),!0}destroy(){let e=this.handles;if(!e)return;let{gl:t,program:n,vao:r,vertexBuffer:i}=e;t.deleteBuffer(i),t.deleteVertexArray(r),t.deleteProgram(n),this.handles=null,this.available=!1}initLineHandles(){let e=null;try{e=this.canvas.getContext(`webgl2`,{alpha:!0,antialias:!0,depth:!1,stencil:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1})}catch{e=null}if(!e)return null;let t=Ms(e,e.VERTEX_SHADER,Es),n=Ms(e,e.FRAGMENT_SHADER,Ds);if(!t||!n)return t&&e.deleteShader(t),n&&e.deleteShader(n),null;let r=Ns(e,t,n);if(e.deleteShader(t),e.deleteShader(n),!r)return null;let i=e.createVertexArray(),a=e.createBuffer();if(!i||!a)return i&&e.deleteVertexArray(i),a&&e.deleteBuffer(a),e.deleteProgram(r),null;let o=e.getUniformLocation(r,`u_resolution`),s=e.getUniformLocation(r,`u_scrollX`),c=e.getUniformLocation(r,`u_color`);if(!o||!s||!c)return e.deleteBuffer(a),e.deleteVertexArray(i),e.deleteProgram(r),null;let l=e.getAttribLocation(r,`a_position`);return l<0?(e.deleteBuffer(a),e.deleteVertexArray(i),e.deleteProgram(r),null):(e.bindVertexArray(i),e.bindBuffer(e.ARRAY_BUFFER,a),e.enableVertexAttribArray(l),e.vertexAttribPointer(l,2,e.FLOAT,!1,0,0),e.bindVertexArray(null),e.enable(e.BLEND),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA),{gl:e,program:r,vao:i,vertexBuffer:a,resolutionLocation:o,scrollXLocation:s,colorLocation:c})}};function js(e,t){if(e.length<2)return null;let n=Array(e.length-1);for(let t=0;t<e.length-1;t++){let r=e[t],i=e[t+1],a=i.x-r.x,o=i.y-r.y,s=Math.hypot(a,o);if(s<=0){n[t]=null;continue}n[t]={x:-o/s,y:a/s}}let r=[],i=[];for(let a=0;a<e.length;a++){let o=e[a],s=a>0?n[a-1]:null,c=a<e.length-1?n[a]:null;if(!s&&!c)continue;let l=0,u=0;if(s&&c){l=s.x+c.x,u=s.y+c.y;let e=Math.hypot(l,u);if(e>1e-6){l/=e,u/=e;let t=l*c.x+u*c.y,n=Math.max(.2,Math.abs(t));l*=1/n,u*=1/n}else l=c.x,u=c.y}else{let e=s??c;l=e.x,u=e.y}r.push({x:o.x+l*t,y:o.y+u*t}),i.push({x:o.x-l*t,y:o.y-u*t})}if(r.length<2||i.length<2)return null;let a=[];for(let e=0;e<r.length-1;e++){let t=r[e],n=i[e],o=r[e+1],s=i[e+1];a.push(t.x,t.y,n.x,n.y,o.x,o.y,o.x,o.y,n.x,n.y,s.x,s.y)}return a.length===0?null:{vertices:new Float32Array(a),vertexCount:a.length/2}}function Ms(e,t,n){let r=e.createShader(t);return r?(e.shaderSource(r,n),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS)?r:(e.deleteShader(r),null)):null}function Ns(e,t,n){let r=e.createProgram();return r?(e.attachShader(r,t),e.attachShader(r,n),e.linkProgram(r),e.getProgramParameter(r,e.LINK_STATUS)?r:(e.deleteProgram(r),null)):null}function Ps(e){let t=e.trim().toLowerCase();if(t.startsWith(`rgba(`)){let e=t.slice(5,-1).split(`,`).map(e=>Number(e.trim()));if(e.length===4&&e.every(e=>Number.isFinite(e)))return[e[0]/255,e[1]/255,e[2]/255,e[3]]}if(t.startsWith(`rgb(`)){let e=t.slice(4,-1).split(`,`).map(e=>Number(e.trim()));if(e.length===3&&e.every(e=>Number.isFinite(e)))return[e[0]/255,e[1]/255,e[2]/255,1]}if(t.startsWith(`#`)){let e=t.slice(1);if(e.length===6)return[Number.parseInt(e.slice(0,2),16)/255,Number.parseInt(e.slice(2,4),16)/255,Number.parseInt(e.slice(4,6),16)/255,1];if(e.length===3)return[Number.parseInt(e[0]+e[0],16)/255,Number.parseInt(e[1]+e[1],16)/255,Number.parseInt(e[2]+e[2],16)/255,1]}return null}var Fs=class{dom;pane;opt;contexts=null;webgl;constructor(e,t,n){this.dom=e,this.pane=t,this.opt={...n,priceLabelWidth:n.priceLabelWidth||60},this.webgl={candleSurface:new ks,lineSurface:new As}}getPane(){return this.pane}getDom(){return this.dom}getContexts(){return this.contexts||={mainCtx:this.dom.mainCanvas.getContext(`2d`),overlayCtx:this.dom.overlayCanvas.getContext(`2d`,{desynchronized:!0}),yAxisCtx:this.dom.yAxisCanvas.getContext(`2d`)},this.contexts}getWebGL(){return this.webgl}resize(e,t,n){let r=this.dom.mainCanvas,i=this.dom.overlayCanvas,a=this.dom.yAxisCanvas,o=this.opt.rightAxisWidth+(this.opt.priceLabelWidth||60),s=a.parentElement?.clientWidth??0,c=s>0?s:o,l=Math.round(e*n);r.width!==l&&(r.width=l);let u=Math.round(t*n);r.height!==u&&(r.height=u);let d=`${l/n}px`;r.style.width!==d&&(r.style.width=d);let f=`${u/n}px`;r.style.height!==f&&(r.style.height=f),i.width!==l&&(i.width=l),i.height!==u&&(i.height=u),i.style.width!==d&&(i.style.width=d),i.style.height!==f&&(i.style.height=f);let p=Math.round(c*n);a.width!==p&&(a.width=p);let m=Math.round(t*n);a.height!==m&&(a.height=m);let h=`${p/n}px`;a.style.width!==h&&(a.style.width=h);let g=`${m/n}px`;a.style.height!==g&&(a.style.height=g),this.webgl.candleSurface?.resize(e,t,n),this.webgl.lineSurface?.resize(e,t,n)}destroy(){this.contexts=null,this.webgl.candleSurface?.destroy(),this.webgl.lineSurface?.destroy()}};function Is(e){let{dataLength:t,kWidth:n,kGap:r,viewWidth:i,viewportDpr:a}=e;if(t===0)return 0;let{startXPx:o,unitPx:s}=na(n,r,a),c=(o+(t+24)*s)/a;return Math.max(c,i)}function Ls(e){let t=(0,f.reactive)({zoomLevel:e.initialZoomLevel,kWidth:0,kGap:1,viewportDpr:1,dataLength:0,dataVersion:0,paneRatios:{},drawings:[],selectedDrawingId:null,drawingVersion:0,viewWidth:0}),n=(0,f.computed)(()=>e.rightAxisWidth+e.priceLabelWidth),r=(0,f.computed)(()=>Is({dataLength:t.dataLength,kWidth:t.kWidth,kGap:t.kGap,viewWidth:t.viewWidth,viewportDpr:t.viewportDpr}));function i(){t.dataVersion++}function a(){t.drawingVersion++}function o(e){t.dataLength=e}function s(e){t.viewportDpr=e}function c(e){t.viewWidth=e}function l(e,n,r){t.zoomLevel=e,t.kWidth=n,t.kGap=r}function u(e){t.paneRatios=e}function d(e){t.drawings=e,t.selectedDrawingId&&!e.some(e=>e.id===t.selectedDrawingId)&&(t.selectedDrawingId=null),t.drawingVersion++}function p(e){t.selectedDrawingId=e}return{state:t,computed:{axisHostWidth:n,totalWidth:r},actions:{bumpDataVersion:i,bumpDrawingVersion:a,setDataLength:o,setViewportDpr:s,setViewWidth:c,setZoomState:l,setPaneRatios:u,setDrawings:d,setSelectedDrawingId:p}}}var Rs=[5,10,20,30,60];function zs(e,t,n){let r=Array(e.length);if(e.length<t)return r;let i=0,a=[];for(let n=0;n<t;n++){let t=e[n];if(!t)return r;let o=t.close;a.push(o),i+=o}for(let o=t-1;o<e.length;o++){let s=e[o];if(!s)continue;if(o>=t){let e=a.shift();e!==void 0&&(i-=e);let t=s.close;a.push(t),i+=t}let c=i/t,l=0;for(let e=0;e<t;e++){let t=a[e];t!==void 0&&(l+=(t-c)**2)}let u=Math.sqrt(l/t);r[o]={upper:c+n*u,middle:c,lower:c-n*u}}return r}function Bs(e,t,n){let r=Array(e.length);if(e.length===0)return r;let i=2/(t+1),a=2/(n+1),o=e[0].close,s=o,c=o;r[0]={fast:s,slow:c};for(let t=1;t<e.length;t++){let n=e[t].close;s=n*i+s*(1-i),c=n*a+c*(1-a),r[t]={fast:s,slow:c}}return r}function Vs(e,t,n){let r=Array(e.length);if(e.length<t)return r;let i=0;for(let n=0;n<t;n++){let t=e[n];if(!t)return r;i+=t.close}let a=i/t,o=n/100;r[t-1]={upper:a*(1+o),middle:a,lower:a*(1-o)};for(let a=t;a<e.length;a++){let o=e[a-t],s=e[a];if(!o||!s)continue;i=i-o.close+s.close;let c=i/t,l=n/100;r[a]={upper:c*(1+l),middle:c,lower:c*(1-l)}}return r}function Hs(e,t){let n=Array(e.length);if(e.length<t)return n;let r=0;for(let i=0;i<t;i++){let t=e[i];if(!t)return n;r+=t.close}n[t-1]=r/t;for(let i=t;i<e.length;i++){let a=e[i-t],o=e[i];!a||!o||(r=r-a.close+o.close,n[i]=r/t)}return n}function Us(e,t){let n=Array(e.length);if(e.length<t+1)return n;let r=[];for(let t=1;t<e.length;t++)r.push(e[t].close-e[t-1].close);let i=0,a=0;for(let e=0;e<t;e++){let t=r[e];t!==void 0&&(t>0?i+=t:a+=Math.abs(t))}let o=i/t,s=a/t;s===0?n[t]=100:n[t]=100-100/(1+o/s);for(let e=t;e<r.length;e++){let i=r[e];if(i!==void 0)if(i>0?(o=(o*(t-1)+i)/t,s=s*(t-1)/t):(o=o*(t-1)/t,s=(s*(t-1)+Math.abs(i))/t),s===0)n[e+1]=100;else{let t=o/s;n[e+1]=100-100/(1+t)}}return n}function Ws(e,t){let n=Array(e.length);if(e.length<t)return n;let r=[];for(let t of e)r.push((t.high+t.low+t.close)/3);let i=0;for(let e=0;e<t;e++)i+=r[e];for(let a=t-1;a<e.length;a++){a>=t&&(i=i-r[a-t]+r[a]);let e=i/t,o=0;for(let n=0;n<t;n++)o+=Math.abs(r[a-n]-e);o/=t,o===0?n[a]=0:n[a]=(r[a]-e)/(.015*o)}return n}function Gs(e,t,n){let r=Array(e.length);if(e.length<t)return r;let i=Array(e.length);for(let n=t-1;n<e.length;n++){let r=-1/0,a=1/0;for(let i=0;i<t;i++){let t=e[n-i];t&&(r=Math.max(r,t.high),a=Math.min(a,t.low))}let o=e[n].close;r===a?i[n]=50:i[n]=(o-a)/(r-a)*100}for(let a=t-1+n-1;a<e.length;a++){let e=i[a];if(e===void 0)continue;let t=0,o=0;for(let e=0;e<n;e++){let n=i[a-e];n!==void 0&&(t+=n,o++)}o===n&&(r[a]={k:e,d:t/n})}return r}function Ks(e,t){let n=Array(e.length);if(e.length<t+1)return n;for(let r=t;r<e.length;r++){let i=e[r]?.close,a=e[r-t]?.close;i!==void 0&&a!==void 0&&(n[r]=i-a)}return n}function qs(e,t){let n=Array(e.length);if(e.length<t)return n;for(let r=t-1;r<e.length;r++){let i=-1/0,a=1/0;for(let n=0;n<t;n++){let t=e[r-n];t&&(i=Math.max(i,t.high),a=Math.min(a,t.low))}let o=e[r].close;i===a?n[r]=-50:n[r]=(i-o)/(i-a)*-100}return n}function Js(e,t){let n=Array(e.length);if(e.length<t+1)return n;for(let r=t;r<e.length;r++){let i=e[r]?.close,a=e[r-t]?.close;i!==void 0&&a!==void 0&&a!==0&&(n[r]=(i-a)/a*100)}return n}function Ys(e,t){let n=Array(e.length),r=0,i=0;for(let a=0;a<e.length;a++){let o=e[a];if(o!==void 0){if(r+=o,i++,i>t){let n=e[a-t];n!==void 0&&(r-=n,i--)}i===t&&(n[a]=r/t)}}return n}function Xs(e,t,n,r,i,a){let o=Array(e.length),s=Js(e,t),c=Js(e,n),l=Js(e,r),u=Js(e,i),d=Ys(s,10),f=Ys(c,10),p=Ys(l,10),m=Ys(u,15),h=Array(e.length);for(let t=0;t<e.length;t++){let e=d[t],n=f[t],r=p[t],i=m[t];e!==void 0&&n!==void 0&&r!==void 0&&i!==void 0&&(h[t]=e*1+n*2+r*3+i*4)}let g=Ys(h,a);for(let t=0;t<e.length;t++){let e=h[t],n=g[t];e!==void 0&&n!==void 0&&(o[t]={kst:e,signal:n})}return o}function Zs(e,t){let n=Array(e.length);if(e.length<t)return n;for(let r=t-1;r<e.length;r++){let i=-1/0,a=1/0;for(let n=0;n<t;n++){let t=e[r-n];t&&(i=Math.max(i,t.high),a=Math.min(a,t.low))}let o=e[r].close;i===a?n[r]=50:n[r]=(o-a)/(i-a)*100}return n}var Q=(e,t)=>`indicator:${e}:${t}`,Qs=Q(`ma`,`main`),$s=Q(`boll`,`main`),ec=Q(`expma`,`main`),tc=Q(`ene`,`main`),nc=e=>Q(`rsi`,e),rc=e=>Q(`cci`,e),ic=e=>Q(`stoch`,e),ac=e=>Q(`mom`,e),oc=e=>Q(`wmsr`,e),sc=e=>Q(`kst`,e),cc=e=>Q(`fastk`,e),lc=class{pluginHost=null;currentData=[];maConfig={ma5:!0,ma10:!0,ma20:!0,ma30:!0,ma60:!0};visibleRange={start:0,end:0};cachedSeries={};bollConfig={period:20,multiplier:2,showUpper:!0,showMiddle:!0,showLower:!0,showBand:!0};cachedBollSeries=[];expmaConfig={fastPeriod:12,slowPeriod:50};cachedExpmaSeries=[];eneConfig={period:10,deviation:11};cachedEneSeries=[];rsiConfig={period1:6,period2:12,period3:24,showRSI1:!0,showRSI2:!0,showRSI3:!0};rsiPaneId=`sub_RSI`;cachedRsiSeries={};cciConfig={period:14,showCCI:!0};cciPaneId=`sub_CCI`;cachedCciSeries=[];stochConfig={n:9,m:3,showK:!0,showD:!0};stochPaneId=`sub_STOCH`;cachedStochSeries=[];momConfig={period:10,showMOM:!0};momPaneId=`sub_MOM`;cachedMomSeries=[];wmsrConfig={period:14,showWMSR:!0};wmsrPaneId=`sub_WMSR`;cachedWmsrSeries=[];kstConfig={roc1:10,roc2:15,roc3:20,roc4:30,signalPeriod:9,showKST:!0,showSignal:!0};kstPaneId=`sub_KST`;cachedKstSeries=[];fastkConfig={period:9,showFASTK:!0};fastkPaneId=`sub_FASTK`;cachedFastkSeries=[];dirtyData=!0;dirtyRange=!0;dirtyBollConfig=!0;dirtyExpmaConfig=!0;dirtyEneConfig=!0;dirtyRsiConfig=!0;dirtyCciConfig=!0;dirtyStochConfig=!0;dirtyMomConfig=!0;dirtyWmsrConfig=!0;dirtyKstConfig=!0;dirtyFastkConfig=!0;dirtyRsiState=!0;dirtyCciState=!0;dirtyStochState=!0;dirtyMomState=!0;dirtyWmsrState=!0;dirtyKstState=!0;dirtyFastkState=!0;activeMainIndicators=new Set;setPluginHost(e){this.pluginHost=e}setActiveMainIndicators(e){this.activeMainIndicators=new Set(e.map(e=>e.toLowerCase()))}update(e,t){this.currentData=e,this.visibleRange=t,this.dirtyData=!0,this.computeIfDirty()}updateMAConfig(e){this.maConfig={...e},this.dirtyData=!0,this.computeIfDirty()}updateBOLLConfig(e){this.bollConfig={...this.bollConfig,...e},this.dirtyBollConfig=!0,this.computeIfDirty()}updateEXPMAConfig(e){this.expmaConfig={...this.expmaConfig,...e},this.dirtyExpmaConfig=!0,this.computeIfDirty()}updateENEConfig(e){this.eneConfig={...this.eneConfig,...e},this.dirtyEneConfig=!0,this.computeIfDirty()}updateRSIConfig(e,t){t!==void 0&&(this.rsiPaneId=t),this.rsiConfig={...this.rsiConfig,...e},this.dirtyRsiConfig=!0,this.computeIfDirty()}updateCCIConfig(e,t){t!==void 0&&(this.cciPaneId=t),this.cciConfig={...this.cciConfig,...e},this.dirtyCciConfig=!0,this.computeIfDirty()}updateSTOCHConfig(e,t){t!==void 0&&(this.stochPaneId=t),this.stochConfig={...this.stochConfig,...e},this.dirtyStochConfig=!0,this.computeIfDirty()}updateMOMConfig(e,t){t!==void 0&&(this.momPaneId=t),this.momConfig={...this.momConfig,...e},this.dirtyMomConfig=!0,this.computeIfDirty()}updateWMSRConfig(e,t){t!==void 0&&(this.wmsrPaneId=t),this.wmsrConfig={...this.wmsrConfig,...e},this.dirtyWmsrConfig=!0,this.computeIfDirty()}updateKSTConfig(e,t){t!==void 0&&(this.kstPaneId=t),this.kstConfig={...this.kstConfig,...e},this.dirtyKstConfig=!0,this.computeIfDirty()}updateFASTKConfig(e,t){t!==void 0&&(this.fastkPaneId=t),this.fastkConfig={...this.fastkConfig,...e},this.dirtyFastkConfig=!0,this.computeIfDirty()}updateVisibleRange(e){this.visibleRange=e,this.dirtyRange=!0,this.computeIfDirty()}recompute(){this.dirtyData=!0,this.dirtyRange=!0,this.computeIfDirty()}computeIfDirty(){if(!this.dirtyData&&!this.dirtyRange&&!this.dirtyBollConfig&&!this.dirtyExpmaConfig&&!this.dirtyEneConfig&&!this.dirtyRsiConfig&&!this.dirtyCciConfig&&!this.dirtyStochConfig&&!this.dirtyMomConfig&&!this.dirtyWmsrConfig&&!this.dirtyKstConfig&&!this.dirtyFastkConfig||!this.pluginHost)return;if(this.dirtyData){this.cachedSeries={};for(let e of Rs){let t=`ma${e}`;this.maConfig[t]&&(this.cachedSeries[e]=Hs(this.currentData,e))}}if((this.dirtyData||this.dirtyBollConfig)&&(this.cachedBollSeries=zs(this.currentData,this.bollConfig.period,this.bollConfig.multiplier)),(this.dirtyData||this.dirtyExpmaConfig)&&(this.cachedExpmaSeries=Bs(this.currentData,this.expmaConfig.fastPeriod,this.expmaConfig.slowPeriod)),(this.dirtyData||this.dirtyEneConfig)&&(this.cachedEneSeries=Vs(this.currentData,this.eneConfig.period,this.eneConfig.deviation)),this.dirtyData||this.dirtyRsiConfig){this.cachedRsiSeries={};let e=[this.rsiConfig.period1,this.rsiConfig.period2,this.rsiConfig.period3],t=[this.rsiConfig.showRSI1,this.rsiConfig.showRSI2,this.rsiConfig.showRSI3];for(let n=0;n<e.length;n++)t[n]&&(this.cachedRsiSeries[e[n]]=Us(this.currentData,e[n]))}(this.dirtyData||this.dirtyCciConfig)&&(this.cciConfig.showCCI?this.cachedCciSeries=Ws(this.currentData,this.cciConfig.period):this.cachedCciSeries=[]),(this.dirtyData||this.dirtyStochConfig)&&(this.stochConfig.showK||this.stochConfig.showD?this.cachedStochSeries=Gs(this.currentData,this.stochConfig.n,this.stochConfig.m):this.cachedStochSeries=[]),(this.dirtyData||this.dirtyMomConfig)&&(this.momConfig.showMOM?this.cachedMomSeries=Ks(this.currentData,this.momConfig.period):this.cachedMomSeries=[]),(this.dirtyData||this.dirtyWmsrConfig)&&(this.wmsrConfig.showWMSR?this.cachedWmsrSeries=qs(this.currentData,this.wmsrConfig.period):this.cachedWmsrSeries=[]),(this.dirtyData||this.dirtyKstConfig)&&(this.kstConfig.showKST||this.kstConfig.showSignal?this.cachedKstSeries=Xs(this.currentData,this.kstConfig.roc1,this.kstConfig.roc2,this.kstConfig.roc3,this.kstConfig.roc4,this.kstConfig.signalPeriod):this.cachedKstSeries=[]),(this.dirtyData||this.dirtyFastkConfig)&&(this.fastkConfig.showFASTK?this.cachedFastkSeries=Zs(this.currentData,this.fastkConfig.period):this.cachedFastkSeries=[]);let e=1/0,t=-1/0;if(this.dirtyData||this.dirtyRange)for(let n of Object.values(this.cachedSeries))for(let r=this.visibleRange.start;r<this.visibleRange.end&&r<n.length;r++){let i=n[r];i!==void 0&&(e=Math.min(e,i),t=Math.max(t,i))}let n=1/0,r=-1/0,i=this.dirtyData||this.dirtyRange||this.dirtyBollConfig;if(i)for(let e=this.visibleRange.start;e<this.visibleRange.end&&e<this.cachedBollSeries.length;e++){let t=this.cachedBollSeries[e];t&&(n=Math.min(n,t.upper,t.middle,t.lower),r=Math.max(r,t.upper,t.middle,t.lower))}let a=1/0,o=-1/0,s=this.dirtyData||this.dirtyRange||this.dirtyExpmaConfig;if(s)for(let e=this.visibleRange.start;e<this.visibleRange.end&&e<this.cachedExpmaSeries.length;e++){let t=this.cachedExpmaSeries[e];t&&(a=Math.min(a,t.fast,t.slow),o=Math.max(o,t.fast,t.slow))}let c=1/0,l=-1/0,u=this.dirtyData||this.dirtyRange||this.dirtyEneConfig;if(u)for(let e=this.visibleRange.start;e<this.visibleRange.end&&e<this.cachedEneSeries.length;e++){let t=this.cachedEneSeries[e];t&&(c=Math.min(c,t.upper,t.middle,t.lower),l=Math.max(l,t.upper,t.middle,t.lower))}let d=1/0,f=-1/0;if(this.dirtyRsiState=this.dirtyData||this.dirtyRange||this.dirtyRsiConfig,this.dirtyRsiState)for(let e of Object.values(this.cachedRsiSeries))for(let t=this.visibleRange.start;t<this.visibleRange.end&&t<e.length;t++){let n=e[t];n!==void 0&&(d=Math.min(d,n),f=Math.max(f,n))}let p=1/0,m=-1/0;if(this.dirtyCciState=this.dirtyData||this.dirtyRange||this.dirtyCciConfig,this.dirtyCciState)for(let e=this.visibleRange.start;e<this.visibleRange.end&&e<this.cachedCciSeries.length;e++){let t=this.cachedCciSeries[e];t!==void 0&&(p=Math.min(p,t),m=Math.max(m,t))}let h=1/0,g=-1/0;if(this.dirtyStochState=this.dirtyData||this.dirtyRange||this.dirtyStochConfig,this.dirtyStochState)for(let e=this.visibleRange.start;e<this.visibleRange.end&&e<this.cachedStochSeries.length;e++){let t=this.cachedStochSeries[e];t&&(h=Math.min(h,t.k,t.d),g=Math.max(g,t.k,t.d))}let _=1/0,v=-1/0;if(this.dirtyMomState=this.dirtyData||this.dirtyRange||this.dirtyMomConfig,this.dirtyMomState)for(let e=this.visibleRange.start;e<this.visibleRange.end&&e<this.cachedMomSeries.length;e++){let t=this.cachedMomSeries[e];t!==void 0&&(_=Math.min(_,t),v=Math.max(v,t))}let y=1/0,b=-1/0;if(this.dirtyWmsrState=this.dirtyData||this.dirtyRange||this.dirtyWmsrConfig,this.dirtyWmsrState)for(let e=this.visibleRange.start;e<this.visibleRange.end&&e<this.cachedWmsrSeries.length;e++){let t=this.cachedWmsrSeries[e];t!==void 0&&(y=Math.min(y,t),b=Math.max(b,t))}let x=1/0,S=-1/0;if(this.dirtyKstState=this.dirtyData||this.dirtyRange||this.dirtyKstConfig,this.dirtyKstState)for(let e=this.visibleRange.start;e<this.visibleRange.end&&e<this.cachedKstSeries.length;e++){let t=this.cachedKstSeries[e];t&&(x=Math.min(x,t.kst,t.signal),S=Math.max(S,t.kst,t.signal))}let C=1/0,w=-1/0;if(this.dirtyFastkState=this.dirtyData||this.dirtyRange||this.dirtyFastkConfig,this.dirtyFastkState)for(let e=this.visibleRange.start;e<this.visibleRange.end&&e<this.cachedFastkSeries.length;e++){let t=this.cachedFastkSeries[e];t!==void 0&&(C=Math.min(C,t),w=Math.max(w,t))}if(this.dirtyData||this.dirtyRange){let n=Object.keys(this.cachedSeries).map(Number),r={timestamp:Date.now(),series:this.cachedSeries,enabledPeriods:n,visibleMin:e,visibleMax:t};this.pluginHost.setSharedState(Qs,r,`ma_scheduler`)}if(i){let e={timestamp:Date.now(),series:this.cachedBollSeries,params:this.bollConfig,visibleMin:n,visibleMax:r};this.pluginHost.setSharedState($s,e,`indicator_scheduler`)}if(s){let e={timestamp:Date.now(),series:this.cachedExpmaSeries,params:this.expmaConfig,visibleMin:a,visibleMax:o};this.pluginHost.setSharedState(ec,e,`indicator_scheduler`)}if(u){let e={timestamp:Date.now(),series:this.cachedEneSeries,params:this.eneConfig,visibleMin:c,visibleMax:l};this.pluginHost.setSharedState(tc,e,`indicator_scheduler`)}if(this.dirtyRsiState){let e=nc(this.rsiPaneId),t=Object.keys(this.cachedRsiSeries).map(Number),n={timestamp:Date.now(),series:this.cachedRsiSeries,enabledPeriods:t,params:this.rsiConfig,valueMin:0,valueMax:100,visibleMin:d,visibleMax:f};this.pluginHost.setSharedState(e,n,`indicator_scheduler`)}if(this.dirtyCciState){let e=rc(this.cciPaneId),t=Math.min(p,-150),n=Math.max(m,150),r={timestamp:Date.now(),series:this.cachedCciSeries,params:this.cciConfig,valueMin:t,valueMax:n,visibleMin:p,visibleMax:m};this.pluginHost.setSharedState(e,r,`indicator_scheduler`)}if(this.dirtyStochState){let e=ic(this.stochPaneId),t={timestamp:Date.now(),series:this.cachedStochSeries,params:this.stochConfig,valueMin:0,valueMax:100,visibleMin:h,visibleMax:g};this.pluginHost.setSharedState(e,t,`indicator_scheduler`)}if(this.dirtyMomState){let e=ac(this.momPaneId),t=Math.max(Math.abs(v),Math.abs(_))*.1,n=_-t,r=v+t,i={timestamp:Date.now(),series:this.cachedMomSeries,params:this.momConfig,valueMin:n,valueMax:r,visibleMin:_,visibleMax:v};this.pluginHost.setSharedState(e,i,`indicator_scheduler`)}if(this.dirtyWmsrState){let e=oc(this.wmsrPaneId),t={timestamp:Date.now(),series:this.cachedWmsrSeries,params:this.wmsrConfig,valueMin:-100,valueMax:0,visibleMin:y,visibleMax:b};this.pluginHost.setSharedState(e,t,`indicator_scheduler`)}if(this.dirtyKstState){let e=sc(this.kstPaneId),t=(S-x)*.1,n=x-t,r=S+t,i={timestamp:Date.now(),series:this.cachedKstSeries,params:this.kstConfig,valueMin:n,valueMax:r,visibleMin:x,visibleMax:S};this.pluginHost.setSharedState(e,i,`indicator_scheduler`)}if(this.dirtyFastkState){let e=cc(this.fastkPaneId),t={timestamp:Date.now(),series:this.cachedFastkSeries,params:this.fastkConfig,valueMin:0,valueMax:100,visibleMin:C,visibleMax:w};this.pluginHost.setSharedState(e,t,`indicator_scheduler`)}this.dirtyData=!1,this.dirtyRange=!1,this.dirtyBollConfig=!1,this.dirtyExpmaConfig=!1,this.dirtyEneConfig=!1,this.dirtyRsiConfig=!1,this.dirtyCciConfig=!1,this.dirtyStochConfig=!1,this.dirtyMomConfig=!1,this.dirtyWmsrConfig=!1,this.dirtyKstConfig=!1,this.dirtyFastkConfig=!1,this.dirtyRsiState=!1,this.dirtyCciState=!1,this.dirtyStochState=!1,this.dirtyMomState=!1,this.dirtyWmsrState=!1,this.dirtyKstState=!1,this.dirtyFastkState=!1}getMainIndicatorPriceRange(){let e=1/0,t=-1/0,{start:n,end:r}=this.visibleRange;if(this.activeMainIndicators.has(`ma`)&&Object.keys(this.cachedSeries).length>0)for(let i of Object.values(this.cachedSeries))for(let a=n;a<r&&a<i.length;a++){let n=i[a];n!==void 0&&(e=Math.min(e,n),t=Math.max(t,n))}if(this.activeMainIndicators.has(`boll`)&&this.cachedBollSeries.length>0)for(let i=n;i<r&&i<this.cachedBollSeries.length;i++){let n=this.cachedBollSeries[i];n&&(e=Math.min(e,n.upper,n.middle,n.lower),t=Math.max(t,n.upper,n.middle,n.lower))}if(this.activeMainIndicators.has(`expma`)&&this.cachedExpmaSeries.length>0)for(let i=n;i<r&&i<this.cachedExpmaSeries.length;i++){let n=this.cachedExpmaSeries[i];n&&(e=Math.min(e,n.fast,n.slow),t=Math.max(t,n.fast,n.slow))}if(this.activeMainIndicators.has(`ene`)&&this.cachedEneSeries.length>0)for(let i=n;i<r&&i<this.cachedEneSeries.length;i++){let n=this.cachedEneSeries[i];n&&(e=Math.min(e,n.upper,n.middle,n.lower),t=Math.max(t,n.upper,n.middle,n.lower))}return!Number.isFinite(e)||!Number.isFinite(t)?null:{min:e,max:t}}};function uc(e={}){let{paneId:t=`sub`}=e,n=Q(`volume`,t),r=null;return{name:`volume_${t}`,version:`1.0.0`,description:`成交量渲染器`,debugName:`成交量`,paneId:t,priority:G.MAIN,onInstall(e){r=e},getDeclaredNamespaces(){return[n]},draw(e){let{ctx:i,pane:a,data:o,range:s,dpr:c}=e,l=o;if(!l.length)return;let{start:u,end:d}=s,f=0,p=1/0;for(let e=u;e<d&&e<l.length;e++){let t=l[e];if(!t)continue;let n=t.volume;n!=null&&(f=Math.max(f,n),p=Math.min(p,n))}if(f===0||!Number.isFinite(p))return;let m=Math.max(.05,(f-p)*.1),h=Math.max(0,p-m),g=f+m,_=a.yAxis.getDisplayRange({minPrice:h,maxPrice:g}),v=_.minPrice,y=_.maxPrice-v||1,b=a.height-(0-v)/y*a.height,x=Math.round(b*c)/c;r?.setSharedState(n,{valueMin:h,valueMax:g,timestamp:Date.now()},`volume_${t}`);let S=[],C=[],w=[];for(let t=u;t<d;t++){let n=l[t];if(!n)continue;let r=n.volume;if(!r)continue;let i=e.kBarRects[t-u];if(!i)continue;let o=a.height-(r-v)/y*a.height,s=Math.round(o*c)/c,d=1/c,f=x-s,p=f<=0?d:Math.max(f,d),m=f<=0?x-d:x-p,h={x:i.x,y:m,width:i.width,height:p},g=mc(n);g===xa.UP?S.push(h):g===xa.DOWN?C.push(h):w.push(h)}dc(e,S,C,w)?pc(i,e):fc(i,e.scrollLeft,S,C,w)}}}function dc(e,t,n,r){let i=e.candleWebGLSurface;if(!i||!i.isAvailable())return!1;i.clear();let a=t.length===0||i.drawRects(t,xa.UP,e.scrollLeft),o=n.length===0||i.drawRects(n,xa.DOWN,e.scrollLeft),s=r.length===0||i.drawRects(r,xa.NEUTRAL,e.scrollLeft);return a&&o&&s}function fc(e,t,n,r,i){e.save(),e.translate(-t,0),e.fillStyle=xa.UP;for(let t of n)e.fillRect(t.x,t.y,t.width,t.height);e.fillStyle=xa.DOWN;for(let t of r)e.fillRect(t.x,t.y,t.width,t.height);e.fillStyle=xa.NEUTRAL;for(let t of i)e.fillRect(t.x,t.y,t.width,t.height);e.restore()}function pc(e,t){let n=t.candleWebGLSurface;if(!n)return;let r=n.getCanvas();r.width<=0||r.height<=0||e.drawImage(r,0,0,r.width,r.height,0,0,r.width/t.dpr,r.height/t.dpr)}function mc(e){return e.close>e.open?xa.UP:e.close<e.open?xa.DOWN:xa.NEUTRAL}var hc={5:ya.MA5,10:ya.MA10,20:ya.MA20,30:ya.MA30,60:ya.MA60};function gc(e,t,n,r){let i=n.yAxis.getDisplayRange();return[e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,i.maxPrice.toFixed(6),i.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),r.join(`,`)].join(`|`)}function _c(){let e=null,t=``,n=new Map;function r(){t=``,n=new Map}return{name:`ma`,version:`2.0.0`,description:`MA均线渲染器(带绘制缓存)`,debugName:`MA均线`,paneId:`main`,priority:G.INDICATOR,onInstall(t){e=t},getDeclaredNamespaces(){return[Qs]},draw(i){let{ctx:a,pane:o,range:s,scrollLeft:c,dpr:l,kLineCenters:u,lineWebGLSurface:d}=i,f=e?.getSharedState(Qs);if(!f||f.visibleMin>f.visibleMax){r();return}if(f.enabledPeriods.length===0){r();return}let p=gc(s,u,o,f.enabledPeriods);if(t!==p){t=p,n=new Map;for(let[e,t]of Object.entries(f.series)){let r=Number(e),i=[];for(let e=s.start;e<s.end&&e<t.length;e++){let n=t[e];if(n===void 0)continue;let r=u[e-s.start];r!==void 0&&i.push({x:r,y:o.yAxis.priceToY(n)})}i.length>=2&&n.set(r,i)}}let m=!1;if(d?.isAvailable()){let e=!0;for(let t of f.enabledPeriods){let r=n.get(t);if(r&&!d.drawLineStrip({points:r,width:1},hc[t]??ya.MA5,c)){e=!1;break}}if(e){m=!0;let e=d.getCanvas();if(e.width>0&&e.height>0){let t=a.imageSmoothingEnabled;a.imageSmoothingEnabled=!1,a.drawImage(e,0,0,e.width,e.height,0,0,e.width/l,e.height/l),a.imageSmoothingEnabled=t}}}if(!m){a.save(),a.translate(-c,0),a.lineWidth=1,a.lineJoin=`round`,a.lineCap=`round`;for(let e of f.enabledPeriods){let t=n.get(e);if(!(!t||t.length<2)){a.strokeStyle=hc[e]??ya.MA5,a.beginPath(),a.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++){let n=t[e];a.lineTo(n.x,n.y)}a.stroke()}}a.restore()}},getConfig(){let t=e?.getSharedState(Qs),n={};return t?.enabledPeriods.forEach(e=>{n[`ma${e}`]=!0}),n},setConfig(e){}}}function vc(e,t,n,r,i,a,o,s){let c=n.yAxis.getDisplayRange();return[e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,c.maxPrice.toFixed(6),c.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),Number(r),Number(i),Number(a),Number(o),s].join(`|`)}function yc(){let e=null,t=``,n=null,r=null,i=null,a=null;function o(){t=``,n=null,r=null,i=null,a=null}return{name:`boll`,version:`2.0.0`,description:`布林带渲染器(带绘制缓存)`,debugName:`BOLL布林带`,paneId:`main`,priority:G.INDICATOR,onInstall(t){e=t},getDeclaredNamespaces(){return[$s]},draw(s){let{ctx:c,pane:l,data:u,range:d,scrollLeft:f,dpr:p,kLineCenters:m}=s,h=u,g=e?.getSharedState($s);if(!g||g.visibleMin>g.visibleMax){o();return}if(g.series.length===0){o();return}let{period:_,showUpper:v,showMiddle:y,showLower:b,showBand:x}=g.params,S=g.series;if(h.length<_){o();return}let C=Math.max(d.start,_-1),w=Math.min(d.end,h.length),T=vc(d,m,l,v,y,b,x,_);if(t!==T){t=T,n=x?new Path2D:null,r=v?new Path2D:null,i=y?new Path2D:null,a=b?new Path2D:null;let e=!1,o=!1,s=!1,c=!1;for(let t=C;t<w;t++){let u=S[t];if(!u)continue;let f=m[t-d.start];if(f===void 0)continue;let h=Z(l.yAxis.priceToY(u.upper),p),g=Z(l.yAxis.priceToY(u.middle),p),_=Z(l.yAxis.priceToY(u.lower),p);n&&(e?n.lineTo(f,h):(n.moveTo(f,h),e=!0)),r&&(o?r.lineTo(f,h):(r.moveTo(f,h),o=!0)),i&&(s?i.lineTo(f,g):(i.moveTo(f,g),s=!0)),a&&(c?a.lineTo(f,_):(a.moveTo(f,_),c=!0))}if(n&&e){for(let e=w-1;e>=C;e--){let t=S[e];if(!t)continue;let r=m[e-d.start];if(r===void 0)continue;let i=Z(l.yAxis.priceToY(t.lower),p);n.lineTo(r,i)}n.closePath()}}c.save(),c.translate(-f,0),c.lineWidth=1,c.lineJoin=`round`,c.lineCap=`round`,n&&(c.fillStyle=ba.BAND_FILL,c.fill(n)),r&&(c.strokeStyle=ba.UPPER,c.stroke(r)),i&&(c.strokeStyle=ba.MIDDLE,c.stroke(i)),a&&(c.strokeStyle=ba.LOWER,c.stroke(a)),c.restore()},getConfig(){let t=e?.getSharedState($s);return t?{...t.params}:{}},setConfig(e){}}}function bc(e,t,n){let r=n.yAxis.getDisplayRange();return[e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,r.maxPrice.toFixed(6),r.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType()].join(`|`)}function xc(){let e=null,t=``,n=[],r=[];function i(){t=``,n=[],r=[]}return{name:`expma`,version:`2.0.0`,description:`EXPMA 指数平滑移动平均线渲染器(带绘制缓存)`,debugName:`EXPMA`,paneId:`main`,priority:G.INDICATOR,onInstall(t){e=t},getDeclaredNamespaces(){return[ec]},draw(a){let{ctx:o,pane:s,data:c,range:l,scrollLeft:u,dpr:d,kLineCenters:f,lineWebGLSurface:p}=a,m=c,h=e?.getSharedState(ec);if(!h||h.visibleMin>h.visibleMax){i();return}if(h.series.length===0||m.length<2){i();return}let g=h.series,_=l.start,v=Math.min(l.end,m.length),y=bc(l,f,s);if(t!==y){t=y,n=[],r=[];for(let e=_;e<v;e++){let t=g[e];if(!t)continue;let i=f[e-l.start];i!==void 0&&(n.push({x:i,y:s.yAxis.priceToY(t.fast)}),r.push({x:i,y:s.yAxis.priceToY(t.slow)}))}}let b=!1;if(p?.isAvailable()){let e=!0;if(n.length>=2&&(e=p.drawLineStrip({points:n,width:1},Oa.FAST,u)),e&&r.length>=2&&(e=p.drawLineStrip({points:r,width:1},Oa.SLOW,u)),e){b=!0;let e=p.getCanvas();if(e.width>0&&e.height>0){let t=o.imageSmoothingEnabled;o.imageSmoothingEnabled=!1,o.drawImage(e,0,0,e.width,e.height,0,0,e.width/d,e.height/d),o.imageSmoothingEnabled=t}}}if(!b){if(o.save(),o.translate(-u,0),o.lineWidth=1,o.lineJoin=`round`,o.lineCap=`round`,n.length>=2){o.strokeStyle=Oa.FAST,o.beginPath(),o.moveTo(n[0].x,n[0].y);for(let e=1;e<n.length;e++){let t=n[e];o.lineTo(t.x,t.y)}o.stroke()}if(r.length>=2){o.strokeStyle=Oa.SLOW,o.beginPath(),o.moveTo(r[0].x,r[0].y);for(let e=1;e<r.length;e++){let t=r[e];o.lineTo(t.x,t.y)}o.stroke()}o.restore()}},getConfig(){let t=e?.getSharedState(ec);return t?{...t.params}:{}},setConfig(e){}}}function Sc(){let e=null;return{name:`ene`,version:`2.0.0`,description:`ENE 轨道线渲染器(无状态)`,debugName:`ENE轨道线`,paneId:`main`,priority:G.INDICATOR,onInstall(t){e=t},getDeclaredNamespaces(){return[tc]},draw(t){let{ctx:n,pane:r,data:i,range:a,scrollLeft:o,dpr:s,kLineCenters:c}=t,l=i,u=e?.getSharedState(tc);if(!u||u.visibleMin>u.visibleMax||u.series.length===0)return;let{period:d}=u.params,f=u.series;if(l.length<d)return;n.save(),n.translate(-o,0);let p=Math.max(a.start,d-1),m=Math.min(a.end,l.length),h=ka.UPPER,g=ka.MIDDLE,_=ka.LOWER;n.fillStyle=ka.BAND_FILL,n.beginPath();let v=!0;for(let e=p;e<m;e++){let t=f[e];if(!t)continue;let i=c[e-a.start];if(i===void 0)continue;let o=r.yAxis.priceToY(t.upper),l=i,u=Z(o,s);v?(n.moveTo(l,u),v=!1):n.lineTo(l,u)}for(let e=m-1;e>=p;e--){let t=f[e];if(!t)continue;let i=c[e-a.start];if(i===void 0)continue;let o=r.yAxis.priceToY(t.lower),l=i,u=Z(o,s);n.lineTo(l,u)}n.closePath(),n.fill(),n.lineWidth=1,n.lineJoin=`round`,n.lineCap=`round`;let y=(e,t)=>{n.strokeStyle=t,n.beginPath();let i=!0;for(let t=p;t<m;t++){let o=f[t];if(!o)continue;let l=c[t-a.start];if(l===void 0)continue;let u=r.yAxis.priceToY(o[e]),d=l,p=Z(u,s);i?(n.moveTo(d,p),i=!1):n.lineTo(d,p)}n.stroke()};y(`upper`,h),y(`middle`,g),y(`lower`,_),n.restore()},getConfig(){let t=e?.getSharedState(tc);return t?{...t.params}:{}},setConfig(e){}}}var Cc=`"Trebuchet MS", Roboto, Ubuntu, sans-serif`;function wc(e,t){return`${t?.bold?`bold `:``}${e}px ${Cc}`}function Tc(e,t){e.font!==t&&(e.font=t)}var Ec=new Map,Dc=512;function Oc(e,t){let n=`${e.font}\n${t}`,r=Ec.get(n);if(r!==void 0)return r;let i=e.measureText(t).width;return Ec.size>=Dc&&Ec.clear(),Ec.set(n,i),i}function kc(e){let t={yPaddingPx:e.yPaddingPx,indicators:{MA:{enabled:!0,params:{}},BOLL:{enabled:!1,params:{period:20,multiplier:2}},EXPMA:{enabled:!1,params:{fastPeriod:12,slowPeriod:50}},ENE:{enabled:!1,params:{period:10,deviation:11}}}},n=null;return{name:`mainIndicatorLegend`,version:`2.0.0`,description:`主图指标图例渲染器(MA 数据来自 StateStore)`,debugName:`主图指标图例`,paneId:`main`,priority:G.FOREGROUND,enabled:!0,onInstall(e){n=e},getDeclaredNamespaces(){return[Qs,$s,ec,tc]},draw(e){let{ctx:r,data:i,range:a,crosshairIndex:o}=e,s=i;if(!s.length)return;r.save(),Tc(r,wc(12)),r.textAlign=`left`;let c=o??Math.min(a.end-1,s.length-1),l=[];t.indicators.MA?.enabled&&l.push({draw:e=>{let i=[],a=n?.getSharedState(Qs);if(a&&a.visibleMin<=a.visibleMax)for(let e of a.enabledPeriods){let t=`MA${e}`,n=a.series[e]?.[c];i.push({label:`MA${e}`,color:ya[t]||ya.MA5,value:n})}if(i.length>0){let n=12,a=t.yPaddingPx/2+12+e*18;r.fillStyle=J.NEUTRAL,r.fillText(`MA`,n,a),n+=Oc(r,`MA`)+10;for(let e of i){let t=typeof e.value==`number`?` ${e.value.toFixed(2)}`:``,i=`${e.label}${t}`;r.fillStyle=e.color,r.fillText(i,n,a),n+=Oc(r,i)+10}}}}),t.indicators.BOLL?.enabled&&l.push({draw:e=>{let i=n?.getSharedState($s),a=i?.series[c],o=i?.params.period??20,s=i?.params.multiplier??2,l=12,u=t.yPaddingPx/2+12+e*18,d=`BOLL(${o},${s})`;if(r.fillStyle=J.NEUTRAL,r.fillText(d,l,u),l+=Oc(r,d)+10,a){let e=`上轨:${a.upper.toFixed(2)}`;r.fillStyle=ba.UPPER,r.fillText(e,l,u),l+=Oc(r,e)+10;let t=`中轨:${a.middle.toFixed(2)}`;r.fillStyle=ba.MIDDLE,r.fillText(t,l,u),l+=Oc(r,t)+10;let n=`下轨:${a.lower.toFixed(2)}`;r.fillStyle=ba.LOWER,r.fillText(n,l,u)}}}),t.indicators.EXPMA?.enabled&&l.push({draw:e=>{let i=n?.getSharedState(ec),a=i?.series[c],o=i?.params.fastPeriod??12,s=i?.params.slowPeriod??50,l=12,u=t.yPaddingPx/2+12+e*18,d=`EXPMA(${o},${s})`;if(r.fillStyle=J.NEUTRAL,r.fillText(d,l,u),l+=Oc(r,d)+10,a){let e=`快:${a.fast.toFixed(2)}`;r.fillStyle=Oa.FAST,r.fillText(e,l,u),l+=Oc(r,e)+10;let t=`慢:${a.slow.toFixed(2)}`;r.fillStyle=Oa.SLOW,r.fillText(t,l,u)}}}),t.indicators.ENE?.enabled&&l.push({draw:e=>{let i=n?.getSharedState(tc),a=i?.series[c],o=i?.params.period??10,s=i?.params.deviation??11,l=12,u=t.yPaddingPx/2+12+e*18,d=`ENE(${o},${s})`;if(r.fillStyle=J.NEUTRAL,r.fillText(d,l,u),l+=Oc(r,d)+10,a){let e=`上轨:${a.upper.toFixed(2)}`;r.fillStyle=ka.UPPER,r.fillText(e,l,u),l+=Oc(r,e)+10;let t=`中轨:${a.middle.toFixed(2)}`;r.fillStyle=ka.MIDDLE,r.fillText(t,l,u),l+=Oc(r,t)+10;let n=`下轨:${a.lower.toFixed(2)}`;r.fillStyle=ka.LOWER,r.fillText(n,l,u)}}}),l.forEach((e,t)=>e.draw(t)),r.restore()},getConfig(){return{yPaddingPx:t.yPaddingPx,indicators:{...t.indicators}}},setConfig(e){if(typeof e.yPaddingPx==`number`&&(t.yPaddingPx=e.yPaddingPx),e.indicators&&typeof e.indicators==`object`)for(let[n,r]of Object.entries(e.indicators))t.indicators[n]||(t.indicators[n]={enabled:!1,params:{}}),r.enabled!==void 0&&(t.indicators[n].enabled=r.enabled),r.params&&(t.indicators[n].params=r.params)}}}function Ac(e,t){let n=Array(e.length),r=2/(t+1);if(e.length===0)return n;n[0]=e[0].close;for(let t=1;t<e.length;t++){let i=e[t];i&&(n[t]=i.close*r+n[t-1]*(1-r))}return n}function jc(e,t){let n=Array(e.length),r=2/(t+1),i=e.findIndex(e=>e!==void 0);if(i===-1)return n;n[i]=e[i];for(let t=i+1;t<e.length;t++){let i=e[t],a=n[t-1];i===void 0||a===void 0||(n[t]=i*r+a*(1-r))}return n}function Mc(e,t,n,r){let i=Array(e.length);if(e.length<n)return i;let a=Ac(e,t),o=Ac(e,n),s=Array(e.length);for(let t=0;t<e.length;t++){let e=a[t],n=o[t];e!==void 0&&n!==void 0&&(s[t]=e-n)}let c=jc(s,r);for(let t=0;t<e.length;t++){let e=s[t],n=c[t];e!==void 0&&n!==void 0&&(i[t]={dif:e,dea:n,macd:(e-n)*2})}return i}function Nc(e={}){let{paneId:t=`sub`,config:n={}}=e,r=Q(`macd`,t),i=null,a={fastPeriod:12,slowPeriod:26,signalPeriod:9,showDIF:!0,showDEA:!0,showBAR:!0,...n},o=null,s=0,c=0,l=0,u=[];function d(e){return(o!==e||s!==a.fastPeriod||c!==a.slowPeriod||l!==a.signalPeriod)&&(u=Mc(e,a.fastPeriod,a.slowPeriod,a.signalPeriod),o=e,s=a.fastPeriod,c=a.slowPeriod,l=a.signalPeriod),u}return{name:`macd_${t}`,version:`1.0.0`,description:`MACD 指标渲染器`,debugName:`MACD`,paneId:t,priority:G.INDICATOR,onInstall(e){i=e},getDeclaredNamespaces(){return[r]},draw(e){let{ctx:n,pane:o,data:s,range:c,scrollLeft:l,dpr:u}=e,f=s;if(f.length<a.slowPeriod)return;let p=d(f),m=-1/0,h=1/0;for(let e=c.start;e<c.end&&e<p.length;e++){let t=p[e];t&&(m=Math.max(m,t.dif,t.dea,t.macd),h=Math.min(h,t.dif,t.dea,t.macd))}if(!Number.isFinite(m)||!Number.isFinite(h))return;let g=Math.max(.05,(m-h)*.1),_=h-g,v=m+g;v-_;let y=c.end-1,b=y>=0&&y<p.length?p[y]:null,x={valueMin:_,valueMax:v,timestamp:Date.now(),latestValues:b?{dif:b.dif,dea:b.dea,macd:b.macd}:void 0};i?.setSharedState(r,x,`macd_${t}`);let S=o.yAxis.getDisplayRange({minPrice:_,maxPrice:v}),C=S.minPrice,w=S.maxPrice-C||1,T=o.height-(0-C)/w*o.height,E=Math.max(c.start,a.slowPeriod-1),D=Math.min(c.end,f.length);if(a.showBAR){let t=Math.round(T*u)/u,r=[],i=[],a=[],s=[];for(let n=E;n<D;n++){let l=p[n];if(!l)continue;let d=e.kBarRects[n-c.start];if(!d)continue;let f=o.height-(l.macd-C)/w*o.height,m=l.macd>=0,h=n>0?p[n-1]:null,g=h?l.macd>=h.macd:!0,_=Math.round(f*u)/u,v=1/u;if(m){let e=t-_,n=e<=0?v:Math.max(e,v),a=e<=0?t-v:t-n,o={x:d.x,y:a,width:d.width,height:n};g?r.push(o):i.push(o)}else{let e=_-t,n=e<=0?v:Math.max(e,v),r={x:d.x,y:t,width:d.width,height:n};g?s.push(r):a.push(r)}}Pc(e,r,i,a,s)?Ic(n,e):Fc(n,l,r,i,a,s)}if(n.save(),n.translate(-l,0),a.showDIF){n.strokeStyle=Y.DIF,n.lineWidth=1,n.lineJoin=`round`,n.lineCap=`round`,n.beginPath();let t=!0;for(let r=E;r<D;r++){let i=p[r];if(!i)continue;let a=e.kLineCenters[r-c.start];if(a===void 0)continue;let s=o.height-(i.dif-C)/w*o.height,l=a,d=Z(s,u);t?(n.moveTo(l,d),t=!1):n.lineTo(l,d)}n.stroke()}if(a.showDEA){n.strokeStyle=Y.DEA,n.lineWidth=1,n.lineJoin=`round`,n.lineCap=`round`,n.beginPath();let t=!0;for(let r=E;r<D;r++){let i=p[r];if(!i)continue;let a=e.kLineCenters[r-c.start];if(a===void 0)continue;let s=o.height-(i.dea-C)/w*o.height,l=a,d=Z(s,u);t?(n.moveTo(l,d),t=!1):n.lineTo(l,d)}n.stroke()}n.restore()},onDataUpdate(){o=null},getConfig(){return{...a}},setConfig(e){`fastPeriod`in e&&e.fastPeriod!==a.fastPeriod&&(o=null),`slowPeriod`in e&&e.slowPeriod!==a.slowPeriod&&(o=null),`signalPeriod`in e&&e.signalPeriod!==a.signalPeriod&&(o=null),Object.assign(a,e)}}}function Pc(e,t,n,r,i){let a=e.candleWebGLSurface;if(!a||!a.isAvailable())return!1;a.clear();let o=t.length===0||a.drawRects(t,Y.BAR_UP,e.scrollLeft),s=n.length===0||a.drawRects(n,Y.BAR_UP_LIGHT,e.scrollLeft),c=r.length===0||a.drawRects(r,Y.BAR_DOWN,e.scrollLeft),l=i.length===0||a.drawRects(i,Y.BAR_DOWN_LIGHT,e.scrollLeft);return o&&s&&c&&l}function Fc(e,t,n,r,i,a){e.save(),e.translate(-t,0),e.fillStyle=Y.BAR_UP;for(let t of n)e.fillRect(t.x,t.y,t.width,t.height);e.fillStyle=Y.BAR_UP_LIGHT;for(let t of r)e.fillRect(t.x,t.y,t.width,t.height);e.fillStyle=Y.BAR_DOWN;for(let t of i)e.fillRect(t.x,t.y,t.width,t.height);e.fillStyle=Y.BAR_DOWN_LIGHT;for(let t of a)e.fillRect(t.x,t.y,t.width,t.height);e.restore()}function Ic(e,t){let n=t.candleWebGLSurface;if(!n)return;let r=n.getCanvas();r.width<=0||r.height<=0||e.drawImage(r,0,0,r.width,r.height,0,0,r.width/t.dpr,r.height/t.dpr)}function Lc(e,t,n=12,r=26,i=9){return t<r||t>=e.length?null:Mc(e,n,r,i)[t]??null}function Rc(e,t,n=12,r=26,i=9){let a=Lc(e,t,n,r,i);return a?{name:`MACD`,params:[n,r,i],values:[{label:`DIF`,value:a.dif,color:Y.DIF},{label:`DEA`,value:a.dea,color:Y.DEA},{label:`MACD`,value:a.macd,color:a.macd>=0?Y.BAR_UP:Y.BAR_DOWN}]}:null}function zc(e={}){let{paneId:t=`sub`}=e,n=null;return{name:`rsi_${t}`,version:`2.0.0`,description:`RSI 相对强弱指标渲染器(无状态)`,debugName:`RSI`,paneId:t,priority:G.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){return[nc(t)]},draw(e){let{ctx:r,pane:i,range:a,scrollLeft:o,dpr:s,kLineCenters:c}=e,l=nc(t),u=n?.getSharedState(l);if(!u||u.visibleMin>u.visibleMax)return;let{valueMin:d,valueMax:f,params:p,series:m}=u;f-d;let h=i.yAxis.getDisplayRange({minPrice:d,maxPrice:f}),g=h.minPrice,_=h.maxPrice-g||1;r.save(),r.translate(-o,0);let v=i.height-(80-g)/_*i.height,y=i.height-(50-g)/_*i.height,b=i.height-(20-g)/_*i.height,x=o,S=o+e.paneWidth;r.strokeStyle=`rgba(0, 0, 0, 0.1)`,r.lineWidth=1,r.setLineDash([4,4]),r.beginPath(),r.moveTo(x,v),r.lineTo(S,v),r.moveTo(x,y),r.lineTo(S,y),r.moveTo(x,b),r.lineTo(S,b),r.stroke(),r.setLineDash([]);let C=Math.max(a.start,p.period1),w=Math.min(a.end,c.length+a.start),T=(e,t)=>{r.strokeStyle=t,r.lineWidth=1,r.lineJoin=`round`,r.lineCap=`round`,r.beginPath();let n=!0;for(let t=C;t<w;t++){let o=e[t];if(o===void 0)continue;let l=c[t-a.start];if(l===void 0)continue;let u=i.height-(o-g)/_*i.height,d=l,f=Z(u,s);n?(r.moveTo(d,f),n=!1):r.lineTo(d,f)}r.stroke()};p.showRSI1&&m[p.period1]&&T(m[p.period1],Sa.RSI1),p.showRSI2&&m[p.period2]&&T(m[p.period2],Sa.RSI2),p.showRSI3&&m[p.period3]&&T(m[p.period3],Sa.RSI3),r.restore()},getConfig(){let e=nc(t),r=n?.getSharedState(e);return r?{...r.params}:{}},setConfig(e){}}}function Bc(e,t,n,r,i,a=`sub_RSI`){let o=nc(a),s=i.getSharedState(o);if(!s)return null;let c=s.series[t]?.[e],l=s.series[n]?.[e],u=s.series[r]?.[e],d=[];return c!==void 0&&d.push({label:`RSI${t}`,value:c,color:Sa.RSI1}),l!==void 0&&d.push({label:`RSI${n}`,value:l,color:Sa.RSI2}),u!==void 0&&d.push({label:`RSI${r}`,value:u,color:Sa.RSI3}),d.length===0?null:{name:`RSI`,params:[t,n,r],values:d}}function Vc(e={}){let{paneId:t=`sub`}=e,n=rc(t),r=null;return{name:`cci_${t}`,version:`2.0.0`,description:`CCI 顺势指标渲染器(无状态)`,debugName:`CCI`,paneId:t,priority:G.MAIN,onInstall(e){r=e},getDeclaredNamespaces(){return[n]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,dpr:s,kLineCenters:c}=e,l=r?.getSharedState(n);if(!l||l.visibleMin>l.visibleMax)return;let{valueMin:u,valueMax:d,params:f,series:p}=l;d-u;let m=i.yAxis.getDisplayRange({minPrice:u,maxPrice:d}),h=m.minPrice,g=m.maxPrice-h||1,_=i.height-(0-h)/g*i.height;t.save(),t.translate(-o,0);let v=i.height-(100-h)/g*i.height,y=i.height-(-100-h)/g*i.height,b=o,x=o+e.paneWidth;t.strokeStyle=Ca.OVERBOUGHT,t.lineWidth=1,t.setLineDash([4,4]),t.beginPath(),t.moveTo(b,v),t.lineTo(x,v),t.stroke(),t.strokeStyle=Ca.OVERSOLD,t.beginPath(),t.moveTo(b,y),t.lineTo(x,y),t.stroke(),t.strokeStyle=`rgba(0, 0, 0, 0.1)`,t.beginPath(),t.moveTo(b,_),t.lineTo(x,_),t.stroke(),t.setLineDash([]);let S=Math.max(a.start,f.period-1),C=Math.min(a.end,p.length);if(f.showCCI){t.strokeStyle=Ca.CCI,t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,t.beginPath();let e=!0;for(let n=S;n<C;n++){let r=p[n];if(r===void 0)continue;let o=c[n-a.start];if(o===void 0)continue;let l=i.height-(r-h)/g*i.height,u=o,d=Z(l,s);e?(t.moveTo(u,d),e=!1):t.lineTo(u,d)}t.stroke()}t.restore()},getConfig(){return r?.getSharedState(n)?.params??{}},setConfig(){}}}function Hc(e,t,n,r=`sub_CCI`){let i=n.getSharedState(rc(r));if(!i)return null;let a=i.series[e];return a===void 0?null:{name:`CCI`,params:[t],values:[{label:`CCI`,value:a,color:Ca.CCI}]}}function Uc(e={}){let{paneId:t=`sub`}=e,n=ic(t),r=null;return{name:`stoch_${t}`,version:`2.0.0`,description:`STOCH 随机指标渲染器(无状态)`,debugName:`STOCH`,paneId:t,priority:G.MAIN,onInstall(e){r=e},getDeclaredNamespaces(){return[n]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,dpr:s,kLineCenters:c}=e,l=r?.getSharedState(n);if(!l||l.visibleMin>l.visibleMax)return;let{valueMin:u,valueMax:d,params:f,series:p}=l;d-u;let m=i.yAxis.getDisplayRange({minPrice:u,maxPrice:d}),h=m.minPrice,g=m.maxPrice-h||1;t.save(),t.translate(-o,0);let _=i.height-(80-h)/g*i.height,v=i.height-(20-h)/g*i.height,y=o,b=o+e.paneWidth;t.strokeStyle=`rgba(0, 0, 0, 0.1)`,t.lineWidth=1,t.setLineDash([4,4]),t.beginPath(),t.moveTo(y,_),t.lineTo(b,_),t.moveTo(y,v),t.lineTo(b,v),t.stroke(),t.setLineDash([]);let x=Math.max(a.start,f.n+f.m-2),S=Math.min(a.end,p.length);if(f.showK){t.strokeStyle=wa.K,t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,t.beginPath();let e=!0;for(let n=x;n<S;n++){let r=p[n];if(!r)continue;let o=c[n-a.start];if(o===void 0)continue;let l=i.height-(r.k-h)/g*i.height,u=o,d=Z(l,s);e?(t.moveTo(u,d),e=!1):t.lineTo(u,d)}t.stroke()}if(f.showD){t.strokeStyle=wa.D,t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,t.beginPath();let e=!0;for(let n=x;n<S;n++){let r=p[n];if(!r)continue;let o=c[n-a.start];if(o===void 0)continue;let l=i.height-(r.d-h)/g*i.height,u=o,d=Z(l,s);e?(t.moveTo(u,d),e=!1):t.lineTo(u,d)}t.stroke()}t.restore()},getConfig(){return r?.getSharedState(n)?.params??{}},setConfig(){}}}function Wc(e,t,n,r,i=`sub_STOCH`){let a=r.getSharedState(ic(i));if(!a)return null;let o=a.series[e];if(!o||o.k===void 0)return null;let s=[];return a.params.showK&&s.push({label:`K`,value:o.k,color:wa.K}),a.params.showD&&s.push({label:`D`,value:o.d,color:wa.D}),s.length===0?null:{name:`STOCH`,params:[t,n],values:s}}function Gc(e={}){let{paneId:t=`sub`}=e,n=ac(t),r=null;return{name:`mom_${t}`,version:`2.0.0`,description:`MOM 动量指标渲染器(无状态)`,debugName:`MOM`,paneId:t,priority:G.MAIN,onInstall(e){r=e},getDeclaredNamespaces(){return[n]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,dpr:s,kLineCenters:c}=e,l=r?.getSharedState(n);if(!l||l.visibleMin>l.visibleMax)return;let{valueMin:u,valueMax:d,params:f,series:p}=l;d-u;let m=i.yAxis.getDisplayRange({minPrice:u,maxPrice:d}),h=m.minPrice,g=m.maxPrice-h||1,_=i.height-(0-h)/g*i.height;t.save(),t.translate(-o,0);let v=o,y=o+e.paneWidth;t.strokeStyle=Ta.ZERO,t.lineWidth=1,t.beginPath(),t.moveTo(v,_),t.lineTo(y,_),t.stroke();let b=Math.max(a.start,f.period),x=Math.min(a.end,p.length);if(f.showMOM){t.strokeStyle=Ta.MOM,t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,t.beginPath();let e=!0;for(let n=b;n<x;n++){let r=p[n];if(r===void 0)continue;let o=c[n-a.start];if(o===void 0)continue;let l=i.height-(r-h)/g*i.height,u=o,d=Z(l,s);e?(t.moveTo(u,d),e=!1):t.lineTo(u,d)}t.stroke()}t.restore()},getConfig(){return r?.getSharedState(n)?.params??{}},setConfig(){}}}function Kc(e,t,n,r=`sub_MOM`){let i=n.getSharedState(ac(r));if(!i)return null;let a=i.series[e];return a===void 0?null:{name:`MOM`,params:[t],values:[{label:`MOM`,value:a,color:Ta.MOM}]}}function qc(e={}){let{paneId:t=`sub`}=e,n=oc(t),r=null;return{name:`wmsr_${t}`,version:`2.0.0`,description:`WMSR 威廉指标渲染器(无状态)`,debugName:`WMSR`,paneId:t,priority:G.MAIN,onInstall(e){r=e},getDeclaredNamespaces(){return[n]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,dpr:s,kLineCenters:c}=e,l=r?.getSharedState(n);if(!l||l.visibleMin>l.visibleMax)return;let{valueMin:u,valueMax:d,params:f,series:p}=l;d-u;let m=i.yAxis.getDisplayRange({minPrice:u,maxPrice:d}),h=m.minPrice,g=m.maxPrice-h||1;t.save(),t.translate(-o,0);let _=i.height-(-20-h)/g*i.height,v=i.height-(-80-h)/g*i.height,y=i.height-(-50-h)/g*i.height,b=o,x=o+e.paneWidth;t.strokeStyle=Ea.OVERBOUGHT,t.lineWidth=1,t.setLineDash([4,4]),t.beginPath(),t.moveTo(b,_),t.lineTo(x,_),t.stroke(),t.strokeStyle=Ea.OVERSOLD,t.beginPath(),t.moveTo(b,v),t.lineTo(x,v),t.stroke(),t.strokeStyle=`rgba(0, 0, 0, 0.1)`,t.beginPath(),t.moveTo(b,y),t.lineTo(x,y),t.stroke(),t.setLineDash([]);let S=Math.max(a.start,f.period-1),C=Math.min(a.end,p.length);if(f.showWMSR){t.strokeStyle=Ea.WMSR,t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,t.beginPath();let e=!0;for(let n=S;n<C;n++){let r=p[n];if(r===void 0)continue;let o=c[n-a.start];if(o===void 0)continue;let l=i.height-(r-h)/g*i.height,u=o,d=Z(l,s);e?(t.moveTo(u,d),e=!1):t.lineTo(u,d)}t.stroke()}t.restore()},getConfig(){return r?.getSharedState(n)?.params??{}},setConfig(){}}}function Jc(e,t,n,r=`sub_WMSR`){let i=n.getSharedState(oc(r));if(!i)return null;let a=i.series[e];return a===void 0?null:{name:`WMSR`,params:[t],values:[{label:`WMSR`,value:a,color:Ea.WMSR}]}}function Yc(e={}){let{paneId:t=`sub`}=e,n=sc(t),r=null;return{name:`kst_${t}`,version:`2.0.0`,description:`KST 确知指标渲染器(无状态)`,debugName:`KST`,paneId:t,priority:G.MAIN,onInstall(e){r=e},getDeclaredNamespaces(){return[n]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,dpr:s,kLineCenters:c}=e,l=r?.getSharedState(n);if(!l||l.visibleMin>l.visibleMax)return;let{valueMin:u,valueMax:d,params:f,series:p}=l;d-u;let m=i.yAxis.getDisplayRange({minPrice:u,maxPrice:d}),h=m.minPrice,g=m.maxPrice-h||1,_=i.height-(0-h)/g*i.height;t.save(),t.translate(-o,0);let v=o,y=o+e.paneWidth;t.strokeStyle=`rgba(0, 0, 0, 0.1)`,t.lineWidth=1,t.beginPath(),t.moveTo(v,_),t.lineTo(y,_),t.stroke();let b=Math.max(a.start,f.roc4+15+f.signalPeriod-1),x=Math.min(a.end,p.length);if(f.showKST){t.strokeStyle=Da.KST,t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,t.beginPath();let e=!0;for(let n=b;n<x;n++){let r=p[n];if(!r)continue;let o=c[n-a.start];if(o===void 0)continue;let l=i.height-(r.kst-h)/g*i.height,u=o,d=Z(l,s);e?(t.moveTo(u,d),e=!1):t.lineTo(u,d)}t.stroke()}if(f.showSignal){t.strokeStyle=Da.SIGNAL,t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,t.beginPath();let e=!0;for(let n=b;n<x;n++){let r=p[n];if(!r)continue;let o=c[n-a.start];if(o===void 0)continue;let l=i.height-(r.signal-h)/g*i.height,u=o,d=Z(l,s);e?(t.moveTo(u,d),e=!1):t.lineTo(u,d)}t.stroke()}t.restore()},getConfig(){return r?.getSharedState(n)?.params??{}},setConfig(){}}}function Xc(e,t,n,r,i,a,o,s=`sub_KST`){let c=o.getSharedState(sc(s));if(!c)return null;let l=c.series[e];if(!l)return null;let u=[];return c.params.showKST&&u.push({label:`KST`,value:l.kst,color:Da.KST}),c.params.showSignal&&u.push({label:`Signal`,value:l.signal,color:Da.SIGNAL}),u.length===0?null:{name:`KST`,params:[t,n,r,i,a],values:u}}function Zc(e={}){let{paneId:t=`sub`}=e,n=cc(t),r=null;return{name:`fastk_${t}`,version:`2.0.0`,description:`FASTK 快速随机指标渲染器(无状态)`,debugName:`FASTK`,paneId:t,priority:G.MAIN,onInstall(e){r=e},getDeclaredNamespaces(){return[n]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,dpr:s,kLineCenters:c}=e,l=r?.getSharedState(n);if(!l||l.visibleMin>l.visibleMax)return;let{valueMin:u,valueMax:d,params:f,series:p}=l;d-u;let m=i.yAxis.getDisplayRange({minPrice:u,maxPrice:d}),h=m.minPrice,g=m.maxPrice-h||1;t.save(),t.translate(-o,0);let _=i.height-(80-h)/g*i.height,v=i.height-(20-h)/g*i.height,y=o,b=o+e.paneWidth;t.strokeStyle=`rgba(0, 0, 0, 0.1)`,t.lineWidth=1,t.setLineDash([4,4]),t.beginPath(),t.moveTo(y,_),t.lineTo(b,_),t.moveTo(y,v),t.lineTo(b,v),t.stroke(),t.setLineDash([]);let x=Math.max(a.start,f.period-1),S=Math.min(a.end,p.length);if(f.showFASTK){t.strokeStyle=wa.K,t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,t.beginPath();let e=!0;for(let n=x;n<S;n++){let r=p[n];if(r===void 0)continue;let o=c[n-a.start];if(o===void 0)continue;let l=i.height-(r-h)/g*i.height,u=o,d=Z(l,s);e?(t.moveTo(u,d),e=!1):t.lineTo(u,d)}t.stroke()}t.restore()},getConfig(){return r?.getSharedState(n)?.params??{}},setConfig(){}}}function Qc(e,t,n,r=`sub_FASTK`){let i=n.getSharedState(cc(r));if(!i)return null;let a=i.series[e];return a===void 0?null:{name:`FASTK`,params:[t],values:[{label:`FASTK`,value:a,color:wa.K}]}}function $c(e){let{indicatorId:t,paneId:n}=e;switch(t){case`VOLUME`:return uc({paneId:n});case`MACD`:return Nc({paneId:n});case`RSI`:return zc({paneId:n});case`CCI`:return Vc({paneId:n});case`STOCH`:return Uc({paneId:n});case`MOM`:return Gc({paneId:n});case`WMSR`:return qc({paneId:n});case`KST`:return Yc({paneId:n});case`FASTK`:return Zc({paneId:n});default:throw Error(`Unknown indicator: ${t}`)}}var el=8,tl=6,nl=class e{chart;activeTool=`cursor`;pendingAnchors=[];drawings=[];callbacks={};previewDrawingId=`__preview__`;dragState=null;selectedDrawingId=null;static SINGLE_ANCHOR_TOOLS=[`h-line`,`h-ray`,`v-line`,`crosshair-line`];static DOUBLE_ANCHOR_TOOLS=[`trend-line`,`ray`,`info-line`,`regression-channel`];static TRIPLE_ANCHOR_TOOLS=[`parallel-channel`,`flat-line`,`disjoint-channel`];constructor(e){this.chart=e}setCallbacks(e){this.callbacks=e}getActiveTool(){return this.activeTool}setTool(e){this.activeTool=e,this.pendingAnchors=[],this.removePreview(),this.dragState=null,this.setSelected(null),this.callbacks.onToolChange?.(e)}getDrawings(){return this.drawings}setDrawings(e){this.drawings=e,this.chart.setDrawings(e)}clear(){this.pendingAnchors=[],this.removePreview(),this.dragState=null,this.setSelected(null)}getSelectedDrawing(){return this.selectedDrawingId?this.drawings.find(e=>e.id===this.selectedDrawingId)??null:null}updateDrawingStyle(e,t){this.drawings=this.drawings.map(n=>n.id===e?{...n,style:{...n.style,...t}}:n),this.chart.setDrawings(this.drawings)}removeDrawing(e){this.drawings=this.drawings.filter(t=>t.id!==e),this.selectedDrawingId===e&&this.setSelected(null),this.chart.setDrawings(this.drawings)}onPointerMove(e,t){return this.dragState?this.handleDragMove(e,t):this.activeTool===`cursor`?!1:this.handlePreviewMove(e,t)}onPointerDown(t,n){if(this.activeTool===`cursor`)return this.handleCursorDown(t,n);let r=this.resolveAnchorFromPointer(t,n);if(!r)return!1;if(e.SINGLE_ANCHOR_TOOLS.includes(this.activeTool))return this.createSingleAnchorDrawing(r),!0;let i=e.DOUBLE_ANCHOR_TOOLS.includes(this.activeTool),a=e.TRIPLE_ANCHOR_TOOLS.includes(this.activeTool);if(!i&&!a)return!1;this.pendingAnchors.push(r);let o=i?2:3;return this.pendingAnchors.length>=o&&(this.createMultiAnchorDrawing(this.pendingAnchors),this.pendingAnchors=[]),!0}onPointerUp(e,t){return this.dragState?(this.dragState=null,!0):!1}handleCursorDown(e,t){let n=t.getBoundingClientRect(),r=e.clientX-n.left,i=e.clientY-n.top,a=this.hitTest(r,i);return a?(this.setSelected(a.drawing),this.dragState={drawingId:a.drawing.id,anchorIndex:`anchorIndex`in a?a.anchorIndex:void 0,snapshot:a.drawing.anchors.map(e=>({...e})),startMouse:{x:r,y:i}},!0):(this.setSelected(null),!1)}handleDragMove(e,t){if(!this.dragState)return!1;let n=this.drawings.find(e=>e.id===this.dragState.drawingId);if(!n)return this.dragState=null,!1;let r=this.resolveAnchorFromPointer(e,t);if(this.dragState.anchorIndex!==void 0){if(r){let e=this.dragState.anchorIndex;n.anchors[e]={...n.anchors[e],index:r.index,time:r.time,price:r.price},n.kind===`flat-line`&&e===1&&n.anchors.length>=3&&(n.anchors[2]={...n.anchors[2],index:r.index,time:r.time})}}else{let r=t.getBoundingClientRect(),i=e.clientX-r.left,a=e.clientY-r.top,o=i-this.dragState.startMouse.x,s=a-this.dragState.startMouse.y;for(let e=0;e<n.anchors.length;e++){let t=this.dragState.snapshot[e],r=this.anchorToScreen(t);if(!r)continue;let i=r.x+o,a=r.y+s,c=this.screenToAnchor(i,a);c&&(n.anchors[e]={...n.anchors[e],index:c.index,time:c.time,price:c.price})}}return this.chart.setDrawings([...this.drawings]),!0}handlePreviewMove(t,n){let r=this.resolveAnchorFromPointer(t,n);if(!r)return this.removePreview(),!1;let i=e.SINGLE_ANCHOR_TOOLS.includes(this.activeTool),a=e.DOUBLE_ANCHOR_TOOLS.includes(this.activeTool),o=e.TRIPLE_ANCHOR_TOOLS.includes(this.activeTool);if(!i&&!a&&!o)return!1;let s;if(i)s={id:this.previewDrawingId,kind:this.getDrawingKind(this.activeTool),paneId:`main`,visible:!0,anchors:[{id:`${this.previewDrawingId}-a`,index:r.index,time:r.time,price:r.price}],params:{},style:{stroke:`#2962ff`,strokeWidth:1,strokeStyle:`dashed`}};else if(a&&this.pendingAnchors.length>=1)s={id:this.previewDrawingId,kind:this.getDrawingKind(this.activeTool),paneId:`main`,visible:!0,anchors:[{id:`${this.previewDrawingId}-a`,index:this.pendingAnchors[0].index,time:this.pendingAnchors[0].time,price:this.pendingAnchors[0].price},{id:`${this.previewDrawingId}-b`,index:r.index,time:r.time,price:r.price}],params:this.activeTool===`regression-channel`?{sigma:2}:{},style:{stroke:`#2962ff`,strokeWidth:1,strokeStyle:`dashed`,...this.activeTool===`regression-channel`?{fillOpacity:.1}:{}}};else if(o){if(this.pendingAnchors.length===0)return!1;if(this.pendingAnchors.length===1)s={id:this.previewDrawingId,kind:`trend-line`,paneId:`main`,visible:!0,anchors:[{id:`${this.previewDrawingId}-a`,index:this.pendingAnchors[0].index,time:this.pendingAnchors[0].time,price:this.pendingAnchors[0].price},{id:`${this.previewDrawingId}-b`,index:r.index,time:r.time,price:r.price}],params:{},style:{stroke:`#2962ff`,strokeWidth:1,strokeStyle:`dashed`}};else{let e=this.activeTool===`flat-line`?{id:`${this.previewDrawingId}-c`,index:this.pendingAnchors[1].index,time:this.pendingAnchors[1].time,price:r.price}:{id:`${this.previewDrawingId}-c`,index:r.index,time:r.time,price:r.price};s={id:this.previewDrawingId,kind:this.getDrawingKind(this.activeTool),paneId:`main`,visible:!0,anchors:[{id:`${this.previewDrawingId}-a`,index:this.pendingAnchors[0].index,time:this.pendingAnchors[0].time,price:this.pendingAnchors[0].price},{id:`${this.previewDrawingId}-b`,index:this.pendingAnchors[1].index,time:this.pendingAnchors[1].time,price:this.pendingAnchors[1].price},e],params:{},style:{stroke:`#2962ff`,strokeWidth:1,strokeStyle:`dashed`,fillOpacity:.1}}}}else return!1;return this.drawings=this.drawings.filter(e=>e.id!==this.previewDrawingId),this.drawings=[...this.drawings,s],this.chart.setDrawings(this.drawings),!0}hitTest(e,t){let n=this.drawings.filter(e=>e.id!==this.previewDrawingId&&e.visible),r=new Map;for(let i of n){if(i.kind===`regression-channel`&&i.anchors.length>=2){let n=this.hitTestRegressionEndpoints(i,e,t,r);if(n)return n}for(let n=0;n<i.anchors.length;n++){let r=this.anchorToScreen(i.anchors[n]);if(r&&Math.hypot(e-r.x,t-r.y)<=el)return{drawing:i,anchorIndex:n}}}for(let i of n){let n=this.getDrawingLineSegments(i,r);for(let r of n)if(rl(e,t,r.a,r.b)<=tl)return{drawing:i}}return null}getDrawingLineSegments(e,t){let n=this.chart.getViewport();if(!n)return[];if(e.kind===`regression-channel`)return this.getRegressionChannelGeometry(e,t)?.segments??[];if(e.anchors.length===1){let t=this.anchorToScreen(e.anchors[0]);if(!t)return[];let r=this.chart.getPaneRenderers().find(e=>e.getPane().id===`main`)?.getPane();if(!r)return[];let i=n.plotWidth,a=r.height;switch(e.kind){case`horizontal-line`:return[{a:{x:0,y:t.y},b:{x:i,y:t.y}}];case`horizontal-ray`:return[{a:t,b:{x:i,y:t.y}}];case`vertical-line`:return[{a:{x:t.x,y:0},b:{x:t.x,y:a}}];case`cross-line`:return[{a:{x:0,y:t.y},b:{x:i,y:t.y}},{a:{x:t.x,y:0},b:{x:t.x,y:a}}];default:return[]}}let r=e.anchors.map(e=>this.anchorToScreen(e)).filter(Boolean);if(r.length<2)return[];let i=[];if(r.length===2){let t=r[0],a=r[1],o=a.x-t.x,s=a.y-t.y,c=t,l=a,u=this.getExtendMode(e),d=Math.max(n.plotWidth,n.plotHeight)*4;(u===`right`||u===`both`)&&(l={x:a.x+o*d,y:a.y+s*d}),(u===`left`||u===`both`)&&(c={x:t.x-o*d,y:t.y-s*d}),i.push({a:c,b:l})}else if(r.length>=3)switch(e.kind){case`parallel-channel`:{let[e,t,n]=r,a=t.x-e.x,o=t.y-e.y,s={x:n.x+a,y:n.y+o};i.push({a:e,b:t},{a:n,b:s});break}case`flat-line`:{let[e,t,n]=r,a={x:e.x,y:n.y},o={x:t.x,y:n.y};i.push({a:e,b:t}),i.push({a,b:o});break}case`disjoint-channel`:{let[e,t,n]=r,a=t.x-e.x,o=t.y-e.y,s={x:n.x+a,y:n.y-o};i.push({a:e,b:t}),i.push({a:n,b:s});break}default:for(let e=0;e<r.length-1;e++)i.push({a:r[e],b:r[e+1]})}return i}hitTestRegressionEndpoints(e,t,n,r){let i=this.getRegressionChannelGeometry(e,r);if(!i)return null;for(let r of i.endpoints)if(Math.hypot(t-r.point.x,n-r.point.y)<=el)return{drawing:e,anchorIndex:r.anchorIndex};return null}getRegressionChannelGeometry(e,t){let n=t?.get(e.id);if(n!==void 0)return n;let r=this.chart.getData();if(r.length===0||e.anchors.length<2)return t?.set(e.id,null),null;let i=Math.round(e.anchors[0].index),a=Math.round(e.anchors[1].index),o=Math.min(Math.max(i,0),r.length-1),s=Math.min(Math.max(a,0),r.length-1),c=Math.min(o,s),l=Math.max(o,s),u=r.slice(c,l+1),d=fl(u.map(e=>e.close));if(!d)return t?.set(e.id,null),null;let f=e.params?.sigma??2,p=d.stdDev*f,m=d.intercept,h=d.intercept+d.slope*(u.length-1),g=this.anchorToScreen({id:``,index:i,price:m}),_=this.anchorToScreen({id:``,index:a,price:h}),v=this.anchorToScreen({id:``,index:i,price:m+p}),y=this.anchorToScreen({id:``,index:a,price:h+p}),b=this.anchorToScreen({id:``,index:i,price:m-p}),x=this.anchorToScreen({id:``,index:a,price:h-p}),S=[];g&&_&&S.push({a:g,b:_}),v&&y&&S.push({a:v,b:y}),b&&x&&S.push({a:b,b:x});let C=[];g&&C.push({point:g,anchorIndex:0}),_&&C.push({point:_,anchorIndex:1}),v&&C.push({point:v,anchorIndex:0}),y&&C.push({point:y,anchorIndex:1}),b&&C.push({point:b,anchorIndex:0}),x&&C.push({point:x,anchorIndex:1});let w={segments:S,endpoints:C};return t?.set(e.id,w),w}getExtendMode(e){switch(e.kind){case`ray`:return`right`;case`extended-line`:return`both`;default:return`none`}}anchorToScreen(e){let t=this.chart.getViewport();if(!t)return null;let n=this.chart.getOption(),r=this.chart.getCurrentDpr(),{startXPx:i,unitPx:a}=na(n.kWidth,n.kGap,r);if(!Number.isFinite(e.index))return null;let o=(i+e.index*a+(a-1)/2)/r-t.scrollLeft,s=this.chart.getPaneRenderers().find(e=>e.getPane().id===`main`)?.getPane();return s?{x:o,y:s.yAxis.priceToY(e.price)}:null}screenToAnchor(e,t){let n=this.chart.getData();if(!this.chart.getViewport()||n.length===0)return null;let r=this.chart.getLogicalIndexAtX(e);if(r===null)return null;let i=this.chart.getPaneRenderers().find(e=>e.getPane().id===`main`)?.getPane();return i?{index:r,time:this.chart.getTimestampAtLogicalIndex(r)??void 0??void 0,price:i.yAxis.yToPrice(t-i.top)}:null}setSelected(e){let t=e?.id??null;this.selectedDrawingId!==t&&(this.selectedDrawingId=t,this.chart.setSelectedDrawingId(t),this.callbacks.onDrawingSelected?.(e))}removePreview(){this.drawings.some(e=>e.id===this.previewDrawingId)&&(this.drawings=this.drawings.filter(e=>e.id!==this.previewDrawingId),this.chart.setDrawings(this.drawings))}resolveAnchorFromPointer(e,t){let n=this.chart.getData(),r=this.chart.getViewport();if(!r||n.length===0)return null;let i=t.getBoundingClientRect(),a=e.clientX-i.left,o=e.clientY-i.top;if(a<0||o<0||a>r.plotWidth||o>r.plotHeight)return null;let s=this.chart.getPaneRenderers().find(e=>{let t=e.getPane();return t.id===`main`&&o>=t.top&&o<=t.top+t.height})?.getPane();if(!s)return null;let c=this.chart.getLogicalIndexAtX(a);return c===null?null:{index:c,time:this.chart.getTimestampAtLogicalIndex(c)??void 0??void 0,price:s.yAxis.yToPrice(o-s.top)}}createSingleAnchorDrawing(e){this.drawings=this.drawings.filter(e=>e.id!==this.previewDrawingId);let t={id:`drawing-${Date.now()}`,kind:this.getDrawingKind(this.activeTool),paneId:`main`,visible:!0,anchors:[{id:`${Date.now()}-a`,index:e.index,time:e.time,price:e.price}],params:{},style:{stroke:`#2962ff`,strokeWidth:1,strokeStyle:`solid`}};this.drawings=[...this.drawings,t],this.chart.setDrawings(this.drawings),this.callbacks.onDrawingCreated?.(t),this.activeTool=`cursor`,this.callbacks.onToolChange?.(`cursor`)}createMultiAnchorDrawing(e){this.drawings=this.drawings.filter(e=>e.id!==this.previewDrawingId);let t=this.getDrawingKind(this.activeTool),n=t===`regression-channel`?{sigma:2}:{},r=t===`flat-line`&&e.length>=3?[e[0],e[1],{index:e[1].index,time:e[1].time,price:e[2].price}]:e,i=[`parallel-channel`,`regression-channel`,`flat-line`,`disjoint-channel`].includes(t),a={id:`drawing-${Date.now()}`,kind:t,paneId:`main`,visible:!0,anchors:r.map((e,t)=>({id:`${Date.now()}-${String.fromCharCode(97+t)}`,index:e.index,time:e.time,price:e.price})),params:n,style:{stroke:`#2962ff`,strokeWidth:1,strokeStyle:`solid`,...i?{fillOpacity:.1}:{}}};this.drawings=[...this.drawings,a],this.chart.setDrawings(this.drawings),this.callbacks.onDrawingCreated?.(a),this.activeTool=`cursor`,this.callbacks.onToolChange?.(`cursor`)}getDrawingKind(e){switch(e){case`cursor`:throw Error(`cursor is not a drawing kind`);case`h-line`:return`horizontal-line`;case`h-ray`:return`horizontal-ray`;case`v-line`:return`vertical-line`;case`crosshair-line`:return`cross-line`;default:return e}}};function rl(e,t,n,r){let i=r.x-n.x,a=r.y-n.y,o=i*i+a*a;if(o===0)return Math.hypot(e-n.x,t-n.y);let s=((e-n.x)*i+(t-n.y)*a)/o;return s=Math.max(0,Math.min(1,s)),Math.hypot(e-(n.x+s*i),t-(n.y+s*a))}var il=class{drawings=[];selectedId=null;getSelectedId(){return this.selectedId}setSelectedId(e){this.selectedId=e}getAll(){return this.drawings}getVisibleByPane(e){return this.drawings.filter(t=>t.visible&&t.paneId===e).sort((e,t)=>(e.zIndex??0)-(t.zIndex??0))}setAll(e){this.drawings=[...e],this.selectedId&&!this.drawings.some(e=>e.id===this.selectedId)&&(this.selectedId=null)}upsert(e){let t=this.drawings.findIndex(t=>t.id===e.id);if(t>=0){this.drawings[t]=e;return}this.drawings.push(e)}remove(e){this.drawings=this.drawings.filter(t=>t.id!==e)}clear(){this.drawings=[],this.selectedId=null}},al=class{definitions=new Map;register(e){this.definitions.set(e.kind,e)}get(e){return this.definitions.get(e)}compute(e,t){let n=this.get(e.kind);return n?n.compute(e,t):null}};function ol(e,t){if(e.strokeStyle=t?.stroke??`#2962ff`,e.lineWidth=t?.strokeWidth??1,t?.strokeStyle===`dashed`){e.setLineDash([6,4]);return}if(t?.strokeStyle===`dotted`){e.setLineDash([2,3]);return}e.setLineDash([])}function sl(e,t){e.fillStyle=t?.fill??t?.stroke??`#2962ff`,e.globalAlpha=t?.fillOpacity??1}function cl(e,t,n,r,i){let a=(e,t)=>{let n=0;return e<i.left?n|=1:e>i.right&&(n|=2),t<i.top?n|=8:t>i.bottom&&(n|=4),n},o=e,s=t,c=n,l=r;for(;;){let e=a(o,s),t=a(c,l);if(!(e|t))return{a:{x:o,y:s},b:{x:c,y:l}};if(e&t)return null;let n=e||t,r=0,u=0;n&8?(r=o+(c-o)*(i.top-s)/(l-s),u=i.top):n&4?(r=o+(c-o)*(i.bottom-s)/(l-s),u=i.bottom):n&2?(u=s+(l-s)*(i.right-o)/(c-o),r=i.right):(u=s+(l-s)*(i.left-o)/(c-o),r=i.left),n===e?(o=r,s=u):(c=r,l=u)}}function ll(e,t){let{a:n,b:r,extend:i=`none`}=e;if(i===`none`)return cl(n.x,n.y,r.x,r.y,t);let a=r.x-n.x,o=r.y-n.y;if(a===0&&o===0)return null;let s=Math.max(t.right-t.left,t.bottom-t.top)*4,c=n,l=r;return(i===`left`||i===`both`)&&(c={x:n.x-a*s,y:n.y-o*s}),(i===`right`||i===`both`)&&(l={x:r.x+a*s,y:r.y+o*s}),cl(c.x,c.y,l.x,l.y,t)}function ul(e,t){if(!Number.isFinite(e.index))return-1;let n=Math.round(e.index);return n<0||n>=t.length?-1:n}function dl(e,t=2){if(!Number.isFinite(e))return`0`;let n=e.toFixed(t);return e>0?`+${n}`:n}function fl(e){let t=e.length;if(t<2)return null;let n=0,r=0,i=0,a=0;for(let o=0;o<t;o++){let t=o,s=e[o];n+=t,r+=s,i+=t*s,a+=t*t}let o=t*a-n*n;if(o===0)return null;let s=(t*i-n*r)/o,c=(r-s*n)/t,l=0;for(let n=0;n<t;n++){let t=c+s*n,r=e[n]-t;l+=r*r}return{slope:s,intercept:c,stdDev:Math.sqrt(l/t)}}function pl(){return{point(e,t,n){let r=t.style?.pointRadius??4;e.save(),e.fillStyle=t.style?.fill??t.style?.stroke??`#2962ff`,e.beginPath(),e.arc(t.point.x,t.point.y,Math.max(r,1/n),0,Math.PI*2),e.fill(),e.restore()},line(e,t,n,r){let i=ll(t,n);if(!i)return;e.save(),ol(e,t.style);let a=(t.style?.strokeWidth??1)<=1?.5/r:0;if(e.beginPath(),e.moveTo(i.a.x+a,i.a.y+a),e.lineTo(i.b.x+a,i.b.y+a),e.stroke(),t.showEndpoints!==!1){let n=t.style?.pointRadius??4;e.fillStyle=t.style?.stroke??`#2962ff`,e.beginPath(),e.arc(t.a.x,t.a.y,Math.max(n,1/r),0,Math.PI*2),e.fill(),e.beginPath(),e.arc(t.b.x,t.b.y,Math.max(n,1/r),0,Math.PI*2),e.fill()}e.restore()},area(e,t){if(t.points.length!==0){e.save(),sl(e,t.style),e.beginPath(),e.moveTo(t.points[0].x,t.points[0].y);for(let n=1;n<t.points.length;n++){let r=t.points[n];e.lineTo(r.x,r.y)}t.closed&&e.closePath(),e.fill(),e.restore()}},text(e,t){e.save(),e.fillStyle=t.style?.textColor??t.style?.stroke??`#2962ff`,e.font=`${t.style?.fontSize??12}px sans-serif`,e.textAlign=t.align??`left`,e.textBaseline=t.baseline??`bottom`,e.fillText(t.text,t.point.x,t.point.y),e.restore()}}}function ml(e,t){return{kind:e,minAnchors:2,maxAnchors:2,compute(e,n){let[r,i]=e.anchors;return!r||!i?{primitives:[]}:{primitives:[{kind:`line`,a:n.toScreen(r),b:n.toScreen(i),extend:t,style:e.style}]}}}}function hl(e){return{kind:e,minAnchors:1,maxAnchors:1,compute(t,n){let[r]=t.anchors;if(!r)return{primitives:[]};let i=n.toScreen(r),a=n.pane.height,o=n.viewport.plotWidth;return e===`horizontal-line`?{primitives:[{kind:`line`,a:{x:0,y:i.y},b:{x:o,y:i.y},showEndpoints:!1,style:t.style},{kind:`point`,point:i,style:t.style}]}:e===`horizontal-ray`?{primitives:[{kind:`line`,a:i,b:{x:o,y:i.y},showEndpoints:!1,style:t.style},{kind:`point`,point:i,style:t.style}]}:e===`vertical-line`?{primitives:[{kind:`line`,a:{x:i.x,y:0},b:{x:i.x,y:a},showEndpoints:!1,style:t.style},{kind:`point`,point:i,style:t.style}]}:{primitives:[{kind:`line`,a:{x:0,y:i.y},b:{x:o,y:i.y},showEndpoints:!1,style:t.style},{kind:`line`,a:{x:i.x,y:0},b:{x:i.x,y:a},showEndpoints:!1,style:t.style},{kind:`point`,point:i,style:t.style}]}}}}function gl(){return{kind:`info-line`,minAnchors:2,maxAnchors:2,compute(e,t){let[n,r]=e.anchors;if(!n||!r)return{primitives:[]};let i=t.toScreen(n),a=t.toScreen(r),o=Math.round(n.index),s=Math.round(r.index)-o,c=r.price-n.price,l=n.price===0?0:c/n.price*100,u=Math.atan2(a.y-i.y,a.x-i.x)*(180/Math.PI),d=`${dl(c)} (${dl(l)}%) ${s} bars ${dl(u)}°`;return{primitives:[{kind:`line`,a:i,b:a,style:e.style},{kind:`text`,point:{x:(i.x+a.x)/2+8,y:Math.min(i.y,a.y)-8},text:d,align:`left`,baseline:`bottom`,style:e.style}],meta:{delta:c,percent:l,bars:s,angle:u}}}}}function _l(){return{kind:`parallel-channel`,minAnchors:3,maxAnchors:3,compute(e,t){let[n,r,i]=e.anchors;if(!n||!r||!i)return{primitives:[]};let a=t.toScreen(n),o=t.toScreen(r),s=t.toScreen(i),c=o.x-a.x,l=o.y-a.y,u={x:s.x+c,y:s.y+l},d=e.params?.extend??`none`,f=i.index+(r.index-n.index),p=i.time?(typeof i.time==`string`?new Date(i.time).getTime():i.time)+((typeof r.time==`string`?new Date(r.time).getTime():r.time??0)-(typeof n.time==`string`?new Date(n.time).getTime():n.time??0)):void 0;return{primitives:[{kind:`area`,points:[a,o,u,s],closed:!0,style:e.style},{kind:`line`,a,b:o,extend:d,style:e.style},{kind:`line`,a:s,b:u,extend:d,style:e.style}],computedAnchors:[{id:`${e.id}-p4`,index:f,time:p,price:i.price+(r.price-n.price)}]}}}}function vl(){return{kind:`flat-line`,minAnchors:3,maxAnchors:3,compute(e,t){let[n,r,i]=e.anchors;if(!n||!r||!i)return{primitives:[]};let a=t.toScreen(n),o=t.toScreen(r),s=t.toScreen(i),c={x:a.x,y:s.y},l={x:o.x,y:s.y};return{primitives:[{kind:`area`,points:[a,o,l,c],closed:!0,style:e.style},{kind:`line`,a,b:o,style:e.style},{kind:`line`,a:c,b:l,style:e.style},{kind:`point`,point:c,style:e.style},{kind:`point`,point:l,style:e.style}],computedAnchors:[{id:`${e.id}-h1`,index:n.index,time:n.time,price:i.price},{id:`${e.id}-h2`,index:r.index,time:r.time,price:i.price}]}}}}function yl(){return{kind:`disjoint-channel`,minAnchors:3,maxAnchors:3,compute(e,t){let[n,r,i]=e.anchors;if(!n||!r||!i)return{primitives:[]};let a=t.toScreen(n),o=t.toScreen(r),s=t.toScreen(i),c=o.x-a.x,l=o.y-a.y,u={x:s.x+c,y:s.y-l},d=i.index+(r.index-n.index),f=i.price-(r.price-n.price),p=i.time?(typeof i.time==`string`?new Date(i.time).getTime():i.time)-((typeof r.time==`string`?new Date(r.time).getTime():r.time??0)-(typeof n.time==`string`?new Date(n.time).getTime():n.time??0)):void 0;return{primitives:[{kind:`area`,points:[a,o,u,s],closed:!0,style:e.style},{kind:`line`,a,b:o,style:e.style},{kind:`line`,a:s,b:u,style:e.style}],computedAnchors:[{id:`${e.id}-p4`,index:d,time:p,price:f}]}}}}function bl(){return{kind:`regression-channel`,minAnchors:2,maxAnchors:2,compute(e,t){let[n,r]=e.anchors;if(!n||!r)return{primitives:[]};let i=ul(n,t.seriesData),a=ul(r,t.seriesData);if(i<0&&a<0)return{primitives:[]};let o=Math.min(Math.max(Math.round(n.index),0),t.seriesData.length-1),s=Math.min(Math.max(Math.round(r.index),0),t.seriesData.length-1),c=Math.min(o,s),l=Math.max(o,s),u=t.seriesData.slice(c,l+1),d=fl(u.map(e=>e.close));if(!d)return{primitives:[]};let f=e.params?.sigma??2,p=d.stdDev*f,m=d.intercept,h=d.intercept+d.slope*(u.length-1),g={id:`${e.id}-reg-start`,index:Math.round(n.index),time:t.seriesData[c].timestamp,price:m},_={id:`${e.id}-reg-end`,index:Math.round(r.index),time:t.seriesData[l].timestamp,price:h},v={...g,id:`${e.id}-reg-upper-start`,price:m+p},y={..._,id:`${e.id}-reg-upper-end`,price:h+p},b={...g,id:`${e.id}-reg-lower-start`,price:m-p},x={..._,id:`${e.id}-reg-lower-end`,price:h-p},S=t.toScreen(g),C=t.toScreen(_),w=t.toScreen(v),T=t.toScreen(y),E=t.toScreen(b),D=t.toScreen(x);return{primitives:[{kind:`area`,points:[w,T,D,E],closed:!0,style:e.style},{kind:`line`,a:S,b:C,style:{...e.style,strokeStyle:`dashed`}},{kind:`line`,a:w,b:T,style:e.style},{kind:`line`,a:E,b:D,style:e.style}],computedAnchors:[g,_],meta:{sigma:f,stdDev:d.stdDev,slope:d.slope}}}}}function xl(e){e.register(ml(`trend-line`,`none`)),e.register(ml(`ray`,`right`)),e.register(ml(`extended-line`,`both`)),e.register(hl(`horizontal-line`)),e.register(hl(`horizontal-ray`)),e.register(hl(`vertical-line`)),e.register(hl(`cross-line`)),e.register(gl()),e.register(_l()),e.register(bl()),e.register(vl()),e.register(yl())}function Sl(e){let t=e.store,n=e.definitions??new al,r=e.renderers??pl();return xl(n),{name:`drawingRenderer`,version:`0.1.0`,description:`绘图渲染器`,debugName:`绘图层`,paneId:e.paneId??`main`,priority:-25,draw(e){let{ctx:i,pane:a,data:o,range:s,dpr:c,paneWidth:l,kLinePositions:u,kLineCenters:d,kBarRects:f,kWidth:p,kGap:m}=e,h=e.viewport??{scrollLeft:e.scrollLeft,plotWidth:l,plotHeight:a.height},{startXPx:g,unitPx:_}=na(p,m,c),v=o,y=v.slice(s.start,s.end),b=t.getVisibleByPane(a.id);if(b.length===0)return;let x={left:0,top:0,right:h.plotWidth,bottom:a.height};i.save(),i.beginPath(),i.rect(0,0,h.plotWidth,a.height),i.clip();for(let o of b){let b=n.compute(o,{pane:a,visibleData:y,seriesData:v,range:s,kLinePositions:u,kLineCenters:d,kBarRects:f,kWidth:p,kGap:m,dpr:c,paneWidth:l,viewport:h,toScreen(e){return!Number.isFinite(e.index)||e.index<0?{x:-p,y:a.yAxis.priceToY(e.price)}:{x:(g+e.index*_+(_-1)/2)/c-h.scrollLeft,y:a.yAxis.priceToY(e.price)}}});if(!b)continue;let S=t.getSelectedId()===o.id,C=S?b.primitives.map(e=>Cl(e,o.style)):b.primitives;if(S&&o.visible&&a.role===`price`){let t=[...o.anchors,...b.computedAnchors??[]];if(t.length===0)continue;if(t.length>=2){let n=1/0,r=-1/0;for(let e of t)Number.isFinite(e.price)&&(e.price<n&&(n=e.price),e.price>r&&(r=e.price));Number.isFinite(n)&&Number.isFinite(r)&&n!==r&&(e.yAxisRanges||=[],e.yAxisRanges.push({topY:a.yAxis.priceToY(r),bottomY:a.yAxis.priceToY(n),color:o.style?.stroke??`#2962ff`,opacity:.15}))}if(t.length>=2){let n=1/0,r=-1/0;for(let e of t)!Number.isFinite(e.index)||e.index<0||(e.index<n&&(n=e.index),e.index>r&&(r=e.index));if(Number.isFinite(n)&&Number.isFinite(r)&&n!==r){e.xAxisRanges||=[];let t=(g+n*_+(_-1)/2)/c,i=(g+r*_+(_-1)/2)/c;e.xAxisRanges.push({leftX:t,rightX:i,color:o.style?.stroke??`#2962ff`,opacity:.15})}}let n=e=>{if(e>=0&&e<v.length)return v[e]?.timestamp??null;if(v.length>=2&&e>=v.length){let t=v.length-1,n=v.length-2,r=v[t].timestamp,i=r-v[n].timestamp;return r+(e-t)*i}return null};for(let r of t){if(!Number.isFinite(r.index)||!Number.isFinite(r.price))continue;let t=r.index<0?{x:-p,y:a.yAxis.priceToY(r.price)}:{x:(g+r.index*_+(_-1)/2)/c-h.scrollLeft,y:a.yAxis.priceToY(r.price)};if(t.y>=0&&t.y<=a.height&&(e.yAxisLabels||=[],e.yAxisLabels.push({dataIndex:Math.round(r.index),price:r.price,y:t.y,style:{bgColor:o.style?.stroke??`#2962ff`,borderColor:o.style?.stroke??`#2962ff`,textColor:`#ffffff`}})),t.x>=-p&&t.x<=h.plotWidth+p){let i=r.time?typeof r.time==`string`?new Date(r.time).getTime():r.time:n(Math.round(r.index));if(!i)continue;e.xAxisLabels||=[],e.xAxisLabels.push({dataIndex:Math.round(r.index),timestamp:i,x:t.x+h.scrollLeft,style:{bgColor:o.style?.stroke??`#2962ff`,textColor:`#ffffff`}})}}}for(let e of C){if(e.kind===`point`){r.point(i,e,c);continue}if(e.kind===`line`){r.line(i,e,x,c);continue}if(e.kind===`area`){r.area(i,e,c);continue}r.text(i,e,c)}}i.restore()}}}function Cl(e,t){let n=t.stroke??`#2962ff`,r=(t.strokeWidth??1)+1,i=(t.pointRadius??4)+2;return e.kind===`point`?{...e,style:{...e.style,stroke:n,pointRadius:i}}:e.kind===`line`?{...e,style:{...e.style,stroke:n,strokeWidth:r}}:e.kind===`area`?{...e,style:{...e.style,stroke:n}}:{...e,style:{...e.style,textColor:n,fontSize:(e.style?.fontSize??12)+1}}}var wl=class e{dom;opt;data=[];raf=null;pendingUpdateLevel=q.All;viewport=null;paneRenderers=[];markerManager;drawingStore=new il;interaction;pluginHost;rendererPluginManager;preciseDpr=0;resizeObserver;onScroll;observedSize={width:0,height:0};cachedScrollLeft=0;overlayHadCrosshair=!1;settings={};paneRatios=new Map;onViewportChange;xAxisCtx=null;onPaneLayoutChange;onDataChange;currentZoomLevel=1;zoomLevelCount;indicatorScheduler;lastVisibleRange={start:0,end:0};cachedDrawFrame=null;activeMainIndicators=new Set;mainIndicatorParams={MA:{ma5:!0,ma10:!0,ma20:!0,ma30:!0,ma60:!0},BOLL:{period:20,multiplier:2,showUpper:!0,showMiddle:!0,showLower:!0,showBand:!0},EXPMA:{fastPeriod:12,slowPeriod:50},ENE:{period:10,deviation:11}};enableMainIndicator(e,t){let n=e.toUpperCase();return[`MA`,`BOLL`,`EXPMA`,`ENE`].includes(n)?this.activeMainIndicators.has(n)?(t&&(this.mainIndicatorParams[n]={...this.mainIndicatorParams[n],...t},this.updateIndicatorSchedulerConfig(n)),!0):(this.activeMainIndicators.add(n),t&&(this.mainIndicatorParams[n]={...this.mainIndicatorParams[n],...t}),this.enableMainIndicatorRenderer(n),this.updateIndicatorSchedulerConfig(n),this.scheduleDraw(),!0):(console.warn(`[Chart] 未知的主图指标: ${e}`),!1)}disableMainIndicator(e){let t=e.toUpperCase();return this.activeMainIndicators.has(t)?(this.activeMainIndicators.delete(t),this.disableMainIndicatorRenderer(t),this.updateIndicatorSchedulerConfig(t),this.scheduleDraw(),!0):!1}toggleMainIndicator(e,t){t?this.enableMainIndicator(e):this.disableMainIndicator(e)}getActiveMainIndicators(){return Array.from(this.activeMainIndicators)}isMainIndicatorActive(e){return this.activeMainIndicators.has(e.toUpperCase())}updateMainIndicatorParams(e,t){let n=e.toUpperCase();this.mainIndicatorParams[n]||(this.mainIndicatorParams[n]={}),this.mainIndicatorParams[n]={...this.mainIndicatorParams[n],...t};let r=n.toLowerCase(),i=this.getRenderer(r);i&&i.setConfig&&i.setConfig(this.mainIndicatorParams[n]),this.updateIndicatorSchedulerConfig(n),this.scheduleDraw()}getMainIndicatorParams(e){return this.mainIndicatorParams[e.toUpperCase()]??null}clearMainIndicators(){for(let e of this.activeMainIndicators)this.disableMainIndicatorRenderer(e);this.activeMainIndicators.clear(),this.scheduleDraw()}enableMainIndicatorRenderer(e){let t={MA:()=>{this.getRenderer(`ma`)||this.useRenderer(_c()),this.setRendererEnabled(`ma`,!0)},BOLL:()=>{this.getRenderer(`boll`)||this.useRenderer(yc()),this.setRendererEnabled(`boll`,!0)},EXPMA:()=>{this.getRenderer(`expma`)||this.useRenderer(xc()),this.setRendererEnabled(`expma`,!0)},ENE:()=>{this.getRenderer(`ene`)||this.useRenderer(Sc()),this.setRendererEnabled(`ene`,!0)}}[e];t&&t(),this.getRenderer(`mainIndicatorLegend`)||this.useRenderer(kc({yPaddingPx:this.opt.yPaddingPx}))}disableMainIndicatorRenderer(e){let t={MA:`ma`,BOLL:`boll`,EXPMA:`expma`,ENE:`ene`}[e];t&&this.setRendererEnabled(t,!1)}updateIndicatorSchedulerConfig(e){let t=this.activeMainIndicators.has(e),n=this.mainIndicatorParams[e];switch(e){case`MA`:this.indicatorScheduler.updateMAConfig({ma5:t,ma10:t,ma20:t,ma30:t,ma60:t});break;case`BOLL`:t?this.indicatorScheduler.updateBOLLConfig(n):this.indicatorScheduler.updateBOLLConfig({...n,showUpper:!1,showMiddle:!1,showLower:!1,showBand:!1});break;case`EXPMA`:t&&this.indicatorScheduler.updateEXPMAConfig(n);break;case`ENE`:t&&this.indicatorScheduler.updateENEConfig(n);break}}setActiveMainIndicators(e){let t=new Set(e.map(e=>e.toUpperCase())),n=new Set(this.activeMainIndicators);for(let e of n)t.has(e)||this.disableMainIndicator(e);for(let e of t)n.has(e)||this.enableMainIndicator(e)}constructor(e,t){this.dom=e;let{kWidth:n,kGap:r,...i}=t;this.opt={...i,kWidth:n??0,kGap:r??0},this.interaction=new ws(this),this.markerManager=new So,this.pluginHost=ea(),this.rendererPluginManager=new ma,this.rendererPluginManager.setPluginHost(this.pluginHost),this.rendererPluginManager.setInvalidateCallback(()=>this.scheduleDraw()),this.syncPaneRatiosFromSpecs(this.opt.panes),this.zoomLevelCount=Math.max(2,Math.round(this.opt.zoomLevels??20)),this.currentZoomLevel=this.opt.initialZoomLevel??1,this.currentZoomLevel=Math.max(1,Math.min(this.zoomLevelCount,this.currentZoomLevel)),this.indicatorScheduler=new lc,this.indicatorScheduler.setPluginHost(this.pluginHost),this.initPanes(),this.useRenderer(Sl({store:this.drawingStore})),this.initResizeObserver()}initResizeObserver(){if(typeof ResizeObserver>`u`)return;let e=this.dom.container;if(e){this.cachedScrollLeft=e.scrollLeft,this.onScroll=()=>{this.cachedScrollLeft=e.scrollLeft},e.addEventListener(`scroll`,this.onScroll,{passive:!0}),this.resizeObserver=new ResizeObserver(e=>{let t=e[0];if(!t)return;let n=this.observedSize.width,r=this.observedSize.height,i=this.preciseDpr;this.updateObservedMetrics(t);let a=this.observedSize.width!==n,o=this.observedSize.height!==r,s=this.preciseDpr!==i;(a||o||s)&&this.resize()});try{this.resizeObserver.observe(e,{box:`device-pixel-content-box`})}catch{this.resizeObserver.observe(e)}}}updateObservedMetrics(e){let t=Math.max(1,Math.round(e.contentRect.width)),n=Math.max(1,Math.round(e.contentRect.height));this.observedSize.width=t,this.observedSize.height=n;let r=e.devicePixelContentBoxSize?.[0],i=e.contentBoxSize?.[0];if(!r||!i||i.inlineSize<=0){this.preciseDpr=0;return}let a=r.inlineSize/i.inlineSize;this.preciseDpr=Math.round(a*64)/64}getEffectiveDpr(){let e=this.preciseDpr>0?this.preciseDpr:Math.round((window.devicePixelRatio||1)*64)/64;return e<1&&(e=1),e}getViewport(){return this.viewport}getCurrentDpr(){return this.getEffectiveDpr()}getCachedScrollLeft(){return this.cachedScrollLeft}get plugin(){return this.pluginHost}useRenderer(e,t){this.rendererPluginManager.register(e),t&&e.setConfig&&e.setConfig(t)}removeRenderer(e){this.rendererPluginManager.unregister(e)}getRenderer(e){return this.rendererPluginManager.getPlugin(e)}updateRendererConfig(e,t){this.rendererPluginManager.updateConfig(e,t)}setRendererEnabled(e,t){this.rendererPluginManager.setEnabled(e,t)}getAllRenderers(){return this.rendererPluginManager.getAllPlugins()}updateSettings(e){this.settings={...e},this.interaction.updateSettings(e);let t=e.logarithmicScale?`log`:`linear`;for(let e of this.paneRenderers)e.getPane().yAxis.setScaleType(t);this.scheduleDraw()}draw(e=q.All){this.markerManager.clear();let t=e===q.Overlay&&this.cachedDrawFrame!==null,n=t?this.cachedDrawFrame.viewport:this.computeViewport();if(!n||this.data.length===0)return;let r=t?this.cachedDrawFrame.range:(()=>{let{start:e,end:t}=ra(n.scrollLeft,n.plotWidth,this.opt.kWidth,this.opt.kGap,this.data.length,n.dpr);return{start:e,end:t}})();!t&&(r.start!==this.lastVisibleRange.start||r.end!==this.lastVisibleRange.end)&&(this.indicatorScheduler.updateVisibleRange(r),this.lastVisibleRange=r);let i=t?this.cachedDrawFrame.kLinePositions:this.calcKLinePositions(r),a,o,s;if(t)a=this.cachedDrawFrame.kLineCenters,o=this.cachedDrawFrame.kBarRects,s=this.cachedDrawFrame.kWidthPx;else{let e=na(this.opt.kWidth,this.opt.kGap,n.dpr),t=Math.max(1,e.unitPx-1);t%2==0&&--t,a=Array(i.length),o=Array(i.length);for(let r=0;r<i.length;r++){let s=i[r],c=Math.round(s*n.dpr)+(e.kWidthPx-1)/2;a[r]=c/n.dpr;let l=c-(t-1)/2;o[r]={x:l/n.dpr,width:t/n.dpr}}s=na(this.opt.kWidth,this.opt.kGap,n.dpr).kWidthPx,this.cachedDrawFrame={viewport:{...n},range:{...r},kLinePositions:[...i],kLineCenters:[...a],kBarRects:o.map(e=>({...e})),kWidthPx:s}}this.interaction.setKLinePositions(i,r,s);let c=[],l=[],u=[],d=[];this.indicatorScheduler.setActiveMainIndicators(Array.from(this.activeMainIndicators));let f=t?null:this.indicatorScheduler.getMainIndicatorPriceRange(),p=this.interaction.getCrosshairIndex()!==null;for(let s of this.paneRenderers){let m=s.getPane(),{mainCtx:h,overlayCtx:g,yAxisCtx:_}=s.getContexts(),{candleSurface:v,lineSurface:y}=s.getWebGL();if(!t){let e=m.role===`price`?f:null;m.updateRange(this.data,r,e)}let b=e===q.Main||e===q.All,x=(e===q.Overlay||e===q.All)&&(p||this.overlayHadCrosshair);if(b&&h&&(h.setTransform(1,0,0,1,0,0),h.scale(n.dpr,n.dpr),h.clearRect(0,0,n.plotWidth+1,m.height+2/n.dpr),v?.clear(),y?.clear()),x&&g){let e=g.canvas.width/n.dpr;g.setTransform(1,0,0,1,0,0),g.scale(n.dpr,n.dpr),g.clearRect(0,0,e+1,m.height+2/n.dpr)}if(_&&!t){let e=_.canvas.width/n.dpr;_.setTransform(1,0,0,1,0,0),_.scale(n.dpr,n.dpr),_.clearRect(0,0,e,m.height+2/n.dpr)}let S={ctx:h,overlayCtx:g??void 0,pane:qi(m),data:this.data,range:r,scrollLeft:n.scrollLeft,kWidth:this.opt.kWidth,kGap:this.opt.kGap,dpr:n.dpr,paneWidth:n.plotWidth,kLinePositions:i,kLineCenters:a,kBarRects:o,markerManager:this.markerManager,crosshairIndex:this.interaction.getCrosshairIndex(),yAxisCtx:_??void 0,candleWebGLSurface:v??void 0,lineWebGLSurface:y??void 0,zoomLevel:this.currentZoomLevel,zoomLevelCount:this.zoomLevelCount,viewport:{scrollLeft:n.scrollLeft,plotWidth:n.plotWidth,plotHeight:n.plotHeight},settings:this.settings,yAxisLabels:c,xAxisLabels:l,yAxisRanges:u,xAxisRanges:d},C=this.rendererPluginManager.render(m.id,S,e);C.length>0&&this.pluginHost.events.emit(`renderer:error`,{paneId:m.id,errors:C});let w=this.rendererPluginManager.renderPlugin(`yAxis`,S);w.length>0&&this.pluginHost.events.emit(`renderer:error`,{paneId:m.id,errors:w})}this.overlayHadCrosshair=p;let m=this.xAxisCtx??this.dom.xAxisCanvas.getContext(`2d`);if(this.xAxisCtx||=m,m){let e={ctx:m,pane:{id:`xAxis`,role:`auxiliary`,capabilities:{showPriceAxisTicks:!1,showCrosshairPriceLabel:!1,candleHitTest:!1,supportsPriceTranslate:!1},top:0,height:this.opt.bottomAxisHeight,yAxis:{priceToY:()=>0,yToPrice:()=>0,getPaddingTop:()=>0,getPaddingBottom:()=>0,getPriceOffset:()=>0,getDisplayRange:e=>e??{maxPrice:0,minPrice:0},getScaleType:()=>`linear`},priceRange:{maxPrice:0,minPrice:0}},data:this.data,range:r,scrollLeft:n.scrollLeft,kWidth:this.opt.kWidth,kGap:this.opt.kGap,dpr:n.dpr,paneWidth:n.plotWidth,kLinePositions:i,kLineCenters:a,kBarRects:o,xAxisCtx:m,viewport:{scrollLeft:n.scrollLeft,plotWidth:n.plotWidth,plotHeight:n.plotHeight},yAxisLabels:[],xAxisLabels:l,xAxisRanges:d},t=this.rendererPluginManager.renderPlugin(`timeAxis`,e);t.length>0&&this.pluginHost.events.emit(`renderer:error`,{paneId:`timeAxis`,errors:t})}}applyRenderState(e,t,n){let r=n===void 0?this.currentZoomLevel:Math.max(1,Math.min(this.zoomLevelCount,n));(this.opt.kWidth!==e||this.opt.kGap!==t||this.currentZoomLevel!==r)&&(this.opt={...this.opt,kWidth:e,kGap:t},n!==void 0&&(this.currentZoomLevel=r),this.scheduleDraw())}getZoomLevelCount(){return this.zoomLevelCount}setOnViewportChange(e){this.onViewportChange=e}setOnPaneLayoutChange(e){this.onPaneLayoutChange=e}setOnDataChange(e){this.onDataChange=e}getPaneRenderers(){return this.paneRenderers}getMarkerManager(){return this.markerManager}updateCustomMarkers(e){this.markerManager.setCustomMarkers(e),this.scheduleDraw()}clearCustomMarkers(){this.markerManager.clearCustomMarkers(),this.scheduleDraw()}getDom(){return this.dom}getOption(){return this.opt}calcKLinePositions(e){let{start:t,end:n}=e,r=n-t;if(r<=0)return[];let i=this.getEffectiveDpr(),{unitPx:a,startXPx:o}=na(this.opt.kWidth,this.opt.kGap,i),s=Array(r);for(let e=0;e<r;e++)s[e]=(o+(t+e)*a)/i;return s}updateOptions(e){if(e.kWidth!==void 0&&(console.warn(`[Chart] kWidth cannot be set directly. Use applyRenderState() instead.`),delete e.kWidth),e.kGap!==void 0&&delete e.kGap,e.panes){let t=e.panes.map(e=>({...e}));this.opt={...this.opt,...e,panes:t},this.applyPaneLayoutSpecs(t);return}this.opt={...this.opt,...e},this.resize()}updatePaneLayout(e){this.applyPaneLayoutSpecs(e)}setPaneDefinitions(e){this.applyPaneLayoutSpecs(e)}upsertPane(e){let t=this.opt.panes.findIndex(t=>t.id===e.id);if(t===-1){this.applyPaneLayoutSpecs([...this.opt.panes,{...e}]);return}let n=[...this.opt.panes];n[t]={...n[t],...e},this.applyPaneLayoutSpecs(n)}removePaneDefinition(e){this.opt.panes.some(t=>t.id===e)&&(this.paneRatios.delete(e),this.applyPaneLayoutSpecs(this.opt.panes.filter(t=>t.id!==e)))}bindIndicatorToPane(e,t,n){this.opt.panes.some(t=>t.id===e)||this.upsertPane({id:e,ratio:1,visible:!0,role:`indicator`});let r=`${t.toLowerCase()}_${e}`;if(this.getRenderer(r)){n&&this.updateRendererConfig(r,n);return}let i=$c({indicatorId:t,paneId:e});this.useRenderer(i,n)}setDrawings(e){this.drawingStore.setAll(e),this.scheduleDraw()}setSelectedDrawingId(e){this.drawingStore.getSelectedId()!==e&&(this.drawingStore.setSelectedId(e),this.scheduleDraw())}getPaneLayoutSpecs(){let e=this.opt.panes.filter(e=>e.visible!==!1).reduce((e,t)=>e+(this.paneRatios.get(t.id)??t.ratio??0),0),t=e>0?e:1;return this.opt.panes.map(e=>{let n=this.paneRatios.get(e.id)??e.ratio??0,r=e.visible===!1?n:n/t,i=this.paneRenderers.find(t=>t.getPane().id===e.id)?.getPane();return{...e,ratio:r,role:i?.role??e.role,capabilities:i?{...i.capabilities}:e.capabilities}})}emitPaneLayoutChange(){this.onPaneLayoutChange?.(this.getPaneLayoutSpecs())}applyPaneLayoutSpecs(e){this.opt.panes=e.map(e=>({...e})),this.syncPaneRatiosFromSpecs(this.opt.panes),this.initPanes(),this.layoutPanes(),this.emitPaneLayoutChange(),this.scheduleDraw()}resizePaneBoundary(e,t){if(!Number.isFinite(t)||t===0)return!1;let n=this.viewport;if(!n)return!1;let r=this.opt.panes.filter(e=>e.visible!==!1),i=r.findIndex(t=>t.id===e);if(i<0||i>=r.length-1)return!1;let a=r[i],o=r[i+1];if(!a||!o)return!1;let s=new Map;for(let e of r){let t=this.paneRenderers.find(t=>t.getPane().id===e.id);t&&s.set(e.id,t.getPane().height)}let c=t>0?i:i+1,l=t>0?i+1:i,u=t>0?1:-1,d=Math.abs(t),f=l;for(;d>0&&f>=0&&f<r.length;){let e=r[f];if(!e)break;let t=s.get(e.id)??0,i=this.getPaneMinHeight(e,n.plotHeight),a=Math.max(0,t-i);if(a>0){let n=Math.min(a,d);s.set(e.id,t-n),d-=n}d>0&&(f+=u)}if(d>0)return!1;let p=r[c];if(!p)return!1;let m=s.get(p.id)??0;s.set(p.id,m+Math.abs(t));let h=Math.max(0,this.opt.paneGap??0)*Math.max(0,r.length-1),g=Math.max(1,n.plotHeight-h);for(let e of r){let t=s.get(e.id)??0;this.paneRatios.set(e.id,t/g)}return this.normalizeVisiblePaneRatios(r),this.syncPaneRatiosToSpecs(),this.layoutPanes(),this.emitPaneLayoutChange(),this.scheduleDraw(),!0}resolvePaneRole(e,t){return e.role?e.role:t===0?`price`:`indicator`}addPane(e){if(this.opt.panes.some(t=>t.id===e)){console.warn(`Pane "${e}" already exists`);return}let t=this.opt.panes.some((e,t)=>this.resolvePaneRole(e,t)===`price`)?`indicator`:`price`;this.applyPaneLayoutSpecs([...this.opt.panes,{id:e,ratio:1,visible:!0,role:t}])}removePane(e){if(!this.opt.panes.some(t=>t.id===e))return;let t=this.opt.panes.filter(t=>t.id!==e);this.paneRatios.delete(e),this.applyPaneLayoutSpecs(t)}hasPane(e){return this.opt.panes.some(t=>t.id===e)}static SUB_PANE_PREFIX=`sub_`;createSubPane(t,n){let r=`${e.SUB_PANE_PREFIX}${t}`,i=`${t.toLowerCase()}_${r}`;if(this.getRenderer(i))return n&&this.updateRendererConfig(i,n),!0;let a=this.opt.panes.filter(e=>e.visible!==!1),o=a.filter((e,t)=>this.resolvePaneRole(e,t)===`price`),s=a.filter((e,t)=>this.resolvePaneRole(e,t)===`indicator`);if(o.length===1){let e=o[0];e&&this.paneRatios.set(e.id,3);for(let e of s)this.paneRatios.set(e.id,1);this.paneRatios.set(r,1)}else this.paneRatios.set(r,1);return this.upsertPane({id:r,ratio:this.paneRatios.get(r)??1,visible:!0,role:`indicator`}),this.bindIndicatorToPane(r,t,n),!0}removeSubPane(t){let n=`${e.SUB_PANE_PREFIX}${t}`;if(!this.hasPane(n))return;let r=`${t.toLowerCase()}_${n}`;this.removeRenderer(r),this.paneRatios.delete(n),this.applyPaneLayoutSpecs(this.opt.panes.filter(e=>e.id!==n))}clearSubPanes(){let t=this.opt.panes.map(e=>e.id).filter(t=>t.startsWith(e.SUB_PANE_PREFIX));if(t.length!==0){for(let n of t){let t=`${n.slice(e.SUB_PANE_PREFIX.length).toLowerCase()}_${n}`;this.removeRenderer(t),this.paneRatios.delete(n)}this.applyPaneLayoutSpecs(this.opt.panes.filter(t=>!t.id.startsWith(e.SUB_PANE_PREFIX)))}}getSubPaneIndicators(){return this.opt.panes.map(e=>e.id).filter(t=>t.startsWith(e.SUB_PANE_PREFIX)).map(t=>t.slice(e.SUB_PANE_PREFIX.length))}translatePrice(e,t){let n=this.paneRenderers.find(t=>t.getPane().id===e);if(!n)return;let r=n.getPane();if(!r.capabilities.supportsPriceTranslate)return;let i=r.yAxis.deltaYToPriceOffset(t),a=r.yAxis.getPriceOffset();r.yAxis.setPriceOffset(a+i),this.scheduleDraw()}resetPriceOffset(e){let t=this.paneRenderers.find(t=>t.getPane().id===e);t&&(t.getPane().yAxis.resetPriceOffset(),this.scheduleDraw())}scalePrice(e,t){let n=this.paneRenderers.find(t=>t.getPane().id===e);if(!n)return;let r=n.getPane();r.capabilities.supportsPriceTranslate&&(r.yAxis.scaleByDelta(t),this.scheduleDraw())}updateData(e){this.data=e??[],this.onDataChange?.(this.data);let t=this.dom.container;if(t){let e=this.getContentWidth(),n=Math.max(0,e-t.clientWidth);this.cachedScrollLeft>n&&(t.scrollLeft=n,this.cachedScrollLeft=n)}this.interaction.reset(),this.indicatorScheduler.update(this.data,this.lastVisibleRange),this.scheduleDraw()}getData(){return this.data}getIndicatorScheduler(){return this.indicatorScheduler}getTrailingSlotCount(){return 24}getLogicalSlotCount(){return this.data.length+this.getTrailingSlotCount()}getTimestampAtLogicalIndex(e){return!Number.isInteger(e)||e<0||e>=this.data.length?null:this.data[e]?.timestamp??null}getLogicalIndexAtX(e){let t=this.viewport;if(!t||this.data.length===0)return null;let n=this.getEffectiveDpr(),{startXPx:r,unitPx:i}=na(this.opt.kWidth,this.opt.kGap,n),a=Math.round((t.scrollLeft+e)*n),o=Math.floor((a-r)/i);return o<0?null:o}getDataIndexAtX(e){let t=this.getLogicalIndexAtX(e);return t===null||t>=this.data.length?null:t}getContentWidth(){return Is({dataLength:this.data.length,kWidth:this.opt.kWidth,kGap:this.opt.kGap,viewWidth:this.viewport?.plotWidth??0,viewportDpr:this.getEffectiveDpr()})}resize(){let e=this.computeViewport();!e||e.viewWidth<10||e.viewHeight<10||(this.layoutPanes(),this.emitPaneLayoutChange(),this.scheduleDraw())}scheduleDraw(e=q.All){if(this.raf!==null){if(this.pendingUpdateLevel===q.All)return;if(e===q.All){this.pendingUpdateLevel=q.All;return}if(this.pendingUpdateLevel===q.Main&&e===q.Overlay||this.pendingUpdateLevel===q.Overlay&&e===q.Main){this.pendingUpdateLevel=q.All;return}return}this.pendingUpdateLevel=e,this.raf=requestAnimationFrame(()=>{this.raf=null;let e=this.pendingUpdateLevel;this.pendingUpdateLevel=q.All,this.draw(e)})}async destroy(){this.raf!==null&&(cancelAnimationFrame(this.raf),this.raf=null),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.preciseDpr=0,this.observedSize={width:0,height:0},this.onScroll&&=(this.dom.container?.removeEventListener(`scroll`,this.onScroll),void 0),this.viewport=null,this.cachedDrawFrame=null,this.xAxisCtx=null,this.paneRenderers.forEach(e=>e.destroy()),this.paneRenderers=[],this.rendererPluginManager.clear(),this.onViewportChange=void 0,this.onPaneLayoutChange=void 0,await this.pluginHost.destroy()}initPanes(){this.paneRenderers=this.opt.panes.map((e,t)=>{let n=new fa(e.id,{role:this.resolvePaneRole(e,t),capabilities:e.capabilities}),r=document.createElement(`canvas`),i=document.createElement(`canvas`),a=document.createElement(`canvas`),o=n.role===`price`;return r.id=`${e.id}-main`,r.className=o?`main-canvas main`:`main-canvas sub`,r.style.position=`absolute`,r.style.left=`0`,r.style.top=`0`,i.id=`${e.id}-overlay`,i.className=`overlay-canvas`,i.style.position=`absolute`,i.style.left=`0`,i.style.top=`0`,i.style.pointerEvents=`none`,i.style.backgroundColor=`transparent`,a.id=`${e.id}-yAxis`,a.className=`right-axis`,a.style.position=`absolute`,a.style.left=`0`,new Fs({mainCanvas:r,overlayCanvas:i,yAxisCanvas:a},n,{rightAxisWidth:this.opt.rightAxisWidth,yPaddingPx:this.opt.yPaddingPx,priceLabelWidth:this.opt.priceLabelWidth})});let e=this.dom.canvasLayer,t=this.dom.rightAxisLayer;e&&e.querySelectorAll(`canvas:not(.x-axis-canvas)`).forEach(e=>e.remove()),t&&t.querySelectorAll(`canvas.right-axis`).forEach(e=>e.remove()),this.paneRenderers.forEach(n=>{let r=n.getDom();e.appendChild(r.mainCanvas),e.appendChild(r.overlayCanvas),t.appendChild(r.yAxisCanvas)}),this.rendererPluginManager.setKnownPaneIds(this.paneRenderers.map(e=>e.getPane().id))}syncPaneRatiosFromSpecs(e){let t=new Map;for(let n of e){let e=this.paneRatios.get(n.id),r=Number.isFinite(n.ratio)?n.ratio:0,i=e===void 0?r>0?r:1:e;t.set(n.id,i)}this.paneRatios=t,this.normalizeVisiblePaneRatios(e),this.syncPaneRatiosToSpecs()}syncPaneRatiosToSpecs(){let e=this.opt.panes.filter(e=>e.visible!==!1).reduce((e,t)=>e+(this.paneRatios.get(t.id)??t.ratio??0),0),t=e>0?e:1;this.opt.panes=this.opt.panes.map(e=>{let n=this.paneRatios.get(e.id)??e.ratio??0;return e.visible===!1?{...e,ratio:n}:{...e,ratio:n/t}})}normalizeVisiblePaneRatios(e){let t=e.filter(e=>e.visible!==!1);if(t.length===0)return;let n=0;for(let e of t){let t=this.paneRatios.get(e.id)??e.ratio??0,r=Number.isFinite(t)&&t>0?t:0;this.paneRatios.set(e.id,r),n+=r}if(n<=0){let e=1/t.length;for(let n of t)this.paneRatios.set(n.id,e);return}for(let e of t){let t=this.paneRatios.get(e.id)??0;this.paneRatios.set(e.id,t/n)}}getPaneMinHeight(e,t){let n=this.opt.defaultPaneMinHeightPx??120,r=e.minHeightPx??n;return Math.max(1,Math.min(Math.round(r),Math.max(1,t)))}computePaneHeightsByRatio(e,t){if(e.length===0)return[];let n=e.map(e=>this.paneRatios.get(e.id)??e.ratio??0),r=n.reduce((e,t)=>e+(t>0?t:0),0),i=(r>0?n.map(e=>(e>0?e:0)/r):e.map(()=>1/e.length)).map(e=>Math.max(1,Math.round(t*e))),a=e.map(e=>this.getPaneMinHeight(e,t));for(let e=0;e<i.length;e++)i[e]=Math.max(i[e],Math.min(a[e],t));let o=i.reduce((e,t)=>e+t,0);if(o>t){let e=o-t;for(;e>0;){let n=!1;for(let r=i.length-1;r>=0&&e>0;r--){let o=Math.max(1,Math.min(a[r],t)),s=i[r];s>o&&(i[r]=s-1,e--,n=!0)}if(!n)break}}else o<t&&(i[i.length-1]=(i[i.length-1]??1)+(t-o));return o=i.reduce((e,t)=>e+t,0),o!==t&&i.length>0&&(i[i.length-1]=Math.max(1,(i[i.length-1]??1)+(t-o))),i}layoutPanes(){let e=this.viewport;if(!e)return;let t=this.opt.panes.filter(e=>e.visible!==!1);if(t.length===0)return;let n=Math.max(0,this.opt.paneGap??0),r=0,i=n*Math.max(0,t.length-1),a=Math.max(1,e.plotHeight-i);this.normalizeVisiblePaneRatios(t);let o=this.computePaneHeightsByRatio(t,a);for(let i=0;i<t.length;i++){let a=t[i];if(!a)continue;let s=this.paneRenderers.find(e=>e.getPane().id===a.id);if(!s)continue;let c=s.getPane(),l=o[i]??1;c.setLayout(r,l),c.setPadding(this.opt.yPaddingPx,this.opt.yPaddingPx),s.resize(e.plotWidth,l,e.dpr),this.rendererPluginManager.notifyResize(c.id,qi(c));let u=s.getDom();u.mainCanvas.style.top=`${r}px`,u.overlayCanvas.style.top=`${r}px`,u.yAxisCanvas.style.top=`${r}px`,u.yAxisCanvas.style.left=`0px`,r+=l+n}let s=Math.max(1,a);for(let e of t){let t=this.paneRenderers.find(t=>t.getPane().id===e.id);if(!t)continue;let n=t.getPane().height;this.paneRatios.set(e.id,n/s)}this.normalizeVisiblePaneRatios(t),this.syncPaneRatiosToSpecs()}computeViewport(){let e=this.dom.container;if(!e)return null;let t=this.observedSize.width,n=this.observedSize.height,r=t>0?t:Math.max(1,Math.round(e.clientWidth)),i=n>0?n:Math.max(1,Math.round(e.clientHeight)),a=Math.round(r),o=Math.round(i-this.opt.bottomAxisHeight),s=this.getEffectiveDpr(),c=16*1024*1024;r*s*(i*s)>c&&(s=Math.sqrt(c/(r*i)));let l=Math.round(this.cachedScrollLeft*s)/s,u=`${r}px`;this.dom.canvasLayer.style.width!==u&&(this.dom.canvasLayer.style.width=u);let d=`${i}px`;this.dom.canvasLayer.style.height!==d&&(this.dom.canvasLayer.style.height=d);let f=Math.round(a*s);this.dom.xAxisCanvas.width!==f&&(this.dom.xAxisCanvas.width=f);let p=Math.round(this.opt.bottomAxisHeight*s);this.dom.xAxisCanvas.height!==p&&(this.dom.xAxisCanvas.height=p);let m=`${f/s}px`;this.dom.xAxisCanvas.style.width!==m&&(this.dom.xAxisCanvas.style.width=m);let h=`${p/s}px`;this.dom.xAxisCanvas.style.height!==h&&(this.dom.xAxisCanvas.style.height=h);let g={viewWidth:r,viewHeight:i,plotWidth:a,plotHeight:o,scrollLeft:l,dpr:s},_=this.viewport,v=!_||_.viewWidth!==g.viewWidth||_.viewHeight!==g.viewHeight||_.plotWidth!==g.plotWidth||_.plotHeight!==g.plotHeight||_.scrollLeft!==g.scrollLeft||_.dpr!==g.dpr;return this.viewport=g,v&&this.onViewportChange?.(g),g}},Tl=3;function El(e,t){let n=(e-1)/(t.zoomLevelCount-1);return t.minKWidth+n*(t.maxKWidth-t.minKWidth)}function Dl(e){return Tl/e}function Ol(e,t,n,r,i,a,o){let s=Math.max(1,Math.min(o.zoomLevelCount,r+e));if(s===r)return null;let c=El(s,o),l=Dl(o.dpr),u=na(i,a,o.dpr),d=na(c,l,o.dpr),f=(Math.round((n+t)*o.dpr)-u.startXPx)/u.unitPx;return{targetLevel:s,newKWidth:c,newKGap:l,newScrollLeft:(d.startXPx+f*d.unitPx)/o.dpr-t}}function kl(e,t,n,r,i,a,o){let s=Math.max(1,Math.min(o.zoomLevelCount,Math.round(e)))-r;return s===0?null:Ol(s,t,n,r,i,a,o)}function Al(e){return e.open>e.close?`down`:e.open<e.close?`up`:`flat`}var $=function(e){return e.RISE_WITH_VOLUME=`rise_with_volume`,e.RISE_WITHOUT_VOLUME=`rise_without_volume`,e.FALL_WITH_VOLUME=`fall_with_volume`,e.FALL_WITHOUT_VOLUME=`fall_without_volume`,e.OTHERS=`others`,e}({}),jl={volumeAmplifyThreshold:1.5,volumeShrinkThreshold:.8,avgPeriod:20},Ml=class{prefixSum=[];dataLength=0;build(e){let t=e.length;if(t===0){this.prefixSum=[],this.dataLength=0;return}this.prefixSum=[0];for(let n=0;n<t;n++)this.prefixSum.push(this.prefixSum[n]+(e[n]?.volume??0));this.dataLength=t}query(e,t){return e<0||t>=this.dataLength||e>t?0:this.prefixSum[t+1]-this.prefixSum[e]}getVolumeMA(e,t){if(e<t-1)return 0;let n=e-t+1;return this.query(n,e)/t}get length(){return this.dataLength}};function Nl(e,t,n,r=jl){let i=new Ml;i.build(e);let a=[],{volumeAmplifyThreshold:o,volumeShrinkThreshold:s,avgPeriod:c}=r;for(let r=t;r<n&&r<e.length;r++){let t=e[r]?.volume;if(r<1||!t){a.push($.OTHERS);continue}let n=i.getVolumeMA(r,c),l=e[r];if(!l){a.push($.OTHERS);continue}let u=l.close-l.open,d=u>0,f=u<0,p=t>n*o,m=t<n*s;d&&p?a.push($.RISE_WITH_VOLUME):d&&m?a.push($.RISE_WITHOUT_VOLUME):f&&p?a.push($.FALL_WITH_VOLUME):f&&m?a.push($.FALL_WITHOUT_VOLUME):a.push($.OTHERS)}return a}function Pl(){return{name:`candle`,version:`1.0.0`,description:`K线蜡烛图渲染器`,debugName:`K线`,paneId:`main`,priority:G.MAIN,draw(e){let{ctx:t,pane:n,data:r,range:i,scrollLeft:a,kWidth:o,kGap:s,dpr:c,kLinePositions:l,markerManager:u,settings:d}=e,f=r;if(!f.length)return;let p=Fl({pane:n,data:f,range:i,kWidth:o,kGap:s,dpr:c,kLinePositions:l,settings:d});Ll(e,p)?Rl(t,e):Il(t,a,p),zl(e,p,u)}}}function Fl(e){let{pane:t,data:n,range:r,kWidth:i,kGap:a,dpr:o,kLinePositions:s,settings:c}=e,{kWidthPx:l}=na(i,a,o),u=c?.showVolumePriceMarkers!==!1,d=u?Nl(n,r.start,r.end,jl):null,f=[],p=[],m=[],h=[],g=[],_=[];for(let e=r.start;e<r.end&&e<n.length;e++){let i=n[e];if(!i)continue;let a=t.yAxis.priceToY(i.open),c=t.yAxis.priceToY(i.close),u=t.yAxis.priceToY(i.high),d=t.yAxis.priceToY(i.low),v=s[e-r.start];if(v===void 0)continue;let y=e=>Math.round(e*o)/o,b=y(a),x=y(c),S=y(u),C=y(d),w=Math.min(b,x),T=Math.max(Math.abs(b-x),1),E=Na(Math.round(v*o),w,l,T,o),D=Al(i),O={i:e,aligned:E,trend:D,openY:a,closeY:c,highY:u,lowY:d,alignedHighY:S,alignedLowY:C,e:i},k=E.bodyRect,A=D===`up`?f:p,j=D===`up`?m:h,M=D===`up`?g:_;A.push(O),j.push(k);let N=E.bodyRect.y,ee=E.bodyRect.y+E.bodyRect.height,P=Math.max(i.open,i.close),F=Math.min(i.open,i.close);if(i.high>P){let e=ja(E.wickRect.x,S,N,o);e&&M.push(e)}if(i.low<F){let e=ja(E.wickRect.x,ee,C,o);e&&M.push(e)}}return{upKLines:f,downKLines:p,upBodyRects:m,downBodyRects:h,upWickRects:g,downWickRects:_,wickWidth:f[0]?.aligned.wickRect.width??p[0]?.aligned.wickRect.width??1,relations:d,showVolumePriceMarkers:u}}function Il(e,t,n){e.save(),e.translate(-t,0),e.fillStyle=J.UP;for(let t of n.upBodyRects)e.fillRect(t.x,t.y,t.width,t.height);e.fillStyle=J.DOWN;for(let t of n.downBodyRects)e.fillRect(t.x,t.y,t.width,t.height);e.fillStyle=J.UP;for(let t of n.upWickRects)e.fillRect(t.x,t.y,n.wickWidth,t.height);e.fillStyle=J.DOWN;for(let t of n.downWickRects)e.fillRect(t.x,t.y,n.wickWidth,t.height);e.restore()}function Ll(e,t){let n=e.candleWebGLSurface;if(!n||!n.isAvailable())return!1;n.clear();let r=t.upBodyRects.length===0||n.drawRects(t.upBodyRects,J.UP,e.scrollLeft),i=t.downBodyRects.length===0||n.drawRects(t.downBodyRects,J.DOWN,e.scrollLeft),a=t.upWickRects.length===0||n.drawRects(t.upWickRects,J.UP,e.scrollLeft),o=t.downWickRects.length===0||n.drawRects(t.downWickRects,J.DOWN,e.scrollLeft);return r&&i&&a&&o}function Rl(e,t){let n=t.candleWebGLSurface;if(!n)return;let r=n.getCanvas();r.width<=0||r.height<=0||e.drawImage(r,0,0,r.width,r.height,0,0,r.width/t.dpr,r.height/t.dpr)}function zl(e,t,n){let{ctx:r,range:i,kWidth:a,dpr:o}=e;if(!(!t.showVolumePriceMarkers||!n||(e.zoomLevel??1)<2)){r.save(),r.translate(-e.scrollLeft,0);for(let s of t.upKLines){let c=t.relations?.[s.i-i.start];if(c!==void 0&&c!==$.OTHERS){let t=c===$.RISE_WITH_VOLUME||c===$.RISE_WITHOUT_VOLUME?s.alignedHighY-15:s.alignedLowY+15,l=s.i-i.start,u=e.kLineCenters[l];Bl(r,u,t,c,s.i,a,4,n,o)}}for(let s of t.downKLines){let c=t.relations?.[s.i-i.start];if(c!==void 0&&c!==$.OTHERS){let t=c===$.RISE_WITH_VOLUME||c===$.RISE_WITHOUT_VOLUME?s.alignedHighY-15:s.alignedLowY+15,l=s.i-i.start,u=e.kLineCenters[l];Bl(r,u,t,c,s.i,a,4,n,o)}}r.restore()}}function Bl(e,t,n,r,i,a,o=4,s,c){let l=e=>Math.round(e*c)/c;t=l(t),n=l(n);let u=Math.min(a,20),d=u*Math.sqrt(3)/2,f,p;switch(r){case $.RISE_WITH_VOLUME:f=`#FF4444`,p=!0;break;case $.RISE_WITHOUT_VOLUME:f=`#00C853`,p=!0;break;case $.FALL_WITH_VOLUME:f=`#FF4444`,p=!1;break;case $.FALL_WITHOUT_VOLUME:f=`#00C853`,p=!1;break;default:return}if(e.save(),e.beginPath(),p){let r=l(n-o),i=l(r-d);e.moveTo(t,i),e.lineTo(l(t-u/2),r),e.lineTo(l(t+u/2),r)}else{let r=l(n+o),i=l(r+d);e.moveTo(t,i),e.lineTo(l(t-u/2),r),e.lineTo(l(t+u/2),r)}e.closePath(),e.fillStyle=f,e.fill(),e.restore();let m,h;if(p){let e=l(l(n-o)-d);m=l(t-u/2),h=e}else{let e=l(n+o);l(e+d),m=l(t-u/2),h=e}let g;switch(r){case $.RISE_WITH_VOLUME:g=`RISE_WITH_VOLUME`;break;case $.RISE_WITHOUT_VOLUME:g=`RISE_WITHOUT_VOLUME`;break;case $.FALL_WITH_VOLUME:g=`FALL_WITH_VOLUME`;break;case $.FALL_WITHOUT_VOLUME:g=`FALL_WITHOUT_VOLUME`;break;default:return}let _=`mk_price-volume_${i}`;s.register({id:_,type:`triangle`,markerType:g,x:m,y:h,width:u,height:d,dataIndex:i,metadata:{relation:r}})}function Vl(e,t){return Math.max(3,Math.round(e/60)+1)}function Hl(e){let{height:t,paddingTop:n,paddingBottom:r,isMain:i,hideEdgeTicks:a}=e,o=n,s=Math.max(n,t-r),c=Math.max(0,s-o),l=Vl(t,i),u=[];for(let e=0;e<l;e++){if(a&&(e===0||e===l-1))continue;let t=l<=1?0:e/(l-1),n=o+t*c;u.push({index:e,t,y:n})}return u}var Ul=1e-10,Wl=[1,1.2,1.5,2,2.5,3,4,5,6,7.5,8,10];function Gl(e){if(!Number.isFinite(e)||e<=0)return e;let t=10**Math.floor(Math.log10(e)),n=e/t,r=Wl[0],i=1/0;for(let e of Wl){let t=Math.abs(e-n);t<i&&(i=t,r=e)}return r*t}function Kl(e){let{height:t,paddingTop:n,paddingBottom:r,valueMin:i,valueMax:a,targetCount:o}=e,s=Math.max(i,Ul),c=Math.max(a,s*1.001),l=n,u=Math.max(n,t-r),d=Math.max(0,u-l);if(d<=0)return[];let f=ca({minPrice:s,maxPrice:c}),p=K(s,f),m=K(c,f),h=m-p;if(!Number.isFinite(h)||Math.abs(h)<1e-10)return[];let g=Math.max(2,o),_=g<=1?d:d/(g-1),v=_*.6,y=_*.15,b=[],x=null;for(let e=0;e<g;e++){let t=g<=1?0:e/(g-1),n=l+t*d,r=sa(m-t*h,f),i=r,a=t,o=n,s=Gl(r);if(Number.isFinite(s)&&s>0){let e=(m-K(s,f))/h,t=l+e*d;Number.isFinite(t)&&Math.abs(t-n)<=y&&(i=s,a=e,o=t)}o<l-.5||o>u+.5||x!==null&&Math.abs(o-x)<v||(b.push({index:b.length,t:a,y:o,value:i}),x=o)}return b}function ql(e){let{valueMin:t,valueMax:n,scaleType:r=`linear`}=e;if(r===`log`){if(t<=0)return ql({...e,scaleType:`linear`});let r=Math.max(t,Ul),i=Math.max(n,r*1.001),{height:a,paddingTop:o,paddingBottom:s,isMain:c,hideEdgeTicks:l}=e,u=Kl({height:a,paddingTop:o,paddingBottom:s,valueMin:r,valueMax:i,targetCount:Math.max(2,Vl(a,c))});return l&&u.length>2&&(u=u.slice(1,-1)),u.map((e,t)=>({...e,index:t}))}let i=Hl(e),a=Vl(e.height,e.isMain),o=n-t||1;return i.map(e=>{let t=n-o/Math.max(1,a-1)*e.index;return{...e,value:t}})}function Jl(){return{name:`gridLines`,version:`1.0.0`,description:`网格线渲染器`,debugName:`网格线`,paneId:Ji,priority:G.GRID,draw(e){let{ctx:t,pane:n,data:r,range:i,scrollLeft:a,kWidth:o,dpr:s,kLinePositions:c}=e,l=r;if(!l.length)return;t.save(),t.fillStyle=va.HORIZONTAL,t.translate(-a,0);let u=t.canvas.width/s,d=a,f=a+u,p=n.yAxis.getPaddingTop(),m=n.yAxis.getPaddingBottom(),h=n.yAxis.getScaleType(),g;if(h===`log`&&n.role===`price`){let e=n.yAxis.getDisplayRange(n.priceRange);g=ql({height:n.height,paddingTop:p,paddingBottom:m,isMain:!0,valueMin:e.minPrice,valueMax:e.maxPrice,scaleType:`log`}).map(e=>e.y)}else g=Hl({height:n.height,paddingTop:p,paddingBottom:m,isMain:n.role===`price`}).map(e=>e.y);for(let e of g){let n=Ma(d,f,e,s);n&&t.fillRect(n.x,n.y,n.width,n.height)}let _=Ka(l);for(let e of _){if(e<i.start||e>=i.end||e>=l.length)continue;let r=e-i.start;if(r<0||r>=c.length)continue;let a=ja(c[r]+o/2,0,n.height,s);a&&t.fillRect(a.x,a.y,a.width,a.height)}t.restore()}}}function Yl(){return{name:`lastPriceLine`,version:`1.0.0`,description:`最新价虚线渲染器`,debugName:`最新价线`,paneId:`main`,priority:G.LAST_PRICE_LABEL,draw(e){let{ctx:t,pane:n,data:r,scrollLeft:i,dpr:a,kLinePositions:o,paneWidth:s}=e,c=r,l=c[c.length-1];if(!l)return;let u=n.yAxis.getDisplayRange(n.priceRange);if(l.close<u.minPrice||l.close>u.maxPrice)return;let d=Math.round(n.yAxis.priceToY(l.close));e.yAxisLabels||=[],e.yAxisLabels.push({dataIndex:c.length-1,price:l.close,y:d,type:`lastPrice`,style:{bgColor:`rgba(255, 247, 248, 0.98)`,borderColor:J.LAST_PRICE,textColor:J.LAST_PRICE}}),t.save(),t.translate(-i,0);let f=o[0]??0,p=s+i;t.strokeStyle=J.LAST_PRICE,t.lineWidth=1,t.setLineDash([4,3]),t.beginPath();let m=(Math.floor(d*a)+.5)/a;t.moveTo(Math.round(f*a)/a,m),t.lineTo(Math.round(p*a)/a,m),t.stroke(),t.setLineDash([]),t.restore()}}}var Xl=new Map,Zl=256;function Ql(e,t){let n=`${e.font}\n${t}`,r=Xl.get(n);if(r!==void 0)return r;let i=e.measureText(t).width;return Xl.size>=Zl&&Xl.clear(),Xl.set(n,i),i}function $l(){return{name:`extremaMarkers`,version:`1.0.0`,description:`可视区最高/最低价标注渲染器`,debugName:`极值标记`,paneId:Ji,priority:G.OVERLAY,draw(e){let{ctx:t,pane:n,data:r,range:i,scrollLeft:a,dpr:o,paneWidth:s,kLineCenters:c}=e,l=r;if(!l.length||n.role!==`price`)return;let u=Math.max(0,i.start),d=Math.min(l.length,i.end);if(d-u<=0)return;let f=-1/0,p=1/0,m=u,h=u;for(let e=u;e<d;e++){let t=l[e];t&&(t.high>=f&&(f=t.high,m=e),t.low<=p&&(p=t.low,h=e))}if(!Number.isFinite(f)||!Number.isFinite(p))return;let g=e=>{let t=e-i.start;return t<0||t>=c.length?0:c[t]};e.yAxisLabels||=[],e.yAxisLabels.push({dataIndex:m,price:f,y:n.yAxis.priceToY(f),style:{bgColor:`rgba(255, 247, 248, 0.98)`,borderColor:J.LAST_PRICE,textColor:J.LAST_PRICE}}),e.yAxisLabels.push({dataIndex:h,price:p,y:n.yAxis.priceToY(p),style:{bgColor:`rgba(255, 247, 248, 0.98)`,borderColor:J.LAST_PRICE,textColor:J.LAST_PRICE}}),t.save(),t.translate(-a,0),eu(t,g(m),n.yAxis.priceToY(f),f,o,s,a),eu(t,g(h),n.yAxis.priceToY(p),p,o,s,a),t.restore()}}}function eu(e,t,n,r,i,a,o){let s=r.toFixed(2);Tc(e,wc(12));let c=Ql(e,s),l=t-o+30+4+c>a,u=t,d=l?t-30:t+30;u>d&&([u,d]=[d,u]);let f=Ma(u,d,n,i);f&&(e.fillStyle=ha.WEAK,e.fillRect(f.x,f.y,f.width,f.height));let p=X(d,i),m=X(n,i);e.fillStyle=ha.WEAK,e.beginPath(),e.arc(p,m,2,0,Math.PI*2),e.fill(),e.textBaseline=`middle`,e.fillStyle=J.NEUTRAL,l?(e.textAlign=`right`,e.fillText(s,X(t-30-4,i),Z(n,i))):(e.textAlign=`left`,e.fillText(s,X(t+30+4,i),Z(n,i)))}function tu(e,t,n,r,i,a){let o=t-n||1,s=Math.max(1,r-i-a);return n+(1-(Math.min(Math.max(e,i),i+s)-i)/s)*o}var nu=new Map,ru=512;function iu(e,t){let n=`${e.font}\n${t}`,r=nu.get(n);if(r!==void 0)return r;let i=e.measureText(t).width;return nu.size>=ru&&nu.clear(),nu.set(n,i),i}function au(e,t){let{x:n,y:r,width:i,height:a,crosshairX:o,timestamp:s,dpr:c,fontSize:l=16,paddingX:u=8}=t,d=Ga(s);e.save(),Tc(e,wc(l)),e.textBaseline=`middle`,e.textAlign=`center`;let f=Math.round(iu(e,d)),p=Math.min(i,f+u*2),m=a,h=Math.min(Math.max(o,n+p/2),n+i-p/2),g=r+a/2,_=h-p/2,v=r;e.fillStyle=`rgba(0, 0, 0, 0.8)`,e.fillRect(X(_,c),X(v,c),X(p,c),X(m,c)),e.fillStyle=`#ffffff`,e.fillText(d,X(h,c),Z(g,c)),e.restore()}function ou(e,t){let{x:n,y:r,width:i,height:a,crosshairY:o,priceRange:s,yPaddingPx:c=0,dpr:l,bgColor:u=`rgba(0, 0, 0, 0.8)`,borderColor:d,textColor:f=`#ffffff`,fontSize:p=16,priceOffset:m=0,price:h,formatPrice:g}=t,_=Math.max(0,Math.min(c,Math.floor(a/2)-1)),{maxPrice:v,minPrice:y}=s,b=h??tu(o-r,v,y,a,_,_)+m,x=g?g(b):b.toFixed(2);e.save(),Tc(e,wc(p)),e.textBaseline=`middle`,e.textAlign=`center`;let S=p+4,C=Math.min(Math.max(o,r+S/2),r+a-S/2),w=C-S/2,T=n,E=X(w,l),D=i,O=X(S,l);e.fillStyle=u,e.fillRect(T,E,D,O),d&&(e.strokeStyle=d,e.lineWidth=1,e.strokeRect(Z(T,l),Z(E,l),Math.max(0,D-1/l),Math.max(0,O-1/l)));let k=n+i/2;e.fillStyle=f,e.fillText(x,X(k,l),Z(C,l)),e.restore()}function su(e,t){let{x:n,y:r,width:i,height:a,data:o,scrollLeft:s,kWidth:c,kGap:l,startIndex:u,endIndex:d,dpr:f,bgColor:p=ga.TRANSPARENT,textColor:m=ha.SECONDARY,lineColor:h=_a.DARK,fontSize:g=12,paddingX:_=8,drawTopBorder:v=!0,drawBottomBorder:y=!0}=t,b=Math.round(c*f),x=b%2==0?b+1:b,S=Math.round(l*f),C=x+S,w=S,T=C/f,E=w/f,D=x/f;e.fillStyle=p,e.fillRect(n,r,i,a),v&&(e.strokeStyle=h,e.lineWidth=1,e.beginPath(),e.moveTo(n,Z(r,f)),e.lineTo(n+i,Z(r,f)),e.stroke()),y&&(e.strokeStyle=h,e.lineWidth=1,e.beginPath(),e.moveTo(n,Z(r+a,f)),e.lineTo(n+i,Z(r+a,f)),e.stroke()),e.textAlign=`center`,e.textBaseline=`middle`,e.fillStyle=m;let O=r+a/2,k=wc(g),A=wc(g,{bold:!0}),j=Ka(o).filter(e=>e>=u&&e<d);for(let t of j){let n=o[t];if(!n)continue;let r=E+t*T+D/2-s,a=_,c=Math.max(_,i-_);if(r>=a&&r<=c){let t=Math.min(Math.max(r,a),c),{text:i,isYear:o}=Ha(n.timestamp);Tc(e,o?A:k),e.fillText(i,X(t,f),Z(O,f))}}}function cu(e,t){let{x:n,y:r,width:i,height:a,priceY:o,price:s,dpr:c,bgColor:l=`rgba(0, 0, 0, 0.8)`,borderColor:u,textColor:d=`#ffffff`,fontSize:f=12}=t,p=s.toFixed(2);e.save(),Tc(e,wc(f)),e.textBaseline=`middle`,e.textAlign=`center`;let m=f+4,h=Math.min(Math.max(o,r+m/2),r+a-m/2),g=h-m/2,_=n,v=X(g,c),y=i,b=X(m,c);e.fillStyle=l,e.fillRect(_,v,y,b),u&&(e.strokeStyle=u,e.lineWidth=1,e.strokeRect(Z(_,c),Z(v,c),Math.max(0,y-1/c),Math.max(0,b-1/c)));let x=n+i/2;e.fillStyle=d,e.fillText(p,X(x,c),Z(h,c)),e.restore()}function lu(e,t){let{x:n,y:r,width:i,height:a,labelX:o,timestamp:s,dpr:c,fontSize:l=12,paddingX:u=8}=t,d=Ga(s);e.save(),Tc(e,wc(l)),e.textBaseline=`middle`,e.textAlign=`center`;let f=Math.round(iu(e,d)),p=Math.min(i,f+u*2),m=a,h=Math.min(Math.max(o,n+p/2),n+i-p/2),g=r+a/2,_=h-p/2,v=r;e.fillStyle=t.bgColor??`rgba(0, 0, 0, 0.8)`,e.fillRect(X(_,c),X(v,c),X(p,c),X(m,c)),e.fillStyle=t.textColor??`#ffffff`,e.fillText(d,X(h,c),Z(g,c)),e.restore()}function uu(e){let{ctx:t,dpr:n,axisWidth:r,height:i,paddingTop:a,paddingBottom:o,valueMin:s,valueMax:c,isMain:l,decimals:u=2,hideEdgeTicks:d=!0,scaleType:f=`linear`,formatLabel:p}=e;t.save(),t.clearRect(0,0,r,i),Tc(t,wc(12)),t.textBaseline=`middle`,t.textAlign=`center`,t.fillStyle=ha.SECONDARY;let m=r/2,h=ql({height:i,paddingTop:a,paddingBottom:o,isMain:l,hideEdgeTicks:d,valueMin:s,valueMax:c,scaleType:f});for(let{y:e,value:r}of h)t.fillText(p?p(r):r.toFixed(u),X(m,n),Z(e,n));t.restore()}function du(e){let{axisWidth:t,paneId:n,indicatorKey:r,label:i,decimals:a=2,yPaddingPx:o=0,scaleType:s=`linear`,getCrosshair:c,formatTickLabel:l,formatCrosshairLabel:u}=e,d=Q(r,n),f=null;return{name:`${r}Scale_${n}`,version:`1.0.0`,description:`${i} 刻度渲染器`,debugName:`${i}刻度`,paneId:n,priority:G.INDICATOR_SCALE,onInstall(e){f=e},draw(e){let{yAxisCtx:n,pane:r,dpr:i}=e;if(!n||!f)return;let p=f.getSharedState(d);if(!p)return;let m=r.yAxis.getScaleType()??s,h=r.yAxis.getDisplayRange({minPrice:p.valueMin,maxPrice:p.valueMax});uu({ctx:n,dpr:i,axisWidth:t,height:r.height,paddingTop:r.yAxis.getPaddingTop(),paddingBottom:r.yAxis.getPaddingBottom(),valueMin:h.minPrice,valueMax:h.maxPrice,isMain:!1,decimals:a,hideEdgeTicks:!1,scaleType:m,formatLabel:l});let g=c?.();if(!g||g.activePaneId!==r.id)return;let _=g.y-r.top,v=r.yAxis.getPaddingTop(),y=r.yAxis.getPaddingBottom(),b=v,x=Math.max(v,r.height-y),S=Math.max(1,x-b),C=(Math.min(Math.max(_,b),x)-b)/S,w=h.maxPrice-C*(h.maxPrice-h.minPrice);ou(n,{x:0,y:0,width:t,height:r.height,crosshairY:_,priceRange:h,yPaddingPx:o,dpr:i,fontSize:12,priceOffset:0,price:w,formatPrice:u})}}}function fu(e){return{name:`yAxis`,version:`1.0.0`,description:`Y轴价格刻度渲染器`,debugName:`Y轴`,paneId:Ji,priority:G.SYSTEM_YAXIS,draw(t){let{ctx:n,pane:r,dpr:i,yAxisCtx:a,data:o}=t,s=r.yAxis.getScaleType(),c=a||n,l=a?.canvas?a.canvas.width/i:e.axisWidth,u=r.yAxis.getDisplayRange(r.priceRange);if(r.capabilities.showPriceAxisTicks&&uu({ctx:c,dpr:i,axisWidth:l,height:r.height,paddingTop:r.yAxis.getPaddingTop(),paddingBottom:r.yAxis.getPaddingBottom(),valueMin:u.minPrice,valueMax:u.maxPrice,isMain:!0,decimals:2,hideEdgeTicks:!1,scaleType:s}),t.yAxisRanges&&r.role===`price`)for(let e of t.yAxisRanges){let t=e.topY+r.top,n=e.bottomY-e.topY;n<=0||(c.save(),c.globalAlpha=e.opacity,c.fillStyle=e.color,c.fillRect(0,t,l,n),c.restore())}if(t.yAxisLabels&&r.role===`price`)for(let e of t.yAxisLabels){let t=e.type===`lastPrice`;cu(c,{x:0,y:r.top,width:l,height:r.height,priceY:e.y+r.top,price:e.price,dpr:i,bgColor:e.style?.bgColor??`rgba(0, 0, 0, 0.8)`,borderColor:e.style?.borderColor,textColor:e.style?.textColor??`#ffffff`,fontSize:t?12:11})}let d=e.getCrosshair?.();d&&d.activePaneId===r.id&&d.price!==null&&ou(c,{x:0,y:r.top,width:l,height:r.height,crosshairY:d.y,priceRange:u,yPaddingPx:e.yPaddingPx,dpr:i,fontSize:12,priceOffset:0,price:d.price})}}}function pu(e){return du({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`macd`,label:`MACD`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}var mu=1e8;function hu(e){return du({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`volume`,label:`VOL`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair,formatTickLabel:e=>`${(e/mu).toFixed(2)}B`,formatCrosshairLabel:e=>`${(e/mu).toFixed(2)}B`})}function gu(e){return du({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`rsi`,label:`RSI`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function _u(e){return du({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`cci`,label:`CCI`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function vu(e){return du({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`stoch`,label:`STOCH`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function yu(e){return du({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`mom`,label:`MOM`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function bu(e){return du({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`wmsr`,label:`WMSR`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function xu(e){return du({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`kst`,label:`KST`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function Su(e){return du({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`fastk`,label:`FASTK`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}var Cu=Symbol(`time-axis`);function wu(e){return{name:`timeAxis`,version:`1.0.0`,description:`时间轴渲染器`,debugName:`时间轴`,paneId:Cu,priority:G.SYSTEM_XAXIS,isSystem:!0,draw(t){let{ctx:n,data:r,range:i,scrollLeft:a,kWidth:o,kGap:s,dpr:c,paneWidth:l}=t,u=r,d=n,f=l,p=e.height;if(d.setTransform(1,0,0,1,0,0),d.scale(c,c),d.clearRect(0,0,f,p),su(d,{x:0,y:0,width:f,height:p,data:u,scrollLeft:a,kWidth:o,kGap:s,startIndex:i.start,endIndex:i.end,dpr:c,drawTopBorder:!1,drawBottomBorder:!1}),t.xAxisRanges)for(let e of t.xAxisRanges){let t=e.leftX-a,n=e.rightX-a-t;n<=0||(d.save(),d.globalAlpha=e.opacity,d.fillStyle=e.color,d.fillRect(t,0,n,p),d.restore())}let m=e.getCrosshair?.();if(m&&typeof m.index==`number`){let e=u[m.index];e&&au(d,{x:0,y:0,width:f,height:p,crosshairX:m.x,timestamp:e.timestamp,dpr:c,fontSize:12})}if(t.xAxisLabels)for(let e of t.xAxisLabels){let t=e.x-a;t>=0&&t<=f&&lu(d,{x:0,y:0,width:f,height:p,labelX:t,timestamp:e.timestamp,dpr:c,fontSize:12,bgColor:e.style?.bgColor,textColor:e.style?.textColor})}}}}function Tu(e){return{name:`crosshair`,version:`1.0.0`,description:`十字线渲染器`,debugName:`十字线`,paneId:Ji,priority:G.SYSTEM_CROSSHAIR,layer:`overlay`,draw(t){let{pane:n,dpr:r,paneWidth:i,overlayCtx:a}=t,o=e.getCrosshairState();if(o.isDragging||!o.pos)return;let{x:s}=o.pos,c=n.id===o.activePaneId,l=-1;c&&o.price!==null&&(l=n.yAxis.priceToY(o.price));let u=a;if(!u)return;u.save(),u.beginPath(),u.rect(0,0,i,n.height),u.clip(),u.fillStyle=Aa.LINE;let d=ja(s,0,n.height,r);if(d&&u.fillRect(d.x,d.y,d.width,d.height),c&&l>=0){let e=Ma(0,i,Math.min(l,n.height-1/r),r);e&&u.fillRect(e.x,e.y,e.width,e.height)}u.restore()}}}var Eu=new Map,Du=256;function Ou(e,t){let n=`${e.font}\n${t}`,r=Eu.get(n);if(r!==void 0)return r;let i=e.measureText(t).width;return Eu.size>=Du&&Eu.clear(),Eu.set(n,i),i}function ku(e){let t={...e};return{name:`paneTitle_${e.paneId}`,version:`1.0.0`,description:`面板标题渲染器`,debugName:`面板标题`,paneId:e.paneId,priority:G.FOREGROUND,draw(e){let{ctx:n,pane:r}=e;if(r.id!==t.paneId)return;let i=t.yOffset??12;n.save(),Tc(n,wc(12)),n.textAlign=`left`,n.textBaseline=`top`;let a=t.getTitleInfo?.();if(a){let e=12;if(n.fillStyle=ha.PRIMARY,n.fillText(a.name,e,i),e+=Ou(n,a.name),a.params&&a.params.length>0){let t=`(${a.params.join(`,`)})`;n.fillStyle=ha.TERTIARY,n.fillText(t,e,i),e+=Ou(n,t)+8}else e+=8;if(a.values&&a.values.length>0)for(let t of a.values){let r=`${t.label} ${t.value.toFixed(3)}`;n.fillStyle=t.color,n.fillText(r,e,i),e+=Ou(n,r)+8}}else if(n.fillStyle=ha.PRIMARY,n.fillText(t.title,12,i),t.description){let e=Ou(n,t.title);n.fillStyle=ha.WEAK,n.fillText(` - ${t.description}`,12+e,i)}n.restore()},setConfig(e){t={...t,...e}}}}var Au={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function ju(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Au,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M7.904 17.563a1.2 1.2 0 0 0 2.228.308l2.09-3.093l4.907 4.907a1.067 1.067 0 0 0 1.509 0l1.047-1.047a1.067 1.067 0 0 0 0-1.509l-4.907-4.907l3.113-2.09a1.2 1.2 0 0 0-.309-2.228L4 4z`},null,-1)]])}var Mu=(0,f.markRaw)({name:`tabler-pointer`,render:ju}),Nu={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Pu(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Nu,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 19h16M4 15l4-6l4 2l4-5l4 4`},null,-1)]])}var Fu=(0,f.markRaw)({name:`tabler-chart-line`,render:Pu}),Iu={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Lu(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Iu,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M17 7L7 17M8 7h9v9`},null,-1)]])}var Ru=(0,f.markRaw)({name:`tabler-arrow-up-right`,render:Lu}),zu={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Bu(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,zu,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 12h14m-6 6l6-6m-6-6l6 6`},null,-1)]])}var Vu=(0,f.markRaw)({name:`tabler-arrow-right`,render:Bu}),Hu={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Uu(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Hu,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 12h14`},null,-1)]])}var Wu=(0,f.markRaw)({name:`tabler-minus`,render:Uu}),Gu={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Ku(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Gu,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 12v.01M7 12h10m4 0v.01`},null,-1)]])}var qu=(0,f.markRaw)({name:`tabler-separator`,render:Ku}),Ju={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Yu(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Ju,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 8V6a2 2 0 0 1 2-2h2M4 16v2a2 2 0 0 0 2 2h2m8-16h2a2 2 0 0 1 2 2v2m-4 12h2a2 2 0 0 0 2-2v-2M9 12h6m-3-3v6`},null,-1)]])}var Xu=(0,f.markRaw)({name:`tabler-crosshair`,render:Yu}),Zu={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Qu(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Zu,[...t[0]||=[(0,f.createElementVNode)(`g`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`},[(0,f.createElementVNode)(`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 0 0-18 0m9-3h.01`}),(0,f.createElementVNode)(`path`,{d:`M11 12h1v4h1`})],-1)]])}var $u=(0,f.markRaw)({name:`tabler-info-circle`,render:Qu}),ed={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function td(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,ed,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 8V6a2 2 0 0 1 2-2h2M4 16v2a2 2 0 0 0 2 2h2m8-16h2a2 2 0 0 1 2 2v2m-4 12h2a2 2 0 0 0 2-2v-2`},null,-1)]])}var nd=(0,f.markRaw)({name:`tabler-maximize`,render:td}),rd={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function id(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,rd,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 19v-2a2 2 0 0 1 2-2h2M15 5v2a2 2 0 0 0 2 2h2M5 15h2a2 2 0 0 1 2 2v2M5 9h2a2 2 0 0 0 2-2V5`},null,-1)]])}var ad=(0,f.markRaw)({name:`tabler-minimize`,render:id}),od={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function sd(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,od,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 10a7 7 0 1 0 14 0a7 7 0 1 0-14 0m4 0h6m-3-3v6m11 8l-6-6`},null,-1)]])}var cd=(0,f.markRaw)({name:`tabler-zoom-in`,render:sd}),ld={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function ud(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,ld,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 10a7 7 0 1 0 14 0a7 7 0 1 0-14 0m4 0h6m8 11l-6-6`},null,-1)]])}var dd=(0,f.markRaw)({name:`tabler-zoom-out`,render:ud}),fd={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function pd(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,fd,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 5a2 2 0 1 0 4 0a2 2 0 1 0-4 0m14 0a2 2 0 1 0 4 0a2 2 0 1 0-4 0M3 19a2 2 0 1 0 4 0a2 2 0 1 0-4 0m14 0a2 2 0 1 0 4 0a2 2 0 1 0-4 0M5 7v10M7 5h10M7 19h10m2-12v10`},null,-1)]])}var md=(0,f.markRaw)({name:`tabler-shape`,render:pd}),hd={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function gd(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,hd,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 7a2 2 0 1 0 4 0a2 2 0 1 0-4 0m11 8a2 2 0 1 0 4 0a2 2 0 1 0-4 0m1-9a3 3 0 1 0 6 0a3 3 0 1 0-6 0M3 18a3 3 0 1 0 6 0a3 3 0 1 0-6 0m6-1l5-1.5m-7.5-7l7.81 5.37M7 7l8-1`},null,-1)]])}var _d=(0,f.markRaw)({name:`tabler-chart-dots-3`,render:gd}),vd={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function yd(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,vd,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`m18 10l-6-6l-6 6zm0 4l-6 6l-6-6z`},null,-1)]])}var bd=(0,f.markRaw)({name:`tabler-caret-up-down`,render:yd}),xd={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Sd(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,xd,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8 4H5v16h3m8-16h3v16h-3`},null,-1)]])}var Cd=(0,f.markRaw)({name:`tabler-brackets`,render:Sd}),wd={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Td(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,wd,[...t[0]||=[(0,f.createElementVNode)(`g`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`},[(0,f.createElementVNode)(`path`,{d:`M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 0 0-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 0 0-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 0 0-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 0 0-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 0 0 1.066-2.573c-.94-1.543.826-3.31 2.37-2.37c1 .608 2.296.07 2.572-1.065`}),(0,f.createElementVNode)(`path`,{d:`M9 12a3 3 0 1 0 6 0a3 3 0 0 0-6 0`})],-1)]])}var Ed=(0,f.markRaw)({name:`tabler-settings`,render:Td}),Dd=[{key:`showVolumePriceMarkers`,label:`显示量价关系标记`,type:`boolean`,default:!0,group:`main`},{key:`logarithmicScale`,label:`对数价格轴`,type:`boolean`,default:!1,group:`main`},{key:`disableMainPaneVerticalScroll`,label:`主图纵轴刻度自适应调整`,type:`boolean`,default:!0,group:`experimental`},{key:`performanceTest10kKlines`,label:`万条K线性能测试`,type:`boolean`,default:!1,group:`experimental`}],Od=`kline-chart-settings`,kd={class:`left-toolbar`,"aria-label":`图表工具栏`},Ad={class:`left-toolbar__group`},jd=[`title`,`aria-label`,`onClick`],Md=[`onClick`],Nd=[`title`,`aria-label`,`onClick`],Pd={class:`left-toolbar__group`},Fd={class:`left-toolbar__group`},Id=[`title`,`aria-label`],Ld={class:`left-toolbar__group`},Rd={class:`settings-body`},zd={class:`settings-label`},Bd=[`onUpdate:modelValue`],Vd={class:`settings-label`},Hd=[`onUpdate:modelValue`],Ud=yo((0,f.defineComponent)({__name:`LeftToolbar`,props:{isFullscreen:{type:Boolean}},emits:[`selectTool`,`toggleFullscreen`,`zoomIn`,`zoomOut`,`settingsChange`],setup(e,{expose:t,emit:n}){let r=n,i=[{id:`cursor`,title:`光标`,icon:Mu},{id:`lines`,title:`线条`,icon:Fu,children:[{id:`trend-line`,title:`线段`,icon:Fu},{id:`ray`,title:`射线`,icon:Ru},{id:`h-line`,title:`水平线`,icon:Wu},{id:`h-ray`,title:`水平射线`,icon:Vu},{id:`v-line`,title:`垂直线`,icon:qu},{id:`crosshair-line`,title:`十字线`,icon:Xu},{id:`info-line`,title:`信息线`,icon:$u}]},{id:`channels`,title:`通道`,icon:md,children:[{id:`parallel-channel`,title:`平行通道`,icon:md},{id:`regression-channel`,title:`回归趋势`,icon:_d},{id:`flat-line`,title:`平滑顶底`,icon:bd},{id:`disjoint-channel`,title:`不相交通道`,icon:Cd}]}],a=(0,f.computed)(()=>Dd.filter(e=>e.group===`main`)),o=(0,f.computed)(()=>Dd.filter(e=>e.group===`experimental`)),s=(0,f.ref)(`cursor`),c=(0,f.ref)(null),l=(0,f.ref)(!1),u=Do();function d(){try{let e=localStorage.getItem(Od);if(e){let t=JSON.parse(e),n={};return Dd.forEach(e=>{n[e.key]=t[e.key]??e.default}),n}}catch{}let e={};return Dd.forEach(t=>{e[t.key]=t.default}),e}function p(e){try{localStorage.setItem(Od,JSON.stringify(e))}catch{}}let m=(0,f.ref)(d()),h=(0,f.ref)({...m.value});function g(e){return s.value===e.id?!0:e.children?e.children.some(e=>e.id===s.value):!1}function _(e){if(e.children?.length){if(!e.children.some(e=>e.id===s.value)){let t=e.children[0];s.value=t.id,r(`selectTool`,t.id)}y(e.id);return}s.value=e.id,r(`selectTool`,e.id),c.value=null}function v(e){s.value=e.id,r(`selectTool`,e.id),c.value=null}function y(e){c.value=c.value===e?null:e}function b(){h.value={...m.value},l.value=!0}function x(){l.value=!1}function S(){let e={};Dd.forEach(t=>{e[t.key]=t.default}),h.value=e}function C(){m.value={...h.value},p(m.value),r(`settingsChange`,{...m.value}),x()}function w(){return{...m.value}}t({getSettings:w});function T(e){e.target.closest(`.tool-item`)||(c.value=null)}return(0,f.onMounted)(()=>{document.addEventListener(`click`,T,!0),r(`settingsChange`,{...m.value})}),(0,f.onUnmounted)(()=>{document.removeEventListener(`click`,T,!0)}),(t,n)=>((0,f.openBlock)(),(0,f.createElementBlock)(f.Fragment,null,[(0,f.createElementVNode)(`nav`,kd,[(0,f.createElementVNode)(`div`,Ad,[((0,f.openBlock)(),(0,f.createElementBlock)(f.Fragment,null,(0,f.renderList)(i,e=>(0,f.createElementVNode)(`div`,{key:e.id,class:`tool-item`},[(0,f.createElementVNode)(`button`,{type:`button`,class:(0,f.normalizeClass)([`left-toolbar__button`,{active:g(e)}]),title:e.title,"aria-label":e.title,onClick:t=>_(e),onPointerdown:n[0]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointermove:n[1]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointerup:n[2]||=(0,f.withModifiers)(()=>{},[`stop`])},[((0,f.openBlock)(),(0,f.createBlock)((0,f.resolveDynamicComponent)(e.icon),{class:`tool-icon`,"aria-hidden":`true`})),e.children&&e.children.length?((0,f.openBlock)(),(0,f.createElementBlock)(`span`,{key:0,class:(0,f.normalizeClass)([`corner-indicator`,{open:c.value===e.id}]),onClick:(0,f.withModifiers)(t=>y(e.id),[`stop`]),"aria-label":`展开子菜单`},null,10,Md)):(0,f.createCommentVNode)(``,!0)],42,jd),(0,f.createVNode)(f.Transition,{name:`dropdown`},{default:(0,f.withCtx)(()=>[c.value===e.id&&e.children&&e.children.length?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:0,class:`tool-dropdown`,onPointerdown:n[3]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointermove:n[4]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointerup:n[5]||=(0,f.withModifiers)(()=>{},[`stop`])},[((0,f.openBlock)(!0),(0,f.createElementBlock)(f.Fragment,null,(0,f.renderList)(e.children,e=>((0,f.openBlock)(),(0,f.createElementBlock)(`button`,{key:e.id,type:`button`,class:(0,f.normalizeClass)([`left-toolbar__button`,{active:s.value===e.id}]),title:e.title,"aria-label":e.title,onClick:t=>v(e)},[((0,f.openBlock)(),(0,f.createBlock)((0,f.resolveDynamicComponent)(e.icon),{class:`tool-icon`,"aria-hidden":`true`}))],10,Nd))),128))],32)):(0,f.createCommentVNode)(``,!0)]),_:2},1024)])),64))]),n[22]||=(0,f.createElementVNode)(`span`,{class:`left-toolbar__divider`},null,-1),(0,f.createElementVNode)(`div`,Pd,[(0,f.createElementVNode)(`button`,{type:`button`,class:`left-toolbar__button`,title:`放大`,"aria-label":`放大`,onClick:n[6]||=e=>t.$emit(`zoomIn`),onPointerdown:n[7]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointermove:n[8]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointerup:n[9]||=(0,f.withModifiers)(()=>{},[`stop`])},[(0,f.createVNode)((0,f.unref)(cd),{class:`tool-icon`,"aria-hidden":`true`})],32),(0,f.createElementVNode)(`button`,{type:`button`,class:`left-toolbar__button`,title:`缩小`,"aria-label":`缩小`,onClick:n[10]||=e=>t.$emit(`zoomOut`),onPointerdown:n[11]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointermove:n[12]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointerup:n[13]||=(0,f.withModifiers)(()=>{},[`stop`])},[(0,f.createVNode)((0,f.unref)(dd),{class:`tool-icon`,"aria-hidden":`true`})],32)]),n[23]||=(0,f.createElementVNode)(`span`,{class:`left-toolbar__divider`},null,-1),(0,f.createElementVNode)(`div`,Fd,[(0,f.createElementVNode)(`button`,{type:`button`,class:`left-toolbar__button`,title:e.isFullscreen?`退出全屏`:`全屏显示`,"aria-label":e.isFullscreen?`退出全屏`:`全屏显示`,onClick:n[14]||=e=>t.$emit(`toggleFullscreen`),onPointerdown:n[15]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointermove:n[16]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointerup:n[17]||=(0,f.withModifiers)(()=>{},[`stop`])},[e.isFullscreen?((0,f.openBlock)(),(0,f.createBlock)((0,f.unref)(ad),{key:0,class:`tool-icon`,"aria-hidden":`true`})):((0,f.openBlock)(),(0,f.createBlock)((0,f.unref)(nd),{key:1,class:`tool-icon`,"aria-hidden":`true`}))],40,Id)]),n[24]||=(0,f.createElementVNode)(`span`,{class:`left-toolbar__divider`},null,-1),(0,f.createElementVNode)(`div`,Ld,[(0,f.createElementVNode)(`button`,{type:`button`,class:`left-toolbar__button`,title:`设置`,"aria-label":`设置`,onClick:b,onPointerdown:n[18]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointermove:n[19]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointerup:n[20]||=(0,f.withModifiers)(()=>{},[`stop`])},[(0,f.createVNode)((0,f.unref)(Ed),{class:`tool-icon`,"aria-hidden":`true`})],32)])]),((0,f.openBlock)(),(0,f.createBlock)(f.Teleport,{to:(0,f.unref)(u)},[(0,f.createVNode)(f.Transition,{name:`overlay`},{default:(0,f.withCtx)(()=>[l.value?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:0,class:`settings-overlay`,onClick:x},[(0,f.createVNode)(f.Transition,{name:`modal`},{default:(0,f.withCtx)(()=>[(0,f.createElementVNode)(`div`,{class:`settings-modal`,onClick:n[21]||=(0,f.withModifiers)(()=>{},[`stop`])},[(0,f.createElementVNode)(`div`,{class:`settings-header`},[n[26]||=(0,f.createElementVNode)(`div`,{class:`header-left`},[(0,f.createElementVNode)(`span`,{class:`settings-title`},`图表设置`),(0,f.createElementVNode)(`span`,{class:`settings-subtitle`},`个性化配置`)],-1),(0,f.createElementVNode)(`div`,{class:`header-right`},[(0,f.createElementVNode)(`button`,{class:`settings-close`,onClick:x},[...n[25]||=[(0,f.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`},[(0,f.createElementVNode)(`path`,{d:`M18 6L6 18M6 6l12 12`})],-1)]])])]),(0,f.createElementVNode)(`div`,Rd,[a.value.length>0?((0,f.openBlock)(),(0,f.createElementBlock)(f.Fragment,{key:0},[n[27]||=(0,f.createElementVNode)(`div`,{class:`settings-section-divider`},[(0,f.createElementVNode)(`span`,{class:`settings-section-label`},`主图设置`)],-1),((0,f.openBlock)(!0),(0,f.createElementBlock)(f.Fragment,null,(0,f.renderList)(a.value,e=>((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:e.key,class:`settings-item`},[(0,f.createElementVNode)(`label`,zd,[(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)(e.label),1),(0,f.withDirectives)((0,f.createElementVNode)(`input`,{type:`checkbox`,class:`settings-checkbox`,"onUpdate:modelValue":t=>h.value[e.key]=t},null,8,Bd),[[f.vModelCheckbox,h.value[e.key]]])])]))),128))],64)):(0,f.createCommentVNode)(``,!0),o.value.length>0?((0,f.openBlock)(),(0,f.createElementBlock)(f.Fragment,{key:1},[n[28]||=(0,f.createElementVNode)(`div`,{class:`settings-section-divider`},[(0,f.createElementVNode)(`span`,{class:`settings-section-label`},`实验性 / 临时`)],-1),((0,f.openBlock)(!0),(0,f.createElementBlock)(f.Fragment,null,(0,f.renderList)(o.value,e=>((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:e.key,class:`settings-item experimental`},[(0,f.createElementVNode)(`label`,Vd,[(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)(e.label),1),(0,f.withDirectives)((0,f.createElementVNode)(`input`,{type:`checkbox`,class:`settings-checkbox`,"onUpdate:modelValue":t=>h.value[e.key]=t},null,8,Hd),[[f.vModelCheckbox,h.value[e.key]]])])]))),128))],64)):(0,f.createCommentVNode)(``,!0)]),(0,f.createElementVNode)(`div`,{class:`settings-footer`},[(0,f.createElementVNode)(`button`,{class:`settings-btn reset`,onClick:S},[...n[29]||=[(0,f.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`},[(0,f.createElementVNode)(`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}),(0,f.createElementVNode)(`path`,{d:`M3 3v5h5`})],-1),(0,f.createTextVNode)(` 重置 `,-1)]]),(0,f.createElementVNode)(`div`,{class:`footer-right`},[(0,f.createElementVNode)(`button`,{class:`settings-btn cancel`,onClick:x},`取消`),(0,f.createElementVNode)(`button`,{class:`settings-btn confirm`,onClick:C},[...n[30]||=[(0,f.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.5`},[(0,f.createElementVNode)(`path`,{d:`M20 6L9 17l-5-5`})],-1),(0,f.createTextVNode)(` 确定 `,-1)]])])])])]),_:1})])):(0,f.createCommentVNode)(``,!0)]),_:1})],8,[`to`]))],64))}}),[[`__scopeId`,`data-v-f47a57b0`]]),Wd={class:`chart-wrapper`},Gd={class:`pane-separator-layer`,"aria-hidden":`true`},Kd=4,qd=yo((0,f.defineComponent)({__name:`KLineChart`,props:{semanticConfig:{},yPaddingPx:{default:0},minKWidth:{default:2},maxKWidth:{default:50},rightAxisWidth:{default:0},bottomAxisHeight:{default:24},priceLabelWidth:{default:60},zoomLevels:{default:20},initialZoomLevel:{default:3},isFullscreen:{type:Boolean,default:!1}},emits:[`zoomLevelChange`,`toggleFullscreen`],setup(e,{expose:t,emit:n}){let r=e,i=n,a=(0,f.ref)(null),o=(0,f.ref)(null),s=(0,f.ref)(null),c=(0,f.ref)(null),l=(0,f.ref)(null),u=(0,f.ref)(null),d=(0,f.ref)(null),p=(0,f.shallowRef)(null),m=(0,f.shallowRef)(null),h=Ls({initialZoomLevel:r.initialZoomLevel??1,minKWidth:r.minKWidth,maxKWidth:r.maxKWidth,zoomLevels:r.zoomLevels,rightAxisWidth:r.rightAxisWidth,priceLabelWidth:r.priceLabelWidth});h.actions.setZoomState(h.state.zoomLevel,El(h.state.zoomLevel,{minKWidth:r.minKWidth,maxKWidth:r.maxKWidth,zoomLevelCount:r.zoomLevels,dpr:h.state.viewportDpr}),Dl(h.state.viewportDpr)),(0,f.computed)(()=>h.state.dataLength),(0,f.computed)(()=>h.state.viewportDpr);let g=(0,f.computed)(()=>h.state.zoomLevel),_=(0,f.computed)(()=>h.state.kWidth),v=(0,f.computed)(()=>h.state.kGap),y=(0,f.computed)(()=>h.state.paneRatios),b=(0,f.computed)(()=>h.state.selectedDrawingId),x=(0,f.computed)(()=>h.state.dataVersion);function S(){p.value?.scheduleDraw()}function C(e){if(p.value?.updateSettings(e),e.performanceTest10kKlines){let e=w();console.time(`updateData-10k`),p.value?.updateData(e),console.timeEnd(`updateData-10k`),h.actions.setDataLength(e.length),h.actions.bumpDataVersion()}else m.value&&p.value?.getData()?.length===1e4&&m.value.applyConfig(r.semanticConfig)}function w(){let e=[],t=new Date(`2020-01-01`).getTime(),n=3e3;for(let r=0;r<1e4;r++){let i=t+r*864e5,a=(Math.random()-.5)*2*.02+1e-4,o=n,s=o*(1+a),c=Math.max(o,s)*(1+Math.random()*.01),l=Math.min(o,s)*(1-Math.random()*.01),u=Math.floor(1e6+Math.random()*5e6);e.push({timestamp:i,open:parseFloat(o.toFixed(2)),high:parseFloat(c.toFixed(2)),low:parseFloat(l.toFixed(2)),close:parseFloat(s.toFixed(2)),volume:u}),n=s}return e}function T(e,t,n){let r=e.getBoundingClientRect();return{width:Math.max(t,Math.round(r.width)),height:Math.max(n,Math.round(r.height))}}function E(e){if(!e)return;let t=T(e,180,80);p.value?.interaction.setTooltipSize(t)}function D(e){e&&(ee.value=T(e,120,60))}let O=(0,f.ref)({x:0,y:0}),k=(0,f.ref)(!1),A=(0,f.shallowRef)({crosshairPos:null,crosshairIndex:null,crosshairPrice:null,hoveredIndex:null,activePaneId:null,tooltipPos:{x:0,y:0},tooltipAnchorPlacement:`right-bottom`,hoveredMarkerData:null,hoveredCustomMarker:null,isDragging:!1,isResizingPaneBoundary:!1,isHoveringPaneBoundary:!1,hoveredPaneBoundaryId:null,isHoveringRightAxis:!1}),j=(0,f.shallowRef)(null),M=(0,f.computed)(()=>{let e=b.value;return e?h.state.drawings.find(t=>t.id===e)??null:null}),N=(0,f.ref)([]),ee=(0,f.ref)({width:220,height:120}),P=(0,f.computed)(()=>{let e=c.value,t=l.value;return!e||!t?{x:0,y:0}:{x:e.offsetLeft,y:e.offsetTop}}),F=(0,f.computed)(()=>A.value.hoveredMarkerData),te=(0,f.computed)(()=>A.value.hoveredCustomMarker),ne=(0,f.computed)(()=>A.value.isDragging),re=(0,f.computed)(()=>A.value.isResizingPaneBoundary),ie=(0,f.computed)(()=>A.value.isHoveringPaneBoundary),ae=(0,f.computed)(()=>A.value.hoveredPaneBoundaryId),oe=(0,f.computed)(()=>A.value.isHoveringRightAxis),se=(0,f.computed)(()=>A.value.hoveredIndex),ce=(0,f.computed)(()=>A.value.crosshairIndex),le=(0,f.computed)(()=>{let e=A.value.hoveredIndex;if(typeof e!=`number`)return null;x.value;let t=p.value?.getData();return t&&e>=0&&e<t.length?t[e]:null}),ue=(0,f.computed)(()=>A.value.hoveredIndex),de=(0,f.computed)(()=>A.value.tooltipPos),fe=(0,f.computed)(()=>({x:de.value.x+P.value.x,y:de.value.y+P.value.y})),pe=(0,f.computed)(()=>({left:`${fe.value.x}px`,top:`${fe.value.y}px`})),me=(0,f.computed)(()=>({x:O.value.x+P.value.x,y:O.value.y+P.value.y})),he=(0,f.computed)(()=>({left:`${me.value.x}px`,top:`${me.value.y}px`})),ge=(0,f.computed)(()=>A.value.tooltipAnchorPlacement),_e=(0,f.computed)(()=>{let e=p.value?.getViewport(),t=c.value,n=e?.plotWidth??(t?t.clientWidth:0);return O.value.x+12+ee.value.width+12>n?`left-bottom`:`right-bottom`}),ve=(0,f.computed)(()=>(x.value,p.value?.getData()??[]));function ye(e){j.value?.setTool(e)}function be(e){let t=M.value;!t||!j.value||(j.value.updateDrawingStyle(t.id,e),h.actions.bumpDrawingVersion())}function xe(){let e=M.value;!e||!j.value||(j.value.removeDrawing(e.id),h.actions.setSelectedDrawingId(null),h.actions.bumpDrawingVersion(),h.actions.setDrawings(j.value.getDrawings()))}function Se(e){let t=c.value;if(t){if(j.value?.onPointerDown(e,t)){h.actions.setDrawings(j.value.getDrawings()),h.actions.bumpDrawingVersion();return}p.value?.interaction.onPointerDown(e)}}function Ce(e){let t=c.value;if(t){let n=t.getBoundingClientRect();if(O.value={x:e.clientX-n.left,y:e.clientY-n.top},j.value?.onPointerMove(e,t)){h.actions.setDrawings(j.value.getDrawings());return}}p.value?.interaction.onPointerMove(e)}function we(e){let t=c.value;if(t&&j.value?.onPointerUp(e,t)){h.actions.setDrawings(j.value.getDrawings());return}p.value?.interaction.onPointerUp(e)}function Te(e){p.value?.interaction.onPointerLeave(e)}function Ee(e){p.value?.interaction.onRightAxisPointerDown(e)}function De(e){p.value?.interaction.onRightAxisPointerMove(e)}function Oe(e){p.value?.interaction.onRightAxisPointerUp(e)}function ke(e){p.value?.interaction.onRightAxisPointerLeave(e)}function Ae(){p.value?.interaction.onScroll()}let I=(0,f.ref)([]),je=(0,f.ref)({}),L=(0,f.ref)([]),Me={VOLUME:{defaultParams:{},getTitleInfo:()=>({name:`VOL`,params:[],values:[]})},MACD:{defaultParams:{fastPeriod:12,slowPeriod:26,signalPeriod:9},getTitleInfo:(e,t,n)=>t===null?null:Rc(e,t,n.fastPeriod??12,n.slowPeriod??26,n.signalPeriod??9)},RSI:{defaultParams:{period1:6,period2:12,period3:24},getTitleInfo:(e,t,n)=>t===null?null:Bc(t,n.period1??6,n.period2??12,n.period3??24,p.value.plugin,`sub_RSI`)},CCI:{defaultParams:{period:14,showCCI:!0},getTitleInfo:(e,t,n)=>t===null?null:Hc(t,n.period??14,p.value.plugin,`sub_CCI`)},STOCH:{defaultParams:{n:9,m:3,showK:!0,showD:!0},getTitleInfo:(e,t,n)=>t===null?null:Wc(t,n.n??9,n.m??3,p.value.plugin,`sub_STOCH`)},MOM:{defaultParams:{period:10,showMOM:!0},getTitleInfo:(e,t,n)=>t===null?null:Kc(t,n.period??10,p.value.plugin,`sub_MOM`)},WMSR:{defaultParams:{period:14,showWMSR:!0},getTitleInfo:(e,t,n)=>t===null?null:Jc(t,n.period??14,p.value.plugin,`sub_WMSR`)},KST:{defaultParams:{roc1:10,roc2:15,roc3:20,roc4:30,signalPeriod:9,showKST:!0,showSignal:!0},getTitleInfo:(e,t,n)=>t===null?null:Xc(t,n.roc1??10,n.roc2??15,n.roc3??20,n.roc4??30,n.signalPeriod??9,p.value.plugin,`sub_KST`)},FASTK:{defaultParams:{period:9,showFASTK:!0},getTitleInfo:(e,t,n)=>t===null?null:Qc(t,n.period??9,p.value.plugin,`sub_FASTK`)}},Ne=Object.keys(Me);function Pe(){let e=y.value.main??3;return L.value.length===0?[{id:`main`,ratio:e,visible:!0,role:`price`}]:[{id:`main`,ratio:e,visible:!0,role:`price`},...L.value.map(e=>({id:e.id,ratio:y.value[e.id]??1,visible:!0,role:`indicator`}))]}function Fe(e){return{...Me[e].defaultParams}}function Ie(e=`VOLUME`,t){if(L.value.length>=Kd)return!1;let n=`sub_${e}`;if(L.value.some(e=>e.id===n))return!0;if(!p.value?.createSubPane(e,t??Fe(e)))return!1;e===`RSI`&&p.value?.getIndicatorScheduler().updateRSIConfig(t??Fe(e),n),e===`CCI`&&p.value?.getIndicatorScheduler().updateCCIConfig(t??Fe(e),n),e===`STOCH`&&p.value?.getIndicatorScheduler().updateSTOCHConfig(t??Fe(e),n),e===`MOM`&&p.value?.getIndicatorScheduler().updateMOMConfig(t??Fe(e),n),e===`WMSR`&&p.value?.getIndicatorScheduler().updateWMSRConfig(t??Fe(e),n),e===`KST`&&p.value?.getIndicatorScheduler().updateKSTConfig(t??Fe(e),n),e===`FASTK`&&p.value?.getIndicatorScheduler().updateFASTKConfig(t??Fe(e),n);let r=ku({paneId:n,title:e,getTitleInfo:()=>Ve(n)});return p.value?.useRenderer(r),L.value.push({id:n,indicatorId:e,rendererName:`${e.toLowerCase()}_${n}`,paneTitleRendererName:r.name,params:t??Fe(e)}),I.value.includes(e)||I.value.push(e),S(),!0}function Le(e){let t=L.value.findIndex(t=>t.id===e);if(t===-1)return;let n=L.value[t];n&&(p.value?.removeRenderer(n.paneTitleRendererName),p.value?.removeSubPane(n.indicatorId),L.value.splice(t,1),L.value.some(e=>e.indicatorId===n.indicatorId)||(I.value=I.value.filter(e=>e!==n.indicatorId)))}function Re(){for(let e of L.value)p.value?.removeRenderer(e.paneTitleRendererName);p.value?.clearSubPanes(),L.value=[],I.value=I.value.filter(e=>!Ne.includes(e))}function ze(){let e=r.semanticConfig,t=p.value;if(!t)return;let n=e.indicators?.main;if(n)for(let e of n)e.enabled&&(I.value.includes(e.type)||I.value.push(e.type),e.params&&(je.value[e.type]=e.params),t.enableMainIndicator(e.type,e.params))}(0,f.watch)([I,je],([e])=>{let t=p.value;t&&(t.updateRendererConfig(`mainIndicatorLegend`,{indicators:{MA:{enabled:e.includes(`MA`),params:je.value.MA||{}},BOLL:{enabled:e.includes(`BOLL`),params:je.value.BOLL||{}},EXPMA:{enabled:e.includes(`EXPMA`),params:je.value.EXPMA||{}},ENE:{enabled:e.includes(`ENE`),params:je.value.ENE||{}}}}),S())},{deep:!0});function Be(){let e=p.value?.getSubPaneIndicators()??[];L.value=[];for(let t of e){let e=`sub_${t}`,n=ku({paneId:e,title:t,getTitleInfo:()=>Ve(e)});p.value?.useRenderer(n),L.value.push({id:e,indicatorId:t,rendererName:`${t.toLowerCase()}_${e}`,paneTitleRendererName:n.name,params:Fe(t)}),I.value.includes(t)||I.value.push(t)}S()}function R(e,t){let n=L.value.find(t=>t.id===e);if(!n)return;let r=n.indicatorId;p.value?.removeRenderer(n.paneTitleRendererName),p.value?.removeSubPane(r),p.value?.createSubPane(t,Fe(t));let i=`sub_${t}`,a=ku({paneId:i,title:t,getTitleInfo:()=>Ve(i)});p.value?.useRenderer(a);let o=L.value.findIndex(t=>t.id===e);o!==-1&&(L.value[o]={id:i,indicatorId:t,rendererName:`${t.toLowerCase()}_${i}`,paneTitleRendererName:a.name,params:Fe(t)}),I.value=I.value.filter(e=>e!==r),I.value.includes(t)||I.value.push(t)}function Ve(e){let t=L.value.find(t=>t.id===e);if(!t)return null;let n=p.value?.getData();if(!n||n.length===0)return null;let r=Me[t.indicatorId],i=t.params;return r.getTitleInfo(n,ce.value,i)}function He(e,t){let n=p.value;if(n){if(e===`MA`||e===`BOLL`||e===`EXPMA`||e===`ENE`){n.toggleMainIndicator(e,t),t?I.value.includes(e)||I.value.push(e):I.value=I.value.filter(t=>t!==e);return}if(Ne.includes(e)){if(t){if(I.value.includes(e)||I.value.push(e),L.value.find(t=>t.indicatorId===e))return;if(!Ie(e)){let t=L.value[L.value.length-1];t&&R(t.id,e)}}else I.value=I.value.filter(t=>t!==e),L.value.filter(t=>t.indicatorId===e).forEach(e=>Le(e.id));S()}}}function Ue(e,t){if(je.value[e]=t,e===`MA`||e===`BOLL`||e===`EXPMA`||e===`ENE`){p.value?.updateMainIndicatorParams(e,t),S();return}if(e===`RSI`){p.value?.getIndicatorScheduler().updateRSIConfig(t,`sub_RSI`),L.value.filter(e=>e.indicatorId===`RSI`).forEach(e=>{e.params={...t}}),S();return}if(e===`CCI`){p.value?.getIndicatorScheduler().updateCCIConfig(t,`sub_CCI`),L.value.filter(e=>e.indicatorId===`CCI`).forEach(e=>{e.params={...t}}),S();return}if(e===`STOCH`){p.value?.getIndicatorScheduler().updateSTOCHConfig(t,`sub_STOCH`),L.value.filter(e=>e.indicatorId===`STOCH`).forEach(e=>{e.params={...t}}),S();return}if(e===`MOM`){p.value?.getIndicatorScheduler().updateMOMConfig(t,`sub_MOM`),L.value.filter(e=>e.indicatorId===`MOM`).forEach(e=>{e.params={...t}}),S();return}if(e===`WMSR`){p.value?.getIndicatorScheduler().updateWMSRConfig(t,`sub_WMSR`),L.value.filter(e=>e.indicatorId===`WMSR`).forEach(e=>{e.params={...t}}),S();return}if(e===`KST`){p.value?.getIndicatorScheduler().updateKSTConfig(t,`sub_KST`),L.value.filter(e=>e.indicatorId===`KST`).forEach(e=>{e.params={...t}}),S();return}if(e===`FASTK`){p.value?.getIndicatorScheduler().updateFASTKConfig(t,`sub_FASTK`),L.value.filter(e=>e.indicatorId===`FASTK`).forEach(e=>{e.params={...t}}),S();return}Ne.includes(e)&&L.value.filter(t=>t.indicatorId===e).forEach(e=>{e.params={...t},p.value?.updateRendererConfig(e.rendererName,t)}),S()}function We(e){if(!e.length||L.value.length<=1)return;let t=e.filter(e=>Ne.includes(e));if(!t.length)return;let n=new Map(L.value.map(e=>[e.indicatorId,e])),r=[];for(let e of t){let t=n.get(e);t&&(r.push(t),n.delete(e))}if(r.length===0)return;for(let e of L.value)n.has(e.indicatorId)&&(r.push(e),n.delete(e.indicatorId));let i=L.value.map(e=>e.id),a=r.map(e=>e.id);if(i.join(`|`)===a.join(`|`))return;L.value=r;let o=I.value.filter(e=>!Ne.includes(e)),s=L.value.map(e=>e.indicatorId);I.value=[...o,...s];let c=p.value;c&&c.updatePaneLayout(Pe())}let Ge=(0,f.computed)(()=>r.rightAxisWidth+r.priceLabelWidth),Ke=h.computed.totalWidth;function qe(){let e=c.value,t=p.value;if(!e||!t)return;let n=t.getData()?.length??0;if(n===0)return;let r=t.getCurrentDpr(),{unitPx:i,startXPx:a}=na(_.value,v.value,r),o=(a+n*i)/r,s=Math.max(0,e.scrollWidth-e.clientWidth),l=Math.min(s,Math.max(0,o-e.clientWidth));e.scrollLeft=Math.round(l*r)/r,S()}function Je(e,t){let n=p.value,a=c.value;if(!n||!a)return;let o=n.getCurrentDpr(),s=kl(e,t??(n.getViewport()?.plotWidth??a.clientWidth)/2,a.scrollLeft,g.value,_.value,v.value,{minKWidth:r.minKWidth,maxKWidth:r.maxKWidth,zoomLevelCount:r.zoomLevels,dpr:o});s&&(h.actions.setZoomState(s.targetLevel,s.newKWidth,s.newKGap),n.interaction.clearHover(),(0,f.nextTick)(()=>{let e=c.value;if(!e)return;let t=Math.max(0,e.scrollWidth-e.clientWidth),r=Math.min(Math.max(0,s.newScrollLeft),t);e.scrollLeft=Math.round(r*o)/o,n.applyRenderState(s.newKWidth,s.newKGap,s.targetLevel),i(`zoomLevelChange`,s.targetLevel,s.newKWidth)}))}return t({scheduleRender:S,scrollToRight:qe,addSubPane:Ie,removeSubPane:Le,switchSubIndicator:R,clearAllSubPanes:Re,get plugin(){return p.value?.plugin},zoomToLevel:Je,zoomIn:e=>Je(g.value+1,e),zoomOut:e=>Je(g.value-1,e),getZoomLevel:()=>g.value,getZoomLevelCount:()=>p.value?.getZoomLevelCount()??10}),(0,f.onMounted)(()=>{k.value=!1;let e=c.value,t=o.value,n=s.value,l=a.value;if(!e||!t||!n||!l)return;let u=t=>{t.preventDefault();let n=p.value;if(!n)return;let a=e.getBoundingClientRect(),o=t.clientX-a.left,s=e.scrollLeft,l=n.getCurrentDpr(),u=Ol(t.deltaY>0?-1:1,o,s,g.value,_.value,v.value,{minKWidth:r.minKWidth,maxKWidth:r.maxKWidth,zoomLevelCount:r.zoomLevels,dpr:l});u&&(h.actions.setZoomState(u.targetLevel,u.newKWidth,u.newKGap),n.interaction.clearHover(),(0,f.nextTick)(()=>{let e=c.value;if(!e)return;let t=Math.max(0,e.scrollWidth-e.clientWidth),r=Math.min(Math.max(0,u.newScrollLeft),t);e.scrollLeft=Math.round(r*l)/l,n.applyRenderState(u.newKWidth,u.newKGap,u.targetLevel),i(`zoomLevelChange`,u.targetLevel,u.newKWidth)}))};e.addEventListener(`wheel`,u,{passive:!1});let y=new wl({container:e,canvasLayer:t,rightAxisLayer:n,xAxisCanvas:l},{yPaddingPx:r.yPaddingPx,rightAxisWidth:r.rightAxisWidth,bottomAxisHeight:r.bottomAxisHeight,priceLabelWidth:r.priceLabelWidth,minKWidth:r.minKWidth,maxKWidth:r.maxKWidth,panes:[{id:`main`,ratio:1}],paneGap:0,zoomLevels:r.zoomLevels,initialZoomLevel:r.initialZoomLevel});y.useRenderer(Jl()),y.useRenderer($l()),y.useRenderer(_c()),y.setRendererEnabled(`ma`,!1),y.useRenderer(yc()),y.setRendererEnabled(`boll`,!1),y.useRenderer(xc()),y.setRendererEnabled(`expma`,!1),y.useRenderer(Sc()),y.setRendererEnabled(`ene`,!1),y.useRenderer(Pl()),y.useRenderer(Yl()),y.useRenderer(Ra());let b=r.rightAxisWidth+r.priceLabelWidth,x=()=>{let e=y.interaction.crosshairPos,t=y.interaction.crosshairPrice,n=y.interaction.activePaneId;return e&&t!==null?{y:e.y,price:t,activePaneId:n}:null};y.useRenderer(fu({axisWidth:b,yPaddingPx:r.yPaddingPx,getCrosshair:x})),y.useRenderer(kc({yPaddingPx:r.yPaddingPx}));let S=[{create:hu,paneId:`sub_VOLUME`},{create:pu,paneId:`sub_MACD`},{create:gu,paneId:`sub_RSI`},{create:_u,paneId:`sub_CCI`},{create:vu,paneId:`sub_STOCH`},{create:yu,paneId:`sub_MOM`},{create:bu,paneId:`sub_WMSR`},{create:xu,paneId:`sub_KST`},{create:Su,paneId:`sub_FASTK`}];for(let e of S)y.useRenderer(e.create({axisWidth:b,paneId:e.paneId,yPaddingPx:r.yPaddingPx,getCrosshair:x}));y.useRenderer(Tu({getCrosshairState:()=>({pos:y.interaction.crosshairPos,activePaneId:y.interaction.activePaneId,isDragging:y.interaction.isDraggingState(),price:y.interaction.crosshairPrice})})),y.useRenderer(wu({height:r.bottomAxisHeight,getCrosshair:()=>{let e=y.interaction.crosshairPos,t=y.interaction.crosshairIndex;return e&&t!==null?{x:e.x,index:t}:null}})),y.setOnViewportChange(e=>{h.state.viewportDpr!==e.dpr&&h.actions.setViewportDpr(e.dpr),h.state.viewWidth!==e.plotWidth&&h.actions.setViewWidth(e.plotWidth);let t=Dl(e.dpr);h.state.kGap!==t&&h.actions.setZoomState(h.state.zoomLevel,h.state.kWidth,t);let n=y.getOption();(n.kWidth!==h.state.kWidth||n.kGap!==t)&&y.applyRenderState(h.state.kWidth,t,h.state.zoomLevel)}),y.setOnPaneLayoutChange(e=>{let t={};for(let n of e)t[n.id]=n.ratio;h.actions.setPaneRatios(t);let n=y.getPaneRenderers(),r=c.value&&parseInt(getComputedStyle(c.value).borderTopWidth)||0;N.value=n.slice(0,-1).map(e=>{let t=e.getPane();return{id:t.id,top:t.top+t.height+r}})}),y.setOnDataChange(e=>{h.actions.setDataLength(e.length),h.actions.bumpDataVersion()}),p.value=y,y.applyRenderState(h.state.kWidth,h.state.kGap,h.state.zoomLevel);let C=d.value?.getSettings()??{showVolumePriceMarkers:!0};y.updateSettings(C),j.value=new nl(y),j.value.setCallbacks({onDrawingCreated:e=>{h.actions.setDrawings([...h.state.drawings,e]),h.actions.setSelectedDrawingId(e.id)},onToolChange:e=>{},onDrawingSelected:e=>{h.actions.setSelectedDrawingId(e?.id??null)}}),y.interaction.setTooltipAnchorPositioning(k.value),y.interaction.setOnInteractionChange(e=>{A.value=e}),y.interaction.setOnPinchZoom((e,t)=>{let n=c.value;if(!n||!y)return;let a=t-n.getBoundingClientRect().left,o=n.scrollLeft,s=y.getCurrentDpr(),l=Ol(e,a,o,g.value,_.value,v.value,{minKWidth:r.minKWidth,maxKWidth:r.maxKWidth,zoomLevelCount:r.zoomLevels,dpr:s});l&&(h.actions.setZoomState(l.targetLevel,l.newKWidth,l.newKGap),y.interaction.clearHover(),(0,f.nextTick)(()=>{let e=c.value;if(!e)return;let t=Math.max(0,e.scrollWidth-e.clientWidth),n=Math.min(Math.max(0,l.newScrollLeft),t);e.scrollLeft=Math.round(n*s)/s,y.applyRenderState(l.newKWidth,l.newKGap,l.targetLevel),i(`zoomLevelChange`,l.targetLevel,l.newKWidth)}))}),A.value=y.interaction.getInteractionSnapshot(),h.actions.setViewportDpr(y.getCurrentDpr()),y.resize(),m.value=new ji(y),m.value.on(`config:error`,e=>{console.error(`Semantic config error:`,e)}),m.value.on(`config:ready`,()=>{h.actions.setDataLength(y.getData()?.length??0),h.actions.bumpDataVersion(),ze(),Be(),(0,f.nextTick)(()=>qe())}),m.value.applyConfig(r.semanticConfig).then(e=>{e&&!e.success&&console.error(`Semantic config apply failed:`,e.errors)}),y.__onWheel=u}),(0,f.onUnmounted)(()=>{let e=p.value;if(e){let t=e.__onWheel,n=c.value;t&&n&&n.removeEventListener(`wheel`,t),e.destroy()}p.value=null,j.value=null}),(0,f.watch)(()=>r.yPaddingPx,e=>{p.value?.updateOptions({yPaddingPx:e})}),(0,f.watch)(()=>r.semanticConfig,async(e,t)=>{if(e&&e!==t){let t=await m.value?.applyConfig(e);t&&!t.success&&console.error(`Semantic config apply failed:`,t.errors)}},{deep:!0}),(t,n)=>((0,f.openBlock)(),(0,f.createElementBlock)(`div`,Wd,[(0,f.createElementVNode)(`div`,{class:(0,f.normalizeClass)([`chart-stage`,{"is-dragging":ne.value,"is-resizing-pane":re.value,"is-hovering-pane-separator":ie.value,"is-hovering-right-axis":oe.value,"is-hovering-kline":se.value!==null}])},[(0,f.createVNode)(Ud,{ref_key:`toolbarRef`,ref:d,"is-fullscreen":e.isFullscreen,onSelectTool:ye,onToggleFullscreen:n[0]||=e=>t.$emit(`toggleFullscreen`),onZoomIn:n[1]||=e=>Je(g.value+1),onZoomOut:n[2]||=e=>Je(g.value-1),onSettingsChange:C},null,8,[`is-fullscreen`]),(0,f.createElementVNode)(`div`,{class:`chart-main`,ref_key:`chartMainRef`,ref:l},[(0,f.createElementVNode)(`div`,Gd,[((0,f.openBlock)(!0),(0,f.createElementBlock)(f.Fragment,null,(0,f.renderList)(N.value,e=>((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:e.id,class:(0,f.normalizeClass)([`pane-separator-line`,{"is-active":ae.value===e.id}]),style:(0,f.normalizeStyle)({top:`${e.top}px`})},null,6))),128))]),(0,f.createElementVNode)(`div`,{ref_key:`tooltipLayerRef`,ref:u,class:`tooltip-layer`},null,512),(0,f.createElementVNode)(`div`,{class:`chart-container`,ref_key:`containerRef`,ref:c,onScrollPassive:Ae,onPointerdown:Se,onPointermove:Ce,onPointerup:we,onPointerleave:Te},[(0,f.createElementVNode)(`div`,{class:`scroll-content`,style:(0,f.normalizeStyle)({width:(0,f.unref)(Ke)+`px`})},[(0,f.createElementVNode)(`div`,{class:`canvas-layer`,ref_key:`canvasLayerRef`,ref:o},[(0,f.createElementVNode)(`canvas`,{class:`x-axis-canvas`,ref_key:`xAxisCanvasRef`,ref:a},null,512),M.value?((0,f.openBlock)(),(0,f.createBlock)(Cs,{key:0,drawing:M.value,onUpdateStyle:be,onDelete:xe},null,8,[`drawing`])):(0,f.createCommentVNode)(``,!0)],512)],4)],544),u.value?((0,f.openBlock)(),(0,f.createBlock)(f.Teleport,{key:0,to:u.value},[le.value?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:0,class:(0,f.normalizeClass)([`tooltip-anchor kline-tooltip-anchor`,{"use-anchor":k.value}]),style:(0,f.normalizeStyle)(pe.value)},null,6)):(0,f.createCommentVNode)(``,!0),F.value||te.value?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:1,class:(0,f.normalizeClass)([`tooltip-anchor marker-tooltip-anchor`,{"use-anchor":k.value}]),style:(0,f.normalizeStyle)(he.value)},null,6)):(0,f.createCommentVNode)(``,!0),le.value?((0,f.openBlock)(),(0,f.createBlock)(bo,{key:2,k:le.value,index:ue.value,data:ve.value,pos:fe.value,"set-el":E,"use-anchor":k.value,"anchor-placement":ge.value},null,8,[`k`,`index`,`data`,`pos`,`use-anchor`,`anchor-placement`])):(0,f.createCommentVNode)(``,!0),F.value||te.value?((0,f.openBlock)(),(0,f.createBlock)(To,{key:3,marker:F.value||te.value,pos:me.value,"use-anchor":k.value,"anchor-placement":_e.value,"set-el":D},null,8,[`marker`,`pos`,`use-anchor`,`anchor-placement`])):(0,f.createCommentVNode)(``,!0)],8,[`to`])):(0,f.createCommentVNode)(``,!0),(0,f.createElementVNode)(`div`,{class:`right-axis-host`,ref_key:`rightAxisLayerRef`,ref:s,style:(0,f.normalizeStyle)({width:Ge.value+`px`}),onPointerdown:Ee,onPointermove:De,onPointerup:Oe,onPointerleave:ke},null,36)],512)],2),(0,f.createVNode)(hs,{"active-indicators":I.value,"indicator-params":je.value,onToggle:He,onUpdateParams:Ue,onReorderSubIndicators:We},null,8,[`active-indicators`,`indicator-params`])]))}}),[[`__scopeId`,`data-v-533a72a5`]]),Jd={install(e){e.component(`KLineChart`,qd)}};exports.ConfigManager=Zi,exports.EventBus=p,exports.GLOBAL_PANE_ID=Ji,exports.HookSystem=Xi,exports.KLineChart=qd,exports.KMapPlugin=Jd,exports.PluginHostImpl=$i,exports.PluginRegistry=Yi,exports.PluginState=Ki,exports.RENDERER_PRIORITY=G,exports.RendererPluginManager=ma,exports.createPluginHost=ea,exports.wrapPaneInfo=qi;
63
+ }`,Ns=new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),Ps=class{canvas;handles=null;logicalWidth=0;logicalHeight=0;available=!1;rectCapacity=0;rectScratch=new Float32Array;constructor(e){this.canvas=e??document.createElement(`canvas`),this.handles=this.initRectHandles(),this.available=this.handles!==null}isAvailable(){return this.available}getCanvas(){return this.canvas}resize(e,t,n){this.logicalWidth=e,this.logicalHeight=t;let r=Math.max(1,Math.round(e*n)),i=Math.max(1,Math.round(t*n));this.canvas.width!==r&&(this.canvas.width=r),this.canvas.height!==i&&(this.canvas.height=i)}clear(){let e=this.handles?.gl;!e||this.logicalWidth<=0||this.logicalHeight<=0||(e.viewport(0,0,this.canvas.width,this.canvas.height),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT))}drawRects(e,t,n){let r=this.handles;if(!r||!e.length||this.logicalWidth<=0||this.logicalHeight<=0)return!1;let i=Bs(t);if(!i)return!1;let a=e.length*4;this.rectScratch.length<a&&(this.rectScratch=new Float32Array(Is(a)));for(let t=0;t<e.length;t++){let n=e[t],r=t*4;this.rectScratch[r]=n.x,this.rectScratch[r+1]=n.y,this.rectScratch[r+2]=n.width,this.rectScratch[r+3]=n.height}let{gl:o}=r;return o.viewport(0,0,this.canvas.width,this.canvas.height),o.useProgram(r.program),o.bindVertexArray(r.vao),o.bindBuffer(o.ARRAY_BUFFER,r.rectBuffer),this.rectCapacity<a&&(this.rectCapacity=Is(a),o.bufferData(o.ARRAY_BUFFER,this.rectCapacity*Float32Array.BYTES_PER_ELEMENT,o.DYNAMIC_DRAW)),o.bufferSubData(o.ARRAY_BUFFER,0,this.rectScratch.subarray(0,a)),o.uniform2f(r.resolutionLocation,this.logicalWidth,this.logicalHeight),o.uniform1f(r.scrollXLocation,n),o.uniform4f(r.colorLocation,i[0],i[1],i[2],i[3]),o.drawArraysInstanced(o.TRIANGLES,0,6,e.length),o.bindVertexArray(null),!0}destroy(){let e=this.handles;if(!e)return;let{gl:t,program:n,vao:r,unitBuffer:i,rectBuffer:a}=e;t.deleteBuffer(i),t.deleteBuffer(a),t.deleteVertexArray(r),t.deleteProgram(n),this.handles=null,this.available=!1}initRectHandles(){let e=null;try{e=this.canvas.getContext(`webgl2`,{alpha:!0,antialias:!1,depth:!1,stencil:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1})}catch{e=null}if(!e)return null;let t=Rs(e,e.VERTEX_SHADER,As),n=Rs(e,e.FRAGMENT_SHADER,Ms);if(!t||!n)return t&&e.deleteShader(t),n&&e.deleteShader(n),null;let r=zs(e,t,n);if(e.deleteShader(t),e.deleteShader(n),!r)return null;let i=e.createVertexArray(),a=e.createBuffer(),o=e.createBuffer();if(!i||!a||!o)return i&&e.deleteVertexArray(i),a&&e.deleteBuffer(a),o&&e.deleteBuffer(o),e.deleteProgram(r),null;let s=e.getUniformLocation(r,`u_resolution`),c=e.getUniformLocation(r,`u_scrollX`),l=e.getUniformLocation(r,`u_color`);if(!s||!c||!l)return e.deleteBuffer(a),e.deleteBuffer(o),e.deleteVertexArray(i),e.deleteProgram(r),null;let u=e.getAttribLocation(r,`a_unit`),d=e.getAttribLocation(r,`a_rect`);return u<0||d<0?(e.deleteBuffer(a),e.deleteBuffer(o),e.deleteVertexArray(i),e.deleteProgram(r),null):(e.bindVertexArray(i),e.bindBuffer(e.ARRAY_BUFFER,a),e.bufferData(e.ARRAY_BUFFER,Ns,e.STATIC_DRAW),e.enableVertexAttribArray(u),e.vertexAttribPointer(u,2,e.FLOAT,!1,0,0),e.vertexAttribDivisor(u,0),e.bindBuffer(e.ARRAY_BUFFER,o),e.enableVertexAttribArray(d),e.vertexAttribPointer(d,4,e.FLOAT,!1,16,0),e.vertexAttribDivisor(d,1),e.bindVertexArray(null),e.enable(e.BLEND),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA),{gl:e,program:r,vao:i,unitBuffer:a,rectBuffer:o,resolutionLocation:s,scrollXLocation:c,colorLocation:l})}},Fs=class{canvas;handles=null;logicalWidth=0;logicalHeight=0;dpr=1;available=!1;vertexCapacity=0;geoCache=new WeakMap;constructor(e){this.canvas=e??document.createElement(`canvas`),this.handles=this.initLineHandles(),this.available=this.handles!==null}isAvailable(){return this.available}getCanvas(){return this.canvas}resize(e,t,n){this.logicalWidth=e,this.logicalHeight=t,this.dpr=n;let r=Math.max(1,Math.round(e*n)),i=Math.max(1,Math.round(t*n));this.canvas.width!==r&&(this.canvas.width=r),this.canvas.height!==i&&(this.canvas.height=i)}clear(){let e=this.handles?.gl;!e||this.logicalWidth<=0||this.logicalHeight<=0||(e.viewport(0,0,this.canvas.width,this.canvas.height),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT))}drawLineStrip(e,t,n){let r=this.handles;if(!r||e.points.length<2||this.logicalWidth<=0||this.logicalHeight<=0)return!1;let i=Bs(t);if(!i)return!1;let a=e.width/2,o,s=this.geoCache.get(e.points);if(s){let t=s.get(a);t?o=t:(o=Ls(e.points,a),o&&s.set(a,o))}else o=Ls(e.points,a),o&&(s=new Map,s.set(a,o),this.geoCache.set(e.points,s));if(!o)return!1;let{gl:c}=r;c.viewport(0,0,this.canvas.width,this.canvas.height),c.useProgram(r.program),c.bindVertexArray(r.vao),c.bindBuffer(c.ARRAY_BUFFER,r.vertexBuffer);let l=o.vertices.length;return this.vertexCapacity<l&&(this.vertexCapacity=Is(l),c.bufferData(c.ARRAY_BUFFER,this.vertexCapacity*Float32Array.BYTES_PER_ELEMENT,c.DYNAMIC_DRAW)),c.bufferSubData(c.ARRAY_BUFFER,0,o.vertices),c.uniform2f(r.resolutionLocation,this.logicalWidth,this.logicalHeight),c.uniform1f(r.scrollXLocation,n),c.uniform4f(r.colorLocation,i[0],i[1],i[2],i[3]),c.drawArrays(c.TRIANGLES,0,o.vertexCount),c.bindVertexArray(null),!0}destroy(){let e=this.handles;if(!e)return;let{gl:t,program:n,vao:r,vertexBuffer:i}=e;t.deleteBuffer(i),t.deleteVertexArray(r),t.deleteProgram(n),this.handles=null,this.available=!1}initLineHandles(){let e=null;try{e=this.canvas.getContext(`webgl2`,{alpha:!0,antialias:!0,depth:!1,stencil:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1})}catch{e=null}if(!e)return null;let t=Rs(e,e.VERTEX_SHADER,js),n=Rs(e,e.FRAGMENT_SHADER,Ms);if(!t||!n)return t&&e.deleteShader(t),n&&e.deleteShader(n),null;let r=zs(e,t,n);if(e.deleteShader(t),e.deleteShader(n),!r)return null;let i=e.createVertexArray(),a=e.createBuffer();if(!i||!a)return i&&e.deleteVertexArray(i),a&&e.deleteBuffer(a),e.deleteProgram(r),null;let o=e.getUniformLocation(r,`u_resolution`),s=e.getUniformLocation(r,`u_scrollX`),c=e.getUniformLocation(r,`u_color`);if(!o||!s||!c)return e.deleteBuffer(a),e.deleteVertexArray(i),e.deleteProgram(r),null;let l=e.getAttribLocation(r,`a_position`);return l<0?(e.deleteBuffer(a),e.deleteVertexArray(i),e.deleteProgram(r),null):(e.bindVertexArray(i),e.bindBuffer(e.ARRAY_BUFFER,a),e.enableVertexAttribArray(l),e.vertexAttribPointer(l,2,e.FLOAT,!1,0,0),e.bindVertexArray(null),e.enable(e.BLEND),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA),{gl:e,program:r,vao:i,vertexBuffer:a,resolutionLocation:o,scrollXLocation:s,colorLocation:c})}};function Is(e){let t=1;for(;t<e;)t<<=1;return t}function Ls(e,t){if(e.length<2)return null;let n=Array(e.length-1),r=0;for(let t=0;t<e.length-1;t++){let i=e[t],a=e[t+1],o=a.x-i.x,s=a.y-i.y,c=Math.hypot(o,s);if(c<=0){n[t]={nx:0,ny:0,valid:!1};continue}n[t]={nx:-s/c,ny:o/c,valid:!0},r++}if(r===0)return null;let i=(e.length-1)*12,a=new Float32Array(i),o=0;for(let r=0;r<e.length-1;r++){let i=e[r],s=e[r+1],c=r>0?n[r-1]:null,l=n[r];if(!l.valid||!c&&!l.valid)continue;let u=0,d=0;if(c?.valid&&l.valid){u=c.nx+l.nx,d=c.ny+l.ny;let e=Math.hypot(u,d);if(e>1e-6){u/=e,d/=e;let t=u*l.nx+d*l.ny,n=Math.max(.2,Math.abs(t));u*=1/n,d*=1/n}else u=l.nx,d=l.ny}else if(l.valid)u=l.nx,d=l.ny;else if(c?.valid)u=c.nx,d=c.ny;else continue;let f=l.nx,p=l.ny,m=r<e.length-2?n[r+1]:null;if(m?.valid&&l.valid){f=l.nx+m.nx,p=l.ny+m.ny;let e=Math.hypot(f,p);if(e>1e-6){f/=e,p/=e;let t=f*m.nx+p*m.ny,n=Math.max(.2,Math.abs(t));f*=1/n,p*=1/n}else f=l.nx,p=l.ny}let h=i.x+u*t,g=i.y+d*t,_=i.x-u*t,v=i.y-d*t,y=s.x+f*t,b=s.y+p*t,x=s.x-f*t,S=s.y-p*t;a[o++]=h,a[o++]=g,a[o++]=_,a[o++]=v,a[o++]=y,a[o++]=b,a[o++]=y,a[o++]=b,a[o++]=_,a[o++]=v,a[o++]=x,a[o++]=S}return o===0?null:{vertices:o===i?a:a.subarray(0,o),vertexCount:o/2}}function Rs(e,t,n){let r=e.createShader(t);return r?(e.shaderSource(r,n),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS)?r:(e.deleteShader(r),null)):null}function zs(e,t,n){let r=e.createProgram();return r?(e.attachShader(r,t),e.attachShader(r,n),e.linkProgram(r),e.getProgramParameter(r,e.LINK_STATUS)?r:(e.deleteProgram(r),null)):null}function Bs(e){let t=e.trim().toLowerCase();if(t.startsWith(`rgba(`)){let e=t.slice(5,-1).split(`,`).map(e=>Number(e.trim()));if(e.length===4&&e.every(e=>Number.isFinite(e)))return[e[0]/255,e[1]/255,e[2]/255,e[3]]}if(t.startsWith(`rgb(`)){let e=t.slice(4,-1).split(`,`).map(e=>Number(e.trim()));if(e.length===3&&e.every(e=>Number.isFinite(e)))return[e[0]/255,e[1]/255,e[2]/255,1]}if(t.startsWith(`#`)){let e=t.slice(1);if(e.length===6)return[Number.parseInt(e.slice(0,2),16)/255,Number.parseInt(e.slice(2,4),16)/255,Number.parseInt(e.slice(4,6),16)/255,1];if(e.length===3)return[Number.parseInt(e[0]+e[0],16)/255,Number.parseInt(e[1]+e[1],16)/255,Number.parseInt(e[2]+e[2],16)/255,1]}return null}var Vs=class{dom;pane;opt;contexts=null;webgl;constructor(e,t,n){this.dom=e,this.pane=t,this.opt={...n,priceLabelWidth:n.priceLabelWidth||60},this.webgl={candleSurface:new Ps,lineSurface:new Fs}}getPane(){return this.pane}getDom(){return this.dom}getContexts(){return this.contexts||={mainCtx:this.dom.mainCanvas.getContext(`2d`),overlayCtx:this.dom.overlayCanvas.getContext(`2d`,{desynchronized:!0}),yAxisCtx:this.dom.yAxisCanvas.getContext(`2d`)},this.contexts}getWebGL(){return this.webgl}resize(e,t,n){let r=this.dom.mainCanvas,i=this.dom.overlayCanvas,a=this.dom.yAxisCanvas,o=this.opt.rightAxisWidth+(this.opt.priceLabelWidth||60),s=a.parentElement?.clientWidth??0,c=s>0?s:o,l=Math.round(e*n);r.width!==l&&(r.width=l);let u=Math.round(t*n);r.height!==u&&(r.height=u);let d=`${l/n}px`;r.style.width!==d&&(r.style.width=d);let f=`${u/n}px`;r.style.height!==f&&(r.style.height=f),i.width!==l&&(i.width=l),i.height!==u&&(i.height=u),i.style.width!==d&&(i.style.width=d),i.style.height!==f&&(i.style.height=f);let p=Math.round(c*n);a.width!==p&&(a.width=p);let m=Math.round(t*n);a.height!==m&&(a.height=m);let h=`${p/n}px`;a.style.width!==h&&(a.style.width=h);let g=`${m/n}px`;a.style.height!==g&&(a.style.height=g),this.webgl.candleSurface?.resize(e,t,n),this.webgl.lineSurface?.resize(e,t,n)}destroy(){this.contexts=null,this.webgl.candleSurface?.destroy(),this.webgl.lineSurface?.destroy()}};function Hs(e){let{dataLength:t,kWidth:n,kGap:r,viewWidth:i,viewportDpr:a}=e;if(t===0)return 0;let{startXPx:o,unitPx:s}=na(n,r,a),c=(o+(t+24)*s)/a;return Math.max(c,i)}function Us(e){let t=(0,f.reactive)({zoomLevel:e.initialZoomLevel,kWidth:0,kGap:1,viewportDpr:1,dataLength:0,dataVersion:0,paneRatios:{},drawings:[],selectedDrawingId:null,drawingVersion:0,viewWidth:0}),n=(0,f.computed)(()=>e.rightAxisWidth+e.priceLabelWidth),r=(0,f.computed)(()=>Hs({dataLength:t.dataLength,kWidth:t.kWidth,kGap:t.kGap,viewWidth:t.viewWidth,viewportDpr:t.viewportDpr}));function i(){t.dataVersion++}function a(){t.drawingVersion++}function o(e){t.dataLength=e}function s(e){t.viewportDpr=e}function c(e){t.viewWidth=e}function l(e,n,r){t.zoomLevel=e,t.kWidth=n,t.kGap=r}function u(e){t.paneRatios=e}function d(e){t.drawings=e,t.selectedDrawingId&&!e.some(e=>e.id===t.selectedDrawingId)&&(t.selectedDrawingId=null),t.drawingVersion++}function p(e){t.selectedDrawingId=e}return{state:t,computed:{axisHostWidth:n,totalWidth:r},actions:{bumpDataVersion:i,bumpDrawingVersion:a,setDataLength:o,setViewportDpr:s,setViewWidth:c,setZoomState:l,setPaneRatios:u,setDrawings:d,setSelectedDrawingId:p}}}var Ws=[5,10,20,30,60];function Gs(e,t,n){let r=Array(e.length);if(e.length<t)return r;let i=0,a=[];for(let n=0;n<t;n++){let t=e[n];if(!t)return r;let o=t.close;a.push(o),i+=o}for(let o=t-1;o<e.length;o++){let s=e[o];if(!s)continue;if(o>=t){let e=a.shift();e!==void 0&&(i-=e);let t=s.close;a.push(t),i+=t}let c=i/t,l=0;for(let e=0;e<t;e++){let t=a[e];t!==void 0&&(l+=(t-c)**2)}let u=Math.sqrt(l/t);r[o]={upper:c+n*u,middle:c,lower:c-n*u}}return r}function Ks(e,t,n){let r=Array(e.length);if(e.length===0)return r;let i=2/(t+1),a=2/(n+1),o=e[0].close,s=o,c=o;r[0]={fast:s,slow:c};for(let t=1;t<e.length;t++){let n=e[t].close;s=n*i+s*(1-i),c=n*a+c*(1-a),r[t]={fast:s,slow:c}}return r}function qs(e,t,n){let r=Array(e.length);if(e.length<t)return r;let i=0;for(let n=0;n<t;n++){let t=e[n];if(!t)return r;i+=t.close}let a=i/t,o=n/100;r[t-1]={upper:a*(1+o),middle:a,lower:a*(1-o)};for(let a=t;a<e.length;a++){let o=e[a-t],s=e[a];if(!o||!s)continue;i=i-o.close+s.close;let c=i/t,l=n/100;r[a]={upper:c*(1+l),middle:c,lower:c*(1-l)}}return r}function Js(e,t){let n=Array(e.length);if(e.length<t)return n;let r=0;for(let i=0;i<t;i++){let t=e[i];if(!t)return n;r+=t.close}n[t-1]=r/t;for(let i=t;i<e.length;i++){let a=e[i-t],o=e[i];!a||!o||(r=r-a.close+o.close,n[i]=r/t)}return n}function Ys(e,t){let n=Array(e.length);if(e.length<t+1)return n;let r=[];for(let t=1;t<e.length;t++)r.push(e[t].close-e[t-1].close);let i=0,a=0;for(let e=0;e<t;e++){let t=r[e];t!==void 0&&(t>0?i+=t:a+=Math.abs(t))}let o=i/t,s=a/t;s===0?n[t]=100:n[t]=100-100/(1+o/s);for(let e=t;e<r.length;e++){let i=r[e];if(i!==void 0)if(i>0?(o=(o*(t-1)+i)/t,s=s*(t-1)/t):(o=o*(t-1)/t,s=(s*(t-1)+Math.abs(i))/t),s===0)n[e+1]=100;else{let t=o/s;n[e+1]=100-100/(1+t)}}return n}function Xs(e,t){let n=Array(e.length);if(e.length<t)return n;let r=[];for(let t of e)r.push((t.high+t.low+t.close)/3);let i=0;for(let e=0;e<t;e++)i+=r[e];for(let a=t-1;a<e.length;a++){a>=t&&(i=i-r[a-t]+r[a]);let e=i/t,o=0;for(let n=0;n<t;n++)o+=Math.abs(r[a-n]-e);o/=t,o===0?n[a]=0:n[a]=(r[a]-e)/(.015*o)}return n}function Zs(e,t,n){let r=Array(e.length);if(e.length<t)return r;let i=Array(e.length);for(let n=t-1;n<e.length;n++){let r=-1/0,a=1/0;for(let i=0;i<t;i++){let t=e[n-i];t&&(r=Math.max(r,t.high),a=Math.min(a,t.low))}let o=e[n].close;r===a?i[n]=50:i[n]=(o-a)/(r-a)*100}for(let a=t-1+n-1;a<e.length;a++){let e=i[a];if(e===void 0)continue;let t=0,o=0;for(let e=0;e<n;e++){let n=i[a-e];n!==void 0&&(t+=n,o++)}o===n&&(r[a]={k:e,d:t/n})}return r}function Qs(e,t){let n=Array(e.length);if(e.length<t+1)return n;for(let r=t;r<e.length;r++){let i=e[r]?.close,a=e[r-t]?.close;i!==void 0&&a!==void 0&&(n[r]=i-a)}return n}function $s(e,t){let n=Array(e.length);if(e.length<t)return n;for(let r=t-1;r<e.length;r++){let i=-1/0,a=1/0;for(let n=0;n<t;n++){let t=e[r-n];t&&(i=Math.max(i,t.high),a=Math.min(a,t.low))}let o=e[r].close;i===a?n[r]=-50:n[r]=(i-o)/(i-a)*-100}return n}function ec(e,t){let n=Array(e.length);if(e.length<t+1)return n;for(let r=t;r<e.length;r++){let i=e[r]?.close,a=e[r-t]?.close;i!==void 0&&a!==void 0&&a!==0&&(n[r]=(i-a)/a*100)}return n}function tc(e,t){let n=Array(e.length),r=0,i=0;for(let a=0;a<e.length;a++){let o=e[a];if(o!==void 0){if(r+=o,i++,i>t){let n=e[a-t];n!==void 0&&(r-=n,i--)}i===t&&(n[a]=r/t)}}return n}function nc(e,t,n,r,i,a){let o=Array(e.length),s=ec(e,t),c=ec(e,n),l=ec(e,r),u=ec(e,i),d=tc(s,10),f=tc(c,10),p=tc(l,10),m=tc(u,15),h=Array(e.length);for(let t=0;t<e.length;t++){let e=d[t],n=f[t],r=p[t],i=m[t];e!==void 0&&n!==void 0&&r!==void 0&&i!==void 0&&(h[t]=e*1+n*2+r*3+i*4)}let g=tc(h,a);for(let t=0;t<e.length;t++){let e=h[t],n=g[t];e!==void 0&&n!==void 0&&(o[t]={kst:e,signal:n})}return o}function rc(e,t){let n=Array(e.length);if(e.length<t)return n;for(let r=t-1;r<e.length;r++){let i=-1/0,a=1/0;for(let n=0;n<t;n++){let t=e[r-n];t&&(i=Math.max(i,t.high),a=Math.min(a,t.low))}let o=e[r].close;i===a?n[r]=50:n[r]=(o-a)/(i-a)*100}return n}function ic(e,t){let n=Array(e.length),r=2/(t+1);if(e.length===0)return n;n[0]=e[0].close;for(let t=1;t<e.length;t++){let i=e[t];i&&(n[t]=i.close*r+n[t-1]*(1-r))}return n}function ac(e,t){let n=Array(e.length),r=2/(t+1),i=e.findIndex(e=>e!==void 0);if(i===-1)return n;n[i]=e[i];for(let t=i+1;t<e.length;t++){let i=e[t],a=n[t-1];i===void 0||a===void 0||(n[t]=i*r+a*(1-r))}return n}function oc(e,t,n,r){let i=Array(e.length);if(e.length<n)return i;let a=ic(e,t),o=ic(e,n),s=Array(e.length);for(let t=0;t<e.length;t++){let e=a[t],n=o[t];e!==void 0&&n!==void 0&&(s[t]=e-n)}let c=ac(s,r);for(let t=0;t<e.length;t++){let e=s[t],n=c[t];e!==void 0&&n!==void 0&&(i[t]={dif:e,dea:n,macd:(e-n)*2})}return i}var sc=class{currentData=[];dataVersion=0;config=this.getDefaultConfig();configVersion=0;cachedSeries={};cachedBollSeries=[];cachedExpmaSeries=[];cachedEneSeries=[];cachedRsiSeries={};cachedCciSeries=[];cachedStochSeries=[];cachedMomSeries=[];cachedWmsrSeries=[];cachedKstSeries=[];cachedFastkSeries=[];cachedMacdSeries=[];dirtyData=!0;dirtyMAConfig=!0;dirtyBollConfig=!0;dirtyExpmaConfig=!0;dirtyEneConfig=!0;dirtyRsiConfig=!0;dirtyCciConfig=!0;dirtyStochConfig=!0;dirtyMomConfig=!0;dirtyWmsrConfig=!0;dirtyKstConfig=!0;dirtyFastkConfig=!0;dirtyMacdConfig=!0;getDefaultConfig(){return{ma:{ma5:!0,ma10:!0,ma20:!0,ma30:!0,ma60:!0},boll:{period:20,multiplier:2,showUpper:!0,showMiddle:!0,showLower:!0,showBand:!0},expma:{fastPeriod:12,slowPeriod:50},ene:{period:10,deviation:11},rsi:{period1:6,period2:12,period3:24,showRSI1:!0,showRSI2:!0,showRSI3:!0},cci:{period:14,showCCI:!0},stoch:{n:9,m:3,showK:!0,showD:!0},mom:{period:10,showMOM:!0},wmsr:{period:14,showWMSR:!0},kst:{roc1:10,roc2:15,roc3:20,roc4:30,signalPeriod:9,showKST:!0,showSignal:!0},fastk:{period:9,showFASTK:!0},macd:{fastPeriod:12,slowPeriod:26,signalPeriod:9,showDIF:!0,showDEA:!0,showBAR:!0},rsiPaneId:`sub_RSI`,cciPaneId:`sub_CCI`,stochPaneId:`sub_STOCH`,momPaneId:`sub_MOM`,wmsrPaneId:`sub_WMSR`,kstPaneId:`sub_KST`,fastkPaneId:`sub_FASTK`,macdPaneId:`sub_MACD`}}setData(e,t){this.dataVersion===t&&!this.dirtyData||(this.currentData=e,this.dataVersion=t,this.dirtyData=!0)}shallowEqual(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0}setConfig(e,t){e.ma!==void 0&&!this.shallowEqual(e.ma,this.config.ma)&&(this.config.ma={...this.config.ma,...e.ma},this.dirtyMAConfig=!0),e.boll!==void 0&&!this.shallowEqual(e.boll,this.config.boll)&&(this.config.boll={...this.config.boll,...e.boll},this.dirtyBollConfig=!0),e.expma!==void 0&&!this.shallowEqual(e.expma,this.config.expma)&&(this.config.expma={...this.config.expma,...e.expma},this.dirtyExpmaConfig=!0),e.ene!==void 0&&!this.shallowEqual(e.ene,this.config.ene)&&(this.config.ene={...this.config.ene,...e.ene},this.dirtyEneConfig=!0),e.rsi!==void 0&&!this.shallowEqual(e.rsi,this.config.rsi)&&(this.config.rsi={...this.config.rsi,...e.rsi},this.dirtyRsiConfig=!0),e.cci!==void 0&&!this.shallowEqual(e.cci,this.config.cci)&&(this.config.cci={...this.config.cci,...e.cci},this.dirtyCciConfig=!0),e.stoch!==void 0&&!this.shallowEqual(e.stoch,this.config.stoch)&&(this.config.stoch={...this.config.stoch,...e.stoch},this.dirtyStochConfig=!0),e.mom!==void 0&&!this.shallowEqual(e.mom,this.config.mom)&&(this.config.mom={...this.config.mom,...e.mom},this.dirtyMomConfig=!0),e.wmsr!==void 0&&!this.shallowEqual(e.wmsr,this.config.wmsr)&&(this.config.wmsr={...this.config.wmsr,...e.wmsr},this.dirtyWmsrConfig=!0),e.kst!==void 0&&!this.shallowEqual(e.kst,this.config.kst)&&(this.config.kst={...this.config.kst,...e.kst},this.dirtyKstConfig=!0),e.fastk!==void 0&&!this.shallowEqual(e.fastk,this.config.fastk)&&(this.config.fastk={...this.config.fastk,...e.fastk},this.dirtyFastkConfig=!0),e.macd!==void 0&&!this.shallowEqual(e.macd,this.config.macd)&&(this.config.macd={...this.config.macd,...e.macd},this.dirtyMacdConfig=!0),e.rsiPaneId!==void 0&&(this.config.rsiPaneId=e.rsiPaneId),e.cciPaneId!==void 0&&(this.config.cciPaneId=e.cciPaneId),e.stochPaneId!==void 0&&(this.config.stochPaneId=e.stochPaneId),e.momPaneId!==void 0&&(this.config.momPaneId=e.momPaneId),e.wmsrPaneId!==void 0&&(this.config.wmsrPaneId=e.wmsrPaneId),e.kstPaneId!==void 0&&(this.config.kstPaneId=e.kstPaneId),e.fastkPaneId!==void 0&&(this.config.fastkPaneId=e.fastkPaneId),e.macdPaneId!==void 0&&(this.config.macdPaneId=e.macdPaneId),this.configVersion=t}forceDirty(){this.dirtyData=!0,this.dirtyMAConfig=!0,this.dirtyBollConfig=!0,this.dirtyExpmaConfig=!0,this.dirtyEneConfig=!0,this.dirtyRsiConfig=!0,this.dirtyCciConfig=!0,this.dirtyStochConfig=!0,this.dirtyMomConfig=!0,this.dirtyWmsrConfig=!0,this.dirtyKstConfig=!0,this.dirtyFastkConfig=!0,this.dirtyMacdConfig=!0}getDataVersion(){return this.dataVersion}getConfigVersion(){return this.configVersion}computeSeries(){let e=this.currentData,t=[];if(this.dirtyData||this.dirtyMAConfig){this.cachedSeries={};for(let t of Ws){let n=`ma${t}`;this.config.ma[n]&&(this.cachedSeries[t]=Js(e,t))}t.push(`ma`)}if((this.dirtyData||this.dirtyBollConfig)&&(this.cachedBollSeries=Gs(e,this.config.boll.period,this.config.boll.multiplier),t.push(`boll`)),(this.dirtyData||this.dirtyExpmaConfig)&&(this.cachedExpmaSeries=Ks(e,this.config.expma.fastPeriod,this.config.expma.slowPeriod),t.push(`expma`)),(this.dirtyData||this.dirtyEneConfig)&&(this.cachedEneSeries=qs(e,this.config.ene.period,this.config.ene.deviation),t.push(`ene`)),this.dirtyData||this.dirtyRsiConfig){this.cachedRsiSeries={};let n=[this.config.rsi.period1,this.config.rsi.period2,this.config.rsi.period3],r=[this.config.rsi.showRSI1,this.config.rsi.showRSI2,this.config.rsi.showRSI3];for(let t=0;t<n.length;t++)r[t]&&(this.cachedRsiSeries[n[t]]=Ys(e,n[t]));t.push(`rsi`)}return(this.dirtyData||this.dirtyCciConfig)&&(this.config.cci.showCCI?this.cachedCciSeries=Xs(e,this.config.cci.period):this.cachedCciSeries=[],t.push(`cci`)),(this.dirtyData||this.dirtyStochConfig)&&(this.config.stoch.showK||this.config.stoch.showD?this.cachedStochSeries=Zs(e,this.config.stoch.n,this.config.stoch.m):this.cachedStochSeries=[],t.push(`stoch`)),(this.dirtyData||this.dirtyMomConfig)&&(this.config.mom.showMOM?this.cachedMomSeries=Qs(e,this.config.mom.period):this.cachedMomSeries=[],t.push(`mom`)),(this.dirtyData||this.dirtyWmsrConfig)&&(this.config.wmsr.showWMSR?this.cachedWmsrSeries=$s(e,this.config.wmsr.period):this.cachedWmsrSeries=[],t.push(`wmsr`)),(this.dirtyData||this.dirtyKstConfig)&&(this.config.kst.showKST||this.config.kst.showSignal?this.cachedKstSeries=nc(e,this.config.kst.roc1,this.config.kst.roc2,this.config.kst.roc3,this.config.kst.roc4,this.config.kst.signalPeriod):this.cachedKstSeries=[],t.push(`kst`)),(this.dirtyData||this.dirtyFastkConfig)&&(this.config.fastk.showFASTK?this.cachedFastkSeries=rc(e,this.config.fastk.period):this.cachedFastkSeries=[],t.push(`fastk`)),(this.dirtyData||this.dirtyMacdConfig)&&(this.config.macd.showDIF||this.config.macd.showDEA||this.config.macd.showBAR?this.cachedMacdSeries=oc(e,this.config.macd.fastPeriod,this.config.macd.slowPeriod,this.config.macd.signalPeriod):this.cachedMacdSeries=[],t.push(`macd`)),this.dirtyData=!1,this.dirtyMAConfig=!1,this.dirtyBollConfig=!1,this.dirtyExpmaConfig=!1,this.dirtyEneConfig=!1,this.dirtyRsiConfig=!1,this.dirtyCciConfig=!1,this.dirtyStochConfig=!1,this.dirtyMomConfig=!1,this.dirtyWmsrConfig=!1,this.dirtyKstConfig=!1,this.dirtyFastkConfig=!1,this.dirtyMacdConfig=!1,{ma:{series:this.cachedSeries,enabledPeriods:Object.keys(this.cachedSeries).map(Number)},boll:{series:this.cachedBollSeries,params:{...this.config.boll}},expma:{series:this.cachedExpmaSeries,params:{...this.config.expma}},ene:{series:this.cachedEneSeries,params:{...this.config.ene}},rsi:{series:this.cachedRsiSeries,enabledPeriods:Object.keys(this.cachedRsiSeries).map(Number),params:{...this.config.rsi}},cci:{series:this.cachedCciSeries,params:{...this.config.cci}},stoch:{series:this.cachedStochSeries,params:{...this.config.stoch}},mom:{series:this.cachedMomSeries,params:{...this.config.mom}},wmsr:{series:this.cachedWmsrSeries,params:{...this.config.wmsr}},kst:{series:this.cachedKstSeries,params:{...this.config.kst}},fastk:{series:this.cachedFastkSeries,params:{...this.config.fastk}},macd:{series:this.cachedMacdSeries,params:{...this.config.macd}},_changed:t}}getCachedSeries(){return{_changed:[],ma:{series:this.cachedSeries,enabledPeriods:Object.keys(this.cachedSeries).map(Number)},boll:{series:this.cachedBollSeries,params:{...this.config.boll}},expma:{series:this.cachedExpmaSeries,params:{...this.config.expma}},ene:{series:this.cachedEneSeries,params:{...this.config.ene}},rsi:{series:this.cachedRsiSeries,enabledPeriods:Object.keys(this.cachedRsiSeries).map(Number),params:{...this.config.rsi}},cci:{series:this.cachedCciSeries,params:{...this.config.cci}},stoch:{series:this.cachedStochSeries,params:{...this.config.stoch}},mom:{series:this.cachedMomSeries,params:{...this.config.mom}},wmsr:{series:this.cachedWmsrSeries,params:{...this.config.wmsr}},kst:{series:this.cachedKstSeries,params:{...this.config.kst}},fastk:{series:this.cachedFastkSeries,params:{...this.config.fastk}},macd:{series:this.cachedMacdSeries,params:{...this.config.macd}}}}};function cc(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.type==`string`?[`ready`,`seriesResult`,`error`].includes(t.type):!1}function lc(e,t,n){let r=uc(e.ma.series,t),i=dc(e.boll.series,t),a=fc(e.expma.series,t),o=pc(e.ene.series,t),s=mc(e.rsi.series,t),c=hc(e.cci.series,t),l=gc(e.stoch.series,t),u=_c(e.mom.series,t),d=vc(e.wmsr.series,t),f=yc(e.kst.series,t),p=bc(e.fastk.series,t),m=xc(e.macd.series,t),h=t.end-1,g=h>=0&&h<e.macd.series.length?e.macd.series[h]:null,_=Math.max(Math.abs(m.max),Math.abs(m.min))*.1,v=Number.isFinite(m.min)?m.min-_:m.min,y=Number.isFinite(m.max)?m.max+_:m.max,b=Math.min(c.min,-150),x=Math.max(c.max,150),S=Math.max(Math.abs(u.max),Math.abs(u.min))*.1,C=u.min-S,w=u.max+S,T=(f.max-f.min)*.1,E=f.min-T,D=f.max+T;return{ma:{timestamp:n,series:e.ma.series,enabledPeriods:e.ma.enabledPeriods,visibleMin:r.min,visibleMax:r.max},boll:{timestamp:n,series:e.boll.series,params:e.boll.params,visibleMin:i.min,visibleMax:i.max},expma:{timestamp:n,series:e.expma.series,params:e.expma.params,visibleMin:a.min,visibleMax:a.max},ene:{timestamp:n,series:e.ene.series,params:e.ene.params,visibleMin:o.min,visibleMax:o.max},rsi:{timestamp:n,series:e.rsi.series,enabledPeriods:e.rsi.enabledPeriods,params:e.rsi.params,valueMin:0,valueMax:100,visibleMin:s.min,visibleMax:s.max},cci:{timestamp:n,series:e.cci.series,params:e.cci.params,valueMin:b,valueMax:x,visibleMin:c.min,visibleMax:c.max},stoch:{timestamp:n,series:e.stoch.series,params:e.stoch.params,valueMin:0,valueMax:100,visibleMin:l.min,visibleMax:l.max},mom:{timestamp:n,series:e.mom.series,params:e.mom.params,valueMin:C,valueMax:w,visibleMin:u.min,visibleMax:u.max},wmsr:{timestamp:n,series:e.wmsr.series,params:e.wmsr.params,valueMin:-100,valueMax:0,visibleMin:d.min,visibleMax:d.max},kst:{timestamp:n,series:e.kst.series,params:e.kst.params,valueMin:E,valueMax:D,visibleMin:f.min,visibleMax:f.max},fastk:{timestamp:n,series:e.fastk.series,params:e.fastk.params,valueMin:0,valueMax:100,visibleMin:p.min,visibleMax:p.max},macd:{timestamp:n,series:e.macd.series,params:e.macd.params,valueMin:v,valueMax:y,visibleMin:m.min,visibleMax:m.max,latestValues:g?{dif:g.dif,dea:g.dea,macd:g.macd}:void 0}}}function uc(e,t){let n=1/0,r=-1/0;for(let i of Object.values(e))for(let e=t.start;e<t.end&&e<i.length;e++){let t=i[e];t!==void 0&&(n=Math.min(n,t),r=Math.max(r,t))}return{min:n,max:r}}function dc(e,t){let n=1/0,r=-1/0;for(let i=t.start;i<t.end&&i<e.length;i++){let t=e[i];t&&(n=Math.min(n,t.upper,t.middle,t.lower),r=Math.max(r,t.upper,t.middle,t.lower))}return{min:n,max:r}}function fc(e,t){let n=1/0,r=-1/0;for(let i=t.start;i<t.end&&i<e.length;i++){let t=e[i];t&&(n=Math.min(n,t.fast,t.slow),r=Math.max(r,t.fast,t.slow))}return{min:n,max:r}}function pc(e,t){let n=1/0,r=-1/0;for(let i=t.start;i<t.end&&i<e.length;i++){let t=e[i];t&&(n=Math.min(n,t.upper,t.middle,t.lower),r=Math.max(r,t.upper,t.middle,t.lower))}return{min:n,max:r}}function mc(e,t){let n=1/0,r=-1/0;for(let i of Object.values(e))for(let e=t.start;e<t.end&&e<i.length;e++){let t=i[e];t!==void 0&&(n=Math.min(n,t),r=Math.max(r,t))}return{min:n,max:r}}function hc(e,t){let n=1/0,r=-1/0;for(let i=t.start;i<t.end&&i<e.length;i++){let t=e[i];t!==void 0&&(n=Math.min(n,t),r=Math.max(r,t))}return{min:n,max:r}}function gc(e,t){let n=1/0,r=-1/0;for(let i=t.start;i<t.end&&i<e.length;i++){let t=e[i];t&&(n=Math.min(n,t.k,t.d),r=Math.max(r,t.k,t.d))}return{min:n,max:r}}function _c(e,t){let n=1/0,r=-1/0;for(let i=t.start;i<t.end&&i<e.length;i++){let t=e[i];t!==void 0&&(n=Math.min(n,t),r=Math.max(r,t))}return{min:n,max:r}}function vc(e,t){let n=1/0,r=-1/0;for(let i=t.start;i<t.end&&i<e.length;i++){let t=e[i];t!==void 0&&(n=Math.min(n,t),r=Math.max(r,t))}return{min:n,max:r}}function yc(e,t){let n=1/0,r=-1/0;for(let i=t.start;i<t.end&&i<e.length;i++){let t=e[i];t&&(n=Math.min(n,t.kst,t.signal),r=Math.max(r,t.kst,t.signal))}return{min:n,max:r}}function bc(e,t){let n=1/0,r=-1/0;for(let i=t.start;i<t.end&&i<e.length;i++){let t=e[i];t!==void 0&&(n=Math.min(n,t),r=Math.max(r,t))}return{min:n,max:r}}function xc(e,t){let n=1/0,r=-1/0;for(let i=t.start;i<t.end&&i<e.length;i++){let t=e[i];t&&(n=Math.min(n,t.dif,t.dea,t.macd),r=Math.max(r,t.dif,t.dea,t.macd))}return{min:n,max:r}}function Sc(e,t,n){let r=1/0,i=-1/0,{start:a,end:o}=t;if(n.has(`ma`)&&Object.keys(e.ma.series).length>0)for(let t of Object.values(e.ma.series))for(let e=a;e<o&&e<t.length;e++){let n=t[e];n!==void 0&&(r=Math.min(r,n),i=Math.max(i,n))}if(n.has(`boll`)&&e.boll.series.length>0)for(let t=a;t<o&&t<e.boll.series.length;t++){let n=e.boll.series[t];n&&(r=Math.min(r,n.upper,n.middle,n.lower),i=Math.max(i,n.upper,n.middle,n.lower))}if(n.has(`expma`)&&e.expma.series.length>0)for(let t=a;t<o&&t<e.expma.series.length;t++){let n=e.expma.series[t];n&&(r=Math.min(r,n.fast,n.slow),i=Math.max(i,n.fast,n.slow))}if(n.has(`ene`)&&e.ene.series.length>0)for(let t=a;t<o&&t<e.ene.series.length;t++){let n=e.ene.series[t];n&&(r=Math.min(r,n.upper,n.middle,n.lower),i=Math.max(i,n.upper,n.middle,n.lower))}return!Number.isFinite(r)||!Number.isFinite(i)?null:{min:r,max:i}}var Q=(e,t)=>`indicator:${e}:${t}`,Cc=Q(`ma`,`main`),wc=Q(`boll`,`main`),Tc=Q(`expma`,`main`),Ec=Q(`ene`,`main`),Dc=e=>Q(`rsi`,e),Oc=e=>Q(`cci`,e),kc=e=>Q(`stoch`,e),Ac=e=>Q(`mom`,e),jc=e=>Q(`wmsr`,e),Mc=e=>Q(`kst`,e),Nc=e=>Q(`fastk`,e),Pc=`indicator:macd`;function Fc(e){return`${Pc}:${e}`}var Ic=class{pluginHost=null;visibleRange={start:0,end:0};activeMainIndicators=new Set;dataVersion=0;configVersion=0;requestId=0;lastAppliedRequestId=0;currentData=[];configSnapshot=this.getDefaultConfig();worker=null;workerReady=!1;useWorker=!1;pendingRequest=null;inlineRuntime=null;latestResult=null;invalidateCallback=null;constructor(){this.initBackend()}setPluginHost(e){this.pluginHost=e}setInvalidateCallback(e){this.invalidateCallback=e}destroy(){this.terminateWorker(),this.inlineRuntime=null,this.latestResult=null,this.invalidateCallback=null}getDefaultConfig(){return{ma:{ma5:!0,ma10:!0,ma20:!0,ma30:!0,ma60:!0},boll:{period:20,multiplier:2,showUpper:!0,showMiddle:!0,showLower:!0,showBand:!0},expma:{fastPeriod:12,slowPeriod:50},ene:{period:10,deviation:11},rsi:{period1:6,period2:12,period3:24,showRSI1:!0,showRSI2:!0,showRSI3:!0},cci:{period:14,showCCI:!0},stoch:{n:9,m:3,showK:!0,showD:!0},mom:{period:10,showMOM:!0},wmsr:{period:14,showWMSR:!0},kst:{roc1:10,roc2:15,roc3:20,roc4:30,signalPeriod:9,showKST:!0,showSignal:!0},fastk:{period:9,showFASTK:!0},macd:{fastPeriod:12,slowPeriod:26,signalPeriod:9,showDIF:!0,showDEA:!0,showBAR:!0},rsiPaneId:`sub_RSI`,cciPaneId:`sub_CCI`,stochPaneId:`sub_STOCH`,momPaneId:`sub_MOM`,wmsrPaneId:`sub_WMSR`,kstPaneId:`sub_KST`,fastkPaneId:`sub_FASTK`,macdPaneId:`sub_MACD`}}initBackend(){this.tryInitWorker()||this.initInlineRuntime()}tryInitWorker(){if(console.log(`[IndicatorScheduler] tryInitWorker: Worker available?`,typeof Worker<`u`),typeof Worker>`u`)return!1;try{let e=new URL(`data:video/mp2t;base64,LyoqCiAqIEluZGljYXRvciBXb3JrZXIg5YWl5Y+jCiAqIOi/kOihjOWcqOeLrOeri+e6v+eoi++8jOi0n+i0o+aMh+agh+iuoeeulwogKi8KCmltcG9ydCB0eXBlIHsKICAgIEluZGljYXRvcldvcmtlclJlcXVlc3QsCiAgICBJbmRpY2F0b3JXb3JrZXJSZXNwb25zZSwKfSBmcm9tICcuL3dvcmtlclByb3RvY29sJwppbXBvcnQgeyBQUk9UT0NPTF9WRVJTSU9OIH0gZnJvbSAnLi93b3JrZXJQcm90b2NvbCcKaW1wb3J0IHsgSW5kaWNhdG9yUnVudGltZSB9IGZyb20gJy4vaW5kaWNhdG9yUnVudGltZScKCi8vIFdvcmtlciDlhajlsYDkvZznlKjln58KY29uc3QgY3R4ID0gc2VsZiBhcyB1bmtub3duIGFzIFdvcmtlcgoKLy8g6L+Q6KGM5pe25a6e5L6LCmxldCBydW50aW1lOiBJbmRpY2F0b3JSdW50aW1lIHwgbnVsbCA9IG51bGwKCi8qKgogKiDlj5HpgIHlk43lupTliLDkuLvnur/nqIsKICovCmZ1bmN0aW9uIHBvc3RSZXNwb25zZShyZXNwb25zZTogSW5kaWNhdG9yV29ya2VyUmVzcG9uc2UpOiB2b2lkIHsKICAgIGN0eC5wb3N0TWVzc2FnZShyZXNwb25zZSkKfQoKLyoqCiAqIOWkhOeQhuWIneWni+WMlgogKi8KZnVuY3Rpb24gaGFuZGxlSW5pdCgpOiB2b2lkIHsKICAgIHJ1bnRpbWUgPSBuZXcgSW5kaWNhdG9yUnVudGltZSgpCiAgICBwb3N0UmVzcG9uc2UoewogICAgICAgIHR5cGU6ICdyZWFkeScsCiAgICAgICAgcHJvdG9jb2xWZXJzaW9uOiBQUk9UT0NPTF9WRVJTSU9OLAogICAgfSkKfQoKLyoqCiAqIOWkhOeQhuiuvue9ruaVsOaNrgogKi8KZnVuY3Rpb24gaGFuZGxlU2V0RGF0YShkYXRhOiB1bmtub3duW10sIHZlcnNpb246IG51bWJlcik6IHZvaWQgewogICAgaWYgKCFydW50aW1lKSB7CiAgICAgICAgcG9zdFJlc3BvbnNlKHsKICAgICAgICAgICAgdHlwZTogJ2Vycm9yJywKICAgICAgICAgICAgc3RhZ2U6ICdzZXREYXRhJywKICAgICAgICAgICAgbWVzc2FnZTogJ1J1bnRpbWUgbm90IGluaXRpYWxpemVkJywKICAgICAgICB9KQogICAgICAgIHJldHVybgogICAgfQogICAgcnVudGltZS5zZXREYXRhKGRhdGEgYXMgdW5rbm93bltdLCB2ZXJzaW9uKQp9CgovKioKICog5aSE55CG6K6+572u6YWN572uCiAqLwpmdW5jdGlvbiBoYW5kbGVTZXRDb25maWcoY29uZmlnOiB1bmtub3duLCB2ZXJzaW9uOiBudW1iZXIpOiB2b2lkIHsKICAgIGlmICghcnVudGltZSkgewogICAgICAgIHBvc3RSZXNwb25zZSh7CiAgICAgICAgICAgIHR5cGU6ICdlcnJvcicsCiAgICAgICAgICAgIHN0YWdlOiAnc2V0Q29uZmlnJywKICAgICAgICAgICAgbWVzc2FnZTogJ1J1bnRpbWUgbm90IGluaXRpYWxpemVkJywKICAgICAgICB9KQogICAgICAgIHJldHVybgogICAgfQogICAgcnVudGltZS5zZXRDb25maWcoY29uZmlnIGFzIHVua25vd24sIHZlcnNpb24pCn0KCi8qKgogKiDlpITnkIborqHnrpcgc2VyaWVzCiAqLwpmdW5jdGlvbiBoYW5kbGVDb21wdXRlU2VyaWVzKHJlcXVlc3RJZDogbnVtYmVyLCBkYXRhVmVyc2lvbjogbnVtYmVyLCBjb25maWdWZXJzaW9uOiBudW1iZXIpOiB2b2lkIHsKICAgIGlmICghcnVudGltZSkgewogICAgICAgIHBvc3RSZXNwb25zZSh7CiAgICAgICAgICAgIHR5cGU6ICdlcnJvcicsCiAgICAgICAgICAgIHJlcXVlc3RJZCwKICAgICAgICAgICAgc3RhZ2U6ICdjb21wdXRlU2VyaWVzJywKICAgICAgICAgICAgbWVzc2FnZTogJ1J1bnRpbWUgbm90IGluaXRpYWxpemVkJywKICAgICAgICB9KQogICAgICAgIHJldHVybgogICAgfQoKICAgIGNvbnN0IHN0YXJ0VGltZSA9IHBlcmZvcm1hbmNlLm5vdygpCgogICAgdHJ5IHsKICAgICAgICBjb25zb2xlLmxvZyhgW0luZGljYXRvcldvcmtlcl0gY29tcHV0ZVNlcmllcyBTVEFSVCByZXFJZD0ke3JlcXVlc3RJZH1gKQogICAgICAgIGNvbnN0IHJlc3VsdHMgPSBydW50aW1lLmNvbXB1dGVTZXJpZXMoKQogICAgICAgIGNvbnN0IGNvbXB1dGVNcyA9IHBlcmZvcm1hbmNlLm5vdygpIC0gc3RhcnRUaW1lCiAgICAgICAgY29uc29sZS5sb2coYFtJbmRpY2F0b3JXb3JrZXJdIGNvbXB1dGVTZXJpZXMgRE9ORSBpbiAke2NvbXB1dGVNcy50b0ZpeGVkKDEpfW1zLCBjaGFuZ2VkPVske3Jlc3VsdHMuX2NoYW5nZWQuam9pbignLCcpfV1gKQoKICAgICAgICBwb3N0UmVzcG9uc2UoewogICAgICAgICAgICB0eXBlOiAnc2VyaWVzUmVzdWx0JywKICAgICAgICAgICAgcmVxdWVzdElkLAogICAgICAgICAgICBkYXRhVmVyc2lvbiwKICAgICAgICAgICAgY29uZmlnVmVyc2lvbiwKICAgICAgICAgICAgcmVzdWx0cywKICAgICAgICAgICAgbWV0cmljczogewogICAgICAgICAgICAgICAgY29tcHV0ZU1zLAogICAgICAgICAgICAgICAgZGF0YUxlbmd0aDogMCwgLy8g55Sx6LCD55So5pa55aGr5YWFCiAgICAgICAgICAgIH0sCiAgICAgICAgfSkKICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgIGNvbnN0IG1lc3NhZ2UgPSBlcnIgaW5zdGFuY2VvZiBFcnJvciA/IGVyci5tZXNzYWdlIDogU3RyaW5nKGVycikKICAgICAgICBwb3N0UmVzcG9uc2UoewogICAgICAgICAgICB0eXBlOiAnZXJyb3InLAogICAgICAgICAgICByZXF1ZXN0SWQsCiAgICAgICAgICAgIHN0YWdlOiAnY29tcHV0ZVNlcmllcycsCiAgICAgICAgICAgIG1lc3NhZ2UsCiAgICAgICAgfSkKICAgIH0KfQoKLyoqCiAqIOWkhOeQhumUgOavgQogKi8KZnVuY3Rpb24gaGFuZGxlRGlzcG9zZSgpOiB2b2lkIHsKICAgIHJ1bnRpbWUgPSBudWxsCiAgICAvLyBXb3JrZXIg5Lya6KKr5Li757q/56iLIHRlcm1pbmF0Ze+8jOi/memHjOWBmua4heeQhuWNs+WPrwp9CgovKioKICog5raI5oGv5aSE55CG5ZmoCiAqLwpjdHgub25tZXNzYWdlID0gKGV2ZW50OiBNZXNzYWdlRXZlbnQ8SW5kaWNhdG9yV29ya2VyUmVxdWVzdD4pID0+IHsKICAgIGNvbnN0IG1zZyA9IGV2ZW50LmRhdGEKCiAgICBpZiAoIW1zZyB8fCB0eXBlb2YgbXNnICE9PSAnb2JqZWN0JykgewogICAgICAgIHBvc3RSZXNwb25zZSh7CiAgICAgICAgICAgIHR5cGU6ICdlcnJvcicsCiAgICAgICAgICAgIHN0YWdlOiAnaW5pdCcsCiAgICAgICAgICAgIG1lc3NhZ2U6ICdJbnZhbGlkIG1lc3NhZ2UgZm9ybWF0JywKICAgICAgICB9KQogICAgICAgIHJldHVybgogICAgfQoKICAgIHN3aXRjaCAobXNnLnR5cGUpIHsKICAgICAgICBjYXNlICdpbml0JzoKICAgICAgICAgICAgaGFuZGxlSW5pdCgpCiAgICAgICAgICAgIGJyZWFrCgogICAgICAgIGNhc2UgJ3NldERhdGEnOgogICAgICAgICAgICBoYW5kbGVTZXREYXRhKG1zZy5kYXRhLCBtc2cuZGF0YVZlcnNpb24pCiAgICAgICAgICAgIGJyZWFrCgogICAgICAgIGNhc2UgJ3NldENvbmZpZyc6CiAgICAgICAgICAgIGhhbmRsZVNldENvbmZpZyhtc2cuY29uZmlncywgbXNnLmNvbmZpZ1ZlcnNpb24pCiAgICAgICAgICAgIGJyZWFrCgogICAgICAgIGNhc2UgJ2NvbXB1dGVTZXJpZXMnOgogICAgICAgICAgICBoYW5kbGVDb21wdXRlU2VyaWVzKG1zZy5yZXF1ZXN0SWQsIG1zZy5kYXRhVmVyc2lvbiwgbXNnLmNvbmZpZ1ZlcnNpb24pCiAgICAgICAgICAgIGJyZWFrCgogICAgICAgIGNhc2UgJ2Rpc3Bvc2UnOgogICAgICAgICAgICBoYW5kbGVEaXNwb3NlKCkKICAgICAgICAgICAgYnJlYWsKCiAgICAgICAgZGVmYXVsdDogewogICAgICAgICAgICBjb25zdCBfZXhoYXVzdGl2ZUNoZWNrOiBuZXZlciA9IG1zZwogICAgICAgICAgICBwb3N0UmVzcG9uc2UoewogICAgICAgICAgICAgICAgdHlwZTogJ2Vycm9yJywKICAgICAgICAgICAgICAgIHN0YWdlOiAnaW5pdCcsCiAgICAgICAgICAgICAgICBtZXNzYWdlOiBgVW5rbm93biBtZXNzYWdlIHR5cGU6ICR7KF9leGhhdXN0aXZlQ2hlY2sgYXMgdW5rbm93biBhcyB7IHR5cGU6IHN0cmluZyB9KS50eXBlfWAsCiAgICAgICAgICAgIH0pCiAgICAgICAgfQogICAgfQp9CgovLyDpgJrnn6XkuLvnur/nqIsgd29ya2VyIOW3suWKoOi9ve+8iOWPr+mAie+8jOS4u+imgeeUqOS6juiwg+ivle+8iQovLyBjb25zb2xlLmxvZygnW0luZGljYXRvcldvcmtlcl0gTG9hZGVkJykK`,``+{}.url);return console.log(`[IndicatorScheduler] Creating worker from:`,e.href),this.worker=new Worker(e,{type:`module`}),console.log(`[IndicatorScheduler] Worker created, waiting for ready...`),this.worker.onmessage=e=>this.handleWorkerMessage(e.data),this.worker.onerror=e=>{console.error(`[IndicatorScheduler] Worker error:`,e),this.fallbackToInline()},this.worker.postMessage({type:`init`,protocolVersion:1}),!0}catch(e){return console.warn(`[IndicatorScheduler] Failed to init worker:`,e),!1}}initInlineRuntime(){console.log(`[IndicatorScheduler] Using INLINE runtime (fallback)`),this.inlineRuntime=new sc,this.useWorker=!1,this.workerReady=!0}fallbackToInline(){console.warn(`[IndicatorScheduler] Falling back to inline runtime`),this.terminateWorker(),this.initInlineRuntime(),this.pendingRequest&&this.computeWithInline()}terminateWorker(){this.worker&&=(this.worker.terminate(),null),this.workerReady=!1,this.useWorker=!1}handleWorkerMessage(e){if(!cc(e)){console.warn(`[IndicatorScheduler] Invalid worker response:`,e);return}switch(e.type){case`ready`:this.workerReady=!0,this.useWorker=!0,console.log(`[IndicatorScheduler] Worker READY - using Worker backend`),this.triggerRecompute();break;case`seriesResult`:this.handleSeriesResult(e);break;case`error`:console.error(`[IndicatorScheduler] Worker error:`,e.stage,e.message),this.pendingRequest&&e.requestId===this.pendingRequest.requestId&&this.fallbackToInline();break;default:console.warn(`[IndicatorScheduler] Unknown response type:`,e.type)}}handleSeriesResult(e){e.requestId<this.lastAppliedRequestId||e.dataVersion!==this.dataVersion||e.configVersion!==this.configVersion||(console.log(`[IndicatorScheduler] << Worker result: requestId=${e.requestId} metrics=`,e.metrics),this.lastAppliedRequestId=e.requestId,this.pendingRequest=null,this.latestResult=e.results,this.applyResults(e.results),this.invalidateCallback?.())}applyResults(e){if(!this.pluginHost)return;let t=new Set(e._changed),n=Date.now(),r=lc(e,this.visibleRange,n);if(t.has(`ma`)&&this.pluginHost.setSharedState(Cc,r.ma,`ma_scheduler`),t.has(`boll`)&&this.pluginHost.setSharedState(wc,r.boll,`indicator_scheduler`),t.has(`expma`)&&this.pluginHost.setSharedState(Tc,r.expma,`indicator_scheduler`),t.has(`ene`)&&this.pluginHost.setSharedState(Ec,r.ene,`indicator_scheduler`),t.has(`rsi`)){let e=Dc(this.configSnapshot.rsiPaneId);this.pluginHost.setSharedState(e,r.rsi,`indicator_scheduler`)}if(t.has(`cci`)){let e=Oc(this.configSnapshot.cciPaneId);this.pluginHost.setSharedState(e,r.cci,`indicator_scheduler`)}if(t.has(`stoch`)){let e=kc(this.configSnapshot.stochPaneId);this.pluginHost.setSharedState(e,r.stoch,`indicator_scheduler`)}if(t.has(`mom`)){let e=Ac(this.configSnapshot.momPaneId);this.pluginHost.setSharedState(e,r.mom,`indicator_scheduler`)}if(t.has(`wmsr`)){let e=jc(this.configSnapshot.wmsrPaneId);this.pluginHost.setSharedState(e,r.wmsr,`indicator_scheduler`)}if(t.has(`kst`)){let e=Mc(this.configSnapshot.kstPaneId);this.pluginHost.setSharedState(e,r.kst,`indicator_scheduler`)}if(t.has(`fastk`)){let e=Nc(this.configSnapshot.fastkPaneId);this.pluginHost.setSharedState(e,r.fastk,`indicator_scheduler`)}if(t.has(`macd`)){let e=Fc(this.configSnapshot.macdPaneId);this.pluginHost.setSharedState(e,r.macd,`indicator_scheduler`)}}updateVisibleStatesOnly(){if(!this.pluginHost||!this.latestResult)return;let e=Date.now(),t=lc(this.latestResult,this.visibleRange,e);t.ma.enabledPeriods.length>0&&this.pluginHost.setSharedState(Cc,t.ma,`ma_scheduler`),this.pluginHost.setSharedState(wc,t.boll,`indicator_scheduler`),this.pluginHost.setSharedState(Tc,t.expma,`indicator_scheduler`),this.pluginHost.setSharedState(Ec,t.ene,`indicator_scheduler`);let n=Dc(this.configSnapshot.rsiPaneId);this.pluginHost.setSharedState(n,t.rsi,`indicator_scheduler`);let r=Oc(this.configSnapshot.cciPaneId);this.pluginHost.setSharedState(r,t.cci,`indicator_scheduler`);let i=kc(this.configSnapshot.stochPaneId);this.pluginHost.setSharedState(i,t.stoch,`indicator_scheduler`);let a=Ac(this.configSnapshot.momPaneId);this.pluginHost.setSharedState(a,t.mom,`indicator_scheduler`);let o=jc(this.configSnapshot.wmsrPaneId);this.pluginHost.setSharedState(o,t.wmsr,`indicator_scheduler`);let s=Mc(this.configSnapshot.kstPaneId);this.pluginHost.setSharedState(s,t.kst,`indicator_scheduler`);let c=Nc(this.configSnapshot.fastkPaneId);this.pluginHost.setSharedState(c,t.fastk,`indicator_scheduler`);let l=Fc(this.configSnapshot.macdPaneId);this.pluginHost.setSharedState(l,t.macd,`indicator_scheduler`)}update(e,t){this.currentData=e,this.visibleRange=t,this.dataVersion++,this.useWorker&&this.worker&&this.workerReady?this.computeWithWorker():this.computeWithInline()}updateVisibleRange(e){this.visibleRange=e,this.latestResult&&this.updateVisibleStatesOnly()}updateMAConfig(e){this.configSnapshot.ma={...e},this.configVersion++,this.triggerRecompute()}updateBOLLConfig(e){this.configSnapshot.boll={...this.configSnapshot.boll,...e},this.configVersion++,this.triggerRecompute()}updateEXPMAConfig(e){this.configSnapshot.expma={...this.configSnapshot.expma,...e},this.configVersion++,this.triggerRecompute()}updateENEConfig(e){this.configSnapshot.ene={...this.configSnapshot.ene,...e},this.configVersion++,this.triggerRecompute()}updateRSIConfig(e,t){t!==void 0&&(this.configSnapshot.rsiPaneId=t),this.configSnapshot.rsi={...this.configSnapshot.rsi,...e},this.configVersion++,this.triggerRecompute()}updateCCIConfig(e,t){t!==void 0&&(this.configSnapshot.cciPaneId=t),this.configSnapshot.cci={...this.configSnapshot.cci,...e},this.configVersion++,this.triggerRecompute()}updateSTOCHConfig(e,t){t!==void 0&&(this.configSnapshot.stochPaneId=t),this.configSnapshot.stoch={...this.configSnapshot.stoch,...e},this.configVersion++,this.triggerRecompute()}updateMOMConfig(e,t){t!==void 0&&(this.configSnapshot.momPaneId=t),this.configSnapshot.mom={...this.configSnapshot.mom,...e},this.configVersion++,this.triggerRecompute()}updateWMSRConfig(e,t){t!==void 0&&(this.configSnapshot.wmsrPaneId=t),this.configSnapshot.wmsr={...this.configSnapshot.wmsr,...e},this.configVersion++,this.triggerRecompute()}updateKSTConfig(e,t){t!==void 0&&(this.configSnapshot.kstPaneId=t),this.configSnapshot.kst={...this.configSnapshot.kst,...e},this.configVersion++,this.triggerRecompute()}updateFASTKConfig(e,t){t!==void 0&&(this.configSnapshot.fastkPaneId=t),this.configSnapshot.fastk={...this.configSnapshot.fastk,...e},this.configVersion++,this.triggerRecompute()}updateMACDConfig(e,t){t!==void 0&&(this.configSnapshot.macdPaneId=t),this.configSnapshot.macd={...this.configSnapshot.macd,...e},this.configVersion++,this.triggerRecompute()}setActiveMainIndicators(e){this.activeMainIndicators=new Set(e.map(e=>e.toLowerCase()))}getMainIndicatorPriceRange(){return this.latestResult?Sc(this.latestResult,this.visibleRange,this.activeMainIndicators):null}recompute(){this.inlineRuntime&&this.inlineRuntime.forceDirty(),this.dataVersion++,this.triggerRecompute()}triggerRecompute(){this.useWorker&&this.worker&&this.workerReady?this.computeWithWorker():this.computeWithInline()}computeWithWorker(){!this.worker||!this.workerReady||(console.log(`[IndicatorScheduler] >> Worker compute: requestId=${this.requestId+1} dataV=${this.dataVersion} configV=${this.configVersion}`),this.requestId++,this.pendingRequest={requestId:this.requestId,dataVersion:this.dataVersion,configVersion:this.configVersion},this.worker.postMessage({type:`setData`,dataVersion:this.dataVersion,format:`aos`,data:this.currentData}),this.worker.postMessage({type:`setConfig`,configVersion:this.configVersion,configs:this.configSnapshot}),this.worker.postMessage({type:`computeSeries`,requestId:this.requestId,dataVersion:this.dataVersion,configVersion:this.configVersion}))}computeWithInline(){this.inlineRuntime||=new sc,console.log(`[IndicatorScheduler] >> INLINE compute: dataV=${this.dataVersion} configV=${this.configVersion}`),this.inlineRuntime.setData(this.currentData,this.dataVersion),this.inlineRuntime.setConfig(this.configSnapshot,this.configVersion);let e=this.inlineRuntime.computeSeries();this.latestResult=e,this.applyResults(e),this.invalidateCallback?.()}};function Lc(e={}){let{paneId:t=`sub`}=e,n=Q(`volume`,t),r=null;return{name:`volume_${t}`,version:`1.0.0`,description:`成交量渲染器`,debugName:`成交量`,paneId:t,priority:G.MAIN,onInstall(e){r=e},getDeclaredNamespaces(){return[n]},draw(e){let{ctx:i,pane:a,data:o,range:s,dpr:c}=e,l=o;if(!l.length)return;let{start:u,end:d}=s,f=0,p=1/0;for(let e=u;e<d&&e<l.length;e++){let t=l[e];if(!t)continue;let n=t.volume;n!=null&&(f=Math.max(f,n),p=Math.min(p,n))}if(f===0||!Number.isFinite(p))return;let m=Math.max(.05,(f-p)*.1),h=Math.max(0,p-m),g=f+m,_=a.yAxis.getDisplayRange({minPrice:h,maxPrice:g}),v=_.minPrice,y=_.maxPrice-v||1,b=a.height-(0-v)/y*a.height,x=Math.round(b*c)/c;r?.setSharedState(n,{valueMin:h,valueMax:g,timestamp:Date.now()},`volume_${t}`);let S=[],C=[],w=[];for(let t=u;t<d;t++){let n=l[t];if(!n)continue;let r=n.volume;if(!r)continue;let i=e.kBarRects[t-u];if(!i)continue;let o=a.height-(r-v)/y*a.height,s=Math.round(o*c)/c,d=1/c,f=x-s,p=f<=0?d:Math.max(f,d),m=f<=0?x-d:x-p,h={x:i.x,y:m,width:i.width,height:p},g=Vc(n);g===xa.UP?S.push(h):g===xa.DOWN?C.push(h):w.push(h)}Rc(e,S,C,w)?Bc(i,e):zc(i,e.scrollLeft,S,C,w)}}}function Rc(e,t,n,r){if(e.settings?.enableWebGLRendering===!1)return!1;let i=e.candleWebGLSurface;if(!i||!i.isAvailable())return!1;i.clear();let a=t.length===0||i.drawRects(t,xa.UP,e.scrollLeft),o=n.length===0||i.drawRects(n,xa.DOWN,e.scrollLeft),s=r.length===0||i.drawRects(r,xa.NEUTRAL,e.scrollLeft);return a&&o&&s}function zc(e,t,n,r,i){e.save(),e.translate(-t,0),e.fillStyle=xa.UP;for(let t of n)e.fillRect(t.x,t.y,t.width,t.height);e.fillStyle=xa.DOWN;for(let t of r)e.fillRect(t.x,t.y,t.width,t.height);e.fillStyle=xa.NEUTRAL;for(let t of i)e.fillRect(t.x,t.y,t.width,t.height);e.restore()}function Bc(e,t){let n=t.candleWebGLSurface;if(!n)return;let r=n.getCanvas();r.width<=0||r.height<=0||e.drawImage(r,0,0,r.width,r.height,0,0,r.width/t.dpr,r.height/t.dpr)}function Vc(e){return e.close>e.open?xa.UP:e.close<e.open?xa.DOWN:xa.NEUTRAL}var Hc={5:ya.MA5,10:ya.MA10,20:ya.MA20,30:ya.MA30,60:ya.MA60};function Uc(e,t,n,r){let i=n.yAxis.getDisplayRange();return[e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,i.maxPrice.toFixed(6),i.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),r.join(`,`),n.height.toFixed(2)].join(`|`)}function Wc(){let e=null,t=``,n=new Map;function r(){t=``,n=new Map}return{name:`ma`,version:`2.0.0`,description:`MA均线渲染器(带绘制缓存)`,debugName:`MA均线`,paneId:`main`,priority:G.INDICATOR,onInstall(t){e=t},getDeclaredNamespaces(){return[Cc]},draw(i){let{ctx:a,pane:o,range:s,scrollLeft:c,dpr:l,kLineCenters:u,lineWebGLSurface:d}=i,f=e?.getSharedState(Cc);if(!f||f.visibleMin>f.visibleMax){r();return}if(f.enabledPeriods.length===0){r();return}let p=Uc(s,u,o,f.enabledPeriods);if(t!==p){t=p,n=new Map;for(let[e,t]of Object.entries(f.series)){let r=Number(e),i=[];for(let e=s.start;e<s.end&&e<t.length;e++){let n=t[e];if(n===void 0)continue;let r=u[e-s.start];r!==void 0&&i.push({x:r,y:o.yAxis.priceToY(n)})}i.length>=2&&n.set(r,i)}}let m=i.settings?.enableWebGLRendering!==!1,h=!1;if(m&&d?.isAvailable()){let e=!0;for(let t of f.enabledPeriods){let r=n.get(t);if(r&&!d.drawLineStrip({points:r,width:1},Hc[t]??ya.MA5,c)){e=!1;break}}if(e){h=!0;let e=d.getCanvas();if(e.width>0&&e.height>0){let t=a.imageSmoothingEnabled;a.imageSmoothingEnabled=!1,a.drawImage(e,0,0,e.width,e.height,0,0,e.width/l,e.height/l),a.imageSmoothingEnabled=t}}}if(!h){a.save(),a.translate(-c,0),a.lineWidth=1,a.lineJoin=`round`,a.lineCap=`round`;for(let e of f.enabledPeriods){let t=n.get(e);if(!(!t||t.length<2)){a.strokeStyle=Hc[e]??ya.MA5,a.beginPath(),a.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++){let n=t[e];a.lineTo(n.x,n.y)}a.stroke()}}a.restore()}},getConfig(){let t=e?.getSharedState(Cc),n={};return t?.enabledPeriods.forEach(e=>{n[`ma${e}`]=!0}),n},setConfig(e){}}}function Gc(e,t,n,r,i,a,o,s){let c=n.yAxis.getDisplayRange();return[e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,c.maxPrice.toFixed(6),c.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),Number(r),Number(i),Number(a),Number(o),s,n.height.toFixed(2)].join(`|`)}function Kc(){let e=null,t=``,n=null,r=null,i=null,a=null;function o(){t=``,n=null,r=null,i=null,a=null}return{name:`boll`,version:`2.0.0`,description:`布林带渲染器(带绘制缓存)`,debugName:`BOLL布林带`,paneId:`main`,priority:G.INDICATOR,onInstall(t){e=t},getDeclaredNamespaces(){return[wc]},draw(s){let{ctx:c,pane:l,data:u,range:d,scrollLeft:f,dpr:p,kLineCenters:m}=s,h=u,g=e?.getSharedState(wc);if(!g||g.visibleMin>g.visibleMax){o();return}if(g.series.length===0){o();return}let{period:_,showUpper:v,showMiddle:y,showLower:b,showBand:x}=g.params,S=g.series;if(h.length<_){o();return}let C=Math.max(d.start,_-1),w=Math.min(d.end,h.length),T=Gc(d,m,l,v,y,b,x,_);if(t!==T){t=T,n=x?new Path2D:null,r=v?new Path2D:null,i=y?new Path2D:null,a=b?new Path2D:null;let e=!1,o=!1,s=!1,c=!1;for(let t=C;t<w;t++){let u=S[t];if(!u)continue;let f=m[t-d.start];if(f===void 0)continue;let h=Z(l.yAxis.priceToY(u.upper),p),g=Z(l.yAxis.priceToY(u.middle),p),_=Z(l.yAxis.priceToY(u.lower),p);n&&(e?n.lineTo(f,h):(n.moveTo(f,h),e=!0)),r&&(o?r.lineTo(f,h):(r.moveTo(f,h),o=!0)),i&&(s?i.lineTo(f,g):(i.moveTo(f,g),s=!0)),a&&(c?a.lineTo(f,_):(a.moveTo(f,_),c=!0))}if(n&&e){for(let e=w-1;e>=C;e--){let t=S[e];if(!t)continue;let r=m[e-d.start];if(r===void 0)continue;let i=Z(l.yAxis.priceToY(t.lower),p);n.lineTo(r,i)}n.closePath()}}c.save(),c.translate(-f,0),c.lineWidth=1,c.lineJoin=`round`,c.lineCap=`round`,n&&(c.fillStyle=ba.BAND_FILL,c.fill(n)),r&&(c.strokeStyle=ba.UPPER,c.stroke(r)),i&&(c.strokeStyle=ba.MIDDLE,c.stroke(i)),a&&(c.strokeStyle=ba.LOWER,c.stroke(a)),c.restore()},getConfig(){let t=e?.getSharedState(wc);return t?{...t.params}:{}},setConfig(e){}}}function qc(e,t,n){let r=n.yAxis.getDisplayRange();return[e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,r.maxPrice.toFixed(6),r.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),n.height.toFixed(2)].join(`|`)}function Jc(){let e=null,t=``,n=[],r=[];function i(){t=``,n=[],r=[]}return{name:`expma`,version:`2.0.0`,description:`EXPMA 指数平滑移动平均线渲染器(带绘制缓存)`,debugName:`EXPMA`,paneId:`main`,priority:G.INDICATOR,onInstall(t){e=t},getDeclaredNamespaces(){return[Tc]},draw(a){let{ctx:o,pane:s,data:c,range:l,scrollLeft:u,dpr:d,kLineCenters:f,lineWebGLSurface:p}=a,m=c,h=e?.getSharedState(Tc);if(!h||h.visibleMin>h.visibleMax){i();return}if(h.series.length===0||m.length<2){i();return}let g=h.series,_=l.start,v=Math.min(l.end,m.length),y=qc(l,f,s);if(t!==y){t=y,n=[],r=[];for(let e=_;e<v;e++){let t=g[e];if(!t)continue;let i=f[e-l.start];i!==void 0&&(n.push({x:i,y:s.yAxis.priceToY(t.fast)}),r.push({x:i,y:s.yAxis.priceToY(t.slow)}))}}let b=a.settings?.enableWebGLRendering!==!1,x=!1;if(b&&p?.isAvailable()){let e=!0;if(n.length>=2&&(e=p.drawLineStrip({points:n,width:1},Oa.FAST,u)),e&&r.length>=2&&(e=p.drawLineStrip({points:r,width:1},Oa.SLOW,u)),e){x=!0;let e=p.getCanvas();if(e.width>0&&e.height>0){let t=o.imageSmoothingEnabled;o.imageSmoothingEnabled=!1,o.drawImage(e,0,0,e.width,e.height,0,0,e.width/d,e.height/d),o.imageSmoothingEnabled=t}}}if(!x){if(o.save(),o.translate(-u,0),o.lineWidth=1,o.lineJoin=`round`,o.lineCap=`round`,n.length>=2){o.strokeStyle=Oa.FAST,o.beginPath(),o.moveTo(n[0].x,n[0].y);for(let e=1;e<n.length;e++){let t=n[e];o.lineTo(t.x,t.y)}o.stroke()}if(r.length>=2){o.strokeStyle=Oa.SLOW,o.beginPath(),o.moveTo(r[0].x,r[0].y);for(let e=1;e<r.length;e++){let t=r[e];o.lineTo(t.x,t.y)}o.stroke()}o.restore()}},getConfig(){let t=e?.getSharedState(Tc);return t?{...t.params}:{}},setConfig(e){}}}function Yc(){let e=null;return{name:`ene`,version:`2.0.0`,description:`ENE 轨道线渲染器(无状态)`,debugName:`ENE轨道线`,paneId:`main`,priority:G.INDICATOR,onInstall(t){e=t},getDeclaredNamespaces(){return[Ec]},draw(t){let{ctx:n,pane:r,data:i,range:a,scrollLeft:o,dpr:s,kLineCenters:c}=t,l=i,u=e?.getSharedState(Ec);if(!u||u.visibleMin>u.visibleMax||u.series.length===0)return;let{period:d}=u.params,f=u.series;if(l.length<d)return;n.save(),n.translate(-o,0);let p=Math.max(a.start,d-1),m=Math.min(a.end,l.length),h=ka.UPPER,g=ka.MIDDLE,_=ka.LOWER;n.fillStyle=ka.BAND_FILL,n.beginPath();let v=!0;for(let e=p;e<m;e++){let t=f[e];if(!t)continue;let i=c[e-a.start];if(i===void 0)continue;let o=r.yAxis.priceToY(t.upper),l=i,u=Z(o,s);v?(n.moveTo(l,u),v=!1):n.lineTo(l,u)}for(let e=m-1;e>=p;e--){let t=f[e];if(!t)continue;let i=c[e-a.start];if(i===void 0)continue;let o=r.yAxis.priceToY(t.lower),l=i,u=Z(o,s);n.lineTo(l,u)}n.closePath(),n.fill(),n.lineWidth=1,n.lineJoin=`round`,n.lineCap=`round`;let y=(e,t)=>{n.strokeStyle=t,n.beginPath();let i=!0;for(let t=p;t<m;t++){let o=f[t];if(!o)continue;let l=c[t-a.start];if(l===void 0)continue;let u=r.yAxis.priceToY(o[e]),d=l,p=Z(u,s);i?(n.moveTo(d,p),i=!1):n.lineTo(d,p)}n.stroke()};y(`upper`,h),y(`middle`,g),y(`lower`,_),n.restore()},getConfig(){let t=e?.getSharedState(Ec);return t?{...t.params}:{}},setConfig(e){}}}var Xc=`"Trebuchet MS", Roboto, Ubuntu, sans-serif`;function Zc(e,t){return`${t?.bold?`bold `:``}${e}px ${Xc}`}function Qc(e,t){e.font!==t&&(e.font=t)}var $c=new Map,el=512;function tl(e,t){let n=`${e.font}\n${t}`,r=$c.get(n);if(r!==void 0)return r;let i=e.measureText(t).width;return $c.size>=el&&$c.clear(),$c.set(n,i),i}function nl(e){let t={yPaddingPx:e.yPaddingPx,indicators:{MA:{enabled:!0,params:{}},BOLL:{enabled:!1,params:{period:20,multiplier:2}},EXPMA:{enabled:!1,params:{fastPeriod:12,slowPeriod:50}},ENE:{enabled:!1,params:{period:10,deviation:11}}}},n=null;return{name:`mainIndicatorLegend`,version:`2.0.0`,description:`主图指标图例渲染器(MA 数据来自 StateStore)`,debugName:`主图指标图例`,paneId:`main`,priority:G.FOREGROUND,enabled:!0,onInstall(e){n=e},getDeclaredNamespaces(){return[Cc,wc,Tc,Ec]},draw(e){let{ctx:r,data:i,range:a,crosshairIndex:o}=e,s=i;if(!s.length)return;r.save(),Qc(r,Zc(12)),r.textAlign=`left`;let c=o??Math.min(a.end-1,s.length-1),l=[];t.indicators.MA?.enabled&&l.push({draw:e=>{let i=[],a=n?.getSharedState(Cc);if(a&&a.visibleMin<=a.visibleMax)for(let e of a.enabledPeriods){let t=`MA${e}`,n=a.series[e]?.[c];i.push({label:`MA${e}`,color:ya[t]||ya.MA5,value:n})}if(i.length>0){let n=12,a=t.yPaddingPx/2+12+e*18;r.fillStyle=J.NEUTRAL,r.fillText(`MA`,n,a),n+=tl(r,`MA`)+10;for(let e of i){let t=typeof e.value==`number`?` ${e.value.toFixed(2)}`:``,i=`${e.label}${t}`;r.fillStyle=e.color,r.fillText(i,n,a),n+=tl(r,i)+10}}}}),t.indicators.BOLL?.enabled&&l.push({draw:e=>{let i=n?.getSharedState(wc),a=i?.series[c],o=i?.params.period??20,s=i?.params.multiplier??2,l=12,u=t.yPaddingPx/2+12+e*18,d=`BOLL(${o},${s})`;if(r.fillStyle=J.NEUTRAL,r.fillText(d,l,u),l+=tl(r,d)+10,a){let e=`上轨:${a.upper.toFixed(2)}`;r.fillStyle=ba.UPPER,r.fillText(e,l,u),l+=tl(r,e)+10;let t=`中轨:${a.middle.toFixed(2)}`;r.fillStyle=ba.MIDDLE,r.fillText(t,l,u),l+=tl(r,t)+10;let n=`下轨:${a.lower.toFixed(2)}`;r.fillStyle=ba.LOWER,r.fillText(n,l,u)}}}),t.indicators.EXPMA?.enabled&&l.push({draw:e=>{let i=n?.getSharedState(Tc),a=i?.series[c],o=i?.params.fastPeriod??12,s=i?.params.slowPeriod??50,l=12,u=t.yPaddingPx/2+12+e*18,d=`EXPMA(${o},${s})`;if(r.fillStyle=J.NEUTRAL,r.fillText(d,l,u),l+=tl(r,d)+10,a){let e=`快:${a.fast.toFixed(2)}`;r.fillStyle=Oa.FAST,r.fillText(e,l,u),l+=tl(r,e)+10;let t=`慢:${a.slow.toFixed(2)}`;r.fillStyle=Oa.SLOW,r.fillText(t,l,u)}}}),t.indicators.ENE?.enabled&&l.push({draw:e=>{let i=n?.getSharedState(Ec),a=i?.series[c],o=i?.params.period??10,s=i?.params.deviation??11,l=12,u=t.yPaddingPx/2+12+e*18,d=`ENE(${o},${s})`;if(r.fillStyle=J.NEUTRAL,r.fillText(d,l,u),l+=tl(r,d)+10,a){let e=`上轨:${a.upper.toFixed(2)}`;r.fillStyle=ka.UPPER,r.fillText(e,l,u),l+=tl(r,e)+10;let t=`中轨:${a.middle.toFixed(2)}`;r.fillStyle=ka.MIDDLE,r.fillText(t,l,u),l+=tl(r,t)+10;let n=`下轨:${a.lower.toFixed(2)}`;r.fillStyle=ka.LOWER,r.fillText(n,l,u)}}}),l.forEach((e,t)=>e.draw(t)),r.restore()},getConfig(){return{yPaddingPx:t.yPaddingPx,indicators:{...t.indicators}}},setConfig(e){if(typeof e.yPaddingPx==`number`&&(t.yPaddingPx=e.yPaddingPx),e.indicators&&typeof e.indicators==`object`)for(let[n,r]of Object.entries(e.indicators))t.indicators[n]||(t.indicators[n]={enabled:!1,params:{}}),r.enabled!==void 0&&(t.indicators[n].enabled=r.enabled),r.params&&(t.indicators[n].params=r.params)}}}function rl(e={}){let{paneId:t=`sub`,config:n={}}=e,r=Fc(t),i=null,a={fastPeriod:12,slowPeriod:26,signalPeriod:9,showDIF:!0,showDEA:!0,showBAR:!0,...n},o=``,s=[],c=[];function l(){o=``,s=[],c=[]}function u(e,t,n,r,i){return n.yAxis.getDisplayRange(),[e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,i.toFixed(6),r.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),a.showDIF,a.showDEA].join(`|`)}return{name:`macd_${t}`,version:`1.0.0`,description:`MACD 指标渲染器`,debugName:`MACD`,paneId:t,priority:G.INDICATOR,onInstall(e){i=e},getDeclaredNamespaces(){return[r]},draw(e){let{ctx:t,pane:n,data:l,range:d,scrollLeft:f,dpr:p,kLineCenters:m,lineWebGLSurface:h}=e,g=l,_=i?.getSharedState(r);if(!_||_.visibleMin>_.visibleMax||g.length<a.slowPeriod)return;let v=_.series;if(!v||v.length===0)return;let y=_.visibleMin,b=_.visibleMax,x=Math.max(.05,(b-y)*.1);y-=x,b+=x,b-y;let S=n.yAxis.getDisplayRange({minPrice:y,maxPrice:b}),C=S.minPrice,w=S.maxPrice,T=w-C||1,E=n.height-(0-C)/T*n.height,D=Math.max(d.start,a.slowPeriod-1),O=Math.min(d.end,g.length);if(a.showBAR){let r=Math.round(E*p)/p,i=[],a=[],o=[],s=[];for(let t=D;t<O;t++){let c=v[t];if(!c)continue;let l=e.kBarRects[t-d.start];if(!l)continue;let u=n.height-(c.macd-C)/T*n.height,f=c.macd>=0,m=t>0?v[t-1]:null,h=m?c.macd>=m.macd:!0,g=Math.round(u*p)/p,_=1/p;if(f){let e=r-g,t=e<=0?_:Math.max(e,_),n=e<=0?r-_:r-t,o={x:l.x,y:n,width:l.width,height:t};h?i.push(o):a.push(o)}else{let e=g-r,t=e<=0?_:Math.max(e,_),n={x:l.x,y:r,width:l.width,height:t};h?s.push(n):o.push(n)}}il(e,i,a,o,s)?sl(t,e):al(t,f,i,a,o,s)}let k=u(d,m,n,C,w);if(o!==k){if(o=k,s=[],c=[],a.showDIF)for(let e=D;e<O;e++){let t=v[e];if(!t)continue;let r=m[e-d.start];if(r===void 0)continue;let i=n.height-(t.dif-C)/T*n.height;s.push({x:r,y:i})}if(a.showDEA)for(let e=D;e<O;e++){let t=v[e];if(!t)continue;let r=m[e-d.start];if(r===void 0)continue;let i=n.height-(t.dea-C)/T*n.height;c.push({x:r,y:i})}}let A=e.settings?.enableWebGLRendering!==!1,j=!1;if(A&&h?.isAvailable()){let e=!0;if(a.showDIF&&s.length>=2&&(e=h.drawLineStrip({points:s,width:1},Y.DIF,f)),e&&a.showDEA&&c.length>=2&&(e=h.drawLineStrip({points:c,width:1},Y.DEA,f)),e){j=!0;let e=h.getCanvas();if(e.width>0&&e.height>0){let n=t.imageSmoothingEnabled;t.imageSmoothingEnabled=!1,t.drawImage(e,0,0,e.width,e.height,0,0,e.width/p,e.height/p),t.imageSmoothingEnabled=n}}}j||ol(t,f,s,c,a)},onDataUpdate(){l()},getConfig(){return{...a}},setConfig(e){let t=!1;`fastPeriod`in e&&e.fastPeriod!==a.fastPeriod&&l(),`slowPeriod`in e&&e.slowPeriod!==a.slowPeriod&&l(),`signalPeriod`in e&&e.signalPeriod!==a.signalPeriod&&l(),`showDIF`in e&&e.showDIF!==a.showDIF&&(t=!0),`showDEA`in e&&e.showDEA!==a.showDEA&&(t=!0),Object.assign(a,e),t&&l()}}}function il(e,t,n,r,i){if(e.settings?.enableWebGLRendering===!1)return!1;let a=e.candleWebGLSurface;if(!a||!a.isAvailable())return!1;a.clear();let o=t.length===0||a.drawRects(t,Y.BAR_UP,e.scrollLeft),s=n.length===0||a.drawRects(n,Y.BAR_UP_LIGHT,e.scrollLeft),c=r.length===0||a.drawRects(r,Y.BAR_DOWN,e.scrollLeft),l=i.length===0||a.drawRects(i,Y.BAR_DOWN_LIGHT,e.scrollLeft);return o&&s&&c&&l}function al(e,t,n,r,i,a){e.save(),e.translate(-t,0),e.fillStyle=Y.BAR_UP;for(let t of n)e.fillRect(t.x,t.y,t.width,t.height);e.fillStyle=Y.BAR_UP_LIGHT;for(let t of r)e.fillRect(t.x,t.y,t.width,t.height);e.fillStyle=Y.BAR_DOWN;for(let t of i)e.fillRect(t.x,t.y,t.width,t.height);e.fillStyle=Y.BAR_DOWN_LIGHT;for(let t of a)e.fillRect(t.x,t.y,t.width,t.height);e.restore()}function ol(e,t,n,r,i){if(e.save(),e.translate(-t,0),e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,i.showDIF&&n.length>=2){e.strokeStyle=Y.DIF,e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++){let r=n[t];e.lineTo(r.x,r.y)}e.stroke()}if(i.showDEA&&r.length>=2){e.strokeStyle=Y.DEA,e.beginPath(),e.moveTo(r[0].x,r[0].y);for(let t=1;t<r.length;t++){let n=r[t];e.lineTo(n.x,n.y)}e.stroke()}e.restore()}function sl(e,t){let n=t.candleWebGLSurface;if(!n)return;let r=n.getCanvas();r.width<=0||r.height<=0||e.drawImage(r,0,0,r.width,r.height,0,0,r.width/t.dpr,r.height/t.dpr)}function cl(e,t,n=12,r=26,i=9){return t<r||t>=e.length?null:oc(e,n,r,i)[t]??null}function ll(e,t,n=12,r=26,i=9){let a=cl(e,t,n,r,i);return a?{name:`MACD`,params:[n,r,i],values:[{label:`DIF`,value:a.dif,color:Y.DIF},{label:`DEA`,value:a.dea,color:Y.DEA},{label:`MACD`,value:a.macd,color:a.macd>=0?Y.BAR_UP:Y.BAR_DOWN}]}:null}function ul(e={}){let{paneId:t=`sub`}=e,n=null,r=``,i=[],a=[],o=[];function s(){r=``,i=[],a=[],o=[]}function c(e,t,n,r){let i=n.yAxis.getDisplayRange();return[e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,i.maxPrice.toFixed(6),i.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),r.showRSI1,r.showRSI2,r.showRSI3].join(`|`)}return{name:`rsi_${t}`,version:`2.0.0`,description:`RSI 相对强弱指标渲染器(WebGL + Canvas2D 回退)`,debugName:`RSI`,paneId:t,priority:G.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){return[Dc(t)]},draw(e){let{ctx:l,pane:u,range:d,scrollLeft:f,dpr:p,kLineCenters:m,lineWebGLSurface:h}=e,g=Dc(t),_=n?.getSharedState(g);if(!_||_.visibleMin>_.visibleMax){s();return}let{valueMin:v,valueMax:y,params:b,series:x}=_,S=u.yAxis.getDisplayRange({minPrice:v,maxPrice:y}),C=S.minPrice,w=S.maxPrice-C||1;l.save(),l.translate(-f,0);let T=u.height-(80-C)/w*u.height,E=u.height-(50-C)/w*u.height,D=u.height-(20-C)/w*u.height,O=f,k=f+e.paneWidth;l.strokeStyle=`rgba(0, 0, 0, 0.1)`,l.lineWidth=1,l.setLineDash([4,4]),l.beginPath(),l.moveTo(O,T),l.lineTo(k,T),l.moveTo(O,E),l.lineTo(k,E),l.moveTo(O,D),l.lineTo(k,D),l.stroke(),l.setLineDash([]),l.restore();let A=Math.max(d.start,b.period1),j=Math.min(d.end,m.length+d.start),M=c(d,m,u,b);if(r!==M){if(r=M,i=[],a=[],o=[],b.showRSI1&&x[b.period1]){let e=x[b.period1];for(let t=A;t<j;t++){let n=e[t];if(n===void 0)continue;let r=m[t-d.start];if(r===void 0)continue;let a=u.height-(n-C)/w*u.height;i.push({x:r,y:a})}}if(b.showRSI2&&x[b.period2]){let e=x[b.period2];for(let t=A;t<j;t++){let n=e[t];if(n===void 0)continue;let r=m[t-d.start];if(r===void 0)continue;let i=u.height-(n-C)/w*u.height;a.push({x:r,y:i})}}if(b.showRSI3&&x[b.period3]){let e=x[b.period3];for(let t=A;t<j;t++){let n=e[t];if(n===void 0)continue;let r=m[t-d.start];if(r===void 0)continue;let i=u.height-(n-C)/w*u.height;o.push({x:r,y:i})}}}let N=e.settings?.enableWebGLRendering!==!1,ee=!1;if(N&&h?.isAvailable()){let e=!0;if(b.showRSI1&&i.length>=2&&(e=h.drawLineStrip({points:i,width:1},Sa.RSI1,f)),e&&b.showRSI2&&a.length>=2&&(e=h.drawLineStrip({points:a,width:1},Sa.RSI2,f)),e&&b.showRSI3&&o.length>=2&&(e=h.drawLineStrip({points:o,width:1},Sa.RSI3,f)),e){ee=!0;let e=h.getCanvas();if(e.width>0&&e.height>0){let t=l.imageSmoothingEnabled;l.imageSmoothingEnabled=!1,l.drawImage(e,0,0,e.width,e.height,0,0,e.width/p,e.height/p),l.imageSmoothingEnabled=t}}}ee||dl(l,f,i,a,o,b)},getConfig(){let e=Dc(t),r=n?.getSharedState(e);return r?{...r.params}:{}},setConfig(e){}}}function dl(e,t,n,r,i,a){if(e.save(),e.translate(-t,0),e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,a.showRSI1&&n.length>=2){e.strokeStyle=Sa.RSI1,e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++){let r=n[t];e.lineTo(r.x,r.y)}e.stroke()}if(a.showRSI2&&r.length>=2){e.strokeStyle=Sa.RSI2,e.beginPath(),e.moveTo(r[0].x,r[0].y);for(let t=1;t<r.length;t++){let n=r[t];e.lineTo(n.x,n.y)}e.stroke()}if(a.showRSI3&&i.length>=2){e.strokeStyle=Sa.RSI3,e.beginPath(),e.moveTo(i[0].x,i[0].y);for(let t=1;t<i.length;t++){let n=i[t];e.lineTo(n.x,n.y)}e.stroke()}e.restore()}function fl(e,t,n,r,i,a=`sub_RSI`){let o=Dc(a),s=i.getSharedState(o);if(!s)return null;let c=s.series[t]?.[e],l=s.series[n]?.[e],u=s.series[r]?.[e],d=[];return c!==void 0&&d.push({label:`RSI${t}`,value:c,color:Sa.RSI1}),l!==void 0&&d.push({label:`RSI${n}`,value:l,color:Sa.RSI2}),u!==void 0&&d.push({label:`RSI${r}`,value:u,color:Sa.RSI3}),d.length===0?null:{name:`RSI`,params:[t,n,r],values:d}}function pl(e={}){let{paneId:t=`sub`}=e,n=Oc(t),r=null,i=``,a=[];function o(){i=``,a=[]}function s(e,t,n,r){let i=n.yAxis.getDisplayRange();return[e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,i.maxPrice.toFixed(6),i.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),r.showCCI,r.period].join(`|`)}return{name:`cci_${t}`,version:`2.0.0`,description:`CCI 顺势指标渲染器(WebGL + Canvas2D 回退)`,debugName:`CCI`,paneId:t,priority:G.MAIN,onInstall(e){r=e},getDeclaredNamespaces(){return[n]},draw(e){let{ctx:t,pane:c,range:l,scrollLeft:u,dpr:d,kLineCenters:f,lineWebGLSurface:p}=e,m=r?.getSharedState(n);if(!m||m.visibleMin>m.visibleMax){o();return}let{valueMin:h,valueMax:g,params:_,series:v}=m;g-h;let y=c.yAxis.getDisplayRange({minPrice:h,maxPrice:g}),b=y.minPrice,x=y.maxPrice-b||1,S=c.height-(0-b)/x*c.height;t.save(),t.translate(-u,0);let C=c.height-(100-b)/x*c.height,w=c.height-(-100-b)/x*c.height,T=u,E=u+e.paneWidth;t.strokeStyle=Ca.OVERBOUGHT,t.lineWidth=1,t.setLineDash([4,4]),t.beginPath(),t.moveTo(T,C),t.lineTo(E,C),t.stroke(),t.strokeStyle=Ca.OVERSOLD,t.beginPath(),t.moveTo(T,w),t.lineTo(E,w),t.stroke(),t.strokeStyle=`rgba(0, 0, 0, 0.1)`,t.beginPath(),t.moveTo(T,S),t.lineTo(E,S),t.stroke(),t.setLineDash([]),t.restore();let D=Math.max(l.start,_.period-1),O=Math.min(l.end,v.length),k=s(l,f,c,_);if(i!==k&&(i=k,a=[],_.showCCI))for(let e=D;e<O;e++){let t=v[e];if(t===void 0)continue;let n=f[e-l.start];if(n===void 0)continue;let r=c.height-(t-b)/x*c.height;a.push({x:n,y:r})}let A=e.settings?.enableWebGLRendering!==!1,j=!1;if(A&&p?.isAvailable()&&_.showCCI&&a.length>=2&&p.drawLineStrip({points:a,width:1},Ca.CCI,u)){j=!0;let e=p.getCanvas();if(e.width>0&&e.height>0){let n=t.imageSmoothingEnabled;t.imageSmoothingEnabled=!1,t.drawImage(e,0,0,e.width,e.height,0,0,e.width/d,e.height/d),t.imageSmoothingEnabled=n}}j||ml(t,u,a,_)},getConfig(){return r?.getSharedState(n)?.params??{}},setConfig(){}}}function ml(e,t,n,r){if(!(!r.showCCI||n.length<2)){e.save(),e.translate(-t,0),e.strokeStyle=Ca.CCI,e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++){let r=n[t];e.lineTo(r.x,r.y)}e.stroke(),e.restore()}}function hl(e,t,n,r=`sub_CCI`){let i=n.getSharedState(Oc(r));if(!i)return null;let a=i.series[e];return a===void 0?null:{name:`CCI`,params:[t],values:[{label:`CCI`,value:a,color:Ca.CCI}]}}function gl(e={}){let{paneId:t=`sub`}=e,n=kc(t),r=null,i=``,a=[],o=[];function s(){i=``,a=[],o=[]}function c(e,t,n,r){let i=n.yAxis.getDisplayRange();return[e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,i.maxPrice.toFixed(6),i.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),r.showK,r.showD,r.n,r.m].join(`|`)}return{name:`stoch_${t}`,version:`2.0.0`,description:`STOCH 随机指标渲染器(WebGL + Canvas2D 回退)`,debugName:`STOCH`,paneId:t,priority:G.MAIN,onInstall(e){r=e},getDeclaredNamespaces(){return[n]},draw(e){let{ctx:t,pane:l,range:u,scrollLeft:d,dpr:f,kLineCenters:p,lineWebGLSurface:m}=e,h=r?.getSharedState(n);if(!h||h.visibleMin>h.visibleMax){s();return}let{valueMin:g,valueMax:_,params:v,series:y}=h;_-g;let b=l.yAxis.getDisplayRange({minPrice:g,maxPrice:_}),x=b.minPrice,S=b.maxPrice-x||1;t.save(),t.translate(-d,0);let C=l.height-(80-x)/S*l.height,w=l.height-(20-x)/S*l.height,T=d,E=d+e.paneWidth;t.strokeStyle=`rgba(0, 0, 0, 0.1)`,t.lineWidth=1,t.setLineDash([4,4]),t.beginPath(),t.moveTo(T,C),t.lineTo(E,C),t.moveTo(T,w),t.lineTo(E,w),t.stroke(),t.setLineDash([]),t.restore();let D=Math.max(u.start,v.n+v.m-2),O=Math.min(u.end,y.length),k=c(u,p,l,v);if(i!==k){if(i=k,a=[],o=[],v.showK)for(let e=D;e<O;e++){let t=y[e];if(!t)continue;let n=p[e-u.start];if(n===void 0)continue;let r=l.height-(t.k-x)/S*l.height;a.push({x:n,y:r})}if(v.showD)for(let e=D;e<O;e++){let t=y[e];if(!t)continue;let n=p[e-u.start];if(n===void 0)continue;let r=l.height-(t.d-x)/S*l.height;o.push({x:n,y:r})}}let A=e.settings?.enableWebGLRendering!==!1,j=!1;if(A&&m?.isAvailable()){let e=!0;if(v.showK&&a.length>=2&&(e=m.drawLineStrip({points:a,width:1},wa.K,d)),e&&v.showD&&o.length>=2&&(e=m.drawLineStrip({points:o,width:1},wa.D,d)),e){j=!0;let e=m.getCanvas();if(e.width>0&&e.height>0){let n=t.imageSmoothingEnabled;t.imageSmoothingEnabled=!1,t.drawImage(e,0,0,e.width,e.height,0,0,e.width/f,e.height/f),t.imageSmoothingEnabled=n}}}j||_l(t,d,a,o,v)},getConfig(){return r?.getSharedState(n)?.params??{}},setConfig(){}}}function _l(e,t,n,r,i){if(e.save(),e.translate(-t,0),e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,i.showK&&n.length>=2){e.strokeStyle=wa.K,e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++){let r=n[t];e.lineTo(r.x,r.y)}e.stroke()}if(i.showD&&r.length>=2){e.strokeStyle=wa.D,e.beginPath(),e.moveTo(r[0].x,r[0].y);for(let t=1;t<r.length;t++){let n=r[t];e.lineTo(n.x,n.y)}e.stroke()}e.restore()}function vl(e,t,n,r,i=`sub_STOCH`){let a=r.getSharedState(kc(i));if(!a)return null;let o=a.series[e];if(!o||o.k===void 0)return null;let s=[];return a.params.showK&&s.push({label:`K`,value:o.k,color:wa.K}),a.params.showD&&s.push({label:`D`,value:o.d,color:wa.D}),s.length===0?null:{name:`STOCH`,params:[t,n],values:s}}function yl(e={}){let{paneId:t=`sub`}=e,n=Ac(t),r=null,i=``,a=[];function o(){i=``,a=[]}function s(e,t,n,r){let i=n.yAxis.getDisplayRange();return[e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,i.maxPrice.toFixed(6),i.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),r.showMOM,r.period].join(`|`)}return{name:`mom_${t}`,version:`2.0.0`,description:`MOM 动量指标渲染器(WebGL + Canvas2D 回退)`,debugName:`MOM`,paneId:t,priority:G.MAIN,onInstall(e){r=e},getDeclaredNamespaces(){return[n]},draw(e){let{ctx:t,pane:c,range:l,scrollLeft:u,dpr:d,kLineCenters:f,lineWebGLSurface:p}=e,m=r?.getSharedState(n);if(!m||m.visibleMin>m.visibleMax){o();return}let{valueMin:h,valueMax:g,params:_,series:v}=m;g-h;let y=c.yAxis.getDisplayRange({minPrice:h,maxPrice:g}),b=y.minPrice,x=y.maxPrice-b||1,S=c.height-(0-b)/x*c.height;t.save(),t.translate(-u,0);let C=u,w=u+e.paneWidth;t.strokeStyle=Ta.ZERO,t.lineWidth=1,t.beginPath(),t.moveTo(C,S),t.lineTo(w,S),t.stroke(),t.restore();let T=Math.max(l.start,_.period),E=Math.min(l.end,v.length),D=s(l,f,c,_);if(i!==D&&(i=D,a=[],_.showMOM))for(let e=T;e<E;e++){let t=v[e];if(t===void 0)continue;let n=f[e-l.start];if(n===void 0)continue;let r=c.height-(t-b)/x*c.height;a.push({x:n,y:r})}let O=e.settings?.enableWebGLRendering!==!1,k=!1;if(O&&p?.isAvailable()&&_.showMOM&&a.length>=2&&p.drawLineStrip({points:a,width:1},Ta.MOM,u)){k=!0;let e=p.getCanvas();if(e.width>0&&e.height>0){let n=t.imageSmoothingEnabled;t.imageSmoothingEnabled=!1,t.drawImage(e,0,0,e.width,e.height,0,0,e.width/d,e.height/d),t.imageSmoothingEnabled=n}}k||bl(t,u,a,_)},getConfig(){return r?.getSharedState(n)?.params??{}},setConfig(){}}}function bl(e,t,n,r){if(!(!r.showMOM||n.length<2)){e.save(),e.translate(-t,0),e.strokeStyle=Ta.MOM,e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++){let r=n[t];e.lineTo(r.x,r.y)}e.stroke(),e.restore()}}function xl(e,t,n,r=`sub_MOM`){let i=n.getSharedState(Ac(r));if(!i)return null;let a=i.series[e];return a===void 0?null:{name:`MOM`,params:[t],values:[{label:`MOM`,value:a,color:Ta.MOM}]}}function Sl(e={}){let{paneId:t=`sub`}=e,n=jc(t),r=null,i=``,a=[];function o(){i=``,a=[]}function s(e,t,n,r){let i=n.yAxis.getDisplayRange();return[e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,i.maxPrice.toFixed(6),i.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),r.showWMSR,r.period].join(`|`)}return{name:`wmsr_${t}`,version:`2.0.0`,description:`WMSR 威廉指标渲染器(WebGL + Canvas2D 回退)`,debugName:`WMSR`,paneId:t,priority:G.MAIN,onInstall(e){r=e},getDeclaredNamespaces(){return[n]},draw(e){let{ctx:t,pane:c,range:l,scrollLeft:u,dpr:d,kLineCenters:f,lineWebGLSurface:p}=e,m=r?.getSharedState(n);if(!m||m.visibleMin>m.visibleMax){o();return}let{valueMin:h,valueMax:g,params:_,series:v}=m;g-h;let y=c.yAxis.getDisplayRange({minPrice:h,maxPrice:g}),b=y.minPrice,x=y.maxPrice-b||1;t.save(),t.translate(-u,0);let S=c.height-(-20-b)/x*c.height,C=c.height-(-80-b)/x*c.height,w=c.height-(-50-b)/x*c.height,T=u,E=u+e.paneWidth;t.strokeStyle=Ea.OVERBOUGHT,t.lineWidth=1,t.setLineDash([4,4]),t.beginPath(),t.moveTo(T,S),t.lineTo(E,S),t.stroke(),t.strokeStyle=Ea.OVERSOLD,t.beginPath(),t.moveTo(T,C),t.lineTo(E,C),t.stroke(),t.strokeStyle=`rgba(0, 0, 0, 0.1)`,t.beginPath(),t.moveTo(T,w),t.lineTo(E,w),t.stroke(),t.setLineDash([]),t.restore();let D=Math.max(l.start,_.period-1),O=Math.min(l.end,v.length),k=s(l,f,c,_);if(i!==k&&(i=k,a=[],_.showWMSR))for(let e=D;e<O;e++){let t=v[e];if(t===void 0)continue;let n=f[e-l.start];if(n===void 0)continue;let r=c.height-(t-b)/x*c.height;a.push({x:n,y:r})}let A=e.settings?.enableWebGLRendering!==!1,j=!1;if(A&&p?.isAvailable()&&_.showWMSR&&a.length>=2&&p.drawLineStrip({points:a,width:1},Ea.WMSR,u)){j=!0;let e=p.getCanvas();if(e.width>0&&e.height>0){let n=t.imageSmoothingEnabled;t.imageSmoothingEnabled=!1,t.drawImage(e,0,0,e.width,e.height,0,0,e.width/d,e.height/d),t.imageSmoothingEnabled=n}}j||Cl(t,u,a,_)},getConfig(){return r?.getSharedState(n)?.params??{}},setConfig(){}}}function Cl(e,t,n,r){if(!(!r.showWMSR||n.length<2)){e.save(),e.translate(-t,0),e.strokeStyle=Ea.WMSR,e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++){let r=n[t];e.lineTo(r.x,r.y)}e.stroke(),e.restore()}}function wl(e,t,n,r=`sub_WMSR`){let i=n.getSharedState(jc(r));if(!i)return null;let a=i.series[e];return a===void 0?null:{name:`WMSR`,params:[t],values:[{label:`WMSR`,value:a,color:Ea.WMSR}]}}function Tl(e={}){let{paneId:t=`sub`}=e,n=Mc(t),r=null,i=``,a=[],o=[];function s(){i=``,a=[],o=[]}function c(e,t,n,r){let i=n.yAxis.getDisplayRange();return[e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,i.maxPrice.toFixed(6),i.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),r.showKST,r.showSignal,r.roc1,r.roc2,r.roc3,r.roc4,r.signalPeriod].join(`|`)}return{name:`kst_${t}`,version:`2.0.0`,description:`KST 确知指标渲染器(WebGL + Canvas2D 回退)`,debugName:`KST`,paneId:t,priority:G.MAIN,onInstall(e){r=e},getDeclaredNamespaces(){return[n]},draw(e){let{ctx:t,pane:l,range:u,scrollLeft:d,dpr:f,kLineCenters:p,lineWebGLSurface:m}=e,h=r?.getSharedState(n);if(!h||h.visibleMin>h.visibleMax){s();return}let{valueMin:g,valueMax:_,params:v,series:y}=h;_-g;let b=l.yAxis.getDisplayRange({minPrice:g,maxPrice:_}),x=b.minPrice,S=b.maxPrice-x||1,C=l.height-(0-x)/S*l.height;t.save(),t.translate(-d,0);let w=d,T=d+e.paneWidth;t.strokeStyle=`rgba(0, 0, 0, 0.1)`,t.lineWidth=1,t.beginPath(),t.moveTo(w,C),t.lineTo(T,C),t.stroke(),t.restore();let E=Math.max(u.start,v.roc4+15+v.signalPeriod-1),D=Math.min(u.end,y.length),O=c(u,p,l,v);if(i!==O){if(i=O,a=[],o=[],v.showKST)for(let e=E;e<D;e++){let t=y[e];if(!t)continue;let n=p[e-u.start];if(n===void 0)continue;let r=l.height-(t.kst-x)/S*l.height;a.push({x:n,y:r})}if(v.showSignal)for(let e=E;e<D;e++){let t=y[e];if(!t)continue;let n=p[e-u.start];if(n===void 0)continue;let r=l.height-(t.signal-x)/S*l.height;o.push({x:n,y:r})}}let k=e.settings?.enableWebGLRendering!==!1,A=!1;if(k&&m?.isAvailable()){let e=!0;if(v.showKST&&a.length>=2&&(e=m.drawLineStrip({points:a,width:1},Da.KST,d)),e&&v.showSignal&&o.length>=2&&(e=m.drawLineStrip({points:o,width:1},Da.SIGNAL,d)),e){A=!0;let e=m.getCanvas();if(e.width>0&&e.height>0){let n=t.imageSmoothingEnabled;t.imageSmoothingEnabled=!1,t.drawImage(e,0,0,e.width,e.height,0,0,e.width/f,e.height/f),t.imageSmoothingEnabled=n}}}A||El(t,d,a,o,v)},getConfig(){return r?.getSharedState(n)?.params??{}},setConfig(){}}}function El(e,t,n,r,i){if(e.save(),e.translate(-t,0),e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,i.showKST&&n.length>=2){e.strokeStyle=Da.KST,e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++){let r=n[t];e.lineTo(r.x,r.y)}e.stroke()}if(i.showSignal&&r.length>=2){e.strokeStyle=Da.SIGNAL,e.beginPath(),e.moveTo(r[0].x,r[0].y);for(let t=1;t<r.length;t++){let n=r[t];e.lineTo(n.x,n.y)}e.stroke()}e.restore()}function Dl(e,t,n,r,i,a,o,s=`sub_KST`){let c=o.getSharedState(Mc(s));if(!c)return null;let l=c.series[e];if(!l)return null;let u=[];return c.params.showKST&&u.push({label:`KST`,value:l.kst,color:Da.KST}),c.params.showSignal&&u.push({label:`Signal`,value:l.signal,color:Da.SIGNAL}),u.length===0?null:{name:`KST`,params:[t,n,r,i,a],values:u}}function Ol(e={}){let{paneId:t=`sub`}=e,n=Nc(t),r=null,i=``,a=[];function o(){i=``,a=[]}function s(e,t,n,r){let i=n.yAxis.getDisplayRange();return[e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,i.maxPrice.toFixed(6),i.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),r.showFASTK,r.period].join(`|`)}return{name:`fastk_${t}`,version:`2.0.0`,description:`FASTK 快速随机指标渲染器(WebGL + Canvas2D 回退)`,debugName:`FASTK`,paneId:t,priority:G.MAIN,onInstall(e){r=e},getDeclaredNamespaces(){return[n]},draw(e){let{ctx:t,pane:c,range:l,scrollLeft:u,dpr:d,kLineCenters:f,lineWebGLSurface:p}=e,m=r?.getSharedState(n);if(!m||m.visibleMin>m.visibleMax){o();return}let{valueMin:h,valueMax:g,params:_,series:v}=m;g-h;let y=c.yAxis.getDisplayRange({minPrice:h,maxPrice:g}),b=y.minPrice,x=y.maxPrice-b||1;t.save(),t.translate(-u,0);let S=c.height-(80-b)/x*c.height,C=c.height-(20-b)/x*c.height,w=u,T=u+e.paneWidth;t.strokeStyle=`rgba(0, 0, 0, 0.1)`,t.lineWidth=1,t.setLineDash([4,4]),t.beginPath(),t.moveTo(w,S),t.lineTo(T,S),t.moveTo(w,C),t.lineTo(T,C),t.stroke(),t.setLineDash([]),t.restore();let E=Math.max(l.start,_.period-1),D=Math.min(l.end,v.length),O=s(l,f,c,_);if(i!==O&&(i=O,a=[],_.showFASTK))for(let e=E;e<D;e++){let t=v[e];if(t===void 0)continue;let n=f[e-l.start];if(n===void 0)continue;let r=c.height-(t-b)/x*c.height;a.push({x:n,y:r})}let k=e.settings?.enableWebGLRendering!==!1,A=!1;if(k&&p?.isAvailable()&&_.showFASTK&&a.length>=2&&p.drawLineStrip({points:a,width:1},wa.K,u)){A=!0;let e=p.getCanvas();if(e.width>0&&e.height>0){let n=t.imageSmoothingEnabled;t.imageSmoothingEnabled=!1,t.drawImage(e,0,0,e.width,e.height,0,0,e.width/d,e.height/d),t.imageSmoothingEnabled=n}}A||kl(t,u,a,_)},getConfig(){return r?.getSharedState(n)?.params??{}},setConfig(){}}}function kl(e,t,n,r){if(!(!r.showFASTK||n.length<2)){e.save(),e.translate(-t,0),e.strokeStyle=wa.K,e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++){let r=n[t];e.lineTo(r.x,r.y)}e.stroke(),e.restore()}}function Al(e,t,n,r=`sub_FASTK`){let i=n.getSharedState(Nc(r));if(!i)return null;let a=i.series[e];return a===void 0?null:{name:`FASTK`,params:[t],values:[{label:`FASTK`,value:a,color:wa.K}]}}function jl(e){let{indicatorId:t,paneId:n}=e;switch(t){case`VOLUME`:return Lc({paneId:n});case`MACD`:return rl({paneId:n});case`RSI`:return ul({paneId:n});case`CCI`:return pl({paneId:n});case`STOCH`:return gl({paneId:n});case`MOM`:return yl({paneId:n});case`WMSR`:return Sl({paneId:n});case`KST`:return Tl({paneId:n});case`FASTK`:return Ol({paneId:n});default:throw Error(`Unknown indicator: ${t}`)}}var Ml=8,Nl=6,Pl=class e{chart;activeTool=`cursor`;pendingAnchors=[];drawings=[];callbacks={};previewDrawingId=`__preview__`;dragState=null;selectedDrawingId=null;static SINGLE_ANCHOR_TOOLS=[`h-line`,`h-ray`,`v-line`,`crosshair-line`];static DOUBLE_ANCHOR_TOOLS=[`trend-line`,`ray`,`info-line`,`regression-channel`];static TRIPLE_ANCHOR_TOOLS=[`parallel-channel`,`flat-line`,`disjoint-channel`];constructor(e){this.chart=e}setCallbacks(e){this.callbacks=e}getActiveTool(){return this.activeTool}setTool(e){this.activeTool=e,this.pendingAnchors=[],this.removePreview(),this.dragState=null,this.setSelected(null),this.callbacks.onToolChange?.(e)}getDrawings(){return this.drawings}setDrawings(e){this.drawings=e,this.chart.setDrawings(e)}clear(){this.pendingAnchors=[],this.removePreview(),this.dragState=null,this.setSelected(null)}getSelectedDrawing(){return this.selectedDrawingId?this.drawings.find(e=>e.id===this.selectedDrawingId)??null:null}updateDrawingStyle(e,t){this.drawings=this.drawings.map(n=>n.id===e?{...n,style:{...n.style,...t}}:n),this.chart.setDrawings(this.drawings)}removeDrawing(e){this.drawings=this.drawings.filter(t=>t.id!==e),this.selectedDrawingId===e&&this.setSelected(null),this.chart.setDrawings(this.drawings)}onPointerMove(e,t){return this.dragState?this.handleDragMove(e,t):this.activeTool===`cursor`?!1:this.handlePreviewMove(e,t)}onPointerDown(t,n){if(this.activeTool===`cursor`)return this.handleCursorDown(t,n);let r=this.resolveAnchorFromPointer(t,n);if(!r)return!1;if(e.SINGLE_ANCHOR_TOOLS.includes(this.activeTool))return this.createSingleAnchorDrawing(r),!0;let i=e.DOUBLE_ANCHOR_TOOLS.includes(this.activeTool),a=e.TRIPLE_ANCHOR_TOOLS.includes(this.activeTool);if(!i&&!a)return!1;this.pendingAnchors.push(r);let o=i?2:3;return this.pendingAnchors.length>=o&&(this.createMultiAnchorDrawing(this.pendingAnchors),this.pendingAnchors=[]),!0}onPointerUp(e,t){return this.dragState?(this.dragState=null,!0):!1}handleCursorDown(e,t){let n=t.getBoundingClientRect(),r=e.clientX-n.left,i=e.clientY-n.top,a=this.hitTest(r,i);return a?(this.setSelected(a.drawing),this.dragState={drawingId:a.drawing.id,anchorIndex:`anchorIndex`in a?a.anchorIndex:void 0,snapshot:a.drawing.anchors.map(e=>({...e})),startMouse:{x:r,y:i}},!0):(this.setSelected(null),!1)}handleDragMove(e,t){if(!this.dragState)return!1;let n=this.drawings.find(e=>e.id===this.dragState.drawingId);if(!n)return this.dragState=null,!1;let r=this.resolveAnchorFromPointer(e,t);if(this.dragState.anchorIndex!==void 0){if(r){let e=this.dragState.anchorIndex;n.anchors[e]={...n.anchors[e],index:r.index,time:r.time,price:r.price},n.kind===`flat-line`&&e===1&&n.anchors.length>=3&&(n.anchors[2]={...n.anchors[2],index:r.index,time:r.time})}}else{let r=t.getBoundingClientRect(),i=e.clientX-r.left,a=e.clientY-r.top,o=i-this.dragState.startMouse.x,s=a-this.dragState.startMouse.y;for(let e=0;e<n.anchors.length;e++){let t=this.dragState.snapshot[e],r=this.anchorToScreen(t);if(!r)continue;let i=r.x+o,a=r.y+s,c=this.screenToAnchor(i,a);c&&(n.anchors[e]={...n.anchors[e],index:c.index,time:c.time,price:c.price})}}return this.chart.setDrawings([...this.drawings]),!0}handlePreviewMove(t,n){let r=this.resolveAnchorFromPointer(t,n);if(!r)return this.removePreview(),!1;let i=e.SINGLE_ANCHOR_TOOLS.includes(this.activeTool),a=e.DOUBLE_ANCHOR_TOOLS.includes(this.activeTool),o=e.TRIPLE_ANCHOR_TOOLS.includes(this.activeTool);if(!i&&!a&&!o)return!1;let s;if(i)s={id:this.previewDrawingId,kind:this.getDrawingKind(this.activeTool),paneId:`main`,visible:!0,anchors:[{id:`${this.previewDrawingId}-a`,index:r.index,time:r.time,price:r.price}],params:{},style:{stroke:`#2962ff`,strokeWidth:1,strokeStyle:`dashed`}};else if(a&&this.pendingAnchors.length>=1)s={id:this.previewDrawingId,kind:this.getDrawingKind(this.activeTool),paneId:`main`,visible:!0,anchors:[{id:`${this.previewDrawingId}-a`,index:this.pendingAnchors[0].index,time:this.pendingAnchors[0].time,price:this.pendingAnchors[0].price},{id:`${this.previewDrawingId}-b`,index:r.index,time:r.time,price:r.price}],params:this.activeTool===`regression-channel`?{sigma:2}:{},style:{stroke:`#2962ff`,strokeWidth:1,strokeStyle:`dashed`,...this.activeTool===`regression-channel`?{fillOpacity:.1}:{}}};else if(o){if(this.pendingAnchors.length===0)return!1;if(this.pendingAnchors.length===1)s={id:this.previewDrawingId,kind:`trend-line`,paneId:`main`,visible:!0,anchors:[{id:`${this.previewDrawingId}-a`,index:this.pendingAnchors[0].index,time:this.pendingAnchors[0].time,price:this.pendingAnchors[0].price},{id:`${this.previewDrawingId}-b`,index:r.index,time:r.time,price:r.price}],params:{},style:{stroke:`#2962ff`,strokeWidth:1,strokeStyle:`dashed`}};else{let e=this.activeTool===`flat-line`?{id:`${this.previewDrawingId}-c`,index:this.pendingAnchors[1].index,time:this.pendingAnchors[1].time,price:r.price}:{id:`${this.previewDrawingId}-c`,index:r.index,time:r.time,price:r.price};s={id:this.previewDrawingId,kind:this.getDrawingKind(this.activeTool),paneId:`main`,visible:!0,anchors:[{id:`${this.previewDrawingId}-a`,index:this.pendingAnchors[0].index,time:this.pendingAnchors[0].time,price:this.pendingAnchors[0].price},{id:`${this.previewDrawingId}-b`,index:this.pendingAnchors[1].index,time:this.pendingAnchors[1].time,price:this.pendingAnchors[1].price},e],params:{},style:{stroke:`#2962ff`,strokeWidth:1,strokeStyle:`dashed`,fillOpacity:.1}}}}else return!1;return this.drawings=this.drawings.filter(e=>e.id!==this.previewDrawingId),this.drawings=[...this.drawings,s],this.chart.setDrawings(this.drawings),!0}hitTest(e,t){let n=this.drawings.filter(e=>e.id!==this.previewDrawingId&&e.visible),r=new Map;for(let i of n){if(i.kind===`regression-channel`&&i.anchors.length>=2){let n=this.hitTestRegressionEndpoints(i,e,t,r);if(n)return n}for(let n=0;n<i.anchors.length;n++){let r=this.anchorToScreen(i.anchors[n]);if(r&&Math.hypot(e-r.x,t-r.y)<=Ml)return{drawing:i,anchorIndex:n}}}for(let i of n){let n=this.getDrawingLineSegments(i,r);for(let r of n)if(Fl(e,t,r.a,r.b)<=Nl)return{drawing:i}}return null}getDrawingLineSegments(e,t){let n=this.chart.getViewport();if(!n)return[];if(e.kind===`regression-channel`)return this.getRegressionChannelGeometry(e,t)?.segments??[];if(e.anchors.length===1){let t=this.anchorToScreen(e.anchors[0]);if(!t)return[];let r=this.chart.getPaneRenderers().find(e=>e.getPane().id===`main`)?.getPane();if(!r)return[];let i=n.plotWidth,a=r.height;switch(e.kind){case`horizontal-line`:return[{a:{x:0,y:t.y},b:{x:i,y:t.y}}];case`horizontal-ray`:return[{a:t,b:{x:i,y:t.y}}];case`vertical-line`:return[{a:{x:t.x,y:0},b:{x:t.x,y:a}}];case`cross-line`:return[{a:{x:0,y:t.y},b:{x:i,y:t.y}},{a:{x:t.x,y:0},b:{x:t.x,y:a}}];default:return[]}}let r=e.anchors.map(e=>this.anchorToScreen(e)).filter(Boolean);if(r.length<2)return[];let i=[];if(r.length===2){let t=r[0],a=r[1],o=a.x-t.x,s=a.y-t.y,c=t,l=a,u=this.getExtendMode(e),d=Math.max(n.plotWidth,n.plotHeight)*4;(u===`right`||u===`both`)&&(l={x:a.x+o*d,y:a.y+s*d}),(u===`left`||u===`both`)&&(c={x:t.x-o*d,y:t.y-s*d}),i.push({a:c,b:l})}else if(r.length>=3)switch(e.kind){case`parallel-channel`:{let[e,t,n]=r,a=t.x-e.x,o=t.y-e.y,s={x:n.x+a,y:n.y+o};i.push({a:e,b:t},{a:n,b:s});break}case`flat-line`:{let[e,t,n]=r,a={x:e.x,y:n.y},o={x:t.x,y:n.y};i.push({a:e,b:t}),i.push({a,b:o});break}case`disjoint-channel`:{let[e,t,n]=r,a=t.x-e.x,o=t.y-e.y,s={x:n.x+a,y:n.y-o};i.push({a:e,b:t}),i.push({a:n,b:s});break}default:for(let e=0;e<r.length-1;e++)i.push({a:r[e],b:r[e+1]})}return i}hitTestRegressionEndpoints(e,t,n,r){let i=this.getRegressionChannelGeometry(e,r);if(!i)return null;for(let r of i.endpoints)if(Math.hypot(t-r.point.x,n-r.point.y)<=Ml)return{drawing:e,anchorIndex:r.anchorIndex};return null}getRegressionChannelGeometry(e,t){let n=t?.get(e.id);if(n!==void 0)return n;let r=this.chart.getData();if(r.length===0||e.anchors.length<2)return t?.set(e.id,null),null;let i=Math.round(e.anchors[0].index),a=Math.round(e.anchors[1].index),o=Math.min(Math.max(i,0),r.length-1),s=Math.min(Math.max(a,0),r.length-1),c=Math.min(o,s),l=Math.max(o,s),u=r.slice(c,l+1),d=Wl(u.map(e=>e.close));if(!d)return t?.set(e.id,null),null;let f=e.params?.sigma??2,p=d.stdDev*f,m=d.intercept,h=d.intercept+d.slope*(u.length-1),g=this.anchorToScreen({id:``,index:i,price:m}),_=this.anchorToScreen({id:``,index:a,price:h}),v=this.anchorToScreen({id:``,index:i,price:m+p}),y=this.anchorToScreen({id:``,index:a,price:h+p}),b=this.anchorToScreen({id:``,index:i,price:m-p}),x=this.anchorToScreen({id:``,index:a,price:h-p}),S=[];g&&_&&S.push({a:g,b:_}),v&&y&&S.push({a:v,b:y}),b&&x&&S.push({a:b,b:x});let C=[];g&&C.push({point:g,anchorIndex:0}),_&&C.push({point:_,anchorIndex:1}),v&&C.push({point:v,anchorIndex:0}),y&&C.push({point:y,anchorIndex:1}),b&&C.push({point:b,anchorIndex:0}),x&&C.push({point:x,anchorIndex:1});let w={segments:S,endpoints:C};return t?.set(e.id,w),w}getExtendMode(e){switch(e.kind){case`ray`:return`right`;case`extended-line`:return`both`;default:return`none`}}anchorToScreen(e){let t=this.chart.getViewport();if(!t)return null;let n=this.chart.getOption(),r=this.chart.getCurrentDpr(),{startXPx:i,unitPx:a}=na(n.kWidth,n.kGap,r);if(!Number.isFinite(e.index))return null;let o=(i+e.index*a+(a-1)/2)/r-t.scrollLeft,s=this.chart.getPaneRenderers().find(e=>e.getPane().id===`main`)?.getPane();return s?{x:o,y:s.yAxis.priceToY(e.price)}:null}screenToAnchor(e,t){let n=this.chart.getData();if(!this.chart.getViewport()||n.length===0)return null;let r=this.chart.getLogicalIndexAtX(e);if(r===null)return null;let i=this.chart.getPaneRenderers().find(e=>e.getPane().id===`main`)?.getPane();return i?{index:r,time:this.chart.getTimestampAtLogicalIndex(r)??void 0??void 0,price:i.yAxis.yToPrice(t-i.top)}:null}setSelected(e){let t=e?.id??null;this.selectedDrawingId!==t&&(this.selectedDrawingId=t,this.chart.setSelectedDrawingId(t),this.callbacks.onDrawingSelected?.(e))}removePreview(){this.drawings.some(e=>e.id===this.previewDrawingId)&&(this.drawings=this.drawings.filter(e=>e.id!==this.previewDrawingId),this.chart.setDrawings(this.drawings))}resolveAnchorFromPointer(e,t){let n=this.chart.getData(),r=this.chart.getViewport();if(!r||n.length===0)return null;let i=t.getBoundingClientRect(),a=e.clientX-i.left,o=e.clientY-i.top;if(a<0||o<0||a>r.plotWidth||o>r.plotHeight)return null;let s=this.chart.getPaneRenderers().find(e=>{let t=e.getPane();return t.id===`main`&&o>=t.top&&o<=t.top+t.height})?.getPane();if(!s)return null;let c=this.chart.getLogicalIndexAtX(a);return c===null?null:{index:c,time:this.chart.getTimestampAtLogicalIndex(c)??void 0??void 0,price:s.yAxis.yToPrice(o-s.top)}}createSingleAnchorDrawing(e){this.drawings=this.drawings.filter(e=>e.id!==this.previewDrawingId);let t={id:`drawing-${Date.now()}`,kind:this.getDrawingKind(this.activeTool),paneId:`main`,visible:!0,anchors:[{id:`${Date.now()}-a`,index:e.index,time:e.time,price:e.price}],params:{},style:{stroke:`#2962ff`,strokeWidth:1,strokeStyle:`solid`}};this.drawings=[...this.drawings,t],this.chart.setDrawings(this.drawings),this.callbacks.onDrawingCreated?.(t),this.activeTool=`cursor`,this.callbacks.onToolChange?.(`cursor`)}createMultiAnchorDrawing(e){this.drawings=this.drawings.filter(e=>e.id!==this.previewDrawingId);let t=this.getDrawingKind(this.activeTool),n=t===`regression-channel`?{sigma:2}:{},r=t===`flat-line`&&e.length>=3?[e[0],e[1],{index:e[1].index,time:e[1].time,price:e[2].price}]:e,i=[`parallel-channel`,`regression-channel`,`flat-line`,`disjoint-channel`].includes(t),a={id:`drawing-${Date.now()}`,kind:t,paneId:`main`,visible:!0,anchors:r.map((e,t)=>({id:`${Date.now()}-${String.fromCharCode(97+t)}`,index:e.index,time:e.time,price:e.price})),params:n,style:{stroke:`#2962ff`,strokeWidth:1,strokeStyle:`solid`,...i?{fillOpacity:.1}:{}}};this.drawings=[...this.drawings,a],this.chart.setDrawings(this.drawings),this.callbacks.onDrawingCreated?.(a),this.activeTool=`cursor`,this.callbacks.onToolChange?.(`cursor`)}getDrawingKind(e){switch(e){case`cursor`:throw Error(`cursor is not a drawing kind`);case`h-line`:return`horizontal-line`;case`h-ray`:return`horizontal-ray`;case`v-line`:return`vertical-line`;case`crosshair-line`:return`cross-line`;default:return e}}};function Fl(e,t,n,r){let i=r.x-n.x,a=r.y-n.y,o=i*i+a*a;if(o===0)return Math.hypot(e-n.x,t-n.y);let s=((e-n.x)*i+(t-n.y)*a)/o;return s=Math.max(0,Math.min(1,s)),Math.hypot(e-(n.x+s*i),t-(n.y+s*a))}var Il=class{drawings=[];selectedId=null;getSelectedId(){return this.selectedId}setSelectedId(e){this.selectedId=e}getAll(){return this.drawings}getVisibleByPane(e){return this.drawings.filter(t=>t.visible&&t.paneId===e).sort((e,t)=>(e.zIndex??0)-(t.zIndex??0))}setAll(e){this.drawings=[...e],this.selectedId&&!this.drawings.some(e=>e.id===this.selectedId)&&(this.selectedId=null)}upsert(e){let t=this.drawings.findIndex(t=>t.id===e.id);if(t>=0){this.drawings[t]=e;return}this.drawings.push(e)}remove(e){this.drawings=this.drawings.filter(t=>t.id!==e)}clear(){this.drawings=[],this.selectedId=null}},Ll=class{definitions=new Map;register(e){this.definitions.set(e.kind,e)}get(e){return this.definitions.get(e)}compute(e,t){let n=this.get(e.kind);return n?n.compute(e,t):null}};function Rl(e,t){if(e.strokeStyle=t?.stroke??`#2962ff`,e.lineWidth=t?.strokeWidth??1,t?.strokeStyle===`dashed`){e.setLineDash([6,4]);return}if(t?.strokeStyle===`dotted`){e.setLineDash([2,3]);return}e.setLineDash([])}function zl(e,t){e.fillStyle=t?.fill??t?.stroke??`#2962ff`,e.globalAlpha=t?.fillOpacity??1}function Bl(e,t,n,r,i){let a=(e,t)=>{let n=0;return e<i.left?n|=1:e>i.right&&(n|=2),t<i.top?n|=8:t>i.bottom&&(n|=4),n},o=e,s=t,c=n,l=r;for(;;){let e=a(o,s),t=a(c,l);if(!(e|t))return{a:{x:o,y:s},b:{x:c,y:l}};if(e&t)return null;let n=e||t,r=0,u=0;n&8?(r=o+(c-o)*(i.top-s)/(l-s),u=i.top):n&4?(r=o+(c-o)*(i.bottom-s)/(l-s),u=i.bottom):n&2?(u=s+(l-s)*(i.right-o)/(c-o),r=i.right):(u=s+(l-s)*(i.left-o)/(c-o),r=i.left),n===e?(o=r,s=u):(c=r,l=u)}}function Vl(e,t){let{a:n,b:r,extend:i=`none`}=e;if(i===`none`)return Bl(n.x,n.y,r.x,r.y,t);let a=r.x-n.x,o=r.y-n.y;if(a===0&&o===0)return null;let s=Math.max(t.right-t.left,t.bottom-t.top)*4,c=n,l=r;return(i===`left`||i===`both`)&&(c={x:n.x-a*s,y:n.y-o*s}),(i===`right`||i===`both`)&&(l={x:r.x+a*s,y:r.y+o*s}),Bl(c.x,c.y,l.x,l.y,t)}function Hl(e,t){if(!Number.isFinite(e.index))return-1;let n=Math.round(e.index);return n<0||n>=t.length?-1:n}function Ul(e,t=2){if(!Number.isFinite(e))return`0`;let n=e.toFixed(t);return e>0?`+${n}`:n}function Wl(e){let t=e.length;if(t<2)return null;let n=0,r=0,i=0,a=0;for(let o=0;o<t;o++){let t=o,s=e[o];n+=t,r+=s,i+=t*s,a+=t*t}let o=t*a-n*n;if(o===0)return null;let s=(t*i-n*r)/o,c=(r-s*n)/t,l=0;for(let n=0;n<t;n++){let t=c+s*n,r=e[n]-t;l+=r*r}return{slope:s,intercept:c,stdDev:Math.sqrt(l/t)}}function Gl(){return{point(e,t,n){let r=t.style?.pointRadius??4;e.save(),e.fillStyle=t.style?.fill??t.style?.stroke??`#2962ff`,e.beginPath(),e.arc(t.point.x,t.point.y,Math.max(r,1/n),0,Math.PI*2),e.fill(),e.restore()},line(e,t,n,r){let i=Vl(t,n);if(!i)return;e.save(),Rl(e,t.style);let a=(t.style?.strokeWidth??1)<=1?.5/r:0;if(e.beginPath(),e.moveTo(i.a.x+a,i.a.y+a),e.lineTo(i.b.x+a,i.b.y+a),e.stroke(),t.showEndpoints!==!1){let n=t.style?.pointRadius??4;e.fillStyle=t.style?.stroke??`#2962ff`,e.beginPath(),e.arc(t.a.x,t.a.y,Math.max(n,1/r),0,Math.PI*2),e.fill(),e.beginPath(),e.arc(t.b.x,t.b.y,Math.max(n,1/r),0,Math.PI*2),e.fill()}e.restore()},area(e,t){if(t.points.length!==0){e.save(),zl(e,t.style),e.beginPath(),e.moveTo(t.points[0].x,t.points[0].y);for(let n=1;n<t.points.length;n++){let r=t.points[n];e.lineTo(r.x,r.y)}t.closed&&e.closePath(),e.fill(),e.restore()}},text(e,t){e.save(),e.fillStyle=t.style?.textColor??t.style?.stroke??`#2962ff`,e.font=`${t.style?.fontSize??12}px sans-serif`,e.textAlign=t.align??`left`,e.textBaseline=t.baseline??`bottom`,e.fillText(t.text,t.point.x,t.point.y),e.restore()}}}function Kl(e,t){return{kind:e,minAnchors:2,maxAnchors:2,compute(e,n){let[r,i]=e.anchors;return!r||!i?{primitives:[]}:{primitives:[{kind:`line`,a:n.toScreen(r),b:n.toScreen(i),extend:t,style:e.style}]}}}}function ql(e){return{kind:e,minAnchors:1,maxAnchors:1,compute(t,n){let[r]=t.anchors;if(!r)return{primitives:[]};let i=n.toScreen(r),a=n.pane.height,o=n.viewport.plotWidth;return e===`horizontal-line`?{primitives:[{kind:`line`,a:{x:0,y:i.y},b:{x:o,y:i.y},showEndpoints:!1,style:t.style},{kind:`point`,point:i,style:t.style}]}:e===`horizontal-ray`?{primitives:[{kind:`line`,a:i,b:{x:o,y:i.y},showEndpoints:!1,style:t.style},{kind:`point`,point:i,style:t.style}]}:e===`vertical-line`?{primitives:[{kind:`line`,a:{x:i.x,y:0},b:{x:i.x,y:a},showEndpoints:!1,style:t.style},{kind:`point`,point:i,style:t.style}]}:{primitives:[{kind:`line`,a:{x:0,y:i.y},b:{x:o,y:i.y},showEndpoints:!1,style:t.style},{kind:`line`,a:{x:i.x,y:0},b:{x:i.x,y:a},showEndpoints:!1,style:t.style},{kind:`point`,point:i,style:t.style}]}}}}function Jl(){return{kind:`info-line`,minAnchors:2,maxAnchors:2,compute(e,t){let[n,r]=e.anchors;if(!n||!r)return{primitives:[]};let i=t.toScreen(n),a=t.toScreen(r),o=Math.round(n.index),s=Math.round(r.index)-o,c=r.price-n.price,l=n.price===0?0:c/n.price*100,u=Math.atan2(a.y-i.y,a.x-i.x)*(180/Math.PI),d=`${Ul(c)} (${Ul(l)}%) ${s} bars ${Ul(u)}°`;return{primitives:[{kind:`line`,a:i,b:a,style:e.style},{kind:`text`,point:{x:(i.x+a.x)/2+8,y:Math.min(i.y,a.y)-8},text:d,align:`left`,baseline:`bottom`,style:e.style}],meta:{delta:c,percent:l,bars:s,angle:u}}}}}function Yl(){return{kind:`parallel-channel`,minAnchors:3,maxAnchors:3,compute(e,t){let[n,r,i]=e.anchors;if(!n||!r||!i)return{primitives:[]};let a=t.toScreen(n),o=t.toScreen(r),s=t.toScreen(i),c=o.x-a.x,l=o.y-a.y,u={x:s.x+c,y:s.y+l},d=e.params?.extend??`none`,f=i.index+(r.index-n.index),p=i.time?(typeof i.time==`string`?new Date(i.time).getTime():i.time)+((typeof r.time==`string`?new Date(r.time).getTime():r.time??0)-(typeof n.time==`string`?new Date(n.time).getTime():n.time??0)):void 0;return{primitives:[{kind:`area`,points:[a,o,u,s],closed:!0,style:e.style},{kind:`line`,a,b:o,extend:d,style:e.style},{kind:`line`,a:s,b:u,extend:d,style:e.style}],computedAnchors:[{id:`${e.id}-p4`,index:f,time:p,price:i.price+(r.price-n.price)}]}}}}function Xl(){return{kind:`flat-line`,minAnchors:3,maxAnchors:3,compute(e,t){let[n,r,i]=e.anchors;if(!n||!r||!i)return{primitives:[]};let a=t.toScreen(n),o=t.toScreen(r),s=t.toScreen(i),c={x:a.x,y:s.y},l={x:o.x,y:s.y};return{primitives:[{kind:`area`,points:[a,o,l,c],closed:!0,style:e.style},{kind:`line`,a,b:o,style:e.style},{kind:`line`,a:c,b:l,style:e.style},{kind:`point`,point:c,style:e.style},{kind:`point`,point:l,style:e.style}],computedAnchors:[{id:`${e.id}-h1`,index:n.index,time:n.time,price:i.price},{id:`${e.id}-h2`,index:r.index,time:r.time,price:i.price}]}}}}function Zl(){return{kind:`disjoint-channel`,minAnchors:3,maxAnchors:3,compute(e,t){let[n,r,i]=e.anchors;if(!n||!r||!i)return{primitives:[]};let a=t.toScreen(n),o=t.toScreen(r),s=t.toScreen(i),c=o.x-a.x,l=o.y-a.y,u={x:s.x+c,y:s.y-l},d=i.index+(r.index-n.index),f=i.price-(r.price-n.price),p=i.time?(typeof i.time==`string`?new Date(i.time).getTime():i.time)-((typeof r.time==`string`?new Date(r.time).getTime():r.time??0)-(typeof n.time==`string`?new Date(n.time).getTime():n.time??0)):void 0;return{primitives:[{kind:`area`,points:[a,o,u,s],closed:!0,style:e.style},{kind:`line`,a,b:o,style:e.style},{kind:`line`,a:s,b:u,style:e.style}],computedAnchors:[{id:`${e.id}-p4`,index:d,time:p,price:f}]}}}}function Ql(){return{kind:`regression-channel`,minAnchors:2,maxAnchors:2,compute(e,t){let[n,r]=e.anchors;if(!n||!r)return{primitives:[]};let i=Hl(n,t.seriesData),a=Hl(r,t.seriesData);if(i<0&&a<0)return{primitives:[]};let o=Math.min(Math.max(Math.round(n.index),0),t.seriesData.length-1),s=Math.min(Math.max(Math.round(r.index),0),t.seriesData.length-1),c=Math.min(o,s),l=Math.max(o,s),u=t.seriesData.slice(c,l+1),d=Wl(u.map(e=>e.close));if(!d)return{primitives:[]};let f=e.params?.sigma??2,p=d.stdDev*f,m=d.intercept,h=d.intercept+d.slope*(u.length-1),g={id:`${e.id}-reg-start`,index:Math.round(n.index),time:t.seriesData[c].timestamp,price:m},_={id:`${e.id}-reg-end`,index:Math.round(r.index),time:t.seriesData[l].timestamp,price:h},v={...g,id:`${e.id}-reg-upper-start`,price:m+p},y={..._,id:`${e.id}-reg-upper-end`,price:h+p},b={...g,id:`${e.id}-reg-lower-start`,price:m-p},x={..._,id:`${e.id}-reg-lower-end`,price:h-p},S=t.toScreen(g),C=t.toScreen(_),w=t.toScreen(v),T=t.toScreen(y),E=t.toScreen(b),D=t.toScreen(x);return{primitives:[{kind:`area`,points:[w,T,D,E],closed:!0,style:e.style},{kind:`line`,a:S,b:C,style:{...e.style,strokeStyle:`dashed`}},{kind:`line`,a:w,b:T,style:e.style},{kind:`line`,a:E,b:D,style:e.style}],computedAnchors:[g,_],meta:{sigma:f,stdDev:d.stdDev,slope:d.slope}}}}}function $l(e){e.register(Kl(`trend-line`,`none`)),e.register(Kl(`ray`,`right`)),e.register(Kl(`extended-line`,`both`)),e.register(ql(`horizontal-line`)),e.register(ql(`horizontal-ray`)),e.register(ql(`vertical-line`)),e.register(ql(`cross-line`)),e.register(Jl()),e.register(Yl()),e.register(Ql()),e.register(Xl()),e.register(Zl())}function eu(e){let t=e.store,n=e.definitions??new Ll,r=e.renderers??Gl();return $l(n),{name:`drawingRenderer`,version:`0.1.0`,description:`绘图渲染器`,debugName:`绘图层`,paneId:e.paneId??`main`,priority:-25,draw(e){let{ctx:i,pane:a,data:o,range:s,dpr:c,paneWidth:l,kLinePositions:u,kLineCenters:d,kBarRects:f,kWidth:p,kGap:m}=e,h=e.viewport??{scrollLeft:e.scrollLeft,plotWidth:l,plotHeight:a.height},{startXPx:g,unitPx:_}=na(p,m,c),v=o,y=v.slice(s.start,s.end),b=t.getVisibleByPane(a.id);if(b.length===0)return;let x={left:0,top:0,right:h.plotWidth,bottom:a.height};i.save(),i.beginPath(),i.rect(0,0,h.plotWidth,a.height),i.clip();for(let o of b){let b=n.compute(o,{pane:a,visibleData:y,seriesData:v,range:s,kLinePositions:u,kLineCenters:d,kBarRects:f,kWidth:p,kGap:m,dpr:c,paneWidth:l,viewport:h,toScreen(e){return!Number.isFinite(e.index)||e.index<0?{x:-p,y:a.yAxis.priceToY(e.price)}:{x:(g+e.index*_+(_-1)/2)/c-h.scrollLeft,y:a.yAxis.priceToY(e.price)}}});if(!b)continue;let S=t.getSelectedId()===o.id,C=S?b.primitives.map(e=>tu(e,o.style)):b.primitives;if(S&&o.visible&&a.role===`price`){let t=[...o.anchors,...b.computedAnchors??[]];if(t.length===0)continue;if(t.length>=2){let n=1/0,r=-1/0;for(let e of t)Number.isFinite(e.price)&&(e.price<n&&(n=e.price),e.price>r&&(r=e.price));Number.isFinite(n)&&Number.isFinite(r)&&n!==r&&(e.yAxisRanges||=[],e.yAxisRanges.push({topY:a.yAxis.priceToY(r),bottomY:a.yAxis.priceToY(n),color:o.style?.stroke??`#2962ff`,opacity:.15}))}if(t.length>=2){let n=1/0,r=-1/0;for(let e of t)!Number.isFinite(e.index)||e.index<0||(e.index<n&&(n=e.index),e.index>r&&(r=e.index));if(Number.isFinite(n)&&Number.isFinite(r)&&n!==r){e.xAxisRanges||=[];let t=(g+n*_+(_-1)/2)/c,i=(g+r*_+(_-1)/2)/c;e.xAxisRanges.push({leftX:t,rightX:i,color:o.style?.stroke??`#2962ff`,opacity:.15})}}let n=e=>{if(e>=0&&e<v.length)return v[e]?.timestamp??null;if(v.length>=2&&e>=v.length){let t=v.length-1,n=v.length-2,r=v[t].timestamp,i=r-v[n].timestamp;return r+(e-t)*i}return null};for(let r of t){if(!Number.isFinite(r.index)||!Number.isFinite(r.price))continue;let t=r.index<0?{x:-p,y:a.yAxis.priceToY(r.price)}:{x:(g+r.index*_+(_-1)/2)/c-h.scrollLeft,y:a.yAxis.priceToY(r.price)};if(t.y>=0&&t.y<=a.height&&(e.yAxisLabels||=[],e.yAxisLabels.push({dataIndex:Math.round(r.index),price:r.price,y:t.y,style:{bgColor:o.style?.stroke??`#2962ff`,borderColor:o.style?.stroke??`#2962ff`,textColor:`#ffffff`}})),t.x>=-p&&t.x<=h.plotWidth+p){let i=r.time?typeof r.time==`string`?new Date(r.time).getTime():r.time:n(Math.round(r.index));if(!i)continue;e.xAxisLabels||=[],e.xAxisLabels.push({dataIndex:Math.round(r.index),timestamp:i,x:t.x+h.scrollLeft,style:{bgColor:o.style?.stroke??`#2962ff`,textColor:`#ffffff`}})}}}for(let e of C){if(e.kind===`point`){r.point(i,e,c);continue}if(e.kind===`line`){r.line(i,e,x,c);continue}if(e.kind===`area`){r.area(i,e,c);continue}r.text(i,e,c)}}i.restore()}}}function tu(e,t){let n=t.stroke??`#2962ff`,r=(t.strokeWidth??1)+1,i=(t.pointRadius??4)+2;return e.kind===`point`?{...e,style:{...e.style,stroke:n,pointRadius:i}}:e.kind===`line`?{...e,style:{...e.style,stroke:n,strokeWidth:r}}:e.kind===`area`?{...e,style:{...e.style,stroke:n}}:{...e,style:{...e.style,textColor:n,fontSize:(e.style?.fontSize??12)+1}}}var nu=class e{dom;opt;data=[];raf=null;pendingUpdateLevel=q.All;viewport=null;paneRenderers=[];markerManager;drawingStore=new Il;interaction;pluginHost;rendererPluginManager;preciseDpr=0;resizeObserver;onScroll;observedSize={width:0,height:0};cachedScrollLeft=0;overlayHadCrosshair=!1;settings={};paneRatios=new Map;onViewportChange;xAxisCtx=null;onPaneLayoutChange;onDataChange;currentZoomLevel=1;zoomLevelCount;indicatorScheduler;lastVisibleRange={start:0,end:0};cachedDrawFrame=null;activeMainIndicators=new Set;mainIndicatorParams={MA:{ma5:!0,ma10:!0,ma20:!0,ma30:!0,ma60:!0},BOLL:{period:20,multiplier:2,showUpper:!0,showMiddle:!0,showLower:!0,showBand:!0},EXPMA:{fastPeriod:12,slowPeriod:50},ENE:{period:10,deviation:11}};enableMainIndicator(e,t){let n=e.toUpperCase();return[`MA`,`BOLL`,`EXPMA`,`ENE`].includes(n)?this.activeMainIndicators.has(n)?(t&&(this.mainIndicatorParams[n]={...this.mainIndicatorParams[n],...t},this.updateIndicatorSchedulerConfig(n)),!0):(this.activeMainIndicators.add(n),t&&(this.mainIndicatorParams[n]={...this.mainIndicatorParams[n],...t}),this.enableMainIndicatorRenderer(n),this.updateIndicatorSchedulerConfig(n),this.scheduleDraw(),!0):(console.warn(`[Chart] 未知的主图指标: ${e}`),!1)}disableMainIndicator(e){let t=e.toUpperCase();return this.activeMainIndicators.has(t)?(this.activeMainIndicators.delete(t),this.disableMainIndicatorRenderer(t),this.updateIndicatorSchedulerConfig(t),this.scheduleDraw(),!0):!1}toggleMainIndicator(e,t){t?this.enableMainIndicator(e):this.disableMainIndicator(e)}getActiveMainIndicators(){return Array.from(this.activeMainIndicators)}isMainIndicatorActive(e){return this.activeMainIndicators.has(e.toUpperCase())}updateMainIndicatorParams(e,t){let n=e.toUpperCase();this.mainIndicatorParams[n]||(this.mainIndicatorParams[n]={}),this.mainIndicatorParams[n]={...this.mainIndicatorParams[n],...t};let r=n.toLowerCase(),i=this.getRenderer(r);i&&i.setConfig&&i.setConfig(this.mainIndicatorParams[n]),this.updateIndicatorSchedulerConfig(n),this.scheduleDraw()}getMainIndicatorParams(e){return this.mainIndicatorParams[e.toUpperCase()]??null}clearMainIndicators(){for(let e of this.activeMainIndicators)this.disableMainIndicatorRenderer(e);this.activeMainIndicators.clear(),this.scheduleDraw()}enableMainIndicatorRenderer(e){let t={MA:()=>{this.getRenderer(`ma`)||this.useRenderer(Wc()),this.setRendererEnabled(`ma`,!0)},BOLL:()=>{this.getRenderer(`boll`)||this.useRenderer(Kc()),this.setRendererEnabled(`boll`,!0)},EXPMA:()=>{this.getRenderer(`expma`)||this.useRenderer(Jc()),this.setRendererEnabled(`expma`,!0)},ENE:()=>{this.getRenderer(`ene`)||this.useRenderer(Yc()),this.setRendererEnabled(`ene`,!0)}}[e];t&&t(),this.getRenderer(`mainIndicatorLegend`)||this.useRenderer(nl({yPaddingPx:this.opt.yPaddingPx}))}disableMainIndicatorRenderer(e){let t={MA:`ma`,BOLL:`boll`,EXPMA:`expma`,ENE:`ene`}[e];t&&this.setRendererEnabled(t,!1)}updateIndicatorSchedulerConfig(e){let t=this.activeMainIndicators.has(e),n=this.mainIndicatorParams[e];switch(e){case`MA`:this.indicatorScheduler.updateMAConfig({ma5:t,ma10:t,ma20:t,ma30:t,ma60:t});break;case`BOLL`:t?this.indicatorScheduler.updateBOLLConfig(n):this.indicatorScheduler.updateBOLLConfig({...n,showUpper:!1,showMiddle:!1,showLower:!1,showBand:!1});break;case`EXPMA`:t&&this.indicatorScheduler.updateEXPMAConfig(n);break;case`ENE`:t&&this.indicatorScheduler.updateENEConfig(n);break}}setActiveMainIndicators(e){let t=new Set(e.map(e=>e.toUpperCase())),n=new Set(this.activeMainIndicators);for(let e of n)t.has(e)||this.disableMainIndicator(e);for(let e of t)n.has(e)||this.enableMainIndicator(e)}constructor(e,t){this.dom=e;let{kWidth:n,kGap:r,...i}=t;this.opt={...i,kWidth:n??0,kGap:r??0},this.interaction=new ks(this),this.markerManager=new Do,this.pluginHost=ea(),this.rendererPluginManager=new ma,this.rendererPluginManager.setPluginHost(this.pluginHost),this.rendererPluginManager.setInvalidateCallback(()=>this.scheduleDraw()),this.syncPaneRatiosFromSpecs(this.opt.panes),this.zoomLevelCount=Math.max(2,Math.round(this.opt.zoomLevels??20)),this.currentZoomLevel=this.opt.initialZoomLevel??1,this.currentZoomLevel=Math.max(1,Math.min(this.zoomLevelCount,this.currentZoomLevel)),this.indicatorScheduler=new Ic,this.indicatorScheduler.setPluginHost(this.pluginHost),this.indicatorScheduler.setInvalidateCallback(()=>this.scheduleDraw()),this.initPanes(),this.useRenderer(eu({store:this.drawingStore})),this.initResizeObserver()}initResizeObserver(){if(typeof ResizeObserver>`u`)return;let e=this.dom.container;if(e){this.cachedScrollLeft=e.scrollLeft,this.onScroll=()=>{this.cachedScrollLeft=e.scrollLeft},e.addEventListener(`scroll`,this.onScroll,{passive:!0}),this.resizeObserver=new ResizeObserver(e=>{let t=e[0];if(!t)return;let n=this.observedSize.width,r=this.observedSize.height,i=this.preciseDpr;this.updateObservedMetrics(t);let a=this.observedSize.width!==n,o=this.observedSize.height!==r,s=this.preciseDpr!==i;(a||o||s)&&this.resize()});try{this.resizeObserver.observe(e,{box:`device-pixel-content-box`})}catch{this.resizeObserver.observe(e)}}}updateObservedMetrics(e){let t=Math.max(1,Math.round(e.contentRect.width)),n=Math.max(1,Math.round(e.contentRect.height));this.observedSize.width=t,this.observedSize.height=n;let r=e.devicePixelContentBoxSize?.[0],i=e.contentBoxSize?.[0];if(!r||!i||i.inlineSize<=0){this.preciseDpr=0;return}let a=r.inlineSize/i.inlineSize;this.preciseDpr=Math.round(a*64)/64}getEffectiveDpr(){let e=this.preciseDpr>0?this.preciseDpr:Math.round((window.devicePixelRatio||1)*64)/64;return e<1&&(e=1),e}getViewport(){return this.viewport}getCurrentDpr(){return this.getEffectiveDpr()}getCachedScrollLeft(){return this.cachedScrollLeft}get plugin(){return this.pluginHost}useRenderer(e,t){this.rendererPluginManager.register(e),t&&e.setConfig&&e.setConfig(t)}removeRenderer(e){this.rendererPluginManager.unregister(e)}getRenderer(e){return this.rendererPluginManager.getPlugin(e)}updateRendererConfig(e,t){this.rendererPluginManager.updateConfig(e,t)}setRendererEnabled(e,t){this.rendererPluginManager.setEnabled(e,t)}getAllRenderers(){return this.rendererPluginManager.getAllPlugins()}updateSettings(e){this.settings={...e},this.interaction.updateSettings(e);let t=e.logarithmicScale?`log`:`linear`;for(let e of this.paneRenderers)e.getPane().yAxis.setScaleType(t);this.scheduleDraw()}draw(e=q.All){this.markerManager.clear();let t=e===q.Overlay&&this.cachedDrawFrame!==null,n=t?this.cachedDrawFrame.viewport:this.computeViewport();if(!n||this.data.length===0)return;let r=t?this.cachedDrawFrame.range:(()=>{let{start:e,end:t}=ra(n.scrollLeft,n.plotWidth,this.opt.kWidth,this.opt.kGap,this.data.length,n.dpr);return{start:e,end:t}})();!t&&(r.start!==this.lastVisibleRange.start||r.end!==this.lastVisibleRange.end)&&(this.indicatorScheduler.updateVisibleRange(r),this.lastVisibleRange=r);let i=t?this.cachedDrawFrame.kLinePositions:this.calcKLinePositions(r),a,o,s;if(t)a=this.cachedDrawFrame.kLineCenters,o=this.cachedDrawFrame.kBarRects,s=this.cachedDrawFrame.kWidthPx;else{let e=na(this.opt.kWidth,this.opt.kGap,n.dpr),t=Math.max(1,e.unitPx-1);t%2==0&&--t,a=Array(i.length),o=Array(i.length);for(let r=0;r<i.length;r++){let s=i[r],c=Math.round(s*n.dpr)+(e.kWidthPx-1)/2;a[r]=c/n.dpr;let l=c-(t-1)/2;o[r]={x:l/n.dpr,width:t/n.dpr}}s=na(this.opt.kWidth,this.opt.kGap,n.dpr).kWidthPx,this.cachedDrawFrame={viewport:{...n},range:{...r},kLinePositions:[...i],kLineCenters:[...a],kBarRects:o.map(e=>({...e})),kWidthPx:s}}this.interaction.setKLinePositions(i,r,s);let c=[],l=[],u=[],d=[];this.indicatorScheduler.setActiveMainIndicators(Array.from(this.activeMainIndicators));let f=t?null:this.indicatorScheduler.getMainIndicatorPriceRange(),p=this.interaction.getCrosshairIndex()!==null;for(let s of this.paneRenderers){let m=s.getPane(),{mainCtx:h,overlayCtx:g,yAxisCtx:_}=s.getContexts(),{candleSurface:v,lineSurface:y}=s.getWebGL();if(!t){let e=m.role===`price`?f:null;m.updateRange(this.data,r,e)}let b=e===q.Main||e===q.All,x=(e===q.Overlay||e===q.All)&&(p||this.overlayHadCrosshair);if(b&&h&&(h.setTransform(1,0,0,1,0,0),h.scale(n.dpr,n.dpr),h.clearRect(0,0,n.plotWidth+1,m.height+2/n.dpr),v?.clear(),y?.clear()),x&&g){let e=g.canvas.width/n.dpr;g.setTransform(1,0,0,1,0,0),g.scale(n.dpr,n.dpr),g.clearRect(0,0,e+1,m.height+2/n.dpr)}if(_&&!t){let e=_.canvas.width/n.dpr;_.setTransform(1,0,0,1,0,0),_.scale(n.dpr,n.dpr),_.clearRect(0,0,e,m.height+2/n.dpr)}let S={ctx:h,overlayCtx:g??void 0,pane:qi(m),data:this.data,range:r,scrollLeft:n.scrollLeft,kWidth:this.opt.kWidth,kGap:this.opt.kGap,dpr:n.dpr,paneWidth:n.plotWidth,kLinePositions:i,kLineCenters:a,kBarRects:o,markerManager:this.markerManager,crosshairIndex:this.interaction.getCrosshairIndex(),yAxisCtx:_??void 0,candleWebGLSurface:v??void 0,lineWebGLSurface:y??void 0,zoomLevel:this.currentZoomLevel,zoomLevelCount:this.zoomLevelCount,viewport:{scrollLeft:n.scrollLeft,plotWidth:n.plotWidth,plotHeight:n.plotHeight},settings:this.settings,yAxisLabels:c,xAxisLabels:l,yAxisRanges:u,xAxisRanges:d},C=this.rendererPluginManager.render(m.id,S,e);C.length>0&&this.pluginHost.events.emit(`renderer:error`,{paneId:m.id,errors:C});let w=this.rendererPluginManager.renderPlugin(`yAxis`,S);w.length>0&&this.pluginHost.events.emit(`renderer:error`,{paneId:m.id,errors:w})}this.overlayHadCrosshair=p;let m=this.xAxisCtx??this.dom.xAxisCanvas.getContext(`2d`);if(this.xAxisCtx||=m,m){let e={ctx:m,pane:{id:`xAxis`,role:`auxiliary`,capabilities:{showPriceAxisTicks:!1,showCrosshairPriceLabel:!1,candleHitTest:!1,supportsPriceTranslate:!1},top:0,height:this.opt.bottomAxisHeight,yAxis:{priceToY:()=>0,yToPrice:()=>0,getPaddingTop:()=>0,getPaddingBottom:()=>0,getPriceOffset:()=>0,getDisplayRange:e=>e??{maxPrice:0,minPrice:0},getScaleType:()=>`linear`},priceRange:{maxPrice:0,minPrice:0}},data:this.data,range:r,scrollLeft:n.scrollLeft,kWidth:this.opt.kWidth,kGap:this.opt.kGap,dpr:n.dpr,paneWidth:n.plotWidth,kLinePositions:i,kLineCenters:a,kBarRects:o,xAxisCtx:m,viewport:{scrollLeft:n.scrollLeft,plotWidth:n.plotWidth,plotHeight:n.plotHeight},yAxisLabels:[],xAxisLabels:l,xAxisRanges:d},t=this.rendererPluginManager.renderPlugin(`timeAxis`,e);t.length>0&&this.pluginHost.events.emit(`renderer:error`,{paneId:`timeAxis`,errors:t})}}applyRenderState(e,t,n){let r=n===void 0?this.currentZoomLevel:Math.max(1,Math.min(this.zoomLevelCount,n));(this.opt.kWidth!==e||this.opt.kGap!==t||this.currentZoomLevel!==r)&&(this.opt={...this.opt,kWidth:e,kGap:t},n!==void 0&&(this.currentZoomLevel=r),this.scheduleDraw())}getZoomLevelCount(){return this.zoomLevelCount}setOnViewportChange(e){this.onViewportChange=e}setOnPaneLayoutChange(e){this.onPaneLayoutChange=e}setOnDataChange(e){this.onDataChange=e}getPaneRenderers(){return this.paneRenderers}getMarkerManager(){return this.markerManager}updateCustomMarkers(e){this.markerManager.setCustomMarkers(e),this.scheduleDraw()}clearCustomMarkers(){this.markerManager.clearCustomMarkers(),this.scheduleDraw()}getDom(){return this.dom}getOption(){return this.opt}calcKLinePositions(e){let{start:t,end:n}=e,r=n-t;if(r<=0)return[];let i=this.getEffectiveDpr(),{unitPx:a,startXPx:o}=na(this.opt.kWidth,this.opt.kGap,i),s=Array(r);for(let e=0;e<r;e++)s[e]=(o+(t+e)*a)/i;return s}updateOptions(e){if(e.kWidth!==void 0&&(console.warn(`[Chart] kWidth cannot be set directly. Use applyRenderState() instead.`),delete e.kWidth),e.kGap!==void 0&&delete e.kGap,e.panes){let t=e.panes.map(e=>({...e}));this.opt={...this.opt,...e,panes:t},this.applyPaneLayoutSpecs(t);return}this.opt={...this.opt,...e},this.resize()}updatePaneLayout(e){this.applyPaneLayoutSpecs(e)}setPaneDefinitions(e){this.applyPaneLayoutSpecs(e)}upsertPane(e){let t=this.opt.panes.findIndex(t=>t.id===e.id);if(t===-1){this.applyPaneLayoutSpecs([...this.opt.panes,{...e}]);return}let n=[...this.opt.panes];n[t]={...n[t],...e},this.applyPaneLayoutSpecs(n)}removePaneDefinition(e){this.opt.panes.some(t=>t.id===e)&&(this.paneRatios.delete(e),this.applyPaneLayoutSpecs(this.opt.panes.filter(t=>t.id!==e)))}bindIndicatorToPane(e,t,n){this.opt.panes.some(t=>t.id===e)||this.upsertPane({id:e,ratio:1,visible:!0,role:`indicator`});let r=`${t.toLowerCase()}_${e}`;if(this.getRenderer(r)){n&&this.updateRendererConfig(r,n);return}let i=jl({indicatorId:t,paneId:e});this.useRenderer(i,n)}setDrawings(e){this.drawingStore.setAll(e),this.scheduleDraw()}setSelectedDrawingId(e){this.drawingStore.getSelectedId()!==e&&(this.drawingStore.setSelectedId(e),this.scheduleDraw())}getPaneLayoutSpecs(){let e=this.opt.panes.filter(e=>e.visible!==!1).reduce((e,t)=>e+(this.paneRatios.get(t.id)??t.ratio??0),0),t=e>0?e:1;return this.opt.panes.map(e=>{let n=this.paneRatios.get(e.id)??e.ratio??0,r=e.visible===!1?n:n/t,i=this.paneRenderers.find(t=>t.getPane().id===e.id)?.getPane();return{...e,ratio:r,role:i?.role??e.role,capabilities:i?{...i.capabilities}:e.capabilities}})}emitPaneLayoutChange(){this.onPaneLayoutChange?.(this.getPaneLayoutSpecs())}applyPaneLayoutSpecs(e){this.opt.panes=e.map(e=>({...e})),this.syncPaneRatiosFromSpecs(this.opt.panes),this.initPanes(),this.layoutPanes(),this.emitPaneLayoutChange(),this.scheduleDraw()}resizePaneBoundary(e,t){if(!Number.isFinite(t)||t===0)return!1;let n=this.viewport;if(!n)return!1;let r=this.opt.panes.filter(e=>e.visible!==!1),i=r.findIndex(t=>t.id===e);if(i<0||i>=r.length-1)return!1;let a=r[i],o=r[i+1];if(!a||!o)return!1;let s=new Map;for(let e of r){let t=this.paneRenderers.find(t=>t.getPane().id===e.id);t&&s.set(e.id,t.getPane().height)}let c=t>0?i:i+1,l=t>0?i+1:i,u=t>0?1:-1,d=Math.abs(t),f=l;for(;d>0&&f>=0&&f<r.length;){let e=r[f];if(!e)break;let t=s.get(e.id)??0,i=this.getPaneMinHeight(e,n.plotHeight),a=Math.max(0,t-i);if(a>0){let n=Math.min(a,d);s.set(e.id,t-n),d-=n}d>0&&(f+=u)}if(d>0)return!1;let p=r[c];if(!p)return!1;let m=s.get(p.id)??0;s.set(p.id,m+Math.abs(t));let h=Math.max(0,this.opt.paneGap??0)*Math.max(0,r.length-1),g=Math.max(1,n.plotHeight-h);for(let e of r){let t=s.get(e.id)??0;this.paneRatios.set(e.id,t/g)}return this.normalizeVisiblePaneRatios(r),this.syncPaneRatiosToSpecs(),this.layoutPanes(),this.emitPaneLayoutChange(),this.scheduleDraw(),!0}resolvePaneRole(e,t){return e.role?e.role:t===0?`price`:`indicator`}addPane(e){if(this.opt.panes.some(t=>t.id===e)){console.warn(`Pane "${e}" already exists`);return}let t=this.opt.panes.some((e,t)=>this.resolvePaneRole(e,t)===`price`)?`indicator`:`price`;this.applyPaneLayoutSpecs([...this.opt.panes,{id:e,ratio:1,visible:!0,role:t}])}removePane(e){if(!this.opt.panes.some(t=>t.id===e))return;let t=this.opt.panes.filter(t=>t.id!==e);this.paneRatios.delete(e),this.applyPaneLayoutSpecs(t)}hasPane(e){return this.opt.panes.some(t=>t.id===e)}static SUB_PANE_PREFIX=`sub_`;createSubPane(t,n){let r=`${e.SUB_PANE_PREFIX}${t}`,i=`${t.toLowerCase()}_${r}`;if(this.getRenderer(i))return n&&this.updateRendererConfig(i,n),!0;let a=this.opt.panes.filter(e=>e.visible!==!1),o=a.filter((e,t)=>this.resolvePaneRole(e,t)===`price`),s=a.filter((e,t)=>this.resolvePaneRole(e,t)===`indicator`);if(o.length===1){let e=o[0];e&&this.paneRatios.set(e.id,3);for(let e of s)this.paneRatios.set(e.id,1);this.paneRatios.set(r,1)}else this.paneRatios.set(r,1);return this.upsertPane({id:r,ratio:this.paneRatios.get(r)??1,visible:!0,role:`indicator`}),this.bindIndicatorToPane(r,t,n),!0}removeSubPane(t){let n=`${e.SUB_PANE_PREFIX}${t}`;if(!this.hasPane(n))return;let r=`${t.toLowerCase()}_${n}`;this.removeRenderer(r),this.paneRatios.delete(n),this.applyPaneLayoutSpecs(this.opt.panes.filter(e=>e.id!==n))}clearSubPanes(){let t=this.opt.panes.map(e=>e.id).filter(t=>t.startsWith(e.SUB_PANE_PREFIX));if(t.length!==0){for(let n of t){let t=`${n.slice(e.SUB_PANE_PREFIX.length).toLowerCase()}_${n}`;this.removeRenderer(t),this.paneRatios.delete(n)}this.applyPaneLayoutSpecs(this.opt.panes.filter(t=>!t.id.startsWith(e.SUB_PANE_PREFIX)))}}getSubPaneIndicators(){return this.opt.panes.map(e=>e.id).filter(t=>t.startsWith(e.SUB_PANE_PREFIX)).map(t=>t.slice(e.SUB_PANE_PREFIX.length))}translatePrice(e,t){let n=this.paneRenderers.find(t=>t.getPane().id===e);if(!n)return;let r=n.getPane();if(!r.capabilities.supportsPriceTranslate)return;let i=r.yAxis.deltaYToPriceOffset(t),a=r.yAxis.getPriceOffset();r.yAxis.setPriceOffset(a+i),this.scheduleDraw()}resetPriceOffset(e){let t=this.paneRenderers.find(t=>t.getPane().id===e);t&&(t.getPane().yAxis.resetPriceOffset(),this.scheduleDraw())}scalePrice(e,t){let n=this.paneRenderers.find(t=>t.getPane().id===e);if(!n)return;let r=n.getPane();r.capabilities.supportsPriceTranslate&&(r.yAxis.scaleByDelta(t),this.scheduleDraw())}updateData(e){this.data=e??[],this.onDataChange?.(this.data);let t=this.dom.container;if(t){let e=this.getContentWidth(),n=Math.max(0,e-t.clientWidth);this.cachedScrollLeft>n&&(t.scrollLeft=n,this.cachedScrollLeft=n)}this.interaction.reset(),this.indicatorScheduler.update(this.data,this.lastVisibleRange),this.scheduleDraw()}getData(){return this.data}getIndicatorScheduler(){return this.indicatorScheduler}getTrailingSlotCount(){return 24}getLogicalSlotCount(){return this.data.length+this.getTrailingSlotCount()}getTimestampAtLogicalIndex(e){return!Number.isInteger(e)||e<0||e>=this.data.length?null:this.data[e]?.timestamp??null}getLogicalIndexAtX(e){let t=this.viewport;if(!t||this.data.length===0)return null;let n=this.getEffectiveDpr(),{startXPx:r,unitPx:i}=na(this.opt.kWidth,this.opt.kGap,n),a=Math.round((t.scrollLeft+e)*n),o=Math.floor((a-r)/i);return o<0?null:o}getDataIndexAtX(e){let t=this.getLogicalIndexAtX(e);return t===null||t>=this.data.length?null:t}getContentWidth(){return Hs({dataLength:this.data.length,kWidth:this.opt.kWidth,kGap:this.opt.kGap,viewWidth:this.viewport?.plotWidth??0,viewportDpr:this.getEffectiveDpr()})}resize(){let e=this.computeViewport();!e||e.viewWidth<10||e.viewHeight<10||(this.layoutPanes(),this.emitPaneLayoutChange(),this.scheduleDraw())}scheduleDraw(e=q.All){if(this.raf!==null){if(this.pendingUpdateLevel===q.All)return;if(e===q.All){this.pendingUpdateLevel=q.All;return}if(this.pendingUpdateLevel===q.Main&&e===q.Overlay||this.pendingUpdateLevel===q.Overlay&&e===q.Main){this.pendingUpdateLevel=q.All;return}return}this.pendingUpdateLevel=e,this.raf=requestAnimationFrame(()=>{this.raf=null;let e=this.pendingUpdateLevel;this.pendingUpdateLevel=q.All,this.draw(e)})}async destroy(){this.raf!==null&&(cancelAnimationFrame(this.raf),this.raf=null),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.preciseDpr=0,this.observedSize={width:0,height:0},this.onScroll&&=(this.dom.container?.removeEventListener(`scroll`,this.onScroll),void 0),this.viewport=null,this.cachedDrawFrame=null,this.xAxisCtx=null,this.paneRenderers.forEach(e=>e.destroy()),this.paneRenderers=[],this.rendererPluginManager.clear(),this.onViewportChange=void 0,this.onPaneLayoutChange=void 0,this.indicatorScheduler.destroy(),await this.pluginHost.destroy()}initPanes(){this.paneRenderers=this.opt.panes.map((e,t)=>{let n=new fa(e.id,{role:this.resolvePaneRole(e,t),capabilities:e.capabilities}),r=document.createElement(`canvas`),i=document.createElement(`canvas`),a=document.createElement(`canvas`),o=n.role===`price`;return r.id=`${e.id}-main`,r.className=o?`main-canvas main`:`main-canvas sub`,r.style.position=`absolute`,r.style.left=`0`,r.style.top=`0`,i.id=`${e.id}-overlay`,i.className=`overlay-canvas`,i.style.position=`absolute`,i.style.left=`0`,i.style.top=`0`,i.style.pointerEvents=`none`,i.style.backgroundColor=`transparent`,a.id=`${e.id}-yAxis`,a.className=`right-axis`,a.style.position=`absolute`,a.style.left=`0`,new Vs({mainCanvas:r,overlayCanvas:i,yAxisCanvas:a},n,{rightAxisWidth:this.opt.rightAxisWidth,yPaddingPx:this.opt.yPaddingPx,priceLabelWidth:this.opt.priceLabelWidth})});let e=this.dom.canvasLayer,t=this.dom.rightAxisLayer;e&&e.querySelectorAll(`canvas:not(.x-axis-canvas)`).forEach(e=>e.remove()),t&&t.querySelectorAll(`canvas.right-axis`).forEach(e=>e.remove()),this.paneRenderers.forEach(n=>{let r=n.getDom();e.appendChild(r.mainCanvas),e.appendChild(r.overlayCanvas),t.appendChild(r.yAxisCanvas)}),this.rendererPluginManager.setKnownPaneIds(this.paneRenderers.map(e=>e.getPane().id))}syncPaneRatiosFromSpecs(e){let t=new Map;for(let n of e){let e=this.paneRatios.get(n.id),r=Number.isFinite(n.ratio)?n.ratio:0,i=e===void 0?r>0?r:1:e;t.set(n.id,i)}this.paneRatios=t,this.normalizeVisiblePaneRatios(e),this.syncPaneRatiosToSpecs()}syncPaneRatiosToSpecs(){let e=this.opt.panes.filter(e=>e.visible!==!1).reduce((e,t)=>e+(this.paneRatios.get(t.id)??t.ratio??0),0),t=e>0?e:1;this.opt.panes=this.opt.panes.map(e=>{let n=this.paneRatios.get(e.id)??e.ratio??0;return e.visible===!1?{...e,ratio:n}:{...e,ratio:n/t}})}normalizeVisiblePaneRatios(e){let t=e.filter(e=>e.visible!==!1);if(t.length===0)return;let n=0;for(let e of t){let t=this.paneRatios.get(e.id)??e.ratio??0,r=Number.isFinite(t)&&t>0?t:0;this.paneRatios.set(e.id,r),n+=r}if(n<=0){let e=1/t.length;for(let n of t)this.paneRatios.set(n.id,e);return}for(let e of t){let t=this.paneRatios.get(e.id)??0;this.paneRatios.set(e.id,t/n)}}getPaneMinHeight(e,t){let n=this.opt.defaultPaneMinHeightPx??120,r=e.minHeightPx??n;return Math.max(1,Math.min(Math.round(r),Math.max(1,t)))}computePaneHeightsByRatio(e,t){if(e.length===0)return[];let n=e.map(e=>this.paneRatios.get(e.id)??e.ratio??0),r=n.reduce((e,t)=>e+(t>0?t:0),0),i=(r>0?n.map(e=>(e>0?e:0)/r):e.map(()=>1/e.length)).map(e=>Math.max(1,Math.round(t*e))),a=e.map(e=>this.getPaneMinHeight(e,t));for(let e=0;e<i.length;e++)i[e]=Math.max(i[e],Math.min(a[e],t));let o=i.reduce((e,t)=>e+t,0);if(o>t){let e=o-t;for(;e>0;){let n=!1;for(let r=i.length-1;r>=0&&e>0;r--){let o=Math.max(1,Math.min(a[r],t)),s=i[r];s>o&&(i[r]=s-1,e--,n=!0)}if(!n)break}}else o<t&&(i[i.length-1]=(i[i.length-1]??1)+(t-o));return o=i.reduce((e,t)=>e+t,0),o!==t&&i.length>0&&(i[i.length-1]=Math.max(1,(i[i.length-1]??1)+(t-o))),i}layoutPanes(){let e=this.viewport;if(!e)return;let t=this.opt.panes.filter(e=>e.visible!==!1);if(t.length===0)return;let n=Math.max(0,this.opt.paneGap??0),r=0,i=n*Math.max(0,t.length-1),a=Math.max(1,e.plotHeight-i);this.normalizeVisiblePaneRatios(t);let o=this.computePaneHeightsByRatio(t,a);for(let i=0;i<t.length;i++){let a=t[i];if(!a)continue;let s=this.paneRenderers.find(e=>e.getPane().id===a.id);if(!s)continue;let c=s.getPane(),l=o[i]??1;c.setLayout(r,l),c.setPadding(this.opt.yPaddingPx,this.opt.yPaddingPx),s.resize(e.plotWidth,l,e.dpr),this.rendererPluginManager.notifyResize(c.id,qi(c));let u=s.getDom();u.mainCanvas.style.top=`${r}px`,u.overlayCanvas.style.top=`${r}px`,u.yAxisCanvas.style.top=`${r}px`,u.yAxisCanvas.style.left=`0px`,r+=l+n}let s=Math.max(1,a);for(let e of t){let t=this.paneRenderers.find(t=>t.getPane().id===e.id);if(!t)continue;let n=t.getPane().height;this.paneRatios.set(e.id,n/s)}this.normalizeVisiblePaneRatios(t),this.syncPaneRatiosToSpecs()}computeViewport(){let e=this.dom.container;if(!e)return null;let t=this.observedSize.width,n=this.observedSize.height,r=t>0?t:Math.max(1,Math.round(e.clientWidth)),i=n>0?n:Math.max(1,Math.round(e.clientHeight)),a=Math.round(r),o=Math.round(i-this.opt.bottomAxisHeight),s=this.getEffectiveDpr(),c=16*1024*1024;r*s*(i*s)>c&&(s=Math.sqrt(c/(r*i)));let l=Math.round(this.cachedScrollLeft*s)/s,u=`${r}px`;this.dom.canvasLayer.style.width!==u&&(this.dom.canvasLayer.style.width=u);let d=`${i}px`;this.dom.canvasLayer.style.height!==d&&(this.dom.canvasLayer.style.height=d);let f=Math.round(a*s);this.dom.xAxisCanvas.width!==f&&(this.dom.xAxisCanvas.width=f);let p=Math.round(this.opt.bottomAxisHeight*s);this.dom.xAxisCanvas.height!==p&&(this.dom.xAxisCanvas.height=p);let m=`${f/s}px`;this.dom.xAxisCanvas.style.width!==m&&(this.dom.xAxisCanvas.style.width=m);let h=`${p/s}px`;this.dom.xAxisCanvas.style.height!==h&&(this.dom.xAxisCanvas.style.height=h);let g={viewWidth:r,viewHeight:i,plotWidth:a,plotHeight:o,scrollLeft:l,dpr:s},_=this.viewport,v=!_||_.viewWidth!==g.viewWidth||_.viewHeight!==g.viewHeight||_.plotWidth!==g.plotWidth||_.plotHeight!==g.plotHeight||_.scrollLeft!==g.scrollLeft||_.dpr!==g.dpr;return this.viewport=g,v&&this.onViewportChange?.(g),g}},ru=3;function iu(e,t){let n=(e-1)/(t.zoomLevelCount-1);return t.minKWidth+n*(t.maxKWidth-t.minKWidth)}function au(e,t){let n=Math.round(e*t);return Math.max(1,Math.min(ru,Math.round(n*.6)))/t}function ou(e,t,n,r,i,a,o){let s=Math.max(1,Math.min(o.zoomLevelCount,r+e));if(s===r)return null;let c=iu(s,o),l=au(c,o.dpr),u=na(i,a,o.dpr),d=na(c,l,o.dpr),f=(Math.round((n+t)*o.dpr)-u.startXPx)/u.unitPx;return{targetLevel:s,newKWidth:c,newKGap:l,newScrollLeft:(d.startXPx+f*d.unitPx)/o.dpr-t}}function su(e,t,n,r,i,a,o){let s=Math.max(1,Math.min(o.zoomLevelCount,Math.round(e)))-r;return s===0?null:ou(s,t,n,r,i,a,o)}function cu(e){return e.open>e.close?`down`:e.open<e.close?`up`:`flat`}var $=function(e){return e.RISE_WITH_VOLUME=`rise_with_volume`,e.RISE_WITHOUT_VOLUME=`rise_without_volume`,e.FALL_WITH_VOLUME=`fall_with_volume`,e.FALL_WITHOUT_VOLUME=`fall_without_volume`,e.OTHERS=`others`,e}({}),lu={volumeAmplifyThreshold:1.5,volumeShrinkThreshold:.8,avgPeriod:20},uu=class{prefixSum=[];dataLength=0;build(e){let t=e.length;if(t===0){this.prefixSum=[],this.dataLength=0;return}this.prefixSum=[0];for(let n=0;n<t;n++)this.prefixSum.push(this.prefixSum[n]+(e[n]?.volume??0));this.dataLength=t}query(e,t){return e<0||t>=this.dataLength||e>t?0:this.prefixSum[t+1]-this.prefixSum[e]}getVolumeMA(e,t){if(e<t-1)return 0;let n=e-t+1;return this.query(n,e)/t}get length(){return this.dataLength}};function du(e,t,n,r=lu){let i=new uu;i.build(e);let a=[],{volumeAmplifyThreshold:o,volumeShrinkThreshold:s,avgPeriod:c}=r;for(let r=t;r<n&&r<e.length;r++){let t=e[r]?.volume;if(r<1||!t){a.push($.OTHERS);continue}let n=i.getVolumeMA(r,c),l=e[r];if(!l){a.push($.OTHERS);continue}let u=l.close-l.open,d=u>0,f=u<0,p=t>n*o,m=t<n*s;d&&p?a.push($.RISE_WITH_VOLUME):d&&m?a.push($.RISE_WITHOUT_VOLUME):f&&p?a.push($.FALL_WITH_VOLUME):f&&m?a.push($.FALL_WITHOUT_VOLUME):a.push($.OTHERS)}return a}function fu(){return{name:`candle`,version:`1.0.0`,description:`K线蜡烛图渲染器`,debugName:`K线`,paneId:`main`,priority:G.MAIN,draw(e){let{ctx:t,pane:n,data:r,range:i,scrollLeft:a,kWidth:o,kGap:s,dpr:c,kLinePositions:l,markerManager:u,settings:d}=e,f=r;if(!f.length)return;let p=pu({pane:n,data:f,range:i,kWidth:o,kGap:s,dpr:c,kLinePositions:l,settings:d});hu(e,p)?gu(t,e):mu(t,a,p),_u(e,p,u)}}}function pu(e){let{pane:t,data:n,range:r,kWidth:i,kGap:a,dpr:o,kLinePositions:s,settings:c}=e,{kWidthPx:l}=na(i,a,o),u=c?.showVolumePriceMarkers!==!1,d=u?du(n,r.start,r.end,lu):null,f=[],p=[],m=[],h=[],g=[],_=[],{maxPrice:v,minPrice:y}=t.yAxis.getDisplayRange(),b=t.yAxis.getPaddingTop(),x=t.yAxis.getPaddingBottom(),S=Math.max(1,t.height-b-x),C=t.yAxis.getScaleType()!==`log`,w;if(C){let e=S/(v-y||1),t=b+S;w=n=>t-(n-y)*e}else w=e=>t.yAxis.priceToY(e);for(let e=r.start;e<r.end&&e<n.length;e++){let t=n[e];if(!t)continue;let i=w(t.open),a=w(t.close),c=w(t.high),u=w(t.low),d=s[e-r.start];if(d===void 0)continue;let v=e=>Math.round(e*o)/o,y=v(i),b=v(a),x=v(c),S=v(u),C=Math.min(y,b),T=Math.max(Math.abs(y-b),1),E=Na(Math.round(d*o),C,l,T,o),D=cu(t),O={i:e,aligned:E,trend:D,openY:i,closeY:a,highY:c,lowY:u,alignedHighY:x,alignedLowY:S,e:t},k=E.bodyRect,A=D===`up`?f:p,j=D===`up`?m:h,M=D===`up`?g:_;A.push(O),j.push(k);let N=E.bodyRect.y,ee=E.bodyRect.y+E.bodyRect.height,te=Math.max(t.open,t.close),P=Math.min(t.open,t.close);if(t.high>te){let e=ja(E.wickRect.x,x,N,o);e&&M.push(e)}if(t.low<P){let e=ja(E.wickRect.x,ee,S,o);e&&M.push(e)}}return{upKLines:f,downKLines:p,upBodyRects:m,downBodyRects:h,upWickRects:g,downWickRects:_,wickWidth:f[0]?.aligned.wickRect.width??p[0]?.aligned.wickRect.width??1,relations:d,showVolumePriceMarkers:u}}function mu(e,t,n){e.save(),e.translate(-t,0),e.fillStyle=J.UP;for(let t of n.upBodyRects)e.fillRect(t.x,t.y,t.width,t.height);e.fillStyle=J.DOWN;for(let t of n.downBodyRects)e.fillRect(t.x,t.y,t.width,t.height);e.fillStyle=J.UP;for(let t of n.upWickRects)e.fillRect(t.x,t.y,n.wickWidth,t.height);e.fillStyle=J.DOWN;for(let t of n.downWickRects)e.fillRect(t.x,t.y,n.wickWidth,t.height);e.restore()}function hu(e,t){if(e.settings?.enableWebGLRendering===!1)return!1;let n=e.candleWebGLSurface;if(!n||!n.isAvailable())return!1;n.clear();let r=t.upBodyRects.length===0||n.drawRects(t.upBodyRects,J.UP,e.scrollLeft),i=t.downBodyRects.length===0||n.drawRects(t.downBodyRects,J.DOWN,e.scrollLeft),a=t.upWickRects.length===0||n.drawRects(t.upWickRects,J.UP,e.scrollLeft),o=t.downWickRects.length===0||n.drawRects(t.downWickRects,J.DOWN,e.scrollLeft);return r&&i&&a&&o}function gu(e,t){let n=t.candleWebGLSurface;if(!n)return;let r=n.getCanvas();r.width<=0||r.height<=0||e.drawImage(r,0,0,r.width,r.height,0,0,r.width/t.dpr,r.height/t.dpr)}function _u(e,t,n){let{ctx:r,range:i,kWidth:a,dpr:o}=e;if(!(!t.showVolumePriceMarkers||!n||(e.zoomLevel??1)<2)){r.save(),r.translate(-e.scrollLeft,0);for(let s of t.upKLines){let c=t.relations?.[s.i-i.start];if(c!==void 0&&c!==$.OTHERS){let t=c===$.RISE_WITH_VOLUME||c===$.RISE_WITHOUT_VOLUME?s.alignedHighY-15:s.alignedLowY+15,l=s.i-i.start,u=e.kLineCenters[l];vu(r,u,t,c,s.i,a,4,n,o)}}for(let s of t.downKLines){let c=t.relations?.[s.i-i.start];if(c!==void 0&&c!==$.OTHERS){let t=c===$.RISE_WITH_VOLUME||c===$.RISE_WITHOUT_VOLUME?s.alignedHighY-15:s.alignedLowY+15,l=s.i-i.start,u=e.kLineCenters[l];vu(r,u,t,c,s.i,a,4,n,o)}}r.restore()}}function vu(e,t,n,r,i,a,o=4,s,c){let l=e=>Math.round(e*c)/c;t=l(t),n=l(n);let u=Math.min(a,20),d=u*Math.sqrt(3)/2,f,p;switch(r){case $.RISE_WITH_VOLUME:f=`#FF4444`,p=!0;break;case $.RISE_WITHOUT_VOLUME:f=`#00C853`,p=!0;break;case $.FALL_WITH_VOLUME:f=`#FF4444`,p=!1;break;case $.FALL_WITHOUT_VOLUME:f=`#00C853`,p=!1;break;default:return}if(e.save(),e.beginPath(),p){let r=l(n-o),i=l(r-d);e.moveTo(t,i),e.lineTo(l(t-u/2),r),e.lineTo(l(t+u/2),r)}else{let r=l(n+o),i=l(r+d);e.moveTo(t,i),e.lineTo(l(t-u/2),r),e.lineTo(l(t+u/2),r)}e.closePath(),e.fillStyle=f,e.fill(),e.restore();let m,h;if(p){let e=l(l(n-o)-d);m=l(t-u/2),h=e}else{let e=l(n+o);l(e+d),m=l(t-u/2),h=e}let g;switch(r){case $.RISE_WITH_VOLUME:g=`RISE_WITH_VOLUME`;break;case $.RISE_WITHOUT_VOLUME:g=`RISE_WITHOUT_VOLUME`;break;case $.FALL_WITH_VOLUME:g=`FALL_WITH_VOLUME`;break;case $.FALL_WITHOUT_VOLUME:g=`FALL_WITHOUT_VOLUME`;break;default:return}let _=`mk_price-volume_${i}`;s.register({id:_,type:`triangle`,markerType:g,x:m,y:h,width:u,height:d,dataIndex:i,metadata:{relation:r}})}function yu(e,t){return Math.max(3,Math.round(e/60)+1)}function bu(e){let{height:t,paddingTop:n,paddingBottom:r,isMain:i,hideEdgeTicks:a}=e,o=n,s=Math.max(n,t-r),c=Math.max(0,s-o),l=yu(t,i),u=[];for(let e=0;e<l;e++){if(a&&(e===0||e===l-1))continue;let t=l<=1?0:e/(l-1),n=o+t*c;u.push({index:e,t,y:n})}return u}var xu=1e-10,Su=[1,1.2,1.5,2,2.5,3,4,5,6,7.5,8,10];function Cu(e){if(!Number.isFinite(e)||e<=0)return e;let t=10**Math.floor(Math.log10(e)),n=e/t,r=Su[0],i=1/0;for(let e of Su){let t=Math.abs(e-n);t<i&&(i=t,r=e)}return r*t}function wu(e){let{height:t,paddingTop:n,paddingBottom:r,valueMin:i,valueMax:a,targetCount:o}=e,s=Math.max(i,xu),c=Math.max(a,s*1.001),l=n,u=Math.max(n,t-r),d=Math.max(0,u-l);if(d<=0)return[];let f=ca({minPrice:s,maxPrice:c}),p=K(s,f),m=K(c,f),h=m-p;if(!Number.isFinite(h)||Math.abs(h)<1e-10)return[];let g=Math.max(2,o),_=g<=1?d:d/(g-1),v=_*.6,y=_*.15,b=[],x=null;for(let e=0;e<g;e++){let t=g<=1?0:e/(g-1),n=l+t*d,r=sa(m-t*h,f),i=r,a=t,o=n,s=Cu(r);if(Number.isFinite(s)&&s>0){let e=(m-K(s,f))/h,t=l+e*d;Number.isFinite(t)&&Math.abs(t-n)<=y&&(i=s,a=e,o=t)}o<l-.5||o>u+.5||x!==null&&Math.abs(o-x)<v||(b.push({index:b.length,t:a,y:o,value:i}),x=o)}return b}var Tu=``,Eu=[];function Du(e){return`${e.valueMin}:${e.valueMax}:${e.height}:${e.paddingTop}:${e.paddingBottom}:${e.isMain}:${e.scaleType??`linear`}:${e.hideEdgeTicks??!1}`}function Ou(e){let t=Du(e);if(t===Tu)return Eu;let{valueMin:n,valueMax:r,scaleType:i=`linear`}=e;if(i===`log`){if(n<=0)return Ou({...e,scaleType:`linear`});let i=Math.max(n,xu),a=Math.max(r,i*1.001),{height:o,paddingTop:s,paddingBottom:c,isMain:l,hideEdgeTicks:u}=e,d=wu({height:o,paddingTop:s,paddingBottom:c,valueMin:i,valueMax:a,targetCount:Math.max(2,yu(o,l))});u&&d.length>2&&(d=d.slice(1,-1));let f=d.map((e,t)=>({...e,index:t}));return Tu=t,Eu=f,f}let a=bu(e),o=yu(e.height,e.isMain),s=r-n||1,c=a.map(e=>{let t=r-s/Math.max(1,o-1)*e.index;return{...e,value:t}});return Tu=t,Eu=c,c}function ku(){return{name:`gridLines`,version:`1.0.0`,description:`网格线渲染器`,debugName:`网格线`,paneId:Ji,priority:G.GRID,draw(e){let{ctx:t,pane:n,data:r,range:i,scrollLeft:a,kWidth:o,dpr:s,kLinePositions:c}=e,l=r;if(!l.length)return;t.save(),t.fillStyle=va.HORIZONTAL,t.translate(-a,0);let u=t.canvas.width/s,d=a,f=a+u,p=n.yAxis.getPaddingTop(),m=n.yAxis.getPaddingBottom(),h=n.yAxis.getScaleType(),g;if(h===`log`&&n.role===`price`){let e=n.yAxis.getDisplayRange(n.priceRange);g=Ou({height:n.height,paddingTop:p,paddingBottom:m,isMain:!0,valueMin:e.minPrice,valueMax:e.maxPrice,scaleType:`log`}).map(e=>e.y)}else g=bu({height:n.height,paddingTop:p,paddingBottom:m,isMain:n.role===`price`}).map(e=>e.y);for(let e of g){let n=Ma(d,f,e,s);n&&t.fillRect(n.x,n.y,n.width,n.height)}let _=Za(l);for(let e of _){if(e<i.start||e>=i.end||e>=l.length)continue;let r=e-i.start;if(r<0||r>=c.length)continue;let a=ja(c[r]+o/2,0,n.height,s);a&&t.fillRect(a.x,a.y,a.width,a.height)}t.restore()}}}function Au(){return{name:`lastPriceLine`,version:`1.0.0`,description:`最新价虚线渲染器`,debugName:`最新价线`,paneId:`main`,priority:G.LAST_PRICE_LABEL,draw(e){let{ctx:t,pane:n,data:r,scrollLeft:i,dpr:a,kLinePositions:o,paneWidth:s}=e,c=r,l=c[c.length-1];if(!l)return;let u=n.yAxis.getDisplayRange(n.priceRange);if(l.close<u.minPrice||l.close>u.maxPrice)return;let d=Math.round(n.yAxis.priceToY(l.close));e.yAxisLabels||=[],e.yAxisLabels.push({dataIndex:c.length-1,price:l.close,y:d,type:`lastPrice`,style:{bgColor:`rgba(255, 247, 248, 0.98)`,borderColor:J.LAST_PRICE,textColor:J.LAST_PRICE}}),t.save(),t.translate(-i,0);let f=o[0]??0,p=s+i;t.strokeStyle=J.LAST_PRICE,t.lineWidth=1,t.setLineDash([4,3]),t.beginPath();let m=(Math.floor(d*a)+.5)/a;t.moveTo(Math.round(f*a)/a,m),t.lineTo(Math.round(p*a)/a,m),t.stroke(),t.setLineDash([]),t.restore()}}}var ju=new Map,Mu=256;function Nu(e,t){let n=`${e.font}\n${t}`,r=ju.get(n);if(r!==void 0)return r;let i=e.measureText(t).width;return ju.size>=Mu&&ju.clear(),ju.set(n,i),i}function Pu(){return{name:`extremaMarkers`,version:`1.0.0`,description:`可视区最高/最低价标注渲染器`,debugName:`极值标记`,paneId:Ji,priority:G.OVERLAY,draw(e){let{ctx:t,pane:n,data:r,range:i,scrollLeft:a,dpr:o,paneWidth:s,kLineCenters:c}=e,l=r;if(!l.length||n.role!==`price`)return;let u=Math.max(0,i.start),d=Math.min(l.length,i.end);if(d-u<=0)return;let f=-1/0,p=1/0,m=u,h=u;for(let e=u;e<d;e++){let t=l[e];t&&(t.high>=f&&(f=t.high,m=e),t.low<=p&&(p=t.low,h=e))}if(!Number.isFinite(f)||!Number.isFinite(p))return;let g=e=>{let t=e-i.start;return t<0||t>=c.length?0:c[t]};e.yAxisLabels||=[],e.yAxisLabels.push({dataIndex:m,price:f,y:n.yAxis.priceToY(f),style:{bgColor:`rgba(255, 247, 248, 0.98)`,borderColor:J.LAST_PRICE,textColor:J.LAST_PRICE}}),e.yAxisLabels.push({dataIndex:h,price:p,y:n.yAxis.priceToY(p),style:{bgColor:`rgba(255, 247, 248, 0.98)`,borderColor:J.LAST_PRICE,textColor:J.LAST_PRICE}}),t.save(),t.translate(-a,0),Fu(t,g(m),n.yAxis.priceToY(f),f,o,s,a),Fu(t,g(h),n.yAxis.priceToY(p),p,o,s,a),t.restore()}}}function Fu(e,t,n,r,i,a,o){let s=r.toFixed(2);Qc(e,Zc(12));let c=Nu(e,s),l=t-o+30+4+c>a,u=t,d=l?t-30:t+30;u>d&&([u,d]=[d,u]);let f=Ma(u,d,n,i);f&&(e.fillStyle=ha.WEAK,e.fillRect(f.x,f.y,f.width,f.height));let p=X(d,i),m=X(n,i);e.fillStyle=ha.WEAK,e.beginPath(),e.arc(p,m,2,0,Math.PI*2),e.fill(),e.textBaseline=`middle`,e.fillStyle=J.NEUTRAL,l?(e.textAlign=`right`,e.fillText(s,X(t-30-4,i),Z(n,i))):(e.textAlign=`left`,e.fillText(s,X(t+30+4,i),Z(n,i)))}function Iu(e,t,n,r,i,a){let o=t-n||1,s=Math.max(1,r-i-a);return n+(1-(Math.min(Math.max(e,i),i+s)-i)/s)*o}var Lu=new Map,Ru=512;function zu(e,t){let n=`${e.font}\n${t}`,r=Lu.get(n);if(r!==void 0)return r;let i=e.measureText(t).width;return Lu.size>=Ru&&Lu.clear(),Lu.set(n,i),i}function Bu(e,t){let{x:n,y:r,width:i,height:a,crosshairX:o,timestamp:s,dpr:c,fontSize:l=16,paddingX:u=8}=t,d=Ga(s);e.save(),Qc(e,Zc(l)),e.textBaseline=`middle`,e.textAlign=`center`;let f=Math.round(zu(e,d)),p=Math.min(i,f+u*2),m=a,h=Math.min(Math.max(o,n+p/2),n+i-p/2),g=r+a/2,_=h-p/2,v=r;e.fillStyle=`rgba(0, 0, 0, 0.8)`,e.fillRect(X(_,c),X(v,c),X(p,c),X(m,c)),e.fillStyle=`#ffffff`,e.fillText(d,X(h,c),Z(g,c)),e.restore()}function Vu(e,t){let{x:n,y:r,width:i,height:a,crosshairY:o,priceRange:s,yPaddingPx:c=0,dpr:l,bgColor:u=`rgba(0, 0, 0, 0.8)`,borderColor:d,textColor:f=`#ffffff`,fontSize:p=16,priceOffset:m=0,price:h,formatPrice:g}=t,_=Math.max(0,Math.min(c,Math.floor(a/2)-1)),{maxPrice:v,minPrice:y}=s,b=h??Iu(o-r,v,y,a,_,_)+m,x=g?g(b):b.toFixed(2);e.save(),Qc(e,Zc(p)),e.textBaseline=`middle`,e.textAlign=`center`;let S=p+4,C=Math.min(Math.max(o,r+S/2),r+a-S/2),w=C-S/2,T=n,E=X(w,l),D=i,O=X(S,l);e.fillStyle=u,e.fillRect(T,E,D,O),d&&(e.strokeStyle=d,e.lineWidth=1,e.strokeRect(Z(T,l),Z(E,l),Math.max(0,D-1/l),Math.max(0,O-1/l)));let k=n+i/2;e.fillStyle=f,e.fillText(x,X(k,l),Z(C,l)),e.restore()}function Hu(e,t){let{x:n,y:r,width:i,height:a,data:o,scrollLeft:s,kWidth:c,kGap:l,startIndex:u,endIndex:d,dpr:f,bgColor:p=ga.TRANSPARENT,textColor:m=ha.SECONDARY,lineColor:h=_a.DARK,fontSize:g=12,paddingX:_=8,drawTopBorder:v=!0,drawBottomBorder:y=!0}=t,b=Math.round(c*f),x=b%2==0?b+1:b,S=Math.round(l*f),C=x+S,w=S,T=C/f,E=w/f,D=x/f;e.fillStyle=p,e.fillRect(n,r,i,a),v&&(e.strokeStyle=h,e.lineWidth=1,e.beginPath(),e.moveTo(n,Z(r,f)),e.lineTo(n+i,Z(r,f)),e.stroke()),y&&(e.strokeStyle=h,e.lineWidth=1,e.beginPath(),e.moveTo(n,Z(r+a,f)),e.lineTo(n+i,Z(r+a,f)),e.stroke()),e.textAlign=`center`,e.textBaseline=`middle`,e.fillStyle=m;let O=r+a/2,k=Zc(g),A=Zc(g,{bold:!0}),j=Za(o).filter(e=>e>=u&&e<d);for(let t of j){let n=o[t];if(!n)continue;let r=E+t*T+D/2-s,a=_,c=Math.max(_,i-_);if(r>=a&&r<=c){let t=Math.min(Math.max(r,a),c),{text:i,isYear:o}=Ha(n.timestamp);Qc(e,o?A:k),e.fillText(i,X(t,f),Z(O,f))}}}function Uu(e,t){let{x:n,y:r,width:i,height:a,priceY:o,price:s,dpr:c,bgColor:l=`rgba(0, 0, 0, 0.8)`,borderColor:u,textColor:d=`#ffffff`,fontSize:f=12}=t,p=s.toFixed(2);e.save(),Qc(e,Zc(f)),e.textBaseline=`middle`,e.textAlign=`center`;let m=f+4,h=Math.min(Math.max(o,r+m/2),r+a-m/2),g=h-m/2,_=n,v=X(g,c),y=i,b=X(m,c);e.fillStyle=l,e.fillRect(_,v,y,b),u&&(e.strokeStyle=u,e.lineWidth=1,e.strokeRect(Z(_,c),Z(v,c),Math.max(0,y-1/c),Math.max(0,b-1/c)));let x=n+i/2;e.fillStyle=d,e.fillText(p,X(x,c),Z(h,c)),e.restore()}function Wu(e,t){let{x:n,y:r,width:i,height:a,labelX:o,timestamp:s,dpr:c,fontSize:l=12,paddingX:u=8}=t,d=Ga(s);e.save(),Qc(e,Zc(l)),e.textBaseline=`middle`,e.textAlign=`center`;let f=Math.round(zu(e,d)),p=Math.min(i,f+u*2),m=a,h=Math.min(Math.max(o,n+p/2),n+i-p/2),g=r+a/2,_=h-p/2,v=r;e.fillStyle=t.bgColor??`rgba(0, 0, 0, 0.8)`,e.fillRect(X(_,c),X(v,c),X(p,c),X(m,c)),e.fillStyle=t.textColor??`#ffffff`,e.fillText(d,X(h,c),Z(g,c)),e.restore()}function Gu(e){let{ctx:t,dpr:n,axisWidth:r,height:i,paddingTop:a,paddingBottom:o,valueMin:s,valueMax:c,isMain:l,decimals:u=2,hideEdgeTicks:d=!0,scaleType:f=`linear`,formatLabel:p}=e;t.save(),t.clearRect(0,0,r,i),Qc(t,Zc(12)),t.textBaseline=`middle`,t.textAlign=`center`,t.fillStyle=ha.SECONDARY;let m=r/2,h=Ou({height:i,paddingTop:a,paddingBottom:o,isMain:l,hideEdgeTicks:d,valueMin:s,valueMax:c,scaleType:f});for(let{y:e,value:r}of h)t.fillText(p?p(r):r.toFixed(u),X(m,n),Z(e,n));t.restore()}function Ku(e){let{axisWidth:t,paneId:n,indicatorKey:r,label:i,decimals:a=2,yPaddingPx:o=0,scaleType:s=`linear`,getCrosshair:c,formatTickLabel:l,formatCrosshairLabel:u}=e,d=Q(r,n),f=null;return{name:`${r}Scale_${n}`,version:`1.0.0`,description:`${i} 刻度渲染器`,debugName:`${i}刻度`,paneId:n,priority:G.INDICATOR_SCALE,onInstall(e){f=e},draw(e){let{yAxisCtx:n,pane:r,dpr:i}=e;if(!n||!f)return;let p=f.getSharedState(d);if(!p)return;let m=r.yAxis.getScaleType()??s,h=r.yAxis.getDisplayRange({minPrice:p.valueMin,maxPrice:p.valueMax});Gu({ctx:n,dpr:i,axisWidth:t,height:r.height,paddingTop:r.yAxis.getPaddingTop(),paddingBottom:r.yAxis.getPaddingBottom(),valueMin:h.minPrice,valueMax:h.maxPrice,isMain:!1,decimals:a,hideEdgeTicks:!1,scaleType:m,formatLabel:l});let g=c?.();if(!g||g.activePaneId!==r.id)return;let _=g.y-r.top,v=r.yAxis.getPaddingTop(),y=r.yAxis.getPaddingBottom(),b=v,x=Math.max(v,r.height-y),S=Math.max(1,x-b),C=(Math.min(Math.max(_,b),x)-b)/S,w=h.maxPrice-C*(h.maxPrice-h.minPrice);Vu(n,{x:0,y:0,width:t,height:r.height,crosshairY:_,priceRange:h,yPaddingPx:o,dpr:i,fontSize:12,priceOffset:0,price:w,formatPrice:u})}}}function qu(e){return{name:`yAxis`,version:`1.0.0`,description:`Y轴价格刻度渲染器`,debugName:`Y轴`,paneId:Ji,priority:G.SYSTEM_YAXIS,draw(t){let{ctx:n,pane:r,dpr:i,yAxisCtx:a,data:o}=t,s=r.yAxis.getScaleType(),c=a||n,l=a?.canvas?a.canvas.width/i:e.axisWidth,u=r.yAxis.getDisplayRange(r.priceRange);if(r.capabilities.showPriceAxisTicks&&Gu({ctx:c,dpr:i,axisWidth:l,height:r.height,paddingTop:r.yAxis.getPaddingTop(),paddingBottom:r.yAxis.getPaddingBottom(),valueMin:u.minPrice,valueMax:u.maxPrice,isMain:!0,decimals:2,hideEdgeTicks:!1,scaleType:s}),t.yAxisRanges&&r.role===`price`)for(let e of t.yAxisRanges){let t=e.topY+r.top,n=e.bottomY-e.topY;n<=0||(c.save(),c.globalAlpha=e.opacity,c.fillStyle=e.color,c.fillRect(0,t,l,n),c.restore())}if(t.yAxisLabels&&r.role===`price`)for(let e of t.yAxisLabels){let t=e.type===`lastPrice`;Uu(c,{x:0,y:r.top,width:l,height:r.height,priceY:e.y+r.top,price:e.price,dpr:i,bgColor:e.style?.bgColor??`rgba(0, 0, 0, 0.8)`,borderColor:e.style?.borderColor,textColor:e.style?.textColor??`#ffffff`,fontSize:t?12:11})}let d=e.getCrosshair?.();d&&d.activePaneId===r.id&&d.price!==null&&Vu(c,{x:0,y:r.top,width:l,height:r.height,crosshairY:d.y,priceRange:u,yPaddingPx:e.yPaddingPx,dpr:i,fontSize:12,priceOffset:0,price:d.price})}}}function Ju(e){return Ku({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`macd`,label:`MACD`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}var Yu=1e8;function Xu(e){return Ku({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`volume`,label:`VOL`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair,formatTickLabel:e=>`${(e/Yu).toFixed(2)}B`,formatCrosshairLabel:e=>`${(e/Yu).toFixed(2)}B`})}function Zu(e){return Ku({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`rsi`,label:`RSI`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function Qu(e){return Ku({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`cci`,label:`CCI`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function $u(e){return Ku({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`stoch`,label:`STOCH`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function ed(e){return Ku({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`mom`,label:`MOM`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function td(e){return Ku({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`wmsr`,label:`WMSR`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function nd(e){return Ku({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`kst`,label:`KST`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function rd(e){return Ku({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`fastk`,label:`FASTK`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}var id=Symbol(`time-axis`);function ad(e){return{name:`timeAxis`,version:`1.0.0`,description:`时间轴渲染器`,debugName:`时间轴`,paneId:id,priority:G.SYSTEM_XAXIS,isSystem:!0,draw(t){let{ctx:n,data:r,range:i,scrollLeft:a,kWidth:o,kGap:s,dpr:c,paneWidth:l}=t,u=r,d=n,f=l,p=e.height;if(d.setTransform(1,0,0,1,0,0),d.scale(c,c),d.clearRect(0,0,f,p),Hu(d,{x:0,y:0,width:f,height:p,data:u,scrollLeft:a,kWidth:o,kGap:s,startIndex:i.start,endIndex:i.end,dpr:c,drawTopBorder:!1,drawBottomBorder:!1}),t.xAxisRanges)for(let e of t.xAxisRanges){let t=e.leftX-a,n=e.rightX-a-t;n<=0||(d.save(),d.globalAlpha=e.opacity,d.fillStyle=e.color,d.fillRect(t,0,n,p),d.restore())}let m=e.getCrosshair?.();if(m&&typeof m.index==`number`){let e=u[m.index];e&&Bu(d,{x:0,y:0,width:f,height:p,crosshairX:m.x,timestamp:e.timestamp,dpr:c,fontSize:12})}if(t.xAxisLabels)for(let e of t.xAxisLabels){let t=e.x-a;t>=0&&t<=f&&Wu(d,{x:0,y:0,width:f,height:p,labelX:t,timestamp:e.timestamp,dpr:c,fontSize:12,bgColor:e.style?.bgColor,textColor:e.style?.textColor})}}}}function od(e){return{name:`crosshair`,version:`1.0.0`,description:`十字线渲染器`,debugName:`十字线`,paneId:Ji,priority:G.SYSTEM_CROSSHAIR,layer:`overlay`,draw(t){let{pane:n,dpr:r,paneWidth:i,overlayCtx:a}=t,o=e.getCrosshairState();if(o.isDragging||!o.pos)return;let{x:s}=o.pos,c=n.id===o.activePaneId,l=-1;c&&o.price!==null&&(l=n.yAxis.priceToY(o.price));let u=a;if(!u)return;u.save(),u.beginPath(),u.rect(0,0,i,n.height),u.clip(),u.fillStyle=Aa.LINE;let d=ja(s,0,n.height,r);if(d&&u.fillRect(d.x,d.y,d.width,d.height),c&&l>=0){let e=Ma(0,i,Math.min(l,n.height-1/r),r);e&&u.fillRect(e.x,e.y,e.width,e.height)}u.restore()}}}var sd=new Map,cd=256;function ld(e,t){let n=`${e.font}\n${t}`,r=sd.get(n);if(r!==void 0)return r;let i=e.measureText(t).width;return sd.size>=cd&&sd.clear(),sd.set(n,i),i}function ud(e){let t={...e};return{name:`paneTitle_${e.paneId}`,version:`1.0.0`,description:`面板标题渲染器`,debugName:`面板标题`,paneId:e.paneId,priority:G.FOREGROUND,draw(e){let{ctx:n,pane:r}=e;if(r.id!==t.paneId)return;let i=t.yOffset??12;n.save(),Qc(n,Zc(12)),n.textAlign=`left`,n.textBaseline=`top`;let a=t.getTitleInfo?.();if(a){let e=12;if(n.fillStyle=ha.PRIMARY,n.fillText(a.name,e,i),e+=ld(n,a.name),a.params&&a.params.length>0){let t=`(${a.params.join(`,`)})`;n.fillStyle=ha.TERTIARY,n.fillText(t,e,i),e+=ld(n,t)+8}else e+=8;if(a.values&&a.values.length>0)for(let t of a.values){let r=`${t.label} ${t.value.toFixed(3)}`;n.fillStyle=t.color,n.fillText(r,e,i),e+=ld(n,r)+8}}else if(n.fillStyle=ha.PRIMARY,n.fillText(t.title,12,i),t.description){let e=ld(n,t.title);n.fillStyle=ha.WEAK,n.fillText(` - ${t.description}`,12+e,i)}n.restore()},setConfig(e){t={...t,...e}}}}var dd={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function fd(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,dd,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M7.904 17.563a1.2 1.2 0 0 0 2.228.308l2.09-3.093l4.907 4.907a1.067 1.067 0 0 0 1.509 0l1.047-1.047a1.067 1.067 0 0 0 0-1.509l-4.907-4.907l3.113-2.09a1.2 1.2 0 0 0-.309-2.228L4 4z`},null,-1)]])}var pd=(0,f.markRaw)({name:`tabler-pointer`,render:fd}),md={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function hd(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,md,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 19h16M4 15l4-6l4 2l4-5l4 4`},null,-1)]])}var gd=(0,f.markRaw)({name:`tabler-chart-line`,render:hd}),_d={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function vd(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,_d,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M17 7L7 17M8 7h9v9`},null,-1)]])}var yd=(0,f.markRaw)({name:`tabler-arrow-up-right`,render:vd}),bd={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function xd(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,bd,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 12h14m-6 6l6-6m-6-6l6 6`},null,-1)]])}var Sd=(0,f.markRaw)({name:`tabler-arrow-right`,render:xd}),Cd={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function wd(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Cd,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 12h14`},null,-1)]])}var Td=(0,f.markRaw)({name:`tabler-minus`,render:wd}),Ed={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Dd(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Ed,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 12v.01M7 12h10m4 0v.01`},null,-1)]])}var Od=(0,f.markRaw)({name:`tabler-separator`,render:Dd}),kd={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Ad(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,kd,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 8V6a2 2 0 0 1 2-2h2M4 16v2a2 2 0 0 0 2 2h2m8-16h2a2 2 0 0 1 2 2v2m-4 12h2a2 2 0 0 0 2-2v-2M9 12h6m-3-3v6`},null,-1)]])}var jd=(0,f.markRaw)({name:`tabler-crosshair`,render:Ad}),Md={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Nd(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Md,[...t[0]||=[(0,f.createElementVNode)(`g`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`},[(0,f.createElementVNode)(`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 0 0-18 0m9-3h.01`}),(0,f.createElementVNode)(`path`,{d:`M11 12h1v4h1`})],-1)]])}var Pd=(0,f.markRaw)({name:`tabler-info-circle`,render:Nd}),Fd={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Id(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Fd,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 8V6a2 2 0 0 1 2-2h2M4 16v2a2 2 0 0 0 2 2h2m8-16h2a2 2 0 0 1 2 2v2m-4 12h2a2 2 0 0 0 2-2v-2`},null,-1)]])}var Ld=(0,f.markRaw)({name:`tabler-maximize`,render:Id}),Rd={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function zd(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Rd,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 19v-2a2 2 0 0 1 2-2h2M15 5v2a2 2 0 0 0 2 2h2M5 15h2a2 2 0 0 1 2 2v2M5 9h2a2 2 0 0 0 2-2V5`},null,-1)]])}var Bd=(0,f.markRaw)({name:`tabler-minimize`,render:zd}),Vd={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Hd(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Vd,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 10a7 7 0 1 0 14 0a7 7 0 1 0-14 0m4 0h6m-3-3v6m11 8l-6-6`},null,-1)]])}var Ud=(0,f.markRaw)({name:`tabler-zoom-in`,render:Hd}),Wd={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Gd(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Wd,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 10a7 7 0 1 0 14 0a7 7 0 1 0-14 0m4 0h6m8 11l-6-6`},null,-1)]])}var Kd=(0,f.markRaw)({name:`tabler-zoom-out`,render:Gd}),qd={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Jd(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,qd,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 5a2 2 0 1 0 4 0a2 2 0 1 0-4 0m14 0a2 2 0 1 0 4 0a2 2 0 1 0-4 0M3 19a2 2 0 1 0 4 0a2 2 0 1 0-4 0m14 0a2 2 0 1 0 4 0a2 2 0 1 0-4 0M5 7v10M7 5h10M7 19h10m2-12v10`},null,-1)]])}var Yd=(0,f.markRaw)({name:`tabler-shape`,render:Jd}),Xd={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Zd(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Xd,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 7a2 2 0 1 0 4 0a2 2 0 1 0-4 0m11 8a2 2 0 1 0 4 0a2 2 0 1 0-4 0m1-9a3 3 0 1 0 6 0a3 3 0 1 0-6 0M3 18a3 3 0 1 0 6 0a3 3 0 1 0-6 0m6-1l5-1.5m-7.5-7l7.81 5.37M7 7l8-1`},null,-1)]])}var Qd=(0,f.markRaw)({name:`tabler-chart-dots-3`,render:Zd}),$d={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function ef(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,$d,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`m18 10l-6-6l-6 6zm0 4l-6 6l-6-6z`},null,-1)]])}var tf=(0,f.markRaw)({name:`tabler-caret-up-down`,render:ef}),nf={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function rf(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,nf,[...t[0]||=[(0,f.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8 4H5v16h3m8-16h3v16h-3`},null,-1)]])}var af=(0,f.markRaw)({name:`tabler-brackets`,render:rf}),of={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function sf(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,of,[...t[0]||=[(0,f.createElementVNode)(`g`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`},[(0,f.createElementVNode)(`path`,{d:`M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 0 0-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 0 0-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 0 0-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 0 0-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 0 0 1.066-2.573c-.94-1.543.826-3.31 2.37-2.37c1 .608 2.296.07 2.572-1.065`}),(0,f.createElementVNode)(`path`,{d:`M9 12a3 3 0 1 0 6 0a3 3 0 0 0-6 0`})],-1)]])}var cf=(0,f.markRaw)({name:`tabler-settings`,render:sf});function lf(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent.toLowerCase();return/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini|mobile|touch/.test(e)}var uf=[{key:`showVolumePriceMarkers`,label:`显示量价关系标记`,type:`boolean`,default:!1,group:`main`},{key:`logarithmicScale`,label:`对数价格轴`,type:`boolean`,default:!1,group:`main`},{key:`enableWebGLRendering`,label:`启用 WebGL 硬件加速渲染`,type:`boolean`,default:!0,group:`main`},{key:`disableMainPaneVerticalScroll`,label:`主图纵轴刻度自适应调整`,type:`boolean`,default:!0,group:`experimental`},{key:`performanceTest10kKlines`,label:`万条K线性能测试`,type:`boolean`,default:!1,group:`experimental`}],df=`kline-chart-settings`,ff={class:`left-toolbar`,"aria-label":`图表工具栏`},pf={class:`left-toolbar__group`},mf=[`title`,`aria-label`,`onClick`],hf=[`onClick`],gf=[`title`,`aria-label`,`onClick`],_f={class:`left-toolbar__group`},vf={class:`left-toolbar__group`},yf=[`title`,`aria-label`],bf={class:`left-toolbar__group`},xf={class:`settings-body`},Sf={class:`settings-label`},Cf=[`onUpdate:modelValue`],wf={class:`settings-label`},Tf=[`onUpdate:modelValue`],Ef=wo((0,f.defineComponent)({__name:`LeftToolbar`,props:{isFullscreen:{type:Boolean}},emits:[`selectTool`,`toggleFullscreen`,`zoomIn`,`zoomOut`,`settingsChange`],setup(e,{expose:t,emit:n}){let r=n,i=[{id:`cursor`,title:`光标`,icon:pd},{id:`lines`,title:`线条`,icon:gd,children:[{id:`trend-line`,title:`线段`,icon:gd},{id:`ray`,title:`射线`,icon:yd},{id:`h-line`,title:`水平线`,icon:Td},{id:`h-ray`,title:`水平射线`,icon:Sd},{id:`v-line`,title:`垂直线`,icon:Od},{id:`crosshair-line`,title:`十字线`,icon:jd},{id:`info-line`,title:`信息线`,icon:Pd}]},{id:`channels`,title:`通道`,icon:Yd,children:[{id:`parallel-channel`,title:`平行通道`,icon:Yd},{id:`regression-channel`,title:`回归趋势`,icon:Qd},{id:`flat-line`,title:`平滑顶底`,icon:tf},{id:`disjoint-channel`,title:`不相交通道`,icon:af}]}],a=(0,f.computed)(()=>uf.filter(e=>e.group===`main`)),o=(0,f.computed)(()=>uf.filter(e=>e.group===`experimental`)),s=(0,f.ref)(`cursor`),c=(0,f.ref)(null),l=(0,f.ref)(!1),u=Mo();function d(){let e=lf(),t=t=>t.key===`enableWebGLRendering`&&e?!1:t.default;try{let e=localStorage.getItem(df);if(e){let n=JSON.parse(e),r={};return uf.forEach(e=>{r[e.key]=n[e.key]??t(e)}),r}}catch{}let n={};return uf.forEach(e=>{n[e.key]=t(e)}),n}function p(e){try{localStorage.setItem(df,JSON.stringify(e))}catch{}}let m=(0,f.ref)(d()),h=(0,f.ref)({...m.value});function g(e){return s.value===e.id?!0:e.children?e.children.some(e=>e.id===s.value):!1}function _(e){if(e.children?.length){if(!e.children.some(e=>e.id===s.value)){let t=e.children[0];s.value=t.id,r(`selectTool`,t.id)}y(e.id);return}s.value=e.id,r(`selectTool`,e.id),c.value=null}function v(e){s.value=e.id,r(`selectTool`,e.id),c.value=null}function y(e){c.value=c.value===e?null:e}function b(){h.value={...m.value},l.value=!0}function x(){l.value=!1}function S(){let e=lf(),t={};uf.forEach(n=>{n.key===`enableWebGLRendering`&&e?t[n.key]=!1:t[n.key]=n.default}),h.value=t}function C(){m.value={...h.value},p(m.value),r(`settingsChange`,{...m.value}),x()}function w(){return{...m.value}}t({getSettings:w});function T(e){e.target.closest(`.tool-item`)||(c.value=null)}return(0,f.onMounted)(()=>{document.addEventListener(`click`,T,!0),r(`settingsChange`,{...m.value})}),(0,f.onUnmounted)(()=>{document.removeEventListener(`click`,T,!0)}),(t,n)=>((0,f.openBlock)(),(0,f.createElementBlock)(f.Fragment,null,[(0,f.createElementVNode)(`nav`,ff,[(0,f.createElementVNode)(`div`,pf,[((0,f.openBlock)(),(0,f.createElementBlock)(f.Fragment,null,(0,f.renderList)(i,e=>(0,f.createElementVNode)(`div`,{key:e.id,class:`tool-item`},[(0,f.createElementVNode)(`button`,{type:`button`,class:(0,f.normalizeClass)([`left-toolbar__button`,{active:g(e)}]),title:e.title,"aria-label":e.title,onClick:t=>_(e),onPointerdown:n[0]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointermove:n[1]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointerup:n[2]||=(0,f.withModifiers)(()=>{},[`stop`])},[((0,f.openBlock)(),(0,f.createBlock)((0,f.resolveDynamicComponent)(e.icon),{class:`tool-icon`,"aria-hidden":`true`})),e.children&&e.children.length?((0,f.openBlock)(),(0,f.createElementBlock)(`span`,{key:0,class:(0,f.normalizeClass)([`corner-indicator`,{open:c.value===e.id}]),onClick:(0,f.withModifiers)(t=>y(e.id),[`stop`]),"aria-label":`展开子菜单`},null,10,hf)):(0,f.createCommentVNode)(``,!0)],42,mf),(0,f.createVNode)(f.Transition,{name:`dropdown`},{default:(0,f.withCtx)(()=>[c.value===e.id&&e.children&&e.children.length?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:0,class:`tool-dropdown`,onPointerdown:n[3]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointermove:n[4]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointerup:n[5]||=(0,f.withModifiers)(()=>{},[`stop`])},[((0,f.openBlock)(!0),(0,f.createElementBlock)(f.Fragment,null,(0,f.renderList)(e.children,e=>((0,f.openBlock)(),(0,f.createElementBlock)(`button`,{key:e.id,type:`button`,class:(0,f.normalizeClass)([`left-toolbar__button`,{active:s.value===e.id}]),title:e.title,"aria-label":e.title,onClick:t=>v(e)},[((0,f.openBlock)(),(0,f.createBlock)((0,f.resolveDynamicComponent)(e.icon),{class:`tool-icon`,"aria-hidden":`true`}))],10,gf))),128))],32)):(0,f.createCommentVNode)(``,!0)]),_:2},1024)])),64))]),n[22]||=(0,f.createElementVNode)(`span`,{class:`left-toolbar__divider`},null,-1),(0,f.createElementVNode)(`div`,_f,[(0,f.createElementVNode)(`button`,{type:`button`,class:`left-toolbar__button`,title:`放大`,"aria-label":`放大`,onClick:n[6]||=e=>t.$emit(`zoomIn`),onPointerdown:n[7]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointermove:n[8]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointerup:n[9]||=(0,f.withModifiers)(()=>{},[`stop`])},[(0,f.createVNode)((0,f.unref)(Ud),{class:`tool-icon`,"aria-hidden":`true`})],32),(0,f.createElementVNode)(`button`,{type:`button`,class:`left-toolbar__button`,title:`缩小`,"aria-label":`缩小`,onClick:n[10]||=e=>t.$emit(`zoomOut`),onPointerdown:n[11]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointermove:n[12]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointerup:n[13]||=(0,f.withModifiers)(()=>{},[`stop`])},[(0,f.createVNode)((0,f.unref)(Kd),{class:`tool-icon`,"aria-hidden":`true`})],32)]),n[23]||=(0,f.createElementVNode)(`span`,{class:`left-toolbar__divider`},null,-1),(0,f.createElementVNode)(`div`,vf,[(0,f.createElementVNode)(`button`,{type:`button`,class:`left-toolbar__button`,title:e.isFullscreen?`退出全屏`:`全屏显示`,"aria-label":e.isFullscreen?`退出全屏`:`全屏显示`,onClick:n[14]||=e=>t.$emit(`toggleFullscreen`),onPointerdown:n[15]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointermove:n[16]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointerup:n[17]||=(0,f.withModifiers)(()=>{},[`stop`])},[e.isFullscreen?((0,f.openBlock)(),(0,f.createBlock)((0,f.unref)(Bd),{key:0,class:`tool-icon`,"aria-hidden":`true`})):((0,f.openBlock)(),(0,f.createBlock)((0,f.unref)(Ld),{key:1,class:`tool-icon`,"aria-hidden":`true`}))],40,yf)]),n[24]||=(0,f.createElementVNode)(`span`,{class:`left-toolbar__divider`},null,-1),(0,f.createElementVNode)(`div`,bf,[(0,f.createElementVNode)(`button`,{type:`button`,class:`left-toolbar__button`,title:`设置`,"aria-label":`设置`,onClick:b,onPointerdown:n[18]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointermove:n[19]||=(0,f.withModifiers)(()=>{},[`stop`]),onPointerup:n[20]||=(0,f.withModifiers)(()=>{},[`stop`])},[(0,f.createVNode)((0,f.unref)(cf),{class:`tool-icon`,"aria-hidden":`true`})],32)])]),((0,f.openBlock)(),(0,f.createBlock)(f.Teleport,{to:(0,f.unref)(u)},[(0,f.createVNode)(f.Transition,{name:`overlay`},{default:(0,f.withCtx)(()=>[l.value?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:0,class:`settings-overlay`,onClick:x},[(0,f.createVNode)(f.Transition,{name:`modal`},{default:(0,f.withCtx)(()=>[(0,f.createElementVNode)(`div`,{class:`settings-modal`,onClick:n[21]||=(0,f.withModifiers)(()=>{},[`stop`])},[(0,f.createElementVNode)(`div`,{class:`settings-header`},[n[26]||=(0,f.createElementVNode)(`div`,{class:`header-left`},[(0,f.createElementVNode)(`span`,{class:`settings-title`},`图表设置`),(0,f.createElementVNode)(`span`,{class:`settings-subtitle`},`个性化配置`)],-1),(0,f.createElementVNode)(`div`,{class:`header-right`},[(0,f.createElementVNode)(`button`,{class:`settings-close`,onClick:x},[...n[25]||=[(0,f.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`},[(0,f.createElementVNode)(`path`,{d:`M18 6L6 18M6 6l12 12`})],-1)]])])]),(0,f.createElementVNode)(`div`,xf,[a.value.length>0?((0,f.openBlock)(),(0,f.createElementBlock)(f.Fragment,{key:0},[n[27]||=(0,f.createElementVNode)(`div`,{class:`settings-section-divider`},[(0,f.createElementVNode)(`span`,{class:`settings-section-label`},`主图设置`)],-1),((0,f.openBlock)(!0),(0,f.createElementBlock)(f.Fragment,null,(0,f.renderList)(a.value,e=>((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:e.key,class:`settings-item`},[(0,f.createElementVNode)(`label`,Sf,[(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)(e.label),1),(0,f.withDirectives)((0,f.createElementVNode)(`input`,{type:`checkbox`,class:`settings-checkbox`,"onUpdate:modelValue":t=>h.value[e.key]=t},null,8,Cf),[[f.vModelCheckbox,h.value[e.key]]])])]))),128))],64)):(0,f.createCommentVNode)(``,!0),o.value.length>0?((0,f.openBlock)(),(0,f.createElementBlock)(f.Fragment,{key:1},[n[28]||=(0,f.createElementVNode)(`div`,{class:`settings-section-divider`},[(0,f.createElementVNode)(`span`,{class:`settings-section-label`},`实验性 / 临时`)],-1),((0,f.openBlock)(!0),(0,f.createElementBlock)(f.Fragment,null,(0,f.renderList)(o.value,e=>((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:e.key,class:`settings-item experimental`},[(0,f.createElementVNode)(`label`,wf,[(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)(e.label),1),(0,f.withDirectives)((0,f.createElementVNode)(`input`,{type:`checkbox`,class:`settings-checkbox`,"onUpdate:modelValue":t=>h.value[e.key]=t},null,8,Tf),[[f.vModelCheckbox,h.value[e.key]]])])]))),128))],64)):(0,f.createCommentVNode)(``,!0)]),(0,f.createElementVNode)(`div`,{class:`settings-footer`},[(0,f.createElementVNode)(`button`,{class:`settings-btn reset`,onClick:S},[...n[29]||=[(0,f.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`},[(0,f.createElementVNode)(`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}),(0,f.createElementVNode)(`path`,{d:`M3 3v5h5`})],-1),(0,f.createTextVNode)(` 重置 `,-1)]]),(0,f.createElementVNode)(`div`,{class:`footer-right`},[(0,f.createElementVNode)(`button`,{class:`settings-btn cancel`,onClick:x},`取消`),(0,f.createElementVNode)(`button`,{class:`settings-btn confirm`,onClick:C},[...n[30]||=[(0,f.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.5`},[(0,f.createElementVNode)(`path`,{d:`M20 6L9 17l-5-5`})],-1),(0,f.createTextVNode)(` 确定 `,-1)]])])])])]),_:1})])):(0,f.createCommentVNode)(``,!0)]),_:1})],8,[`to`]))],64))}}),[[`__scopeId`,`data-v-3bc8355a`]]),Df={class:`chart-wrapper`},Of={class:`pane-separator-layer`,"aria-hidden":`true`},kf=4,Af=wo((0,f.defineComponent)({__name:`KLineChart`,props:{semanticConfig:{},yPaddingPx:{default:0},minKWidth:{default:1},maxKWidth:{default:50},rightAxisWidth:{default:0},bottomAxisHeight:{default:24},priceLabelWidth:{default:60},zoomLevels:{default:20},initialZoomLevel:{default:3},isFullscreen:{type:Boolean,default:!1}},emits:[`zoomLevelChange`,`toggleFullscreen`],setup(e,{expose:t,emit:n}){let r=e,i=n,a=(0,f.ref)(null),o=(0,f.ref)(null),s=(0,f.ref)(null),c=(0,f.ref)(null),l=(0,f.ref)(null),u=(0,f.ref)(null),d=(0,f.ref)(null),p=(0,f.shallowRef)(null),m=(0,f.shallowRef)(null),h=Us({initialZoomLevel:r.initialZoomLevel??1,minKWidth:r.minKWidth,maxKWidth:r.maxKWidth,zoomLevels:r.zoomLevels,rightAxisWidth:r.rightAxisWidth,priceLabelWidth:r.priceLabelWidth});h.actions.setZoomState(h.state.zoomLevel,iu(h.state.zoomLevel,{minKWidth:r.minKWidth,maxKWidth:r.maxKWidth,zoomLevelCount:r.zoomLevels,dpr:h.state.viewportDpr}),au(iu(h.state.zoomLevel,{minKWidth:r.minKWidth,maxKWidth:r.maxKWidth,zoomLevelCount:r.zoomLevels,dpr:h.state.viewportDpr}),h.state.viewportDpr)),(0,f.computed)(()=>h.state.dataLength),(0,f.computed)(()=>h.state.viewportDpr);let g=(0,f.computed)(()=>h.state.zoomLevel),_=(0,f.computed)(()=>h.state.kWidth),v=(0,f.computed)(()=>h.state.kGap),y=(0,f.computed)(()=>h.state.paneRatios),b=(0,f.computed)(()=>h.state.selectedDrawingId),x=(0,f.computed)(()=>h.state.dataVersion);function S(){p.value?.scheduleDraw()}function C(e){if(p.value?.updateSettings(e),e.performanceTest10kKlines){let e=w();console.time(`updateData-10k`),p.value?.updateData(e),console.timeEnd(`updateData-10k`),h.actions.setDataLength(e.length),h.actions.bumpDataVersion()}else m.value&&p.value?.getData()?.length===1e4&&m.value.applyConfig(r.semanticConfig)}function w(){let e=[],t=new Date(`2020-01-01`).getTime(),n=3e3;for(let r=0;r<1e4;r++){let i=t+r*864e5,a=(Math.random()-.5)*2*.02+1e-4,o=n,s=o*(1+a),c=Math.max(o,s)*(1+Math.random()*.01),l=Math.min(o,s)*(1-Math.random()*.01),u=Math.floor(1e6+Math.random()*5e6);e.push({timestamp:i,open:parseFloat(o.toFixed(2)),high:parseFloat(c.toFixed(2)),low:parseFloat(l.toFixed(2)),close:parseFloat(s.toFixed(2)),volume:u}),n=s}return e}function T(e,t,n){let r=e.getBoundingClientRect();return{width:Math.max(t,Math.round(r.width)),height:Math.max(n,Math.round(r.height))}}function E(e){if(!e)return;let t=T(e,180,80);p.value?.interaction.setTooltipSize(t)}function D(e){e&&(ee.value=T(e,120,60))}let O=(0,f.ref)({x:0,y:0}),k=(0,f.ref)(!1),A=(0,f.shallowRef)({crosshairPos:null,crosshairIndex:null,crosshairPrice:null,hoveredIndex:null,activePaneId:null,tooltipPos:{x:0,y:0},tooltipAnchorPlacement:`right-bottom`,hoveredMarkerData:null,hoveredCustomMarker:null,isDragging:!1,isResizingPaneBoundary:!1,isHoveringPaneBoundary:!1,hoveredPaneBoundaryId:null,isHoveringRightAxis:!1}),j=(0,f.shallowRef)(null),M=(0,f.computed)(()=>{let e=b.value;return e?h.state.drawings.find(t=>t.id===e)??null:null}),N=(0,f.ref)([]),ee=(0,f.ref)({width:220,height:120}),te=(0,f.computed)(()=>{let e=c.value,t=l.value;return!e||!t?{x:0,y:0}:{x:e.offsetLeft,y:e.offsetTop}}),P=(0,f.computed)(()=>A.value.hoveredMarkerData),ne=(0,f.computed)(()=>A.value.hoveredCustomMarker),re=(0,f.computed)(()=>A.value.isDragging),ie=(0,f.computed)(()=>A.value.isResizingPaneBoundary),ae=(0,f.computed)(()=>A.value.isHoveringPaneBoundary),oe=(0,f.computed)(()=>A.value.hoveredPaneBoundaryId),se=(0,f.computed)(()=>A.value.isHoveringRightAxis),ce=(0,f.computed)(()=>A.value.hoveredIndex),le=(0,f.computed)(()=>A.value.crosshairIndex),ue=(0,f.computed)(()=>{let e=A.value.hoveredIndex;if(typeof e!=`number`)return null;x.value;let t=p.value?.getData();return t&&e>=0&&e<t.length?t[e]:null}),de=(0,f.computed)(()=>A.value.hoveredIndex),fe=(0,f.computed)(()=>A.value.tooltipPos),pe=(0,f.computed)(()=>({x:fe.value.x+te.value.x,y:fe.value.y+te.value.y})),me=(0,f.computed)(()=>({left:`${pe.value.x}px`,top:`${pe.value.y}px`})),he=(0,f.computed)(()=>({x:O.value.x+te.value.x,y:O.value.y+te.value.y})),ge=(0,f.computed)(()=>({left:`${he.value.x}px`,top:`${he.value.y}px`})),_e=(0,f.computed)(()=>A.value.tooltipAnchorPlacement),ve=(0,f.computed)(()=>{let e=p.value?.getViewport(),t=c.value,n=e?.plotWidth??(t?t.clientWidth:0);return O.value.x+12+ee.value.width+12>n?`left-bottom`:`right-bottom`}),ye=(0,f.computed)(()=>(x.value,p.value?.getData()??[]));function be(e){j.value?.setTool(e)}function xe(e){let t=M.value;!t||!j.value||(j.value.updateDrawingStyle(t.id,e),h.actions.bumpDrawingVersion())}function Se(){let e=M.value;!e||!j.value||(j.value.removeDrawing(e.id),h.actions.setSelectedDrawingId(null),h.actions.bumpDrawingVersion(),h.actions.setDrawings(j.value.getDrawings()))}function Ce(e){let t=c.value;if(t){if(j.value?.onPointerDown(e,t)){h.actions.setDrawings(j.value.getDrawings()),h.actions.bumpDrawingVersion();return}p.value?.interaction.onPointerDown(e)}}function we(e){let t=c.value;if(t){let n=t.getBoundingClientRect();if(O.value={x:e.clientX-n.left,y:e.clientY-n.top},j.value?.onPointerMove(e,t)){h.actions.setDrawings(j.value.getDrawings());return}}p.value?.interaction.onPointerMove(e)}function Te(e){let t=c.value;if(t&&j.value?.onPointerUp(e,t)){h.actions.setDrawings(j.value.getDrawings());return}p.value?.interaction.onPointerUp(e)}function Ee(e){p.value?.interaction.onPointerLeave(e)}function De(e){p.value?.interaction.onRightAxisPointerDown(e)}function Oe(e){p.value?.interaction.onRightAxisPointerMove(e)}function ke(e){p.value?.interaction.onRightAxisPointerUp(e)}function Ae(e){p.value?.interaction.onRightAxisPointerLeave(e)}function je(){p.value?.interaction.onScroll()}let F=(0,f.ref)([]),Me=(0,f.ref)({}),I=(0,f.ref)([]),Ne={VOLUME:{defaultParams:{},getTitleInfo:()=>({name:`VOL`,params:[],values:[]})},MACD:{defaultParams:{fastPeriod:12,slowPeriod:26,signalPeriod:9},getTitleInfo:(e,t,n)=>t===null?null:ll(e,t,n.fastPeriod??12,n.slowPeriod??26,n.signalPeriod??9)},RSI:{defaultParams:{period1:6,period2:12,period3:24},getTitleInfo:(e,t,n)=>t===null?null:fl(t,n.period1??6,n.period2??12,n.period3??24,p.value.plugin,`sub_RSI`)},CCI:{defaultParams:{period:14,showCCI:!0},getTitleInfo:(e,t,n)=>t===null?null:hl(t,n.period??14,p.value.plugin,`sub_CCI`)},STOCH:{defaultParams:{n:9,m:3,showK:!0,showD:!0},getTitleInfo:(e,t,n)=>t===null?null:vl(t,n.n??9,n.m??3,p.value.plugin,`sub_STOCH`)},MOM:{defaultParams:{period:10,showMOM:!0},getTitleInfo:(e,t,n)=>t===null?null:xl(t,n.period??10,p.value.plugin,`sub_MOM`)},WMSR:{defaultParams:{period:14,showWMSR:!0},getTitleInfo:(e,t,n)=>t===null?null:wl(t,n.period??14,p.value.plugin,`sub_WMSR`)},KST:{defaultParams:{roc1:10,roc2:15,roc3:20,roc4:30,signalPeriod:9,showKST:!0,showSignal:!0},getTitleInfo:(e,t,n)=>t===null?null:Dl(t,n.roc1??10,n.roc2??15,n.roc3??20,n.roc4??30,n.signalPeriod??9,p.value.plugin,`sub_KST`)},FASTK:{defaultParams:{period:9,showFASTK:!0},getTitleInfo:(e,t,n)=>t===null?null:Al(t,n.period??9,p.value.plugin,`sub_FASTK`)}},Pe=Object.keys(Ne);function Fe(){let e=y.value.main??3;return I.value.length===0?[{id:`main`,ratio:e,visible:!0,role:`price`}]:[{id:`main`,ratio:e,visible:!0,role:`price`},...I.value.map(e=>({id:e.id,ratio:y.value[e.id]??1,visible:!0,role:`indicator`}))]}function L(e){return{...Ne[e].defaultParams}}function Ie(e=`VOLUME`,t){if(I.value.length>=kf)return!1;let n=`sub_${e}`;if(I.value.some(e=>e.id===n))return!0;if(!p.value?.createSubPane(e,t??L(e)))return!1;e===`MACD`&&p.value?.getIndicatorScheduler().updateMACDConfig(t??L(e),n),e===`RSI`&&p.value?.getIndicatorScheduler().updateRSIConfig(t??L(e),n),e===`CCI`&&p.value?.getIndicatorScheduler().updateCCIConfig(t??L(e),n),e===`STOCH`&&p.value?.getIndicatorScheduler().updateSTOCHConfig(t??L(e),n),e===`MOM`&&p.value?.getIndicatorScheduler().updateMOMConfig(t??L(e),n),e===`WMSR`&&p.value?.getIndicatorScheduler().updateWMSRConfig(t??L(e),n),e===`KST`&&p.value?.getIndicatorScheduler().updateKSTConfig(t??L(e),n),e===`FASTK`&&p.value?.getIndicatorScheduler().updateFASTKConfig(t??L(e),n);let r=ud({paneId:n,title:e,getTitleInfo:()=>He(n)});return p.value?.useRenderer(r),I.value.push({id:n,indicatorId:e,rendererName:`${e.toLowerCase()}_${n}`,paneTitleRendererName:r.name,params:t??L(e)}),F.value.includes(e)||F.value.push(e),S(),!0}function Le(e){let t=I.value.findIndex(t=>t.id===e);if(t===-1)return;let n=I.value[t];n&&(p.value?.removeRenderer(n.paneTitleRendererName),p.value?.removeSubPane(n.indicatorId),I.value.splice(t,1),I.value.some(e=>e.indicatorId===n.indicatorId)||(F.value=F.value.filter(e=>e!==n.indicatorId)))}function Re(){for(let e of I.value)p.value?.removeRenderer(e.paneTitleRendererName);p.value?.clearSubPanes(),I.value=[],F.value=F.value.filter(e=>!Pe.includes(e))}function ze(){let e=r.semanticConfig,t=p.value;if(!t)return;let n=e.indicators?.main;if(n)for(let e of n)e.enabled&&(F.value.includes(e.type)||F.value.push(e.type),e.params&&(Me.value[e.type]=e.params),t.enableMainIndicator(e.type,e.params))}(0,f.watch)([F,Me],([e])=>{let t=p.value;t&&(t.updateRendererConfig(`mainIndicatorLegend`,{indicators:{MA:{enabled:e.includes(`MA`),params:Me.value.MA||{}},BOLL:{enabled:e.includes(`BOLL`),params:Me.value.BOLL||{}},EXPMA:{enabled:e.includes(`EXPMA`),params:Me.value.EXPMA||{}},ENE:{enabled:e.includes(`ENE`),params:Me.value.ENE||{}}}}),S())},{deep:!0});function Be(){let e=p.value?.getSubPaneIndicators()??[];I.value=[];for(let t of e){let e=`sub_${t}`,n=ud({paneId:e,title:t,getTitleInfo:()=>He(e)});p.value?.useRenderer(n),I.value.push({id:e,indicatorId:t,rendererName:`${t.toLowerCase()}_${e}`,paneTitleRendererName:n.name,params:L(t)}),F.value.includes(t)||F.value.push(t)}S()}function R(e,t){let n=I.value.find(t=>t.id===e);if(!n)return;let r=n.indicatorId;p.value?.removeRenderer(n.paneTitleRendererName),p.value?.removeSubPane(r),p.value?.createSubPane(t,L(t));let i=`sub_${t}`,a=ud({paneId:i,title:t,getTitleInfo:()=>He(i)});p.value?.useRenderer(a);let o=I.value.findIndex(t=>t.id===e);o!==-1&&(I.value[o]={id:i,indicatorId:t,rendererName:`${t.toLowerCase()}_${i}`,paneTitleRendererName:a.name,params:L(t)}),F.value=F.value.filter(e=>e!==r),F.value.includes(t)||F.value.push(t)}let Ve=new Map;function He(e){let t=I.value.find(t=>t.id===e);if(!t)return null;let n=p.value?.getData();if(!n||n.length===0)return null;let r=le.value,i=n.length,a=Ve.get(e);if(a&&a.idx===r&&a.dataLen===i)return a.result;let o=Ne[t.indicatorId],s=t.params,c=o.getTitleInfo(n,r,s);return Ve.set(e,{idx:r,dataLen:i,result:c}),c}function Ue(e,t){let n=p.value;if(n){if(e===`MA`||e===`BOLL`||e===`EXPMA`||e===`ENE`){n.toggleMainIndicator(e,t),t?F.value.includes(e)||F.value.push(e):F.value=F.value.filter(t=>t!==e);return}if(Pe.includes(e)){if(t){if(F.value.includes(e)||F.value.push(e),I.value.find(t=>t.indicatorId===e))return;if(!Ie(e)){let t=I.value[I.value.length-1];t&&R(t.id,e)}}else F.value=F.value.filter(t=>t!==e),I.value.filter(t=>t.indicatorId===e).forEach(e=>Le(e.id));S()}}}function We(e,t){if(Me.value[e]=t,e===`MA`||e===`BOLL`||e===`EXPMA`||e===`ENE`){p.value?.updateMainIndicatorParams(e,t),S();return}if(e===`MACD`){p.value?.getIndicatorScheduler().updateMACDConfig(t,`sub_MACD`),I.value.filter(e=>e.indicatorId===`MACD`).forEach(e=>{e.params={...t}}),S();return}if(e===`RSI`){p.value?.getIndicatorScheduler().updateRSIConfig(t,`sub_RSI`),I.value.filter(e=>e.indicatorId===`RSI`).forEach(e=>{e.params={...t}}),S();return}if(e===`CCI`){p.value?.getIndicatorScheduler().updateCCIConfig(t,`sub_CCI`),I.value.filter(e=>e.indicatorId===`CCI`).forEach(e=>{e.params={...t}}),S();return}if(e===`STOCH`){p.value?.getIndicatorScheduler().updateSTOCHConfig(t,`sub_STOCH`),I.value.filter(e=>e.indicatorId===`STOCH`).forEach(e=>{e.params={...t}}),S();return}if(e===`MOM`){p.value?.getIndicatorScheduler().updateMOMConfig(t,`sub_MOM`),I.value.filter(e=>e.indicatorId===`MOM`).forEach(e=>{e.params={...t}}),S();return}if(e===`WMSR`){p.value?.getIndicatorScheduler().updateWMSRConfig(t,`sub_WMSR`),I.value.filter(e=>e.indicatorId===`WMSR`).forEach(e=>{e.params={...t}}),S();return}if(e===`KST`){p.value?.getIndicatorScheduler().updateKSTConfig(t,`sub_KST`),I.value.filter(e=>e.indicatorId===`KST`).forEach(e=>{e.params={...t}}),S();return}if(e===`FASTK`){p.value?.getIndicatorScheduler().updateFASTKConfig(t,`sub_FASTK`),I.value.filter(e=>e.indicatorId===`FASTK`).forEach(e=>{e.params={...t}}),S();return}Pe.includes(e)&&I.value.filter(t=>t.indicatorId===e).forEach(e=>{e.params={...t},p.value?.updateRendererConfig(e.rendererName,t)}),S()}function Ge(e){if(!e.length||I.value.length<=1)return;let t=e.filter(e=>Pe.includes(e));if(!t.length)return;let n=new Map(I.value.map(e=>[e.indicatorId,e])),r=[];for(let e of t){let t=n.get(e);t&&(r.push(t),n.delete(e))}if(r.length===0)return;for(let e of I.value)n.has(e.indicatorId)&&(r.push(e),n.delete(e.indicatorId));let i=I.value.map(e=>e.id),a=r.map(e=>e.id);if(i.join(`|`)===a.join(`|`))return;I.value=r;let o=F.value.filter(e=>!Pe.includes(e)),s=I.value.map(e=>e.indicatorId);F.value=[...o,...s];let c=p.value;c&&c.updatePaneLayout(Fe())}let Ke=(0,f.computed)(()=>r.rightAxisWidth+r.priceLabelWidth),qe=h.computed.totalWidth;function Je(){let e=c.value,t=p.value;if(!e||!t)return;let n=t.getData()?.length??0;if(n===0)return;let r=t.getCurrentDpr(),{unitPx:i,startXPx:a}=na(_.value,v.value,r),o=(a+n*i)/r,s=Math.max(0,e.scrollWidth-e.clientWidth),l=Math.min(s,Math.max(0,o-e.clientWidth));e.scrollLeft=Math.round(l*r)/r,S()}function Ye(e,t){let n=p.value,a=c.value;if(!n||!a)return;let o=n.getCurrentDpr(),s=su(e,t??(n.getViewport()?.plotWidth??a.clientWidth)/2,a.scrollLeft,g.value,_.value,v.value,{minKWidth:r.minKWidth,maxKWidth:r.maxKWidth,zoomLevelCount:r.zoomLevels,dpr:o});s&&(h.actions.setZoomState(s.targetLevel,s.newKWidth,s.newKGap),n.interaction.clearHover(),(0,f.nextTick)(()=>{let e=c.value;if(!e)return;let t=Math.max(0,e.scrollWidth-e.clientWidth),r=Math.min(Math.max(0,s.newScrollLeft),t);e.scrollLeft=Math.round(r*o)/o,n.applyRenderState(s.newKWidth,s.newKGap,s.targetLevel),i(`zoomLevelChange`,s.targetLevel,s.newKWidth)}))}return t({scheduleRender:S,scrollToRight:Je,addSubPane:Ie,removeSubPane:Le,switchSubIndicator:R,clearAllSubPanes:Re,get plugin(){return p.value?.plugin},zoomToLevel:Ye,zoomIn:e=>Ye(g.value+1,e),zoomOut:e=>Ye(g.value-1,e),getZoomLevel:()=>g.value,getZoomLevelCount:()=>p.value?.getZoomLevelCount()??10}),(0,f.onMounted)(()=>{k.value=!1;let e=c.value,t=o.value,n=s.value,l=a.value;if(!e||!t||!n||!l)return;let u=t=>{t.preventDefault();let n=p.value;if(!n)return;let a=e.getBoundingClientRect(),o=t.clientX-a.left,s=e.scrollLeft,l=n.getCurrentDpr(),u=ou(t.deltaY>0?-1:1,o,s,g.value,_.value,v.value,{minKWidth:r.minKWidth,maxKWidth:r.maxKWidth,zoomLevelCount:r.zoomLevels,dpr:l});u&&(h.actions.setZoomState(u.targetLevel,u.newKWidth,u.newKGap),n.interaction.clearHover(),(0,f.nextTick)(()=>{let e=c.value;if(!e)return;let t=Math.max(0,e.scrollWidth-e.clientWidth),r=Math.min(Math.max(0,u.newScrollLeft),t);e.scrollLeft=Math.round(r*l)/l,n.applyRenderState(u.newKWidth,u.newKGap,u.targetLevel),i(`zoomLevelChange`,u.targetLevel,u.newKWidth)}))};e.addEventListener(`wheel`,u,{passive:!1});let y=new nu({container:e,canvasLayer:t,rightAxisLayer:n,xAxisCanvas:l},{yPaddingPx:r.yPaddingPx,rightAxisWidth:r.rightAxisWidth,bottomAxisHeight:r.bottomAxisHeight,priceLabelWidth:r.priceLabelWidth,minKWidth:r.minKWidth,maxKWidth:r.maxKWidth,panes:[{id:`main`,ratio:1}],paneGap:0,zoomLevels:r.zoomLevels,initialZoomLevel:r.initialZoomLevel});y.useRenderer(ku()),y.useRenderer(Pu()),y.useRenderer(Wc()),y.setRendererEnabled(`ma`,!1),y.useRenderer(Kc()),y.setRendererEnabled(`boll`,!1),y.useRenderer(Jc()),y.setRendererEnabled(`expma`,!1),y.useRenderer(Yc()),y.setRendererEnabled(`ene`,!1),y.useRenderer(fu()),y.useRenderer(Au()),y.useRenderer(Ra());let b=r.rightAxisWidth+r.priceLabelWidth,x=()=>{let e=y.interaction.crosshairPos,t=y.interaction.crosshairPrice,n=y.interaction.activePaneId;return e&&t!==null?{y:e.y,price:t,activePaneId:n}:null};y.useRenderer(qu({axisWidth:b,yPaddingPx:r.yPaddingPx,getCrosshair:x})),y.useRenderer(nl({yPaddingPx:r.yPaddingPx}));let S=[{create:Xu,paneId:`sub_VOLUME`},{create:Ju,paneId:`sub_MACD`},{create:Zu,paneId:`sub_RSI`},{create:Qu,paneId:`sub_CCI`},{create:$u,paneId:`sub_STOCH`},{create:ed,paneId:`sub_MOM`},{create:td,paneId:`sub_WMSR`},{create:nd,paneId:`sub_KST`},{create:rd,paneId:`sub_FASTK`}];for(let e of S)y.useRenderer(e.create({axisWidth:b,paneId:e.paneId,yPaddingPx:r.yPaddingPx,getCrosshair:x}));y.useRenderer(od({getCrosshairState:()=>({pos:y.interaction.crosshairPos,activePaneId:y.interaction.activePaneId,isDragging:y.interaction.isDraggingState(),price:y.interaction.crosshairPrice})})),y.useRenderer(ad({height:r.bottomAxisHeight,getCrosshair:()=>{let e=y.interaction.crosshairPos,t=y.interaction.crosshairIndex;return e&&t!==null?{x:e.x,index:t}:null}})),y.setOnViewportChange(e=>{h.state.viewportDpr!==e.dpr&&h.actions.setViewportDpr(e.dpr),h.state.viewWidth!==e.plotWidth&&h.actions.setViewWidth(e.plotWidth);let t=au(h.state.kWidth,e.dpr);h.state.kGap!==t&&h.actions.setZoomState(h.state.zoomLevel,h.state.kWidth,t);let n=y.getOption();(n.kWidth!==h.state.kWidth||n.kGap!==t)&&y.applyRenderState(h.state.kWidth,t,h.state.zoomLevel)}),y.setOnPaneLayoutChange(e=>{let t={};for(let n of e)t[n.id]=n.ratio;h.actions.setPaneRatios(t);let n=y.getPaneRenderers(),r=c.value&&parseInt(getComputedStyle(c.value).borderTopWidth)||0;N.value=n.slice(0,-1).map(e=>{let t=e.getPane();return{id:t.id,top:t.top+t.height+r}})}),y.setOnDataChange(e=>{h.actions.setDataLength(e.length),h.actions.bumpDataVersion()}),p.value=y,y.applyRenderState(h.state.kWidth,h.state.kGap,h.state.zoomLevel);let C=d.value?.getSettings()??{showVolumePriceMarkers:!0};if(y.updateSettings(C),C.performanceTest10kKlines){let e=w();console.time(`updateData-10k`),y.updateData(e),console.timeEnd(`updateData-10k`),h.actions.setDataLength(e.length),h.actions.bumpDataVersion()}j.value=new Pl(y),j.value.setCallbacks({onDrawingCreated:e=>{h.actions.setDrawings([...h.state.drawings,e]),h.actions.setSelectedDrawingId(e.id)},onToolChange:e=>{},onDrawingSelected:e=>{h.actions.setSelectedDrawingId(e?.id??null)}}),y.interaction.setTooltipAnchorPositioning(k.value),y.interaction.setOnInteractionChange(e=>{A.value=e}),y.interaction.setOnPinchZoom((e,t)=>{let n=c.value;if(!n||!y)return;let a=t-n.getBoundingClientRect().left,o=n.scrollLeft,s=y.getCurrentDpr(),l=ou(e,a,o,g.value,_.value,v.value,{minKWidth:r.minKWidth,maxKWidth:r.maxKWidth,zoomLevelCount:r.zoomLevels,dpr:s});l&&(h.actions.setZoomState(l.targetLevel,l.newKWidth,l.newKGap),y.interaction.clearHover(),(0,f.nextTick)(()=>{let e=c.value;if(!e)return;let t=Math.max(0,e.scrollWidth-e.clientWidth),n=Math.min(Math.max(0,l.newScrollLeft),t);e.scrollLeft=Math.round(n*s)/s,y.applyRenderState(l.newKWidth,l.newKGap,l.targetLevel),i(`zoomLevelChange`,l.targetLevel,l.newKWidth)}))}),A.value=y.interaction.getInteractionSnapshot(),h.actions.setViewportDpr(y.getCurrentDpr()),y.resize(),m.value=new ji(y),m.value.on(`config:error`,e=>{console.error(`Semantic config error:`,e)}),m.value.on(`config:ready`,()=>{h.actions.setDataLength(y.getData()?.length??0),h.actions.bumpDataVersion(),ze(),Be(),(0,f.nextTick)(()=>Je())}),m.value.applyConfig(r.semanticConfig).then(e=>{e&&!e.success&&console.error(`Semantic config apply failed:`,e.errors)}),y.__onWheel=u}),(0,f.onUnmounted)(()=>{let e=p.value;if(e){let t=e.__onWheel,n=c.value;t&&n&&n.removeEventListener(`wheel`,t),e.destroy()}p.value=null,j.value=null}),(0,f.watch)(()=>r.yPaddingPx,e=>{p.value?.updateOptions({yPaddingPx:e})}),(0,f.watch)(()=>r.semanticConfig,async(e,t)=>{if(e&&e!==t){let t=await m.value?.applyConfig(e);t&&!t.success&&console.error(`Semantic config apply failed:`,t.errors)}},{deep:!0}),(t,n)=>((0,f.openBlock)(),(0,f.createElementBlock)(`div`,Df,[(0,f.createElementVNode)(`div`,{class:(0,f.normalizeClass)([`chart-stage`,{"is-dragging":re.value,"is-resizing-pane":ie.value,"is-hovering-pane-separator":ae.value,"is-hovering-right-axis":se.value,"is-hovering-kline":ce.value!==null}])},[(0,f.createVNode)(Ef,{ref_key:`toolbarRef`,ref:d,"is-fullscreen":e.isFullscreen,onSelectTool:be,onToggleFullscreen:n[0]||=e=>t.$emit(`toggleFullscreen`),onZoomIn:n[1]||=e=>Ye(g.value+1),onZoomOut:n[2]||=e=>Ye(g.value-1),onSettingsChange:C},null,8,[`is-fullscreen`]),(0,f.createElementVNode)(`div`,{class:`chart-main`,ref_key:`chartMainRef`,ref:l},[(0,f.createElementVNode)(`div`,Of,[((0,f.openBlock)(!0),(0,f.createElementBlock)(f.Fragment,null,(0,f.renderList)(N.value,e=>((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:e.id,class:(0,f.normalizeClass)([`pane-separator-line`,{"is-active":oe.value===e.id}]),style:(0,f.normalizeStyle)({top:`${e.top}px`})},null,6))),128))]),(0,f.createElementVNode)(`div`,{ref_key:`tooltipLayerRef`,ref:u,class:`tooltip-layer`},null,512),(0,f.createElementVNode)(`div`,{class:`chart-container`,ref_key:`containerRef`,ref:c,onScrollPassive:je,onPointerdown:Ce,onPointermove:we,onPointerup:Te,onPointerleave:Ee},[(0,f.createElementVNode)(`div`,{class:`scroll-content`,style:(0,f.normalizeStyle)({width:(0,f.unref)(qe)+`px`})},[(0,f.createElementVNode)(`div`,{class:`canvas-layer`,ref_key:`canvasLayerRef`,ref:o},[(0,f.createElementVNode)(`canvas`,{class:`x-axis-canvas`,ref_key:`xAxisCanvasRef`,ref:a},null,512),M.value?((0,f.openBlock)(),(0,f.createBlock)(Os,{key:0,drawing:M.value,onUpdateStyle:xe,onDelete:Se},null,8,[`drawing`])):(0,f.createCommentVNode)(``,!0)],512)],4)],544),u.value?((0,f.openBlock)(),(0,f.createBlock)(f.Teleport,{key:0,to:u.value},[ue.value?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:0,class:(0,f.normalizeClass)([`tooltip-anchor kline-tooltip-anchor`,{"use-anchor":k.value}]),style:(0,f.normalizeStyle)(me.value)},null,6)):(0,f.createCommentVNode)(``,!0),P.value||ne.value?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:1,class:(0,f.normalizeClass)([`tooltip-anchor marker-tooltip-anchor`,{"use-anchor":k.value}]),style:(0,f.normalizeStyle)(ge.value)},null,6)):(0,f.createCommentVNode)(``,!0),ue.value?((0,f.openBlock)(),(0,f.createBlock)(To,{key:2,k:ue.value,index:de.value,data:ye.value,pos:pe.value,"set-el":E,"use-anchor":k.value,"anchor-placement":_e.value},null,8,[`k`,`index`,`data`,`pos`,`use-anchor`,`anchor-placement`])):(0,f.createCommentVNode)(``,!0),P.value||ne.value?((0,f.openBlock)(),(0,f.createBlock)(Ao,{key:3,marker:P.value||ne.value,pos:he.value,"use-anchor":k.value,"anchor-placement":ve.value,"set-el":D},null,8,[`marker`,`pos`,`use-anchor`,`anchor-placement`])):(0,f.createCommentVNode)(``,!0)],8,[`to`])):(0,f.createCommentVNode)(``,!0),(0,f.createElementVNode)(`div`,{class:`right-axis-host`,ref_key:`rightAxisLayerRef`,ref:s,style:(0,f.normalizeStyle)({width:Ke.value+`px`}),onPointerdown:De,onPointermove:Oe,onPointerup:ke,onPointerleave:Ae},null,36)],512)],2),(0,f.createVNode)(bs,{"active-indicators":F.value,"indicator-params":Me.value,onToggle:Ue,onUpdateParams:We,onReorderSubIndicators:Ge},null,8,[`active-indicators`,`indicator-params`])]))}}),[[`__scopeId`,`data-v-5f030216`]]),jf={install(e){e.component(`KLineChart`,Af)}};exports.ConfigManager=Zi,exports.EventBus=p,exports.GLOBAL_PANE_ID=Ji,exports.HookSystem=Xi,exports.KLineChart=Af,exports.KMapPlugin=jf,exports.PluginHostImpl=$i,exports.PluginRegistry=Yi,exports.PluginState=Ki,exports.RENDERER_PRIORITY=G,exports.RendererPluginManager=ma,exports.createPluginHost=ea,exports.wrapPaneInfo=qi;