@363045841yyt/klinechart 0.5.5-alpha.0 → 0.5.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}},P=b(`Date`),ee=b(`File`),te=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=ke(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])}},F=(e,t)=>{let n,r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},I=b(`HTMLFormElement`),L=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),ke=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Ae=b(`RegExp`),je=(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)},Me=e=>{je(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 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:P,isFile:ee,isReactNativeBlob:te,isReactNative:ne,isBlob:re,isRegExp:Ae,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:F,isHTMLForm:I,hasOwnProperty:ke,hasOwnProp:ke,reduceDescriptors:je,freezeMethods:Me,toObjectSet:Ne,toCamelCase:L,noop:Pe,toFiniteNumber:Fe,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(`
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=I(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`),F=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),L=b(`RegExp`),je=(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)},Me=e=>{je(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 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:L,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:I,hasOwnProp:I,reduceDescriptors:je,freezeMethods:Me,toObjectSet:Ne,toCamelCase:F,noop:Pe,toFiniteNumber:Fe,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,10 +7,10 @@ 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:H.transitional(H.boolean),forcedJSONParsing:H.transitional(H.boolean),clarifyTimeoutError:H.transitional(H.boolean),legacyInterceptorReqResOrdering:H.transitional(H.boolean)},!1),r!=null&&(R.isFunction(r)?t.paramsSerializer={serialize:r}:Sn.assertOptions(r,{encode:H.function,serialize:H.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls===void 0?t.allowAbsoluteUrls=!0:t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls),Sn.assertOptions(t,{baseUrl:H.spelling(`baseURL`),withXsrfToken:H.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){Cn.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}))}}Cn.prototype[e]=t(),e!==`query`&&(Cn.prototype[e+`Form`]=t(!0))});var wn=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 Tn(e){return function(t){return e.apply(null,t)}}function En(e){return R.isObject(e)&&e.isAxiosError===!0}var Dn={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(Dn).forEach(([e,t])=>{Dn[t]=e});function On(e){let t=new Cn(e),n=m(Cn.prototype.request,t);return R.extend(n,Cn.prototype,t,{allOwnKeys:!0}),R.extend(n,t,null,{allOwnKeys:!0}),n.create=function(t){return On(Kt(e,t))},n}var U=On(kt);U.Axios=Cn,U.CanceledError=Mt,U.CancelToken=wn,U.isCancel=jt,U.VERSION=an,U.toFormData=ct,U.AxiosError=B,U.Cancel=U.CanceledError,U.all=function(e){return Promise.all(e)},U.spread=Tn,U.isAxiosError=En,U.mergeConfig=Kt,U.AxiosHeaders=z,U.formToJSON=e=>Et(R.isHTMLForm(e)?new FormData(e):e),U.getAdapter=gn.getAdapter,U.HttpStatusCode=Dn,U.default=U;function kn(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 An(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 jn(e){return e&&{daily:`d`,weekly:`w`,monthly:`m`,5:`5`,15:`15`,30:`30`,60:`60`}[e]||`d`}function Mn(e){return e&&{qfq:`2`,hfq:`1`,none:`3`}[e]||`3`}function Nn(e){let t=kn(e.date),n=e=>{let t=parseFloat(e);return Number.isNaN(t)?0:t};return{timestamp:An(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 Pn=``,Fn=`/api/stock/kdata`;async function In(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(Nn).sort((e,t)=>e.timestamp-t.timestamp);throw Error(`Mock data failed`)}let{timeout:t,...n}=e,r=`${Pn}${Fn}`,i={stock_code:n.symbol,start_date:n.start_date,end_date:n.end_date,frequency:jn(n.period),adjustflag:Mn(n.adjust),timeout:t};try{let e=(await U.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(Nn).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(Nn).sort((e,t)=>e.timestamp-t.timestamp)}}catch{}throw U.isAxiosError(e)?Error(`获取K线数据失败: ${e.message}`):e}}function Ln(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 Rn=`/api/public/stock_zh_a_hist`;function zn(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 Bn(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 Vn(e){return{timestamp:Bn(zn(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 Hn(e){try{let{timeout:t,...n}=e;return(await U.get(Rn,{params:n,timeout:t?t*1e3:void 0})).data.map(Vn)}catch(e){throw U.isAxiosError(e)?Error(`获取K线数据失败: ${e.message}`):e}}var Un=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(`|`)}`}},Wn=class{name=`baostock`;async fetchKLineData(e){return In({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}},Gn=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 Ln(await Hn({symbol:e.symbol,start_date:t,end_date:n,period:r,adjust:e.adjust===`none`?void 0:e.adjust,timeout:e.timeout}))}},Kn=class{static instances=new Map;static create(e){if(!this.instances.has(e))switch(e){case`baostock`:this.instances.set(e,new Wn);break;case`dongcai`:this.instances.set(e,new Gn);break;default:throw Error(`未知的数据源类型: ${e}`)}return this.instances.get(e)}},qn=3600*1e3;function Jn(e,t){return Un.generateKey(`kline:${e}`,{symbol:t.symbol,startDate:t.startDate,endDate:t.endDate,period:t.period,adjust:t.adjust})}async function Yn(e,t,n=!0){let r=Jn(e,t);if(n){let e=Un.get(r,qn);if(e)return console.log(`[KLineCache] 命中缓存: ${r}`),e}let i=await Kn.create(e).fetchKLineData(t);return n&&i.length>0&&(Un.set(r,i),console.log(`[KLineCache] 写入缓存: ${r}, ${i.length} 条数据`)),i}var Xn=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})),Zn=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;var t=Xn(),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}}})),W=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=Xn(),n=Zn(),r=Xn();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=Zn();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._)`!${ne(e)}`}e.not=j;var M=te(e.operators.AND);function N(...e){return e.reduce(M)}e.and=N;var P=te(e.operators.OR);function ee(...e){return e.reduce(P)}e.or=ee;function te(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})`}})),G=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=W(),n=Xn();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})),Qn=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W();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`)}})),$n=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=W(),n=G(),r=Qn();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])}})),er=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;var t=$n(),n=W(),r=Qn(),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)}})),tr=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})),nr=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})),rr=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=tr(),n=nr(),r=$n(),i=W(),a=G(),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})`}})),G=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=W(),n=Xn();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})),Qn=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W();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`)}})),$n=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=W(),n=G(),r=Qn();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])}})),er=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;var t=$n(),n=W(),r=Qn(),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)}})),tr=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})),nr=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})),rr=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=tr(),n=nr(),r=$n(),i=W(),a=G(),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}}})),ir=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.assignDefaults=void 0;var t=W(),n=G();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)}`)}})),K=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=W(),n=G(),r=Qn(),i=G();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})),ar=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;var t=W(),n=Qn(),r=K(),i=$n();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})),or=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;var t=W(),n=G();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})),sr=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}})),cr=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`)}})),lr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;var t=G(),n=sr(),r=cr(),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})),ur=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;var t=er(),n=rr(),r=nr(),i=rr(),a=ir(),o=ar(),s=or(),c=W(),l=Qn(),u=lr(),d=G(),f=$n();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||ee(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)),P(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):P(e,d),f||o.if((0,c._)`${l.default.errors} === ${a||0}`))}}function P(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 ee(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(te(e,t),e.opts.allowUnionTypes||ne(e,t),re(e,e.dataTypes))}function te(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})),dr=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}}})),fr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=lr();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))}}})),pr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;var t=W(),n=dr(),r=Qn(),i=lr(),a=G(),o=ur(),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}})),mr=c({$id:()=>hr,additionalProperties:()=>!1,default:()=>br,description:()=>gr,properties:()=>yr,required:()=>vr,type:()=>_r}),hr,gr,_r,vr,yr,br,xr=o((()=>{hr=`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`,gr=`Meta-schema for $data reference (JSON AnySchema extension proposal)`,_r=`object`,vr=[`$data`],yr={$data:{type:`string`,anyOf:[{format:`relative-json-pointer`},{format:`json-pointer`}]}},br={$id:hr,description:gr,type:_r,required:vr,properties:yr,additionalProperties:!1}})),Sr=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}})),Cr=s(((e,t)=>{var{isUUID:n}=Sr(),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}})),wr=s(((e,t)=>{var{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizePercentEncoding:a,normalizePathEncoding:o,escapePreservingEscapes:s,reescapeHostDelimiters:c,isIPv4:l,nonSimpleDomain:u}=Sr(),{SCHEMES:d,getSchemeHandler:f}=Cr();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})),Tr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=wr();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),Er=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=ur();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return t.KeywordCxt}});var n=W();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=dr(),i=fr(),a=tr(),o=pr(),s=W(),c=lr(),l=rr(),u=G(),f=(xr(),d(mr).default),p=Tr(),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;P.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]=te(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 P(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=te(t)),e.validateSchema=this.compile(t,!0))}var ee={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function te(e){return{anyOf:[e,ee]}}})),Dr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),Or=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.callRef=e.getValidate=void 0;var t=fr(),n=K(),r=W(),i=Qn(),a=pr(),o=G(),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})),kr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=Dr(),n=Or();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),Ar=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W(),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})`)}}})),jr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W();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}))`)}}})),Mr=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`})),Nr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W(),n=G(),r=Mr();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}`)}}})),Pr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=K(),n=G(),r=W();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})`)}}}})),Fr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W();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}`)}}})),Ir=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=K(),n=W(),r=G();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)}}}})),Lr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W();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}`)}}})),Rr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=sr();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),zr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=rr(),n=W(),r=G(),i=Rr();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)})))}}}})),Br=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W(),n=G(),r=Rr();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}`)}}})),Vr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W(),n=G(),r=Rr();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}`}}}})),Hr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=Ar(),n=jr(),r=Nr(),i=Pr(),a=Fr(),o=Ir(),s=Lr(),c=zr(),l=Br(),u=Vr();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]})),Ur=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateAdditionalItems=void 0;var t=W(),n=G(),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})),Wr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateTuple=void 0;var t=W(),n=G(),r=K(),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})),Gr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=Wr();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),Kr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W(),n=G(),r=K(),i=Ur();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)))}}})),qr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W(),n=G();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)))}}}})),Jr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;var t=W(),n=G(),r=K();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}}})),ir=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.assignDefaults=void 0;var t=W(),n=G();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)}`)}})),ar=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=W(),n=G(),r=Qn(),i=G();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})),or=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;var t=W(),n=Qn(),r=ar(),i=$n();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})),sr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;var t=W(),n=G();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})),cr=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}})),lr=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`)}})),ur=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;var t=G(),n=cr(),r=lr(),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})),dr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;var t=er(),n=rr(),r=nr(),i=rr(),a=ir(),o=or(),s=sr(),c=W(),l=Qn(),u=ur(),d=G(),f=$n();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})),fr=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}}})),pr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=ur();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))}}})),mr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;var t=W(),n=fr(),r=Qn(),i=ur(),a=G(),o=dr(),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}})),hr=c({$id:()=>gr,additionalProperties:()=>!1,default:()=>xr,description:()=>_r,properties:()=>br,required:()=>yr,type:()=>vr}),gr,_r,vr,yr,br,xr,Sr=o((()=>{gr=`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`,_r=`Meta-schema for $data reference (JSON AnySchema extension proposal)`,vr=`object`,yr=[`$data`],br={$data:{type:`string`,anyOf:[{format:`relative-json-pointer`},{format:`json-pointer`}]}},xr={$id:gr,description:_r,type:vr,required:yr,properties:br,additionalProperties:!1}})),Cr=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}})),wr=s(((e,t)=>{var{isUUID:n}=Cr(),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}})),Tr=s(((e,t)=>{var{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizePercentEncoding:a,normalizePathEncoding:o,escapePreservingEscapes:s,reescapeHostDelimiters:c,isIPv4:l,nonSimpleDomain:u}=Cr(),{SCHEMES:d,getSchemeHandler:f}=wr();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})),Er=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=Tr();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),Dr=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=dr();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return t.KeywordCxt}});var n=W();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=fr(),i=pr(),a=tr(),o=mr(),s=W(),c=ur(),l=rr(),u=G(),f=(Sr(),d(hr).default),p=Er(),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]}}})),Or=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),kr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.callRef=e.getValidate=void 0;var t=pr(),n=ar(),r=W(),i=Qn(),a=mr(),o=G(),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})),Ar=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=Or(),n=kr();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),jr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W(),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})`)}}})),Mr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W();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}))`)}}})),Nr=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`})),Pr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W(),n=G(),r=Nr();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}`)}}})),Fr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=ar(),n=G(),r=W();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})`)}}}})),Ir=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W();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}`)}}})),Lr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=ar(),n=W(),r=G();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)}}}})),Rr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W();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}`)}}})),zr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=cr();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),Br=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=rr(),n=W(),r=G(),i=zr();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)})))}}}})),Vr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W(),n=G(),r=zr();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}`)}}})),Hr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W(),n=G(),r=zr();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}`}}}})),Ur=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=jr(),n=Mr(),r=Pr(),i=Fr(),a=Ir(),o=Lr(),s=Rr(),c=Br(),l=Vr(),u=Hr();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]})),Wr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateAdditionalItems=void 0;var t=W(),n=G(),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})),Gr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateTuple=void 0;var t=W(),n=G(),r=ar(),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})),Kr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=Gr();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),qr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W(),n=G(),r=ar(),i=Wr();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)))}}})),Jr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W(),n=G();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)))}}}})),Yr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;var t=W(),n=G(),r=ar();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})),Yr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W(),n=G();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)}}})),Xr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=K(),n=W(),r=Qn(),i=G();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)}}}})),Zr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=ur(),n=K(),r=G(),i=Xr();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)}}}})),Qr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=K(),n=W(),r=G(),i=G();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())})})}}}})),$r=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=G();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`}}})),ei=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:K().validateUnion,error:{message:`must match a schema in anyOf`}}})),ti=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W(),n=G();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)})})}}}})),ni=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=G();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)})}}})),ri=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W(),n=G(),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})),ii=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=G();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`)}}})),ai=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=Ur(),n=Gr(),r=Wr(),i=Kr(),a=qr(),o=Jr(),s=Yr(),c=Xr(),l=Zr(),u=Qr(),d=$r(),f=ei(),p=ti(),m=ni(),h=ri(),g=ii();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=_})),oi=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W();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})`}}}}})),si=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=[oi().default]})),ci=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`]})),li=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=kr(),n=Hr(),r=ai(),i=si(),a=ci();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),ui=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={}))})),di=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W(),n=ui(),r=pr(),i=fr(),a=G();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}}}}})),fi=c({$id:()=>mi,$schema:()=>pi,default:()=>yi,definitions:()=>gi,properties:()=>vi,title:()=>hi,type:()=>_i}),pi,mi,hi,gi,_i,vi,yi,bi=o((()=>{pi=`http://json-schema.org/draft-07/schema#`,mi=`http://json-schema.org/draft-07/schema#`,hi=`Core schema meta-schema`,gi={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:[]}},_i=[`object`,`boolean`],vi={$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:`#`}},yi={$schema:pi,$id:mi,title:hi,definitions:gi,type:_i,properties:vi,default:!0}})),xi=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=Er(),r=li(),i=di(),a=(bi(),d(fi).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=ur();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return l.KeywordCxt}});var u=W();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=dr();Object.defineProperty(e,`ValidationError`,{enumerable:!0,get:function(){return f.default}});var p=fr();Object.defineProperty(e,`MissingRefError`,{enumerable:!0,get:function(){return p.default}})}))(),1),Si={$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}$`}}}}},Ci=[`__proto__`,`constructor`,`prototype`],wi=/^(#[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*\))$/,Ti={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 Ei(e){return{"5min":30,"15min":60,"30min":90,"60min":180,daily:365*3,weekly:365*5,monthly:365*10}[e]??365}var Di=(typeof document<`u`?document.createElement(`canvas`):null)?.getContext(`2d`)??null,Oi=class e{ajv;limits;constructor(){this.ajv=new xi.default({allErrors:!0,allowUnionTypes:!0}),this.ajv.addFormat(`date`,{type:`string`,validate:e=>/^\d{4}-\d{2}-\d{2}$/.test(e)}),this.ajv.addSchema(Si),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))Ci.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=Ei(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(!Ti[n].test(t))return{valid:!1,errors:[`Invalid symbol "${t}" for exchange "${n}"`]}}else if(!Object.values(Ti).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`&&!wi.test(r)&&n.push(`Invalid ${i} in marker "${t}": ${r}`)}if(Di)for(let i of r){let r=e[i];typeof r==`string`&&(Di.fillStyle=`#000000`,Di.fillStyle=r,Di.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}},ki=class{chart;validator;events;constructor(e){this.chart=e,this.validator=new Oi,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 Yn(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:Ai(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 Ai(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 ji={arrow_up:16,arrow_down:16,flag:14,circle:12,rectangle:14,diamond:12};function Mi(e,t,n,r,i,a){let o=a.fillColor||`#000000`,s=a.strokeColor||o,c=i||ji[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`:Li(e,n,r,c);break;case`arrow_down`:Ri(e,n,r,c);break;case`circle`:zi(e,n,r,c);break;case`rectangle`:Bi(e,n,r,c);break;case`diamond`:Vi(e,n,r,c);break;case`flag`:Hi(e,n,r,c);break}e.globalAlpha=1}var Ni=2.5,Pi=4;function Fi(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*Ni,d=Ii(e,t.text,u),f=e.measureText(d).width,p=n,m=r;switch(t.position){case`left`:p=n-l-f/2-Pi;break;case`right`:p=n+l+f/2+Pi;break;case`top`:m=r-l-s/2-Pi;break;case`bottom`:m=r+l+s/2+Pi;break;default:m=o?r-l-s/2-Pi:r+l+s/2+Pi;break}t.offset&&(p+=t.offset.x||0,m+=t.offset.y||0),e.textAlign=t.align||`center`,e.fillText(d,p,m)}function Ii(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 Li(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 Ri(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 zi(e,t,n,r){e.beginPath(),e.arc(t,n,r/2,0,Math.PI*2),e.fill()}function Bi(e,t,n,r){e.fillRect(t-r/2,n-r/2,r,r)}function Vi(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 Hi(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 Ui(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 Wi=function(e){return e.Registered=`registered`,e.Installed=`installed`,e.Error=`error`,e}({});function Gi(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)},priceRange:e.priceRange}}var Ki=Symbol(`global-pane`),q={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},qi=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()}},Ji=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}},Yi=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())}},Xi=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()}},Zi=class{registry;eventBus;hookSystem;configManager;stateStore;isDestroyed=!1;logger;constructor(e){this.registry=new qi,this.eventBus=new p,this.hookSystem=new Ji,this.configManager=new Yi,this.stateStore=new Xi,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 Qi(e){return new Zi(e)}var $i=Symbol(`renderer:global-cache`),ea=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`?$i: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($i)??[];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($i,[...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($i)??[];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){let n=this.getRenderers(e),r=[];for(let e of n)try{e.draw(t)}catch(n){let i=n instanceof Error?n:Error(String(n));console.error(`[RendererPlugin] ${e.name} draw error:`,i),r.push({name:e.name,error:{message:i.message,stack:i.stack},paneId:t.pane.id,timestamp:Date.now()})}return r}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)}}},ta=1.2,na=24,ra=6;function ia(e){switch(e){case`arrow_up`:case`flag`:return!0;default:return!1}}function aa(){return{name:`customMarkers`,version:`1.0.0`,description:`自定义标记渲染器`,debugName:`自定义标记`,paneId:Ki,priority:q.OVERLAY,draw(e){let{ctx:t,pane:n,data:r,range:i,scrollLeft:a,kWidth:o,kLinePositions:s,markerManager:c}=e;if(!c)return;let l=c.getCustomMarkers();if(!l||l.length===0)return;let u=r;if(u.length&&n.role===`price`){t.save(),t.translate(-a,0);for(let e of l){let r=sa(u,e.timestamp);if(r===-1||r<i.start||r>=i.end)continue;let l=r-i.start;if(l<0||l>=s.length)continue;let d=s[l]+o/2,f=u[r],p=e.style?.size,m=oa(o,p),h=(e.offset?.y??0)<0?!0:(e.offset?.y??0)>0?!1:ia(e.shape),g;g=h?n.yAxis.priceToY(f.high)-m/2-4+(e.offset?.y??0):n.yAxis.priceToY(f.low)+m/2+4+(e.offset?.y??0);let _=d+(e.offset?.x??0),v=g;Mi(t,e.shape,_,v,m,e.style||{}),e.label&&Fi(t,e.label,_,v,m,e.style||{},h),c.setCustomMarkerPosition(e.id,_-a,v,m,e.shape)}t.restore()}}}}function oa(e,t){let n=e*ta;return Math.max(ra,Math.min(n,t??na))}function sa(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 ca(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 la(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 da=ca,fa=ca;function pa(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 ma={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)`},ha={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`},ga={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`},_a={HORIZONTAL:`rgba(0, 0, 0, 0.06)`,VERTICAL:`rgba(0, 0, 0, 0.12)`},Y={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)`},va={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)`},ya={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`},ba={UP:`#ff5252`,DOWN:`#22ab94`,NEUTRAL:`rgba(0, 0, 0, 0.78)`},xa={RSI1:`rgba(69, 112, 249, 1)`,RSI2:`rgba(255, 152, 0, 1)`,RSI3:`rgba(156, 39, 176, 1)`},Sa={CCI:`rgba(69, 112, 249, 1)`,OVERBOUGHT:`rgba(214, 10, 34, 0.5)`,OVERSOLD:`rgba(3, 123, 102, 0.5)`},Ca={K:`rgba(69, 112, 249, 1)`,D:`rgba(255, 152, 0, 1)`,J:`rgba(156, 39, 176, 1)`},wa={MOM:`rgba(69, 112, 249, 1)`,ZERO:`rgba(0, 0, 0, 0.2)`},Ta={WMSR:`rgba(69, 112, 249, 1)`,OVERBOUGHT:`rgba(214, 10, 34, 0.5)`,OVERSOLD:`rgba(3, 123, 102, 0.5)`},Ea={KST:`rgba(69, 112, 249, 1)`,SIGNAL:`rgba(255, 152, 0, 1)`},Da={FAST:`rgba(255, 152, 0, 1)`,SLOW:`rgba(69, 112, 249, 1)`},Oa={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)`},ka={LINE:`rgba(0, 0, 0, 0.28)`,LABEL_BG:`rgb(0, 0, 0)`,LABEL_TEXT:`rgba(255, 255, 255, 0.92)`},Aa=J.UP,ja=J.DOWN,Ma=J.NEUTRAL;function Na(e){return e>0?Aa:e<0?ja:Ma}function Pa(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 Fa(e,t=2){return`${e>0?`+`:``}${e.toFixed(t)}`}function Ia(e,t=2){return`${e.toFixed(t)}%`}function La(e,t=2){return`${e>0?`+`:``}${e.toFixed(t)}%`}function Ra(e,t){let n=t?.close??e.open;return Na(e.open-n)}function za(e){return Na(e.close-e.open)}function Ba(e){return typeof e.changePercent==`number`?Na(e.changePercent):typeof e.changeAmount==`number`?Na(e.changeAmount):Ma}var Va={class:`kline-tooltip__title`},Ha={key:0},Ua={class:`kline-tooltip__grid`},Wa={class:`row`},Ga={class:`row`},Ka={class:`row`},qa={class:`row`},Ja={key:0,class:`row`},Ya={key:1,class:`row`},Xa={key:2,class:`row`},Za={key:3,class:`row`},Qa={key:4,class:`row`},$a={key:5,class:`row`},eo=(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 Ma;let n=t.index;return Ra(e,typeof n==`number`&&n>0?t.data[n-1]:void 0)}),o=(0,f.computed)(()=>{let e=t.k;return e?za(e):Ma}),s=(0,f.computed)(()=>{let e=t.k;return e?Ba(e):Ma});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`,Va,[e.k.stockCode?((0,f.openBlock)(),(0,f.createElementBlock)(`span`,Ha,(0,f.toDisplayString)(e.k.stockCode),1)):(0,f.createCommentVNode)(``,!0),(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)((0,f.unref)(da)(e.k.timestamp)),1)]),(0,f.createElementVNode)(`div`,Ua,[(0,f.createElementVNode)(`div`,Wa,[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`,Ga,[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`,Ka,[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`,qa,[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`,Ja,[c[4]||=(0,f.createElementVNode)(`span`,null,`成交量`,-1),(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)((0,f.unref)(Pa)(e.k.volume)),1)])):(0,f.createCommentVNode)(``,!0),typeof e.k.turnover==`number`?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,Ya,[c[5]||=(0,f.createElementVNode)(`span`,null,`成交额`,-1),(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)((0,f.unref)(Pa)(e.k.turnover)),1)])):(0,f.createCommentVNode)(``,!0),typeof e.k.amplitude==`number`?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,Xa,[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`,Za,[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)(La)(e.k.changePercent)),5)])):(0,f.createCommentVNode)(``,!0),typeof e.k.changeAmount==`number`?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,Qa,[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)(Fa)(e.k.changeAmount)),5)])):(0,f.createCommentVNode)(``,!0),typeof e.k.turnoverRate==`number`?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,$a,[c[9]||=(0,f.createElementVNode)(`span`,null,`换手率`,-1),(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)((0,f.unref)(Ia)(e.k.turnoverRate)),1)])):(0,f.createCommentVNode)(``,!0)])],6)):(0,f.createCommentVNode)(``,!0)}}),to=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},no=to(eo,[[`__scopeId`,`data-v-d0fe85e6`]]),ro={RISE_WITH_VOLUME:`量价齐升`,RISE_WITHOUT_VOLUME:`量缩价升`,FALL_WITH_VOLUME:`量价齐缩`,FALL_WITHOUT_VOLUME:`量升价缩`},io=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&&Ui(e,t,r.shape,r.x,r.y,r.size))return n}return null}},ao={class:`marker-tooltip__title`},oo={key:0,class:`marker-tooltip__content`},so=to((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 ro[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`,ao,(0,f.toDisplayString)(o.value),1),c.value?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,oo,[((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`]]),co={class:`params-header`},lo={class:`header-left`},uo={class:`params-title`},fo={class:`header-right`},po={key:0,class:`indicator-description`},mo={class:`params-body`},ho={class:`param-header`},go={class:`param-label`},_o={class:`param-label-text`},vo={key:0,class:`param-range`},yo={class:`input-wrapper`},bo=[`disabled`,`onClick`],xo=[`value`,`min`,`max`,`step`,`onInput`],So=[`disabled`,`onClick`],Co={key:0,class:`param-description`},wo={class:`params-footer`},To={class:`footer-right`},Eo=to((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);(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 o(e,t){let n=t.target,r=parseFloat(n.value);isNaN(r)||(i.value[e]=r)}function s(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 c(){let e={};n.params.forEach(t=>{e[t.key]=t.default??n.values[t.key]??0}),i.value=e}function l(){r(`confirm`,{...i.value})}return(t,n)=>((0,f.openBlock)(),(0,f.createBlock)(f.Teleport,{to:`body`},[(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`,co,[(0,f.createElementVNode)(`div`,lo,[(0,f.createElementVNode)(`span`,uo,(0,f.toDisplayString)(e.indicatorName),1),n[5]||=(0,f.createElementVNode)(`span`,{class:`params-subtitle`},`参数设置`,-1)]),(0,f.createElementVNode)(`div`,fo,[(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`,po,[(0,f.createElementVNode)(`p`,null,(0,f.toDisplayString)(e.indicatorDescription),1)])):(0,f.createCommentVNode)(``,!0)]),_:1}),(0,f.createElementVNode)(`div`,mo,[((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`,ho,[(0,f.createElementVNode)(`label`,go,[(0,f.createElementVNode)(`span`,_o,(0,f.toDisplayString)(e.label),1),e.min!==void 0||e.max!==void 0?((0,f.openBlock)(),(0,f.createElementBlock)(`span`,vo,(0,f.toDisplayString)(e.min??`-∞`)+` ~ `+(0,f.toDisplayString)(e.max??`+∞`),1)):(0,f.createCommentVNode)(``,!0)]),(0,f.createElementVNode)(`div`,yo,[(0,f.createElementVNode)(`button`,{class:`stepper-btn`,disabled:e.min!==void 0&&(i.value[e.key]??0)<=e.min,onClick:t=>s(e,-1)},` − `,8,bo),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=>o(e.key,t)},null,40,xo)):(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=>s(e,1)},` + `,8,So)])]),(0,f.createVNode)(f.Transition,{name:`slide`},{default:(0,f.withCtx)(()=>[a.value&&e.description?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,Co,(0,f.toDisplayString)(e.description),1)):(0,f.createCommentVNode)(``,!0)]),_:2},1024)],2))),128))]),(0,f.createElementVNode)(`div`,wo,[(0,f.createElementVNode)(`button`,{class:`params-btn reset`,onClick:c},[...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`,To,[(0,f.createElementVNode)(`button`,{class:`params-btn cancel`,onClick:n[2]||=e=>t.$emit(`close`)},`取消`),(0,f.createElementVNode)(`button`,{class:`params-btn confirm`,onClick:l},[...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})]))}}),[[`__scopeId`,`data-v-c14eedcc`]]),Do={class:`indicator-selector`},Oo={class:`indicator-scroll-container`},ko={class:`indicator-list`},Ao={key:0,class:`indicator-divider`,"aria-hidden":`true`},jo=[`draggable`,`onDragstart`,`onDragover`,`onDrop`],Mo=[`onMouseenter`],No={class:`btn-content`},Po={key:0,class:`param-hint`},Fo={key:0,class:`hover-overlay`},Io=[`onClick`],Lo={key:1,class:`divider`},Ro=[`onClick`],zo={class:`indicator-item`},Bo={class:`menu-section`},Vo={class:`menu-items`},Ho=[`disabled`,`onClick`],Uo={class:`param-hint`},Wo={key:0,class:`active-tag`},Go={class:`menu-section`},Ko={class:`menu-items`},qo=[`disabled`,`onClick`],Jo={class:`param-hint`},Yo={key:0,class:`active-tag`},Xo=to((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=(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):[]),y=(0,f.computed)(()=>v.value.some(e=>e.pane===`main`)?v.value.find(e=>e.pane===`sub`)?.id??null:null),b=(0,f.computed)(()=>u.value&&n.find(e=>e.id===u.value)||null);function x(e){return a.activeIndicators?.includes(e)??!1}function S(e){if(x(e))return;let t=n.find(t=>t.id===e);t&&(t.pane===`main`&&n.filter(t=>t.pane===`main`&&t.id!==e&&x(t.id)).forEach(e=>o(`toggle`,e.id,!1)),o(`toggle`,e,!0),p.value=!1)}function C(e){o(`toggle`,e,!1)}function w(e){u.value=e,l.value=!0}function T(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 E(e){let t=T(e.id);return e.params?e.params.map(e=>t[e.key]??``).join(`,`):``}function D(e){u.value&&o(`updateParams`,u.value,e),l.value=!1}function O(e){return n.find(t=>t.id===e)?.pane===`sub`}function k(e,t){if(!O(t)){e.preventDefault();return}_.value=t,g.value=null,e.dataTransfer?.setData(`text/plain`,t),e.dataTransfer&&(e.dataTransfer.effectAllowed=`move`)}function A(e,t){!_.value||!O(t)||_.value===t||(g.value=t,e.dataTransfer&&(e.dataTransfer.dropEffect=`move`))}function j(e,t){let n=_.value||e.dataTransfer?.getData(`text/plain`)||``;if(!n||n===t){M();return}if(!O(n)||!O(t)){M();return}let r=v.value.findIndex(e=>e.id===n),i=v.value.findIndex(e=>e.id===t);if(r<0||i<0){M();return}let a=[...v.value.map(e=>e.id)],[s]=a.splice(r,1);if(!s){M();return}a.splice(i,0,s),o(`reorderSubIndicators`,a.filter(e=>O(e))),M()}function M(){g.value=null,_.value=null}function N(){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 ee(){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`,ee)}),(0,f.onUnmounted)(()=>{document.removeEventListener(`click`,P),window.removeEventListener(`resize`,ee)}),(e,t)=>((0,f.openBlock)(),(0,f.createElementBlock)(`div`,Do,[(0,f.createElementVNode)(`div`,Oo,[(0,f.createElementVNode)(`div`,ko,[((0,f.openBlock)(!0),(0,f.createElementBlock)(f.Fragment,null,(0,f.renderList)(v.value,e=>((0,f.openBlock)(),(0,f.createElementBlock)(f.Fragment,{key:e.id},[e.id===y.value?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,Ao)):(0,f.createCommentVNode)(``,!0),(0,f.createElementVNode)(`div`,{class:(0,f.normalizeClass)([`indicator-item`,{draggable:O(e.id),"drag-over":g.value===e.id,"is-dragging":_.value===e.id}]),draggable:O(e.id),onDragstart:t=>k(t,e.id),onDragover:(0,f.withModifiers)(t=>A(t,e.id),[`prevent`]),onDrop:(0,f.withModifiers)(t=>j(t,e.id),[`prevent`]),onDragend:M},[(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`,No,[(0,f.createTextVNode)((0,f.toDisplayString)(e.label)+` `,1),e.params?((0,f.openBlock)(),(0,f.createElementBlock)(`span`,Po,` (`+(0,f.toDisplayString)(E(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`,Fo,[e.params?((0,f.openBlock)(),(0,f.createElementBlock)(`button`,{key:0,class:`action-btn settings-btn`,onClick:(0,f.withModifiers)(t=>w(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,Io)):(0,f.createCommentVNode)(``,!0),e.params?((0,f.openBlock)(),(0,f.createElementBlock)(`span`,Lo)):(0,f.createCommentVNode)(``,!0),(0,f.createElementVNode)(`button`,{class:`action-btn remove-btn`,onClick:(0,f.withModifiers)(t=>C(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,Ro)])):(0,f.createCommentVNode)(``,!0)]),_:2},1024)],2)],40,Mo)],42,jo)],64))),128)),(0,f.createElementVNode)(`div`,zo,[(0,f.createElementVNode)(`button`,{ref_key:`addBtnRef`,ref:s,class:`add-btn`,onClick:N,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:`body`},[(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`,Bo,[t[6]||=(0,f.createElementVNode)(`div`,{class:`menu-title`},`主图指标`,-1),(0,f.createElementVNode)(`div`,Vo,[((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:x(e.id)}]),disabled:x(e.id),onClick:t=>S(e.id)},[(0,f.createTextVNode)((0,f.toDisplayString)(e.label)+` `,1),(0,f.createElementVNode)(`span`,Uo,` (`+(0,f.toDisplayString)(e.name)+`) `,1),x(e.id)?((0,f.openBlock)(),(0,f.createElementBlock)(`span`,Wo,[...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,Ho))),128))])]),(0,f.createElementVNode)(`div`,Go,[t[8]||=(0,f.createElementVNode)(`div`,{class:`menu-title`},`副图指标`,-1),(0,f.createElementVNode)(`div`,Ko,[((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:x(e.id)}]),disabled:x(e.id),onClick:t=>S(e.id)},[(0,f.createTextVNode)((0,f.toDisplayString)(e.label)+` `,1),(0,f.createElementVNode)(`span`,Jo,` (`+(0,f.toDisplayString)(e.name)+`) `,1),x(e.id)?((0,f.openBlock)(),(0,f.createElementBlock)(`span`,Yo,[...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,qo))),128))])])],6)):(0,f.createCommentVNode)(``,!0)]),_:1})])),b.value?((0,f.openBlock)(),(0,f.createBlock)(Eo,{key:0,visible:l.value,"indicator-id":b.value.id,"indicator-name":b.value.name,"indicator-description":b.value.description,params:b.value.params||[],values:T(b.value.id),onClose:t[1]||=e=>l.value=!1,onConfirm:D},null,8,[`visible`,`indicator-id`,`indicator-name`,`indicator-description`,`params`,`values`])):(0,f.createCommentVNode)(``,!0)]))}}),[[`__scopeId`,`data-v-4b90c954`]]),Zo={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Qo(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Zo,[...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 $o=(0,f.markRaw)({name:`tabler-trash`,render:Qo}),es={class:`toolbar-item color-item`,title:`颜色`},ts=[`value`],ns=[`value`],rs=[`value`],is=to((0,f.defineComponent)({__name:`DrawingStyleToolbar`,props:{drawing:{}},emits:[`updateStyle`,`delete`],setup(e,{emit:t}){let n=t;function r(e){n(`updateStyle`,{stroke:e})}function i(e){n(`updateStyle`,{strokeWidth:e})}function a(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`,es,[(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=>r(e.target.value)},null,40,ts)]),(0,f.createElementVNode)(`select`,{class:`toolbar-select`,value:e.drawing.style.strokeWidth??1,onChange:n[1]||=e=>i(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,ns),(0,f.createElementVNode)(`select`,{class:`toolbar-select`,value:e.drawing.style.strokeStyle??`solid`,onChange:n[2]||=e=>a(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,rs),(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)($o),{class:`delete-icon`,"aria-hidden":`true`})])],32))}}),[[`__scopeId`,`data-v-088ccef5`]]);function as(e,t){let n=Math.round(e*t);return n%2==0&&(n+=1),Math.max(1,n)}function X(e,t,n){let r=as(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 os(e,t,n,r,i,a=1){let{unitPx:o,startXPx:s}=X(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 ss(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 cs=class{range={maxPrice:100,minPrice:0};height=1;paddingTop=0;paddingBottom=0;priceOffset=0;verticalScale=1;setRange(e){this.range=e}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){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}getDisplayRange(e){let t=e??this.range,n=t.minPrice,r=t.maxPrice,i=r-n||1,a=(r+n)/2+this.priceOffset,o=i/(2*this.verticalScale);return{maxPrice:a+o,minPrice:a-o}}priceToY(e){let{maxPrice:t,minPrice:n}=this.range,r=e-this.priceOffset,i=t-n||1,a=(r-n)/i,o=Math.max(1,this.height-this.paddingTop-this.paddingBottom),s=this.paddingTop+o*(1-a),c=this.paddingTop+o/2;return c+(s-c)*this.verticalScale}yToPrice(e){let{maxPrice:t,minPrice:n}=this.range,r=t-n||1,i=Math.max(1,this.height-this.paddingTop-this.paddingBottom),a=this.paddingTop+i/2;return n+(1-(a+(e-a)/this.verticalScale-this.paddingTop)/i)*r+this.priceOffset}deltaYToPriceOffset(e){return e*((this.range.maxPrice-this.range.minPrice||1)/Math.max(1,this.height-this.paddingTop-this.paddingBottom))}};function ls(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 us=class{id;role;capabilities;top=0;height=0;priceRange={maxPrice:100,minPrice:0};yAxis=new cs;renderers=[];constructor(e,t={}){this.id=e,this.role=t.role??(e===`main`?`price`:`indicator`),this.capabilities={...ls(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){this.priceRange=ss(e,t.start,t.end),this.yAxis.setRange(this.priceRange)}},ds=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;hoveredMarkerId=null;clickedMarkerId=null;hoveredMarkerData=null;clickedMarkerData=null;onMarkerHoverCallback;onMarkerClickCallback;hoveredCustomMarker=null;onCustomMarkerHoverCallback;onCustomMarkerClickCallback;kLinePositions=null;visibleRange=null;kWidthPx=null;constructor(e){this.chart=e}setOnPinchZoom(e){this.onPinchZoomCallback=e}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())}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 n=this.chart.getDom().container,{mouseX:r,mouseY:i}=t,a=n.scrollLeft,o=this.chart.getMarkerManager(),s=a+r,c=o.hitTest(s,i,3);if(c){this.clickedMarkerId=c.id,this.clickedMarkerData=c,this.onMarkerClickCallback&&this.onMarkerClickCallback(c);return}let l=this.hitTestPaneSeparator(i);if(l){this.isDragging=!0,this.dragMode=`resize-separator`,this.dragStartY=e.clientY,this.activeSeparatorUpperPaneId=l,this.hoveredSeparatorUpperPaneId=l,this.clearHover(),this.chart.scheduleDraw();return}let u=this.getPaneByY(i);this.isDragging=!0,this.dragMode=`pan`,this.updatePlotHoverFromPoint(e.clientX,e.clientY),this.dragStartX=e.clientX,this.dragStartY=e.clientY,this.scrollStartX=n.scrollLeft,this.activePaneIdOnDrag=u?.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;r!==0&&this.activePaneIdOnDrag===`main`&&(this.chart.translatePrice(this.activePaneIdOnDrag,r),this.dragStartY=e.clientY)}return}let n=this.getPlotPointerLocation(e.clientX,e.clientY);n&&(this.hoveredSeparatorUpperPaneId=this.hitTestPaneSeparator(n.mouseY),this.updatePlotHoverFromPoint(e.clientX,e.clientY),this.chart.scheduleDraw(),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){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),this.chart.scheduleDraw(),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?(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):!1}clearHover(){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=a.scrollLeft,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],P=v/2,ee=Math.abs(M-j),te=ee<8?(j+M)/2-8/2:j,ne=ee<8?(j+M)/2+8/2:M,re=E>=te&&E<=ne&&N>=0&&N<=v,ie=Math.abs(N-P)<=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.kWidthPx=null}getCrosshairIndex(){return this.crosshairIndex}},fs=class{dom;pane;opt;constructor(e,t,n){this.dom=e,this.pane=t,this.opt={...n,priceLabelWidth:n.priceLabelWidth||60}}getPane(){return this.pane}getDom(){return this.dom}resize(e,t,n){let r=this.dom.plotCanvas,i=this.dom.yAxisCanvas;r.width=Math.round(e*n),r.height=Math.round(t*n),r.style.width=`${r.width/n}px`,r.style.height=`${r.height/n}px`;let a=this.opt.rightAxisWidth+(this.opt.priceLabelWidth||60),o=i.parentElement?.clientWidth??0,s=o>0?o:a;i.width=Math.round(s*n),i.height=Math.round(t*n),i.style.width=`${s}px`,i.style.height=`${i.height/n}px`}destroy(){}};function ps(e){let{dataLength:t,kWidth:n,kGap:r,viewWidth:i,viewportDpr:a}=e;if(t===0)return 0;let{startXPx:o,unitPx:s}=X(n,r,a),c=(o+(t+24)*s)/a;return Math.max(c,i)}function ms(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)(()=>ps({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 hs=(e,t)=>`indicator:${e}:${t}`;function gs(e={}){let{paneId:t=`sub`}=e,n=hs(`volume`,t),r=null;return{name:`volume_${t}`,version:`1.0.0`,description:`成交量渲染器`,debugName:`成交量`,paneId:t,priority:q.MAIN,onInstall(e){r=e},getDeclaredNamespaces(){return[n]},draw(e){let{ctx:i,pane:a,data:o,range:s,scrollLeft:c,dpr:l}=e,u=o;if(!u.length)return;i.save(),i.translate(-c,0);let{start:d,end:f}=s,p=0,m=1/0;for(let e=d;e<f&&e<u.length;e++){let t=u[e];if(!t)continue;let n=t.volume;n!=null&&(p=Math.max(p,n),m=Math.min(m,n))}if(p===0||!Number.isFinite(m)){i.restore();return}let h=Math.max(.05,(p-m)*.1),g=Math.max(0,m-h),_=p+h,v=a.yAxis.getDisplayRange({minPrice:g,maxPrice:_}),y=v.minPrice,b=v.maxPrice-y||1,x=a.height-(0-y)/b*a.height;r?.setSharedState(n,{valueMin:g,valueMax:_,timestamp:Date.now()},`volume_${t}`);for(let t=d;t<f;t++){let n=u[t];if(!n)continue;let r=n.volume;if(!r)continue;let o=e.kBarRects[t-d];if(!o)continue;let s=o.x,c=o.width;_s(i,s,vs(n),r,c,y,b,x,a.height,l)}i.restore()}}}function _s(e,t,n,r,i,a,o,s,c,l){let u=c-(r-a)/o*c,d=Math.round(u*l)/l,f=Math.round(s*l)/l,p=1/l,m=f-d,h=m<=0?p:Math.max(m,p),g=m<=0?f-p:f-h;e.fillStyle=n,e.fillRect(t,g,i,h)}function vs(e){return e.close>e.open?ba.UP:e.close<e.open?ba.DOWN:ba.NEUTRAL}function Z(e,t){return Math.round(e*t)/t}function Q(e,t){return(Math.floor(e*t)+.5)/t}function ys(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 bs(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 xs(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}}function Ss(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 Cs(e={}){let t={ma5:!0,ma10:!0,ma20:!0,ma30:!0,ma60:!0,...e},n=new Map,r=null;function i(e,t){let i=n.get(t);if(i&&r===e)return i.values;let a=Ss(e,t);return n.set(t,{period:t,values:a}),r=e,a}function a(e,t,n,r){let{pane:i,range:a,dpr:o,kLineCenters:s}=n;e.strokeStyle=r,e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,e.beginPath();let c=!0;for(let n=a.start;n<a.end&&n<t.length;n++){let r=t[n];if(r===void 0)continue;let l=s[n-a.start];if(l===void 0)continue;let u=i.yAxis.priceToY(r),d=l,f=Q(u,o);c?(e.moveTo(d,f),c=!1):e.lineTo(d,f)}e.stroke()}return{name:`ma`,version:`1.0.0`,description:`MA均线渲染器`,debugName:`MA均线`,paneId:`main`,priority:q.INDICATOR,draw(e){let{ctx:n,data:r,scrollLeft:o}=e,s=r;s.length&&(n.save(),n.translate(-o,0),t.ma5&&a(n,i(s,5),e,Y.MA5),t.ma10&&a(n,i(s,10),e,Y.MA10),t.ma20&&a(n,i(s,20),e,Y.MA20),t.ma30&&a(n,i(s,30),e,Y.MA30),t.ma60&&a(n,i(s,60),e,Y.MA60),n.restore())},onDataUpdate(){r=null,n.clear()},getConfig(){return{...t}},setConfig(e){Object.assign(t,e)}}}function ws(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 Ts(e={}){let t={period:20,multiplier:2,showUpper:!0,showMiddle:!0,showLower:!0,showBand:!0,...e},n=null,r=0,i=0,a=[];function o(e){return(n!==e||r!==t.period||i!==t.multiplier)&&(a=ws(e,t.period,t.multiplier),n=e,r=t.period,i=t.multiplier),a}return{name:`boll`,version:`1.0.0`,description:`布林带渲染器`,debugName:`BOLL布林带`,paneId:`main`,priority:q.INDICATOR,draw(e){let{ctx:n,pane:r,data:i,range:a,scrollLeft:s,dpr:c,kLineCenters:l}=e,u=i;if(u.length<t.period)return;let d=o(u);n.save(),n.translate(-s,0);let f=Math.max(a.start,t.period-1),p=Math.min(a.end,u.length);if(t.showBand){n.fillStyle=va.BAND_FILL,n.beginPath();let e=!0;for(let t=f;t<p;t++){let i=d[t];if(!i)continue;let o=l[t-a.start];if(o===void 0)continue;let s=r.yAxis.priceToY(i.upper),u=o,f=Q(s,c);e?(n.moveTo(u,f),e=!1):n.lineTo(u,f)}for(let e=p-1;e>=f;e--){let t=d[e];if(!t)continue;let i=l[e-a.start];if(i===void 0)continue;let o=r.yAxis.priceToY(t.lower),s=i,u=Q(o,c);n.lineTo(s,u)}n.closePath(),n.fill()}n.lineWidth=1,n.lineJoin=`round`,n.lineCap=`round`;let m=(e,t)=>{n.strokeStyle=t,n.beginPath();let i=!0;for(let t=f;t<p;t++){let o=d[t];if(!o)continue;let s=l[t-a.start];if(s===void 0)continue;let u=r.yAxis.priceToY(o[e]),f=s,p=Q(u,c);i?(n.moveTo(f,p),i=!1):n.lineTo(f,p)}n.stroke()};t.showUpper&&m(`upper`,va.UPPER),t.showMiddle&&m(`middle`,va.MIDDLE),t.showLower&&m(`lower`,va.LOWER),n.restore()},onDataUpdate(){n=null},getConfig(){return{...t}},setConfig(e){`period`in e&&e.period!==t.period&&(n=null),`multiplier`in e&&e.multiplier!==t.multiplier&&(n=null),Object.assign(t,e)}}}function Es(e,t,n=20,r=2){if(t<n-1||t>=e.length)return null;let i=0;for(let r=0;r<n;r++){let n=e[t-r];if(!n)return null;i+=n.close}let a=i/n,o=0;for(let r=0;r<n;r++){let n=e[t-r];if(!n)return null;o+=(n.close-a)**2}let s=Math.sqrt(o/n);return{upper:a+r*s,middle:a,lower:a-r*s}}function Ds(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 Os(e,t,n=12,r=50){if(t<0||t>=e.length)return null;let i=2/(n+1),a=2/(r+1),o=e[0].close,s=o,c=o;for(let n=1;n<=t;n++){let t=e[n].close;s=t*i+s*(1-i),c=t*a+c*(1-a)}return{fast:s,slow:c}}function ks(e={}){let t={fastPeriod:12,slowPeriod:50,...e},n=null,r=0,i=0,a=[];function o(e){return(n!==e||r!==t.fastPeriod||i!==t.slowPeriod)&&(a=Ds(e,t.fastPeriod,t.slowPeriod),n=e,r=t.fastPeriod,i=t.slowPeriod),a}return{name:`expma`,version:`1.0.0`,description:`EXPMA 指数平滑移动平均线渲染器`,debugName:`EXPMA`,paneId:`main`,priority:q.INDICATOR,draw(e){let{ctx:t,pane:n,data:r,range:i,scrollLeft:a,kWidth:s,dpr:c,kLinePositions:l}=e,u=r;if(u.length<2)return;let d=o(u);t.save(),t.translate(-a,0);let f=i.start,p=Math.min(i.end,u.length),m=Da.FAST,h=Da.SLOW,g=(r,a)=>{t.strokeStyle=a,t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,t.beginPath();let o=!0;for(let a=f;a<p;a++){let s=d[a];if(!s)continue;let l=e.kLineCenters[a-i.start];if(l===void 0)continue;let u=n.yAxis.priceToY(s[r]),f=l,p=Q(u,c);o?(t.moveTo(f,p),o=!1):t.lineTo(f,p)}t.stroke()};g(`fast`,m),g(`slow`,h),t.restore()},onDataUpdate(){n=null},getConfig(){return{...t}},setConfig(e){`fastPeriod`in e&&e.fastPeriod!==t.fastPeriod&&(n=null),`slowPeriod`in e&&e.slowPeriod!==t.slowPeriod&&(n=null),Object.assign(t,e)}}}function As(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,n=10,r=11){if(t<n-1||t>=e.length)return null;let i=0;for(let r=0;r<n;r++){let n=e[t-r];if(!n)return null;i+=n.close}let a=i/n,o=r/100;return{upper:a*(1+o),middle:a,lower:a*(1-o)}}function Ms(e={}){let t={period:10,deviation:11,...e},n=null,r=0,i=0,a=[];function o(e){return(n!==e||r!==t.period||i!==t.deviation)&&(a=As(e,t.period,t.deviation),n=e,r=t.period,i=t.deviation),a}return{name:`ene`,version:`1.0.0`,description:`ENE 轨道线渲染器`,debugName:`ENE轨道线`,paneId:`main`,priority:q.INDICATOR,draw(e){let{ctx:n,pane:r,data:i,range:a,scrollLeft:s,dpr:c,kLineCenters:l}=e,u=i;if(u.length<t.period)return;let d=o(u);n.save(),n.translate(-s,0);let f=Math.max(a.start,t.period-1),p=Math.min(a.end,u.length);n.fillStyle=`rgba(69, 112, 249, 0.08)`,n.beginPath();let m=!0;for(let e=f;e<p;e++){let t=d[e];if(!t)continue;let i=l[e-a.start];if(i===void 0)continue;let o=r.yAxis.priceToY(t.upper),s=i,u=Q(o,c);m?(n.moveTo(s,u),m=!1):n.lineTo(s,u)}for(let e=p-1;e>=f;e--){let t=d[e];if(!t)continue;let i=l[e-a.start];if(i===void 0)continue;let o=r.yAxis.priceToY(t.lower),s=i,u=Q(o,c);n.lineTo(s,u)}n.closePath(),n.fill(),n.lineWidth=1,n.lineJoin=`round`,n.lineCap=`round`;let h=(e,t)=>{n.strokeStyle=t,n.beginPath();let i=!0;for(let t=f;t<p;t++){let o=d[t];if(!o)continue;let s=l[t-a.start];if(s===void 0)continue;let u=r.yAxis.priceToY(o[e]),f=s,p=Q(u,c);i?(n.moveTo(f,p),i=!1):n.lineTo(f,p)}n.stroke()};h(`upper`,`rgba(214, 10, 34, 1)`),h(`middle`,`rgba(69, 112, 249, 1)`),h(`lower`,`rgba(3, 123, 102, 1)`),n.restore()},onDataUpdate(){n=null},getConfig(){return{...t}},setConfig(e){`period`in e&&e.period!==t.period&&(n=null),`deviation`in e&&e.deviation!==t.deviation&&(n=null),Object.assign(t,e)}}}function Ns(e,t,n){if(t<n-1)return;let r=0;for(let i=0;i<n;i++){let n=e[t-i];if(!n)return;r+=n.close}return r/n}function Ps(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}}}};return{name:`mainIndicatorLegend`,version:`1.0.0`,description:`主图指标图例渲染器(统一管理 MA、BOLL 等)`,debugName:`主图指标图例`,paneId:`main`,priority:q.FOREGROUND,enabled:!0,draw(e){let{ctx:n,data:r,range:i,crosshairIndex:a}=e,o=r;if(!o.length)return;n.save(),n.font=`12px Arial`,n.textAlign=`left`;let s=a??Math.min(i.end-1,o.length-1),c=[],l=t.indicators.MA;l?.enabled&&c.push({draw:e=>{let r=[],i=l.params.periods;if(i&&Array.isArray(i)?i.forEach(e=>{let t=`MA${e}`;r.push({label:`MA${e}`,color:Y[t]||Y.MA5,value:Ns(o,s,e)})}):r.push({label:`MA5`,color:Y.MA5,value:Ns(o,s,5)},{label:`MA10`,color:Y.MA10,value:Ns(o,s,10)},{label:`MA20`,color:Y.MA20,value:Ns(o,s,20)},{label:`MA30`,color:Y.MA30,value:Ns(o,s,30)},{label:`MA60`,color:Y.MA60,value:Ns(o,s,60)}),r.length>0){let i=12,a=t.yPaddingPx/2+12+e*18;n.fillStyle=J.NEUTRAL,n.fillText(`MA`,i,a),i+=n.measureText(`MA`).width+10;for(let e of r){let t=typeof e.value==`number`?` ${e.value.toFixed(2)}`:``,r=`${e.label}${t}`;n.fillStyle=e.color,n.fillText(r,i,a),i+=n.measureText(r).width+10}}}});let u=t.indicators.BOLL;u?.enabled&&c.push({draw:e=>{let r=u.params.period??20,i=u.params.multiplier??2,a=Es(o,s,r,i),c=12,l=t.yPaddingPx/2+12+e*18;n.fillStyle=J.NEUTRAL,n.fillText(`BOLL(${r},${i})`,c,l),c+=n.measureText(`BOLL(${r},${i})`).width+10,a&&(n.fillStyle=va.UPPER,n.fillText(`上轨:${a.upper.toFixed(2)}`,c,l),c+=n.measureText(`上轨:${a.upper.toFixed(2)}`).width+10,n.fillStyle=va.MIDDLE,n.fillText(`中轨:${a.middle.toFixed(2)}`,c,l),c+=n.measureText(`中轨:${a.middle.toFixed(2)}`).width+10,n.fillStyle=va.LOWER,n.fillText(`下轨:${a.lower.toFixed(2)}`,c,l))}});let d=t.indicators.EXPMA;d?.enabled&&c.push({draw:e=>{let r=d.params.fastPeriod??12,i=d.params.slowPeriod??50,a=Os(o,s,r,i),c=12,l=t.yPaddingPx/2+12+e*18;n.fillStyle=J.NEUTRAL,n.fillText(`EXPMA(${r},${i})`,c,l),c+=n.measureText(`EXPMA(${r},${i})`).width+10,a&&(n.fillStyle=Da.FAST,n.fillText(`快:${a.fast.toFixed(2)}`,c,l),c+=n.measureText(`快:${a.fast.toFixed(2)}`).width+10,n.fillStyle=Da.SLOW,n.fillText(`慢:${a.slow.toFixed(2)}`,c,l))}});let f=t.indicators.ENE;f?.enabled&&c.push({draw:e=>{let r=f.params.period??10,i=f.params.deviation??11,a=js(o,s,r,i),c=12,l=t.yPaddingPx/2+12+e*18;n.fillStyle=J.NEUTRAL,n.fillText(`ENE(${r},${i})`,c,l),c+=n.measureText(`ENE(${r},${i})`).width+10,a&&(n.fillStyle=Oa.UPPER,n.fillText(`上轨:${a.upper.toFixed(2)}`,c,l),c+=n.measureText(`上轨:${a.upper.toFixed(2)}`).width+10,n.fillStyle=Oa.MIDDLE,n.fillText(`中轨:${a.middle.toFixed(2)}`,c,l),c+=n.measureText(`中轨:${a.middle.toFixed(2)}`).width+10,n.fillStyle=Oa.LOWER,n.fillText(`下轨:${a.lower.toFixed(2)}`,c,l))}}),c.forEach((e,t)=>e.draw(t)),n.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 Fs(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 Is(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 Ls(e,t,n,r){let i=Array(e.length);if(e.length<n)return i;let a=Fs(e,t),o=Fs(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=Is(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 Rs(e={}){let{paneId:t=`sub`,config:n={}}=e,r=hs(`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=Ls(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:q.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;n.save(),n.translate(-l,0);let 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;for(let r=E;r<D;r++){let i=p[r];if(!i)continue;let a=e.kBarRects[r-c.start];if(!a)continue;let s=a.x,l=a.width,d=o.height-(i.macd-C)/w*o.height,f=i.macd>=0,m=r>0?p[r-1]:null,h;h=m?i.macd>=m.macd:!0;let g;g=f?h?ya.BAR_UP:ya.BAR_UP_LIGHT:h?ya.BAR_DOWN_LIGHT:ya.BAR_DOWN,n.fillStyle=g;let _=Math.round(d*u)/u,v=1/u;if(f){let e=t-_,r=e<=0?v:Math.max(e,v),i=e<=0?t-v:t-r;n.fillRect(s,i,l,r)}else{let e=_-t,r=e<=0?v:Math.max(e,v);n.fillRect(s,t,l,r)}}}if(a.showDIF){n.strokeStyle=ya.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=Q(s,u);t?(n.moveTo(l,d),t=!1):n.lineTo(l,d)}n.stroke()}if(a.showDEA){n.strokeStyle=ya.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=Q(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 zs(e,t,n=12,r=26,i=9){return t<r||t>=e.length?null:Ls(e,n,r,i)[t]??null}function Bs(e,t,n=12,r=26,i=9){let a=zs(e,t,n,r,i);return a?{name:`MACD`,params:[n,r,i],values:[{label:`DIF`,value:a.dif,color:ya.DIF},{label:`DEA`,value:a.dea,color:ya.DEA},{label:`MACD`,value:a.macd,color:a.macd>=0?ya.BAR_UP:ya.BAR_DOWN}]}:null}function Vs(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 Hs(e={}){let{paneId:t=`sub`,config:n={}}=e,r=hs(`rsi`,t),i=null,a={period1:6,period2:12,period3:24,showRSI1:!0,showRSI2:!0,showRSI3:!0,...n},o=null,s=0,c=0,l=0,u=[],d=[],f=[];function p(e){return(o!==e||s!==a.period1||c!==a.period2||l!==a.period3)&&(u=Vs(e,a.period1),d=Vs(e,a.period2),f=Vs(e,a.period3),o=e,s=a.period1,c=a.period2,l=a.period3),{rsi1:u,rsi2:d,rsi3:f}}return{name:`rsi_${t}`,version:`1.0.0`,description:`RSI 相对强弱指标渲染器`,debugName:`RSI`,paneId:t,priority:q.MAIN,onInstall(e){i=e},getDeclaredNamespaces(){return[r]},draw(e){let{ctx:n,pane:o,data:s,range:c,scrollLeft:l,dpr:u,kLineCenters:d}=e,f=s;if(f.length<a.period1+1)return;let{rsi1:m,rsi2:h,rsi3:g}=p(f),_={valueMin:0,valueMax:100,timestamp:Date.now()};i?.setSharedState(r,_,`rsi_${t}`);let v=o.yAxis.getDisplayRange({minPrice:0,maxPrice:100}),y=v.minPrice,b=v.maxPrice-y||1;n.save(),n.translate(-l,0);let x=o.height-(80-y)/b*o.height,S=o.height-(50-y)/b*o.height,C=o.height-(20-y)/b*o.height,w=l,T=l+e.paneWidth;n.strokeStyle=`rgba(0, 0, 0, 0.1)`,n.lineWidth=1,n.setLineDash([4,4]),n.beginPath(),n.moveTo(w,x),n.lineTo(T,x),n.moveTo(w,S),n.lineTo(T,S),n.moveTo(w,C),n.lineTo(T,C),n.stroke(),n.setLineDash([]);let E=Math.max(c.start,a.period1),D=Math.min(c.end,f.length),O=(e,t)=>{n.strokeStyle=t,n.lineWidth=1,n.lineJoin=`round`,n.lineCap=`round`,n.beginPath();let r=!0;for(let t=E;t<D;t++){let i=e[t];if(i===void 0)continue;let a=d[t-c.start];if(a===void 0)continue;let s=o.height-(i-y)/b*o.height,l=a,f=Q(s,u);r?(n.moveTo(l,f),r=!1):n.lineTo(l,f)}n.stroke()};a.showRSI1&&O(m,xa.RSI1),a.showRSI2&&O(h,xa.RSI2),a.showRSI3&&O(g,xa.RSI3),n.restore()},onDataUpdate(){o=null},getConfig(){return{...a}},setConfig(e){`period1`in e&&e.period1!==a.period1&&(o=null),`period2`in e&&e.period2!==a.period2&&(o=null),`period3`in e&&e.period3!==a.period3&&(o=null),Object.assign(a,e)}}}function Us(e,t,n=6,r=12,i=24){if(t<n+1||t>=e.length)return null;let a=Vs(e,n)[t],o=Vs(e,r)[t],s=Vs(e,i)[t],c=[];return a!==void 0&&c.push({label:`RSI${n}`,value:a,color:xa.RSI1}),o!==void 0&&c.push({label:`RSI${r}`,value:o,color:xa.RSI2}),s!==void 0&&c.push({label:`RSI${i}`,value:s,color:xa.RSI3}),c.length===0?null:{name:`RSI`,params:[n,r,i],values:c}}function Ws(e,t){let n=Array(e.length);if(e.length<t)return n;let r=e.map(e=>(e.high+e.low+e.close)/3);for(let i=t-1;i<e.length;i++){let e=0;for(let n=0;n<t;n++)e+=r[i-n];let a=e/t,o=0;for(let e=0;e<t;e++)o+=Math.abs(r[i-e]-a);let s=o/t;s===0?n[i]=0:n[i]=(r[i]-a)/(.015*s)}return n}function Gs(e={}){let{paneId:t=`sub`,config:n={}}=e,r=hs(`cci`,t),i=null,a={period:14,showCCI:!0,...n},o=null,s=0,c=[];function l(e){return(o!==e||s!==a.period)&&(c=Ws(e,a.period),o=e,s=a.period),c}return{name:`cci_${t}`,version:`1.0.0`,description:`CCI 顺势指标渲染器`,debugName:`CCI`,paneId:t,priority:q.MAIN,onInstall(e){i=e},getDeclaredNamespaces(){return[r]},draw(e){let{ctx:n,pane:o,data:s,range:c,scrollLeft:u,dpr:d,kLineCenters:f}=e,p=s;if(p.length<a.period)return;let m=l(p),h=-1/0,g=1/0;for(let e=c.start;e<c.end&&e<m.length;e++){let t=m[e];t!==void 0&&(h=Math.max(h,t),g=Math.min(g,t))}if(!Number.isFinite(h)||!Number.isFinite(g))return;h=Math.max(h,150),g=Math.min(g,-150),h-g;let _={valueMin:g,valueMax:h,timestamp:Date.now()};i?.setSharedState(r,_,`cci_${t}`);let v=o.yAxis.getDisplayRange({minPrice:g,maxPrice:h}),y=v.minPrice,b=v.maxPrice-y||1,x=o.height-(0-y)/b*o.height;n.save(),n.translate(-u,0);let S=o.height-(100-y)/b*o.height,C=o.height-(-100-y)/b*o.height,w=u,T=u+e.paneWidth;n.strokeStyle=Sa.OVERBOUGHT,n.lineWidth=1,n.setLineDash([4,4]),n.beginPath(),n.moveTo(w,S),n.lineTo(T,S),n.stroke(),n.strokeStyle=Sa.OVERSOLD,n.beginPath(),n.moveTo(w,C),n.lineTo(T,C),n.stroke(),n.strokeStyle=`rgba(0, 0, 0, 0.1)`,n.beginPath(),n.moveTo(w,x),n.lineTo(T,x),n.stroke(),n.setLineDash([]);let E=Math.max(c.start,a.period-1),D=Math.min(c.end,p.length);if(a.showCCI){n.strokeStyle=Sa.CCI,n.lineWidth=1,n.lineJoin=`round`,n.lineCap=`round`,n.beginPath();let e=!0;for(let t=E;t<D;t++){let r=m[t];if(r===void 0)continue;let i=f[t-c.start];if(i===void 0)continue;let a=o.height-(r-y)/b*o.height,s=i,l=Q(a,d);e?(n.moveTo(s,l),e=!1):n.lineTo(s,l)}n.stroke()}n.restore()},onDataUpdate(){o=null},getConfig(){return{...a}},setConfig(e){`period`in e&&e.period!==a.period&&(o=null),Object.assign(a,e)}}}function Ks(e,t,n){return Ws(e,n)[t]}function qs(e,t,n=14){if(t<n||t>=e.length)return null;let r=Ks(e,t,n);return r===void 0?null:{name:`CCI`,params:[n],values:[{label:`CCI`,value:r,color:Sa.CCI}]}}function Js(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 Ys(e={}){let{paneId:t=`sub`,config:n={}}=e,r=hs(`stoch`,t),i=null,a={n:9,m:3,showK:!0,showD:!0,...n},o=null,s=0,c=0,l=[];function u(e){return(o!==e||s!==a.n||c!==a.m)&&(l=Js(e,a.n,a.m),o=e,s=a.n,c=a.m),l}return{name:`stoch_${t}`,version:`1.0.0`,description:`STOCH 随机指标渲染器`,debugName:`STOCH`,paneId:t,priority:q.MAIN,onInstall(e){i=e},getDeclaredNamespaces(){return[r]},draw(e){let{ctx:n,pane:o,data:s,range:c,scrollLeft:l,dpr:d,kLineCenters:f}=e,p=s;if(p.length<a.n+a.m-1)return;let m=u(p),h={valueMin:0,valueMax:100,timestamp:Date.now()};i?.setSharedState(r,h,`stoch_${t}`);let g=o.yAxis.getDisplayRange({minPrice:0,maxPrice:100}),_=g.minPrice,v=g.maxPrice-_||1;n.save(),n.translate(-l,0);let y=o.height-(80-_)/v*o.height,b=o.height-(20-_)/v*o.height,x=l,S=l+e.paneWidth;n.strokeStyle=`rgba(0, 0, 0, 0.1)`,n.lineWidth=1,n.setLineDash([4,4]),n.beginPath(),n.moveTo(x,y),n.lineTo(S,y),n.moveTo(x,b),n.lineTo(S,b),n.stroke(),n.setLineDash([]);let C=Math.max(c.start,a.n+a.m-2),w=Math.min(c.end,p.length);if(a.showK){n.strokeStyle=Ca.K,n.lineWidth=1,n.lineJoin=`round`,n.lineCap=`round`,n.beginPath();let e=!0;for(let t=C;t<w;t++){let r=m[t];if(!r)continue;let i=f[t-c.start];if(i===void 0)continue;let a=o.height-(r.k-_)/v*o.height,s=i,l=Q(a,d);e?(n.moveTo(s,l),e=!1):n.lineTo(s,l)}n.stroke()}if(a.showD){n.strokeStyle=Ca.D,n.lineWidth=1,n.lineJoin=`round`,n.lineCap=`round`,n.beginPath();let e=!0;for(let t=C;t<w;t++){let r=m[t];if(!r)continue;let i=f[t-c.start];if(i===void 0)continue;let a=o.height-(r.d-_)/v*o.height,s=i,l=Q(a,d);e?(n.moveTo(s,l),e=!1):n.lineTo(s,l)}n.stroke()}n.restore()},onDataUpdate(){o=null},getConfig(){return{...a}},setConfig(e){`n`in e&&e.n!==a.n&&(o=null),`m`in e&&e.m!==a.m&&(o=null),Object.assign(a,e)}}}function Xs(e,t,n,r){return Js(e,n,r)[t]}function Zs(e,t,n=9,r=3){if(t<n+r-1||t>=e.length)return null;let i=Xs(e,t,n,r);return i?{name:`STOCH`,params:[n,r],values:[{label:`K`,value:i.k,color:Ca.K},{label:`D`,value:i.d,color:Ca.D}]}:null}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={}){let{paneId:t=`sub`,config:n={}}=e,r=hs(`mom`,t),i=null,a={period:10,showMOM:!0,...n},o=null,s=0,c=[];function l(e){return(o!==e||s!==a.period)&&(c=Qs(e,a.period),o=e,s=a.period),c}return{name:`mom_${t}`,version:`1.0.0`,description:`MOM 动量指标渲染器`,debugName:`MOM`,paneId:t,priority:q.MAIN,onInstall(e){i=e},getDeclaredNamespaces(){return[r]},draw(e){let{ctx:n,pane:o,data:s,range:c,scrollLeft:u,dpr:d,kLineCenters:f}=e,p=s;if(p.length<a.period+1)return;let m=l(p),h=-1/0,g=1/0;for(let e=c.start;e<c.end&&e<m.length;e++){let t=m[e];t!==void 0&&(h=Math.max(h,t),g=Math.min(g,t))}if(!Number.isFinite(h)||!Number.isFinite(g))return;let _=Math.max(Math.abs(h),Math.abs(g))*.1;h+=_,g-=_,h-g;let v={valueMin:g,valueMax:h,timestamp:Date.now()};i?.setSharedState(r,v,`mom_${t}`);let y=o.yAxis.getDisplayRange({minPrice:g,maxPrice:h}),b=y.minPrice,x=y.maxPrice-b||1,S=o.height-(0-b)/x*o.height;n.save(),n.translate(-u,0);let C=u,w=u+e.paneWidth;n.strokeStyle=wa.ZERO,n.lineWidth=1,n.beginPath(),n.moveTo(C,S),n.lineTo(w,S),n.stroke();let T=Math.max(c.start,a.period),E=Math.min(c.end,p.length);if(a.showMOM){n.strokeStyle=wa.MOM,n.lineWidth=1,n.lineJoin=`round`,n.lineCap=`round`,n.beginPath();let e=!0;for(let t=T;t<E;t++){let r=m[t];if(r===void 0)continue;let i=f[t-c.start];if(i===void 0)continue;let a=o.height-(r-b)/x*o.height,s=i,l=Q(a,d);e?(n.moveTo(s,l),e=!1):n.lineTo(s,l)}n.stroke()}n.restore()},onDataUpdate(){o=null},getConfig(){return{...a}},setConfig(e){`period`in e&&e.period!==a.period&&(o=null),Object.assign(a,e)}}}function ec(e,t,n){return Qs(e,n)[t]}function tc(e,t,n=10){if(t<n||t>=e.length)return null;let r=ec(e,t,n);return r===void 0?null:{name:`MOM`,params:[n],values:[{label:`MOM`,value:r,color:wa.MOM}]}}function nc(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 rc(e={}){let{paneId:t=`sub`,config:n={}}=e,r=hs(`wmsr`,t),i=null,a={period:14,showWMSR:!0,...n},o=null,s=0,c=[];function l(e){return(o!==e||s!==a.period)&&(c=nc(e,a.period),o=e,s=a.period),c}return{name:`wmsr_${t}`,version:`1.0.0`,description:`WMSR 威廉指标渲染器`,debugName:`WMSR`,paneId:t,priority:q.MAIN,onInstall(e){i=e},getDeclaredNamespaces(){return[r]},draw(e){let{ctx:n,pane:o,data:s,range:c,scrollLeft:u,dpr:d,kLineCenters:f}=e,p=s;if(p.length<a.period)return;let m=l(p),h=-100;0-h;let g={valueMin:h,valueMax:0,timestamp:Date.now()};i?.setSharedState(r,g,`wmsr_${t}`);let _=o.yAxis.getDisplayRange({minPrice:h,maxPrice:0}),v=_.minPrice,y=_.maxPrice-v||1;n.save(),n.translate(-u,0);let b=o.height-(-20-v)/y*o.height,x=o.height-(-80-v)/y*o.height,S=o.height-(-50-v)/y*o.height,C=u,w=u+e.paneWidth;n.strokeStyle=Ta.OVERBOUGHT,n.lineWidth=1,n.setLineDash([4,4]),n.beginPath(),n.moveTo(C,b),n.lineTo(w,b),n.stroke(),n.strokeStyle=Ta.OVERSOLD,n.beginPath(),n.moveTo(C,x),n.lineTo(w,x),n.stroke(),n.strokeStyle=`rgba(0, 0, 0, 0.1)`,n.beginPath(),n.moveTo(C,S),n.lineTo(w,S),n.stroke(),n.setLineDash([]);let T=Math.max(c.start,a.period-1),E=Math.min(c.end,p.length);if(a.showWMSR){n.strokeStyle=Ta.WMSR,n.lineWidth=1,n.lineJoin=`round`,n.lineCap=`round`,n.beginPath();let e=!0;for(let t=T;t<E;t++){let r=m[t];if(r===void 0)continue;let i=f[t-c.start];if(i===void 0)continue;let a=o.height-(r-v)/y*o.height,s=i,l=Q(a,d);e?(n.moveTo(s,l),e=!1):n.lineTo(s,l)}n.stroke()}n.restore()},onDataUpdate(){o=null},getConfig(){return{...a}},setConfig(e){`period`in e&&e.period!==a.period&&(o=null),Object.assign(a,e)}}}function ic(e,t,n){return nc(e,n)[t]}function ac(e,t,n=14){if(t<n||t>=e.length)return null;let r=ic(e,t,n);return r===void 0?null:{name:`WMSR`,params:[n],values:[{label:`WMSR`,value:r,color:Ta.WMSR}]}}function oc(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 sc(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 cc(e,t,n,r,i,a){let o=Array(e.length),s=oc(e,t),c=oc(e,n),l=oc(e,r),u=oc(e,i),d=sc(s,10),f=sc(c,10),p=sc(l,10),m=sc(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=sc(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 lc(e={}){let{paneId:t=`sub`,config:n={}}=e,r=hs(`kst`,t),i=null,a={roc1:10,roc2:15,roc3:20,roc4:30,signalPeriod:9,showKST:!0,showSignal:!0,...n},o=null,s=``,c=[];function l(e){let t=`${a.roc1}-${a.roc2}-${a.roc3}-${a.roc4}-${a.signalPeriod}`;return(o!==e||s!==t)&&(c=cc(e,a.roc1,a.roc2,a.roc3,a.roc4,a.signalPeriod),o=e,s=t),c}return{name:`kst_${t}`,version:`1.0.0`,description:`KST 确知指标渲染器`,debugName:`KST`,paneId:t,priority:q.MAIN,onInstall(e){i=e},getDeclaredNamespaces(){return[r]},draw(e){let{ctx:n,pane:o,data:s,range:c,scrollLeft:u,dpr:d,kLineCenters:f}=e,p=s;if(p.length<a.roc4+15+a.signalPeriod)return;let m=l(p),h=-1/0,g=1/0;for(let e=c.start;e<c.end&&e<m.length;e++){let t=m[e];t&&(h=Math.max(h,t.kst,t.signal),g=Math.min(g,t.kst,t.signal))}if(!Number.isFinite(h)||!Number.isFinite(g))return;let _=(h-g)*.1||1;h+=_,g-=_,h-g;let v={valueMin:g,valueMax:h,timestamp:Date.now()};i?.setSharedState(r,v,`kst_${t}`);let y=o.yAxis.getDisplayRange({minPrice:g,maxPrice:h}),b=y.minPrice,x=y.maxPrice-b||1,S=o.height-(0-b)/x*o.height;n.save(),n.translate(-u,0);let C=u,w=u+e.paneWidth;n.strokeStyle=`rgba(0, 0, 0, 0.1)`,n.lineWidth=1,n.beginPath(),n.moveTo(C,S),n.lineTo(w,S),n.stroke();let T=Math.max(c.start,a.roc4+15+a.signalPeriod-1),E=Math.min(c.end,p.length);if(a.showKST){n.strokeStyle=Ea.KST,n.lineWidth=1,n.lineJoin=`round`,n.lineCap=`round`,n.beginPath();let e=!0;for(let t=T;t<E;t++){let r=m[t];if(!r)continue;let i=f[t-c.start];if(i===void 0)continue;let a=o.height-(r.kst-b)/x*o.height,s=i,l=Q(a,d);e?(n.moveTo(s,l),e=!1):n.lineTo(s,l)}n.stroke()}if(a.showSignal){n.strokeStyle=Ea.SIGNAL,n.lineWidth=1,n.lineJoin=`round`,n.lineCap=`round`,n.beginPath();let e=!0;for(let t=T;t<E;t++){let r=m[t];if(!r)continue;let i=f[t-c.start];if(i===void 0)continue;let a=o.height-(r.signal-b)/x*o.height,s=i,l=Q(a,d);e?(n.moveTo(s,l),e=!1):n.lineTo(s,l)}n.stroke()}n.restore()},onDataUpdate(){o=null},getConfig(){return{...a}},setConfig(e){o=null,Object.assign(a,e)}}}function uc(e,t,n,r,i,a,o){return cc(e,n,r,i,a,o)[t]}function dc(e,t,n=10,r=15,i=20,a=30,o=9){if(t<a+15+o||t>=e.length)return null;let s=uc(e,t,n,r,i,a,o);return s?{name:`KST`,params:[n,r,i,a,o],values:[{label:`KST`,value:s.kst,color:Ea.KST},{label:`Signal`,value:s.signal,color:Ea.SIGNAL}]}:null}function fc(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 pc(e={}){let{paneId:t=`sub`,config:n={}}=e,r=hs(`fastk`,t),i=null,a={period:9,showFASTK:!0,...n},o=null,s=0,c=[];function l(e){return(o!==e||s!==a.period)&&(c=fc(e,a.period),o=e,s=a.period),c}return{name:`fastk_${t}`,version:`1.0.0`,description:`FASTK 快速随机指标渲染器`,debugName:`FASTK`,paneId:t,priority:q.MAIN,onInstall(e){i=e},getDeclaredNamespaces(){return[r]},draw(e){let{ctx:n,pane:o,data:s,range:c,scrollLeft:u,dpr:d,kLineCenters:f}=e,p=s;if(p.length<a.period)return;let m=l(p),h={valueMin:0,valueMax:100,timestamp:Date.now()};i?.setSharedState(r,h,`fastk_${t}`);let g=o.yAxis.getDisplayRange({minPrice:0,maxPrice:100}),_=g.minPrice,v=g.maxPrice-_||1;n.save(),n.translate(-u,0);let y=o.height-(80-_)/v*o.height,b=o.height-(20-_)/v*o.height,x=u,S=u+e.paneWidth;n.strokeStyle=`rgba(0, 0, 0, 0.1)`,n.lineWidth=1,n.setLineDash([4,4]),n.beginPath(),n.moveTo(x,y),n.lineTo(S,y),n.moveTo(x,b),n.lineTo(S,b),n.stroke(),n.setLineDash([]);let C=Math.max(c.start,a.period-1),w=Math.min(c.end,p.length);if(a.showFASTK){n.strokeStyle=Ca.K,n.lineWidth=1,n.lineJoin=`round`,n.lineCap=`round`,n.beginPath();let e=!0;for(let t=C;t<w;t++){let r=m[t];if(r===void 0)continue;let i=f[t-c.start];if(i===void 0)continue;let a=o.height-(r-_)/v*o.height,s=i,l=Q(a,d);e?(n.moveTo(s,l),e=!1):n.lineTo(s,l)}n.stroke()}n.restore()},onDataUpdate(){o=null},getConfig(){return{...a}},setConfig(e){`period`in e&&e.period!==a.period&&(o=null),Object.assign(a,e)}}}function mc(e,t,n){return fc(e,n)[t]}function hc(e,t,n=9){if(t<n||t>=e.length)return null;let r=mc(e,t,n);return r===void 0?null:{name:`FASTK`,params:[n],values:[{label:`FASTK`,value:r,color:Ca.K}]}}function gc(e){let{indicatorId:t,paneId:n}=e;switch(t){case`VOLUME`:return gs({paneId:n});case`MACD`:return Rs({paneId:n});case`RSI`:return Hs({paneId:n});case`CCI`:return Gs({paneId:n});case`STOCH`:return Ys({paneId:n});case`MOM`:return $s({paneId:n});case`WMSR`:return rc({paneId:n});case`KST`:return lc({paneId:n});case`FASTK`:return pc({paneId:n});default:throw Error(`Unknown indicator: ${t}`)}}var _c=8,vc=6,yc=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);for(let r of n){if(r.kind===`regression-channel`&&r.anchors.length>=2){let n=this.hitTestRegressionEndpoints(r,e,t);if(n)return n}for(let n=0;n<r.anchors.length;n++){let i=this.anchorToScreen(r.anchors[n]);if(i&&Math.hypot(e-i.x,t-i.y)<=_c)return{drawing:r,anchorIndex:n}}}for(let r of n){let n=this.getDrawingLineSegments(r);for(let i of n)if(bc(e,t,i.a,i.b)<=vc)return{drawing:r}}return null}getDrawingLineSegments(e){let t=this.chart.getViewport();if(!t)return[];if(e.anchors.length===1){let n=this.anchorToScreen(e.anchors[0]);if(!n)return[];let r=this.chart.getPaneRenderers().find(e=>e.getPane().id===`main`)?.getPane();if(!r)return[];let i=t.plotWidth,a=r.height;switch(e.kind){case`horizontal-line`:return[{a:{x:0,y:n.y},b:{x:i,y:n.y}}];case`horizontal-ray`:return[{a:n,b:{x:i,y:n.y}}];case`vertical-line`:return[{a:{x:n.x,y:0},b:{x:n.x,y:a}}];case`cross-line`:return[{a:{x:0,y:n.y},b:{x:i,y:n.y}},{a:{x:n.x,y:0},b:{x:n.x,y:a}}];default:return[]}}let n=e.anchors.map(e=>this.anchorToScreen(e)).filter(Boolean);if(n.length<2)return[];let r=[];if(n.length===2){let i=n[0],a=n[1];if(e.kind===`regression-channel`){let t=this.chart.getData(),n=Math.round(e.anchors[0].index),i=Math.round(e.anchors[1].index),a=Math.min(Math.max(n,0),Math.max(i,0)),o=Math.max(Math.max(n,0),Math.max(i,0)),s=Math.min(Math.max(a,0),t.length-1),c=Math.min(Math.max(o,0),t.length-1),l=t.slice(s,c+1),u=kc(l.map(e=>e.close));if(u){let t=e.params?.sigma??2,a=u.stdDev*t,o=u.intercept,s=u.intercept+u.slope*(l.length-1),c=this.anchorToScreen({id:``,index:n,price:o}),d=this.anchorToScreen({id:``,index:i,price:s}),f=this.anchorToScreen({id:``,index:n,price:o+a}),p=this.anchorToScreen({id:``,index:i,price:s+a}),m=this.anchorToScreen({id:``,index:n,price:o-a}),h=this.anchorToScreen({id:``,index:i,price:s-a});return c&&d&&r.push({a:c,b:d}),f&&p&&r.push({a:f,b:p}),m&&h&&r.push({a:m,b:h}),r}}let o=a.x-i.x,s=a.y-i.y,c=i,l=a,u=this.getExtendMode(e),d=Math.max(t.plotWidth,t.plotHeight)*4;(u===`right`||u===`both`)&&(l={x:a.x+o*d,y:a.y+s*d}),(u===`left`||u===`both`)&&(c={x:i.x-o*d,y:i.y-s*d}),r.push({a:c,b:l})}else if(n.length>=3)switch(e.kind){case`parallel-channel`:{let[e,t,i]=n,a=t.x-e.x,o=t.y-e.y,s={x:i.x+a,y:i.y+o};r.push({a:e,b:t},{a:i,b:s});break}case`flat-line`:{let[e,t,i]=n,a={x:e.x,y:i.y},o={x:t.x,y:i.y};r.push({a:e,b:t}),r.push({a,b:o});break}case`disjoint-channel`:{let[e,t,i]=n,a=t.x-e.x,o=t.y-e.y,s={x:i.x+a,y:i.y-o};r.push({a:e,b:t}),r.push({a:i,b:s});break}default:for(let e=0;e<n.length-1;e++)r.push({a:n[e],b:n[e+1]})}return r}hitTestRegressionEndpoints(e,t,n){let r=this.chart.getData();if(r.length===0)return 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=kc(u.map(e=>e.close));if(!d)return null;let f=e.params?.sigma??2,p=d.stdDev*f,m=d.intercept,h=d.intercept+d.slope*(u.length-1),g=[{index:i,price:m},{index:a,price:h},{index:i,price:m+p},{index:a,price:h+p},{index:i,price:m-p},{index:a,price:h-p}];for(let r of g){let o=this.anchorToScreen({id:``,index:r.index,price:r.price});if(o&&Math.hypot(t-o.x,n-o.y)<=_c)return{drawing:e,anchorIndex:r.index<=Math.min(i,a)?0:1}}return null}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}=X(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 bc(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 xc=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}},Sc=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 Cc(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 wc(e,t){e.fillStyle=t?.fill??t?.stroke??`#2962ff`,e.globalAlpha=t?.fillOpacity??1}function Tc(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 Ec(e,t){let{a:n,b:r,extend:i=`none`}=e;if(i===`none`)return Tc(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}),Tc(c.x,c.y,l.x,l.y,t)}function Dc(e,t){if(!Number.isFinite(e.index))return-1;let n=Math.round(e.index);return n<0||n>=t.length?-1:n}function Oc(e,t=2){if(!Number.isFinite(e))return`0`;let n=e.toFixed(t);return e>0?`+${n}`:n}function kc(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 Ac(){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=Ec(t,n);if(!i)return;e.save(),Cc(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(),wc(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 jc(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 Mc(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 Nc(){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=`${Oc(c)} (${Oc(l)}%) ${s} bars ${Oc(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 Pc(){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`;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}]}}}}function Fc(){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}]}}}}function Ic(){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};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}]}}}}function Lc(){return{kind:`regression-channel`,minAnchors:2,maxAnchors:2,compute(e,t){let[n,r]=e.anchors;if(!n||!r)return{primitives:[]};let i=Dc(n,t.seriesData),a=Dc(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=kc(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},{kind:`line`,a:w,b:T,style:e.style},{kind:`line`,a:E,b:D,style:e.style}],meta:{sigma:f,stdDev:d.stdDev,slope:d.slope}}}}}function Rc(e){e.register(jc(`trend-line`,`none`)),e.register(jc(`ray`,`right`)),e.register(jc(`extended-line`,`both`)),e.register(Mc(`horizontal-line`)),e.register(Mc(`horizontal-ray`)),e.register(Mc(`vertical-line`)),e.register(Mc(`cross-line`)),e.register(Nc()),e.register(Pc()),e.register(Lc()),e.register(Fc()),e.register(Ic())}function zc(e){let t=e.store,n=e.definitions??new Sc,r=e.renderers??Ac();return Rc(n),{name:`drawingRenderer`,version:`0.1.0`,description:`绘图渲染器`,debugName:`绘图层`,paneId:e.paneId??`main`,priority:q.OVERLAY,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:_}=X(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 e of b){let o=n.compute(e,{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(!o)continue;let b=t.getSelectedId()===e.id?o.primitives.map(t=>Bc(t,e.style)):o.primitives;for(let e of b){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 Bc(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 Vc=class e{dom;opt;data=[];raf=null;viewport=null;paneRenderers=[];markerManager;drawingStore=new xc;interaction;pluginHost;rendererPluginManager;preciseDpr=0;resizeObserver;observedSize={width:0,height:0};paneRatios=new Map;onViewportChange;onPaneLayoutChange;onDataChange;currentZoomLevel=1;zoomLevelCount;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 ds(this),this.markerManager=new io,this.pluginHost=Qi(),this.rendererPluginManager=new ea,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.initPanes(),this.useRenderer(zc({store:this.drawingStore})),this.initResizeObserver()}initResizeObserver(){if(typeof ResizeObserver>`u`)return;let e=this.dom.container;if(e){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()}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()}draw(){this.markerManager.clear();let e=this.computeViewport();if(!e||this.data.length===0)return;let{start:t,end:n}=os(e.scrollLeft,e.plotWidth,this.opt.kWidth,this.opt.kGap,this.data.length,e.dpr),r={start:t,end:n},i=this.calcKLinePositions(r),a=X(this.opt.kWidth,this.opt.kGap,e.dpr),o=Math.max(1,a.unitPx-1);o%2==0&&--o;let s=Array(i.length),c=Array(i.length);for(let t=0;t<i.length;t++){let n=i[t],r=Math.round(n*e.dpr)+(a.kWidthPx-1)/2;s[t]=r/e.dpr,c[t]={x:(r-(o-1)/2)/e.dpr,width:o/e.dpr}}let{kWidthPx:l}=X(this.opt.kWidth,this.opt.kGap,e.dpr);this.interaction.setKLinePositions(i,r,l);for(let t of this.paneRenderers){let n=t.getPane(),a=t.getDom().plotCanvas.getContext(`2d`),o=t.getDom().yAxisCanvas.getContext(`2d`);if(n.updateRange(this.data,r),a&&(a.setTransform(1,0,0,1,0,0),a.scale(e.dpr,e.dpr),a.clearRect(0,0,e.plotWidth+1,n.height+2/e.dpr)),o){let t=o.canvas.width/e.dpr;o.setTransform(1,0,0,1,0,0),o.scale(e.dpr,e.dpr),o.clearRect(0,0,t,n.height+2/e.dpr)}let l={ctx:a,pane:Gi(n),data:this.data,range:r,scrollLeft:e.scrollLeft,kWidth:this.opt.kWidth,kGap:this.opt.kGap,dpr:e.dpr,paneWidth:e.plotWidth,kLinePositions:i,kLineCenters:s,kBarRects:c,markerManager:this.markerManager,crosshairIndex:this.interaction.getCrosshairIndex(),yAxisCtx:o??void 0,zoomLevel:this.currentZoomLevel,zoomLevelCount:this.zoomLevelCount,viewport:{scrollLeft:e.scrollLeft,plotWidth:e.plotWidth,plotHeight:e.plotHeight}};if(a){a.save();let e=this.rendererPluginManager.render(n.id,l);e.length>0&&this.pluginHost.events.emit(`renderer:error`,{paneId:n.id,errors:e}),a.restore()}}let u=this.dom.xAxisCanvas.getContext(`2d`);if(u){let t={ctx:u,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}},priceRange:{maxPrice:0,minPrice:0}},data:this.data,range:r,scrollLeft:e.scrollLeft,kWidth:this.opt.kWidth,kGap:this.opt.kGap,dpr:e.dpr,paneWidth:e.plotWidth,kLinePositions:i,kLineCenters:s,kBarRects:c,xAxisCtx:u,viewport:{scrollLeft:e.scrollLeft,plotWidth:e.plotWidth,plotHeight:e.plotHeight}},n=this.rendererPluginManager.renderPlugin(`timeAxis`,t);n.length>0&&this.pluginHost.events.emit(`renderer:error`,{paneId:`timeAxis`,errors:n})}}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}=X(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=gc({indicatorId:t,paneId:e});this.useRenderer(i,n)}setDrawings(e){this.drawingStore.setAll(e),this.scheduleDraw()}setSelectedDrawingId(e){this.drawingStore.setSelectedId(e)}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()}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);t.scrollLeft>n&&(t.scrollLeft=n)}this.interaction.reset(),this.scheduleDraw()}getData(){return this.data}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}=X(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 ps({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(){this.raf!=null&&cancelAnimationFrame(this.raf),this.raf=requestAnimationFrame(()=>{this.raf=null,this.draw()})}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.viewport=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 us(e.id,{role:this.resolvePaneRole(e,t),capabilities:e.capabilities}),r=document.createElement(`canvas`),i=document.createElement(`canvas`),a=n.role===`price`;return r.id=`${e.id}-plot`,r.className=a?`plot-canvas main`:`plot-canvas sub`,r.style.position=`absolute`,r.style.left=`0`,r.style.top=`0`,i.id=`${e.id}-yAxis`,i.className=`right-axis`,i.style.position=`absolute`,i.style.left=`0`,new fs({plotCanvas:r,yAxisCanvas:i},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.plotCanvas),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,Gi(c));let u=s.getDom();u.plotCanvas.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(e.scrollLeft*s)/s;this.dom.canvasLayer.style.width=`${r}px`,this.dom.canvasLayer.style.height=`${i}px`,this.dom.xAxisCanvas.style.width=`${a}px`,this.dom.xAxisCanvas.style.height=`${this.opt.bottomAxisHeight}px`,this.dom.xAxisCanvas.width=Math.round(a*s),this.dom.xAxisCanvas.height=Math.round(this.opt.bottomAxisHeight*s);let u={viewWidth:r,viewHeight:i,plotWidth:a,plotHeight:o,scrollLeft:l,dpr:s},d=this.viewport,f=!d||d.viewWidth!==u.viewWidth||d.viewHeight!==u.viewHeight||d.plotWidth!==u.plotWidth||d.plotHeight!==u.plotHeight||d.scrollLeft!==u.scrollLeft||d.dpr!==u.dpr;return this.viewport=u,f&&this.onViewportChange?.(u),u}},Hc=3;function Uc(e,t){let n=(e-1)/(t.zoomLevelCount-1);return t.minKWidth+n*(t.maxKWidth-t.minKWidth)}function Wc(e){return Hc/e}function Gc(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=Uc(s,o),l=Wc(o.dpr),u=X(i,a,o.dpr),d=X(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 Kc(e,t,n,r,i,a,o){let s=Math.max(1,Math.min(o.zoomLevelCount,Math.round(e)))-r;return s===0?null:Gc(s,t,n,r,i,a,o)}function qc(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}({}),Jc={volumeAmplifyThreshold:1.5,volumeShrinkThreshold:.8,avgPeriod:20},Yc=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 Xc(e,t,n,r=Jc){let i=new Yc;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 Zc(){return{name:`candle`,version:`1.0.0`,description:`K线蜡烛图渲染器`,debugName:`K线`,paneId:`main`,priority:q.MAIN,draw(e){let{ctx:t,pane:n,data:r,range:i,scrollLeft:a,kWidth:o,kGap:s,dpr:c,kLinePositions:l,markerManager:u}=e,d=r;if(!d.length)return;let{kWidthPx:f}=X(o,s,c);t.save(),t.translate(-a,0);let p=l||[],m=Xc(d,i.start,i.end,Jc);for(let r=i.start;r<i.end&&r<d.length;r++){let a=d[r];if(!a)continue;let s=n.yAxis.priceToY(a.open),l=n.yAxis.priceToY(a.close),h=n.yAxis.priceToY(a.high),g=n.yAxis.priceToY(a.low),_=p[r-i.start];if(!_)continue;let v=e=>Math.round(e*c)/c,y=v(s),b=v(l),x=v(h),S=v(g),C=Math.min(y,b),w=Math.max(Math.abs(y-b),1),T=xs(Math.round(_*c),C,f,w,c);t.fillStyle=qc(a)===`up`?J.UP:J.DOWN,t.fillRect(T.bodyRect.x,T.bodyRect.y,T.bodyRect.width,T.bodyRect.height);let E=T.wickRect.width,D=T.wickRect.x,O=T.bodyRect.y,k=T.bodyRect.y+T.bodyRect.height,A=Math.max(a.open,a.close),j=Math.min(a.open,a.close);if(a.high>A){let e=ys(D,x,O,c);e&&t.fillRect(e.x,e.y,E,e.height)}if(a.low<j){let e=ys(D,k,S,c);e&&t.fillRect(e.x,e.y,E,e.height)}let M=m[r-i.start];if(M!==$.OTHERS&&u&&(e.zoomLevel??1)>=2){let e=M===$.RISE_WITH_VOLUME||M===$.RISE_WITHOUT_VOLUME?x-15:S+15;Qc(t,T.bodyRect.x+T.bodyRect.width/2,e,M,r,o,4,u,c)}}t.restore()}}}function Qc(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 $c(e,t){return Math.max(3,Math.round(e/60)+1)}function el(){return{name:`gridLines`,version:`1.0.0`,description:`网格线渲染器`,debugName:`网格线`,paneId:Ki,priority:q.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;let u=$c(n.height);t.save(),t.fillStyle=_a.HORIZONTAL,t.translate(-a,0);let d=t.canvas.width/s,f=a,p=a+d,m=n.yAxis.getPaddingTop(),h=n.yAxis.getPaddingBottom(),g=m,_=Math.max(m,n.height-h),v=Math.max(0,_-g);for(let e=0;e<u;e++){let n=u<=1?0:e/(u-1),r=bs(f,p,Math.round(g+n*v),s);r&&t.fillRect(r.x,r.y,r.width,r.height)}let y=pa(l);for(let e of y){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=ys(c[r]+o/2,0,n.height,s);a&&t.fillRect(a.x,a.y,a.width,a.height)}t.restore()}}}function tl(){return{name:`lastPriceLine`,version:`1.0.0`,description:`最新价虚线渲染器`,debugName:`最新价线`,paneId:`main`,priority:q.FOREGROUND,draw(e){let{ctx:t,pane:n,data:r,scrollLeft:i,kWidth:a,dpr:o,kLinePositions:s,paneWidth:c}=e,l=r,u=l[l.length-1];if(!u)return;t.save(),t.translate(-i,0);let d=Math.round(n.yAxis.priceToY(u.close)),f=s[0]??0,p=c+i;t.strokeStyle=J.LAST_PRICE,t.lineWidth=1,t.setLineDash([4,3]),t.beginPath();let m=(Math.floor(d*o)+.5)/o;t.moveTo(Math.round(f*o)/o,m),t.lineTo(Math.round(p*o)/o,m),t.stroke(),t.setLineDash([]),t.restore()}}}function nl(){return{name:`extremaMarkers`,version:`1.0.0`,description:`可视区最高/最低价标注渲染器`,debugName:`极值标记`,paneId:Ki,priority:q.OVERLAY,draw(e){let{ctx:t,pane:n,data:r,range:i,scrollLeft:a,kWidth:o,dpr:s,paneWidth:c,kLinePositions:l}=e,u=r;if(!u.length||n.role!==`price`)return;let d=Math.max(0,i.start),f=Math.min(u.length,i.end);if(f-d<=0)return;let p=-1/0,m=1/0,h=d,g=d;for(let e=d;e<f;e++){let t=u[e];t&&(t.high>=p&&(p=t.high,h=e),t.low<=m&&(m=t.low,g=e))}if(!Number.isFinite(p)||!Number.isFinite(m))return;let _=e=>{let t=e-i.start;return t<0||t>=l.length?0:l[t]+o/2};t.save(),t.translate(-a,0),rl(t,_(h),n.yAxis.priceToY(p),p,s,c,a),rl(t,_(g),n.yAxis.priceToY(m),m,s,c,a),t.restore()}}}function rl(e,t,n,r,i,a,o){let s=r.toFixed(2);e.font=`12px Arial`;let c=e.measureText(s).width,l=t-o+30+4+c>a,u=t,d=l?t-30:t+30;u>d&&([u,d]=[d,u]);let f=bs(u,d,n,i);f&&(e.fillStyle=ma.WEAK,e.fillRect(f.x,f.y,f.width,f.height));let p=Z(d,i),m=Z(n,i);e.fillStyle=ma.WEAK,e.beginPath(),e.arc(p,m,2,0,Math.PI*2),e.fill(),e.font=`12px Arial`,e.textBaseline=`middle`,e.fillStyle=J.NEUTRAL,l?(e.textAlign=`right`,e.fillText(s,Z(t-30-4,i),Z(n,i))):(e.textAlign=`left`,e.fillText(s,Z(t+30+4,i),Z(n,i)))}function il(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}function al(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=fa(s);e.save(),e.font=`${l}px -apple-system,BlinkMacSystemFont,Trebuchet MS,Roboto,Ubuntu,sans-serif`,e.textBaseline=`middle`,e.textAlign=`center`;let f=Math.round(e.measureText(d).width),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(Z(_,c),Z(v,c),Z(p,c),Z(m,c)),e.fillStyle=`#ffffff`,e.fillText(d,Z(h,c),Z(g,c)),e.restore()}function ol(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??il(o-r,v,y,a,_,_)+m,x=g?g(b):b.toFixed(2);e.save(),e.font=`${p}px -apple-system,BlinkMacSystemFont,Trebuchet MS,Roboto,Ubuntu,sans-serif`,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=Z(w,l),D=i,O=Z(S,l);e.fillStyle=u,e.fillRect(T,E,D,O),d&&(e.strokeStyle=d,e.lineWidth=1,e.strokeRect(Q(T,l),Q(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,Z(k,l),Z(C,l)),e.restore()}function sl(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=ha.TRANSPARENT,textColor:m=ma.SECONDARY,lineColor:h=ga.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,Q(r,f)),e.lineTo(n+i,Q(r,f)),e.stroke()),y&&(e.strokeStyle=h,e.lineWidth=1,e.beginPath(),e.moveTo(n,Q(r+a,f)),e.lineTo(n+i,Q(r+a,f)),e.stroke()),e.textAlign=`center`,e.textBaseline=`middle`;let O=r+a/2+1,k=pa(o).filter(e=>e>=u&&e<d);for(let t of k){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}=la(n.timestamp);e.fillStyle=m,e.font=`${o?`bold `:``}${g}px -apple-system,BlinkMacSystemFont,Trebuchet MS,Roboto,Ubuntu,sans-serif`,e.fillText(i,Z(t,f),Z(O,f))}}}function cl(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,formatLabel:f}=e,p=c-s||1;t.save(),t.clearRect(0,0,r,i),t.font=`12px -apple-system,BlinkMacSystemFont,Trebuchet MS,Roboto,Ubuntu,sans-serif`,t.textBaseline=`middle`,t.textAlign=`center`;let m=r/2,h=a,g=Math.max(a,i-o),_=Math.max(0,g-h),v=$c(i,l),y=p/Math.max(1,v-1);for(let e=0;e<v;e++){if(d&&(e===0||e===v-1))continue;let r=c-y*e,i=h+(v<=1?0:e/(v-1))*_;t.fillStyle=ma.SECONDARY,t.fillText(f?f(r):r.toFixed(u),Z(m,n),Z(i,n))}t.restore()}function ll(e){let{axisWidth:t,paneId:n,indicatorKey:r,label:i,decimals:a=2,yPaddingPx:o=0,getCrosshair:s,formatTickLabel:c,formatCrosshairLabel:l}=e,u=hs(r,n),d=null;return{name:`${r}Scale_${n}`,version:`1.0.0`,description:`${i} 刻度渲染器`,debugName:`${i}刻度`,paneId:n,priority:q.INDICATOR_SCALE,onInstall(e){d=e},draw(e){let{yAxisCtx:n,pane:r,dpr:i}=e;if(!n||!d)return;let f=d.getSharedState(u);if(!f)return;let p=r.yAxis.getDisplayRange({minPrice:f.valueMin,maxPrice:f.valueMax});cl({ctx:n,dpr:i,axisWidth:t,height:r.height,paddingTop:r.yAxis.getPaddingTop(),paddingBottom:r.yAxis.getPaddingBottom(),valueMin:p.minPrice,valueMax:p.maxPrice,isMain:!1,decimals:a,hideEdgeTicks:!1,formatLabel:c});let m=s?.();if(!m||m.activePaneId!==r.id)return;let h=m.y-r.top,g=r.yAxis.getPaddingTop(),_=r.yAxis.getPaddingBottom(),v=g,y=Math.max(g,r.height-_),b=Math.max(1,y-v),x=(Math.min(Math.max(h,v),y)-v)/b,S=p.maxPrice-x*(p.maxPrice-p.minPrice);ol(n,{x:0,y:0,width:t,height:r.height,crosshairY:h,priceRange:p,yPaddingPx:o,dpr:i,fontSize:12,priceOffset:0,price:S,formatPrice:l})}}}function ul(e){return{name:`yAxis`,version:`1.0.0`,description:`Y轴价格刻度渲染器`,debugName:`Y轴`,paneId:Ki,priority:q.SYSTEM_YAXIS,draw(t){let{ctx:n,pane:r,dpr:i,yAxisCtx:a,data:o}=t,s=a||n,c=a?.canvas?a.canvas.width/i:e.axisWidth,l=r.yAxis.getDisplayRange(r.priceRange);r.capabilities.showPriceAxisTicks&&cl({ctx:s,dpr:i,axisWidth:c,height:r.height,paddingTop:r.yAxis.getPaddingTop(),paddingBottom:r.yAxis.getPaddingBottom(),valueMin:l.minPrice,valueMax:l.maxPrice,isMain:!0,decimals:2,hideEdgeTicks:!1});let u=o,d=r.id===`main`?u[u.length-1]:null;if(d){let t=r.yAxis.priceToY(d.close);ol(s,{x:0,y:r.top,width:c,height:r.height,crosshairY:t+r.top,priceRange:l,yPaddingPx:e.yPaddingPx,dpr:i,bgColor:`rgba(255, 247, 248, 0.98)`,borderColor:J.LAST_PRICE,textColor:J.LAST_PRICE,fontSize:12,priceOffset:0,price:d.close})}let f=e.getCrosshair?.();f&&f.activePaneId===r.id&&f.price!==null&&ol(s,{x:0,y:r.top,width:c,height:r.height,crosshairY:f.y,priceRange:l,yPaddingPx:e.yPaddingPx,dpr:i,fontSize:12,priceOffset:0,price:f.price})}}}function dl(e){return ll({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`macd`,label:`MACD`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}var fl=1e8;function pl(e){return ll({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`volume`,label:`VOL`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair,formatTickLabel:e=>(e/fl).toFixed(2),formatCrosshairLabel:e=>`${(e/fl).toFixed(2)}亿`})}function ml(e){return ll({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`rsi`,label:`RSI`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function hl(e){return ll({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`cci`,label:`CCI`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function gl(e){return ll({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`stoch`,label:`STOCH`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function _l(e){return ll({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`mom`,label:`MOM`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function vl(e){return ll({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`wmsr`,label:`WMSR`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function yl(e){return ll({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`kst`,label:`KST`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function bl(e){return ll({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`fastk`,label:`FASTK`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}var xl=Symbol(`time-axis`);function Sl(e){return{name:`timeAxis`,version:`1.0.0`,description:`时间轴渲染器`,debugName:`时间轴`,paneId:xl,priority:q.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;d.setTransform(1,0,0,1,0,0),d.scale(c,c),d.clearRect(0,0,f,p),sl(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});let m=e.getCrosshair?.();if(m&&typeof m.index==`number`){let e=u[m.index];e&&al(d,{x:0,y:0,width:f,height:p,crosshairX:m.x,timestamp:e.timestamp,dpr:c,fontSize:12})}}}}function Cl(e){return{name:`crosshair`,version:`1.0.0`,description:`十字线渲染器`,debugName:`十字线`,paneId:Ki,priority:q.SYSTEM_CROSSHAIR,draw(t){let{ctx:n,pane:r,dpr:i,paneWidth:a}=t,o=e.getCrosshairState();if(o.isDragging||!o.pos)return;let{x:s}=o.pos,c=r.id===o.activePaneId,l=-1;c&&o.price!==null&&(l=r.yAxis.priceToY(o.price)),n.save(),n.beginPath(),n.rect(0,0,a,r.height),n.clip(),n.fillStyle=ka.LINE;let u=ys(s,0,r.height,i);if(u&&n.fillRect(u.x,u.y,u.width,u.height),c&&l>=0){let e=bs(0,a,Math.min(l,r.height-1/i),i);e&&n.fillRect(e.x,e.y,e.width,e.height)}n.restore()}}}function wl(e){let t={...e};return{name:`paneTitle_${e.paneId}`,version:`1.0.0`,description:`面板标题渲染器`,debugName:`面板标题`,paneId:e.paneId,priority:q.FOREGROUND,draw(e){let{ctx:n,pane:r}=e;if(r.id!==t.paneId)return;let i=t.yOffset??12;n.save(),n.font=`12px Arial`,n.textAlign=`left`,n.textBaseline=`top`;let a=t.getTitleInfo?.();if(a){let e=12;if(n.fillStyle=ma.PRIMARY,n.fillText(a.name,e,i),e+=n.measureText(a.name).width,a.params&&a.params.length>0){let t=`(${a.params.join(`,`)})`;n.fillStyle=ma.TERTIARY,n.fillText(t,e,i),e+=n.measureText(t).width+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+=n.measureText(r).width+8}}else if(n.fillStyle=ma.PRIMARY,n.fillText(t.title,12,i),t.description){let e=n.measureText(t.title).width;n.fillStyle=ma.WEAK,n.fillText(` - ${t.description}`,12+e,i)}n.restore()},setConfig(e){t={...t,...e}}}}var Tl={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function El(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Tl,[...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 Dl=(0,f.markRaw)({name:`tabler-pointer`,render:El}),Ol={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function kl(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Ol,[...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 Al=(0,f.markRaw)({name:`tabler-chart-line`,render:kl}),jl={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Ml(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,jl,[...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 Nl=(0,f.markRaw)({name:`tabler-arrow-up-right`,render:Ml}),Pl={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Fl(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Pl,[...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 Il=(0,f.markRaw)({name:`tabler-arrow-right`,render:Fl}),Ll={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Rl(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Ll,[...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 zl=(0,f.markRaw)({name:`tabler-minus`,render:Rl}),Bl={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Vl(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Bl,[...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 Hl=(0,f.markRaw)({name:`tabler-separator`,render:Vl}),Ul={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Wl(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Ul,[...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 Gl=(0,f.markRaw)({name:`tabler-crosshair`,render:Wl}),Kl={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function ql(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Kl,[...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 Jl=(0,f.markRaw)({name:`tabler-info-circle`,render:ql}),Yl={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Xl(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Yl,[...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 Zl=(0,f.markRaw)({name:`tabler-maximize`,render:Xl}),Ql={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function $l(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Ql,[...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 eu=(0,f.markRaw)({name:`tabler-minimize`,render:$l}),tu={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function nu(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,tu,[...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 ru=(0,f.markRaw)({name:`tabler-zoom-in`,render:nu}),iu={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function au(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:`M3 10a7 7 0 1 0 14 0a7 7 0 1 0-14 0m4 0h6m8 11l-6-6`},null,-1)]])}var ou=(0,f.markRaw)({name:`tabler-zoom-out`,render:au}),su={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function cu(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,su,[...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 lu=(0,f.markRaw)({name:`tabler-shape`,render:cu}),uu={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function du(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,uu,[...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 fu=(0,f.markRaw)({name:`tabler-chart-dots-3`,render:du}),pu={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function mu(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,pu,[...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 hu=(0,f.markRaw)({name:`tabler-caret-up-down`,render:mu}),gu={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function _u(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:`M8 4H5v16h3m8-16h3v16h-3`},null,-1)]])}var vu=(0,f.markRaw)({name:`tabler-brackets`,render:_u}),yu={class:`left-toolbar`,"aria-label":`图表工具栏`},bu={class:`left-toolbar__group`},xu=[`title`,`aria-label`,`onClick`],Su=[`onClick`],Cu=[`title`,`aria-label`,`onClick`],wu={class:`left-toolbar__group`},Tu={class:`left-toolbar__group`},Eu=[`title`,`aria-label`],Du=to((0,f.defineComponent)({__name:`LeftToolbar`,props:{isFullscreen:{type:Boolean}},emits:[`selectTool`,`toggleFullscreen`,`zoomIn`,`zoomOut`],setup(e,{emit:t}){let n=t,r=[{id:`cursor`,title:`光标`,icon:Dl},{id:`lines`,title:`线条`,icon:Al,children:[{id:`trend-line`,title:`线段`,icon:Al},{id:`ray`,title:`射线`,icon:Nl},{id:`h-line`,title:`水平线`,icon:zl},{id:`h-ray`,title:`水平射线`,icon:Il},{id:`v-line`,title:`垂直线`,icon:Hl},{id:`crosshair-line`,title:`十字线`,icon:Gl},{id:`info-line`,title:`信息线`,icon:Jl}]},{id:`channels`,title:`通道`,icon:lu,children:[{id:`parallel-channel`,title:`平行通道`,icon:lu},{id:`regression-channel`,title:`回归趋势`,icon:fu},{id:`flat-line`,title:`平滑顶底`,icon:hu},{id:`disjoint-channel`,title:`不相交通道`,icon:vu}]}],i=(0,f.ref)(`cursor`),a=(0,f.ref)(null);function o(e){return i.value===e.id?!0:e.children?e.children.some(e=>e.id===i.value):!1}function s(e){if(e.children?.length){if(!e.children.some(e=>e.id===i.value)){let t=e.children[0];i.value=t.id,n(`selectTool`,t.id)}l(e.id);return}i.value=e.id,n(`selectTool`,e.id),a.value=null}function c(e){i.value=e.id,n(`selectTool`,e.id),a.value=null}function l(e){a.value=a.value===e?null:e}function u(e){e.target.closest(`.tool-item`)||(a.value=null)}return(0,f.onMounted)(()=>{document.addEventListener(`click`,u,!0)}),(0,f.onUnmounted)(()=>{document.removeEventListener(`click`,u,!0)}),(t,n)=>((0,f.openBlock)(),(0,f.createElementBlock)(`nav`,yu,[(0,f.createElementVNode)(`div`,bu,[((0,f.openBlock)(),(0,f.createElementBlock)(f.Fragment,null,(0,f.renderList)(r,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:o(e)}]),title:e.title,"aria-label":e.title,onClick:t=>s(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:a.value===e.id}]),onClick:(0,f.withModifiers)(t=>l(e.id),[`stop`]),"aria-label":`展开子菜单`},null,10,Su)):(0,f.createCommentVNode)(``,!0)],42,xu),(0,f.createVNode)(f.Transition,{name:`dropdown`},{default:(0,f.withCtx)(()=>[a.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:i.value===e.id}]),title:e.title,"aria-label":e.title,onClick:t=>c(e)},[((0,f.openBlock)(),(0,f.createBlock)((0,f.resolveDynamicComponent)(e.icon),{class:`tool-icon`,"aria-hidden":`true`}))],10,Cu))),128))],32)):(0,f.createCommentVNode)(``,!0)]),_:2},1024)])),64))]),n[18]||=(0,f.createElementVNode)(`span`,{class:`left-toolbar__divider`},null,-1),(0,f.createElementVNode)(`div`,wu,[(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)(ru),{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)(ou),{class:`tool-icon`,"aria-hidden":`true`})],32)]),n[19]||=(0,f.createElementVNode)(`span`,{class:`left-toolbar__divider`},null,-1),(0,f.createElementVNode)(`div`,Tu,[(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)(eu),{key:0,class:`tool-icon`,"aria-hidden":`true`})):((0,f.openBlock)(),(0,f.createBlock)((0,f.unref)(Zl),{key:1,class:`tool-icon`,"aria-hidden":`true`}))],40,Eu)])]))}}),[[`__scopeId`,`data-v-f1125609`]]),Ou={class:`chart-wrapper`},ku={class:`pane-separator-layer`,"aria-hidden":`true`},Au=4,ju=to((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.shallowRef)(null),p=(0,f.shallowRef)(null),m=ms({initialZoomLevel:r.initialZoomLevel??1,minKWidth:r.minKWidth,maxKWidth:r.maxKWidth,zoomLevels:r.zoomLevels,rightAxisWidth:r.rightAxisWidth,priceLabelWidth:r.priceLabelWidth});m.actions.setZoomState(m.state.zoomLevel,Uc(m.state.zoomLevel,{minKWidth:r.minKWidth,maxKWidth:r.maxKWidth,zoomLevelCount:r.zoomLevels,dpr:m.state.viewportDpr}),Wc(m.state.viewportDpr)),(0,f.computed)(()=>m.state.dataLength),(0,f.computed)(()=>m.state.viewportDpr);let h=(0,f.computed)(()=>m.state.zoomLevel),g=(0,f.computed)(()=>m.state.kWidth),_=(0,f.computed)(()=>m.state.kGap),v=(0,f.computed)(()=>m.state.paneRatios),y=(0,f.computed)(()=>m.state.selectedDrawingId),b=(0,f.computed)(()=>m.state.dataVersion);function x(){d.value?.scheduleDraw()}function S(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 C(e){if(!e)return;let t=S(e,180,80);d.value?.interaction.setTooltipSize(t)}function w(e){e&&(j.value=S(e,120,60))}let T=(0,f.ref)({x:0,y:0}),E=(0,f.ref)(!1),D=(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}),O=(0,f.shallowRef)(null),k=(0,f.computed)(()=>{let e=y.value;return e?m.state.drawings.find(t=>t.id===e)??null:null}),A=(0,f.ref)([]),j=(0,f.ref)({width:220,height:120}),M=(0,f.computed)(()=>{let e=c.value,t=l.value;return!e||!t?{x:0,y:0}:{x:e.offsetLeft,y:e.offsetTop}}),N=(0,f.computed)(()=>D.value.hoveredMarkerData),P=(0,f.computed)(()=>D.value.hoveredCustomMarker),ee=(0,f.computed)(()=>D.value.isDragging),te=(0,f.computed)(()=>D.value.isResizingPaneBoundary),ne=(0,f.computed)(()=>D.value.isHoveringPaneBoundary),re=(0,f.computed)(()=>D.value.hoveredPaneBoundaryId),ie=(0,f.computed)(()=>D.value.isHoveringRightAxis),ae=(0,f.computed)(()=>D.value.hoveredIndex),oe=(0,f.computed)(()=>D.value.crosshairIndex),se=(0,f.computed)(()=>{let e=D.value.hoveredIndex;if(typeof e!=`number`)return null;b.value;let t=d.value?.getData();return t&&e>=0&&e<t.length?t[e]:null}),ce=(0,f.computed)(()=>D.value.hoveredIndex),le=(0,f.computed)(()=>D.value.tooltipPos),ue=(0,f.computed)(()=>({x:le.value.x+M.value.x,y:le.value.y+M.value.y})),de=(0,f.computed)(()=>({left:`${ue.value.x}px`,top:`${ue.value.y}px`})),fe=(0,f.computed)(()=>({x:T.value.x+M.value.x,y:T.value.y+M.value.y})),pe=(0,f.computed)(()=>({left:`${fe.value.x}px`,top:`${fe.value.y}px`})),me=(0,f.computed)(()=>D.value.tooltipAnchorPlacement),he=(0,f.computed)(()=>{let e=d.value?.getViewport(),t=c.value,n=e?.plotWidth??(t?t.clientWidth:0);return T.value.x+12+j.value.width+12>n?`left-bottom`:`right-bottom`}),ge=(0,f.computed)(()=>(b.value,d.value?.getData()??[]));function _e(e){O.value?.setTool(e)}function ve(e){let t=k.value;!t||!O.value||(O.value.updateDrawingStyle(t.id,e),m.actions.bumpDrawingVersion())}function ye(){let e=k.value;!e||!O.value||(O.value.removeDrawing(e.id),m.actions.setSelectedDrawingId(null),m.actions.bumpDrawingVersion(),m.actions.setDrawings(O.value.getDrawings()))}function be(e){let t=c.value;if(t){if(O.value?.onPointerDown(e,t)){m.actions.setDrawings(O.value.getDrawings()),m.actions.bumpDrawingVersion();return}d.value?.interaction.onPointerDown(e)}}function xe(e){let t=c.value;if(t){let n=t.getBoundingClientRect();if(T.value={x:e.clientX-n.left,y:e.clientY-n.top},O.value?.onPointerMove(e,t)){m.actions.setDrawings(O.value.getDrawings());return}}d.value?.interaction.onPointerMove(e)}function Se(e){let t=c.value;if(t&&O.value?.onPointerUp(e,t)){m.actions.setDrawings(O.value.getDrawings());return}d.value?.interaction.onPointerUp(e)}function Ce(e){d.value?.interaction.onPointerLeave(e)}function we(e){d.value?.interaction.onRightAxisPointerDown(e)}function Te(e){d.value?.interaction.onRightAxisPointerMove(e)}function Ee(e){d.value?.interaction.onRightAxisPointerUp(e)}function De(e){d.value?.interaction.onRightAxisPointerLeave(e)}function Oe(){d.value?.interaction.onScroll()}let F=(0,f.ref)([]),I=(0,f.ref)({}),L=(0,f.ref)([]),ke={VOLUME:{defaultParams:{},getTitleInfo:()=>({name:`VOL`,params:[],values:[]})},MACD:{defaultParams:{fastPeriod:12,slowPeriod:26,signalPeriod:9},getTitleInfo:(e,t,n)=>t===null?null:Bs(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:Us(e,t,n.period1??6,n.period2??12,n.period3??24)},CCI:{defaultParams:{period:14},getTitleInfo:(e,t,n)=>t===null?null:qs(e,t,n.period??14)},STOCH:{defaultParams:{n:9,m:3},getTitleInfo:(e,t,n)=>t===null?null:Zs(e,t,n.n??9,n.m??3)},MOM:{defaultParams:{period:10},getTitleInfo:(e,t,n)=>t===null?null:tc(e,t,n.period??10)},WMSR:{defaultParams:{period:14},getTitleInfo:(e,t,n)=>t===null?null:ac(e,t,n.period??14)},KST:{defaultParams:{roc1:10,roc2:15,roc3:20,roc4:30,signalPeriod:9},getTitleInfo:(e,t,n)=>t===null?null:dc(e,t,n.roc1??10,n.roc2??15,n.roc3??20,n.roc4??30,n.signalPeriod??9)},FASTK:{defaultParams:{period:9},getTitleInfo:(e,t,n)=>t===null?null:hc(e,t,n.period??9)}},Ae=Object.keys(ke);function je(){let e=v.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:v.value[e.id]??1,visible:!0,role:`indicator`}))]}function Me(e){return{...ke[e].defaultParams}}function Ne(e=`VOLUME`,t){if(L.value.length>=Au)return!1;let n=`sub_${e}`;if(L.value.some(e=>e.id===n))return!0;if(!d.value?.createSubPane(e,t??Me(e)))return!1;let r=wl({paneId:n,title:e,getTitleInfo:()=>ze(n)});return d.value?.useRenderer(r),L.value.push({id:n,indicatorId:e,rendererName:`${e.toLowerCase()}_${n}`,paneTitleRendererName:r.name,params:t??Me(e)}),F.value.includes(e)||F.value.push(e),x(),!0}function Pe(e){let t=L.value.findIndex(t=>t.id===e);if(t===-1)return;let n=L.value[t];n&&(d.value?.removeRenderer(n.paneTitleRendererName),d.value?.removeSubPane(n.indicatorId),L.value.splice(t,1),L.value.some(e=>e.indicatorId===n.indicatorId)||(F.value=F.value.filter(e=>e!==n.indicatorId)))}function Fe(){for(let e of L.value)d.value?.removeRenderer(e.paneTitleRendererName);d.value?.clearSubPanes(),L.value=[],F.value=F.value.filter(e=>!Ae.includes(e))}function Ie(){let e=r.semanticConfig.indicators?.main;if(e)for(let t of e)t.enabled&&(F.value.includes(t.type)||F.value.push(t.type),t.params&&(I.value[t.type]=t.params))}(0,f.watch)([F,I],([e])=>{let t=d.value;t&&(t.updateRendererConfig(`mainIndicatorLegend`,{indicators:{MA:{enabled:e.includes(`MA`),params:I.value.MA||{}},BOLL:{enabled:e.includes(`BOLL`),params:I.value.BOLL||{}},EXPMA:{enabled:e.includes(`EXPMA`),params:I.value.EXPMA||{}},ENE:{enabled:e.includes(`ENE`),params:I.value.ENE||{}}}}),t.setRendererEnabled(`ma`,e.includes(`MA`)),t.setRendererEnabled(`boll`,e.includes(`BOLL`)),t.setRendererEnabled(`expma`,e.includes(`EXPMA`)),t.setRendererEnabled(`ene`,e.includes(`ENE`)),x())},{deep:!0});function Le(){let e=d.value?.getSubPaneIndicators()??[];L.value=[];for(let t of e){let e=`sub_${t}`,n=wl({paneId:e,title:t,getTitleInfo:()=>ze(e)});d.value?.useRenderer(n),L.value.push({id:e,indicatorId:t,rendererName:`${t.toLowerCase()}_${e}`,paneTitleRendererName:n.name,params:Me(t)}),F.value.includes(t)||F.value.push(t)}x()}function Re(e,t){let n=L.value.find(t=>t.id===e);if(!n)return;let r=n.indicatorId;d.value?.removeRenderer(n.paneTitleRendererName),d.value?.removeSubPane(r),d.value?.createSubPane(t,Me(t));let i=`sub_${t}`,a=wl({paneId:i,title:t,getTitleInfo:()=>ze(i)});d.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:Me(t)}),F.value=F.value.filter(e=>e!==r),F.value.includes(t)||F.value.push(t)}function ze(e){let t=L.value.find(t=>t.id===e);if(!t)return null;let n=d.value?.getData();if(!n||n.length===0)return null;let r=ke[t.indicatorId],i=t.params;return r.getTitleInfo(n,oe.value,i)}function Be(e,t){if(e===`MA`||e===`BOLL`||e===`EXPMA`||e===`ENE`){t?F.value.includes(e)||F.value.push(e):F.value=F.value.filter(t=>t!==e);return}if(Ae.includes(e)){if(t){if(F.value.includes(e)||F.value.push(e),L.value.find(t=>t.indicatorId===e))return;if(!Ne(e)){let t=L.value[L.value.length-1];t&&Re(t.id,e)}}else F.value=F.value.filter(t=>t!==e),L.value.filter(t=>t.indicatorId===e).forEach(e=>Pe(e.id));x()}}function R(){d.value?.updateRendererConfig(`mainIndicatorLegend`,{indicators:{MA:{enabled:F.value.includes(`MA`),params:I.value.MA||{}},BOLL:{enabled:F.value.includes(`BOLL`),params:I.value.BOLL||{}},EXPMA:{enabled:F.value.includes(`EXPMA`),params:I.value.EXPMA||{}},ENE:{enabled:F.value.includes(`ENE`),params:I.value.ENE||{}}}})}function Ve(e,t){if(I.value[e]=t,e===`MA`||e===`BOLL`||e===`EXPMA`||e===`ENE`){e===`BOLL`&&d.value?.updateRendererConfig(`boll`,t),e===`EXPMA`&&d.value?.updateRendererConfig(`expma`,t),e===`ENE`&&d.value?.updateRendererConfig(`ene`,t),R(),x();return}Ae.includes(e)&&L.value.filter(t=>t.indicatorId===e).forEach(e=>{e.params={...t},d.value?.updateRendererConfig(e.rendererName,t)}),x()}function He(e){if(!e.length||L.value.length<=1)return;let t=e.filter(e=>Ae.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=F.value.filter(e=>!Ae.includes(e)),s=L.value.map(e=>e.indicatorId);F.value=[...o,...s];let c=d.value;c&&c.updatePaneLayout(je())}let Ue=(0,f.computed)(()=>r.rightAxisWidth+r.priceLabelWidth),We=m.computed.totalWidth;function Ge(){let e=c.value,t=d.value;if(!e||!t)return;let n=t.getData()?.length??0;if(n===0)return;let r=t.getCurrentDpr(),{unitPx:i,startXPx:a}=X(g.value,_.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,x()}function Ke(e,t){let n=d.value,a=c.value;if(!n||!a)return;let o=n.getCurrentDpr(),s=Kc(e,t??(n.getViewport()?.plotWidth??a.clientWidth)/2,a.scrollLeft,h.value,g.value,_.value,{minKWidth:r.minKWidth,maxKWidth:r.maxKWidth,zoomLevelCount:r.zoomLevels,dpr:o});s&&(m.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:x,scrollToRight:Ge,addSubPane:Ne,removeSubPane:Pe,switchSubIndicator:Re,clearAllSubPanes:Fe,get plugin(){return d.value?.plugin},zoomToLevel:Ke,zoomIn:e=>Ke(h.value+1,e),zoomOut:e=>Ke(h.value-1,e),getZoomLevel:()=>h.value,getZoomLevelCount:()=>d.value?.getZoomLevelCount()??10}),(0,f.onMounted)(()=>{E.value=typeof CSS<`u`&&CSS.supports(`anchor-name: --kmap-anchor`)&&CSS.supports(`position-anchor: --kmap-anchor`);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=d.value;if(!n)return;let a=e.getBoundingClientRect(),o=t.clientX-a.left,s=e.scrollLeft,l=n.getCurrentDpr(),u=Gc(t.deltaY>0?-1:1,o,s,h.value,g.value,_.value,{minKWidth:r.minKWidth,maxKWidth:r.maxKWidth,zoomLevelCount:r.zoomLevels,dpr:l});u&&(m.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 v=new Vc({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});v.useRenderer(el()),v.useRenderer(nl()),v.useRenderer(Cs({ma5:!0,ma10:!0,ma20:!0,ma30:!0,ma60:!0})),v.useRenderer(Ts()),v.setRendererEnabled(`boll`,!1),v.useRenderer(ks()),v.setRendererEnabled(`expma`,!1),v.useRenderer(Ms()),v.setRendererEnabled(`ene`,!1),v.useRenderer(Zc()),v.useRenderer(tl()),v.useRenderer(aa());let y=r.rightAxisWidth+r.priceLabelWidth,b=()=>{let e=v.interaction.crosshairPos,t=v.interaction.crosshairPrice,n=v.interaction.activePaneId;return e&&t!==null?{y:e.y,price:t,activePaneId:n}:null};v.useRenderer(ul({axisWidth:y,yPaddingPx:r.yPaddingPx,getCrosshair:b})),v.useRenderer(Ps({yPaddingPx:r.yPaddingPx}));let x=[{create:pl,paneId:`sub_VOLUME`},{create:dl,paneId:`sub_MACD`},{create:ml,paneId:`sub_RSI`},{create:hl,paneId:`sub_CCI`},{create:gl,paneId:`sub_STOCH`},{create:_l,paneId:`sub_MOM`},{create:vl,paneId:`sub_WMSR`},{create:yl,paneId:`sub_KST`},{create:bl,paneId:`sub_FASTK`}];for(let e of x)v.useRenderer(e.create({axisWidth:y,paneId:e.paneId,yPaddingPx:r.yPaddingPx,getCrosshair:b}));v.useRenderer(Cl({getCrosshairState:()=>({pos:v.interaction.crosshairPos,activePaneId:v.interaction.activePaneId,isDragging:v.interaction.isDraggingState(),price:v.interaction.crosshairPrice})})),v.useRenderer(Sl({height:r.bottomAxisHeight,getCrosshair:()=>{let e=v.interaction.crosshairPos,t=v.interaction.crosshairIndex;return e&&t!==null?{x:e.x,index:t}:null}})),v.setOnViewportChange(e=>{m.state.viewportDpr!==e.dpr&&m.actions.setViewportDpr(e.dpr),m.state.viewWidth!==e.plotWidth&&m.actions.setViewWidth(e.plotWidth);let t=Wc(e.dpr);m.state.kGap!==t&&m.actions.setZoomState(m.state.zoomLevel,m.state.kWidth,t);let n=v.getOption();(n.kWidth!==m.state.kWidth||n.kGap!==t)&&v.applyRenderState(m.state.kWidth,t,m.state.zoomLevel)}),v.setOnPaneLayoutChange(e=>{let t={};for(let n of e)t[n.id]=n.ratio;m.actions.setPaneRatios(t);let n=v.getPaneRenderers(),r=c.value&&parseInt(getComputedStyle(c.value).borderTopWidth)||0;A.value=n.slice(0,-1).map(e=>{let t=e.getPane();return{id:t.id,top:t.top+t.height+r}})}),v.setOnDataChange(e=>{m.actions.setDataLength(e.length),m.actions.bumpDataVersion()}),d.value=v,v.applyRenderState(m.state.kWidth,m.state.kGap,m.state.zoomLevel),O.value=new yc(v),O.value.setCallbacks({onDrawingCreated:e=>{m.actions.setDrawings([...m.state.drawings,e]),m.actions.setSelectedDrawingId(e.id)},onToolChange:e=>{},onDrawingSelected:e=>{m.actions.setSelectedDrawingId(e?.id??null)}}),v.interaction.setTooltipAnchorPositioning(E.value),v.interaction.setOnInteractionChange(e=>{D.value=e}),v.interaction.setOnPinchZoom((e,t)=>{let n=c.value;if(!n||!v)return;let a=t-n.getBoundingClientRect().left,o=n.scrollLeft,s=v.getCurrentDpr(),l=Gc(e,a,o,h.value,g.value,_.value,{minKWidth:r.minKWidth,maxKWidth:r.maxKWidth,zoomLevelCount:r.zoomLevels,dpr:s});l&&(m.actions.setZoomState(l.targetLevel,l.newKWidth,l.newKGap),v.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,v.applyRenderState(l.newKWidth,l.newKGap,l.targetLevel),i(`zoomLevelChange`,l.targetLevel,l.newKWidth)}))}),D.value=v.interaction.getInteractionSnapshot(),m.actions.setViewportDpr(v.getCurrentDpr()),v.resize(),p.value=new ki(v),p.value.on(`config:error`,e=>{console.error(`Semantic config error:`,e)}),p.value.on(`config:ready`,()=>{m.actions.setDataLength(v.getData()?.length??0),m.actions.bumpDataVersion(),Ie(),Le(),(0,f.nextTick)(()=>Ge())}),p.value.applyConfig(r.semanticConfig).then(e=>{e&&!e.success&&console.error(`Semantic config apply failed:`,e.errors)}),v.__onWheel=u}),(0,f.onUnmounted)(()=>{let e=d.value;if(e){let t=e.__onWheel,n=c.value;t&&n&&n.removeEventListener(`wheel`,t),e.destroy()}d.value=null,O.value=null}),(0,f.watch)(()=>r.yPaddingPx,e=>{d.value?.updateOptions({yPaddingPx:e})}),(0,f.watch)(()=>r.semanticConfig,async(e,t)=>{if(e&&e!==t){let t=await p.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`,Ou,[(0,f.createElementVNode)(`div`,{class:(0,f.normalizeClass)([`chart-stage`,{"is-dragging":ee.value,"is-resizing-pane":te.value,"is-hovering-pane-separator":ne.value,"is-hovering-right-axis":ie.value,"is-hovering-kline":ae.value!==null}])},[(0,f.createVNode)(Du,{"is-fullscreen":e.isFullscreen,onSelectTool:_e,onToggleFullscreen:n[0]||=e=>t.$emit(`toggleFullscreen`),onZoomIn:n[1]||=e=>Ke(h.value+1),onZoomOut:n[2]||=e=>Ke(h.value-1)},null,8,[`is-fullscreen`]),(0,f.createElementVNode)(`div`,{class:`chart-main`,ref_key:`chartMainRef`,ref:l},[(0,f.createElementVNode)(`div`,ku,[((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.id,class:(0,f.normalizeClass)([`pane-separator-line`,{"is-active":re.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:Oe,onPointerdown:be,onPointermove:xe,onPointerup:Se,onPointerleave:Ce},[(0,f.createElementVNode)(`div`,{class:`scroll-content`,style:(0,f.normalizeStyle)({width:(0,f.unref)(We)+`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),k.value?((0,f.openBlock)(),(0,f.createBlock)(is,{key:0,drawing:k.value,onUpdateStyle:ve,onDelete:ye},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},[se.value?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:0,class:(0,f.normalizeClass)([`tooltip-anchor kline-tooltip-anchor`,{"use-anchor":E.value}]),style:(0,f.normalizeStyle)(de.value)},null,6)):(0,f.createCommentVNode)(``,!0),N.value||P.value?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:1,class:(0,f.normalizeClass)([`tooltip-anchor marker-tooltip-anchor`,{"use-anchor":E.value}]),style:(0,f.normalizeStyle)(pe.value)},null,6)):(0,f.createCommentVNode)(``,!0),se.value?((0,f.openBlock)(),(0,f.createBlock)(no,{key:2,k:se.value,index:ce.value,data:ge.value,pos:ue.value,"set-el":C,"use-anchor":E.value,"anchor-placement":me.value},null,8,[`k`,`index`,`data`,`pos`,`use-anchor`,`anchor-placement`])):(0,f.createCommentVNode)(``,!0),N.value||P.value?((0,f.openBlock)(),(0,f.createBlock)(so,{key:3,marker:N.value||P.value,pos:fe.value,"use-anchor":E.value,"anchor-placement":he.value,"set-el":w},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:Ue.value+`px`}),onPointerdown:we,onPointermove:Te,onPointerup:Ee,onPointerleave:De},null,36)],512)],2),(0,f.createVNode)(Xo,{"active-indicators":F.value,"indicator-params":I.value,onToggle:Be,onUpdateParams:Ve,onReorderSubIndicators:He},null,8,[`active-indicators`,`indicator-params`])]))}}),[[`__scopeId`,`data-v-c53b9583`]]),Mu={install(e){e.component(`KLineChart`,ju)}};exports.ConfigManager=Yi,exports.EventBus=p,exports.GLOBAL_PANE_ID=Ki,exports.HookSystem=Ji,exports.KLineChart=ju,exports.KMapPlugin=Mu,exports.PluginHostImpl=Zi,exports.PluginRegistry=qi,exports.PluginState=Wi,exports.RENDERER_PRIORITY=q,exports.RendererPluginManager=ea,exports.createPluginHost=Qi,exports.wrapPaneInfo=Gi;
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})),Xr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W(),n=G();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)}}})),Zr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=ar(),n=W(),r=Qn(),i=G();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)}}}})),Qr=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=dr(),n=ar(),r=G(),i=Zr();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)}}}})),$r=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=ar(),n=W(),r=G(),i=G();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())})})}}}})),ei=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=G();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`}}})),ti=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:ar().validateUnion,error:{message:`must match a schema in anyOf`}}})),ni=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W(),n=G();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)})})}}}})),ri=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=G();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)})}}})),ii=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W(),n=G(),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})),ai=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=G();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`)}}})),oi=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=Wr(),n=Kr(),r=Gr(),i=qr(),a=Jr(),o=Yr(),s=Xr(),c=Zr(),l=Qr(),u=$r(),d=ei(),f=ti(),p=ni(),m=ri(),h=ii(),g=ai();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=_})),si=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W();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})`}}}}})),ci=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=[si().default]})),li=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`]})),ui=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=Ar(),n=Ur(),r=oi(),i=ci(),a=li();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),di=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={}))})),fi=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=W(),n=di(),r=mr(),i=pr(),a=G();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}}}}})),pi=c({$id:()=>hi,$schema:()=>mi,default:()=>bi,definitions:()=>_i,properties:()=>yi,title:()=>gi,type:()=>vi}),mi,hi,gi,_i,vi,yi,bi,xi=o((()=>{mi=`http://json-schema.org/draft-07/schema#`,hi=`http://json-schema.org/draft-07/schema#`,gi=`Core schema meta-schema`,_i={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:[]}},vi=[`object`,`boolean`],yi={$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:`#`}},bi={$schema:mi,$id:hi,title:gi,definitions:_i,type:vi,properties:yi,default:!0}})),Si=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=Dr(),r=ui(),i=fi(),a=(xi(),d(pi).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=dr();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return l.KeywordCxt}});var u=W();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=fr();Object.defineProperty(e,`ValidationError`,{enumerable:!0,get:function(){return f.default}});var p=pr();Object.defineProperty(e,`MissingRefError`,{enumerable:!0,get:function(){return p.default}})}))(),1),Ci={$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}$`}}}}},wi=[`__proto__`,`constructor`,`prototype`],Ti=/^(#[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*\))$/,Ei={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 Di(e){return{"5min":30,"15min":60,"30min":90,"60min":180,daily:365*3,weekly:365*5,monthly:365*10}[e]??365}var Oi=(typeof document<`u`?document.createElement(`canvas`):null)?.getContext(`2d`)??null,ki=class e{ajv;limits;constructor(){this.ajv=new Si.default({allErrors:!0,allowUnionTypes:!0}),this.ajv.addFormat(`date`,{type:`string`,validate:e=>/^\d{4}-\d{2}-\d{2}$/.test(e)}),this.ajv.addSchema(Ci),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))wi.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=Di(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(!Ei[n].test(t))return{valid:!1,errors:[`Invalid symbol "${t}" for exchange "${n}"`]}}else if(!Object.values(Ei).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`&&!Ti.test(r)&&n.push(`Invalid ${i} in marker "${t}": ${r}`)}if(Oi)for(let i of r){let r=e[i];typeof r==`string`&&(Oi.fillStyle=`#000000`,Oi.fillStyle=r,Oi.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}},Ai=class{chart;validator;events;constructor(e){this.chart=e,this.validator=new ki,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 Yn(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:ji(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 ji(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 Mi={arrow_up:16,arrow_down:16,flag:14,circle:12,rectangle:14,diamond:12};function Ni(e,t,n,r,i,a){let o=a.fillColor||`#000000`,s=a.strokeColor||o,c=i||Mi[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`:Ri(e,n,r,c);break;case`arrow_down`:zi(e,n,r,c);break;case`circle`:Bi(e,n,r,c);break;case`rectangle`:Vi(e,n,r,c);break;case`diamond`:Hi(e,n,r,c);break;case`flag`:Ui(e,n,r,c);break}e.globalAlpha=1}var Pi=2.5,Fi=4;function Ii(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*Pi,d=Li(e,t.text,u),f=e.measureText(d).width,p=n,m=r;switch(t.position){case`left`:p=n-l-f/2-Fi;break;case`right`:p=n+l+f/2+Fi;break;case`top`:m=r-l-s/2-Fi;break;case`bottom`:m=r+l+s/2+Fi;break;default:m=o?r-l-s/2-Fi:r+l+s/2+Fi;break}t.offset&&(p+=t.offset.x||0,m+=t.offset.y||0),e.textAlign=t.align||`center`,e.fillText(d,p,m)}function Li(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 Ri(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 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.arc(t,n,r/2,0,Math.PI*2),e.fill()}function Vi(e,t,n,r){e.fillRect(t-r/2,n-r/2,r,r)}function Hi(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 Ui(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 Wi(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 Gi=function(e){return e.Registered=`registered`,e.Installed=`installed`,e.Error=`error`,e}({});function Ki(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 qi=Symbol(`global-pane`),K={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},Ji=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()}},Yi=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}},Xi=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())}},Zi=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()}},Qi=class{registry;eventBus;hookSystem;configManager;stateStore;isDestroyed=!1;logger;constructor(e){this.registry=new Ji,this.eventBus=new p,this.hookSystem=new Yi,this.configManager=new Xi,this.stateStore=new Zi,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 $i(e){return new Qi(e)}var ea=Symbol(`renderer:global-cache`),ta=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`?ea: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(ea)??[];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(ea,[...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(ea)??[];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){let n=this.getRenderers(e),r=[];for(let e of n)try{e.draw(t)}catch(n){let i=n instanceof Error?n:Error(String(n));console.error(`[RendererPlugin] ${e.name} draw error:`,i),r.push({name:e.name,error:{message:i.message,stack:i.stack},paneId:t.pane.id,timestamp:Date.now()})}return r}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)}}},na={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)`},q={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)`},ra={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`},ia={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`},aa={HORIZONTAL:`rgba(0, 0, 0, 0.06)`,VERTICAL:`rgba(0, 0, 0, 0.12)`},J={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)`},oa={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)`},sa={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`},ca={UP:`#ff5252`,DOWN:`#22ab94`,NEUTRAL:`rgba(0, 0, 0, 0.78)`},la={RSI1:`rgba(69, 112, 249, 1)`,RSI2:`rgba(255, 152, 0, 1)`,RSI3:`rgba(156, 39, 176, 1)`},ua={CCI:`rgba(69, 112, 249, 1)`,OVERBOUGHT:`rgba(214, 10, 34, 0.5)`,OVERSOLD:`rgba(3, 123, 102, 0.5)`},da={K:`rgba(69, 112, 249, 1)`,D:`rgba(255, 152, 0, 1)`,J:`rgba(156, 39, 176, 1)`},fa={MOM:`rgba(69, 112, 249, 1)`,ZERO:`rgba(0, 0, 0, 0.2)`},pa={WMSR:`rgba(69, 112, 249, 1)`,OVERBOUGHT:`rgba(214, 10, 34, 0.5)`,OVERSOLD:`rgba(3, 123, 102, 0.5)`},ma={KST:`rgba(69, 112, 249, 1)`,SIGNAL:`rgba(255, 152, 0, 1)`},ha={FAST:`rgba(255, 152, 0, 1)`,SLOW:`rgba(69, 112, 249, 1)`},ga={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)`},_a={LINE:`rgba(0, 0, 0, 0.28)`,LABEL_BG:`rgb(0, 0, 0)`,LABEL_TEXT:`rgba(255, 255, 255, 0.92)`};function Y(e,t){return Math.round(e*t)/t}function X(e,t){return(Math.floor(e*t)+.5)/t}function va(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 ya(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 ba(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 xa=1.2,Sa=24,Ca=6;function wa(e){switch(e){case`arrow_up`:case`flag`:return!0;default:return!1}}function Ta(){return{name:`customMarkers`,version:`1.0.0`,description:`自定义标记渲染器`,debugName:`自定义标记`,paneId:qi,priority:K.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=Da(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=Ea(o,m),g=(e.offset?.y??0)<0?!0:(e.offset?.y??0)>0?!1:wa(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;Ni(t,e.shape,b,x,S,e.style||{}),e.label&&Ii(t,e.label,b,x,S,e.style||{},g),l.setCustomMarkerPosition(e.id,b-a,x,S,e.shape)}t.restore()}}}}function Ea(e,t){let n=e*xa;return Math.max(Ca,Math.min(n,t??Sa))}function Da(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 Oa(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 ka(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 Aa(e){let t=new Date(e);return`${t.getFullYear()}-${t.getMonth()}`}var ja=Oa,Ma=Oa;function Na(e){if(e.length===0)return[];let t=[0],n=Aa(e[0].timestamp);for(let r=1;r<e.length;r++){let i=e[r];if(!i)continue;let a=Aa(i.timestamp);a!==n&&(t.push(r),n=a)}return t}var Pa=q.UP,Fa=q.DOWN,Ia=q.NEUTRAL;function La(e){return e>0?Pa:e<0?Fa:Ia}function Ra(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 za(e,t=2){return`${e>0?`+`:``}${e.toFixed(t)}`}function Ba(e,t=2){return`${e.toFixed(t)}%`}function Va(e,t=2){return`${e>0?`+`:``}${e.toFixed(t)}%`}function Ha(e,t){let n=t?.close??e.open;return La(e.open-n)}function Ua(e){return La(e.close-e.open)}function Wa(e){return typeof e.changePercent==`number`?La(e.changePercent):typeof e.changeAmount==`number`?La(e.changeAmount):Ia}var Ga={class:`kline-tooltip__title`},Ka={key:0},qa={class:`kline-tooltip__grid`},Ja={class:`row`},Ya={class:`row`},Xa={class:`row`},Za={class:`row`},Qa={key:0,class:`row`},$a={key:1,class:`row`},eo={key:2,class:`row`},to={key:3,class:`row`},no={key:4,class:`row`},ro={key:5,class:`row`},io=(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 Ia;let n=t.index;return Ha(e,typeof n==`number`&&n>0?t.data[n-1]:void 0)}),o=(0,f.computed)(()=>{let e=t.k;return e?Ua(e):Ia}),s=(0,f.computed)(()=>{let e=t.k;return e?Wa(e):Ia});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`,Ga,[e.k.stockCode?((0,f.openBlock)(),(0,f.createElementBlock)(`span`,Ka,(0,f.toDisplayString)(e.k.stockCode),1)):(0,f.createCommentVNode)(``,!0),(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)((0,f.unref)(ja)(e.k.timestamp)),1)]),(0,f.createElementVNode)(`div`,qa,[(0,f.createElementVNode)(`div`,Ja,[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`,Ya,[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`,Xa,[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`,Za,[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`,Qa,[c[4]||=(0,f.createElementVNode)(`span`,null,`成交量`,-1),(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)((0,f.unref)(Ra)(e.k.volume)),1)])):(0,f.createCommentVNode)(``,!0),typeof e.k.turnover==`number`?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,$a,[c[5]||=(0,f.createElementVNode)(`span`,null,`成交额`,-1),(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)((0,f.unref)(Ra)(e.k.turnover)),1)])):(0,f.createCommentVNode)(``,!0),typeof e.k.amplitude==`number`?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,eo,[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`,to,[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)(Va)(e.k.changePercent)),5)])):(0,f.createCommentVNode)(``,!0),typeof e.k.changeAmount==`number`?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,no,[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)(za)(e.k.changeAmount)),5)])):(0,f.createCommentVNode)(``,!0),typeof e.k.turnoverRate==`number`?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,ro,[c[9]||=(0,f.createElementVNode)(`span`,null,`换手率`,-1),(0,f.createElementVNode)(`span`,null,(0,f.toDisplayString)((0,f.unref)(Ba)(e.k.turnoverRate)),1)])):(0,f.createCommentVNode)(``,!0)])],6)):(0,f.createCommentVNode)(``,!0)}}),ao=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},oo=ao(io,[[`__scopeId`,`data-v-d0fe85e6`]]),so={RISE_WITH_VOLUME:`量价齐升`,RISE_WITHOUT_VOLUME:`量缩价升`,FALL_WITH_VOLUME:`量价齐缩`,FALL_WITHOUT_VOLUME:`量升价缩`},co=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&&Wi(e,t,r.shape,r.x,r.y,r.size))return n}return null}},lo={class:`marker-tooltip__title`},uo={key:0,class:`marker-tooltip__content`},fo=ao((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 so[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`,lo,(0,f.toDisplayString)(o.value),1),c.value?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,uo,[((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`]]),po=Symbol(`fullscreen-teleport-target`);function mo(){let e=(0,f.inject)(po,null);return(0,f.computed)(()=>e?.value??`body`)}var ho={class:`params-header`},go={class:`header-left`},_o={class:`params-title`},vo={class:`header-right`},yo={key:0,class:`indicator-description`},bo={class:`params-body`},xo={class:`param-header`},So={class:`param-label`},Co={class:`param-label-text`},wo={key:0,class:`param-range`},To={class:`input-wrapper`},Eo=[`disabled`,`onClick`],Do=[`value`,`min`,`max`,`step`,`onInput`],Oo=[`disabled`,`onClick`],ko={key:0,class:`param-description`},Ao={class:`params-footer`},jo={class:`footer-right`},Mo=ao((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`,ho,[(0,f.createElementVNode)(`div`,go,[(0,f.createElementVNode)(`span`,_o,(0,f.toDisplayString)(e.indicatorName),1),n[5]||=(0,f.createElementVNode)(`span`,{class:`params-subtitle`},`参数设置`,-1)]),(0,f.createElementVNode)(`div`,vo,[(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`,yo,[(0,f.createElementVNode)(`p`,null,(0,f.toDisplayString)(e.indicatorDescription),1)])):(0,f.createCommentVNode)(``,!0)]),_:1}),(0,f.createElementVNode)(`div`,bo,[((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`,xo,[(0,f.createElementVNode)(`label`,So,[(0,f.createElementVNode)(`span`,Co,(0,f.toDisplayString)(e.label),1),e.min!==void 0||e.max!==void 0?((0,f.openBlock)(),(0,f.createElementBlock)(`span`,wo,(0,f.toDisplayString)(e.min??`-∞`)+` ~ `+(0,f.toDisplayString)(e.max??`+∞`),1)):(0,f.createCommentVNode)(``,!0)]),(0,f.createElementVNode)(`div`,To,[(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,Eo),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,Do)):(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,Oo)])]),(0,f.createVNode)(f.Transition,{name:`slide`},{default:(0,f.withCtx)(()=>[a.value&&e.description?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,ko,(0,f.toDisplayString)(e.description),1)):(0,f.createCommentVNode)(``,!0)]),_:2},1024)],2))),128))]),(0,f.createElementVNode)(`div`,Ao,[(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`,jo,[(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`]]),No={class:`indicator-selector`},Po={class:`indicator-scroll-container`},Fo={class:`indicator-list`},Io={key:0,class:`indicator-divider`,"aria-hidden":`true`},Lo=[`draggable`,`onDragstart`,`onDragover`,`onDrop`],Ro=[`onMouseenter`],zo={class:`btn-content`},Bo={key:0,class:`param-hint`},Vo={key:0,class:`hover-overlay`},Ho=[`onClick`],Uo={key:1,class:`divider`},Wo=[`onClick`],Go={class:`indicator-item`},Ko={class:`menu-section`},qo={class:`menu-items`},Jo=[`disabled`,`onClick`],Yo={class:`param-hint`},Xo={key:0,class:`active-tag`},Zo={class:`menu-section`},Qo={class:`menu-items`},$o=[`disabled`,`onClick`],es={class:`param-hint`},ts={key:0,class:`active-tag`},ns=ao((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`,No,[(0,f.createElementVNode)(`div`,Po,[(0,f.createElementVNode)(`div`,Fo,[((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`,Io)):(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`,zo,[(0,f.createTextVNode)((0,f.toDisplayString)(e.label)+` `,1),e.params?((0,f.openBlock)(),(0,f.createElementBlock)(`span`,Bo,` (`+(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`,Vo,[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,Ho)):(0,f.createCommentVNode)(``,!0),e.params?((0,f.openBlock)(),(0,f.createElementBlock)(`span`,Uo)):(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,Wo)])):(0,f.createCommentVNode)(``,!0)]),_:2},1024)],2)],40,Ro)],42,Lo)],64))),128)),(0,f.createElementVNode)(`div`,Go,[(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`,Ko,[t[6]||=(0,f.createElementVNode)(`div`,{class:`menu-title`},`主图指标`,-1),(0,f.createElementVNode)(`div`,qo,[((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`,Yo,` (`+(0,f.toDisplayString)(e.name)+`) `,1),S(e.id)?((0,f.openBlock)(),(0,f.createElementBlock)(`span`,Xo,[...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,Jo))),128))])]),(0,f.createElementVNode)(`div`,Zo,[t[8]||=(0,f.createElementVNode)(`div`,{class:`menu-title`},`副图指标`,-1),(0,f.createElementVNode)(`div`,Qo,[((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`,es,` (`+(0,f.toDisplayString)(e.name)+`) `,1),S(e.id)?((0,f.openBlock)(),(0,f.createElementBlock)(`span`,ts,[...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,$o))),128))])])],6)):(0,f.createCommentVNode)(``,!0)]),_:1})],8,[`to`])),x.value?((0,f.openBlock)(),(0,f.createBlock)(Mo,{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-0f3a76b5`]]),rs={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function is(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,rs,[...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 as=(0,f.markRaw)({name:`tabler-trash`,render:is}),os={class:`toolbar-item color-item`,title:`颜色`},ss=[`value`],cs=[`value`],ls=[`value`],us=ao((0,f.defineComponent)({__name:`DrawingStyleToolbar`,props:{drawing:{}},emits:[`updateStyle`,`delete`],setup(e,{emit:t}){let n=t;function r(e){n(`updateStyle`,{stroke:e})}function i(e){n(`updateStyle`,{strokeWidth:e})}function a(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`,os,[(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=>r(e.target.value)},null,40,ss)]),(0,f.createElementVNode)(`select`,{class:`toolbar-select`,value:e.drawing.style.strokeWidth??1,onChange:n[1]||=e=>i(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,cs),(0,f.createElementVNode)(`select`,{class:`toolbar-select`,value:e.drawing.style.strokeStyle??`solid`,onChange:n[2]||=e=>a(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,ls),(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)(as),{class:`delete-icon`,"aria-hidden":`true`})])],32))}}),[[`__scopeId`,`data-v-088ccef5`]]);function ds(e,t){let n=Math.round(e*t);return n%2==0&&(n+=1),Math.max(1,n)}function Z(e,t,n){let r=ds(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 fs(e,t,n,r,i,a=1){let{unitPx:o,startXPx:s}=Z(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 ps(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 ms={logicalOffset:4,coordOffset:1e-4};function hs(e){return Math.abs(e)<1e-15}function Q(e,t){let n=Math.abs(e);if(hs(n))return 0;let r=Math.log10(n+t.coordOffset)+t.logicalOffset;return e<0?-r:r}function gs(e,t){let n=Math.abs(e);if(hs(n))return 0;let r=10**(n-t.logicalOffset)-t.coordOffset;return e<0?-r:r}function _s(e){if(e===null)return{...ms};let t=Math.abs(e.maxPrice-e.minPrice);if(t>=1||t<1e-15)return{...ms};let n=Math.ceil(Math.abs(Math.log10(t))),r=ms.logicalOffset+n;return{logicalOffset:r,coordOffset:1/10**r}}function vs(e,t){return e.logicalOffset===t.logicalOffset&&e.coordOffset===t.coordOffset}var ys=class{range={maxPrice:100,minPrice:0};height=1;paddingTop=0;paddingBottom=0;priceOffset=0;verticalScale=1;scaleType=`linear`;logFormula=_s(null);setRange(e){if(this.range=e,this.scaleType===`log`&&e.minPrice>0){let t=_s(e);if(!vs(t,this.logFormula)){let n=Q(e.minPrice,this.logFormula),r=(Q(e.maxPrice,this.logFormula)+n)/2+this.priceOffset;this.logFormula=t;let i=Q(e.minPrice,this.logFormula),a=(Q(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=Q(this.range.minPrice,this.logFormula),n=Q(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=_s(this.range);let e=(this.range.maxPrice+this.range.minPrice)/2,t=e+this.priceOffset;this.priceOffset=Q(t,this.logFormula)-Q(e,this.logFormula),this.priceOffset=this.clampOffset(this.priceOffset)}else if(e===`linear`&&this.scaleType===`log`){let e=Q(this.range.minPrice,this.logFormula),t=gs((Q(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=Q(t,this.logFormula),r=Q(n,this.logFormula),i=r-e||1,a=(r+e)/2+this.priceOffset,o=i/(2*this.verticalScale);return{maxPrice:gs(a+o,this.logFormula),minPrice:gs(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=Q(n,this.logFormula),a=Q(t,this.logFormula);i=(Q(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=Q(n,this.logFormula);return gs(e+i*(Q(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=Q(this.range.minPrice,this.logFormula);return e*((Q(this.range.maxPrice,this.logFormula)-n)/t)}return e*((this.range.maxPrice-this.range.minPrice||1)/t)}};function bs(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 xs=class{id;role;capabilities;top=0;height=0;priceRange={maxPrice:100,minPrice:0};yAxis=new ys;renderers=[];constructor(e,t={}){this.id=e,this.role=t.role??(e===`main`?`price`:`indicator`),this.capabilities={...bs(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){this.priceRange=ps(e,t.start,t.end),this.yAxis.setRange(this.priceRange)}},Ss=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;hoveredMarkerId=null;clickedMarkerId=null;hoveredMarkerData=null;clickedMarkerData=null;onMarkerHoverCallback;onMarkerClickCallback;hoveredCustomMarker=null;onCustomMarkerHoverCallback;onCustomMarkerClickCallback;kLinePositions=null;visibleRange=null;kWidthPx=null;constructor(e){this.chart=e}setOnPinchZoom(e){this.onPinchZoomCallback=e}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())}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 n=this.chart.getDom().container,{mouseX:r,mouseY:i}=t,a=n.scrollLeft,o=this.chart.getMarkerManager(),s=a+r,c=o.hitTest(s,i,3);if(c){this.clickedMarkerId=c.id,this.clickedMarkerData=c,this.onMarkerClickCallback&&this.onMarkerClickCallback(c);return}let l=this.hitTestPaneSeparator(i);if(l){this.isDragging=!0,this.dragMode=`resize-separator`,this.dragStartY=e.clientY,this.activeSeparatorUpperPaneId=l,this.hoveredSeparatorUpperPaneId=l,this.clearHover(),this.chart.scheduleDraw();return}let u=this.getPaneByY(i);this.isDragging=!0,this.dragMode=`pan`,this.updatePlotHoverFromPoint(e.clientX,e.clientY),this.dragStartX=e.clientX,this.dragStartY=e.clientY,this.scrollStartX=n.scrollLeft,this.activePaneIdOnDrag=u?.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;r!==0&&this.activePaneIdOnDrag===`main`&&(this.chart.translatePrice(this.activePaneIdOnDrag,r),this.dragStartY=e.clientY)}return}let n=this.getPlotPointerLocation(e.clientX,e.clientY);n&&(this.hoveredSeparatorUpperPaneId=this.hitTestPaneSeparator(n.mouseY),this.updatePlotHoverFromPoint(e.clientX,e.clientY),this.chart.scheduleDraw(),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){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),this.chart.scheduleDraw(),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?(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):!1}clearHover(){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=a.scrollLeft,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.kWidthPx=null}getCrosshairIndex(){return this.crosshairIndex}},Cs=class{dom;pane;opt;constructor(e,t,n){this.dom=e,this.pane=t,this.opt={...n,priceLabelWidth:n.priceLabelWidth||60}}getPane(){return this.pane}getDom(){return this.dom}resize(e,t,n){let r=this.dom.plotCanvas,i=this.dom.yAxisCanvas;r.width=Math.round(e*n),r.height=Math.round(t*n),r.style.width=`${r.width/n}px`,r.style.height=`${r.height/n}px`;let a=this.opt.rightAxisWidth+(this.opt.priceLabelWidth||60),o=i.parentElement?.clientWidth??0;i.width=Math.round((o>0?o:a)*n),i.height=Math.round(t*n),i.style.width=`${i.width/n}px`,i.style.height=`${i.height/n}px`}destroy(){}};function ws(e){let{dataLength:t,kWidth:n,kGap:r,viewWidth:i,viewportDpr:a}=e;if(t===0)return 0;let{startXPx:o,unitPx:s}=Z(n,r,a),c=(o+(t+24)*s)/a;return Math.max(c,i)}function Ts(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)(()=>ws({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 Es=(e,t)=>`indicator:${e}:${t}`;function Ds(e={}){let{paneId:t=`sub`}=e,n=Es(`volume`,t),r=null;return{name:`volume_${t}`,version:`1.0.0`,description:`成交量渲染器`,debugName:`成交量`,paneId:t,priority:K.MAIN,onInstall(e){r=e},getDeclaredNamespaces(){return[n]},draw(e){let{ctx:i,pane:a,data:o,range:s,scrollLeft:c,dpr:l}=e,u=o;if(!u.length)return;i.save(),i.translate(-c,0);let{start:d,end:f}=s,p=0,m=1/0;for(let e=d;e<f&&e<u.length;e++){let t=u[e];if(!t)continue;let n=t.volume;n!=null&&(p=Math.max(p,n),m=Math.min(m,n))}if(p===0||!Number.isFinite(m)){i.restore();return}let h=Math.max(.05,(p-m)*.1),g=Math.max(0,m-h),_=p+h,v=a.yAxis.getDisplayRange({minPrice:g,maxPrice:_}),y=v.minPrice,b=v.maxPrice-y||1,x=a.height-(0-y)/b*a.height;r?.setSharedState(n,{valueMin:g,valueMax:_,timestamp:Date.now()},`volume_${t}`);for(let t=d;t<f;t++){let n=u[t];if(!n)continue;let r=n.volume;if(!r)continue;let o=e.kBarRects[t-d];if(!o)continue;let s=o.x,c=o.width;Os(i,s,ks(n),r,c,y,b,x,a.height,l)}i.restore()}}}function Os(e,t,n,r,i,a,o,s,c,l){let u=c-(r-a)/o*c,d=Math.round(u*l)/l,f=Math.round(s*l)/l,p=1/l,m=f-d,h=m<=0?p:Math.max(m,p),g=m<=0?f-p:f-h;e.fillStyle=n,e.fillRect(t,g,i,h)}function ks(e){return e.close>e.open?ca.UP:e.close<e.open?ca.DOWN:ca.NEUTRAL}function As(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 js(e={}){let t={ma5:!0,ma10:!0,ma20:!0,ma30:!0,ma60:!0,...e},n=new Map,r=null;function i(e,t){let i=n.get(t);if(i&&r===e)return i.values;let a=As(e,t);return n.set(t,{period:t,values:a}),r=e,a}function a(e,t,n,r){let{pane:i,range:a,dpr:o,kLineCenters:s}=n;e.strokeStyle=r,e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,e.beginPath();let c=!0;for(let n=a.start;n<a.end&&n<t.length;n++){let r=t[n];if(r===void 0)continue;let l=s[n-a.start];if(l===void 0)continue;let u=i.yAxis.priceToY(r),d=l,f=X(u,o);c?(e.moveTo(d,f),c=!1):e.lineTo(d,f)}e.stroke()}return{name:`ma`,version:`1.0.0`,description:`MA均线渲染器`,debugName:`MA均线`,paneId:`main`,priority:K.INDICATOR,draw(e){let{ctx:n,data:r,scrollLeft:o}=e,s=r;s.length&&(n.save(),n.translate(-o,0),t.ma5&&a(n,i(s,5),e,J.MA5),t.ma10&&a(n,i(s,10),e,J.MA10),t.ma20&&a(n,i(s,20),e,J.MA20),t.ma30&&a(n,i(s,30),e,J.MA30),t.ma60&&a(n,i(s,60),e,J.MA60),n.restore())},onDataUpdate(){r=null,n.clear()},getConfig(){return{...t}},setConfig(e){Object.assign(t,e)}}}function Ms(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 Ns(e={}){let t={period:20,multiplier:2,showUpper:!0,showMiddle:!0,showLower:!0,showBand:!0,...e},n=null,r=0,i=0,a=[];function o(e){return(n!==e||r!==t.period||i!==t.multiplier)&&(a=Ms(e,t.period,t.multiplier),n=e,r=t.period,i=t.multiplier),a}return{name:`boll`,version:`1.0.0`,description:`布林带渲染器`,debugName:`BOLL布林带`,paneId:`main`,priority:K.INDICATOR,draw(e){let{ctx:n,pane:r,data:i,range:a,scrollLeft:s,dpr:c,kLineCenters:l}=e,u=i;if(u.length<t.period)return;let d=o(u);n.save(),n.translate(-s,0);let f=Math.max(a.start,t.period-1),p=Math.min(a.end,u.length);if(t.showBand){n.fillStyle=oa.BAND_FILL,n.beginPath();let e=!0;for(let t=f;t<p;t++){let i=d[t];if(!i)continue;let o=l[t-a.start];if(o===void 0)continue;let s=r.yAxis.priceToY(i.upper),u=o,f=X(s,c);e?(n.moveTo(u,f),e=!1):n.lineTo(u,f)}for(let e=p-1;e>=f;e--){let t=d[e];if(!t)continue;let i=l[e-a.start];if(i===void 0)continue;let o=r.yAxis.priceToY(t.lower),s=i,u=X(o,c);n.lineTo(s,u)}n.closePath(),n.fill()}n.lineWidth=1,n.lineJoin=`round`,n.lineCap=`round`;let m=(e,t)=>{n.strokeStyle=t,n.beginPath();let i=!0;for(let t=f;t<p;t++){let o=d[t];if(!o)continue;let s=l[t-a.start];if(s===void 0)continue;let u=r.yAxis.priceToY(o[e]),f=s,p=X(u,c);i?(n.moveTo(f,p),i=!1):n.lineTo(f,p)}n.stroke()};t.showUpper&&m(`upper`,oa.UPPER),t.showMiddle&&m(`middle`,oa.MIDDLE),t.showLower&&m(`lower`,oa.LOWER),n.restore()},onDataUpdate(){n=null},getConfig(){return{...t}},setConfig(e){`period`in e&&e.period!==t.period&&(n=null),`multiplier`in e&&e.multiplier!==t.multiplier&&(n=null),Object.assign(t,e)}}}function Ps(e,t,n=20,r=2){if(t<n-1||t>=e.length)return null;let i=0;for(let r=0;r<n;r++){let n=e[t-r];if(!n)return null;i+=n.close}let a=i/n,o=0;for(let r=0;r<n;r++){let n=e[t-r];if(!n)return null;o+=(n.close-a)**2}let s=Math.sqrt(o/n);return{upper:a+r*s,middle:a,lower:a-r*s}}function Fs(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 Is(e,t,n=12,r=50){if(t<0||t>=e.length)return null;let i=2/(n+1),a=2/(r+1),o=e[0].close,s=o,c=o;for(let n=1;n<=t;n++){let t=e[n].close;s=t*i+s*(1-i),c=t*a+c*(1-a)}return{fast:s,slow:c}}function Ls(e={}){let t={fastPeriod:12,slowPeriod:50,...e},n=null,r=0,i=0,a=[];function o(e){return(n!==e||r!==t.fastPeriod||i!==t.slowPeriod)&&(a=Fs(e,t.fastPeriod,t.slowPeriod),n=e,r=t.fastPeriod,i=t.slowPeriod),a}return{name:`expma`,version:`1.0.0`,description:`EXPMA 指数平滑移动平均线渲染器`,debugName:`EXPMA`,paneId:`main`,priority:K.INDICATOR,draw(e){let{ctx:t,pane:n,data:r,range:i,scrollLeft:a,kWidth:s,dpr:c,kLinePositions:l}=e,u=r;if(u.length<2)return;let d=o(u);t.save(),t.translate(-a,0);let f=i.start,p=Math.min(i.end,u.length),m=ha.FAST,h=ha.SLOW,g=(r,a)=>{t.strokeStyle=a,t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,t.beginPath();let o=!0;for(let a=f;a<p;a++){let s=d[a];if(!s)continue;let l=e.kLineCenters[a-i.start];if(l===void 0)continue;let u=n.yAxis.priceToY(s[r]),f=l,p=X(u,c);o?(t.moveTo(f,p),o=!1):t.lineTo(f,p)}t.stroke()};g(`fast`,m),g(`slow`,h),t.restore()},onDataUpdate(){n=null},getConfig(){return{...t}},setConfig(e){`fastPeriod`in e&&e.fastPeriod!==t.fastPeriod&&(n=null),`slowPeriod`in e&&e.slowPeriod!==t.slowPeriod&&(n=null),Object.assign(t,e)}}}function Rs(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 zs(e,t,n=10,r=11){if(t<n-1||t>=e.length)return null;let i=0;for(let r=0;r<n;r++){let n=e[t-r];if(!n)return null;i+=n.close}let a=i/n,o=r/100;return{upper:a*(1+o),middle:a,lower:a*(1-o)}}function Bs(e={}){let t={period:10,deviation:11,...e},n=null,r=0,i=0,a=[];function o(e){return(n!==e||r!==t.period||i!==t.deviation)&&(a=Rs(e,t.period,t.deviation),n=e,r=t.period,i=t.deviation),a}return{name:`ene`,version:`1.0.0`,description:`ENE 轨道线渲染器`,debugName:`ENE轨道线`,paneId:`main`,priority:K.INDICATOR,draw(e){let{ctx:n,pane:r,data:i,range:a,scrollLeft:s,dpr:c,kLineCenters:l}=e,u=i;if(u.length<t.period)return;let d=o(u);n.save(),n.translate(-s,0);let f=Math.max(a.start,t.period-1),p=Math.min(a.end,u.length);n.fillStyle=`rgba(69, 112, 249, 0.08)`,n.beginPath();let m=!0;for(let e=f;e<p;e++){let t=d[e];if(!t)continue;let i=l[e-a.start];if(i===void 0)continue;let o=r.yAxis.priceToY(t.upper),s=i,u=X(o,c);m?(n.moveTo(s,u),m=!1):n.lineTo(s,u)}for(let e=p-1;e>=f;e--){let t=d[e];if(!t)continue;let i=l[e-a.start];if(i===void 0)continue;let o=r.yAxis.priceToY(t.lower),s=i,u=X(o,c);n.lineTo(s,u)}n.closePath(),n.fill(),n.lineWidth=1,n.lineJoin=`round`,n.lineCap=`round`;let h=(e,t)=>{n.strokeStyle=t,n.beginPath();let i=!0;for(let t=f;t<p;t++){let o=d[t];if(!o)continue;let s=l[t-a.start];if(s===void 0)continue;let u=r.yAxis.priceToY(o[e]),f=s,p=X(u,c);i?(n.moveTo(f,p),i=!1):n.lineTo(f,p)}n.stroke()};h(`upper`,`rgba(214, 10, 34, 1)`),h(`middle`,`rgba(69, 112, 249, 1)`),h(`lower`,`rgba(3, 123, 102, 1)`),n.restore()},onDataUpdate(){n=null},getConfig(){return{...t}},setConfig(e){`period`in e&&e.period!==t.period&&(n=null),`deviation`in e&&e.deviation!==t.deviation&&(n=null),Object.assign(t,e)}}}function Vs(e,t,n){if(t<n-1)return;let r=0;for(let i=0;i<n;i++){let n=e[t-i];if(!n)return;r+=n.close}return r/n}var Hs=`"Trebuchet MS", Roboto, Ubuntu, sans-serif`;function Us(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}}}};return{name:`mainIndicatorLegend`,version:`1.0.0`,description:`主图指标图例渲染器(统一管理 MA、BOLL 等)`,debugName:`主图指标图例`,paneId:`main`,priority:K.FOREGROUND,enabled:!0,draw(e){let{ctx:n,data:r,range:i,crosshairIndex:a}=e,o=r;if(!o.length)return;n.save(),n.font=`12px Arial`,n.textAlign=`left`;let s=a??Math.min(i.end-1,o.length-1),c=[],l=t.indicators.MA;l?.enabled&&c.push({draw:e=>{let r=[],i=l.params.periods;if(i&&Array.isArray(i)?i.forEach(e=>{let t=`MA${e}`;r.push({label:`MA${e}`,color:J[t]||J.MA5,value:Vs(o,s,e)})}):r.push({label:`MA5`,color:J.MA5,value:Vs(o,s,5)},{label:`MA10`,color:J.MA10,value:Vs(o,s,10)},{label:`MA20`,color:J.MA20,value:Vs(o,s,20)},{label:`MA30`,color:J.MA30,value:Vs(o,s,30)},{label:`MA60`,color:J.MA60,value:Vs(o,s,60)}),r.length>0){let i=12,a=t.yPaddingPx/2+12+e*18;n.fillStyle=q.NEUTRAL,n.fillText(`MA`,i,a),i+=n.measureText(`MA`).width+10;for(let e of r){let t=typeof e.value==`number`?` ${e.value.toFixed(2)}`:``,r=`${e.label}${t}`;n.fillStyle=e.color,n.fillText(r,i,a),i+=n.measureText(r).width+10}}}});let u=t.indicators.BOLL;u?.enabled&&c.push({draw:e=>{let r=u.params.period??20,i=u.params.multiplier??2,a=Ps(o,s,r,i),c=12,l=t.yPaddingPx/2+12+e*18;n.fillStyle=q.NEUTRAL,n.fillText(`BOLL(${r},${i})`,c,l),c+=n.measureText(`BOLL(${r},${i})`).width+10,a&&(n.fillStyle=oa.UPPER,n.fillText(`上轨:${a.upper.toFixed(2)}`,c,l),c+=n.measureText(`上轨:${a.upper.toFixed(2)}`).width+10,n.fillStyle=oa.MIDDLE,n.fillText(`中轨:${a.middle.toFixed(2)}`,c,l),c+=n.measureText(`中轨:${a.middle.toFixed(2)}`).width+10,n.fillStyle=oa.LOWER,n.fillText(`下轨:${a.lower.toFixed(2)}`,c,l))}});let d=t.indicators.EXPMA;d?.enabled&&c.push({draw:e=>{let r=d.params.fastPeriod??12,i=d.params.slowPeriod??50,a=Is(o,s,r,i),c=12,l=t.yPaddingPx/2+12+e*18;n.fillStyle=q.NEUTRAL,n.fillText(`EXPMA(${r},${i})`,c,l),c+=n.measureText(`EXPMA(${r},${i})`).width+10,a&&(n.fillStyle=ha.FAST,n.fillText(`快:${a.fast.toFixed(2)}`,c,l),c+=n.measureText(`快:${a.fast.toFixed(2)}`).width+10,n.fillStyle=ha.SLOW,n.fillText(`慢:${a.slow.toFixed(2)}`,c,l))}});let f=t.indicators.ENE;f?.enabled&&c.push({draw:e=>{let r=f.params.period??10,i=f.params.deviation??11,a=zs(o,s,r,i),c=12,l=t.yPaddingPx/2+12+e*18;n.fillStyle=q.NEUTRAL,n.fillText(`ENE(${r},${i})`,c,l),c+=n.measureText(`ENE(${r},${i})`).width+10,a&&(n.fillStyle=ga.UPPER,n.fillText(`上轨:${a.upper.toFixed(2)}`,c,l),c+=n.measureText(`上轨:${a.upper.toFixed(2)}`).width+10,n.fillStyle=ga.MIDDLE,n.fillText(`中轨:${a.middle.toFixed(2)}`,c,l),c+=n.measureText(`中轨:${a.middle.toFixed(2)}`).width+10,n.fillStyle=ga.LOWER,n.fillText(`下轨:${a.lower.toFixed(2)}`,c,l))}}),c.forEach((e,t)=>e.draw(t)),n.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 Ws(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 Gs(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 Ks(e,t,n,r){let i=Array(e.length);if(e.length<n)return i;let a=Ws(e,t),o=Ws(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=Gs(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 qs(e={}){let{paneId:t=`sub`,config:n={}}=e,r=Es(`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=Ks(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:K.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;n.save(),n.translate(-l,0);let 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;for(let r=E;r<D;r++){let i=p[r];if(!i)continue;let a=e.kBarRects[r-c.start];if(!a)continue;let s=a.x,l=a.width,d=o.height-(i.macd-C)/w*o.height,f=i.macd>=0,m=r>0?p[r-1]:null,h;h=m?i.macd>=m.macd:!0;let g;g=f?h?sa.BAR_UP:sa.BAR_UP_LIGHT:h?sa.BAR_DOWN_LIGHT:sa.BAR_DOWN,n.fillStyle=g;let _=Math.round(d*u)/u,v=1/u;if(f){let e=t-_,r=e<=0?v:Math.max(e,v),i=e<=0?t-v:t-r;n.fillRect(s,i,l,r)}else{let e=_-t,r=e<=0?v:Math.max(e,v);n.fillRect(s,t,l,r)}}}if(a.showDIF){n.strokeStyle=sa.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=X(s,u);t?(n.moveTo(l,d),t=!1):n.lineTo(l,d)}n.stroke()}if(a.showDEA){n.strokeStyle=sa.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=X(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 Js(e,t,n=12,r=26,i=9){return t<r||t>=e.length?null:Ks(e,n,r,i)[t]??null}function Ys(e,t,n=12,r=26,i=9){let a=Js(e,t,n,r,i);return a?{name:`MACD`,params:[n,r,i],values:[{label:`DIF`,value:a.dif,color:sa.DIF},{label:`DEA`,value:a.dea,color:sa.DEA},{label:`MACD`,value:a.macd,color:a.macd>=0?sa.BAR_UP:sa.BAR_DOWN}]}:null}function Xs(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 Zs(e={}){let{paneId:t=`sub`,config:n={}}=e,r=Es(`rsi`,t),i=null,a={period1:6,period2:12,period3:24,showRSI1:!0,showRSI2:!0,showRSI3:!0,...n},o=null,s=0,c=0,l=0,u=[],d=[],f=[];function p(e){return(o!==e||s!==a.period1||c!==a.period2||l!==a.period3)&&(u=Xs(e,a.period1),d=Xs(e,a.period2),f=Xs(e,a.period3),o=e,s=a.period1,c=a.period2,l=a.period3),{rsi1:u,rsi2:d,rsi3:f}}return{name:`rsi_${t}`,version:`1.0.0`,description:`RSI 相对强弱指标渲染器`,debugName:`RSI`,paneId:t,priority:K.MAIN,onInstall(e){i=e},getDeclaredNamespaces(){return[r]},draw(e){let{ctx:n,pane:o,data:s,range:c,scrollLeft:l,dpr:u,kLineCenters:d}=e,f=s;if(f.length<a.period1+1)return;let{rsi1:m,rsi2:h,rsi3:g}=p(f),_={valueMin:0,valueMax:100,timestamp:Date.now()};i?.setSharedState(r,_,`rsi_${t}`);let v=o.yAxis.getDisplayRange({minPrice:0,maxPrice:100}),y=v.minPrice,b=v.maxPrice-y||1;n.save(),n.translate(-l,0);let x=o.height-(80-y)/b*o.height,S=o.height-(50-y)/b*o.height,C=o.height-(20-y)/b*o.height,w=l,T=l+e.paneWidth;n.strokeStyle=`rgba(0, 0, 0, 0.1)`,n.lineWidth=1,n.setLineDash([4,4]),n.beginPath(),n.moveTo(w,x),n.lineTo(T,x),n.moveTo(w,S),n.lineTo(T,S),n.moveTo(w,C),n.lineTo(T,C),n.stroke(),n.setLineDash([]);let E=Math.max(c.start,a.period1),D=Math.min(c.end,f.length),O=(e,t)=>{n.strokeStyle=t,n.lineWidth=1,n.lineJoin=`round`,n.lineCap=`round`,n.beginPath();let r=!0;for(let t=E;t<D;t++){let i=e[t];if(i===void 0)continue;let a=d[t-c.start];if(a===void 0)continue;let s=o.height-(i-y)/b*o.height,l=a,f=X(s,u);r?(n.moveTo(l,f),r=!1):n.lineTo(l,f)}n.stroke()};a.showRSI1&&O(m,la.RSI1),a.showRSI2&&O(h,la.RSI2),a.showRSI3&&O(g,la.RSI3),n.restore()},onDataUpdate(){o=null},getConfig(){return{...a}},setConfig(e){`period1`in e&&e.period1!==a.period1&&(o=null),`period2`in e&&e.period2!==a.period2&&(o=null),`period3`in e&&e.period3!==a.period3&&(o=null),Object.assign(a,e)}}}function Qs(e,t,n=6,r=12,i=24){if(t<n+1||t>=e.length)return null;let a=Xs(e,n)[t],o=Xs(e,r)[t],s=Xs(e,i)[t],c=[];return a!==void 0&&c.push({label:`RSI${n}`,value:a,color:la.RSI1}),o!==void 0&&c.push({label:`RSI${r}`,value:o,color:la.RSI2}),s!==void 0&&c.push({label:`RSI${i}`,value:s,color:la.RSI3}),c.length===0?null:{name:`RSI`,params:[n,r,i],values:c}}function $s(e,t){let n=Array(e.length);if(e.length<t)return n;let r=e.map(e=>(e.high+e.low+e.close)/3);for(let i=t-1;i<e.length;i++){let e=0;for(let n=0;n<t;n++)e+=r[i-n];let a=e/t,o=0;for(let e=0;e<t;e++)o+=Math.abs(r[i-e]-a);let s=o/t;s===0?n[i]=0:n[i]=(r[i]-a)/(.015*s)}return n}function ec(e={}){let{paneId:t=`sub`,config:n={}}=e,r=Es(`cci`,t),i=null,a={period:14,showCCI:!0,...n},o=null,s=0,c=[];function l(e){return(o!==e||s!==a.period)&&(c=$s(e,a.period),o=e,s=a.period),c}return{name:`cci_${t}`,version:`1.0.0`,description:`CCI 顺势指标渲染器`,debugName:`CCI`,paneId:t,priority:K.MAIN,onInstall(e){i=e},getDeclaredNamespaces(){return[r]},draw(e){let{ctx:n,pane:o,data:s,range:c,scrollLeft:u,dpr:d,kLineCenters:f}=e,p=s;if(p.length<a.period)return;let m=l(p),h=-1/0,g=1/0;for(let e=c.start;e<c.end&&e<m.length;e++){let t=m[e];t!==void 0&&(h=Math.max(h,t),g=Math.min(g,t))}if(!Number.isFinite(h)||!Number.isFinite(g))return;h=Math.max(h,150),g=Math.min(g,-150),h-g;let _={valueMin:g,valueMax:h,timestamp:Date.now()};i?.setSharedState(r,_,`cci_${t}`);let v=o.yAxis.getDisplayRange({minPrice:g,maxPrice:h}),y=v.minPrice,b=v.maxPrice-y||1,x=o.height-(0-y)/b*o.height;n.save(),n.translate(-u,0);let S=o.height-(100-y)/b*o.height,C=o.height-(-100-y)/b*o.height,w=u,T=u+e.paneWidth;n.strokeStyle=ua.OVERBOUGHT,n.lineWidth=1,n.setLineDash([4,4]),n.beginPath(),n.moveTo(w,S),n.lineTo(T,S),n.stroke(),n.strokeStyle=ua.OVERSOLD,n.beginPath(),n.moveTo(w,C),n.lineTo(T,C),n.stroke(),n.strokeStyle=`rgba(0, 0, 0, 0.1)`,n.beginPath(),n.moveTo(w,x),n.lineTo(T,x),n.stroke(),n.setLineDash([]);let E=Math.max(c.start,a.period-1),D=Math.min(c.end,p.length);if(a.showCCI){n.strokeStyle=ua.CCI,n.lineWidth=1,n.lineJoin=`round`,n.lineCap=`round`,n.beginPath();let e=!0;for(let t=E;t<D;t++){let r=m[t];if(r===void 0)continue;let i=f[t-c.start];if(i===void 0)continue;let a=o.height-(r-y)/b*o.height,s=i,l=X(a,d);e?(n.moveTo(s,l),e=!1):n.lineTo(s,l)}n.stroke()}n.restore()},onDataUpdate(){o=null},getConfig(){return{...a}},setConfig(e){`period`in e&&e.period!==a.period&&(o=null),Object.assign(a,e)}}}function tc(e,t,n){return $s(e,n)[t]}function nc(e,t,n=14){if(t<n||t>=e.length)return null;let r=tc(e,t,n);return r===void 0?null:{name:`CCI`,params:[n],values:[{label:`CCI`,value:r,color:ua.CCI}]}}function rc(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 ic(e={}){let{paneId:t=`sub`,config:n={}}=e,r=Es(`stoch`,t),i=null,a={n:9,m:3,showK:!0,showD:!0,...n},o=null,s=0,c=0,l=[];function u(e){return(o!==e||s!==a.n||c!==a.m)&&(l=rc(e,a.n,a.m),o=e,s=a.n,c=a.m),l}return{name:`stoch_${t}`,version:`1.0.0`,description:`STOCH 随机指标渲染器`,debugName:`STOCH`,paneId:t,priority:K.MAIN,onInstall(e){i=e},getDeclaredNamespaces(){return[r]},draw(e){let{ctx:n,pane:o,data:s,range:c,scrollLeft:l,dpr:d,kLineCenters:f}=e,p=s;if(p.length<a.n+a.m-1)return;let m=u(p),h={valueMin:0,valueMax:100,timestamp:Date.now()};i?.setSharedState(r,h,`stoch_${t}`);let g=o.yAxis.getDisplayRange({minPrice:0,maxPrice:100}),_=g.minPrice,v=g.maxPrice-_||1;n.save(),n.translate(-l,0);let y=o.height-(80-_)/v*o.height,b=o.height-(20-_)/v*o.height,x=l,S=l+e.paneWidth;n.strokeStyle=`rgba(0, 0, 0, 0.1)`,n.lineWidth=1,n.setLineDash([4,4]),n.beginPath(),n.moveTo(x,y),n.lineTo(S,y),n.moveTo(x,b),n.lineTo(S,b),n.stroke(),n.setLineDash([]);let C=Math.max(c.start,a.n+a.m-2),w=Math.min(c.end,p.length);if(a.showK){n.strokeStyle=da.K,n.lineWidth=1,n.lineJoin=`round`,n.lineCap=`round`,n.beginPath();let e=!0;for(let t=C;t<w;t++){let r=m[t];if(!r)continue;let i=f[t-c.start];if(i===void 0)continue;let a=o.height-(r.k-_)/v*o.height,s=i,l=X(a,d);e?(n.moveTo(s,l),e=!1):n.lineTo(s,l)}n.stroke()}if(a.showD){n.strokeStyle=da.D,n.lineWidth=1,n.lineJoin=`round`,n.lineCap=`round`,n.beginPath();let e=!0;for(let t=C;t<w;t++){let r=m[t];if(!r)continue;let i=f[t-c.start];if(i===void 0)continue;let a=o.height-(r.d-_)/v*o.height,s=i,l=X(a,d);e?(n.moveTo(s,l),e=!1):n.lineTo(s,l)}n.stroke()}n.restore()},onDataUpdate(){o=null},getConfig(){return{...a}},setConfig(e){`n`in e&&e.n!==a.n&&(o=null),`m`in e&&e.m!==a.m&&(o=null),Object.assign(a,e)}}}function ac(e,t,n,r){return rc(e,n,r)[t]}function oc(e,t,n=9,r=3){if(t<n+r-1||t>=e.length)return null;let i=ac(e,t,n,r);return i?{name:`STOCH`,params:[n,r],values:[{label:`K`,value:i.k,color:da.K},{label:`D`,value:i.d,color:da.D}]}:null}function sc(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 cc(e={}){let{paneId:t=`sub`,config:n={}}=e,r=Es(`mom`,t),i=null,a={period:10,showMOM:!0,...n},o=null,s=0,c=[];function l(e){return(o!==e||s!==a.period)&&(c=sc(e,a.period),o=e,s=a.period),c}return{name:`mom_${t}`,version:`1.0.0`,description:`MOM 动量指标渲染器`,debugName:`MOM`,paneId:t,priority:K.MAIN,onInstall(e){i=e},getDeclaredNamespaces(){return[r]},draw(e){let{ctx:n,pane:o,data:s,range:c,scrollLeft:u,dpr:d,kLineCenters:f}=e,p=s;if(p.length<a.period+1)return;let m=l(p),h=-1/0,g=1/0;for(let e=c.start;e<c.end&&e<m.length;e++){let t=m[e];t!==void 0&&(h=Math.max(h,t),g=Math.min(g,t))}if(!Number.isFinite(h)||!Number.isFinite(g))return;let _=Math.max(Math.abs(h),Math.abs(g))*.1;h+=_,g-=_,h-g;let v={valueMin:g,valueMax:h,timestamp:Date.now()};i?.setSharedState(r,v,`mom_${t}`);let y=o.yAxis.getDisplayRange({minPrice:g,maxPrice:h}),b=y.minPrice,x=y.maxPrice-b||1,S=o.height-(0-b)/x*o.height;n.save(),n.translate(-u,0);let C=u,w=u+e.paneWidth;n.strokeStyle=fa.ZERO,n.lineWidth=1,n.beginPath(),n.moveTo(C,S),n.lineTo(w,S),n.stroke();let T=Math.max(c.start,a.period),E=Math.min(c.end,p.length);if(a.showMOM){n.strokeStyle=fa.MOM,n.lineWidth=1,n.lineJoin=`round`,n.lineCap=`round`,n.beginPath();let e=!0;for(let t=T;t<E;t++){let r=m[t];if(r===void 0)continue;let i=f[t-c.start];if(i===void 0)continue;let a=o.height-(r-b)/x*o.height,s=i,l=X(a,d);e?(n.moveTo(s,l),e=!1):n.lineTo(s,l)}n.stroke()}n.restore()},onDataUpdate(){o=null},getConfig(){return{...a}},setConfig(e){`period`in e&&e.period!==a.period&&(o=null),Object.assign(a,e)}}}function lc(e,t,n){return sc(e,n)[t]}function uc(e,t,n=10){if(t<n||t>=e.length)return null;let r=lc(e,t,n);return r===void 0?null:{name:`MOM`,params:[n],values:[{label:`MOM`,value:r,color:fa.MOM}]}}function dc(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 fc(e={}){let{paneId:t=`sub`,config:n={}}=e,r=Es(`wmsr`,t),i=null,a={period:14,showWMSR:!0,...n},o=null,s=0,c=[];function l(e){return(o!==e||s!==a.period)&&(c=dc(e,a.period),o=e,s=a.period),c}return{name:`wmsr_${t}`,version:`1.0.0`,description:`WMSR 威廉指标渲染器`,debugName:`WMSR`,paneId:t,priority:K.MAIN,onInstall(e){i=e},getDeclaredNamespaces(){return[r]},draw(e){let{ctx:n,pane:o,data:s,range:c,scrollLeft:u,dpr:d,kLineCenters:f}=e,p=s;if(p.length<a.period)return;let m=l(p),h=-100;0-h;let g={valueMin:h,valueMax:0,timestamp:Date.now()};i?.setSharedState(r,g,`wmsr_${t}`);let _=o.yAxis.getDisplayRange({minPrice:h,maxPrice:0}),v=_.minPrice,y=_.maxPrice-v||1;n.save(),n.translate(-u,0);let b=o.height-(-20-v)/y*o.height,x=o.height-(-80-v)/y*o.height,S=o.height-(-50-v)/y*o.height,C=u,w=u+e.paneWidth;n.strokeStyle=pa.OVERBOUGHT,n.lineWidth=1,n.setLineDash([4,4]),n.beginPath(),n.moveTo(C,b),n.lineTo(w,b),n.stroke(),n.strokeStyle=pa.OVERSOLD,n.beginPath(),n.moveTo(C,x),n.lineTo(w,x),n.stroke(),n.strokeStyle=`rgba(0, 0, 0, 0.1)`,n.beginPath(),n.moveTo(C,S),n.lineTo(w,S),n.stroke(),n.setLineDash([]);let T=Math.max(c.start,a.period-1),E=Math.min(c.end,p.length);if(a.showWMSR){n.strokeStyle=pa.WMSR,n.lineWidth=1,n.lineJoin=`round`,n.lineCap=`round`,n.beginPath();let e=!0;for(let t=T;t<E;t++){let r=m[t];if(r===void 0)continue;let i=f[t-c.start];if(i===void 0)continue;let a=o.height-(r-v)/y*o.height,s=i,l=X(a,d);e?(n.moveTo(s,l),e=!1):n.lineTo(s,l)}n.stroke()}n.restore()},onDataUpdate(){o=null},getConfig(){return{...a}},setConfig(e){`period`in e&&e.period!==a.period&&(o=null),Object.assign(a,e)}}}function pc(e,t,n){return dc(e,n)[t]}function mc(e,t,n=14){if(t<n||t>=e.length)return null;let r=pc(e,t,n);return r===void 0?null:{name:`WMSR`,params:[n],values:[{label:`WMSR`,value:r,color:pa.WMSR}]}}function hc(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 gc(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 _c(e,t,n,r,i,a){let o=Array(e.length),s=hc(e,t),c=hc(e,n),l=hc(e,r),u=hc(e,i),d=gc(s,10),f=gc(c,10),p=gc(l,10),m=gc(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=gc(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 vc(e={}){let{paneId:t=`sub`,config:n={}}=e,r=Es(`kst`,t),i=null,a={roc1:10,roc2:15,roc3:20,roc4:30,signalPeriod:9,showKST:!0,showSignal:!0,...n},o=null,s=``,c=[];function l(e){let t=`${a.roc1}-${a.roc2}-${a.roc3}-${a.roc4}-${a.signalPeriod}`;return(o!==e||s!==t)&&(c=_c(e,a.roc1,a.roc2,a.roc3,a.roc4,a.signalPeriod),o=e,s=t),c}return{name:`kst_${t}`,version:`1.0.0`,description:`KST 确知指标渲染器`,debugName:`KST`,paneId:t,priority:K.MAIN,onInstall(e){i=e},getDeclaredNamespaces(){return[r]},draw(e){let{ctx:n,pane:o,data:s,range:c,scrollLeft:u,dpr:d,kLineCenters:f}=e,p=s;if(p.length<a.roc4+15+a.signalPeriod)return;let m=l(p),h=-1/0,g=1/0;for(let e=c.start;e<c.end&&e<m.length;e++){let t=m[e];t&&(h=Math.max(h,t.kst,t.signal),g=Math.min(g,t.kst,t.signal))}if(!Number.isFinite(h)||!Number.isFinite(g))return;let _=(h-g)*.1||1;h+=_,g-=_,h-g;let v={valueMin:g,valueMax:h,timestamp:Date.now()};i?.setSharedState(r,v,`kst_${t}`);let y=o.yAxis.getDisplayRange({minPrice:g,maxPrice:h}),b=y.minPrice,x=y.maxPrice-b||1,S=o.height-(0-b)/x*o.height;n.save(),n.translate(-u,0);let C=u,w=u+e.paneWidth;n.strokeStyle=`rgba(0, 0, 0, 0.1)`,n.lineWidth=1,n.beginPath(),n.moveTo(C,S),n.lineTo(w,S),n.stroke();let T=Math.max(c.start,a.roc4+15+a.signalPeriod-1),E=Math.min(c.end,p.length);if(a.showKST){n.strokeStyle=ma.KST,n.lineWidth=1,n.lineJoin=`round`,n.lineCap=`round`,n.beginPath();let e=!0;for(let t=T;t<E;t++){let r=m[t];if(!r)continue;let i=f[t-c.start];if(i===void 0)continue;let a=o.height-(r.kst-b)/x*o.height,s=i,l=X(a,d);e?(n.moveTo(s,l),e=!1):n.lineTo(s,l)}n.stroke()}if(a.showSignal){n.strokeStyle=ma.SIGNAL,n.lineWidth=1,n.lineJoin=`round`,n.lineCap=`round`,n.beginPath();let e=!0;for(let t=T;t<E;t++){let r=m[t];if(!r)continue;let i=f[t-c.start];if(i===void 0)continue;let a=o.height-(r.signal-b)/x*o.height,s=i,l=X(a,d);e?(n.moveTo(s,l),e=!1):n.lineTo(s,l)}n.stroke()}n.restore()},onDataUpdate(){o=null},getConfig(){return{...a}},setConfig(e){o=null,Object.assign(a,e)}}}function yc(e,t,n,r,i,a,o){return _c(e,n,r,i,a,o)[t]}function bc(e,t,n=10,r=15,i=20,a=30,o=9){if(t<a+15+o||t>=e.length)return null;let s=yc(e,t,n,r,i,a,o);return s?{name:`KST`,params:[n,r,i,a,o],values:[{label:`KST`,value:s.kst,color:ma.KST},{label:`Signal`,value:s.signal,color:ma.SIGNAL}]}:null}function xc(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 Sc(e={}){let{paneId:t=`sub`,config:n={}}=e,r=Es(`fastk`,t),i=null,a={period:9,showFASTK:!0,...n},o=null,s=0,c=[];function l(e){return(o!==e||s!==a.period)&&(c=xc(e,a.period),o=e,s=a.period),c}return{name:`fastk_${t}`,version:`1.0.0`,description:`FASTK 快速随机指标渲染器`,debugName:`FASTK`,paneId:t,priority:K.MAIN,onInstall(e){i=e},getDeclaredNamespaces(){return[r]},draw(e){let{ctx:n,pane:o,data:s,range:c,scrollLeft:u,dpr:d,kLineCenters:f}=e,p=s;if(p.length<a.period)return;let m=l(p),h={valueMin:0,valueMax:100,timestamp:Date.now()};i?.setSharedState(r,h,`fastk_${t}`);let g=o.yAxis.getDisplayRange({minPrice:0,maxPrice:100}),_=g.minPrice,v=g.maxPrice-_||1;n.save(),n.translate(-u,0);let y=o.height-(80-_)/v*o.height,b=o.height-(20-_)/v*o.height,x=u,S=u+e.paneWidth;n.strokeStyle=`rgba(0, 0, 0, 0.1)`,n.lineWidth=1,n.setLineDash([4,4]),n.beginPath(),n.moveTo(x,y),n.lineTo(S,y),n.moveTo(x,b),n.lineTo(S,b),n.stroke(),n.setLineDash([]);let C=Math.max(c.start,a.period-1),w=Math.min(c.end,p.length);if(a.showFASTK){n.strokeStyle=da.K,n.lineWidth=1,n.lineJoin=`round`,n.lineCap=`round`,n.beginPath();let e=!0;for(let t=C;t<w;t++){let r=m[t];if(r===void 0)continue;let i=f[t-c.start];if(i===void 0)continue;let a=o.height-(r-_)/v*o.height,s=i,l=X(a,d);e?(n.moveTo(s,l),e=!1):n.lineTo(s,l)}n.stroke()}n.restore()},onDataUpdate(){o=null},getConfig(){return{...a}},setConfig(e){`period`in e&&e.period!==a.period&&(o=null),Object.assign(a,e)}}}function Cc(e,t,n){return xc(e,n)[t]}function wc(e,t,n=9){if(t<n||t>=e.length)return null;let r=Cc(e,t,n);return r===void 0?null:{name:`FASTK`,params:[n],values:[{label:`FASTK`,value:r,color:da.K}]}}function Tc(e){let{indicatorId:t,paneId:n}=e;switch(t){case`VOLUME`:return Ds({paneId:n});case`MACD`:return qs({paneId:n});case`RSI`:return Zs({paneId:n});case`CCI`:return ec({paneId:n});case`STOCH`:return ic({paneId:n});case`MOM`:return cc({paneId:n});case`WMSR`:return fc({paneId:n});case`KST`:return vc({paneId:n});case`FASTK`:return Sc({paneId:n});default:throw Error(`Unknown indicator: ${t}`)}}var Ec=8,Dc=6,Oc=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)<=Ec)return{drawing:i,anchorIndex:n}}}for(let i of n){let n=this.getDrawingLineSegments(i,r);for(let r of n)if(kc(e,t,r.a,r.b)<=Dc)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)<=Ec)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=Rc(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}=Z(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 kc(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 Ac=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}},jc=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 Mc(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 Nc(e,t){e.fillStyle=t?.fill??t?.stroke??`#2962ff`,e.globalAlpha=t?.fillOpacity??1}function Pc(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 Fc(e,t){let{a:n,b:r,extend:i=`none`}=e;if(i===`none`)return Pc(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}),Pc(c.x,c.y,l.x,l.y,t)}function Ic(e,t){if(!Number.isFinite(e.index))return-1;let n=Math.round(e.index);return n<0||n>=t.length?-1:n}function Lc(e,t=2){if(!Number.isFinite(e))return`0`;let n=e.toFixed(t);return e>0?`+${n}`:n}function Rc(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 zc(){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=Fc(t,n);if(!i)return;e.save(),Mc(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(),Nc(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 Bc(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 Vc(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 Hc(){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=`${Lc(c)} (${Lc(l)}%) ${s} bars ${Lc(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 Uc(){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 Wc(){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 Gc(){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 Kc(){return{kind:`regression-channel`,minAnchors:2,maxAnchors:2,compute(e,t){let[n,r]=e.anchors;if(!n||!r)return{primitives:[]};let i=Ic(n,t.seriesData),a=Ic(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=Rc(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 qc(e){e.register(Bc(`trend-line`,`none`)),e.register(Bc(`ray`,`right`)),e.register(Bc(`extended-line`,`both`)),e.register(Vc(`horizontal-line`)),e.register(Vc(`horizontal-ray`)),e.register(Vc(`vertical-line`)),e.register(Vc(`cross-line`)),e.register(Hc()),e.register(Uc()),e.register(Kc()),e.register(Wc()),e.register(Gc())}function Jc(e){let t=e.store,n=e.definitions??new jc,r=e.renderers??zc();return qc(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:_}=Z(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=>Yc(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 Yc(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 Xc=class e{dom;opt;data=[];raf=null;viewport=null;paneRenderers=[];markerManager;drawingStore=new Ac;interaction;pluginHost;rendererPluginManager;preciseDpr=0;resizeObserver;observedSize={width:0,height:0};settings={};paneRatios=new Map;onViewportChange;onPaneLayoutChange;onDataChange;currentZoomLevel=1;zoomLevelCount;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 Ss(this),this.markerManager=new co,this.pluginHost=$i(),this.rendererPluginManager=new ta,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.initPanes(),this.useRenderer(Jc({store:this.drawingStore})),this.initResizeObserver()}initResizeObserver(){if(typeof ResizeObserver>`u`)return;let e=this.dom.container;if(e){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()}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};let t=e.logarithmicScale?`log`:`linear`;for(let e of this.paneRenderers)e.getPane().yAxis.setScaleType(t);this.scheduleDraw()}draw(){this.markerManager.clear();let e=this.computeViewport();if(!e||this.data.length===0)return;let{start:t,end:n}=fs(e.scrollLeft,e.plotWidth,this.opt.kWidth,this.opt.kGap,this.data.length,e.dpr),r={start:t,end:n},i=this.calcKLinePositions(r),a=Z(this.opt.kWidth,this.opt.kGap,e.dpr),o=Math.max(1,a.unitPx-1);o%2==0&&--o;let s=Array(i.length),c=Array(i.length);for(let t=0;t<i.length;t++){let n=i[t],r=Math.round(n*e.dpr)+(a.kWidthPx-1)/2;s[t]=r/e.dpr,c[t]={x:(r-(o-1)/2)/e.dpr,width:o/e.dpr}}let{kWidthPx:l}=Z(this.opt.kWidth,this.opt.kGap,e.dpr);this.interaction.setKLinePositions(i,r,l);let u=[],d=[],f=[],p=[];for(let t of this.paneRenderers){let n=t.getPane(),a=t.getDom().plotCanvas.getContext(`2d`),o=t.getDom().yAxisCanvas.getContext(`2d`);if(n.updateRange(this.data,r),a&&(a.setTransform(1,0,0,1,0,0),a.scale(e.dpr,e.dpr),a.clearRect(0,0,e.plotWidth+1,n.height+2/e.dpr)),o){let t=o.canvas.width/e.dpr;o.setTransform(1,0,0,1,0,0),o.scale(e.dpr,e.dpr),o.clearRect(0,0,t,n.height+2/e.dpr)}let l={ctx:a,pane:Ki(n),data:this.data,range:r,scrollLeft:e.scrollLeft,kWidth:this.opt.kWidth,kGap:this.opt.kGap,dpr:e.dpr,paneWidth:e.plotWidth,kLinePositions:i,kLineCenters:s,kBarRects:c,markerManager:this.markerManager,crosshairIndex:this.interaction.getCrosshairIndex(),yAxisCtx:o??void 0,zoomLevel:this.currentZoomLevel,zoomLevelCount:this.zoomLevelCount,viewport:{scrollLeft:e.scrollLeft,plotWidth:e.plotWidth,plotHeight:e.plotHeight},settings:this.settings,yAxisLabels:u,xAxisLabels:d,yAxisRanges:f,xAxisRanges:p};if(a){a.save();let e=this.rendererPluginManager.render(n.id,l);e.length>0&&this.pluginHost.events.emit(`renderer:error`,{paneId:n.id,errors:e}),a.restore()}}let m=this.dom.xAxisCanvas.getContext(`2d`);if(m){let t={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:e.scrollLeft,kWidth:this.opt.kWidth,kGap:this.opt.kGap,dpr:e.dpr,paneWidth:e.plotWidth,kLinePositions:i,kLineCenters:s,kBarRects:c,xAxisCtx:m,viewport:{scrollLeft:e.scrollLeft,plotWidth:e.plotWidth,plotHeight:e.plotHeight},yAxisLabels:[],xAxisLabels:d,xAxisRanges:p},n=this.rendererPluginManager.renderPlugin(`timeAxis`,t);n.length>0&&this.pluginHost.events.emit(`renderer:error`,{paneId:`timeAxis`,errors:n})}}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}=Z(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=Tc({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()}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);t.scrollLeft>n&&(t.scrollLeft=n)}this.interaction.reset(),this.scheduleDraw()}getData(){return this.data}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}=Z(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 ws({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(){this.raf!=null&&cancelAnimationFrame(this.raf),this.raf=requestAnimationFrame(()=>{this.raf=null,this.draw()})}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.viewport=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 xs(e.id,{role:this.resolvePaneRole(e,t),capabilities:e.capabilities}),r=document.createElement(`canvas`),i=document.createElement(`canvas`),a=n.role===`price`;return r.id=`${e.id}-plot`,r.className=a?`plot-canvas main`:`plot-canvas sub`,r.style.position=`absolute`,r.style.left=`0`,r.style.top=`0`,i.id=`${e.id}-yAxis`,i.className=`right-axis`,i.style.position=`absolute`,i.style.left=`0`,new Cs({plotCanvas:r,yAxisCanvas:i},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.plotCanvas),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,Ki(c));let u=s.getDom();u.plotCanvas.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(e.scrollLeft*s)/s;this.dom.canvasLayer.style.width=`${r}px`,this.dom.canvasLayer.style.height=`${i}px`,this.dom.xAxisCanvas.width=Math.round(a*s),this.dom.xAxisCanvas.height=Math.round(this.opt.bottomAxisHeight*s),this.dom.xAxisCanvas.style.width=`${this.dom.xAxisCanvas.width/s}px`,this.dom.xAxisCanvas.style.height=`${this.dom.xAxisCanvas.height/s}px`;let u={viewWidth:r,viewHeight:i,plotWidth:a,plotHeight:o,scrollLeft:l,dpr:s},d=this.viewport,f=!d||d.viewWidth!==u.viewWidth||d.viewHeight!==u.viewHeight||d.plotWidth!==u.plotWidth||d.plotHeight!==u.plotHeight||d.scrollLeft!==u.scrollLeft||d.dpr!==u.dpr;return this.viewport=u,f&&this.onViewportChange?.(u),u}},Zc=3;function Qc(e,t){let n=(e-1)/(t.zoomLevelCount-1);return t.minKWidth+n*(t.maxKWidth-t.minKWidth)}function $c(e){return Zc/e}function el(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=Qc(s,o),l=$c(o.dpr),u=Z(i,a,o.dpr),d=Z(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 tl(e,t,n,r,i,a,o){let s=Math.max(1,Math.min(o.zoomLevelCount,Math.round(e)))-r;return s===0?null:el(s,t,n,r,i,a,o)}function nl(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}({}),rl={volumeAmplifyThreshold:1.5,volumeShrinkThreshold:.8,avgPeriod:20},il=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 al(e,t,n,r=rl){let i=new il;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 ol(){return{name:`candle`,version:`1.0.0`,description:`K线蜡烛图渲染器`,debugName:`K线`,paneId:`main`,priority:K.MAIN,draw(e){let{ctx:t,pane:n,data:r,range:i,scrollLeft:a,kWidth:o,kGap:s,dpr:c,kLinePositions:l,markerManager:u}=e,d=r;if(!d.length)return;let{kWidthPx:f}=Z(o,s,c);t.save(),t.translate(-a,0);let p=l||[],m=al(d,i.start,i.end,rl);for(let r=i.start;r<i.end&&r<d.length;r++){let a=d[r];if(!a)continue;let s=n.yAxis.priceToY(a.open),l=n.yAxis.priceToY(a.close),h=n.yAxis.priceToY(a.high),g=n.yAxis.priceToY(a.low),_=p[r-i.start];if(!_)continue;let v=e=>Math.round(e*c)/c,y=v(s),b=v(l),x=v(h),S=v(g),C=Math.min(y,b),w=Math.max(Math.abs(y-b),1),T=ba(Math.round(_*c),C,f,w,c);t.fillStyle=nl(a)===`up`?q.UP:q.DOWN,t.fillRect(T.bodyRect.x,T.bodyRect.y,T.bodyRect.width,T.bodyRect.height);let E=T.wickRect.width,D=T.wickRect.x,O=T.bodyRect.y,k=T.bodyRect.y+T.bodyRect.height,A=Math.max(a.open,a.close),j=Math.min(a.open,a.close);if(a.high>A){let e=va(D,x,O,c);e&&t.fillRect(e.x,e.y,E,e.height)}if(a.low<j){let e=va(D,k,S,c);e&&t.fillRect(e.x,e.y,E,e.height)}let M=m[r-i.start];if((e.settings?.showVolumePriceMarkers??!0)&&M!==$.OTHERS&&u&&(e.zoomLevel??1)>=2){let n=M===$.RISE_WITH_VOLUME||M===$.RISE_WITHOUT_VOLUME?x-15:S+15,a=r-i.start,s=e.kLineCenters[a];sl(t,s,n,M,r,o,4,u,c)}}t.restore()}}}function sl(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 cl(e,t){return Math.max(3,Math.round(e/60)+1)}function ll(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=cl(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,dl=[1,1.2,1.5,2,2.5,3,4,5,6,7.5,8,10];function fl(e){if(!Number.isFinite(e)||e<=0)return e;let t=10**Math.floor(Math.log10(e)),n=e/t,r=dl[0],i=1/0;for(let e of dl){let t=Math.abs(e-n);t<i&&(i=t,r=e)}return r*t}function pl(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=_s({minPrice:s,maxPrice:c}),p=Q(s,f),m=Q(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=gs(m-t*h,f),i=r,a=t,o=n,s=fl(r);if(Number.isFinite(s)&&s>0){let e=(m-Q(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 ml(e){let{valueMin:t,valueMax:n,scaleType:r=`linear`}=e;if(r===`log`){if(t<=0)return ml({...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=pl({height:a,paddingTop:o,paddingBottom:s,valueMin:r,valueMax:i,targetCount:Math.max(2,cl(a,c))});return l&&u.length>2&&(u=u.slice(1,-1)),u.map((e,t)=>({...e,index:t}))}let i=ll(e),a=cl(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 hl(){return{name:`gridLines`,version:`1.0.0`,description:`网格线渲染器`,debugName:`网格线`,paneId:qi,priority:K.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=aa.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=ml({height:n.height,paddingTop:p,paddingBottom:m,isMain:!0,valueMin:e.minPrice,valueMax:e.maxPrice,scaleType:`log`}).map(e=>e.y)}else g=ll({height:n.height,paddingTop:p,paddingBottom:m,isMain:n.role===`price`}).map(e=>e.y);for(let e of g){let n=ya(d,f,e,s);n&&t.fillRect(n.x,n.y,n.width,n.height)}let _=Na(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=va(c[r]+o/2,0,n.height,s);a&&t.fillRect(a.x,a.y,a.width,a.height)}t.restore()}}}function gl(){return{name:`lastPriceLine`,version:`1.0.0`,description:`最新价虚线渲染器`,debugName:`最新价线`,paneId:`main`,priority:K.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:q.LAST_PRICE,textColor:q.LAST_PRICE}}),t.save(),t.translate(-i,0);let f=o[0]??0,p=s+i;t.strokeStyle=q.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()}}}function _l(){return{name:`extremaMarkers`,version:`1.0.0`,description:`可视区最高/最低价标注渲染器`,debugName:`极值标记`,paneId:qi,priority:K.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:q.LAST_PRICE,textColor:q.LAST_PRICE}}),e.yAxisLabels.push({dataIndex:h,price:p,y:n.yAxis.priceToY(p),style:{bgColor:`rgba(255, 247, 248, 0.98)`,borderColor:q.LAST_PRICE,textColor:q.LAST_PRICE}}),t.save(),t.translate(-a,0),vl(t,g(m),n.yAxis.priceToY(f),f,o,s,a),vl(t,g(h),n.yAxis.priceToY(p),p,o,s,a),t.restore()}}}function vl(e,t,n,r,i,a,o){let s=r.toFixed(2);e.font=`12px ${Hs}`;let c=e.measureText(s).width,l=t-o+30+4+c>a,u=t,d=l?t-30:t+30;u>d&&([u,d]=[d,u]);let f=ya(u,d,n,i);f&&(e.fillStyle=na.WEAK,e.fillRect(f.x,f.y,f.width,f.height));let p=Y(d,i),m=Y(n,i);e.fillStyle=na.WEAK,e.beginPath(),e.arc(p,m,2,0,Math.PI*2),e.fill(),e.font=`12px ${Hs}`,e.textBaseline=`middle`,e.fillStyle=q.NEUTRAL,l?(e.textAlign=`right`,e.fillText(s,Y(t-30-4,i),X(n,i))):(e.textAlign=`left`,e.fillText(s,Y(t+30+4,i),X(n,i)))}function yl(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}function bl(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=Ma(s);e.save(),e.font=`${l}px ${Hs}`,e.textBaseline=`middle`,e.textAlign=`center`;let f=Math.round(e.measureText(d).width),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(Y(_,c),Y(v,c),Y(p,c),Y(m,c)),e.fillStyle=`#ffffff`,e.fillText(d,Y(h,c),X(g,c)),e.restore()}function xl(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??yl(o-r,v,y,a,_,_)+m,x=g?g(b):b.toFixed(2);e.save(),e.font=`${p}px ${Hs}`,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=Y(w,l),D=i,O=Y(S,l);e.fillStyle=u,e.fillRect(T,E,D,O),d&&(e.strokeStyle=d,e.lineWidth=1,e.strokeRect(X(T,l),X(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,Y(k,l),X(C,l)),e.restore()}function Sl(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=ra.TRANSPARENT,textColor:m=na.SECONDARY,lineColor:h=ia.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,X(r,f)),e.lineTo(n+i,X(r,f)),e.stroke()),y&&(e.strokeStyle=h,e.lineWidth=1,e.beginPath(),e.moveTo(n,X(r+a,f)),e.lineTo(n+i,X(r+a,f)),e.stroke()),e.textAlign=`center`,e.textBaseline=`middle`;let O=r+a/2,k=Na(o).filter(e=>e>=u&&e<d);for(let t of k){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}=ka(n.timestamp);e.fillStyle=m,e.font=`${o?`bold `:``}${g}px Arial`,e.fillText(i,Y(t,f),X(O,f))}}}function Cl(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(),e.font=`${f}px ${Hs}`,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=Y(g,c),y=i,b=Y(m,c);e.fillStyle=l,e.fillRect(_,v,y,b),u&&(e.strokeStyle=u,e.lineWidth=1,e.strokeRect(X(_,c),X(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,Y(x,c),X(h,c)),e.restore()}function wl(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=Ma(s);e.save(),e.font=`${l}px ${Hs}`,e.textBaseline=`middle`,e.textAlign=`center`;let f=Math.round(e.measureText(d).width),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(Y(_,c),Y(v,c),Y(p,c),Y(m,c)),e.fillStyle=t.textColor??`#ffffff`,e.fillText(d,Y(h,c),X(g,c)),e.restore()}function Tl(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),t.font=`12px ${Hs}`,t.textBaseline=`middle`,t.textAlign=`center`;let m=r/2,h=ml({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.fillStyle=na.SECONDARY,t.fillText(p?p(r):r.toFixed(u),Y(m,n),X(e,n));t.restore()}function El(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=Es(r,n),f=null;return{name:`${r}Scale_${n}`,version:`1.0.0`,description:`${i} 刻度渲染器`,debugName:`${i}刻度`,paneId:n,priority:K.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});Tl({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);xl(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 Dl(e){return{name:`yAxis`,version:`1.0.0`,description:`Y轴价格刻度渲染器`,debugName:`Y轴`,paneId:qi,priority:K.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&&Tl({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`;Cl(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&&xl(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 Ol(e){return El({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`macd`,label:`MACD`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}var kl=1e8;function Al(e){return El({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`volume`,label:`VOL`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair,formatTickLabel:e=>`${(e/kl).toFixed(2)}B`,formatCrosshairLabel:e=>`${(e/kl).toFixed(2)}B`})}function jl(e){return El({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`rsi`,label:`RSI`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function Ml(e){return El({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`cci`,label:`CCI`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function Nl(e){return El({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`stoch`,label:`STOCH`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function Pl(e){return El({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`mom`,label:`MOM`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function Fl(e){return El({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`wmsr`,label:`WMSR`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function Il(e){return El({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`kst`,label:`KST`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function Ll(e){return El({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`fastk`,label:`FASTK`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}var Rl=Symbol(`time-axis`);function zl(e){return{name:`timeAxis`,version:`1.0.0`,description:`时间轴渲染器`,debugName:`时间轴`,paneId:Rl,priority:K.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),Sl(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&&bl(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&&wl(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 Bl(e){return{name:`crosshair`,version:`1.0.0`,description:`十字线渲染器`,debugName:`十字线`,paneId:qi,priority:K.SYSTEM_CROSSHAIR,draw(t){let{ctx:n,pane:r,dpr:i,paneWidth:a}=t,o=e.getCrosshairState();if(o.isDragging||!o.pos)return;let{x:s}=o.pos,c=r.id===o.activePaneId,l=-1;c&&o.price!==null&&(l=r.yAxis.priceToY(o.price)),n.save(),n.beginPath(),n.rect(0,0,a,r.height),n.clip(),n.fillStyle=_a.LINE;let u=va(s,0,r.height,i);if(u&&n.fillRect(u.x,u.y,u.width,u.height),c&&l>=0){let e=ya(0,a,Math.min(l,r.height-1/i),i);e&&n.fillRect(e.x,e.y,e.width,e.height)}n.restore()}}}function Vl(e){let t={...e};return{name:`paneTitle_${e.paneId}`,version:`1.0.0`,description:`面板标题渲染器`,debugName:`面板标题`,paneId:e.paneId,priority:K.FOREGROUND,draw(e){let{ctx:n,pane:r}=e;if(r.id!==t.paneId)return;let i=t.yOffset??12;n.save(),n.font=`12px Arial`,n.textAlign=`left`,n.textBaseline=`top`;let a=t.getTitleInfo?.();if(a){let e=12;if(n.fillStyle=na.PRIMARY,n.fillText(a.name,e,i),e+=n.measureText(a.name).width,a.params&&a.params.length>0){let t=`(${a.params.join(`,`)})`;n.fillStyle=na.TERTIARY,n.fillText(t,e,i),e+=n.measureText(t).width+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+=n.measureText(r).width+8}}else if(n.fillStyle=na.PRIMARY,n.fillText(t.title,12,i),t.description){let e=n.measureText(t.title).width;n.fillStyle=na.WEAK,n.fillText(` - ${t.description}`,12+e,i)}n.restore()},setConfig(e){t={...t,...e}}}}var Hl={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Ul(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Hl,[...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 Wl=(0,f.markRaw)({name:`tabler-pointer`,render:Ul}),Gl={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Kl(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Gl,[...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 ql=(0,f.markRaw)({name:`tabler-chart-line`,render:Kl}),Jl={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Yl(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Jl,[...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 Xl=(0,f.markRaw)({name:`tabler-arrow-up-right`,render:Yl}),Zl={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Ql(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Zl,[...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 $l=(0,f.markRaw)({name:`tabler-arrow-right`,render:Ql}),eu={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function tu(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,eu,[...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 nu=(0,f.markRaw)({name:`tabler-minus`,render:tu}),ru={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function iu(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,ru,[...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 au=(0,f.markRaw)({name:`tabler-separator`,render:iu}),ou={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function su(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,ou,[...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 cu=(0,f.markRaw)({name:`tabler-crosshair`,render:su}),lu={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function uu(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,lu,[...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 du=(0,f.markRaw)({name:`tabler-info-circle`,render:uu}),fu={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function pu(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,fu,[...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 mu=(0,f.markRaw)({name:`tabler-maximize`,render:pu}),hu={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function gu(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:`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 _u=(0,f.markRaw)({name:`tabler-minimize`,render:gu}),vu={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function yu(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,vu,[...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 bu=(0,f.markRaw)({name:`tabler-zoom-in`,render:yu}),xu={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Su(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,xu,[...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 Cu=(0,f.markRaw)({name:`tabler-zoom-out`,render:Su}),wu={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Tu(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,wu,[...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 Eu=(0,f.markRaw)({name:`tabler-shape`,render:Tu}),Du={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Ou(e,t){return(0,f.openBlock)(),(0,f.createElementBlock)(`svg`,Du,[...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 ku=(0,f.markRaw)({name:`tabler-chart-dots-3`,render:Ou}),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:`m18 10l-6-6l-6 6zm0 4l-6 6l-6-6z`},null,-1)]])}var Mu=(0,f.markRaw)({name:`tabler-caret-up-down`,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:`M8 4H5v16h3m8-16h3v16h-3`},null,-1)]])}var Fu=(0,f.markRaw)({name:`tabler-brackets`,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)(`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 Ru=(0,f.markRaw)({name:`tabler-settings`,render:Lu}),zu=[{key:`showVolumePriceMarkers`,label:`显示量价关系标记`,type:`boolean`,default:!0},{key:`logarithmicScale`,label:`对数价格轴`,type:`boolean`,default:!1}],Bu=`kline-chart-settings`,Vu={class:`left-toolbar`,"aria-label":`图表工具栏`},Hu={class:`left-toolbar__group`},Uu=[`title`,`aria-label`,`onClick`],Wu=[`onClick`],Gu=[`title`,`aria-label`,`onClick`],Ku={class:`left-toolbar__group`},qu={class:`left-toolbar__group`},Ju=[`title`,`aria-label`],Yu={class:`left-toolbar__group`},Xu={class:`settings-body`},Zu={class:`settings-item`},Qu={class:`settings-label`},$u={class:`settings-item`},ed={class:`settings-label`},td=ao((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:Wl},{id:`lines`,title:`线条`,icon:ql,children:[{id:`trend-line`,title:`线段`,icon:ql},{id:`ray`,title:`射线`,icon:Xl},{id:`h-line`,title:`水平线`,icon:nu},{id:`h-ray`,title:`水平射线`,icon:$l},{id:`v-line`,title:`垂直线`,icon:au},{id:`crosshair-line`,title:`十字线`,icon:cu},{id:`info-line`,title:`信息线`,icon:du}]},{id:`channels`,title:`通道`,icon:Eu,children:[{id:`parallel-channel`,title:`平行通道`,icon:Eu},{id:`regression-channel`,title:`回归趋势`,icon:ku},{id:`flat-line`,title:`平滑顶底`,icon:Mu},{id:`disjoint-channel`,title:`不相交通道`,icon:Fu}]}],a=(0,f.ref)(`cursor`),o=(0,f.ref)(null),s=(0,f.ref)(!1),c=mo();function l(){try{let e=localStorage.getItem(Bu);if(e){let t=JSON.parse(e),n={};return zu.forEach(e=>{n[e.key]=t[e.key]??e.default}),n}}catch{}let e={};return zu.forEach(t=>{e[t.key]=t.default}),e}function u(e){try{localStorage.setItem(Bu,JSON.stringify(e))}catch{}}let d=(0,f.ref)(l()),p=(0,f.ref)({...d.value});function m(e){return a.value===e.id?!0:e.children?e.children.some(e=>e.id===a.value):!1}function h(e){if(e.children?.length){if(!e.children.some(e=>e.id===a.value)){let t=e.children[0];a.value=t.id,r(`selectTool`,t.id)}_(e.id);return}a.value=e.id,r(`selectTool`,e.id),o.value=null}function g(e){a.value=e.id,r(`selectTool`,e.id),o.value=null}function _(e){o.value=o.value===e?null:e}function v(){p.value={...d.value},s.value=!0}function y(){s.value=!1}function b(){let e={};zu.forEach(t=>{e[t.key]=t.default}),p.value=e}function x(){d.value={...p.value},u(d.value),r(`settingsChange`,{...d.value}),y()}function S(){return{...d.value}}t({getSettings:S});function C(e){e.target.closest(`.tool-item`)||(o.value=null)}return(0,f.onMounted)(()=>{document.addEventListener(`click`,C,!0)}),(0,f.onUnmounted)(()=>{document.removeEventListener(`click`,C,!0)}),(t,n)=>((0,f.openBlock)(),(0,f.createElementBlock)(f.Fragment,null,[(0,f.createElementVNode)(`nav`,Vu,[(0,f.createElementVNode)(`div`,Hu,[((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:m(e)}]),title:e.title,"aria-label":e.title,onClick:t=>h(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:o.value===e.id}]),onClick:(0,f.withModifiers)(t=>_(e.id),[`stop`]),"aria-label":`展开子菜单`},null,10,Wu)):(0,f.createCommentVNode)(``,!0)],42,Uu),(0,f.createVNode)(f.Transition,{name:`dropdown`},{default:(0,f.withCtx)(()=>[o.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:a.value===e.id}]),title:e.title,"aria-label":e.title,onClick:t=>g(e)},[((0,f.openBlock)(),(0,f.createBlock)((0,f.resolveDynamicComponent)(e.icon),{class:`tool-icon`,"aria-hidden":`true`}))],10,Gu))),128))],32)):(0,f.createCommentVNode)(``,!0)]),_:2},1024)])),64))]),n[24]||=(0,f.createElementVNode)(`span`,{class:`left-toolbar__divider`},null,-1),(0,f.createElementVNode)(`div`,Ku,[(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)(bu),{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)(Cu),{class:`tool-icon`,"aria-hidden":`true`})],32)]),n[25]||=(0,f.createElementVNode)(`span`,{class:`left-toolbar__divider`},null,-1),(0,f.createElementVNode)(`div`,qu,[(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)(_u),{key:0,class:`tool-icon`,"aria-hidden":`true`})):((0,f.openBlock)(),(0,f.createBlock)((0,f.unref)(mu),{key:1,class:`tool-icon`,"aria-hidden":`true`}))],40,Ju)]),n[26]||=(0,f.createElementVNode)(`span`,{class:`left-toolbar__divider`},null,-1),(0,f.createElementVNode)(`div`,Yu,[(0,f.createElementVNode)(`button`,{type:`button`,class:`left-toolbar__button`,title:`设置`,"aria-label":`设置`,onClick:v,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)(Ru),{class:`tool-icon`,"aria-hidden":`true`})],32)])]),((0,f.openBlock)(),(0,f.createBlock)(f.Teleport,{to:(0,f.unref)(c)},[(0,f.createVNode)(f.Transition,{name:`overlay`},{default:(0,f.withCtx)(()=>[s.value?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:0,class:`settings-overlay`,onClick:y},[(0,f.createVNode)(f.Transition,{name:`modal`},{default:(0,f.withCtx)(()=>[(0,f.createElementVNode)(`div`,{class:`settings-modal`,onClick:n[23]||=(0,f.withModifiers)(()=>{},[`stop`])},[(0,f.createElementVNode)(`div`,{class:`settings-header`},[n[28]||=(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:y},[...n[27]||=[(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`,Xu,[(0,f.createElementVNode)(`div`,Zu,[(0,f.createElementVNode)(`label`,Qu,[n[29]||=(0,f.createElementVNode)(`span`,null,`显示量价关系标记`,-1),(0,f.withDirectives)((0,f.createElementVNode)(`input`,{type:`checkbox`,class:`settings-checkbox`,"onUpdate:modelValue":n[21]||=e=>p.value.showVolumePriceMarkers=e},null,512),[[f.vModelCheckbox,p.value.showVolumePriceMarkers]])])]),(0,f.createElementVNode)(`div`,$u,[(0,f.createElementVNode)(`label`,ed,[n[30]||=(0,f.createElementVNode)(`span`,null,`对数价格轴`,-1),(0,f.withDirectives)((0,f.createElementVNode)(`input`,{type:`checkbox`,class:`settings-checkbox`,"onUpdate:modelValue":n[22]||=e=>p.value.logarithmicScale=e},null,512),[[f.vModelCheckbox,p.value.logarithmicScale]])])])]),(0,f.createElementVNode)(`div`,{class:`settings-footer`},[(0,f.createElementVNode)(`button`,{class:`settings-btn reset`,onClick:b},[...n[31]||=[(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:y},`取消`),(0,f.createElementVNode)(`button`,{class:`settings-btn confirm`,onClick:x},[...n[32]||=[(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-1f5465f7`]]),nd={class:`chart-wrapper`},rd={class:`pane-separator-layer`,"aria-hidden":`true`},id=4,ad=ao((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=Ts({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,Qc(h.state.zoomLevel,{minKWidth:r.minKWidth,maxKWidth:r.maxKWidth,zoomLevelCount:r.zoomLevels,dpr:h.state.viewportDpr}),$c(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){p.value?.updateSettings(e)}function w(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 T(e){if(!e)return;let t=w(e,180,80);p.value?.interaction.setTooltipSize(t)}function E(e){e&&(N.value=w(e,120,60))}let D=(0,f.ref)({x:0,y:0}),O=(0,f.ref)(!1),k=(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}),A=(0,f.shallowRef)(null),j=(0,f.computed)(()=>{let e=b.value;return e?h.state.drawings.find(t=>t.id===e)??null:null}),M=(0,f.ref)([]),N=(0,f.ref)({width:220,height:120}),ee=(0,f.computed)(()=>{let e=c.value,t=l.value;return!e||!t?{x:0,y:0}:{x:e.offsetLeft,y:e.offsetTop}}),te=(0,f.computed)(()=>k.value.hoveredMarkerData),P=(0,f.computed)(()=>k.value.hoveredCustomMarker),ne=(0,f.computed)(()=>k.value.isDragging),re=(0,f.computed)(()=>k.value.isResizingPaneBoundary),ie=(0,f.computed)(()=>k.value.isHoveringPaneBoundary),ae=(0,f.computed)(()=>k.value.hoveredPaneBoundaryId),oe=(0,f.computed)(()=>k.value.isHoveringRightAxis),se=(0,f.computed)(()=>k.value.hoveredIndex),ce=(0,f.computed)(()=>k.value.crosshairIndex),le=(0,f.computed)(()=>{let e=k.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)(()=>k.value.hoveredIndex),de=(0,f.computed)(()=>k.value.tooltipPos),fe=(0,f.computed)(()=>({x:de.value.x+ee.value.x,y:de.value.y+ee.value.y})),pe=(0,f.computed)(()=>({left:`${fe.value.x}px`,top:`${fe.value.y}px`})),me=(0,f.computed)(()=>({x:D.value.x+ee.value.x,y:D.value.y+ee.value.y})),he=(0,f.computed)(()=>({left:`${me.value.x}px`,top:`${me.value.y}px`})),ge=(0,f.computed)(()=>k.value.tooltipAnchorPlacement),_e=(0,f.computed)(()=>{let e=p.value?.getViewport(),t=c.value,n=e?.plotWidth??(t?t.clientWidth:0);return D.value.x+12+N.value.width+12>n?`left-bottom`:`right-bottom`}),ve=(0,f.computed)(()=>(x.value,p.value?.getData()??[]));function ye(e){A.value?.setTool(e)}function be(e){let t=j.value;!t||!A.value||(A.value.updateDrawingStyle(t.id,e),h.actions.bumpDrawingVersion())}function xe(){let e=j.value;!e||!A.value||(A.value.removeDrawing(e.id),h.actions.setSelectedDrawingId(null),h.actions.bumpDrawingVersion(),h.actions.setDrawings(A.value.getDrawings()))}function Se(e){let t=c.value;if(t){if(A.value?.onPointerDown(e,t)){h.actions.setDrawings(A.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(D.value={x:e.clientX-n.left,y:e.clientY-n.top},A.value?.onPointerMove(e,t)){h.actions.setDrawings(A.value.getDrawings());return}}p.value?.interaction.onPointerMove(e)}function we(e){let t=c.value;if(t&&A.value?.onPointerUp(e,t)){h.actions.setDrawings(A.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 F=(0,f.ref)([]),I=(0,f.ref)({}),L=(0,f.ref)([]),je={VOLUME:{defaultParams:{},getTitleInfo:()=>({name:`VOL`,params:[],values:[]})},MACD:{defaultParams:{fastPeriod:12,slowPeriod:26,signalPeriod:9},getTitleInfo:(e,t,n)=>t===null?null:Ys(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:Qs(e,t,n.period1??6,n.period2??12,n.period3??24)},CCI:{defaultParams:{period:14},getTitleInfo:(e,t,n)=>t===null?null:nc(e,t,n.period??14)},STOCH:{defaultParams:{n:9,m:3},getTitleInfo:(e,t,n)=>t===null?null:oc(e,t,n.n??9,n.m??3)},MOM:{defaultParams:{period:10},getTitleInfo:(e,t,n)=>t===null?null:uc(e,t,n.period??10)},WMSR:{defaultParams:{period:14},getTitleInfo:(e,t,n)=>t===null?null:mc(e,t,n.period??14)},KST:{defaultParams:{roc1:10,roc2:15,roc3:20,roc4:30,signalPeriod:9},getTitleInfo:(e,t,n)=>t===null?null:bc(e,t,n.roc1??10,n.roc2??15,n.roc3??20,n.roc4??30,n.signalPeriod??9)},FASTK:{defaultParams:{period:9},getTitleInfo:(e,t,n)=>t===null?null:wc(e,t,n.period??9)}},Me=Object.keys(je);function Ne(){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 Pe(e){return{...je[e].defaultParams}}function Fe(e=`VOLUME`,t){if(L.value.length>=id)return!1;let n=`sub_${e}`;if(L.value.some(e=>e.id===n))return!0;if(!p.value?.createSubPane(e,t??Pe(e)))return!1;let r=Vl({paneId:n,title:e,getTitleInfo:()=>R(n)});return p.value?.useRenderer(r),L.value.push({id:n,indicatorId:e,rendererName:`${e.toLowerCase()}_${n}`,paneTitleRendererName:r.name,params:t??Pe(e)}),F.value.includes(e)||F.value.push(e),S(),!0}function Ie(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)||(F.value=F.value.filter(e=>e!==n.indicatorId)))}function Le(){for(let e of L.value)p.value?.removeRenderer(e.paneTitleRendererName);p.value?.clearSubPanes(),L.value=[],F.value=F.value.filter(e=>!Me.includes(e))}function Re(){let e=r.semanticConfig.indicators?.main;if(e)for(let t of e)t.enabled&&(F.value.includes(t.type)||F.value.push(t.type),t.params&&(I.value[t.type]=t.params))}(0,f.watch)([F,I],([e])=>{let t=p.value;t&&(t.updateRendererConfig(`mainIndicatorLegend`,{indicators:{MA:{enabled:e.includes(`MA`),params:I.value.MA||{}},BOLL:{enabled:e.includes(`BOLL`),params:I.value.BOLL||{}},EXPMA:{enabled:e.includes(`EXPMA`),params:I.value.EXPMA||{}},ENE:{enabled:e.includes(`ENE`),params:I.value.ENE||{}}}}),t.setRendererEnabled(`ma`,e.includes(`MA`)),t.setRendererEnabled(`boll`,e.includes(`BOLL`)),t.setRendererEnabled(`expma`,e.includes(`EXPMA`)),t.setRendererEnabled(`ene`,e.includes(`ENE`)),S())},{deep:!0});function ze(){let e=p.value?.getSubPaneIndicators()??[];L.value=[];for(let t of e){let e=`sub_${t}`,n=Vl({paneId:e,title:t,getTitleInfo:()=>R(e)});p.value?.useRenderer(n),L.value.push({id:e,indicatorId:t,rendererName:`${t.toLowerCase()}_${e}`,paneTitleRendererName:n.name,params:Pe(t)}),F.value.includes(t)||F.value.push(t)}S()}function Be(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,Pe(t));let i=`sub_${t}`,a=Vl({paneId:i,title:t,getTitleInfo:()=>R(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:Pe(t)}),F.value=F.value.filter(e=>e!==r),F.value.includes(t)||F.value.push(t)}function R(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=je[t.indicatorId],i=t.params;return r.getTitleInfo(n,ce.value,i)}function Ve(e,t){if(e===`MA`||e===`BOLL`||e===`EXPMA`||e===`ENE`){t?F.value.includes(e)||F.value.push(e):F.value=F.value.filter(t=>t!==e);return}if(Me.includes(e)){if(t){if(F.value.includes(e)||F.value.push(e),L.value.find(t=>t.indicatorId===e))return;if(!Fe(e)){let t=L.value[L.value.length-1];t&&Be(t.id,e)}}else F.value=F.value.filter(t=>t!==e),L.value.filter(t=>t.indicatorId===e).forEach(e=>Ie(e.id));S()}}function He(){p.value?.updateRendererConfig(`mainIndicatorLegend`,{indicators:{MA:{enabled:F.value.includes(`MA`),params:I.value.MA||{}},BOLL:{enabled:F.value.includes(`BOLL`),params:I.value.BOLL||{}},EXPMA:{enabled:F.value.includes(`EXPMA`),params:I.value.EXPMA||{}},ENE:{enabled:F.value.includes(`ENE`),params:I.value.ENE||{}}}})}function Ue(e,t){if(I.value[e]=t,e===`MA`||e===`BOLL`||e===`EXPMA`||e===`ENE`){e===`BOLL`&&p.value?.updateRendererConfig(`boll`,t),e===`EXPMA`&&p.value?.updateRendererConfig(`expma`,t),e===`ENE`&&p.value?.updateRendererConfig(`ene`,t),He(),S();return}Me.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=>Me.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=F.value.filter(e=>!Me.includes(e)),s=L.value.map(e=>e.indicatorId);F.value=[...o,...s];let c=p.value;c&&c.updatePaneLayout(Ne())}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}=Z(_.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=tl(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:Fe,removeSubPane:Ie,switchSubIndicator:Be,clearAllSubPanes:Le,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)(()=>{O.value=typeof CSS<`u`&&CSS.supports(`anchor-name: --kmap-anchor`)&&CSS.supports(`position-anchor: --kmap-anchor`);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=el(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 Xc({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(hl()),y.useRenderer(_l()),y.useRenderer(js({ma5:!0,ma10:!0,ma20:!0,ma30:!0,ma60:!0})),y.useRenderer(Ns()),y.setRendererEnabled(`boll`,!1),y.useRenderer(Ls()),y.setRendererEnabled(`expma`,!1),y.useRenderer(Bs()),y.setRendererEnabled(`ene`,!1),y.useRenderer(ol()),y.useRenderer(gl()),y.useRenderer(Ta());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(Dl({axisWidth:b,yPaddingPx:r.yPaddingPx,getCrosshair:x})),y.useRenderer(Us({yPaddingPx:r.yPaddingPx}));let S=[{create:Al,paneId:`sub_VOLUME`},{create:Ol,paneId:`sub_MACD`},{create:jl,paneId:`sub_RSI`},{create:Ml,paneId:`sub_CCI`},{create:Nl,paneId:`sub_STOCH`},{create:Pl,paneId:`sub_MOM`},{create:Fl,paneId:`sub_WMSR`},{create:Il,paneId:`sub_KST`},{create:Ll,paneId:`sub_FASTK`}];for(let e of S)y.useRenderer(e.create({axisWidth:b,paneId:e.paneId,yPaddingPx:r.yPaddingPx,getCrosshair:x}));y.useRenderer(Bl({getCrosshairState:()=>({pos:y.interaction.crosshairPos,activePaneId:y.interaction.activePaneId,isDragging:y.interaction.isDraggingState(),price:y.interaction.crosshairPrice})})),y.useRenderer(zl({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=$c(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;M.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),A.value=new Oc(y),A.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(O.value),y.interaction.setOnInteractionChange(e=>{k.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=el(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)}))}),k.value=y.interaction.getInteractionSnapshot(),h.actions.setViewportDpr(y.getCurrentDpr()),y.resize(),m.value=new Ai(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(),Re(),ze(),(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,A.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`,nd,[(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)(td,{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`,rd,[((0,f.openBlock)(!0),(0,f.createElementBlock)(f.Fragment,null,(0,f.renderList)(M.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),j.value?((0,f.openBlock)(),(0,f.createBlock)(us,{key:0,drawing:j.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":O.value}]),style:(0,f.normalizeStyle)(pe.value)},null,6)):(0,f.createCommentVNode)(``,!0),te.value||P.value?((0,f.openBlock)(),(0,f.createElementBlock)(`div`,{key:1,class:(0,f.normalizeClass)([`tooltip-anchor marker-tooltip-anchor`,{"use-anchor":O.value}]),style:(0,f.normalizeStyle)(he.value)},null,6)):(0,f.createCommentVNode)(``,!0),le.value?((0,f.openBlock)(),(0,f.createBlock)(oo,{key:2,k:le.value,index:ue.value,data:ve.value,pos:fe.value,"set-el":T,"use-anchor":O.value,"anchor-placement":ge.value},null,8,[`k`,`index`,`data`,`pos`,`use-anchor`,`anchor-placement`])):(0,f.createCommentVNode)(``,!0),te.value||P.value?((0,f.openBlock)(),(0,f.createBlock)(fo,{key:3,marker:te.value||P.value,pos:me.value,"use-anchor":O.value,"anchor-placement":_e.value,"set-el":E},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)(ns,{"active-indicators":F.value,"indicator-params":I.value,onToggle:Ve,onUpdateParams:Ue,onReorderSubIndicators:We},null,8,[`active-indicators`,`indicator-params`])]))}}),[[`__scopeId`,`data-v-fff9d345`]]),od={install(e){e.component(`KLineChart`,ad)}};exports.ConfigManager=Xi,exports.EventBus=p,exports.GLOBAL_PANE_ID=qi,exports.HookSystem=Yi,exports.KLineChart=ad,exports.KMapPlugin=od,exports.PluginHostImpl=Qi,exports.PluginRegistry=Ji,exports.PluginState=Gi,exports.RENDERER_PRIORITY=K,exports.RendererPluginManager=ta,exports.createPluginHost=$i,exports.wrapPaneInfo=Ki;