open-webui/static/pyscript/index-CTWZX_TW.js

3 lines
32 KiB
JavaScript
Raw Normal View History

2024-05-17 03:49:28 +00:00
import{codePointSize as t,codePointAt as e,EditorSelection as o,CharCategory as n,Prec as i,Facet as s,combineConfig as l,StateField as r,StateEffect as a,MapMode as c,RangeValue as h,RangeSet as p,fromCodePoint as f,Annotation as d,Text as u,Transaction as m}from"./codemirror_state-BKbyfKsm.js";import{E as g,k as v,D as b,s as w,g as y,V as x,l as C,a as I,W as O}from"./codemirror_view-C0PMO2z_.js";import{s as k,i as D}from"./codemirror_language-_XiX6II0.js";class T{constructor(t,e,o){this.state=t,this.pos=e,this.explicit=o,this.abortListeners=[]}tokenBefore(t){let e=k(this.state).resolveInner(this.pos,-1);for(;e&&t.indexOf(e.name)<0;)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}matchBefore(t){let e=this.state.doc.lineAt(this.pos),o=Math.max(e.from,this.pos-250),n=e.text.slice(o-e.from,this.pos-e.from),i=n.search(P(t,!1));return i<0?null:{from:o+i,to:this.pos,text:n.slice(i)}}get aborted(){return null==this.abortListeners}addEventListener(t,e){"abort"==t&&this.abortListeners&&this.abortListeners.push(e)}}function A(t){let e=Object.keys(t).join(""),o=/\w/.test(e);return o&&(e=e.replace(/\w/g,"")),`[${o?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function R(t){let e=t.map((t=>"string"==typeof t?{label:t}:t)),[o,n]=e.every((t=>/^\w+$/.test(t.label)))?[/\w*$/,/\w+$/]:function(t){let e=Object.create(null),o=Object.create(null);for(let{label:n}of t){e[n[0]]=!0;for(let t=1;t<n.length;t++)o[n[t]]=!0}let n=A(e)+A(o)+"*$";return[new RegExp("^"+n),new RegExp(n)]}(e);return t=>{let i=t.matchBefore(n);return i||t.explicit?{from:i?i.from:t.pos,options:e,validFor:o}:null}}function S(t,e){return o=>{for(let e=k(o.state).resolveInner(o.pos,-1);e;e=e.parent){if(t.indexOf(e.name)>-1)return null;if(e.type.isTop)break}return e(o)}}class E{constructor(t,e,o,n){this.completion=t,this.source=e,this.match=o,this.score=n}}function L(t){return t.selection.main.from}function P(t,e){var o;let{source:n}=t,i=e&&"^"!=n[0],s="$"!=n[n.length-1];return i||s?new RegExp(`${i?"^":""}(?:${n})${s?"$":""}`,null!==(o=t.flags)&&void 0!==o?o:t.ignoreCase?"i":""):t}const M=d.define();const B=new WeakMap;function j(t){if(!Array.isArray(t))return t;let e=B.get(t);return e||B.set(t,e=R(t)),e}const $=a.define(),F=a.define();class N{constructor(o){this.pattern=o,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<o.length;){let i=e(o,n),s=t(i);this.chars.push(i);let l=o.slice(n,n+s),r=l.toUpperCase();this.folded.push(e(r==l?l.toLowerCase():r,0)),n+=s}this.astral=o.length!=this.chars.length}ret(t,e){return this.score=t,this.matched=e,!0}match(o){if(0==this.pattern.length)return this.ret(-100,[]);if(o.length<this.pattern.length)return!1;let{chars:n,folded:i,any:s,precise:l,byWord:r}=this;if(1==n.length){let s=e(o,0),l=t(s),r=l==o.length?0:-100;if(s==n[0]);else{if(s!=i[0])return!1;r+=-200}return this.ret(r,[0,l])}let a=o.indexOf(this.pattern);if(0==a)return this.ret(o.length==this.pattern.length?0:-100,[0,this.pattern.length]);let c=n.length,h=0;if(a<0){for(let l=0,r=Math.min(o.length,200);l<r&&h<c;){let r=e(o,l);r!=n[h]&&r!=i[h]||(s[h++]=l),l+=t(r)}if(h<c)return!1}let p=0,d=0,u=!1,m=0,g=-1,v=-1,b=/[a-z]/.test(o),w=!0;for(let s=0,h=Math.min(o.length,200),y=0;s<h&&d<c;){let h=e(o,s);a<0&&(p<c&&h==n[p]&&(l[p++]=s),m<c&&(h==n[m]||h==i[m]?(0==m&&(g=s),v=s+1,m++):m=0));let x,C=h<255?h>=48&&h<=57||h>=97&&h<=122?2:h>=65&&h<=90?1:0:(x=f(h))!=x.toLowerCase()?1:x!=x.toUpperCase()?2:0;(!s||1==C&&b||0==y&&0!=C)&&(n[d]==h||i[d]==h&&(u=!0)?r[d++]=s:r.length&&(w=!1)),y=C,s+=t(h)}return d==c&&0==r[0]&&w?this.result((u?-200:0)-100,r,o):m==c&&0==g?this.ret(-200-o.length+(v==o.length?0:-100),[0,v]):a>-1?this.ret(-700-o.length,[a,a+this.pattern.length]):m==c?this.ret(-900-o.length,[g,v]):d==c?this.result((u?-200:0)-100-700+(w?0:-1100),r,o):2!=n.length&&this.result((s[0]?-700:0)-200-1100,s,o)}result(o,n,i){let s=[],l=0;for(let o of n){let n=o+(this.astral?t(e(i,o)):1);l&&s[l-1]==o?s[l-1]=n:(s[l++]=o,s[l++]=n)}return this.ret(o-i.length,s)}}const U=s.define({combine:t=>l(t
//# sourceMappingURL=index-CTWZX_TW.js.map