@onerjs/code-input 0.1.6 → 0.1.7

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.
@@ -1,28 +1,28 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),je=[{label:"Math",kind:"class",detail:"Math",type:`interface Math {
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),Xe=[{label:"Math",kind:"class",detail:"Math",type:`interface Math {
2
2
  readonly PI: number
3
3
  readonly E: number
4
4
  abs(x: number): number
5
5
  round(x: number): number
6
6
  max(...values: number[]): number
7
7
  random(): number
8
- }`,documentation:"内置数学对象",members:[{label:"PI",kind:"property",detail:"number"},{label:"E",kind:"property",detail:"number"},{label:"abs",kind:"function",detail:"(x: number) => number"},{label:"ceil",kind:"function",detail:"(x: number) => number"},{label:"floor",kind:"function",detail:"(x: number) => number"},{label:"round",kind:"function",detail:"(x: number) => number"},{label:"max",kind:"function",detail:"(...values: number[]) => number"},{label:"min",kind:"function",detail:"(...values: number[]) => number"},{label:"pow",kind:"function",detail:"(base: number, exp: number) => number"},{label:"random",kind:"function",detail:"() => number"},{label:"sqrt",kind:"function",detail:"(x: number) => number"},{label:"trunc",kind:"function",detail:"(x: number) => number"}]},{label:"JSON",kind:"class",detail:"JSON",members:[{label:"parse",kind:"function",detail:"(text: string) => any"},{label:"stringify",kind:"function",detail:"(value: any, space?: number) => string"}]},{label:"console",kind:"variable",detail:"Console",members:[{label:"log",kind:"function",detail:"(...data: any[]) => void"},{label:"info",kind:"function",detail:"(...data: any[]) => void"},{label:"warn",kind:"function",detail:"(...data: any[]) => void"},{label:"error",kind:"function",detail:"(...data: any[]) => void"},{label:"debug",kind:"function",detail:"(...data: any[]) => void"},{label:"table",kind:"function",detail:"(data: any) => void"},{label:"time",kind:"function",detail:"(label: string) => void"},{label:"timeEnd",kind:"function",detail:"(label: string) => void"}]},{label:"Object",kind:"class",detail:"Object",members:[{label:"keys",kind:"function",detail:"(o: object) => string[]"},{label:"values",kind:"function",detail:"(o: object) => any[]"},{label:"entries",kind:"function",detail:"(o: object) => [string, any][]"},{label:"assign",kind:"function",detail:"(target: object, ...sources: object[]) => object"},{label:"freeze",kind:"function",detail:"(o: object) => object"}]},{label:"Array",kind:"class",detail:"Array",members:[{label:"isArray",kind:"function",detail:"(value: any) => boolean"},{label:"from",kind:"function",detail:"(iterable: any) => any[]"},{label:"of",kind:"function",detail:"(...items: any[]) => any[]"}]},{label:"Promise",kind:"class",detail:"Promise",members:[{label:"resolve",kind:"function",detail:"(value?: any) => Promise<any>"},{label:"reject",kind:"function",detail:"(reason?: any) => Promise<never>"},{label:"all",kind:"function",detail:"(values: any[]) => Promise<any[]>"},{label:"race",kind:"function",detail:"(values: any[]) => Promise<any>"}]},{label:"Date",kind:"class",detail:"Date",members:[{label:"now",kind:"function",detail:"() => number"},{label:"parse",kind:"function",detail:"(dateString: string) => number"}]},{label:"String",kind:"class",detail:"String",members:[{label:"fromCharCode",kind:"function",detail:"(...codes: number[]) => string"},{label:"from",kind:"function",detail:"(value: any) => string"}]},{label:"Number",kind:"class",detail:"Number",members:[{label:"isNaN",kind:"function",detail:"(value: any) => boolean"},{label:"isInteger",kind:"function",detail:"(value: any) => boolean"},{label:"parseFloat",kind:"function",detail:"(value: string) => number"},{label:"parseInt",kind:"function",detail:"(value: string, radix?: number) => number"}]},{label:"setTimeout",kind:"function",detail:"(callback: Function, ms?: number) => number"},{label:"clearTimeout",kind:"function",detail:"(id: number) => void"},{label:"setInterval",kind:"function",detail:"(callback: Function, ms?: number) => number"},{label:"clearInterval",kind:"function",detail:"(id: number) => void"}],Mt=/[\w$]/;function Fe(n,s){const a=[];let e=null;for(let $=0;$<s;$++){const v=n[$];if(e){v===e&&n[$-1]!=="\\"&&(e=null);continue}if(v==="'"||v==='"'||v==="`"){e=v;continue}if(v==="("){a.push({index:$,commas:0});continue}if(v===")"){a.pop();continue}v===","&&a.length&&a[a.length-1].commas++}const i=a[a.length-1];if(!i)return null;let c=i.index-1;for(;c>=0&&/\s/.test(n[c]);)c--;const p=c;for(;c>=0&&Mt.test(n[c]);)c--;const d=n.slice(c+1,p+1);if(!d)return null;let r=s;for(;r>0&&/[\w$'"]/.test(n[r-1]);)r--;const f=n.slice(r,s);let C=f,A=null;return f&&(f[0]==="'"||f[0]==='"')&&(A=f[0],C=f.slice(1)),{functionName:d,paramIndex:i.commas,prefix:C,replaceStart:r,quote:A}}const _e=["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","from","function","if","import","in","instanceof","let","new","of","return","super","switch","this","throw","try","typeof","var","void","while","with","yield","async","await","true","false","null","undefined","NaN","Infinity"],It=["abstract","any","as","asserts","bigint","boolean","declare","enum","implements","infer","interface","is","keyof","namespace","never","number","object","override","private","protected","public","readonly","satisfies","static","string","symbol","type","unknown"];function he(n){return n==="typescript"?[..._e,...It]:_e}function pe(n){return new Set(he(n))}const Ht=/((?:[A-Za-z_$][\w$]*\??\.)*)([A-Za-z_$][\w$]*)?$/,Le=/\b(?:const|let|var|function|class)\s+([A-Za-z_$][\w$]*)/g,_t=/^[A-Za-z_$]/;function Pe(n,s){const a=n.slice(0,s),e=Ht.exec(a);if(!e)return{prefix:"",chain:[]};const i=e[1]??"",c=e[2]??"",p=i.split(".").filter(Boolean).map(d=>d.replace(/\?$/,""));return{prefix:c,chain:p}}function me(n,s){const a=[],e=new Set;let i;for(Le.lastIndex=0;(i=Le.exec(n))&&!(i.index>=s);){const c=i[1];if(e.has(c))continue;e.add(c);const p=i[0].slice(0,i[0].indexOf(c)).trim();a.push({label:c,kind:p==="function"?"function":p==="class"?"class":"variable",detail:"当前文件"})}return a}function qe(n,s){let a=s;for(const e of n){if(!a)return null;const i=a.find(c=>c.label===e);if(!i)return null;a=i.members??[]}return a}function Lt(n,s){const a=n.toLowerCase(),e=s.toLowerCase(),i=a.indexOf(e);if(i===0)return 1e3-a.length;if(i>0)return 800-i;let c=0,p=0,d=-1;for(let r=0;r<a.length&&c<e.length;r++)a[r]===e[c]&&(d>=0&&(p+=r-d-1),d=r,c++);return c!==e.length?null:400-p-a.length}function Ke(n,s){if(!s)return n;const a=[];for(const e of n){const i=Lt(e.label,s);i!==null&&a.push({item:e,score:i})}return a.sort((e,i)=>i.score-e.score||e.item.label.localeCompare(i.item.label)),a.map(e=>e.item)}function Nt(n){const s=new Set,a=[];for(const e of n)s.has(e.label)||(s.add(e.label),a.push(e));return a}function Ze(n,s,a){const{prefix:e,chain:i}=Pe(n,s);if(a.auto&&(!e&&i.length===0||e&&!_t.test(e)))return null;const c=a.declared??[],p=[...c,...a.completions];let d;if(i.length>0){const f=qe(i,p);if(!f||f.length===0)return null;d=f}else d=[...a.completions,...c,...he(a.language).map(f=>({label:f,kind:"keyword"}))];const r=Ke(Nt(d),e);return r.length===0?null:{items:r,start:s-e.length,end:s}}const At=/([A-Za-z_$][\w$]*(?:\??\.[A-Za-z_$][\w$]*)*)\??\.\s*$/;function Ue(n,s,a,e){const i=n.slice(s,a);if(!i)return null;const c=[...e.declared??[],...e.completions],p=At.exec(n.slice(0,s));if(p){const d=p[1].split(".").filter(Boolean).map(C=>C.replace(/\?$/,"")),r=qe(d,c),f=r==null?void 0:r.find(C=>C.label===i);if(f)return f}return c.find(d=>d.label===i)??null}const W="[A-Za-z_$][\\w$]*",Ne="(?:readonly\\s+|public\\s+|private\\s+|protected\\s+|static\\s+|abstract\\s+)*";function Ae(n,s){let a=0,e=!1,i=s;for(let c=s;c<n.length;c++){const p=n[c];for(let d=0;d<p.length;d++){const r=p[d];r==="{"?(a++,e=!0):r==="}"&&a--}if(e&&a<=0){i=c;break}}return{end:i,body:n.slice(s+1,i)}}function Ve(n){return n.trim().replace(/[,;]$/,"").trim()}function Vt(n){return/^(?:export\s+)?(?:declare\s+)?(?:abstract\s+)?(?:interface|class|type|function|const|let|var|namespace|enum)\b/.test(n)}function X(n,s){const a=n[s];let e=a.lastIndexOf("}");const i=a.lastIndexOf(";");if(i>e&&(e=i),e===-1)return;const c=a.slice(e+1).replace(/^[\s;]+/,"").trim();!c||!Vt(c)||(n[s]=a.slice(0,e+1),n.splice(s+1,0,c))}function q(n){return n.length?n.join(`
8
+ }`,documentation:"内置数学对象",members:[{label:"PI",kind:"property",detail:"number"},{label:"E",kind:"property",detail:"number"},{label:"abs",kind:"function",detail:"(x: number) => number"},{label:"ceil",kind:"function",detail:"(x: number) => number"},{label:"floor",kind:"function",detail:"(x: number) => number"},{label:"round",kind:"function",detail:"(x: number) => number"},{label:"max",kind:"function",detail:"(...values: number[]) => number"},{label:"min",kind:"function",detail:"(...values: number[]) => number"},{label:"pow",kind:"function",detail:"(base: number, exp: number) => number"},{label:"random",kind:"function",detail:"() => number"},{label:"sqrt",kind:"function",detail:"(x: number) => number"},{label:"trunc",kind:"function",detail:"(x: number) => number"}]},{label:"JSON",kind:"class",detail:"JSON",members:[{label:"parse",kind:"function",detail:"(text: string) => any"},{label:"stringify",kind:"function",detail:"(value: any, space?: number) => string"}]},{label:"console",kind:"variable",detail:"Console",members:[{label:"log",kind:"function",detail:"(...data: any[]) => void"},{label:"info",kind:"function",detail:"(...data: any[]) => void"},{label:"warn",kind:"function",detail:"(...data: any[]) => void"},{label:"error",kind:"function",detail:"(...data: any[]) => void"},{label:"debug",kind:"function",detail:"(...data: any[]) => void"},{label:"table",kind:"function",detail:"(data: any) => void"},{label:"time",kind:"function",detail:"(label: string) => void"},{label:"timeEnd",kind:"function",detail:"(label: string) => void"}]},{label:"Object",kind:"class",detail:"Object",members:[{label:"keys",kind:"function",detail:"(o: object) => string[]"},{label:"values",kind:"function",detail:"(o: object) => any[]"},{label:"entries",kind:"function",detail:"(o: object) => [string, any][]"},{label:"assign",kind:"function",detail:"(target: object, ...sources: object[]) => object"},{label:"freeze",kind:"function",detail:"(o: object) => object"}]},{label:"Array",kind:"class",detail:"Array",members:[{label:"isArray",kind:"function",detail:"(value: any) => boolean"},{label:"from",kind:"function",detail:"(iterable: any) => any[]"},{label:"of",kind:"function",detail:"(...items: any[]) => any[]"}]},{label:"Promise",kind:"class",detail:"Promise",members:[{label:"resolve",kind:"function",detail:"(value?: any) => Promise<any>"},{label:"reject",kind:"function",detail:"(reason?: any) => Promise<never>"},{label:"all",kind:"function",detail:"(values: any[]) => Promise<any[]>"},{label:"race",kind:"function",detail:"(values: any[]) => Promise<any>"}]},{label:"Date",kind:"class",detail:"Date",members:[{label:"now",kind:"function",detail:"() => number"},{label:"parse",kind:"function",detail:"(dateString: string) => number"}]},{label:"String",kind:"class",detail:"String",members:[{label:"fromCharCode",kind:"function",detail:"(...codes: number[]) => string"},{label:"from",kind:"function",detail:"(value: any) => string"}]},{label:"Number",kind:"class",detail:"Number",members:[{label:"isNaN",kind:"function",detail:"(value: any) => boolean"},{label:"isInteger",kind:"function",detail:"(value: any) => boolean"},{label:"parseFloat",kind:"function",detail:"(value: string) => number"},{label:"parseInt",kind:"function",detail:"(value: string, radix?: number) => number"}]},{label:"setTimeout",kind:"function",detail:"(callback: Function, ms?: number) => number"},{label:"clearTimeout",kind:"function",detail:"(id: number) => void"},{label:"setInterval",kind:"function",detail:"(callback: Function, ms?: number) => number"},{label:"clearInterval",kind:"function",detail:"(id: number) => void"}],Nt=/[\w$]/;function Je(n,r){const a=[];let e=null;for(let $=0;$<r;$++){const v=n[$];if(e){v===e&&n[$-1]!=="\\"&&(e=null);continue}if(v==="'"||v==='"'||v==="`"){e=v;continue}if(v==="("){a.push({index:$,commas:0});continue}if(v===")"){a.pop();continue}v===","&&a.length&&a[a.length-1].commas++}const i=a[a.length-1];if(!i)return null;let c=i.index-1;for(;c>=0&&/\s/.test(n[c]);)c--;const p=c;for(;c>=0&&Nt.test(n[c]);)c--;const d=n.slice(c+1,p+1);if(!d)return null;let s=r;for(;s>0&&/[\w$'"]/.test(n[s-1]);)s--;const f=n.slice(s,r);let E=f,V=null;return f&&(f[0]==="'"||f[0]==='"')&&(V=f[0],E=f.slice(1)),{functionName:d,paramIndex:i.commas,prefix:E,replaceStart:s,quote:V}}const We=["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","from","function","if","import","in","instanceof","let","new","of","return","super","switch","this","throw","try","typeof","var","void","while","with","yield","async","await","true","false","null","undefined","NaN","Infinity"],At=["abstract","any","as","asserts","bigint","boolean","declare","enum","implements","infer","interface","is","keyof","namespace","never","number","object","override","private","protected","public","readonly","satisfies","static","string","symbol","type","unknown"];function Te(n){return n==="typescript"?[...We,...At]:We}function xe(n){return new Set(Te(n))}const Vt=/((?:[A-Za-z_$][\w$]*\??\.)*)([A-Za-z_$][\w$]*)?$/,je=/\b(?:const|let|var|function|class)\s+([A-Za-z_$][\w$]*)/g,Ot=/^[A-Za-z_$]/;function Ge(n,r){const a=n.slice(0,r),e=Vt.exec(a);if(!e)return{prefix:"",chain:[]};const i=e[1]??"",c=e[2]??"",p=i.split(".").filter(Boolean).map(d=>d.replace(/\?$/,""));return{prefix:c,chain:p}}function we(n,r){const a=[],e=new Set;let i;for(je.lastIndex=0;(i=je.exec(n))&&!(i.index>=r);){const c=i[1];if(e.has(c))continue;e.add(c);const p=i[0].slice(0,i[0].indexOf(c)).trim();a.push({label:c,kind:p==="function"?"function":p==="class"?"class":"variable",detail:"当前文件"})}return a}function Qe(n,r){let a=r;for(const e of n){if(!a)return null;const i=a.find(c=>c.label===e);if(!i)return null;a=i.members??[]}return a}function zt(n,r){const a=n.toLowerCase(),e=r.toLowerCase(),i=a.indexOf(e);if(i===0)return 1e3-a.length;if(i>0)return 800-i;let c=0,p=0,d=-1;for(let s=0;s<a.length&&c<e.length;s++)a[s]===e[c]&&(d>=0&&(p+=s-d-1),d=s,c++);return c!==e.length?null:400-p-a.length}function et(n,r){if(!r)return n;const a=[];for(const e of n){const i=zt(e.label,r);i!==null&&a.push({item:e,score:i})}return a.sort((e,i)=>i.score-e.score||e.item.label.localeCompare(i.item.label)),a.map(e=>e.item)}function Dt(n){const r=new Set,a=[];for(const e of n)r.has(e.label)||(r.add(e.label),a.push(e));return a}function tt(n,r,a){const{prefix:e,chain:i}=Ge(n,r);if(a.auto&&(!e&&i.length===0||e&&!Ot.test(e)))return null;const c=a.declared??[],p=[...c,...a.completions];let d;if(i.length>0){const f=Qe(i,p);if(!f||f.length===0)return null;d=f}else d=[...a.completions,...c,...Te(a.language).map(f=>({label:f,kind:"keyword"}))];const s=et(Dt(d),e);return s.length===0?null:{items:s,start:r-e.length,end:r}}const Wt=/([A-Za-z_$][\w$]*(?:\??\.[A-Za-z_$][\w$]*)*)\??\.\s*$/;function nt(n,r,a,e){const i=n.slice(r,a);if(!i)return null;const c=[...e.declared??[],...e.completions],p=Wt.exec(n.slice(0,r));if(p){const d=p[1].split(".").filter(Boolean).map(E=>E.replace(/\?$/,"")),s=Qe(d,c),f=s==null?void 0:s.find(E=>E.label===i);if(f)return f}return c.find(d=>d.label===i)??null}const W="[A-Za-z_$][\\w$]*",Fe="(?:readonly\\s+|public\\s+|private\\s+|protected\\s+|static\\s+|abstract\\s+)*";function Pe(n,r){let a=0,e=!1,i=r;for(let c=r;c<n.length;c++){const p=n[c];for(let d=0;d<p.length;d++){const s=p[d];s==="{"?(a++,e=!0):s==="}"&&a--}if(e&&a<=0){i=c;break}}return{end:i,body:n.slice(r+1,i)}}function qe(n){return n.trim().replace(/[,;]$/,"").trim()}function jt(n){return/^(?:export\s+)?(?:declare\s+)?(?:abstract\s+)?(?:interface|class|type|function|const|let|var|namespace|enum)\b/.test(n)}function J(n,r){const a=n[r];let e=a.lastIndexOf("}");const i=a.lastIndexOf(";");if(i>e&&(e=i),e===-1)return;const c=a.slice(e+1).replace(/^[\s;]+/,"").trim();!c||!jt(c)||(n[r]=a.slice(0,e+1),n.splice(r+1,0,c))}function P(n){return n.length?n.join(`
9
9
  `).replace(/^\s*\/\*\*?/,"").replace(/\*\/\s*$/,"").split(`
10
- `).map(s=>s.replace(/^\s*\*+\s?/,"").replace(/^\s*\/\/\s?/,"")).join(`
10
+ `).map(r=>r.replace(/^\s*\*+\s?/,"").replace(/^\s*\/\/\s?/,"")).join(`
11
11
  `).replace(/\n{3,}/g,`
12
12
 
13
- `).trim():""}function Oe(n){return n.split(`
14
- `).filter(s=>!/^\s*(\/\/|\/\*|\*)/.test(s)).join(`
13
+ `).trim():""}function Ke(n){return n.split(`
14
+ `).filter(r=>!/^\s*(\/\/|\/\*|\*)/.test(r)).join(`
15
15
  `).replace(/\n{2,}/g,`
16
- `).trim()}function ze(n){const s=[],a=new Set,e=new RegExp(`^${Ne}(${W})(\\?)?\\s*\\((.*)\\)\\s*:\\s*(.+?);?$`),i=new RegExp(`^${Ne}(${W})(\\?)?\\s*:\\s*(.+?);?$`);let c=[],p=!1;for(const d of n){const r=d.trim();if(p){c.push(r),r.includes("*/")&&(p=!1);continue}if(r.startsWith("/*")){c.push(r),r.includes("*/")||(p=!0);continue}if(r.startsWith("//")){c.push(r);continue}if(!r||r.startsWith("}")||r.startsWith("[")){c=[];continue}const f=e.exec(r);if(f){const A=q(c);c=[];const $=f[1];if(a.has($))continue;a.add($),s.push({label:$,kind:"function",detail:`(${f[3].trim()}) => ${Ve(f[4])}`,documentation:A||void 0});continue}const C=i.exec(r);if(C){const A=q(c);c=[];const $=C[1];if(a.has($))continue;a.add($);const v=Ve(C[3]),y=/^\(|=>/.test(v)?"function":"property";s.push({label:$,kind:y,detail:v,documentation:A||void 0})}}return s}function Ye(n){const s=[],a=/(['"])((?:\\.|(?!\1).)*)\1/g;let e;for(;e=a.exec(n);)s.push(e[2]);return s}function Ot(n,s){const a=[];let e=0,i="",c=null;for(let p=0;p<n.length;p++){const d=n[p];if(c){i+=d,d===c&&n[p-1]!=="\\"&&(c=null);continue}if(d==="'"||d==='"'||d==="`"){c=d,i+=d;continue}if(d==="("||d==="<"||d==="["||d==="{"?e++:(d===")"||d===">"||d==="]"||d==="}")&&e--,d===s&&e===0){a.push(i),i="";continue}i+=d}return a.push(i),a}function zt(n,s){const a=n.trim(),e=Ye(a);if(e.length)return e;const i=s.get(a.replace(/\[\]$/,""));return(i==null?void 0:i.literals)??[]}function Dt(n,s){const a=n.trim();return a?Ot(a,",").map(e=>{const i=new RegExp(`^\\s*(${W})\\s*(\\?)?\\s*:\\s*(.+)$`).exec(e);if(!i)return{name:e.trim(),type:"",optional:!1,literals:[]};const c=i[3].replace(/\s*=\s*[^=]*$/,"").trim();return{name:i[1],optional:!!i[2],type:c,literals:zt(c,s)}}):[]}function Xe(n){const s=n.replace(/\[\]/g,"").replace(/<[^>]*>/g,"").replace(/\s*\|\s*null\s*/g,"").trim(),a=new RegExp(`^(${W})$`).exec(s);return a?a[1]:null}function Wt(n){const s=n.trim();if(!s||s.endsWith(";"))return!1;const a=(s.match(/[(<[{]/g)??[]).length,e=(s.match(/[)>\]}]/g)??[]).length;return/[|&,(<]\s*$/.test(s)||a>e}function Je(n,s,a,e=0){return e>6?n:n.map(i=>{if(i.kind!=="property"||!i.detail)return i;const c=Xe(i.detail),p=c?s.get(c):void 0;if(!p||a.has(p.label))return i;const d=new Set(a);return d.add(p.label),{...i,type:p.type,members:Je(p.members,s,d,e+1)}})}const jt=50,J=new Map,Ft={items:[],signatures:new Map};function Ge(n){if(!n||!n.trim())return Ft;const s=J.get(n);if(s)return s;const a=Pt(n);if(J.size>=jt){const e=J.keys().next().value;e!==void 0&&J.delete(e)}return J.set(n,a),a}function Qe(n){return Ge(n).items}function et(n){return Ge(n).signatures}function Pt(n){const s=n.split(`
17
- `),a=new Map,e=new Map,i=new RegExp(`^(?:export\\s+)?(?:declare\\s+)?interface\\s+(${W})`),c=new RegExp(`^(?:export\\s+)?(?:declare\\s+)?(?:abstract\\s+)?class\\s+(${W})`),p=new RegExp(`^(?:export\\s+)?(?:declare\\s+)?type\\s+(${W})\\s*=`);let d=[],r=!1;for(let v=0;v<s.length;v++){const y=s[v].trim();if(r){d.push(y),y.includes("*/")&&(r=!1);continue}if(y.startsWith("/*")){d.push(y),y.includes("*/")||(r=!0);continue}if(y.startsWith("//")){d.push(y);continue}if(!y){d=[];continue}const N=i.exec(y);if(N&&y.includes("{")){const w=q(d);d=[];const{end:T,body:M}=Ae(s,v),b=N[1];a.set(b,{label:b,type:Oe(s.slice(v,T+1).join(`
18
- `).replace(/^\s*export\s+/,"")),members:ze(M),kind:"interface",documentation:w||void 0}),X(s,T),v=T;continue}const _=c.exec(y);if(_&&y.includes("{")){const w=q(d);d=[];const{end:T,body:M}=Ae(s,v),b=_[1];a.set(b,{label:b,type:Oe(s.slice(v,T+1).join(`
19
- `).replace(/^\s*export\s+/,"")),members:ze(M),kind:"class",documentation:w||void 0}),X(s,T),v=T;continue}const R=p.exec(y);if(R){const w=q(d);d=[];const T=[s[v]];let M=v;for(;Wt(T.join(`
20
- `))&&M+1<s.length;)M++,T.push(s[M]);const b=T.join(`
21
- `).replace(/^\s*export\s+/,"").replace(/;\s*$/,"").trim();a.set(R[1],{label:R[1],type:b,members:[],kind:"type",documentation:w||void 0,literals:Ye(b)}),X(s,M),v=M;continue}d=[]}const f=[],C=new Set,A=new RegExp(`^(?:export\\s+)?(?:declare\\s+)?function\\s+(${W})\\s*\\(([^)]*)\\)\\s*:\\s*([^;{]+)`),$=new RegExp(`^(?:export\\s+)?(?:declare\\s+)?(?:const|let|var)\\s+(${W})\\s*:\\s*([^=;]+)`);d=[],r=!1;for(let v=0;v<s.length;v++){const y=s[v].trim();if(r){d.push(y),y.includes("*/")&&(r=!1);continue}if(y.startsWith("/*")){d.push(y),y.includes("*/")||(r=!0);continue}if(y.startsWith("//")){d.push(y);continue}if(!y){d=[];continue}const N=A.exec(y);if(N){X(s,v);const R=q(d);d=[];const w=N[1];C.has(w)||(C.add(w),f.push({label:w,kind:"function",detail:`(${N[2].trim()}) => ${N[3].trim()}`,documentation:R||void 0})),e.set(w,{name:w,params:Dt(N[2],a)});continue}const _=$.exec(y);if(_){X(s,v);const R=q(d);d=[];const w=_[1];if(C.has(w))continue;C.add(w);const T=_[2].trim(),M=Xe(T),b=M?a.get(M):void 0,ee=(b==null?void 0:b.kind)==="class"?"class":/^\(|=>/.test(T)?"function":"variable";f.push({label:w,kind:ee,detail:T,type:b==null?void 0:b.type,documentation:R||(b==null?void 0:b.documentation)||void 0,members:b?Je(b.members,a,new Set([b.label])):void 0});continue}d=[]}return{items:f,signatures:e}}function le(n,s,a,e){if(!a||!e)return null;const i=Math.max(0,s-1),c=n.lastIndexOf(a,i);if(c===-1||n.lastIndexOf(e,i)>c)return null;const d=n.indexOf(e,c+a.length);return{start:c+a.length,end:d===-1?n.length:d}}function qt(n,s,a,e){return le(n,s,a,e)!==null}const De=/[A-Za-z_$]/,Kt=/[\w$]/,We=/\s/;function G(n,s){const a=[],e=n.length;let i=0;for(;i<e;){const c=n[i],p=n[i+1];if(We.test(c)){i++;continue}if(c==="/"&&p==="/"){let r=n.indexOf(`
22
- `,i);r===-1&&(r=e),a.push({start:i,end:r,type:"comment"}),i=r;continue}if(c==="/"&&p==="*"){const r=n.indexOf("*/",i+2),f=r===-1?e:r+2;a.push({start:i,end:f,type:"comment"}),i=f;continue}if(c==='"'||c==="'"){let r=i+1;for(;r<e;){if(n[r]==="\\"){r+=2;continue}if(n[r]===`
23
- `)break;if(n[r]===c){r++;break}r++}a.push({start:i,end:r,type:"string"}),i=r;continue}if(c==="`"){let r=i+1;for(;r<e;){if(n[r]==="\\"){r+=2;continue}if(n[r]==="`"){r++;break}r++}a.push({start:i,end:r,type:"template"}),i=r;continue}if(/[0-9]/.test(c)||c==="."&&/[0-9]/.test(p??"")){let r=i+1;for(;r<e&&/[\w.]/.test(n[r]);)r++;a.push({start:i,end:r,type:"number"}),i=r;continue}if(De.test(c)){let r=i+1;for(;r<e&&Kt.test(n[r]);)r++;const f=n.slice(i,r),C=s.keywords.has(f)?"keyword":s.builtins.has(f)?"builtin":"identifier";a.push({start:i,end:r,type:C}),i=r;continue}let d=i+1;for(;d<e;){const r=n[d];if(We.test(r)||De.test(r)||/[0-9]/.test(r)||r==='"'||r==="'"||r==="`"||r==="/")break;d++}a.push({start:i,end:d,type:"punctuation"}),i=d}return a}const Zt={"&":"&amp;","<":"&lt;",">":"&gt;"};function K(n){return n.replace(/[&<>]/g,s=>Zt[s]??s)}function Q(n,s,a=0){let e="",i=0;for(const c of s){c.start>i&&(e+=K(n.slice(i,c.start)));const p=K(n.slice(c.start,c.end));e+=`<span class="tok-${c.type}" data-start="${c.start+a}" data-end="${c.end+a}">${p}</span>`,i=c.end}return i<n.length&&(e+=K(n.slice(i))),e}function tt(n,s,a,e){if(!a||!e)return Q(n,G(n,s));let i="",c=0;for(;c<n.length;){const p=n.indexOf(a,c);if(p===-1){i+=K(n.slice(c));break}i+=K(n.slice(c,p));const d=n.indexOf(e,p+a.length),r=d===-1?n.length:d,f=n.slice(p+a.length,r);i+=`<span class="tok-brace">${K(a)}</span>`,i+=Q(f,G(f,s),p+a.length),d===-1?c=r:(i+=`<span class="tok-brace">${K(e)}</span>`,c=d+e.length)}return i}const Ut={key:0,class:"gutter","aria-hidden":"true"},Yt=["innerHTML"],Xt=["value","readonly","placeholder"],Jt=["onMouseenter","onClick"],Gt={class:"popup-label"},Qt={key:0,class:"popup-detail"},en={class:"hover-head"},tn={class:"hover-name"},nn={key:0,class:"hover-colon"},ln={key:0,class:"hover-type"},on={key:0,class:"hover-doc"},an={key:1,class:"hover-def"},rn=["innerHTML"],sn=["title","aria-label"],cn={key:0,viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true"},un={key:1,viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true"},dn=o.defineComponent({__name:"CodeEditor",props:{modelValue:{},mode:{default:"code"},language:{default:"javascript"},completions:{default:()=>[]},tsTypes:{default:""},completionFilter:{},templateCompletions:{default:()=>[]},templateOpen:{default:"{{"},templateClose:{default:"}}"},placeholder:{default:""},readonly:{type:Boolean,default:!1},lineNumbers:{type:Boolean,default:!0},hover:{type:Boolean,default:!0},theme:{default:"light"},collapsible:{type:Boolean,default:!1},defaultExpanded:{type:Boolean,default:!1},collapsedHeight:{default:"34px"},collapseOnBlur:{type:Boolean,default:!1},borderRadius:{default:"4px"},background:{default:""},borderColor:{default:""},minHeight:{default:"260px"}},emits:["update:modelValue","change","expand","collapse"],setup(n,{expose:s,emit:a}){const e=n,i=a,c={variable:"变量",function:"函数",property:"属性",class:"对象",keyword:"关键字",value:"值"},p={"(":")","[":"]","{":"}",'"':'"',"'":"'"},d=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]),r=o.ref(e.modelValue),f=o.ref(),C=o.ref(),A=o.ref(),$=o.ref(),v=o.ref(),y=o.ref(),N=o.ref(),_=o.ref([]),R=o.ref(0),w=o.ref(!1),T=o.ref({start:0,end:0}),M=o.ref({}),b=o.ref(null),ee=o.ref({}),lt=o.computed(()=>e.tsTypes?Qe(e.tsTypes):[]),ot=o.computed(()=>e.tsTypes?et(e.tsTypes):new Map),ge=o.computed(()=>[...je,...lt.value,...e.completions]),oe=o.computed(()=>e.mode==="template"?[...e.templateCompletions,...ge.value]:ge.value),it=o.computed(()=>{const t={keywords:pe(e.language),builtins:new Set(oe.value.map(l=>l.label))};return e.mode==="template"?`${tt(r.value,t,e.templateOpen,e.templateClose)}
24
- `:`${Q(r.value,G(r.value,t))}
25
- `}),at=o.computed(()=>r.value.split(`
26
- `).length),z=o.ref(e.defaultExpanded),ie=o.ref(!1),ae=o.computed(()=>e.collapsible&&!z.value),rt=o.computed(()=>{const t={};return e.collapsible&&(t.height=e.collapsedHeight),t}),st=o.computed(()=>{const t={"--ce-radius":e.borderRadius,"--ce-collapsed-height":e.collapsedHeight};return e.background&&(t["--ce-bg"]=e.background),e.borderColor&&(t["--ce-border"]=e.borderColor),e.collapsible?{...t,height:z.value?e.minHeight:e.collapsedHeight}:{...t,height:e.minHeight}});let be=0;function ve(t){if(z.value===t)return;const l=f.value;t&&l&&(be=l.scrollTop),z.value=t,e.collapsible&&(ie.value=!0),i(t?"expand":"collapse"),I(),O(),o.nextTick(()=>{if(re(),!z.value&&l){const u=Math.max(0,l.scrollHeight-l.clientHeight);l.scrollTop=Math.max(0,Math.min(be,u)),V(!0),document.activeElement===l&&F();return}V(!0),t&&e.collapseOnBlur&&l&&document.activeElement!==l&&l.focus()})}function ct(){ie.value=!1}function ut(){ve(!z.value)}o.watch(()=>e.modelValue,t=>{t!==r.value&&(r.value=t,I())}),o.watch(r,()=>{o.nextTick(()=>V(!0))});function ye(t){return c[t]}function dt(t){return t?Q(t,G(t,{keywords:pe("typescript"),builtins:new Set})):""}let Z={top:14,bottom:14,left:16,right:16,lineHeight:22};function re(){const t=f.value;if(!t)return;const l=window.getComputedStyle(t);Z={top:parseFloat(l.paddingTop)||0,bottom:parseFloat(l.paddingBottom)||0,left:parseFloat(l.paddingLeft)||0,right:parseFloat(l.paddingRight)||0,lineHeight:parseFloat(l.lineHeight)||22}}function V(t=!1){const l=f.value;if(!l)return;const u=$.value;if(u&&(u.style.transform=`translate(${-l.scrollLeft}px, ${-l.scrollTop}px)`),v.value&&(v.value.style.transform=`translateY(${-l.scrollTop}px)`),t){const m=`${r.value}|${e.mode}|${l.clientWidth}|${l.clientHeight}`;m!==xe&&(xe=m,ft())}}function F(){const t=f.value;if(!t)return;const l=we();if(!l)return;const u=t.getBoundingClientRect(),m=t.offsetWidth?u.width/t.offsetWidth:1,g=t.offsetHeight?u.height/t.offsetHeight:1;let h=t.scrollTop;if(ae.value){const Ie=t.clientHeight*g,He=Z.top*g,Tt=Z.bottom*g,St=l.lineHeight*g,$t=Ie-He-Tt,Bt=l.top+t.scrollTop*g-He-Math.max(0,($t-St)/2),Rt=Math.max(0,t.scrollHeight*g-Ie);h=Math.max(0,Math.min(Bt,Rt))/g}const E=t.clientWidth*m,x=Z.left*m,k=Z.right*m,S=t.scrollLeft*m,B=l.left+S,D=S+x,L=S+E-k,H=8*m;let P=t.scrollLeft;B<D+H?P=Math.max(0,(B-x-H)/m):B>L-H&&(P=Math.max(0,(B-x-E+k+H)/m));const j=Math.abs(h-t.scrollTop)>.5,Me=Math.abs(P-t.scrollLeft)>.5;!j&&!Me||(j&&(t.scrollTop=h),Me&&(t.scrollLeft=P),V())}let ke=[],xe="",te=0,se=-1,ce=-1,ue={x:0,y:0};function ft(){const t=f.value,l=A.value;if(!t||!l)return;const u=t.getBoundingClientRect(),m=[];l.querySelectorAll("[data-start]").forEach(g=>{const h=g.getBoundingClientRect();m.push({start:Number(g.dataset.start),end:Number(g.dataset.end),left:h.left-u.left+t.scrollLeft,right:h.right-u.left+t.scrollLeft,top:h.top-u.top+t.scrollTop,bottom:h.bottom-u.top+t.scrollTop})}),ke=m}function pt(t,l){for(const u of ke)if(t>=u.left-1&&t<=u.right+1&&l>=u.top&&l<=u.bottom)return u;return null}function O(){b.value=null,te=0,se=-1,ce=-1}function mt(t){const l=N.value,u=f.value;if(!l||!u)return;const m=u.getBoundingClientRect(),g=m.left+t.left-u.scrollLeft,h=m.left+t.right-u.scrollLeft,E=m.top+t.top-u.scrollTop,x=m.top+t.bottom-u.scrollTop,k=12,S=8,B=l.offsetWidth,D=l.offsetHeight;let L=g,H=x+S;L+B>window.innerWidth-k&&(L=h-B),H+D>window.innerHeight-k&&(H=E-D-S),L=Math.max(k,Math.min(L,window.innerWidth-k-B)),H=Math.max(k,H),ee.value={left:`${L}px`,top:`${H}px`}}function ht(t,l){const u=f.value;if(!u||e.readonly||!e.hover||w.value){O();return}if(u.selectionStart!==u.selectionEnd){O();return}const m=N.value;if(b.value&&m){const x=m.getBoundingClientRect();if(t>=x.left&&t<=x.right&&l>=x.top&&l<=x.bottom)return}const g=u.getBoundingClientRect(),h=pt(t-g.left+u.scrollLeft,l-g.top+u.scrollTop);if(!h){O();return}if(b.value&&se===h.start&&ce===h.end)return;const E=Ue(u.value,h.start,h.end,{completions:oe.value,declared:me(u.value,h.start)});if(!E){O();return}b.value=E,se=h.start,ce=h.end,o.nextTick(()=>mt(h))}function gt(t){ue={x:t.clientX,y:t.clientY},!te&&(te=requestAnimationFrame(()=>{te=0,ht(ue.x,ue.y)}))}function we(){const t=f.value;if(!t)return null;const l=window.getComputedStyle(t),u=document.createElement("div"),m=parseFloat(l.paddingLeft)||0,g=parseFloat(l.paddingRight)||0,h=t.getBoundingClientRect();Object.assign(u.style,{position:"fixed",left:`${h.left}px`,top:`${h.top}px`,visibility:"hidden",pointerEvents:"none",zIndex:"-1",whiteSpace:l.whiteSpace,overflowWrap:l.overflowWrap,wordBreak:l.wordBreak,boxSizing:"content-box",width:`${t.clientWidth-m-g}px`,paddingTop:l.paddingTop,paddingRight:l.paddingRight,paddingBottom:l.paddingBottom,paddingLeft:l.paddingLeft,border:"0",fontFamily:l.fontFamily,fontSize:l.fontSize,fontWeight:l.fontWeight,fontStyle:l.fontStyle,fontVariant:l.fontVariant,letterSpacing:l.letterSpacing,lineHeight:l.lineHeight,textTransform:l.textTransform,tabSize:l.tabSize}),u.textContent=t.value.slice(0,t.selectionStart);const E=document.createElement("span");E.textContent="​",u.appendChild(E),document.body.appendChild(u);const x=E.getBoundingClientRect();document.body.removeChild(u);const k=parseFloat(l.lineHeight)||22,S=x.height,B=S>0&&S<k?(k-S)/2:0;return{left:x.left-h.left-t.scrollLeft,top:x.top-h.top-t.scrollTop-B,lineHeight:k}}async function Ee(){await o.nextTick();const t=C.value,l=y.value,u=we();if(!t||!l||!u)return;const m=4,g=8,h=window.innerWidth,E=window.innerHeight,x=t.getBoundingClientRect(),k=l.scrollHeight,S=E-(x.top+u.top+u.lineHeight)-m-g,B=x.top+u.top-m-g,D=S>=Math.min(k,180)||S>=B,L=Math.min(248,Math.max(D?S:B,96)),H=Math.min(k,L),P=l.offsetWidth||280;let j=u.left;x.left+j+P>h-g&&(j=h-g-P-x.left),j=Math.max(j,g-x.left),M.value={left:`${j}px`,top:`${D?u.top+u.lineHeight+m:u.top-m-H}px`,maxHeight:`${L}px`}}function I(){w.value=!1,_.value=[],R.value=0,O()}function Y(t=!1){var x;const l=f.value;if(!l||e.readonly)return;if(l.selectionStart!==l.selectionEnd){I();return}const u=l.selectionStart;let m=!t;const g=Fe(l.value,u);if(g){const k=(x=ot.value.get(g.functionName))==null?void 0:x.params[g.paramIndex],S=(k==null?void 0:k.literals)??[];if(S.length){const B=g.quote??"'",D=S.map(H=>({label:`${B}${H}${B}`,kind:"value",detail:k==null?void 0:k.type,insertText:`${B}${H}${B}`})),L=Ke(D,g.prefix);if(L.length){_.value=L,T.value={start:g.replaceStart,end:u},R.value=0,w.value=!0,Ee();return}}}if(e.mode==="template"){const k=le(l.value,u,e.templateOpen,e.templateClose);if(!k){I();return}t&&l.value.slice(k.start,u).trim()===""&&(m=!0)}const h=Ze(l.value,u,{language:e.language,completions:oe.value,declared:me(l.value,u),auto:!m});if(!h){I();return}let E=h.items;if(e.completionFilter){const k=Pe(l.value,u);if(E=e.completionFilter(E,{prefix:k.prefix,chain:k.chain,text:l.value,position:u,mode:e.mode,language:e.language}),E.length===0){I();return}}_.value=E,T.value={start:h.start,end:h.end},R.value=0,w.value=!0,Ee()}function bt(t){r.value=t,i("update:modelValue",t),i("change",t)}function ne(t,l,u,m=t+u.length){const g=f.value;if(!g)return;const h=g.value.slice(0,t)+u+g.value.slice(l);bt(h),I(),o.nextTick(()=>{g.value=h,g.setSelectionRange(m,m),g.focus(),V(!0),F()})}function Ce(t=_.value[R.value]){if(!t)return;const l=t.insertText??t.label;ne(T.value.start,T.value.end,l),I()}function Te(t){const l=_.value.length;l&&(R.value=(R.value+t+l)%l,o.nextTick(()=>{var u,m;(m=(u=y.value)==null?void 0:u.querySelector(".is-active"))==null||m.scrollIntoView({block:"nearest"})}))}function vt(t){const l=t.target;r.value=l.value,i("update:modelValue",l.value),i("change",l.value),O(),V(),F(),o.nextTick(F),Y(!0)}function yt(t){if(I(),O(),!e.collapsible||!e.collapseOnBlur||!z.value)return;const l=t.relatedTarget;l&&l.closest(".expand-toggle")||ve(!1)}function kt(){Se(),F()}function Se(){const t=f.value;if(!t||e.readonly)return;if(t.selectionStart!==t.selectionEnd){I();return}const l=t.selectionStart;if(l>0&&t.value[l-1]==="."){Y(!0);return}if(e.mode==="template"){const u=le(t.value,l,e.templateOpen,e.templateClose);if(u&&t.value.slice(u.start,l).trim()===""){Y(!0);return}}I()}let de=0;function $e(){window.clearTimeout(de),de=window.setTimeout(()=>{de=0,Se(),F()},0)}function Be(t){t.target!==f.value&&w.value&&I()}function xt(){O(),V(),ae.value&&wt()}let fe=0;function wt(){window.clearTimeout(fe),fe=window.setTimeout(()=>{fe=0,Et()},120)}function Et(){const t=f.value;if(!t)return;const l=Z.lineHeight,u=t.scrollTop,m=Math.round(u/l)*l;Math.abs(m-u)<.5||(t.scrollTop=m,V())}function Ct(t){var g;const l=f.value;if(!l)return;const u=t.metaKey||t.ctrlKey,m=d.has(t.key);if(t.key===" "&&u){t.preventDefault(),Y(!1);return}if(w.value){if(t.key==="ArrowDown"){t.preventDefault(),Te(1);return}if(t.key==="ArrowUp"){t.preventDefault(),Te(-1);return}if(t.key==="Enter"||t.key==="Tab"){t.preventDefault(),Ce();return}if(t.key==="Escape"){t.preventDefault(),I();return}if(m||u){I(),m&&!u&&$e();return}}if(m&&!u){$e();return}if(t.key==="Enter"&&!u&&!t.shiftKey){const h=l.selectionStart;if(h!==l.selectionEnd)return;const E=l.value.lastIndexOf(`
27
- `,h-1)+1,x=l.value.slice(E,h),k=((g=x.match(/^[ \t]*/))==null?void 0:g[0])??"",S=/[{[(]$/.test(x.trimEnd())?" ":"";t.preventDefault(),ne(h,h,`
28
- ${k}${S}`);return}if(t.key==="Tab"){t.preventDefault(),ne(l.selectionStart,l.selectionEnd," ");return}if(t.key.length===1&&!u&&!t.altKey&&p[t.key]){if(l.selectionStart!==l.selectionEnd)return;const h=l.selectionStart,E=l.value[h-1],x=l.value[h];if((t.key==='"'||t.key==="'")&&E&&/[\w$]/.test(E)||x!==void 0&&!/[\s)\]},;:]/.test(x))return;t.preventDefault(),ne(h,h,t.key+p[t.key],h+1),e.mode==="template"&&o.nextTick(()=>Y(!0))}}function Re(){w.value&&I(),O(),o.nextTick(()=>{re(),V(!0)})}let U=null;return o.onMounted(()=>{window.addEventListener("resize",Re),window.addEventListener("scroll",Be,!0),o.nextTick(()=>{re(),V(!0)}),typeof ResizeObserver<"u"&&f.value&&(U=new ResizeObserver(()=>{V(!0),F()}),U.observe(f.value))}),o.onBeforeUnmount(()=>{window.removeEventListener("resize",Re),window.removeEventListener("scroll",Be,!0),U==null||U.disconnect(),U=null}),s({focus:()=>{var t;return(t=f.value)==null?void 0:t.focus()}}),(t,l)=>(o.openBlock(),o.createElementBlock("div",{class:o.normalizeClass(["code-input",{"is-collapsible":n.collapsible}]),style:o.normalizeStyle(rt.value)},[o.createElementVNode("div",{class:o.normalizeClass(["code-editor",{"is-readonly":n.readonly,"is-dark":n.theme==="dark","is-collapsed":ae.value,"is-expanding":ie.value}]),style:o.normalizeStyle(st.value),onAnimationend:o.withModifiers(ct,["self"])},[n.lineNumbers?(o.openBlock(),o.createElementBlock("div",Ut,[o.createElementVNode("div",{ref_key:"gutterInner",ref:v,class:"gutter-inner code-font"},[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(at.value,u=>(o.openBlock(),o.createElementBlock("div",{key:u,class:"gutter-line"},o.toDisplayString(u),1))),128))],512)])):o.createCommentVNode("",!0),o.createElementVNode("div",{ref_key:"stage",ref:C,class:"stage"},[o.createElementVNode("div",{ref_key:"highlightLayer",ref:A,class:"highlight code-font"},[o.createElementVNode("pre",{ref_key:"highlightInner",ref:$,class:"code-font"},[o.createElementVNode("code",{innerHTML:it.value},null,8,Yt)],512)],512),o.createElementVNode("textarea",{ref_key:"textarea",ref:f,class:"code-font input",value:r.value,readonly:n.readonly,placeholder:n.placeholder,spellcheck:"false",autocomplete:"off",autocapitalize:"off",autocorrect:"off",wrap:"off",onInput:vt,onKeydown:Ct,onScroll:xt,onClick:kt,onMousemove:gt,onMouseleave:O,onBlur:yt},null,40,Xt),w.value?(o.openBlock(),o.createElementBlock("ul",{key:0,ref_key:"popup",ref:y,class:"popup",style:o.normalizeStyle(M.value),onMousedown:l[0]||(l[0]=o.withModifiers(()=>{},["prevent"]))},[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(_.value,(u,m)=>(o.openBlock(),o.createElementBlock("li",{key:`${u.label}-${m}`,class:o.normalizeClass(["popup-item",{"is-active":m===R.value}]),onMouseenter:g=>R.value=m,onClick:g=>Ce(u)},[o.createElementVNode("span",{class:o.normalizeClass(["badge",`badge-${u.kind}`])},o.toDisplayString(ye(u.kind)),3),o.createElementVNode("span",Gt,o.toDisplayString(u.label),1),u.detail?(o.openBlock(),o.createElementBlock("span",Qt,o.toDisplayString(u.detail),1)):o.createCommentVNode("",!0)],42,Jt))),128))],36)):o.createCommentVNode("",!0),b.value?(o.openBlock(),o.createElementBlock("div",{key:1,ref_key:"hoverCard",ref:N,class:"hover-card",style:o.normalizeStyle(ee.value)},[o.createElementVNode("div",en,[o.createElementVNode("span",{class:o.normalizeClass(["badge",`badge-${b.value.kind}`])},o.toDisplayString(ye(b.value.kind)),3),o.createElementVNode("span",tn,[o.createTextVNode(o.toDisplayString(b.value.label),1),b.value.detail?(o.openBlock(),o.createElementBlock("span",nn,":")):o.createCommentVNode("",!0)]),b.value.detail?(o.openBlock(),o.createElementBlock("span",ln,o.toDisplayString(b.value.detail),1)):o.createCommentVNode("",!0)]),b.value.documentation?(o.openBlock(),o.createElementBlock("p",on,o.toDisplayString(b.value.documentation),1)):o.createCommentVNode("",!0),b.value.type?(o.openBlock(),o.createElementBlock("pre",an,[o.createElementVNode("code",{innerHTML:dt(b.value.type)},null,8,rn)])):o.createCommentVNode("",!0)],4)):o.createCommentVNode("",!0)],512),n.collapsible?(o.openBlock(),o.createElementBlock("button",{key:1,type:"button",class:"expand-toggle",title:z.value?"收起":"展开","aria-label":z.value?"收起编辑器":"展开编辑器",onClick:ut},[z.value?(o.openBlock(),o.createElementBlock("svg",un,[...l[2]||(l[2]=[o.createElementVNode("path",{d:"M11 2 5 8 11 14",fill:"none",stroke:"currentColor","stroke-width":"1.6","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])):(o.openBlock(),o.createElementBlock("svg",cn,[...l[1]||(l[1]=[o.createElementVNode("path",{d:"M6 2 12 8 6 14",fill:"none",stroke:"currentColor","stroke-width":"1.6","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])]))],8,sn)):o.createCommentVNode("",!0)],38)],6))}}),fn=(n,s)=>{const a=n.__vccOpts||n;for(const[e,i]of s)a[e]=i;return a},nt=fn(dn,[["__scopeId","data-v-38bf31d4"]]),pn={install(n){n.component("CodeInput",nt)}};exports.CodeEditor=nt;exports.collectCompletions=Ze;exports.default=pn;exports.defaultCompletions=je;exports.findArgumentContext=Fe;exports.findTemplateRange=le;exports.getKeywordSet=pe;exports.getKeywords=he;exports.highlight=Q;exports.highlightTemplate=tt;exports.isInsideTemplate=qt;exports.parseTsCompletions=Qe;exports.parseTsSignatures=et;exports.resolveHoverItem=Ue;exports.scanDeclarations=me;exports.tokenize=G;
16
+ `).trim()}function Ze(n){const r=[],a=new Set,e=new RegExp(`^${Fe}(${W})(\\?)?\\s*\\((.*)\\)\\s*:\\s*(.+?);?$`),i=new RegExp(`^${Fe}(${W})(\\?)?\\s*:\\s*(.+?);?$`);let c=[],p=!1;for(const d of n){const s=d.trim();if(p){c.push(s),s.includes("*/")&&(p=!1);continue}if(s.startsWith("/*")){c.push(s),s.includes("*/")||(p=!0);continue}if(s.startsWith("//")){c.push(s);continue}if(!s||s.startsWith("}")||s.startsWith("[")){c=[];continue}const f=e.exec(s);if(f){const V=P(c);c=[];const $=f[1];if(a.has($))continue;a.add($),r.push({label:$,kind:"function",detail:`(${f[3].trim()}) => ${qe(f[4])}`,documentation:V||void 0});continue}const E=i.exec(s);if(E){const V=P(c);c=[];const $=E[1];if(a.has($))continue;a.add($);const v=qe(E[3]),y=/^\(|=>/.test(v)?"function":"property";r.push({label:$,kind:y,detail:v,documentation:V||void 0})}}return r}function lt(n){const r=[],a=/(['"])((?:\\.|(?!\1).)*)\1/g;let e;for(;e=a.exec(n);)r.push(e[2]);return r}function Ft(n,r){const a=[];let e=0,i="",c=null;for(let p=0;p<n.length;p++){const d=n[p];if(c){i+=d,d===c&&n[p-1]!=="\\"&&(c=null);continue}if(d==="'"||d==='"'||d==="`"){c=d,i+=d;continue}if(d==="("||d==="<"||d==="["||d==="{"?e++:(d===")"||d===">"||d==="]"||d==="}")&&e--,d===r&&e===0){a.push(i),i="";continue}i+=d}return a.push(i),a}function Pt(n,r){const a=n.trim(),e=lt(a);if(e.length)return e;const i=r.get(a.replace(/\[\]$/,""));return(i==null?void 0:i.literals)??[]}function qt(n,r){const a=n.trim();return a?Ft(a,",").map(e=>{const i=new RegExp(`^\\s*(${W})\\s*(\\?)?\\s*:\\s*(.+)$`).exec(e);if(!i)return{name:e.trim(),type:"",optional:!1,literals:[]};const c=i[3].replace(/\s*=\s*[^=]*$/,"").trim();return{name:i[1],optional:!!i[2],type:c,literals:Pt(c,r)}}):[]}function ot(n){const r=n.replace(/\[\]/g,"").replace(/<[^>]*>/g,"").replace(/\s*\|\s*null\s*/g,"").trim(),a=new RegExp(`^(${W})$`).exec(r);return a?a[1]:null}function Kt(n){const r=n.trim();if(!r||r.endsWith(";"))return!1;const a=(r.match(/[(<[{]/g)??[]).length,e=(r.match(/[)>\]}]/g)??[]).length;return/[|&,(<]\s*$/.test(r)||a>e}function it(n,r,a,e=0){return e>6?n:n.map(i=>{if(i.kind!=="property"||!i.detail)return i;const c=ot(i.detail),p=c?r.get(c):void 0;if(!p||a.has(p.label))return i;const d=new Set(a);return d.add(p.label),{...i,type:p.type,members:it(p.members,r,d,e+1)}})}const Zt=50,G=new Map,Ut={items:[],signatures:new Map};function at(n){if(!n||!n.trim())return Ut;const r=G.get(n);if(r)return r;const a=Yt(n);if(G.size>=Zt){const e=G.keys().next().value;e!==void 0&&G.delete(e)}return G.set(n,a),a}function st(n){return at(n).items}function rt(n){return at(n).signatures}function Yt(n){const r=n.split(`
17
+ `),a=new Map,e=new Map,i=new RegExp(`^(?:export\\s+)?(?:declare\\s+)?interface\\s+(${W})`),c=new RegExp(`^(?:export\\s+)?(?:declare\\s+)?(?:abstract\\s+)?class\\s+(${W})`),p=new RegExp(`^(?:export\\s+)?(?:declare\\s+)?type\\s+(${W})\\s*=`);let d=[],s=!1;for(let v=0;v<r.length;v++){const y=r[v].trim();if(s){d.push(y),y.includes("*/")&&(s=!1);continue}if(y.startsWith("/*")){d.push(y),y.includes("*/")||(s=!0);continue}if(y.startsWith("//")){d.push(y);continue}if(!y){d=[];continue}const N=i.exec(y);if(N&&y.includes("{")){const w=P(d);d=[];const{end:C,body:I}=Pe(r,v),b=N[1];a.set(b,{label:b,type:Ke(r.slice(v,C+1).join(`
18
+ `).replace(/^\s*export\s+/,"")),members:Ze(I),kind:"interface",documentation:w||void 0}),J(r,C),v=C;continue}const _=c.exec(y);if(_&&y.includes("{")){const w=P(d);d=[];const{end:C,body:I}=Pe(r,v),b=_[1];a.set(b,{label:b,type:Ke(r.slice(v,C+1).join(`
19
+ `).replace(/^\s*export\s+/,"")),members:Ze(I),kind:"class",documentation:w||void 0}),J(r,C),v=C;continue}const B=p.exec(y);if(B){const w=P(d);d=[];const C=[r[v]];let I=v;for(;Kt(C.join(`
20
+ `))&&I+1<r.length;)I++,C.push(r[I]);const b=C.join(`
21
+ `).replace(/^\s*export\s+/,"").replace(/;\s*$/,"").trim();a.set(B[1],{label:B[1],type:b,members:[],kind:"type",documentation:w||void 0,literals:lt(b)}),J(r,I),v=I;continue}d=[]}const f=[],E=new Set,V=new RegExp(`^(?:export\\s+)?(?:declare\\s+)?function\\s+(${W})\\s*\\(([^)]*)\\)\\s*:\\s*([^;{]+)`),$=new RegExp(`^(?:export\\s+)?(?:declare\\s+)?(?:const|let|var)\\s+(${W})\\s*:\\s*([^=;]+)`);d=[],s=!1;for(let v=0;v<r.length;v++){const y=r[v].trim();if(s){d.push(y),y.includes("*/")&&(s=!1);continue}if(y.startsWith("/*")){d.push(y),y.includes("*/")||(s=!0);continue}if(y.startsWith("//")){d.push(y);continue}if(!y){d=[];continue}const N=V.exec(y);if(N){J(r,v);const B=P(d);d=[];const w=N[1];E.has(w)||(E.add(w),f.push({label:w,kind:"function",detail:`(${N[2].trim()}) => ${N[3].trim()}`,documentation:B||void 0})),e.set(w,{name:w,params:qt(N[2],a)});continue}const _=$.exec(y);if(_){J(r,v);const B=P(d);d=[];const w=_[1];if(E.has(w))continue;E.add(w);const C=_[2].trim(),I=ot(C),b=I?a.get(I):void 0,te=(b==null?void 0:b.kind)==="class"?"class":/^\(|=>/.test(C)?"function":"variable";f.push({label:w,kind:te,detail:C,type:b==null?void 0:b.type,documentation:B||(b==null?void 0:b.documentation)||void 0,members:b?it(b.members,a,new Set([b.label])):void 0});continue}d=[]}return{items:f,signatures:e}}function ce(n,r,a,e){if(!a||!e)return null;const i=Math.max(0,r-1),c=n.lastIndexOf(a,i);if(c===-1||n.lastIndexOf(e,i)>c)return null;const d=n.indexOf(e,c+a.length);return{start:c+a.length,end:d===-1?n.length:d}}function Xt(n,r,a,e){return ce(n,r,a,e)!==null}const Ue=/[A-Za-z_$]/,Jt=/[\w$]/,Ye=/\s/;function Q(n,r){const a=[],e=n.length;let i=0;for(;i<e;){const c=n[i],p=n[i+1];if(Ye.test(c)){i++;continue}if(c==="/"&&p==="/"){let s=n.indexOf(`
22
+ `,i);s===-1&&(s=e),a.push({start:i,end:s,type:"comment"}),i=s;continue}if(c==="/"&&p==="*"){const s=n.indexOf("*/",i+2),f=s===-1?e:s+2;a.push({start:i,end:f,type:"comment"}),i=f;continue}if(c==='"'||c==="'"){let s=i+1;for(;s<e;){if(n[s]==="\\"){s+=2;continue}if(n[s]===`
23
+ `)break;if(n[s]===c){s++;break}s++}a.push({start:i,end:s,type:"string"}),i=s;continue}if(c==="`"){let s=i+1;for(;s<e;){if(n[s]==="\\"){s+=2;continue}if(n[s]==="`"){s++;break}s++}a.push({start:i,end:s,type:"template"}),i=s;continue}if(/[0-9]/.test(c)||c==="."&&/[0-9]/.test(p??"")){let s=i+1;for(;s<e&&/[\w.]/.test(n[s]);)s++;a.push({start:i,end:s,type:"number"}),i=s;continue}if(Ue.test(c)){let s=i+1;for(;s<e&&Jt.test(n[s]);)s++;const f=n.slice(i,s),E=r.keywords.has(f)?"keyword":r.builtins.has(f)?"builtin":"identifier";a.push({start:i,end:s,type:E}),i=s;continue}let d=i+1;for(;d<e;){const s=n[d];if(Ye.test(s)||Ue.test(s)||/[0-9]/.test(s)||s==='"'||s==="'"||s==="`"||s==="/")break;d++}a.push({start:i,end:d,type:"punctuation"}),i=d}return a}const Gt={"&":"&amp;","<":"&lt;",">":"&gt;"};function q(n){return n.replace(/[&<>]/g,r=>Gt[r]??r)}function ee(n,r,a=0){let e="",i=0;for(const c of r){c.start>i&&(e+=q(n.slice(i,c.start)));const p=q(n.slice(c.start,c.end));e+=`<span class="tok-${c.type}" data-start="${c.start+a}" data-end="${c.end+a}">${p}</span>`,i=c.end}return i<n.length&&(e+=q(n.slice(i))),e}function ct(n,r,a,e){if(!a||!e)return ee(n,Q(n,r));let i="",c=0;for(;c<n.length;){const p=n.indexOf(a,c);if(p===-1){i+=q(n.slice(c));break}i+=q(n.slice(c,p));const d=n.indexOf(e,p+a.length),s=d===-1?n.length:d,f=n.slice(p+a.length,s);i+=`<span class="tok-brace">${q(a)}</span>`,i+=ee(f,Q(f,r),p+a.length),d===-1?c=s:(i+=`<span class="tok-brace">${q(e)}</span>`,c=d+e.length)}return i}const Qt={key:0,class:"gutter","aria-hidden":"true"},en=["innerHTML"],tn=["value","readonly","placeholder"],nn=["onMouseenter","onClick"],ln={class:"popup-label"},on={key:0,class:"popup-detail"},an={class:"hover-head"},sn={class:"hover-name"},rn={key:0,class:"hover-colon"},cn={key:0,class:"hover-type"},un={key:0,class:"hover-doc"},dn={key:1,class:"hover-def"},fn=["innerHTML"],pn=["title","aria-label"],mn={key:0,viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true"},hn={key:1,viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true"},gn=o.defineComponent({__name:"CodeEditor",props:{modelValue:{},mode:{default:"code"},language:{default:"javascript"},completions:{default:()=>[]},tsTypes:{default:""},completionFilter:{},templateCompletions:{default:()=>[]},templateOpen:{default:"{{"},templateClose:{default:"}}"},placeholder:{default:""},readonly:{type:Boolean,default:!1},lineNumbers:{type:Boolean,default:!0},hover:{type:Boolean,default:!0},theme:{default:"light"},collapsible:{type:Boolean,default:!1},defaultExpanded:{type:Boolean,default:!1},collapsedHeight:{default:"34px"},collapseOnBlur:{type:Boolean,default:!1},borderRadius:{default:"4px"},background:{default:""},borderColor:{default:""},minHeight:{default:"260px"}},emits:["update:modelValue","change","expand","collapse"],setup(n,{expose:r,emit:a}){const e=n,i=a,c={variable:"变量",function:"函数",property:"属性",class:"对象",keyword:"关键字",value:"值"},p={"(":")","[":"]","{":"}",'"':'"',"'":"'"},d=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]),s=o.ref(e.modelValue),f=o.ref(),E=o.ref(),V=o.ref(),$=o.ref(),v=o.ref(),y=o.ref(),N=o.ref(),_=o.ref([]),B=o.ref(0),w=o.ref(!1),C=o.ref({start:0,end:0}),I=o.ref({}),b=o.ref(null),te=o.ref({}),dt=o.computed(()=>e.tsTypes?st(e.tsTypes):[]),ft=o.computed(()=>e.tsTypes?rt(e.tsTypes):new Map),Ee=o.computed(()=>[...Xe,...dt.value,...e.completions]),ue=o.computed(()=>e.mode==="template"?[...e.templateCompletions,...Ee.value]:Ee.value),pt=o.computed(()=>{const t={keywords:xe(e.language),builtins:new Set(ue.value.map(l=>l.label))};return e.mode==="template"?`${ct(s.value,t,e.templateOpen,e.templateClose)}
24
+ `:`${ee(s.value,Q(s.value,t))}
25
+ `}),mt=o.computed(()=>s.value.split(`
26
+ `).length),D=o.ref(e.defaultExpanded),de=o.ref(!1),ne=o.computed(()=>e.collapsible&&!D.value),ht=o.computed(()=>{const t={};return e.collapsible&&(t.height=e.collapsedHeight),t}),gt=o.computed(()=>{const t={"--ce-radius":e.borderRadius,"--ce-collapsed-height":e.collapsedHeight};return e.background&&(t["--ce-bg"]=e.background),e.borderColor&&(t["--ce-border"]=e.borderColor),e.collapsible?{...t,height:D.value?e.minHeight:e.collapsedHeight}:{...t,height:e.minHeight}});let Ce=0;function Se(t){if(D.value===t)return;const l=f.value;t&&l&&(Ce=l.scrollTop),D.value=t,e.collapsible&&(de.value=!0),i(t?"expand":"collapse"),H(),z(),o.nextTick(()=>{if(fe(),!D.value&&l){const u=Math.max(0,l.scrollHeight-l.clientHeight);l.scrollTop=Math.max(0,Math.min(Ce,u)),O(!0),document.activeElement===l&&F();return}O(!0),t&&e.collapseOnBlur&&l&&document.activeElement!==l&&l.focus()})}function bt(){de.value=!1}function vt(){Se(!D.value)}o.watch(()=>e.modelValue,t=>{t!==s.value&&(s.value=t,H())}),o.watch(s,()=>{o.nextTick(()=>O(!0))});function $e(t){return c[t]}function yt(t){return t?ee(t,Q(t,{keywords:xe("typescript"),builtins:new Set})):""}let K={top:14,bottom:14,left:16,right:16,lineHeight:22};function fe(){const t=f.value;if(!t)return;const l=window.getComputedStyle(t);K={top:parseFloat(l.paddingTop)||0,bottom:parseFloat(l.paddingBottom)||0,left:parseFloat(l.paddingLeft)||0,right:parseFloat(l.paddingRight)||0,lineHeight:parseFloat(l.lineHeight)||22}}function O(t=!1){const l=f.value;if(!l)return;const u=$.value;if(u&&(u.style.transform=`translate(${-l.scrollLeft}px, ${-l.scrollTop}px)`),v.value&&(v.value.style.transform=`translateY(${-l.scrollTop}px)`),t){const m=`${s.value}|${e.mode}|${l.clientWidth}|${l.clientHeight}`;m!==Me&&(Me=m,kt())}}function F(){const t=f.value;if(!t)return;const l=Re();if(!l)return;const u=t.getBoundingClientRect(),m=t.offsetWidth?u.width/t.offsetWidth:1,g=t.offsetHeight?u.height/t.offsetHeight:1,h=t.clientHeight*g,T=K.top*g,x=K.bottom*g,k=l.lineHeight*g,S=t.scrollTop*g,M=Math.max(0,t.scrollHeight*g-h),A=(ne.value?8:14)*g;let R=t.scrollTop;if(ne.value){const re=h-T-x,X=l.top+S-T-Math.max(0,(re-k)/2);R=Math.max(0,Math.min(X,M))/g}else{const re=T,ye=h-x,X=l.top,De=X+k;let ke=S;X<re+A?ke=S+(X-re-A):De>ye-A&&(ke=S+(De-ye+A)),R=Math.max(0,Math.min(ke,M))/g}const L=t.clientWidth*m,U=K.left*m,j=K.right*m,ve=t.scrollLeft*m,ie=l.left+ve,_t=ve+U,Lt=ve+L-j,ae=8*m;let se=t.scrollLeft;ie<_t+ae?se=Math.max(0,(ie-U-ae)/m):ie>Lt-ae&&(se=Math.max(0,(ie-U-L+j+ae)/m));const Oe=Math.abs(R-t.scrollTop)>.5,ze=Math.abs(se-t.scrollLeft)>.5;!Oe&&!ze||(Oe&&(t.scrollTop=R),ze&&(t.scrollLeft=se),O())}let Be=[],Me="",le=0,pe=-1,me=-1,he={x:0,y:0};function kt(){const t=f.value,l=V.value;if(!t||!l)return;const u=t.getBoundingClientRect(),m=[];l.querySelectorAll("[data-start]").forEach(g=>{const h=g.getBoundingClientRect();m.push({start:Number(g.dataset.start),end:Number(g.dataset.end),left:h.left-u.left+t.scrollLeft,right:h.right-u.left+t.scrollLeft,top:h.top-u.top+t.scrollTop,bottom:h.bottom-u.top+t.scrollTop})}),Be=m}function xt(t,l){for(const u of Be)if(t>=u.left-1&&t<=u.right+1&&l>=u.top&&l<=u.bottom)return u;return null}function z(){b.value=null,le=0,pe=-1,me=-1}function wt(t){const l=N.value,u=f.value;if(!l||!u)return;const m=u.getBoundingClientRect(),g=m.left+t.left-u.scrollLeft,h=m.left+t.right-u.scrollLeft,T=m.top+t.top-u.scrollTop,x=m.top+t.bottom-u.scrollTop,k=12,S=8,M=l.offsetWidth,A=l.offsetHeight;let R=g,L=x+S;R+M>window.innerWidth-k&&(R=h-M),L+A>window.innerHeight-k&&(L=T-A-S),R=Math.max(k,Math.min(R,window.innerWidth-k-M)),L=Math.max(k,L),te.value={left:`${R}px`,top:`${L}px`}}function Tt(t,l){const u=f.value;if(!u||e.readonly||!e.hover||w.value){z();return}if(u.selectionStart!==u.selectionEnd){z();return}const m=N.value;if(b.value&&m){const x=m.getBoundingClientRect();if(t>=x.left&&t<=x.right&&l>=x.top&&l<=x.bottom)return}const g=u.getBoundingClientRect(),h=xt(t-g.left+u.scrollLeft,l-g.top+u.scrollTop);if(!h){z();return}if(b.value&&pe===h.start&&me===h.end)return;const T=nt(u.value,h.start,h.end,{completions:ue.value,declared:we(u.value,h.start)});if(!T){z();return}b.value=T,pe=h.start,me=h.end,o.nextTick(()=>wt(h))}function Et(t){he={x:t.clientX,y:t.clientY},!le&&(le=requestAnimationFrame(()=>{le=0,Tt(he.x,he.y)}))}function Re(){const t=f.value;if(!t)return null;const l=window.getComputedStyle(t),u=document.createElement("div"),m=parseFloat(l.paddingLeft)||0,g=parseFloat(l.paddingRight)||0,h=t.getBoundingClientRect();Object.assign(u.style,{position:"fixed",left:`${h.left}px`,top:`${h.top}px`,visibility:"hidden",pointerEvents:"none",zIndex:"-1",whiteSpace:l.whiteSpace,overflowWrap:l.overflowWrap,wordBreak:l.wordBreak,boxSizing:"content-box",width:`${t.clientWidth-m-g}px`,paddingTop:l.paddingTop,paddingRight:l.paddingRight,paddingBottom:l.paddingBottom,paddingLeft:l.paddingLeft,border:"0",fontFamily:l.fontFamily,fontSize:l.fontSize,fontWeight:l.fontWeight,fontStyle:l.fontStyle,fontVariant:l.fontVariant,letterSpacing:l.letterSpacing,lineHeight:l.lineHeight,textTransform:l.textTransform,tabSize:l.tabSize}),u.textContent=t.value.slice(0,t.selectionStart);const T=document.createElement("span");T.textContent="​",u.appendChild(T),document.body.appendChild(u);const x=T.getBoundingClientRect();document.body.removeChild(u);const k=parseFloat(l.lineHeight)||22,S=x.height,M=S>0&&S<k?(k-S)/2:0;return{left:x.left-h.left-t.scrollLeft,top:x.top-h.top-t.scrollTop-M,lineHeight:k}}async function Ie(){await o.nextTick();const t=E.value,l=y.value,u=Re();if(!t||!l||!u)return;const m=4,g=8,h=window.innerWidth,T=window.innerHeight,x=t.getBoundingClientRect(),k=l.scrollHeight,S=T-(x.top+u.top+u.lineHeight)-m-g,M=x.top+u.top-m-g,A=S>=Math.min(k,180)||S>=M,R=Math.min(248,Math.max(A?S:M,96)),L=Math.min(k,R),U=l.offsetWidth||280;let j=u.left;x.left+j+U>h-g&&(j=h-g-U-x.left),j=Math.max(j,g-x.left),I.value={left:`${j}px`,top:`${A?u.top+u.lineHeight+m:u.top-m-L}px`,maxHeight:`${R}px`}}function H(){w.value=!1,_.value=[],B.value=0,z()}function Y(t=!1){var x;const l=f.value;if(!l||e.readonly)return;if(l.selectionStart!==l.selectionEnd){H();return}const u=l.selectionStart;let m=!t;const g=Je(l.value,u);if(g){const k=(x=ft.value.get(g.functionName))==null?void 0:x.params[g.paramIndex],S=(k==null?void 0:k.literals)??[];if(S.length){const M=g.quote??"'",A=S.map(L=>({label:`${M}${L}${M}`,kind:"value",detail:k==null?void 0:k.type,insertText:`${M}${L}${M}`})),R=et(A,g.prefix);if(R.length){_.value=R,C.value={start:g.replaceStart,end:u},B.value=0,w.value=!0,Ie();return}}}if(e.mode==="template"){const k=ce(l.value,u,e.templateOpen,e.templateClose);if(!k){H();return}t&&l.value.slice(k.start,u).trim()===""&&(m=!0)}const h=tt(l.value,u,{language:e.language,completions:ue.value,declared:we(l.value,u),auto:!m});if(!h){H();return}let T=h.items;if(e.completionFilter){const k=Ge(l.value,u);if(T=e.completionFilter(T,{prefix:k.prefix,chain:k.chain,text:l.value,position:u,mode:e.mode,language:e.language}),T.length===0){H();return}}_.value=T,C.value={start:h.start,end:h.end},B.value=0,w.value=!0,Ie()}function Ct(t){s.value=t,i("update:modelValue",t),i("change",t)}function oe(t,l,u,m=t+u.length){const g=f.value;if(!g)return;const h=g.value.slice(0,t)+u+g.value.slice(l);Ct(h),H(),o.nextTick(()=>{g.value=h,g.setSelectionRange(m,m),g.focus(),O(!0),F()})}function He(t=_.value[B.value]){if(!t)return;const l=t.insertText??t.label;oe(C.value.start,C.value.end,l),H()}function _e(t){const l=_.value.length;l&&(B.value=(B.value+t+l)%l,o.nextTick(()=>{var u,m;(m=(u=y.value)==null?void 0:u.querySelector(".is-active"))==null||m.scrollIntoView({block:"nearest"})}))}function St(t){const l=t.target;s.value=l.value,i("update:modelValue",l.value),i("change",l.value),z(),O(),F(),o.nextTick(F),Y(!0)}function $t(t){if(H(),z(),!e.collapsible||!e.collapseOnBlur||!D.value)return;const l=t.relatedTarget;l&&l.closest(".expand-toggle")||Se(!1)}function Bt(){Le(),F()}function Le(){const t=f.value;if(!t||e.readonly)return;if(t.selectionStart!==t.selectionEnd){H();return}const l=t.selectionStart;if(l>0&&t.value[l-1]==="."){Y(!0);return}if(e.mode==="template"){const u=ce(t.value,l,e.templateOpen,e.templateClose);if(u&&t.value.slice(u.start,l).trim()===""){Y(!0);return}}H()}let ge=0;function Ne(){window.clearTimeout(ge),ge=window.setTimeout(()=>{ge=0,Le(),F()},0)}function Ae(t){t.target!==f.value&&w.value&&H()}function Mt(){z(),O(),ne.value&&Rt()}let be=0;function Rt(){window.clearTimeout(be),be=window.setTimeout(()=>{be=0,It()},120)}function It(){const t=f.value;if(!t)return;const l=K.lineHeight,u=t.scrollTop,m=Math.round(u/l)*l;Math.abs(m-u)<.5||(t.scrollTop=m,O())}function Ht(t){var g;const l=f.value;if(!l)return;const u=t.metaKey||t.ctrlKey,m=d.has(t.key);if(t.key===" "&&u){t.preventDefault(),Y(!1);return}if(w.value){if(t.key==="ArrowDown"){t.preventDefault(),_e(1);return}if(t.key==="ArrowUp"){t.preventDefault(),_e(-1);return}if(t.key==="Enter"||t.key==="Tab"){t.preventDefault(),He();return}if(t.key==="Escape"){t.preventDefault(),H();return}if(m||u){H(),m&&!u&&Ne();return}}if(m&&!u){Ne();return}if(t.key==="Enter"&&!u&&!t.shiftKey){const h=l.selectionStart;if(h!==l.selectionEnd)return;const T=l.value.lastIndexOf(`
27
+ `,h-1)+1,x=l.value.slice(T,h),k=((g=x.match(/^[ \t]*/))==null?void 0:g[0])??"",S=/[{[(]$/.test(x.trimEnd())?" ":"";t.preventDefault(),oe(h,h,`
28
+ ${k}${S}`);return}if(t.key==="Tab"){t.preventDefault(),oe(l.selectionStart,l.selectionEnd," ");return}if(t.key.length===1&&!u&&!t.altKey&&p[t.key]){if(l.selectionStart!==l.selectionEnd)return;const h=l.selectionStart,T=l.value[h-1],x=l.value[h];if((t.key==='"'||t.key==="'")&&T&&/[\w$]/.test(T)||x!==void 0&&!/[\s)\]},;:]/.test(x))return;t.preventDefault(),oe(h,h,t.key+p[t.key],h+1),e.mode==="template"&&o.nextTick(()=>Y(!0))}}function Ve(){w.value&&H(),z(),o.nextTick(()=>{fe(),O(!0)})}let Z=null;return o.onMounted(()=>{window.addEventListener("resize",Ve),window.addEventListener("scroll",Ae,!0),o.nextTick(()=>{fe(),O(!0)}),typeof ResizeObserver<"u"&&f.value&&(Z=new ResizeObserver(()=>{O(!0),F()}),Z.observe(f.value))}),o.onBeforeUnmount(()=>{window.removeEventListener("resize",Ve),window.removeEventListener("scroll",Ae,!0),Z==null||Z.disconnect(),Z=null}),r({focus:()=>{var t;return(t=f.value)==null?void 0:t.focus()}}),(t,l)=>(o.openBlock(),o.createElementBlock("div",{class:o.normalizeClass(["code-input",{"is-collapsible":n.collapsible}]),style:o.normalizeStyle(ht.value)},[o.createElementVNode("div",{class:o.normalizeClass(["code-editor",{"is-readonly":n.readonly,"is-dark":n.theme==="dark","is-collapsed":ne.value,"is-expanding":de.value}]),style:o.normalizeStyle(gt.value),onAnimationend:o.withModifiers(bt,["self"])},[n.lineNumbers?(o.openBlock(),o.createElementBlock("div",Qt,[o.createElementVNode("div",{ref_key:"gutterInner",ref:v,class:"gutter-inner code-font"},[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(mt.value,u=>(o.openBlock(),o.createElementBlock("div",{key:u,class:"gutter-line"},o.toDisplayString(u),1))),128))],512)])):o.createCommentVNode("",!0),o.createElementVNode("div",{ref_key:"stage",ref:E,class:"stage"},[o.createElementVNode("div",{ref_key:"highlightLayer",ref:V,class:"highlight code-font"},[o.createElementVNode("pre",{ref_key:"highlightInner",ref:$,class:"code-font"},[o.createElementVNode("code",{innerHTML:pt.value},null,8,en)],512)],512),o.createElementVNode("textarea",{ref_key:"textarea",ref:f,class:"code-font input",value:s.value,readonly:n.readonly,placeholder:n.placeholder,spellcheck:"false",autocomplete:"off",autocapitalize:"off",autocorrect:"off",wrap:"off",onInput:St,onKeydown:Ht,onScroll:Mt,onClick:Bt,onMousemove:Et,onMouseleave:z,onBlur:$t},null,40,tn),w.value?(o.openBlock(),o.createElementBlock("ul",{key:0,ref_key:"popup",ref:y,class:"popup",style:o.normalizeStyle(I.value),onMousedown:l[0]||(l[0]=o.withModifiers(()=>{},["prevent"]))},[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(_.value,(u,m)=>(o.openBlock(),o.createElementBlock("li",{key:`${u.label}-${m}`,class:o.normalizeClass(["popup-item",{"is-active":m===B.value}]),onMouseenter:g=>B.value=m,onClick:g=>He(u)},[o.createElementVNode("span",{class:o.normalizeClass(["badge",`badge-${u.kind}`])},o.toDisplayString($e(u.kind)),3),o.createElementVNode("span",ln,o.toDisplayString(u.label),1),u.detail?(o.openBlock(),o.createElementBlock("span",on,o.toDisplayString(u.detail),1)):o.createCommentVNode("",!0)],42,nn))),128))],36)):o.createCommentVNode("",!0),b.value?(o.openBlock(),o.createElementBlock("div",{key:1,ref_key:"hoverCard",ref:N,class:"hover-card",style:o.normalizeStyle(te.value)},[o.createElementVNode("div",an,[o.createElementVNode("span",{class:o.normalizeClass(["badge",`badge-${b.value.kind}`])},o.toDisplayString($e(b.value.kind)),3),o.createElementVNode("span",sn,[o.createTextVNode(o.toDisplayString(b.value.label),1),b.value.detail?(o.openBlock(),o.createElementBlock("span",rn,":")):o.createCommentVNode("",!0)]),b.value.detail?(o.openBlock(),o.createElementBlock("span",cn,o.toDisplayString(b.value.detail),1)):o.createCommentVNode("",!0)]),b.value.documentation?(o.openBlock(),o.createElementBlock("p",un,o.toDisplayString(b.value.documentation),1)):o.createCommentVNode("",!0),b.value.type?(o.openBlock(),o.createElementBlock("pre",dn,[o.createElementVNode("code",{innerHTML:yt(b.value.type)},null,8,fn)])):o.createCommentVNode("",!0)],4)):o.createCommentVNode("",!0)],512),n.collapsible?(o.openBlock(),o.createElementBlock("button",{key:1,type:"button",class:"expand-toggle",title:D.value?"收起":"展开","aria-label":D.value?"收起编辑器":"展开编辑器",onClick:vt},[D.value?(o.openBlock(),o.createElementBlock("svg",hn,[...l[2]||(l[2]=[o.createElementVNode("path",{d:"M11 2 5 8 11 14",fill:"none",stroke:"currentColor","stroke-width":"1.6","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])):(o.openBlock(),o.createElementBlock("svg",mn,[...l[1]||(l[1]=[o.createElementVNode("path",{d:"M6 2 12 8 6 14",fill:"none",stroke:"currentColor","stroke-width":"1.6","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])]))],8,pn)):o.createCommentVNode("",!0)],38)],6))}}),bn=(n,r)=>{const a=n.__vccOpts||n;for(const[e,i]of r)a[e]=i;return a},ut=bn(gn,[["__scopeId","data-v-e1c19d60"]]),vn={install(n){n.component("CodeInput",ut)}};exports.CodeEditor=ut;exports.collectCompletions=tt;exports.default=vn;exports.defaultCompletions=Xe;exports.findArgumentContext=Je;exports.findTemplateRange=ce;exports.getKeywordSet=xe;exports.getKeywords=Te;exports.highlight=ee;exports.highlightTemplate=ct;exports.isInsideTemplate=Xt;exports.parseTsCompletions=st;exports.parseTsSignatures=rt;exports.resolveHoverItem=nt;exports.scanDeclarations=we;exports.tokenize=Q;