@rizom/brain 0.2.0-alpha.163 → 0.2.0-alpha.165

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/plugins.js CHANGED
@@ -160,8 +160,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
160
160
  `+K}let v=U(D.buffer,J[w],Y[w],D.position,O);K+=$.repeat(" ",V.indent)+G((D.line+1).toString(),A)+" | "+v.str+`
161
161
  `,K+=$.repeat("-",V.indent+A+3+v.pos)+`^
162
162
  `;for(let k=1;k<=V.linesAfter;k++){if(w+k>=Y.length)break;let b=U(D.buffer,J[w+k],Y[w+k],D.position-(J[w]-J[w+k]),O);K+=$.repeat(" ",V.indent)+G((D.line+k+1).toString(),A)+" | "+b.str+`
163
- `}return K.replace(/\n$/,"")}return qZ=X,qZ}var RZ,eH;function P4(){if(eH)return RZ;eH=1;let $=$D(),U=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],G=["scalar","sequence","mapping"];function X(V){let Z={};if(V!==null)Object.keys(V).forEach(function(J){V[J].forEach(function(Y){Z[String(Y)]=J})});return Z}function D(V,Z){if(Z=Z||{},Object.keys(Z).forEach(function(J){if(U.indexOf(J)===-1)throw new $('Unknown option "'+J+'" is met in definition of "'+V+'" YAML type.')}),this.options=Z,this.tag=V,this.kind=Z.kind||null,this.resolve=Z.resolve||function(){return!0},this.construct=Z.construct||function(J){return J},this.instanceOf=Z.instanceOf||null,this.predicate=Z.predicate||null,this.represent=Z.represent||null,this.representName=Z.representName||null,this.defaultStyle=Z.defaultStyle||null,this.multi=Z.multi||!1,this.styleAliases=X(Z.styleAliases||null),G.indexOf(this.kind)===-1)throw new $('Unknown kind "'+this.kind+'" is specified for "'+V+'" YAML type.')}return RZ=D,RZ}var NZ,$w;function Mw(){if($w)return NZ;$w=1;let $=$D(),U=P4();function G(V,Z){let J=[];return V[Z].forEach(function(Y){let W=J.length;J.forEach(function(w,K){if(w.tag===Y.tag&&w.kind===Y.kind&&w.multi===Y.multi)W=K}),J[W]=Y}),J}function X(){let V={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function Z(J){if(J.multi)V.multi[J.kind].push(J),V.multi.fallback.push(J);else V[J.kind][J.tag]=V.fallback[J.tag]=J}for(let J=0,Y=arguments.length;J<Y;J+=1)arguments[J].forEach(Z);return V}function D(V){return this.extend(V)}return D.prototype.extend=function(Z){let J=[],Y=[];if(Z instanceof U)Y.push(Z);else if(Array.isArray(Z))Y=Y.concat(Z);else if(Z&&(Array.isArray(Z.implicit)||Array.isArray(Z.explicit))){if(Z.implicit)J=J.concat(Z.implicit);if(Z.explicit)Y=Y.concat(Z.explicit)}else throw new $("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");J.forEach(function(w){if(!(w instanceof U))throw new $("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(w.loadKind&&w.loadKind!=="scalar")throw new $("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(w.multi)throw new $("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),Y.forEach(function(w){if(!(w instanceof U))throw new $("Specified list of YAML types (or a single Type object) contains a non-Type object.")});let W=Object.create(D.prototype);return W.implicit=(this.implicit||[]).concat(J),W.explicit=(this.explicit||[]).concat(Y),W.compiledImplicit=G(W,"implicit"),W.compiledExplicit=G(W,"explicit"),W.compiledTypeMap=X(W.compiledImplicit,W.compiledExplicit),W},NZ=D,NZ}var MZ,Uw;function Qw(){if(Uw)return MZ;return Uw=1,MZ=new(P4())("tag:yaml.org,2002:str",{kind:"scalar",construct:function(U){return U!==null?U:""}}),MZ}var QZ,Dw;function Iw(){if(Dw)return QZ;return Dw=1,QZ=new(P4())("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(U){return U!==null?U:[]}}),QZ}var IZ,Gw;function Bw(){if(Gw)return IZ;return Gw=1,IZ=new(P4())("tag:yaml.org,2002:map",{kind:"mapping",construct:function(U){return U!==null?U:{}}}),IZ}var BZ,Xw;function Tw(){if(Xw)return BZ;return Xw=1,BZ=new(Mw())({explicit:[Qw(),Iw(),Bw()]}),BZ}var TZ,Vw;function zw(){if(Vw)return TZ;Vw=1;let $=P4();function U(D){if(D===null)return!0;let V=D.length;return V===1&&D==="~"||V===4&&(D==="null"||D==="Null"||D==="NULL")}function G(){return null}function X(D){return D===null}return TZ=new $("tag:yaml.org,2002:null",{kind:"scalar",resolve:U,construct:G,predicate:X,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"}),TZ}var zZ,Zw;function vw(){if(Zw)return zZ;Zw=1;let $=P4();function U(D){if(D===null)return!1;let V=D.length;return V===4&&(D==="true"||D==="True"||D==="TRUE")||V===5&&(D==="false"||D==="False"||D==="FALSE")}function G(D){return D==="true"||D==="True"||D==="TRUE"}function X(D){return Object.prototype.toString.call(D)==="[object Boolean]"}return zZ=new $("tag:yaml.org,2002:bool",{kind:"scalar",resolve:U,construct:G,predicate:X,represent:{lowercase:function(D){return D?"true":"false"},uppercase:function(D){return D?"TRUE":"FALSE"},camelcase:function(D){return D?"True":"False"}},defaultStyle:"lowercase"}),zZ}var vZ,Jw;function Lw(){if(Jw)return vZ;Jw=1;let $=eU(),U=P4();function G(W){return W>=48&&W<=57||W>=65&&W<=70||W>=97&&W<=102}function X(W){return W>=48&&W<=55}function D(W){return W>=48&&W<=57}function V(W){if(W===null)return!1;let w=W.length,K=0,A=!1;if(!w)return!1;let O=W[K];if(O==="-"||O==="+")O=W[++K];if(O==="0"){if(K+1===w)return!0;if(O=W[++K],O==="b"){K++;for(;K<w;K++){if(O=W[K],O!=="0"&&O!=="1")return!1;A=!0}return A&&isFinite(Z(W))}if(O==="x"){K++;for(;K<w;K++){if(!G(W.charCodeAt(K)))return!1;A=!0}return A&&isFinite(Z(W))}if(O==="o"){K++;for(;K<w;K++){if(!X(W.charCodeAt(K)))return!1;A=!0}return A&&isFinite(Z(W))}}for(;K<w;K++){if(!D(W.charCodeAt(K)))return!1;A=!0}if(!A)return!1;return isFinite(Z(W))}function Z(W){let w=W,K=1,A=w[0];if(A==="-"||A==="+"){if(A==="-")K=-1;w=w.slice(1),A=w[0]}if(w==="0")return 0;if(A==="0"){if(w[1]==="b")return K*parseInt(w.slice(2),2);if(w[1]==="x")return K*parseInt(w.slice(2),16);if(w[1]==="o")return K*parseInt(w.slice(2),8)}return K*parseInt(w,10)}function J(W){return Z(W)}function Y(W){return Object.prototype.toString.call(W)==="[object Number]"&&(W%1===0&&!$.isNegativeZero(W))}return vZ=new U("tag:yaml.org,2002:int",{kind:"scalar",resolve:V,construct:J,predicate:Y,represent:{binary:function(W){return W>=0?"0b"+W.toString(2):"-0b"+W.toString(2).slice(1)},octal:function(W){return W>=0?"0o"+W.toString(8):"-0o"+W.toString(8).slice(1)},decimal:function(W){return W.toString(10)},hexadecimal:function(W){return W>=0?"0x"+W.toString(16).toUpperCase():"-0x"+W.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),vZ}var LZ,Pw;function Sw(){if(Pw)return LZ;Pw=1;let $=eU(),U=P4(),G=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),X=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function D(W){if(W===null)return!1;if(!G.test(W))return!1;if(isFinite(parseFloat(W,10)))return!0;return X.test(W)}function V(W){let w=W.toLowerCase(),K=w[0]==="-"?-1:1;if("+-".indexOf(w[0])>=0)w=w.slice(1);if(w===".inf")return K===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY;else if(w===".nan")return NaN;return K*parseFloat(w,10)}let Z=/^[-+]?[0-9]+e/;function J(W,w){if(isNaN(W))switch(w){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===W)switch(w){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===W)switch(w){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if($.isNegativeZero(W))return"-0.0";let K=W.toString(10);return Z.test(K)?K.replace("e",".e"):K}function Y(W){return Object.prototype.toString.call(W)==="[object Number]"&&(W%1!==0||$.isNegativeZero(W))}return LZ=new U("tag:yaml.org,2002:float",{kind:"scalar",resolve:D,construct:V,predicate:Y,represent:J,defaultStyle:"lowercase"}),LZ}var SZ,Ww;function gw(){if(Ww)return SZ;return Ww=1,SZ=Tw().extend({implicit:[zw(),vw(),Lw(),Sw()]}),SZ}var gZ,Yw;function jw(){if(Yw)return gZ;return Yw=1,gZ=gw(),gZ}var jZ,Hw;function Ew(){if(Hw)return jZ;Hw=1;let $=P4(),U=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),G=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function X(Z){if(Z===null)return!1;if(U.exec(Z)!==null)return!0;if(G.exec(Z)!==null)return!0;return!1}function D(Z){let J=0,Y=null,W=U.exec(Z);if(W===null)W=G.exec(Z);if(W===null)throw Error("Date resolve error");let w=+W[1],K=+W[2]-1,A=+W[3];if(!W[4])return new Date(Date.UTC(w,K,A));let O=+W[4],v=+W[5],k=+W[6];if(W[7]){J=W[7].slice(0,3);while(J.length<3)J+="0";J=+J}if(W[9]){let y=+W[10],P$=+(W[11]||0);if(Y=(y*60+P$)*60000,W[9]==="-")Y=-Y}let b=new Date(Date.UTC(w,K,A,O,v,k,J));if(Y)b.setTime(b.getTime()-Y);return b}function V(Z){return Z.toISOString()}return jZ=new $("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:X,construct:D,instanceOf:Date,represent:V}),jZ}var EZ,ww;function Cw(){if(ww)return EZ;ww=1;let $=P4();function U(G){return G==="<<"||G===null}return EZ=new $("tag:yaml.org,2002:merge",{kind:"scalar",resolve:U}),EZ}var CZ,Kw;function kw(){if(Kw)return CZ;Kw=1;let $=P4(),U=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
164
- \r`;function G(Z){if(Z===null)return!1;let J=0,Y=Z.length,W=U;for(let w=0;w<Y;w++){let K=W.indexOf(Z.charAt(w));if(K>64)continue;if(K<0)return!1;J+=6}return J%8===0}function X(Z){let J=Z.replace(/[\r\n=]/g,""),Y=J.length,W=U,w=0,K=[];for(let O=0;O<Y;O++){if(O%4===0&&O)K.push(w>>16&255),K.push(w>>8&255),K.push(w&255);w=w<<6|W.indexOf(J.charAt(O))}let A=Y%4*6;if(A===0)K.push(w>>16&255),K.push(w>>8&255),K.push(w&255);else if(A===18)K.push(w>>10&255),K.push(w>>2&255);else if(A===12)K.push(w>>4&255);return new Uint8Array(K)}function D(Z){let J="",Y=0,W=Z.length,w=U;for(let A=0;A<W;A++){if(A%3===0&&A)J+=w[Y>>18&63],J+=w[Y>>12&63],J+=w[Y>>6&63],J+=w[Y&63];Y=(Y<<8)+Z[A]}let K=W%3;if(K===0)J+=w[Y>>18&63],J+=w[Y>>12&63],J+=w[Y>>6&63],J+=w[Y&63];else if(K===2)J+=w[Y>>10&63],J+=w[Y>>4&63],J+=w[Y<<2&63],J+=w[64];else if(K===1)J+=w[Y>>2&63],J+=w[Y<<4&63],J+=w[64],J+=w[64];return J}function V(Z){return Object.prototype.toString.call(Z)==="[object Uint8Array]"}return CZ=new $("tag:yaml.org,2002:binary",{kind:"scalar",resolve:G,construct:X,predicate:V,represent:D}),CZ}var kZ,Ow;function xw(){if(Ow)return kZ;Ow=1;let $=P4(),U=Object.prototype.hasOwnProperty,G=Object.prototype.toString;function X(V){if(V===null)return!0;let Z=[],J=V;for(let Y=0,W=J.length;Y<W;Y+=1){let w=J[Y],K=!1;if(G.call(w)!=="[object Object]")return!1;let A;for(A in w)if(U.call(w,A))if(!K)K=!0;else return!1;if(!K)return!1;if(Z.indexOf(A)===-1)Z.push(A);else return!1}return!0}function D(V){return V!==null?V:[]}return kZ=new $("tag:yaml.org,2002:omap",{kind:"sequence",resolve:X,construct:D}),kZ}var xZ,Aw;function bw(){if(Aw)return xZ;Aw=1;let $=P4(),U=Object.prototype.toString;function G(D){if(D===null)return!0;let V=D,Z=Array(V.length);for(let J=0,Y=V.length;J<Y;J+=1){let W=V[J];if(U.call(W)!=="[object Object]")return!1;let w=Object.keys(W);if(w.length!==1)return!1;Z[J]=[w[0],W[w[0]]]}return!0}function X(D){if(D===null)return[];let V=D,Z=Array(V.length);for(let J=0,Y=V.length;J<Y;J+=1){let W=V[J],w=Object.keys(W);Z[J]=[w[0],W[w[0]]]}return Z}return xZ=new $("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:G,construct:X}),xZ}var bZ,_w;function uw(){if(_w)return bZ;_w=1;let $=P4(),U=Object.prototype.hasOwnProperty;function G(D){if(D===null)return!0;let V=D;for(let Z in V)if(U.call(V,Z)){if(V[Z]!==null)return!1}return!0}function X(D){return D!==null?D:{}}return bZ=new $("tag:yaml.org,2002:set",{kind:"mapping",resolve:G,construct:X}),bZ}var uZ,Fw;function hZ(){if(Fw)return uZ;return Fw=1,uZ=jw().extend({implicit:[Ew(),Cw()],explicit:[kw(),xw(),bw(),uw()]}),uZ}var qw;function gQ(){if(qw)return k0;qw=1;let $=eU(),U=$D(),G=SQ(),X=hZ(),D=Object.prototype.hasOwnProperty,V=1,Z=2,J=3,Y=4,W=1,w=2,K=3,A=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,O=/[\x85\u2028\u2029]/,v=/[,\[\]{}]/,k=/^(?:!|!!|![0-9A-Za-z-]+!)$/,b=/^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;function y(H){return Object.prototype.toString.call(H)}function P$(H){return H===10||H===13}function c(H){return H===9||H===32}function t(H){return H===9||H===32||H===10||H===13}function X$(H){return H===44||H===91||H===93||H===123||H===125}function u(H){if(H>=48&&H<=57)return H-48;let Q=H|32;if(Q>=97&&Q<=102)return Q-97+10;return-1}function F$(H){if(H===120)return 2;if(H===117)return 4;if(H===85)return 8;return 0}function N$(H){if(H>=48&&H<=57)return H-48;return-1}function _$(H){switch(H){case 48:return"\x00";case 97:return"\x07";case 98:return"\b";case 116:return"\t";case 9:return"\t";case 110:return`
163
+ `}return K.replace(/\n$/,"")}return qZ=X,qZ}var RZ,eH;function P4(){if(eH)return RZ;eH=1;let $=$D(),U=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],G=["scalar","sequence","mapping"];function X(V){let Z={};if(V!==null)Object.keys(V).forEach(function(J){V[J].forEach(function(Y){Z[String(Y)]=J})});return Z}function D(V,Z){if(Z=Z||{},Object.keys(Z).forEach(function(J){if(U.indexOf(J)===-1)throw new $('Unknown option "'+J+'" is met in definition of "'+V+'" YAML type.')}),this.options=Z,this.tag=V,this.kind=Z.kind||null,this.resolve=Z.resolve||function(){return!0},this.construct=Z.construct||function(J){return J},this.instanceOf=Z.instanceOf||null,this.predicate=Z.predicate||null,this.represent=Z.represent||null,this.representName=Z.representName||null,this.defaultStyle=Z.defaultStyle||null,this.multi=Z.multi||!1,this.styleAliases=X(Z.styleAliases||null),G.indexOf(this.kind)===-1)throw new $('Unknown kind "'+this.kind+'" is specified for "'+V+'" YAML type.')}return RZ=D,RZ}var NZ,$3;function M3(){if($3)return NZ;$3=1;let $=$D(),U=P4();function G(V,Z){let J=[];return V[Z].forEach(function(Y){let W=J.length;J.forEach(function(w,K){if(w.tag===Y.tag&&w.kind===Y.kind&&w.multi===Y.multi)W=K}),J[W]=Y}),J}function X(){let V={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function Z(J){if(J.multi)V.multi[J.kind].push(J),V.multi.fallback.push(J);else V[J.kind][J.tag]=V.fallback[J.tag]=J}for(let J=0,Y=arguments.length;J<Y;J+=1)arguments[J].forEach(Z);return V}function D(V){return this.extend(V)}return D.prototype.extend=function(Z){let J=[],Y=[];if(Z instanceof U)Y.push(Z);else if(Array.isArray(Z))Y=Y.concat(Z);else if(Z&&(Array.isArray(Z.implicit)||Array.isArray(Z.explicit))){if(Z.implicit)J=J.concat(Z.implicit);if(Z.explicit)Y=Y.concat(Z.explicit)}else throw new $("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");J.forEach(function(w){if(!(w instanceof U))throw new $("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(w.loadKind&&w.loadKind!=="scalar")throw new $("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(w.multi)throw new $("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),Y.forEach(function(w){if(!(w instanceof U))throw new $("Specified list of YAML types (or a single Type object) contains a non-Type object.")});let W=Object.create(D.prototype);return W.implicit=(this.implicit||[]).concat(J),W.explicit=(this.explicit||[]).concat(Y),W.compiledImplicit=G(W,"implicit"),W.compiledExplicit=G(W,"explicit"),W.compiledTypeMap=X(W.compiledImplicit,W.compiledExplicit),W},NZ=D,NZ}var MZ,U3;function Q3(){if(U3)return MZ;return U3=1,MZ=new(P4())("tag:yaml.org,2002:str",{kind:"scalar",construct:function(U){return U!==null?U:""}}),MZ}var QZ,D3;function I3(){if(D3)return QZ;return D3=1,QZ=new(P4())("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(U){return U!==null?U:[]}}),QZ}var IZ,G3;function B3(){if(G3)return IZ;return G3=1,IZ=new(P4())("tag:yaml.org,2002:map",{kind:"mapping",construct:function(U){return U!==null?U:{}}}),IZ}var BZ,X3;function T3(){if(X3)return BZ;return X3=1,BZ=new(M3())({explicit:[Q3(),I3(),B3()]}),BZ}var TZ,V3;function z3(){if(V3)return TZ;V3=1;let $=P4();function U(D){if(D===null)return!0;let V=D.length;return V===1&&D==="~"||V===4&&(D==="null"||D==="Null"||D==="NULL")}function G(){return null}function X(D){return D===null}return TZ=new $("tag:yaml.org,2002:null",{kind:"scalar",resolve:U,construct:G,predicate:X,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"}),TZ}var zZ,Z3;function v3(){if(Z3)return zZ;Z3=1;let $=P4();function U(D){if(D===null)return!1;let V=D.length;return V===4&&(D==="true"||D==="True"||D==="TRUE")||V===5&&(D==="false"||D==="False"||D==="FALSE")}function G(D){return D==="true"||D==="True"||D==="TRUE"}function X(D){return Object.prototype.toString.call(D)==="[object Boolean]"}return zZ=new $("tag:yaml.org,2002:bool",{kind:"scalar",resolve:U,construct:G,predicate:X,represent:{lowercase:function(D){return D?"true":"false"},uppercase:function(D){return D?"TRUE":"FALSE"},camelcase:function(D){return D?"True":"False"}},defaultStyle:"lowercase"}),zZ}var vZ,J3;function L3(){if(J3)return vZ;J3=1;let $=eU(),U=P4();function G(W){return W>=48&&W<=57||W>=65&&W<=70||W>=97&&W<=102}function X(W){return W>=48&&W<=55}function D(W){return W>=48&&W<=57}function V(W){if(W===null)return!1;let w=W.length,K=0,A=!1;if(!w)return!1;let O=W[K];if(O==="-"||O==="+")O=W[++K];if(O==="0"){if(K+1===w)return!0;if(O=W[++K],O==="b"){K++;for(;K<w;K++){if(O=W[K],O!=="0"&&O!=="1")return!1;A=!0}return A&&isFinite(Z(W))}if(O==="x"){K++;for(;K<w;K++){if(!G(W.charCodeAt(K)))return!1;A=!0}return A&&isFinite(Z(W))}if(O==="o"){K++;for(;K<w;K++){if(!X(W.charCodeAt(K)))return!1;A=!0}return A&&isFinite(Z(W))}}for(;K<w;K++){if(!D(W.charCodeAt(K)))return!1;A=!0}if(!A)return!1;return isFinite(Z(W))}function Z(W){let w=W,K=1,A=w[0];if(A==="-"||A==="+"){if(A==="-")K=-1;w=w.slice(1),A=w[0]}if(w==="0")return 0;if(A==="0"){if(w[1]==="b")return K*parseInt(w.slice(2),2);if(w[1]==="x")return K*parseInt(w.slice(2),16);if(w[1]==="o")return K*parseInt(w.slice(2),8)}return K*parseInt(w,10)}function J(W){return Z(W)}function Y(W){return Object.prototype.toString.call(W)==="[object Number]"&&(W%1===0&&!$.isNegativeZero(W))}return vZ=new U("tag:yaml.org,2002:int",{kind:"scalar",resolve:V,construct:J,predicate:Y,represent:{binary:function(W){return W>=0?"0b"+W.toString(2):"-0b"+W.toString(2).slice(1)},octal:function(W){return W>=0?"0o"+W.toString(8):"-0o"+W.toString(8).slice(1)},decimal:function(W){return W.toString(10)},hexadecimal:function(W){return W>=0?"0x"+W.toString(16).toUpperCase():"-0x"+W.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),vZ}var LZ,P3;function S3(){if(P3)return LZ;P3=1;let $=eU(),U=P4(),G=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),X=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function D(W){if(W===null)return!1;if(!G.test(W))return!1;if(isFinite(parseFloat(W,10)))return!0;return X.test(W)}function V(W){let w=W.toLowerCase(),K=w[0]==="-"?-1:1;if("+-".indexOf(w[0])>=0)w=w.slice(1);if(w===".inf")return K===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY;else if(w===".nan")return NaN;return K*parseFloat(w,10)}let Z=/^[-+]?[0-9]+e/;function J(W,w){if(isNaN(W))switch(w){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===W)switch(w){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===W)switch(w){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if($.isNegativeZero(W))return"-0.0";let K=W.toString(10);return Z.test(K)?K.replace("e",".e"):K}function Y(W){return Object.prototype.toString.call(W)==="[object Number]"&&(W%1!==0||$.isNegativeZero(W))}return LZ=new U("tag:yaml.org,2002:float",{kind:"scalar",resolve:D,construct:V,predicate:Y,represent:J,defaultStyle:"lowercase"}),LZ}var SZ,W3;function g3(){if(W3)return SZ;return W3=1,SZ=T3().extend({implicit:[z3(),v3(),L3(),S3()]}),SZ}var gZ,Y3;function j3(){if(Y3)return gZ;return Y3=1,gZ=g3(),gZ}var jZ,H3;function E3(){if(H3)return jZ;H3=1;let $=P4(),U=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),G=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function X(Z){if(Z===null)return!1;if(U.exec(Z)!==null)return!0;if(G.exec(Z)!==null)return!0;return!1}function D(Z){let J=0,Y=null,W=U.exec(Z);if(W===null)W=G.exec(Z);if(W===null)throw Error("Date resolve error");let w=+W[1],K=+W[2]-1,A=+W[3];if(!W[4])return new Date(Date.UTC(w,K,A));let O=+W[4],v=+W[5],k=+W[6];if(W[7]){J=W[7].slice(0,3);while(J.length<3)J+="0";J=+J}if(W[9]){let y=+W[10],P$=+(W[11]||0);if(Y=(y*60+P$)*60000,W[9]==="-")Y=-Y}let b=new Date(Date.UTC(w,K,A,O,v,k,J));if(Y)b.setTime(b.getTime()-Y);return b}function V(Z){return Z.toISOString()}return jZ=new $("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:X,construct:D,instanceOf:Date,represent:V}),jZ}var EZ,w3;function C3(){if(w3)return EZ;w3=1;let $=P4();function U(G){return G==="<<"||G===null}return EZ=new $("tag:yaml.org,2002:merge",{kind:"scalar",resolve:U}),EZ}var CZ,K3;function k3(){if(K3)return CZ;K3=1;let $=P4(),U=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
164
+ \r`;function G(Z){if(Z===null)return!1;let J=0,Y=Z.length,W=U;for(let w=0;w<Y;w++){let K=W.indexOf(Z.charAt(w));if(K>64)continue;if(K<0)return!1;J+=6}return J%8===0}function X(Z){let J=Z.replace(/[\r\n=]/g,""),Y=J.length,W=U,w=0,K=[];for(let O=0;O<Y;O++){if(O%4===0&&O)K.push(w>>16&255),K.push(w>>8&255),K.push(w&255);w=w<<6|W.indexOf(J.charAt(O))}let A=Y%4*6;if(A===0)K.push(w>>16&255),K.push(w>>8&255),K.push(w&255);else if(A===18)K.push(w>>10&255),K.push(w>>2&255);else if(A===12)K.push(w>>4&255);return new Uint8Array(K)}function D(Z){let J="",Y=0,W=Z.length,w=U;for(let A=0;A<W;A++){if(A%3===0&&A)J+=w[Y>>18&63],J+=w[Y>>12&63],J+=w[Y>>6&63],J+=w[Y&63];Y=(Y<<8)+Z[A]}let K=W%3;if(K===0)J+=w[Y>>18&63],J+=w[Y>>12&63],J+=w[Y>>6&63],J+=w[Y&63];else if(K===2)J+=w[Y>>10&63],J+=w[Y>>4&63],J+=w[Y<<2&63],J+=w[64];else if(K===1)J+=w[Y>>2&63],J+=w[Y<<4&63],J+=w[64],J+=w[64];return J}function V(Z){return Object.prototype.toString.call(Z)==="[object Uint8Array]"}return CZ=new $("tag:yaml.org,2002:binary",{kind:"scalar",resolve:G,construct:X,predicate:V,represent:D}),CZ}var kZ,O3;function x3(){if(O3)return kZ;O3=1;let $=P4(),U=Object.prototype.hasOwnProperty,G=Object.prototype.toString;function X(V){if(V===null)return!0;let Z=[],J=V;for(let Y=0,W=J.length;Y<W;Y+=1){let w=J[Y],K=!1;if(G.call(w)!=="[object Object]")return!1;let A;for(A in w)if(U.call(w,A))if(!K)K=!0;else return!1;if(!K)return!1;if(Z.indexOf(A)===-1)Z.push(A);else return!1}return!0}function D(V){return V!==null?V:[]}return kZ=new $("tag:yaml.org,2002:omap",{kind:"sequence",resolve:X,construct:D}),kZ}var xZ,A3;function b3(){if(A3)return xZ;A3=1;let $=P4(),U=Object.prototype.toString;function G(D){if(D===null)return!0;let V=D,Z=Array(V.length);for(let J=0,Y=V.length;J<Y;J+=1){let W=V[J];if(U.call(W)!=="[object Object]")return!1;let w=Object.keys(W);if(w.length!==1)return!1;Z[J]=[w[0],W[w[0]]]}return!0}function X(D){if(D===null)return[];let V=D,Z=Array(V.length);for(let J=0,Y=V.length;J<Y;J+=1){let W=V[J],w=Object.keys(W);Z[J]=[w[0],W[w[0]]]}return Z}return xZ=new $("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:G,construct:X}),xZ}var bZ,_3;function u3(){if(_3)return bZ;_3=1;let $=P4(),U=Object.prototype.hasOwnProperty;function G(D){if(D===null)return!0;let V=D;for(let Z in V)if(U.call(V,Z)){if(V[Z]!==null)return!1}return!0}function X(D){return D!==null?D:{}}return bZ=new $("tag:yaml.org,2002:set",{kind:"mapping",resolve:G,construct:X}),bZ}var uZ,F3;function hZ(){if(F3)return uZ;return F3=1,uZ=j3().extend({implicit:[E3(),C3()],explicit:[k3(),x3(),b3(),u3()]}),uZ}var q3;function gQ(){if(q3)return k0;q3=1;let $=eU(),U=$D(),G=SQ(),X=hZ(),D=Object.prototype.hasOwnProperty,V=1,Z=2,J=3,Y=4,W=1,w=2,K=3,A=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,O=/[\x85\u2028\u2029]/,v=/[,\[\]{}]/,k=/^(?:!|!!|![0-9A-Za-z-]+!)$/,b=/^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;function y(H){return Object.prototype.toString.call(H)}function P$(H){return H===10||H===13}function c(H){return H===9||H===32}function t(H){return H===9||H===32||H===10||H===13}function X$(H){return H===44||H===91||H===93||H===123||H===125}function u(H){if(H>=48&&H<=57)return H-48;let Q=H|32;if(Q>=97&&Q<=102)return Q-97+10;return-1}function F$(H){if(H===120)return 2;if(H===117)return 4;if(H===85)return 8;return 0}function N$(H){if(H>=48&&H<=57)return H-48;return-1}function _$(H){switch(H){case 48:return"\x00";case 97:return"\x07";case 98:return"\b";case 116:return"\t";case 9:return"\t";case 110:return`
165
165
  `;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"\x85";case 95:return"\xA0";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function Q$(H){if(H<=65535)return String.fromCharCode(H);return String.fromCharCode((H-65536>>10)+55296,(H-65536&1023)+56320)}function h$(H,Q,T){if(Q==="__proto__")Object.defineProperty(H,Q,{configurable:!0,enumerable:!0,writable:!0,value:T});else H[Q]=T}let R$=Array(256),e=Array(256);for(let H=0;H<256;H++)R$[H]=_$(H)?1:0,e[H]=_$(H);function D$(H,Q){this.input=H,this.filename=Q.filename||null,this.schema=Q.schema||X,this.onWarning=Q.onWarning||null,this.legacy=Q.legacy||!1,this.json=Q.json||!1,this.listener=Q.listener||null,this.maxDepth=typeof Q.maxDepth==="number"?Q.maxDepth:100,this.maxTotalMergeKeys=typeof Q.maxTotalMergeKeys==="number"?Q.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=H.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function H$(H,Q){let T={name:H.filename,buffer:H.input.slice(0,-1),position:H.position,line:H.line,column:H.position-H.lineStart};return T.snippet=G(T),new U(Q,T)}function d(H,Q){throw H$(H,Q)}function v$(H,Q){if(H.onWarning)H.onWarning.call(null,H$(H,Q))}function g$(H,Q,T){let j=H.anchorMapTransactions;if(j.length!==0){let L=j[j.length-1];if(!D.call(L,Q))L[Q]={existed:D.call(H.anchorMap,Q),value:H.anchorMap[Q]}}H.anchorMap[Q]=T}function w4(H){H.anchorMapTransactions.push(Object.create(null))}function N(H){let Q=H.anchorMapTransactions.pop(),T=H.anchorMapTransactions;if(T.length===0)return;let j=T[T.length-1],L=Object.keys(Q);for(let r=0,q=L.length;r<q;r+=1){let B=L[r];if(!D.call(j,B))j[B]=Q[B]}}function d$(H){let Q=H.anchorMapTransactions.pop(),T=Object.keys(Q);for(let j=T.length-1;j>=0;j-=1){let L=Q[T[j]];if(L.existed)H.anchorMap[T[j]]=L.value;else delete H.anchorMap[T[j]]}}function U4(H){return{position:H.position,line:H.line,lineStart:H.lineStart,lineIndent:H.lineIndent,firstTabInLine:H.firstTabInLine,tag:H.tag,anchor:H.anchor,kind:H.kind,result:H.result}}function M(H,Q){H.position=Q.position,H.line=Q.line,H.lineStart=Q.lineStart,H.lineIndent=Q.lineIndent,H.firstTabInLine=Q.firstTabInLine,H.tag=Q.tag,H.anchor=Q.anchor,H.kind=Q.kind,H.result=Q.result}let m$={YAML:function(Q,T,j){if(Q.version!==null)d(Q,"duplication of %YAML directive");if(j.length!==1)d(Q,"YAML directive accepts exactly one argument");let L=/^([0-9]+)\.([0-9]+)$/.exec(j[0]);if(L===null)d(Q,"ill-formed argument of the YAML directive");let r=parseInt(L[1],10),q=parseInt(L[2],10);if(r!==1)d(Q,"unacceptable YAML version of the document");if(Q.version=j[0],Q.checkLineBreaks=q<2,q!==1&&q!==2)v$(Q,"unsupported YAML version of the document")},TAG:function(Q,T,j){let L;if(j.length!==2)d(Q,"TAG directive accepts exactly two arguments");let r=j[0];if(L=j[1],!k.test(r))d(Q,"ill-formed tag handle (first argument) of the TAG directive");if(D.call(Q.tagMap,r))d(Q,'there is a previously declared suffix for "'+r+'" tag handle');if(!b.test(L))d(Q,"ill-formed tag prefix (second argument) of the TAG directive");try{L=decodeURIComponent(L)}catch(q){d(Q,"tag prefix is malformed: "+L)}Q.tagMap[r]=L}};function C$(H,Q,T,j){if(Q<T){let L=H.input.slice(Q,T);if(j)for(let r=0,q=L.length;r<q;r+=1){let B=L.charCodeAt(r);if(!(B===9||B>=32&&B<=1114111))d(H,"expected valid JSON character")}else if(A.test(L))d(H,"the stream contains non-printable characters");H.result+=L}}function I4(H,Q,T,j){if(!$.isObject(T))d(H,"cannot merge mappings; the provided source object is unacceptable");let L=Object.keys(T);for(let r=0,q=L.length;r<q;r+=1){let B=L[r];if(H.maxTotalMergeKeys!==-1&&++H.totalMergeKeys>H.maxTotalMergeKeys)d(H,"merge keys exceeded maxTotalMergeKeys ("+H.maxTotalMergeKeys+")");if(!D.call(Q,B))h$(Q,B,T[B]),j[B]=!0}}function K4(H,Q,T,j,L,r,q,B,x){if(Array.isArray(L)){L=Array.prototype.slice.call(L);for(let E=0,C=L.length;E<C;E+=1){if(Array.isArray(L[E]))d(H,"nested arrays are not supported inside keys");if(typeof L==="object"&&y(L[E])==="[object Object]")L[E]="[object Object]"}}if(typeof L==="object"&&y(L)==="[object Object]")L="[object Object]";if(L=String(L),Q===null)Q={};if(j==="tag:yaml.org,2002:merge")if(Array.isArray(r))for(let E=0,C=r.length;E<C;E+=1)I4(H,Q,r[E],T);else I4(H,Q,r,T);else{if(!H.json&&!D.call(T,L)&&D.call(Q,L))H.line=q||H.line,H.lineStart=B||H.lineStart,H.position=x||H.position,d(H,"duplicated mapping key");h$(Q,L,r),delete T[L]}return Q}function L$(H){let Q=H.input.charCodeAt(H.position);if(Q===10)H.position++;else if(Q===13){if(H.position++,H.input.charCodeAt(H.position)===10)H.position++}else d(H,"a line break is expected");H.line+=1,H.lineStart=H.position,H.firstTabInLine=-1}function I$(H,Q,T){let j=0,L=H.input.charCodeAt(H.position);while(L!==0){while(c(L)){if(L===9&&H.firstTabInLine===-1)H.firstTabInLine=H.position;L=H.input.charCodeAt(++H.position)}if(Q&&L===35)do L=H.input.charCodeAt(++H.position);while(L!==10&&L!==13&&L!==0);if(P$(L)){L$(H),L=H.input.charCodeAt(H.position),j++,H.lineIndent=0;while(L===32)H.lineIndent++,L=H.input.charCodeAt(++H.position)}else break}if(T!==-1&&j!==0&&H.lineIndent<T)v$(H,"deficient indentation");return j}function o$(H){let Q=H.position,T=H.input.charCodeAt(Q);if((T===45||T===46)&&T===H.input.charCodeAt(Q+1)&&T===H.input.charCodeAt(Q+2)){if(Q+=3,T=H.input.charCodeAt(Q),T===0||t(T))return!0}return!1}function l$(H,Q){if(Q===1)H.result+=" ";else if(Q>1)H.result+=$.repeat(`
166
166
  `,Q-1)}function L4(H,Q,T){let j,L,r,q,B,x,E=H.kind,C=H.result,p=H.input.charCodeAt(H.position);if(t(p)||X$(p)||p===35||p===38||p===42||p===33||p===124||p===62||p===39||p===34||p===37||p===64||p===96)return!1;if(p===63||p===45){let m=H.input.charCodeAt(H.position+1);if(t(m)||T&&X$(m))return!1}H.kind="scalar",H.result="",j=L=H.position,r=!1;while(p!==0){if(p===58){let m=H.input.charCodeAt(H.position+1);if(t(m)||T&&X$(m))break}else if(p===35){let m=H.input.charCodeAt(H.position-1);if(t(m))break}else if(H.position===H.lineStart&&o$(H)||T&&X$(p))break;else if(P$(p))if(q=H.line,B=H.lineStart,x=H.lineIndent,I$(H,!1,-1),H.lineIndent>=Q){r=!0,p=H.input.charCodeAt(H.position);continue}else{H.position=L,H.line=q,H.lineStart=B,H.lineIndent=x;break}if(r)C$(H,j,L,!1),l$(H,H.line-q),j=L=H.position,r=!1;if(!c(p))L=H.position+1;p=H.input.charCodeAt(++H.position)}if(C$(H,j,L,!1),H.result)return!0;return H.kind=E,H.result=C,!1}function a4(H,Q){let T,j,L=H.input.charCodeAt(H.position);if(L!==39)return!1;H.kind="scalar",H.result="",H.position++,T=j=H.position;while((L=H.input.charCodeAt(H.position))!==0)if(L===39)if(C$(H,T,H.position,!0),L=H.input.charCodeAt(++H.position),L===39)T=H.position,H.position++,j=H.position;else return!0;else if(P$(L))C$(H,T,j,!0),l$(H,I$(H,!1,Q)),T=j=H.position;else if(H.position===H.lineStart&&o$(H))d(H,"unexpected end of the document within a single quoted scalar");else if(H.position++,!c(L))j=H.position;d(H,"unexpected end of the stream within a single quoted scalar")}function F6(H,Q){let T,j,L,r=H.input.charCodeAt(H.position);if(r!==34)return!1;H.kind="scalar",H.result="",H.position++,T=j=H.position;while((r=H.input.charCodeAt(H.position))!==0)if(r===34)return C$(H,T,H.position,!0),H.position++,!0;else if(r===92){if(C$(H,T,H.position,!0),r=H.input.charCodeAt(++H.position),P$(r))I$(H,!1,Q);else if(r<256&&R$[r])H.result+=e[r],H.position++;else if((L=F$(r))>0){let q=L,B=0;for(;q>0;q--)if(r=H.input.charCodeAt(++H.position),(L=u(r))>=0)B=(B<<4)+L;else d(H,"expected hexadecimal character");H.result+=Q$(B),H.position++}else d(H,"unknown escape sequence");T=j=H.position}else if(P$(r))C$(H,T,j,!0),l$(H,I$(H,!1,Q)),T=j=H.position;else if(H.position===H.lineStart&&o$(H))d(H,"unexpected end of the document within a double quoted scalar");else if(H.position++,!c(r))j=H.position;d(H,"unexpected end of the stream within a double quoted scalar")}function q6(H,Q){let T=!0,j,L,r,q=H.tag,B,x=H.anchor,E,C,p,m,U$=Object.create(null),$$,G$,V$,q$=H.input.charCodeAt(H.position);if(q$===91)E=93,m=!1,B=[];else if(q$===123)E=125,m=!0,B={};else return!1;if(H.anchor!==null)g$(H,H.anchor,B);q$=H.input.charCodeAt(++H.position);while(q$!==0){if(I$(H,!0,Q),q$=H.input.charCodeAt(H.position),q$===E)return H.position++,H.tag=q,H.anchor=x,H.kind=m?"mapping":"sequence",H.result=B,!0;else if(!T)d(H,"missed comma between flow collection entries");else if(q$===44)d(H,"expected the node content, but found ','");if(G$=$$=V$=null,C=p=!1,q$===63){let S$=H.input.charCodeAt(H.position+1);if(t(S$))C=p=!0,H.position++,I$(H,!0,Q)}if(j=H.line,L=H.lineStart,r=H.position,S4(H,Q,V,!1,!0),G$=H.tag,$$=H.result,I$(H,!0,Q),q$=H.input.charCodeAt(H.position),(p||H.line===j)&&q$===58)C=!0,q$=H.input.charCodeAt(++H.position),I$(H,!0,Q),S4(H,Q,V,!1,!0),V$=H.result;if(m)K4(H,B,U$,G$,$$,V$,j,L,r);else if(C)B.push(K4(H,null,U$,G$,$$,V$,j,L,r));else B.push($$);if(I$(H,!0,Q),q$=H.input.charCodeAt(H.position),q$===44)T=!0,q$=H.input.charCodeAt(++H.position);else T=!1}d(H,"unexpected end of the stream within a flow collection")}function R6(H,Q){let T,j=W,L=!1,r=!1,q=Q,B=0,x=!1,E,C=H.input.charCodeAt(H.position);if(C===124)T=!1;else if(C===62)T=!0;else return!1;H.kind="scalar",H.result="";while(C!==0)if(C=H.input.charCodeAt(++H.position),C===43||C===45)if(W===j)j=C===43?K:w;else d(H,"repeat of a chomping mode identifier");else if((E=N$(C))>=0)if(E===0)d(H,"bad explicit indentation width of a block scalar; it cannot be less than one");else if(!r)q=Q+E-1,r=!0;else d(H,"repeat of an indentation width identifier");else break;if(c(C)){do C=H.input.charCodeAt(++H.position);while(c(C));if(C===35)do C=H.input.charCodeAt(++H.position);while(!P$(C)&&C!==0)}while(C!==0){L$(H),H.lineIndent=0,C=H.input.charCodeAt(H.position);while((!r||H.lineIndent<q)&&C===32)H.lineIndent++,C=H.input.charCodeAt(++H.position);if(!r&&H.lineIndent>q)q=H.lineIndent;if(P$(C)){B++;continue}if(!r&&q===0)d(H,"missing indentation for block scalar");if(H.lineIndent<q){if(j===K)H.result+=$.repeat(`
167
167
  `,L?1+B:B);else if(j===W){if(L)H.result+=`
@@ -170,7 +170,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
170
170
  `,B+1);else if(B===0){if(L)H.result+=" "}else H.result+=$.repeat(`
171
171
  `,B);else H.result+=$.repeat(`
172
172
  `,L?1+B:B);L=!0,r=!0,B=0;let p=H.position;while(!P$(C)&&C!==0)C=H.input.charCodeAt(++H.position);C$(H,p,H.position,!1)}return!0}function B4(H,Q){let{tag:T,anchor:j}=H,L=[],r=!1;if(H.firstTabInLine!==-1)return!1;if(H.anchor!==null)g$(H,H.anchor,L);let q=H.input.charCodeAt(H.position);while(q!==0){if(H.firstTabInLine!==-1)H.position=H.firstTabInLine,d(H,"tab characters must not be used in indentation");if(q!==45)break;let B=H.input.charCodeAt(H.position+1);if(!t(B))break;if(r=!0,H.position++,I$(H,!0,-1)){if(H.lineIndent<=Q){L.push(null),q=H.input.charCodeAt(H.position);continue}}let x=H.line;if(S4(H,Q,J,!1,!0),L.push(H.result),I$(H,!0,-1),q=H.input.charCodeAt(H.position),(H.line===x||H.lineIndent>Q)&&q!==0)d(H,"bad indentation of a sequence entry");else if(H.lineIndent<Q)break}if(r)return H.tag=T,H.anchor=j,H.kind="sequence",H.result=L,!0;return!1}function t6(H,Q,T){let j,L,r,q,B=H.tag,x=H.anchor,E={},C=Object.create(null),p=null,m=null,U$=null,$$=!1,G$=!1;if(H.firstTabInLine!==-1)return!1;if(H.anchor!==null)g$(H,H.anchor,E);let V$=H.input.charCodeAt(H.position);while(V$!==0){if(!$$&&H.firstTabInLine!==-1)H.position=H.firstTabInLine,d(H,"tab characters must not be used in indentation");let q$=H.input.charCodeAt(H.position+1),S$=H.line;if((V$===63||V$===58)&&t(q$)){if(V$===63){if($$)K4(H,E,C,p,m,null,L,r,q),p=m=U$=null;G$=!0,$$=!0,j=!0}else if($$)$$=!1,j=!0;else d(H,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");H.position+=1,V$=q$}else{if(L=H.line,r=H.lineStart,q=H.position,!S4(H,T,Z,!1,!0))break;if(H.line===S$){V$=H.input.charCodeAt(H.position);while(c(V$))V$=H.input.charCodeAt(++H.position);if(V$===58){if(V$=H.input.charCodeAt(++H.position),!t(V$))d(H,"a whitespace character is expected after the key-value separator within a block mapping");if($$)K4(H,E,C,p,m,null,L,r,q),p=m=U$=null;G$=!0,$$=!1,j=!1,p=H.tag,m=H.result}else if(G$)d(H,"can not read an implicit mapping pair; a colon is missed");else return H.tag=B,H.anchor=x,!0}else if(G$)d(H,"can not read a block mapping entry; a multiline key may not be an implicit key");else return H.tag=B,H.anchor=x,!0}if(H.line===S$||H.lineIndent>Q){if($$)L=H.line,r=H.lineStart,q=H.position;if(S4(H,Q,Y,!0,j))if($$)m=H.result;else U$=H.result;if(!$$)K4(H,E,C,p,m,U$,L,r,q),p=m=U$=null;I$(H,!0,-1),V$=H.input.charCodeAt(H.position)}if((H.line===S$||H.lineIndent>Q)&&V$!==0)d(H,"bad indentation of a mapping entry");else if(H.lineIndent<Q)break}if($$)K4(H,E,C,p,m,null,L,r,q);if(G$)H.tag=B,H.anchor=x,H.kind="mapping",H.result=E;return G$}function e6(H){let Q=!1,T=!1,j,L,r=H.input.charCodeAt(H.position);if(r!==33)return!1;if(H.tag!==null)d(H,"duplication of a tag property");if(r=H.input.charCodeAt(++H.position),r===60)Q=!0,r=H.input.charCodeAt(++H.position);else if(r===33)T=!0,j="!!",r=H.input.charCodeAt(++H.position);else j="!";let q=H.position;if(Q){do r=H.input.charCodeAt(++H.position);while(r!==0&&r!==62);if(H.position<H.length)L=H.input.slice(q,H.position),r=H.input.charCodeAt(++H.position);else d(H,"unexpected end of the stream within a verbatim tag")}else{while(r!==0&&!t(r)){if(r===33)if(!T){if(j=H.input.slice(q-1,H.position+1),!k.test(j))d(H,"named tag handle cannot contain such characters");T=!0,q=H.position+1}else d(H,"tag suffix cannot contain exclamation marks");r=H.input.charCodeAt(++H.position)}if(L=H.input.slice(q,H.position),v.test(L))d(H,"tag suffix cannot contain flow indicator characters")}if(L&&!b.test(L))d(H,"tag name cannot contain such characters: "+L);try{L=decodeURIComponent(L)}catch(B){d(H,"tag name is malformed: "+L)}if(Q)H.tag=L;else if(D.call(H.tagMap,j))H.tag=H.tagMap[j]+L;else if(j==="!")H.tag="!"+L;else if(j==="!!")H.tag="tag:yaml.org,2002:"+L;else d(H,'undeclared tag handle "'+j+'"');return!0}function N6(H){let Q=H.input.charCodeAt(H.position);if(Q!==38)return!1;if(H.anchor!==null)d(H,"duplication of an anchor property");Q=H.input.charCodeAt(++H.position);let T=H.position;while(Q!==0&&!t(Q)&&!X$(Q))Q=H.input.charCodeAt(++H.position);if(H.position===T)d(H,"name of an anchor node must contain at least one character");return H.anchor=H.input.slice(T,H.position),!0}function $1(H){let Q=H.input.charCodeAt(H.position);if(Q!==42)return!1;Q=H.input.charCodeAt(++H.position);let T=H.position;while(Q!==0&&!t(Q)&&!X$(Q))Q=H.input.charCodeAt(++H.position);if(H.position===T)d(H,"name of an alias node must contain at least one character");let j=H.input.slice(T,H.position);if(!D.call(H.anchorMap,j))d(H,'unidentified alias "'+j+'"');return H.result=H.anchorMap[j],I$(H,!0,-1),!0}function XU(H,Q,T,j){let L=U4(H);if(w4(H),M(H,Q),H.tag=null,H.anchor=null,H.kind=null,H.result=null,t6(H,T,j)&&H.kind==="mapping")return N(H),!0;return d$(H),M(H,L),!1}function S4(H,Q,T,j,L){let r,q,B=1,x=!1,E=!1,C=null,p,m,U$;if(H.depth>=H.maxDepth)d(H,"nesting exceeded maxDepth ("+H.maxDepth+")");if(H.depth+=1,H.listener!==null)H.listener("open",H);H.tag=null,H.anchor=null,H.kind=null,H.result=null;let $$=r=q=Y===T||J===T;if(j){if(I$(H,!0,-1)){if(x=!0,H.lineIndent>Q)B=1;else if(H.lineIndent===Q)B=0;else if(H.lineIndent<Q)B=-1}}if(B===1)while(!0){let G$=H.input.charCodeAt(H.position),V$=U4(H);if(x&&(G$===33&&H.tag!==null||G$===38&&H.anchor!==null))break;if(!e6(H)&&!N6(H))break;if(C===null)C=V$;if(I$(H,!0,-1)){if(x=!0,q=$$,H.lineIndent>Q)B=1;else if(H.lineIndent===Q)B=0;else if(H.lineIndent<Q)B=-1}else q=!1}if(q)q=x||L;if(B===1||Y===T){if(V===T||Z===T)m=Q;else m=Q+1;if(U$=H.position-H.lineStart,B===1)if(q&&(B4(H,U$)||t6(H,U$,m))||q6(H,m))E=!0;else{let G$=H.input.charCodeAt(H.position);if(C!==null&&$$&&!q&&G$!==124&&G$!==62&&XU(H,C,C.position-C.lineStart,m))E=!0;else if(r&&R6(H,m)||a4(H,m)||F6(H,m))E=!0;else if($1(H)){if(E=!0,H.tag!==null||H.anchor!==null)d(H,"alias node should not have any properties")}else if(L4(H,m,V===T)){if(E=!0,H.tag===null)H.tag="?"}if(H.anchor!==null)g$(H,H.anchor,H.result)}else if(B===0)E=q&&B4(H,U$)}if(H.tag===null){if(H.anchor!==null)g$(H,H.anchor,H.result)}else if(H.tag==="?"){if(H.result!==null&&H.kind!=="scalar")d(H,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+H.kind+'"');for(let G$=0,V$=H.implicitTypes.length;G$<V$;G$+=1)if(p=H.implicitTypes[G$],p.resolve(H.result)){if(H.result=p.construct(H.result),H.tag=p.tag,H.anchor!==null)g$(H,H.anchor,H.result);break}}else if(H.tag!=="!"){if(D.call(H.typeMap[H.kind||"fallback"],H.tag))p=H.typeMap[H.kind||"fallback"][H.tag];else{p=null;let G$=H.typeMap.multi[H.kind||"fallback"];for(let V$=0,q$=G$.length;V$<q$;V$+=1)if(H.tag.slice(0,G$[V$].tag.length)===G$[V$].tag){p=G$[V$];break}}if(!p)d(H,"unknown tag !<"+H.tag+">");if(H.result!==null&&p.kind!==H.kind)d(H,"unacceptable node kind for !<"+H.tag+'> tag; it should be "'+p.kind+'", not "'+H.kind+'"');if(!p.resolve(H.result,H.tag))d(H,"cannot resolve a node with !<"+H.tag+"> explicit tag");else if(H.result=p.construct(H.result,H.tag),H.anchor!==null)g$(H,H.anchor,H.result)}if(H.listener!==null)H.listener("close",H);return H.depth-=1,H.tag!==null||H.anchor!==null||E}function VU(H){let Q=H.position,T=!1,j;H.version=null,H.checkLineBreaks=H.legacy,H.tagMap=Object.create(null),H.anchorMap=Object.create(null);while((j=H.input.charCodeAt(H.position))!==0){if(I$(H,!0,-1),j=H.input.charCodeAt(H.position),H.lineIndent>0||j!==37)break;T=!0,j=H.input.charCodeAt(++H.position);let L=H.position;while(j!==0&&!t(j))j=H.input.charCodeAt(++H.position);let r=H.input.slice(L,H.position),q=[];if(r.length<1)d(H,"directive name must not be less than one character in length");while(j!==0){while(c(j))j=H.input.charCodeAt(++H.position);if(j===35){do j=H.input.charCodeAt(++H.position);while(j!==0&&!P$(j));break}if(P$(j))break;L=H.position;while(j!==0&&!t(j))j=H.input.charCodeAt(++H.position);q.push(H.input.slice(L,H.position))}if(j!==0)L$(H);if(D.call(m$,r))m$[r](H,r,q);else v$(H,'unknown document directive "'+r+'"')}if(I$(H,!0,-1),H.lineIndent===0&&H.input.charCodeAt(H.position)===45&&H.input.charCodeAt(H.position+1)===45&&H.input.charCodeAt(H.position+2)===45)H.position+=3,I$(H,!0,-1);else if(T)d(H,"directives end mark is expected");if(S4(H,H.lineIndent-1,Y,!1,!0),I$(H,!0,-1),H.checkLineBreaks&&O.test(H.input.slice(Q,H.position)))v$(H,"non-ASCII line breaks are interpreted as content");if(H.documents.push(H.result),H.position===H.lineStart&&o$(H)){if(H.input.charCodeAt(H.position)===46)H.position+=3,I$(H,!0,-1);return}if(H.position<H.length-1)d(H,"end of the stream or a document separator is expected")}function U1(H,Q){if(H=String(H),Q=Q||{},H.length!==0){if(H.charCodeAt(H.length-1)!==10&&H.charCodeAt(H.length-1)!==13)H+=`
173
- `;if(H.charCodeAt(0)===65279)H=H.slice(1)}let T=new D$(H,Q),j=H.indexOf("\x00");if(j!==-1)T.position=j,d(T,"null byte is not allowed in input");T.input+="\x00";while(T.input.charCodeAt(T.position)===32)T.lineIndent+=1,T.position+=1;while(T.position<T.length-1)VU(T);return T.documents}function S(H,Q,T){if(Q!==null&&typeof Q==="object"&&typeof T>"u")T=Q,Q=null;let j=U1(H,T);if(typeof Q!=="function")return j;for(let L=0,r=j.length;L<r;L+=1)Q(j[L])}function g(H,Q){let T=U1(H,Q);if(T.length===0)return;else if(T.length===1)return T[0];throw new U("expected a single document in the stream, but found more")}return k0.loadAll=S,k0.load=g,k0}var rZ={},Rw;function jQ(){if(Rw)return rZ;Rw=1;let $=eU(),U=$D(),G=hZ(),X=Object.prototype.toString,D=Object.prototype.hasOwnProperty,V=65279,Z=9,J=10,Y=13,W=32,w=33,K=34,A=35,O=37,v=38,k=39,b=42,y=44,P$=45,c=58,t=61,X$=62,u=63,F$=64,N$=91,_$=93,Q$=96,h$=123,R$=124,e=125,D$={};D$[0]="\\0",D$[7]="\\a",D$[8]="\\b",D$[9]="\\t",D$[10]="\\n",D$[11]="\\v",D$[12]="\\f",D$[13]="\\r",D$[27]="\\e",D$[34]="\\\"",D$[92]="\\\\",D$[133]="\\N",D$[160]="\\_",D$[8232]="\\L",D$[8233]="\\P";let H$=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],d=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function v$(q,B){if(B===null)return{};let x={},E=Object.keys(B);for(let C=0,p=E.length;C<p;C+=1){let m=E[C],U$=String(B[m]);if(m.slice(0,2)==="!!")m="tag:yaml.org,2002:"+m.slice(2);let $$=q.compiledTypeMap.fallback[m];if($$&&D.call($$.styleAliases,U$))U$=$$.styleAliases[U$];x[m]=U$}return x}function g$(q){let B,x,E=q.toString(16).toUpperCase();if(q<=255)B="x",x=2;else if(q<=65535)B="u",x=4;else if(q<=4294967295)B="U",x=8;else throw new U("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+B+$.repeat("0",x-E.length)+E}let w4=1,N=2;function d$(q){this.schema=q.schema||G,this.indent=Math.max(1,q.indent||2),this.noArrayIndent=q.noArrayIndent||!1,this.skipInvalid=q.skipInvalid||!1,this.flowLevel=$.isNothing(q.flowLevel)?-1:q.flowLevel,this.styleMap=v$(this.schema,q.styles||null),this.sortKeys=q.sortKeys||!1,this.lineWidth=q.lineWidth||80,this.noRefs=q.noRefs||!1,this.noCompatMode=q.noCompatMode||!1,this.condenseFlow=q.condenseFlow||!1,this.quotingType=q.quotingType==='"'?N:w4,this.forceQuotes=q.forceQuotes||!1,this.replacer=typeof q.replacer==="function"?q.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function U4(q,B){let x=$.repeat(" ",B),E=0,C="",p=q.length;while(E<p){let m,U$=q.indexOf(`
173
+ `;if(H.charCodeAt(0)===65279)H=H.slice(1)}let T=new D$(H,Q),j=H.indexOf("\x00");if(j!==-1)T.position=j,d(T,"null byte is not allowed in input");T.input+="\x00";while(T.input.charCodeAt(T.position)===32)T.lineIndent+=1,T.position+=1;while(T.position<T.length-1)VU(T);return T.documents}function S(H,Q,T){if(Q!==null&&typeof Q==="object"&&typeof T>"u")T=Q,Q=null;let j=U1(H,T);if(typeof Q!=="function")return j;for(let L=0,r=j.length;L<r;L+=1)Q(j[L])}function g(H,Q){let T=U1(H,Q);if(T.length===0)return;else if(T.length===1)return T[0];throw new U("expected a single document in the stream, but found more")}return k0.loadAll=S,k0.load=g,k0}var rZ={},R3;function jQ(){if(R3)return rZ;R3=1;let $=eU(),U=$D(),G=hZ(),X=Object.prototype.toString,D=Object.prototype.hasOwnProperty,V=65279,Z=9,J=10,Y=13,W=32,w=33,K=34,A=35,O=37,v=38,k=39,b=42,y=44,P$=45,c=58,t=61,X$=62,u=63,F$=64,N$=91,_$=93,Q$=96,h$=123,R$=124,e=125,D$={};D$[0]="\\0",D$[7]="\\a",D$[8]="\\b",D$[9]="\\t",D$[10]="\\n",D$[11]="\\v",D$[12]="\\f",D$[13]="\\r",D$[27]="\\e",D$[34]="\\\"",D$[92]="\\\\",D$[133]="\\N",D$[160]="\\_",D$[8232]="\\L",D$[8233]="\\P";let H$=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],d=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function v$(q,B){if(B===null)return{};let x={},E=Object.keys(B);for(let C=0,p=E.length;C<p;C+=1){let m=E[C],U$=String(B[m]);if(m.slice(0,2)==="!!")m="tag:yaml.org,2002:"+m.slice(2);let $$=q.compiledTypeMap.fallback[m];if($$&&D.call($$.styleAliases,U$))U$=$$.styleAliases[U$];x[m]=U$}return x}function g$(q){let B,x,E=q.toString(16).toUpperCase();if(q<=255)B="x",x=2;else if(q<=65535)B="u",x=4;else if(q<=4294967295)B="U",x=8;else throw new U("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+B+$.repeat("0",x-E.length)+E}let w4=1,N=2;function d$(q){this.schema=q.schema||G,this.indent=Math.max(1,q.indent||2),this.noArrayIndent=q.noArrayIndent||!1,this.skipInvalid=q.skipInvalid||!1,this.flowLevel=$.isNothing(q.flowLevel)?-1:q.flowLevel,this.styleMap=v$(this.schema,q.styles||null),this.sortKeys=q.sortKeys||!1,this.lineWidth=q.lineWidth||80,this.noRefs=q.noRefs||!1,this.noCompatMode=q.noCompatMode||!1,this.condenseFlow=q.condenseFlow||!1,this.quotingType=q.quotingType==='"'?N:w4,this.forceQuotes=q.forceQuotes||!1,this.replacer=typeof q.replacer==="function"?q.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function U4(q,B){let x=$.repeat(" ",B),E=0,C="",p=q.length;while(E<p){let m,U$=q.indexOf(`
174
174
  `,E);if(U$===-1)m=q.slice(E),E=p;else m=q.slice(E,U$+1),E=U$+1;if(m.length&&m!==`
175
175
  `)C+=x;C+=m}return C}function M(q,B){return`
176
176
  `+$.repeat(" ",q.indent*B)}function m$(q,B){for(let x=0,E=q.implicitTypes.length;x<E;x+=1)if(q.implicitTypes[x].resolve(B))return!0;return!1}function C$(q){return q===W||q===Z}function I4(q){return q>=32&&q<=126||q>=161&&q<=55295&&q!==8232&&q!==8233||q>=57344&&q<=65533&&q!==V||q>=65536&&q<=1114111}function K4(q){return I4(q)&&q!==V&&q!==Y&&q!==J}function L$(q,B,x){let E=K4(q),C=E&&!C$(q);return(x?E:E&&q!==y&&q!==N$&&q!==_$&&q!==h$&&q!==e)&&q!==A&&!(B===c&&!C)||K4(B)&&!C$(B)&&q===A||B===c&&C}function I$(q){return I4(q)&&q!==V&&!C$(q)&&q!==P$&&q!==u&&q!==c&&q!==y&&q!==N$&&q!==_$&&q!==h$&&q!==e&&q!==A&&q!==v&&q!==b&&q!==w&&q!==R$&&q!==t&&q!==X$&&q!==k&&q!==K&&q!==O&&q!==F$&&q!==Q$}function o$(q){return!C$(q)&&q!==c}function l$(q,B){let x=q.charCodeAt(B),E;if(x>=55296&&x<=56319&&B+1<q.length){if(E=q.charCodeAt(B+1),E>=56320&&E<=57343)return(x-55296)*1024+E-56320+65536}return x}function L4(q){return/^\n* /.test(q)}let a4=1,F6=2,q6=3,R6=4,B4=5;function t6(q,B,x,E,C,p,m,U$){let $$,G$=0,V$=null,q$=!1,S$=!1,iJ=E!==-1,ZU=-1,JU=I$(l$(q,0))&&o$(l$(q,q.length-1));if(B||m)for($$=0;$$<q.length;G$>=65536?$$+=2:$$++){if(G$=l$(q,$$),!I4(G$))return B4;JU=JU&&L$(G$,V$,U$),V$=G$}else{for($$=0;$$<q.length;G$>=65536?$$+=2:$$++){if(G$=l$(q,$$),G$===J){if(q$=!0,iJ)S$=S$||$$-ZU-1>E&&q[ZU+1]!==" ",ZU=$$}else if(!I4(G$))return B4;JU=JU&&L$(G$,V$,U$),V$=G$}S$=S$||iJ&&($$-ZU-1>E&&q[ZU+1]!==" ")}if(!q$&&!S$){if(JU&&!m&&!C(q))return a4;return p===N?B4:F6}if(x>9&&L4(q))return B4;if(!m)return S$?R6:q6;return p===N?B4:F6}function e6(q,B,x,E,C){q.dump=function(){if(B.length===0)return q.quotingType===N?'""':"''";if(!q.noCompatMode){if(H$.indexOf(B)!==-1||d.test(B))return q.quotingType===N?'"'+B+'"':"'"+B+"'"}let p=q.indent*Math.max(1,x),m=q.lineWidth===-1?-1:Math.max(Math.min(q.lineWidth,40),q.lineWidth-p),U$=E||q.flowLevel>-1&&x>=q.flowLevel;function $$(G$){return m$(q,G$)}switch(t6(B,U$,q.indent,m,$$,q.quotingType,q.forceQuotes&&!E,C)){case a4:return B;case F6:return"'"+B.replace(/'/g,"''")+"'";case q6:return"|"+N6(B,q.indent)+$1(U4(B,p));case R6:return">"+N6(B,q.indent)+$1(U4(XU(B,m),p));case B4:return'"'+VU(B)+'"';default:throw new U("impossible error: invalid scalar style")}}()}function N6(q,B){let x=L4(q)?String(B):"",E=q[q.length-1]===`
@@ -185,7 +185,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
185
185
  `+q.slice(C,p),C=p+1;m=U$}if($$+=`
186
186
  `,q.length-C>B&&m>C)$$+=q.slice(C,m)+`
187
187
  `+q.slice(m+1);else $$+=q.slice(C);return $$.slice(1)}function VU(q){let B="",x=0;for(let E=0;E<q.length;x>=65536?E+=2:E++){x=l$(q,E);let C=D$[x];if(!C&&I4(x)){if(B+=q[E],x>=65536)B+=q[E+1]}else B+=C||g$(x)}return B}function U1(q,B,x){let E="",C=q.tag;for(let p=0,m=x.length;p<m;p+=1){let U$=x[p];if(q.replacer)U$=q.replacer.call(x,String(p),U$);if(T(q,B,U$,!1,!1)||typeof U$>"u"&&T(q,B,null,!1,!1)){if(E!=="")E+=","+(!q.condenseFlow?" ":"");E+=q.dump}}q.tag=C,q.dump="["+E+"]"}function S(q,B,x,E){let C="",p=q.tag;for(let m=0,U$=x.length;m<U$;m+=1){let $$=x[m];if(q.replacer)$$=q.replacer.call(x,String(m),$$);if(T(q,B+1,$$,!0,!0,!1,!0)||typeof $$>"u"&&T(q,B+1,null,!0,!0,!1,!0)){if(!E||C!=="")C+=M(q,B);if(q.dump&&J===q.dump.charCodeAt(0))C+="-";else C+="- ";C+=q.dump}}q.tag=p,q.dump=C||"[]"}function g(q,B,x){let E="",C=q.tag,p=Object.keys(x);for(let m=0,U$=p.length;m<U$;m+=1){let $$="";if(E!=="")$$+=", ";if(q.condenseFlow)$$+='"';let G$=p[m],V$=x[G$];if(q.replacer)V$=q.replacer.call(x,G$,V$);if(!T(q,B,G$,!1,!1))continue;if(q.dump.length>1024)$$+="? ";if($$+=q.dump+(q.condenseFlow?'"':"")+":"+(q.condenseFlow?"":" "),!T(q,B,V$,!1,!1))continue;$$+=q.dump,E+=$$}q.tag=C,q.dump="{"+E+"}"}function H(q,B,x,E){let C="",p=q.tag,m=Object.keys(x);if(q.sortKeys===!0)m.sort();else if(typeof q.sortKeys==="function")m.sort(q.sortKeys);else if(q.sortKeys)throw new U("sortKeys must be a boolean or a function");for(let U$=0,$$=m.length;U$<$$;U$+=1){let G$="";if(!E||C!=="")G$+=M(q,B);let V$=m[U$],q$=x[V$];if(q.replacer)q$=q.replacer.call(x,V$,q$);if(!T(q,B+1,V$,!0,!0,!0))continue;let S$=q.tag!==null&&q.tag!=="?"||q.dump&&q.dump.length>1024;if(S$)if(q.dump&&J===q.dump.charCodeAt(0))G$+="?";else G$+="? ";if(G$+=q.dump,S$)G$+=M(q,B);if(!T(q,B+1,q$,!0,S$))continue;if(q.dump&&J===q.dump.charCodeAt(0))G$+=":";else G$+=": ";G$+=q.dump,C+=G$}q.tag=p,q.dump=C||"{}"}function Q(q,B,x){let E=x?q.explicitTypes:q.implicitTypes;for(let C=0,p=E.length;C<p;C+=1){let m=E[C];if((m.instanceOf||m.predicate)&&(!m.instanceOf||typeof B==="object"&&B instanceof m.instanceOf)&&(!m.predicate||m.predicate(B))){if(x)if(m.multi&&m.representName)q.tag=m.representName(B);else q.tag=m.tag;else q.tag="?";if(m.represent){let U$=q.styleMap[m.tag]||m.defaultStyle,$$;if(X.call(m.represent)==="[object Function]")$$=m.represent(B,U$);else if(D.call(m.represent,U$))$$=m.represent[U$](B,U$);else throw new U("!<"+m.tag+'> tag resolver accepts not "'+U$+'" style');q.dump=$$}return!0}}return!1}function T(q,B,x,E,C,p,m){if(q.tag=null,q.dump=x,!Q(q,x,!1))Q(q,x,!0);let U$=X.call(q.dump),$$=E;if(E)E=q.flowLevel<0||q.flowLevel>B;let G$=U$==="[object Object]"||U$==="[object Array]",V$,q$;if(G$)V$=q.duplicates.indexOf(x),q$=V$!==-1;if(q.tag!==null&&q.tag!=="?"||q$||q.indent!==2&&B>0)C=!1;if(q$&&q.usedDuplicates[V$])q.dump="*ref_"+V$;else{if(G$&&q$&&!q.usedDuplicates[V$])q.usedDuplicates[V$]=!0;if(U$==="[object Object]"){if(E&&Object.keys(q.dump).length!==0){if(H(q,B,q.dump,C),q$)q.dump="&ref_"+V$+q.dump}else if(g(q,B,q.dump),q$)q.dump="&ref_"+V$+" "+q.dump}else if(U$==="[object Array]"){if(E&&q.dump.length!==0){if(q.noArrayIndent&&!m&&B>0)S(q,B-1,q.dump,C);else S(q,B,q.dump,C);if(q$)q.dump="&ref_"+V$+q.dump}else if(U1(q,B,q.dump),q$)q.dump="&ref_"+V$+" "+q.dump}else if(U$==="[object String]"){if(q.tag!=="?")e6(q,q.dump,B,p,$$)}else if(U$==="[object Undefined]")return!1;else{if(q.skipInvalid)return!1;throw new U("unacceptable kind of an object to dump "+U$)}if(q.tag!==null&&q.tag!=="?"){let S$=encodeURI(q.tag[0]==="!"?q.tag.slice(1):q.tag).replace(/!/g,"%21");if(q.tag[0]==="!")S$="!"+S$;else if(S$.slice(0,18)==="tag:yaml.org,2002:")S$="!!"+S$.slice(18);else S$="!<"+S$+">";q.dump=S$+" "+q.dump}}return!0}function j(q,B){let x=[],E=[];L(q,x,E);let C=E.length;for(let p=0;p<C;p+=1)B.duplicates.push(x[E[p]]);B.usedDuplicates=Array(C)}function L(q,B,x){if(q!==null&&typeof q==="object"){let E=B.indexOf(q);if(E!==-1){if(x.indexOf(E)===-1)x.push(E)}else if(B.push(q),Array.isArray(q))for(let C=0,p=q.length;C<p;C+=1)L(q[C],B,x);else{let C=Object.keys(q);for(let p=0,m=C.length;p<m;p+=1)L(q[C[p]],B,x)}}}function r(q,B){B=B||{};let x=new d$(B);if(!x.noRefs)j(q,x);let E=q;if(x.replacer)E=x.replacer.call({"":E},"",E);if(T(x,0,E,!0,!0))return x.dump+`
188
- `;return""}return rZ.dump=r,rZ}var Nw;function EQ(){if(Nw)return e$;Nw=1;let $=gQ(),U=jQ();function G(X,D){return function(){throw Error("Function yaml."+X+" is removed in js-yaml 4. Use yaml."+D+" instead, which is now safe by default.")}}return e$.Type=P4(),e$.Schema=Mw(),e$.FAILSAFE_SCHEMA=Tw(),e$.JSON_SCHEMA=gw(),e$.CORE_SCHEMA=jw(),e$.DEFAULT_SCHEMA=hZ(),e$.load=$.load,e$.loadAll=$.loadAll,e$.dump=U.dump,e$.YAMLException=$D(),e$.types={binary:kw(),float:Sw(),map:Bw(),null:zw(),pairs:bw(),set:uw(),timestamp:Ew(),bool:vw(),int:Lw(),merge:Cw(),omap:xw(),seq:Iw(),str:Qw()},e$.safeLoad=G("safeLoad","load"),e$.safeLoadAll=G("safeLoadAll","loadAll"),e$.safeDump=G("safeDump","dump"),e$}var Ay=EQ();var Fy=P.record(P.string(),P.unknown());var py=P.object({slug:P.string(),title:P.string(),type:P.string(),entityId:P.string(),contentHash:P.string()});function mZ($){return`preview.${$.trim().replace(/^https?:\/\//,"")}`}var CQ=P.string(),kQ=P.looseObject({id:P.string().min(1)}),xQ=P.looseObject({label:P.string().min(1)}),bQ=P.looseObject({layouts:P.record(P.string(),P.unknown()),plugin:P.custom(($)=>typeof $==="function").optional(),routes:P.array(kQ),entityDisplay:P.record(P.string(),xQ),content:P.unknown().optional(),themeOverride:P.string().optional(),headScripts:P.array(P.string()).optional(),staticAssets:P.record(P.string(),P.string()).optional()}),uQ=P.custom(($)=>bQ.safeParse($).success);import{webcrypto as mw}from"crypto";var hw="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var rQ=128,w6,p1;function hQ($){if($<0)throw RangeError("Wrong ID size");try{if(!w6||w6.length<$)w6=Buffer.allocUnsafe($*rQ),mw.getRandomValues(w6),p1=0;else if(p1+$>w6.length)mw.getRandomValues(w6),p1=0}catch(U){throw w6=void 0,U}p1+=$}function yw($=21){hQ($|=0);let U="";for(let G=p1-$;G<p1;G++)U+=hw[w6[G]&63];return U}function l6($=12){return yw($)}var yZ=P.enum(["file_operations","content_operations","data_processing","batch_processing"]),mQ=P.object({pluginId:P.string().optional(),progressToken:P.union([P.string(),P.number()]).optional(),operationType:yZ,operationTarget:P.string().optional(),interfaceType:P.string().optional(),conversationId:P.string().optional(),channelId:P.string().optional(),silent:P.boolean().optional()}),l1=P.object({pluginId:P.string().optional(),progressToken:P.union([P.string(),P.number()]).optional(),operationType:yZ,operationTarget:P.string().optional(),interfaceType:P.string().optional(),conversationId:P.string().optional(),channelId:P.string().optional(),silent:P.boolean().optional(),rootJobId:P.string()}),Ef=P.enum(["none","skip","replace","coalesce"]);var fZ=P.enum(["pending","processing","completed","failed"]),fw=P.enum(["completed","failed"]);var yQ=P.object({id:P.string(),type:P.string(),status:fZ,data:P.unknown(),result:P.unknown().optional(),lastError:P.string().optional().nullable(),attempts:P.number(),maxRetries:P.number(),priority:P.number(),createdAt:P.date(),updatedAt:P.date(),processedAt:P.date().optional().nullable(),completedAt:P.date().optional().nullable(),failedAt:P.date().optional().nullable()}),fQ=P.object({jobId:P.string(),type:P.string(),status:fw,result:P.unknown().optional(),error:P.string().optional()}),pw=P.object({success:P.literal(!1),error:P.string().optional()}),pZ=P.object({id:P.string(),type:P.enum(["job","batch"]),status:fZ,message:P.string().optional(),progress:P.object({current:P.number(),total:P.number(),percentage:P.number()}).optional(),aggregationKey:P.string().optional(),batchDetails:P.object({totalOperations:P.number(),completedOperations:P.number(),failedOperations:P.number(),currentOperation:P.string().optional(),errors:P.array(P.string()).optional()}).optional(),jobDetails:P.object({jobType:P.string(),priority:P.number(),retryCount:P.number()}).optional(),metadata:l1});import{createClient as Bl}from"@libsql/client";var a=Symbol.for("drizzle:entityKind");function W4($,U){if(!$||typeof $!=="object")return!1;if($ instanceof U)return!0;if(!Object.prototype.hasOwnProperty.call(U,a))throw Error(`Class "${U.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let G=Object.getPrototypeOf($).constructor;if(G)while(G){if(a in G&&G[a]===U[a])return!0;G=Object.getPrototypeOf(G)}return!1}class K6{constructor($,U){this.table=$,this.config=U,this.name=U.name,this.keyAsName=U.keyAsName,this.notNull=U.notNull,this.default=U.default,this.defaultFn=U.defaultFn,this.onUpdateFn=U.onUpdateFn,this.hasDefault=U.hasDefault,this.primary=U.primaryKey,this.isUnique=U.isUnique,this.uniqueName=U.uniqueName,this.uniqueType=U.uniqueType,this.dataType=U.dataType,this.columnType=U.columnType,this.generated=U.generated,this.generatedIdentity=U.generatedIdentity}static[a]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue($){return $}mapToDriverValue($){return $}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}class lZ{static[a]="ColumnBuilder";config;constructor($,U,G){this.config={name:$,keyAsName:$==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:U,columnType:G,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default($){return this.config.default=$,this.config.hasDefault=!0,this}$defaultFn($){return this.config.defaultFn=$,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn($){return this.config.onUpdateFn=$,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName($){if(this.config.name!=="")return;this.config.name=$}}var E4=Symbol.for("drizzle:Name");function lw($,...U){return $(...U)}function iw($,U){return`${$[E4]}_${U.join("_")}_unique`}class UD extends K6{constructor($,U){if(!U.uniqueName)U.uniqueName=iw($,[U.name]);super($,U);this.table=$}static[a]="PgColumn"}class pQ extends UD{static[a]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op($){return this.indexConfig.opClass=$,this}}class lQ extends UD{static[a]="PgEnumObjectColumn";enum;enumValues=this.config.enum.enumValues;constructor($,U){super($,U);this.enum=U.enum}getSQLType(){return this.enum.enumName}}var nw=Symbol.for("drizzle:isPgEnum");function cw($){return!!$&&typeof $==="function"&&nw in $&&$[nw]===!0}class iQ extends UD{static[a]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor($,U){super($,U);this.enum=U.enum}getSQLType(){return this.enum.enumName}}class x0{static[a]="Subquery";constructor($,U,G,X=!1,D=[]){this._={brand:"Subquery",sql:$,selectedFields:U,alias:G,isWith:X,usedTables:D}}}var dw="0.45.2";var iZ,nZ,ow={startActiveSpan($,U){if(!iZ)return U();if(!nZ)nZ=iZ.trace.getTracer("drizzle-orm",dw);return lw((G,X)=>X.startActiveSpan($,(D)=>{try{return U(D)}catch(V){throw D.setStatus({code:G.SpanStatusCode.ERROR,message:V instanceof Error?V.message:"Unknown error"}),V}finally{D.end()}}),iZ,nZ)}};var i1=Symbol.for("drizzle:ViewBaseConfig");var cZ=Symbol.for("drizzle:Schema"),aw=Symbol.for("drizzle:Columns"),sw=Symbol.for("drizzle:ExtraConfigColumns"),dZ=Symbol.for("drizzle:OriginalName"),oZ=Symbol.for("drizzle:BaseName"),DD=Symbol.for("drizzle:IsAlias"),tw=Symbol.for("drizzle:ExtraConfigBuilder"),nQ=Symbol.for("drizzle:IsDrizzleTable");class x${static[a]="Table";static Symbol={Name:E4,Schema:cZ,OriginalName:dZ,Columns:aw,ExtraConfigColumns:sw,BaseName:oZ,IsAlias:DD,ExtraConfigBuilder:tw};[E4];[dZ];[cZ];[aw];[sw];[oZ];[DD]=!1;[nQ]=!0;[tw]=void 0;constructor($,U,G){this[E4]=this[dZ]=$,this[cZ]=U,this[oZ]=G}}function cQ($){return $!==null&&$!==void 0&&typeof $.getSQL==="function"}function dQ($){let U={sql:"",params:[]};for(let G of $)if(U.sql+=G.sql,U.params.push(...G.params),G.typings?.length){if(!U.typings)U.typings=[];U.typings.push(...G.typings)}return U}class v4{static[a]="StringChunk";value;constructor($){this.value=Array.isArray($)?$:[$]}getSQL(){return new b$([this])}}class b${constructor($){this.queryChunks=$;for(let U of $)if(W4(U,x$)){let G=U[x$.Symbol.Schema];this.usedTables.push(G===void 0?U[x$.Symbol.Name]:G+"."+U[x$.Symbol.Name])}}static[a]="SQL";decoder=ew;shouldInlineParams=!1;usedTables=[];append($){return this.queryChunks.push(...$.queryChunks),this}toQuery($){return ow.startActiveSpan("drizzle.buildSQL",(U)=>{let G=this.buildQueryFromSourceParams(this.queryChunks,$);return U?.setAttributes({"drizzle.query.text":G.sql,"drizzle.query.params":JSON.stringify(G.params)}),G})}buildQueryFromSourceParams($,U){let G=Object.assign({},U,{inlineParams:U.inlineParams||this.shouldInlineParams,paramStartIndex:U.paramStartIndex||{value:0}}),{casing:X,escapeName:D,escapeParam:V,prepareTyping:Z,inlineParams:J,paramStartIndex:Y}=G;return dQ($.map((W)=>{if(W4(W,v4))return{sql:W.value.join(""),params:[]};if(W4(W,b0))return{sql:D(W.value),params:[]};if(W===void 0)return{sql:"",params:[]};if(Array.isArray(W)){let w=[new v4("(")];for(let[K,A]of W.entries())if(w.push(A),K<W.length-1)w.push(new v4(", "));return w.push(new v4(")")),this.buildQueryFromSourceParams(w,G)}if(W4(W,b$))return this.buildQueryFromSourceParams(W.queryChunks,{...G,inlineParams:J||W.shouldInlineParams});if(W4(W,x$)){let w=W[x$.Symbol.Schema],K=W[x$.Symbol.Name];return{sql:w===void 0||W[DD]?D(K):D(w)+"."+D(K),params:[]}}if(W4(W,K6)){let w=X.getColumnCasing(W);if(U.invokeSource==="indexes")return{sql:D(w),params:[]};let K=W.table[x$.Symbol.Schema];return{sql:W.table[DD]||K===void 0?D(W.table[x$.Symbol.Name])+"."+D(w):D(K)+"."+D(W.table[x$.Symbol.Name])+"."+D(w),params:[]}}if(W4(W,U3)){let w=W[i1].schema,K=W[i1].name;return{sql:w===void 0||W[i1].isAlias?D(K):D(w)+"."+D(K),params:[]}}if(W4(W,aZ)){if(W4(W.value,u0))return{sql:V(Y.value++,W),params:[W],typings:["none"]};let w=W.value===null?null:W.encoder.mapToDriverValue(W.value);if(W4(w,b$))return this.buildQueryFromSourceParams([w],G);if(J)return{sql:this.mapInlineParam(w,G),params:[]};let K=["none"];if(Z)K=[Z(W.encoder)];return{sql:V(Y.value++,w),params:[w],typings:K}}if(W4(W,u0))return{sql:V(Y.value++,W),params:[W],typings:["none"]};if(W4(W,b$.Aliased)&&W.fieldAlias!==void 0)return{sql:D(W.fieldAlias),params:[]};if(W4(W,x0)){if(W._.isWith)return{sql:D(W._.alias),params:[]};return this.buildQueryFromSourceParams([new v4("("),W._.sql,new v4(") "),new b0(W._.alias)],G)}if(cw(W)){if(W.schema)return{sql:D(W.schema)+"."+D(W.enumName),params:[]};return{sql:D(W.enumName),params:[]}}if(cQ(W)){if(W.shouldOmitSQLParens?.())return this.buildQueryFromSourceParams([W.getSQL()],G);return this.buildQueryFromSourceParams([new v4("("),W.getSQL(),new v4(")")],G)}if(J)return{sql:this.mapInlineParam(W,G),params:[]};return{sql:V(Y.value++,W),params:[W],typings:["none"]}}))}mapInlineParam($,{escapeString:U}){if($===null)return"null";if(typeof $==="number"||typeof $==="boolean")return $.toString();if(typeof $==="string")return U($);if(typeof $==="object"){let G=$.toString();if(G==="[object Object]")return U(JSON.stringify($));return U(G)}throw Error("Unexpected param value: "+$)}getSQL(){return this}as($){if($===void 0)return this;return new b$.Aliased(this,$)}mapWith($){return this.decoder=typeof $==="function"?{mapFromDriverValue:$}:$,this}inlineParams(){return this.shouldInlineParams=!0,this}if($){return $?this:void 0}}class b0{constructor($){this.value=$}static[a]="Name";brand;getSQL(){return new b$([this])}}var ew={mapFromDriverValue:($)=>$},$3={mapToDriverValue:($)=>$},qp={...ew,...$3};class aZ{constructor($,U=$3){this.value=$,this.encoder=U}static[a]="Param";brand;getSQL(){return new b$([this])}}function i6($,...U){let G=[];if(U.length>0||$.length>0&&$[0]!=="")G.push(new v4($[0]));for(let[X,D]of U.entries())G.push(D,new v4($[X+1]));return new b$(G)}(($)=>{function U(){return new b$([])}$.empty=U;function G(Y){return new b$(Y)}$.fromList=G;function X(Y){return new b$([new v4(Y)])}$.raw=X;function D(Y,W){let w=[];for(let[K,A]of Y.entries()){if(K>0&&W!==void 0)w.push(W);w.push(A)}return new b$(w)}$.join=D;function V(Y){return new b0(Y)}$.identifier=V;function Z(Y){return new u0(Y)}$.placeholder=Z;function J(Y,W){return new aZ(Y,W)}$.param=J})(i6||(i6={}));(($)=>{class U{constructor(G,X){this.sql=G,this.fieldAlias=X}static[a]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new U(this.sql,this.fieldAlias)}}$.Aliased=U})(b$||(b$={}));class u0{constructor($){this.name=$}static[a]="Placeholder";getSQL(){return new b$([this])}}var oQ=Symbol.for("drizzle:IsDrizzleView");class U3{static[a]="View";[i1];[oQ]=!0;constructor({name:$,schema:U,selectedFields:G,query:X}){this[i1]={name:$,originalName:$,schema:U,selectedFields:G,query:X,isExisting:!X,isAlias:!1}}getSQL(){return new b$([this])}}K6.prototype.getSQL=function(){return new b$([this])};x$.prototype.getSQL=function(){return new b$([this])};x0.prototype.getSQL=function(){return new b$([this])};function y4($,U){return{name:typeof $==="string"&&$.length>0?$:"",config:typeof $==="object"?$:U}}var sZ=typeof TextDecoder>"u"?null:new TextDecoder;class tZ{static[a]="SQLiteForeignKeyBuilder";reference;_onUpdate;_onDelete;constructor($,U){if(this.reference=()=>{let{name:G,columns:X,foreignColumns:D}=$();return{name:G,columns:X,foreignTable:D[0].table,foreignColumns:D}},U)this._onUpdate=U.onUpdate,this._onDelete=U.onDelete}onUpdate($){return this._onUpdate=$,this}onDelete($){return this._onDelete=$,this}build($){return new D3($,this)}}class D3{constructor($,U){this.table=$,this.reference=U.reference,this.onUpdate=U._onUpdate,this.onDelete=U._onDelete}static[a]="SQLiteForeignKey";reference;onUpdate;onDelete;getName(){let{name:$,columns:U,foreignColumns:G}=this.reference(),X=U.map((Z)=>Z.name),D=G.map((Z)=>Z.name),V=[this.table[E4],...X,G[0].table[E4],...D];return $??`${V.join("_")}_fk`}}function G3($,U){return`${$[E4]}_${U.join("_")}_unique`}class f$ extends lZ{static[a]="SQLiteColumnBuilder";foreignKeyConfigs=[];references($,U={}){return this.foreignKeyConfigs.push({ref:$,actions:U}),this}unique($){return this.config.isUnique=!0,this.config.uniqueName=$,this}generatedAlwaysAs($,U){return this.config.generated={as:$,type:"always",mode:U?.mode??"virtual"},this}buildForeignKeys($,U){return this.foreignKeyConfigs.map(({ref:G,actions:X})=>{return((D,V)=>{let Z=new tZ(()=>{let J=D();return{columns:[$],foreignColumns:[J]}});if(V.onUpdate)Z.onUpdate(V.onUpdate);if(V.onDelete)Z.onDelete(V.onDelete);return Z.build(U)})(G,X)})}}class p$ extends K6{constructor($,U){if(!U.uniqueName)U.uniqueName=G3($,[U.name]);super($,U);this.table=$}static[a]="SQLiteColumn"}class X3 extends f${static[a]="SQLiteBigIntBuilder";constructor($){super($,"bigint","SQLiteBigInt")}build($){return new V3($,this.config)}}class V3 extends p${static[a]="SQLiteBigInt";getSQLType(){return"blob"}mapFromDriverValue($){if(typeof Buffer<"u"&&Buffer.from){let U=Buffer.isBuffer($)?$:$ instanceof ArrayBuffer?Buffer.from($):$.buffer?Buffer.from($.buffer,$.byteOffset,$.byteLength):Buffer.from($);return BigInt(U.toString("utf8"))}return BigInt(sZ.decode($))}mapToDriverValue($){return Buffer.from($.toString())}}class Z3 extends f${static[a]="SQLiteBlobJsonBuilder";constructor($){super($,"json","SQLiteBlobJson")}build($){return new J3($,this.config)}}class J3 extends p${static[a]="SQLiteBlobJson";getSQLType(){return"blob"}mapFromDriverValue($){if(typeof Buffer<"u"&&Buffer.from){let U=Buffer.isBuffer($)?$:$ instanceof ArrayBuffer?Buffer.from($):$.buffer?Buffer.from($.buffer,$.byteOffset,$.byteLength):Buffer.from($);return JSON.parse(U.toString("utf8"))}return JSON.parse(sZ.decode($))}mapToDriverValue($){return Buffer.from(JSON.stringify($))}}class P3 extends f${static[a]="SQLiteBlobBufferBuilder";constructor($){super($,"buffer","SQLiteBlobBuffer")}build($){return new W3($,this.config)}}class W3 extends p${static[a]="SQLiteBlobBuffer";mapFromDriverValue($){if(Buffer.isBuffer($))return $;return Buffer.from($)}getSQLType(){return"blob"}}function Y3($,U){let{name:G,config:X}=y4($,U);if(X?.mode==="json")return new Z3(G);if(X?.mode==="bigint")return new X3(G);return new P3(G)}class H3 extends f${static[a]="SQLiteCustomColumnBuilder";constructor($,U,G){super($,"custom","SQLiteCustomColumn");this.config.fieldConfig=U,this.config.customTypeParams=G}build($){return new w3($,this.config)}}class w3 extends p${static[a]="SQLiteCustomColumn";sqlName;mapTo;mapFrom;constructor($,U){super($,U);this.sqlName=U.customTypeParams.dataType(U.fieldConfig),this.mapTo=U.customTypeParams.toDriver,this.mapFrom=U.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue($){return typeof this.mapFrom==="function"?this.mapFrom($):$}mapToDriverValue($){return typeof this.mapTo==="function"?this.mapTo($):$}}function r0($){return(U,G)=>{let{name:X,config:D}=y4(U,G);return new H3(X,D,$)}}class h0 extends f${static[a]="SQLiteBaseIntegerBuilder";constructor($,U,G){super($,U,G);this.config.autoIncrement=!1}primaryKey($){if($?.autoIncrement)this.config.autoIncrement=!0;return this.config.hasDefault=!0,super.primaryKey()}}class m0 extends p${static[a]="SQLiteBaseInteger";autoIncrement=this.config.autoIncrement;getSQLType(){return"integer"}}class K3 extends h0{static[a]="SQLiteIntegerBuilder";constructor($){super($,"number","SQLiteInteger")}build($){return new O3($,this.config)}}class O3 extends m0{static[a]="SQLiteInteger"}class A3 extends h0{static[a]="SQLiteTimestampBuilder";constructor($,U){super($,"date","SQLiteTimestamp");this.config.mode=U}defaultNow(){return this.default(i6`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build($){return new _3($,this.config)}}class _3 extends m0{static[a]="SQLiteTimestamp";mode=this.config.mode;mapFromDriverValue($){if(this.config.mode==="timestamp")return new Date($*1000);return new Date($)}mapToDriverValue($){let U=$.getTime();if(this.config.mode==="timestamp")return Math.floor(U/1000);return U}}class F3 extends h0{static[a]="SQLiteBooleanBuilder";constructor($,U){super($,"boolean","SQLiteBoolean");this.config.mode=U}build($){return new q3($,this.config)}}class q3 extends m0{static[a]="SQLiteBoolean";mode=this.config.mode;mapFromDriverValue($){return Number($)===1}mapToDriverValue($){return $?1:0}}function Y4($,U){let{name:G,config:X}=y4($,U);if(X?.mode==="timestamp"||X?.mode==="timestamp_ms")return new A3(G,X.mode);if(X?.mode==="boolean")return new F3(G,X.mode);return new K3(G)}class R3 extends f${static[a]="SQLiteNumericBuilder";constructor($){super($,"string","SQLiteNumeric")}build($){return new N3($,this.config)}}class N3 extends p${static[a]="SQLiteNumeric";mapFromDriverValue($){if(typeof $==="string")return $;return String($)}getSQLType(){return"numeric"}}class M3 extends f${static[a]="SQLiteNumericNumberBuilder";constructor($){super($,"number","SQLiteNumericNumber")}build($){return new Q3($,this.config)}}class Q3 extends p${static[a]="SQLiteNumericNumber";mapFromDriverValue($){if(typeof $==="number")return $;return Number($)}mapToDriverValue=String;getSQLType(){return"numeric"}}class I3 extends f${static[a]="SQLiteNumericBigIntBuilder";constructor($){super($,"bigint","SQLiteNumericBigInt")}build($){return new B3($,this.config)}}class B3 extends p${static[a]="SQLiteNumericBigInt";mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return"numeric"}}function T3($,U){let{name:G,config:X}=y4($,U),D=X?.mode;return D==="number"?new M3(G):D==="bigint"?new I3(G):new R3(G)}class z3 extends f${static[a]="SQLiteRealBuilder";constructor($){super($,"number","SQLiteReal")}build($){return new v3($,this.config)}}class v3 extends p${static[a]="SQLiteReal";getSQLType(){return"real"}}function L3($){return new z3($??"")}class S3 extends f${static[a]="SQLiteTextBuilder";constructor($,U){super($,"string","SQLiteText");this.config.enumValues=U.enum,this.config.length=U.length}build($){return new g3($,this.config)}}class g3 extends p${static[a]="SQLiteText";enumValues=this.config.enumValues;length=this.config.length;constructor($,U){super($,U)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:""}`}}class j3 extends f${static[a]="SQLiteTextJsonBuilder";constructor($){super($,"json","SQLiteTextJson")}build($){return new E3($,this.config)}}class E3 extends p${static[a]="SQLiteTextJson";getSQLType(){return"text"}mapFromDriverValue($){return JSON.parse($)}mapToDriverValue($){return JSON.stringify($)}}function O$($,U={}){let{name:G,config:X}=y4($,U);if(X.mode==="json")return new j3(G);return new S3(G,X)}function C3(){return{blob:Y3,customType:r0,integer:Y4,numeric:T3,real:L3,text:O$}}var eZ=Symbol.for("drizzle:SQLiteInlineForeignKeys");class GD extends x${static[a]="SQLiteTable";static Symbol=Object.assign({},x$.Symbol,{InlineForeignKeys:eZ});[x$.Symbol.Columns];[eZ]=[];[x$.Symbol.ExtraConfigBuilder]=void 0}function aQ($,U,G,X,D=$){let V=new GD($,X,D),Z=typeof U==="function"?U(C3()):U,J=Object.fromEntries(Object.entries(Z).map(([W,w])=>{let K=w;K.setName(W);let A=K.build(V);return V[eZ].push(...K.buildForeignKeys(A,V)),[W,A]})),Y=Object.assign(V,J);if(Y[x$.Symbol.Columns]=J,Y[x$.Symbol.ExtraConfigColumns]=J,G)Y[GD.Symbol.ExtraConfigBuilder]=G;return Y}var f4=($,U,G)=>{return aQ($,U,G)};class k3{constructor($,U){this.name=$,this.value=U}static[a]="SQLiteCheckBuilder";brand;build($){return new x3($,this)}}class x3{constructor($,U){this.table=$,this.name=U.name,this.value=U.value}static[a]="SQLiteCheck";name;value}function b3($,U){return new k3($,U)}class u3{constructor($,U){this.name=$,this.unique=U}static[a]="SQLiteIndexBuilderOn";on(...$){return new r3(this.name,$,this.unique)}}class r3{static[a]="SQLiteIndexBuilder";config;constructor($,U,G){this.config={name:$,columns:U,unique:G,where:void 0}}where($){return this.config.where=$,this}build($){return new h3(this.config,$)}}class h3{static[a]="SQLiteIndex";config;constructor($,U){this.config={...$,table:U}}}function C4($){return new u3($,!1)}function y0(...$){if($[0].columns)return new $J($[0].columns,$[0].name);return new $J($)}class $J{static[a]="SQLitePrimaryKeyBuilder";columns;name;constructor($,U){this.columns=$,this.name=U}build($){return new m3($,this.columns,this.name)}}class m3{constructor($,U,G){this.table=$,this.columns=U,this.name=G}static[a]="SQLitePrimaryKey";columns;name;getName(){return this.name??`${this.table[GD.Symbol.Name]}_${this.columns.map(($)=>$.name).join("_")}_pk`}}var y3=f4("job_queue",{id:O$("id").primaryKey().$defaultFn(()=>l6()),type:O$("type").notNull(),data:O$("data").notNull(),result:O$("result",{mode:"json"}),source:O$("source"),metadata:O$("metadata",{mode:"json"}).$type().notNull(),status:O$("status",{enum:["pending","processing","completed","failed"]}).notNull().default("pending"),priority:Y4("priority").notNull().default(0),retryCount:Y4("retryCount").notNull().default(0),maxRetries:Y4("maxRetries").notNull().default(3),lastError:O$("lastError"),createdAt:Y4("createdAt").notNull().$defaultFn(()=>Date.now()),scheduledFor:Y4("scheduledFor").notNull().$defaultFn(()=>Date.now()),startedAt:Y4("startedAt"),completedAt:Y4("completedAt")},($)=>({queueReadyIdx:C4("idx_job_queue_ready").on($.status,$.priority,$.scheduledFor),jobTypeIdx:C4("idx_job_queue_type").on($.type,$.status),jobSourceIdx:C4("idx_job_queue_source").on($.source)}));var Cl=P.looseObject({deduplicationKey:P.string().optional()});var Xi=P.preprocess(($)=>{if(typeof $!=="string")return $;return JSON.parse($)},P.record(P.string(),P.unknown()));var Ji=P.record(P.string(),P.unknown());var sQ=P.object({id:P.string(),type:P.string(),data:P.string(),status:P.enum(["pending","processing","completed","failed"]),source:P.string().nullable(),priority:P.number(),retryCount:P.number(),maxRetries:P.number(),lastError:P.string().nullable(),createdAt:P.number(),scheduledFor:P.number(),startedAt:P.number().nullable(),completedAt:P.number().nullable(),metadata:l1,result:P.unknown().nullable().optional()});function UJ($,U,G){return async(X)=>{let{type:D,data:V,toolContext:Z=null,options:J}=X,{metadata:Y,...W}=J??{},w={source:U,...J?.rootJobId&&{rootJobId:J.rootJobId},...W,metadata:{operationType:"data_processing",pluginId:U,...Z&&{interfaceType:Z.interfaceType,channelId:Z.channelId},...Y}},K=G&&!D.includes(":")?`${U}:${D}`:D;return $.enqueue({type:K,data:V,options:w})}}function DJ($,U){return async(G,X)=>{let D=l6(),V=G.map((J)=>({...J,type:J.type.includes(":")?J.type:`${U}:${J.type}`})),Z={...X,source:U,rootJobId:D,metadata:{...X?.metadata,operationType:"batch_processing",pluginId:U}};return await $.enqueueBatch(V,Z,D,U),D}}function GJ($,U){return(G,X)=>{let D=G.includes(":")?G:`${U}:${G}`;$.registerHandler(D,X,U)}}var tQ=P.custom(($)=>typeof $==="object"&&$!==null&&("safeParse"in $)),eQ=P.object({name:P.string(),schema:tQ});function f3($){return eQ.safeParse($).success}function $I($){if(!$)return;return{status:$.status,message:$.message,lastCheck:$.lastCheck?.toISOString(),details:$.details}}function p3($){return{model:$.model,version:$.version,uptime:$.uptime,entities:$.entities,entityCounts:$.entityCounts,embeddings:$.embeddings,ai:$.ai,daemons:$.daemons.map((U)=>({name:U.name,pluginId:U.pluginId,status:U.status,health:$I(U.health)})),endpoints:$.endpoints,interactions:$.interactions}}import{createClient as xi}from"@libsql/client";var f0=f4("conversations",{id:O$("id").primaryKey(),sessionId:O$("session_id").notNull(),interfaceType:O$("interface_type").notNull(),channelId:O$("channel_id").notNull(),started:O$("started").notNull(),lastActive:O$("last_active").notNull(),metadata:O$("metadata"),created:O$("created").notNull(),updated:O$("updated").notNull()},($)=>({sessionIdx:C4("idx_conversations_session").on($.sessionId),channelIdx:C4("idx_conversations_channel").on($.channelId),interfaceSessionIdx:C4("idx_conversations_interface_session").on($.interfaceType,$.sessionId),interfaceChannelIdx:C4("idx_conversations_interface_channel").on($.interfaceType,$.channelId)})),l3=f4("messages",{id:O$("id").primaryKey(),conversationId:O$("conversation_id").notNull().references(()=>f0.id,{onDelete:"cascade"}),role:O$("role").notNull(),content:O$("content").notNull(),timestamp:O$("timestamp").notNull(),metadata:O$("metadata")},($)=>({conversationIdx:C4("idx_messages_conversation").on($.conversationId),timestampIdx:C4("idx_messages_timestamp").on($.timestamp)})),i3=f4("summary_tracking",{conversationId:O$("conversation_id").primaryKey().references(()=>f0.id,{onDelete:"cascade"}),lastSummarizedAt:O$("last_summarized_at"),lastMessageId:O$("last_message_id"),messagesSinceSummary:Y4("messages_since_summary").default(0),updated:O$("updated").notNull()});var UI=P.preprocess(($)=>{if(typeof $!=="string")return $;try{return JSON.parse($)}catch{return}},P.record(P.string(),P.unknown())).catch({});function VD($){return UI.parse($)}var p0=P.object({actorId:P.string(),canonicalId:P.string().optional(),interfaceType:P.string(),role:k6,displayName:P.string().optional(),username:P.string().optional(),isBot:P.boolean().optional()}),l0=P.object({messageId:P.string().optional(),channelId:P.string().optional(),channelName:P.string().optional(),threadId:P.string().optional(),metadata:P.record(P.string(),P.unknown()).optional()}),DI=P.looseObject({actor:p0.optional(),source:l0.optional()});var GI=P.object({id:P.string(),conversationId:P.string(),role:P.string(),content:P.string(),timestamp:P.string(),metadata:P.string().nullable()}),XI=P.object({conversationId:P.string(),messageCount:P.number(),messages:P.array(GI),windowStart:P.number(),windowEnd:P.number(),windowSize:P.number(),timestamp:P.string()});var n1=P.record(P.string(),P.unknown());var JI=P.object({id:P.string(),sessionId:P.string(),interfaceType:P.string(),channelId:P.string(),channelName:P.string().optional(),startedAt:P.string(),lastActiveAt:P.string(),createdAt:P.string(),updatedAt:P.string(),metadata:n1}),PI=P.object({id:P.string(),conversationId:P.string(),role:k6,content:P.string(),timestamp:P.string(),metadata:n1});function WI($){let U=k6.safeParse($);return U.success?U.data:"user"}function i0($){let U=VD($.metadata),G=typeof U.channelName==="string"?U.channelName:void 0;return{id:$.id,sessionId:$.sessionId,interfaceType:$.interfaceType,channelId:$.channelId,channelName:G,startedAt:$.started,lastActiveAt:$.lastActive,createdAt:$.created,updatedAt:$.updated,metadata:U}}function n3($){return{id:$.id,conversationId:$.conversationId,role:WI($.role),content:$.content,timestamp:$.timestamp,metadata:VD($.metadata)}}var XJ=P.object({name:P.string(),role:P.string(),purpose:P.string(),values:P.array(P.string())}),VJ=P.object({name:P.string(),kind:P.enum(["professional","team","collective"]),organization:P.string().optional(),description:P.string().optional(),avatar:P.string().optional(),website:P.string().optional(),email:P.string().optional(),socialLinks:P.array(P.object({platform:P.enum(["github","instagram","linkedin","email","website"]),url:P.string(),label:P.string().optional()})).optional()});function c3($){return XJ.parse($)}function d3($){return VJ.parse($)}function o3($){return async()=>{return p3(await $.getAppInfo())}}function a3($,U){return{get:()=>c3($.getIdentity()),getProfile:()=>d3($.getProfile()),getAppInfo:U}}function s3($,U,G){let X=$.getMessageBus();return{send:async(V)=>{return X.send({...V,sender:U})},subscribe:(V,Z)=>{if(f3(V)){let J=V,Y=Z,W=async(w)=>{let K=J.schema.safeParse(w.payload);if(!K.success)return G.warn(`Invalid payload for channel ${J.name}`,{error:K.error.message}),{noop:!0};let{payload:A,...O}=w;return Y(K.data,O)};return X.subscribe(J.name,W)}return X.subscribe(V,Z)}}}function t3($,U){let G=$.getJobQueueService();return{...$.jobs,enqueue:UJ(G,U,!0),enqueueBatch:DJ($.jobs,U),registerHandler:GJ(G,U)}}function e3($){let U=$.getPermissionService();return{assertEntityActionAllowed:(G,X,D)=>{U.assertEntityActionAllowed(G,X,D.userPermissionLevel)}}}function $K($){return{get:async(U)=>{let X=await $.getConversationService().getConversation(U);return X?i0(X):null},search:async(U)=>{return(await $.getConversationService().searchConversations(U)).map(i0)},list:async(U)=>{return(await $.getConversationService().listConversations(U)).map(i0)},getMessages:async(U,G)=>{return(await $.getConversationService().getMessages(U,G)).map(n3)},countMessages:async(U)=>{return $.getConversationService().countMessages(U)}}}function UK($,U){return{registerHandler:(G,X)=>{$.registerEvalHandler(U,G,X)}}}function DK($){return{register:(U,G)=>{$.getInsightsRegistry().register(U,G)}}}function GK($,U){return{register:(G)=>{$.registerEndpoint({...G,pluginId:U})}}}function XK($,U){return{register:(G)=>{$.registerInteraction({...G,pluginId:U})}}}function c1($,U,G){let X=$.getEntityService(),D=$.getLogger().child(U),V=$.getDomain(),Z=$.getLocalSiteUrl(),J=$.shouldPreferLocalUrls(),Y=$.getThemeCSS(),W=o3($),w=$.getAttachmentRegistry(),K=$.getRuntimeUploadRegistry(),A=$.getRuntimeState();return{pluginId:U,logger:D,entityService:X,semantic:{project:(O)=>X.projectSemanticSpace(O)},identity:a3($,W),appInfo:W,judge:(O)=>$.judge(O),domain:V,siteUrl:V?`https://${V}`:void 0,localSiteUrl:Z,previewUrl:V?`https://${mZ(V)}`:void 0,preferLocalUrls:J,themeCSS:Y,entityDisplay:G?.entityDisplay,spaces:$.getSpaces(),permissions:e3($),messaging:s3($,U,D),jobs:t3($,U),attachments:w,uploads:K,runtimeState:A,conversations:$K($),dataDir:$.getDataDir(),eval:UK($,U),insights:DK($),endpoints:GK($,U),interactions:XK($,U)}}import{createClient as gn}from"@libsql/client";var n0=f4("entities",{id:O$("id").notNull(),entityType:O$("entityType").notNull(),content:O$("content").notNull(),contentHash:O$("contentHash").notNull(),visibility:O$("visibility",{enum:["public","shared","restricted"]}).notNull().default("public"),metadata:O$("metadata",{mode:"json"}).$type().notNull().default(i6`'{}'`),created:Y4("created").notNull().$defaultFn(()=>Date.now()),updated:Y4("updated").notNull().$defaultFn(()=>Date.now())},($)=>{return{pk:y0({columns:[$.id,$.entityType]}),visibilityCheck:b3("entities_visibility_check",i6`${$.visibility} IN ('public', 'shared', 'restricted')`)}});import{createClient as hn}from"@libsql/client";var VK=r0({dataType(){return"F32_BLOB(1536)"},toDriver($){return Buffer.from($.buffer)},fromDriver($){return new Float32Array($.buffer,$.byteOffset,$.byteLength/4)}});var c0=f4("embeddings",{entityId:O$("entity_id").notNull(),entityType:O$("entity_type").notNull(),embedding:VK("embedding").notNull(),contentHash:O$("content_hash").notNull()},($)=>{return{pk:y0({columns:[$.entityId,$.entityType]})}});var YI=P.enum(["public","shared","restricted"]),ZD=P.union([YI,P.literal("private")]).optional().transform(($)=>{if($===void 0)return"public";if($==="private")return"restricted";return $});function d0($){if($==="anchor")return"restricted";if($==="trusted")return"shared";return"public"}var JJ=P.object({id:P.string(),entityType:P.string(),content:P.string(),created:P.string().datetime(),updated:P.string().datetime(),visibility:ZD,metadata:P.record(P.string(),P.unknown()),contentHash:P.string()}),KI=P.enum(["public","shared","restricted"]),OI=P.object({id:P.string(),entityType:P.string(),content:P.string(),created:P.string().datetime(),updated:P.string().datetime(),visibility:P.union([KI,P.literal("private")]).optional().transform(($)=>{if($===void 0)return"public";if($==="private")return"restricted";return $}),metadata:P.record(P.string(),P.unknown()),contentHash:P.string()}),JK=P.object({}),AI=P.object({mediaType:P.string(),url:P.string(),downloadUrl:P.string().optional(),previewUrl:P.string().optional(),filename:P.string().optional(),sizeBytes:P.number().optional(),source:P.object({entityType:P.string().optional(),entityId:P.string().optional(),attachmentType:P.string().optional()}).optional()});var Uc=P.object({id:P.string().min(1,"Entity ID is required"),entityType:P.string().min(1,"Entity type is required"),contentHash:P.string().min(1,"Content hash is required"),operation:P.enum(["create","update"])});var Wc=P.object({limit:P.number().int().positive().optional().default(20),offset:P.number().int().min(0).optional().default(0),types:P.array(P.string()).optional().default([]),excludeTypes:P.array(P.string()).optional().default([]),weight:P.record(P.string(),P.number()).optional(),visibilityScope:P.enum(["public","shared","restricted"]).optional(),includeUngenerated:P.boolean().optional().default(!1),minScore:P.number().min(0).optional()}),Yc=P.preprocess(($)=>{if(typeof $!=="string")return $;return JSON.parse($)},P.record(P.string(),P.unknown()));var jJ=ND(SJ(),1);function JG($,U){if(Object.keys(U).length===0)return $;let G=Object.fromEntries(Object.entries(U).filter(([,X])=>X!==void 0));return jJ.default.stringify($,G)}function gJ($){if($ instanceof Date)return $.toISOString();if(Array.isArray($))return $.map(gJ);if($!==null&&typeof $==="object"){let U={};for(let[G,X]of Object.entries($))U[G]=gJ(X);return U}return $}function AD($,U){let{content:G,data:X}=jJ.default($),D=gJ(X);return{content:G.trim(),metadata:U.parse(D)}}var $d=P.object({visibility:P.enum(["public","shared","restricted","private"]).optional().transform(($)=>{if($===void 0)return"public";return $==="private"?"restricted":$})});var Xd=P.looseObject({issues:P.array(P.looseObject({message:P.string()}))});var wd=P.record(P.string(),P.unknown());var Mv=P.object({field:P.string(),direction:P.enum(["asc","desc"]),nullsFirst:P.boolean().optional()}),Nd=P.object({limit:P.number().int().positive().optional(),offset:P.number().int().min(0).optional().default(0),sortFields:P.array(Mv).optional(),filter:P.object({metadata:P.record(P.string(),P.unknown()).optional(),visibilityScope:P.enum(["public","shared","restricted"]).optional()}).optional(),publishedOnly:P.boolean().optional()});var Sd=P.custom(($)=>typeof $==="object"&&$!==null&&!Array.isArray($));var gd=P.object({id:P.string().min(1),entityType:P.string().min(1),contentHash:P.string().min(1)});var gv=ND(SJ(),1);var Do=E0();var wo=P.record(P.string(),P.unknown());var kv=P.object({currentPage:P.number(),totalPages:P.number(),totalItems:P.number(),pageSize:P.number(),hasNextPage:P.boolean(),hasPrevPage:P.boolean()});function xv($){return $.replace(/:/g,"-")}function bv($){return $.split(/[:.-]/).map((U)=>U.charAt(0).toUpperCase()+U.slice(1)).join(" ")}var EJ=new Map;async function zA($,U,G){let X=EJ.get(U);if(X!==void 0)return X;let D=xv(U),V;try{V=await $.getEntity({entityType:"prompt",id:D})}catch{return G}if(V?.content){let Z=AD(V.content,P.record(P.string(),P.unknown())).content;return EJ.set(U,Z),Z}try{let Z=bv(U),J=JG(G,{title:Z,target:U});await $.createEntity({entity:{id:D,entityType:"prompt",content:J,metadata:{title:Z,target:U,slug:D}}})}catch{}return EJ.set(U,G),G}function PG($){let U=$.getEntityService(),G=$.getEntityRegistry(),X=$.getDataSourceRegistry();return{register:(D,V,Z,J)=>{G.registerEntityType(D,V,Z,J)},getAdapter:(D)=>{try{return G.getAdapter(D)}catch{return}},extendFrontmatterSchema:(D,V)=>{G.extendFrontmatterSchema(D,V)},getEffectiveFrontmatterSchema:(D)=>{return G.getEffectiveFrontmatterSchema(D)},registerCreateInterceptor:(D,V)=>{G.registerCreateInterceptor(D,V)},registerUploadSaveHandler:(D)=>{G.registerUploadSaveHandler(D)},getUploadSaveHandler:(D)=>{return G.getUploadSaveHandler(D)},update:async(D)=>{return U.updateEntity({entity:D})},registerDataSource:(D)=>{X.register(D)}}}function WG($){return{resolve:(U,G)=>{return zA($,U,G)}}}function vA($,U,G){let X=c1($,U,G),D=$.getEntityService();return{...X,entityService:D,entities:PG($),ai:{query:(V,Z)=>$.query(V,Z),generate:async(V)=>{return $.generateContent(V)},generateObject:async(V,Z)=>{return $.generateObject(V,Z)},generateImage:async(V,Z)=>{return $.generateImage(V,Z)},canGenerateImages:()=>{return $.canGenerateImages()}},prompts:WG(D),permissions:X.permissions}}function SA($,U,G){let X=!1,D=!1;if($.jobs.registerHandler(G.job.type,G.job.handler),G.initialSync){let V=G.initialSync;$.messaging.subscribe("sync:initial:completed",async()=>{if(X)return{success:!0};if(X=!0,!(await V.shouldEnqueue?.()??!0))return U.info("Skipping derived entity projection initial sync",{projectionId:G.id,targetType:G.targetType}),{success:!0};return D=await LA($,U,G,V.jobData,rv(V.jobOptions),"initial-sync"),{success:!0}})}if(G.sourceChange){let V=G.sourceChange,Z=new Set(V.sourceTypes),J=V.events??["entity:created","entity:updated"],Y=async(W)=>{if(V.requireInitialSync&&!X)return{success:!0};let w=W.payload,K=uv(V,w);if(!K||!Z.has("*")&&!Z.has(K))return{success:!0};if(!(await V.shouldEnqueue?.(w)??!0))return{success:!0};let O=await V.jobData(w);if(!O)return{success:!0};return await LA($,U,G,O,V.jobOptions?.(w),"source-change"),{success:!0}};for(let W of J)$.messaging.subscribe(W,Y)}return{hasObservedInitialSync:()=>X,hasQueuedInitialSync:()=>D}}function uv($,U){if($.sourceType)return $.sourceType;if($.sourceKind&&$.sourceKind!=="entity")return $.sourceKind;return U.entityType}async function LA($,U,G,X,D,V){try{return await $.jobs.enqueue({type:G.job.type,data:X,...D?{options:D}:{}}),U.info("Queued derived entity projection",{projectionId:G.id,targetType:G.targetType,reason:V}),!0}catch(Z){return U.error("Failed to queue derived entity projection",{projectionId:G.id,targetType:G.targetType,reason:V,error:m4(Z)}),!1}}function rv($){return typeof $==="function"?$():$}var Ma=P.object({});class YG extends C6{type="entity";entityActionPolicy;derivedEntityProjectionControllers=new Map;constructor($,U,G,X,D){super($,U,G,X);if(D!==void 0)this.entityActionPolicy=D}async register($,U){let G=vA($,this.id,U);if(this.context=G,this.setupMessageHandlers(G),G.entities.register(this.entityType,this.schema,this.adapter,this.getEntityTypeConfig()),this.interceptCreate!==YG.prototype.interceptCreate)G.entities.registerCreateInterceptor(this.entityType,(Y,W)=>this.interceptCreate(Y,W,G));let X=this.createGenerationHandler(G);if(X)G.jobs.registerHandler(`${this.entityType}:generation`,X);let D=this.getTemplates();if(D&&Object.keys(D).length>0)$.registerTemplates(D,this.id);let V=this.getDataSources();for(let Y of V)G.entities.registerDataSource(Y);let Z=this.getDerivedEntityProjections(G);for(let Y of Z){let W=SA(G,this.logger,Y);this.derivedEntityProjectionControllers.set(Y.id,W)}await this.onRegister(this.context);let J=await this.getInstructions();return{tools:[],resources:[],...J&&{instructions:J}}}async interceptCreate($,U,G){return{kind:"continue",input:$}}createGenerationHandler($){return null}getTemplates(){return null}getDataSources(){return[]}getEntityTypeConfig(){return}getDerivedEntityProjections($){return[]}getDerivedEntityProjectionController($){return this.derivedEntityProjectionControllers.get($)}}class gA extends YG{hooks;constructor($,U,G,X,D){super($,U,G,X);this.hooks=D}get entityType(){return this.hooks.getEntityType()}get schema(){return this.hooks.getSchema()}get adapter(){return this.hooks.getAdapter()}onRegister($){return this.hooks.onRegister($)}onReady($){return this.hooks.onReady($)}onShutdown(){return this.hooks.onShutdown()}getEntityTypeConfig(){return this.hooks.getEntityTypeConfig()}getDataSources(){return this.hooks.getDataSources()}getInstructions(){return this.hooks.getInstructions()}interceptCreate($,U,G){return this.hooks.interceptCreate($,U,G)}}class CJ{type="entity";id;version;packageName;description;delegate;constructor($,U,G,X){if(this.id=$,this.version=U.version,this.packageName=U.name,U.description!==void 0)this.description=U.description;this.delegate=new gA($,U,G,X,{getEntityType:()=>this.entityType,getSchema:()=>this.schema,getAdapter:()=>this.adapter,onRegister:(D)=>this.onRegister(D),onReady:(D)=>this.onReady(D),onShutdown:()=>this.onShutdown(),getEntityTypeConfig:()=>this.getEntityTypeConfig(),getDataSources:()=>this.getDataSources(),getInstructions:()=>this.getInstructions(),interceptCreate:(D,V,Z)=>this.interceptCreate(D,V,Z)})}register($,U){return this.delegate.register($,U)}async onRegister($){}async onReady($){}async onShutdown(){}async getInstructions(){return}getEntityTypeConfig(){return}getDataSources(){return[]}async interceptCreate($,U,G){return{kind:"continue",input:$}}ready(){return this.delegate.ready()}shutdown(){return this.delegate.shutdown?.()??Promise.resolve()}}function jA($){return NV($)}function EA($){if(!$)return;return{...$.userPermissionLevel&&{userPermissionLevel:$.userPermissionLevel},...$.interfaceType&&{interfaceType:$.interfaceType},...$.channelId&&{channelId:$.channelId},...$.channelName&&{channelName:$.channelName},...$.actor&&{actor:$.actor},...$.source&&{source:$.source},...$.attachments&&{attachments:$.attachments}}}function CA($){return{chat:async(U,G,X)=>{return jA(await $.chat(U,G,EA(X)))},confirmPendingAction:async(U,G,X,D)=>{let V=EA(D);if(!V)throw Error("Confirmation requires caller context.");return jA(await $.confirmPendingAction(U,G,X,V))},invalidate:()=>{$.invalidateAgent()}}}function kA($,U,G){let X=c1($,U,G),D=$.getMCPService(),V=$.getPermissionService(),Z=CA($.getAgentService());return{...X,mcpTransport:D,agent:Z,permissions:{...X.permissions,getUserLevel:(J,Y,W)=>{return V.determineUserLevel(J,Y,W)}},daemons:{register:(J,Y)=>{let W=`${U}:${J}`;$.registerDaemon(W,Y,U),X.logger.debug(`Registered daemon: ${W}`)}},conversations:{...X.conversations,start:async(J)=>{return $.getConversationService().startConversation(J)},addMessage:async(J)=>{await $.getConversationService().addMessage(J)},updateMetadata:async(J)=>{return $.getConversationService().updateConversationMetadata(J)},delete:async(J)=>{return $.getConversationService().deleteConversation(J)}},tools:{listForPermissionLevel:(J)=>{return $.listToolsForPermissionLevel(J)}},apiRoutes:{getRoutes:()=>{return $.getPluginApiRoutes()},getMessageBus:()=>{return $.getMessageBus()}},webRoutes:{getRoutes:()=>{return $.getPluginWebRoutes()}},plugins:{has:(J)=>$.hasPlugin(J)}}}var hv=3600000;class _D extends C6{type="interface";daemon;jobTrackingEntries=new Map;jobTrackingTtlMs=hv;async register($,U){let G=kA($,this.id,U);if(this.context=G,this.initializeDaemon(),this.daemon)await this.registerDaemon(G);return this.setupMessageHandlers(G),await this.onRegister(G),this.getCapabilities()}async onRegister($){}async registerDaemon($){if(!this.daemon)return;$.daemons.register(this.id,this.daemon),$.logger.debug(`Registered daemon for interface: ${this.id}`)}createDaemon(){return}requiresDaemonStartup(){return!1}getWebRoutes(){return[]}initializeDaemon(){let $=this.createDaemon();if($)this.daemon=$}async handleProgressEvent($,U){}cleanupExpiredEntries(){let $=Date.now(),U=[];for(let[G,X]of this.jobTrackingEntries)if($-X.createdAt>this.jobTrackingTtlMs)U.push(G);for(let G of U)this.jobTrackingEntries.delete(G)}ownsJob($,U){return this.jobTrackingEntries.has($)||U!==void 0&&this.jobTrackingEntries.has(U)}getJobTracking($,U){let G=this.jobTrackingEntries.get($);if(G)return G.info;if(U){let X=this.jobTrackingEntries.get(U);if(X)return X.info}return}setJobTracking($,U){this.cleanupExpiredEntries(),this.jobTrackingEntries.set($,{info:U,createdAt:Date.now()})}removeJobTracking($){this.jobTrackingEntries.delete($)}async createJobWithTracking($,U){let X=await this.getContext().jobs.enqueue($);return this.setJobTracking(X,U),X}async createBatchWithTracking($,U,G){let D=await this.getContext().jobs.enqueueBatch($,G);return this.setJobTracking(D,U),D}}class xA extends _D{hooks;constructor($,U,G,X,D){super($,U,G,X);this.hooks=D}onRegister($){return this.hooks.onRegister($)}onReady($){return this.hooks.onReady($)}onShutdown(){return this.hooks.onShutdown()}getTools(){return this.hooks.getTools()}getResources(){return this.hooks.getResources()}getInstructions(){return this.hooks.getInstructions()}getWebRoutes(){return this.hooks.getWebRoutes()}requiresDaemonStartup(){return this.hooks.requiresDaemonStartup()}}class FD{type="interface";id;version;packageName;description;delegate;constructor($,U,G,X){if(this.id=$,this.version=U.version,this.packageName=U.name,U.description!==void 0)this.description=U.description;this.delegate=new xA($,U,G,X,{onRegister:(D)=>this.onRegister(D),onReady:(D)=>this.onReady(D),onShutdown:()=>this.onShutdown(),getTools:()=>this.getTools(),getResources:()=>this.getResources(),getInstructions:()=>this.getInstructions(),getWebRoutes:()=>this.getWebRoutes(),requiresDaemonStartup:()=>this.requiresDaemonStartup()})}register($,U){return this.delegate.register($,U)}async onRegister($){}async onReady($){}async onShutdown(){}async getTools(){return[]}async getResources(){return[]}async getInstructions(){return}getWebRoutes(){return[]}requiresDaemonStartup(){return!1}ready(){return this.delegate.ready()}shutdown(){return this.delegate.shutdown?.()??Promise.resolve()}}function bA($,U){$.messaging.subscribe("job-progress",async(G)=>{try{let X=pZ.safeParse(G.payload);if(!X.success)return U.onInvalidSchema(),{success:!1};let D=X.data;return await U.onProgress(D,D.metadata),{success:!0}}catch(X){return U.onError(X),{success:!1}}})}function uA($){let U=$.status==="completed"?"\u2705":"\u274C",G=$.status==="completed"?"completed":"failed",X=$.metadata.operationType.replace(/_/g," "),D=$.metadata.operationTarget?`: ${$.metadata.operationTarget}`:"",V=`${U} **${X}${D}** ${G}`;if($.message)V+=`
188
+ `;return""}return rZ.dump=r,rZ}var N3;function EQ(){if(N3)return e$;N3=1;let $=gQ(),U=jQ();function G(X,D){return function(){throw Error("Function yaml."+X+" is removed in js-yaml 4. Use yaml."+D+" instead, which is now safe by default.")}}return e$.Type=P4(),e$.Schema=M3(),e$.FAILSAFE_SCHEMA=T3(),e$.JSON_SCHEMA=g3(),e$.CORE_SCHEMA=j3(),e$.DEFAULT_SCHEMA=hZ(),e$.load=$.load,e$.loadAll=$.loadAll,e$.dump=U.dump,e$.YAMLException=$D(),e$.types={binary:k3(),float:S3(),map:B3(),null:z3(),pairs:b3(),set:u3(),timestamp:E3(),bool:v3(),int:L3(),merge:C3(),omap:x3(),seq:I3(),str:Q3()},e$.safeLoad=G("safeLoad","load"),e$.safeLoadAll=G("safeLoadAll","loadAll"),e$.safeDump=G("safeDump","dump"),e$}var Ay=EQ();var Fy=P.record(P.string(),P.unknown());var py=P.object({slug:P.string(),title:P.string(),type:P.string(),entityId:P.string(),contentHash:P.string()});function mZ($){return`preview.${$.trim().replace(/^https?:\/\//,"")}`}var CQ=P.string(),kQ=P.looseObject({id:P.string().min(1)}),xQ=P.looseObject({label:P.string().min(1)}),bQ=P.looseObject({layouts:P.record(P.string(),P.unknown()),plugin:P.custom(($)=>typeof $==="function").optional(),routes:P.array(kQ),entityDisplay:P.record(P.string(),xQ),content:P.unknown().optional(),themeOverride:P.string().optional(),headScripts:P.array(P.string()).optional(),staticAssets:P.record(P.string(),P.string()).optional()}),uQ=P.custom(($)=>bQ.safeParse($).success);import{webcrypto as m3}from"crypto";var h3="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var rQ=128,w6,p1;function hQ($){if($<0)throw RangeError("Wrong ID size");try{if(!w6||w6.length<$)w6=Buffer.allocUnsafe($*rQ),m3.getRandomValues(w6),p1=0;else if(p1+$>w6.length)m3.getRandomValues(w6),p1=0}catch(U){throw w6=void 0,U}p1+=$}function y3($=21){hQ($|=0);let U="";for(let G=p1-$;G<p1;G++)U+=h3[w6[G]&63];return U}function l6($=12){return y3($)}var yZ=P.enum(["file_operations","content_operations","data_processing","batch_processing"]),mQ=P.object({pluginId:P.string().optional(),progressToken:P.union([P.string(),P.number()]).optional(),operationType:yZ,operationTarget:P.string().optional(),interfaceType:P.string().optional(),conversationId:P.string().optional(),channelId:P.string().optional(),silent:P.boolean().optional()}),l1=P.object({pluginId:P.string().optional(),progressToken:P.union([P.string(),P.number()]).optional(),operationType:yZ,operationTarget:P.string().optional(),interfaceType:P.string().optional(),conversationId:P.string().optional(),channelId:P.string().optional(),silent:P.boolean().optional(),rootJobId:P.string()}),Ef=P.enum(["none","skip","replace","coalesce"]);var fZ=P.enum(["pending","processing","completed","failed"]),f3=P.enum(["completed","failed"]);var yQ=P.object({id:P.string(),type:P.string(),status:fZ,data:P.unknown(),result:P.unknown().optional(),lastError:P.string().optional().nullable(),attempts:P.number(),maxRetries:P.number(),priority:P.number(),createdAt:P.date(),updatedAt:P.date(),processedAt:P.date().optional().nullable(),completedAt:P.date().optional().nullable(),failedAt:P.date().optional().nullable()}),fQ=P.object({jobId:P.string(),type:P.string(),status:f3,result:P.unknown().optional(),error:P.string().optional()}),p3=P.object({success:P.literal(!1),error:P.string().optional()}),pZ=P.object({id:P.string(),type:P.enum(["job","batch"]),status:fZ,message:P.string().optional(),progress:P.object({current:P.number(),total:P.number(),percentage:P.number()}).optional(),aggregationKey:P.string().optional(),batchDetails:P.object({totalOperations:P.number(),completedOperations:P.number(),failedOperations:P.number(),currentOperation:P.string().optional(),errors:P.array(P.string()).optional()}).optional(),jobDetails:P.object({jobType:P.string(),priority:P.number(),retryCount:P.number()}).optional(),metadata:l1});import{createClient as Bl}from"@libsql/client";var a=Symbol.for("drizzle:entityKind");function W4($,U){if(!$||typeof $!=="object")return!1;if($ instanceof U)return!0;if(!Object.prototype.hasOwnProperty.call(U,a))throw Error(`Class "${U.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let G=Object.getPrototypeOf($).constructor;if(G)while(G){if(a in G&&G[a]===U[a])return!0;G=Object.getPrototypeOf(G)}return!1}class K6{constructor($,U){this.table=$,this.config=U,this.name=U.name,this.keyAsName=U.keyAsName,this.notNull=U.notNull,this.default=U.default,this.defaultFn=U.defaultFn,this.onUpdateFn=U.onUpdateFn,this.hasDefault=U.hasDefault,this.primary=U.primaryKey,this.isUnique=U.isUnique,this.uniqueName=U.uniqueName,this.uniqueType=U.uniqueType,this.dataType=U.dataType,this.columnType=U.columnType,this.generated=U.generated,this.generatedIdentity=U.generatedIdentity}static[a]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue($){return $}mapToDriverValue($){return $}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}class lZ{static[a]="ColumnBuilder";config;constructor($,U,G){this.config={name:$,keyAsName:$==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:U,columnType:G,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default($){return this.config.default=$,this.config.hasDefault=!0,this}$defaultFn($){return this.config.defaultFn=$,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn($){return this.config.onUpdateFn=$,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName($){if(this.config.name!=="")return;this.config.name=$}}var E4=Symbol.for("drizzle:Name");function l3($,...U){return $(...U)}function i3($,U){return`${$[E4]}_${U.join("_")}_unique`}class UD extends K6{constructor($,U){if(!U.uniqueName)U.uniqueName=i3($,[U.name]);super($,U);this.table=$}static[a]="PgColumn"}class pQ extends UD{static[a]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op($){return this.indexConfig.opClass=$,this}}class lQ extends UD{static[a]="PgEnumObjectColumn";enum;enumValues=this.config.enum.enumValues;constructor($,U){super($,U);this.enum=U.enum}getSQLType(){return this.enum.enumName}}var n3=Symbol.for("drizzle:isPgEnum");function c3($){return!!$&&typeof $==="function"&&n3 in $&&$[n3]===!0}class iQ extends UD{static[a]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor($,U){super($,U);this.enum=U.enum}getSQLType(){return this.enum.enumName}}class x0{static[a]="Subquery";constructor($,U,G,X=!1,D=[]){this._={brand:"Subquery",sql:$,selectedFields:U,alias:G,isWith:X,usedTables:D}}}var d3="0.45.2";var iZ,nZ,o3={startActiveSpan($,U){if(!iZ)return U();if(!nZ)nZ=iZ.trace.getTracer("drizzle-orm",d3);return l3((G,X)=>X.startActiveSpan($,(D)=>{try{return U(D)}catch(V){throw D.setStatus({code:G.SpanStatusCode.ERROR,message:V instanceof Error?V.message:"Unknown error"}),V}finally{D.end()}}),iZ,nZ)}};var i1=Symbol.for("drizzle:ViewBaseConfig");var cZ=Symbol.for("drizzle:Schema"),a3=Symbol.for("drizzle:Columns"),s3=Symbol.for("drizzle:ExtraConfigColumns"),dZ=Symbol.for("drizzle:OriginalName"),oZ=Symbol.for("drizzle:BaseName"),DD=Symbol.for("drizzle:IsAlias"),t3=Symbol.for("drizzle:ExtraConfigBuilder"),nQ=Symbol.for("drizzle:IsDrizzleTable");class x${static[a]="Table";static Symbol={Name:E4,Schema:cZ,OriginalName:dZ,Columns:a3,ExtraConfigColumns:s3,BaseName:oZ,IsAlias:DD,ExtraConfigBuilder:t3};[E4];[dZ];[cZ];[a3];[s3];[oZ];[DD]=!1;[nQ]=!0;[t3]=void 0;constructor($,U,G){this[E4]=this[dZ]=$,this[cZ]=U,this[oZ]=G}}function cQ($){return $!==null&&$!==void 0&&typeof $.getSQL==="function"}function dQ($){let U={sql:"",params:[]};for(let G of $)if(U.sql+=G.sql,U.params.push(...G.params),G.typings?.length){if(!U.typings)U.typings=[];U.typings.push(...G.typings)}return U}class v4{static[a]="StringChunk";value;constructor($){this.value=Array.isArray($)?$:[$]}getSQL(){return new b$([this])}}class b${constructor($){this.queryChunks=$;for(let U of $)if(W4(U,x$)){let G=U[x$.Symbol.Schema];this.usedTables.push(G===void 0?U[x$.Symbol.Name]:G+"."+U[x$.Symbol.Name])}}static[a]="SQL";decoder=e3;shouldInlineParams=!1;usedTables=[];append($){return this.queryChunks.push(...$.queryChunks),this}toQuery($){return o3.startActiveSpan("drizzle.buildSQL",(U)=>{let G=this.buildQueryFromSourceParams(this.queryChunks,$);return U?.setAttributes({"drizzle.query.text":G.sql,"drizzle.query.params":JSON.stringify(G.params)}),G})}buildQueryFromSourceParams($,U){let G=Object.assign({},U,{inlineParams:U.inlineParams||this.shouldInlineParams,paramStartIndex:U.paramStartIndex||{value:0}}),{casing:X,escapeName:D,escapeParam:V,prepareTyping:Z,inlineParams:J,paramStartIndex:Y}=G;return dQ($.map((W)=>{if(W4(W,v4))return{sql:W.value.join(""),params:[]};if(W4(W,b0))return{sql:D(W.value),params:[]};if(W===void 0)return{sql:"",params:[]};if(Array.isArray(W)){let w=[new v4("(")];for(let[K,A]of W.entries())if(w.push(A),K<W.length-1)w.push(new v4(", "));return w.push(new v4(")")),this.buildQueryFromSourceParams(w,G)}if(W4(W,b$))return this.buildQueryFromSourceParams(W.queryChunks,{...G,inlineParams:J||W.shouldInlineParams});if(W4(W,x$)){let w=W[x$.Symbol.Schema],K=W[x$.Symbol.Name];return{sql:w===void 0||W[DD]?D(K):D(w)+"."+D(K),params:[]}}if(W4(W,K6)){let w=X.getColumnCasing(W);if(U.invokeSource==="indexes")return{sql:D(w),params:[]};let K=W.table[x$.Symbol.Schema];return{sql:W.table[DD]||K===void 0?D(W.table[x$.Symbol.Name])+"."+D(w):D(K)+"."+D(W.table[x$.Symbol.Name])+"."+D(w),params:[]}}if(W4(W,Uw)){let w=W[i1].schema,K=W[i1].name;return{sql:w===void 0||W[i1].isAlias?D(K):D(w)+"."+D(K),params:[]}}if(W4(W,aZ)){if(W4(W.value,u0))return{sql:V(Y.value++,W),params:[W],typings:["none"]};let w=W.value===null?null:W.encoder.mapToDriverValue(W.value);if(W4(w,b$))return this.buildQueryFromSourceParams([w],G);if(J)return{sql:this.mapInlineParam(w,G),params:[]};let K=["none"];if(Z)K=[Z(W.encoder)];return{sql:V(Y.value++,w),params:[w],typings:K}}if(W4(W,u0))return{sql:V(Y.value++,W),params:[W],typings:["none"]};if(W4(W,b$.Aliased)&&W.fieldAlias!==void 0)return{sql:D(W.fieldAlias),params:[]};if(W4(W,x0)){if(W._.isWith)return{sql:D(W._.alias),params:[]};return this.buildQueryFromSourceParams([new v4("("),W._.sql,new v4(") "),new b0(W._.alias)],G)}if(c3(W)){if(W.schema)return{sql:D(W.schema)+"."+D(W.enumName),params:[]};return{sql:D(W.enumName),params:[]}}if(cQ(W)){if(W.shouldOmitSQLParens?.())return this.buildQueryFromSourceParams([W.getSQL()],G);return this.buildQueryFromSourceParams([new v4("("),W.getSQL(),new v4(")")],G)}if(J)return{sql:this.mapInlineParam(W,G),params:[]};return{sql:V(Y.value++,W),params:[W],typings:["none"]}}))}mapInlineParam($,{escapeString:U}){if($===null)return"null";if(typeof $==="number"||typeof $==="boolean")return $.toString();if(typeof $==="string")return U($);if(typeof $==="object"){let G=$.toString();if(G==="[object Object]")return U(JSON.stringify($));return U(G)}throw Error("Unexpected param value: "+$)}getSQL(){return this}as($){if($===void 0)return this;return new b$.Aliased(this,$)}mapWith($){return this.decoder=typeof $==="function"?{mapFromDriverValue:$}:$,this}inlineParams(){return this.shouldInlineParams=!0,this}if($){return $?this:void 0}}class b0{constructor($){this.value=$}static[a]="Name";brand;getSQL(){return new b$([this])}}var e3={mapFromDriverValue:($)=>$},$w={mapToDriverValue:($)=>$},qp={...e3,...$w};class aZ{constructor($,U=$w){this.value=$,this.encoder=U}static[a]="Param";brand;getSQL(){return new b$([this])}}function i6($,...U){let G=[];if(U.length>0||$.length>0&&$[0]!=="")G.push(new v4($[0]));for(let[X,D]of U.entries())G.push(D,new v4($[X+1]));return new b$(G)}(($)=>{function U(){return new b$([])}$.empty=U;function G(Y){return new b$(Y)}$.fromList=G;function X(Y){return new b$([new v4(Y)])}$.raw=X;function D(Y,W){let w=[];for(let[K,A]of Y.entries()){if(K>0&&W!==void 0)w.push(W);w.push(A)}return new b$(w)}$.join=D;function V(Y){return new b0(Y)}$.identifier=V;function Z(Y){return new u0(Y)}$.placeholder=Z;function J(Y,W){return new aZ(Y,W)}$.param=J})(i6||(i6={}));(($)=>{class U{constructor(G,X){this.sql=G,this.fieldAlias=X}static[a]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new U(this.sql,this.fieldAlias)}}$.Aliased=U})(b$||(b$={}));class u0{constructor($){this.name=$}static[a]="Placeholder";getSQL(){return new b$([this])}}var oQ=Symbol.for("drizzle:IsDrizzleView");class Uw{static[a]="View";[i1];[oQ]=!0;constructor({name:$,schema:U,selectedFields:G,query:X}){this[i1]={name:$,originalName:$,schema:U,selectedFields:G,query:X,isExisting:!X,isAlias:!1}}getSQL(){return new b$([this])}}K6.prototype.getSQL=function(){return new b$([this])};x$.prototype.getSQL=function(){return new b$([this])};x0.prototype.getSQL=function(){return new b$([this])};function y4($,U){return{name:typeof $==="string"&&$.length>0?$:"",config:typeof $==="object"?$:U}}var sZ=typeof TextDecoder>"u"?null:new TextDecoder;class tZ{static[a]="SQLiteForeignKeyBuilder";reference;_onUpdate;_onDelete;constructor($,U){if(this.reference=()=>{let{name:G,columns:X,foreignColumns:D}=$();return{name:G,columns:X,foreignTable:D[0].table,foreignColumns:D}},U)this._onUpdate=U.onUpdate,this._onDelete=U.onDelete}onUpdate($){return this._onUpdate=$,this}onDelete($){return this._onDelete=$,this}build($){return new Dw($,this)}}class Dw{constructor($,U){this.table=$,this.reference=U.reference,this.onUpdate=U._onUpdate,this.onDelete=U._onDelete}static[a]="SQLiteForeignKey";reference;onUpdate;onDelete;getName(){let{name:$,columns:U,foreignColumns:G}=this.reference(),X=U.map((Z)=>Z.name),D=G.map((Z)=>Z.name),V=[this.table[E4],...X,G[0].table[E4],...D];return $??`${V.join("_")}_fk`}}function Gw($,U){return`${$[E4]}_${U.join("_")}_unique`}class f$ extends lZ{static[a]="SQLiteColumnBuilder";foreignKeyConfigs=[];references($,U={}){return this.foreignKeyConfigs.push({ref:$,actions:U}),this}unique($){return this.config.isUnique=!0,this.config.uniqueName=$,this}generatedAlwaysAs($,U){return this.config.generated={as:$,type:"always",mode:U?.mode??"virtual"},this}buildForeignKeys($,U){return this.foreignKeyConfigs.map(({ref:G,actions:X})=>{return((D,V)=>{let Z=new tZ(()=>{let J=D();return{columns:[$],foreignColumns:[J]}});if(V.onUpdate)Z.onUpdate(V.onUpdate);if(V.onDelete)Z.onDelete(V.onDelete);return Z.build(U)})(G,X)})}}class p$ extends K6{constructor($,U){if(!U.uniqueName)U.uniqueName=Gw($,[U.name]);super($,U);this.table=$}static[a]="SQLiteColumn"}class Xw extends f${static[a]="SQLiteBigIntBuilder";constructor($){super($,"bigint","SQLiteBigInt")}build($){return new Vw($,this.config)}}class Vw extends p${static[a]="SQLiteBigInt";getSQLType(){return"blob"}mapFromDriverValue($){if(typeof Buffer<"u"&&Buffer.from){let U=Buffer.isBuffer($)?$:$ instanceof ArrayBuffer?Buffer.from($):$.buffer?Buffer.from($.buffer,$.byteOffset,$.byteLength):Buffer.from($);return BigInt(U.toString("utf8"))}return BigInt(sZ.decode($))}mapToDriverValue($){return Buffer.from($.toString())}}class Zw extends f${static[a]="SQLiteBlobJsonBuilder";constructor($){super($,"json","SQLiteBlobJson")}build($){return new Jw($,this.config)}}class Jw extends p${static[a]="SQLiteBlobJson";getSQLType(){return"blob"}mapFromDriverValue($){if(typeof Buffer<"u"&&Buffer.from){let U=Buffer.isBuffer($)?$:$ instanceof ArrayBuffer?Buffer.from($):$.buffer?Buffer.from($.buffer,$.byteOffset,$.byteLength):Buffer.from($);return JSON.parse(U.toString("utf8"))}return JSON.parse(sZ.decode($))}mapToDriverValue($){return Buffer.from(JSON.stringify($))}}class Pw extends f${static[a]="SQLiteBlobBufferBuilder";constructor($){super($,"buffer","SQLiteBlobBuffer")}build($){return new Ww($,this.config)}}class Ww extends p${static[a]="SQLiteBlobBuffer";mapFromDriverValue($){if(Buffer.isBuffer($))return $;return Buffer.from($)}getSQLType(){return"blob"}}function Yw($,U){let{name:G,config:X}=y4($,U);if(X?.mode==="json")return new Zw(G);if(X?.mode==="bigint")return new Xw(G);return new Pw(G)}class Hw extends f${static[a]="SQLiteCustomColumnBuilder";constructor($,U,G){super($,"custom","SQLiteCustomColumn");this.config.fieldConfig=U,this.config.customTypeParams=G}build($){return new ww($,this.config)}}class ww extends p${static[a]="SQLiteCustomColumn";sqlName;mapTo;mapFrom;constructor($,U){super($,U);this.sqlName=U.customTypeParams.dataType(U.fieldConfig),this.mapTo=U.customTypeParams.toDriver,this.mapFrom=U.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue($){return typeof this.mapFrom==="function"?this.mapFrom($):$}mapToDriverValue($){return typeof this.mapTo==="function"?this.mapTo($):$}}function r0($){return(U,G)=>{let{name:X,config:D}=y4(U,G);return new Hw(X,D,$)}}class h0 extends f${static[a]="SQLiteBaseIntegerBuilder";constructor($,U,G){super($,U,G);this.config.autoIncrement=!1}primaryKey($){if($?.autoIncrement)this.config.autoIncrement=!0;return this.config.hasDefault=!0,super.primaryKey()}}class m0 extends p${static[a]="SQLiteBaseInteger";autoIncrement=this.config.autoIncrement;getSQLType(){return"integer"}}class Kw extends h0{static[a]="SQLiteIntegerBuilder";constructor($){super($,"number","SQLiteInteger")}build($){return new Ow($,this.config)}}class Ow extends m0{static[a]="SQLiteInteger"}class Aw extends h0{static[a]="SQLiteTimestampBuilder";constructor($,U){super($,"date","SQLiteTimestamp");this.config.mode=U}defaultNow(){return this.default(i6`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build($){return new _w($,this.config)}}class _w extends m0{static[a]="SQLiteTimestamp";mode=this.config.mode;mapFromDriverValue($){if(this.config.mode==="timestamp")return new Date($*1000);return new Date($)}mapToDriverValue($){let U=$.getTime();if(this.config.mode==="timestamp")return Math.floor(U/1000);return U}}class Fw extends h0{static[a]="SQLiteBooleanBuilder";constructor($,U){super($,"boolean","SQLiteBoolean");this.config.mode=U}build($){return new qw($,this.config)}}class qw extends m0{static[a]="SQLiteBoolean";mode=this.config.mode;mapFromDriverValue($){return Number($)===1}mapToDriverValue($){return $?1:0}}function Y4($,U){let{name:G,config:X}=y4($,U);if(X?.mode==="timestamp"||X?.mode==="timestamp_ms")return new Aw(G,X.mode);if(X?.mode==="boolean")return new Fw(G,X.mode);return new Kw(G)}class Rw extends f${static[a]="SQLiteNumericBuilder";constructor($){super($,"string","SQLiteNumeric")}build($){return new Nw($,this.config)}}class Nw extends p${static[a]="SQLiteNumeric";mapFromDriverValue($){if(typeof $==="string")return $;return String($)}getSQLType(){return"numeric"}}class Mw extends f${static[a]="SQLiteNumericNumberBuilder";constructor($){super($,"number","SQLiteNumericNumber")}build($){return new Qw($,this.config)}}class Qw extends p${static[a]="SQLiteNumericNumber";mapFromDriverValue($){if(typeof $==="number")return $;return Number($)}mapToDriverValue=String;getSQLType(){return"numeric"}}class Iw extends f${static[a]="SQLiteNumericBigIntBuilder";constructor($){super($,"bigint","SQLiteNumericBigInt")}build($){return new Bw($,this.config)}}class Bw extends p${static[a]="SQLiteNumericBigInt";mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return"numeric"}}function Tw($,U){let{name:G,config:X}=y4($,U),D=X?.mode;return D==="number"?new Mw(G):D==="bigint"?new Iw(G):new Rw(G)}class zw extends f${static[a]="SQLiteRealBuilder";constructor($){super($,"number","SQLiteReal")}build($){return new vw($,this.config)}}class vw extends p${static[a]="SQLiteReal";getSQLType(){return"real"}}function Lw($){return new zw($??"")}class Sw extends f${static[a]="SQLiteTextBuilder";constructor($,U){super($,"string","SQLiteText");this.config.enumValues=U.enum,this.config.length=U.length}build($){return new gw($,this.config)}}class gw extends p${static[a]="SQLiteText";enumValues=this.config.enumValues;length=this.config.length;constructor($,U){super($,U)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:""}`}}class jw extends f${static[a]="SQLiteTextJsonBuilder";constructor($){super($,"json","SQLiteTextJson")}build($){return new Ew($,this.config)}}class Ew extends p${static[a]="SQLiteTextJson";getSQLType(){return"text"}mapFromDriverValue($){return JSON.parse($)}mapToDriverValue($){return JSON.stringify($)}}function O$($,U={}){let{name:G,config:X}=y4($,U);if(X.mode==="json")return new jw(G);return new Sw(G,X)}function Cw(){return{blob:Yw,customType:r0,integer:Y4,numeric:Tw,real:Lw,text:O$}}var eZ=Symbol.for("drizzle:SQLiteInlineForeignKeys");class GD extends x${static[a]="SQLiteTable";static Symbol=Object.assign({},x$.Symbol,{InlineForeignKeys:eZ});[x$.Symbol.Columns];[eZ]=[];[x$.Symbol.ExtraConfigBuilder]=void 0}function aQ($,U,G,X,D=$){let V=new GD($,X,D),Z=typeof U==="function"?U(Cw()):U,J=Object.fromEntries(Object.entries(Z).map(([W,w])=>{let K=w;K.setName(W);let A=K.build(V);return V[eZ].push(...K.buildForeignKeys(A,V)),[W,A]})),Y=Object.assign(V,J);if(Y[x$.Symbol.Columns]=J,Y[x$.Symbol.ExtraConfigColumns]=J,G)Y[GD.Symbol.ExtraConfigBuilder]=G;return Y}var f4=($,U,G)=>{return aQ($,U,G)};class kw{constructor($,U){this.name=$,this.value=U}static[a]="SQLiteCheckBuilder";brand;build($){return new xw($,this)}}class xw{constructor($,U){this.table=$,this.name=U.name,this.value=U.value}static[a]="SQLiteCheck";name;value}function bw($,U){return new kw($,U)}class uw{constructor($,U){this.name=$,this.unique=U}static[a]="SQLiteIndexBuilderOn";on(...$){return new rw(this.name,$,this.unique)}}class rw{static[a]="SQLiteIndexBuilder";config;constructor($,U,G){this.config={name:$,columns:U,unique:G,where:void 0}}where($){return this.config.where=$,this}build($){return new hw(this.config,$)}}class hw{static[a]="SQLiteIndex";config;constructor($,U){this.config={...$,table:U}}}function C4($){return new uw($,!1)}function y0(...$){if($[0].columns)return new $J($[0].columns,$[0].name);return new $J($)}class $J{static[a]="SQLitePrimaryKeyBuilder";columns;name;constructor($,U){this.columns=$,this.name=U}build($){return new mw($,this.columns,this.name)}}class mw{constructor($,U,G){this.table=$,this.columns=U,this.name=G}static[a]="SQLitePrimaryKey";columns;name;getName(){return this.name??`${this.table[GD.Symbol.Name]}_${this.columns.map(($)=>$.name).join("_")}_pk`}}var yw=f4("job_queue",{id:O$("id").primaryKey().$defaultFn(()=>l6()),type:O$("type").notNull(),data:O$("data").notNull(),result:O$("result",{mode:"json"}),source:O$("source"),metadata:O$("metadata",{mode:"json"}).$type().notNull(),status:O$("status",{enum:["pending","processing","completed","failed"]}).notNull().default("pending"),priority:Y4("priority").notNull().default(0),retryCount:Y4("retryCount").notNull().default(0),maxRetries:Y4("maxRetries").notNull().default(3),lastError:O$("lastError"),createdAt:Y4("createdAt").notNull().$defaultFn(()=>Date.now()),scheduledFor:Y4("scheduledFor").notNull().$defaultFn(()=>Date.now()),startedAt:Y4("startedAt"),completedAt:Y4("completedAt")},($)=>({queueReadyIdx:C4("idx_job_queue_ready").on($.status,$.priority,$.scheduledFor),jobTypeIdx:C4("idx_job_queue_type").on($.type,$.status),jobSourceIdx:C4("idx_job_queue_source").on($.source)}));var Cl=P.looseObject({deduplicationKey:P.string().optional()});var Xi=P.preprocess(($)=>{if(typeof $!=="string")return $;return JSON.parse($)},P.record(P.string(),P.unknown()));var Ji=P.record(P.string(),P.unknown());var sQ=P.object({id:P.string(),type:P.string(),data:P.string(),status:P.enum(["pending","processing","completed","failed"]),source:P.string().nullable(),priority:P.number(),retryCount:P.number(),maxRetries:P.number(),lastError:P.string().nullable(),createdAt:P.number(),scheduledFor:P.number(),startedAt:P.number().nullable(),completedAt:P.number().nullable(),metadata:l1,result:P.unknown().nullable().optional()});function UJ($,U,G){return async(X)=>{let{type:D,data:V,toolContext:Z=null,options:J}=X,{metadata:Y,...W}=J??{},w={source:U,...J?.rootJobId&&{rootJobId:J.rootJobId},...W,metadata:{operationType:"data_processing",pluginId:U,...Z&&{interfaceType:Z.interfaceType,channelId:Z.channelId},...Y}},K=G&&!D.includes(":")?`${U}:${D}`:D;return $.enqueue({type:K,data:V,options:w})}}function DJ($,U){return async(G,X)=>{let D=l6(),V=G.map((J)=>({...J,type:J.type.includes(":")?J.type:`${U}:${J.type}`})),Z={...X,source:U,rootJobId:D,metadata:{...X?.metadata,operationType:"batch_processing",pluginId:U}};return await $.enqueueBatch(V,Z,D,U),D}}function GJ($,U){return(G,X)=>{let D=G.includes(":")?G:`${U}:${G}`;$.registerHandler(D,X,U)}}var tQ=P.custom(($)=>typeof $==="object"&&$!==null&&("safeParse"in $)),eQ=P.object({name:P.string(),schema:tQ});function fw($){return eQ.safeParse($).success}function $I($){if(!$)return;return{status:$.status,message:$.message,lastCheck:$.lastCheck?.toISOString(),details:$.details}}function pw($){return{model:$.model,version:$.version,uptime:$.uptime,entities:$.entities,entityCounts:$.entityCounts,embeddings:$.embeddings,ai:$.ai,daemons:$.daemons.map((U)=>({name:U.name,pluginId:U.pluginId,status:U.status,health:$I(U.health)})),endpoints:$.endpoints,interactions:$.interactions}}import{createClient as xi}from"@libsql/client";var f0=f4("conversations",{id:O$("id").primaryKey(),sessionId:O$("session_id").notNull(),interfaceType:O$("interface_type").notNull(),channelId:O$("channel_id").notNull(),started:O$("started").notNull(),lastActive:O$("last_active").notNull(),metadata:O$("metadata"),created:O$("created").notNull(),updated:O$("updated").notNull()},($)=>({sessionIdx:C4("idx_conversations_session").on($.sessionId),channelIdx:C4("idx_conversations_channel").on($.channelId),interfaceSessionIdx:C4("idx_conversations_interface_session").on($.interfaceType,$.sessionId),interfaceChannelIdx:C4("idx_conversations_interface_channel").on($.interfaceType,$.channelId)})),lw=f4("messages",{id:O$("id").primaryKey(),conversationId:O$("conversation_id").notNull().references(()=>f0.id,{onDelete:"cascade"}),role:O$("role").notNull(),content:O$("content").notNull(),timestamp:O$("timestamp").notNull(),metadata:O$("metadata")},($)=>({conversationIdx:C4("idx_messages_conversation").on($.conversationId),timestampIdx:C4("idx_messages_timestamp").on($.timestamp)})),iw=f4("summary_tracking",{conversationId:O$("conversation_id").primaryKey().references(()=>f0.id,{onDelete:"cascade"}),lastSummarizedAt:O$("last_summarized_at"),lastMessageId:O$("last_message_id"),messagesSinceSummary:Y4("messages_since_summary").default(0),updated:O$("updated").notNull()});var UI=P.preprocess(($)=>{if(typeof $!=="string")return $;try{return JSON.parse($)}catch{return}},P.record(P.string(),P.unknown())).catch({});function VD($){return UI.parse($)}var p0=P.object({actorId:P.string(),canonicalId:P.string().optional(),interfaceType:P.string(),role:k6,displayName:P.string().optional(),username:P.string().optional(),isBot:P.boolean().optional()}),l0=P.object({messageId:P.string().optional(),channelId:P.string().optional(),channelName:P.string().optional(),threadId:P.string().optional(),metadata:P.record(P.string(),P.unknown()).optional()}),DI=P.looseObject({actor:p0.optional(),source:l0.optional()});var GI=P.object({id:P.string(),conversationId:P.string(),role:P.string(),content:P.string(),timestamp:P.string(),metadata:P.string().nullable()}),XI=P.object({conversationId:P.string(),messageCount:P.number(),messages:P.array(GI),windowStart:P.number(),windowEnd:P.number(),windowSize:P.number(),timestamp:P.string()});var n1=P.record(P.string(),P.unknown());var JI=P.object({id:P.string(),sessionId:P.string(),interfaceType:P.string(),channelId:P.string(),channelName:P.string().optional(),startedAt:P.string(),lastActiveAt:P.string(),createdAt:P.string(),updatedAt:P.string(),metadata:n1}),PI=P.object({id:P.string(),conversationId:P.string(),role:k6,content:P.string(),timestamp:P.string(),metadata:n1});function WI($){let U=k6.safeParse($);return U.success?U.data:"user"}function i0($){let U=VD($.metadata),G=typeof U.channelName==="string"?U.channelName:void 0;return{id:$.id,sessionId:$.sessionId,interfaceType:$.interfaceType,channelId:$.channelId,channelName:G,startedAt:$.started,lastActiveAt:$.lastActive,createdAt:$.created,updatedAt:$.updated,metadata:U}}function nw($){return{id:$.id,conversationId:$.conversationId,role:WI($.role),content:$.content,timestamp:$.timestamp,metadata:VD($.metadata)}}var XJ=P.object({name:P.string(),role:P.string(),purpose:P.string(),values:P.array(P.string())}),VJ=P.object({name:P.string(),kind:P.enum(["professional","team","collective"]),organization:P.string().optional(),description:P.string().optional(),avatar:P.string().optional(),website:P.string().optional(),email:P.string().optional(),socialLinks:P.array(P.object({platform:P.enum(["github","instagram","linkedin","email","website"]),url:P.string(),label:P.string().optional()})).optional()});function cw($){return XJ.parse($)}function dw($){return VJ.parse($)}function ow($){return async()=>{return pw(await $.getAppInfo())}}function aw($,U){return{get:()=>cw($.getIdentity()),getProfile:()=>dw($.getProfile()),getAppInfo:U}}function sw($,U,G){let X=$.getMessageBus();return{send:async(V)=>{return X.send({...V,sender:U})},subscribe:(V,Z)=>{if(fw(V)){let J=V,Y=Z,W=async(w)=>{let K=J.schema.safeParse(w.payload);if(!K.success)return G.warn(`Invalid payload for channel ${J.name}`,{error:K.error.message}),{noop:!0};let{payload:A,...O}=w;return Y(K.data,O)};return X.subscribe(J.name,W)}return X.subscribe(V,Z)}}}function tw($,U){let G=$.getJobQueueService();return{...$.jobs,enqueue:UJ(G,U,!0),enqueueBatch:DJ($.jobs,U),registerHandler:GJ(G,U)}}function ew($){let U=$.getPermissionService();return{assertEntityActionAllowed:(G,X,D)=>{U.assertEntityActionAllowed(G,X,D.userPermissionLevel)}}}function $K($){return{get:async(U)=>{let X=await $.getConversationService().getConversation(U);return X?i0(X):null},search:async(U)=>{return(await $.getConversationService().searchConversations(U)).map(i0)},list:async(U)=>{return(await $.getConversationService().listConversations(U)).map(i0)},getMessages:async(U,G)=>{return(await $.getConversationService().getMessages(U,G)).map(nw)},countMessages:async(U)=>{return $.getConversationService().countMessages(U)}}}function UK($,U){return{registerHandler:(G,X)=>{$.registerEvalHandler(U,G,X)}}}function DK($){return{register:(U,G)=>{$.getInsightsRegistry().register(U,G)}}}function GK($,U){return{register:(G)=>{$.registerEndpoint({...G,pluginId:U})}}}function XK($,U){return{register:(G)=>{$.registerInteraction({...G,pluginId:U})}}}function c1($,U,G){let X=$.getEntityService(),D=$.getLogger().child(U),V=$.getDomain(),Z=$.getLocalSiteUrl(),J=$.shouldPreferLocalUrls(),Y=$.getThemeCSS(),W=ow($),w=$.getAttachmentRegistry(),K=$.getRuntimeUploadRegistry(),A=$.getRuntimeState();return{pluginId:U,logger:D,entityService:X,semantic:{project:(O)=>X.projectSemanticSpace(O)},identity:aw($,W),appInfo:W,judge:(O)=>$.judge(O),domain:V,siteUrl:V?`https://${V}`:void 0,localSiteUrl:Z,previewUrl:V?`https://${mZ(V)}`:void 0,preferLocalUrls:J,themeCSS:Y,entityDisplay:G?.entityDisplay,spaces:$.getSpaces(),permissions:ew($),messaging:sw($,U,D),jobs:tw($,U),attachments:w,uploads:K,runtimeState:A,conversations:$K($),dataDir:$.getDataDir(),eval:UK($,U),insights:DK($),endpoints:GK($,U),interactions:XK($,U)}}import{createClient as gn}from"@libsql/client";var n0=f4("entities",{id:O$("id").notNull(),entityType:O$("entityType").notNull(),content:O$("content").notNull(),contentHash:O$("contentHash").notNull(),visibility:O$("visibility",{enum:["public","shared","restricted"]}).notNull().default("public"),metadata:O$("metadata",{mode:"json"}).$type().notNull().default(i6`'{}'`),created:Y4("created").notNull().$defaultFn(()=>Date.now()),updated:Y4("updated").notNull().$defaultFn(()=>Date.now())},($)=>{return{pk:y0({columns:[$.id,$.entityType]}),visibilityCheck:bw("entities_visibility_check",i6`${$.visibility} IN ('public', 'shared', 'restricted')`)}});import{createClient as hn}from"@libsql/client";var VK=r0({dataType(){return"F32_BLOB(1536)"},toDriver($){return Buffer.from($.buffer)},fromDriver($){return new Float32Array($.buffer,$.byteOffset,$.byteLength/4)}});var c0=f4("embeddings",{entityId:O$("entity_id").notNull(),entityType:O$("entity_type").notNull(),embedding:VK("embedding").notNull(),contentHash:O$("content_hash").notNull()},($)=>{return{pk:y0({columns:[$.entityId,$.entityType]})}});var YI=P.enum(["public","shared","restricted"]),ZD=P.union([YI,P.literal("private")]).optional().transform(($)=>{if($===void 0)return"public";if($==="private")return"restricted";return $});function d0($){if($==="anchor")return"restricted";if($==="trusted")return"shared";return"public"}var JJ=P.object({id:P.string(),entityType:P.string(),content:P.string(),created:P.string().datetime(),updated:P.string().datetime(),visibility:ZD,metadata:P.record(P.string(),P.unknown()),contentHash:P.string()}),KI=P.enum(["public","shared","restricted"]),OI=P.object({id:P.string(),entityType:P.string(),content:P.string(),created:P.string().datetime(),updated:P.string().datetime(),visibility:P.union([KI,P.literal("private")]).optional().transform(($)=>{if($===void 0)return"public";if($==="private")return"restricted";return $}),metadata:P.record(P.string(),P.unknown()),contentHash:P.string()}),JK=P.object({}),AI=P.object({mediaType:P.string(),url:P.string(),downloadUrl:P.string().optional(),previewUrl:P.string().optional(),filename:P.string().optional(),sizeBytes:P.number().optional(),source:P.object({entityType:P.string().optional(),entityId:P.string().optional(),attachmentType:P.string().optional()}).optional()});var Uc=P.object({id:P.string().min(1,"Entity ID is required"),entityType:P.string().min(1,"Entity type is required"),contentHash:P.string().min(1,"Content hash is required"),operation:P.enum(["create","update"])});var Wc=P.object({limit:P.number().int().positive().optional().default(20),offset:P.number().int().min(0).optional().default(0),types:P.array(P.string()).optional().default([]),excludeTypes:P.array(P.string()).optional().default([]),weight:P.record(P.string(),P.number()).optional(),visibilityScope:P.enum(["public","shared","restricted"]).optional(),includeUngenerated:P.boolean().optional().default(!1),minScore:P.number().min(0).optional()}),Yc=P.preprocess(($)=>{if(typeof $!=="string")return $;return JSON.parse($)},P.record(P.string(),P.unknown()));var jJ=ND(SJ(),1);function JG($,U){if(Object.keys(U).length===0)return $;let G=Object.fromEntries(Object.entries(U).filter(([,X])=>X!==void 0));return jJ.default.stringify($,G)}function gJ($){if($ instanceof Date)return $.toISOString();if(Array.isArray($))return $.map(gJ);if($!==null&&typeof $==="object"){let U={};for(let[G,X]of Object.entries($))U[G]=gJ(X);return U}return $}function AD($,U){let{content:G,data:X}=jJ.default($),D=gJ(X);return{content:G.trim(),metadata:U.parse(D)}}var $d=P.object({visibility:P.enum(["public","shared","restricted","private"]).optional().transform(($)=>{if($===void 0)return"public";return $==="private"?"restricted":$})});var Xd=P.looseObject({issues:P.array(P.looseObject({message:P.string()}))});var wd=P.record(P.string(),P.unknown());var Mv=P.object({field:P.string(),direction:P.enum(["asc","desc"]),nullsFirst:P.boolean().optional()}),Nd=P.object({limit:P.number().int().positive().optional(),offset:P.number().int().min(0).optional().default(0),sortFields:P.array(Mv).optional(),filter:P.object({metadata:P.record(P.string(),P.unknown()).optional(),visibilityScope:P.enum(["public","shared","restricted"]).optional()}).optional(),publishedOnly:P.boolean().optional()});var Sd=P.custom(($)=>typeof $==="object"&&$!==null&&!Array.isArray($));var gd=P.object({id:P.string().min(1),entityType:P.string().min(1),contentHash:P.string().min(1)});var gv=ND(SJ(),1);var Do=E0();var wo=P.record(P.string(),P.unknown());var kv=P.object({currentPage:P.number(),totalPages:P.number(),totalItems:P.number(),pageSize:P.number(),hasNextPage:P.boolean(),hasPrevPage:P.boolean()});function xv($){return $.replace(/:/g,"-")}function bv($){return $.split(/[:.-]/).map((U)=>U.charAt(0).toUpperCase()+U.slice(1)).join(" ")}var EJ=new Map;async function zA($,U,G){let X=EJ.get(U);if(X!==void 0)return X;let D=xv(U),V;try{V=await $.getEntity({entityType:"prompt",id:D})}catch{return G}if(V?.content){let Z=AD(V.content,P.record(P.string(),P.unknown())).content;return EJ.set(U,Z),Z}try{let Z=bv(U),J=JG(G,{title:Z,target:U});await $.createEntity({entity:{id:D,entityType:"prompt",content:J,metadata:{title:Z,target:U,slug:D}}})}catch{}return EJ.set(U,G),G}function PG($){let U=$.getEntityService(),G=$.getEntityRegistry(),X=$.getDataSourceRegistry();return{register:(D,V,Z,J)=>{G.registerEntityType(D,V,Z,J)},getAdapter:(D)=>{try{return G.getAdapter(D)}catch{return}},extendFrontmatterSchema:(D,V)=>{G.extendFrontmatterSchema(D,V)},getEffectiveFrontmatterSchema:(D)=>{return G.getEffectiveFrontmatterSchema(D)},registerCreateInterceptor:(D,V)=>{G.registerCreateInterceptor(D,V)},registerUploadSaveHandler:(D)=>{G.registerUploadSaveHandler(D)},getUploadSaveHandler:(D)=>{return G.getUploadSaveHandler(D)},update:async(D)=>{return U.updateEntity({entity:D})},registerDataSource:(D)=>{X.register(D)}}}function WG($){return{resolve:(U,G)=>{return zA($,U,G)}}}function vA($,U,G){let X=c1($,U,G),D=$.getEntityService();return{...X,entityService:D,entities:PG($),ai:{query:(V,Z)=>$.query(V,Z),generate:async(V)=>{return $.generateContent(V)},generateObject:async(V,Z)=>{return $.generateObject(V,Z)},generateImage:async(V,Z)=>{return $.generateImage(V,Z)},canGenerateImages:()=>{return $.canGenerateImages()}},prompts:WG(D),permissions:X.permissions}}function SA($,U,G){let X=!1,D=!1;if($.jobs.registerHandler(G.job.type,G.job.handler),G.initialSync){let V=G.initialSync;$.messaging.subscribe("sync:initial:completed",async()=>{if(X)return{success:!0};if(X=!0,!(await V.shouldEnqueue?.()??!0))return U.info("Skipping derived entity projection initial sync",{projectionId:G.id,targetType:G.targetType}),{success:!0};return D=await LA($,U,G,V.jobData,rv(V.jobOptions),"initial-sync"),{success:!0}})}if(G.sourceChange){let V=G.sourceChange,Z=new Set(V.sourceTypes),J=V.events??["entity:created","entity:updated"],Y=async(W)=>{if(V.requireInitialSync&&!X)return{success:!0};let w=W.payload,K=uv(V,w);if(!K||!Z.has("*")&&!Z.has(K))return{success:!0};if(!(await V.shouldEnqueue?.(w)??!0))return{success:!0};let O=await V.jobData(w);if(!O)return{success:!0};return await LA($,U,G,O,V.jobOptions?.(w),"source-change"),{success:!0}};for(let W of J)$.messaging.subscribe(W,Y)}return{hasObservedInitialSync:()=>X,hasQueuedInitialSync:()=>D}}function uv($,U){if($.sourceType)return $.sourceType;if($.sourceKind&&$.sourceKind!=="entity")return $.sourceKind;return U.entityType}async function LA($,U,G,X,D,V){try{return await $.jobs.enqueue({type:G.job.type,data:X,...D?{options:D}:{}}),U.info("Queued derived entity projection",{projectionId:G.id,targetType:G.targetType,reason:V}),!0}catch(Z){return U.error("Failed to queue derived entity projection",{projectionId:G.id,targetType:G.targetType,reason:V,error:m4(Z)}),!1}}function rv($){return typeof $==="function"?$():$}var Ma=P.object({});class YG extends C6{type="entity";entityActionPolicy;derivedEntityProjectionControllers=new Map;constructor($,U,G,X,D){super($,U,G,X);if(D!==void 0)this.entityActionPolicy=D}async register($,U){let G=vA($,this.id,U);if(this.context=G,this.setupMessageHandlers(G),G.entities.register(this.entityType,this.schema,this.adapter,this.getEntityTypeConfig()),this.interceptCreate!==YG.prototype.interceptCreate)G.entities.registerCreateInterceptor(this.entityType,(Y,W)=>this.interceptCreate(Y,W,G));let X=this.createGenerationHandler(G);if(X)G.jobs.registerHandler(`${this.entityType}:generation`,X);let D=this.getTemplates();if(D&&Object.keys(D).length>0)$.registerTemplates(D,this.id);let V=this.getDataSources();for(let Y of V)G.entities.registerDataSource(Y);let Z=this.getDerivedEntityProjections(G);for(let Y of Z){let W=SA(G,this.logger,Y);this.derivedEntityProjectionControllers.set(Y.id,W)}await this.onRegister(this.context);let J=await this.getInstructions();return{tools:[],resources:[],...J&&{instructions:J}}}async interceptCreate($,U,G){return{kind:"continue",input:$}}createGenerationHandler($){return null}getTemplates(){return null}getDataSources(){return[]}getEntityTypeConfig(){return}getDerivedEntityProjections($){return[]}getDerivedEntityProjectionController($){return this.derivedEntityProjectionControllers.get($)}}class gA extends YG{hooks;constructor($,U,G,X,D){super($,U,G,X);this.hooks=D}get entityType(){return this.hooks.getEntityType()}get schema(){return this.hooks.getSchema()}get adapter(){return this.hooks.getAdapter()}onRegister($){return this.hooks.onRegister($)}onReady($){return this.hooks.onReady($)}onShutdown(){return this.hooks.onShutdown()}getEntityTypeConfig(){return this.hooks.getEntityTypeConfig()}getDataSources(){return this.hooks.getDataSources()}getInstructions(){return this.hooks.getInstructions()}interceptCreate($,U,G){return this.hooks.interceptCreate($,U,G)}}class CJ{type="entity";id;version;packageName;description;delegate;constructor($,U,G,X){if(this.id=$,this.version=U.version,this.packageName=U.name,U.description!==void 0)this.description=U.description;this.delegate=new gA($,U,G,X,{getEntityType:()=>this.entityType,getSchema:()=>this.schema,getAdapter:()=>this.adapter,onRegister:(D)=>this.onRegister(D),onReady:(D)=>this.onReady(D),onShutdown:()=>this.onShutdown(),getEntityTypeConfig:()=>this.getEntityTypeConfig(),getDataSources:()=>this.getDataSources(),getInstructions:()=>this.getInstructions(),interceptCreate:(D,V,Z)=>this.interceptCreate(D,V,Z)})}register($,U){return this.delegate.register($,U)}async onRegister($){}async onReady($){}async onShutdown(){}async getInstructions(){return}getEntityTypeConfig(){return}getDataSources(){return[]}async interceptCreate($,U,G){return{kind:"continue",input:$}}ready(){return this.delegate.ready()}shutdown(){return this.delegate.shutdown?.()??Promise.resolve()}}function jA($){return NV($)}function EA($){if(!$)return;return{...$.userPermissionLevel&&{userPermissionLevel:$.userPermissionLevel},...$.interfaceType&&{interfaceType:$.interfaceType},...$.channelId&&{channelId:$.channelId},...$.channelName&&{channelName:$.channelName},...$.actor&&{actor:$.actor},...$.source&&{source:$.source},...$.attachments&&{attachments:$.attachments}}}function CA($){return{chat:async(U,G,X)=>{return jA(await $.chat(U,G,EA(X)))},confirmPendingAction:async(U,G,X,D)=>{let V=EA(D);if(!V)throw Error("Confirmation requires caller context.");return jA(await $.confirmPendingAction(U,G,X,V))},invalidate:()=>{$.invalidateAgent()}}}function kA($,U,G){let X=c1($,U,G),D=$.getMCPService(),V=$.getPermissionService(),Z=CA($.getAgentService());return{...X,mcpTransport:D,agent:Z,permissions:{...X.permissions,getUserLevel:(J,Y,W)=>{return V.determineUserLevel(J,Y,W)}},daemons:{register:(J,Y)=>{let W=`${U}:${J}`;$.registerDaemon(W,Y,U),X.logger.debug(`Registered daemon: ${W}`)}},conversations:{...X.conversations,start:async(J)=>{return $.getConversationService().startConversation(J)},addMessage:async(J)=>{await $.getConversationService().addMessage(J)},updateMetadata:async(J)=>{return $.getConversationService().updateConversationMetadata(J)},delete:async(J)=>{return $.getConversationService().deleteConversation(J)}},tools:{listForPermissionLevel:(J)=>{return $.listToolsForPermissionLevel(J)}},apiRoutes:{getRoutes:()=>{return $.getPluginApiRoutes()},getMessageBus:()=>{return $.getMessageBus()}},webRoutes:{getRoutes:()=>{return $.getPluginWebRoutes()}},plugins:{has:(J)=>$.hasPlugin(J)}}}var hv=3600000;class _D extends C6{type="interface";daemon;jobTrackingEntries=new Map;jobTrackingTtlMs=hv;async register($,U){let G=kA($,this.id,U);if(this.context=G,this.initializeDaemon(),this.daemon)await this.registerDaemon(G);return this.setupMessageHandlers(G),await this.onRegister(G),this.getCapabilities()}async onRegister($){}async registerDaemon($){if(!this.daemon)return;$.daemons.register(this.id,this.daemon),$.logger.debug(`Registered daemon for interface: ${this.id}`)}createDaemon(){return}requiresDaemonStartup(){return!1}getWebRoutes(){return[]}initializeDaemon(){let $=this.createDaemon();if($)this.daemon=$}async handleProgressEvent($,U){}cleanupExpiredEntries(){let $=Date.now(),U=[];for(let[G,X]of this.jobTrackingEntries)if($-X.createdAt>this.jobTrackingTtlMs)U.push(G);for(let G of U)this.jobTrackingEntries.delete(G)}ownsJob($,U){return this.jobTrackingEntries.has($)||U!==void 0&&this.jobTrackingEntries.has(U)}getJobTracking($,U){let G=this.jobTrackingEntries.get($);if(G)return G.info;if(U){let X=this.jobTrackingEntries.get(U);if(X)return X.info}return}setJobTracking($,U){this.cleanupExpiredEntries(),this.jobTrackingEntries.set($,{info:U,createdAt:Date.now()})}removeJobTracking($){this.jobTrackingEntries.delete($)}async createJobWithTracking($,U){let X=await this.getContext().jobs.enqueue($);return this.setJobTracking(X,U),X}async createBatchWithTracking($,U,G){let D=await this.getContext().jobs.enqueueBatch($,G);return this.setJobTracking(D,U),D}}class xA extends _D{hooks;constructor($,U,G,X,D){super($,U,G,X);this.hooks=D}onRegister($){return this.hooks.onRegister($)}onReady($){return this.hooks.onReady($)}onShutdown(){return this.hooks.onShutdown()}getTools(){return this.hooks.getTools()}getResources(){return this.hooks.getResources()}getInstructions(){return this.hooks.getInstructions()}getWebRoutes(){return this.hooks.getWebRoutes()}requiresDaemonStartup(){return this.hooks.requiresDaemonStartup()}}class FD{type="interface";id;version;packageName;description;delegate;constructor($,U,G,X){if(this.id=$,this.version=U.version,this.packageName=U.name,U.description!==void 0)this.description=U.description;this.delegate=new xA($,U,G,X,{onRegister:(D)=>this.onRegister(D),onReady:(D)=>this.onReady(D),onShutdown:()=>this.onShutdown(),getTools:()=>this.getTools(),getResources:()=>this.getResources(),getInstructions:()=>this.getInstructions(),getWebRoutes:()=>this.getWebRoutes(),requiresDaemonStartup:()=>this.requiresDaemonStartup()})}register($,U){return this.delegate.register($,U)}async onRegister($){}async onReady($){}async onShutdown(){}async getTools(){return[]}async getResources(){return[]}async getInstructions(){return}getWebRoutes(){return[]}requiresDaemonStartup(){return!1}ready(){return this.delegate.ready()}shutdown(){return this.delegate.shutdown?.()??Promise.resolve()}}function bA($,U){$.messaging.subscribe("job-progress",async(G)=>{try{let X=pZ.safeParse(G.payload);if(!X.success)return U.onInvalidSchema(),{success:!1};let D=X.data;return await U.onProgress(D,D.metadata),{success:!0}}catch(X){return U.onError(X),{success:!1}}})}function uA($){let U=$.status==="completed"?"\u2705":"\u274C",G=$.status==="completed"?"completed":"failed",X=$.metadata.operationType.replace(/_/g," "),D=$.metadata.operationTarget?`: ${$.metadata.operationTarget}`:"",V=`${U} **${X}${D}** ${G}`;if($.message)V+=`
189
189
  ${$.message}`;return V}function rA($){let U=$.metadata.operationType.replace(/_/g," "),G=$.metadata.operationTarget?`: ${$.metadata.operationTarget}`:"",X=`\uD83D\uDD04 **${U}${G}**`;if($.progress&&$.progress.total>0)X+=` ${$.progress.current}/${$.progress.total} (${$.progress.percentage}%)`;if($.message)X+=`
190
190
  ${$.message}`;return X}var mv=P.enum(["tool:invoking","tool:completed","tool:failed"]),yv=P.object({toolName:P.string().min(1),conversationId:P.string().min(1),interfaceType:P.string().min(1),channelId:P.string().min(1).optional(),channelName:P.string().min(1).optional(),toolCallId:P.string().min(1).optional(),error:P.string().optional()}),fv=["tool:invoking","tool:completed","tool:failed"];function hA($,U){for(let G of fv)$.messaging.subscribe(G,async(X)=>{try{let D=mv.safeParse(X.type),V=yv.safeParse(X.payload);if(!D.success||!V.success)return U.onInvalidSchema(),{success:!1};return await U.onToolActivity({type:D.data,...V.data}),{success:!0}}catch(D){return U.onError(D),{success:!1}}})}function qD($,U){return{state:U,toolName:$.toolName,conversationId:$.conversationId,interfaceType:$.interfaceType,...$.channelId!==void 0&&{channelId:$.channelId},...$.channelName!==void 0&&{channelName:$.channelName},...$.error!==void 0&&{error:$.error}}}function mA($,U){return $.pendingConfirmations?.some((G)=>G.toolName===U)===!0||pv($.cards).some((G)=>G.toolName===U)}function pv($){return $?.filter((U)=>U.kind==="tool-approval"&&U.state==="approval-requested")??[]}var kJ=1e5,lv=[".md",".txt",".markdown"],iv=["text/plain","text/markdown","text/x-markdown"],nv=/https?:\/\/[^\s<>"{}|\\^`[\]]+?(?=[,;:\s]|$)/gi,cv=["meet.google.com","zoom.us","teams.microsoft.com","whereby.com","gather.town","calendly.com","cal.com","discord.com","discord.gg","cdn.discordapp.com","media.discordapp.net","giphy.com","tenor.com","wetransfer.com","file.io"],dv=P.object({captureUrls:P.boolean().default(!1),blockedUrlDomains:P.array(P.string()).default(cv)});function yA($,U){if(U&&iv.some((G)=>U.startsWith(G)))return!0;return lv.some((G)=>$.toLowerCase().endsWith(G))}function fA($){return $<=kJ}function pA($){if($.includes(0))return!1;try{return new TextDecoder("utf-8",{fatal:!0}).decode($),!0}catch{return!1}}function lA($,U){return`User uploaded a file "${$}":
191
191
 
@@ -193,5 +193,5 @@ ${U}`}function iA($,U){let G=$.match(nv)??[];return[...new Set(G)].filter((X)=>{
193
193
 
194
194
  ${U}`}extractCaptureableUrls($,U){let G=$.match(/https?:\/\/[^\s<>"{}|\\^`[\]]+?(?=[,;:\s]|$)/gi)??[];return[...new Set(G)].filter((X)=>{try{let{hostname:D}=new URL(X);return!U.some((V)=>D===V||D.endsWith(`.${V}`))}catch{return!1}})}captureUrlViaAgent($,U,G,X,D){return this.messageDelegate.captureUrlViaAgentPublic($,U,G,X,D)}trackAgentResponseForJob($,U,G){this.messageDelegate.trackAgentResponseForJobPublic($,U,G)}registerProgressCallback($){this.messageDelegate.registerProgressCallback($)}unregisterProgressCallback(){this.messageDelegate.unregisterProgressCallback()}getProgressEvents(){return this.messageDelegate.getProgressEvents()}getActiveProgressEvents(){return this.messageDelegate.getActiveProgressEvents()}startProcessingInput($=null){this.messageDelegate.startProcessingInput($)}endProcessingInput(){this.messageDelegate.endProcessingInput()}getCurrentChannelId(){return this.messageDelegate.getCurrentChannelIdPublic()}ready(){return this.messageDelegate.ready()}shutdown(){return this.messageDelegate.shutdown?.()??Promise.resolve()}}var sv=P.object({name:P.string(),description:P.string(),schema:P.any(),basePrompt:P.string().optional(),useKnowledgeContext:P.boolean().optional(),requiredPermission:P.enum(["anchor","trusted","public"]),formatter:P.any().optional(),layout:P.object({component:P.any().optional(),fullscreen:P.boolean().optional()}).optional(),dataSourceId:P.string().optional()});class RD{static canGenerate($){return!!$.basePrompt&&!!$.dataSourceId&&$.dataSourceId.includes("ai-content")}static canFetch($){return!!$.dataSourceId&&!this.canGenerate($)}static canRender($){return!!$.layout?.component}static isStaticOnly($){return!this.canGenerate($)&&!this.canFetch($)}static getCapabilities($){return{canGenerate:this.canGenerate($),canFetch:this.canFetch($),canRender:this.canRender($),isStaticOnly:this.isStaticOnly($)}}static validate($){let U=[];if($.dataSourceId?.includes("ai-content")&&!$.basePrompt)U.push(`Template "${$.name}" has AI-content dataSourceId but no basePrompt. AI generation requires a basePrompt.`);if($.basePrompt&&(!$.dataSourceId||!$.dataSourceId.includes("ai-content")))U.push(`Template "${$.name}" has basePrompt but no AI-content dataSourceId. The basePrompt won't be used.`);return U}static logCapabilities($,U){let G=this.getCapabilities($),X=this.validate($);if(U)U.debug(`Template capabilities for "${$.name}":`,{...G,errors:X.length>0?X:void 0})}}var ev=P.enum(["anchor","trusted","public"]),$L=P.enum(["create","update","delete","extract","publish"]),GU=P.enum(["never","anchor","trusted","public"]),tA=P.strictObject({create:GU.optional(),update:GU.optional(),delete:GU.optional(),extract:GU.optional(),publish:GU.optional()}),UL=P.record(P.string(),tA);var DL=P.enum(["site-content-preview","site-content-production"]),GL=P.enum(["web","image","pdf"]),rJ=P.custom(($)=>typeof $==="function"),XL=P.object({name:P.string(),schema:P.any(),description:P.string().optional(),pluginId:P.string(),renderers:P.object({web:P.union([rJ,P.string()]).optional(),image:P.union([rJ,P.string()]).optional(),pdf:P.union([rJ,P.string()]).optional()})}),VL=P.object({enableContentGeneration:P.boolean().default(!1),outputDir:P.string(),workingDir:P.string().optional(),environment:P.enum(["preview","production"]).default("preview"),siteConfig:P.object({title:P.string(),description:P.string(),url:P.string().optional()}).optional()}),ZL=P.object({success:P.boolean(),routesBuilt:P.number(),errors:P.array(P.string()).optional(),warnings:P.array(P.string()).optional()});function eA($,U,G){let X=c1($,U,G),D=$.getEntityService(),V=$.getRenderService(),Z=$.getContentService();return{...X,entityService:D,entities:PG($),webRoutes:{getRoutes:()=>$.getPluginWebRoutes()},templates:{register:(J,Y)=>{$.registerTemplates(J,Y??U)},format:(J,Y)=>{return Z.formatContent(J,Y,{pluginId:U})},parse:(J,Y)=>{return Z.parseContent(J,Y,U)},resolve:async(J,Y)=>{return await Z.resolveContent(J,Y,U)},getCapabilities:(J)=>{let Y=J.includes(":")?J:`${U}:${J}`,W=$.getTemplate(Y);if(!W)return null;let w=RD.getCapabilities(W);return{canGenerate:w.canGenerate,canFetch:w.canFetch,canRender:w.canRender,isStaticOnly:w.isStaticOnly}}},views:{get:(J)=>{return V.get(J)??void 0},list:()=>{return V.list()},hasRenderer:(J,Y="web")=>{return V.hasRenderer(J,Y)},getRenderer:(J,Y="web")=>{return V.getRenderer(J,Y)},validate:(J,Y)=>{return V.validate(J,Y)}},prompts:WG(D),ai:{query:(J,Y)=>$.query(J,Y),generate:async(J)=>{return $.generateContent(J)},generateObject:async(J,Y)=>{return $.generateObject(J,Y)},generateImage:async(J,Y)=>{return $.generateImage(J,Y)},canGenerateImages:()=>{return $.canGenerateImages()}},registerInstructions:(J)=>{$.registerInstructions(U,J)}}}class hJ extends C6{type="service";getApiRoutes(){return[]}getWebRoutes(){return[]}async register($,U){let G=eA($,this.id,U);return this.context=G,this.setupMessageHandlers(G),await this.onRegister(G),this.getCapabilities()}get entityService(){return this.getContext().entityService}registerEntityType($,U,G,X){this.getContext().entities.register($,U,G,X)}async enqueueJob($){return this.getContext().jobs.enqueue($)}async enqueueBatch($,U){return this.getContext().jobs.enqueueBatch($,U)}async registerEntityTypes($){}async registerJobHandlers($){}async onRegister($){await this.registerEntityTypes($),await this.registerJobHandlers($)}}class $_ extends hJ{hooks;constructor($,U,G,X,D){super($,U,G,X);this.hooks=D}onRegister($){return this.hooks.onRegister($)}onReady($){return this.hooks.onReady($)}onShutdown(){return this.hooks.onShutdown()}getTools(){return this.hooks.getTools()}getResources(){return this.hooks.getResources()}getInstructions(){return this.hooks.getInstructions()}}class mJ{type="service";id;version;packageName;description;delegate;constructor($,U,G,X){if(this.id=$,this.version=U.version,this.packageName=U.name,U.description!==void 0)this.description=U.description;this.delegate=new $_($,U,G,X,{onRegister:(D)=>this.onRegister(D),onReady:(D)=>this.onReady(D),onShutdown:()=>this.onShutdown(),getTools:()=>this.getTools(),getResources:()=>this.getResources(),getInstructions:()=>this.getInstructions()})}register($,U){return this.delegate.register($,U)}async onRegister($){}async onReady($){}async onShutdown(){}async getTools(){return[]}async getResources(){return[]}async getInstructions(){return}ready(){return this.delegate.ready()}shutdown(){return this.delegate.shutdown?.()??Promise.resolve()}}var U_=P.object({kind:P.string().min(1),id:P.string().min(1)}),PL=P.object({kind:P.literal("text"),filename:P.string().min(1),mediaType:P.string().min(1),content:P.string(),sizeBytes:P.number().nonnegative().optional(),source:U_.optional()}),WL=P.custom(($)=>$ instanceof Uint8Array),YL=P.object({kind:P.literal("file"),filename:P.string().min(1),mediaType:P.string().min(1),data:WL,sizeBytes:P.number().nonnegative().optional(),source:U_.optional()}),HL=P.discriminatedUnion("kind",[PL,YL]),wL=P.object({userPermissionLevel:P.enum(["anchor","trusted","public"]).optional(),interfaceType:P.string().optional(),channelId:P.string().optional(),channelName:P.string().optional(),actor:p0.optional(),source:l0.optional(),attachments:P.array(HL).optional()});var KL=P.object({status:P.enum(["healthy","warning","error","unknown"]),message:P.string().optional(),lastCheck:P.date().optional(),details:P.record(P.string(),P.unknown()).optional()}),D_=P.object({name:P.string(),pluginId:P.string(),status:P.string(),health:KL.optional()});import{McpServer as Vt,ResourceTemplate as Zt}from"@modelcontextprotocol/sdk/server/mcp.js";var G_=P.object({interfaceType:P.string(),userId:P.string(),conversationId:P.string().optional(),channelId:P.string().optional(),channelName:P.string().optional(),runId:P.string().optional(),toolCallId:P.string().optional(),userPermissionLevel:P.enum(["anchor","trusted","public"]).optional()}),X_=P.strictObject({success:P.literal(!0),data:P.unknown().optional(),message:P.string().optional(),cached:P.literal(!0).optional()}),V_=P.strictObject({success:P.literal(!1),error:P.string(),code:P.string().optional()}),Z_=P.strictObject({needsConfirmation:P.literal(!0),toolName:P.string(),summary:P.string(),completionSummary:P.string().optional(),preview:P.string().optional(),args:P.unknown()}),yJ=P.union([X_,V_,Z_]);var es=P.union([P.looseObject({success:P.literal(!0)}),P.object({success:P.literal(!1),error:P.string()})]);var OL=P.union([P.object({success:P.literal(!0),data:P.unknown(),message:P.string().optional()}),P.object({success:P.literal(!1),error:P.string(),code:P.string().optional()})]);var nt=P.object({id:P.string(),type:P.string(),version:P.string(),status:P.string()}),ct=P.object({name:P.string(),description:P.string()}),J_=P.enum(["anchor","trusted","public"]),fJ=P.object({label:P.string(),url:P.string(),pluginId:P.string(),priority:P.number().default(100),visibility:J_.default("public")}),AL=P.enum(["human","agent","admin","protocol"]),_L=P.enum(["available","coming-soon","disabled"]),pJ=P.object({id:P.string(),label:P.string(),description:P.string().optional(),href:P.string(),kind:AL,pluginId:P.string(),priority:P.number().default(100),visibility:J_.default("public"),status:_L.default("available")}),lJ=P.object({entityType:P.string(),count:P.number()}),dt=P.object({model:P.string(),version:P.string(),uptime:P.number(),entities:P.number(),entityCounts:P.array(lJ),embeddings:P.number(),ai:P.object({model:P.string(),embeddingModel:P.string()}),daemons:P.array(D_),endpoints:P.array(fJ),interactions:P.array(pJ)});var ot=P.object({id:P.string(),version:P.string(),type:P.enum(["core","entity","service","interface"]),description:P.string().optional(),dependencies:P.array(P.string()).optional(),packageName:P.string()});var FL=P.object({status:P.enum(["healthy","warning","error","unknown"]),message:P.string().optional(),lastCheck:P.string().optional(),details:P.record(P.string(),P.unknown()).optional()}),qL=P.object({name:P.string(),pluginId:P.string(),status:P.string(),health:FL.optional()}),RL=P.object({model:P.string(),version:P.string(),uptime:P.number(),entities:P.number(),entityCounts:P.array(lJ),embeddings:P.number(),ai:P.object({model:P.string(),embeddingModel:P.string()}),daemons:P.array(qL),endpoints:P.array(fJ),interactions:P.array(pJ)});var NL=P.union([P.object({success:P.boolean(),data:P.unknown().optional(),error:P.string().optional()}),P.object({noop:P.literal(!0)})]),ML=P.object({id:P.string(),timestamp:P.string(),type:P.string(),source:P.string(),target:P.string().optional(),metadata:n1.optional()});export{WR as urlCaptureConfigSchema,JR as toolSuccess,PR as toolError,YR as defineChannel,VR as createTool,ZR as createResource,D0 as ToolResultDataSchema,mJ as ServicePlugin,U0 as PendingConfirmationSchema,PI as MessageSchema,NL as MessageResponseSchema,uJ as MessageInterfacePlugin,FD as InterfacePlugin,n1 as ExtensionMetadataSchema,CJ as EntityPlugin,JI as ConversationSchema,wL as ChatContextSchema,XJ as BrainCharacterSchema,ML as BaseMessageSchema,RL as AppInfoSchema,VJ as AnchorProfileSchema,G0 as AgentResponseSchema};
195
195
 
196
- //# debugId=6CBF696567C742D164756E2164756E21
196
+ //# debugId=D1D5F7FF1ABE8C4A64756E2164756E21
197
197
  //# sourceMappingURL=plugins.js.map