ocx 2.0.3 → 2.0.4

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.
Files changed (2) hide show
  1. package/dist/index.js +80 -79
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,20 +1,20 @@
1
1
  #!/usr/bin/env -S bun --no-env-file
2
2
  // @bun
3
- var t$=Object.create;var{getPrototypeOf:e$,defineProperty:o8,getOwnPropertyNames:D_}=Object;var F_=Object.prototype.hasOwnProperty;var f3=(D,F,B)=>{B=D!=null?t$(e$(D)):{};let $=F||!D||!D.__esModule?o8(B,"default",{value:D,enumerable:!0}):B;for(let _ of D_(D))if(!F_.call($,_))o8($,_,{get:()=>D[_],enumerable:!0});return $};var d0=(D,F)=>()=>(F||D((F={exports:{}}).exports,F),F.exports);var j2=(D,F)=>{for(var B in F)o8(D,B,{get:F[B],enumerable:!0,configurable:!0,set:($)=>F[B]=()=>$})};var V=(D,F)=>()=>(D&&(F=D(D=0)),F);var WF=import.meta.require;function _3(D,F=!1){let B=D.length,$=0,_="",Q=0,Y=16,q=0,H=0,J=0,X=0,z=0;function M(N,x){let O=0,b=0;while(O<N||!x){let L=D.charCodeAt($);if(L>=48&&L<=57)b=b*16+L-48;else if(L>=65&&L<=70)b=b*16+L-65+10;else if(L>=97&&L<=102)b=b*16+L-97+10;else break;$++,O++}if(O<N)b=-1;return b}function A(N){$=N,_="",Q=0,Y=16,z=0}function K(){let N=$;if(D.charCodeAt($)===48)$++;else{$++;while($<D.length&&zF(D.charCodeAt($)))$++}if($<D.length&&D.charCodeAt($)===46)if($++,$<D.length&&zF(D.charCodeAt($))){$++;while($<D.length&&zF(D.charCodeAt($)))$++}else return z=3,D.substring(N,$);let x=$;if($<D.length&&(D.charCodeAt($)===69||D.charCodeAt($)===101)){if($++,$<D.length&&D.charCodeAt($)===43||D.charCodeAt($)===45)$++;if($<D.length&&zF(D.charCodeAt($))){$++;while($<D.length&&zF(D.charCodeAt($)))$++;x=$}else z=3}return D.substring(N,x)}function j(){let N="",x=$;while(!0){if($>=B){N+=D.substring(x,$),z=2;break}let O=D.charCodeAt($);if(O===34){N+=D.substring(x,$),$++;break}if(O===92){if(N+=D.substring(x,$),$++,$>=B){z=2;break}switch(D.charCodeAt($++)){case 34:N+='"';break;case 92:N+="\\";break;case 47:N+="/";break;case 98:N+="\b";break;case 102:N+="\f";break;case 110:N+=`
4
- `;break;case 114:N+="\r";break;case 116:N+="\t";break;case 117:let L=M(4,!0);if(L>=0)N+=String.fromCharCode(L);else z=4;break;default:z=5}x=$;continue}if(O>=0&&O<=31)if($3(O)){N+=D.substring(x,$),z=2;break}else z=6;$++}return N}function S(){if(_="",z=0,Q=$,H=q,X=J,$>=B)return Q=B,Y=17;let N=D.charCodeAt($);if(r8(N)){do $++,_+=String.fromCharCode(N),N=D.charCodeAt($);while(r8(N));return Y=15}if($3(N)){if($++,_+=String.fromCharCode(N),N===13&&D.charCodeAt($)===10)$++,_+=`
5
- `;return q++,J=$,Y=14}switch(N){case 123:return $++,Y=1;case 125:return $++,Y=2;case 91:return $++,Y=3;case 93:return $++,Y=4;case 58:return $++,Y=6;case 44:return $++,Y=5;case 34:return $++,_=j(),Y=10;case 47:let x=$-1;if(D.charCodeAt($+1)===47){$+=2;while($<B){if($3(D.charCodeAt($)))break;$++}return _=D.substring(x,$),Y=12}if(D.charCodeAt($+1)===42){$+=2;let O=B-1,b=!1;while($<O){let L=D.charCodeAt($);if(L===42&&D.charCodeAt($+1)===47){$+=2,b=!0;break}if($++,$3(L)){if(L===13&&D.charCodeAt($)===10)$++;q++,J=$}}if(!b)$++,z=1;return _=D.substring(x,$),Y=13}return _+=String.fromCharCode(N),$++,Y=16;case 45:if(_+=String.fromCharCode(N),$++,$===B||!zF(D.charCodeAt($)))return Y=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return _+=K(),Y=11;default:while($<B&&Z(N))$++,N=D.charCodeAt($);if(Q!==$){switch(_=D.substring(Q,$),_){case"true":return Y=8;case"false":return Y=9;case"null":return Y=7}return Y=16}return _+=String.fromCharCode(N),$++,Y=16}}function Z(N){if(r8(N)||$3(N))return!1;switch(N){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function s(){let N;do N=S();while(N>=12&&N<=15);return N}return{setPosition:A,getPosition:()=>$,scan:F?s:S,getToken:()=>Y,getTokenValue:()=>_,getTokenOffset:()=>Q,getTokenLength:()=>$-Q,getTokenStartLine:()=>H,getTokenStartCharacter:()=>Q-X,getTokenError:()=>z}}function r8(D){return D===32||D===9}function $3(D){return D===10||D===13}function zF(D){return D>=48&&D<=57}var r6;var h3=V(()=>{(function(D){D[D.lineFeed=10]="lineFeed",D[D.carriageReturn=13]="carriageReturn",D[D.space=32]="space",D[D._0=48]="_0",D[D._1=49]="_1",D[D._2=50]="_2",D[D._3=51]="_3",D[D._4=52]="_4",D[D._5=53]="_5",D[D._6=54]="_6",D[D._7=55]="_7",D[D._8=56]="_8",D[D._9=57]="_9",D[D.a=97]="a",D[D.b=98]="b",D[D.c=99]="c",D[D.d=100]="d",D[D.e=101]="e",D[D.f=102]="f",D[D.g=103]="g",D[D.h=104]="h",D[D.i=105]="i",D[D.j=106]="j",D[D.k=107]="k",D[D.l=108]="l",D[D.m=109]="m",D[D.n=110]="n",D[D.o=111]="o",D[D.p=112]="p",D[D.q=113]="q",D[D.r=114]="r",D[D.s=115]="s",D[D.t=116]="t",D[D.u=117]="u",D[D.v=118]="v",D[D.w=119]="w",D[D.x=120]="x",D[D.y=121]="y",D[D.z=122]="z",D[D.A=65]="A",D[D.B=66]="B",D[D.C=67]="C",D[D.D=68]="D",D[D.E=69]="E",D[D.F=70]="F",D[D.G=71]="G",D[D.H=72]="H",D[D.I=73]="I",D[D.J=74]="J",D[D.K=75]="K",D[D.L=76]="L",D[D.M=77]="M",D[D.N=78]="N",D[D.O=79]="O",D[D.P=80]="P",D[D.Q=81]="Q",D[D.R=82]="R",D[D.S=83]="S",D[D.T=84]="T",D[D.U=85]="U",D[D.V=86]="V",D[D.W=87]="W",D[D.X=88]="X",D[D.Y=89]="Y",D[D.Z=90]="Z",D[D.asterisk=42]="asterisk",D[D.backslash=92]="backslash",D[D.closeBrace=125]="closeBrace",D[D.closeBracket=93]="closeBracket",D[D.colon=58]="colon",D[D.comma=44]="comma",D[D.dot=46]="dot",D[D.doubleQuote=34]="doubleQuote",D[D.minus=45]="minus",D[D.openBrace=123]="openBrace",D[D.openBracket=91]="openBracket",D[D.plus=43]="plus",D[D.slash=47]="slash",D[D.formFeed=12]="formFeed",D[D.tab=9]="tab"})(r6||(r6={}))});var q0,t8,t6;var e6=V(()=>{q0=Array(20).fill(0).map((D,F)=>{return" ".repeat(F)}),t8={" ":{"\n":Array(200).fill(0).map((D,F)=>{return`
3
+ var B_=Object.create;var{getPrototypeOf:$_,defineProperty:t8,getOwnPropertyNames:__}=Object;var Q_=Object.prototype.hasOwnProperty;var h3=(D,F,B)=>{B=D!=null?B_($_(D)):{};let $=F||!D||!D.__esModule?t8(B,"default",{value:D,enumerable:!0}):B;for(let _ of __(D))if(!Q_.call($,_))t8($,_,{get:()=>D[_],enumerable:!0});return $};var c0=(D,F)=>()=>(F||D((F={exports:{}}).exports,F),F.exports);var j2=(D,F)=>{for(var B in F)t8(D,B,{get:F[B],enumerable:!0,configurable:!0,set:($)=>F[B]=()=>$})};var V=(D,F)=>()=>(D&&(F=D(D=0)),F);var GF=import.meta.require;function Q3(D,F=!1){let B=D.length,$=0,_="",Q=0,Y=16,q=0,H=0,J=0,X=0,z=0;function M(N,y){let O=0,b=0;while(O<N||!y){let L=D.charCodeAt($);if(L>=48&&L<=57)b=b*16+L-48;else if(L>=65&&L<=70)b=b*16+L-65+10;else if(L>=97&&L<=102)b=b*16+L-97+10;else break;$++,O++}if(O<N)b=-1;return b}function A(N){$=N,_="",Q=0,Y=16,z=0}function K(){let N=$;if(D.charCodeAt($)===48)$++;else{$++;while($<D.length&&zF(D.charCodeAt($)))$++}if($<D.length&&D.charCodeAt($)===46)if($++,$<D.length&&zF(D.charCodeAt($))){$++;while($<D.length&&zF(D.charCodeAt($)))$++}else return z=3,D.substring(N,$);let y=$;if($<D.length&&(D.charCodeAt($)===69||D.charCodeAt($)===101)){if($++,$<D.length&&D.charCodeAt($)===43||D.charCodeAt($)===45)$++;if($<D.length&&zF(D.charCodeAt($))){$++;while($<D.length&&zF(D.charCodeAt($)))$++;y=$}else z=3}return D.substring(N,y)}function j(){let N="",y=$;while(!0){if($>=B){N+=D.substring(y,$),z=2;break}let O=D.charCodeAt($);if(O===34){N+=D.substring(y,$),$++;break}if(O===92){if(N+=D.substring(y,$),$++,$>=B){z=2;break}switch(D.charCodeAt($++)){case 34:N+='"';break;case 92:N+="\\";break;case 47:N+="/";break;case 98:N+="\b";break;case 102:N+="\f";break;case 110:N+=`
4
+ `;break;case 114:N+="\r";break;case 116:N+="\t";break;case 117:let L=M(4,!0);if(L>=0)N+=String.fromCharCode(L);else z=4;break;default:z=5}y=$;continue}if(O>=0&&O<=31)if(_3(O)){N+=D.substring(y,$),z=2;break}else z=6;$++}return N}function S(){if(_="",z=0,Q=$,H=q,X=J,$>=B)return Q=B,Y=17;let N=D.charCodeAt($);if(e8(N)){do $++,_+=String.fromCharCode(N),N=D.charCodeAt($);while(e8(N));return Y=15}if(_3(N)){if($++,_+=String.fromCharCode(N),N===13&&D.charCodeAt($)===10)$++,_+=`
5
+ `;return q++,J=$,Y=14}switch(N){case 123:return $++,Y=1;case 125:return $++,Y=2;case 91:return $++,Y=3;case 93:return $++,Y=4;case 58:return $++,Y=6;case 44:return $++,Y=5;case 34:return $++,_=j(),Y=10;case 47:let y=$-1;if(D.charCodeAt($+1)===47){$+=2;while($<B){if(_3(D.charCodeAt($)))break;$++}return _=D.substring(y,$),Y=12}if(D.charCodeAt($+1)===42){$+=2;let O=B-1,b=!1;while($<O){let L=D.charCodeAt($);if(L===42&&D.charCodeAt($+1)===47){$+=2,b=!0;break}if($++,_3(L)){if(L===13&&D.charCodeAt($)===10)$++;q++,J=$}}if(!b)$++,z=1;return _=D.substring(y,$),Y=13}return _+=String.fromCharCode(N),$++,Y=16;case 45:if(_+=String.fromCharCode(N),$++,$===B||!zF(D.charCodeAt($)))return Y=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return _+=K(),Y=11;default:while($<B&&R(N))$++,N=D.charCodeAt($);if(Q!==$){switch(_=D.substring(Q,$),_){case"true":return Y=8;case"false":return Y=9;case"null":return Y=7}return Y=16}return _+=String.fromCharCode(N),$++,Y=16}}function R(N){if(e8(N)||_3(N))return!1;switch(N){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function s(){let N;do N=S();while(N>=12&&N<=15);return N}return{setPosition:A,getPosition:()=>$,scan:F?s:S,getToken:()=>Y,getTokenValue:()=>_,getTokenOffset:()=>Q,getTokenLength:()=>$-Q,getTokenStartLine:()=>H,getTokenStartCharacter:()=>Q-X,getTokenError:()=>z}}function e8(D){return D===32||D===9}function _3(D){return D===10||D===13}function zF(D){return D>=48&&D<=57}var D7;var m3=V(()=>{(function(D){D[D.lineFeed=10]="lineFeed",D[D.carriageReturn=13]="carriageReturn",D[D.space=32]="space",D[D._0=48]="_0",D[D._1=49]="_1",D[D._2=50]="_2",D[D._3=51]="_3",D[D._4=52]="_4",D[D._5=53]="_5",D[D._6=54]="_6",D[D._7=55]="_7",D[D._8=56]="_8",D[D._9=57]="_9",D[D.a=97]="a",D[D.b=98]="b",D[D.c=99]="c",D[D.d=100]="d",D[D.e=101]="e",D[D.f=102]="f",D[D.g=103]="g",D[D.h=104]="h",D[D.i=105]="i",D[D.j=106]="j",D[D.k=107]="k",D[D.l=108]="l",D[D.m=109]="m",D[D.n=110]="n",D[D.o=111]="o",D[D.p=112]="p",D[D.q=113]="q",D[D.r=114]="r",D[D.s=115]="s",D[D.t=116]="t",D[D.u=117]="u",D[D.v=118]="v",D[D.w=119]="w",D[D.x=120]="x",D[D.y=121]="y",D[D.z=122]="z",D[D.A=65]="A",D[D.B=66]="B",D[D.C=67]="C",D[D.D=68]="D",D[D.E=69]="E",D[D.F=70]="F",D[D.G=71]="G",D[D.H=72]="H",D[D.I=73]="I",D[D.J=74]="J",D[D.K=75]="K",D[D.L=76]="L",D[D.M=77]="M",D[D.N=78]="N",D[D.O=79]="O",D[D.P=80]="P",D[D.Q=81]="Q",D[D.R=82]="R",D[D.S=83]="S",D[D.T=84]="T",D[D.U=85]="U",D[D.V=86]="V",D[D.W=87]="W",D[D.X=88]="X",D[D.Y=89]="Y",D[D.Z=90]="Z",D[D.asterisk=42]="asterisk",D[D.backslash=92]="backslash",D[D.closeBrace=125]="closeBrace",D[D.closeBracket=93]="closeBracket",D[D.colon=58]="colon",D[D.comma=44]="comma",D[D.dot=46]="dot",D[D.doubleQuote=34]="doubleQuote",D[D.minus=45]="minus",D[D.openBrace=123]="openBrace",D[D.openBracket=91]="openBracket",D[D.plus=43]="plus",D[D.slash=47]="slash",D[D.formFeed=12]="formFeed",D[D.tab=9]="tab"})(D7||(D7={}))});var H0,D1,F7;var B7=V(()=>{H0=Array(20).fill(0).map((D,F)=>{return" ".repeat(F)}),D1={" ":{"\n":Array(200).fill(0).map((D,F)=>{return`
6
6
  `+" ".repeat(F)}),"\r":Array(200).fill(0).map((D,F)=>{return"\r"+" ".repeat(F)}),"\r\n":Array(200).fill(0).map((D,F)=>{return`\r
7
7
  `+" ".repeat(F)})},"\t":{"\n":Array(200).fill(0).map((D,F)=>{return`
8
8
  `+"\t".repeat(F)}),"\r":Array(200).fill(0).map((D,F)=>{return"\r"+"\t".repeat(F)}),"\r\n":Array(200).fill(0).map((D,F)=>{return`\r
9
- `+"\t".repeat(F)})}},t6=[`
9
+ `+"\t".repeat(F)})}},F7=[`
10
10
  `,"\r",`\r
11
- `]});function e8(D,F,B){let $,_,Q,Y,q;if(F){Y=F.offset,q=Y+F.length,Q=Y;while(Q>0&&!Q3(D,Q-1))Q--;let O=q;while(O<D.length&&!Q3(D,O))O++;_=D.substring(Q,O),$=$_(_,B)}else _=D,$=0,Q=0,Y=0,q=D.length;let H=__(B,D),J=t6.includes(H),X=0,z=0,M;if(B.insertSpaces)M=q0[B.tabSize||4]??MF(q0[1],B.tabSize||4);else M="\t";let A=M==="\t"?"\t":" ",K=_3(_,!1),j=!1;function S(){if(X>1)return MF(H,X)+MF(M,$+z);let O=M.length*($+z);if(!J||O>t8[A][H].length)return H+MF(M,$+z);if(O<=0)return H;return t8[A][H][O]}function Z(){let O=K.scan();X=0;while(O===15||O===14){if(O===14&&B.keepLines)X+=1;else if(O===14)X=1;O=K.scan()}return j=O===16||K.getTokenError()!==0,O}let s=[];function N(O,b,L){if(!j&&(!F||b<q&&L>Y)&&D.substring(b,L)!==O)s.push({offset:b,length:L-b,content:O})}let x=Z();if(B.keepLines&&X>0)N(MF(H,X),0,0);if(x!==17){let O=K.getTokenOffset()+Q,b=M.length*$<20&&B.insertSpaces?q0[M.length*$]:MF(M,$);N(b,Q,O)}while(x!==17){let O=K.getTokenOffset()+K.getTokenLength()+Q,b=Z(),L="",e=!1;while(X===0&&(b===12||b===13)){let FD=K.getTokenOffset()+Q;N(q0[1],O,FD),O=K.getTokenOffset()+K.getTokenLength()+Q,e=b===12,L=e?S():"",b=Z()}if(b===2){if(x!==1)z--;if(B.keepLines&&X>0||!B.keepLines&&x!==1)L=S();else if(B.keepLines)L=q0[1]}else if(b===4){if(x!==3)z--;if(B.keepLines&&X>0||!B.keepLines&&x!==3)L=S();else if(B.keepLines)L=q0[1]}else{switch(x){case 3:case 1:if(z++,B.keepLines&&X>0||!B.keepLines)L=S();else L=q0[1];break;case 5:if(B.keepLines&&X>0||!B.keepLines)L=S();else L=q0[1];break;case 12:L=S();break;case 13:if(X>0)L=S();else if(!e)L=q0[1];break;case 6:if(B.keepLines&&X>0)L=S();else if(!e)L=q0[1];break;case 10:if(B.keepLines&&X>0)L=S();else if(b===6&&!e)L="";break;case 7:case 8:case 9:case 11:case 2:case 4:if(B.keepLines&&X>0)L=S();else if((b===12||b===13)&&!e)L=q0[1];else if(b!==5&&b!==17)j=!0;break;case 16:j=!0;break}if(X>0&&(b===12||b===13))L=S()}if(b===17)if(B.keepLines&&X>0)L=S();else L=B.insertFinalNewline?H:"";let p=K.getTokenOffset()+Q;N(L,O,p),x=b}return s}function MF(D,F){let B="";for(let $=0;$<F;$++)B+=D;return B}function $_(D,F){let B=0,$=0,_=F.tabSize||4;while(B<D.length){let Q=D.charAt(B);if(Q===q0[1])$++;else if(Q==="\t")$+=_;else break;B++}return Math.floor($/_)}function __(D,F){for(let B=0;B<F.length;B++){let $=F.charAt(B);if($==="\r"){if(B+1<F.length&&F.charAt(B+1)===`
11
+ `]});function F1(D,F,B){let $,_,Q,Y,q;if(F){Y=F.offset,q=Y+F.length,Q=Y;while(Q>0&&!Y3(D,Q-1))Q--;let O=q;while(O<D.length&&!Y3(D,O))O++;_=D.substring(Q,O),$=q_(_,B)}else _=D,$=0,Q=0,Y=0,q=D.length;let H=H_(B,D),J=F7.includes(H),X=0,z=0,M;if(B.insertSpaces)M=H0[B.tabSize||4]??MF(H0[1],B.tabSize||4);else M="\t";let A=M==="\t"?"\t":" ",K=Q3(_,!1),j=!1;function S(){if(X>1)return MF(H,X)+MF(M,$+z);let O=M.length*($+z);if(!J||O>D1[A][H].length)return H+MF(M,$+z);if(O<=0)return H;return D1[A][H][O]}function R(){let O=K.scan();X=0;while(O===15||O===14){if(O===14&&B.keepLines)X+=1;else if(O===14)X=1;O=K.scan()}return j=O===16||K.getTokenError()!==0,O}let s=[];function N(O,b,L){if(!j&&(!F||b<q&&L>Y)&&D.substring(b,L)!==O)s.push({offset:b,length:L-b,content:O})}let y=R();if(B.keepLines&&X>0)N(MF(H,X),0,0);if(y!==17){let O=K.getTokenOffset()+Q,b=M.length*$<20&&B.insertSpaces?H0[M.length*$]:MF(M,$);N(b,Q,O)}while(y!==17){let O=K.getTokenOffset()+K.getTokenLength()+Q,b=R(),L="",e=!1;while(X===0&&(b===12||b===13)){let FD=K.getTokenOffset()+Q;N(H0[1],O,FD),O=K.getTokenOffset()+K.getTokenLength()+Q,e=b===12,L=e?S():"",b=R()}if(b===2){if(y!==1)z--;if(B.keepLines&&X>0||!B.keepLines&&y!==1)L=S();else if(B.keepLines)L=H0[1]}else if(b===4){if(y!==3)z--;if(B.keepLines&&X>0||!B.keepLines&&y!==3)L=S();else if(B.keepLines)L=H0[1]}else{switch(y){case 3:case 1:if(z++,B.keepLines&&X>0||!B.keepLines)L=S();else L=H0[1];break;case 5:if(B.keepLines&&X>0||!B.keepLines)L=S();else L=H0[1];break;case 12:L=S();break;case 13:if(X>0)L=S();else if(!e)L=H0[1];break;case 6:if(B.keepLines&&X>0)L=S();else if(!e)L=H0[1];break;case 10:if(B.keepLines&&X>0)L=S();else if(b===6&&!e)L="";break;case 7:case 8:case 9:case 11:case 2:case 4:if(B.keepLines&&X>0)L=S();else if((b===12||b===13)&&!e)L=H0[1];else if(b!==5&&b!==17)j=!0;break;case 16:j=!0;break}if(X>0&&(b===12||b===13))L=S()}if(b===17)if(B.keepLines&&X>0)L=S();else L=B.insertFinalNewline?H:"";let p=K.getTokenOffset()+Q;N(L,O,p),y=b}return s}function MF(D,F){let B="";for(let $=0;$<F;$++)B+=D;return B}function q_(D,F){let B=0,$=0,_=F.tabSize||4;while(B<D.length){let Q=D.charAt(B);if(Q===H0[1])$++;else if(Q==="\t")$+=_;else break;B++}return Math.floor($/_)}function H_(D,F){for(let B=0;B<F.length;B++){let $=F.charAt(B);if($==="\r"){if(B+1<F.length&&F.charAt(B+1)===`
12
12
  `)return`\r
13
13
  `;return"\r"}else if($===`
14
14
  `)return`
15
15
  `}return D&&D.eol||`
16
- `}function Q3(D,F){return`\r
17
- `.indexOf(D.charAt(F))!==-1}var D1=V(()=>{h3();e6()});function D7(D,F=[],B=Y3.DEFAULT){let $=null,_=[],Q=[];function Y(H){if(Array.isArray(_))_.push(H);else if($!==null)_[$]=H}return B1(D,{onObjectBegin:()=>{let H={};Y(H),Q.push(_),_=H,$=null},onObjectProperty:(H)=>{$=H},onObjectEnd:()=>{_=Q.pop()},onArrayBegin:()=>{let H=[];Y(H),Q.push(_),_=H,$=null},onArrayEnd:()=>{_=Q.pop()},onLiteralValue:Y,onError:(H,J,X)=>{F.push({error:H,offset:J,length:X})}},B),_[0]}function F1(D,F=[],B=Y3.DEFAULT){let $={type:"array",offset:-1,length:-1,children:[],parent:void 0};function _(H){if($.type==="property")$.length=H-$.offset,$=$.parent}function Q(H){return $.children.push(H),H}B1(D,{onObjectBegin:(H)=>{$=Q({type:"object",offset:H,length:-1,parent:$,children:[]})},onObjectProperty:(H,J,X)=>{$=Q({type:"property",offset:J,length:-1,parent:$,children:[]}),$.children.push({type:"string",value:H,offset:J,length:X,parent:$})},onObjectEnd:(H,J)=>{_(H+J),$.length=H+J-$.offset,$=$.parent,_(H+J)},onArrayBegin:(H,J)=>{$=Q({type:"array",offset:H,length:-1,parent:$,children:[]})},onArrayEnd:(H,J)=>{$.length=H+J-$.offset,$=$.parent,_(H+J)},onLiteralValue:(H,J,X)=>{Q({type:Y_(H),offset:J,length:X,parent:$,value:H}),_(J+X)},onSeparator:(H,J,X)=>{if($.type==="property"){if(H===":")$.colonOffset=J;else if(H===",")_(J)}},onError:(H,J,X)=>{F.push({error:H,offset:J,length:X})}},B);let q=$.children[0];if(q)delete q.parent;return q}function m3(D,F){if(!D)return;let B=D;for(let $ of F)if(typeof $==="string"){if(B.type!=="object"||!Array.isArray(B.children))return;let _=!1;for(let Q of B.children)if(Array.isArray(Q.children)&&Q.children[0].value===$&&Q.children.length===2){B=Q.children[1],_=!0;break}if(!_)return}else{let _=$;if(B.type!=="array"||_<0||!Array.isArray(B.children)||_>=B.children.length)return;B=B.children[_]}return B}function B1(D,F,B=Y3.DEFAULT){let $=_3(D,!1),_=[],Q=0;function Y(v){return v?()=>Q===0&&v($.getTokenOffset(),$.getTokenLength(),$.getTokenStartLine(),$.getTokenStartCharacter()):()=>!0}function q(v){return v?(f)=>Q===0&&v(f,$.getTokenOffset(),$.getTokenLength(),$.getTokenStartLine(),$.getTokenStartCharacter()):()=>!0}function H(v){return v?(f)=>Q===0&&v(f,$.getTokenOffset(),$.getTokenLength(),$.getTokenStartLine(),$.getTokenStartCharacter(),()=>_.slice()):()=>!0}function J(v){return v?()=>{if(Q>0)Q++;else if(v($.getTokenOffset(),$.getTokenLength(),$.getTokenStartLine(),$.getTokenStartCharacter(),()=>_.slice())===!1)Q=1}:()=>!0}function X(v){return v?()=>{if(Q>0)Q--;if(Q===0)v($.getTokenOffset(),$.getTokenLength(),$.getTokenStartLine(),$.getTokenStartCharacter())}:()=>!0}let z=J(F.onObjectBegin),M=H(F.onObjectProperty),A=X(F.onObjectEnd),K=J(F.onArrayBegin),j=X(F.onArrayEnd),S=H(F.onLiteralValue),Z=q(F.onSeparator),s=Y(F.onComment),N=q(F.onError),x=B&&B.disallowComments,O=B&&B.allowTrailingComma;function b(){while(!0){let v=$.scan();switch($.getTokenError()){case 4:L(14);break;case 5:L(15);break;case 3:L(13);break;case 1:if(!x)L(11);break;case 2:L(12);break;case 6:L(16);break}switch(v){case 12:case 13:if(x)L(10);else s();break;case 16:L(1);break;case 15:case 14:break;default:return v}}}function L(v,f=[],_D=[]){if(N(v),f.length+_D.length>0){let r=$.getToken();while(r!==17){if(f.indexOf(r)!==-1){b();break}else if(_D.indexOf(r)!==-1)break;r=b()}}}function e(v){let f=$.getTokenValue();if(v)S(f);else M(f),_.push(f);return b(),!0}function p(){switch($.getToken()){case 11:let v=$.getTokenValue(),f=Number(v);if(isNaN(f))L(2),f=0;S(f);break;case 7:S(null);break;case 8:S(!0);break;case 9:S(!1);break;default:return!1}return b(),!0}function FD(){if($.getToken()!==10)return L(3,[],[2,5]),!1;if(e(!1),$.getToken()===6){if(Z(":"),b(),!i())L(4,[],[2,5])}else L(5,[],[2,5]);return _.pop(),!0}function KD(){z(),b();let v=!1;while($.getToken()!==2&&$.getToken()!==17){if($.getToken()===5){if(!v)L(4,[],[]);if(Z(","),b(),$.getToken()===2&&O)break}else if(v)L(6,[],[]);if(!FD())L(4,[],[2,5]);v=!0}if(A(),$.getToken()!==2)L(7,[2],[]);else b();return!0}function k(){K(),b();let v=!0,f=!1;while($.getToken()!==4&&$.getToken()!==17){if($.getToken()===5){if(!f)L(4,[],[]);if(Z(","),b(),$.getToken()===4&&O)break}else if(f)L(6,[],[]);if(v)_.push(0),v=!1;else _[_.length-1]++;if(!i())L(4,[],[4,5]);f=!0}if(j(),!v)_.pop();if($.getToken()!==4)L(8,[4],[]);else b();return!0}function i(){switch($.getToken()){case 3:return k();case 1:return KD();case 10:return e(!0);default:return p()}}if(b(),$.getToken()===17){if(B.allowEmptyContent)return!0;return L(4,[],[]),!1}if(!i())return L(4,[],[]),!1;if($.getToken()!==17)L(9,[],[]);return!0}function Y_(D){switch(typeof D){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(!D)return"null";else if(Array.isArray(D))return"array";return"object"}default:return"null"}}var Y3;var $1=V(()=>{h3();(function(D){D.DEFAULT={allowTrailingComma:!1}})(Y3||(Y3={}))});function F7(D,F,B,$){let _=F.slice(),Y=F1(D,[]),q=void 0,H=void 0;while(_.length>0)if(H=_.pop(),q=m3(Y,_),q===void 0&&B!==void 0)if(typeof H==="string")B={[H]:B};else B=[B];else break;if(!q){if(B===void 0)throw Error("Can not delete in empty document");return P2(D,{offset:Y?Y.offset:0,length:Y?Y.length:0,content:JSON.stringify(B)},$)}else if(q.type==="object"&&typeof H==="string"&&Array.isArray(q.children)){let J=m3(q,[H]);if(J!==void 0)if(B===void 0){if(!J.parent)throw Error("Malformed AST");let X=q.children.indexOf(J.parent),z,M=J.parent.offset+J.parent.length;if(X>0){let A=q.children[X-1];z=A.offset+A.length}else if(z=q.offset+1,q.children.length>1)M=q.children[1].offset;return P2(D,{offset:z,length:M-z,content:""},$)}else return P2(D,{offset:J.offset,length:J.length,content:JSON.stringify(B)},$);else{if(B===void 0)return[];let X=`${JSON.stringify(H)}: ${JSON.stringify(B)}`,z=$.getInsertionIndex?$.getInsertionIndex(q.children.map((A)=>A.children[0].value)):q.children.length,M;if(z>0){let A=q.children[z-1];M={offset:A.offset+A.length,length:0,content:","+X}}else if(q.children.length===0)M={offset:q.offset+1,length:0,content:X};else M={offset:q.offset+1,length:0,content:X+","};return P2(D,M,$)}}else if(q.type==="array"&&typeof H==="number"&&Array.isArray(q.children)){let J=H;if(J===-1){let X=`${JSON.stringify(B)}`,z;if(q.children.length===0)z={offset:q.offset+1,length:0,content:X};else{let M=q.children[q.children.length-1];z={offset:M.offset+M.length,length:0,content:","+X}}return P2(D,z,$)}else if(B===void 0&&q.children.length>=0){let X=H,z=q.children[X],M;if(q.children.length===1)M={offset:q.offset+1,length:q.length-2,content:""};else if(q.children.length-1===X){let A=q.children[X-1],K=A.offset+A.length,j=q.offset+q.length;M={offset:K,length:j-2-K,content:""}}else M={offset:z.offset,length:q.children[X+1].offset-z.offset,content:""};return P2(D,M,$)}else if(B!==void 0){let X,z=`${JSON.stringify(B)}`;if(!$.isArrayInsertion&&q.children.length>H){let M=q.children[H];X={offset:M.offset,length:M.length,content:z}}else if(q.children.length===0||H===0)X={offset:q.offset+1,length:0,content:q.children.length===0?z:z+","};else{let M=H>q.children.length?q.children.length:H,A=q.children[M-1];X={offset:A.offset+A.length,length:0,content:","+z}}return P2(D,X,$)}else throw Error(`Can not ${B===void 0?"remove":$.isArrayInsertion?"insert":"modify"} Array index ${J} as length is not sufficient`)}else throw Error(`Can not add ${typeof H!=="number"?"index":"property"} to parent of type ${q.type}`)}function P2(D,F,B){if(!B.formattingOptions)return[F];let $=g3(D,F),_=F.offset,Q=F.offset+F.content.length;if(F.length===0||F.content.length===0){while(_>0&&!Q3($,_-1))_--;while(Q<$.length&&!Q3($,Q))Q++}let Y=e8($,{offset:_,length:Q-_},{...B.formattingOptions,keepLines:!1});for(let H=Y.length-1;H>=0;H--){let J=Y[H];$=g3($,J),_=Math.min(_,J.offset),Q=Math.max(Q,J.offset+J.length),Q+=J.content.length-J.length}let q=D.length-($.length-Q)-_;return[{offset:_,length:q,content:$.substring(_,Q)}]}function g3(D,F){return D.substring(0,F.offset)+F.content+D.substring(F.offset+F.length)}var B7=V(()=>{D1();$1()});function K2(D){switch(D){case 1:return"InvalidSymbol";case 2:return"InvalidNumberFormat";case 3:return"PropertyNameExpected";case 4:return"ValueExpected";case 5:return"ColonExpected";case 6:return"CommaExpected";case 7:return"CloseBraceExpected";case 8:return"CloseBracketExpected";case 9:return"EndOfFileExpected";case 10:return"InvalidCommentToken";case 11:return"UnexpectedEndOfComment";case 12:return"UnexpectedEndOfString";case 13:return"UnexpectedEndOfNumber";case 14:return"InvalidUnicode";case 15:return"InvalidEscapeCharacter";case 16:return"InvalidCharacter"}return"<unknown ParseErrorCode>"}function AF(D,F,B,$){return F7(D,F,B,$)}function jF(D,F){let B=F.slice(0).sort((_,Q)=>{let Y=_.offset-Q.offset;if(Y===0)return _.length-Q.length;return Y}),$=D.length;for(let _=B.length-1;_>=0;_--){let Q=B[_];if(Q.offset+Q.length<=$)D=g3(D,Q);else throw Error("Overlapping edit");$=Q.offset}return D}var $7,_7,ND,Q7;var b0=V(()=>{D1();B7();h3();$1();(function(D){D[D.None=0]="None",D[D.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",D[D.UnexpectedEndOfString=2]="UnexpectedEndOfString",D[D.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",D[D.InvalidUnicode=4]="InvalidUnicode",D[D.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",D[D.InvalidCharacter=6]="InvalidCharacter"})($7||($7={}));(function(D){D[D.OpenBraceToken=1]="OpenBraceToken",D[D.CloseBraceToken=2]="CloseBraceToken",D[D.OpenBracketToken=3]="OpenBracketToken",D[D.CloseBracketToken=4]="CloseBracketToken",D[D.CommaToken=5]="CommaToken",D[D.ColonToken=6]="ColonToken",D[D.NullKeyword=7]="NullKeyword",D[D.TrueKeyword=8]="TrueKeyword",D[D.FalseKeyword=9]="FalseKeyword",D[D.StringLiteral=10]="StringLiteral",D[D.NumericLiteral=11]="NumericLiteral",D[D.LineCommentTrivia=12]="LineCommentTrivia",D[D.BlockCommentTrivia=13]="BlockCommentTrivia",D[D.LineBreakTrivia=14]="LineBreakTrivia",D[D.Trivia=15]="Trivia",D[D.Unknown=16]="Unknown",D[D.EOF=17]="EOF"})(_7||(_7={}));ND=D7;(function(D){D[D.InvalidSymbol=1]="InvalidSymbol",D[D.InvalidNumberFormat=2]="InvalidNumberFormat",D[D.PropertyNameExpected=3]="PropertyNameExpected",D[D.ValueExpected=4]="ValueExpected",D[D.ColonExpected=5]="ColonExpected",D[D.CommaExpected=6]="CommaExpected",D[D.CloseBraceExpected=7]="CloseBraceExpected",D[D.CloseBracketExpected=8]="CloseBracketExpected",D[D.EndOfFileExpected=9]="EndOfFileExpected",D[D.InvalidCommentToken=10]="InvalidCommentToken",D[D.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",D[D.UnexpectedEndOfString=12]="UnexpectedEndOfString",D[D.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",D[D.InvalidUnicode=14]="InvalidUnicode",D[D.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",D[D.InvalidCharacter=16]="InvalidCharacter"})(Q7||(Q7={}))});var QD,_1,I,c0=(D)=>{switch(typeof D){case"undefined":return I.undefined;case"string":return I.string;case"number":return Number.isNaN(D)?I.nan:I.number;case"boolean":return I.boolean;case"function":return I.function;case"bigint":return I.bigint;case"symbol":return I.symbol;case"object":if(Array.isArray(D))return I.array;if(D===null)return I.null;if(D.then&&typeof D.then==="function"&&D.catch&&typeof D.catch==="function")return I.promise;if(typeof Map<"u"&&D instanceof Map)return I.map;if(typeof Set<"u"&&D instanceof Set)return I.set;if(typeof Date<"u"&&D instanceof Date)return I.date;return I.object;default:return I.unknown}};var q3=V(()=>{(function(D){D.assertEqual=(_)=>{};function F(_){}D.assertIs=F;function B(_){throw Error()}D.assertNever=B,D.arrayToEnum=(_)=>{let Q={};for(let Y of _)Q[Y]=Y;return Q},D.getValidEnumValues=(_)=>{let Q=D.objectKeys(_).filter((q)=>typeof _[_[q]]!=="number"),Y={};for(let q of Q)Y[q]=_[q];return D.objectValues(Y)},D.objectValues=(_)=>{return D.objectKeys(_).map(function(Q){return _[Q]})},D.objectKeys=typeof Object.keys==="function"?(_)=>Object.keys(_):(_)=>{let Q=[];for(let Y in _)if(Object.prototype.hasOwnProperty.call(_,Y))Q.push(Y);return Q},D.find=(_,Q)=>{for(let Y of _)if(Q(Y))return Y;return},D.isInteger=typeof Number.isInteger==="function"?(_)=>Number.isInteger(_):(_)=>typeof _==="number"&&Number.isFinite(_)&&Math.floor(_)===_;function $(_,Q=" | "){return _.map((Y)=>typeof Y==="string"?`'${Y}'`:Y).join(Q)}D.joinValues=$,D.jsonStringifyReplacer=(_,Q)=>{if(typeof Q==="bigint")return Q.toString();return Q}})(QD||(QD={}));(function(D){D.mergeShapes=(F,B)=>{return{...F,...B}}})(_1||(_1={}));I=QD.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"])});var R,J_=(D)=>{return JSON.stringify(D,null,2).replace(/"([^"]+)":/g,"$1:")},cD;var d3=V(()=>{q3();R=QD.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);cD=class cD extends Error{get errors(){return this.issues}constructor(D){super();this.issues=[],this.addIssue=(B)=>{this.issues=[...this.issues,B]},this.addIssues=(B=[])=>{this.issues=[...this.issues,...B]};let F=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,F);else this.__proto__=F;this.name="ZodError",this.issues=D}format(D){let F=D||function(_){return _.message},B={_errors:[]},$=(_)=>{for(let Q of _.issues)if(Q.code==="invalid_union")Q.unionErrors.map($);else if(Q.code==="invalid_return_type")$(Q.returnTypeError);else if(Q.code==="invalid_arguments")$(Q.argumentsError);else if(Q.path.length===0)B._errors.push(F(Q));else{let Y=B,q=0;while(q<Q.path.length){let H=Q.path[q];if(q!==Q.path.length-1)Y[H]=Y[H]||{_errors:[]};else Y[H]=Y[H]||{_errors:[]},Y[H]._errors.push(F(Q));Y=Y[H],q++}}};return $(this),B}static assert(D){if(!(D instanceof cD))throw Error(`Not a ZodError: ${D}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,QD.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(D=(F)=>F.message){let F={},B=[];for(let $ of this.issues)if($.path.length>0){let _=$.path[0];F[_]=F[_]||[],F[_].push(D($))}else B.push(D($));return{formErrors:B,fieldErrors:F}}get formErrors(){return this.flatten()}};cD.create=(D)=>{return new cD(D)}});var X_=(D,F)=>{let B;switch(D.code){case R.invalid_type:if(D.received===I.undefined)B="Required";else B=`Expected ${D.expected}, received ${D.received}`;break;case R.invalid_literal:B=`Invalid literal value, expected ${JSON.stringify(D.expected,QD.jsonStringifyReplacer)}`;break;case R.unrecognized_keys:B=`Unrecognized key(s) in object: ${QD.joinValues(D.keys,", ")}`;break;case R.invalid_union:B="Invalid input";break;case R.invalid_union_discriminator:B=`Invalid discriminator value. Expected ${QD.joinValues(D.options)}`;break;case R.invalid_enum_value:B=`Invalid enum value. Expected ${QD.joinValues(D.options)}, received '${D.received}'`;break;case R.invalid_arguments:B="Invalid function arguments";break;case R.invalid_return_type:B="Invalid function return type";break;case R.invalid_date:B="Invalid date";break;case R.invalid_string:if(typeof D.validation==="object")if("includes"in D.validation){if(B=`Invalid input: must include "${D.validation.includes}"`,typeof D.validation.position==="number")B=`${B} at one or more positions greater than or equal to ${D.validation.position}`}else if("startsWith"in D.validation)B=`Invalid input: must start with "${D.validation.startsWith}"`;else if("endsWith"in D.validation)B=`Invalid input: must end with "${D.validation.endsWith}"`;else QD.assertNever(D.validation);else if(D.validation!=="regex")B=`Invalid ${D.validation}`;else B="Invalid";break;case R.too_small:if(D.type==="array")B=`Array must contain ${D.exact?"exactly":D.inclusive?"at least":"more than"} ${D.minimum} element(s)`;else if(D.type==="string")B=`String must contain ${D.exact?"exactly":D.inclusive?"at least":"over"} ${D.minimum} character(s)`;else if(D.type==="number")B=`Number must be ${D.exact?"exactly equal to ":D.inclusive?"greater than or equal to ":"greater than "}${D.minimum}`;else if(D.type==="bigint")B=`Number must be ${D.exact?"exactly equal to ":D.inclusive?"greater than or equal to ":"greater than "}${D.minimum}`;else if(D.type==="date")B=`Date must be ${D.exact?"exactly equal to ":D.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(D.minimum))}`;else B="Invalid input";break;case R.too_big:if(D.type==="array")B=`Array must contain ${D.exact?"exactly":D.inclusive?"at most":"less than"} ${D.maximum} element(s)`;else if(D.type==="string")B=`String must contain ${D.exact?"exactly":D.inclusive?"at most":"under"} ${D.maximum} character(s)`;else if(D.type==="number")B=`Number must be ${D.exact?"exactly":D.inclusive?"less than or equal to":"less than"} ${D.maximum}`;else if(D.type==="bigint")B=`BigInt must be ${D.exact?"exactly":D.inclusive?"less than or equal to":"less than"} ${D.maximum}`;else if(D.type==="date")B=`Date must be ${D.exact?"exactly":D.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(D.maximum))}`;else B="Invalid input";break;case R.custom:B="Invalid input";break;case R.invalid_intersection_types:B="Intersection results could not be merged";break;case R.not_multiple_of:B=`Number must be a multiple of ${D.multipleOf}`;break;case R.not_finite:B="Number must be finite";break;default:B=F.defaultError,QD.assertNever(D)}return{message:B}},F2;var Q1=V(()=>{d3();q3();F2=X_});function G_(D){Y7=D}function KF(){return Y7}var Y7;var c3=V(()=>{Q1();Y7=F2});function T(D,F){let B=KF(),$=H3({issueData:F,data:D.data,path:D.path,errorMaps:[D.common.contextualErrorMap,D.schemaErrorMap,B,B===F2?void 0:F2].filter((_)=>!!_)});D.common.issues.push($)}class lD{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray(D,F){let B=[];for(let $ of F){if($.status==="aborted")return l;if($.status==="dirty")D.dirty();B.push($.value)}return{status:D.value,value:B}}static async mergeObjectAsync(D,F){let B=[];for(let $ of F){let _=await $.key,Q=await $.value;B.push({key:_,value:Q})}return lD.mergeObjectSync(D,B)}static mergeObjectSync(D,F){let B={};for(let $ of F){let{key:_,value:Q}=$;if(_.status==="aborted")return l;if(Q.status==="aborted")return l;if(_.status==="dirty")D.dirty();if(Q.status==="dirty")D.dirty();if(_.value!=="__proto__"&&(typeof Q.value<"u"||$.alwaysSet))B[_.value]=Q.value}return{status:D.value,value:B}}}var H3=(D)=>{let{data:F,path:B,errorMaps:$,issueData:_}=D,Q=[...B,..._.path||[]],Y={..._,path:Q};if(_.message!==void 0)return{..._,path:Q,message:_.message};let q="",H=$.filter((J)=>!!J).slice().reverse();for(let J of H)q=J(Y,{data:F,defaultError:q}).message;return{..._,path:Q,message:q}},W_,l,x2=(D)=>({status:"dirty",value:D}),sD=(D)=>({status:"valid",value:D}),l3=(D)=>D.status==="aborted",p3=(D)=>D.status==="dirty",U2=(D)=>D.status==="valid",UF=(D)=>typeof Promise<"u"&&D instanceof Promise;var Y1=V(()=>{c3();Q1();W_=[];l=Object.freeze({status:"aborted"})});var q7=()=>{};var y;var H7=V(()=>{(function(D){D.errToObj=(F)=>typeof F==="string"?{message:F}:F||{},D.toString=(F)=>typeof F==="string"?F:F?.message})(y||(y={}))});class S0{constructor(D,F,B,$){this._cachedPath=[],this.parent=D,this.data=F,this._path=B,this._key=$}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}function DD(D){if(!D)return{};let{errorMap:F,invalid_type_error:B,required_error:$,description:_}=D;if(F&&(B||$))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(F)return{errorMap:F,description:_};return{errorMap:(Y,q)=>{let{message:H}=D;if(Y.code==="invalid_enum_value")return{message:H??q.defaultError};if(typeof q.data>"u")return{message:H??$??q.defaultError};if(Y.code!=="invalid_type")return{message:q.defaultError};return{message:H??B??q.defaultError}},description:_}}class BD{get description(){return this._def.description}_getType(D){return c0(D.data)}_getOrReturnCtx(D,F){return F||{common:D.parent.common,data:D.data,parsedType:c0(D.data),schemaErrorMap:this._def.errorMap,path:D.path,parent:D.parent}}_processInputParams(D){return{status:new lD,ctx:{common:D.parent.common,data:D.data,parsedType:c0(D.data),schemaErrorMap:this._def.errorMap,path:D.path,parent:D.parent}}}_parseSync(D){let F=this._parse(D);if(UF(F))throw Error("Synchronous parse encountered promise.");return F}_parseAsync(D){let F=this._parse(D);return Promise.resolve(F)}parse(D,F){let B=this.safeParse(D,F);if(B.success)return B.data;throw B.error}safeParse(D,F){let B={common:{issues:[],async:F?.async??!1,contextualErrorMap:F?.errorMap},path:F?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:D,parsedType:c0(D)},$=this._parseSync({data:D,path:B.path,parent:B});return J7(B,$)}"~validate"(D){let F={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:D,parsedType:c0(D)};if(!this["~standard"].async)try{let B=this._parseSync({data:D,path:[],parent:F});return U2(B)?{value:B.value}:{issues:F.common.issues}}catch(B){if(B?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;F.common={issues:[],async:!0}}return this._parseAsync({data:D,path:[],parent:F}).then((B)=>U2(B)?{value:B.value}:{issues:F.common.issues})}async parseAsync(D,F){let B=await this.safeParseAsync(D,F);if(B.success)return B.data;throw B.error}async safeParseAsync(D,F){let B={common:{issues:[],contextualErrorMap:F?.errorMap,async:!0},path:F?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:D,parsedType:c0(D)},$=this._parse({data:D,path:B.path,parent:B}),_=await(UF($)?$:Promise.resolve($));return J7(B,_)}refine(D,F){let B=($)=>{if(typeof F==="string"||typeof F>"u")return{message:F};else if(typeof F==="function")return F($);else return F};return this._refinement(($,_)=>{let Q=D($),Y=()=>_.addIssue({code:R.custom,...B($)});if(typeof Promise<"u"&&Q instanceof Promise)return Q.then((q)=>{if(!q)return Y(),!1;else return!0});if(!Q)return Y(),!1;else return!0})}refinement(D,F){return this._refinement((B,$)=>{if(!D(B))return $.addIssue(typeof F==="function"?F(B,$):F),!1;else return!0})}_refinement(D){return new k0({schema:this,typeName:n.ZodEffects,effect:{type:"refinement",refinement:D}})}superRefine(D){return this._refinement(D)}constructor(D){this.spa=this.safeParseAsync,this._def=D,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(F)=>this["~validate"](F)}}optional(){return N0.create(this,this._def)}nullable(){return $2.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Z0.create(this)}promise(){return m2.create(this,this._def)}or(D){return bF.create([this,D],this._def)}and(D){return RF.create(this,D,this._def)}transform(D){return new k0({...DD(this._def),schema:this,typeName:n.ZodEffects,effect:{type:"transform",transform:D}})}default(D){let F=typeof D==="function"?D:()=>D;return new kF({...DD(this._def),innerType:this,defaultValue:F,typeName:n.ZodDefault})}brand(){return new n3({typeName:n.ZodBranded,type:this,...DD(this._def)})}catch(D){let F=typeof D==="function"?D:()=>D;return new IF({...DD(this._def),innerType:this,catchValue:F,typeName:n.ZodCatch})}describe(D){return new this.constructor({...this._def,description:D})}pipe(D){return M3.create(this,D)}readonly(){return TF.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}function W7(D){let F="[0-5]\\d";if(D.precision)F=`${F}\\.\\d{${D.precision}}`;else if(D.precision==null)F=`${F}(\\.\\d+)?`;let B=D.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${F})${B}`}function k_(D){return new RegExp(`^${W7(D)}$`)}function z7(D){let F=`${G7}T${W7(D)}`,B=[];if(B.push(D.local?"Z?":"Z"),D.offset)B.push("([+-]\\d{2}:?\\d{2})");return F=`${F}(${B.join("|")})`,new RegExp(`^${F}$`)}function I_(D,F){if((F==="v4"||!F)&&w_.test(D))return!0;if((F==="v6"||!F)&&b_.test(D))return!0;return!1}function T_(D,F){if(!U_.test(D))return!1;try{let[B]=D.split(".");if(!B)return!1;let $=B.replace(/-/g,"+").replace(/_/g,"/").padEnd(B.length+(4-B.length%4)%4,"="),_=JSON.parse(atob($));if(typeof _!=="object"||_===null)return!1;if("typ"in _&&_?.typ!=="JWT")return!1;if(!_.alg)return!1;if(F&&_.alg!==F)return!1;return!0}catch{return!1}}function v_(D,F){if((F==="v4"||!F)&&O_.test(D))return!0;if((F==="v6"||!F)&&R_.test(D))return!0;return!1}function C_(D,F){let B=(D.toString().split(".")[1]||"").length,$=(F.toString().split(".")[1]||"").length,_=B>$?B:$,Q=Number.parseInt(D.toFixed(_).replace(".","")),Y=Number.parseInt(F.toFixed(_).replace(".",""));return Q%Y/10**_}function VF(D){if(D instanceof ID){let F={};for(let B in D.shape){let $=D.shape[B];F[B]=N0.create(VF($))}return new ID({...D._def,shape:()=>F})}else if(D instanceof Z0)return new Z0({...D._def,type:VF(D.element)});else if(D instanceof N0)return N0.create(VF(D.unwrap()));else if(D instanceof $2)return $2.create(VF(D.unwrap()));else if(D instanceof p0)return p0.create(D.items.map((F)=>VF(F)));else return D}function H1(D,F){let B=c0(D),$=c0(F);if(D===F)return{valid:!0,data:D};else if(B===I.object&&$===I.object){let _=QD.objectKeys(F),Q=QD.objectKeys(D).filter((q)=>_.indexOf(q)!==-1),Y={...D,...F};for(let q of Q){let H=H1(D[q],F[q]);if(!H.valid)return{valid:!1};Y[q]=H.data}return{valid:!0,data:Y}}else if(B===I.array&&$===I.array){if(D.length!==F.length)return{valid:!1};let _=[];for(let Q=0;Q<D.length;Q++){let Y=D[Q],q=F[Q],H=H1(Y,q);if(!H.valid)return{valid:!1};_.push(H.data)}return{valid:!0,data:_}}else if(B===I.date&&$===I.date&&+D===+F)return{valid:!0,data:D};else return{valid:!1}}function M7(D,F){return new w2({values:D,typeName:n.ZodEnum,...DD(F)})}function X7(D,F){let B=typeof D==="function"?D(F):typeof D==="string"?{message:D}:D;return typeof B==="string"?{message:B}:B}function A7(D,F={},B){if(D)return f2.create().superRefine(($,_)=>{let Q=D($);if(Q instanceof Promise)return Q.then((Y)=>{if(!Y){let q=X7(F,$),H=q.fatal??B??!0;_.addIssue({code:"custom",...q,fatal:H})}});if(!Q){let Y=X7(F,$),q=Y.fatal??B??!0;_.addIssue({code:"custom",...Y,fatal:q})}return});return f2.create()}var J7=(D,F)=>{if(U2(F))return{success:!0,data:F.value};else{if(!D.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let B=new cD(D.common.issues);return this._error=B,this._error}}}},z_,M_,A_,j_,K_,U_,V_,E_,L_="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",q1,w_,O_,b_,R_,Z_,N_,G7="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",S_,R0,E2,L2,LF,y2,J3,wF,OF,f2,V2,l0,X3,Z0,ID,bF,B2=(D)=>{if(D instanceof ZF)return B2(D.schema);else if(D instanceof k0)return B2(D.innerType());else if(D instanceof NF)return[D.value];else if(D instanceof w2)return D.options;else if(D instanceof SF)return QD.objectValues(D.enum);else if(D instanceof kF)return B2(D._def.innerType);else if(D instanceof wF)return[void 0];else if(D instanceof OF)return[null];else if(D instanceof N0)return[void 0,...B2(D.unwrap())];else if(D instanceof $2)return[null,...B2(D.unwrap())];else if(D instanceof n3)return B2(D.unwrap());else if(D instanceof TF)return B2(D.unwrap());else if(D instanceof IF)return B2(D._def.innerType);else return[]},i3,RF,p0,G3,W3,h2,EF,ZF,NF,w2,SF,m2,k0,N0,$2,kF,IF,z3,u_,n3,M3,TF,P_,n,x_=(D,F={message:`Input not instance of ${D.name}`})=>A7((B)=>B instanceof D,F),j7,K7,y_,f_,U7,h_,m_,g_,d_,c_,l_,p_,i_,n_,s_,a_,o_,r_,t_,e_,DQ,FQ,BQ,$Q,_Q,QQ,YQ,qQ,HQ,JQ,XQ,GQ,WQ,zQ,MQ=()=>j7().optional(),AQ=()=>K7().optional(),jQ=()=>U7().optional(),KQ,UQ;var V7=V(()=>{d3();c3();H7();Y1();q3();z_=/^c[^\s-]{8,}$/i,M_=/^[0-9a-z]+$/,A_=/^[0-9A-HJKMNP-TV-Z]{26}$/i,j_=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,K_=/^[a-z0-9_-]{21}$/i,U_=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,V_=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,E_=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,w_=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,O_=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,b_=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,R_=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Z_=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,N_=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,S_=new RegExp(`^${G7}$`);R0=class R0 extends BD{_parse(D){if(this._def.coerce)D.data=String(D.data);if(this._getType(D)!==I.string){let _=this._getOrReturnCtx(D);return T(_,{code:R.invalid_type,expected:I.string,received:_.parsedType}),l}let B=new lD,$=void 0;for(let _ of this._def.checks)if(_.kind==="min"){if(D.data.length<_.value)$=this._getOrReturnCtx(D,$),T($,{code:R.too_small,minimum:_.value,type:"string",inclusive:!0,exact:!1,message:_.message}),B.dirty()}else if(_.kind==="max"){if(D.data.length>_.value)$=this._getOrReturnCtx(D,$),T($,{code:R.too_big,maximum:_.value,type:"string",inclusive:!0,exact:!1,message:_.message}),B.dirty()}else if(_.kind==="length"){let Q=D.data.length>_.value,Y=D.data.length<_.value;if(Q||Y){if($=this._getOrReturnCtx(D,$),Q)T($,{code:R.too_big,maximum:_.value,type:"string",inclusive:!0,exact:!0,message:_.message});else if(Y)T($,{code:R.too_small,minimum:_.value,type:"string",inclusive:!0,exact:!0,message:_.message});B.dirty()}}else if(_.kind==="email"){if(!E_.test(D.data))$=this._getOrReturnCtx(D,$),T($,{validation:"email",code:R.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="emoji"){if(!q1)q1=new RegExp(L_,"u");if(!q1.test(D.data))$=this._getOrReturnCtx(D,$),T($,{validation:"emoji",code:R.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="uuid"){if(!j_.test(D.data))$=this._getOrReturnCtx(D,$),T($,{validation:"uuid",code:R.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="nanoid"){if(!K_.test(D.data))$=this._getOrReturnCtx(D,$),T($,{validation:"nanoid",code:R.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="cuid"){if(!z_.test(D.data))$=this._getOrReturnCtx(D,$),T($,{validation:"cuid",code:R.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="cuid2"){if(!M_.test(D.data))$=this._getOrReturnCtx(D,$),T($,{validation:"cuid2",code:R.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="ulid"){if(!A_.test(D.data))$=this._getOrReturnCtx(D,$),T($,{validation:"ulid",code:R.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="url")try{new URL(D.data)}catch{$=this._getOrReturnCtx(D,$),T($,{validation:"url",code:R.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="regex"){if(_.regex.lastIndex=0,!_.regex.test(D.data))$=this._getOrReturnCtx(D,$),T($,{validation:"regex",code:R.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="trim")D.data=D.data.trim();else if(_.kind==="includes"){if(!D.data.includes(_.value,_.position))$=this._getOrReturnCtx(D,$),T($,{code:R.invalid_string,validation:{includes:_.value,position:_.position},message:_.message}),B.dirty()}else if(_.kind==="toLowerCase")D.data=D.data.toLowerCase();else if(_.kind==="toUpperCase")D.data=D.data.toUpperCase();else if(_.kind==="startsWith"){if(!D.data.startsWith(_.value))$=this._getOrReturnCtx(D,$),T($,{code:R.invalid_string,validation:{startsWith:_.value},message:_.message}),B.dirty()}else if(_.kind==="endsWith"){if(!D.data.endsWith(_.value))$=this._getOrReturnCtx(D,$),T($,{code:R.invalid_string,validation:{endsWith:_.value},message:_.message}),B.dirty()}else if(_.kind==="datetime"){if(!z7(_).test(D.data))$=this._getOrReturnCtx(D,$),T($,{code:R.invalid_string,validation:"datetime",message:_.message}),B.dirty()}else if(_.kind==="date"){if(!S_.test(D.data))$=this._getOrReturnCtx(D,$),T($,{code:R.invalid_string,validation:"date",message:_.message}),B.dirty()}else if(_.kind==="time"){if(!k_(_).test(D.data))$=this._getOrReturnCtx(D,$),T($,{code:R.invalid_string,validation:"time",message:_.message}),B.dirty()}else if(_.kind==="duration"){if(!V_.test(D.data))$=this._getOrReturnCtx(D,$),T($,{validation:"duration",code:R.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="ip"){if(!I_(D.data,_.version))$=this._getOrReturnCtx(D,$),T($,{validation:"ip",code:R.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="jwt"){if(!T_(D.data,_.alg))$=this._getOrReturnCtx(D,$),T($,{validation:"jwt",code:R.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="cidr"){if(!v_(D.data,_.version))$=this._getOrReturnCtx(D,$),T($,{validation:"cidr",code:R.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="base64"){if(!Z_.test(D.data))$=this._getOrReturnCtx(D,$),T($,{validation:"base64",code:R.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="base64url"){if(!N_.test(D.data))$=this._getOrReturnCtx(D,$),T($,{validation:"base64url",code:R.invalid_string,message:_.message}),B.dirty()}else QD.assertNever(_);return{status:B.value,value:D.data}}_regex(D,F,B){return this.refinement(($)=>D.test($),{validation:F,code:R.invalid_string,...y.errToObj(B)})}_addCheck(D){return new R0({...this._def,checks:[...this._def.checks,D]})}email(D){return this._addCheck({kind:"email",...y.errToObj(D)})}url(D){return this._addCheck({kind:"url",...y.errToObj(D)})}emoji(D){return this._addCheck({kind:"emoji",...y.errToObj(D)})}uuid(D){return this._addCheck({kind:"uuid",...y.errToObj(D)})}nanoid(D){return this._addCheck({kind:"nanoid",...y.errToObj(D)})}cuid(D){return this._addCheck({kind:"cuid",...y.errToObj(D)})}cuid2(D){return this._addCheck({kind:"cuid2",...y.errToObj(D)})}ulid(D){return this._addCheck({kind:"ulid",...y.errToObj(D)})}base64(D){return this._addCheck({kind:"base64",...y.errToObj(D)})}base64url(D){return this._addCheck({kind:"base64url",...y.errToObj(D)})}jwt(D){return this._addCheck({kind:"jwt",...y.errToObj(D)})}ip(D){return this._addCheck({kind:"ip",...y.errToObj(D)})}cidr(D){return this._addCheck({kind:"cidr",...y.errToObj(D)})}datetime(D){if(typeof D==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:D});return this._addCheck({kind:"datetime",precision:typeof D?.precision>"u"?null:D?.precision,offset:D?.offset??!1,local:D?.local??!1,...y.errToObj(D?.message)})}date(D){return this._addCheck({kind:"date",message:D})}time(D){if(typeof D==="string")return this._addCheck({kind:"time",precision:null,message:D});return this._addCheck({kind:"time",precision:typeof D?.precision>"u"?null:D?.precision,...y.errToObj(D?.message)})}duration(D){return this._addCheck({kind:"duration",...y.errToObj(D)})}regex(D,F){return this._addCheck({kind:"regex",regex:D,...y.errToObj(F)})}includes(D,F){return this._addCheck({kind:"includes",value:D,position:F?.position,...y.errToObj(F?.message)})}startsWith(D,F){return this._addCheck({kind:"startsWith",value:D,...y.errToObj(F)})}endsWith(D,F){return this._addCheck({kind:"endsWith",value:D,...y.errToObj(F)})}min(D,F){return this._addCheck({kind:"min",value:D,...y.errToObj(F)})}max(D,F){return this._addCheck({kind:"max",value:D,...y.errToObj(F)})}length(D,F){return this._addCheck({kind:"length",value:D,...y.errToObj(F)})}nonempty(D){return this.min(1,y.errToObj(D))}trim(){return new R0({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new R0({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new R0({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((D)=>D.kind==="datetime")}get isDate(){return!!this._def.checks.find((D)=>D.kind==="date")}get isTime(){return!!this._def.checks.find((D)=>D.kind==="time")}get isDuration(){return!!this._def.checks.find((D)=>D.kind==="duration")}get isEmail(){return!!this._def.checks.find((D)=>D.kind==="email")}get isURL(){return!!this._def.checks.find((D)=>D.kind==="url")}get isEmoji(){return!!this._def.checks.find((D)=>D.kind==="emoji")}get isUUID(){return!!this._def.checks.find((D)=>D.kind==="uuid")}get isNANOID(){return!!this._def.checks.find((D)=>D.kind==="nanoid")}get isCUID(){return!!this._def.checks.find((D)=>D.kind==="cuid")}get isCUID2(){return!!this._def.checks.find((D)=>D.kind==="cuid2")}get isULID(){return!!this._def.checks.find((D)=>D.kind==="ulid")}get isIP(){return!!this._def.checks.find((D)=>D.kind==="ip")}get isCIDR(){return!!this._def.checks.find((D)=>D.kind==="cidr")}get isBase64(){return!!this._def.checks.find((D)=>D.kind==="base64")}get isBase64url(){return!!this._def.checks.find((D)=>D.kind==="base64url")}get minLength(){let D=null;for(let F of this._def.checks)if(F.kind==="min"){if(D===null||F.value>D)D=F.value}return D}get maxLength(){let D=null;for(let F of this._def.checks)if(F.kind==="max"){if(D===null||F.value<D)D=F.value}return D}};R0.create=(D)=>{return new R0({checks:[],typeName:n.ZodString,coerce:D?.coerce??!1,...DD(D)})};E2=class E2 extends BD{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(D){if(this._def.coerce)D.data=Number(D.data);if(this._getType(D)!==I.number){let _=this._getOrReturnCtx(D);return T(_,{code:R.invalid_type,expected:I.number,received:_.parsedType}),l}let B=void 0,$=new lD;for(let _ of this._def.checks)if(_.kind==="int"){if(!QD.isInteger(D.data))B=this._getOrReturnCtx(D,B),T(B,{code:R.invalid_type,expected:"integer",received:"float",message:_.message}),$.dirty()}else if(_.kind==="min"){if(_.inclusive?D.data<_.value:D.data<=_.value)B=this._getOrReturnCtx(D,B),T(B,{code:R.too_small,minimum:_.value,type:"number",inclusive:_.inclusive,exact:!1,message:_.message}),$.dirty()}else if(_.kind==="max"){if(_.inclusive?D.data>_.value:D.data>=_.value)B=this._getOrReturnCtx(D,B),T(B,{code:R.too_big,maximum:_.value,type:"number",inclusive:_.inclusive,exact:!1,message:_.message}),$.dirty()}else if(_.kind==="multipleOf"){if(C_(D.data,_.value)!==0)B=this._getOrReturnCtx(D,B),T(B,{code:R.not_multiple_of,multipleOf:_.value,message:_.message}),$.dirty()}else if(_.kind==="finite"){if(!Number.isFinite(D.data))B=this._getOrReturnCtx(D,B),T(B,{code:R.not_finite,message:_.message}),$.dirty()}else QD.assertNever(_);return{status:$.value,value:D.data}}gte(D,F){return this.setLimit("min",D,!0,y.toString(F))}gt(D,F){return this.setLimit("min",D,!1,y.toString(F))}lte(D,F){return this.setLimit("max",D,!0,y.toString(F))}lt(D,F){return this.setLimit("max",D,!1,y.toString(F))}setLimit(D,F,B,$){return new E2({...this._def,checks:[...this._def.checks,{kind:D,value:F,inclusive:B,message:y.toString($)}]})}_addCheck(D){return new E2({...this._def,checks:[...this._def.checks,D]})}int(D){return this._addCheck({kind:"int",message:y.toString(D)})}positive(D){return this._addCheck({kind:"min",value:0,inclusive:!1,message:y.toString(D)})}negative(D){return this._addCheck({kind:"max",value:0,inclusive:!1,message:y.toString(D)})}nonpositive(D){return this._addCheck({kind:"max",value:0,inclusive:!0,message:y.toString(D)})}nonnegative(D){return this._addCheck({kind:"min",value:0,inclusive:!0,message:y.toString(D)})}multipleOf(D,F){return this._addCheck({kind:"multipleOf",value:D,message:y.toString(F)})}finite(D){return this._addCheck({kind:"finite",message:y.toString(D)})}safe(D){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:y.toString(D)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:y.toString(D)})}get minValue(){let D=null;for(let F of this._def.checks)if(F.kind==="min"){if(D===null||F.value>D)D=F.value}return D}get maxValue(){let D=null;for(let F of this._def.checks)if(F.kind==="max"){if(D===null||F.value<D)D=F.value}return D}get isInt(){return!!this._def.checks.find((D)=>D.kind==="int"||D.kind==="multipleOf"&&QD.isInteger(D.value))}get isFinite(){let D=null,F=null;for(let B of this._def.checks)if(B.kind==="finite"||B.kind==="int"||B.kind==="multipleOf")return!0;else if(B.kind==="min"){if(F===null||B.value>F)F=B.value}else if(B.kind==="max"){if(D===null||B.value<D)D=B.value}return Number.isFinite(F)&&Number.isFinite(D)}};E2.create=(D)=>{return new E2({checks:[],typeName:n.ZodNumber,coerce:D?.coerce||!1,...DD(D)})};L2=class L2 extends BD{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse(D){if(this._def.coerce)try{D.data=BigInt(D.data)}catch{return this._getInvalidInput(D)}if(this._getType(D)!==I.bigint)return this._getInvalidInput(D);let B=void 0,$=new lD;for(let _ of this._def.checks)if(_.kind==="min"){if(_.inclusive?D.data<_.value:D.data<=_.value)B=this._getOrReturnCtx(D,B),T(B,{code:R.too_small,type:"bigint",minimum:_.value,inclusive:_.inclusive,message:_.message}),$.dirty()}else if(_.kind==="max"){if(_.inclusive?D.data>_.value:D.data>=_.value)B=this._getOrReturnCtx(D,B),T(B,{code:R.too_big,type:"bigint",maximum:_.value,inclusive:_.inclusive,message:_.message}),$.dirty()}else if(_.kind==="multipleOf"){if(D.data%_.value!==BigInt(0))B=this._getOrReturnCtx(D,B),T(B,{code:R.not_multiple_of,multipleOf:_.value,message:_.message}),$.dirty()}else QD.assertNever(_);return{status:$.value,value:D.data}}_getInvalidInput(D){let F=this._getOrReturnCtx(D);return T(F,{code:R.invalid_type,expected:I.bigint,received:F.parsedType}),l}gte(D,F){return this.setLimit("min",D,!0,y.toString(F))}gt(D,F){return this.setLimit("min",D,!1,y.toString(F))}lte(D,F){return this.setLimit("max",D,!0,y.toString(F))}lt(D,F){return this.setLimit("max",D,!1,y.toString(F))}setLimit(D,F,B,$){return new L2({...this._def,checks:[...this._def.checks,{kind:D,value:F,inclusive:B,message:y.toString($)}]})}_addCheck(D){return new L2({...this._def,checks:[...this._def.checks,D]})}positive(D){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:y.toString(D)})}negative(D){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:y.toString(D)})}nonpositive(D){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:y.toString(D)})}nonnegative(D){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:y.toString(D)})}multipleOf(D,F){return this._addCheck({kind:"multipleOf",value:D,message:y.toString(F)})}get minValue(){let D=null;for(let F of this._def.checks)if(F.kind==="min"){if(D===null||F.value>D)D=F.value}return D}get maxValue(){let D=null;for(let F of this._def.checks)if(F.kind==="max"){if(D===null||F.value<D)D=F.value}return D}};L2.create=(D)=>{return new L2({checks:[],typeName:n.ZodBigInt,coerce:D?.coerce??!1,...DD(D)})};LF=class LF extends BD{_parse(D){if(this._def.coerce)D.data=Boolean(D.data);if(this._getType(D)!==I.boolean){let B=this._getOrReturnCtx(D);return T(B,{code:R.invalid_type,expected:I.boolean,received:B.parsedType}),l}return sD(D.data)}};LF.create=(D)=>{return new LF({typeName:n.ZodBoolean,coerce:D?.coerce||!1,...DD(D)})};y2=class y2 extends BD{_parse(D){if(this._def.coerce)D.data=new Date(D.data);if(this._getType(D)!==I.date){let _=this._getOrReturnCtx(D);return T(_,{code:R.invalid_type,expected:I.date,received:_.parsedType}),l}if(Number.isNaN(D.data.getTime())){let _=this._getOrReturnCtx(D);return T(_,{code:R.invalid_date}),l}let B=new lD,$=void 0;for(let _ of this._def.checks)if(_.kind==="min"){if(D.data.getTime()<_.value)$=this._getOrReturnCtx(D,$),T($,{code:R.too_small,message:_.message,inclusive:!0,exact:!1,minimum:_.value,type:"date"}),B.dirty()}else if(_.kind==="max"){if(D.data.getTime()>_.value)$=this._getOrReturnCtx(D,$),T($,{code:R.too_big,message:_.message,inclusive:!0,exact:!1,maximum:_.value,type:"date"}),B.dirty()}else QD.assertNever(_);return{status:B.value,value:new Date(D.data.getTime())}}_addCheck(D){return new y2({...this._def,checks:[...this._def.checks,D]})}min(D,F){return this._addCheck({kind:"min",value:D.getTime(),message:y.toString(F)})}max(D,F){return this._addCheck({kind:"max",value:D.getTime(),message:y.toString(F)})}get minDate(){let D=null;for(let F of this._def.checks)if(F.kind==="min"){if(D===null||F.value>D)D=F.value}return D!=null?new Date(D):null}get maxDate(){let D=null;for(let F of this._def.checks)if(F.kind==="max"){if(D===null||F.value<D)D=F.value}return D!=null?new Date(D):null}};y2.create=(D)=>{return new y2({checks:[],coerce:D?.coerce||!1,typeName:n.ZodDate,...DD(D)})};J3=class J3 extends BD{_parse(D){if(this._getType(D)!==I.symbol){let B=this._getOrReturnCtx(D);return T(B,{code:R.invalid_type,expected:I.symbol,received:B.parsedType}),l}return sD(D.data)}};J3.create=(D)=>{return new J3({typeName:n.ZodSymbol,...DD(D)})};wF=class wF extends BD{_parse(D){if(this._getType(D)!==I.undefined){let B=this._getOrReturnCtx(D);return T(B,{code:R.invalid_type,expected:I.undefined,received:B.parsedType}),l}return sD(D.data)}};wF.create=(D)=>{return new wF({typeName:n.ZodUndefined,...DD(D)})};OF=class OF extends BD{_parse(D){if(this._getType(D)!==I.null){let B=this._getOrReturnCtx(D);return T(B,{code:R.invalid_type,expected:I.null,received:B.parsedType}),l}return sD(D.data)}};OF.create=(D)=>{return new OF({typeName:n.ZodNull,...DD(D)})};f2=class f2 extends BD{constructor(){super(...arguments);this._any=!0}_parse(D){return sD(D.data)}};f2.create=(D)=>{return new f2({typeName:n.ZodAny,...DD(D)})};V2=class V2 extends BD{constructor(){super(...arguments);this._unknown=!0}_parse(D){return sD(D.data)}};V2.create=(D)=>{return new V2({typeName:n.ZodUnknown,...DD(D)})};l0=class l0 extends BD{_parse(D){let F=this._getOrReturnCtx(D);return T(F,{code:R.invalid_type,expected:I.never,received:F.parsedType}),l}};l0.create=(D)=>{return new l0({typeName:n.ZodNever,...DD(D)})};X3=class X3 extends BD{_parse(D){if(this._getType(D)!==I.undefined){let B=this._getOrReturnCtx(D);return T(B,{code:R.invalid_type,expected:I.void,received:B.parsedType}),l}return sD(D.data)}};X3.create=(D)=>{return new X3({typeName:n.ZodVoid,...DD(D)})};Z0=class Z0 extends BD{_parse(D){let{ctx:F,status:B}=this._processInputParams(D),$=this._def;if(F.parsedType!==I.array)return T(F,{code:R.invalid_type,expected:I.array,received:F.parsedType}),l;if($.exactLength!==null){let Q=F.data.length>$.exactLength.value,Y=F.data.length<$.exactLength.value;if(Q||Y)T(F,{code:Q?R.too_big:R.too_small,minimum:Y?$.exactLength.value:void 0,maximum:Q?$.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:$.exactLength.message}),B.dirty()}if($.minLength!==null){if(F.data.length<$.minLength.value)T(F,{code:R.too_small,minimum:$.minLength.value,type:"array",inclusive:!0,exact:!1,message:$.minLength.message}),B.dirty()}if($.maxLength!==null){if(F.data.length>$.maxLength.value)T(F,{code:R.too_big,maximum:$.maxLength.value,type:"array",inclusive:!0,exact:!1,message:$.maxLength.message}),B.dirty()}if(F.common.async)return Promise.all([...F.data].map((Q,Y)=>{return $.type._parseAsync(new S0(F,Q,F.path,Y))})).then((Q)=>{return lD.mergeArray(B,Q)});let _=[...F.data].map((Q,Y)=>{return $.type._parseSync(new S0(F,Q,F.path,Y))});return lD.mergeArray(B,_)}get element(){return this._def.type}min(D,F){return new Z0({...this._def,minLength:{value:D,message:y.toString(F)}})}max(D,F){return new Z0({...this._def,maxLength:{value:D,message:y.toString(F)}})}length(D,F){return new Z0({...this._def,exactLength:{value:D,message:y.toString(F)}})}nonempty(D){return this.min(1,D)}};Z0.create=(D,F)=>{return new Z0({type:D,minLength:null,maxLength:null,exactLength:null,typeName:n.ZodArray,...DD(F)})};ID=class ID extends BD{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let D=this._def.shape(),F=QD.objectKeys(D);return this._cached={shape:D,keys:F},this._cached}_parse(D){if(this._getType(D)!==I.object){let H=this._getOrReturnCtx(D);return T(H,{code:R.invalid_type,expected:I.object,received:H.parsedType}),l}let{status:B,ctx:$}=this._processInputParams(D),{shape:_,keys:Q}=this._getCached(),Y=[];if(!(this._def.catchall instanceof l0&&this._def.unknownKeys==="strip")){for(let H in $.data)if(!Q.includes(H))Y.push(H)}let q=[];for(let H of Q){let J=_[H],X=$.data[H];q.push({key:{status:"valid",value:H},value:J._parse(new S0($,X,$.path,H)),alwaysSet:H in $.data})}if(this._def.catchall instanceof l0){let H=this._def.unknownKeys;if(H==="passthrough")for(let J of Y)q.push({key:{status:"valid",value:J},value:{status:"valid",value:$.data[J]}});else if(H==="strict"){if(Y.length>0)T($,{code:R.unrecognized_keys,keys:Y}),B.dirty()}else if(H==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let H=this._def.catchall;for(let J of Y){let X=$.data[J];q.push({key:{status:"valid",value:J},value:H._parse(new S0($,X,$.path,J)),alwaysSet:J in $.data})}}if($.common.async)return Promise.resolve().then(async()=>{let H=[];for(let J of q){let X=await J.key,z=await J.value;H.push({key:X,value:z,alwaysSet:J.alwaysSet})}return H}).then((H)=>{return lD.mergeObjectSync(B,H)});else return lD.mergeObjectSync(B,q)}get shape(){return this._def.shape()}strict(D){return y.errToObj,new ID({...this._def,unknownKeys:"strict",...D!==void 0?{errorMap:(F,B)=>{let $=this._def.errorMap?.(F,B).message??B.defaultError;if(F.code==="unrecognized_keys")return{message:y.errToObj(D).message??$};return{message:$}}}:{}})}strip(){return new ID({...this._def,unknownKeys:"strip"})}passthrough(){return new ID({...this._def,unknownKeys:"passthrough"})}extend(D){return new ID({...this._def,shape:()=>({...this._def.shape(),...D})})}merge(D){return new ID({unknownKeys:D._def.unknownKeys,catchall:D._def.catchall,shape:()=>({...this._def.shape(),...D._def.shape()}),typeName:n.ZodObject})}setKey(D,F){return this.augment({[D]:F})}catchall(D){return new ID({...this._def,catchall:D})}pick(D){let F={};for(let B of QD.objectKeys(D))if(D[B]&&this.shape[B])F[B]=this.shape[B];return new ID({...this._def,shape:()=>F})}omit(D){let F={};for(let B of QD.objectKeys(this.shape))if(!D[B])F[B]=this.shape[B];return new ID({...this._def,shape:()=>F})}deepPartial(){return VF(this)}partial(D){let F={};for(let B of QD.objectKeys(this.shape)){let $=this.shape[B];if(D&&!D[B])F[B]=$;else F[B]=$.optional()}return new ID({...this._def,shape:()=>F})}required(D){let F={};for(let B of QD.objectKeys(this.shape))if(D&&!D[B])F[B]=this.shape[B];else{let _=this.shape[B];while(_ instanceof N0)_=_._def.innerType;F[B]=_}return new ID({...this._def,shape:()=>F})}keyof(){return M7(QD.objectKeys(this.shape))}};ID.create=(D,F)=>{return new ID({shape:()=>D,unknownKeys:"strip",catchall:l0.create(),typeName:n.ZodObject,...DD(F)})};ID.strictCreate=(D,F)=>{return new ID({shape:()=>D,unknownKeys:"strict",catchall:l0.create(),typeName:n.ZodObject,...DD(F)})};ID.lazycreate=(D,F)=>{return new ID({shape:D,unknownKeys:"strip",catchall:l0.create(),typeName:n.ZodObject,...DD(F)})};bF=class bF extends BD{_parse(D){let{ctx:F}=this._processInputParams(D),B=this._def.options;function $(_){for(let Y of _)if(Y.result.status==="valid")return Y.result;for(let Y of _)if(Y.result.status==="dirty")return F.common.issues.push(...Y.ctx.common.issues),Y.result;let Q=_.map((Y)=>new cD(Y.ctx.common.issues));return T(F,{code:R.invalid_union,unionErrors:Q}),l}if(F.common.async)return Promise.all(B.map(async(_)=>{let Q={...F,common:{...F.common,issues:[]},parent:null};return{result:await _._parseAsync({data:F.data,path:F.path,parent:Q}),ctx:Q}})).then($);else{let _=void 0,Q=[];for(let q of B){let H={...F,common:{...F.common,issues:[]},parent:null},J=q._parseSync({data:F.data,path:F.path,parent:H});if(J.status==="valid")return J;else if(J.status==="dirty"&&!_)_={result:J,ctx:H};if(H.common.issues.length)Q.push(H.common.issues)}if(_)return F.common.issues.push(..._.ctx.common.issues),_.result;let Y=Q.map((q)=>new cD(q));return T(F,{code:R.invalid_union,unionErrors:Y}),l}}get options(){return this._def.options}};bF.create=(D,F)=>{return new bF({options:D,typeName:n.ZodUnion,...DD(F)})};i3=class i3 extends BD{_parse(D){let{ctx:F}=this._processInputParams(D);if(F.parsedType!==I.object)return T(F,{code:R.invalid_type,expected:I.object,received:F.parsedType}),l;let B=this.discriminator,$=F.data[B],_=this.optionsMap.get($);if(!_)return T(F,{code:R.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[B]}),l;if(F.common.async)return _._parseAsync({data:F.data,path:F.path,parent:F});else return _._parseSync({data:F.data,path:F.path,parent:F})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(D,F,B){let $=new Map;for(let _ of F){let Q=B2(_.shape[D]);if(!Q.length)throw Error(`A discriminator value for key \`${D}\` could not be extracted from all schema options`);for(let Y of Q){if($.has(Y))throw Error(`Discriminator property ${String(D)} has duplicate value ${String(Y)}`);$.set(Y,_)}}return new i3({typeName:n.ZodDiscriminatedUnion,discriminator:D,options:F,optionsMap:$,...DD(B)})}};RF=class RF extends BD{_parse(D){let{status:F,ctx:B}=this._processInputParams(D),$=(_,Q)=>{if(l3(_)||l3(Q))return l;let Y=H1(_.value,Q.value);if(!Y.valid)return T(B,{code:R.invalid_intersection_types}),l;if(p3(_)||p3(Q))F.dirty();return{status:F.value,value:Y.data}};if(B.common.async)return Promise.all([this._def.left._parseAsync({data:B.data,path:B.path,parent:B}),this._def.right._parseAsync({data:B.data,path:B.path,parent:B})]).then(([_,Q])=>$(_,Q));else return $(this._def.left._parseSync({data:B.data,path:B.path,parent:B}),this._def.right._parseSync({data:B.data,path:B.path,parent:B}))}};RF.create=(D,F,B)=>{return new RF({left:D,right:F,typeName:n.ZodIntersection,...DD(B)})};p0=class p0 extends BD{_parse(D){let{status:F,ctx:B}=this._processInputParams(D);if(B.parsedType!==I.array)return T(B,{code:R.invalid_type,expected:I.array,received:B.parsedType}),l;if(B.data.length<this._def.items.length)return T(B,{code:R.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),l;if(!this._def.rest&&B.data.length>this._def.items.length)T(B,{code:R.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),F.dirty();let _=[...B.data].map((Q,Y)=>{let q=this._def.items[Y]||this._def.rest;if(!q)return null;return q._parse(new S0(B,Q,B.path,Y))}).filter((Q)=>!!Q);if(B.common.async)return Promise.all(_).then((Q)=>{return lD.mergeArray(F,Q)});else return lD.mergeArray(F,_)}get items(){return this._def.items}rest(D){return new p0({...this._def,rest:D})}};p0.create=(D,F)=>{if(!Array.isArray(D))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new p0({items:D,typeName:n.ZodTuple,rest:null,...DD(F)})};G3=class G3 extends BD{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(D){let{status:F,ctx:B}=this._processInputParams(D);if(B.parsedType!==I.object)return T(B,{code:R.invalid_type,expected:I.object,received:B.parsedType}),l;let $=[],_=this._def.keyType,Q=this._def.valueType;for(let Y in B.data)$.push({key:_._parse(new S0(B,Y,B.path,Y)),value:Q._parse(new S0(B,B.data[Y],B.path,Y)),alwaysSet:Y in B.data});if(B.common.async)return lD.mergeObjectAsync(F,$);else return lD.mergeObjectSync(F,$)}get element(){return this._def.valueType}static create(D,F,B){if(F instanceof BD)return new G3({keyType:D,valueType:F,typeName:n.ZodRecord,...DD(B)});return new G3({keyType:R0.create(),valueType:D,typeName:n.ZodRecord,...DD(F)})}};W3=class W3 extends BD{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(D){let{status:F,ctx:B}=this._processInputParams(D);if(B.parsedType!==I.map)return T(B,{code:R.invalid_type,expected:I.map,received:B.parsedType}),l;let $=this._def.keyType,_=this._def.valueType,Q=[...B.data.entries()].map(([Y,q],H)=>{return{key:$._parse(new S0(B,Y,B.path,[H,"key"])),value:_._parse(new S0(B,q,B.path,[H,"value"]))}});if(B.common.async){let Y=new Map;return Promise.resolve().then(async()=>{for(let q of Q){let H=await q.key,J=await q.value;if(H.status==="aborted"||J.status==="aborted")return l;if(H.status==="dirty"||J.status==="dirty")F.dirty();Y.set(H.value,J.value)}return{status:F.value,value:Y}})}else{let Y=new Map;for(let q of Q){let{key:H,value:J}=q;if(H.status==="aborted"||J.status==="aborted")return l;if(H.status==="dirty"||J.status==="dirty")F.dirty();Y.set(H.value,J.value)}return{status:F.value,value:Y}}}};W3.create=(D,F,B)=>{return new W3({valueType:F,keyType:D,typeName:n.ZodMap,...DD(B)})};h2=class h2 extends BD{_parse(D){let{status:F,ctx:B}=this._processInputParams(D);if(B.parsedType!==I.set)return T(B,{code:R.invalid_type,expected:I.set,received:B.parsedType}),l;let $=this._def;if($.minSize!==null){if(B.data.size<$.minSize.value)T(B,{code:R.too_small,minimum:$.minSize.value,type:"set",inclusive:!0,exact:!1,message:$.minSize.message}),F.dirty()}if($.maxSize!==null){if(B.data.size>$.maxSize.value)T(B,{code:R.too_big,maximum:$.maxSize.value,type:"set",inclusive:!0,exact:!1,message:$.maxSize.message}),F.dirty()}let _=this._def.valueType;function Q(q){let H=new Set;for(let J of q){if(J.status==="aborted")return l;if(J.status==="dirty")F.dirty();H.add(J.value)}return{status:F.value,value:H}}let Y=[...B.data.values()].map((q,H)=>_._parse(new S0(B,q,B.path,H)));if(B.common.async)return Promise.all(Y).then((q)=>Q(q));else return Q(Y)}min(D,F){return new h2({...this._def,minSize:{value:D,message:y.toString(F)}})}max(D,F){return new h2({...this._def,maxSize:{value:D,message:y.toString(F)}})}size(D,F){return this.min(D,F).max(D,F)}nonempty(D){return this.min(1,D)}};h2.create=(D,F)=>{return new h2({valueType:D,minSize:null,maxSize:null,typeName:n.ZodSet,...DD(F)})};EF=class EF extends BD{constructor(){super(...arguments);this.validate=this.implement}_parse(D){let{ctx:F}=this._processInputParams(D);if(F.parsedType!==I.function)return T(F,{code:R.invalid_type,expected:I.function,received:F.parsedType}),l;function B(Y,q){return H3({data:Y,path:F.path,errorMaps:[F.common.contextualErrorMap,F.schemaErrorMap,KF(),F2].filter((H)=>!!H),issueData:{code:R.invalid_arguments,argumentsError:q}})}function $(Y,q){return H3({data:Y,path:F.path,errorMaps:[F.common.contextualErrorMap,F.schemaErrorMap,KF(),F2].filter((H)=>!!H),issueData:{code:R.invalid_return_type,returnTypeError:q}})}let _={errorMap:F.common.contextualErrorMap},Q=F.data;if(this._def.returns instanceof m2){let Y=this;return sD(async function(...q){let H=new cD([]),J=await Y._def.args.parseAsync(q,_).catch((M)=>{throw H.addIssue(B(q,M)),H}),X=await Reflect.apply(Q,this,J);return await Y._def.returns._def.type.parseAsync(X,_).catch((M)=>{throw H.addIssue($(X,M)),H})})}else{let Y=this;return sD(function(...q){let H=Y._def.args.safeParse(q,_);if(!H.success)throw new cD([B(q,H.error)]);let J=Reflect.apply(Q,this,H.data),X=Y._def.returns.safeParse(J,_);if(!X.success)throw new cD([$(J,X.error)]);return X.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...D){return new EF({...this._def,args:p0.create(D).rest(V2.create())})}returns(D){return new EF({...this._def,returns:D})}implement(D){return this.parse(D)}strictImplement(D){return this.parse(D)}static create(D,F,B){return new EF({args:D?D:p0.create([]).rest(V2.create()),returns:F||V2.create(),typeName:n.ZodFunction,...DD(B)})}};ZF=class ZF extends BD{get schema(){return this._def.getter()}_parse(D){let{ctx:F}=this._processInputParams(D);return this._def.getter()._parse({data:F.data,path:F.path,parent:F})}};ZF.create=(D,F)=>{return new ZF({getter:D,typeName:n.ZodLazy,...DD(F)})};NF=class NF extends BD{_parse(D){if(D.data!==this._def.value){let F=this._getOrReturnCtx(D);return T(F,{received:F.data,code:R.invalid_literal,expected:this._def.value}),l}return{status:"valid",value:D.data}}get value(){return this._def.value}};NF.create=(D,F)=>{return new NF({value:D,typeName:n.ZodLiteral,...DD(F)})};w2=class w2 extends BD{_parse(D){if(typeof D.data!=="string"){let F=this._getOrReturnCtx(D),B=this._def.values;return T(F,{expected:QD.joinValues(B),received:F.parsedType,code:R.invalid_type}),l}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has(D.data)){let F=this._getOrReturnCtx(D),B=this._def.values;return T(F,{received:F.data,code:R.invalid_enum_value,options:B}),l}return sD(D.data)}get options(){return this._def.values}get enum(){let D={};for(let F of this._def.values)D[F]=F;return D}get Values(){let D={};for(let F of this._def.values)D[F]=F;return D}get Enum(){let D={};for(let F of this._def.values)D[F]=F;return D}extract(D,F=this._def){return w2.create(D,{...this._def,...F})}exclude(D,F=this._def){return w2.create(this.options.filter((B)=>!D.includes(B)),{...this._def,...F})}};w2.create=M7;SF=class SF extends BD{_parse(D){let F=QD.getValidEnumValues(this._def.values),B=this._getOrReturnCtx(D);if(B.parsedType!==I.string&&B.parsedType!==I.number){let $=QD.objectValues(F);return T(B,{expected:QD.joinValues($),received:B.parsedType,code:R.invalid_type}),l}if(!this._cache)this._cache=new Set(QD.getValidEnumValues(this._def.values));if(!this._cache.has(D.data)){let $=QD.objectValues(F);return T(B,{received:B.data,code:R.invalid_enum_value,options:$}),l}return sD(D.data)}get enum(){return this._def.values}};SF.create=(D,F)=>{return new SF({values:D,typeName:n.ZodNativeEnum,...DD(F)})};m2=class m2 extends BD{unwrap(){return this._def.type}_parse(D){let{ctx:F}=this._processInputParams(D);if(F.parsedType!==I.promise&&F.common.async===!1)return T(F,{code:R.invalid_type,expected:I.promise,received:F.parsedType}),l;let B=F.parsedType===I.promise?F.data:Promise.resolve(F.data);return sD(B.then(($)=>{return this._def.type.parseAsync($,{path:F.path,errorMap:F.common.contextualErrorMap})}))}};m2.create=(D,F)=>{return new m2({type:D,typeName:n.ZodPromise,...DD(F)})};k0=class k0 extends BD{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===n.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(D){let{status:F,ctx:B}=this._processInputParams(D),$=this._def.effect||null,_={addIssue:(Q)=>{if(T(B,Q),Q.fatal)F.abort();else F.dirty()},get path(){return B.path}};if(_.addIssue=_.addIssue.bind(_),$.type==="preprocess"){let Q=$.transform(B.data,_);if(B.common.async)return Promise.resolve(Q).then(async(Y)=>{if(F.value==="aborted")return l;let q=await this._def.schema._parseAsync({data:Y,path:B.path,parent:B});if(q.status==="aborted")return l;if(q.status==="dirty")return x2(q.value);if(F.value==="dirty")return x2(q.value);return q});else{if(F.value==="aborted")return l;let Y=this._def.schema._parseSync({data:Q,path:B.path,parent:B});if(Y.status==="aborted")return l;if(Y.status==="dirty")return x2(Y.value);if(F.value==="dirty")return x2(Y.value);return Y}}if($.type==="refinement"){let Q=(Y)=>{let q=$.refinement(Y,_);if(B.common.async)return Promise.resolve(q);if(q instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return Y};if(B.common.async===!1){let Y=this._def.schema._parseSync({data:B.data,path:B.path,parent:B});if(Y.status==="aborted")return l;if(Y.status==="dirty")F.dirty();return Q(Y.value),{status:F.value,value:Y.value}}else return this._def.schema._parseAsync({data:B.data,path:B.path,parent:B}).then((Y)=>{if(Y.status==="aborted")return l;if(Y.status==="dirty")F.dirty();return Q(Y.value).then(()=>{return{status:F.value,value:Y.value}})})}if($.type==="transform")if(B.common.async===!1){let Q=this._def.schema._parseSync({data:B.data,path:B.path,parent:B});if(!U2(Q))return l;let Y=$.transform(Q.value,_);if(Y instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:F.value,value:Y}}else return this._def.schema._parseAsync({data:B.data,path:B.path,parent:B}).then((Q)=>{if(!U2(Q))return l;return Promise.resolve($.transform(Q.value,_)).then((Y)=>({status:F.value,value:Y}))});QD.assertNever($)}};k0.create=(D,F,B)=>{return new k0({schema:D,typeName:n.ZodEffects,effect:F,...DD(B)})};k0.createWithPreprocess=(D,F,B)=>{return new k0({schema:F,effect:{type:"preprocess",transform:D},typeName:n.ZodEffects,...DD(B)})};N0=class N0 extends BD{_parse(D){if(this._getType(D)===I.undefined)return sD(void 0);return this._def.innerType._parse(D)}unwrap(){return this._def.innerType}};N0.create=(D,F)=>{return new N0({innerType:D,typeName:n.ZodOptional,...DD(F)})};$2=class $2 extends BD{_parse(D){if(this._getType(D)===I.null)return sD(null);return this._def.innerType._parse(D)}unwrap(){return this._def.innerType}};$2.create=(D,F)=>{return new $2({innerType:D,typeName:n.ZodNullable,...DD(F)})};kF=class kF extends BD{_parse(D){let{ctx:F}=this._processInputParams(D),B=F.data;if(F.parsedType===I.undefined)B=this._def.defaultValue();return this._def.innerType._parse({data:B,path:F.path,parent:F})}removeDefault(){return this._def.innerType}};kF.create=(D,F)=>{return new kF({innerType:D,typeName:n.ZodDefault,defaultValue:typeof F.default==="function"?F.default:()=>F.default,...DD(F)})};IF=class IF extends BD{_parse(D){let{ctx:F}=this._processInputParams(D),B={...F,common:{...F.common,issues:[]}},$=this._def.innerType._parse({data:B.data,path:B.path,parent:{...B}});if(UF($))return $.then((_)=>{return{status:"valid",value:_.status==="valid"?_.value:this._def.catchValue({get error(){return new cD(B.common.issues)},input:B.data})}});else return{status:"valid",value:$.status==="valid"?$.value:this._def.catchValue({get error(){return new cD(B.common.issues)},input:B.data})}}removeCatch(){return this._def.innerType}};IF.create=(D,F)=>{return new IF({innerType:D,typeName:n.ZodCatch,catchValue:typeof F.catch==="function"?F.catch:()=>F.catch,...DD(F)})};z3=class z3 extends BD{_parse(D){if(this._getType(D)!==I.nan){let B=this._getOrReturnCtx(D);return T(B,{code:R.invalid_type,expected:I.nan,received:B.parsedType}),l}return{status:"valid",value:D.data}}};z3.create=(D)=>{return new z3({typeName:n.ZodNaN,...DD(D)})};u_=Symbol("zod_brand");n3=class n3 extends BD{_parse(D){let{ctx:F}=this._processInputParams(D),B=F.data;return this._def.type._parse({data:B,path:F.path,parent:F})}unwrap(){return this._def.type}};M3=class M3 extends BD{_parse(D){let{status:F,ctx:B}=this._processInputParams(D);if(B.common.async)return(async()=>{let _=await this._def.in._parseAsync({data:B.data,path:B.path,parent:B});if(_.status==="aborted")return l;if(_.status==="dirty")return F.dirty(),x2(_.value);else return this._def.out._parseAsync({data:_.value,path:B.path,parent:B})})();else{let $=this._def.in._parseSync({data:B.data,path:B.path,parent:B});if($.status==="aborted")return l;if($.status==="dirty")return F.dirty(),{status:"dirty",value:$.value};else return this._def.out._parseSync({data:$.value,path:B.path,parent:B})}}static create(D,F){return new M3({in:D,out:F,typeName:n.ZodPipeline})}};TF=class TF extends BD{_parse(D){let F=this._def.innerType._parse(D),B=($)=>{if(U2($))$.value=Object.freeze($.value);return $};return UF(F)?F.then(($)=>B($)):B(F)}unwrap(){return this._def.innerType}};TF.create=(D,F)=>{return new TF({innerType:D,typeName:n.ZodReadonly,...DD(F)})};P_={object:ID.lazycreate};(function(D){D.ZodString="ZodString",D.ZodNumber="ZodNumber",D.ZodNaN="ZodNaN",D.ZodBigInt="ZodBigInt",D.ZodBoolean="ZodBoolean",D.ZodDate="ZodDate",D.ZodSymbol="ZodSymbol",D.ZodUndefined="ZodUndefined",D.ZodNull="ZodNull",D.ZodAny="ZodAny",D.ZodUnknown="ZodUnknown",D.ZodNever="ZodNever",D.ZodVoid="ZodVoid",D.ZodArray="ZodArray",D.ZodObject="ZodObject",D.ZodUnion="ZodUnion",D.ZodDiscriminatedUnion="ZodDiscriminatedUnion",D.ZodIntersection="ZodIntersection",D.ZodTuple="ZodTuple",D.ZodRecord="ZodRecord",D.ZodMap="ZodMap",D.ZodSet="ZodSet",D.ZodFunction="ZodFunction",D.ZodLazy="ZodLazy",D.ZodLiteral="ZodLiteral",D.ZodEnum="ZodEnum",D.ZodEffects="ZodEffects",D.ZodNativeEnum="ZodNativeEnum",D.ZodOptional="ZodOptional",D.ZodNullable="ZodNullable",D.ZodDefault="ZodDefault",D.ZodCatch="ZodCatch",D.ZodPromise="ZodPromise",D.ZodBranded="ZodBranded",D.ZodPipeline="ZodPipeline",D.ZodReadonly="ZodReadonly"})(n||(n={}));j7=R0.create,K7=E2.create,y_=z3.create,f_=L2.create,U7=LF.create,h_=y2.create,m_=J3.create,g_=wF.create,d_=OF.create,c_=f2.create,l_=V2.create,p_=l0.create,i_=X3.create,n_=Z0.create,s_=ID.create,a_=ID.strictCreate,o_=bF.create,r_=i3.create,t_=RF.create,e_=p0.create,DQ=G3.create,FQ=W3.create,BQ=h2.create,$Q=EF.create,_Q=ZF.create,QQ=NF.create,YQ=w2.create,qQ=SF.create,HQ=m2.create,JQ=k0.create,XQ=N0.create,GQ=$2.create,WQ=k0.createWithPreprocess,zQ=M3.create,KQ={string:(D)=>R0.create({...D,coerce:!0}),number:(D)=>E2.create({...D,coerce:!0}),boolean:(D)=>LF.create({...D,coerce:!0}),bigint:(D)=>L2.create({...D,coerce:!0}),date:(D)=>y2.create({...D,coerce:!0})},UQ=l});var W={};j2(W,{void:()=>i_,util:()=>QD,unknown:()=>l_,union:()=>o_,undefined:()=>g_,tuple:()=>e_,transformer:()=>JQ,symbol:()=>m_,string:()=>j7,strictObject:()=>a_,setErrorMap:()=>G_,set:()=>BQ,record:()=>DQ,quotelessJson:()=>J_,promise:()=>HQ,preprocess:()=>WQ,pipeline:()=>zQ,ostring:()=>MQ,optional:()=>XQ,onumber:()=>AQ,oboolean:()=>jQ,objectUtil:()=>_1,object:()=>s_,number:()=>K7,nullable:()=>GQ,null:()=>d_,never:()=>p_,nativeEnum:()=>qQ,nan:()=>y_,map:()=>FQ,makeIssue:()=>H3,literal:()=>QQ,lazy:()=>_Q,late:()=>P_,isValid:()=>U2,isDirty:()=>p3,isAsync:()=>UF,isAborted:()=>l3,intersection:()=>t_,instanceof:()=>x_,getParsedType:()=>c0,getErrorMap:()=>KF,function:()=>$Q,enum:()=>YQ,effect:()=>JQ,discriminatedUnion:()=>r_,defaultErrorMap:()=>F2,datetimeRegex:()=>z7,date:()=>h_,custom:()=>A7,coerce:()=>KQ,boolean:()=>U7,bigint:()=>f_,array:()=>n_,any:()=>c_,addIssueToContext:()=>T,ZodVoid:()=>X3,ZodUnknown:()=>V2,ZodUnion:()=>bF,ZodUndefined:()=>wF,ZodType:()=>BD,ZodTuple:()=>p0,ZodTransformer:()=>k0,ZodSymbol:()=>J3,ZodString:()=>R0,ZodSet:()=>h2,ZodSchema:()=>BD,ZodRecord:()=>G3,ZodReadonly:()=>TF,ZodPromise:()=>m2,ZodPipeline:()=>M3,ZodParsedType:()=>I,ZodOptional:()=>N0,ZodObject:()=>ID,ZodNumber:()=>E2,ZodNullable:()=>$2,ZodNull:()=>OF,ZodNever:()=>l0,ZodNativeEnum:()=>SF,ZodNaN:()=>z3,ZodMap:()=>W3,ZodLiteral:()=>NF,ZodLazy:()=>ZF,ZodIssueCode:()=>R,ZodIntersection:()=>RF,ZodFunction:()=>EF,ZodFirstPartyTypeKind:()=>n,ZodError:()=>cD,ZodEnum:()=>w2,ZodEffects:()=>k0,ZodDiscriminatedUnion:()=>i3,ZodDefault:()=>kF,ZodDate:()=>y2,ZodCatch:()=>IF,ZodBranded:()=>n3,ZodBoolean:()=>LF,ZodBigInt:()=>L2,ZodArray:()=>Z0,ZodAny:()=>f2,Schema:()=>BD,ParseStatus:()=>lD,OK:()=>sD,NEVER:()=>UQ,INVALID:()=>l,EMPTY_PATH:()=>W_,DIRTY:()=>x2,BRAND:()=>u_});var J1=V(()=>{c3();Y1();q7();q3();V7();d3()});var _2=V(()=>{J1();J1()});var L7;var E7=V(()=>{L7={name:"ocx",version:"2.0.3",description:"OCX CLI - ShadCN-style registry for OpenCode extensions. Install agents, plugins, skills, and MCP servers.",author:"kdcokenny",license:"MIT",type:"module",main:"./dist/index.js",bin:{ocx:"./dist/index.js"},files:["dist/index.js"],publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/kdcokenny/ocx.git"},homepage:"https://github.com/kdcokenny/ocx#readme",bugs:{url:"https://github.com/kdcokenny/ocx/issues"},keywords:["opencode","cli","extensions","agents","plugins","mcp","shadcn","registry"],engines:{node:">=18"},scripts:{build:"bun run scripts/build.ts","build:binary":"bun run scripts/build-binary.ts",check:"bun check:biome && bun check:types","check:biome":"biome check .","check:types":"tsc --noEmit",dev:"bun run src/index.ts",prepublishOnly:"bun run build",test:"bun test"},dependencies:{commander:"^14.0.0",fuzzysort:"^3.1.0","jsonc-parser":"3.3.1",kleur:"^4.1.5",ora:"^8.2.0",remeda:"^2.33.0",zod:"^3.24.0"},devDependencies:{"@types/bun":"latest"}}});function EQ(D){return`https://${A3}/schemas/v${D}/registry.json`}var A3="ocx.kdco.dev",w7="kdcokenny/ocx",X1,G1,I0=2,T0,O7;var s3=V(()=>{E7();X1=`https://${A3}/schemas/ocx.json`,G1=`https://${A3}/schemas/registry.json`;T0=EQ(I0),O7=L7.version});var XD,zD,MD,RD,c,U,g2,gD,d2,vD,v0,CD,O2,vF,C0,CF,W1;var $D=V(()=>{XD={SUCCESS:0,GENERAL:1,NOT_FOUND:66,NETWORK:69,CONFIG:78,INTEGRITY:65,CONFLICT:6};zD=class zD extends Error{code;exitCode;constructor(D,F,B=XD.GENERAL){super(D);this.code=F;this.exitCode=B;this.name="OCXError"}};MD=class MD extends zD{constructor(D){super(D,"NOT_FOUND",XD.NOT_FOUND);this.name="NotFoundError"}};RD=class RD extends zD{url;status;statusText;phase;qualifiedName;registryContext;registryName;constructor(D,F){super(D,"NETWORK_ERROR",XD.NETWORK);this.name="NetworkError",this.url=F?.url,this.status=F?.status,this.statusText=F?.statusText,this.phase=F?.phase,this.qualifiedName=F?.qualifiedName,this.registryContext=F?.registryContext,this.registryName=F?.registryName}};c=class c extends zD{constructor(D){super(D,"CONFIG_ERROR",XD.CONFIG);this.name="ConfigError"}};U=class U extends zD{constructor(D){super(D,"VALIDATION_ERROR",XD.GENERAL);this.name="ValidationError"}};g2=class g2 extends zD{details;constructor(D){super("Registry validation failed","VALIDATION_FAILED",XD.CONFIG);this.details=D;this.name="ValidationFailedError"}};gD=class gD extends zD{constructor(D){super(D,"CONFLICT",XD.CONFLICT);this.name="ConflictError"}};d2=class d2 extends zD{component;expected;found;constructor(D,F,B){let $=`Integrity verification failed for "${D}"
16
+ `}function Y3(D,F){return`\r
17
+ `.indexOf(D.charAt(F))!==-1}var B1=V(()=>{m3();B7()});function $7(D,F=[],B=q3.DEFAULT){let $=null,_=[],Q=[];function Y(H){if(Array.isArray(_))_.push(H);else if($!==null)_[$]=H}return _1(D,{onObjectBegin:()=>{let H={};Y(H),Q.push(_),_=H,$=null},onObjectProperty:(H)=>{$=H},onObjectEnd:()=>{_=Q.pop()},onArrayBegin:()=>{let H=[];Y(H),Q.push(_),_=H,$=null},onArrayEnd:()=>{_=Q.pop()},onLiteralValue:Y,onError:(H,J,X)=>{F.push({error:H,offset:J,length:X})}},B),_[0]}function $1(D,F=[],B=q3.DEFAULT){let $={type:"array",offset:-1,length:-1,children:[],parent:void 0};function _(H){if($.type==="property")$.length=H-$.offset,$=$.parent}function Q(H){return $.children.push(H),H}_1(D,{onObjectBegin:(H)=>{$=Q({type:"object",offset:H,length:-1,parent:$,children:[]})},onObjectProperty:(H,J,X)=>{$=Q({type:"property",offset:J,length:-1,parent:$,children:[]}),$.children.push({type:"string",value:H,offset:J,length:X,parent:$})},onObjectEnd:(H,J)=>{_(H+J),$.length=H+J-$.offset,$=$.parent,_(H+J)},onArrayBegin:(H,J)=>{$=Q({type:"array",offset:H,length:-1,parent:$,children:[]})},onArrayEnd:(H,J)=>{$.length=H+J-$.offset,$=$.parent,_(H+J)},onLiteralValue:(H,J,X)=>{Q({type:X_(H),offset:J,length:X,parent:$,value:H}),_(J+X)},onSeparator:(H,J,X)=>{if($.type==="property"){if(H===":")$.colonOffset=J;else if(H===",")_(J)}},onError:(H,J,X)=>{F.push({error:H,offset:J,length:X})}},B);let q=$.children[0];if(q)delete q.parent;return q}function g3(D,F){if(!D)return;let B=D;for(let $ of F)if(typeof $==="string"){if(B.type!=="object"||!Array.isArray(B.children))return;let _=!1;for(let Q of B.children)if(Array.isArray(Q.children)&&Q.children[0].value===$&&Q.children.length===2){B=Q.children[1],_=!0;break}if(!_)return}else{let _=$;if(B.type!=="array"||_<0||!Array.isArray(B.children)||_>=B.children.length)return;B=B.children[_]}return B}function _1(D,F,B=q3.DEFAULT){let $=Q3(D,!1),_=[],Q=0;function Y(v){return v?()=>Q===0&&v($.getTokenOffset(),$.getTokenLength(),$.getTokenStartLine(),$.getTokenStartCharacter()):()=>!0}function q(v){return v?(f)=>Q===0&&v(f,$.getTokenOffset(),$.getTokenLength(),$.getTokenStartLine(),$.getTokenStartCharacter()):()=>!0}function H(v){return v?(f)=>Q===0&&v(f,$.getTokenOffset(),$.getTokenLength(),$.getTokenStartLine(),$.getTokenStartCharacter(),()=>_.slice()):()=>!0}function J(v){return v?()=>{if(Q>0)Q++;else if(v($.getTokenOffset(),$.getTokenLength(),$.getTokenStartLine(),$.getTokenStartCharacter(),()=>_.slice())===!1)Q=1}:()=>!0}function X(v){return v?()=>{if(Q>0)Q--;if(Q===0)v($.getTokenOffset(),$.getTokenLength(),$.getTokenStartLine(),$.getTokenStartCharacter())}:()=>!0}let z=J(F.onObjectBegin),M=H(F.onObjectProperty),A=X(F.onObjectEnd),K=J(F.onArrayBegin),j=X(F.onArrayEnd),S=H(F.onLiteralValue),R=q(F.onSeparator),s=Y(F.onComment),N=q(F.onError),y=B&&B.disallowComments,O=B&&B.allowTrailingComma;function b(){while(!0){let v=$.scan();switch($.getTokenError()){case 4:L(14);break;case 5:L(15);break;case 3:L(13);break;case 1:if(!y)L(11);break;case 2:L(12);break;case 6:L(16);break}switch(v){case 12:case 13:if(y)L(10);else s();break;case 16:L(1);break;case 15:case 14:break;default:return v}}}function L(v,f=[],_D=[]){if(N(v),f.length+_D.length>0){let r=$.getToken();while(r!==17){if(f.indexOf(r)!==-1){b();break}else if(_D.indexOf(r)!==-1)break;r=b()}}}function e(v){let f=$.getTokenValue();if(v)S(f);else M(f),_.push(f);return b(),!0}function p(){switch($.getToken()){case 11:let v=$.getTokenValue(),f=Number(v);if(isNaN(f))L(2),f=0;S(f);break;case 7:S(null);break;case 8:S(!0);break;case 9:S(!1);break;default:return!1}return b(),!0}function FD(){if($.getToken()!==10)return L(3,[],[2,5]),!1;if(e(!1),$.getToken()===6){if(R(":"),b(),!i())L(4,[],[2,5])}else L(5,[],[2,5]);return _.pop(),!0}function KD(){z(),b();let v=!1;while($.getToken()!==2&&$.getToken()!==17){if($.getToken()===5){if(!v)L(4,[],[]);if(R(","),b(),$.getToken()===2&&O)break}else if(v)L(6,[],[]);if(!FD())L(4,[],[2,5]);v=!0}if(A(),$.getToken()!==2)L(7,[2],[]);else b();return!0}function k(){K(),b();let v=!0,f=!1;while($.getToken()!==4&&$.getToken()!==17){if($.getToken()===5){if(!f)L(4,[],[]);if(R(","),b(),$.getToken()===4&&O)break}else if(f)L(6,[],[]);if(v)_.push(0),v=!1;else _[_.length-1]++;if(!i())L(4,[],[4,5]);f=!0}if(j(),!v)_.pop();if($.getToken()!==4)L(8,[4],[]);else b();return!0}function i(){switch($.getToken()){case 3:return k();case 1:return KD();case 10:return e(!0);default:return p()}}if(b(),$.getToken()===17){if(B.allowEmptyContent)return!0;return L(4,[],[]),!1}if(!i())return L(4,[],[]),!1;if($.getToken()!==17)L(9,[],[]);return!0}function X_(D){switch(typeof D){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(!D)return"null";else if(Array.isArray(D))return"array";return"object"}default:return"null"}}var q3;var Q1=V(()=>{m3();(function(D){D.DEFAULT={allowTrailingComma:!1}})(q3||(q3={}))});function _7(D,F,B,$){let _=F.slice(),Y=$1(D,[]),q=void 0,H=void 0;while(_.length>0)if(H=_.pop(),q=g3(Y,_),q===void 0&&B!==void 0)if(typeof H==="string")B={[H]:B};else B=[B];else break;if(!q){if(B===void 0)throw Error("Can not delete in empty document");return P2(D,{offset:Y?Y.offset:0,length:Y?Y.length:0,content:JSON.stringify(B)},$)}else if(q.type==="object"&&typeof H==="string"&&Array.isArray(q.children)){let J=g3(q,[H]);if(J!==void 0)if(B===void 0){if(!J.parent)throw Error("Malformed AST");let X=q.children.indexOf(J.parent),z,M=J.parent.offset+J.parent.length;if(X>0){let A=q.children[X-1];z=A.offset+A.length}else if(z=q.offset+1,q.children.length>1)M=q.children[1].offset;return P2(D,{offset:z,length:M-z,content:""},$)}else return P2(D,{offset:J.offset,length:J.length,content:JSON.stringify(B)},$);else{if(B===void 0)return[];let X=`${JSON.stringify(H)}: ${JSON.stringify(B)}`,z=$.getInsertionIndex?$.getInsertionIndex(q.children.map((A)=>A.children[0].value)):q.children.length,M;if(z>0){let A=q.children[z-1];M={offset:A.offset+A.length,length:0,content:","+X}}else if(q.children.length===0)M={offset:q.offset+1,length:0,content:X};else M={offset:q.offset+1,length:0,content:X+","};return P2(D,M,$)}}else if(q.type==="array"&&typeof H==="number"&&Array.isArray(q.children)){let J=H;if(J===-1){let X=`${JSON.stringify(B)}`,z;if(q.children.length===0)z={offset:q.offset+1,length:0,content:X};else{let M=q.children[q.children.length-1];z={offset:M.offset+M.length,length:0,content:","+X}}return P2(D,z,$)}else if(B===void 0&&q.children.length>=0){let X=H,z=q.children[X],M;if(q.children.length===1)M={offset:q.offset+1,length:q.length-2,content:""};else if(q.children.length-1===X){let A=q.children[X-1],K=A.offset+A.length,j=q.offset+q.length;M={offset:K,length:j-2-K,content:""}}else M={offset:z.offset,length:q.children[X+1].offset-z.offset,content:""};return P2(D,M,$)}else if(B!==void 0){let X,z=`${JSON.stringify(B)}`;if(!$.isArrayInsertion&&q.children.length>H){let M=q.children[H];X={offset:M.offset,length:M.length,content:z}}else if(q.children.length===0||H===0)X={offset:q.offset+1,length:0,content:q.children.length===0?z:z+","};else{let M=H>q.children.length?q.children.length:H,A=q.children[M-1];X={offset:A.offset+A.length,length:0,content:","+z}}return P2(D,X,$)}else throw Error(`Can not ${B===void 0?"remove":$.isArrayInsertion?"insert":"modify"} Array index ${J} as length is not sufficient`)}else throw Error(`Can not add ${typeof H!=="number"?"index":"property"} to parent of type ${q.type}`)}function P2(D,F,B){if(!B.formattingOptions)return[F];let $=d3(D,F),_=F.offset,Q=F.offset+F.content.length;if(F.length===0||F.content.length===0){while(_>0&&!Y3($,_-1))_--;while(Q<$.length&&!Y3($,Q))Q++}let Y=F1($,{offset:_,length:Q-_},{...B.formattingOptions,keepLines:!1});for(let H=Y.length-1;H>=0;H--){let J=Y[H];$=d3($,J),_=Math.min(_,J.offset),Q=Math.max(Q,J.offset+J.length),Q+=J.content.length-J.length}let q=D.length-($.length-Q)-_;return[{offset:_,length:q,content:$.substring(_,Q)}]}function d3(D,F){return D.substring(0,F.offset)+F.content+D.substring(F.offset+F.length)}var Q7=V(()=>{B1();Q1()});function K2(D){switch(D){case 1:return"InvalidSymbol";case 2:return"InvalidNumberFormat";case 3:return"PropertyNameExpected";case 4:return"ValueExpected";case 5:return"ColonExpected";case 6:return"CommaExpected";case 7:return"CloseBraceExpected";case 8:return"CloseBracketExpected";case 9:return"EndOfFileExpected";case 10:return"InvalidCommentToken";case 11:return"UnexpectedEndOfComment";case 12:return"UnexpectedEndOfString";case 13:return"UnexpectedEndOfNumber";case 14:return"InvalidUnicode";case 15:return"InvalidEscapeCharacter";case 16:return"InvalidCharacter"}return"<unknown ParseErrorCode>"}function AF(D,F,B,$){return _7(D,F,B,$)}function jF(D,F){let B=F.slice(0).sort((_,Q)=>{let Y=_.offset-Q.offset;if(Y===0)return _.length-Q.length;return Y}),$=D.length;for(let _=B.length-1;_>=0;_--){let Q=B[_];if(Q.offset+Q.length<=$)D=d3(D,Q);else throw Error("Overlapping edit");$=Q.offset}return D}var Y7,q7,ND,H7;var b0=V(()=>{B1();Q7();m3();Q1();(function(D){D[D.None=0]="None",D[D.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",D[D.UnexpectedEndOfString=2]="UnexpectedEndOfString",D[D.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",D[D.InvalidUnicode=4]="InvalidUnicode",D[D.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",D[D.InvalidCharacter=6]="InvalidCharacter"})(Y7||(Y7={}));(function(D){D[D.OpenBraceToken=1]="OpenBraceToken",D[D.CloseBraceToken=2]="CloseBraceToken",D[D.OpenBracketToken=3]="OpenBracketToken",D[D.CloseBracketToken=4]="CloseBracketToken",D[D.CommaToken=5]="CommaToken",D[D.ColonToken=6]="ColonToken",D[D.NullKeyword=7]="NullKeyword",D[D.TrueKeyword=8]="TrueKeyword",D[D.FalseKeyword=9]="FalseKeyword",D[D.StringLiteral=10]="StringLiteral",D[D.NumericLiteral=11]="NumericLiteral",D[D.LineCommentTrivia=12]="LineCommentTrivia",D[D.BlockCommentTrivia=13]="BlockCommentTrivia",D[D.LineBreakTrivia=14]="LineBreakTrivia",D[D.Trivia=15]="Trivia",D[D.Unknown=16]="Unknown",D[D.EOF=17]="EOF"})(q7||(q7={}));ND=$7;(function(D){D[D.InvalidSymbol=1]="InvalidSymbol",D[D.InvalidNumberFormat=2]="InvalidNumberFormat",D[D.PropertyNameExpected=3]="PropertyNameExpected",D[D.ValueExpected=4]="ValueExpected",D[D.ColonExpected=5]="ColonExpected",D[D.CommaExpected=6]="CommaExpected",D[D.CloseBraceExpected=7]="CloseBraceExpected",D[D.CloseBracketExpected=8]="CloseBracketExpected",D[D.EndOfFileExpected=9]="EndOfFileExpected",D[D.InvalidCommentToken=10]="InvalidCommentToken",D[D.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",D[D.UnexpectedEndOfString=12]="UnexpectedEndOfString",D[D.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",D[D.InvalidUnicode=14]="InvalidUnicode",D[D.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",D[D.InvalidCharacter=16]="InvalidCharacter"})(H7||(H7={}))});var QD,Y1,I,l0=(D)=>{switch(typeof D){case"undefined":return I.undefined;case"string":return I.string;case"number":return Number.isNaN(D)?I.nan:I.number;case"boolean":return I.boolean;case"function":return I.function;case"bigint":return I.bigint;case"symbol":return I.symbol;case"object":if(Array.isArray(D))return I.array;if(D===null)return I.null;if(D.then&&typeof D.then==="function"&&D.catch&&typeof D.catch==="function")return I.promise;if(typeof Map<"u"&&D instanceof Map)return I.map;if(typeof Set<"u"&&D instanceof Set)return I.set;if(typeof Date<"u"&&D instanceof Date)return I.date;return I.object;default:return I.unknown}};var H3=V(()=>{(function(D){D.assertEqual=(_)=>{};function F(_){}D.assertIs=F;function B(_){throw Error()}D.assertNever=B,D.arrayToEnum=(_)=>{let Q={};for(let Y of _)Q[Y]=Y;return Q},D.getValidEnumValues=(_)=>{let Q=D.objectKeys(_).filter((q)=>typeof _[_[q]]!=="number"),Y={};for(let q of Q)Y[q]=_[q];return D.objectValues(Y)},D.objectValues=(_)=>{return D.objectKeys(_).map(function(Q){return _[Q]})},D.objectKeys=typeof Object.keys==="function"?(_)=>Object.keys(_):(_)=>{let Q=[];for(let Y in _)if(Object.prototype.hasOwnProperty.call(_,Y))Q.push(Y);return Q},D.find=(_,Q)=>{for(let Y of _)if(Q(Y))return Y;return},D.isInteger=typeof Number.isInteger==="function"?(_)=>Number.isInteger(_):(_)=>typeof _==="number"&&Number.isFinite(_)&&Math.floor(_)===_;function $(_,Q=" | "){return _.map((Y)=>typeof Y==="string"?`'${Y}'`:Y).join(Q)}D.joinValues=$,D.jsonStringifyReplacer=(_,Q)=>{if(typeof Q==="bigint")return Q.toString();return Q}})(QD||(QD={}));(function(D){D.mergeShapes=(F,B)=>{return{...F,...B}}})(Y1||(Y1={}));I=QD.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"])});var Z,z_=(D)=>{return JSON.stringify(D,null,2).replace(/"([^"]+)":/g,"$1:")},lD;var c3=V(()=>{H3();Z=QD.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);lD=class lD extends Error{get errors(){return this.issues}constructor(D){super();this.issues=[],this.addIssue=(B)=>{this.issues=[...this.issues,B]},this.addIssues=(B=[])=>{this.issues=[...this.issues,...B]};let F=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,F);else this.__proto__=F;this.name="ZodError",this.issues=D}format(D){let F=D||function(_){return _.message},B={_errors:[]},$=(_)=>{for(let Q of _.issues)if(Q.code==="invalid_union")Q.unionErrors.map($);else if(Q.code==="invalid_return_type")$(Q.returnTypeError);else if(Q.code==="invalid_arguments")$(Q.argumentsError);else if(Q.path.length===0)B._errors.push(F(Q));else{let Y=B,q=0;while(q<Q.path.length){let H=Q.path[q];if(q!==Q.path.length-1)Y[H]=Y[H]||{_errors:[]};else Y[H]=Y[H]||{_errors:[]},Y[H]._errors.push(F(Q));Y=Y[H],q++}}};return $(this),B}static assert(D){if(!(D instanceof lD))throw Error(`Not a ZodError: ${D}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,QD.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(D=(F)=>F.message){let F={},B=[];for(let $ of this.issues)if($.path.length>0){let _=$.path[0];F[_]=F[_]||[],F[_].push(D($))}else B.push(D($));return{formErrors:B,fieldErrors:F}}get formErrors(){return this.flatten()}};lD.create=(D)=>{return new lD(D)}});var M_=(D,F)=>{let B;switch(D.code){case Z.invalid_type:if(D.received===I.undefined)B="Required";else B=`Expected ${D.expected}, received ${D.received}`;break;case Z.invalid_literal:B=`Invalid literal value, expected ${JSON.stringify(D.expected,QD.jsonStringifyReplacer)}`;break;case Z.unrecognized_keys:B=`Unrecognized key(s) in object: ${QD.joinValues(D.keys,", ")}`;break;case Z.invalid_union:B="Invalid input";break;case Z.invalid_union_discriminator:B=`Invalid discriminator value. Expected ${QD.joinValues(D.options)}`;break;case Z.invalid_enum_value:B=`Invalid enum value. Expected ${QD.joinValues(D.options)}, received '${D.received}'`;break;case Z.invalid_arguments:B="Invalid function arguments";break;case Z.invalid_return_type:B="Invalid function return type";break;case Z.invalid_date:B="Invalid date";break;case Z.invalid_string:if(typeof D.validation==="object")if("includes"in D.validation){if(B=`Invalid input: must include "${D.validation.includes}"`,typeof D.validation.position==="number")B=`${B} at one or more positions greater than or equal to ${D.validation.position}`}else if("startsWith"in D.validation)B=`Invalid input: must start with "${D.validation.startsWith}"`;else if("endsWith"in D.validation)B=`Invalid input: must end with "${D.validation.endsWith}"`;else QD.assertNever(D.validation);else if(D.validation!=="regex")B=`Invalid ${D.validation}`;else B="Invalid";break;case Z.too_small:if(D.type==="array")B=`Array must contain ${D.exact?"exactly":D.inclusive?"at least":"more than"} ${D.minimum} element(s)`;else if(D.type==="string")B=`String must contain ${D.exact?"exactly":D.inclusive?"at least":"over"} ${D.minimum} character(s)`;else if(D.type==="number")B=`Number must be ${D.exact?"exactly equal to ":D.inclusive?"greater than or equal to ":"greater than "}${D.minimum}`;else if(D.type==="bigint")B=`Number must be ${D.exact?"exactly equal to ":D.inclusive?"greater than or equal to ":"greater than "}${D.minimum}`;else if(D.type==="date")B=`Date must be ${D.exact?"exactly equal to ":D.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(D.minimum))}`;else B="Invalid input";break;case Z.too_big:if(D.type==="array")B=`Array must contain ${D.exact?"exactly":D.inclusive?"at most":"less than"} ${D.maximum} element(s)`;else if(D.type==="string")B=`String must contain ${D.exact?"exactly":D.inclusive?"at most":"under"} ${D.maximum} character(s)`;else if(D.type==="number")B=`Number must be ${D.exact?"exactly":D.inclusive?"less than or equal to":"less than"} ${D.maximum}`;else if(D.type==="bigint")B=`BigInt must be ${D.exact?"exactly":D.inclusive?"less than or equal to":"less than"} ${D.maximum}`;else if(D.type==="date")B=`Date must be ${D.exact?"exactly":D.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(D.maximum))}`;else B="Invalid input";break;case Z.custom:B="Invalid input";break;case Z.invalid_intersection_types:B="Intersection results could not be merged";break;case Z.not_multiple_of:B=`Number must be a multiple of ${D.multipleOf}`;break;case Z.not_finite:B="Number must be finite";break;default:B=F.defaultError,QD.assertNever(D)}return{message:B}},B2;var q1=V(()=>{c3();H3();B2=M_});function A_(D){J7=D}function KF(){return J7}var J7;var l3=V(()=>{q1();J7=B2});function T(D,F){let B=KF(),$=J3({issueData:F,data:D.data,path:D.path,errorMaps:[D.common.contextualErrorMap,D.schemaErrorMap,B,B===B2?void 0:B2].filter((_)=>!!_)});D.common.issues.push($)}class pD{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray(D,F){let B=[];for(let $ of F){if($.status==="aborted")return l;if($.status==="dirty")D.dirty();B.push($.value)}return{status:D.value,value:B}}static async mergeObjectAsync(D,F){let B=[];for(let $ of F){let _=await $.key,Q=await $.value;B.push({key:_,value:Q})}return pD.mergeObjectSync(D,B)}static mergeObjectSync(D,F){let B={};for(let $ of F){let{key:_,value:Q}=$;if(_.status==="aborted")return l;if(Q.status==="aborted")return l;if(_.status==="dirty")D.dirty();if(Q.status==="dirty")D.dirty();if(_.value!=="__proto__"&&(typeof Q.value<"u"||$.alwaysSet))B[_.value]=Q.value}return{status:D.value,value:B}}}var J3=(D)=>{let{data:F,path:B,errorMaps:$,issueData:_}=D,Q=[...B,..._.path||[]],Y={..._,path:Q};if(_.message!==void 0)return{..._,path:Q,message:_.message};let q="",H=$.filter((J)=>!!J).slice().reverse();for(let J of H)q=J(Y,{data:F,defaultError:q}).message;return{..._,path:Q,message:q}},j_,l,y2=(D)=>({status:"dirty",value:D}),aD=(D)=>({status:"valid",value:D}),p3=(D)=>D.status==="aborted",i3=(D)=>D.status==="dirty",U2=(D)=>D.status==="valid",UF=(D)=>typeof Promise<"u"&&D instanceof Promise;var H1=V(()=>{l3();q1();j_=[];l=Object.freeze({status:"aborted"})});var X7=()=>{};var x;var W7=V(()=>{(function(D){D.errToObj=(F)=>typeof F==="string"?{message:F}:F||{},D.toString=(F)=>typeof F==="string"?F:F?.message})(x||(x={}))});class S0{constructor(D,F,B,$){this._cachedPath=[],this.parent=D,this.data=F,this._path=B,this._key=$}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}function DD(D){if(!D)return{};let{errorMap:F,invalid_type_error:B,required_error:$,description:_}=D;if(F&&(B||$))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(F)return{errorMap:F,description:_};return{errorMap:(Y,q)=>{let{message:H}=D;if(Y.code==="invalid_enum_value")return{message:H??q.defaultError};if(typeof q.data>"u")return{message:H??$??q.defaultError};if(Y.code!=="invalid_type")return{message:q.defaultError};return{message:H??B??q.defaultError}},description:_}}class BD{get description(){return this._def.description}_getType(D){return l0(D.data)}_getOrReturnCtx(D,F){return F||{common:D.parent.common,data:D.data,parsedType:l0(D.data),schemaErrorMap:this._def.errorMap,path:D.path,parent:D.parent}}_processInputParams(D){return{status:new pD,ctx:{common:D.parent.common,data:D.data,parsedType:l0(D.data),schemaErrorMap:this._def.errorMap,path:D.path,parent:D.parent}}}_parseSync(D){let F=this._parse(D);if(UF(F))throw Error("Synchronous parse encountered promise.");return F}_parseAsync(D){let F=this._parse(D);return Promise.resolve(F)}parse(D,F){let B=this.safeParse(D,F);if(B.success)return B.data;throw B.error}safeParse(D,F){let B={common:{issues:[],async:F?.async??!1,contextualErrorMap:F?.errorMap},path:F?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:D,parsedType:l0(D)},$=this._parseSync({data:D,path:B.path,parent:B});return G7(B,$)}"~validate"(D){let F={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:D,parsedType:l0(D)};if(!this["~standard"].async)try{let B=this._parseSync({data:D,path:[],parent:F});return U2(B)?{value:B.value}:{issues:F.common.issues}}catch(B){if(B?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;F.common={issues:[],async:!0}}return this._parseAsync({data:D,path:[],parent:F}).then((B)=>U2(B)?{value:B.value}:{issues:F.common.issues})}async parseAsync(D,F){let B=await this.safeParseAsync(D,F);if(B.success)return B.data;throw B.error}async safeParseAsync(D,F){let B={common:{issues:[],contextualErrorMap:F?.errorMap,async:!0},path:F?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:D,parsedType:l0(D)},$=this._parse({data:D,path:B.path,parent:B}),_=await(UF($)?$:Promise.resolve($));return G7(B,_)}refine(D,F){let B=($)=>{if(typeof F==="string"||typeof F>"u")return{message:F};else if(typeof F==="function")return F($);else return F};return this._refinement(($,_)=>{let Q=D($),Y=()=>_.addIssue({code:Z.custom,...B($)});if(typeof Promise<"u"&&Q instanceof Promise)return Q.then((q)=>{if(!q)return Y(),!1;else return!0});if(!Q)return Y(),!1;else return!0})}refinement(D,F){return this._refinement((B,$)=>{if(!D(B))return $.addIssue(typeof F==="function"?F(B,$):F),!1;else return!0})}_refinement(D){return new k0({schema:this,typeName:n.ZodEffects,effect:{type:"refinement",refinement:D}})}superRefine(D){return this._refinement(D)}constructor(D){this.spa=this.safeParseAsync,this._def=D,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(F)=>this["~validate"](F)}}optional(){return N0.create(this,this._def)}nullable(){return _2.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return R0.create(this)}promise(){return m2.create(this,this._def)}or(D){return bF.create([this,D],this._def)}and(D){return ZF.create(this,D,this._def)}transform(D){return new k0({...DD(this._def),schema:this,typeName:n.ZodEffects,effect:{type:"transform",transform:D}})}default(D){let F=typeof D==="function"?D:()=>D;return new kF({...DD(this._def),innerType:this,defaultValue:F,typeName:n.ZodDefault})}brand(){return new s3({typeName:n.ZodBranded,type:this,...DD(this._def)})}catch(D){let F=typeof D==="function"?D:()=>D;return new IF({...DD(this._def),innerType:this,catchValue:F,typeName:n.ZodCatch})}describe(D){return new this.constructor({...this._def,description:D})}pipe(D){return A3.create(this,D)}readonly(){return TF.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}function A7(D){let F="[0-5]\\d";if(D.precision)F=`${F}\\.\\d{${D.precision}}`;else if(D.precision==null)F=`${F}(\\.\\d+)?`;let B=D.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${F})${B}`}function C_(D){return new RegExp(`^${A7(D)}$`)}function j7(D){let F=`${M7}T${A7(D)}`,B=[];if(B.push(D.local?"Z?":"Z"),D.offset)B.push("([+-]\\d{2}:?\\d{2})");return F=`${F}(${B.join("|")})`,new RegExp(`^${F}$`)}function u_(D,F){if((F==="v4"||!F)&&R_.test(D))return!0;if((F==="v6"||!F)&&S_.test(D))return!0;return!1}function P_(D,F){if(!w_.test(D))return!1;try{let[B]=D.split(".");if(!B)return!1;let $=B.replace(/-/g,"+").replace(/_/g,"/").padEnd(B.length+(4-B.length%4)%4,"="),_=JSON.parse(atob($));if(typeof _!=="object"||_===null)return!1;if("typ"in _&&_?.typ!=="JWT")return!1;if(!_.alg)return!1;if(F&&_.alg!==F)return!1;return!0}catch{return!1}}function y_(D,F){if((F==="v4"||!F)&&N_.test(D))return!0;if((F==="v6"||!F)&&k_.test(D))return!0;return!1}function x_(D,F){let B=(D.toString().split(".")[1]||"").length,$=(F.toString().split(".")[1]||"").length,_=B>$?B:$,Q=Number.parseInt(D.toFixed(_).replace(".","")),Y=Number.parseInt(F.toFixed(_).replace(".",""));return Q%Y/10**_}function VF(D){if(D instanceof ID){let F={};for(let B in D.shape){let $=D.shape[B];F[B]=N0.create(VF($))}return new ID({...D._def,shape:()=>F})}else if(D instanceof R0)return new R0({...D._def,type:VF(D.element)});else if(D instanceof N0)return N0.create(VF(D.unwrap()));else if(D instanceof _2)return _2.create(VF(D.unwrap()));else if(D instanceof i0)return i0.create(D.items.map((F)=>VF(F)));else return D}function X1(D,F){let B=l0(D),$=l0(F);if(D===F)return{valid:!0,data:D};else if(B===I.object&&$===I.object){let _=QD.objectKeys(F),Q=QD.objectKeys(D).filter((q)=>_.indexOf(q)!==-1),Y={...D,...F};for(let q of Q){let H=X1(D[q],F[q]);if(!H.valid)return{valid:!1};Y[q]=H.data}return{valid:!0,data:Y}}else if(B===I.array&&$===I.array){if(D.length!==F.length)return{valid:!1};let _=[];for(let Q=0;Q<D.length;Q++){let Y=D[Q],q=F[Q],H=X1(Y,q);if(!H.valid)return{valid:!1};_.push(H.data)}return{valid:!0,data:_}}else if(B===I.date&&$===I.date&&+D===+F)return{valid:!0,data:D};else return{valid:!1}}function K7(D,F){return new w2({values:D,typeName:n.ZodEnum,...DD(F)})}function z7(D,F){let B=typeof D==="function"?D(F):typeof D==="string"?{message:D}:D;return typeof B==="string"?{message:B}:B}function U7(D,F={},B){if(D)return f2.create().superRefine(($,_)=>{let Q=D($);if(Q instanceof Promise)return Q.then((Y)=>{if(!Y){let q=z7(F,$),H=q.fatal??B??!0;_.addIssue({code:"custom",...q,fatal:H})}});if(!Q){let Y=z7(F,$),q=Y.fatal??B??!0;_.addIssue({code:"custom",...Y,fatal:q})}return});return f2.create()}var G7=(D,F)=>{if(U2(F))return{success:!0,data:F.value};else{if(!D.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let B=new lD(D.common.issues);return this._error=B,this._error}}}},K_,U_,V_,E_,L_,w_,O_,b_,Z_="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",J1,R_,N_,S_,k_,I_,T_,M7="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",v_,Z0,E2,L2,LF,x2,X3,wF,OF,f2,V2,p0,W3,R0,ID,bF,$2=(D)=>{if(D instanceof RF)return $2(D.schema);else if(D instanceof k0)return $2(D.innerType());else if(D instanceof NF)return[D.value];else if(D instanceof w2)return D.options;else if(D instanceof SF)return QD.objectValues(D.enum);else if(D instanceof kF)return $2(D._def.innerType);else if(D instanceof wF)return[void 0];else if(D instanceof OF)return[null];else if(D instanceof N0)return[void 0,...$2(D.unwrap())];else if(D instanceof _2)return[null,...$2(D.unwrap())];else if(D instanceof s3)return $2(D.unwrap());else if(D instanceof TF)return $2(D.unwrap());else if(D instanceof IF)return $2(D._def.innerType);else return[]},n3,ZF,i0,G3,z3,h2,EF,RF,NF,w2,SF,m2,k0,N0,_2,kF,IF,M3,f_,s3,A3,TF,h_,n,m_=(D,F={message:`Input not instance of ${D.name}`})=>U7((B)=>B instanceof D,F),V7,E7,g_,d_,L7,c_,l_,p_,i_,n_,s_,a_,o_,r_,t_,e_,DQ,FQ,BQ,$Q,_Q,QQ,YQ,qQ,HQ,JQ,XQ,WQ,GQ,zQ,MQ,AQ,jQ,KQ,UQ=()=>V7().optional(),VQ=()=>E7().optional(),EQ=()=>L7().optional(),LQ,wQ;var w7=V(()=>{c3();l3();W7();H1();H3();K_=/^c[^\s-]{8,}$/i,U_=/^[0-9a-z]+$/,V_=/^[0-9A-HJKMNP-TV-Z]{26}$/i,E_=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,L_=/^[a-z0-9_-]{21}$/i,w_=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,O_=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,b_=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,R_=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,N_=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,S_=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,k_=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,I_=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,T_=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,v_=new RegExp(`^${M7}$`);Z0=class Z0 extends BD{_parse(D){if(this._def.coerce)D.data=String(D.data);if(this._getType(D)!==I.string){let _=this._getOrReturnCtx(D);return T(_,{code:Z.invalid_type,expected:I.string,received:_.parsedType}),l}let B=new pD,$=void 0;for(let _ of this._def.checks)if(_.kind==="min"){if(D.data.length<_.value)$=this._getOrReturnCtx(D,$),T($,{code:Z.too_small,minimum:_.value,type:"string",inclusive:!0,exact:!1,message:_.message}),B.dirty()}else if(_.kind==="max"){if(D.data.length>_.value)$=this._getOrReturnCtx(D,$),T($,{code:Z.too_big,maximum:_.value,type:"string",inclusive:!0,exact:!1,message:_.message}),B.dirty()}else if(_.kind==="length"){let Q=D.data.length>_.value,Y=D.data.length<_.value;if(Q||Y){if($=this._getOrReturnCtx(D,$),Q)T($,{code:Z.too_big,maximum:_.value,type:"string",inclusive:!0,exact:!0,message:_.message});else if(Y)T($,{code:Z.too_small,minimum:_.value,type:"string",inclusive:!0,exact:!0,message:_.message});B.dirty()}}else if(_.kind==="email"){if(!b_.test(D.data))$=this._getOrReturnCtx(D,$),T($,{validation:"email",code:Z.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="emoji"){if(!J1)J1=new RegExp(Z_,"u");if(!J1.test(D.data))$=this._getOrReturnCtx(D,$),T($,{validation:"emoji",code:Z.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="uuid"){if(!E_.test(D.data))$=this._getOrReturnCtx(D,$),T($,{validation:"uuid",code:Z.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="nanoid"){if(!L_.test(D.data))$=this._getOrReturnCtx(D,$),T($,{validation:"nanoid",code:Z.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="cuid"){if(!K_.test(D.data))$=this._getOrReturnCtx(D,$),T($,{validation:"cuid",code:Z.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="cuid2"){if(!U_.test(D.data))$=this._getOrReturnCtx(D,$),T($,{validation:"cuid2",code:Z.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="ulid"){if(!V_.test(D.data))$=this._getOrReturnCtx(D,$),T($,{validation:"ulid",code:Z.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="url")try{new URL(D.data)}catch{$=this._getOrReturnCtx(D,$),T($,{validation:"url",code:Z.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="regex"){if(_.regex.lastIndex=0,!_.regex.test(D.data))$=this._getOrReturnCtx(D,$),T($,{validation:"regex",code:Z.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="trim")D.data=D.data.trim();else if(_.kind==="includes"){if(!D.data.includes(_.value,_.position))$=this._getOrReturnCtx(D,$),T($,{code:Z.invalid_string,validation:{includes:_.value,position:_.position},message:_.message}),B.dirty()}else if(_.kind==="toLowerCase")D.data=D.data.toLowerCase();else if(_.kind==="toUpperCase")D.data=D.data.toUpperCase();else if(_.kind==="startsWith"){if(!D.data.startsWith(_.value))$=this._getOrReturnCtx(D,$),T($,{code:Z.invalid_string,validation:{startsWith:_.value},message:_.message}),B.dirty()}else if(_.kind==="endsWith"){if(!D.data.endsWith(_.value))$=this._getOrReturnCtx(D,$),T($,{code:Z.invalid_string,validation:{endsWith:_.value},message:_.message}),B.dirty()}else if(_.kind==="datetime"){if(!j7(_).test(D.data))$=this._getOrReturnCtx(D,$),T($,{code:Z.invalid_string,validation:"datetime",message:_.message}),B.dirty()}else if(_.kind==="date"){if(!v_.test(D.data))$=this._getOrReturnCtx(D,$),T($,{code:Z.invalid_string,validation:"date",message:_.message}),B.dirty()}else if(_.kind==="time"){if(!C_(_).test(D.data))$=this._getOrReturnCtx(D,$),T($,{code:Z.invalid_string,validation:"time",message:_.message}),B.dirty()}else if(_.kind==="duration"){if(!O_.test(D.data))$=this._getOrReturnCtx(D,$),T($,{validation:"duration",code:Z.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="ip"){if(!u_(D.data,_.version))$=this._getOrReturnCtx(D,$),T($,{validation:"ip",code:Z.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="jwt"){if(!P_(D.data,_.alg))$=this._getOrReturnCtx(D,$),T($,{validation:"jwt",code:Z.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="cidr"){if(!y_(D.data,_.version))$=this._getOrReturnCtx(D,$),T($,{validation:"cidr",code:Z.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="base64"){if(!I_.test(D.data))$=this._getOrReturnCtx(D,$),T($,{validation:"base64",code:Z.invalid_string,message:_.message}),B.dirty()}else if(_.kind==="base64url"){if(!T_.test(D.data))$=this._getOrReturnCtx(D,$),T($,{validation:"base64url",code:Z.invalid_string,message:_.message}),B.dirty()}else QD.assertNever(_);return{status:B.value,value:D.data}}_regex(D,F,B){return this.refinement(($)=>D.test($),{validation:F,code:Z.invalid_string,...x.errToObj(B)})}_addCheck(D){return new Z0({...this._def,checks:[...this._def.checks,D]})}email(D){return this._addCheck({kind:"email",...x.errToObj(D)})}url(D){return this._addCheck({kind:"url",...x.errToObj(D)})}emoji(D){return this._addCheck({kind:"emoji",...x.errToObj(D)})}uuid(D){return this._addCheck({kind:"uuid",...x.errToObj(D)})}nanoid(D){return this._addCheck({kind:"nanoid",...x.errToObj(D)})}cuid(D){return this._addCheck({kind:"cuid",...x.errToObj(D)})}cuid2(D){return this._addCheck({kind:"cuid2",...x.errToObj(D)})}ulid(D){return this._addCheck({kind:"ulid",...x.errToObj(D)})}base64(D){return this._addCheck({kind:"base64",...x.errToObj(D)})}base64url(D){return this._addCheck({kind:"base64url",...x.errToObj(D)})}jwt(D){return this._addCheck({kind:"jwt",...x.errToObj(D)})}ip(D){return this._addCheck({kind:"ip",...x.errToObj(D)})}cidr(D){return this._addCheck({kind:"cidr",...x.errToObj(D)})}datetime(D){if(typeof D==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:D});return this._addCheck({kind:"datetime",precision:typeof D?.precision>"u"?null:D?.precision,offset:D?.offset??!1,local:D?.local??!1,...x.errToObj(D?.message)})}date(D){return this._addCheck({kind:"date",message:D})}time(D){if(typeof D==="string")return this._addCheck({kind:"time",precision:null,message:D});return this._addCheck({kind:"time",precision:typeof D?.precision>"u"?null:D?.precision,...x.errToObj(D?.message)})}duration(D){return this._addCheck({kind:"duration",...x.errToObj(D)})}regex(D,F){return this._addCheck({kind:"regex",regex:D,...x.errToObj(F)})}includes(D,F){return this._addCheck({kind:"includes",value:D,position:F?.position,...x.errToObj(F?.message)})}startsWith(D,F){return this._addCheck({kind:"startsWith",value:D,...x.errToObj(F)})}endsWith(D,F){return this._addCheck({kind:"endsWith",value:D,...x.errToObj(F)})}min(D,F){return this._addCheck({kind:"min",value:D,...x.errToObj(F)})}max(D,F){return this._addCheck({kind:"max",value:D,...x.errToObj(F)})}length(D,F){return this._addCheck({kind:"length",value:D,...x.errToObj(F)})}nonempty(D){return this.min(1,x.errToObj(D))}trim(){return new Z0({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Z0({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Z0({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((D)=>D.kind==="datetime")}get isDate(){return!!this._def.checks.find((D)=>D.kind==="date")}get isTime(){return!!this._def.checks.find((D)=>D.kind==="time")}get isDuration(){return!!this._def.checks.find((D)=>D.kind==="duration")}get isEmail(){return!!this._def.checks.find((D)=>D.kind==="email")}get isURL(){return!!this._def.checks.find((D)=>D.kind==="url")}get isEmoji(){return!!this._def.checks.find((D)=>D.kind==="emoji")}get isUUID(){return!!this._def.checks.find((D)=>D.kind==="uuid")}get isNANOID(){return!!this._def.checks.find((D)=>D.kind==="nanoid")}get isCUID(){return!!this._def.checks.find((D)=>D.kind==="cuid")}get isCUID2(){return!!this._def.checks.find((D)=>D.kind==="cuid2")}get isULID(){return!!this._def.checks.find((D)=>D.kind==="ulid")}get isIP(){return!!this._def.checks.find((D)=>D.kind==="ip")}get isCIDR(){return!!this._def.checks.find((D)=>D.kind==="cidr")}get isBase64(){return!!this._def.checks.find((D)=>D.kind==="base64")}get isBase64url(){return!!this._def.checks.find((D)=>D.kind==="base64url")}get minLength(){let D=null;for(let F of this._def.checks)if(F.kind==="min"){if(D===null||F.value>D)D=F.value}return D}get maxLength(){let D=null;for(let F of this._def.checks)if(F.kind==="max"){if(D===null||F.value<D)D=F.value}return D}};Z0.create=(D)=>{return new Z0({checks:[],typeName:n.ZodString,coerce:D?.coerce??!1,...DD(D)})};E2=class E2 extends BD{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(D){if(this._def.coerce)D.data=Number(D.data);if(this._getType(D)!==I.number){let _=this._getOrReturnCtx(D);return T(_,{code:Z.invalid_type,expected:I.number,received:_.parsedType}),l}let B=void 0,$=new pD;for(let _ of this._def.checks)if(_.kind==="int"){if(!QD.isInteger(D.data))B=this._getOrReturnCtx(D,B),T(B,{code:Z.invalid_type,expected:"integer",received:"float",message:_.message}),$.dirty()}else if(_.kind==="min"){if(_.inclusive?D.data<_.value:D.data<=_.value)B=this._getOrReturnCtx(D,B),T(B,{code:Z.too_small,minimum:_.value,type:"number",inclusive:_.inclusive,exact:!1,message:_.message}),$.dirty()}else if(_.kind==="max"){if(_.inclusive?D.data>_.value:D.data>=_.value)B=this._getOrReturnCtx(D,B),T(B,{code:Z.too_big,maximum:_.value,type:"number",inclusive:_.inclusive,exact:!1,message:_.message}),$.dirty()}else if(_.kind==="multipleOf"){if(x_(D.data,_.value)!==0)B=this._getOrReturnCtx(D,B),T(B,{code:Z.not_multiple_of,multipleOf:_.value,message:_.message}),$.dirty()}else if(_.kind==="finite"){if(!Number.isFinite(D.data))B=this._getOrReturnCtx(D,B),T(B,{code:Z.not_finite,message:_.message}),$.dirty()}else QD.assertNever(_);return{status:$.value,value:D.data}}gte(D,F){return this.setLimit("min",D,!0,x.toString(F))}gt(D,F){return this.setLimit("min",D,!1,x.toString(F))}lte(D,F){return this.setLimit("max",D,!0,x.toString(F))}lt(D,F){return this.setLimit("max",D,!1,x.toString(F))}setLimit(D,F,B,$){return new E2({...this._def,checks:[...this._def.checks,{kind:D,value:F,inclusive:B,message:x.toString($)}]})}_addCheck(D){return new E2({...this._def,checks:[...this._def.checks,D]})}int(D){return this._addCheck({kind:"int",message:x.toString(D)})}positive(D){return this._addCheck({kind:"min",value:0,inclusive:!1,message:x.toString(D)})}negative(D){return this._addCheck({kind:"max",value:0,inclusive:!1,message:x.toString(D)})}nonpositive(D){return this._addCheck({kind:"max",value:0,inclusive:!0,message:x.toString(D)})}nonnegative(D){return this._addCheck({kind:"min",value:0,inclusive:!0,message:x.toString(D)})}multipleOf(D,F){return this._addCheck({kind:"multipleOf",value:D,message:x.toString(F)})}finite(D){return this._addCheck({kind:"finite",message:x.toString(D)})}safe(D){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:x.toString(D)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:x.toString(D)})}get minValue(){let D=null;for(let F of this._def.checks)if(F.kind==="min"){if(D===null||F.value>D)D=F.value}return D}get maxValue(){let D=null;for(let F of this._def.checks)if(F.kind==="max"){if(D===null||F.value<D)D=F.value}return D}get isInt(){return!!this._def.checks.find((D)=>D.kind==="int"||D.kind==="multipleOf"&&QD.isInteger(D.value))}get isFinite(){let D=null,F=null;for(let B of this._def.checks)if(B.kind==="finite"||B.kind==="int"||B.kind==="multipleOf")return!0;else if(B.kind==="min"){if(F===null||B.value>F)F=B.value}else if(B.kind==="max"){if(D===null||B.value<D)D=B.value}return Number.isFinite(F)&&Number.isFinite(D)}};E2.create=(D)=>{return new E2({checks:[],typeName:n.ZodNumber,coerce:D?.coerce||!1,...DD(D)})};L2=class L2 extends BD{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse(D){if(this._def.coerce)try{D.data=BigInt(D.data)}catch{return this._getInvalidInput(D)}if(this._getType(D)!==I.bigint)return this._getInvalidInput(D);let B=void 0,$=new pD;for(let _ of this._def.checks)if(_.kind==="min"){if(_.inclusive?D.data<_.value:D.data<=_.value)B=this._getOrReturnCtx(D,B),T(B,{code:Z.too_small,type:"bigint",minimum:_.value,inclusive:_.inclusive,message:_.message}),$.dirty()}else if(_.kind==="max"){if(_.inclusive?D.data>_.value:D.data>=_.value)B=this._getOrReturnCtx(D,B),T(B,{code:Z.too_big,type:"bigint",maximum:_.value,inclusive:_.inclusive,message:_.message}),$.dirty()}else if(_.kind==="multipleOf"){if(D.data%_.value!==BigInt(0))B=this._getOrReturnCtx(D,B),T(B,{code:Z.not_multiple_of,multipleOf:_.value,message:_.message}),$.dirty()}else QD.assertNever(_);return{status:$.value,value:D.data}}_getInvalidInput(D){let F=this._getOrReturnCtx(D);return T(F,{code:Z.invalid_type,expected:I.bigint,received:F.parsedType}),l}gte(D,F){return this.setLimit("min",D,!0,x.toString(F))}gt(D,F){return this.setLimit("min",D,!1,x.toString(F))}lte(D,F){return this.setLimit("max",D,!0,x.toString(F))}lt(D,F){return this.setLimit("max",D,!1,x.toString(F))}setLimit(D,F,B,$){return new L2({...this._def,checks:[...this._def.checks,{kind:D,value:F,inclusive:B,message:x.toString($)}]})}_addCheck(D){return new L2({...this._def,checks:[...this._def.checks,D]})}positive(D){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:x.toString(D)})}negative(D){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:x.toString(D)})}nonpositive(D){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:x.toString(D)})}nonnegative(D){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:x.toString(D)})}multipleOf(D,F){return this._addCheck({kind:"multipleOf",value:D,message:x.toString(F)})}get minValue(){let D=null;for(let F of this._def.checks)if(F.kind==="min"){if(D===null||F.value>D)D=F.value}return D}get maxValue(){let D=null;for(let F of this._def.checks)if(F.kind==="max"){if(D===null||F.value<D)D=F.value}return D}};L2.create=(D)=>{return new L2({checks:[],typeName:n.ZodBigInt,coerce:D?.coerce??!1,...DD(D)})};LF=class LF extends BD{_parse(D){if(this._def.coerce)D.data=Boolean(D.data);if(this._getType(D)!==I.boolean){let B=this._getOrReturnCtx(D);return T(B,{code:Z.invalid_type,expected:I.boolean,received:B.parsedType}),l}return aD(D.data)}};LF.create=(D)=>{return new LF({typeName:n.ZodBoolean,coerce:D?.coerce||!1,...DD(D)})};x2=class x2 extends BD{_parse(D){if(this._def.coerce)D.data=new Date(D.data);if(this._getType(D)!==I.date){let _=this._getOrReturnCtx(D);return T(_,{code:Z.invalid_type,expected:I.date,received:_.parsedType}),l}if(Number.isNaN(D.data.getTime())){let _=this._getOrReturnCtx(D);return T(_,{code:Z.invalid_date}),l}let B=new pD,$=void 0;for(let _ of this._def.checks)if(_.kind==="min"){if(D.data.getTime()<_.value)$=this._getOrReturnCtx(D,$),T($,{code:Z.too_small,message:_.message,inclusive:!0,exact:!1,minimum:_.value,type:"date"}),B.dirty()}else if(_.kind==="max"){if(D.data.getTime()>_.value)$=this._getOrReturnCtx(D,$),T($,{code:Z.too_big,message:_.message,inclusive:!0,exact:!1,maximum:_.value,type:"date"}),B.dirty()}else QD.assertNever(_);return{status:B.value,value:new Date(D.data.getTime())}}_addCheck(D){return new x2({...this._def,checks:[...this._def.checks,D]})}min(D,F){return this._addCheck({kind:"min",value:D.getTime(),message:x.toString(F)})}max(D,F){return this._addCheck({kind:"max",value:D.getTime(),message:x.toString(F)})}get minDate(){let D=null;for(let F of this._def.checks)if(F.kind==="min"){if(D===null||F.value>D)D=F.value}return D!=null?new Date(D):null}get maxDate(){let D=null;for(let F of this._def.checks)if(F.kind==="max"){if(D===null||F.value<D)D=F.value}return D!=null?new Date(D):null}};x2.create=(D)=>{return new x2({checks:[],coerce:D?.coerce||!1,typeName:n.ZodDate,...DD(D)})};X3=class X3 extends BD{_parse(D){if(this._getType(D)!==I.symbol){let B=this._getOrReturnCtx(D);return T(B,{code:Z.invalid_type,expected:I.symbol,received:B.parsedType}),l}return aD(D.data)}};X3.create=(D)=>{return new X3({typeName:n.ZodSymbol,...DD(D)})};wF=class wF extends BD{_parse(D){if(this._getType(D)!==I.undefined){let B=this._getOrReturnCtx(D);return T(B,{code:Z.invalid_type,expected:I.undefined,received:B.parsedType}),l}return aD(D.data)}};wF.create=(D)=>{return new wF({typeName:n.ZodUndefined,...DD(D)})};OF=class OF extends BD{_parse(D){if(this._getType(D)!==I.null){let B=this._getOrReturnCtx(D);return T(B,{code:Z.invalid_type,expected:I.null,received:B.parsedType}),l}return aD(D.data)}};OF.create=(D)=>{return new OF({typeName:n.ZodNull,...DD(D)})};f2=class f2 extends BD{constructor(){super(...arguments);this._any=!0}_parse(D){return aD(D.data)}};f2.create=(D)=>{return new f2({typeName:n.ZodAny,...DD(D)})};V2=class V2 extends BD{constructor(){super(...arguments);this._unknown=!0}_parse(D){return aD(D.data)}};V2.create=(D)=>{return new V2({typeName:n.ZodUnknown,...DD(D)})};p0=class p0 extends BD{_parse(D){let F=this._getOrReturnCtx(D);return T(F,{code:Z.invalid_type,expected:I.never,received:F.parsedType}),l}};p0.create=(D)=>{return new p0({typeName:n.ZodNever,...DD(D)})};W3=class W3 extends BD{_parse(D){if(this._getType(D)!==I.undefined){let B=this._getOrReturnCtx(D);return T(B,{code:Z.invalid_type,expected:I.void,received:B.parsedType}),l}return aD(D.data)}};W3.create=(D)=>{return new W3({typeName:n.ZodVoid,...DD(D)})};R0=class R0 extends BD{_parse(D){let{ctx:F,status:B}=this._processInputParams(D),$=this._def;if(F.parsedType!==I.array)return T(F,{code:Z.invalid_type,expected:I.array,received:F.parsedType}),l;if($.exactLength!==null){let Q=F.data.length>$.exactLength.value,Y=F.data.length<$.exactLength.value;if(Q||Y)T(F,{code:Q?Z.too_big:Z.too_small,minimum:Y?$.exactLength.value:void 0,maximum:Q?$.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:$.exactLength.message}),B.dirty()}if($.minLength!==null){if(F.data.length<$.minLength.value)T(F,{code:Z.too_small,minimum:$.minLength.value,type:"array",inclusive:!0,exact:!1,message:$.minLength.message}),B.dirty()}if($.maxLength!==null){if(F.data.length>$.maxLength.value)T(F,{code:Z.too_big,maximum:$.maxLength.value,type:"array",inclusive:!0,exact:!1,message:$.maxLength.message}),B.dirty()}if(F.common.async)return Promise.all([...F.data].map((Q,Y)=>{return $.type._parseAsync(new S0(F,Q,F.path,Y))})).then((Q)=>{return pD.mergeArray(B,Q)});let _=[...F.data].map((Q,Y)=>{return $.type._parseSync(new S0(F,Q,F.path,Y))});return pD.mergeArray(B,_)}get element(){return this._def.type}min(D,F){return new R0({...this._def,minLength:{value:D,message:x.toString(F)}})}max(D,F){return new R0({...this._def,maxLength:{value:D,message:x.toString(F)}})}length(D,F){return new R0({...this._def,exactLength:{value:D,message:x.toString(F)}})}nonempty(D){return this.min(1,D)}};R0.create=(D,F)=>{return new R0({type:D,minLength:null,maxLength:null,exactLength:null,typeName:n.ZodArray,...DD(F)})};ID=class ID extends BD{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let D=this._def.shape(),F=QD.objectKeys(D);return this._cached={shape:D,keys:F},this._cached}_parse(D){if(this._getType(D)!==I.object){let H=this._getOrReturnCtx(D);return T(H,{code:Z.invalid_type,expected:I.object,received:H.parsedType}),l}let{status:B,ctx:$}=this._processInputParams(D),{shape:_,keys:Q}=this._getCached(),Y=[];if(!(this._def.catchall instanceof p0&&this._def.unknownKeys==="strip")){for(let H in $.data)if(!Q.includes(H))Y.push(H)}let q=[];for(let H of Q){let J=_[H],X=$.data[H];q.push({key:{status:"valid",value:H},value:J._parse(new S0($,X,$.path,H)),alwaysSet:H in $.data})}if(this._def.catchall instanceof p0){let H=this._def.unknownKeys;if(H==="passthrough")for(let J of Y)q.push({key:{status:"valid",value:J},value:{status:"valid",value:$.data[J]}});else if(H==="strict"){if(Y.length>0)T($,{code:Z.unrecognized_keys,keys:Y}),B.dirty()}else if(H==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let H=this._def.catchall;for(let J of Y){let X=$.data[J];q.push({key:{status:"valid",value:J},value:H._parse(new S0($,X,$.path,J)),alwaysSet:J in $.data})}}if($.common.async)return Promise.resolve().then(async()=>{let H=[];for(let J of q){let X=await J.key,z=await J.value;H.push({key:X,value:z,alwaysSet:J.alwaysSet})}return H}).then((H)=>{return pD.mergeObjectSync(B,H)});else return pD.mergeObjectSync(B,q)}get shape(){return this._def.shape()}strict(D){return x.errToObj,new ID({...this._def,unknownKeys:"strict",...D!==void 0?{errorMap:(F,B)=>{let $=this._def.errorMap?.(F,B).message??B.defaultError;if(F.code==="unrecognized_keys")return{message:x.errToObj(D).message??$};return{message:$}}}:{}})}strip(){return new ID({...this._def,unknownKeys:"strip"})}passthrough(){return new ID({...this._def,unknownKeys:"passthrough"})}extend(D){return new ID({...this._def,shape:()=>({...this._def.shape(),...D})})}merge(D){return new ID({unknownKeys:D._def.unknownKeys,catchall:D._def.catchall,shape:()=>({...this._def.shape(),...D._def.shape()}),typeName:n.ZodObject})}setKey(D,F){return this.augment({[D]:F})}catchall(D){return new ID({...this._def,catchall:D})}pick(D){let F={};for(let B of QD.objectKeys(D))if(D[B]&&this.shape[B])F[B]=this.shape[B];return new ID({...this._def,shape:()=>F})}omit(D){let F={};for(let B of QD.objectKeys(this.shape))if(!D[B])F[B]=this.shape[B];return new ID({...this._def,shape:()=>F})}deepPartial(){return VF(this)}partial(D){let F={};for(let B of QD.objectKeys(this.shape)){let $=this.shape[B];if(D&&!D[B])F[B]=$;else F[B]=$.optional()}return new ID({...this._def,shape:()=>F})}required(D){let F={};for(let B of QD.objectKeys(this.shape))if(D&&!D[B])F[B]=this.shape[B];else{let _=this.shape[B];while(_ instanceof N0)_=_._def.innerType;F[B]=_}return new ID({...this._def,shape:()=>F})}keyof(){return K7(QD.objectKeys(this.shape))}};ID.create=(D,F)=>{return new ID({shape:()=>D,unknownKeys:"strip",catchall:p0.create(),typeName:n.ZodObject,...DD(F)})};ID.strictCreate=(D,F)=>{return new ID({shape:()=>D,unknownKeys:"strict",catchall:p0.create(),typeName:n.ZodObject,...DD(F)})};ID.lazycreate=(D,F)=>{return new ID({shape:D,unknownKeys:"strip",catchall:p0.create(),typeName:n.ZodObject,...DD(F)})};bF=class bF extends BD{_parse(D){let{ctx:F}=this._processInputParams(D),B=this._def.options;function $(_){for(let Y of _)if(Y.result.status==="valid")return Y.result;for(let Y of _)if(Y.result.status==="dirty")return F.common.issues.push(...Y.ctx.common.issues),Y.result;let Q=_.map((Y)=>new lD(Y.ctx.common.issues));return T(F,{code:Z.invalid_union,unionErrors:Q}),l}if(F.common.async)return Promise.all(B.map(async(_)=>{let Q={...F,common:{...F.common,issues:[]},parent:null};return{result:await _._parseAsync({data:F.data,path:F.path,parent:Q}),ctx:Q}})).then($);else{let _=void 0,Q=[];for(let q of B){let H={...F,common:{...F.common,issues:[]},parent:null},J=q._parseSync({data:F.data,path:F.path,parent:H});if(J.status==="valid")return J;else if(J.status==="dirty"&&!_)_={result:J,ctx:H};if(H.common.issues.length)Q.push(H.common.issues)}if(_)return F.common.issues.push(..._.ctx.common.issues),_.result;let Y=Q.map((q)=>new lD(q));return T(F,{code:Z.invalid_union,unionErrors:Y}),l}}get options(){return this._def.options}};bF.create=(D,F)=>{return new bF({options:D,typeName:n.ZodUnion,...DD(F)})};n3=class n3 extends BD{_parse(D){let{ctx:F}=this._processInputParams(D);if(F.parsedType!==I.object)return T(F,{code:Z.invalid_type,expected:I.object,received:F.parsedType}),l;let B=this.discriminator,$=F.data[B],_=this.optionsMap.get($);if(!_)return T(F,{code:Z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[B]}),l;if(F.common.async)return _._parseAsync({data:F.data,path:F.path,parent:F});else return _._parseSync({data:F.data,path:F.path,parent:F})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(D,F,B){let $=new Map;for(let _ of F){let Q=$2(_.shape[D]);if(!Q.length)throw Error(`A discriminator value for key \`${D}\` could not be extracted from all schema options`);for(let Y of Q){if($.has(Y))throw Error(`Discriminator property ${String(D)} has duplicate value ${String(Y)}`);$.set(Y,_)}}return new n3({typeName:n.ZodDiscriminatedUnion,discriminator:D,options:F,optionsMap:$,...DD(B)})}};ZF=class ZF extends BD{_parse(D){let{status:F,ctx:B}=this._processInputParams(D),$=(_,Q)=>{if(p3(_)||p3(Q))return l;let Y=X1(_.value,Q.value);if(!Y.valid)return T(B,{code:Z.invalid_intersection_types}),l;if(i3(_)||i3(Q))F.dirty();return{status:F.value,value:Y.data}};if(B.common.async)return Promise.all([this._def.left._parseAsync({data:B.data,path:B.path,parent:B}),this._def.right._parseAsync({data:B.data,path:B.path,parent:B})]).then(([_,Q])=>$(_,Q));else return $(this._def.left._parseSync({data:B.data,path:B.path,parent:B}),this._def.right._parseSync({data:B.data,path:B.path,parent:B}))}};ZF.create=(D,F,B)=>{return new ZF({left:D,right:F,typeName:n.ZodIntersection,...DD(B)})};i0=class i0 extends BD{_parse(D){let{status:F,ctx:B}=this._processInputParams(D);if(B.parsedType!==I.array)return T(B,{code:Z.invalid_type,expected:I.array,received:B.parsedType}),l;if(B.data.length<this._def.items.length)return T(B,{code:Z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),l;if(!this._def.rest&&B.data.length>this._def.items.length)T(B,{code:Z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),F.dirty();let _=[...B.data].map((Q,Y)=>{let q=this._def.items[Y]||this._def.rest;if(!q)return null;return q._parse(new S0(B,Q,B.path,Y))}).filter((Q)=>!!Q);if(B.common.async)return Promise.all(_).then((Q)=>{return pD.mergeArray(F,Q)});else return pD.mergeArray(F,_)}get items(){return this._def.items}rest(D){return new i0({...this._def,rest:D})}};i0.create=(D,F)=>{if(!Array.isArray(D))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new i0({items:D,typeName:n.ZodTuple,rest:null,...DD(F)})};G3=class G3 extends BD{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(D){let{status:F,ctx:B}=this._processInputParams(D);if(B.parsedType!==I.object)return T(B,{code:Z.invalid_type,expected:I.object,received:B.parsedType}),l;let $=[],_=this._def.keyType,Q=this._def.valueType;for(let Y in B.data)$.push({key:_._parse(new S0(B,Y,B.path,Y)),value:Q._parse(new S0(B,B.data[Y],B.path,Y)),alwaysSet:Y in B.data});if(B.common.async)return pD.mergeObjectAsync(F,$);else return pD.mergeObjectSync(F,$)}get element(){return this._def.valueType}static create(D,F,B){if(F instanceof BD)return new G3({keyType:D,valueType:F,typeName:n.ZodRecord,...DD(B)});return new G3({keyType:Z0.create(),valueType:D,typeName:n.ZodRecord,...DD(F)})}};z3=class z3 extends BD{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(D){let{status:F,ctx:B}=this._processInputParams(D);if(B.parsedType!==I.map)return T(B,{code:Z.invalid_type,expected:I.map,received:B.parsedType}),l;let $=this._def.keyType,_=this._def.valueType,Q=[...B.data.entries()].map(([Y,q],H)=>{return{key:$._parse(new S0(B,Y,B.path,[H,"key"])),value:_._parse(new S0(B,q,B.path,[H,"value"]))}});if(B.common.async){let Y=new Map;return Promise.resolve().then(async()=>{for(let q of Q){let H=await q.key,J=await q.value;if(H.status==="aborted"||J.status==="aborted")return l;if(H.status==="dirty"||J.status==="dirty")F.dirty();Y.set(H.value,J.value)}return{status:F.value,value:Y}})}else{let Y=new Map;for(let q of Q){let{key:H,value:J}=q;if(H.status==="aborted"||J.status==="aborted")return l;if(H.status==="dirty"||J.status==="dirty")F.dirty();Y.set(H.value,J.value)}return{status:F.value,value:Y}}}};z3.create=(D,F,B)=>{return new z3({valueType:F,keyType:D,typeName:n.ZodMap,...DD(B)})};h2=class h2 extends BD{_parse(D){let{status:F,ctx:B}=this._processInputParams(D);if(B.parsedType!==I.set)return T(B,{code:Z.invalid_type,expected:I.set,received:B.parsedType}),l;let $=this._def;if($.minSize!==null){if(B.data.size<$.minSize.value)T(B,{code:Z.too_small,minimum:$.minSize.value,type:"set",inclusive:!0,exact:!1,message:$.minSize.message}),F.dirty()}if($.maxSize!==null){if(B.data.size>$.maxSize.value)T(B,{code:Z.too_big,maximum:$.maxSize.value,type:"set",inclusive:!0,exact:!1,message:$.maxSize.message}),F.dirty()}let _=this._def.valueType;function Q(q){let H=new Set;for(let J of q){if(J.status==="aborted")return l;if(J.status==="dirty")F.dirty();H.add(J.value)}return{status:F.value,value:H}}let Y=[...B.data.values()].map((q,H)=>_._parse(new S0(B,q,B.path,H)));if(B.common.async)return Promise.all(Y).then((q)=>Q(q));else return Q(Y)}min(D,F){return new h2({...this._def,minSize:{value:D,message:x.toString(F)}})}max(D,F){return new h2({...this._def,maxSize:{value:D,message:x.toString(F)}})}size(D,F){return this.min(D,F).max(D,F)}nonempty(D){return this.min(1,D)}};h2.create=(D,F)=>{return new h2({valueType:D,minSize:null,maxSize:null,typeName:n.ZodSet,...DD(F)})};EF=class EF extends BD{constructor(){super(...arguments);this.validate=this.implement}_parse(D){let{ctx:F}=this._processInputParams(D);if(F.parsedType!==I.function)return T(F,{code:Z.invalid_type,expected:I.function,received:F.parsedType}),l;function B(Y,q){return J3({data:Y,path:F.path,errorMaps:[F.common.contextualErrorMap,F.schemaErrorMap,KF(),B2].filter((H)=>!!H),issueData:{code:Z.invalid_arguments,argumentsError:q}})}function $(Y,q){return J3({data:Y,path:F.path,errorMaps:[F.common.contextualErrorMap,F.schemaErrorMap,KF(),B2].filter((H)=>!!H),issueData:{code:Z.invalid_return_type,returnTypeError:q}})}let _={errorMap:F.common.contextualErrorMap},Q=F.data;if(this._def.returns instanceof m2){let Y=this;return aD(async function(...q){let H=new lD([]),J=await Y._def.args.parseAsync(q,_).catch((M)=>{throw H.addIssue(B(q,M)),H}),X=await Reflect.apply(Q,this,J);return await Y._def.returns._def.type.parseAsync(X,_).catch((M)=>{throw H.addIssue($(X,M)),H})})}else{let Y=this;return aD(function(...q){let H=Y._def.args.safeParse(q,_);if(!H.success)throw new lD([B(q,H.error)]);let J=Reflect.apply(Q,this,H.data),X=Y._def.returns.safeParse(J,_);if(!X.success)throw new lD([$(J,X.error)]);return X.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...D){return new EF({...this._def,args:i0.create(D).rest(V2.create())})}returns(D){return new EF({...this._def,returns:D})}implement(D){return this.parse(D)}strictImplement(D){return this.parse(D)}static create(D,F,B){return new EF({args:D?D:i0.create([]).rest(V2.create()),returns:F||V2.create(),typeName:n.ZodFunction,...DD(B)})}};RF=class RF extends BD{get schema(){return this._def.getter()}_parse(D){let{ctx:F}=this._processInputParams(D);return this._def.getter()._parse({data:F.data,path:F.path,parent:F})}};RF.create=(D,F)=>{return new RF({getter:D,typeName:n.ZodLazy,...DD(F)})};NF=class NF extends BD{_parse(D){if(D.data!==this._def.value){let F=this._getOrReturnCtx(D);return T(F,{received:F.data,code:Z.invalid_literal,expected:this._def.value}),l}return{status:"valid",value:D.data}}get value(){return this._def.value}};NF.create=(D,F)=>{return new NF({value:D,typeName:n.ZodLiteral,...DD(F)})};w2=class w2 extends BD{_parse(D){if(typeof D.data!=="string"){let F=this._getOrReturnCtx(D),B=this._def.values;return T(F,{expected:QD.joinValues(B),received:F.parsedType,code:Z.invalid_type}),l}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has(D.data)){let F=this._getOrReturnCtx(D),B=this._def.values;return T(F,{received:F.data,code:Z.invalid_enum_value,options:B}),l}return aD(D.data)}get options(){return this._def.values}get enum(){let D={};for(let F of this._def.values)D[F]=F;return D}get Values(){let D={};for(let F of this._def.values)D[F]=F;return D}get Enum(){let D={};for(let F of this._def.values)D[F]=F;return D}extract(D,F=this._def){return w2.create(D,{...this._def,...F})}exclude(D,F=this._def){return w2.create(this.options.filter((B)=>!D.includes(B)),{...this._def,...F})}};w2.create=K7;SF=class SF extends BD{_parse(D){let F=QD.getValidEnumValues(this._def.values),B=this._getOrReturnCtx(D);if(B.parsedType!==I.string&&B.parsedType!==I.number){let $=QD.objectValues(F);return T(B,{expected:QD.joinValues($),received:B.parsedType,code:Z.invalid_type}),l}if(!this._cache)this._cache=new Set(QD.getValidEnumValues(this._def.values));if(!this._cache.has(D.data)){let $=QD.objectValues(F);return T(B,{received:B.data,code:Z.invalid_enum_value,options:$}),l}return aD(D.data)}get enum(){return this._def.values}};SF.create=(D,F)=>{return new SF({values:D,typeName:n.ZodNativeEnum,...DD(F)})};m2=class m2 extends BD{unwrap(){return this._def.type}_parse(D){let{ctx:F}=this._processInputParams(D);if(F.parsedType!==I.promise&&F.common.async===!1)return T(F,{code:Z.invalid_type,expected:I.promise,received:F.parsedType}),l;let B=F.parsedType===I.promise?F.data:Promise.resolve(F.data);return aD(B.then(($)=>{return this._def.type.parseAsync($,{path:F.path,errorMap:F.common.contextualErrorMap})}))}};m2.create=(D,F)=>{return new m2({type:D,typeName:n.ZodPromise,...DD(F)})};k0=class k0 extends BD{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===n.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(D){let{status:F,ctx:B}=this._processInputParams(D),$=this._def.effect||null,_={addIssue:(Q)=>{if(T(B,Q),Q.fatal)F.abort();else F.dirty()},get path(){return B.path}};if(_.addIssue=_.addIssue.bind(_),$.type==="preprocess"){let Q=$.transform(B.data,_);if(B.common.async)return Promise.resolve(Q).then(async(Y)=>{if(F.value==="aborted")return l;let q=await this._def.schema._parseAsync({data:Y,path:B.path,parent:B});if(q.status==="aborted")return l;if(q.status==="dirty")return y2(q.value);if(F.value==="dirty")return y2(q.value);return q});else{if(F.value==="aborted")return l;let Y=this._def.schema._parseSync({data:Q,path:B.path,parent:B});if(Y.status==="aborted")return l;if(Y.status==="dirty")return y2(Y.value);if(F.value==="dirty")return y2(Y.value);return Y}}if($.type==="refinement"){let Q=(Y)=>{let q=$.refinement(Y,_);if(B.common.async)return Promise.resolve(q);if(q instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return Y};if(B.common.async===!1){let Y=this._def.schema._parseSync({data:B.data,path:B.path,parent:B});if(Y.status==="aborted")return l;if(Y.status==="dirty")F.dirty();return Q(Y.value),{status:F.value,value:Y.value}}else return this._def.schema._parseAsync({data:B.data,path:B.path,parent:B}).then((Y)=>{if(Y.status==="aborted")return l;if(Y.status==="dirty")F.dirty();return Q(Y.value).then(()=>{return{status:F.value,value:Y.value}})})}if($.type==="transform")if(B.common.async===!1){let Q=this._def.schema._parseSync({data:B.data,path:B.path,parent:B});if(!U2(Q))return l;let Y=$.transform(Q.value,_);if(Y instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:F.value,value:Y}}else return this._def.schema._parseAsync({data:B.data,path:B.path,parent:B}).then((Q)=>{if(!U2(Q))return l;return Promise.resolve($.transform(Q.value,_)).then((Y)=>({status:F.value,value:Y}))});QD.assertNever($)}};k0.create=(D,F,B)=>{return new k0({schema:D,typeName:n.ZodEffects,effect:F,...DD(B)})};k0.createWithPreprocess=(D,F,B)=>{return new k0({schema:F,effect:{type:"preprocess",transform:D},typeName:n.ZodEffects,...DD(B)})};N0=class N0 extends BD{_parse(D){if(this._getType(D)===I.undefined)return aD(void 0);return this._def.innerType._parse(D)}unwrap(){return this._def.innerType}};N0.create=(D,F)=>{return new N0({innerType:D,typeName:n.ZodOptional,...DD(F)})};_2=class _2 extends BD{_parse(D){if(this._getType(D)===I.null)return aD(null);return this._def.innerType._parse(D)}unwrap(){return this._def.innerType}};_2.create=(D,F)=>{return new _2({innerType:D,typeName:n.ZodNullable,...DD(F)})};kF=class kF extends BD{_parse(D){let{ctx:F}=this._processInputParams(D),B=F.data;if(F.parsedType===I.undefined)B=this._def.defaultValue();return this._def.innerType._parse({data:B,path:F.path,parent:F})}removeDefault(){return this._def.innerType}};kF.create=(D,F)=>{return new kF({innerType:D,typeName:n.ZodDefault,defaultValue:typeof F.default==="function"?F.default:()=>F.default,...DD(F)})};IF=class IF extends BD{_parse(D){let{ctx:F}=this._processInputParams(D),B={...F,common:{...F.common,issues:[]}},$=this._def.innerType._parse({data:B.data,path:B.path,parent:{...B}});if(UF($))return $.then((_)=>{return{status:"valid",value:_.status==="valid"?_.value:this._def.catchValue({get error(){return new lD(B.common.issues)},input:B.data})}});else return{status:"valid",value:$.status==="valid"?$.value:this._def.catchValue({get error(){return new lD(B.common.issues)},input:B.data})}}removeCatch(){return this._def.innerType}};IF.create=(D,F)=>{return new IF({innerType:D,typeName:n.ZodCatch,catchValue:typeof F.catch==="function"?F.catch:()=>F.catch,...DD(F)})};M3=class M3 extends BD{_parse(D){if(this._getType(D)!==I.nan){let B=this._getOrReturnCtx(D);return T(B,{code:Z.invalid_type,expected:I.nan,received:B.parsedType}),l}return{status:"valid",value:D.data}}};M3.create=(D)=>{return new M3({typeName:n.ZodNaN,...DD(D)})};f_=Symbol("zod_brand");s3=class s3 extends BD{_parse(D){let{ctx:F}=this._processInputParams(D),B=F.data;return this._def.type._parse({data:B,path:F.path,parent:F})}unwrap(){return this._def.type}};A3=class A3 extends BD{_parse(D){let{status:F,ctx:B}=this._processInputParams(D);if(B.common.async)return(async()=>{let _=await this._def.in._parseAsync({data:B.data,path:B.path,parent:B});if(_.status==="aborted")return l;if(_.status==="dirty")return F.dirty(),y2(_.value);else return this._def.out._parseAsync({data:_.value,path:B.path,parent:B})})();else{let $=this._def.in._parseSync({data:B.data,path:B.path,parent:B});if($.status==="aborted")return l;if($.status==="dirty")return F.dirty(),{status:"dirty",value:$.value};else return this._def.out._parseSync({data:$.value,path:B.path,parent:B})}}static create(D,F){return new A3({in:D,out:F,typeName:n.ZodPipeline})}};TF=class TF extends BD{_parse(D){let F=this._def.innerType._parse(D),B=($)=>{if(U2($))$.value=Object.freeze($.value);return $};return UF(F)?F.then(($)=>B($)):B(F)}unwrap(){return this._def.innerType}};TF.create=(D,F)=>{return new TF({innerType:D,typeName:n.ZodReadonly,...DD(F)})};h_={object:ID.lazycreate};(function(D){D.ZodString="ZodString",D.ZodNumber="ZodNumber",D.ZodNaN="ZodNaN",D.ZodBigInt="ZodBigInt",D.ZodBoolean="ZodBoolean",D.ZodDate="ZodDate",D.ZodSymbol="ZodSymbol",D.ZodUndefined="ZodUndefined",D.ZodNull="ZodNull",D.ZodAny="ZodAny",D.ZodUnknown="ZodUnknown",D.ZodNever="ZodNever",D.ZodVoid="ZodVoid",D.ZodArray="ZodArray",D.ZodObject="ZodObject",D.ZodUnion="ZodUnion",D.ZodDiscriminatedUnion="ZodDiscriminatedUnion",D.ZodIntersection="ZodIntersection",D.ZodTuple="ZodTuple",D.ZodRecord="ZodRecord",D.ZodMap="ZodMap",D.ZodSet="ZodSet",D.ZodFunction="ZodFunction",D.ZodLazy="ZodLazy",D.ZodLiteral="ZodLiteral",D.ZodEnum="ZodEnum",D.ZodEffects="ZodEffects",D.ZodNativeEnum="ZodNativeEnum",D.ZodOptional="ZodOptional",D.ZodNullable="ZodNullable",D.ZodDefault="ZodDefault",D.ZodCatch="ZodCatch",D.ZodPromise="ZodPromise",D.ZodBranded="ZodBranded",D.ZodPipeline="ZodPipeline",D.ZodReadonly="ZodReadonly"})(n||(n={}));V7=Z0.create,E7=E2.create,g_=M3.create,d_=L2.create,L7=LF.create,c_=x2.create,l_=X3.create,p_=wF.create,i_=OF.create,n_=f2.create,s_=V2.create,a_=p0.create,o_=W3.create,r_=R0.create,t_=ID.create,e_=ID.strictCreate,DQ=bF.create,FQ=n3.create,BQ=ZF.create,$Q=i0.create,_Q=G3.create,QQ=z3.create,YQ=h2.create,qQ=EF.create,HQ=RF.create,JQ=NF.create,XQ=w2.create,WQ=SF.create,GQ=m2.create,zQ=k0.create,MQ=N0.create,AQ=_2.create,jQ=k0.createWithPreprocess,KQ=A3.create,LQ={string:(D)=>Z0.create({...D,coerce:!0}),number:(D)=>E2.create({...D,coerce:!0}),boolean:(D)=>LF.create({...D,coerce:!0}),bigint:(D)=>L2.create({...D,coerce:!0}),date:(D)=>x2.create({...D,coerce:!0})},wQ=l});var G={};j2(G,{void:()=>o_,util:()=>QD,unknown:()=>s_,union:()=>DQ,undefined:()=>p_,tuple:()=>$Q,transformer:()=>zQ,symbol:()=>l_,string:()=>V7,strictObject:()=>e_,setErrorMap:()=>A_,set:()=>YQ,record:()=>_Q,quotelessJson:()=>z_,promise:()=>GQ,preprocess:()=>jQ,pipeline:()=>KQ,ostring:()=>UQ,optional:()=>MQ,onumber:()=>VQ,oboolean:()=>EQ,objectUtil:()=>Y1,object:()=>t_,number:()=>E7,nullable:()=>AQ,null:()=>i_,never:()=>a_,nativeEnum:()=>WQ,nan:()=>g_,map:()=>QQ,makeIssue:()=>J3,literal:()=>JQ,lazy:()=>HQ,late:()=>h_,isValid:()=>U2,isDirty:()=>i3,isAsync:()=>UF,isAborted:()=>p3,intersection:()=>BQ,instanceof:()=>m_,getParsedType:()=>l0,getErrorMap:()=>KF,function:()=>qQ,enum:()=>XQ,effect:()=>zQ,discriminatedUnion:()=>FQ,defaultErrorMap:()=>B2,datetimeRegex:()=>j7,date:()=>c_,custom:()=>U7,coerce:()=>LQ,boolean:()=>L7,bigint:()=>d_,array:()=>r_,any:()=>n_,addIssueToContext:()=>T,ZodVoid:()=>W3,ZodUnknown:()=>V2,ZodUnion:()=>bF,ZodUndefined:()=>wF,ZodType:()=>BD,ZodTuple:()=>i0,ZodTransformer:()=>k0,ZodSymbol:()=>X3,ZodString:()=>Z0,ZodSet:()=>h2,ZodSchema:()=>BD,ZodRecord:()=>G3,ZodReadonly:()=>TF,ZodPromise:()=>m2,ZodPipeline:()=>A3,ZodParsedType:()=>I,ZodOptional:()=>N0,ZodObject:()=>ID,ZodNumber:()=>E2,ZodNullable:()=>_2,ZodNull:()=>OF,ZodNever:()=>p0,ZodNativeEnum:()=>SF,ZodNaN:()=>M3,ZodMap:()=>z3,ZodLiteral:()=>NF,ZodLazy:()=>RF,ZodIssueCode:()=>Z,ZodIntersection:()=>ZF,ZodFunction:()=>EF,ZodFirstPartyTypeKind:()=>n,ZodError:()=>lD,ZodEnum:()=>w2,ZodEffects:()=>k0,ZodDiscriminatedUnion:()=>n3,ZodDefault:()=>kF,ZodDate:()=>x2,ZodCatch:()=>IF,ZodBranded:()=>s3,ZodBoolean:()=>LF,ZodBigInt:()=>L2,ZodArray:()=>R0,ZodAny:()=>f2,Schema:()=>BD,ParseStatus:()=>pD,OK:()=>aD,NEVER:()=>wQ,INVALID:()=>l,EMPTY_PATH:()=>j_,DIRTY:()=>y2,BRAND:()=>f_});var W1=V(()=>{l3();H1();X7();H3();w7();c3()});var Q2=V(()=>{W1();W1()});var b7;var O7=V(()=>{b7={name:"ocx",version:"2.0.4",description:"OCX CLI - ShadCN-style registry for OpenCode extensions. Install agents, plugins, skills, and MCP servers.",author:"kdcokenny",license:"MIT",type:"module",main:"./dist/index.js",bin:{ocx:"./dist/index.js"},files:["dist/index.js"],publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/kdcokenny/ocx.git"},homepage:"https://github.com/kdcokenny/ocx#readme",bugs:{url:"https://github.com/kdcokenny/ocx/issues"},keywords:["opencode","cli","extensions","agents","plugins","mcp","shadcn","registry"],engines:{node:">=18"},scripts:{build:"bun run scripts/build.ts","build:binary":"bun run scripts/build-binary.ts",check:"bun check:biome && bun check:types","check:biome":"biome check .","check:types":"tsc --noEmit",dev:"bun run src/index.ts",prepublishOnly:"bun run build",test:"bun test"},dependencies:{commander:"^14.0.0",fuzzysort:"^3.1.0","jsonc-parser":"3.3.1",kleur:"^4.1.5",ora:"^8.2.0",remeda:"^2.33.0",zod:"^3.24.0"},devDependencies:{"@types/bun":"latest"}}});function bQ(D){return`https://${j3}/schemas/v${D}/registry.json`}var j3="ocx.kdco.dev",Z7="kdcokenny/ocx",G1,z1,I0=2,T0,R7;var a3=V(()=>{O7();G1=`https://${j3}/schemas/ocx.json`,z1=`https://${j3}/schemas/registry.json`;T0=bQ(I0),R7=b7.version});var XD,zD,MD,ZD,c,U,g2,dD,d2,vD,v0,CD,O2,vF,C0,CF,M1;var $D=V(()=>{XD={SUCCESS:0,GENERAL:1,NOT_FOUND:66,NETWORK:69,CONFIG:78,INTEGRITY:65,CONFLICT:6};zD=class zD extends Error{code;exitCode;constructor(D,F,B=XD.GENERAL){super(D);this.code=F;this.exitCode=B;this.name="OCXError"}};MD=class MD extends zD{constructor(D){super(D,"NOT_FOUND",XD.NOT_FOUND);this.name="NotFoundError"}};ZD=class ZD extends zD{url;status;statusText;phase;qualifiedName;registryContext;registryName;constructor(D,F){super(D,"NETWORK_ERROR",XD.NETWORK);this.name="NetworkError",this.url=F?.url,this.status=F?.status,this.statusText=F?.statusText,this.phase=F?.phase,this.qualifiedName=F?.qualifiedName,this.registryContext=F?.registryContext,this.registryName=F?.registryName}};c=class c extends zD{constructor(D){super(D,"CONFIG_ERROR",XD.CONFIG);this.name="ConfigError"}};U=class U extends zD{constructor(D){super(D,"VALIDATION_ERROR",XD.GENERAL);this.name="ValidationError"}};g2=class g2 extends zD{details;constructor(D){super("Registry validation failed","VALIDATION_FAILED",XD.CONFIG);this.details=D;this.name="ValidationFailedError"}};dD=class dD extends zD{constructor(D){super(D,"CONFLICT",XD.CONFLICT);this.name="ConflictError"}};d2=class d2 extends zD{component;expected;found;constructor(D,F,B){let $=`Integrity verification failed for "${D}"
18
18
  Expected: ${F}
19
19
  Found: ${B}
20
20
 
@@ -28,41 +28,41 @@ Run 'ocx registry remove ${_}' first, then re-add with the new name.`:`Registry
28
28
  Current: ${F}
29
29
  New: ${B}
30
30
 
31
- Run 'ocx registry remove ${D}' first, then re-add with the new URL.`;super(q,"CONFLICT",XD.CONFLICT);this.registryName=D;this.existingUrl=F;this.newUrl=B;this.targetLabel=$;this.existingName=_;this.name="RegistryExistsError",this.conflictType=Y?"url":"name"}};C0=class C0 extends zD{profile;reason;constructor(D,F){super(`Invalid profile name "${D}": ${F}`,"VALIDATION_ERROR",XD.GENERAL);this.profile=D;this.reason=F;this.name="InvalidProfileNameError"}};CF=class CF extends zD{constructor(){super("Profiles not initialized. Run 'ocx init --global' first.","NOT_FOUND",XD.NOT_FOUND);this.name="ProfilesNotInitializedError"}};W1=class W1 extends zD{profile;localDir;constructor(D,F){super(`Local profile directory unsupported: "${F}"
31
+ Run 'ocx registry remove ${D}' first, then re-add with the new URL.`;super(q,"CONFLICT",XD.CONFLICT);this.registryName=D;this.existingUrl=F;this.newUrl=B;this.targetLabel=$;this.existingName=_;this.name="RegistryExistsError",this.conflictType=Y?"url":"name"}};C0=class C0 extends zD{profile;reason;constructor(D,F){super(`Invalid profile name "${D}": ${F}`,"VALIDATION_ERROR",XD.GENERAL);this.profile=D;this.reason=F;this.name="InvalidProfileNameError"}};CF=class CF extends zD{constructor(){super("Profiles not initialized. Run 'ocx init --global' first.","NOT_FOUND",XD.NOT_FOUND);this.name="ProfilesNotInitializedError"}};M1=class M1 extends zD{profile;localDir;constructor(D,F){super(`Local profile directory unsupported: "${F}"
32
32
 
33
33
  Local profiles are not supported. Profiles must be global only.
34
34
  Remove the local profile directory and use global profiles instead:
35
35
  rm -rf "${F}"
36
- ocx profile show ${D} --global`,"CONFIG_ERROR",XD.CONFIG);this.profile=D;this.localDir=F;this.name="LocalProfileUnsupportedError"}}});import*as j0 from"path";function H0(D,F){if(F.includes("\x00"))throw new aD("Path contains null bytes",F,"null_byte");if(j0.isAbsolute(F)||j0.win32.isAbsolute(F))throw new aD("Path must be relative",F,"absolute_path");if(/^[a-zA-Z]:/.test(F)||F.startsWith("\\\\"))throw new aD("Path contains Windows absolute",F,"windows_absolute");let B=j0.basename(F).toUpperCase().split(".")[0]??"";if(LQ.has(B))throw new aD("Path uses Windows reserved name",F,"windows_reserved");let _=F.normalize("NFC").replace(/\\/g,"/"),Q=j0.resolve(D),Y=j0.resolve(Q,_),q=j0.relative(Q,Y);if(q.startsWith("../")||q.startsWith("..\\")||q===".."||j0.isAbsolute(q))throw new aD("Path escapes base directory",F,"path_traversal");return Y}var aD,LQ;var c2=V(()=>{aD=class aD extends Error{attemptedPath;reason;constructor(D,F,B){super(D);this.attemptedPath=F;this.reason=B;this.name="PathValidationError"}};LQ=new Set(["CON","PRN","AUX","NUL","COM1","COM2","COM3","COM4","COM5","COM6","COM7","COM8","COM9","LPT1","LPT2","LPT3","LPT4","LPT5","LPT6","LPT7","LPT8","LPT9"])});import{isAbsolute as wQ,normalize as R7}from"path";function u0(D){if(!D.includes("/"))throw Error(`Invalid component reference: "${D}". Use format: alias/component`);let F=D.split("/");if(F.length>2)throw Error(`Invalid component reference: "${D}". Too many "/" separators. Use format: alias/component`);let[B,$]=F;if(!B||!$)throw Error(`Invalid component reference: "${D}". Both alias and component are required.`);return{namespace:B,component:$}}function A1(D,F){return`${D}/${F}`}function z1(D){if(wQ(D))throw new U(`Invalid path: "${D}" - absolute paths not allowed`);if(D.startsWith("~"))throw new U(`Invalid path: "${D}" - home directory paths not allowed`);if(R7(D).startsWith(".."))throw new U(`Invalid path: "${D}" - path traversal not allowed`)}function P7(D){return D}function b7(D,F){if(OQ.has(D))throw new U(`Target "${D}" is reserved for installer use`);try{H0("/dummy/base",D)}catch($){if($ instanceof aD)throw new U(`Invalid target "${D}": ${$.message}`);throw $}if(F!=="profile"){let $=R7(D);if(N7.some((Q)=>$===Q||$.startsWith(Q)))throw new U(`Target path '${D}' is protected and cannot be overwritten by registry components`)}}function b2(D,F){if(typeof D==="string"){z1(D);let B=P7(D);return b7(B,F),{path:D,target:B}}return z1(D.path),z1(D.target),b7(D.target,F),D}function x7(D){if(typeof D==="string")return{type:"remote",url:D,enabled:!0};return D}function p2(D){let F;if(D.opencode){let{mcp:B,...$}=D.opencode;F={...$,...B&&{mcp:Object.fromEntries(Object.entries(B).map(([_,Q])=>[_,x7(Q)]))}}}return{...D,files:D.files.map((B)=>b2(B,D.type)),opencode:F}}function PF(D){if(D===null||D===void 0||typeof D!=="object")return null;let F=D;if(!Object.hasOwn(F,"$schema"))return{issue:"legacy-schema-v1",remediation:`This registry uses legacy schema v1 (missing $schema). Set "$schema" to "${T0}".`,supportedMajor:I0};let $=F.$schema;if(typeof $!=="string")return{issue:"invalid-schema-url",remediation:`Registry $schema must be a canonical URL like "${T0}".`,schemaUrl:String($),supportedMajor:I0};if(!$)return{issue:"invalid-schema-url",remediation:`Registry $schema must be a canonical URL like "${T0}".`,schemaUrl:$,supportedMajor:I0};if($===G1)return{issue:"legacy-schema-v1",remediation:`Schema URL "${G1}" is legacy v1. Use "${T0}" instead.`,schemaUrl:$,supportedMajor:I0};let _=$.match(uQ);if(!_)return{issue:"invalid-schema-url",remediation:`Registry $schema must be a canonical URL like "${T0}".`,schemaUrl:$,supportedMajor:I0};let Q=_[1];if(!Q)return{issue:"invalid-schema-url",remediation:`Registry $schema must be a canonical URL like "${T0}".`,schemaUrl:$,supportedMajor:I0};let Y=Number.parseInt(Q,10);if(Y!==I0)return{issue:"unsupported-schema-version",remediation:`Schema major v${Y} is unsupported. Use "${T0}" (v${I0}).`,schemaUrl:$,supportedMajor:I0,detectedMajor:Y};return null}var Ez,a3,M1,Z7,uF,OQ,N7,bQ,RQ,S7,k7,I7,T7,ZQ,NQ,SQ,kQ,IQ,TQ,vQ,CQ,v7,C7,u7,l2,uQ,j3,i2,K3,j1;var P0=V(()=>{_2();s3();$D();c2();Ez=W.string().refine((D)=>D.startsWith("npm:"),{message:'npm specifier must start with "npm:" prefix'}).refine((D)=>{let F=D.slice(4);if(!F)return!1;if(F.includes("..")||F.includes("/./"))return!1;return!0},{message:"Invalid npm specifier format"}),a3=W.string().min(1,"Name cannot be empty").max(64,"Name cannot exceed 64 characters").regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,{message:"Must be lowercase alphanumeric with single hyphen separators (e.g., 'my-component', 'my-plugin'). Cannot start/end with hyphen or have consecutive hyphens."}),M1=W.string().regex(/^[a-z0-9]+(-[a-z0-9]+)*\/[a-z0-9]+(-[a-z0-9]+)*$/,{message:'Must be in format "alias/component" (e.g., "kdco/researcher"). Both parts must be lowercase alphanumeric with hyphens.'});Z7=W.string().refine((D)=>{let F=/^[a-z0-9]+(-[a-z0-9]+)*$/,B=/^[a-z0-9]+(-[a-z0-9]+)*\/[a-z0-9]+(-[a-z0-9]+)*$/;return F.test(D)||B.test(D)},{message:'Dependency must be either a bare name (e.g., "utils") or qualified (e.g., "acme/utils")'}),uF=W.enum(["agent","skill","plugin","command","tool","bundle","profile"]),OQ=new Set([".ocx","ocx.lock"]),N7=[".ocx/","ocx.jsonc","package.json",".git/",".env","node_modules/"],bQ=W.string().min(1,"Target path cannot be empty").refine((D)=>{if(D.startsWith("/")||/^[a-zA-Z]:/.test(D))return!1;if(D.includes("\x00"))return!1;return!0},{message:"Target path must be relative and safe (no absolute paths or null bytes)"}).refine((D)=>{return!N7.some((F)=>D===F||D.startsWith(F))},{message:"Target path is protected and cannot be overwritten by registry components"}),RQ=W.object({clientId:W.string().optional(),scopes:W.array(W.string()).optional(),authUrl:W.string().optional(),tokenUrl:W.string().optional()}),S7=W.object({type:W.enum(["remote","local"]),url:W.string().optional(),command:W.union([W.string(),W.array(W.string())]).optional(),environment:W.record(W.string()).optional(),headers:W.record(W.string()).optional(),oauth:W.union([W.boolean(),RQ]).optional(),enabled:W.boolean().default(!0)}).refine((D)=>{if(D.type==="remote"&&!D.url)return!1;if(D.type==="local"&&!D.command)return!1;return!0},{message:"Remote MCP servers require 'url', local servers require 'command'"}),k7=W.union([W.string(),S7]),I7=W.object({path:W.string().min(1,"File path cannot be empty"),target:W.string().min(1,"Target path cannot be empty")}),T7=W.union([W.string().min(1,"File path cannot be empty"),I7]),ZQ=W.object({api:W.string().optional(),headers:W.record(W.string()).optional(),env:W.record(W.string()).optional(),enabled:W.boolean().optional()}).passthrough(),NQ=W.object({command:W.union([W.string(),W.array(W.string())]).optional(),enabled:W.boolean().optional()}).passthrough(),SQ=W.object({command:W.union([W.string(),W.array(W.string())]).optional(),glob:W.string().optional()}).passthrough(),kQ=W.object({description:W.string().optional(),run:W.string().optional()}).passthrough(),IQ=W.object({disabled:W.boolean().optional()}).passthrough(),TQ=W.object({host:W.string().optional(),port:W.number().optional()}).passthrough(),vQ=W.record(W.string()),CQ=W.object({include:W.array(W.string()).optional(),exclude:W.array(W.string()).optional()}).passthrough(),v7=W.object({model:W.string().optional(),description:W.string().optional(),steps:W.number().int().positive().optional(),maxSteps:W.number().int().positive().optional(),mode:W.enum(["primary","subagent","all"]).optional(),tools:W.record(W.boolean()).optional(),temperature:W.number().optional(),top_p:W.number().optional(),prompt:W.string().optional(),permission:W.record(W.union([W.enum(["ask","allow","deny"]),W.record(W.enum(["ask","allow","deny"]))])).optional(),color:W.string().optional(),disable:W.boolean().optional(),options:W.record(W.any()).optional()}),C7=W.object({bash:W.union([W.enum(["ask","allow","deny"]),W.record(W.enum(["ask","allow","deny"]))]).optional(),edit:W.union([W.enum(["ask","allow","deny"]),W.record(W.enum(["ask","allow","deny"]))]).optional(),mcp:W.record(W.enum(["ask","allow","deny"])).optional()}).catchall(W.union([W.enum(["ask","allow","deny"]),W.record(W.enum(["ask","allow","deny"]))])),u7=W.object({$schema:W.string().optional(),theme:W.string().optional(),logLevel:W.string().optional(),username:W.string().optional(),model:W.string().optional(),small_model:W.string().optional(),default_agent:W.string().optional(),mcp:W.record(k7).optional(),plugin:W.array(W.string()).optional(),tools:W.record(W.boolean()).optional(),agent:W.record(v7).optional(),instructions:W.array(W.string()).optional(),permission:C7.optional(),provider:W.record(ZQ).optional(),lsp:W.record(NQ).optional(),formatter:W.record(SQ).optional(),command:W.record(kQ).optional(),tui:IQ.optional(),server:TQ.optional(),keybind:vQ.optional(),watcher:CQ.optional(),auto_update:W.boolean().optional(),auto_compact:W.boolean().optional(),share:W.union([W.boolean(),W.string()]).optional()}),l2=W.object({name:a3,type:uF,description:W.string().min(1).max(1024),files:W.array(T7).default([]),dependencies:W.array(Z7).default([]),npmDependencies:W.array(W.string()).optional(),npmDevDependencies:W.array(W.string()).optional(),opencode:u7.optional()});uQ=new RegExp(`^https://${A3.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}/schemas/v([1-9]\\d*)/registry\\.json$`);j3=/^\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?(\+[a-zA-Z0-9.-]+)?$/,i2=W.object({$schema:W.string().optional(),name:W.string().min(1,"Registry name cannot be empty"),version:W.string().regex(j3,{message:"Version must be valid semver"}),author:W.string().min(1,"Author cannot be empty"),opencode:W.string().regex(j3,{message:"OpenCode version must be valid semver"}).optional(),ocx:W.string().regex(j3,{message:"OCX version must be valid semver"}).optional(),components:W.array(l2)}).refine((D)=>{let F=new Set(D.components.map((B)=>B.name));for(let B of D.components)for(let $ of B.dependencies)if(!$.includes("/")&&!F.has($))return!1;return!0},{message:"Bare dependencies must reference components that exist in the registry. Use qualified references (e.g., 'other-registry/component') for cross-registry dependencies."}),K3=W.object({name:a3,"dist-tags":W.object({latest:W.string()}),versions:W.record(l2)}),j1=W.object({$schema:W.string().optional(),author:W.string(),opencode:W.string().regex(j3,{message:"OpenCode version must be valid semver"}).optional(),ocx:W.string().regex(j3,{message:"OCX version must be valid semver"}).optional(),components:W.array(W.object({name:a3,type:uF,description:W.string()}))})});import{mkdir as K1}from"fs/promises";import{dirname as PQ,join as i0}from"path";async function U3(D){let{source:F,out:B}=D,$=Bun.file(i0(F,"registry.jsonc")),_=Bun.file(i0(F,"registry.json")),Q=await $.exists(),Y=await _.exists();if(!Q&&!Y)throw new n0("No registry.jsonc or registry.json found in source directory");let H=await(Q?$:_).text(),J=ND(H,[],{allowTrailingComma:!0}),X=PF(J);if(X)throw new n0(`Registry schema compatibility failed (${X.issue})`,[X.remediation,...X.schemaUrl!==void 0?[`Invalid $schema: ${X.schemaUrl}`]:[]]);let z=i2.safeParse(J);if(!z.success){let N=z.error.errors.map((x)=>`${x.path.join(".")}: ${x.message}`);throw new n0("Registry validation failed",N)}let M=z.data,A=[];if(D.dryRun){let N=[];for(let O of M.components){N.push({action:"create",target:`file:components/${O.name}.json`,details:{type:"packument"}});for(let b of O.files){let L=b2(b,O.type),e=i0(F,"files",L.path);if(!await Bun.file(e).exists()){A.push(`${O.name}: Source file not found at ${e}`);continue}N.push({action:"create",target:`file:components/${O.name}/${L.path}`,details:{source:e}})}}N.push({action:"create",target:"file:index.json",details:{type:"registry index"}}),N.push({action:"create",target:"file:.well-known/ocx.json",details:{type:"discovery file"}});let x=N.filter((O)=>O.action==="create").length;return{dryRun:!0,command:"build",wouldPerform:N,validation:{passed:A.length===0,errors:A.length>0?A:void 0},summary:`Would build ${M.components.length} components, ${x} files to ${B}`}}let K=i0(B,"components");await K1(K,{recursive:!0});let j="1.0.0";for(let N of M.components){let x={name:N.name,versions:{[j]:N},"dist-tags":{latest:j}},O=i0(K,`${N.name}.json`);await Bun.write(O,JSON.stringify(x,null,2));for(let b of N.files){let L=b2(b,N.type),e=i0(F,"files",L.path),p=i0(K,N.name,L.path),FD=PQ(p);if(!await Bun.file(e).exists()){A.push(`${N.name}: Source file not found at ${e}`);continue}await K1(FD,{recursive:!0});let KD=Bun.file(e);await Bun.write(p,KD)}}if(A.length>0)throw new n0(`Build failed with ${A.length} errors`,A);let S={$schema:M.$schema,name:M.name,version:M.version,author:M.author,...M.opencode&&{opencode:M.opencode},...M.ocx&&{ocx:M.ocx},components:M.components.map((N)=>({name:N.name,type:N.type,description:N.description}))};await Bun.write(i0(B,"index.json"),JSON.stringify(S,null,2));let Z=i0(B,".well-known");await K1(Z,{recursive:!0});let s={registry:"/index.json"};return await Bun.write(i0(Z,"ocx.json"),JSON.stringify(s,null,2)),{componentsCount:M.components.length,outputPath:B}}var n0;var o3=V(()=>{b0();P0();n0=class n0 extends Error{errors;constructor(D,F=[]){super(D);this.errors=F;this.name="BuildRegistryError"}}});import y7 from"path";function f7(D){return y7.posix.isAbsolute(D)||y7.win32.isAbsolute(D)}var h7=()=>{};var U1;var V1=V(()=>{_2();h7();U1=W.string().refine((D)=>!D.includes("\x00"),"Path cannot contain null bytes").refine((D)=>!D.split(/[/\\]/).some((F)=>F===".."),"Path cannot contain '..'").refine((D)=>!f7(D),"Path must be relative, not absolute")});function xD(D){return D.trim().replace(/\/+$/,"")}import{existsSync as xF}from"fs";import{mkdir as g7}from"fs/promises";import Q2 from"path";function E3(D,F,B,$){return`${xD(D)}::${F}/${B}@${$}`}function Z2(D){if(!D.includes("::"))throw Error(`Invalid canonical ID: "${D}". Expected format: registryUrl::registryName/component@revision`);let[F,B]=D.split("::");if(!B||!F)throw Error(`Invalid canonical ID: "${D}". Expected format: registryUrl::registryName/component@revision`);if(!B.includes("@"))throw Error(`Invalid canonical ID: "${D}". Expected format: registryUrl::registryName/component@revision`);let $=B.indexOf("@");if($===-1)throw Error(`Invalid canonical ID: missing revision in ${D}`);let _=B.slice(0,$),Q=B.slice($+1);if(!_||!Q)throw Error(`Invalid canonical ID: "${D}". Expected format: registryUrl::registryName/component@revision`);if(!_.includes("/"))throw Error(`Invalid canonical ID: "${D}". Component must be qualified (registryName/component)`);let[Y,q]=_.split("/");if(!Y||!q)throw Error(`Invalid canonical ID: "${D}". Both registry name and component name are required`);return{registryUrl:xD(F),registryName:Y,name:q,revision:Q}}function N2(D){let F=Q2.join(D,d7,c7);return{path:F,exists:xF(F)}}async function J0(D){let{path:F,exists:B}=N2(D);if(!B)return null;let _=await Bun.file(F).text(),Q=ND(_,[],{allowTrailingComma:!0});return p7.parse(Q)}async function K0(D,F){let B=Q2.join(D,d7,c7);await g7(Q2.dirname(B),{recursive:!0});let $=JSON.stringify(F,null,2);await Bun.write(B,$)}function S2(D){let F=Q2.join(D,E1,V3),B=Q2.join(D,V3),$=xF(F),_=xF(B);if($&&_)throw Error(`Found ${V3} in both .opencode/ and project root. Please consolidate to one location (recommended: .opencode/${V3})`);if($)return{path:F,exists:!0};if(_)return{path:B,exists:!0};return{path:F,exists:!1}}function yF(D,F){let B=Q2.join(D,E1,m7),$=Q2.join(D,m7);if(F?.isFlattened){if(xF($))return{path:$,exists:!0};return{path:$,exists:!1}}if(xF(B))return{path:B,exists:!0};if(xF($))return{path:$,exists:!0};return{path:B,exists:!1}}async function U0(D,F={}){let{path:B,exists:$}=S2(D);if(!$)return null;let Q=await Bun.file(B).text();try{let Y=ND(Q,[],{allowTrailingComma:!0});return R2.parse(Y)}catch(Y){if(F.emitParseDiagnostics??!0)console.error(`Error parsing ${B}:`,Y);throw Y}}async function e3(D,F,B){let $=B??Q2.join(D,E1,V3);await g7(Q2.dirname($),{recursive:!0});let _=JSON.stringify(F,null,2);await Bun.write($,_)}async function L3(D,F){let{path:B,exists:$}=yF(D,F);if(!$)return null;let Q=await Bun.file(B).text(),Y=ND(Q,[],{allowTrailingComma:!0});return t3.parse(Y)}var r3,R2,d7=".ocx",c7="receipt.jsonc",l7,p7,xQ,yQ,t3,V3="ocx.jsonc",m7="ocx.lock",E1=".opencode";var tD=V(()=>{b0();_2();P0();r3=W.object({url:W.string().url("Registry URL must be a valid URL"),headers:W.record(W.string()).optional()}),R2=W.object({$schema:W.string().optional(),profile:W.string().optional(),registries:W.record(r3).default({}),lockRegistries:W.boolean().default(!1),skipCompatCheck:W.boolean().default(!1)}),l7=W.object({registryUrl:W.string(),registryName:W.string(),name:W.string(),revision:W.string(),hash:W.string(),files:W.array(W.object({path:W.string(),hash:W.string()})),installedAt:W.string(),updatedAt:W.string().optional(),owner:W.object({type:W.enum(["user","profile","system"]),id:W.string().optional()}).optional(),opencode:W.record(W.unknown()).optional()}),p7=W.object({version:W.literal(1),root:W.string().optional(),installed:W.record(W.string(),l7).default({})}),xQ=W.object({registry:W.string(),version:W.string(),hash:W.string(),files:W.array(W.string()),installedAt:W.string(),updatedAt:W.string().optional()}),yQ=W.object({registry:W.string(),component:W.string(),version:W.string().optional(),hash:W.string(),installedAt:W.string()}),t3=W.object({lockVersion:W.literal(1),installedFrom:yQ.optional(),installed:W.record(M1,xQ).default({})})});var{Glob:fQ}=globalThis.Bun;var i7,Y2;var fF=V(()=>{_2();V1();tD();i7=W.string().refine((D)=>{try{return new fQ(D),!0}catch{return!1}},{message:"Invalid glob pattern"}),Y2=W.object({$schema:W.string().optional(),bin:W.string().optional(),registries:W.record(r3).default({}),componentPath:U1.optional(),renameWindow:W.boolean().default(!0).describe("Set terminal/tmux window name when launching OpenCode"),exclude:W.array(i7).default(["**/CLAUDE.md","**/CONTEXT.md","**/.opencode/**","**/opencode.jsonc","**/opencode.json"]).describe("Glob patterns for project files to exclude from OpenCode discovery"),include:W.array(i7).default([]).describe("Glob patterns for project files to include (overrides exclude)")})});var L1=V(()=>{V1();tD();fF();P0()});var w3=d0((hQ)=>{class w1 extends Error{constructor(D,F,B){super(B);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=F,this.exitCode=D,this.nestedError=void 0}}class n7 extends w1{constructor(D){super(1,"commander.invalidArgument",D);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}hQ.CommanderError=w1;hQ.InvalidArgumentError=n7});var D8=d0((lQ)=>{var{InvalidArgumentError:dQ}=w3();class s7{constructor(D,F){switch(this.description=F||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,D[0]){case"<":this.required=!0,this._name=D.slice(1,-1);break;case"[":this.required=!1,this._name=D.slice(1,-1);break;default:this.required=!0,this._name=D;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue(D,F){if(F===this.defaultValue||!Array.isArray(F))return[D];return F.push(D),F}default(D,F){return this.defaultValue=D,this.defaultValueDescription=F,this}argParser(D){return this.parseArg=D,this}choices(D){return this.argChoices=D.slice(),this.parseArg=(F,B)=>{if(!this.argChoices.includes(F))throw new dQ(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(F,B);return F},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function cQ(D){let F=D.name()+(D.variadic===!0?"...":"");return D.required?"<"+F+">":"["+F+"]"}lQ.Argument=s7;lQ.humanReadableArgName=cQ});var O1=d0((sQ)=>{var{humanReadableArgName:nQ}=D8();class a7{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(D){this.helpWidth=this.helpWidth??D.helpWidth??80}visibleCommands(D){let F=D.commands.filter(($)=>!$._hidden),B=D._getHelpCommand();if(B&&!B._hidden)F.push(B);if(this.sortSubcommands)F.sort(($,_)=>{return $.name().localeCompare(_.name())});return F}compareOptions(D,F){let B=($)=>{return $.short?$.short.replace(/^-/,""):$.long.replace(/^--/,"")};return B(D).localeCompare(B(F))}visibleOptions(D){let F=D.options.filter(($)=>!$.hidden),B=D._getHelpOption();if(B&&!B.hidden){let $=B.short&&D._findOption(B.short),_=B.long&&D._findOption(B.long);if(!$&&!_)F.push(B);else if(B.long&&!_)F.push(D.createOption(B.long,B.description));else if(B.short&&!$)F.push(D.createOption(B.short,B.description))}if(this.sortOptions)F.sort(this.compareOptions);return F}visibleGlobalOptions(D){if(!this.showGlobalOptions)return[];let F=[];for(let B=D.parent;B;B=B.parent){let $=B.options.filter((_)=>!_.hidden);F.push(...$)}if(this.sortOptions)F.sort(this.compareOptions);return F}visibleArguments(D){if(D._argsDescription)D.registeredArguments.forEach((F)=>{F.description=F.description||D._argsDescription[F.name()]||""});if(D.registeredArguments.find((F)=>F.description))return D.registeredArguments;return[]}subcommandTerm(D){let F=D.registeredArguments.map((B)=>nQ(B)).join(" ");return D._name+(D._aliases[0]?"|"+D._aliases[0]:"")+(D.options.length?" [options]":"")+(F?" "+F:"")}optionTerm(D){return D.flags}argumentTerm(D){return D.name()}longestSubcommandTermLength(D,F){return F.visibleCommands(D).reduce((B,$)=>{return Math.max(B,this.displayWidth(F.styleSubcommandTerm(F.subcommandTerm($))))},0)}longestOptionTermLength(D,F){return F.visibleOptions(D).reduce((B,$)=>{return Math.max(B,this.displayWidth(F.styleOptionTerm(F.optionTerm($))))},0)}longestGlobalOptionTermLength(D,F){return F.visibleGlobalOptions(D).reduce((B,$)=>{return Math.max(B,this.displayWidth(F.styleOptionTerm(F.optionTerm($))))},0)}longestArgumentTermLength(D,F){return F.visibleArguments(D).reduce((B,$)=>{return Math.max(B,this.displayWidth(F.styleArgumentTerm(F.argumentTerm($))))},0)}commandUsage(D){let F=D._name;if(D._aliases[0])F=F+"|"+D._aliases[0];let B="";for(let $=D.parent;$;$=$.parent)B=$.name()+" "+B;return B+F+" "+D.usage()}commandDescription(D){return D.description()}subcommandDescription(D){return D.summary()||D.description()}optionDescription(D){let F=[];if(D.argChoices)F.push(`choices: ${D.argChoices.map((B)=>JSON.stringify(B)).join(", ")}`);if(D.defaultValue!==void 0){if(D.required||D.optional||D.isBoolean()&&typeof D.defaultValue==="boolean")F.push(`default: ${D.defaultValueDescription||JSON.stringify(D.defaultValue)}`)}if(D.presetArg!==void 0&&D.optional)F.push(`preset: ${JSON.stringify(D.presetArg)}`);if(D.envVar!==void 0)F.push(`env: ${D.envVar}`);if(F.length>0){let B=`(${F.join(", ")})`;if(D.description)return`${D.description} ${B}`;return B}return D.description}argumentDescription(D){let F=[];if(D.argChoices)F.push(`choices: ${D.argChoices.map((B)=>JSON.stringify(B)).join(", ")}`);if(D.defaultValue!==void 0)F.push(`default: ${D.defaultValueDescription||JSON.stringify(D.defaultValue)}`);if(F.length>0){let B=`(${F.join(", ")})`;if(D.description)return`${D.description} ${B}`;return B}return D.description}formatItemList(D,F,B){if(F.length===0)return[];return[B.styleTitle(D),...F,""]}groupItems(D,F,B){let $=new Map;return D.forEach((_)=>{let Q=B(_);if(!$.has(Q))$.set(Q,[])}),F.forEach((_)=>{let Q=B(_);if(!$.has(Q))$.set(Q,[]);$.get(Q).push(_)}),$}formatHelp(D,F){let B=F.padWidth(D,F),$=F.helpWidth??80;function _(X,z){return F.formatItem(X,B,z,F)}let Q=[`${F.styleTitle("Usage:")} ${F.styleUsage(F.commandUsage(D))}`,""],Y=F.commandDescription(D);if(Y.length>0)Q=Q.concat([F.boxWrap(F.styleCommandDescription(Y),$),""]);let q=F.visibleArguments(D).map((X)=>{return _(F.styleArgumentTerm(F.argumentTerm(X)),F.styleArgumentDescription(F.argumentDescription(X)))});if(Q=Q.concat(this.formatItemList("Arguments:",q,F)),this.groupItems(D.options,F.visibleOptions(D),(X)=>X.helpGroupHeading??"Options:").forEach((X,z)=>{let M=X.map((A)=>{return _(F.styleOptionTerm(F.optionTerm(A)),F.styleOptionDescription(F.optionDescription(A)))});Q=Q.concat(this.formatItemList(z,M,F))}),F.showGlobalOptions){let X=F.visibleGlobalOptions(D).map((z)=>{return _(F.styleOptionTerm(F.optionTerm(z)),F.styleOptionDescription(F.optionDescription(z)))});Q=Q.concat(this.formatItemList("Global Options:",X,F))}return this.groupItems(D.commands,F.visibleCommands(D),(X)=>X.helpGroup()||"Commands:").forEach((X,z)=>{let M=X.map((A)=>{return _(F.styleSubcommandTerm(F.subcommandTerm(A)),F.styleSubcommandDescription(F.subcommandDescription(A)))});Q=Q.concat(this.formatItemList(z,M,F))}),Q.join(`
37
- `)}displayWidth(D){return o7(D).length}styleTitle(D){return D}styleUsage(D){return D.split(" ").map((F)=>{if(F==="[options]")return this.styleOptionText(F);if(F==="[command]")return this.styleSubcommandText(F);if(F[0]==="["||F[0]==="<")return this.styleArgumentText(F);return this.styleCommandText(F)}).join(" ")}styleCommandDescription(D){return this.styleDescriptionText(D)}styleOptionDescription(D){return this.styleDescriptionText(D)}styleSubcommandDescription(D){return this.styleDescriptionText(D)}styleArgumentDescription(D){return this.styleDescriptionText(D)}styleDescriptionText(D){return D}styleOptionTerm(D){return this.styleOptionText(D)}styleSubcommandTerm(D){return D.split(" ").map((F)=>{if(F==="[options]")return this.styleOptionText(F);if(F[0]==="["||F[0]==="<")return this.styleArgumentText(F);return this.styleSubcommandText(F)}).join(" ")}styleArgumentTerm(D){return this.styleArgumentText(D)}styleOptionText(D){return D}styleArgumentText(D){return D}styleSubcommandText(D){return D}styleCommandText(D){return D}padWidth(D,F){return Math.max(F.longestOptionTermLength(D,F),F.longestGlobalOptionTermLength(D,F),F.longestSubcommandTermLength(D,F),F.longestArgumentTermLength(D,F))}preformatted(D){return/\n[^\S\r\n]/.test(D)}formatItem(D,F,B,$){let Q=" ".repeat(2);if(!B)return Q+D;let Y=D.padEnd(F+D.length-$.displayWidth(D)),q=2,J=(this.helpWidth??80)-F-q-2,X;if(J<this.minWidthToWrap||$.preformatted(B))X=B;else X=$.boxWrap(B,J).replace(/\n/g,`
36
+ ocx profile show ${D} --global`,"CONFIG_ERROR",XD.CONFIG);this.profile=D;this.localDir=F;this.name="LocalProfileUnsupportedError"}}});import*as A0 from"path";function J0(D,F){if(F.includes("\x00"))throw new oD("Path contains null bytes",F,"null_byte");if(A0.isAbsolute(F)||A0.win32.isAbsolute(F))throw new oD("Path must be relative",F,"absolute_path");if(/^[a-zA-Z]:/.test(F)||F.startsWith("\\\\"))throw new oD("Path contains Windows absolute",F,"windows_absolute");let B=A0.basename(F).toUpperCase().split(".")[0]??"";if(ZQ.has(B))throw new oD("Path uses Windows reserved name",F,"windows_reserved");let _=F.normalize("NFC").replace(/\\/g,"/"),Q=A0.resolve(D),Y=A0.resolve(Q,_),q=A0.relative(Q,Y);if(q.startsWith("../")||q.startsWith("..\\")||q===".."||A0.isAbsolute(q))throw new oD("Path escapes base directory",F,"path_traversal");return Y}var oD,ZQ;var c2=V(()=>{oD=class oD extends Error{attemptedPath;reason;constructor(D,F,B){super(D);this.attemptedPath=F;this.reason=B;this.name="PathValidationError"}};ZQ=new Set(["CON","PRN","AUX","NUL","COM1","COM2","COM3","COM4","COM5","COM6","COM7","COM8","COM9","LPT1","LPT2","LPT3","LPT4","LPT5","LPT6","LPT7","LPT8","LPT9"])});import{isAbsolute as RQ,normalize as S7}from"path";function u0(D){if(!D.includes("/"))throw Error(`Invalid component reference: "${D}". Use format: alias/component`);let F=D.split("/");if(F.length>2)throw Error(`Invalid component reference: "${D}". Too many "/" separators. Use format: alias/component`);let[B,$]=F;if(!B||!$)throw Error(`Invalid component reference: "${D}". Both alias and component are required.`);return{namespace:B,component:$}}function K1(D,F){return`${D}/${F}`}function A1(D){if(RQ(D))throw new U(`Invalid path: "${D}" - absolute paths not allowed`);if(D.startsWith("~"))throw new U(`Invalid path: "${D}" - home directory paths not allowed`);if(S7(D).startsWith(".."))throw new U(`Invalid path: "${D}" - path traversal not allowed`)}function f7(D){return D}function N7(D,F){if(NQ.has(D))throw new U(`Target "${D}" is reserved for installer use`);try{J0("/dummy/base",D)}catch($){if($ instanceof oD)throw new U(`Invalid target "${D}": ${$.message}`);throw $}if(F!=="profile"){let $=S7(D);if(I7.some((Q)=>$===Q||$.startsWith(Q)))throw new U(`Target path '${D}' is protected and cannot be overwritten by registry components`)}}function b2(D,F){if(typeof D==="string"){A1(D);let B=f7(D);return N7(B,F),{path:D,target:B}}return A1(D.path),A1(D.target),N7(D.target,F),D}function h7(D){if(typeof D==="string")return{type:"remote",url:D,enabled:!0};return D}function p2(D){let F;if(D.opencode){let{mcp:B,...$}=D.opencode;F={...$,...B&&{mcp:Object.fromEntries(Object.entries(B).map(([_,Q])=>[_,h7(Q)]))}}}return{...D,files:D.files.map((B)=>b2(B,D.type)),opencode:F}}function PF(D){if(D===null||D===void 0||typeof D!=="object")return null;let F=D;if(!Object.hasOwn(F,"$schema"))return{issue:"legacy-schema-v1",remediation:`This registry uses legacy schema v1 (missing $schema). Set "$schema" to "${T0}".`,supportedMajor:I0};let $=F.$schema;if(typeof $!=="string")return{issue:"invalid-schema-url",remediation:`Registry $schema must be a canonical URL like "${T0}".`,schemaUrl:String($),supportedMajor:I0};if(!$)return{issue:"invalid-schema-url",remediation:`Registry $schema must be a canonical URL like "${T0}".`,schemaUrl:$,supportedMajor:I0};if($===z1)return{issue:"legacy-schema-v1",remediation:`Schema URL "${z1}" is legacy v1. Use "${T0}" instead.`,schemaUrl:$,supportedMajor:I0};let _=$.match(fQ);if(!_)return{issue:"invalid-schema-url",remediation:`Registry $schema must be a canonical URL like "${T0}".`,schemaUrl:$,supportedMajor:I0};let Q=_[1];if(!Q)return{issue:"invalid-schema-url",remediation:`Registry $schema must be a canonical URL like "${T0}".`,schemaUrl:$,supportedMajor:I0};let Y=Number.parseInt(Q,10);if(Y!==I0)return{issue:"unsupported-schema-version",remediation:`Schema major v${Y} is unsupported. Use "${T0}" (v${I0}).`,schemaUrl:$,supportedMajor:I0,detectedMajor:Y};return null}var Nz,o3,j1,k7,uF,NQ,I7,SQ,kQ,T7,v7,C7,u7,IQ,TQ,vQ,CQ,uQ,PQ,yQ,xQ,P7,y7,x7,l2,fQ,K3,i2,U3,U1;var P0=V(()=>{Q2();a3();$D();c2();Nz=G.string().refine((D)=>D.startsWith("npm:"),{message:'npm specifier must start with "npm:" prefix'}).refine((D)=>{let F=D.slice(4);if(!F)return!1;if(F.includes("..")||F.includes("/./"))return!1;return!0},{message:"Invalid npm specifier format"}),o3=G.string().min(1,"Name cannot be empty").max(64,"Name cannot exceed 64 characters").regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,{message:"Must be lowercase alphanumeric with single hyphen separators (e.g., 'my-component', 'my-plugin'). Cannot start/end with hyphen or have consecutive hyphens."}),j1=G.string().regex(/^[a-z0-9]+(-[a-z0-9]+)*\/[a-z0-9]+(-[a-z0-9]+)*$/,{message:'Must be in format "alias/component" (e.g., "kdco/researcher"). Both parts must be lowercase alphanumeric with hyphens.'});k7=G.string().refine((D)=>{let F=/^[a-z0-9]+(-[a-z0-9]+)*$/,B=/^[a-z0-9]+(-[a-z0-9]+)*\/[a-z0-9]+(-[a-z0-9]+)*$/;return F.test(D)||B.test(D)},{message:'Dependency must be either a bare name (e.g., "utils") or qualified (e.g., "acme/utils")'}),uF=G.enum(["agent","skill","plugin","command","tool","bundle","profile"]),NQ=new Set([".ocx","ocx.lock"]),I7=[".ocx/","ocx.jsonc","package.json",".git/",".env","node_modules/"],SQ=G.string().min(1,"Target path cannot be empty").refine((D)=>{if(D.startsWith("/")||/^[a-zA-Z]:/.test(D))return!1;if(D.includes("\x00"))return!1;return!0},{message:"Target path must be relative and safe (no absolute paths or null bytes)"}).refine((D)=>{return!I7.some((F)=>D===F||D.startsWith(F))},{message:"Target path is protected and cannot be overwritten by registry components"}),kQ=G.object({clientId:G.string().optional(),scopes:G.array(G.string()).optional(),authUrl:G.string().optional(),tokenUrl:G.string().optional()}),T7=G.object({type:G.enum(["remote","local"]),url:G.string().optional(),command:G.union([G.string(),G.array(G.string())]).optional(),environment:G.record(G.string()).optional(),headers:G.record(G.string()).optional(),oauth:G.union([G.boolean(),kQ]).optional(),enabled:G.boolean().default(!0)}).refine((D)=>{if(D.type==="remote"&&!D.url)return!1;if(D.type==="local"&&!D.command)return!1;return!0},{message:"Remote MCP servers require 'url', local servers require 'command'"}),v7=G.union([G.string(),T7]),C7=G.object({path:G.string().min(1,"File path cannot be empty"),target:G.string().min(1,"Target path cannot be empty")}),u7=G.union([G.string().min(1,"File path cannot be empty"),C7]),IQ=G.object({api:G.string().optional(),headers:G.record(G.string()).optional(),env:G.record(G.string()).optional(),enabled:G.boolean().optional()}).passthrough(),TQ=G.object({command:G.union([G.string(),G.array(G.string())]).optional(),enabled:G.boolean().optional()}).passthrough(),vQ=G.object({command:G.union([G.string(),G.array(G.string())]).optional(),glob:G.string().optional()}).passthrough(),CQ=G.object({description:G.string().optional(),run:G.string().optional()}).passthrough(),uQ=G.object({disabled:G.boolean().optional()}).passthrough(),PQ=G.object({host:G.string().optional(),port:G.number().optional()}).passthrough(),yQ=G.record(G.string()),xQ=G.object({include:G.array(G.string()).optional(),exclude:G.array(G.string()).optional()}).passthrough(),P7=G.object({model:G.string().optional(),description:G.string().optional(),steps:G.number().int().positive().optional(),maxSteps:G.number().int().positive().optional(),mode:G.enum(["primary","subagent","all"]).optional(),tools:G.record(G.boolean()).optional(),temperature:G.number().optional(),top_p:G.number().optional(),prompt:G.string().optional(),permission:G.record(G.union([G.enum(["ask","allow","deny"]),G.record(G.enum(["ask","allow","deny"]))])).optional(),color:G.string().optional(),disable:G.boolean().optional(),options:G.record(G.any()).optional()}),y7=G.object({bash:G.union([G.enum(["ask","allow","deny"]),G.record(G.enum(["ask","allow","deny"]))]).optional(),edit:G.union([G.enum(["ask","allow","deny"]),G.record(G.enum(["ask","allow","deny"]))]).optional(),mcp:G.record(G.enum(["ask","allow","deny"])).optional()}).catchall(G.union([G.enum(["ask","allow","deny"]),G.record(G.enum(["ask","allow","deny"]))])),x7=G.object({$schema:G.string().optional(),theme:G.string().optional(),logLevel:G.string().optional(),username:G.string().optional(),model:G.string().optional(),small_model:G.string().optional(),default_agent:G.string().optional(),mcp:G.record(v7).optional(),plugin:G.array(G.string()).optional(),tools:G.record(G.boolean()).optional(),agent:G.record(P7).optional(),instructions:G.array(G.string()).optional(),permission:y7.optional(),provider:G.record(IQ).optional(),lsp:G.record(TQ).optional(),formatter:G.record(vQ).optional(),command:G.record(CQ).optional(),tui:uQ.optional(),server:PQ.optional(),keybind:yQ.optional(),watcher:xQ.optional(),auto_update:G.boolean().optional(),auto_compact:G.boolean().optional(),share:G.union([G.boolean(),G.string()]).optional()}),l2=G.object({name:o3,type:uF,description:G.string().min(1).max(1024),files:G.array(u7).default([]),dependencies:G.array(k7).default([]),npmDependencies:G.array(G.string()).optional(),npmDevDependencies:G.array(G.string()).optional(),opencode:x7.optional()});fQ=new RegExp(`^https://${j3.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}/schemas/v([1-9]\\d*)/registry\\.json$`);K3=/^\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?(\+[a-zA-Z0-9.-]+)?$/,i2=G.object({$schema:G.string().optional(),name:G.string().min(1,"Registry name cannot be empty"),version:G.string().regex(K3,{message:"Version must be valid semver"}),author:G.string().min(1,"Author cannot be empty"),opencode:G.string().regex(K3,{message:"OpenCode version must be valid semver"}).optional(),ocx:G.string().regex(K3,{message:"OCX version must be valid semver"}).optional(),components:G.array(l2)}).refine((D)=>{let F=new Set(D.components.map((B)=>B.name));for(let B of D.components)for(let $ of B.dependencies)if(!$.includes("/")&&!F.has($))return!1;return!0},{message:"Bare dependencies must reference components that exist in the registry. Use qualified references (e.g., 'other-registry/component') for cross-registry dependencies."}),U3=G.object({name:o3,"dist-tags":G.object({latest:G.string()}),versions:G.record(l2)}),U1=G.object({$schema:G.string().optional(),author:G.string(),opencode:G.string().regex(K3,{message:"OpenCode version must be valid semver"}).optional(),ocx:G.string().regex(K3,{message:"OCX version must be valid semver"}).optional(),components:G.array(G.object({name:o3,type:uF,description:G.string()}))})});import{mkdir as V1}from"fs/promises";import{dirname as hQ,join as n0}from"path";async function V3(D){let{source:F,out:B}=D,$=Bun.file(n0(F,"registry.jsonc")),_=Bun.file(n0(F,"registry.json")),Q=await $.exists(),Y=await _.exists();if(!Q&&!Y)throw new s0("No registry.jsonc or registry.json found in source directory");let H=await(Q?$:_).text(),J=ND(H,[],{allowTrailingComma:!0}),X=PF(J);if(X)throw new s0(`Registry schema compatibility failed (${X.issue})`,[X.remediation,...X.schemaUrl!==void 0?[`Invalid $schema: ${X.schemaUrl}`]:[]]);let z=i2.safeParse(J);if(!z.success){let N=z.error.errors.map((y)=>`${y.path.join(".")}: ${y.message}`);throw new s0("Registry validation failed",N)}let M=z.data,A=[];if(D.dryRun){let N=[];for(let O of M.components){N.push({action:"create",target:`file:components/${O.name}.json`,details:{type:"packument"}});for(let b of O.files){let L=b2(b,O.type),e=n0(F,"files",L.path);if(!await Bun.file(e).exists()){A.push(`${O.name}: Source file not found at ${e}`);continue}N.push({action:"create",target:`file:components/${O.name}/${L.path}`,details:{source:e}})}}N.push({action:"create",target:"file:index.json",details:{type:"registry index"}}),N.push({action:"create",target:"file:.well-known/ocx.json",details:{type:"discovery file"}});let y=N.filter((O)=>O.action==="create").length;return{dryRun:!0,command:"build",wouldPerform:N,validation:{passed:A.length===0,errors:A.length>0?A:void 0},summary:`Would build ${M.components.length} components, ${y} files to ${B}`}}let K=n0(B,"components");await V1(K,{recursive:!0});let j="1.0.0";for(let N of M.components){let y={name:N.name,versions:{[j]:N},"dist-tags":{latest:j}},O=n0(K,`${N.name}.json`);await Bun.write(O,JSON.stringify(y,null,2));for(let b of N.files){let L=b2(b,N.type),e=n0(F,"files",L.path),p=n0(K,N.name,L.path),FD=hQ(p);if(!await Bun.file(e).exists()){A.push(`${N.name}: Source file not found at ${e}`);continue}await V1(FD,{recursive:!0});let KD=Bun.file(e);await Bun.write(p,KD)}}if(A.length>0)throw new s0(`Build failed with ${A.length} errors`,A);let S={$schema:M.$schema,name:M.name,version:M.version,author:M.author,...M.opencode&&{opencode:M.opencode},...M.ocx&&{ocx:M.ocx},components:M.components.map((N)=>({name:N.name,type:N.type,description:N.description}))};await Bun.write(n0(B,"index.json"),JSON.stringify(S,null,2));let R=n0(B,".well-known");await V1(R,{recursive:!0});let s={registry:"/index.json"};return await Bun.write(n0(R,"ocx.json"),JSON.stringify(s,null,2)),{componentsCount:M.components.length,outputPath:B}}var s0;var r3=V(()=>{b0();P0();s0=class s0 extends Error{errors;constructor(D,F=[]){super(D);this.errors=F;this.name="BuildRegistryError"}}});import m7 from"path";function g7(D){return m7.posix.isAbsolute(D)||m7.win32.isAbsolute(D)}var d7=()=>{};var E1;var L1=V(()=>{Q2();d7();E1=G.string().refine((D)=>!D.includes("\x00"),"Path cannot contain null bytes").refine((D)=>!D.split(/[/\\]/).some((F)=>F===".."),"Path cannot contain '..'").refine((D)=>!g7(D),"Path must be relative, not absolute")});function xD(D){return D.trim().replace(/\/+$/,"")}import{existsSync as yF}from"fs";import{mkdir as l7}from"fs/promises";import Y2 from"path";function L3(D,F,B,$){return`${xD(D)}::${F}/${B}@${$}`}function R2(D){if(!D.includes("::"))throw Error(`Invalid canonical ID: "${D}". Expected format: registryUrl::registryName/component@revision`);let[F,B]=D.split("::");if(!B||!F)throw Error(`Invalid canonical ID: "${D}". Expected format: registryUrl::registryName/component@revision`);if(!B.includes("@"))throw Error(`Invalid canonical ID: "${D}". Expected format: registryUrl::registryName/component@revision`);let $=B.indexOf("@");if($===-1)throw Error(`Invalid canonical ID: missing revision in ${D}`);let _=B.slice(0,$),Q=B.slice($+1);if(!_||!Q)throw Error(`Invalid canonical ID: "${D}". Expected format: registryUrl::registryName/component@revision`);if(!_.includes("/"))throw Error(`Invalid canonical ID: "${D}". Component must be qualified (registryName/component)`);let[Y,q]=_.split("/");if(!Y||!q)throw Error(`Invalid canonical ID: "${D}". Both registry name and component name are required`);return{registryUrl:xD(F),registryName:Y,name:q,revision:Q}}function N2(D){let F=Y2.join(D,p7,i7);return{path:F,exists:yF(F)}}async function X0(D){let{path:F,exists:B}=N2(D);if(!B)return null;let _=await Bun.file(F).text(),Q=ND(_,[],{allowTrailingComma:!0});return s7.parse(Q)}async function j0(D,F){let B=Y2.join(D,p7,i7);await l7(Y2.dirname(B),{recursive:!0});let $=JSON.stringify(F,null,2);await Bun.write(B,$)}function S2(D){let F=Y2.join(D,w1,E3),B=Y2.join(D,E3),$=yF(F),_=yF(B);if($&&_)throw Error(`Found ${E3} in both .opencode/ and project root. Please consolidate to one location (recommended: .opencode/${E3})`);if($)return{path:F,exists:!0};if(_)return{path:B,exists:!0};return{path:F,exists:!1}}function xF(D,F){let B=Y2.join(D,w1,c7),$=Y2.join(D,c7);if(F?.isFlattened){if(yF($))return{path:$,exists:!0};return{path:$,exists:!1}}if(yF(B))return{path:B,exists:!0};if(yF($))return{path:$,exists:!0};return{path:B,exists:!1}}async function K0(D,F={}){let{path:B,exists:$}=S2(D);if(!$)return null;let Q=await Bun.file(B).text();try{let Y=ND(Q,[],{allowTrailingComma:!0});return Z2.parse(Y)}catch(Y){if(F.emitParseDiagnostics??!0)console.error(`Error parsing ${B}:`,Y);throw Y}}async function D8(D,F,B){let $=B??Y2.join(D,w1,E3);await l7(Y2.dirname($),{recursive:!0});let _=JSON.stringify(F,null,2);await Bun.write($,_)}async function w3(D,F){let{path:B,exists:$}=xF(D,F);if(!$)return null;let Q=await Bun.file(B).text(),Y=ND(Q,[],{allowTrailingComma:!0});return e3.parse(Y)}var t3,Z2,p7=".ocx",i7="receipt.jsonc",n7,s7,mQ,gQ,e3,E3="ocx.jsonc",c7="ocx.lock",w1=".opencode";var eD=V(()=>{b0();Q2();P0();t3=G.object({url:G.string().url("Registry URL must be a valid URL"),headers:G.record(G.string()).optional()}),Z2=G.object({$schema:G.string().optional(),profile:G.string().optional(),registries:G.record(t3).default({}),lockRegistries:G.boolean().default(!1),skipCompatCheck:G.boolean().default(!1)}),n7=G.object({registryUrl:G.string(),registryName:G.string(),name:G.string(),revision:G.string(),hash:G.string(),files:G.array(G.object({path:G.string(),hash:G.string()})),installedAt:G.string(),updatedAt:G.string().optional(),owner:G.object({type:G.enum(["user","profile","system"]),id:G.string().optional()}).optional(),opencode:G.record(G.unknown()).optional()}),s7=G.object({version:G.literal(1),root:G.string().optional(),installed:G.record(G.string(),n7).default({})}),mQ=G.object({registry:G.string(),version:G.string(),hash:G.string(),files:G.array(G.string()),installedAt:G.string(),updatedAt:G.string().optional()}),gQ=G.object({registry:G.string(),component:G.string(),version:G.string().optional(),hash:G.string(),installedAt:G.string()}),e3=G.object({lockVersion:G.literal(1),installedFrom:gQ.optional(),installed:G.record(j1,mQ).default({})})});var{Glob:dQ}=globalThis.Bun;var a7,q2;var fF=V(()=>{Q2();L1();eD();a7=G.string().refine((D)=>{try{return new dQ(D),!0}catch{return!1}},{message:"Invalid glob pattern"}),q2=G.object({$schema:G.string().optional(),bin:G.string().optional(),registries:G.record(t3).default({}),componentPath:E1.optional(),renameWindow:G.boolean().default(!0).describe("Set terminal/tmux window name when launching OpenCode"),exclude:G.array(a7).default(["**/CLAUDE.md","**/CONTEXT.md","**/.opencode/**","**/opencode.jsonc","**/opencode.json"]).describe("Glob patterns for project files to exclude from OpenCode discovery"),include:G.array(a7).default([]).describe("Glob patterns for project files to include (overrides exclude)")})});var O1=V(()=>{L1();eD();fF();P0()});var O3=c0((cQ)=>{class b1 extends Error{constructor(D,F,B){super(B);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=F,this.exitCode=D,this.nestedError=void 0}}class o7 extends b1{constructor(D){super(1,"commander.invalidArgument",D);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}cQ.CommanderError=b1;cQ.InvalidArgumentError=o7});var F8=c0((sQ)=>{var{InvalidArgumentError:iQ}=O3();class r7{constructor(D,F){switch(this.description=F||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,D[0]){case"<":this.required=!0,this._name=D.slice(1,-1);break;case"[":this.required=!1,this._name=D.slice(1,-1);break;default:this.required=!0,this._name=D;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue(D,F){if(F===this.defaultValue||!Array.isArray(F))return[D];return F.push(D),F}default(D,F){return this.defaultValue=D,this.defaultValueDescription=F,this}argParser(D){return this.parseArg=D,this}choices(D){return this.argChoices=D.slice(),this.parseArg=(F,B)=>{if(!this.argChoices.includes(F))throw new iQ(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(F,B);return F},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function nQ(D){let F=D.name()+(D.variadic===!0?"...":"");return D.required?"<"+F+">":"["+F+"]"}sQ.Argument=r7;sQ.humanReadableArgName=nQ});var Z1=c0((tQ)=>{var{humanReadableArgName:rQ}=F8();class t7{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(D){this.helpWidth=this.helpWidth??D.helpWidth??80}visibleCommands(D){let F=D.commands.filter(($)=>!$._hidden),B=D._getHelpCommand();if(B&&!B._hidden)F.push(B);if(this.sortSubcommands)F.sort(($,_)=>{return $.name().localeCompare(_.name())});return F}compareOptions(D,F){let B=($)=>{return $.short?$.short.replace(/^-/,""):$.long.replace(/^--/,"")};return B(D).localeCompare(B(F))}visibleOptions(D){let F=D.options.filter(($)=>!$.hidden),B=D._getHelpOption();if(B&&!B.hidden){let $=B.short&&D._findOption(B.short),_=B.long&&D._findOption(B.long);if(!$&&!_)F.push(B);else if(B.long&&!_)F.push(D.createOption(B.long,B.description));else if(B.short&&!$)F.push(D.createOption(B.short,B.description))}if(this.sortOptions)F.sort(this.compareOptions);return F}visibleGlobalOptions(D){if(!this.showGlobalOptions)return[];let F=[];for(let B=D.parent;B;B=B.parent){let $=B.options.filter((_)=>!_.hidden);F.push(...$)}if(this.sortOptions)F.sort(this.compareOptions);return F}visibleArguments(D){if(D._argsDescription)D.registeredArguments.forEach((F)=>{F.description=F.description||D._argsDescription[F.name()]||""});if(D.registeredArguments.find((F)=>F.description))return D.registeredArguments;return[]}subcommandTerm(D){let F=D.registeredArguments.map((B)=>rQ(B)).join(" ");return D._name+(D._aliases[0]?"|"+D._aliases[0]:"")+(D.options.length?" [options]":"")+(F?" "+F:"")}optionTerm(D){return D.flags}argumentTerm(D){return D.name()}longestSubcommandTermLength(D,F){return F.visibleCommands(D).reduce((B,$)=>{return Math.max(B,this.displayWidth(F.styleSubcommandTerm(F.subcommandTerm($))))},0)}longestOptionTermLength(D,F){return F.visibleOptions(D).reduce((B,$)=>{return Math.max(B,this.displayWidth(F.styleOptionTerm(F.optionTerm($))))},0)}longestGlobalOptionTermLength(D,F){return F.visibleGlobalOptions(D).reduce((B,$)=>{return Math.max(B,this.displayWidth(F.styleOptionTerm(F.optionTerm($))))},0)}longestArgumentTermLength(D,F){return F.visibleArguments(D).reduce((B,$)=>{return Math.max(B,this.displayWidth(F.styleArgumentTerm(F.argumentTerm($))))},0)}commandUsage(D){let F=D._name;if(D._aliases[0])F=F+"|"+D._aliases[0];let B="";for(let $=D.parent;$;$=$.parent)B=$.name()+" "+B;return B+F+" "+D.usage()}commandDescription(D){return D.description()}subcommandDescription(D){return D.summary()||D.description()}optionDescription(D){let F=[];if(D.argChoices)F.push(`choices: ${D.argChoices.map((B)=>JSON.stringify(B)).join(", ")}`);if(D.defaultValue!==void 0){if(D.required||D.optional||D.isBoolean()&&typeof D.defaultValue==="boolean")F.push(`default: ${D.defaultValueDescription||JSON.stringify(D.defaultValue)}`)}if(D.presetArg!==void 0&&D.optional)F.push(`preset: ${JSON.stringify(D.presetArg)}`);if(D.envVar!==void 0)F.push(`env: ${D.envVar}`);if(F.length>0){let B=`(${F.join(", ")})`;if(D.description)return`${D.description} ${B}`;return B}return D.description}argumentDescription(D){let F=[];if(D.argChoices)F.push(`choices: ${D.argChoices.map((B)=>JSON.stringify(B)).join(", ")}`);if(D.defaultValue!==void 0)F.push(`default: ${D.defaultValueDescription||JSON.stringify(D.defaultValue)}`);if(F.length>0){let B=`(${F.join(", ")})`;if(D.description)return`${D.description} ${B}`;return B}return D.description}formatItemList(D,F,B){if(F.length===0)return[];return[B.styleTitle(D),...F,""]}groupItems(D,F,B){let $=new Map;return D.forEach((_)=>{let Q=B(_);if(!$.has(Q))$.set(Q,[])}),F.forEach((_)=>{let Q=B(_);if(!$.has(Q))$.set(Q,[]);$.get(Q).push(_)}),$}formatHelp(D,F){let B=F.padWidth(D,F),$=F.helpWidth??80;function _(X,z){return F.formatItem(X,B,z,F)}let Q=[`${F.styleTitle("Usage:")} ${F.styleUsage(F.commandUsage(D))}`,""],Y=F.commandDescription(D);if(Y.length>0)Q=Q.concat([F.boxWrap(F.styleCommandDescription(Y),$),""]);let q=F.visibleArguments(D).map((X)=>{return _(F.styleArgumentTerm(F.argumentTerm(X)),F.styleArgumentDescription(F.argumentDescription(X)))});if(Q=Q.concat(this.formatItemList("Arguments:",q,F)),this.groupItems(D.options,F.visibleOptions(D),(X)=>X.helpGroupHeading??"Options:").forEach((X,z)=>{let M=X.map((A)=>{return _(F.styleOptionTerm(F.optionTerm(A)),F.styleOptionDescription(F.optionDescription(A)))});Q=Q.concat(this.formatItemList(z,M,F))}),F.showGlobalOptions){let X=F.visibleGlobalOptions(D).map((z)=>{return _(F.styleOptionTerm(F.optionTerm(z)),F.styleOptionDescription(F.optionDescription(z)))});Q=Q.concat(this.formatItemList("Global Options:",X,F))}return this.groupItems(D.commands,F.visibleCommands(D),(X)=>X.helpGroup()||"Commands:").forEach((X,z)=>{let M=X.map((A)=>{return _(F.styleSubcommandTerm(F.subcommandTerm(A)),F.styleSubcommandDescription(F.subcommandDescription(A)))});Q=Q.concat(this.formatItemList(z,M,F))}),Q.join(`
37
+ `)}displayWidth(D){return e7(D).length}styleTitle(D){return D}styleUsage(D){return D.split(" ").map((F)=>{if(F==="[options]")return this.styleOptionText(F);if(F==="[command]")return this.styleSubcommandText(F);if(F[0]==="["||F[0]==="<")return this.styleArgumentText(F);return this.styleCommandText(F)}).join(" ")}styleCommandDescription(D){return this.styleDescriptionText(D)}styleOptionDescription(D){return this.styleDescriptionText(D)}styleSubcommandDescription(D){return this.styleDescriptionText(D)}styleArgumentDescription(D){return this.styleDescriptionText(D)}styleDescriptionText(D){return D}styleOptionTerm(D){return this.styleOptionText(D)}styleSubcommandTerm(D){return D.split(" ").map((F)=>{if(F==="[options]")return this.styleOptionText(F);if(F[0]==="["||F[0]==="<")return this.styleArgumentText(F);return this.styleSubcommandText(F)}).join(" ")}styleArgumentTerm(D){return this.styleArgumentText(D)}styleOptionText(D){return D}styleArgumentText(D){return D}styleSubcommandText(D){return D}styleCommandText(D){return D}padWidth(D,F){return Math.max(F.longestOptionTermLength(D,F),F.longestGlobalOptionTermLength(D,F),F.longestSubcommandTermLength(D,F),F.longestArgumentTermLength(D,F))}preformatted(D){return/\n[^\S\r\n]/.test(D)}formatItem(D,F,B,$){let Q=" ".repeat(2);if(!B)return Q+D;let Y=D.padEnd(F+D.length-$.displayWidth(D)),q=2,J=(this.helpWidth??80)-F-q-2,X;if(J<this.minWidthToWrap||$.preformatted(B))X=B;else X=$.boxWrap(B,J).replace(/\n/g,`
38
38
  `+" ".repeat(F+q));return Q+Y+" ".repeat(q)+X.replace(/\n/g,`
39
39
  ${Q}`)}boxWrap(D,F){if(F<this.minWidthToWrap)return D;let B=D.split(/\r\n|\n/),$=/[\s]*[^\s]+/g,_=[];return B.forEach((Q)=>{let Y=Q.match($);if(Y===null){_.push("");return}let q=[Y.shift()],H=this.displayWidth(q[0]);Y.forEach((J)=>{let X=this.displayWidth(J);if(H+X<=F){q.push(J),H+=X;return}_.push(q.join(""));let z=J.trimStart();q=[z],H=this.displayWidth(z)}),_.push(q.join(""))}),_.join(`
40
- `)}}function o7(D){let F=/\x1b\[\d*(;\d*)*m/g;return D.replace(F,"")}sQ.Help=a7;sQ.stripColor=o7});var b1=d0((eQ)=>{var{InvalidArgumentError:rQ}=w3();class t7{constructor(D,F){this.flags=D,this.description=F||"",this.required=D.includes("<"),this.optional=D.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(D),this.mandatory=!1;let B=tQ(D);if(this.short=B.shortFlag,this.long=B.longFlag,this.negate=!1,this.long)this.negate=this.long.startsWith("--no-");this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(D,F){return this.defaultValue=D,this.defaultValueDescription=F,this}preset(D){return this.presetArg=D,this}conflicts(D){return this.conflictsWith=this.conflictsWith.concat(D),this}implies(D){let F=D;if(typeof D==="string")F={[D]:!0};return this.implied=Object.assign(this.implied||{},F),this}env(D){return this.envVar=D,this}argParser(D){return this.parseArg=D,this}makeOptionMandatory(D=!0){return this.mandatory=!!D,this}hideHelp(D=!0){return this.hidden=!!D,this}_collectValue(D,F){if(F===this.defaultValue||!Array.isArray(F))return[D];return F.push(D),F}choices(D){return this.argChoices=D.slice(),this.parseArg=(F,B)=>{if(!this.argChoices.includes(F))throw new rQ(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(F,B);return F},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){if(this.negate)return r7(this.name().replace(/^no-/,""));return r7(this.name())}helpGroup(D){return this.helpGroupHeading=D,this}is(D){return this.short===D||this.long===D}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class e7{constructor(D){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,D.forEach((F)=>{if(F.negate)this.negativeOptions.set(F.attributeName(),F);else this.positiveOptions.set(F.attributeName(),F)}),this.negativeOptions.forEach((F,B)=>{if(this.positiveOptions.has(B))this.dualOptions.add(B)})}valueFromOption(D,F){let B=F.attributeName();if(!this.dualOptions.has(B))return!0;let $=this.negativeOptions.get(B).presetArg,_=$!==void 0?$:!1;return F.negate===(_===D)}}function r7(D){return D.split("-").reduce((F,B)=>{return F+B[0].toUpperCase()+B.slice(1)})}function tQ(D){let F,B,$=/^-[^-]$/,_=/^--[^-]/,Q=D.split(/[ |,]+/).concat("guard");if($.test(Q[0]))F=Q.shift();if(_.test(Q[0]))B=Q.shift();if(!F&&$.test(Q[0]))F=Q.shift();if(!F&&_.test(Q[0]))F=B,B=Q.shift();if(Q[0].startsWith("-")){let Y=Q[0],q=`option creation failed due to '${Y}' in option flags '${D}'`;if(/^-[^-][^-]/.test(Y))throw Error(`${q}
40
+ `)}}function e7(D){let F=/\x1b\[\d*(;\d*)*m/g;return D.replace(F,"")}tQ.Help=t7;tQ.stripColor=e7});var R1=c0(($Y)=>{var{InvalidArgumentError:FY}=O3();class F9{constructor(D,F){this.flags=D,this.description=F||"",this.required=D.includes("<"),this.optional=D.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(D),this.mandatory=!1;let B=BY(D);if(this.short=B.shortFlag,this.long=B.longFlag,this.negate=!1,this.long)this.negate=this.long.startsWith("--no-");this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(D,F){return this.defaultValue=D,this.defaultValueDescription=F,this}preset(D){return this.presetArg=D,this}conflicts(D){return this.conflictsWith=this.conflictsWith.concat(D),this}implies(D){let F=D;if(typeof D==="string")F={[D]:!0};return this.implied=Object.assign(this.implied||{},F),this}env(D){return this.envVar=D,this}argParser(D){return this.parseArg=D,this}makeOptionMandatory(D=!0){return this.mandatory=!!D,this}hideHelp(D=!0){return this.hidden=!!D,this}_collectValue(D,F){if(F===this.defaultValue||!Array.isArray(F))return[D];return F.push(D),F}choices(D){return this.argChoices=D.slice(),this.parseArg=(F,B)=>{if(!this.argChoices.includes(F))throw new FY(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(F,B);return F},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){if(this.negate)return D9(this.name().replace(/^no-/,""));return D9(this.name())}helpGroup(D){return this.helpGroupHeading=D,this}is(D){return this.short===D||this.long===D}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class B9{constructor(D){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,D.forEach((F)=>{if(F.negate)this.negativeOptions.set(F.attributeName(),F);else this.positiveOptions.set(F.attributeName(),F)}),this.negativeOptions.forEach((F,B)=>{if(this.positiveOptions.has(B))this.dualOptions.add(B)})}valueFromOption(D,F){let B=F.attributeName();if(!this.dualOptions.has(B))return!0;let $=this.negativeOptions.get(B).presetArg,_=$!==void 0?$:!1;return F.negate===(_===D)}}function D9(D){return D.split("-").reduce((F,B)=>{return F+B[0].toUpperCase()+B.slice(1)})}function BY(D){let F,B,$=/^-[^-]$/,_=/^--[^-]/,Q=D.split(/[ |,]+/).concat("guard");if($.test(Q[0]))F=Q.shift();if(_.test(Q[0]))B=Q.shift();if(!F&&$.test(Q[0]))F=Q.shift();if(!F&&_.test(Q[0]))F=B,B=Q.shift();if(Q[0].startsWith("-")){let Y=Q[0],q=`option creation failed due to '${Y}' in option flags '${D}'`;if(/^-[^-][^-]/.test(Y))throw Error(`${q}
41
41
  - a short flag is a single dash and a single character
42
42
  - either use a single dash and a single character (for a short flag)
43
43
  - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if($.test(Y))throw Error(`${q}
44
44
  - too many short flags`);if(_.test(Y))throw Error(`${q}
45
45
  - too many long flags`);throw Error(`${q}
46
- - unrecognised flag format`)}if(F===void 0&&B===void 0)throw Error(`option creation failed due to no flags found in '${D}'.`);return{shortFlag:F,longFlag:B}}eQ.Option=t7;eQ.DualOptions=e7});var D9=d0((_Y)=>{function BY(D,F){if(Math.abs(D.length-F.length)>3)return Math.max(D.length,F.length);let B=[];for(let $=0;$<=D.length;$++)B[$]=[$];for(let $=0;$<=F.length;$++)B[0][$]=$;for(let $=1;$<=F.length;$++)for(let _=1;_<=D.length;_++){let Q=1;if(D[_-1]===F[$-1])Q=0;else Q=1;if(B[_][$]=Math.min(B[_-1][$]+1,B[_][$-1]+1,B[_-1][$-1]+Q),_>1&&$>1&&D[_-1]===F[$-2]&&D[_-2]===F[$-1])B[_][$]=Math.min(B[_][$],B[_-2][$-2]+1)}return B[D.length][F.length]}function $Y(D,F){if(!F||F.length===0)return"";F=Array.from(new Set(F));let B=D.startsWith("--");if(B)D=D.slice(2),F=F.map((Y)=>Y.slice(2));let $=[],_=3,Q=0.4;if(F.forEach((Y)=>{if(Y.length<=1)return;let q=BY(D,Y),H=Math.max(D.length,Y.length);if((H-q)/H>Q){if(q<_)_=q,$=[Y];else if(q===_)$.push(Y)}}),$.sort((Y,q)=>Y.localeCompare(q)),B)$=$.map((Y)=>`--${Y}`);if($.length>1)return`
46
+ - unrecognised flag format`)}if(F===void 0&&B===void 0)throw Error(`option creation failed due to no flags found in '${D}'.`);return{shortFlag:F,longFlag:B}}$Y.Option=F9;$Y.DualOptions=B9});var $9=c0((HY)=>{function YY(D,F){if(Math.abs(D.length-F.length)>3)return Math.max(D.length,F.length);let B=[];for(let $=0;$<=D.length;$++)B[$]=[$];for(let $=0;$<=F.length;$++)B[0][$]=$;for(let $=1;$<=F.length;$++)for(let _=1;_<=D.length;_++){let Q=1;if(D[_-1]===F[$-1])Q=0;else Q=1;if(B[_][$]=Math.min(B[_-1][$]+1,B[_][$-1]+1,B[_-1][$-1]+Q),_>1&&$>1&&D[_-1]===F[$-2]&&D[_-2]===F[$-1])B[_][$]=Math.min(B[_][$],B[_-2][$-2]+1)}return B[D.length][F.length]}function qY(D,F){if(!F||F.length===0)return"";F=Array.from(new Set(F));let B=D.startsWith("--");if(B)D=D.slice(2),F=F.map((Y)=>Y.slice(2));let $=[],_=3,Q=0.4;if(F.forEach((Y)=>{if(Y.length<=1)return;let q=YY(D,Y),H=Math.max(D.length,Y.length);if((H-q)/H>Q){if(q<_)_=q,$=[Y];else if(q===_)$.push(Y)}}),$.sort((Y,q)=>Y.localeCompare(q)),B)$=$.map((Y)=>`--${Y}`);if($.length>1)return`
47
47
  (Did you mean one of ${$.join(", ")}?)`;if($.length===1)return`
48
- (Did you mean ${$[0]}?)`;return""}_Y.suggestSimilar=$Y});var _9=d0((WY)=>{var YY=WF("events").EventEmitter,R1=WF("child_process"),q2=WF("path"),F8=WF("fs"),AD=WF("process"),{Argument:qY,humanReadableArgName:HY}=D8(),{CommanderError:Z1}=w3(),{Help:JY,stripColor:XY}=O1(),{Option:F9,DualOptions:GY}=b1(),{suggestSimilar:B9}=D9();class S1 extends YY{constructor(D){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=D||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:(F)=>AD.stdout.write(F),writeErr:(F)=>AD.stderr.write(F),outputError:(F,B)=>B(F),getOutHelpWidth:()=>AD.stdout.isTTY?AD.stdout.columns:void 0,getErrHelpWidth:()=>AD.stderr.isTTY?AD.stderr.columns:void 0,getOutHasColors:()=>N1()??(AD.stdout.isTTY&&AD.stdout.hasColors?.()),getErrHasColors:()=>N1()??(AD.stderr.isTTY&&AD.stderr.hasColors?.()),stripColor:(F)=>XY(F)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(D){return this._outputConfiguration=D._outputConfiguration,this._helpOption=D._helpOption,this._helpCommand=D._helpCommand,this._helpConfiguration=D._helpConfiguration,this._exitCallback=D._exitCallback,this._storeOptionsAsProperties=D._storeOptionsAsProperties,this._combineFlagAndOptionalValue=D._combineFlagAndOptionalValue,this._allowExcessArguments=D._allowExcessArguments,this._enablePositionalOptions=D._enablePositionalOptions,this._showHelpAfterError=D._showHelpAfterError,this._showSuggestionAfterError=D._showSuggestionAfterError,this}_getCommandAndAncestors(){let D=[];for(let F=this;F;F=F.parent)D.push(F);return D}command(D,F,B){let $=F,_=B;if(typeof $==="object"&&$!==null)_=$,$=null;_=_||{};let[,Q,Y]=D.match(/([^ ]+) *(.*)/),q=this.createCommand(Q);if($)q.description($),q._executableHandler=!0;if(_.isDefault)this._defaultCommandName=q._name;if(q._hidden=!!(_.noHelp||_.hidden),q._executableFile=_.executableFile||null,Y)q.arguments(Y);if(this._registerCommand(q),q.parent=this,q.copyInheritedSettings(this),$)return this;return q}createCommand(D){return new S1(D)}createHelp(){return Object.assign(new JY,this.configureHelp())}configureHelp(D){if(D===void 0)return this._helpConfiguration;return this._helpConfiguration=D,this}configureOutput(D){if(D===void 0)return this._outputConfiguration;return this._outputConfiguration={...this._outputConfiguration,...D},this}showHelpAfterError(D=!0){if(typeof D!=="string")D=!!D;return this._showHelpAfterError=D,this}showSuggestionAfterError(D=!0){return this._showSuggestionAfterError=!!D,this}addCommand(D,F){if(!D._name)throw Error(`Command passed to .addCommand() must have a name
49
- - specify the name in Command constructor or using .name()`);if(F=F||{},F.isDefault)this._defaultCommandName=D._name;if(F.noHelp||F.hidden)D._hidden=!0;return this._registerCommand(D),D.parent=this,D._checkForBrokenPassThrough(),this}createArgument(D,F){return new qY(D,F)}argument(D,F,B,$){let _=this.createArgument(D,F);if(typeof B==="function")_.default($).argParser(B);else _.default(B);return this.addArgument(_),this}arguments(D){return D.trim().split(/ +/).forEach((F)=>{this.argument(F)}),this}addArgument(D){let F=this.registeredArguments.slice(-1)[0];if(F?.variadic)throw Error(`only the last argument can be variadic '${F.name()}'`);if(D.required&&D.defaultValue!==void 0&&D.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${D.name()}'`);return this.registeredArguments.push(D),this}helpCommand(D,F){if(typeof D==="boolean"){if(this._addImplicitHelpCommand=D,D&&this._defaultCommandGroup)this._initCommandGroup(this._getHelpCommand());return this}let B=D??"help [command]",[,$,_]=B.match(/([^ ]+) *(.*)/),Q=F??"display help for command",Y=this.createCommand($);if(Y.helpOption(!1),_)Y.arguments(_);if(Q)Y.description(Q);if(this._addImplicitHelpCommand=!0,this._helpCommand=Y,D||F)this._initCommandGroup(Y);return this}addHelpCommand(D,F){if(typeof D!=="object")return this.helpCommand(D,F),this;return this._addImplicitHelpCommand=!0,this._helpCommand=D,this._initCommandGroup(D),this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook(D,F){let B=["preSubcommand","preAction","postAction"];if(!B.includes(D))throw Error(`Unexpected value for event passed to hook : '${D}'.
50
- Expecting one of '${B.join("', '")}'`);if(this._lifeCycleHooks[D])this._lifeCycleHooks[D].push(F);else this._lifeCycleHooks[D]=[F];return this}exitOverride(D){if(D)this._exitCallback=D;else this._exitCallback=(F)=>{if(F.code!=="commander.executeSubCommandAsync")throw F};return this}_exit(D,F,B){if(this._exitCallback)this._exitCallback(new Z1(D,F,B));AD.exit(D)}action(D){let F=(B)=>{let $=this.registeredArguments.length,_=B.slice(0,$);if(this._storeOptionsAsProperties)_[$]=this;else _[$]=this.opts();return _.push(this),D.apply(this,_)};return this._actionHandler=F,this}createOption(D,F){return new F9(D,F)}_callParseArg(D,F,B,$){try{return D.parseArg(F,B)}catch(_){if(_.code==="commander.invalidArgument"){let Q=`${$} ${_.message}`;this.error(Q,{exitCode:_.exitCode,code:_.code})}throw _}}_registerOption(D){let F=D.short&&this._findOption(D.short)||D.long&&this._findOption(D.long);if(F){let B=D.long&&this._findOption(D.long)?D.long:D.short;throw Error(`Cannot add option '${D.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${B}'
51
- - already used by option '${F.flags}'`)}this._initOptionGroup(D),this.options.push(D)}_registerCommand(D){let F=($)=>{return[$.name()].concat($.aliases())},B=F(D).find(($)=>this._findCommand($));if(B){let $=F(this._findCommand(B)).join("|"),_=F(D).join("|");throw Error(`cannot add command '${_}' as already have command '${$}'`)}this._initCommandGroup(D),this.commands.push(D)}addOption(D){this._registerOption(D);let F=D.name(),B=D.attributeName();if(D.negate){let _=D.long.replace(/^--no-/,"--");if(!this._findOption(_))this.setOptionValueWithSource(B,D.defaultValue===void 0?!0:D.defaultValue,"default")}else if(D.defaultValue!==void 0)this.setOptionValueWithSource(B,D.defaultValue,"default");let $=(_,Q,Y)=>{if(_==null&&D.presetArg!==void 0)_=D.presetArg;let q=this.getOptionValue(B);if(_!==null&&D.parseArg)_=this._callParseArg(D,_,q,Q);else if(_!==null&&D.variadic)_=D._collectValue(_,q);if(_==null)if(D.negate)_=!1;else if(D.isBoolean()||D.optional)_=!0;else _="";this.setOptionValueWithSource(B,_,Y)};if(this.on("option:"+F,(_)=>{let Q=`error: option '${D.flags}' argument '${_}' is invalid.`;$(_,Q,"cli")}),D.envVar)this.on("optionEnv:"+F,(_)=>{let Q=`error: option '${D.flags}' value '${_}' from env '${D.envVar}' is invalid.`;$(_,Q,"env")});return this}_optionEx(D,F,B,$,_){if(typeof F==="object"&&F instanceof F9)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let Q=this.createOption(F,B);if(Q.makeOptionMandatory(!!D.mandatory),typeof $==="function")Q.default(_).argParser($);else if($ instanceof RegExp){let Y=$;$=(q,H)=>{let J=Y.exec(q);return J?J[0]:H},Q.default(_).argParser($)}else Q.default($);return this.addOption(Q)}option(D,F,B,$){return this._optionEx({},D,F,B,$)}requiredOption(D,F,B,$){return this._optionEx({mandatory:!0},D,F,B,$)}combineFlagAndOptionalValue(D=!0){return this._combineFlagAndOptionalValue=!!D,this}allowUnknownOption(D=!0){return this._allowUnknownOption=!!D,this}allowExcessArguments(D=!0){return this._allowExcessArguments=!!D,this}enablePositionalOptions(D=!0){return this._enablePositionalOptions=!!D,this}passThroughOptions(D=!0){return this._passThroughOptions=!!D,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(D=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!D,this}getOptionValue(D){if(this._storeOptionsAsProperties)return this[D];return this._optionValues[D]}setOptionValue(D,F){return this.setOptionValueWithSource(D,F,void 0)}setOptionValueWithSource(D,F,B){if(this._storeOptionsAsProperties)this[D]=F;else this._optionValues[D]=F;return this._optionValueSources[D]=B,this}getOptionValueSource(D){return this._optionValueSources[D]}getOptionValueSourceWithGlobals(D){let F;return this._getCommandAndAncestors().forEach((B)=>{if(B.getOptionValueSource(D)!==void 0)F=B.getOptionValueSource(D)}),F}_prepareUserArgs(D,F){if(D!==void 0&&!Array.isArray(D))throw Error("first parameter to parse must be array or undefined");if(F=F||{},D===void 0&&F.from===void 0){if(AD.versions?.electron)F.from="electron";let $=AD.execArgv??[];if($.includes("-e")||$.includes("--eval")||$.includes("-p")||$.includes("--print"))F.from="eval"}if(D===void 0)D=AD.argv;this.rawArgs=D.slice();let B;switch(F.from){case void 0:case"node":this._scriptPath=D[1],B=D.slice(2);break;case"electron":if(AD.defaultApp)this._scriptPath=D[1],B=D.slice(2);else B=D.slice(1);break;case"user":B=D.slice(0);break;case"eval":B=D.slice(1);break;default:throw Error(`unexpected parse option { from: '${F.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",B}parse(D,F){this._prepareForParse();let B=this._prepareUserArgs(D,F);return this._parseCommand([],B),this}async parseAsync(D,F){this._prepareForParse();let B=this._prepareUserArgs(D,F);return await this._parseCommand([],B),this}_prepareForParse(){if(this._savedState===null)this.saveStateBeforeParse();else this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw Error(`Can not call parse again when storeOptionsAsProperties is true.
52
- - either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(D,F,B){if(F8.existsSync(D))return;let $=F?`searched for local subcommand relative to directory '${F}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",_=`'${D}' does not exist
48
+ (Did you mean ${$[0]}?)`;return""}HY.suggestSimilar=qY});var q9=c0((jY)=>{var XY=GF("events").EventEmitter,N1=GF("child_process"),H2=GF("path"),B8=GF("fs"),AD=GF("process"),{Argument:WY,humanReadableArgName:GY}=F8(),{CommanderError:S1}=O3(),{Help:zY,stripColor:MY}=Z1(),{Option:_9,DualOptions:AY}=R1(),{suggestSimilar:Q9}=$9();class I1 extends XY{constructor(D){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=D||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:(F)=>AD.stdout.write(F),writeErr:(F)=>AD.stderr.write(F),outputError:(F,B)=>B(F),getOutHelpWidth:()=>AD.stdout.isTTY?AD.stdout.columns:void 0,getErrHelpWidth:()=>AD.stderr.isTTY?AD.stderr.columns:void 0,getOutHasColors:()=>k1()??(AD.stdout.isTTY&&AD.stdout.hasColors?.()),getErrHasColors:()=>k1()??(AD.stderr.isTTY&&AD.stderr.hasColors?.()),stripColor:(F)=>MY(F)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(D){return this._outputConfiguration=D._outputConfiguration,this._helpOption=D._helpOption,this._helpCommand=D._helpCommand,this._helpConfiguration=D._helpConfiguration,this._exitCallback=D._exitCallback,this._storeOptionsAsProperties=D._storeOptionsAsProperties,this._combineFlagAndOptionalValue=D._combineFlagAndOptionalValue,this._allowExcessArguments=D._allowExcessArguments,this._enablePositionalOptions=D._enablePositionalOptions,this._showHelpAfterError=D._showHelpAfterError,this._showSuggestionAfterError=D._showSuggestionAfterError,this}_getCommandAndAncestors(){let D=[];for(let F=this;F;F=F.parent)D.push(F);return D}command(D,F,B){let $=F,_=B;if(typeof $==="object"&&$!==null)_=$,$=null;_=_||{};let[,Q,Y]=D.match(/([^ ]+) *(.*)/),q=this.createCommand(Q);if($)q.description($),q._executableHandler=!0;if(_.isDefault)this._defaultCommandName=q._name;if(q._hidden=!!(_.noHelp||_.hidden),q._executableFile=_.executableFile||null,Y)q.arguments(Y);if(this._registerCommand(q),q.parent=this,q.copyInheritedSettings(this),$)return this;return q}createCommand(D){return new I1(D)}createHelp(){return Object.assign(new zY,this.configureHelp())}configureHelp(D){if(D===void 0)return this._helpConfiguration;return this._helpConfiguration=D,this}configureOutput(D){if(D===void 0)return this._outputConfiguration;return this._outputConfiguration={...this._outputConfiguration,...D},this}showHelpAfterError(D=!0){if(typeof D!=="string")D=!!D;return this._showHelpAfterError=D,this}showSuggestionAfterError(D=!0){return this._showSuggestionAfterError=!!D,this}addCommand(D,F){if(!D._name)throw Error(`Command passed to .addCommand() must have a name
49
+ - specify the name in Command constructor or using .name()`);if(F=F||{},F.isDefault)this._defaultCommandName=D._name;if(F.noHelp||F.hidden)D._hidden=!0;return this._registerCommand(D),D.parent=this,D._checkForBrokenPassThrough(),this}createArgument(D,F){return new WY(D,F)}argument(D,F,B,$){let _=this.createArgument(D,F);if(typeof B==="function")_.default($).argParser(B);else _.default(B);return this.addArgument(_),this}arguments(D){return D.trim().split(/ +/).forEach((F)=>{this.argument(F)}),this}addArgument(D){let F=this.registeredArguments.slice(-1)[0];if(F?.variadic)throw Error(`only the last argument can be variadic '${F.name()}'`);if(D.required&&D.defaultValue!==void 0&&D.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${D.name()}'`);return this.registeredArguments.push(D),this}helpCommand(D,F){if(typeof D==="boolean"){if(this._addImplicitHelpCommand=D,D&&this._defaultCommandGroup)this._initCommandGroup(this._getHelpCommand());return this}let B=D??"help [command]",[,$,_]=B.match(/([^ ]+) *(.*)/),Q=F??"display help for command",Y=this.createCommand($);if(Y.helpOption(!1),_)Y.arguments(_);if(Q)Y.description(Q);if(this._addImplicitHelpCommand=!0,this._helpCommand=Y,D||F)this._initCommandGroup(Y);return this}addHelpCommand(D,F){if(typeof D!=="object")return this.helpCommand(D,F),this;return this._addImplicitHelpCommand=!0,this._helpCommand=D,this._initCommandGroup(D),this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook(D,F){let B=["preSubcommand","preAction","postAction"];if(!B.includes(D))throw Error(`Unexpected value for event passed to hook : '${D}'.
50
+ Expecting one of '${B.join("', '")}'`);if(this._lifeCycleHooks[D])this._lifeCycleHooks[D].push(F);else this._lifeCycleHooks[D]=[F];return this}exitOverride(D){if(D)this._exitCallback=D;else this._exitCallback=(F)=>{if(F.code!=="commander.executeSubCommandAsync")throw F};return this}_exit(D,F,B){if(this._exitCallback)this._exitCallback(new S1(D,F,B));AD.exit(D)}action(D){let F=(B)=>{let $=this.registeredArguments.length,_=B.slice(0,$);if(this._storeOptionsAsProperties)_[$]=this;else _[$]=this.opts();return _.push(this),D.apply(this,_)};return this._actionHandler=F,this}createOption(D,F){return new _9(D,F)}_callParseArg(D,F,B,$){try{return D.parseArg(F,B)}catch(_){if(_.code==="commander.invalidArgument"){let Q=`${$} ${_.message}`;this.error(Q,{exitCode:_.exitCode,code:_.code})}throw _}}_registerOption(D){let F=D.short&&this._findOption(D.short)||D.long&&this._findOption(D.long);if(F){let B=D.long&&this._findOption(D.long)?D.long:D.short;throw Error(`Cannot add option '${D.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${B}'
51
+ - already used by option '${F.flags}'`)}this._initOptionGroup(D),this.options.push(D)}_registerCommand(D){let F=($)=>{return[$.name()].concat($.aliases())},B=F(D).find(($)=>this._findCommand($));if(B){let $=F(this._findCommand(B)).join("|"),_=F(D).join("|");throw Error(`cannot add command '${_}' as already have command '${$}'`)}this._initCommandGroup(D),this.commands.push(D)}addOption(D){this._registerOption(D);let F=D.name(),B=D.attributeName();if(D.negate){let _=D.long.replace(/^--no-/,"--");if(!this._findOption(_))this.setOptionValueWithSource(B,D.defaultValue===void 0?!0:D.defaultValue,"default")}else if(D.defaultValue!==void 0)this.setOptionValueWithSource(B,D.defaultValue,"default");let $=(_,Q,Y)=>{if(_==null&&D.presetArg!==void 0)_=D.presetArg;let q=this.getOptionValue(B);if(_!==null&&D.parseArg)_=this._callParseArg(D,_,q,Q);else if(_!==null&&D.variadic)_=D._collectValue(_,q);if(_==null)if(D.negate)_=!1;else if(D.isBoolean()||D.optional)_=!0;else _="";this.setOptionValueWithSource(B,_,Y)};if(this.on("option:"+F,(_)=>{let Q=`error: option '${D.flags}' argument '${_}' is invalid.`;$(_,Q,"cli")}),D.envVar)this.on("optionEnv:"+F,(_)=>{let Q=`error: option '${D.flags}' value '${_}' from env '${D.envVar}' is invalid.`;$(_,Q,"env")});return this}_optionEx(D,F,B,$,_){if(typeof F==="object"&&F instanceof _9)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let Q=this.createOption(F,B);if(Q.makeOptionMandatory(!!D.mandatory),typeof $==="function")Q.default(_).argParser($);else if($ instanceof RegExp){let Y=$;$=(q,H)=>{let J=Y.exec(q);return J?J[0]:H},Q.default(_).argParser($)}else Q.default($);return this.addOption(Q)}option(D,F,B,$){return this._optionEx({},D,F,B,$)}requiredOption(D,F,B,$){return this._optionEx({mandatory:!0},D,F,B,$)}combineFlagAndOptionalValue(D=!0){return this._combineFlagAndOptionalValue=!!D,this}allowUnknownOption(D=!0){return this._allowUnknownOption=!!D,this}allowExcessArguments(D=!0){return this._allowExcessArguments=!!D,this}enablePositionalOptions(D=!0){return this._enablePositionalOptions=!!D,this}passThroughOptions(D=!0){return this._passThroughOptions=!!D,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(D=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!D,this}getOptionValue(D){if(this._storeOptionsAsProperties)return this[D];return this._optionValues[D]}setOptionValue(D,F){return this.setOptionValueWithSource(D,F,void 0)}setOptionValueWithSource(D,F,B){if(this._storeOptionsAsProperties)this[D]=F;else this._optionValues[D]=F;return this._optionValueSources[D]=B,this}getOptionValueSource(D){return this._optionValueSources[D]}getOptionValueSourceWithGlobals(D){let F;return this._getCommandAndAncestors().forEach((B)=>{if(B.getOptionValueSource(D)!==void 0)F=B.getOptionValueSource(D)}),F}_prepareUserArgs(D,F){if(D!==void 0&&!Array.isArray(D))throw Error("first parameter to parse must be array or undefined");if(F=F||{},D===void 0&&F.from===void 0){if(AD.versions?.electron)F.from="electron";let $=AD.execArgv??[];if($.includes("-e")||$.includes("--eval")||$.includes("-p")||$.includes("--print"))F.from="eval"}if(D===void 0)D=AD.argv;this.rawArgs=D.slice();let B;switch(F.from){case void 0:case"node":this._scriptPath=D[1],B=D.slice(2);break;case"electron":if(AD.defaultApp)this._scriptPath=D[1],B=D.slice(2);else B=D.slice(1);break;case"user":B=D.slice(0);break;case"eval":B=D.slice(1);break;default:throw Error(`unexpected parse option { from: '${F.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",B}parse(D,F){this._prepareForParse();let B=this._prepareUserArgs(D,F);return this._parseCommand([],B),this}async parseAsync(D,F){this._prepareForParse();let B=this._prepareUserArgs(D,F);return await this._parseCommand([],B),this}_prepareForParse(){if(this._savedState===null)this.saveStateBeforeParse();else this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw Error(`Can not call parse again when storeOptionsAsProperties is true.
52
+ - either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(D,F,B){if(B8.existsSync(D))return;let $=F?`searched for local subcommand relative to directory '${F}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",_=`'${D}' does not exist
53
53
  - if '${B}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
54
54
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
55
- - ${$}`;throw Error(_)}_executeSubCommand(D,F){F=F.slice();let B=!1,$=[".js",".ts",".tsx",".mjs",".cjs"];function _(J,X){let z=q2.resolve(J,X);if(F8.existsSync(z))return z;if($.includes(q2.extname(X)))return;let M=$.find((A)=>F8.existsSync(`${z}${A}`));if(M)return`${z}${M}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let Q=D._executableFile||`${this._name}-${D._name}`,Y=this._executableDir||"";if(this._scriptPath){let J;try{J=F8.realpathSync(this._scriptPath)}catch{J=this._scriptPath}Y=q2.resolve(q2.dirname(J),Y)}if(Y){let J=_(Y,Q);if(!J&&!D._executableFile&&this._scriptPath){let X=q2.basename(this._scriptPath,q2.extname(this._scriptPath));if(X!==this._name)J=_(Y,`${X}-${D._name}`)}Q=J||Q}B=$.includes(q2.extname(Q));let q;if(AD.platform!=="win32")if(B)F.unshift(Q),F=$9(AD.execArgv).concat(F),q=R1.spawn(AD.argv[0],F,{stdio:"inherit"});else q=R1.spawn(Q,F,{stdio:"inherit"});else this._checkForMissingExecutable(Q,Y,D._name),F.unshift(Q),F=$9(AD.execArgv).concat(F),q=R1.spawn(AD.execPath,F,{stdio:"inherit"});if(!q.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((X)=>{AD.on(X,()=>{if(q.killed===!1&&q.exitCode===null)q.kill(X)})});let H=this._exitCallback;q.on("close",(J)=>{if(J=J??1,!H)AD.exit(J);else H(new Z1(J,"commander.executeSubCommandAsync","(close)"))}),q.on("error",(J)=>{if(J.code==="ENOENT")this._checkForMissingExecutable(Q,Y,D._name);else if(J.code==="EACCES")throw Error(`'${Q}' not executable`);if(!H)AD.exit(1);else{let X=new Z1(1,"commander.executeSubCommandAsync","(error)");X.nestedError=J,H(X)}}),this.runningCommand=q}_dispatchSubcommand(D,F,B){let $=this._findCommand(D);if(!$)this.help({error:!0});$._prepareForParse();let _;return _=this._chainOrCallSubCommandHook(_,$,"preSubcommand"),_=this._chainOrCall(_,()=>{if($._executableHandler)this._executeSubCommand($,F.concat(B));else return $._parseCommand(F,B)}),_}_dispatchHelpCommand(D){if(!D)this.help();let F=this._findCommand(D);if(F&&!F._executableHandler)F.help();return this._dispatchSubcommand(D,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach((D,F)=>{if(D.required&&this.args[F]==null)this.missingArgument(D.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)return;if(this.args.length>this.registeredArguments.length)this._excessArguments(this.args)}_processArguments(){let D=(B,$,_)=>{let Q=$;if($!==null&&B.parseArg){let Y=`error: command-argument value '${$}' is invalid for argument '${B.name()}'.`;Q=this._callParseArg(B,$,_,Y)}return Q};this._checkNumberOfArguments();let F=[];this.registeredArguments.forEach((B,$)=>{let _=B.defaultValue;if(B.variadic){if($<this.args.length){if(_=this.args.slice($),B.parseArg)_=_.reduce((Q,Y)=>{return D(B,Y,Q)},B.defaultValue)}else if(_===void 0)_=[]}else if($<this.args.length){if(_=this.args[$],B.parseArg)_=D(B,_,B.defaultValue)}F[$]=_}),this.processedArgs=F}_chainOrCall(D,F){if(D?.then&&typeof D.then==="function")return D.then(()=>F());return F()}_chainOrCallHooks(D,F){let B=D,$=[];if(this._getCommandAndAncestors().reverse().filter((_)=>_._lifeCycleHooks[F]!==void 0).forEach((_)=>{_._lifeCycleHooks[F].forEach((Q)=>{$.push({hookedCommand:_,callback:Q})})}),F==="postAction")$.reverse();return $.forEach((_)=>{B=this._chainOrCall(B,()=>{return _.callback(_.hookedCommand,this)})}),B}_chainOrCallSubCommandHook(D,F,B){let $=D;if(this._lifeCycleHooks[B]!==void 0)this._lifeCycleHooks[B].forEach((_)=>{$=this._chainOrCall($,()=>{return _(this,F)})});return $}_parseCommand(D,F){let B=this.parseOptions(F);if(this._parseOptionsEnv(),this._parseOptionsImplied(),D=D.concat(B.operands),F=B.unknown,this.args=D.concat(F),D&&this._findCommand(D[0]))return this._dispatchSubcommand(D[0],D.slice(1),F);if(this._getHelpCommand()&&D[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(D[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(F),this._dispatchSubcommand(this._defaultCommandName,D,F);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(B.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let $=()=>{if(B.unknown.length>0)this.unknownOption(B.unknown[0])},_=`command:${this.name()}`;if(this._actionHandler){$(),this._processArguments();let Q;if(Q=this._chainOrCallHooks(Q,"preAction"),Q=this._chainOrCall(Q,()=>this._actionHandler(this.processedArgs)),this.parent)Q=this._chainOrCall(Q,()=>{this.parent.emit(_,D,F)});return Q=this._chainOrCallHooks(Q,"postAction"),Q}if(this.parent?.listenerCount(_))$(),this._processArguments(),this.parent.emit(_,D,F);else if(D.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",D,F);if(this.listenerCount("command:*"))this.emit("command:*",D,F);else if(this.commands.length)this.unknownCommand();else $(),this._processArguments()}else if(this.commands.length)$(),this.help({error:!0});else $(),this._processArguments()}_findCommand(D){if(!D)return;return this.commands.find((F)=>F._name===D||F._aliases.includes(D))}_findOption(D){return this.options.find((F)=>F.is(D))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((D)=>{D.options.forEach((F)=>{if(F.mandatory&&D.getOptionValue(F.attributeName())===void 0)D.missingMandatoryOptionValue(F)})})}_checkForConflictingLocalOptions(){let D=this.options.filter((B)=>{let $=B.attributeName();if(this.getOptionValue($)===void 0)return!1;return this.getOptionValueSource($)!=="default"});D.filter((B)=>B.conflictsWith.length>0).forEach((B)=>{let $=D.find((_)=>B.conflictsWith.includes(_.attributeName()));if($)this._conflictingOption(B,$)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((D)=>{D._checkForConflictingLocalOptions()})}parseOptions(D){let F=[],B=[],$=F;function _(J){return J.length>1&&J[0]==="-"}let Q=(J)=>{if(!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(J))return!1;return!this._getCommandAndAncestors().some((X)=>X.options.map((z)=>z.short).some((z)=>/^-\d$/.test(z)))},Y=null,q=null,H=0;while(H<D.length||q){let J=q??D[H++];if(q=null,J==="--"){if($===B)$.push(J);$.push(...D.slice(H));break}if(Y&&(!_(J)||Q(J))){this.emit(`option:${Y.name()}`,J);continue}if(Y=null,_(J)){let X=this._findOption(J);if(X){if(X.required){let z=D[H++];if(z===void 0)this.optionMissingArgument(X);this.emit(`option:${X.name()}`,z)}else if(X.optional){let z=null;if(H<D.length&&(!_(D[H])||Q(D[H])))z=D[H++];this.emit(`option:${X.name()}`,z)}else this.emit(`option:${X.name()}`);Y=X.variadic?X:null;continue}}if(J.length>2&&J[0]==="-"&&J[1]!=="-"){let X=this._findOption(`-${J[1]}`);if(X){if(X.required||X.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${X.name()}`,J.slice(2));else this.emit(`option:${X.name()}`),q=`-${J.slice(2)}`;continue}}if(/^--[^=]+=/.test(J)){let X=J.indexOf("="),z=this._findOption(J.slice(0,X));if(z&&(z.required||z.optional)){this.emit(`option:${z.name()}`,J.slice(X+1));continue}}if($===F&&_(J)&&!(this.commands.length===0&&Q(J)))$=B;if((this._enablePositionalOptions||this._passThroughOptions)&&F.length===0&&B.length===0){if(this._findCommand(J)){F.push(J),B.push(...D.slice(H));break}else if(this._getHelpCommand()&&J===this._getHelpCommand().name()){F.push(J,...D.slice(H));break}else if(this._defaultCommandName){B.push(J,...D.slice(H));break}}if(this._passThroughOptions){$.push(J,...D.slice(H));break}$.push(J)}return{operands:F,unknown:B}}opts(){if(this._storeOptionsAsProperties){let D={},F=this.options.length;for(let B=0;B<F;B++){let $=this.options[B].attributeName();D[$]=$===this._versionOptionName?this._version:this[$]}return D}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((D,F)=>Object.assign(D,F.opts()),{})}error(D,F){if(this._outputConfiguration.outputError(`${D}
55
+ - ${$}`;throw Error(_)}_executeSubCommand(D,F){F=F.slice();let B=!1,$=[".js",".ts",".tsx",".mjs",".cjs"];function _(J,X){let z=H2.resolve(J,X);if(B8.existsSync(z))return z;if($.includes(H2.extname(X)))return;let M=$.find((A)=>B8.existsSync(`${z}${A}`));if(M)return`${z}${M}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let Q=D._executableFile||`${this._name}-${D._name}`,Y=this._executableDir||"";if(this._scriptPath){let J;try{J=B8.realpathSync(this._scriptPath)}catch{J=this._scriptPath}Y=H2.resolve(H2.dirname(J),Y)}if(Y){let J=_(Y,Q);if(!J&&!D._executableFile&&this._scriptPath){let X=H2.basename(this._scriptPath,H2.extname(this._scriptPath));if(X!==this._name)J=_(Y,`${X}-${D._name}`)}Q=J||Q}B=$.includes(H2.extname(Q));let q;if(AD.platform!=="win32")if(B)F.unshift(Q),F=Y9(AD.execArgv).concat(F),q=N1.spawn(AD.argv[0],F,{stdio:"inherit"});else q=N1.spawn(Q,F,{stdio:"inherit"});else this._checkForMissingExecutable(Q,Y,D._name),F.unshift(Q),F=Y9(AD.execArgv).concat(F),q=N1.spawn(AD.execPath,F,{stdio:"inherit"});if(!q.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((X)=>{AD.on(X,()=>{if(q.killed===!1&&q.exitCode===null)q.kill(X)})});let H=this._exitCallback;q.on("close",(J)=>{if(J=J??1,!H)AD.exit(J);else H(new S1(J,"commander.executeSubCommandAsync","(close)"))}),q.on("error",(J)=>{if(J.code==="ENOENT")this._checkForMissingExecutable(Q,Y,D._name);else if(J.code==="EACCES")throw Error(`'${Q}' not executable`);if(!H)AD.exit(1);else{let X=new S1(1,"commander.executeSubCommandAsync","(error)");X.nestedError=J,H(X)}}),this.runningCommand=q}_dispatchSubcommand(D,F,B){let $=this._findCommand(D);if(!$)this.help({error:!0});$._prepareForParse();let _;return _=this._chainOrCallSubCommandHook(_,$,"preSubcommand"),_=this._chainOrCall(_,()=>{if($._executableHandler)this._executeSubCommand($,F.concat(B));else return $._parseCommand(F,B)}),_}_dispatchHelpCommand(D){if(!D)this.help();let F=this._findCommand(D);if(F&&!F._executableHandler)F.help();return this._dispatchSubcommand(D,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach((D,F)=>{if(D.required&&this.args[F]==null)this.missingArgument(D.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)return;if(this.args.length>this.registeredArguments.length)this._excessArguments(this.args)}_processArguments(){let D=(B,$,_)=>{let Q=$;if($!==null&&B.parseArg){let Y=`error: command-argument value '${$}' is invalid for argument '${B.name()}'.`;Q=this._callParseArg(B,$,_,Y)}return Q};this._checkNumberOfArguments();let F=[];this.registeredArguments.forEach((B,$)=>{let _=B.defaultValue;if(B.variadic){if($<this.args.length){if(_=this.args.slice($),B.parseArg)_=_.reduce((Q,Y)=>{return D(B,Y,Q)},B.defaultValue)}else if(_===void 0)_=[]}else if($<this.args.length){if(_=this.args[$],B.parseArg)_=D(B,_,B.defaultValue)}F[$]=_}),this.processedArgs=F}_chainOrCall(D,F){if(D?.then&&typeof D.then==="function")return D.then(()=>F());return F()}_chainOrCallHooks(D,F){let B=D,$=[];if(this._getCommandAndAncestors().reverse().filter((_)=>_._lifeCycleHooks[F]!==void 0).forEach((_)=>{_._lifeCycleHooks[F].forEach((Q)=>{$.push({hookedCommand:_,callback:Q})})}),F==="postAction")$.reverse();return $.forEach((_)=>{B=this._chainOrCall(B,()=>{return _.callback(_.hookedCommand,this)})}),B}_chainOrCallSubCommandHook(D,F,B){let $=D;if(this._lifeCycleHooks[B]!==void 0)this._lifeCycleHooks[B].forEach((_)=>{$=this._chainOrCall($,()=>{return _(this,F)})});return $}_parseCommand(D,F){let B=this.parseOptions(F);if(this._parseOptionsEnv(),this._parseOptionsImplied(),D=D.concat(B.operands),F=B.unknown,this.args=D.concat(F),D&&this._findCommand(D[0]))return this._dispatchSubcommand(D[0],D.slice(1),F);if(this._getHelpCommand()&&D[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(D[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(F),this._dispatchSubcommand(this._defaultCommandName,D,F);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(B.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let $=()=>{if(B.unknown.length>0)this.unknownOption(B.unknown[0])},_=`command:${this.name()}`;if(this._actionHandler){$(),this._processArguments();let Q;if(Q=this._chainOrCallHooks(Q,"preAction"),Q=this._chainOrCall(Q,()=>this._actionHandler(this.processedArgs)),this.parent)Q=this._chainOrCall(Q,()=>{this.parent.emit(_,D,F)});return Q=this._chainOrCallHooks(Q,"postAction"),Q}if(this.parent?.listenerCount(_))$(),this._processArguments(),this.parent.emit(_,D,F);else if(D.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",D,F);if(this.listenerCount("command:*"))this.emit("command:*",D,F);else if(this.commands.length)this.unknownCommand();else $(),this._processArguments()}else if(this.commands.length)$(),this.help({error:!0});else $(),this._processArguments()}_findCommand(D){if(!D)return;return this.commands.find((F)=>F._name===D||F._aliases.includes(D))}_findOption(D){return this.options.find((F)=>F.is(D))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((D)=>{D.options.forEach((F)=>{if(F.mandatory&&D.getOptionValue(F.attributeName())===void 0)D.missingMandatoryOptionValue(F)})})}_checkForConflictingLocalOptions(){let D=this.options.filter((B)=>{let $=B.attributeName();if(this.getOptionValue($)===void 0)return!1;return this.getOptionValueSource($)!=="default"});D.filter((B)=>B.conflictsWith.length>0).forEach((B)=>{let $=D.find((_)=>B.conflictsWith.includes(_.attributeName()));if($)this._conflictingOption(B,$)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((D)=>{D._checkForConflictingLocalOptions()})}parseOptions(D){let F=[],B=[],$=F;function _(J){return J.length>1&&J[0]==="-"}let Q=(J)=>{if(!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(J))return!1;return!this._getCommandAndAncestors().some((X)=>X.options.map((z)=>z.short).some((z)=>/^-\d$/.test(z)))},Y=null,q=null,H=0;while(H<D.length||q){let J=q??D[H++];if(q=null,J==="--"){if($===B)$.push(J);$.push(...D.slice(H));break}if(Y&&(!_(J)||Q(J))){this.emit(`option:${Y.name()}`,J);continue}if(Y=null,_(J)){let X=this._findOption(J);if(X){if(X.required){let z=D[H++];if(z===void 0)this.optionMissingArgument(X);this.emit(`option:${X.name()}`,z)}else if(X.optional){let z=null;if(H<D.length&&(!_(D[H])||Q(D[H])))z=D[H++];this.emit(`option:${X.name()}`,z)}else this.emit(`option:${X.name()}`);Y=X.variadic?X:null;continue}}if(J.length>2&&J[0]==="-"&&J[1]!=="-"){let X=this._findOption(`-${J[1]}`);if(X){if(X.required||X.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${X.name()}`,J.slice(2));else this.emit(`option:${X.name()}`),q=`-${J.slice(2)}`;continue}}if(/^--[^=]+=/.test(J)){let X=J.indexOf("="),z=this._findOption(J.slice(0,X));if(z&&(z.required||z.optional)){this.emit(`option:${z.name()}`,J.slice(X+1));continue}}if($===F&&_(J)&&!(this.commands.length===0&&Q(J)))$=B;if((this._enablePositionalOptions||this._passThroughOptions)&&F.length===0&&B.length===0){if(this._findCommand(J)){F.push(J),B.push(...D.slice(H));break}else if(this._getHelpCommand()&&J===this._getHelpCommand().name()){F.push(J,...D.slice(H));break}else if(this._defaultCommandName){B.push(J,...D.slice(H));break}}if(this._passThroughOptions){$.push(J,...D.slice(H));break}$.push(J)}return{operands:F,unknown:B}}opts(){if(this._storeOptionsAsProperties){let D={},F=this.options.length;for(let B=0;B<F;B++){let $=this.options[B].attributeName();D[$]=$===this._versionOptionName?this._version:this[$]}return D}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((D,F)=>Object.assign(D,F.opts()),{})}error(D,F){if(this._outputConfiguration.outputError(`${D}
56
56
  `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==="string")this._outputConfiguration.writeErr(`${this._showHelpAfterError}
57
57
  `);else if(this._showHelpAfterError)this._outputConfiguration.writeErr(`
58
- `),this.outputHelp({error:!0});let B=F||{},$=B.exitCode||1,_=B.code||"commander.error";this._exit($,_,D)}_parseOptionsEnv(){this.options.forEach((D)=>{if(D.envVar&&D.envVar in AD.env){let F=D.attributeName();if(this.getOptionValue(F)===void 0||["default","config","env"].includes(this.getOptionValueSource(F)))if(D.required||D.optional)this.emit(`optionEnv:${D.name()}`,AD.env[D.envVar]);else this.emit(`optionEnv:${D.name()}`)}})}_parseOptionsImplied(){let D=new GY(this.options),F=(B)=>{return this.getOptionValue(B)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(B))};this.options.filter((B)=>B.implied!==void 0&&F(B.attributeName())&&D.valueFromOption(this.getOptionValue(B.attributeName()),B)).forEach((B)=>{Object.keys(B.implied).filter(($)=>!F($)).forEach(($)=>{this.setOptionValueWithSource($,B.implied[$],"implied")})})}missingArgument(D){let F=`error: missing required argument '${D}'`;this.error(F,{code:"commander.missingArgument"})}optionMissingArgument(D){let F=`error: option '${D.flags}' argument missing`;this.error(F,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(D){let F=`error: required option '${D.flags}' not specified`;this.error(F,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(D,F){let B=(Q)=>{let Y=Q.attributeName(),q=this.getOptionValue(Y),H=this.options.find((X)=>X.negate&&Y===X.attributeName()),J=this.options.find((X)=>!X.negate&&Y===X.attributeName());if(H&&(H.presetArg===void 0&&q===!1||H.presetArg!==void 0&&q===H.presetArg))return H;return J||Q},$=(Q)=>{let Y=B(Q),q=Y.attributeName();if(this.getOptionValueSource(q)==="env")return`environment variable '${Y.envVar}'`;return`option '${Y.flags}'`},_=`error: ${$(D)} cannot be used with ${$(F)}`;this.error(_,{code:"commander.conflictingOption"})}unknownOption(D){if(this._allowUnknownOption)return;let F="";if(D.startsWith("--")&&this._showSuggestionAfterError){let $=[],_=this;do{let Q=_.createHelp().visibleOptions(_).filter((Y)=>Y.long).map((Y)=>Y.long);$=$.concat(Q),_=_.parent}while(_&&!_._enablePositionalOptions);F=B9(D,$)}let B=`error: unknown option '${D}'${F}`;this.error(B,{code:"commander.unknownOption"})}_excessArguments(D){if(this._allowExcessArguments)return;let F=this.registeredArguments.length,B=F===1?"":"s",_=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${F} argument${B} but got ${D.length}.`;this.error(_,{code:"commander.excessArguments"})}unknownCommand(){let D=this.args[0],F="";if(this._showSuggestionAfterError){let $=[];this.createHelp().visibleCommands(this).forEach((_)=>{if($.push(_.name()),_.alias())$.push(_.alias())}),F=B9(D,$)}let B=`error: unknown command '${D}'${F}`;this.error(B,{code:"commander.unknownCommand"})}version(D,F,B){if(D===void 0)return this._version;this._version=D,F=F||"-V, --version",B=B||"output the version number";let $=this.createOption(F,B);return this._versionOptionName=$.attributeName(),this._registerOption($),this.on("option:"+$.name(),()=>{this._outputConfiguration.writeOut(`${D}
59
- `),this._exit(0,"commander.version",D)}),this}description(D,F){if(D===void 0&&F===void 0)return this._description;if(this._description=D,F)this._argsDescription=F;return this}summary(D){if(D===void 0)return this._summary;return this._summary=D,this}alias(D){if(D===void 0)return this._aliases[0];let F=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)F=this.commands[this.commands.length-1];if(D===F._name)throw Error("Command alias can't be the same as its name");let B=this.parent?._findCommand(D);if(B){let $=[B.name()].concat(B.aliases()).join("|");throw Error(`cannot add alias '${D}' to command '${this.name()}' as already have command '${$}'`)}return F._aliases.push(D),this}aliases(D){if(D===void 0)return this._aliases;return D.forEach((F)=>this.alias(F)),this}usage(D){if(D===void 0){if(this._usage)return this._usage;let F=this.registeredArguments.map((B)=>{return HY(B)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?F:[]).join(" ")}return this._usage=D,this}name(D){if(D===void 0)return this._name;return this._name=D,this}helpGroup(D){if(D===void 0)return this._helpGroupHeading??"";return this._helpGroupHeading=D,this}commandsGroup(D){if(D===void 0)return this._defaultCommandGroup??"";return this._defaultCommandGroup=D,this}optionsGroup(D){if(D===void 0)return this._defaultOptionGroup??"";return this._defaultOptionGroup=D,this}_initOptionGroup(D){if(this._defaultOptionGroup&&!D.helpGroupHeading)D.helpGroup(this._defaultOptionGroup)}_initCommandGroup(D){if(this._defaultCommandGroup&&!D.helpGroup())D.helpGroup(this._defaultCommandGroup)}nameFromFilename(D){return this._name=q2.basename(D,q2.extname(D)),this}executableDir(D){if(D===void 0)return this._executableDir;return this._executableDir=D,this}helpInformation(D){let F=this.createHelp(),B=this._getOutputContext(D);F.prepareContext({error:B.error,helpWidth:B.helpWidth,outputHasColors:B.hasColors});let $=F.formatHelp(this,F);if(B.hasColors)return $;return this._outputConfiguration.stripColor($)}_getOutputContext(D){D=D||{};let F=!!D.error,B,$,_;if(F)B=(Y)=>this._outputConfiguration.writeErr(Y),$=this._outputConfiguration.getErrHasColors(),_=this._outputConfiguration.getErrHelpWidth();else B=(Y)=>this._outputConfiguration.writeOut(Y),$=this._outputConfiguration.getOutHasColors(),_=this._outputConfiguration.getOutHelpWidth();return{error:F,write:(Y)=>{if(!$)Y=this._outputConfiguration.stripColor(Y);return B(Y)},hasColors:$,helpWidth:_}}outputHelp(D){let F;if(typeof D==="function")F=D,D=void 0;let B=this._getOutputContext(D),$={error:B.error,write:B.write,command:this};this._getCommandAndAncestors().reverse().forEach((Q)=>Q.emit("beforeAllHelp",$)),this.emit("beforeHelp",$);let _=this.helpInformation({error:B.error});if(F){if(_=F(_),typeof _!=="string"&&!Buffer.isBuffer(_))throw Error("outputHelp callback must return a string or a Buffer")}if(B.write(_),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",$),this._getCommandAndAncestors().forEach((Q)=>Q.emit("afterAllHelp",$))}helpOption(D,F){if(typeof D==="boolean"){if(D){if(this._helpOption===null)this._helpOption=void 0;if(this._defaultOptionGroup)this._initOptionGroup(this._getHelpOption())}else this._helpOption=null;return this}if(this._helpOption=this.createOption(D??"-h, --help",F??"display help for command"),D||F)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(D){return this._helpOption=D,this._initOptionGroup(D),this}help(D){this.outputHelp(D);let F=Number(AD.exitCode??0);if(F===0&&D&&typeof D!=="function"&&D.error)F=1;this._exit(F,"commander.help","(outputHelp)")}addHelpText(D,F){let B=["beforeAll","before","after","afterAll"];if(!B.includes(D))throw Error(`Unexpected value for position to addHelpText.
58
+ `),this.outputHelp({error:!0});let B=F||{},$=B.exitCode||1,_=B.code||"commander.error";this._exit($,_,D)}_parseOptionsEnv(){this.options.forEach((D)=>{if(D.envVar&&D.envVar in AD.env){let F=D.attributeName();if(this.getOptionValue(F)===void 0||["default","config","env"].includes(this.getOptionValueSource(F)))if(D.required||D.optional)this.emit(`optionEnv:${D.name()}`,AD.env[D.envVar]);else this.emit(`optionEnv:${D.name()}`)}})}_parseOptionsImplied(){let D=new AY(this.options),F=(B)=>{return this.getOptionValue(B)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(B))};this.options.filter((B)=>B.implied!==void 0&&F(B.attributeName())&&D.valueFromOption(this.getOptionValue(B.attributeName()),B)).forEach((B)=>{Object.keys(B.implied).filter(($)=>!F($)).forEach(($)=>{this.setOptionValueWithSource($,B.implied[$],"implied")})})}missingArgument(D){let F=`error: missing required argument '${D}'`;this.error(F,{code:"commander.missingArgument"})}optionMissingArgument(D){let F=`error: option '${D.flags}' argument missing`;this.error(F,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(D){let F=`error: required option '${D.flags}' not specified`;this.error(F,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(D,F){let B=(Q)=>{let Y=Q.attributeName(),q=this.getOptionValue(Y),H=this.options.find((X)=>X.negate&&Y===X.attributeName()),J=this.options.find((X)=>!X.negate&&Y===X.attributeName());if(H&&(H.presetArg===void 0&&q===!1||H.presetArg!==void 0&&q===H.presetArg))return H;return J||Q},$=(Q)=>{let Y=B(Q),q=Y.attributeName();if(this.getOptionValueSource(q)==="env")return`environment variable '${Y.envVar}'`;return`option '${Y.flags}'`},_=`error: ${$(D)} cannot be used with ${$(F)}`;this.error(_,{code:"commander.conflictingOption"})}unknownOption(D){if(this._allowUnknownOption)return;let F="";if(D.startsWith("--")&&this._showSuggestionAfterError){let $=[],_=this;do{let Q=_.createHelp().visibleOptions(_).filter((Y)=>Y.long).map((Y)=>Y.long);$=$.concat(Q),_=_.parent}while(_&&!_._enablePositionalOptions);F=Q9(D,$)}let B=`error: unknown option '${D}'${F}`;this.error(B,{code:"commander.unknownOption"})}_excessArguments(D){if(this._allowExcessArguments)return;let F=this.registeredArguments.length,B=F===1?"":"s",_=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${F} argument${B} but got ${D.length}.`;this.error(_,{code:"commander.excessArguments"})}unknownCommand(){let D=this.args[0],F="";if(this._showSuggestionAfterError){let $=[];this.createHelp().visibleCommands(this).forEach((_)=>{if($.push(_.name()),_.alias())$.push(_.alias())}),F=Q9(D,$)}let B=`error: unknown command '${D}'${F}`;this.error(B,{code:"commander.unknownCommand"})}version(D,F,B){if(D===void 0)return this._version;this._version=D,F=F||"-V, --version",B=B||"output the version number";let $=this.createOption(F,B);return this._versionOptionName=$.attributeName(),this._registerOption($),this.on("option:"+$.name(),()=>{this._outputConfiguration.writeOut(`${D}
59
+ `),this._exit(0,"commander.version",D)}),this}description(D,F){if(D===void 0&&F===void 0)return this._description;if(this._description=D,F)this._argsDescription=F;return this}summary(D){if(D===void 0)return this._summary;return this._summary=D,this}alias(D){if(D===void 0)return this._aliases[0];let F=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)F=this.commands[this.commands.length-1];if(D===F._name)throw Error("Command alias can't be the same as its name");let B=this.parent?._findCommand(D);if(B){let $=[B.name()].concat(B.aliases()).join("|");throw Error(`cannot add alias '${D}' to command '${this.name()}' as already have command '${$}'`)}return F._aliases.push(D),this}aliases(D){if(D===void 0)return this._aliases;return D.forEach((F)=>this.alias(F)),this}usage(D){if(D===void 0){if(this._usage)return this._usage;let F=this.registeredArguments.map((B)=>{return GY(B)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?F:[]).join(" ")}return this._usage=D,this}name(D){if(D===void 0)return this._name;return this._name=D,this}helpGroup(D){if(D===void 0)return this._helpGroupHeading??"";return this._helpGroupHeading=D,this}commandsGroup(D){if(D===void 0)return this._defaultCommandGroup??"";return this._defaultCommandGroup=D,this}optionsGroup(D){if(D===void 0)return this._defaultOptionGroup??"";return this._defaultOptionGroup=D,this}_initOptionGroup(D){if(this._defaultOptionGroup&&!D.helpGroupHeading)D.helpGroup(this._defaultOptionGroup)}_initCommandGroup(D){if(this._defaultCommandGroup&&!D.helpGroup())D.helpGroup(this._defaultCommandGroup)}nameFromFilename(D){return this._name=H2.basename(D,H2.extname(D)),this}executableDir(D){if(D===void 0)return this._executableDir;return this._executableDir=D,this}helpInformation(D){let F=this.createHelp(),B=this._getOutputContext(D);F.prepareContext({error:B.error,helpWidth:B.helpWidth,outputHasColors:B.hasColors});let $=F.formatHelp(this,F);if(B.hasColors)return $;return this._outputConfiguration.stripColor($)}_getOutputContext(D){D=D||{};let F=!!D.error,B,$,_;if(F)B=(Y)=>this._outputConfiguration.writeErr(Y),$=this._outputConfiguration.getErrHasColors(),_=this._outputConfiguration.getErrHelpWidth();else B=(Y)=>this._outputConfiguration.writeOut(Y),$=this._outputConfiguration.getOutHasColors(),_=this._outputConfiguration.getOutHelpWidth();return{error:F,write:(Y)=>{if(!$)Y=this._outputConfiguration.stripColor(Y);return B(Y)},hasColors:$,helpWidth:_}}outputHelp(D){let F;if(typeof D==="function")F=D,D=void 0;let B=this._getOutputContext(D),$={error:B.error,write:B.write,command:this};this._getCommandAndAncestors().reverse().forEach((Q)=>Q.emit("beforeAllHelp",$)),this.emit("beforeHelp",$);let _=this.helpInformation({error:B.error});if(F){if(_=F(_),typeof _!=="string"&&!Buffer.isBuffer(_))throw Error("outputHelp callback must return a string or a Buffer")}if(B.write(_),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",$),this._getCommandAndAncestors().forEach((Q)=>Q.emit("afterAllHelp",$))}helpOption(D,F){if(typeof D==="boolean"){if(D){if(this._helpOption===null)this._helpOption=void 0;if(this._defaultOptionGroup)this._initOptionGroup(this._getHelpOption())}else this._helpOption=null;return this}if(this._helpOption=this.createOption(D??"-h, --help",F??"display help for command"),D||F)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(D){return this._helpOption=D,this._initOptionGroup(D),this}help(D){this.outputHelp(D);let F=Number(AD.exitCode??0);if(F===0&&D&&typeof D!=="function"&&D.error)F=1;this._exit(F,"commander.help","(outputHelp)")}addHelpText(D,F){let B=["beforeAll","before","after","afterAll"];if(!B.includes(D))throw Error(`Unexpected value for position to addHelpText.
60
60
  Expecting one of '${B.join("', '")}'`);let $=`${D}Help`;return this.on($,(_)=>{let Q;if(typeof F==="function")Q=F({error:_.error,command:_.command});else Q=F;if(Q)_.write(`${Q}
61
- `)}),this}_outputHelpIfRequested(D){let F=this._getHelpOption();if(F&&D.find(($)=>F.is($)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function $9(D){return D.map((F)=>{if(!F.startsWith("--inspect"))return F;let B,$="127.0.0.1",_="9229",Q;if((Q=F.match(/^(--inspect(-brk)?)$/))!==null)B=Q[1];else if((Q=F.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(B=Q[1],/^\d+$/.test(Q[3]))_=Q[3];else $=Q[3];else if((Q=F.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)B=Q[1],$=Q[3],_=Q[4];if(B&&_!=="0")return`${B}=${$}:${parseInt(_)+1}`;return F})}function N1(){if(AD.env.NO_COLOR||AD.env.FORCE_COLOR==="0"||AD.env.FORCE_COLOR==="false")return!1;if(AD.env.FORCE_COLOR||AD.env.CLICOLOR_FORCE!==void 0)return!0;return}WY.Command=S1;WY.useColor=N1});var H9=d0((KY)=>{var{Argument:Q9}=D8(),{Command:k1}=_9(),{CommanderError:AY,InvalidArgumentError:Y9}=w3(),{Help:jY}=O1(),{Option:q9}=b1();KY.program=new k1;KY.createCommand=(D)=>new k1(D);KY.createOption=(D,F)=>new q9(D,F);KY.createArgument=(D,F)=>new Q9(D,F);KY.Command=k1;KY.Option=q9;KY.Argument=Q9;KY.Help=jY;KY.CommanderError=AY;KY.InvalidArgumentError=Y9;KY.InvalidOptionArgumentError=Y9});var J9,WM,zM,MM,AM,jM,X9,KM,G9,UM,H2,VM;var B8=V(()=>{J9=f3(H9(),1),{program:WM,createCommand:zM,createArgument:MM,createOption:AM,CommanderError:jM,InvalidArgumentError:X9,InvalidOptionArgumentError:KM,Command:G9,Argument:UM,Option:H2,Help:VM}=J9.default});import{existsSync as z9,statSync as kY}from"fs";import{join as M9}from"path";function W9(D,F){let B=M9(D,F);if(!z9(B))return"missing";if(!kY(B).isDirectory())throw new U(`Component root "${F}" exists at "${B}" but is not a directory.`);return"directory"}function vY(D,F){let B=W9(D,F.singular),$=W9(D,F.plural);if(B==="directory"&&$==="directory")return F.plural;if(B==="directory")return F.singular;if($==="directory")return F.plural;return F.plural}function CY(D,F,B,$,_){if(!_)return;let Y=`${B===$.plural?$.singular:$.plural}/${_}`,q=M9(D,Y);if(!z9(q))return;throw new gD(`Cross-root logical collision for "${F}": selected root "${B}" but "${Y}" already exists.`)}function hF(D,F){let[B,...$]=D.split("/");if(!B)return D;let _=TY.get(B);if(!_)return D;let Q=vY(F,_),Y=$.join("/");if(CY(F,D,Q,_,Y),!Y)return Q;return`${Q}/${Y}`}var IY,TY;var I1=V(()=>{$D();IY={agent:"agents",command:"commands",plugin:"plugins",skill:"skills",tool:"tools",bundle:"bundles",profile:"profiles"},TY=new Map(Object.entries(IY).flatMap(([D,F])=>{let B={singular:D,plural:F};return[[D,B],[F,B]]}))});import{stat as uY}from"fs/promises";import{homedir as PY}from"os";import{isAbsolute as xY,join as A9,relative as yY,resolve as j9}from"path";function fY(D){let F=D.replace(/\\/g,"/");if(F===$8)return".";if(F.startsWith(T1))return F.slice(T1.length);return D}function X0(){let D=process.env.XDG_CONFIG_HOME,F=D&&xY(D)?D:A9(PY(),".config");return A9(F,"opencode")}async function K9(){try{return(await uY(X0())).isDirectory()}catch{return!1}}function n2(D,F,B){if(F){if(!B)return D;return hF(D,B)}let $=fY(D),_=B?j9(B):process.cwd(),Q=j9(_,$8),Y;try{Y=H0(Q,$)}catch(J){if(J instanceof aD)throw new U(`Invalid local target "${D}": ${J.message}`);throw J}let q=yY(Q,Y).replace(/\\/g,"/");if(q==="."||q==="")return $8;let H=B?hF(q,Q):q;return`${T1}${H}`}var $8=".opencode",T1;var k2=V(()=>{I1();$D();c2();T1=`${$8}/`});class V0{cwd;config;constructor(D,F){this.cwd=D,this.config=F}static async requireInitialized(D){let F=await U0(D);if(!F)throw new c("No ocx.jsonc found in .opencode/ or project root. Run 'ocx init' first.");return new V0(D,F)}getRegistries(){return this.config.registries}getComponentPath(){return".opencode"}}class mF{cwd;config;constructor(D,F){this.cwd=D,this.config=F}static async requireInitialized(){let D=X0();if(!await K9())throw new c("Global config not found. Run 'ocx init --global' first.");let F=await U0(D);if(!F)throw new c("Global config not found. Run 'ocx init --global' first.");return new mF(D,F)}getRegistries(){return this.config?.registries??{}}getComponentPath(){return""}}var gF=V(()=>{tD();$D();k2()});import{rename as U9,symlink as yM,unlink as V9}from"fs/promises";async function dF(D,F){let B=`${D}.tmp.${process.pid}`;try{await Bun.write(B,JSON.stringify(F,null,"\t"),{mode:384}),await U9(B,D)}catch($){try{await V9(B)}catch{}throw $}}async function E9(D,F){let B=`${F}.tmp.${process.pid}`;try{let _=await Bun.file(D).arrayBuffer();await Bun.write(B,_,{mode:384}),await U9(B,F)}catch($){try{await V9(B)}catch{}throw $}}var _8=()=>{};import{existsSync as L9,statSync as hY}from"fs";import{homedir as w9}from"os";import _0 from"path";function X2(){let D=process.env.XDG_CONFIG_HOME||_0.join(w9(),".config");return _0.join(D,"opencode","profiles")}function mY(D=process.cwd()){let F=o2(D);if(F)return _0.join(F,"profiles");return _0.join(D,s2,"profiles")}function yD(D){return _0.join(X2(),D)}function O9(D,F=process.cwd()){return _0.join(mY(F),D)}function Q0(D){return _0.join(yD(D),"ocx.jsonc")}function G2(D){return _0.join(yD(D),"opencode.jsonc")}function a2(D){return _0.join(yD(D),"AGENTS.md")}function o2(D){let F=D;while(!0){let B=_0.join(F,s2);if(L9(B)&&hY(B).isDirectory())return B;let $=_0.join(F,".git");if(L9($))return null;let _=_0.dirname(F);if(_===F)return null;F=_}}function I2(){let D=process.env.XDG_CONFIG_HOME||_0.join(w9(),".config");return _0.join(D,"opencode","ocx.jsonc")}var J2="ocx.jsonc",v1="opencode.jsonc",s2=".opencode";var G0=()=>{};var s0,pM;var Q8=V(()=>{_2();fF();s0=W.string().min(1,"Profile name is required").max(32,"Profile name must be 32 characters or less").regex(/^[a-zA-Z][a-zA-Z0-9._-]*$/,"Profile name must start with a letter and contain only alphanumeric characters, dots, underscores, or hyphens"),pM=W.object({name:s0,ocx:Y2,opencode:W.record(W.unknown()).optional(),hasAgents:W.boolean()})});import{mkdir as b9,readdir as gY,rename as dY,rm as cY,stat as C1}from"fs/promises";function pY(D){if(D.length===0)return"Unknown parse error";let F=D[0];if(!F)return"Unknown parse error";return`${K2(F.error)} at offset ${F.offset}`}function R9(D,F){let B=[],$=ND(D,B,{allowTrailingComma:!0});if(B.length>0){let _=pY(B);throw new c(`Invalid JSONC in ${F}: ${_}`)}return $}function iY(D,F,B){let $=Y2.safeParse(D);if(!$.success){let _=$.error.issues[0],Q=_?.path.length?_.path.join("."):"root",Y=_?.message??"Invalid profile OCX configuration";throw new c(`Invalid profile "${B}" ocx.jsonc at ${F}: ${Q} ${Y}`)}return $.data}function nY(D,F,B){if(!D||typeof D!=="object"||Array.isArray(D))throw new c(`Invalid profile "${B}" opencode.jsonc at ${F}: root must be an object`);return D}function Z9(D,F){if(D.trim().length===0)throw new c(`Invalid profile from ${F}: value cannot be empty or whitespace`);return D}class uD{cwd;constructor(D=process.cwd()){this.cwd=D}get profilesDir(){return X2()}static create(D){return new uD(D??process.cwd())}static async requireInitialized(){let D=uD.create();if(!await D.isInitialized())throw new CF;return D}async isInitialized(){try{return(await C1(this.profilesDir)).isDirectory()}catch{return!1}}async ensureInitialized(){if(!await this.isInitialized())throw new CF}async list(){return await this.ensureInitialized(),(await gY(this.profilesDir,{withFileTypes:!0,encoding:"utf8"})).filter((F)=>F.isDirectory()&&!F.name.startsWith(".")).map((F)=>F.name).sort()}async exists(D){let F=yD(D);try{return(await C1(F)).isDirectory()}catch{return!1}}async get(D){if(!await this.exists(D))throw new CD(D);let F=Q0(D),B=Bun.file(F);if(!await B.exists())throw new c(`Profile "${D}" is missing ocx.jsonc. Expected at: ${F}`);let $=await B.text(),_=R9($,F),Q=iY(_,F,D),Y=G2(D),q=Bun.file(Y),H;if(await q.exists()){let M=await q.text(),A=R9(M,Y);H=nY(A,Y,D)}let J=a2(D),z=await Bun.file(J).exists();return{name:D,ocx:Q,opencode:H,hasAgents:z}}async getLayered(D,F){let B=O9(D,F),$=!1;try{$=(await C1(B)).isDirectory()}catch{$=!1}if($)throw new W1(D,B);return this.get(D)}async add(D){let F=s0.safeParse(D);if(!F.success)throw new C0(D,F.error.errors[0]?.message??"Invalid name");if(await this.exists(D))throw new O2(D);let B=yD(D);await b9(B,{recursive:!0,mode:448});let $=Q0(D);if(!await Bun.file($).exists())await Bun.write($,lY,{mode:384});let Q=G2(D);if(!await Bun.file(Q).exists())await dF(Q,{});let q=a2(D);if(!await Bun.file(q).exists()){let J=`# Profile Instructions
61
+ `)}),this}_outputHelpIfRequested(D){let F=this._getHelpOption();if(F&&D.find(($)=>F.is($)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function Y9(D){return D.map((F)=>{if(!F.startsWith("--inspect"))return F;let B,$="127.0.0.1",_="9229",Q;if((Q=F.match(/^(--inspect(-brk)?)$/))!==null)B=Q[1];else if((Q=F.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(B=Q[1],/^\d+$/.test(Q[3]))_=Q[3];else $=Q[3];else if((Q=F.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)B=Q[1],$=Q[3],_=Q[4];if(B&&_!=="0")return`${B}=${$}:${parseInt(_)+1}`;return F})}function k1(){if(AD.env.NO_COLOR||AD.env.FORCE_COLOR==="0"||AD.env.FORCE_COLOR==="false")return!1;if(AD.env.FORCE_COLOR||AD.env.CLICOLOR_FORCE!==void 0)return!0;return}jY.Command=I1;jY.useColor=k1});var W9=c0((LY)=>{var{Argument:H9}=F8(),{Command:T1}=q9(),{CommanderError:VY,InvalidArgumentError:J9}=O3(),{Help:EY}=Z1(),{Option:X9}=R1();LY.program=new T1;LY.createCommand=(D)=>new T1(D);LY.createOption=(D,F)=>new X9(D,F);LY.createArgument=(D,F)=>new H9(D,F);LY.Command=T1;LY.Option=X9;LY.Argument=H9;LY.Help=EY;LY.CommanderError=VY;LY.InvalidArgumentError=J9;LY.InvalidOptionArgumentError=J9});var G9,VM,EM,LM,wM,OM,z9,bM,M9,ZM,J2,RM;var $8=V(()=>{G9=h3(W9(),1),{program:VM,createCommand:EM,createArgument:LM,createOption:wM,CommanderError:OM,InvalidArgumentError:z9,InvalidOptionArgumentError:bM,Command:M9,Argument:ZM,Option:J2,Help:RM}=G9.default});import{existsSync as j9,statSync as CY}from"fs";import{join as K9}from"path";function A9(D,F){let B=K9(D,F);if(!j9(B))return"missing";if(!CY(B).isDirectory())throw new U(`Component root "${F}" exists at "${B}" but is not a directory.`);return"directory"}function yY(D,F){let B=A9(D,F.singular),$=A9(D,F.plural);if(B==="directory"&&$==="directory")return F.plural;if(B==="directory")return F.singular;if($==="directory")return F.plural;return F.plural}function xY(D,F,B,$,_){if(!_)return;let Y=`${B===$.plural?$.singular:$.plural}/${_}`,q=K9(D,Y);if(!j9(q))return;throw new dD(`Cross-root logical collision for "${F}": selected root "${B}" but "${Y}" already exists.`)}function hF(D,F){let[B,...$]=D.split("/");if(!B)return D;let _=PY.get(B);if(!_)return D;let Q=yY(F,_),Y=$.join("/");if(xY(F,D,Q,_,Y),!Y)return Q;return`${Q}/${Y}`}var uY,PY;var v1=V(()=>{$D();uY={agent:"agents",command:"commands",plugin:"plugins",skill:"skills",tool:"tools",bundle:"bundles",profile:"profiles"},PY=new Map(Object.entries(uY).flatMap(([D,F])=>{let B={singular:D,plural:F};return[[D,B],[F,B]]}))});import{stat as fY}from"fs/promises";import{homedir as hY}from"os";import{isAbsolute as mY,join as U9,relative as gY,resolve as V9}from"path";function dY(D){let F=D.replace(/\\/g,"/");if(F===_8)return".";if(F.startsWith(C1))return F.slice(C1.length);return D}function W0(){let D=process.env.XDG_CONFIG_HOME,F=D&&mY(D)?D:U9(hY(),".config");return U9(F,"opencode")}async function E9(){try{return(await fY(W0())).isDirectory()}catch{return!1}}function n2(D,F,B){if(F){if(!B)return D;return hF(D,B)}let $=dY(D),_=B?V9(B):process.cwd(),Q=V9(_,_8),Y;try{Y=J0(Q,$)}catch(J){if(J instanceof oD)throw new U(`Invalid local target "${D}": ${J.message}`);throw J}let q=gY(Q,Y).replace(/\\/g,"/");if(q==="."||q==="")return _8;let H=B?hF(q,Q):q;return`${C1}${H}`}var _8=".opencode",C1;var k2=V(()=>{v1();$D();c2();C1=`${_8}/`});class U0{cwd;config;constructor(D,F){this.cwd=D,this.config=F}static async requireInitialized(D){let F=await K0(D);if(!F)throw new c("No ocx.jsonc found in .opencode/ or project root. Run 'ocx init' first.");return new U0(D,F)}getRegistries(){return this.config.registries}getComponentPath(){return".opencode"}}class mF{cwd;config;constructor(D,F){this.cwd=D,this.config=F}static async requireInitialized(){let D=W0();if(!await E9())throw new c("Global config not found. Run 'ocx init --global' first.");let F=await K0(D);if(!F)throw new c("Global config not found. Run 'ocx init --global' first.");return new mF(D,F)}getRegistries(){return this.config?.registries??{}}getComponentPath(){return""}}var gF=V(()=>{eD();$D();k2()});import{rename as L9,symlink as lM,unlink as w9}from"fs/promises";async function dF(D,F){let B=`${D}.tmp.${process.pid}`;try{await Bun.write(B,JSON.stringify(F,null,"\t"),{mode:384}),await L9(B,D)}catch($){try{await w9(B)}catch{}throw $}}async function O9(D,F){let B=`${F}.tmp.${process.pid}`;try{let _=await Bun.file(D).arrayBuffer();await Bun.write(B,_,{mode:384}),await L9(B,F)}catch($){try{await w9(B)}catch{}throw $}}var Q8=()=>{};import{existsSync as b9,statSync as cY}from"fs";import{readFile as lY,stat as pY}from"fs/promises";import{homedir as iY}from"os";import uD from"path";function nY(D={}){let F=D.xdgConfigHome??process.env.XDG_CONFIG_HOME;if(F&&F.trim().length>0)return uD.resolve(F);let B=D.homeDir??iY();return uD.resolve(B,".config")}function Z9(D,F){let B=uD.resolve(D),$=uD.resolve(F),_=uD.relative(B,$);if(_==="")return!0;if(_==="..")return!1;if(_.startsWith(`..${uD.sep}`))return!1;return!uD.isAbsolute(_)}function Y8(D={}){return uD.join(nY(D),"opencode")}function P1(D,F={}){let B=Y8(F);if(!Z9(B,D))return"local-project";let $=uD.join(B,"profiles");if(Z9($,D))return"global-profile-root";return"global-root"}function X2(D={}){return uD.join(Y8(D),"profiles")}function sY(D=process.cwd()){let F=o2(D);if(F)return uD.join(F,"profiles");return uD.join(D,s2,"profiles")}function fD(D){return uD.join(X2(),D)}function R9(D,F=process.cwd()){return uD.join(sY(F),D)}function _0(D){return uD.join(fD(D),"ocx.jsonc")}function W2(D){return uD.join(fD(D),"opencode.jsonc")}function a2(D){return uD.join(fD(D),"AGENTS.md")}function o2(D){let F=D;while(!0){let B=uD.join(F,s2);if(b9(B)&&cY(B).isDirectory())return B;let $=uD.join(F,".git");if(b9($))return null;let _=uD.dirname(F);if(_===F)return null;F=_}}function cF(){return uD.join(Y8(),y0)}async function N9(D={}){let F=uD.join(Y8(D),y0),B;try{B=await pY(F)}catch($){let _=$.code;if(_==="ENOENT"||_==="ENOTDIR")throw new I2("missing",F);throw new I2("read-failed",F,$ instanceof Error?$.message:String($))}if(!B.isFile())throw new I2("not-file",F);try{let $=await lY(F,"utf8");return{path:F,content:$}}catch($){throw new I2("read-failed",F,$ instanceof Error?$.message:String($))}}var y0="ocx.jsonc",u1="opencode.jsonc",s2=".opencode",I2;var Q0=V(()=>{I2=class I2 extends Error{reason;configPath;constructor(D,F,B){let $=D==="missing"?`Required global config is missing at "${F}".`:D==="not-file"?`Required global config target is not a file: "${F}".`:`Failed to read required global config at "${F}": ${B??"Unknown read error"}`;super($);this.reason=D;this.configPath=F;this.name="RequiredGlobalConfigReadError"}}});var a0,eM;var q8=V(()=>{Q2();fF();a0=G.string().min(1,"Profile name is required").max(32,"Profile name must be 32 characters or less").regex(/^[a-zA-Z][a-zA-Z0-9._-]*$/,"Profile name must start with a letter and contain only alphanumeric characters, dots, underscores, or hyphens"),eM=G.object({name:a0,ocx:q2,opencode:G.record(G.unknown()).optional(),hasAgents:G.boolean()})});import{mkdir as S9,readdir as aY,rename as oY,rm as rY,stat as y1}from"fs/promises";function eY(D){if(D.length===0)return"Unknown parse error";let F=D[0];if(!F)return"Unknown parse error";return`${K2(F.error)} at offset ${F.offset}`}function k9(D,F){let B=[],$=ND(D,B,{allowTrailingComma:!0});if(B.length>0){let _=eY(B);throw new c(`Invalid JSONC in ${F}: ${_}`)}return $}function Dq(D,F,B){let $=q2.safeParse(D);if(!$.success){let _=$.error.issues[0],Q=_?.path.length?_.path.join("."):"root",Y=_?.message??"Invalid profile OCX configuration";throw new c(`Invalid profile "${B}" ocx.jsonc at ${F}: ${Q} ${Y}`)}return $.data}function Fq(D,F,B){if(!D||typeof D!=="object"||Array.isArray(D))throw new c(`Invalid profile "${B}" opencode.jsonc at ${F}: root must be an object`);return D}function I9(D,F){if(D.trim().length===0)throw new c(`Invalid profile from ${F}: value cannot be empty or whitespace`);return D}class PD{cwd;constructor(D=process.cwd()){this.cwd=D}get profilesDir(){return X2()}static create(D){return new PD(D??process.cwd())}static async requireInitialized(){let D=PD.create();if(!await D.isInitialized())throw new CF;return D}async isInitialized(){try{return(await y1(this.profilesDir)).isDirectory()}catch{return!1}}async ensureInitialized(){if(!await this.isInitialized())throw new CF}async list(){return await this.ensureInitialized(),(await aY(this.profilesDir,{withFileTypes:!0,encoding:"utf8"})).filter((F)=>F.isDirectory()&&!F.name.startsWith(".")).map((F)=>F.name).sort()}async exists(D){let F=fD(D);try{return(await y1(F)).isDirectory()}catch{return!1}}async get(D){if(!await this.exists(D))throw new CD(D);let F=_0(D),B=Bun.file(F);if(!await B.exists())throw new c(`Profile "${D}" is missing ocx.jsonc. Expected at: ${F}`);let $=await B.text(),_=k9($,F),Q=Dq(_,F,D),Y=W2(D),q=Bun.file(Y),H;if(await q.exists()){let M=await q.text(),A=k9(M,Y);H=Fq(A,Y,D)}let J=a2(D),z=await Bun.file(J).exists();return{name:D,ocx:Q,opencode:H,hasAgents:z}}async getLayered(D,F){let B=R9(D,F),$=!1;try{$=(await y1(B)).isDirectory()}catch{$=!1}if($)throw new M1(D,B);return this.get(D)}async add(D){let F=a0.safeParse(D);if(!F.success)throw new C0(D,F.error.errors[0]?.message??"Invalid name");if(await this.exists(D))throw new O2(D);let B=fD(D);await S9(B,{recursive:!0,mode:448});let $=_0(D);if(!await Bun.file($).exists())await Bun.write($,tY,{mode:384});let Q=W2(D);if(!await Bun.file(Q).exists())await dF(Q,{});let q=a2(D);if(!await Bun.file(q).exists()){let J=`# Profile Instructions
62
62
 
63
63
  <!-- Add your custom instructions for this profile here -->
64
64
  <!-- These will be included when running \`ocx opencode -p ${D}\` -->
65
- `;await Bun.write(q,J,{mode:384})}}async remove(D){if(!await this.exists(D))throw new CD(D);if((await this.list()).length<=1)throw Error("Cannot delete the last profile. At least one profile must exist.");let B=yD(D);await cY(B,{recursive:!0})}async move(D,F){let B=s0.safeParse(D);if(!B.success)throw new C0(D,B.error.errors[0]?.message??"Invalid name");let $=s0.safeParse(F);if(!$.success)throw new C0(F,$.error.errors[0]?.message??"Invalid name");if(await this.ensureInitialized(),!await this.exists(D))throw new CD(D);if(D===F)return{warnActiveProfile:!1};if(await this.exists(F))throw new gD(`Cannot move: profile "${F}" already exists. Remove it first with 'ocx profile rm ${F} --global'.`);let _=process.env.OCX_PROFILE===D,Q=yD(D),Y=yD(F);try{await dY(Q,Y)}catch(q){if(q instanceof Error&&"code"in q){let H=q.code;if(H==="EEXIST"||H==="ENOTEMPTY")throw new gD(`Cannot move: profile "${F}" already exists. Remove it first with 'ocx profile rm ${F} --global'.`);if(H==="ENOENT")throw new CD(D)}throw q}return{warnActiveProfile:_}}async resolveProfile(D){if(D!==void 0){let $=Z9(D,"CLI option --profile");if(!await this.exists($))throw new CD($);return $}let F=process.env.OCX_PROFILE;if(F!==void 0){let $=Z9(F,"environment variable OCX_PROFILE");if(!await this.exists($))throw new CD($);return $}let B="default";if(!await this.exists(B))throw new CD(B);return B}async initialize(){await b9(this.profilesDir,{recursive:!0,mode:448}),await this.add("default")}}var N9,lY=`{
65
+ `;await Bun.write(q,J,{mode:384})}}async remove(D){if(!await this.exists(D))throw new CD(D);if((await this.list()).length<=1)throw Error("Cannot delete the last profile. At least one profile must exist.");let B=fD(D);await rY(B,{recursive:!0})}async move(D,F){let B=a0.safeParse(D);if(!B.success)throw new C0(D,B.error.errors[0]?.message??"Invalid name");let $=a0.safeParse(F);if(!$.success)throw new C0(F,$.error.errors[0]?.message??"Invalid name");if(await this.ensureInitialized(),!await this.exists(D))throw new CD(D);if(D===F)return{warnActiveProfile:!1};if(await this.exists(F))throw new dD(`Cannot move: profile "${F}" already exists. Remove it first with 'ocx profile rm ${F} --global'.`);let _=process.env.OCX_PROFILE===D,Q=fD(D),Y=fD(F);try{await oY(Q,Y)}catch(q){if(q instanceof Error&&"code"in q){let H=q.code;if(H==="EEXIST"||H==="ENOTEMPTY")throw new dD(`Cannot move: profile "${F}" already exists. Remove it first with 'ocx profile rm ${F} --global'.`);if(H==="ENOENT")throw new CD(D)}throw q}return{warnActiveProfile:_}}async resolveProfile(D){if(D!==void 0){let $=I9(D,"CLI option --profile");if(!await this.exists($))throw new CD($);return $}let F=process.env.OCX_PROFILE;if(F!==void 0){let $=I9(F,"environment variable OCX_PROFILE");if(!await this.exists($))throw new CD($);return $}let B="default";if(!await this.exists(B))throw new CD(B);return B}async initialize(){await S9(this.profilesDir,{recursive:!0,mode:448}),await this.add("default")}}var T9,tY=`{
66
66
  "$schema": "https://ocx.kdco.dev/schemas/profile.json",
67
67
  "registries": {},
68
68
  "renameWindow": true,
@@ -76,23 +76,23 @@ Expecting one of '${B.join("', '")}'`);let $=`${D}Help`;return this.on($,(_)=>{l
76
76
  ],
77
77
  "include": []
78
78
  }
79
- `;var a0=V(()=>{b0();fF();$D();_8();G0();Q8();N9={$schema:"https://ocx.kdco.dev/schemas/profile.json",registries:{},renameWindow:!0,exclude:["**/CLAUDE.md","**/CONTEXT.md","**/.opencode/**","**/opencode.jsonc","**/opencode.json"],include:[]}});function S9(D,F,B){let $=(_)=>D(_,...F);return B===void 0?$:Object.assign($,{lazy:B,lazyArgs:F})}var k9=()=>{};function I9(D,F,B){let $=D.length-F.length;if($===0)return D(...F);if($===1)return S9(D,F,B);throw Error("Wrong number of arguments")}var T9=V(()=>{k9()});function u1(D){if(typeof D!="object"||!D)return!1;let F=Object.getPrototypeOf(D);return F===null||F===Object.prototype}var v9=()=>{};function P1(...D){return I9(C9,D)}function C9(D,F){let B={...D,...F};for(let $ in F){if(!($ in D))continue;let{[$]:_}=D;if(!u1(_))continue;let{[$]:Q}=F;u1(Q)&&(B[$]=C9(_,Q))}return B}var u9=V(()=>{T9();v9()});var P9=V(()=>{u9()});function x9(D){let F=D.startsWith("npm:"),B=F?D.slice(4):D;if(!B)return D;if(B.startsWith("@")){let Q=B.indexOf("/");if(Q===-1)return D;let q=B.slice(Q+1).indexOf("@");if(q===-1)return D;let H=B.slice(0,Q+1+q);return F?`npm:${H}`:H}let $=B.indexOf("@");if($===-1)return D;let _=B.slice(0,$);return F?`npm:${_}`:_}function sY(D){let F=new Map;for(let $=D.length-1;$>=0;$--){let _=D[$],Q=x9(_);if(!F.has(Q))F.set(Q,$)}let B=[];for(let[$,_]of D.entries()){let Q=x9(_);if(F.get(Q)===$)B.push(_)}return B}function Y8(D,F){let B=P1(D,F);if(Array.isArray(D.plugin)&&Array.isArray(F.plugin))B.plugin=sY([...D.plugin,...F.plugin]);else if(Array.isArray(D.plugin))B.plugin=D.plugin;else if(Array.isArray(F.plugin))B.plugin=F.plugin;if(Array.isArray(D.instructions)&&Array.isArray(F.instructions))B.instructions=Array.from(new Set([...D.instructions,...F.instructions]));else if(Array.isArray(D.instructions))B.instructions=D.instructions;else if(Array.isArray(F.instructions))B.instructions=F.instructions;return B}var x1=V(()=>{P9()});import{existsSync as aY,readFileSync as oY}from"fs";import{dirname as rY,isAbsolute as MA,resolve as y1}from"path";function tY(D){let F=y1(D);while(!0){let B=y1(F,".git");if(aY(B))try{let _=WF("fs").statSync(B);if(_.isDirectory())return F;if(_.isFile()){if(oY(B,"utf8").match(/^gitdir:\s*(.+)$/m)?.[1])return F}}catch{}let $=rY(F);if($===F)return null;F=$}}function f1(D){let F=y1(D);return tY(F)??F}var y9=()=>{};import{existsSync as eY}from"fs";import*as r2 from"path";var{Glob:Dq}=globalThis.Bun;function f9(D){return D.startsWith("http://")||D.startsWith("https://")}function Fq(D,F){if(f9(D))return;if(r2.isAbsolute(D)||r2.win32.isAbsolute(D))throw new U(`Absolute path not allowed in registry instructions: "${D}" (from ${F})`);if(D.startsWith("~"))throw new U(`Home directory path not allowed in registry instructions: "${D}" (from ${F})`);if(D.split(/[/\\]/).some(($)=>$===".."))throw new U(`Path traversal (..) not allowed in registry instructions: "${D}" (from ${F})`)}function Bq(D,F,B){if(f9(D))return[D];if(Fq(D,B),D.includes("*")||D.includes("?")||D.includes("[")){let Q=new Dq(D),Y=[];for(let q of Q.scanSync(F)){let H=r2.join(F,q);Y.push(H)}return Y}let _=r2.join(F,D);if(!eY(_))throw new U(`Registry instruction file not found: "${D}" (from ${B})
80
- Expected at: ${_}`);return[_]}function h9(D,F,B){let $=[],_=new Set;for(let Q of D){let Y=Bq(Q,F,B);for(let q of Y)if(!_.has(q))_.add(q),$.push(q)}return $}var m9=V(()=>{$D()});import{existsSync as t2,readFileSync as d9,statSync as $q}from"fs";import{homedir as _q}from"os";import{join as E0,relative as c9}from"path";var{Glob:q8}=globalThis.Bun;function Qq(D){return D==="local-config"||D==="cli"||D==="env"}function h1(D,F){if(D.trim().length===0)throw new c(`Invalid profile from ${F}: value cannot be empty or whitespace`);return D}function l9(D){if(D.length===0)return"Unknown parse error";let F=D[0];if(!F)return"Unknown parse error";return`${K2(F.error)} at offset ${F.offset}`}function g9(D){let F;try{F=d9(D,"utf8")}catch(Q){let Y=Q instanceof Error?Q.message:"Unknown read error";throw new c(`Failed to read local config at ${D}: ${Y}`)}let B=[],$=ND(F,B,{allowTrailingComma:!0});if(B.length>0){let Q=l9(B);throw new c(`Invalid JSONC in local config at ${D}: ${Q}`)}let _=R2.safeParse($);if(!_.success){let Q=_.error.issues[0],Y=Q?.path.length?Q.path.join("."):"root",q=Q?.message??"Invalid OCX config";throw new c(`Invalid local config at ${D}: ${Y} ${q}`)}return _.data}function Yq(D){let F;try{F=d9(D,"utf8")}catch(_){let Q=_ instanceof Error?_.message:"Unknown read error";throw new c(`Failed to read local OpenCode config at ${D}: ${Q}`)}let B=[],$=ND(F,B,{allowTrailingComma:!0});if(B.length>0){let _=l9(B);throw new c(`Invalid JSONC in local OpenCode config at ${D}: ${_}`)}if(!$||typeof $!=="object"||Array.isArray($))throw new c(`Invalid local OpenCode config at ${D}: root must be an object`);return $}function Hq(D,F,B){let $=[],_=F;while(!0){let Q=E0(_,D);if(t2(Q)&&$q(Q).isFile()){let q=c9(B,Q);$.push(q)}if(_===B)break;let Y=E0(_,"..");if(Y===_)break;_=Y}return $}function Jq(D,F){for(let B of qq){let $=Hq(B,D,F);if($.length>0)return $}return[]}function H8(D){return D.startsWith("./")?D.slice(2):D}function Xq(D,F,B){return D.filter(($)=>{for(let _ of B)if(new q8(H8(_)).match($))return!0;for(let _ of F)if(new q8(H8(_)).match($))return!1;return!0})}async function Gq(D){let F=await J0(D);if(!F||Object.keys(F.installed).length===0)return[];let B=[];for(let[$,_]of Object.entries(F.installed)){if(!_.opencode?.instructions)continue;let Q=_.opencode.instructions;if(!Array.isArray(Q))continue;let Y=`${_.registryName}/${_.name} (${$})`,q=h9(Q,D,Y);B.push(...q)}return Array.from(new Set(B))}class o0{cwd;profileName;profile;localConfigDir;registryInstructions;cachedConfig=null;constructor(D,F,B,$,_){this.cwd=D,this.profileName=F,this.profile=B,this.localConfigDir=$,this.registryInstructions=_}static async create(D,F){let B=uD.create(D),$=null,_="none",Q=o2(D);if(Q){let X=E0(Q,J2);if(t2(X)){let z=g9(X);if(z.profile!==void 0)$=h1(z.profile,`local config at ${X}`),_="local-config"}}if($===null){if(F?.profile!==void 0)$=h1(F.profile,"CLI option --profile"),_="cli";else if(process.env.OCX_PROFILE!==void 0)$=h1(process.env.OCX_PROFILE,"environment variable OCX_PROFILE"),_="env"}let Y=await B.isInitialized();if(Qq(_)&&!Y)throw new CF;let q=null;if(Y)if($!==null)q=await B.getLayered($,D);else try{$=await B.resolveProfile(),q=await B.getLayered($,D),_="default"}catch(X){if(!(X instanceof CD)||X.profile!=="default")throw X;$=null,q=null,_="none"}let H;if(q)H=yD($);else if(Q)H=E0(Q,"..");else H=X0();let J=await Gq(H);return new o0(D,$,q,Q,J)}resolve(){if(this.cachedConfig)return this.cachedConfig;let D={},F=s2,B={};if(this.profile){if(D={...D,...this.profile.ocx.registries},this.profile.ocx.componentPath)F=this.profile.ocx.componentPath;if(this.profile.opencode)B=this.mergeOpencode(B,this.profile.opencode)}let $=this.shouldLoadLocalConfig();if(!this.profile&&$&&this.localConfigDir){let Q=this.loadLocalOcxConfig();if(Q)D=Q.registries}if(this.localConfigDir){let Q=this.loadLocalOpencodeConfig();if(Q)B=this.mergeOpencode(B,Q)}let _=this.discoverInstructions();return this.cachedConfig={registries:D,componentPath:F,opencode:B,instructions:_,profileName:this.profileName},this.cachedConfig}resolveWithOrigin(){let D=new Map,F={},B=s2,$={};if(D.set("componentPath",{path:"",source:"default"}),this.profile){let Y=`~/.config/opencode/profiles/${this.profileName}/ocx.jsonc`;for(let[q,H]of Object.entries(this.profile.ocx.registries))F[q]=H,D.set(`registries.${q}`,{path:Y,source:"global-profile"});if(this.profile.ocx.componentPath)B=this.profile.ocx.componentPath,D.set("componentPath",{path:Y,source:"global-profile"});if(this.profile.opencode){$=this.mergeOpencode($,this.profile.opencode);let q=`~/.config/opencode/profiles/${this.profileName}/opencode.jsonc`;for(let H of Object.keys(this.profile.opencode))D.set(`opencode.${H}`,{path:q,source:"global-profile"})}}let _=this.shouldLoadLocalConfig();if(!this.profile&&_&&this.localConfigDir){let Y=this.loadLocalOcxConfig();if(Y){let q=E0(this.localConfigDir,J2);for(let[H,J]of Object.entries(Y.registries))F[H]=J,D.set(`registries.${H}`,{path:q,source:"local-config"})}}if(this.localConfigDir){let Y=this.loadLocalOpencodeConfig();if(Y){$=this.mergeOpencode($,Y);let q=E0(this.localConfigDir,v1);for(let H of Object.keys(Y))D.set(`opencode.${H}`,{path:q,source:"local-opencode"})}}let Q=this.discoverInstructions();return{registries:F,componentPath:B,opencode:$,instructions:Q,profileName:this.profileName,origins:D}}shouldLoadLocalConfig(){if(!this.profile?.ocx.exclude)return!0;if(!this.localConfigDir)return!0;let F=f1(this.cwd),B=c9(F,this.localConfigDir),$=this.profile.ocx.exclude??[],_=this.profile.ocx.include??[];for(let Q of _){let Y=new q8(H8(Q));if(Y.match(`${B}/`)||Y.match(B))return!0}for(let Q of $){let Y=new q8(H8(Q));if(Y.match(`${B}/`)||Y.match(`${B}/**`))return!1}return!0}loadLocalOcxConfig(){if(!this.localConfigDir)return null;let D=E0(this.localConfigDir,J2);if(!t2(D))return null;return{registries:g9(D).registries}}loadLocalOpencodeConfig(){if(!this.localConfigDir)return null;let D=E0(this.localConfigDir,v1);if(!t2(D))return null;return Yq(D)}discoverInstructions(){let D=[],F=X0(),B=E0(F,"AGENTS.md");if(t2(B))D.push(B);else if(!process.env.OPENCODE_DISABLE_CLAUDE_CODE_PROMPT){let X=E0(_q(),".claude","CLAUDE.md");if(t2(X))D.push(X)}if(this.profile&&this.profileName){let X=E0(yD(this.profileName),"AGENTS.md");if(t2(X))D.push(X)}let $=this.loadRegistryInstructions();D.push(...$);let _=f1(this.cwd),Q=Jq(this.cwd,_),Y=this.profile?.ocx.exclude??[],q=this.profile?.ocx.include??[],J=Xq(Q,Y,q).map((X)=>E0(_,X));return D.push(...J),D}loadRegistryInstructions(){return this.registryInstructions}mergeOpencode(D,F){return Y8(D,F)}getRegistries(){return this.resolve().registries}getComponentPath(){return this.resolve().componentPath}getProfileName(){return this.profileName}getCwd(){return this.cwd}getProfile(){return this.profile}}var qq;var O3=V(()=>{b0();a0();G0();x1();tD();$D();y9();m9();k2();qq=["AGENTS.md","CLAUDE.md","CONTEXT.md"]});function eD(D){return typeof D==="object"&&D!==null&&!Array.isArray(D)&&Object.getPrototypeOf(D)===Object.prototype}var r9={};j2(r9,{fetchRegistryIndex:()=>T2,fetchFileContent:()=>e2,fetchComponentVersion:()=>W8,fetchComponent:()=>R3,classifyRegistryIndexIssue:()=>o9,_clearFetcherCacheForTests:()=>Lq});import{posix as Wq}from"path";function Aq(D,F){return new v0(`Registry at ${D} uses an incompatible format (${F.issue}). ${F.remediation}`,{url:D,issue:F.issue,remediation:F.remediation,...F.schemaUrl!==void 0&&{schemaUrl:F.schemaUrl},...F.supportedMajor!==void 0&&{supportedMajor:F.supportedMajor},...F.detectedMajor!==void 0&&{detectedMajor:F.detectedMajor}})}function i9(D,F){if(typeof D!=="string")throw new U(`Invalid ${F}: expected string, got ${typeof D}`);let B=G8[D]??D,$=uF.safeParse(B);if(!$.success)throw new U(`Unsupported component type "${D}" in ${F}. Expected one of: ${uF.options.join(", ")}`);return $.data}function n9(D){return typeof D==="string"&&Object.hasOwn(G8,D)}function X8(D){return D.startsWith(".opencode/")||D.startsWith(".opencode\\")}function s9(D){if(!eD(D)||!Array.isArray(D.files))return[];let F=[];for(let[B,$]of D.files.entries()){if(typeof $==="string"){if(!X8($))continue;F.push({path:`files[${B}]`,target:$});continue}if(!eD($)||typeof $.target!=="string")continue;if(!X8($.target))continue;F.push({path:`files[${B}].target`,target:$.target})}return F}function jq(D){if(!eD(D))return[];let F=D.components;if(!Array.isArray(F))return[];let B=[];for(let[$,_]of F.entries()){if(!eD(_))continue;let Q=_.type;if(!n9(Q))continue;B.push({path:`components[${$}].type`,type:Q})}return B}function Kq(D){if(!eD(D))return!1;if(typeof D.type==="string"&&D.type.startsWith("ocx:"))return!0;return s9(D).length>0}async function Uq(D){let F=xD(D),B=b3.get(F);if(B)return B;try{await T2(F)}catch(_){if(_ instanceof RD||_ instanceof MD)return null;throw _}if(!b3.has(F))return null;let $=b3.get(F);if(!$)throw Error(`Missing registry schema mode cache entry for ${F}`);return $}function p9(D,F){if(D.includes("\x00"))throw new U(`Unsafe target "${D}" in ${F}: null bytes are not allowed`);if(D.includes("%"))throw new U(`Unsafe target "${D}" in ${F}: encoded paths are not allowed`);if(D.includes("\\"))throw new U(`Unsafe target "${D}" in ${F}: Windows separators are not allowed`);if(D.startsWith("/")||D.startsWith("//")||/^[a-zA-Z]:/.test(D))throw new U(`Unsafe target "${D}" in ${F}: absolute paths are not allowed`);let B=D.startsWith(".opencode/")?D.slice(10):D;if(!B)throw new U(`Unsafe target "${D}" in ${F}: missing path after .opencode/`);let $=B.split("/");if($.some((J)=>J.length===0))throw new U(`Unsafe target "${D}" in ${F}: empty path segments are not allowed`);if($.some((J)=>J==="."||J===".."))throw new U(`Unsafe target "${D}" in ${F}: traversal segments are not allowed`);let[_,...Q]=$;if(!_)throw new U(`Unsafe target "${D}" in ${F}: missing path root segment`);let q=[zq[_]??_,...Q].join("/"),H=Wq.normalize(q);if(H!==q)throw new U(`Unsafe target "${D}" in ${F}: path normalization is ambiguous`);if(H==="."||H===".."||H.startsWith("../"))throw new U(`Unsafe target "${D}" in ${F}: target escapes project root`);return H}function Vq(D,F){if(!eD(D))return D;let B={...D};if(Object.hasOwn(B,"type"))B.type=i9(B.type,`${F}.type`);if(Array.isArray(B.files))B.files=B.files.map(($,_)=>{if(typeof $==="string"){if(!X8($))return $;return p9($,`${F}.files[${_}]`)}if(!eD($))return $;let Q=$.target;if(typeof Q!=="string")return $;if(!X8(Q))return $;return{...$,target:p9(Q,`${F}.files[${_}].target`)}});return B}function Eq(D,F){if(!eD(D))throw new v0(`Registry at ${F} uses legacy schema v1 but does not expose an object index payload.`,{url:F,issue:"legacy-schema-v1",remediation:"Publish an object index with author/components fields, or upgrade to schema v2."});let B=D.components;if(!Array.isArray(B))throw new v0(`Registry at ${F} uses legacy schema v1 but the components field is missing or invalid.`,{url:F,issue:"legacy-schema-v1",remediation:"Ensure the legacy index has a components array, or upgrade to schema v2."});let $=B.map((_,Q)=>{if(!eD(_))throw new U(`Invalid index component at components[${Q}]: expected object, got ${typeof _}`);let{name:Y,description:q}=_;if(typeof Y!=="string")throw new U(`Invalid index component name at components[${Q}].name`);if(typeof q!=="string")throw new U(`Invalid index component description at components[${Q}].description`);return{name:Y,type:i9(_.type,`components[${Q}].type`),description:q}});return{...D,components:$}}async function a9(D,F,B={}){let $=J8.get(D);if($)return $;let _=B.requestUrl??D,Q=(async()=>{let Y={url:_,phase:B.phase},q;try{q=await fetch(_)}catch(J){throw new RD(`Network request failed for ${_}: ${J instanceof Error?J.message:String(J)}`,Y)}if(!q.ok){if(q.status===404)throw new MD(`Not found: ${_}`);throw new RD(`Failed to fetch ${_}: ${q.status} ${q.statusText}`,{...Y,status:q.status,statusText:q.statusText})}let H;try{H=await q.json()}catch(J){throw new RD(`Invalid JSON response from ${_}: ${J instanceof Error?J.message:String(J)}`,Y)}return await F(H)})();return J8.set(D,Q),Q.catch(()=>J8.delete(D)),Q}function o9(D){let F=PF(D);if(!F)return null;return{issue:F.issue,remediation:F.remediation,schemaUrl:F.schemaUrl,supportedMajor:F.supportedMajor,detectedMajor:F.detectedMajor}}async function T2(D){let F=xD(D),B=`${F}/index.json`;return a9(B,($)=>{let _=o9($);if(_&&_.issue!=="legacy-schema-v1")throw Aq(B,_);let Q=$,Y="v2";if(_?.issue==="legacy-schema-v1"){Y="legacy-v1";try{Q=Eq($,B)}catch(H){if(H instanceof v0)throw H;let J=H instanceof Error?H.message:String(H);throw new v0(`Registry at ${B} uses legacy schema v1 but cannot be adapted safely. ${J}`,{url:B,issue:"invalid-format",remediation:"Fix the legacy payload shape (types/descriptions/components) or upgrade the registry to v2."})}}else{let H=jq(Q);if(H.length>0){let J=H[0];if(!J)throw Error("Unexpected missing legacy type issue");let X=G8[J.type];throw new v0(`Registry at ${B} uses legacy component type "${J.type}" in ${J.path}. Use "${X}" for v2 registries.`,{url:B,issue:"invalid-format",remediation:`Replace legacy type "${J.type}" with canonical "${X}" in v2 manifests.`})}}let q=j1.safeParse(Q);if(!q.success)throw new v0(`Registry at ${B} returned an unrecognized index format. Ensure it follows the OCX registry specification. Schema error: ${q.error.message}`,{url:B,issue:"invalid-format",remediation:`Ensure the registry index follows the OCX registry specification. Schema error: ${q.error.message}`});return b3.set(F,Y),q.data},{phase:"registry-index-fetch"})}async function R3(D,F){return(await W8(D,F)).manifest}async function W8(D,F,B){let $=`${xD(D)}/components/${F}.json`;return a9(`${$}#v=${B??"latest"}`,async(_)=>{let Q=Mq.safeParse(_);if(!Q.success)throw new U(`Invalid packument format for "${F}": ${Q.error.message}`);let Y=Q.data,q=B??Y["dist-tags"].latest,H=Y.versions[q];if(!H){if(B){let M=Object.keys(Y.versions).join(", ");throw new U(`Component "${F}" has no version "${B}". Available: ${M}`)}throw new U(`Component "${F}" has no manifest for latest version ${q}`)}let J=`component "${F}@${q}"`,X=H;if(Kq(H))if(await Uq(D)!=="v2")X=Vq(H,J);else{let K=s9(H)[0];if(K)throw new U(`Invalid component manifest for "${F}@${q}": target "${K.target}" at ${K.path} uses a legacy .opencode/ prefix. For v2 registries, use canonical root-relative targets like "plugins/...", "profiles/...", "agents/...", "skills/...", or "commands/..." (without .opencode/).`);if(eD(H)&&n9(H.type)){let j=G8[H.type];throw new U(`Invalid component manifest for "${F}@${q}": type "${H.type}" is a legacy v1 alias. Use "${j}" for v2 registries.`)}}let z=l2.safeParse(X);if(!z.success)throw new U(`Invalid component manifest for "${F}@${q}": ${z.error.message}`);return{manifest:z.data,version:q}},{phase:"packument-fetch",requestUrl:$})}async function e2(D,F,B){let $=`${xD(D)}/components/${F}/${B}`,_={url:$,phase:"file-content-fetch",qualifiedName:F},Q;try{Q=await fetch($)}catch(Y){throw new RD(`Network request failed for ${$}: ${Y instanceof Error?Y.message:String(Y)}`,_)}if(!Q.ok)throw new RD(`Failed to fetch file ${B} for ${F} from ${$}: ${Q.status} ${Q.statusText}`,{..._,status:Q.status,statusText:Q.statusText});return Q.text()}function Lq(){J8.clear(),b3.clear()}var J8,b3,G8,zq,Mq;var DF=V(()=>{_2();P0();$D();J8=new Map,b3=new Map,G8={"ocx:agent":"agent","ocx:skill":"skill","ocx:plugin":"plugin","ocx:command":"command","ocx:tool":"tool","ocx:bundle":"bundle","ocx:profile":"profile"},zq={agent:"agents",skill:"skills",plugin:"plugins",command:"commands",tool:"tools",bundle:"bundles",profile:"profiles",philosophy:"tools"},Mq=K3.extend({versions:W.record(W.unknown())})});function t9(D,F){if(D.includes("/"))return u0(D);if(F)return{namespace:F,component:D};throw new U(`Component '${D}' must include a registry alias (e.g., 'kdco/${D}')`)}async function e9(D,F){let B=new Map,$=new Set,_=new Set,Q=new Set,Y={};async function q(X,z,M=[]){let A=A1(X,z);if(B.has(A))return;if($.has(A)){let Z=[...M,A].join(" \u2192 ");throw new U(`Circular dependency detected: ${Z}`)}$.add(A);let K=D[X];if(!K)throw new MD(`Registry alias '${X}' not found. Add it with 'ocx registry add <url> --name ${X}'.`);let j;try{j=await R3(K.url,z)}catch(Z){if(Z instanceof RD)throw Z;if(Z instanceof MD)throw new MD(`Component '${z}' not found in registry '${X}'.`);if(Z instanceof zD)throw Z;throw new RD(`Failed to fetch component '${z}' from registry '${X}': ${Z instanceof Error?Z.message:String(Z)}`,{url:K.url})}for(let Z of j.dependencies){let s=t9(Z,X);await q(s.namespace,s.component,[...M,A])}let S=p2(j);if(B.set(A,{...S,registryName:X,baseUrl:K.url,qualifiedName:A}),$.delete(A),j.npmDependencies)for(let Z of j.npmDependencies)_.add(Z);if(j.npmDevDependencies)for(let Z of j.npmDevDependencies)Q.add(Z);if(S.opencode)Y=Y8(Y,S.opencode)}for(let X of F){let z=t9(X);await q(z.namespace,z.component)}let H=Array.from(B.values()),J=Array.from(B.keys());return{components:H,installOrder:J,npmDependencies:Array.from(_),npmDevDependencies:Array.from(Q),opencode:Y}}var D4=V(()=>{P0();$D();DF();x1()});import{existsSync as cF}from"fs";import{mkdir as F4}from"fs/promises";import{homedir as wq}from"os";import D0 from"path";function B4(D){let F=process.env.XDG_CONFIG_HOME||D0.join(wq(),".config"),B=D0.resolve(F,"opencode"),$=D0.resolve(D);if($===B)return!0;let _=D0.relative(B,$);return _!==""&&!_.startsWith("..")&&!D0.isAbsolute(_)}function z8(D){if(B4(D)){let Q=D0.join(D,"opencode.jsonc"),Y=D0.join(D,"opencode.json");if(cF(Q))return{path:Q,exists:!0};if(cF(Y))return{path:Y,exists:!0};return{path:Q,exists:!1}}let F=D0.join(D,g1,"opencode.jsonc"),B=D0.join(D,g1,"opencode.json");if(cF(F))return{path:F,exists:!0};if(cF(B))return{path:B,exists:!0};let $=D0.join(D,"opencode.jsonc"),_=D0.join(D,"opencode.json");if(cF($))return{path:$,exists:!0};if(cF(_))return{path:_,exists:!0};return{path:F,exists:!1}}async function $4(D){let{path:F,exists:B}=z8(D);if(B)return{path:F,created:!1};return await F4(D0.dirname(F),{recursive:!0}),await Bun.write(F,Oq),{path:F,created:!0}}async function d1(D){let{path:F,exists:B}=z8(D);if(!B)return null;let _=await Bun.file(F).text();return{config:ND(_,[],{allowTrailingComma:!0}),content:_,path:F}}async function bq(D,F){await Bun.write(D,F)}function Rq(D,F){let $=ND(D,[],{allowTrailingComma:!0});for(let _ of F){if($===null||$===void 0)return;if(typeof $!=="object")return;$=$[_]}return $}function _4(D,F,B){if(B===null||B===void 0)return D;if(eD(B)){let _=Rq(D,F);if(_!==void 0&&(_===null||typeof _!=="object")){let Y=AF(D,F,B,m1);return jF(D,Y)}let Q=D;for(let[Y,q]of Object.entries(B))Q=_4(Q,[...F,Y],q);return Q}if(Array.isArray(B)){let _=AF(D,F,B,m1);return jF(D,_)}let $=AF(D,F,B,m1);return jF(D,$)}async function c1(D,F){let B=await d1(D),$,_,Q=!1;if(B)$=B.content,_=B.path;else $=JSON.stringify({$schema:"https://opencode.ai/config.json"},null,"\t"),_=B4(D)?D0.join(D,"opencode.jsonc"):D0.join(D,g1,"opencode.jsonc"),await F4(D0.dirname(_),{recursive:!0}),Q=!0;let Y=$;$=_4($,[],F);let q=$!==Y;if(q)await bq(_,$);return{path:_,created:Q,changed:q}}var g1=".opencode",m1,Oq=`{
79
+ `;var o0=V(()=>{b0();fF();$D();Q8();Q0();q8();T9={$schema:"https://ocx.kdco.dev/schemas/profile.json",registries:{},renameWindow:!0,exclude:["**/CLAUDE.md","**/CONTEXT.md","**/.opencode/**","**/opencode.jsonc","**/opencode.json"],include:[]}});function v9(D,F,B){let $=(_)=>D(_,...F);return B===void 0?$:Object.assign($,{lazy:B,lazyArgs:F})}var C9=()=>{};function u9(D,F,B){let $=D.length-F.length;if($===0)return D(...F);if($===1)return v9(D,F,B);throw Error("Wrong number of arguments")}var P9=V(()=>{C9()});function x1(D){if(typeof D!="object"||!D)return!1;let F=Object.getPrototypeOf(D);return F===null||F===Object.prototype}var y9=()=>{};function f1(...D){return u9(x9,D)}function x9(D,F){let B={...D,...F};for(let $ in F){if(!($ in D))continue;let{[$]:_}=D;if(!x1(_))continue;let{[$]:Q}=F;x1(Q)&&(B[$]=x9(_,Q))}return B}var f9=V(()=>{P9();y9()});var h9=V(()=>{f9()});function m9(D){let F=D.startsWith("npm:"),B=F?D.slice(4):D;if(!B)return D;if(B.startsWith("@")){let Q=B.indexOf("/");if(Q===-1)return D;let q=B.slice(Q+1).indexOf("@");if(q===-1)return D;let H=B.slice(0,Q+1+q);return F?`npm:${H}`:H}let $=B.indexOf("@");if($===-1)return D;let _=B.slice(0,$);return F?`npm:${_}`:_}function Bq(D){let F=new Map;for(let $=D.length-1;$>=0;$--){let _=D[$],Q=m9(_);if(!F.has(Q))F.set(Q,$)}let B=[];for(let[$,_]of D.entries()){let Q=m9(_);if(F.get(Q)===$)B.push(_)}return B}function H8(D,F){let B=f1(D,F);if(Array.isArray(D.plugin)&&Array.isArray(F.plugin))B.plugin=Bq([...D.plugin,...F.plugin]);else if(Array.isArray(D.plugin))B.plugin=D.plugin;else if(Array.isArray(F.plugin))B.plugin=F.plugin;if(Array.isArray(D.instructions)&&Array.isArray(F.instructions))B.instructions=Array.from(new Set([...D.instructions,...F.instructions]));else if(Array.isArray(D.instructions))B.instructions=D.instructions;else if(Array.isArray(F.instructions))B.instructions=F.instructions;return B}var h1=V(()=>{h9()});import{existsSync as $q,readFileSync as _q}from"fs";import{dirname as Qq,isAbsolute as wA,resolve as m1}from"path";function Yq(D){let F=m1(D);while(!0){let B=m1(F,".git");if($q(B))try{let _=GF("fs").statSync(B);if(_.isDirectory())return F;if(_.isFile()){if(_q(B,"utf8").match(/^gitdir:\s*(.+)$/m)?.[1])return F}}catch{}let $=Qq(F);if($===F)return null;F=$}}function g1(D){let F=m1(D);return Yq(F)??F}var g9=()=>{};import{existsSync as qq}from"fs";import*as r2 from"path";var{Glob:Hq}=globalThis.Bun;function d9(D){return D.startsWith("http://")||D.startsWith("https://")}function Jq(D,F){if(d9(D))return;if(r2.isAbsolute(D)||r2.win32.isAbsolute(D))throw new U(`Absolute path not allowed in registry instructions: "${D}" (from ${F})`);if(D.startsWith("~"))throw new U(`Home directory path not allowed in registry instructions: "${D}" (from ${F})`);if(D.split(/[/\\]/).some(($)=>$===".."))throw new U(`Path traversal (..) not allowed in registry instructions: "${D}" (from ${F})`)}function Xq(D,F,B){if(d9(D))return[D];if(Jq(D,B),D.includes("*")||D.includes("?")||D.includes("[")){let Q=new Hq(D),Y=[];for(let q of Q.scanSync(F)){let H=r2.join(F,q);Y.push(H)}return Y}let _=r2.join(F,D);if(!qq(_))throw new U(`Registry instruction file not found: "${D}" (from ${B})
80
+ Expected at: ${_}`);return[_]}function c9(D,F,B){let $=[],_=new Set;for(let Q of D){let Y=Xq(Q,F,B);for(let q of Y)if(!_.has(q))_.add(q),$.push(q)}return $}var l9=V(()=>{$D()});import{existsSync as t2,readFileSync as i9,statSync as Wq}from"fs";import{homedir as Gq}from"os";import{join as V0,relative as n9}from"path";var{Glob:J8}=globalThis.Bun;function zq(D){return D==="local-config"||D==="cli"||D==="env"}function d1(D,F){if(D.trim().length===0)throw new c(`Invalid profile from ${F}: value cannot be empty or whitespace`);return D}function s9(D){if(D.length===0)return"Unknown parse error";let F=D[0];if(!F)return"Unknown parse error";return`${K2(F.error)} at offset ${F.offset}`}function p9(D){let F;try{F=i9(D,"utf8")}catch(Q){let Y=Q instanceof Error?Q.message:"Unknown read error";throw new c(`Failed to read local config at ${D}: ${Y}`)}let B=[],$=ND(F,B,{allowTrailingComma:!0});if(B.length>0){let Q=s9(B);throw new c(`Invalid JSONC in local config at ${D}: ${Q}`)}let _=Z2.safeParse($);if(!_.success){let Q=_.error.issues[0],Y=Q?.path.length?Q.path.join("."):"root",q=Q?.message??"Invalid OCX config";throw new c(`Invalid local config at ${D}: ${Y} ${q}`)}return _.data}function Mq(D){let F;try{F=i9(D,"utf8")}catch(_){let Q=_ instanceof Error?_.message:"Unknown read error";throw new c(`Failed to read local OpenCode config at ${D}: ${Q}`)}let B=[],$=ND(F,B,{allowTrailingComma:!0});if(B.length>0){let _=s9(B);throw new c(`Invalid JSONC in local OpenCode config at ${D}: ${_}`)}if(!$||typeof $!=="object"||Array.isArray($))throw new c(`Invalid local OpenCode config at ${D}: root must be an object`);return $}function jq(D,F,B){let $=[],_=F;while(!0){let Q=V0(_,D);if(t2(Q)&&Wq(Q).isFile()){let q=n9(B,Q);$.push(q)}if(_===B)break;let Y=V0(_,"..");if(Y===_)break;_=Y}return $}function Kq(D,F){for(let B of Aq){let $=jq(B,D,F);if($.length>0)return $}return[]}function X8(D){return D.startsWith("./")?D.slice(2):D}function Uq(D,F,B){return D.filter(($)=>{for(let _ of B)if(new J8(X8(_)).match($))return!0;for(let _ of F)if(new J8(X8(_)).match($))return!1;return!0})}async function Vq(D){let F=await X0(D);if(!F||Object.keys(F.installed).length===0)return[];let B=[];for(let[$,_]of Object.entries(F.installed)){if(!_.opencode?.instructions)continue;let Q=_.opencode.instructions;if(!Array.isArray(Q))continue;let Y=`${_.registryName}/${_.name} (${$})`,q=c9(Q,D,Y);B.push(...q)}return Array.from(new Set(B))}class r0{cwd;profileName;profile;localConfigDir;registryInstructions;cachedConfig=null;constructor(D,F,B,$,_){this.cwd=D,this.profileName=F,this.profile=B,this.localConfigDir=$,this.registryInstructions=_}static async create(D,F){let B=PD.create(D),$=null,_="none",Q=o2(D);if(Q){let X=V0(Q,y0);if(t2(X)){let z=p9(X);if(z.profile!==void 0)$=d1(z.profile,`local config at ${X}`),_="local-config"}}if($===null){if(F?.profile!==void 0)$=d1(F.profile,"CLI option --profile"),_="cli";else if(process.env.OCX_PROFILE!==void 0)$=d1(process.env.OCX_PROFILE,"environment variable OCX_PROFILE"),_="env"}let Y=await B.isInitialized();if(zq(_)&&!Y)throw new CF;let q=null;if(Y)if($!==null)q=await B.getLayered($,D);else try{$=await B.resolveProfile(),q=await B.getLayered($,D),_="default"}catch(X){if(!(X instanceof CD)||X.profile!=="default")throw X;$=null,q=null,_="none"}let H;if(q)H=fD($);else if(Q)H=V0(Q,"..");else H=W0();let J=await Vq(H);return new r0(D,$,q,Q,J)}resolve(){if(this.cachedConfig)return this.cachedConfig;let D={},F=s2,B={};if(this.profile){if(D={...D,...this.profile.ocx.registries},this.profile.ocx.componentPath)F=this.profile.ocx.componentPath;if(this.profile.opencode)B=this.mergeOpencode(B,this.profile.opencode)}let $=this.shouldLoadLocalConfig();if(!this.profile&&$&&this.localConfigDir){let Q=this.loadLocalOcxConfig();if(Q)D=Q.registries}if(this.localConfigDir){let Q=this.loadLocalOpencodeConfig();if(Q)B=this.mergeOpencode(B,Q)}let _=this.discoverInstructions();return this.cachedConfig={registries:D,componentPath:F,opencode:B,instructions:_,profileName:this.profileName},this.cachedConfig}resolveWithOrigin(){let D=new Map,F={},B=s2,$={};if(D.set("componentPath",{path:"",source:"default"}),this.profile){let Y=`~/.config/opencode/profiles/${this.profileName}/ocx.jsonc`;for(let[q,H]of Object.entries(this.profile.ocx.registries))F[q]=H,D.set(`registries.${q}`,{path:Y,source:"global-profile"});if(this.profile.ocx.componentPath)B=this.profile.ocx.componentPath,D.set("componentPath",{path:Y,source:"global-profile"});if(this.profile.opencode){$=this.mergeOpencode($,this.profile.opencode);let q=`~/.config/opencode/profiles/${this.profileName}/opencode.jsonc`;for(let H of Object.keys(this.profile.opencode))D.set(`opencode.${H}`,{path:q,source:"global-profile"})}}let _=this.shouldLoadLocalConfig();if(!this.profile&&_&&this.localConfigDir){let Y=this.loadLocalOcxConfig();if(Y){let q=V0(this.localConfigDir,y0);for(let[H,J]of Object.entries(Y.registries))F[H]=J,D.set(`registries.${H}`,{path:q,source:"local-config"})}}if(this.localConfigDir){let Y=this.loadLocalOpencodeConfig();if(Y){$=this.mergeOpencode($,Y);let q=V0(this.localConfigDir,u1);for(let H of Object.keys(Y))D.set(`opencode.${H}`,{path:q,source:"local-opencode"})}}let Q=this.discoverInstructions();return{registries:F,componentPath:B,opencode:$,instructions:Q,profileName:this.profileName,origins:D}}shouldLoadLocalConfig(){if(!this.profile?.ocx.exclude)return!0;if(!this.localConfigDir)return!0;let F=g1(this.cwd),B=n9(F,this.localConfigDir),$=this.profile.ocx.exclude??[],_=this.profile.ocx.include??[];for(let Q of _){let Y=new J8(X8(Q));if(Y.match(`${B}/`)||Y.match(B))return!0}for(let Q of $){let Y=new J8(X8(Q));if(Y.match(`${B}/`)||Y.match(`${B}/**`))return!1}return!0}loadLocalOcxConfig(){if(!this.localConfigDir)return null;let D=V0(this.localConfigDir,y0);if(!t2(D))return null;return{registries:p9(D).registries}}loadLocalOpencodeConfig(){if(!this.localConfigDir)return null;let D=V0(this.localConfigDir,u1);if(!t2(D))return null;return Mq(D)}discoverInstructions(){let D=[],F=W0(),B=V0(F,"AGENTS.md");if(t2(B))D.push(B);else if(!process.env.OPENCODE_DISABLE_CLAUDE_CODE_PROMPT){let X=V0(Gq(),".claude","CLAUDE.md");if(t2(X))D.push(X)}if(this.profile&&this.profileName){let X=V0(fD(this.profileName),"AGENTS.md");if(t2(X))D.push(X)}let $=this.loadRegistryInstructions();D.push(...$);let _=g1(this.cwd),Q=Kq(this.cwd,_),Y=this.profile?.ocx.exclude??[],q=this.profile?.ocx.include??[],J=Uq(Q,Y,q).map((X)=>V0(_,X));return D.push(...J),D}loadRegistryInstructions(){return this.registryInstructions}mergeOpencode(D,F){return H8(D,F)}getRegistries(){return this.resolve().registries}getComponentPath(){return this.resolve().componentPath}getProfileName(){return this.profileName}getCwd(){return this.cwd}getProfile(){return this.profile}}var Aq;var b3=V(()=>{b0();o0();Q0();h1();eD();$D();g9();l9();k2();Aq=["AGENTS.md","CLAUDE.md","CONTEXT.md"]});function D0(D){return typeof D==="object"&&D!==null&&!Array.isArray(D)&&Object.getPrototypeOf(D)===Object.prototype}var F4={};j2(F4,{fetchRegistryIndex:()=>T2,fetchFileContent:()=>e2,fetchComponentVersion:()=>M8,fetchComponent:()=>R3,classifyRegistryIndexIssue:()=>D4,_clearFetcherCacheForTests:()=>kq});import{posix as Eq}from"path";function Oq(D,F){return new v0(`Registry at ${D} uses an incompatible format (${F.issue}). ${F.remediation}`,{url:D,issue:F.issue,remediation:F.remediation,...F.schemaUrl!==void 0&&{schemaUrl:F.schemaUrl},...F.supportedMajor!==void 0&&{supportedMajor:F.supportedMajor},...F.detectedMajor!==void 0&&{detectedMajor:F.detectedMajor}})}function o9(D,F){if(typeof D!=="string")throw new U(`Invalid ${F}: expected string, got ${typeof D}`);let B=z8[D]??D,$=uF.safeParse(B);if(!$.success)throw new U(`Unsupported component type "${D}" in ${F}. Expected one of: ${uF.options.join(", ")}`);return $.data}function r9(D){return typeof D==="string"&&Object.hasOwn(z8,D)}function G8(D){return D.startsWith(".opencode/")||D.startsWith(".opencode\\")}function t9(D){if(!D0(D)||!Array.isArray(D.files))return[];let F=[];for(let[B,$]of D.files.entries()){if(typeof $==="string"){if(!G8($))continue;F.push({path:`files[${B}]`,target:$});continue}if(!D0($)||typeof $.target!=="string")continue;if(!G8($.target))continue;F.push({path:`files[${B}].target`,target:$.target})}return F}function bq(D){if(!D0(D))return[];let F=D.components;if(!Array.isArray(F))return[];let B=[];for(let[$,_]of F.entries()){if(!D0(_))continue;let Q=_.type;if(!r9(Q))continue;B.push({path:`components[${$}].type`,type:Q})}return B}function Zq(D){if(!D0(D))return!1;if(typeof D.type==="string"&&D.type.startsWith("ocx:"))return!0;return t9(D).length>0}async function Rq(D){let F=xD(D),B=Z3.get(F);if(B)return B;try{await T2(F)}catch(_){if(_ instanceof ZD||_ instanceof MD)return null;throw _}if(!Z3.has(F))return null;let $=Z3.get(F);if(!$)throw Error(`Missing registry schema mode cache entry for ${F}`);return $}function a9(D,F){if(D.includes("\x00"))throw new U(`Unsafe target "${D}" in ${F}: null bytes are not allowed`);if(D.includes("%"))throw new U(`Unsafe target "${D}" in ${F}: encoded paths are not allowed`);if(D.includes("\\"))throw new U(`Unsafe target "${D}" in ${F}: Windows separators are not allowed`);if(D.startsWith("/")||D.startsWith("//")||/^[a-zA-Z]:/.test(D))throw new U(`Unsafe target "${D}" in ${F}: absolute paths are not allowed`);let B=D.startsWith(".opencode/")?D.slice(10):D;if(!B)throw new U(`Unsafe target "${D}" in ${F}: missing path after .opencode/`);let $=B.split("/");if($.some((J)=>J.length===0))throw new U(`Unsafe target "${D}" in ${F}: empty path segments are not allowed`);if($.some((J)=>J==="."||J===".."))throw new U(`Unsafe target "${D}" in ${F}: traversal segments are not allowed`);let[_,...Q]=$;if(!_)throw new U(`Unsafe target "${D}" in ${F}: missing path root segment`);let q=[Lq[_]??_,...Q].join("/"),H=Eq.normalize(q);if(H!==q)throw new U(`Unsafe target "${D}" in ${F}: path normalization is ambiguous`);if(H==="."||H===".."||H.startsWith("../"))throw new U(`Unsafe target "${D}" in ${F}: target escapes project root`);return H}function Nq(D,F){if(!D0(D))return D;let B={...D};if(Object.hasOwn(B,"type"))B.type=o9(B.type,`${F}.type`);if(Array.isArray(B.files))B.files=B.files.map(($,_)=>{if(typeof $==="string"){if(!G8($))return $;return a9($,`${F}.files[${_}]`)}if(!D0($))return $;let Q=$.target;if(typeof Q!=="string")return $;if(!G8(Q))return $;return{...$,target:a9(Q,`${F}.files[${_}].target`)}});return B}function Sq(D,F){if(!D0(D))throw new v0(`Registry at ${F} uses legacy schema v1 but does not expose an object index payload.`,{url:F,issue:"legacy-schema-v1",remediation:"Publish an object index with author/components fields, or upgrade to schema v2."});let B=D.components;if(!Array.isArray(B))throw new v0(`Registry at ${F} uses legacy schema v1 but the components field is missing or invalid.`,{url:F,issue:"legacy-schema-v1",remediation:"Ensure the legacy index has a components array, or upgrade to schema v2."});let $=B.map((_,Q)=>{if(!D0(_))throw new U(`Invalid index component at components[${Q}]: expected object, got ${typeof _}`);let{name:Y,description:q}=_;if(typeof Y!=="string")throw new U(`Invalid index component name at components[${Q}].name`);if(typeof q!=="string")throw new U(`Invalid index component description at components[${Q}].description`);return{name:Y,type:o9(_.type,`components[${Q}].type`),description:q}});return{...D,components:$}}async function e9(D,F,B={}){let $=W8.get(D);if($)return $;let _=B.requestUrl??D,Q=(async()=>{let Y={url:_,phase:B.phase},q;try{q=await fetch(_)}catch(J){throw new ZD(`Network request failed for ${_}: ${J instanceof Error?J.message:String(J)}`,Y)}if(!q.ok){if(q.status===404)throw new MD(`Not found: ${_}`);throw new ZD(`Failed to fetch ${_}: ${q.status} ${q.statusText}`,{...Y,status:q.status,statusText:q.statusText})}let H;try{H=await q.json()}catch(J){throw new ZD(`Invalid JSON response from ${_}: ${J instanceof Error?J.message:String(J)}`,Y)}return await F(H)})();return W8.set(D,Q),Q.catch(()=>W8.delete(D)),Q}function D4(D){let F=PF(D);if(!F)return null;return{issue:F.issue,remediation:F.remediation,schemaUrl:F.schemaUrl,supportedMajor:F.supportedMajor,detectedMajor:F.detectedMajor}}async function T2(D){let F=xD(D),B=`${F}/index.json`;return e9(B,($)=>{let _=D4($);if(_&&_.issue!=="legacy-schema-v1")throw Oq(B,_);let Q=$,Y="v2";if(_?.issue==="legacy-schema-v1"){Y="legacy-v1";try{Q=Sq($,B)}catch(H){if(H instanceof v0)throw H;let J=H instanceof Error?H.message:String(H);throw new v0(`Registry at ${B} uses legacy schema v1 but cannot be adapted safely. ${J}`,{url:B,issue:"invalid-format",remediation:"Fix the legacy payload shape (types/descriptions/components) or upgrade the registry to v2."})}}else{let H=bq(Q);if(H.length>0){let J=H[0];if(!J)throw Error("Unexpected missing legacy type issue");let X=z8[J.type];throw new v0(`Registry at ${B} uses legacy component type "${J.type}" in ${J.path}. Use "${X}" for v2 registries.`,{url:B,issue:"invalid-format",remediation:`Replace legacy type "${J.type}" with canonical "${X}" in v2 manifests.`})}}let q=U1.safeParse(Q);if(!q.success)throw new v0(`Registry at ${B} returned an unrecognized index format. Ensure it follows the OCX registry specification. Schema error: ${q.error.message}`,{url:B,issue:"invalid-format",remediation:`Ensure the registry index follows the OCX registry specification. Schema error: ${q.error.message}`});return Z3.set(F,Y),q.data},{phase:"registry-index-fetch"})}async function R3(D,F){return(await M8(D,F)).manifest}async function M8(D,F,B){let $=`${xD(D)}/components/${F}.json`;return e9(`${$}#v=${B??"latest"}`,async(_)=>{let Q=wq.safeParse(_);if(!Q.success)throw new U(`Invalid packument format for "${F}": ${Q.error.message}`);let Y=Q.data,q=B??Y["dist-tags"].latest,H=Y.versions[q];if(!H){if(B){let M=Object.keys(Y.versions).join(", ");throw new U(`Component "${F}" has no version "${B}". Available: ${M}`)}throw new U(`Component "${F}" has no manifest for latest version ${q}`)}let J=`component "${F}@${q}"`,X=H;if(Zq(H))if(await Rq(D)!=="v2")X=Nq(H,J);else{let K=t9(H)[0];if(K)throw new U(`Invalid component manifest for "${F}@${q}": target "${K.target}" at ${K.path} uses a legacy .opencode/ prefix. For v2 registries, use canonical root-relative targets like "plugins/...", "profiles/...", "agents/...", "skills/...", or "commands/..." (without .opencode/).`);if(D0(H)&&r9(H.type)){let j=z8[H.type];throw new U(`Invalid component manifest for "${F}@${q}": type "${H.type}" is a legacy v1 alias. Use "${j}" for v2 registries.`)}}let z=l2.safeParse(X);if(!z.success)throw new U(`Invalid component manifest for "${F}@${q}": ${z.error.message}`);return{manifest:z.data,version:q}},{phase:"packument-fetch",requestUrl:$})}async function e2(D,F,B){let $=`${xD(D)}/components/${F}/${B}`,_={url:$,phase:"file-content-fetch",qualifiedName:F},Q;try{Q=await fetch($)}catch(Y){throw new ZD(`Network request failed for ${$}: ${Y instanceof Error?Y.message:String(Y)}`,_)}if(!Q.ok)throw new ZD(`Failed to fetch file ${B} for ${F} from ${$}: ${Q.status} ${Q.statusText}`,{..._,status:Q.status,statusText:Q.statusText});return Q.text()}function kq(){W8.clear(),Z3.clear()}var W8,Z3,z8,Lq,wq;var DF=V(()=>{Q2();P0();$D();W8=new Map,Z3=new Map,z8={"ocx:agent":"agent","ocx:skill":"skill","ocx:plugin":"plugin","ocx:command":"command","ocx:tool":"tool","ocx:bundle":"bundle","ocx:profile":"profile"},Lq={agent:"agents",skill:"skills",plugin:"plugins",command:"commands",tool:"tools",bundle:"bundles",profile:"profiles",philosophy:"tools"},wq=U3.extend({versions:G.record(G.unknown())})});function B4(D,F){if(D.includes("/"))return u0(D);if(F)return{namespace:F,component:D};throw new U(`Component '${D}' must include a registry alias (e.g., 'kdco/${D}')`)}async function $4(D,F){let B=new Map,$=new Set,_=new Set,Q=new Set,Y={};async function q(X,z,M=[]){let A=K1(X,z);if(B.has(A))return;if($.has(A)){let R=[...M,A].join(" \u2192 ");throw new U(`Circular dependency detected: ${R}`)}$.add(A);let K=D[X];if(!K)throw new MD(`Registry alias '${X}' not found. Add it with 'ocx registry add <url> --name ${X}'.`);let j;try{j=await R3(K.url,z)}catch(R){if(R instanceof ZD)throw R;if(R instanceof MD)throw new MD(`Component '${z}' not found in registry '${X}'.`);if(R instanceof zD)throw R;throw new ZD(`Failed to fetch component '${z}' from registry '${X}': ${R instanceof Error?R.message:String(R)}`,{url:K.url})}for(let R of j.dependencies){let s=B4(R,X);await q(s.namespace,s.component,[...M,A])}let S=p2(j);if(B.set(A,{...S,registryName:X,baseUrl:K.url,qualifiedName:A}),$.delete(A),j.npmDependencies)for(let R of j.npmDependencies)_.add(R);if(j.npmDevDependencies)for(let R of j.npmDevDependencies)Q.add(R);if(S.opencode)Y=H8(Y,S.opencode)}for(let X of F){let z=B4(X);await q(z.namespace,z.component)}let H=Array.from(B.values()),J=Array.from(B.keys());return{components:H,installOrder:J,npmDependencies:Array.from(_),npmDevDependencies:Array.from(Q),opencode:Y}}var _4=V(()=>{P0();$D();DF();h1()});import{statSync as Iq}from"fs";import{mkdir as Q4}from"fs/promises";import Y0 from"path";function lF(D){try{return Iq(D).isFile()}catch{return!1}}function A8(D){let F=Y0.resolve(D);if(P1(F)!=="local-project"){let H=Y0.join(F,"opencode.jsonc"),J=Y0.join(F,"opencode.json");if(lF(H))return{path:H,exists:!0};if(lF(J))return{path:J,exists:!0};return{path:H,exists:!1}}let _=Y0.join(F,l1,"opencode.jsonc"),Q=Y0.join(F,l1,"opencode.json");if(lF(_))return{path:_,exists:!0};if(lF(Q))return{path:Q,exists:!0};let Y=Y0.join(F,"opencode.jsonc"),q=Y0.join(F,"opencode.json");if(lF(Y))return{path:Y,exists:!0};if(lF(q))return{path:q,exists:!0};return{path:_,exists:!1}}async function Y4(D){let{path:F,exists:B}=A8(D);if(B)return{path:F,created:!1};return await Q4(Y0.dirname(F),{recursive:!0}),await Bun.write(F,Tq),{path:F,created:!0}}async function p1(D){let{path:F,exists:B}=A8(D);if(!B)return null;let _=await Bun.file(F).text();return{config:ND(_,[],{allowTrailingComma:!0}),content:_,path:F}}async function vq(D,F){await Bun.write(D,F)}function Cq(D,F){let $=ND(D,[],{allowTrailingComma:!0});for(let _ of F){if($===null||$===void 0)return;if(typeof $!=="object")return;$=$[_]}return $}function q4(D,F,B){if(B===null||B===void 0)return D;if(D0(B)){let _=Cq(D,F);if(_!==void 0&&(_===null||typeof _!=="object")){let Y=AF(D,F,B,c1);return jF(D,Y)}let Q=D;for(let[Y,q]of Object.entries(B))Q=q4(Q,[...F,Y],q);return Q}if(Array.isArray(B)){let _=AF(D,F,B,c1);return jF(D,_)}let $=AF(D,F,B,c1);return jF(D,$)}async function i1(D,F){let B=await p1(D),$,_,Q=!1;if(B)$=B.content,_=B.path;else{$=JSON.stringify({$schema:"https://opencode.ai/config.json"},null,"\t");let J=Y0.resolve(D);_=P1(J)!=="local-project"?Y0.join(J,"opencode.jsonc"):Y0.join(J,l1,"opencode.jsonc"),await Q4(Y0.dirname(_),{recursive:!0}),Q=!0}let Y=$;$=q4($,[],F);let q=$!==Y;if(q)await vq(_,$);return{path:_,created:Q,changed:q}}var l1=".opencode",c1,Tq=`{
81
81
  "$schema": "https://opencode.ai/config.json"
82
82
  // Add MCP servers, tools, plugins here
83
83
  }
84
- `;var l1=V(()=>{b0();m1={formattingOptions:{tabSize:2,insertSpaces:!1,eol:`
85
- `}}});function Q4(D){return D.replace(/\r\n/g,`
86
- `).trim()}function p1(D,F){return Q4(D)===Q4(F)}import{existsSync as Zq,lstatSync as Nq}from"fs";import{rm as Sq,unlink as kq}from"fs/promises";import{join as H4}from"path";function J4(D,F){let B=[];for(let[$,_]of Object.entries(F)){let Q=D[$]??null;if(Q!==_)B.push({name:$,from:Q,to:_})}return{changed:B.length>0,entries:B}}function X4(D,F){let B=H4(D,"node_modules"),$=F.map((_)=>_.name).join(", ");return{action:"delete",target:B,details:{reason:`dependency declarations changed (${$}); invalidating to force reinstall`,path:B}}}function q4(D){if(D&&typeof D==="object"&&"code"in D)return String(D.code);return"UNKNOWN"}function i1(D){if(D instanceof Error)return D.message;return String(D)}function vq(D){return new Promise((F)=>setTimeout(F,D))}async function G4(D,F){let B=H4(D,"node_modules"),$=F?.rmImpl??((_,Q)=>Sq(_,Q));if(!Zq(B))return{success:!0,action:"none"};try{if(Nq(B).isSymbolicLink())return await kq(B),{success:!0,action:"unlinked"}}catch(_){let Q=q4(_);if(Q==="ENOENT")return{success:!0,action:"none"};return{success:!1,action:"failed",error:{code:Q,message:i1(_)}}}for(let _=0;_<=Y4;_++)try{return await $(B,{recursive:!0,force:!0}),{success:!0,action:"removed"}}catch(Q){let Y=q4(Q);if(Y==="ENOENT")return{success:!0,action:"none"};if(!Iq.has(Y))return{success:!1,action:"failed",error:{code:Y,message:i1(Q)}};if(_<Y4)await vq(Tq*2**_);else return{success:!1,action:"failed",error:{code:Y,message:i1(Q)}}}return{success:!1,action:"failed",error:{code:"UNKNOWN",message:"exhausted retries"}}}var Iq,Y4=3,Tq=100;var W4=V(()=>{Iq=new Set(["EBUSY","ENOTEMPTY"])});function z4(D,F){let B=0,$,_="",Q="";for(;B<D.length;B++)if($=D[B],_+=$.open,Q+=$.close,~F.indexOf($.close))F=F.replace($.rgx,$.close+$.open);return _+F+Q}function Cq(D,F){let B={has:D,keys:F};return B.reset=ED.reset.bind(B),B.bold=ED.bold.bind(B),B.dim=ED.dim.bind(B),B.italic=ED.italic.bind(B),B.underline=ED.underline.bind(B),B.inverse=ED.inverse.bind(B),B.hidden=ED.hidden.bind(B),B.strikethrough=ED.strikethrough.bind(B),B.black=ED.black.bind(B),B.red=ED.red.bind(B),B.green=ED.green.bind(B),B.yellow=ED.yellow.bind(B),B.blue=ED.blue.bind(B),B.magenta=ED.magenta.bind(B),B.cyan=ED.cyan.bind(B),B.white=ED.white.bind(B),B.gray=ED.gray.bind(B),B.grey=ED.grey.bind(B),B.bgBlack=ED.bgBlack.bind(B),B.bgRed=ED.bgRed.bind(B),B.bgGreen=ED.bgGreen.bind(B),B.bgYellow=ED.bgYellow.bind(B),B.bgBlue=ED.bgBlue.bind(B),B.bgMagenta=ED.bgMagenta.bind(B),B.bgCyan=ED.bgCyan.bind(B),B.bgWhite=ED.bgWhite.bind(B),B}function ZD(D,F){let B={open:`\x1B[${D}m`,close:`\x1B[${F}m`,rgx:new RegExp(`\\x1b\\[${F}m`,"g")};return function($){if(this!==void 0&&this.has!==void 0)return!!~this.has.indexOf(D)||(this.has.push(D),this.keys.push(B)),$===void 0?this:ED.enabled?z4(this.keys,$+""):$+"";return $===void 0?Cq([D],[B]):ED.enabled?z4([B],$+""):$+""}}var n1,M4,A4,j4,K4=!0,ED,P;var W2=V(()=>{if(typeof process<"u")({FORCE_COLOR:n1,NODE_DISABLE_COLORS:M4,NO_COLOR:A4,TERM:j4}=process.env||{}),K4=process.stdout&&process.stdout.isTTY;ED={enabled:!M4&&A4==null&&j4!=="dumb"&&(n1!=null&&n1!=="0"||K4),reset:ZD(0,0),bold:ZD(1,22),dim:ZD(2,22),italic:ZD(3,23),underline:ZD(4,24),inverse:ZD(7,27),hidden:ZD(8,28),strikethrough:ZD(9,29),black:ZD(30,39),red:ZD(31,39),green:ZD(32,39),yellow:ZD(33,39),blue:ZD(34,39),magenta:ZD(35,39),cyan:ZD(36,39),white:ZD(37,39),gray:ZD(90,39),grey:ZD(90,39),bgBlack:ZD(40,49),bgRed:ZD(41,49),bgGreen:ZD(42,49),bgYellow:ZD(43,49),bgBlue:ZD(44,49),bgMagenta:ZD(45,49),bgCyan:ZD(46,49),bgWhite:ZD(47,49)};P=ED});function V4(D,F){if(D==null||D==="")return F;let B=D.trim().toLowerCase();if(B==="true"||B==="1"||B==="yes"||B==="on")return!0;if(B==="false"||B==="0"||B==="no"||B==="off")return!1;return F}var uq,FF,U4;var Z3=V(()=>{uq=Boolean(process.env.CI||process.env.GITHUB_ACTIONS||process.env.GITLAB_CI||process.env.CIRCLECI||process.env.JENKINS_URL||process.env.BUILDKITE),FF=Boolean(process.stdout.isTTY&&!uq),U4=Boolean(FF&&process.env.FORCE_COLOR!=="0"&&process.env.NO_COLOR===void 0)});var lF,G,W0;var fD=V(()=>{W2();Z3();if(!U4)P.enabled=!1;lF={},G={info(...D){if(lF.quiet)return;console.log(P.blue("info"),...D)},success(...D){if(lF.quiet)return;console.log(P.green("\u2713"),...D)},warn(...D){if(lF.quiet)return;console.warn(P.yellow("warn"),...D)},error(...D){console.error(P.red("error"),...D)},debug(...D){if(!lF.verbose)return;console.log(P.gray("debug"),...D)},log(...D){if(lF.quiet)return;console.log(...D)},break(){if(lF.quiet)return;console.log("")}},W0={component:(D)=>P.cyan(D),path:(D)=>P.green(D),command:(D)=>P.yellow(D),url:(D)=>P.blue().underline(D),error:(D)=>P.red(D),dim:(D)=>P.gray(D),bold:(D)=>P.bold(D)}});function z0(D,F={}){if(F.json){console.log(JSON.stringify(D,null,2));return}if(F.quiet)return;if(G.info(W0.dim("\uD83D\uDD0D DRY RUN: No changes will be made")),G.break(),D.wouldPerform.length===0)G.info("No actions would be performed.");else{let $=Pq(D.wouldPerform);for(let[_,Q]of Object.entries($)){let Y=xq(_);G.info(`Would ${Y} ${Q.length} item(s):`);for(let q of Q){let H=yq(q.details);G.info(` \u2022 ${W0.component(q.target)}${H}`)}G.break()}}if(D.summary)G.info(D.summary),G.break();if(D.validation.errors&&D.validation.errors.length>0){G.error("Would fail with errors:");for(let $ of D.validation.errors)G.error(` \u2022 ${$}`);G.break()}if(D.validation.warnings&&D.validation.warnings.length>0){G.warn("Warnings:");for(let $ of D.validation.warnings)G.warn(` \u2022 ${$}`);G.break()}if(F.hints&&F.hints.length>0){for(let $ of F.hints)G.info(W0.dim($));G.break()}G.info(W0.dim("Run without --dry-run to apply changes."))}function Pq(D){let F={};for(let B of D){if(!F[B.action])F[B.action]=[];F[B.action]?.push(B)}return F}function xq(D){return{add:"add",remove:"remove",delete:"delete",update:"update",create:"create",modify:"modify"}[D]??D}function yq(D){if(!D||Object.keys(D).length===0)return"";let F=[];for(let[B,$]of Object.entries(D??{}))if($!==void 0&&$!==null)F.push(`${B}: ${W0.dim(String($))}`);return F.length>0?` (${F.join(", ")})`:""}var BF=V(()=>{fD()});var E4={};j2(E4,{wrapAction:()=>fq,handleError:()=>t});function t(D,F={}){if(F.json){let B=hq(D);console.log(JSON.stringify(B,null,2)),process.exit(B.exitCode)}if(D instanceof zD)G.error(D.message),process.exit(D.exitCode);if(D instanceof cD){G.error("Validation failed:");for(let B of D.issues){let $=B.path.join(".");G.error(` ${$}: ${B.message}`)}process.exit(XD.CONFIG)}if(D instanceof Error){if(G.error(D.message),process.env.DEBUG)console.error(D.stack)}else G.error("An unknown error occurred");process.exit(XD.GENERAL)}function fq(D){return async(...F)=>{try{await D(...F)}catch(B){t(B)}}}function hq(D){if(D instanceof vF)return{success:!1,error:{code:D.code,message:D.message,details:{conflictType:D.conflictType,registryName:D.registryName,existingUrl:D.existingUrl,newUrl:D.newUrl,...D.targetLabel&&{targetLabel:D.targetLabel},...D.existingName&&{existingName:D.existingName}}},exitCode:D.exitCode,meta:{timestamp:new Date().toISOString()}};if(D instanceof d2)return{success:!1,error:{code:D.code,message:D.message,details:{component:D.component,expected:D.expected,found:D.found}},exitCode:D.exitCode,meta:{timestamp:new Date().toISOString()}};if(D instanceof RD){let F={};if(D.url)F.url=D.url;if(D.status!==void 0)F.status=D.status;if(D.statusText)F.statusText=D.statusText;if(D.phase)F.phase=D.phase;if(D.qualifiedName)F.qualifiedName=D.qualifiedName;if(D.registryContext)F.registryContext=D.registryContext;if(D.registryName)F.registryName=D.registryName;return{success:!1,error:{code:D.code,message:D.message,...Object.keys(F).length>0&&{details:F}},exitCode:D.exitCode,meta:{timestamp:new Date().toISOString()}}}if(D instanceof CD)return{success:!1,error:{code:D.code,message:D.message,details:{profile:D.profile}},exitCode:D.exitCode,meta:{timestamp:new Date().toISOString()}};if(D instanceof O2)return{success:!1,error:{code:D.code,message:D.message,details:{profile:D.profile}},exitCode:D.exitCode,meta:{timestamp:new Date().toISOString()}};if(D instanceof C0)return{success:!1,error:{code:D.code,message:D.message,details:{profile:D.profile,reason:D.reason}},exitCode:D.exitCode,meta:{timestamp:new Date().toISOString()}};if(D instanceof n0)return{success:!1,error:{code:"BUILD_ERROR",message:D.message,details:{errors:D.errors}},exitCode:XD.GENERAL,meta:{timestamp:new Date().toISOString()}};if(D instanceof v0){let F={url:D.url,issue:D.issue,remediation:D.remediation};if(D.schemaUrl!==void 0)F.schemaUrl=D.schemaUrl;if(D.supportedMajor!==void 0)F.supportedMajor=D.supportedMajor;if(D.detectedMajor!==void 0)F.detectedMajor=D.detectedMajor;return{success:!1,error:{code:D.code,message:D.message,details:F},exitCode:D.exitCode,meta:{timestamp:new Date().toISOString()}}}if(D instanceof g2)return{success:!1,error:{code:D.code,message:D.message,details:D.details},exitCode:D.exitCode,meta:{timestamp:new Date().toISOString()}};if(D instanceof zD)return{success:!1,error:{code:D.code,message:D.message},exitCode:D.exitCode,meta:{timestamp:new Date().toISOString()}};if(D instanceof cD)return{success:!1,error:{code:"VALIDATION_ERROR",message:D.issues.map((F)=>`${F.path.join(".")}: ${F.message}`).join("; "),details:{issues:D.issues.map((F)=>({path:F.path.join("."),message:F.message,code:F.code}))}},exitCode:XD.CONFIG,meta:{timestamp:new Date().toISOString()}};return{success:!1,error:{code:"UNKNOWN_ERROR",message:D instanceof Error?D.message:"An unknown error occurred"},exitCode:XD.GENERAL,meta:{timestamp:new Date().toISOString()}}}var PD=V(()=>{_2();o3();$D();fD()});function LD(D){console.log(JSON.stringify(D,null,2))}function w4(D){if(!D)throw new U("npm package name cannot be empty");if(D.length>L4)throw new U(`npm package name exceeds maximum length of ${L4} characters: \`${D}\``);if(D.includes("..")||D.includes("/./")||D.startsWith("./"))throw new U(`Invalid npm package name - path traversal detected: \`${D}\``);if(!dq.test(D))throw new U(`Invalid npm package name: \`${D}\`. Must be lowercase, start with alphanumeric, and contain only letters, numbers, hyphens, dots, or underscores.`)}function O4(D){if(!D?.trim())throw new U("npm specifier cannot be empty");let F=D.trim();if(!F.startsWith("npm:"))throw new U(`Invalid npm specifier: \`${D}\`. Must start with \`npm:\` prefix.`);let B=F.slice(4);if(!B)throw new U(`Invalid npm specifier: \`${D}\`. Package name is required.`);let $=B.lastIndexOf("@"),_,Q;if($>0){let Y=B.slice(0,$),q=B.slice($+1);if(Y.includes("/")||!Y.startsWith("@"))_=Y,Q=q||void 0;else throw new U(`Invalid npm specifier: \`${D}\`. Scoped packages must have format @scope/pkg.`)}else _=B;return w4(_),{type:"npm",name:_,version:Q}}function b4(D){return D.trim().startsWith("npm:")}async function s1(D,F){w4(D);let B=D.startsWith("@")?`@${encodeURIComponent(D.slice(1))}`:encodeURIComponent(D),$=`${mq}/${B}`;try{let _=F??AbortSignal.timeout(gq),Q=await fetch($,{signal:_,headers:{Accept:"application/json"}});if(Q.status===404)throw new MD(`npm package \`${D}\` not found on registry`);if(!Q.ok)throw new RD(`Failed to fetch npm package \`${D}\`: HTTP ${Q.status} ${Q.statusText}`);return await Q.json()}catch(_){if(_ instanceof MD||_ instanceof RD)throw _;if(_ instanceof Error&&(_.name==="AbortError"||_.name==="TimeoutError"))throw new RD(`Request to npm registry timed out for package \`${D}\``);let Q=_ instanceof Error?_.message:String(_);throw new RD(`Failed to fetch npm package \`${D}\`: ${Q}`)}}function pF(D,F){return F?`${D}@${F}`:D}function R4(D){let F=[];if(D.type!=="module")throw new U(`Package \`${D.name}\` is not an ESM module (missing "type": "module" in package.json)`);let B=Boolean(D.main),$=D.exports!==void 0;if(!B&&!$)throw new U(`Package \`${D.name}\` has no entry point (missing "main" or "exports")`);if(!D.name.includes("opencode"))F.push(`Package name \`${D.name}\` doesn't contain "opencode" - this may not be an OpenCode plugin`);return{valid:!0,warnings:F}}async function M8(D,F,B){let $=await s1(D,B),_=F??$["dist-tags"].latest,Q=$.versions[_];if(!Q)throw new MD(`Version \`${_}\` not found for npm package \`${D}\``);return Q}function Z4(D){let F=D.trim(),B=F.lastIndexOf("@");if(B<=0)return F;let $=F.slice(0,B);if($.includes("/")||!$.startsWith("@"))return $;return F}var mq="https://registry.npmjs.org",gq=30000,dq,L4=214;var a1=V(()=>{$D();dq=/^(?:@[a-z0-9][\w.-]*\/)?[a-z0-9][\w.-]*$/});function $F(D,F){let B=D.get(F.absolutePath);if(!B){D.set(F.absolutePath,F);return}let $=B.content.equals(F.content)?"identical content":"different content";throw new gD(`Intra-batch target collision at "${F.relativePath}". Both "${B.source}" and "${F.source}" resolve to this path with ${$}. Rename one manifest target so each component writes to a unique path.`)}var A8=V(()=>{$D()});import{createHash as cq}from"crypto";import{existsSync as lq}from"fs";import{join as pq}from"path";function _F(D){return cq("sha256").update(D).digest("hex")}async function j8(D){let F=[...D].sort(($,_)=>$.path.localeCompare(_.path)),B=[];for(let $ of F){let _=_F($.content);B.push(`${$.path}:${_}`)}return _F(B.join(`
87
- `))}async function N3(D,F){let B=[],$=[],_=[];for(let Q of F.files){let Y=pq(D,Q.path);if(!lq(Y)){$.push(Q.path),_.push({path:Q.path,status:"missing"});continue}let q=await Bun.file(Y).text();if(_F(q)!==Q.hash)B.push(Q.path),_.push({path:Q.path,status:"modified"});else _.push({path:Q.path,status:"intact"})}return{intact:B.length===0&&$.length===0,modified:B,missing:$,details:_}}var iF=V(()=>{tD()});function oD(D){return D.addOption(L0.cwd()).addOption(L0.quiet()).addOption(L0.json())}function w0(D){return D.addOption(L0.verbose())}function r0(D){return D.addOption(L0.global)}function K8(D){return D.addOption(L0.profile())}function N4(D){if(!D||D.length===0)throw new C0(D,"cannot be empty");if(D.length>32)throw new C0(D,"must be 32 characters or less");if(!/^[a-zA-Z][a-zA-Z0-9._-]*$/.test(D))throw new C0(D,"must start with a letter and contain only alphanumeric characters, dots, underscores, or hyphens")}var L0;var x0=V(()=>{B8();$D();L0={cwd:()=>new H2("--cwd <path>","Working directory").default(process.cwd()),quiet:()=>new H2("-q, --quiet","Suppress output"),json:()=>new H2("--json","Output as JSON"),profile:()=>new H2("-p, --profile <name>","Target a specific profile's config"),verbose:()=>new H2("-v, --verbose","Verbose output"),global:new H2("-g, --global","Install to global OpenCode config (~/.config/opencode)")}});function sq(){let D=new Map;for(let[F,B]of Object.entries(SD)){for(let[$,_]of Object.entries(B))SD[$]={open:`\x1B[${_[0]}m`,close:`\x1B[${_[1]}m`},B[$]=SD[$],D.set(_[0],_[1]);Object.defineProperty(SD,F,{value:B,enumerable:!1})}return Object.defineProperty(SD,"codes",{value:D,enumerable:!1}),SD.color.close="\x1B[39m",SD.bgColor.close="\x1B[49m",SD.color.ansi=S4(),SD.color.ansi256=k4(),SD.color.ansi16m=I4(),SD.bgColor.ansi=S4(10),SD.bgColor.ansi256=k4(10),SD.bgColor.ansi16m=I4(10),Object.defineProperties(SD,{rgbToAnsi256:{value(F,B,$){if(F===B&&B===$){if(F<8)return 16;if(F>248)return 231;return Math.round((F-8)/247*24)+232}return 16+36*Math.round(F/255*5)+6*Math.round(B/255*5)+Math.round($/255*5)},enumerable:!1},hexToRgb:{value(F){let B=/[a-f\d]{6}|[a-f\d]{3}/i.exec(F.toString(16));if(!B)return[0,0,0];let[$]=B;if($.length===3)$=[...$].map((Q)=>Q+Q).join("");let _=Number.parseInt($,16);return[_>>16&255,_>>8&255,_&255]},enumerable:!1},hexToAnsi256:{value:(F)=>SD.rgbToAnsi256(...SD.hexToRgb(F)),enumerable:!1},ansi256ToAnsi:{value(F){if(F<8)return 30+F;if(F<16)return 90+(F-8);let B,$,_;if(F>=232)B=((F-232)*10+8)/255,$=B,_=B;else{F-=16;let q=F%36;B=Math.floor(F/36)/5,$=Math.floor(q/6)/5,_=q%6/5}let Q=Math.max(B,$,_)*2;if(Q===0)return 30;let Y=30+(Math.round(_)<<2|Math.round($)<<1|Math.round(B));if(Q===2)Y+=60;return Y},enumerable:!1},rgbToAnsi:{value:(F,B,$)=>SD.ansi256ToAnsi(SD.rgbToAnsi256(F,B,$)),enumerable:!1},hexToAnsi:{value:(F)=>SD.ansi256ToAnsi(SD.hexToAnsi256(F)),enumerable:!1}}),SD}var S4=(D=0)=>(F)=>`\x1B[${F+D}m`,k4=(D=0)=>(F)=>`\x1B[${38+D};5;${F}m`,I4=(D=0)=>(F,B,$)=>`\x1B[${38+D};2;${F};${B};${$}m`,SD,Sj,iq,nq,kj,aq,y0;var T4=V(()=>{SD={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Sj=Object.keys(SD.modifier),iq=Object.keys(SD.color),nq=Object.keys(SD.bgColor),kj=[...iq,...nq];aq=sq(),y0=aq});import o1 from"process";import oq from"os";import v4 from"tty";function O0(D,F=globalThis.Deno?globalThis.Deno.args:o1.argv){let B=D.startsWith("-")?"":D.length===1?"-":"--",$=F.indexOf(B+D),_=F.indexOf("--");return $!==-1&&(_===-1||$<_)}function rq(){if("FORCE_COLOR"in kD){if(kD.FORCE_COLOR==="true")return 1;if(kD.FORCE_COLOR==="false")return 0;return kD.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(kD.FORCE_COLOR,10),3)}}function tq(D){if(D===0)return!1;return{level:D,hasBasic:!0,has256:D>=2,has16m:D>=3}}function eq(D,{streamIsTTY:F,sniffFlags:B=!0}={}){let $=rq();if($!==void 0)U8=$;let _=B?U8:$;if(_===0)return 0;if(B){if(O0("color=16m")||O0("color=full")||O0("color=truecolor"))return 3;if(O0("color=256"))return 2}if("TF_BUILD"in kD&&"AGENT_NAME"in kD)return 1;if(D&&!F&&_===void 0)return 0;let Q=_||0;if(kD.TERM==="dumb")return Q;if(o1.platform==="win32"){let Y=oq.release().split(".");if(Number(Y[0])>=10&&Number(Y[2])>=10586)return Number(Y[2])>=14931?3:2;return 1}if("CI"in kD){if(["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some((Y)=>(Y in kD)))return 3;if(["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some((Y)=>(Y in kD))||kD.CI_NAME==="codeship")return 1;return Q}if("TEAMCITY_VERSION"in kD)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(kD.TEAMCITY_VERSION)?1:0;if(kD.COLORTERM==="truecolor")return 3;if(kD.TERM==="xterm-kitty")return 3;if(kD.TERM==="xterm-ghostty")return 3;if(kD.TERM==="wezterm")return 3;if("TERM_PROGRAM"in kD){let Y=Number.parseInt((kD.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(kD.TERM_PROGRAM){case"iTerm.app":return Y>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(kD.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(kD.TERM))return 1;if("COLORTERM"in kD)return 1;return Q}function C4(D,F={}){let B=eq(D,{streamIsTTY:D&&D.isTTY,...F});return tq(B)}var kD,U8,DH,u4;var P4=V(()=>{({env:kD}=o1);if(O0("no-color")||O0("no-colors")||O0("color=false")||O0("color=never"))U8=0;else if(O0("color")||O0("colors")||O0("color=true")||O0("color=always"))U8=1;DH={stdout:C4({isTTY:v4.isatty(1)}),stderr:C4({isTTY:v4.isatty(2)})},u4=DH});function x4(D,F,B){let $=D.indexOf(F);if($===-1)return D;let _=F.length,Q=0,Y="";do Y+=D.slice(Q,$)+F+B,Q=$+_,$=D.indexOf(F,Q);while($!==-1);return Y+=D.slice(Q),Y}function y4(D,F,B,$){let _=0,Q="";do{let Y=D[$-1]==="\r";Q+=D.slice(_,Y?$-1:$)+F+(Y?`\r
84
+ `;var n1=V(()=>{b0();Q0();c1={formattingOptions:{tabSize:2,insertSpaces:!1,eol:`
85
+ `}}});function H4(D){return D.replace(/\r\n/g,`
86
+ `).trim()}function s1(D,F){return H4(D)===H4(F)}import{existsSync as uq,lstatSync as Pq}from"fs";import{rm as yq,unlink as xq}from"fs/promises";import{join as W4}from"path";function G4(D,F){let B=[];for(let[$,_]of Object.entries(F)){let Q=D[$]??null;if(Q!==_)B.push({name:$,from:Q,to:_})}return{changed:B.length>0,entries:B}}function z4(D,F){let B=W4(D,"node_modules"),$=F.map((_)=>_.name).join(", ");return{action:"delete",target:B,details:{reason:`dependency declarations changed (${$}); invalidating to force reinstall`,path:B}}}function X4(D){if(D&&typeof D==="object"&&"code"in D)return String(D.code);return"UNKNOWN"}function a1(D){if(D instanceof Error)return D.message;return String(D)}function mq(D){return new Promise((F)=>setTimeout(F,D))}async function M4(D,F){let B=W4(D,"node_modules"),$=F?.rmImpl??((_,Q)=>yq(_,Q));if(!uq(B))return{success:!0,action:"none"};try{if(Pq(B).isSymbolicLink())return await xq(B),{success:!0,action:"unlinked"}}catch(_){let Q=X4(_);if(Q==="ENOENT")return{success:!0,action:"none"};return{success:!1,action:"failed",error:{code:Q,message:a1(_)}}}for(let _=0;_<=J4;_++)try{return await $(B,{recursive:!0,force:!0}),{success:!0,action:"removed"}}catch(Q){let Y=X4(Q);if(Y==="ENOENT")return{success:!0,action:"none"};if(!fq.has(Y))return{success:!1,action:"failed",error:{code:Y,message:a1(Q)}};if(_<J4)await mq(hq*2**_);else return{success:!1,action:"failed",error:{code:Y,message:a1(Q)}}}return{success:!1,action:"failed",error:{code:"UNKNOWN",message:"exhausted retries"}}}var fq,J4=3,hq=100;var A4=V(()=>{fq=new Set(["EBUSY","ENOTEMPTY"])});function j4(D,F){let B=0,$,_="",Q="";for(;B<D.length;B++)if($=D[B],_+=$.open,Q+=$.close,~F.indexOf($.close))F=F.replace($.rgx,$.close+$.open);return _+F+Q}function gq(D,F){let B={has:D,keys:F};return B.reset=ED.reset.bind(B),B.bold=ED.bold.bind(B),B.dim=ED.dim.bind(B),B.italic=ED.italic.bind(B),B.underline=ED.underline.bind(B),B.inverse=ED.inverse.bind(B),B.hidden=ED.hidden.bind(B),B.strikethrough=ED.strikethrough.bind(B),B.black=ED.black.bind(B),B.red=ED.red.bind(B),B.green=ED.green.bind(B),B.yellow=ED.yellow.bind(B),B.blue=ED.blue.bind(B),B.magenta=ED.magenta.bind(B),B.cyan=ED.cyan.bind(B),B.white=ED.white.bind(B),B.gray=ED.gray.bind(B),B.grey=ED.grey.bind(B),B.bgBlack=ED.bgBlack.bind(B),B.bgRed=ED.bgRed.bind(B),B.bgGreen=ED.bgGreen.bind(B),B.bgYellow=ED.bgYellow.bind(B),B.bgBlue=ED.bgBlue.bind(B),B.bgMagenta=ED.bgMagenta.bind(B),B.bgCyan=ED.bgCyan.bind(B),B.bgWhite=ED.bgWhite.bind(B),B}function RD(D,F){let B={open:`\x1B[${D}m`,close:`\x1B[${F}m`,rgx:new RegExp(`\\x1b\\[${F}m`,"g")};return function($){if(this!==void 0&&this.has!==void 0)return!!~this.has.indexOf(D)||(this.has.push(D),this.keys.push(B)),$===void 0?this:ED.enabled?j4(this.keys,$+""):$+"";return $===void 0?gq([D],[B]):ED.enabled?j4([B],$+""):$+""}}var o1,K4,U4,V4,E4=!0,ED,P;var G2=V(()=>{if(typeof process<"u")({FORCE_COLOR:o1,NODE_DISABLE_COLORS:K4,NO_COLOR:U4,TERM:V4}=process.env||{}),E4=process.stdout&&process.stdout.isTTY;ED={enabled:!K4&&U4==null&&V4!=="dumb"&&(o1!=null&&o1!=="0"||E4),reset:RD(0,0),bold:RD(1,22),dim:RD(2,22),italic:RD(3,23),underline:RD(4,24),inverse:RD(7,27),hidden:RD(8,28),strikethrough:RD(9,29),black:RD(30,39),red:RD(31,39),green:RD(32,39),yellow:RD(33,39),blue:RD(34,39),magenta:RD(35,39),cyan:RD(36,39),white:RD(37,39),gray:RD(90,39),grey:RD(90,39),bgBlack:RD(40,49),bgRed:RD(41,49),bgGreen:RD(42,49),bgYellow:RD(43,49),bgBlue:RD(44,49),bgMagenta:RD(45,49),bgCyan:RD(46,49),bgWhite:RD(47,49)};P=ED});function w4(D,F){if(D==null||D==="")return F;let B=D.trim().toLowerCase();if(B==="true"||B==="1"||B==="yes"||B==="on")return!0;if(B==="false"||B==="0"||B==="no"||B==="off")return!1;return F}var dq,FF,L4;var N3=V(()=>{dq=Boolean(process.env.CI||process.env.GITHUB_ACTIONS||process.env.GITLAB_CI||process.env.CIRCLECI||process.env.JENKINS_URL||process.env.BUILDKITE),FF=Boolean(process.stdout.isTTY&&!dq),L4=Boolean(FF&&process.env.FORCE_COLOR!=="0"&&process.env.NO_COLOR===void 0)});var pF,W,G0;var hD=V(()=>{G2();N3();if(!L4)P.enabled=!1;pF={},W={info(...D){if(pF.quiet)return;console.log(P.blue("info"),...D)},success(...D){if(pF.quiet)return;console.log(P.green("\u2713"),...D)},warn(...D){if(pF.quiet)return;console.warn(P.yellow("warn"),...D)},error(...D){console.error(P.red("error"),...D)},debug(...D){if(!pF.verbose)return;console.log(P.gray("debug"),...D)},log(...D){if(pF.quiet)return;console.log(...D)},break(){if(pF.quiet)return;console.log("")}},G0={component:(D)=>P.cyan(D),path:(D)=>P.green(D),command:(D)=>P.yellow(D),url:(D)=>P.blue().underline(D),error:(D)=>P.red(D),dim:(D)=>P.gray(D),bold:(D)=>P.bold(D)}});function z0(D,F={}){if(F.json){console.log(JSON.stringify(D,null,2));return}if(F.quiet)return;if(W.info(G0.dim("\uD83D\uDD0D DRY RUN: No changes will be made")),W.break(),D.wouldPerform.length===0)W.info("No actions would be performed.");else{let $=cq(D.wouldPerform);for(let[_,Q]of Object.entries($)){let Y=lq(_);W.info(`Would ${Y} ${Q.length} item(s):`);for(let q of Q){let H=pq(q.details);W.info(` \u2022 ${G0.component(q.target)}${H}`)}W.break()}}if(D.summary)W.info(D.summary),W.break();if(D.validation.errors&&D.validation.errors.length>0){W.error("Would fail with errors:");for(let $ of D.validation.errors)W.error(` \u2022 ${$}`);W.break()}if(D.validation.warnings&&D.validation.warnings.length>0){W.warn("Warnings:");for(let $ of D.validation.warnings)W.warn(` \u2022 ${$}`);W.break()}if(F.hints&&F.hints.length>0){for(let $ of F.hints)W.info(G0.dim($));W.break()}W.info(G0.dim("Run without --dry-run to apply changes."))}function cq(D){let F={};for(let B of D){if(!F[B.action])F[B.action]=[];F[B.action]?.push(B)}return F}function lq(D){return{add:"add",remove:"remove",delete:"delete",update:"update",create:"create",modify:"modify"}[D]??D}function pq(D){if(!D||Object.keys(D).length===0)return"";let F=[];for(let[B,$]of Object.entries(D??{}))if($!==void 0&&$!==null)F.push(`${B}: ${G0.dim(String($))}`);return F.length>0?` (${F.join(", ")})`:""}var BF=V(()=>{hD()});var O4={};j2(O4,{wrapAction:()=>iq,handleError:()=>t});function t(D,F={}){if(F.json){let B=nq(D);console.log(JSON.stringify(B,null,2)),process.exit(B.exitCode)}if(D instanceof zD)W.error(D.message),process.exit(D.exitCode);if(D instanceof lD){W.error("Validation failed:");for(let B of D.issues){let $=B.path.join(".");W.error(` ${$}: ${B.message}`)}process.exit(XD.CONFIG)}if(D instanceof Error){if(W.error(D.message),process.env.DEBUG)console.error(D.stack)}else W.error("An unknown error occurred");process.exit(XD.GENERAL)}function iq(D){return async(...F)=>{try{await D(...F)}catch(B){t(B)}}}function nq(D){if(D instanceof vF)return{success:!1,error:{code:D.code,message:D.message,details:{conflictType:D.conflictType,registryName:D.registryName,existingUrl:D.existingUrl,newUrl:D.newUrl,...D.targetLabel&&{targetLabel:D.targetLabel},...D.existingName&&{existingName:D.existingName}}},exitCode:D.exitCode,meta:{timestamp:new Date().toISOString()}};if(D instanceof d2)return{success:!1,error:{code:D.code,message:D.message,details:{component:D.component,expected:D.expected,found:D.found}},exitCode:D.exitCode,meta:{timestamp:new Date().toISOString()}};if(D instanceof ZD){let F={};if(D.url)F.url=D.url;if(D.status!==void 0)F.status=D.status;if(D.statusText)F.statusText=D.statusText;if(D.phase)F.phase=D.phase;if(D.qualifiedName)F.qualifiedName=D.qualifiedName;if(D.registryContext)F.registryContext=D.registryContext;if(D.registryName)F.registryName=D.registryName;return{success:!1,error:{code:D.code,message:D.message,...Object.keys(F).length>0&&{details:F}},exitCode:D.exitCode,meta:{timestamp:new Date().toISOString()}}}if(D instanceof CD)return{success:!1,error:{code:D.code,message:D.message,details:{profile:D.profile}},exitCode:D.exitCode,meta:{timestamp:new Date().toISOString()}};if(D instanceof O2)return{success:!1,error:{code:D.code,message:D.message,details:{profile:D.profile}},exitCode:D.exitCode,meta:{timestamp:new Date().toISOString()}};if(D instanceof C0)return{success:!1,error:{code:D.code,message:D.message,details:{profile:D.profile,reason:D.reason}},exitCode:D.exitCode,meta:{timestamp:new Date().toISOString()}};if(D instanceof s0)return{success:!1,error:{code:"BUILD_ERROR",message:D.message,details:{errors:D.errors}},exitCode:XD.GENERAL,meta:{timestamp:new Date().toISOString()}};if(D instanceof v0){let F={url:D.url,issue:D.issue,remediation:D.remediation};if(D.schemaUrl!==void 0)F.schemaUrl=D.schemaUrl;if(D.supportedMajor!==void 0)F.supportedMajor=D.supportedMajor;if(D.detectedMajor!==void 0)F.detectedMajor=D.detectedMajor;return{success:!1,error:{code:D.code,message:D.message,details:F},exitCode:D.exitCode,meta:{timestamp:new Date().toISOString()}}}if(D instanceof g2)return{success:!1,error:{code:D.code,message:D.message,details:D.details},exitCode:D.exitCode,meta:{timestamp:new Date().toISOString()}};if(D instanceof zD)return{success:!1,error:{code:D.code,message:D.message},exitCode:D.exitCode,meta:{timestamp:new Date().toISOString()}};if(D instanceof lD)return{success:!1,error:{code:"VALIDATION_ERROR",message:D.issues.map((F)=>`${F.path.join(".")}: ${F.message}`).join("; "),details:{issues:D.issues.map((F)=>({path:F.path.join("."),message:F.message,code:F.code}))}},exitCode:XD.CONFIG,meta:{timestamp:new Date().toISOString()}};return{success:!1,error:{code:"UNKNOWN_ERROR",message:D instanceof Error?D.message:"An unknown error occurred"},exitCode:XD.GENERAL,meta:{timestamp:new Date().toISOString()}}}var yD=V(()=>{Q2();r3();$D();hD()});function LD(D){console.log(JSON.stringify(D,null,2))}function Z4(D){if(!D)throw new U("npm package name cannot be empty");if(D.length>b4)throw new U(`npm package name exceeds maximum length of ${b4} characters: \`${D}\``);if(D.includes("..")||D.includes("/./")||D.startsWith("./"))throw new U(`Invalid npm package name - path traversal detected: \`${D}\``);if(!oq.test(D))throw new U(`Invalid npm package name: \`${D}\`. Must be lowercase, start with alphanumeric, and contain only letters, numbers, hyphens, dots, or underscores.`)}function R4(D){if(!D?.trim())throw new U("npm specifier cannot be empty");let F=D.trim();if(!F.startsWith("npm:"))throw new U(`Invalid npm specifier: \`${D}\`. Must start with \`npm:\` prefix.`);let B=F.slice(4);if(!B)throw new U(`Invalid npm specifier: \`${D}\`. Package name is required.`);let $=B.lastIndexOf("@"),_,Q;if($>0){let Y=B.slice(0,$),q=B.slice($+1);if(Y.includes("/")||!Y.startsWith("@"))_=Y,Q=q||void 0;else throw new U(`Invalid npm specifier: \`${D}\`. Scoped packages must have format @scope/pkg.`)}else _=B;return Z4(_),{type:"npm",name:_,version:Q}}function N4(D){return D.trim().startsWith("npm:")}async function r1(D,F){Z4(D);let B=D.startsWith("@")?`@${encodeURIComponent(D.slice(1))}`:encodeURIComponent(D),$=`${sq}/${B}`;try{let _=F??AbortSignal.timeout(aq),Q=await fetch($,{signal:_,headers:{Accept:"application/json"}});if(Q.status===404)throw new MD(`npm package \`${D}\` not found on registry`);if(!Q.ok)throw new ZD(`Failed to fetch npm package \`${D}\`: HTTP ${Q.status} ${Q.statusText}`);return await Q.json()}catch(_){if(_ instanceof MD||_ instanceof ZD)throw _;if(_ instanceof Error&&(_.name==="AbortError"||_.name==="TimeoutError"))throw new ZD(`Request to npm registry timed out for package \`${D}\``);let Q=_ instanceof Error?_.message:String(_);throw new ZD(`Failed to fetch npm package \`${D}\`: ${Q}`)}}function iF(D,F){return F?`${D}@${F}`:D}function S4(D){let F=[];if(D.type!=="module")throw new U(`Package \`${D.name}\` is not an ESM module (missing "type": "module" in package.json)`);let B=Boolean(D.main),$=D.exports!==void 0;if(!B&&!$)throw new U(`Package \`${D.name}\` has no entry point (missing "main" or "exports")`);if(!D.name.includes("opencode"))F.push(`Package name \`${D.name}\` doesn't contain "opencode" - this may not be an OpenCode plugin`);return{valid:!0,warnings:F}}async function j8(D,F,B){let $=await r1(D,B),_=F??$["dist-tags"].latest,Q=$.versions[_];if(!Q)throw new MD(`Version \`${_}\` not found for npm package \`${D}\``);return Q}function k4(D){let F=D.trim(),B=F.lastIndexOf("@");if(B<=0)return F;let $=F.slice(0,B);if($.includes("/")||!$.startsWith("@"))return $;return F}var sq="https://registry.npmjs.org",aq=30000,oq,b4=214;var t1=V(()=>{$D();oq=/^(?:@[a-z0-9][\w.-]*\/)?[a-z0-9][\w.-]*$/});function $F(D,F){let B=D.get(F.absolutePath);if(!B){D.set(F.absolutePath,F);return}let $=B.content.equals(F.content)?"identical content":"different content";throw new dD(`Intra-batch target collision at "${F.relativePath}". Both "${B.source}" and "${F.source}" resolve to this path with ${$}. Rename one manifest target so each component writes to a unique path.`)}var K8=V(()=>{$D()});import{createHash as rq}from"crypto";import{existsSync as tq}from"fs";import{join as eq}from"path";function _F(D){return rq("sha256").update(D).digest("hex")}async function U8(D){let F=[...D].sort(($,_)=>$.path.localeCompare(_.path)),B=[];for(let $ of F){let _=_F($.content);B.push(`${$.path}:${_}`)}return _F(B.join(`
87
+ `))}async function S3(D,F){let B=[],$=[],_=[];for(let Q of F.files){let Y=eq(D,Q.path);if(!tq(Y)){$.push(Q.path),_.push({path:Q.path,status:"missing"});continue}let q=await Bun.file(Y).text();if(_F(q)!==Q.hash)B.push(Q.path),_.push({path:Q.path,status:"modified"});else _.push({path:Q.path,status:"intact"})}return{intact:B.length===0&&$.length===0,modified:B,missing:$,details:_}}var nF=V(()=>{eD()});function rD(D){return D.addOption(E0.cwd()).addOption(E0.quiet()).addOption(E0.json())}function L0(D){return D.addOption(E0.verbose())}function t0(D){return D.addOption(E0.global)}function V8(D){return D.addOption(E0.profile())}function I4(D){if(!D||D.length===0)throw new C0(D,"cannot be empty");if(D.length>32)throw new C0(D,"must be 32 characters or less");if(!/^[a-zA-Z][a-zA-Z0-9._-]*$/.test(D))throw new C0(D,"must start with a letter and contain only alphanumeric characters, dots, underscores, or hyphens")}var E0;var x0=V(()=>{$8();$D();E0={cwd:()=>new J2("--cwd <path>","Working directory").default(process.cwd()),quiet:()=>new J2("-q, --quiet","Suppress output"),json:()=>new J2("--json","Output as JSON"),profile:()=>new J2("-p, --profile <name>","Target a specific profile's config"),verbose:()=>new J2("-v, --verbose","Verbose output"),global:new J2("-g, --global","Install to global OpenCode config (~/.config/opencode)")}});function BH(){let D=new Map;for(let[F,B]of Object.entries(SD)){for(let[$,_]of Object.entries(B))SD[$]={open:`\x1B[${_[0]}m`,close:`\x1B[${_[1]}m`},B[$]=SD[$],D.set(_[0],_[1]);Object.defineProperty(SD,F,{value:B,enumerable:!1})}return Object.defineProperty(SD,"codes",{value:D,enumerable:!1}),SD.color.close="\x1B[39m",SD.bgColor.close="\x1B[49m",SD.color.ansi=T4(),SD.color.ansi256=v4(),SD.color.ansi16m=C4(),SD.bgColor.ansi=T4(10),SD.bgColor.ansi256=v4(10),SD.bgColor.ansi16m=C4(10),Object.defineProperties(SD,{rgbToAnsi256:{value(F,B,$){if(F===B&&B===$){if(F<8)return 16;if(F>248)return 231;return Math.round((F-8)/247*24)+232}return 16+36*Math.round(F/255*5)+6*Math.round(B/255*5)+Math.round($/255*5)},enumerable:!1},hexToRgb:{value(F){let B=/[a-f\d]{6}|[a-f\d]{3}/i.exec(F.toString(16));if(!B)return[0,0,0];let[$]=B;if($.length===3)$=[...$].map((Q)=>Q+Q).join("");let _=Number.parseInt($,16);return[_>>16&255,_>>8&255,_&255]},enumerable:!1},hexToAnsi256:{value:(F)=>SD.rgbToAnsi256(...SD.hexToRgb(F)),enumerable:!1},ansi256ToAnsi:{value(F){if(F<8)return 30+F;if(F<16)return 90+(F-8);let B,$,_;if(F>=232)B=((F-232)*10+8)/255,$=B,_=B;else{F-=16;let q=F%36;B=Math.floor(F/36)/5,$=Math.floor(q/6)/5,_=q%6/5}let Q=Math.max(B,$,_)*2;if(Q===0)return 30;let Y=30+(Math.round(_)<<2|Math.round($)<<1|Math.round(B));if(Q===2)Y+=60;return Y},enumerable:!1},rgbToAnsi:{value:(F,B,$)=>SD.ansi256ToAnsi(SD.rgbToAnsi256(F,B,$)),enumerable:!1},hexToAnsi:{value:(F)=>SD.ansi256ToAnsi(SD.hexToAnsi256(F)),enumerable:!1}}),SD}var T4=(D=0)=>(F)=>`\x1B[${F+D}m`,v4=(D=0)=>(F)=>`\x1B[${38+D};5;${F}m`,C4=(D=0)=>(F,B,$)=>`\x1B[${38+D};2;${F};${B};${$}m`,SD,yj,DH,FH,xj,$H,f0;var u4=V(()=>{SD={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},yj=Object.keys(SD.modifier),DH=Object.keys(SD.color),FH=Object.keys(SD.bgColor),xj=[...DH,...FH];$H=BH(),f0=$H});import e1 from"process";import _H from"os";import P4 from"tty";function w0(D,F=globalThis.Deno?globalThis.Deno.args:e1.argv){let B=D.startsWith("-")?"":D.length===1?"-":"--",$=F.indexOf(B+D),_=F.indexOf("--");return $!==-1&&(_===-1||$<_)}function QH(){if("FORCE_COLOR"in kD){if(kD.FORCE_COLOR==="true")return 1;if(kD.FORCE_COLOR==="false")return 0;return kD.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(kD.FORCE_COLOR,10),3)}}function YH(D){if(D===0)return!1;return{level:D,hasBasic:!0,has256:D>=2,has16m:D>=3}}function qH(D,{streamIsTTY:F,sniffFlags:B=!0}={}){let $=QH();if($!==void 0)E8=$;let _=B?E8:$;if(_===0)return 0;if(B){if(w0("color=16m")||w0("color=full")||w0("color=truecolor"))return 3;if(w0("color=256"))return 2}if("TF_BUILD"in kD&&"AGENT_NAME"in kD)return 1;if(D&&!F&&_===void 0)return 0;let Q=_||0;if(kD.TERM==="dumb")return Q;if(e1.platform==="win32"){let Y=_H.release().split(".");if(Number(Y[0])>=10&&Number(Y[2])>=10586)return Number(Y[2])>=14931?3:2;return 1}if("CI"in kD){if(["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some((Y)=>(Y in kD)))return 3;if(["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some((Y)=>(Y in kD))||kD.CI_NAME==="codeship")return 1;return Q}if("TEAMCITY_VERSION"in kD)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(kD.TEAMCITY_VERSION)?1:0;if(kD.COLORTERM==="truecolor")return 3;if(kD.TERM==="xterm-kitty")return 3;if(kD.TERM==="xterm-ghostty")return 3;if(kD.TERM==="wezterm")return 3;if("TERM_PROGRAM"in kD){let Y=Number.parseInt((kD.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(kD.TERM_PROGRAM){case"iTerm.app":return Y>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(kD.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(kD.TERM))return 1;if("COLORTERM"in kD)return 1;return Q}function y4(D,F={}){let B=qH(D,{streamIsTTY:D&&D.isTTY,...F});return YH(B)}var kD,E8,HH,x4;var f4=V(()=>{({env:kD}=e1);if(w0("no-color")||w0("no-colors")||w0("color=false")||w0("color=never"))E8=0;else if(w0("color")||w0("colors")||w0("color=true")||w0("color=always"))E8=1;HH={stdout:y4({isTTY:P4.isatty(1)}),stderr:y4({isTTY:P4.isatty(2)})},x4=HH});function h4(D,F,B){let $=D.indexOf(F);if($===-1)return D;let _=F.length,Q=0,Y="";do Y+=D.slice(Q,$)+F+B,Q=$+_,$=D.indexOf(F,Q);while($!==-1);return Y+=D.slice(Q),Y}function m4(D,F,B,$){let _=0,Q="";do{let Y=D[$-1]==="\r";Q+=D.slice(_,Y?$-1:$)+F+(Y?`\r
88
88
  `:`
89
89
  `)+B,_=$+1,$=D.indexOf(`
90
- `,_)}while($!==-1);return Q+=D.slice(_),Q}function k3(D){return BH(D)}var f4,h4,r1,nF,S3,m4,sF,FH=(D,F={})=>{if(F.level&&!(Number.isInteger(F.level)&&F.level>=0&&F.level<=3))throw Error("The `level` option should be an integer from 0 to 3");let B=f4?f4.level:0;D.level=F.level===void 0?B:F.level},BH=(D)=>{let F=(...B)=>B.join(" ");return FH(F,D),Object.setPrototypeOf(F,k3.prototype),F},t1=(D,F,B,...$)=>{if(D==="rgb"){if(F==="ansi16m")return y0[B].ansi16m(...$);if(F==="ansi256")return y0[B].ansi256(y0.rgbToAnsi256(...$));return y0[B].ansi(y0.rgbToAnsi(...$))}if(D==="hex")return t1("rgb",F,B,...y0.hexToRgb(...$));return y0[B][D](...$)},$H,_H,e1=(D,F,B)=>{let $,_;if(B===void 0)$=D,_=F;else $=B.openAll+D,_=F+B.closeAll;return{open:D,close:F,openAll:$,closeAll:_,parent:B}},V8=(D,F,B)=>{let $=(..._)=>QH($,_.length===1?""+_[0]:_.join(" "));return Object.setPrototypeOf($,_H),$[r1]=D,$[nF]=F,$[S3]=B,$},QH=(D,F)=>{if(D.level<=0||!F)return D[S3]?"":F;let B=D[nF];if(B===void 0)return F;let{openAll:$,closeAll:_}=B;if(F.includes("\x1B"))while(B!==void 0)F=x4(F,B.close,B.open),B=B.parent;let Q=F.indexOf(`
91
- `);if(Q!==-1)F=y4(F,_,$,Q);return $+F+_},YH,hj,f0;var D6=V(()=>{T4();P4();({stdout:f4,stderr:h4}=u4),r1=Symbol("GENERATOR"),nF=Symbol("STYLER"),S3=Symbol("IS_EMPTY"),m4=["ansi","ansi","ansi256","ansi16m"],sF=Object.create(null);Object.setPrototypeOf(k3.prototype,Function.prototype);for(let[D,F]of Object.entries(y0))sF[D]={get(){let B=V8(this,e1(F.open,F.close,this[nF]),this[S3]);return Object.defineProperty(this,D,{value:B}),B}};sF.visible={get(){let D=V8(this,this[nF],!0);return Object.defineProperty(this,"visible",{value:D}),D}};$H=["rgb","hex","ansi256"];for(let D of $H){sF[D]={get(){let{level:B}=this;return function(...$){let _=e1(t1(D,m4[B],"color",...$),y0.color.close,this[nF]);return V8(this,_,this[S3])}}};let F="bg"+D[0].toUpperCase()+D.slice(1);sF[F]={get(){let{level:B}=this;return function(...$){let _=e1(t1(D,m4[B],"bgColor",...$),y0.bgColor.close,this[nF]);return V8(this,_,this[S3])}}}}_H=Object.defineProperties(()=>{},{...sF,level:{enumerable:!0,get(){return this[r1].level},set(D){this[r1].level=D}}});Object.defineProperties(k3.prototype,sF);YH=k3(),hj=k3({level:h4?h4.level:0}),f0=YH});function F6(D,F,{ignoreNonConfigurable:B=!1}={}){let{name:$}=D;for(let _ of Reflect.ownKeys(F))qH(D,F,_,B);return JH(D,F),zH(D,F,$),D}var qH=(D,F,B,$)=>{if(B==="length"||B==="prototype")return;if(B==="arguments"||B==="caller")return;let _=Object.getOwnPropertyDescriptor(D,B),Q=Object.getOwnPropertyDescriptor(F,B);if(!HH(_,Q)&&$)return;Object.defineProperty(D,B,Q)},HH=function(D,F){return D===void 0||D.configurable||D.writable===F.writable&&D.enumerable===F.enumerable&&D.configurable===F.configurable&&(D.writable||D.value===F.value)},JH=(D,F)=>{let B=Object.getPrototypeOf(F);if(B===Object.getPrototypeOf(D))return;Object.setPrototypeOf(D,B)},XH=(D,F)=>`/* Wrapped ${D}*/
92
- ${F}`,GH,WH,zH=(D,F,B)=>{let $=B===""?"":`with ${B.trim()}() `,_=XH.bind(null,$,F.toString());Object.defineProperty(_,"name",WH);let{writable:Q,enumerable:Y,configurable:q}=GH;Object.defineProperty(D,"toString",{value:_,writable:Q,enumerable:Y,configurable:q})};var g4=V(()=>{GH=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),WH=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name")});var E8,d4=(D,F={})=>{if(typeof D!=="function")throw TypeError("Expected a function");let B,$=0,_=D.displayName||D.name||"<anonymous>",Q=function(...Y){if(E8.set(Q,++$),$===1)B=D.apply(this,Y),D=void 0;else if(F.throw===!0)throw Error(`Function \`${_}\` can only be called once`);return B};return F6(Q,D),E8.set(Q,$),Q},c4;var l4=V(()=>{g4();E8=new WeakMap;d4.callCount=(D)=>{if(!E8.has(D))throw Error(`The given function \`${D.name}\` is not wrapped by the \`onetime\` package`);return E8.get(D)};c4=d4});var QF;var p4=V(()=>{QF=[];QF.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")QF.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")QF.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT")});class i4{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if($6[B6])return $6[B6];MH($6,B6,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(D,F){this.listeners[D].push(F)}removeListener(D,F){let B=this.listeners[D],$=B.indexOf(F);if($===-1)return;if($===0&&B.length===1)B.length=0;else B.splice($,1)}emit(D,F,B){if(this.emitted[D])return!1;this.emitted[D]=!0;let $=!1;for(let _ of this.listeners[D])$=_(F,B)===!0||$;if(D==="exit")$=this.emit("afterExit",F,B)||$;return $}}class Q6{}var L8=(D)=>!!D&&typeof D==="object"&&typeof D.removeListener==="function"&&typeof D.emit==="function"&&typeof D.reallyExit==="function"&&typeof D.listeners==="function"&&typeof D.kill==="function"&&typeof D.pid==="number"&&typeof D.on==="function",B6,$6,MH,AH=(D)=>{return{onExit(F,B){return D.onExit(F,B)},load(){return D.load()},unload(){return D.unload()}}},n4,s4,_6,a4,ij,nj;var o4=V(()=>{p4();B6=Symbol.for("signal-exit emitter"),$6=globalThis,MH=Object.defineProperty.bind(Object);n4=class n4 extends Q6{onExit(){return()=>{}}load(){}unload(){}};s4=class s4 extends Q6{#Y=_6.platform==="win32"?"SIGINT":"SIGHUP";#B=new i4;#D;#_;#W;#F={};#Q=!1;constructor(D){super();this.#D=D,this.#F={};for(let F of QF)this.#F[F]=()=>{let B=this.#D.listeners(F),{count:$}=this.#B,_=D;if(typeof _.__signal_exit_emitter__==="object"&&typeof _.__signal_exit_emitter__.count==="number")$+=_.__signal_exit_emitter__.count;if(B.length===$){this.unload();let Q=this.#B.emit("exit",null,F),Y=F==="SIGHUP"?this.#Y:F;if(!Q)D.kill(D.pid,Y)}};this.#W=D.reallyExit,this.#_=D.emit}onExit(D,F){if(!L8(this.#D))return()=>{};if(this.#Q===!1)this.load();let B=F?.alwaysLast?"afterExit":"exit";return this.#B.on(B,D),()=>{if(this.#B.removeListener(B,D),this.#B.listeners.exit.length===0&&this.#B.listeners.afterExit.length===0)this.unload()}}load(){if(this.#Q)return;this.#Q=!0,this.#B.count+=1;for(let D of QF)try{let F=this.#F[D];if(F)this.#D.on(D,F)}catch(F){}this.#D.emit=(D,...F)=>{return this.#z(D,...F)},this.#D.reallyExit=(D)=>{return this.#$(D)}}unload(){if(!this.#Q)return;this.#Q=!1,QF.forEach((D)=>{let F=this.#F[D];if(!F)throw Error("Listener not defined for signal: "+D);try{this.#D.removeListener(D,F)}catch(B){}}),this.#D.emit=this.#_,this.#D.reallyExit=this.#W,this.#B.count-=1}#$(D){if(!L8(this.#D))return 0;return this.#D.exitCode=D||0,this.#B.emit("exit",this.#D.exitCode,null),this.#W.call(this.#D,this.#D.exitCode)}#z(D,...F){let B=this.#_;if(D==="exit"&&L8(this.#D)){if(typeof F[0]==="number")this.#D.exitCode=F[0];let $=B.call(this.#D,D,...F);return this.#B.emit("exit",this.#D.exitCode,null),$}else return B.call(this.#D,D,...F)}};_6=globalThis.process,{onExit:a4,load:ij,unload:nj}=AH(L8(_6)?new s4(_6):new n4)});import w8 from"process";var r4,jH,t4;var e4=V(()=>{l4();o4();r4=w8.stderr.isTTY?w8.stderr:w8.stdout.isTTY?w8.stdout:void 0,jH=r4?c4(()=>{a4(()=>{r4.write("\x1B[?25h")},{alwaysLast:!0})}):()=>{},t4=jH});import DB from"process";var O8=!1,aF,Y6;var FB=V(()=>{e4();aF={};aF.show=(D=DB.stderr)=>{if(!D.isTTY)return;O8=!1,D.write("\x1B[?25h")};aF.hide=(D=DB.stderr)=>{if(!D.isTTY)return;t4(),O8=!0,D.write("\x1B[?25l")};aF.toggle=(D,F)=>{if(D!==void 0)O8=D;if(O8)aF.show(F);else aF.hide(F)};Y6=aF});var BB=d0((BK,KH)=>{KH.exports={dots:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"]},dots2:{interval:80,frames:["\u28FE","\u28FD","\u28FB","\u28BF","\u287F","\u28DF","\u28EF","\u28F7"]},dots3:{interval:80,frames:["\u280B","\u2819","\u281A","\u281E","\u2816","\u2826","\u2834","\u2832","\u2833","\u2813"]},dots4:{interval:80,frames:["\u2804","\u2806","\u2807","\u280B","\u2819","\u2838","\u2830","\u2820","\u2830","\u2838","\u2819","\u280B","\u2807","\u2806"]},dots5:{interval:80,frames:["\u280B","\u2819","\u281A","\u2812","\u2802","\u2802","\u2812","\u2832","\u2834","\u2826","\u2816","\u2812","\u2810","\u2810","\u2812","\u2813","\u280B"]},dots6:{interval:80,frames:["\u2801","\u2809","\u2819","\u281A","\u2812","\u2802","\u2802","\u2812","\u2832","\u2834","\u2824","\u2804","\u2804","\u2824","\u2834","\u2832","\u2812","\u2802","\u2802","\u2812","\u281A","\u2819","\u2809","\u2801"]},dots7:{interval:80,frames:["\u2808","\u2809","\u280B","\u2813","\u2812","\u2810","\u2810","\u2812","\u2816","\u2826","\u2824","\u2820","\u2820","\u2824","\u2826","\u2816","\u2812","\u2810","\u2810","\u2812","\u2813","\u280B","\u2809","\u2808"]},dots8:{interval:80,frames:["\u2801","\u2801","\u2809","\u2819","\u281A","\u2812","\u2802","\u2802","\u2812","\u2832","\u2834","\u2824","\u2804","\u2804","\u2824","\u2820","\u2820","\u2824","\u2826","\u2816","\u2812","\u2810","\u2810","\u2812","\u2813","\u280B","\u2809","\u2808","\u2808"]},dots9:{interval:80,frames:["\u28B9","\u28BA","\u28BC","\u28F8","\u28C7","\u2867","\u2857","\u284F"]},dots10:{interval:80,frames:["\u2884","\u2882","\u2881","\u2841","\u2848","\u2850","\u2860"]},dots11:{interval:100,frames:["\u2801","\u2802","\u2804","\u2840","\u2880","\u2820","\u2810","\u2808"]},dots12:{interval:80,frames:["\u2880\u2800","\u2840\u2800","\u2804\u2800","\u2882\u2800","\u2842\u2800","\u2805\u2800","\u2883\u2800","\u2843\u2800","\u280D\u2800","\u288B\u2800","\u284B\u2800","\u280D\u2801","\u288B\u2801","\u284B\u2801","\u280D\u2809","\u280B\u2809","\u280B\u2809","\u2809\u2819","\u2809\u2819","\u2809\u2829","\u2808\u2899","\u2808\u2859","\u2888\u2829","\u2840\u2899","\u2804\u2859","\u2882\u2829","\u2842\u2898","\u2805\u2858","\u2883\u2828","\u2843\u2890","\u280D\u2850","\u288B\u2820","\u284B\u2880","\u280D\u2841","\u288B\u2801","\u284B\u2801","\u280D\u2809","\u280B\u2809","\u280B\u2809","\u2809\u2819","\u2809\u2819","\u2809\u2829","\u2808\u2899","\u2808\u2859","\u2808\u2829","\u2800\u2899","\u2800\u2859","\u2800\u2829","\u2800\u2898","\u2800\u2858","\u2800\u2828","\u2800\u2890","\u2800\u2850","\u2800\u2820","\u2800\u2880","\u2800\u2840"]},dots13:{interval:80,frames:["\u28FC","\u28F9","\u28BB","\u283F","\u285F","\u28CF","\u28E7","\u28F6"]},dots8Bit:{interval:80,frames:["\u2800","\u2801","\u2802","\u2803","\u2804","\u2805","\u2806","\u2807","\u2840","\u2841","\u2842","\u2843","\u2844","\u2845","\u2846","\u2847","\u2808","\u2809","\u280A","\u280B","\u280C","\u280D","\u280E","\u280F","\u2848","\u2849","\u284A","\u284B","\u284C","\u284D","\u284E","\u284F","\u2810","\u2811","\u2812","\u2813","\u2814","\u2815","\u2816","\u2817","\u2850","\u2851","\u2852","\u2853","\u2854","\u2855","\u2856","\u2857","\u2818","\u2819","\u281A","\u281B","\u281C","\u281D","\u281E","\u281F","\u2858","\u2859","\u285A","\u285B","\u285C","\u285D","\u285E","\u285F","\u2820","\u2821","\u2822","\u2823","\u2824","\u2825","\u2826","\u2827","\u2860","\u2861","\u2862","\u2863","\u2864","\u2865","\u2866","\u2867","\u2828","\u2829","\u282A","\u282B","\u282C","\u282D","\u282E","\u282F","\u2868","\u2869","\u286A","\u286B","\u286C","\u286D","\u286E","\u286F","\u2830","\u2831","\u2832","\u2833","\u2834","\u2835","\u2836","\u2837","\u2870","\u2871","\u2872","\u2873","\u2874","\u2875","\u2876","\u2877","\u2838","\u2839","\u283A","\u283B","\u283C","\u283D","\u283E","\u283F","\u2878","\u2879","\u287A","\u287B","\u287C","\u287D","\u287E","\u287F","\u2880","\u2881","\u2882","\u2883","\u2884","\u2885","\u2886","\u2887","\u28C0","\u28C1","\u28C2","\u28C3","\u28C4","\u28C5","\u28C6","\u28C7","\u2888","\u2889","\u288A","\u288B","\u288C","\u288D","\u288E","\u288F","\u28C8","\u28C9","\u28CA","\u28CB","\u28CC","\u28CD","\u28CE","\u28CF","\u2890","\u2891","\u2892","\u2893","\u2894","\u2895","\u2896","\u2897","\u28D0","\u28D1","\u28D2","\u28D3","\u28D4","\u28D5","\u28D6","\u28D7","\u2898","\u2899","\u289A","\u289B","\u289C","\u289D","\u289E","\u289F","\u28D8","\u28D9","\u28DA","\u28DB","\u28DC","\u28DD","\u28DE","\u28DF","\u28A0","\u28A1","\u28A2","\u28A3","\u28A4","\u28A5","\u28A6","\u28A7","\u28E0","\u28E1","\u28E2","\u28E3","\u28E4","\u28E5","\u28E6","\u28E7","\u28A8","\u28A9","\u28AA","\u28AB","\u28AC","\u28AD","\u28AE","\u28AF","\u28E8","\u28E9","\u28EA","\u28EB","\u28EC","\u28ED","\u28EE","\u28EF","\u28B0","\u28B1","\u28B2","\u28B3","\u28B4","\u28B5","\u28B6","\u28B7","\u28F0","\u28F1","\u28F2","\u28F3","\u28F4","\u28F5","\u28F6","\u28F7","\u28B8","\u28B9","\u28BA","\u28BB","\u28BC","\u28BD","\u28BE","\u28BF","\u28F8","\u28F9","\u28FA","\u28FB","\u28FC","\u28FD","\u28FE","\u28FF"]},sand:{interval:80,frames:["\u2801","\u2802","\u2804","\u2840","\u2848","\u2850","\u2860","\u28C0","\u28C1","\u28C2","\u28C4","\u28CC","\u28D4","\u28E4","\u28E5","\u28E6","\u28EE","\u28F6","\u28F7","\u28FF","\u287F","\u283F","\u289F","\u281F","\u285B","\u281B","\u282B","\u288B","\u280B","\u280D","\u2849","\u2809","\u2811","\u2821","\u2881"]},line:{interval:130,frames:["-","\\","|","/"]},line2:{interval:100,frames:["\u2802","-","\u2013","\u2014","\u2013","-"]},pipe:{interval:100,frames:["\u2524","\u2518","\u2534","\u2514","\u251C","\u250C","\u252C","\u2510"]},simpleDots:{interval:400,frames:[". ",".. ","..."," "]},simpleDotsScrolling:{interval:200,frames:[". ",".. ","..."," .."," ."," "]},star:{interval:70,frames:["\u2736","\u2738","\u2739","\u273A","\u2739","\u2737"]},star2:{interval:80,frames:["+","x","*"]},flip:{interval:70,frames:["_","_","_","-","`","`","'","\xB4","-","_","_","_"]},hamburger:{interval:100,frames:["\u2631","\u2632","\u2634"]},growVertical:{interval:120,frames:["\u2581","\u2583","\u2584","\u2585","\u2586","\u2587","\u2586","\u2585","\u2584","\u2583"]},growHorizontal:{interval:120,frames:["\u258F","\u258E","\u258D","\u258C","\u258B","\u258A","\u2589","\u258A","\u258B","\u258C","\u258D","\u258E"]},balloon:{interval:140,frames:[" ",".","o","O","@","*"," "]},balloon2:{interval:120,frames:[".","o","O","\xB0","O","o","."]},noise:{interval:100,frames:["\u2593","\u2592","\u2591"]},bounce:{interval:120,frames:["\u2801","\u2802","\u2804","\u2802"]},boxBounce:{interval:120,frames:["\u2596","\u2598","\u259D","\u2597"]},boxBounce2:{interval:100,frames:["\u258C","\u2580","\u2590","\u2584"]},triangle:{interval:50,frames:["\u25E2","\u25E3","\u25E4","\u25E5"]},binary:{interval:80,frames:["010010","001100","100101","111010","111101","010111","101011","111000","110011","110101"]},arc:{interval:100,frames:["\u25DC","\u25E0","\u25DD","\u25DE","\u25E1","\u25DF"]},circle:{interval:120,frames:["\u25E1","\u2299","\u25E0"]},squareCorners:{interval:180,frames:["\u25F0","\u25F3","\u25F2","\u25F1"]},circleQuarters:{interval:120,frames:["\u25F4","\u25F7","\u25F6","\u25F5"]},circleHalves:{interval:50,frames:["\u25D0","\u25D3","\u25D1","\u25D2"]},squish:{interval:100,frames:["\u256B","\u256A"]},toggle:{interval:250,frames:["\u22B6","\u22B7"]},toggle2:{interval:80,frames:["\u25AB","\u25AA"]},toggle3:{interval:120,frames:["\u25A1","\u25A0"]},toggle4:{interval:100,frames:["\u25A0","\u25A1","\u25AA","\u25AB"]},toggle5:{interval:100,frames:["\u25AE","\u25AF"]},toggle6:{interval:300,frames:["\u101D","\u1040"]},toggle7:{interval:80,frames:["\u29BE","\u29BF"]},toggle8:{interval:100,frames:["\u25CD","\u25CC"]},toggle9:{interval:100,frames:["\u25C9","\u25CE"]},toggle10:{interval:100,frames:["\u3282","\u3280","\u3281"]},toggle11:{interval:50,frames:["\u29C7","\u29C6"]},toggle12:{interval:120,frames:["\u2617","\u2616"]},toggle13:{interval:80,frames:["=","*","-"]},arrow:{interval:100,frames:["\u2190","\u2196","\u2191","\u2197","\u2192","\u2198","\u2193","\u2199"]},arrow2:{interval:80,frames:["\u2B06\uFE0F ","\u2197\uFE0F ","\u27A1\uFE0F ","\u2198\uFE0F ","\u2B07\uFE0F ","\u2199\uFE0F ","\u2B05\uFE0F ","\u2196\uFE0F "]},arrow3:{interval:120,frames:["\u25B9\u25B9\u25B9\u25B9\u25B9","\u25B8\u25B9\u25B9\u25B9\u25B9","\u25B9\u25B8\u25B9\u25B9\u25B9","\u25B9\u25B9\u25B8\u25B9\u25B9","\u25B9\u25B9\u25B9\u25B8\u25B9","\u25B9\u25B9\u25B9\u25B9\u25B8"]},bouncingBar:{interval:80,frames:["[ ]","[= ]","[== ]","[=== ]","[====]","[ ===]","[ ==]","[ =]","[ ]","[ =]","[ ==]","[ ===]","[====]","[=== ]","[== ]","[= ]"]},bouncingBall:{interval:80,frames:["( \u25CF )","( \u25CF )","( \u25CF )","( \u25CF )","( \u25CF)","( \u25CF )","( \u25CF )","( \u25CF )","( \u25CF )","(\u25CF )"]},smiley:{interval:200,frames:["\uD83D\uDE04 ","\uD83D\uDE1D "]},monkey:{interval:300,frames:["\uD83D\uDE48 ","\uD83D\uDE48 ","\uD83D\uDE49 ","\uD83D\uDE4A "]},hearts:{interval:100,frames:["\uD83D\uDC9B ","\uD83D\uDC99 ","\uD83D\uDC9C ","\uD83D\uDC9A ","\u2764\uFE0F "]},clock:{interval:100,frames:["\uD83D\uDD5B ","\uD83D\uDD50 ","\uD83D\uDD51 ","\uD83D\uDD52 ","\uD83D\uDD53 ","\uD83D\uDD54 ","\uD83D\uDD55 ","\uD83D\uDD56 ","\uD83D\uDD57 ","\uD83D\uDD58 ","\uD83D\uDD59 ","\uD83D\uDD5A "]},earth:{interval:180,frames:["\uD83C\uDF0D ","\uD83C\uDF0E ","\uD83C\uDF0F "]},material:{interval:17,frames:["\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588","\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581"]},moon:{interval:80,frames:["\uD83C\uDF11 ","\uD83C\uDF12 ","\uD83C\uDF13 ","\uD83C\uDF14 ","\uD83C\uDF15 ","\uD83C\uDF16 ","\uD83C\uDF17 ","\uD83C\uDF18 "]},runner:{interval:140,frames:["\uD83D\uDEB6 ","\uD83C\uDFC3 "]},pong:{interval:80,frames:["\u2590\u2802 \u258C","\u2590\u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802\u258C","\u2590 \u2820\u258C","\u2590 \u2840\u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590\u2820 \u258C"]},shark:{interval:120,frames:["\u2590|\\____________\u258C","\u2590_|\\___________\u258C","\u2590__|\\__________\u258C","\u2590___|\\_________\u258C","\u2590____|\\________\u258C","\u2590_____|\\_______\u258C","\u2590______|\\______\u258C","\u2590_______|\\_____\u258C","\u2590________|\\____\u258C","\u2590_________|\\___\u258C","\u2590__________|\\__\u258C","\u2590___________|\\_\u258C","\u2590____________|\\\u258C","\u2590____________/|\u258C","\u2590___________/|_\u258C","\u2590__________/|__\u258C","\u2590_________/|___\u258C","\u2590________/|____\u258C","\u2590_______/|_____\u258C","\u2590______/|______\u258C","\u2590_____/|_______\u258C","\u2590____/|________\u258C","\u2590___/|_________\u258C","\u2590__/|__________\u258C","\u2590_/|___________\u258C","\u2590/|____________\u258C"]},dqpb:{interval:100,frames:["d","q","p","b"]},weather:{interval:100,frames:["\u2600\uFE0F ","\u2600\uFE0F ","\u2600\uFE0F ","\uD83C\uDF24 ","\u26C5\uFE0F ","\uD83C\uDF25 ","\u2601\uFE0F ","\uD83C\uDF27 ","\uD83C\uDF28 ","\uD83C\uDF27 ","\uD83C\uDF28 ","\uD83C\uDF27 ","\uD83C\uDF28 ","\u26C8 ","\uD83C\uDF28 ","\uD83C\uDF27 ","\uD83C\uDF28 ","\u2601\uFE0F ","\uD83C\uDF25 ","\u26C5\uFE0F ","\uD83C\uDF24 ","\u2600\uFE0F ","\u2600\uFE0F "]},christmas:{interval:400,frames:["\uD83C\uDF32","\uD83C\uDF84"]},grenade:{interval:80,frames:["\u060C ","\u2032 "," \xB4 "," \u203E "," \u2E0C"," \u2E0A"," |"," \u204E"," \u2055"," \u0DF4 "," \u2053"," "," "," "]},point:{interval:125,frames:["\u2219\u2219\u2219","\u25CF\u2219\u2219","\u2219\u25CF\u2219","\u2219\u2219\u25CF","\u2219\u2219\u2219"]},layer:{interval:150,frames:["-","=","\u2261"]},betaWave:{interval:80,frames:["\u03C1\u03B2\u03B2\u03B2\u03B2\u03B2\u03B2","\u03B2\u03C1\u03B2\u03B2\u03B2\u03B2\u03B2","\u03B2\u03B2\u03C1\u03B2\u03B2\u03B2\u03B2","\u03B2\u03B2\u03B2\u03C1\u03B2\u03B2\u03B2","\u03B2\u03B2\u03B2\u03B2\u03C1\u03B2\u03B2","\u03B2\u03B2\u03B2\u03B2\u03B2\u03C1\u03B2","\u03B2\u03B2\u03B2\u03B2\u03B2\u03B2\u03C1"]},fingerDance:{interval:160,frames:["\uD83E\uDD18 ","\uD83E\uDD1F ","\uD83D\uDD96 ","\u270B ","\uD83E\uDD1A ","\uD83D\uDC46 "]},fistBump:{interval:80,frames:["\uD83E\uDD1C\u3000\u3000\u3000\u3000\uD83E\uDD1B ","\uD83E\uDD1C\u3000\u3000\u3000\u3000\uD83E\uDD1B ","\uD83E\uDD1C\u3000\u3000\u3000\u3000\uD83E\uDD1B ","\u3000\uD83E\uDD1C\u3000\u3000\uD83E\uDD1B\u3000 ","\u3000\u3000\uD83E\uDD1C\uD83E\uDD1B\u3000\u3000 ","\u3000\uD83E\uDD1C\u2728\uD83E\uDD1B\u3000\u3000 ","\uD83E\uDD1C\u3000\u2728\u3000\uD83E\uDD1B\u3000 "]},soccerHeader:{interval:80,frames:[" \uD83E\uDDD1\u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F\uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 "]},mindblown:{interval:160,frames:["\uD83D\uDE10 ","\uD83D\uDE10 ","\uD83D\uDE2E ","\uD83D\uDE2E ","\uD83D\uDE26 ","\uD83D\uDE26 ","\uD83D\uDE27 ","\uD83D\uDE27 ","\uD83E\uDD2F ","\uD83D\uDCA5 ","\u2728 ","\u3000 ","\u3000 ","\u3000 "]},speaker:{interval:160,frames:["\uD83D\uDD08 ","\uD83D\uDD09 ","\uD83D\uDD0A ","\uD83D\uDD09 "]},orangePulse:{interval:100,frames:["\uD83D\uDD38 ","\uD83D\uDD36 ","\uD83D\uDFE0 ","\uD83D\uDFE0 ","\uD83D\uDD36 "]},bluePulse:{interval:100,frames:["\uD83D\uDD39 ","\uD83D\uDD37 ","\uD83D\uDD35 ","\uD83D\uDD35 ","\uD83D\uDD37 "]},orangeBluePulse:{interval:100,frames:["\uD83D\uDD38 ","\uD83D\uDD36 ","\uD83D\uDFE0 ","\uD83D\uDFE0 ","\uD83D\uDD36 ","\uD83D\uDD39 ","\uD83D\uDD37 ","\uD83D\uDD35 ","\uD83D\uDD35 ","\uD83D\uDD37 "]},timeTravel:{interval:100,frames:["\uD83D\uDD5B ","\uD83D\uDD5A ","\uD83D\uDD59 ","\uD83D\uDD58 ","\uD83D\uDD57 ","\uD83D\uDD56 ","\uD83D\uDD55 ","\uD83D\uDD54 ","\uD83D\uDD53 ","\uD83D\uDD52 ","\uD83D\uDD51 ","\uD83D\uDD50 "]},aesthetic:{interval:80,frames:["\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B1\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B0\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0","\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1\u25B1"]},dwarfFortress:{interval:80,frames:[" \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A \u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A \u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A \u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\xA3\xA3\xA3 "," \u263A \u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\xA3\xA3\xA3 "," \u263A \u2588\xA3\xA3\xA3 "," \u263A\u2588\xA3\xA3\xA3 "," \u263A\u2588\xA3\xA3\xA3 "," \u263A\u2593\xA3\xA3\xA3 "," \u263A\u2593\xA3\xA3\xA3 "," \u263A\u2592\xA3\xA3\xA3 "," \u263A\u2592\xA3\xA3\xA3 "," \u263A\u2591\xA3\xA3\xA3 "," \u263A\u2591\xA3\xA3\xA3 "," \u263A \xA3\xA3\xA3 "," \u263A\xA3\xA3\xA3 "," \u263A\xA3\xA3\xA3 "," \u263A\u2593\xA3\xA3 "," \u263A\u2593\xA3\xA3 "," \u263A\u2592\xA3\xA3 "," \u263A\u2592\xA3\xA3 "," \u263A\u2591\xA3\xA3 "," \u263A\u2591\xA3\xA3 "," \u263A \xA3\xA3 "," \u263A\xA3\xA3 "," \u263A\xA3\xA3 "," \u263A\u2593\xA3 "," \u263A\u2593\xA3 "," \u263A\u2592\xA3 "," \u263A\u2592\xA3 "," \u263A\u2591\xA3 "," \u263A\u2591\xA3 "," \u263A \xA3 "," \u263A\xA3 "," \u263A\xA3 "," \u263A\u2593 "," \u263A\u2593 "," \u263A\u2592 "," \u263A\u2592 "," \u263A\u2591 "," \u263A\u2591 "," \u263A "," \u263A &"," \u263A \u263C&"," \u263A \u263C &"," \u263A\u263C &"," \u263A\u263C & "," \u203C & "," \u263A & "," \u203C & "," \u263A & "," \u203C & "," \u263A & ","\u203C & "," & "," & "," & \u2591 "," & \u2592 "," & \u2593 "," & \xA3 "," & \u2591\xA3 "," & \u2592\xA3 "," & \u2593\xA3 "," & \xA3\xA3 "," & \u2591\xA3\xA3 "," & \u2592\xA3\xA3 ","& \u2593\xA3\xA3 ","& \xA3\xA3\xA3 "," \u2591\xA3\xA3\xA3 "," \u2592\xA3\xA3\xA3 "," \u2593\xA3\xA3\xA3 "," \u2588\xA3\xA3\xA3 "," \u2591\u2588\xA3\xA3\xA3 "," \u2592\u2588\xA3\xA3\xA3 "," \u2593\u2588\xA3\xA3\xA3 "," \u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "]}}});var q6=d0(($K,_B)=>{var b8=Object.assign({},BB()),$B=Object.keys(b8);Object.defineProperty(b8,"random",{get(){let D=Math.floor(Math.random()*$B.length),F=$B[D];return b8[F]}});_B.exports=b8});import h0 from"process";function H6(){if(h0.platform!=="win32")return h0.env.TERM!=="linux";return Boolean(h0.env.CI)||Boolean(h0.env.WT_SESSION)||Boolean(h0.env.TERMINUS_SUBLIME)||h0.env.ConEmuTask==="{cmd::Cmder}"||h0.env.TERM_PROGRAM==="Terminus-Sublime"||h0.env.TERM_PROGRAM==="vscode"||h0.env.TERM==="xterm-256color"||h0.env.TERM==="alacritty"||h0.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var QB=()=>{};var UH,VH,EH,I3;var YB=V(()=>{D6();QB();UH={info:f0.blue("\u2139"),success:f0.green("\u2714"),warning:f0.yellow("\u26A0"),error:f0.red("\u2716")},VH={info:f0.blue("i"),success:f0.green("\u221A"),warning:f0.yellow("\u203C"),error:f0.red("\xD7")},EH=H6()?UH:VH,I3=EH});function J6({onlyFirst:D=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",D?void 0:"g")}function T3(D){if(typeof D!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof D}\``);return D.replace(LH,"")}var LH;var X6=V(()=>{LH=J6()});function qB(D){return D===161||D===164||D===167||D===168||D===170||D===173||D===174||D>=176&&D<=180||D>=182&&D<=186||D>=188&&D<=191||D===198||D===208||D===215||D===216||D>=222&&D<=225||D===230||D>=232&&D<=234||D===236||D===237||D===240||D===242||D===243||D>=247&&D<=250||D===252||D===254||D===257||D===273||D===275||D===283||D===294||D===295||D===299||D>=305&&D<=307||D===312||D>=319&&D<=322||D===324||D>=328&&D<=331||D===333||D===338||D===339||D===358||D===359||D===363||D===462||D===464||D===466||D===468||D===470||D===472||D===474||D===476||D===593||D===609||D===708||D===711||D>=713&&D<=715||D===717||D===720||D>=728&&D<=731||D===733||D===735||D>=768&&D<=879||D>=913&&D<=929||D>=931&&D<=937||D>=945&&D<=961||D>=963&&D<=969||D===1025||D>=1040&&D<=1103||D===1105||D===8208||D>=8211&&D<=8214||D===8216||D===8217||D===8220||D===8221||D>=8224&&D<=8226||D>=8228&&D<=8231||D===8240||D===8242||D===8243||D===8245||D===8251||D===8254||D===8308||D===8319||D>=8321&&D<=8324||D===8364||D===8451||D===8453||D===8457||D===8467||D===8470||D===8481||D===8482||D===8486||D===8491||D===8531||D===8532||D>=8539&&D<=8542||D>=8544&&D<=8555||D>=8560&&D<=8569||D===8585||D>=8592&&D<=8601||D===8632||D===8633||D===8658||D===8660||D===8679||D===8704||D===8706||D===8707||D===8711||D===8712||D===8715||D===8719||D===8721||D===8725||D===8730||D>=8733&&D<=8736||D===8739||D===8741||D>=8743&&D<=8748||D===8750||D>=8756&&D<=8759||D===8764||D===8765||D===8776||D===8780||D===8786||D===8800||D===8801||D>=8804&&D<=8807||D===8810||D===8811||D===8814||D===8815||D===8834||D===8835||D===8838||D===8839||D===8853||D===8857||D===8869||D===8895||D===8978||D>=9312&&D<=9449||D>=9451&&D<=9547||D>=9552&&D<=9587||D>=9600&&D<=9615||D>=9618&&D<=9621||D===9632||D===9633||D>=9635&&D<=9641||D===9650||D===9651||D===9654||D===9655||D===9660||D===9661||D===9664||D===9665||D>=9670&&D<=9672||D===9675||D>=9678&&D<=9681||D>=9698&&D<=9701||D===9711||D===9733||D===9734||D===9737||D===9742||D===9743||D===9756||D===9758||D===9792||D===9794||D===9824||D===9825||D>=9827&&D<=9829||D>=9831&&D<=9834||D===9836||D===9837||D===9839||D===9886||D===9887||D===9919||D>=9926&&D<=9933||D>=9935&&D<=9939||D>=9941&&D<=9953||D===9955||D===9960||D===9961||D>=9963&&D<=9969||D===9972||D>=9974&&D<=9977||D===9979||D===9980||D===9982||D===9983||D===10045||D>=10102&&D<=10111||D>=11094&&D<=11097||D>=12872&&D<=12879||D>=57344&&D<=63743||D>=65024&&D<=65039||D===65533||D>=127232&&D<=127242||D>=127248&&D<=127277||D>=127280&&D<=127337||D>=127344&&D<=127373||D===127375||D===127376||D>=127387&&D<=127404||D>=917760&&D<=917999||D>=983040&&D<=1048573||D>=1048576&&D<=1114109}function HB(D){return D===12288||D>=65281&&D<=65376||D>=65504&&D<=65510}function JB(D){return D>=4352&&D<=4447||D===8986||D===8987||D===9001||D===9002||D>=9193&&D<=9196||D===9200||D===9203||D===9725||D===9726||D===9748||D===9749||D>=9776&&D<=9783||D>=9800&&D<=9811||D===9855||D>=9866&&D<=9871||D===9875||D===9889||D===9898||D===9899||D===9917||D===9918||D===9924||D===9925||D===9934||D===9940||D===9962||D===9970||D===9971||D===9973||D===9978||D===9981||D===9989||D===9994||D===9995||D===10024||D===10060||D===10062||D>=10067&&D<=10069||D===10071||D>=10133&&D<=10135||D===10160||D===10175||D===11035||D===11036||D===11088||D===11093||D>=11904&&D<=11929||D>=11931&&D<=12019||D>=12032&&D<=12245||D>=12272&&D<=12287||D>=12289&&D<=12350||D>=12353&&D<=12438||D>=12441&&D<=12543||D>=12549&&D<=12591||D>=12593&&D<=12686||D>=12688&&D<=12773||D>=12783&&D<=12830||D>=12832&&D<=12871||D>=12880&&D<=42124||D>=42128&&D<=42182||D>=43360&&D<=43388||D>=44032&&D<=55203||D>=63744&&D<=64255||D>=65040&&D<=65049||D>=65072&&D<=65106||D>=65108&&D<=65126||D>=65128&&D<=65131||D>=94176&&D<=94180||D>=94192&&D<=94198||D>=94208&&D<=101589||D>=101631&&D<=101662||D>=101760&&D<=101874||D>=110576&&D<=110579||D>=110581&&D<=110587||D===110589||D===110590||D>=110592&&D<=110882||D===110898||D>=110928&&D<=110930||D===110933||D>=110948&&D<=110951||D>=110960&&D<=111355||D>=119552&&D<=119638||D>=119648&&D<=119670||D===126980||D===127183||D===127374||D>=127377&&D<=127386||D>=127488&&D<=127490||D>=127504&&D<=127547||D>=127552&&D<=127560||D===127568||D===127569||D>=127584&&D<=127589||D>=127744&&D<=127776||D>=127789&&D<=127797||D>=127799&&D<=127868||D>=127870&&D<=127891||D>=127904&&D<=127946||D>=127951&&D<=127955||D>=127968&&D<=127984||D===127988||D>=127992&&D<=128062||D===128064||D>=128066&&D<=128252||D>=128255&&D<=128317||D>=128331&&D<=128334||D>=128336&&D<=128359||D===128378||D===128405||D===128406||D===128420||D>=128507&&D<=128591||D>=128640&&D<=128709||D===128716||D>=128720&&D<=128722||D>=128725&&D<=128728||D>=128732&&D<=128735||D===128747||D===128748||D>=128756&&D<=128764||D>=128992&&D<=129003||D===129008||D>=129292&&D<=129338||D>=129340&&D<=129349||D>=129351&&D<=129535||D>=129648&&D<=129660||D>=129664&&D<=129674||D>=129678&&D<=129734||D===129736||D>=129741&&D<=129756||D>=129759&&D<=129770||D>=129775&&D<=129784||D>=131072&&D<=196605||D>=196608&&D<=262141}var XB=()=>{};function wH(D){if(!Number.isSafeInteger(D))throw TypeError(`Expected a code point, got \`${typeof D}\`.`)}function GB(D,{ambiguousAsWide:F=!1}={}){if(wH(D),HB(D)||JB(D)||F&&qB(D))return 2;return 1}var WB=V(()=>{XB()});var zB=()=>{return/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g};function G6(D,F={}){if(typeof D!=="string"||D.length===0)return 0;let{ambiguousIsNarrow:B=!0,countAnsiEscapeCodes:$=!1}=F;if(!$)D=T3(D);if(D.length===0)return 0;let _=0,Q={ambiguousAsWide:!B};for(let{segment:Y}of OH.segment(D)){let q=Y.codePointAt(0);if(q<=31||q>=127&&q<=159)continue;if(q>=8203&&q<=8207||q===65279)continue;if(q>=768&&q<=879||q>=6832&&q<=6911||q>=7616&&q<=7679||q>=8400&&q<=8447||q>=65056&&q<=65071)continue;if(q>=55296&&q<=57343)continue;if(q>=65024&&q<=65039)continue;if(bH.test(Y))continue;if(zB().test(Y)){_+=2;continue}_+=GB(q,Q)}return _}var OH,bH;var MB=V(()=>{X6();WB();OH=new Intl.Segmenter,bH=/^\p{Default_Ignorable_Code_Point}$/u});function W6({stream:D=process.stdout}={}){return Boolean(D&&D.isTTY&&process.env.TERM!=="dumb"&&!("CI"in process.env))}import AB from"process";function z6(){let{env:D}=AB,{TERM:F,TERM_PROGRAM:B}=D;if(AB.platform!=="win32")return F!=="linux";return Boolean(D.WT_SESSION)||Boolean(D.TERMINUS_SUBLIME)||D.ConEmuTask==="{cmd::Cmder}"||B==="Terminus-Sublime"||B==="vscode"||F==="xterm-256color"||F==="alacritty"||F==="rxvt-unicode"||F==="rxvt-unicode-256color"||D.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var jB=()=>{};import t0 from"process";class KB{#Y=0;start(){if(this.#Y++,this.#Y===1)this.#B()}stop(){if(this.#Y<=0)throw Error("`stop` called more times than `start`");if(this.#Y--,this.#Y===0)this.#D()}#B(){if(t0.platform==="win32"||!t0.stdin.isTTY)return;t0.stdin.setRawMode(!0),t0.stdin.on("data",this.#_),t0.stdin.resume()}#D(){if(!t0.stdin.isTTY)return;t0.stdin.off("data",this.#_),t0.stdin.pause(),t0.stdin.setRawMode(!1)}#_(D){if(D[0]===RH)t0.emit("SIGINT")}}var RH=3,ZH,M6;var UB=V(()=>{ZH=new KB,M6=ZH});import R8 from"process";class VB{#Y=0;#B=!1;#D=0;#_=-1;#W=0;#F;#Q;#$;#z;#A;#J;#X;#G;#j;#q;#H;color;constructor(D){if(typeof D==="string")D={text:D};if(this.#F={color:"cyan",stream:R8.stderr,discardStdin:!0,hideCursor:!0,...D},this.color=this.#F.color,this.spinner=this.#F.spinner,this.#A=this.#F.interval,this.#$=this.#F.stream,this.#J=typeof this.#F.isEnabled==="boolean"?this.#F.isEnabled:W6({stream:this.#$}),this.#X=typeof this.#F.isSilent==="boolean"?this.#F.isSilent:!1,this.text=this.#F.text,this.prefixText=this.#F.prefixText,this.suffixText=this.#F.suffixText,this.indent=this.#F.indent,R8.env.NODE_ENV==="test")this._stream=this.#$,this._isEnabled=this.#J,Object.defineProperty(this,"_linesToClear",{get(){return this.#Y},set(F){this.#Y=F}}),Object.defineProperty(this,"_frameIndex",{get(){return this.#_}}),Object.defineProperty(this,"_lineCount",{get(){return this.#D}})}get indent(){return this.#G}set indent(D=0){if(!(D>=0&&Number.isInteger(D)))throw Error("The `indent` option must be an integer from 0 and up");this.#G=D,this.#M()}get interval(){return this.#A??this.#Q.interval??100}get spinner(){return this.#Q}set spinner(D){if(this.#_=-1,this.#A=void 0,typeof D==="object"){if(D.frames===void 0)throw Error("The given spinner must have a `frames` property");this.#Q=D}else if(!z6())this.#Q=v3.default.line;else if(D===void 0)this.#Q=v3.default.dots;else if(D!=="default"&&v3.default[D])this.#Q=v3.default[D];else throw Error(`There is no built-in spinner named '${D}'. See https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json for a full list.`)}get text(){return this.#j}set text(D=""){this.#j=D,this.#M()}get prefixText(){return this.#q}set prefixText(D=""){this.#q=D,this.#M()}get suffixText(){return this.#H}set suffixText(D=""){this.#H=D,this.#M()}get isSpinning(){return this.#z!==void 0}#K(D=this.#q,F=" "){if(typeof D==="string"&&D!=="")return D+F;if(typeof D==="function")return D()+F;return""}#U(D=this.#H,F=" "){if(typeof D==="string"&&D!=="")return F+D;if(typeof D==="function")return F+D();return""}#M(){let D=this.#$.columns??80,F=this.#K(this.#q,"-"),B=this.#U(this.#H,"-"),$=" ".repeat(this.#G)+F+"--"+this.#j+"--"+B;this.#D=0;for(let _ of T3($).split(`
93
- `))this.#D+=Math.max(1,Math.ceil(G6(_,{countAnsiEscapeCodes:!0})/D))}get isEnabled(){return this.#J&&!this.#X}set isEnabled(D){if(typeof D!=="boolean")throw TypeError("The `isEnabled` option must be a boolean");this.#J=D}get isSilent(){return this.#X}set isSilent(D){if(typeof D!=="boolean")throw TypeError("The `isSilent` option must be a boolean");this.#X=D}frame(){let D=Date.now();if(this.#_===-1||D-this.#W>=this.interval)this.#_=++this.#_%this.#Q.frames.length,this.#W=D;let{frames:F}=this.#Q,B=F[this.#_];if(this.color)B=f0[this.color](B);let $=typeof this.#q==="string"&&this.#q!==""?this.#q+" ":"",_=typeof this.text==="string"?" "+this.text:"",Q=typeof this.#H==="string"&&this.#H!==""?" "+this.#H:"";return $+B+_+Q}clear(){if(!this.#J||!this.#$.isTTY)return this;this.#$.cursorTo(0);for(let D=0;D<this.#Y;D++){if(D>0)this.#$.moveCursor(0,-1);this.#$.clearLine(1)}if(this.#G||this.lastIndent!==this.#G)this.#$.cursorTo(this.#G);return this.lastIndent=this.#G,this.#Y=0,this}render(){if(this.#X)return this;return this.clear(),this.#$.write(this.frame()),this.#Y=this.#D,this}start(D){if(D)this.text=D;if(this.#X)return this;if(!this.#J){if(this.text)this.#$.write(`- ${this.text}
94
- `);return this}if(this.isSpinning)return this;if(this.#F.hideCursor)Y6.hide(this.#$);if(this.#F.discardStdin&&R8.stdin.isTTY)this.#B=!0,M6.start();return this.render(),this.#z=setInterval(this.render.bind(this),this.interval),this}stop(){if(!this.#J)return this;if(clearInterval(this.#z),this.#z=void 0,this.#_=0,this.clear(),this.#F.hideCursor)Y6.show(this.#$);if(this.#F.discardStdin&&R8.stdin.isTTY&&this.#B)M6.stop(),this.#B=!1;return this}succeed(D){return this.stopAndPersist({symbol:I3.success,text:D})}fail(D){return this.stopAndPersist({symbol:I3.error,text:D})}warn(D){return this.stopAndPersist({symbol:I3.warning,text:D})}info(D){return this.stopAndPersist({symbol:I3.info,text:D})}stopAndPersist(D={}){if(this.#X)return this;let F=D.prefixText??this.#q,B=this.#K(F," "),$=D.symbol??" ",_=D.text??this.text,Y=typeof _==="string"?($?" ":"")+_:"",q=D.suffixText??this.#H,H=this.#U(q," "),J=B+$+Y+H+`
95
- `;return this.stop(),this.#$.write(J),this}}function A6(D){return new VB(D)}var v3,NH;var EB=V(()=>{D6();FB();YB();X6();MB();jB();UB();v3=f3(q6(),1),NH=f3(q6(),1)});function jD(D){let F=FF&&!D.quiet;return A6({text:D.text,isSilent:!F})}var m0=V(()=>{EB();Z3()});function LB(D){let[F=""]=D.split("-"),B=F.split("."),$=parseInt(B[0]??"",10),_=parseInt(B[1]??"",10),Q=parseInt(B[2]??"",10);if(Number.isNaN($)||Number.isNaN(_)||Number.isNaN(Q))return null;return{major:$,minor:_,patch:Q}}function SH(D,F){let B=LB(D),$=LB(F);if(!B||!$)return null;if(B.major!==$.major)return B.major-$.major;if(B.minor!==$.minor)return B.minor-$.minor;return B.patch-$.patch}function wB(D,F,B){if(!D)return{compatible:!0};let $=SH(F,D);if($===null)return{compatible:!0};if($>=0)return{compatible:!0};return{compatible:!1,required:D,installed:F,type:B}}function kH(D,F){let B=F.type==="opencode"?"OpenCode":"OCX CLI",$=F.type==="opencode"?"Update OpenCode to the latest version":"bun update -g ocx";return`
90
+ `,_)}while($!==-1);return Q+=D.slice(_),Q}function I3(D){return XH(D)}var g4,d4,D6,sF,k3,c4,aF,JH=(D,F={})=>{if(F.level&&!(Number.isInteger(F.level)&&F.level>=0&&F.level<=3))throw Error("The `level` option should be an integer from 0 to 3");let B=g4?g4.level:0;D.level=F.level===void 0?B:F.level},XH=(D)=>{let F=(...B)=>B.join(" ");return JH(F,D),Object.setPrototypeOf(F,I3.prototype),F},F6=(D,F,B,...$)=>{if(D==="rgb"){if(F==="ansi16m")return f0[B].ansi16m(...$);if(F==="ansi256")return f0[B].ansi256(f0.rgbToAnsi256(...$));return f0[B].ansi(f0.rgbToAnsi(...$))}if(D==="hex")return F6("rgb",F,B,...f0.hexToRgb(...$));return f0[B][D](...$)},WH,GH,B6=(D,F,B)=>{let $,_;if(B===void 0)$=D,_=F;else $=B.openAll+D,_=F+B.closeAll;return{open:D,close:F,openAll:$,closeAll:_,parent:B}},L8=(D,F,B)=>{let $=(..._)=>zH($,_.length===1?""+_[0]:_.join(" "));return Object.setPrototypeOf($,GH),$[D6]=D,$[sF]=F,$[k3]=B,$},zH=(D,F)=>{if(D.level<=0||!F)return D[k3]?"":F;let B=D[sF];if(B===void 0)return F;let{openAll:$,closeAll:_}=B;if(F.includes("\x1B"))while(B!==void 0)F=h4(F,B.close,B.open),B=B.parent;let Q=F.indexOf(`
91
+ `);if(Q!==-1)F=m4(F,_,$,Q);return $+F+_},MH,nj,h0;var $6=V(()=>{u4();f4();({stdout:g4,stderr:d4}=x4),D6=Symbol("GENERATOR"),sF=Symbol("STYLER"),k3=Symbol("IS_EMPTY"),c4=["ansi","ansi","ansi256","ansi16m"],aF=Object.create(null);Object.setPrototypeOf(I3.prototype,Function.prototype);for(let[D,F]of Object.entries(f0))aF[D]={get(){let B=L8(this,B6(F.open,F.close,this[sF]),this[k3]);return Object.defineProperty(this,D,{value:B}),B}};aF.visible={get(){let D=L8(this,this[sF],!0);return Object.defineProperty(this,"visible",{value:D}),D}};WH=["rgb","hex","ansi256"];for(let D of WH){aF[D]={get(){let{level:B}=this;return function(...$){let _=B6(F6(D,c4[B],"color",...$),f0.color.close,this[sF]);return L8(this,_,this[k3])}}};let F="bg"+D[0].toUpperCase()+D.slice(1);aF[F]={get(){let{level:B}=this;return function(...$){let _=B6(F6(D,c4[B],"bgColor",...$),f0.bgColor.close,this[sF]);return L8(this,_,this[k3])}}}}GH=Object.defineProperties(()=>{},{...aF,level:{enumerable:!0,get(){return this[D6].level},set(D){this[D6].level=D}}});Object.defineProperties(I3.prototype,aF);MH=I3(),nj=I3({level:d4?d4.level:0}),h0=MH});function _6(D,F,{ignoreNonConfigurable:B=!1}={}){let{name:$}=D;for(let _ of Reflect.ownKeys(F))AH(D,F,_,B);return KH(D,F),LH(D,F,$),D}var AH=(D,F,B,$)=>{if(B==="length"||B==="prototype")return;if(B==="arguments"||B==="caller")return;let _=Object.getOwnPropertyDescriptor(D,B),Q=Object.getOwnPropertyDescriptor(F,B);if(!jH(_,Q)&&$)return;Object.defineProperty(D,B,Q)},jH=function(D,F){return D===void 0||D.configurable||D.writable===F.writable&&D.enumerable===F.enumerable&&D.configurable===F.configurable&&(D.writable||D.value===F.value)},KH=(D,F)=>{let B=Object.getPrototypeOf(F);if(B===Object.getPrototypeOf(D))return;Object.setPrototypeOf(D,B)},UH=(D,F)=>`/* Wrapped ${D}*/
92
+ ${F}`,VH,EH,LH=(D,F,B)=>{let $=B===""?"":`with ${B.trim()}() `,_=UH.bind(null,$,F.toString());Object.defineProperty(_,"name",EH);let{writable:Q,enumerable:Y,configurable:q}=VH;Object.defineProperty(D,"toString",{value:_,writable:Q,enumerable:Y,configurable:q})};var l4=V(()=>{VH=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),EH=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name")});var w8,p4=(D,F={})=>{if(typeof D!=="function")throw TypeError("Expected a function");let B,$=0,_=D.displayName||D.name||"<anonymous>",Q=function(...Y){if(w8.set(Q,++$),$===1)B=D.apply(this,Y),D=void 0;else if(F.throw===!0)throw Error(`Function \`${_}\` can only be called once`);return B};return _6(Q,D),w8.set(Q,$),Q},i4;var n4=V(()=>{l4();w8=new WeakMap;p4.callCount=(D)=>{if(!w8.has(D))throw Error(`The given function \`${D.name}\` is not wrapped by the \`onetime\` package`);return w8.get(D)};i4=p4});var QF;var s4=V(()=>{QF=[];QF.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")QF.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")QF.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT")});class a4{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Y6[Q6])return Y6[Q6];wH(Y6,Q6,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(D,F){this.listeners[D].push(F)}removeListener(D,F){let B=this.listeners[D],$=B.indexOf(F);if($===-1)return;if($===0&&B.length===1)B.length=0;else B.splice($,1)}emit(D,F,B){if(this.emitted[D])return!1;this.emitted[D]=!0;let $=!1;for(let _ of this.listeners[D])$=_(F,B)===!0||$;if(D==="exit")$=this.emit("afterExit",F,B)||$;return $}}class H6{}var O8=(D)=>!!D&&typeof D==="object"&&typeof D.removeListener==="function"&&typeof D.emit==="function"&&typeof D.reallyExit==="function"&&typeof D.listeners==="function"&&typeof D.kill==="function"&&typeof D.pid==="number"&&typeof D.on==="function",Q6,Y6,wH,OH=(D)=>{return{onExit(F,B){return D.onExit(F,B)},load(){return D.load()},unload(){return D.unload()}}},o4,r4,q6,t4,DK,FK;var e4=V(()=>{s4();Q6=Symbol.for("signal-exit emitter"),Y6=globalThis,wH=Object.defineProperty.bind(Object);o4=class o4 extends H6{onExit(){return()=>{}}load(){}unload(){}};r4=class r4 extends H6{#Y=q6.platform==="win32"?"SIGINT":"SIGHUP";#B=new a4;#D;#_;#G;#F={};#Q=!1;constructor(D){super();this.#D=D,this.#F={};for(let F of QF)this.#F[F]=()=>{let B=this.#D.listeners(F),{count:$}=this.#B,_=D;if(typeof _.__signal_exit_emitter__==="object"&&typeof _.__signal_exit_emitter__.count==="number")$+=_.__signal_exit_emitter__.count;if(B.length===$){this.unload();let Q=this.#B.emit("exit",null,F),Y=F==="SIGHUP"?this.#Y:F;if(!Q)D.kill(D.pid,Y)}};this.#G=D.reallyExit,this.#_=D.emit}onExit(D,F){if(!O8(this.#D))return()=>{};if(this.#Q===!1)this.load();let B=F?.alwaysLast?"afterExit":"exit";return this.#B.on(B,D),()=>{if(this.#B.removeListener(B,D),this.#B.listeners.exit.length===0&&this.#B.listeners.afterExit.length===0)this.unload()}}load(){if(this.#Q)return;this.#Q=!0,this.#B.count+=1;for(let D of QF)try{let F=this.#F[D];if(F)this.#D.on(D,F)}catch(F){}this.#D.emit=(D,...F)=>{return this.#z(D,...F)},this.#D.reallyExit=(D)=>{return this.#$(D)}}unload(){if(!this.#Q)return;this.#Q=!1,QF.forEach((D)=>{let F=this.#F[D];if(!F)throw Error("Listener not defined for signal: "+D);try{this.#D.removeListener(D,F)}catch(B){}}),this.#D.emit=this.#_,this.#D.reallyExit=this.#G,this.#B.count-=1}#$(D){if(!O8(this.#D))return 0;return this.#D.exitCode=D||0,this.#B.emit("exit",this.#D.exitCode,null),this.#G.call(this.#D,this.#D.exitCode)}#z(D,...F){let B=this.#_;if(D==="exit"&&O8(this.#D)){if(typeof F[0]==="number")this.#D.exitCode=F[0];let $=B.call(this.#D,D,...F);return this.#B.emit("exit",this.#D.exitCode,null),$}else return B.call(this.#D,D,...F)}};q6=globalThis.process,{onExit:t4,load:DK,unload:FK}=OH(O8(q6)?new r4(q6):new o4)});import b8 from"process";var DB,bH,FB;var BB=V(()=>{n4();e4();DB=b8.stderr.isTTY?b8.stderr:b8.stdout.isTTY?b8.stdout:void 0,bH=DB?i4(()=>{t4(()=>{DB.write("\x1B[?25h")},{alwaysLast:!0})}):()=>{},FB=bH});import $B from"process";var Z8=!1,oF,J6;var _B=V(()=>{BB();oF={};oF.show=(D=$B.stderr)=>{if(!D.isTTY)return;Z8=!1,D.write("\x1B[?25h")};oF.hide=(D=$B.stderr)=>{if(!D.isTTY)return;FB(),Z8=!0,D.write("\x1B[?25l")};oF.toggle=(D,F)=>{if(D!==void 0)Z8=D;if(Z8)oF.show(F);else oF.hide(F)};J6=oF});var QB=c0((XK,ZH)=>{ZH.exports={dots:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"]},dots2:{interval:80,frames:["\u28FE","\u28FD","\u28FB","\u28BF","\u287F","\u28DF","\u28EF","\u28F7"]},dots3:{interval:80,frames:["\u280B","\u2819","\u281A","\u281E","\u2816","\u2826","\u2834","\u2832","\u2833","\u2813"]},dots4:{interval:80,frames:["\u2804","\u2806","\u2807","\u280B","\u2819","\u2838","\u2830","\u2820","\u2830","\u2838","\u2819","\u280B","\u2807","\u2806"]},dots5:{interval:80,frames:["\u280B","\u2819","\u281A","\u2812","\u2802","\u2802","\u2812","\u2832","\u2834","\u2826","\u2816","\u2812","\u2810","\u2810","\u2812","\u2813","\u280B"]},dots6:{interval:80,frames:["\u2801","\u2809","\u2819","\u281A","\u2812","\u2802","\u2802","\u2812","\u2832","\u2834","\u2824","\u2804","\u2804","\u2824","\u2834","\u2832","\u2812","\u2802","\u2802","\u2812","\u281A","\u2819","\u2809","\u2801"]},dots7:{interval:80,frames:["\u2808","\u2809","\u280B","\u2813","\u2812","\u2810","\u2810","\u2812","\u2816","\u2826","\u2824","\u2820","\u2820","\u2824","\u2826","\u2816","\u2812","\u2810","\u2810","\u2812","\u2813","\u280B","\u2809","\u2808"]},dots8:{interval:80,frames:["\u2801","\u2801","\u2809","\u2819","\u281A","\u2812","\u2802","\u2802","\u2812","\u2832","\u2834","\u2824","\u2804","\u2804","\u2824","\u2820","\u2820","\u2824","\u2826","\u2816","\u2812","\u2810","\u2810","\u2812","\u2813","\u280B","\u2809","\u2808","\u2808"]},dots9:{interval:80,frames:["\u28B9","\u28BA","\u28BC","\u28F8","\u28C7","\u2867","\u2857","\u284F"]},dots10:{interval:80,frames:["\u2884","\u2882","\u2881","\u2841","\u2848","\u2850","\u2860"]},dots11:{interval:100,frames:["\u2801","\u2802","\u2804","\u2840","\u2880","\u2820","\u2810","\u2808"]},dots12:{interval:80,frames:["\u2880\u2800","\u2840\u2800","\u2804\u2800","\u2882\u2800","\u2842\u2800","\u2805\u2800","\u2883\u2800","\u2843\u2800","\u280D\u2800","\u288B\u2800","\u284B\u2800","\u280D\u2801","\u288B\u2801","\u284B\u2801","\u280D\u2809","\u280B\u2809","\u280B\u2809","\u2809\u2819","\u2809\u2819","\u2809\u2829","\u2808\u2899","\u2808\u2859","\u2888\u2829","\u2840\u2899","\u2804\u2859","\u2882\u2829","\u2842\u2898","\u2805\u2858","\u2883\u2828","\u2843\u2890","\u280D\u2850","\u288B\u2820","\u284B\u2880","\u280D\u2841","\u288B\u2801","\u284B\u2801","\u280D\u2809","\u280B\u2809","\u280B\u2809","\u2809\u2819","\u2809\u2819","\u2809\u2829","\u2808\u2899","\u2808\u2859","\u2808\u2829","\u2800\u2899","\u2800\u2859","\u2800\u2829","\u2800\u2898","\u2800\u2858","\u2800\u2828","\u2800\u2890","\u2800\u2850","\u2800\u2820","\u2800\u2880","\u2800\u2840"]},dots13:{interval:80,frames:["\u28FC","\u28F9","\u28BB","\u283F","\u285F","\u28CF","\u28E7","\u28F6"]},dots8Bit:{interval:80,frames:["\u2800","\u2801","\u2802","\u2803","\u2804","\u2805","\u2806","\u2807","\u2840","\u2841","\u2842","\u2843","\u2844","\u2845","\u2846","\u2847","\u2808","\u2809","\u280A","\u280B","\u280C","\u280D","\u280E","\u280F","\u2848","\u2849","\u284A","\u284B","\u284C","\u284D","\u284E","\u284F","\u2810","\u2811","\u2812","\u2813","\u2814","\u2815","\u2816","\u2817","\u2850","\u2851","\u2852","\u2853","\u2854","\u2855","\u2856","\u2857","\u2818","\u2819","\u281A","\u281B","\u281C","\u281D","\u281E","\u281F","\u2858","\u2859","\u285A","\u285B","\u285C","\u285D","\u285E","\u285F","\u2820","\u2821","\u2822","\u2823","\u2824","\u2825","\u2826","\u2827","\u2860","\u2861","\u2862","\u2863","\u2864","\u2865","\u2866","\u2867","\u2828","\u2829","\u282A","\u282B","\u282C","\u282D","\u282E","\u282F","\u2868","\u2869","\u286A","\u286B","\u286C","\u286D","\u286E","\u286F","\u2830","\u2831","\u2832","\u2833","\u2834","\u2835","\u2836","\u2837","\u2870","\u2871","\u2872","\u2873","\u2874","\u2875","\u2876","\u2877","\u2838","\u2839","\u283A","\u283B","\u283C","\u283D","\u283E","\u283F","\u2878","\u2879","\u287A","\u287B","\u287C","\u287D","\u287E","\u287F","\u2880","\u2881","\u2882","\u2883","\u2884","\u2885","\u2886","\u2887","\u28C0","\u28C1","\u28C2","\u28C3","\u28C4","\u28C5","\u28C6","\u28C7","\u2888","\u2889","\u288A","\u288B","\u288C","\u288D","\u288E","\u288F","\u28C8","\u28C9","\u28CA","\u28CB","\u28CC","\u28CD","\u28CE","\u28CF","\u2890","\u2891","\u2892","\u2893","\u2894","\u2895","\u2896","\u2897","\u28D0","\u28D1","\u28D2","\u28D3","\u28D4","\u28D5","\u28D6","\u28D7","\u2898","\u2899","\u289A","\u289B","\u289C","\u289D","\u289E","\u289F","\u28D8","\u28D9","\u28DA","\u28DB","\u28DC","\u28DD","\u28DE","\u28DF","\u28A0","\u28A1","\u28A2","\u28A3","\u28A4","\u28A5","\u28A6","\u28A7","\u28E0","\u28E1","\u28E2","\u28E3","\u28E4","\u28E5","\u28E6","\u28E7","\u28A8","\u28A9","\u28AA","\u28AB","\u28AC","\u28AD","\u28AE","\u28AF","\u28E8","\u28E9","\u28EA","\u28EB","\u28EC","\u28ED","\u28EE","\u28EF","\u28B0","\u28B1","\u28B2","\u28B3","\u28B4","\u28B5","\u28B6","\u28B7","\u28F0","\u28F1","\u28F2","\u28F3","\u28F4","\u28F5","\u28F6","\u28F7","\u28B8","\u28B9","\u28BA","\u28BB","\u28BC","\u28BD","\u28BE","\u28BF","\u28F8","\u28F9","\u28FA","\u28FB","\u28FC","\u28FD","\u28FE","\u28FF"]},sand:{interval:80,frames:["\u2801","\u2802","\u2804","\u2840","\u2848","\u2850","\u2860","\u28C0","\u28C1","\u28C2","\u28C4","\u28CC","\u28D4","\u28E4","\u28E5","\u28E6","\u28EE","\u28F6","\u28F7","\u28FF","\u287F","\u283F","\u289F","\u281F","\u285B","\u281B","\u282B","\u288B","\u280B","\u280D","\u2849","\u2809","\u2811","\u2821","\u2881"]},line:{interval:130,frames:["-","\\","|","/"]},line2:{interval:100,frames:["\u2802","-","\u2013","\u2014","\u2013","-"]},pipe:{interval:100,frames:["\u2524","\u2518","\u2534","\u2514","\u251C","\u250C","\u252C","\u2510"]},simpleDots:{interval:400,frames:[". ",".. ","..."," "]},simpleDotsScrolling:{interval:200,frames:[". ",".. ","..."," .."," ."," "]},star:{interval:70,frames:["\u2736","\u2738","\u2739","\u273A","\u2739","\u2737"]},star2:{interval:80,frames:["+","x","*"]},flip:{interval:70,frames:["_","_","_","-","`","`","'","\xB4","-","_","_","_"]},hamburger:{interval:100,frames:["\u2631","\u2632","\u2634"]},growVertical:{interval:120,frames:["\u2581","\u2583","\u2584","\u2585","\u2586","\u2587","\u2586","\u2585","\u2584","\u2583"]},growHorizontal:{interval:120,frames:["\u258F","\u258E","\u258D","\u258C","\u258B","\u258A","\u2589","\u258A","\u258B","\u258C","\u258D","\u258E"]},balloon:{interval:140,frames:[" ",".","o","O","@","*"," "]},balloon2:{interval:120,frames:[".","o","O","\xB0","O","o","."]},noise:{interval:100,frames:["\u2593","\u2592","\u2591"]},bounce:{interval:120,frames:["\u2801","\u2802","\u2804","\u2802"]},boxBounce:{interval:120,frames:["\u2596","\u2598","\u259D","\u2597"]},boxBounce2:{interval:100,frames:["\u258C","\u2580","\u2590","\u2584"]},triangle:{interval:50,frames:["\u25E2","\u25E3","\u25E4","\u25E5"]},binary:{interval:80,frames:["010010","001100","100101","111010","111101","010111","101011","111000","110011","110101"]},arc:{interval:100,frames:["\u25DC","\u25E0","\u25DD","\u25DE","\u25E1","\u25DF"]},circle:{interval:120,frames:["\u25E1","\u2299","\u25E0"]},squareCorners:{interval:180,frames:["\u25F0","\u25F3","\u25F2","\u25F1"]},circleQuarters:{interval:120,frames:["\u25F4","\u25F7","\u25F6","\u25F5"]},circleHalves:{interval:50,frames:["\u25D0","\u25D3","\u25D1","\u25D2"]},squish:{interval:100,frames:["\u256B","\u256A"]},toggle:{interval:250,frames:["\u22B6","\u22B7"]},toggle2:{interval:80,frames:["\u25AB","\u25AA"]},toggle3:{interval:120,frames:["\u25A1","\u25A0"]},toggle4:{interval:100,frames:["\u25A0","\u25A1","\u25AA","\u25AB"]},toggle5:{interval:100,frames:["\u25AE","\u25AF"]},toggle6:{interval:300,frames:["\u101D","\u1040"]},toggle7:{interval:80,frames:["\u29BE","\u29BF"]},toggle8:{interval:100,frames:["\u25CD","\u25CC"]},toggle9:{interval:100,frames:["\u25C9","\u25CE"]},toggle10:{interval:100,frames:["\u3282","\u3280","\u3281"]},toggle11:{interval:50,frames:["\u29C7","\u29C6"]},toggle12:{interval:120,frames:["\u2617","\u2616"]},toggle13:{interval:80,frames:["=","*","-"]},arrow:{interval:100,frames:["\u2190","\u2196","\u2191","\u2197","\u2192","\u2198","\u2193","\u2199"]},arrow2:{interval:80,frames:["\u2B06\uFE0F ","\u2197\uFE0F ","\u27A1\uFE0F ","\u2198\uFE0F ","\u2B07\uFE0F ","\u2199\uFE0F ","\u2B05\uFE0F ","\u2196\uFE0F "]},arrow3:{interval:120,frames:["\u25B9\u25B9\u25B9\u25B9\u25B9","\u25B8\u25B9\u25B9\u25B9\u25B9","\u25B9\u25B8\u25B9\u25B9\u25B9","\u25B9\u25B9\u25B8\u25B9\u25B9","\u25B9\u25B9\u25B9\u25B8\u25B9","\u25B9\u25B9\u25B9\u25B9\u25B8"]},bouncingBar:{interval:80,frames:["[ ]","[= ]","[== ]","[=== ]","[====]","[ ===]","[ ==]","[ =]","[ ]","[ =]","[ ==]","[ ===]","[====]","[=== ]","[== ]","[= ]"]},bouncingBall:{interval:80,frames:["( \u25CF )","( \u25CF )","( \u25CF )","( \u25CF )","( \u25CF)","( \u25CF )","( \u25CF )","( \u25CF )","( \u25CF )","(\u25CF )"]},smiley:{interval:200,frames:["\uD83D\uDE04 ","\uD83D\uDE1D "]},monkey:{interval:300,frames:["\uD83D\uDE48 ","\uD83D\uDE48 ","\uD83D\uDE49 ","\uD83D\uDE4A "]},hearts:{interval:100,frames:["\uD83D\uDC9B ","\uD83D\uDC99 ","\uD83D\uDC9C ","\uD83D\uDC9A ","\u2764\uFE0F "]},clock:{interval:100,frames:["\uD83D\uDD5B ","\uD83D\uDD50 ","\uD83D\uDD51 ","\uD83D\uDD52 ","\uD83D\uDD53 ","\uD83D\uDD54 ","\uD83D\uDD55 ","\uD83D\uDD56 ","\uD83D\uDD57 ","\uD83D\uDD58 ","\uD83D\uDD59 ","\uD83D\uDD5A "]},earth:{interval:180,frames:["\uD83C\uDF0D ","\uD83C\uDF0E ","\uD83C\uDF0F "]},material:{interval:17,frames:["\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588","\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581"]},moon:{interval:80,frames:["\uD83C\uDF11 ","\uD83C\uDF12 ","\uD83C\uDF13 ","\uD83C\uDF14 ","\uD83C\uDF15 ","\uD83C\uDF16 ","\uD83C\uDF17 ","\uD83C\uDF18 "]},runner:{interval:140,frames:["\uD83D\uDEB6 ","\uD83C\uDFC3 "]},pong:{interval:80,frames:["\u2590\u2802 \u258C","\u2590\u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802\u258C","\u2590 \u2820\u258C","\u2590 \u2840\u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590\u2820 \u258C"]},shark:{interval:120,frames:["\u2590|\\____________\u258C","\u2590_|\\___________\u258C","\u2590__|\\__________\u258C","\u2590___|\\_________\u258C","\u2590____|\\________\u258C","\u2590_____|\\_______\u258C","\u2590______|\\______\u258C","\u2590_______|\\_____\u258C","\u2590________|\\____\u258C","\u2590_________|\\___\u258C","\u2590__________|\\__\u258C","\u2590___________|\\_\u258C","\u2590____________|\\\u258C","\u2590____________/|\u258C","\u2590___________/|_\u258C","\u2590__________/|__\u258C","\u2590_________/|___\u258C","\u2590________/|____\u258C","\u2590_______/|_____\u258C","\u2590______/|______\u258C","\u2590_____/|_______\u258C","\u2590____/|________\u258C","\u2590___/|_________\u258C","\u2590__/|__________\u258C","\u2590_/|___________\u258C","\u2590/|____________\u258C"]},dqpb:{interval:100,frames:["d","q","p","b"]},weather:{interval:100,frames:["\u2600\uFE0F ","\u2600\uFE0F ","\u2600\uFE0F ","\uD83C\uDF24 ","\u26C5\uFE0F ","\uD83C\uDF25 ","\u2601\uFE0F ","\uD83C\uDF27 ","\uD83C\uDF28 ","\uD83C\uDF27 ","\uD83C\uDF28 ","\uD83C\uDF27 ","\uD83C\uDF28 ","\u26C8 ","\uD83C\uDF28 ","\uD83C\uDF27 ","\uD83C\uDF28 ","\u2601\uFE0F ","\uD83C\uDF25 ","\u26C5\uFE0F ","\uD83C\uDF24 ","\u2600\uFE0F ","\u2600\uFE0F "]},christmas:{interval:400,frames:["\uD83C\uDF32","\uD83C\uDF84"]},grenade:{interval:80,frames:["\u060C ","\u2032 "," \xB4 "," \u203E "," \u2E0C"," \u2E0A"," |"," \u204E"," \u2055"," \u0DF4 "," \u2053"," "," "," "]},point:{interval:125,frames:["\u2219\u2219\u2219","\u25CF\u2219\u2219","\u2219\u25CF\u2219","\u2219\u2219\u25CF","\u2219\u2219\u2219"]},layer:{interval:150,frames:["-","=","\u2261"]},betaWave:{interval:80,frames:["\u03C1\u03B2\u03B2\u03B2\u03B2\u03B2\u03B2","\u03B2\u03C1\u03B2\u03B2\u03B2\u03B2\u03B2","\u03B2\u03B2\u03C1\u03B2\u03B2\u03B2\u03B2","\u03B2\u03B2\u03B2\u03C1\u03B2\u03B2\u03B2","\u03B2\u03B2\u03B2\u03B2\u03C1\u03B2\u03B2","\u03B2\u03B2\u03B2\u03B2\u03B2\u03C1\u03B2","\u03B2\u03B2\u03B2\u03B2\u03B2\u03B2\u03C1"]},fingerDance:{interval:160,frames:["\uD83E\uDD18 ","\uD83E\uDD1F ","\uD83D\uDD96 ","\u270B ","\uD83E\uDD1A ","\uD83D\uDC46 "]},fistBump:{interval:80,frames:["\uD83E\uDD1C\u3000\u3000\u3000\u3000\uD83E\uDD1B ","\uD83E\uDD1C\u3000\u3000\u3000\u3000\uD83E\uDD1B ","\uD83E\uDD1C\u3000\u3000\u3000\u3000\uD83E\uDD1B ","\u3000\uD83E\uDD1C\u3000\u3000\uD83E\uDD1B\u3000 ","\u3000\u3000\uD83E\uDD1C\uD83E\uDD1B\u3000\u3000 ","\u3000\uD83E\uDD1C\u2728\uD83E\uDD1B\u3000\u3000 ","\uD83E\uDD1C\u3000\u2728\u3000\uD83E\uDD1B\u3000 "]},soccerHeader:{interval:80,frames:[" \uD83E\uDDD1\u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F\uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 "]},mindblown:{interval:160,frames:["\uD83D\uDE10 ","\uD83D\uDE10 ","\uD83D\uDE2E ","\uD83D\uDE2E ","\uD83D\uDE26 ","\uD83D\uDE26 ","\uD83D\uDE27 ","\uD83D\uDE27 ","\uD83E\uDD2F ","\uD83D\uDCA5 ","\u2728 ","\u3000 ","\u3000 ","\u3000 "]},speaker:{interval:160,frames:["\uD83D\uDD08 ","\uD83D\uDD09 ","\uD83D\uDD0A ","\uD83D\uDD09 "]},orangePulse:{interval:100,frames:["\uD83D\uDD38 ","\uD83D\uDD36 ","\uD83D\uDFE0 ","\uD83D\uDFE0 ","\uD83D\uDD36 "]},bluePulse:{interval:100,frames:["\uD83D\uDD39 ","\uD83D\uDD37 ","\uD83D\uDD35 ","\uD83D\uDD35 ","\uD83D\uDD37 "]},orangeBluePulse:{interval:100,frames:["\uD83D\uDD38 ","\uD83D\uDD36 ","\uD83D\uDFE0 ","\uD83D\uDFE0 ","\uD83D\uDD36 ","\uD83D\uDD39 ","\uD83D\uDD37 ","\uD83D\uDD35 ","\uD83D\uDD35 ","\uD83D\uDD37 "]},timeTravel:{interval:100,frames:["\uD83D\uDD5B ","\uD83D\uDD5A ","\uD83D\uDD59 ","\uD83D\uDD58 ","\uD83D\uDD57 ","\uD83D\uDD56 ","\uD83D\uDD55 ","\uD83D\uDD54 ","\uD83D\uDD53 ","\uD83D\uDD52 ","\uD83D\uDD51 ","\uD83D\uDD50 "]},aesthetic:{interval:80,frames:["\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B1\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B0\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0","\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1\u25B1"]},dwarfFortress:{interval:80,frames:[" \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A \u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A \u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A \u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\xA3\xA3\xA3 "," \u263A \u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\xA3\xA3\xA3 "," \u263A \u2588\xA3\xA3\xA3 "," \u263A\u2588\xA3\xA3\xA3 "," \u263A\u2588\xA3\xA3\xA3 "," \u263A\u2593\xA3\xA3\xA3 "," \u263A\u2593\xA3\xA3\xA3 "," \u263A\u2592\xA3\xA3\xA3 "," \u263A\u2592\xA3\xA3\xA3 "," \u263A\u2591\xA3\xA3\xA3 "," \u263A\u2591\xA3\xA3\xA3 "," \u263A \xA3\xA3\xA3 "," \u263A\xA3\xA3\xA3 "," \u263A\xA3\xA3\xA3 "," \u263A\u2593\xA3\xA3 "," \u263A\u2593\xA3\xA3 "," \u263A\u2592\xA3\xA3 "," \u263A\u2592\xA3\xA3 "," \u263A\u2591\xA3\xA3 "," \u263A\u2591\xA3\xA3 "," \u263A \xA3\xA3 "," \u263A\xA3\xA3 "," \u263A\xA3\xA3 "," \u263A\u2593\xA3 "," \u263A\u2593\xA3 "," \u263A\u2592\xA3 "," \u263A\u2592\xA3 "," \u263A\u2591\xA3 "," \u263A\u2591\xA3 "," \u263A \xA3 "," \u263A\xA3 "," \u263A\xA3 "," \u263A\u2593 "," \u263A\u2593 "," \u263A\u2592 "," \u263A\u2592 "," \u263A\u2591 "," \u263A\u2591 "," \u263A "," \u263A &"," \u263A \u263C&"," \u263A \u263C &"," \u263A\u263C &"," \u263A\u263C & "," \u203C & "," \u263A & "," \u203C & "," \u263A & "," \u203C & "," \u263A & ","\u203C & "," & "," & "," & \u2591 "," & \u2592 "," & \u2593 "," & \xA3 "," & \u2591\xA3 "," & \u2592\xA3 "," & \u2593\xA3 "," & \xA3\xA3 "," & \u2591\xA3\xA3 "," & \u2592\xA3\xA3 ","& \u2593\xA3\xA3 ","& \xA3\xA3\xA3 "," \u2591\xA3\xA3\xA3 "," \u2592\xA3\xA3\xA3 "," \u2593\xA3\xA3\xA3 "," \u2588\xA3\xA3\xA3 "," \u2591\u2588\xA3\xA3\xA3 "," \u2592\u2588\xA3\xA3\xA3 "," \u2593\u2588\xA3\xA3\xA3 "," \u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "]}}});var X6=c0((WK,qB)=>{var R8=Object.assign({},QB()),YB=Object.keys(R8);Object.defineProperty(R8,"random",{get(){let D=Math.floor(Math.random()*YB.length),F=YB[D];return R8[F]}});qB.exports=R8});import m0 from"process";function W6(){if(m0.platform!=="win32")return m0.env.TERM!=="linux";return Boolean(m0.env.CI)||Boolean(m0.env.WT_SESSION)||Boolean(m0.env.TERMINUS_SUBLIME)||m0.env.ConEmuTask==="{cmd::Cmder}"||m0.env.TERM_PROGRAM==="Terminus-Sublime"||m0.env.TERM_PROGRAM==="vscode"||m0.env.TERM==="xterm-256color"||m0.env.TERM==="alacritty"||m0.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var HB=()=>{};var RH,NH,SH,T3;var JB=V(()=>{$6();HB();RH={info:h0.blue("\u2139"),success:h0.green("\u2714"),warning:h0.yellow("\u26A0"),error:h0.red("\u2716")},NH={info:h0.blue("i"),success:h0.green("\u221A"),warning:h0.yellow("\u203C"),error:h0.red("\xD7")},SH=W6()?RH:NH,T3=SH});function G6({onlyFirst:D=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",D?void 0:"g")}function v3(D){if(typeof D!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof D}\``);return D.replace(kH,"")}var kH;var z6=V(()=>{kH=G6()});function XB(D){return D===161||D===164||D===167||D===168||D===170||D===173||D===174||D>=176&&D<=180||D>=182&&D<=186||D>=188&&D<=191||D===198||D===208||D===215||D===216||D>=222&&D<=225||D===230||D>=232&&D<=234||D===236||D===237||D===240||D===242||D===243||D>=247&&D<=250||D===252||D===254||D===257||D===273||D===275||D===283||D===294||D===295||D===299||D>=305&&D<=307||D===312||D>=319&&D<=322||D===324||D>=328&&D<=331||D===333||D===338||D===339||D===358||D===359||D===363||D===462||D===464||D===466||D===468||D===470||D===472||D===474||D===476||D===593||D===609||D===708||D===711||D>=713&&D<=715||D===717||D===720||D>=728&&D<=731||D===733||D===735||D>=768&&D<=879||D>=913&&D<=929||D>=931&&D<=937||D>=945&&D<=961||D>=963&&D<=969||D===1025||D>=1040&&D<=1103||D===1105||D===8208||D>=8211&&D<=8214||D===8216||D===8217||D===8220||D===8221||D>=8224&&D<=8226||D>=8228&&D<=8231||D===8240||D===8242||D===8243||D===8245||D===8251||D===8254||D===8308||D===8319||D>=8321&&D<=8324||D===8364||D===8451||D===8453||D===8457||D===8467||D===8470||D===8481||D===8482||D===8486||D===8491||D===8531||D===8532||D>=8539&&D<=8542||D>=8544&&D<=8555||D>=8560&&D<=8569||D===8585||D>=8592&&D<=8601||D===8632||D===8633||D===8658||D===8660||D===8679||D===8704||D===8706||D===8707||D===8711||D===8712||D===8715||D===8719||D===8721||D===8725||D===8730||D>=8733&&D<=8736||D===8739||D===8741||D>=8743&&D<=8748||D===8750||D>=8756&&D<=8759||D===8764||D===8765||D===8776||D===8780||D===8786||D===8800||D===8801||D>=8804&&D<=8807||D===8810||D===8811||D===8814||D===8815||D===8834||D===8835||D===8838||D===8839||D===8853||D===8857||D===8869||D===8895||D===8978||D>=9312&&D<=9449||D>=9451&&D<=9547||D>=9552&&D<=9587||D>=9600&&D<=9615||D>=9618&&D<=9621||D===9632||D===9633||D>=9635&&D<=9641||D===9650||D===9651||D===9654||D===9655||D===9660||D===9661||D===9664||D===9665||D>=9670&&D<=9672||D===9675||D>=9678&&D<=9681||D>=9698&&D<=9701||D===9711||D===9733||D===9734||D===9737||D===9742||D===9743||D===9756||D===9758||D===9792||D===9794||D===9824||D===9825||D>=9827&&D<=9829||D>=9831&&D<=9834||D===9836||D===9837||D===9839||D===9886||D===9887||D===9919||D>=9926&&D<=9933||D>=9935&&D<=9939||D>=9941&&D<=9953||D===9955||D===9960||D===9961||D>=9963&&D<=9969||D===9972||D>=9974&&D<=9977||D===9979||D===9980||D===9982||D===9983||D===10045||D>=10102&&D<=10111||D>=11094&&D<=11097||D>=12872&&D<=12879||D>=57344&&D<=63743||D>=65024&&D<=65039||D===65533||D>=127232&&D<=127242||D>=127248&&D<=127277||D>=127280&&D<=127337||D>=127344&&D<=127373||D===127375||D===127376||D>=127387&&D<=127404||D>=917760&&D<=917999||D>=983040&&D<=1048573||D>=1048576&&D<=1114109}function WB(D){return D===12288||D>=65281&&D<=65376||D>=65504&&D<=65510}function GB(D){return D>=4352&&D<=4447||D===8986||D===8987||D===9001||D===9002||D>=9193&&D<=9196||D===9200||D===9203||D===9725||D===9726||D===9748||D===9749||D>=9776&&D<=9783||D>=9800&&D<=9811||D===9855||D>=9866&&D<=9871||D===9875||D===9889||D===9898||D===9899||D===9917||D===9918||D===9924||D===9925||D===9934||D===9940||D===9962||D===9970||D===9971||D===9973||D===9978||D===9981||D===9989||D===9994||D===9995||D===10024||D===10060||D===10062||D>=10067&&D<=10069||D===10071||D>=10133&&D<=10135||D===10160||D===10175||D===11035||D===11036||D===11088||D===11093||D>=11904&&D<=11929||D>=11931&&D<=12019||D>=12032&&D<=12245||D>=12272&&D<=12287||D>=12289&&D<=12350||D>=12353&&D<=12438||D>=12441&&D<=12543||D>=12549&&D<=12591||D>=12593&&D<=12686||D>=12688&&D<=12773||D>=12783&&D<=12830||D>=12832&&D<=12871||D>=12880&&D<=42124||D>=42128&&D<=42182||D>=43360&&D<=43388||D>=44032&&D<=55203||D>=63744&&D<=64255||D>=65040&&D<=65049||D>=65072&&D<=65106||D>=65108&&D<=65126||D>=65128&&D<=65131||D>=94176&&D<=94180||D>=94192&&D<=94198||D>=94208&&D<=101589||D>=101631&&D<=101662||D>=101760&&D<=101874||D>=110576&&D<=110579||D>=110581&&D<=110587||D===110589||D===110590||D>=110592&&D<=110882||D===110898||D>=110928&&D<=110930||D===110933||D>=110948&&D<=110951||D>=110960&&D<=111355||D>=119552&&D<=119638||D>=119648&&D<=119670||D===126980||D===127183||D===127374||D>=127377&&D<=127386||D>=127488&&D<=127490||D>=127504&&D<=127547||D>=127552&&D<=127560||D===127568||D===127569||D>=127584&&D<=127589||D>=127744&&D<=127776||D>=127789&&D<=127797||D>=127799&&D<=127868||D>=127870&&D<=127891||D>=127904&&D<=127946||D>=127951&&D<=127955||D>=127968&&D<=127984||D===127988||D>=127992&&D<=128062||D===128064||D>=128066&&D<=128252||D>=128255&&D<=128317||D>=128331&&D<=128334||D>=128336&&D<=128359||D===128378||D===128405||D===128406||D===128420||D>=128507&&D<=128591||D>=128640&&D<=128709||D===128716||D>=128720&&D<=128722||D>=128725&&D<=128728||D>=128732&&D<=128735||D===128747||D===128748||D>=128756&&D<=128764||D>=128992&&D<=129003||D===129008||D>=129292&&D<=129338||D>=129340&&D<=129349||D>=129351&&D<=129535||D>=129648&&D<=129660||D>=129664&&D<=129674||D>=129678&&D<=129734||D===129736||D>=129741&&D<=129756||D>=129759&&D<=129770||D>=129775&&D<=129784||D>=131072&&D<=196605||D>=196608&&D<=262141}var zB=()=>{};function IH(D){if(!Number.isSafeInteger(D))throw TypeError(`Expected a code point, got \`${typeof D}\`.`)}function MB(D,{ambiguousAsWide:F=!1}={}){if(IH(D),WB(D)||GB(D)||F&&XB(D))return 2;return 1}var AB=V(()=>{zB()});var jB=()=>{return/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g};function M6(D,F={}){if(typeof D!=="string"||D.length===0)return 0;let{ambiguousIsNarrow:B=!0,countAnsiEscapeCodes:$=!1}=F;if(!$)D=v3(D);if(D.length===0)return 0;let _=0,Q={ambiguousAsWide:!B};for(let{segment:Y}of TH.segment(D)){let q=Y.codePointAt(0);if(q<=31||q>=127&&q<=159)continue;if(q>=8203&&q<=8207||q===65279)continue;if(q>=768&&q<=879||q>=6832&&q<=6911||q>=7616&&q<=7679||q>=8400&&q<=8447||q>=65056&&q<=65071)continue;if(q>=55296&&q<=57343)continue;if(q>=65024&&q<=65039)continue;if(vH.test(Y))continue;if(jB().test(Y)){_+=2;continue}_+=MB(q,Q)}return _}var TH,vH;var KB=V(()=>{z6();AB();TH=new Intl.Segmenter,vH=/^\p{Default_Ignorable_Code_Point}$/u});function A6({stream:D=process.stdout}={}){return Boolean(D&&D.isTTY&&process.env.TERM!=="dumb"&&!("CI"in process.env))}import UB from"process";function j6(){let{env:D}=UB,{TERM:F,TERM_PROGRAM:B}=D;if(UB.platform!=="win32")return F!=="linux";return Boolean(D.WT_SESSION)||Boolean(D.TERMINUS_SUBLIME)||D.ConEmuTask==="{cmd::Cmder}"||B==="Terminus-Sublime"||B==="vscode"||F==="xterm-256color"||F==="alacritty"||F==="rxvt-unicode"||F==="rxvt-unicode-256color"||D.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var VB=()=>{};import e0 from"process";class EB{#Y=0;start(){if(this.#Y++,this.#Y===1)this.#B()}stop(){if(this.#Y<=0)throw Error("`stop` called more times than `start`");if(this.#Y--,this.#Y===0)this.#D()}#B(){if(e0.platform==="win32"||!e0.stdin.isTTY)return;e0.stdin.setRawMode(!0),e0.stdin.on("data",this.#_),e0.stdin.resume()}#D(){if(!e0.stdin.isTTY)return;e0.stdin.off("data",this.#_),e0.stdin.pause(),e0.stdin.setRawMode(!1)}#_(D){if(D[0]===CH)e0.emit("SIGINT")}}var CH=3,uH,K6;var LB=V(()=>{uH=new EB,K6=uH});import N8 from"process";class wB{#Y=0;#B=!1;#D=0;#_=-1;#G=0;#F;#Q;#$;#z;#A;#J;#X;#W;#j;#q;#H;color;constructor(D){if(typeof D==="string")D={text:D};if(this.#F={color:"cyan",stream:N8.stderr,discardStdin:!0,hideCursor:!0,...D},this.color=this.#F.color,this.spinner=this.#F.spinner,this.#A=this.#F.interval,this.#$=this.#F.stream,this.#J=typeof this.#F.isEnabled==="boolean"?this.#F.isEnabled:A6({stream:this.#$}),this.#X=typeof this.#F.isSilent==="boolean"?this.#F.isSilent:!1,this.text=this.#F.text,this.prefixText=this.#F.prefixText,this.suffixText=this.#F.suffixText,this.indent=this.#F.indent,N8.env.NODE_ENV==="test")this._stream=this.#$,this._isEnabled=this.#J,Object.defineProperty(this,"_linesToClear",{get(){return this.#Y},set(F){this.#Y=F}}),Object.defineProperty(this,"_frameIndex",{get(){return this.#_}}),Object.defineProperty(this,"_lineCount",{get(){return this.#D}})}get indent(){return this.#W}set indent(D=0){if(!(D>=0&&Number.isInteger(D)))throw Error("The `indent` option must be an integer from 0 and up");this.#W=D,this.#M()}get interval(){return this.#A??this.#Q.interval??100}get spinner(){return this.#Q}set spinner(D){if(this.#_=-1,this.#A=void 0,typeof D==="object"){if(D.frames===void 0)throw Error("The given spinner must have a `frames` property");this.#Q=D}else if(!j6())this.#Q=C3.default.line;else if(D===void 0)this.#Q=C3.default.dots;else if(D!=="default"&&C3.default[D])this.#Q=C3.default[D];else throw Error(`There is no built-in spinner named '${D}'. See https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json for a full list.`)}get text(){return this.#j}set text(D=""){this.#j=D,this.#M()}get prefixText(){return this.#q}set prefixText(D=""){this.#q=D,this.#M()}get suffixText(){return this.#H}set suffixText(D=""){this.#H=D,this.#M()}get isSpinning(){return this.#z!==void 0}#K(D=this.#q,F=" "){if(typeof D==="string"&&D!=="")return D+F;if(typeof D==="function")return D()+F;return""}#U(D=this.#H,F=" "){if(typeof D==="string"&&D!=="")return F+D;if(typeof D==="function")return F+D();return""}#M(){let D=this.#$.columns??80,F=this.#K(this.#q,"-"),B=this.#U(this.#H,"-"),$=" ".repeat(this.#W)+F+"--"+this.#j+"--"+B;this.#D=0;for(let _ of v3($).split(`
93
+ `))this.#D+=Math.max(1,Math.ceil(M6(_,{countAnsiEscapeCodes:!0})/D))}get isEnabled(){return this.#J&&!this.#X}set isEnabled(D){if(typeof D!=="boolean")throw TypeError("The `isEnabled` option must be a boolean");this.#J=D}get isSilent(){return this.#X}set isSilent(D){if(typeof D!=="boolean")throw TypeError("The `isSilent` option must be a boolean");this.#X=D}frame(){let D=Date.now();if(this.#_===-1||D-this.#G>=this.interval)this.#_=++this.#_%this.#Q.frames.length,this.#G=D;let{frames:F}=this.#Q,B=F[this.#_];if(this.color)B=h0[this.color](B);let $=typeof this.#q==="string"&&this.#q!==""?this.#q+" ":"",_=typeof this.text==="string"?" "+this.text:"",Q=typeof this.#H==="string"&&this.#H!==""?" "+this.#H:"";return $+B+_+Q}clear(){if(!this.#J||!this.#$.isTTY)return this;this.#$.cursorTo(0);for(let D=0;D<this.#Y;D++){if(D>0)this.#$.moveCursor(0,-1);this.#$.clearLine(1)}if(this.#W||this.lastIndent!==this.#W)this.#$.cursorTo(this.#W);return this.lastIndent=this.#W,this.#Y=0,this}render(){if(this.#X)return this;return this.clear(),this.#$.write(this.frame()),this.#Y=this.#D,this}start(D){if(D)this.text=D;if(this.#X)return this;if(!this.#J){if(this.text)this.#$.write(`- ${this.text}
94
+ `);return this}if(this.isSpinning)return this;if(this.#F.hideCursor)J6.hide(this.#$);if(this.#F.discardStdin&&N8.stdin.isTTY)this.#B=!0,K6.start();return this.render(),this.#z=setInterval(this.render.bind(this),this.interval),this}stop(){if(!this.#J)return this;if(clearInterval(this.#z),this.#z=void 0,this.#_=0,this.clear(),this.#F.hideCursor)J6.show(this.#$);if(this.#F.discardStdin&&N8.stdin.isTTY&&this.#B)K6.stop(),this.#B=!1;return this}succeed(D){return this.stopAndPersist({symbol:T3.success,text:D})}fail(D){return this.stopAndPersist({symbol:T3.error,text:D})}warn(D){return this.stopAndPersist({symbol:T3.warning,text:D})}info(D){return this.stopAndPersist({symbol:T3.info,text:D})}stopAndPersist(D={}){if(this.#X)return this;let F=D.prefixText??this.#q,B=this.#K(F," "),$=D.symbol??" ",_=D.text??this.text,Y=typeof _==="string"?($?" ":"")+_:"",q=D.suffixText??this.#H,H=this.#U(q," "),J=B+$+Y+H+`
95
+ `;return this.stop(),this.#$.write(J),this}}function U6(D){return new wB(D)}var C3,PH;var OB=V(()=>{$6();_B();JB();z6();KB();VB();LB();C3=h3(X6(),1),PH=h3(X6(),1)});function jD(D){let F=FF&&!D.quiet;return U6({text:D.text,isSilent:!F})}var g0=V(()=>{OB();N3()});function bB(D){let[F=""]=D.split("-"),B=F.split("."),$=parseInt(B[0]??"",10),_=parseInt(B[1]??"",10),Q=parseInt(B[2]??"",10);if(Number.isNaN($)||Number.isNaN(_)||Number.isNaN(Q))return null;return{major:$,minor:_,patch:Q}}function yH(D,F){let B=bB(D),$=bB(F);if(!B||!$)return null;if(B.major!==$.major)return B.major-$.major;if(B.minor!==$.minor)return B.minor-$.minor;return B.patch-$.patch}function ZB(D,F,B){if(!D)return{compatible:!0};let $=yH(F,D);if($===null)return{compatible:!0};if($>=0)return{compatible:!0};return{compatible:!1,required:D,installed:F,type:B}}function xH(D,F){let B=F.type==="opencode"?"OpenCode":"OCX CLI",$=F.type==="opencode"?"Update OpenCode to the latest version":"bun update -g ocx";return`
96
96
  ${P.yellow().bold("\u26A0 WARN")} ${P.yellow("Version compatibility notice")}
97
97
 
98
98
  Registry ${P.cyan(`"${D}"`)} requires ${B} ${P.green(F.required)}
@@ -102,52 +102,53 @@ ${P.yellow().bold("\u26A0 WARN")} ${P.yellow("Version compatibility notice")}
102
102
  consider updating: ${P.dim($)}
103
103
 
104
104
  To silence: ${P.dim("--skip-compat-check")} or set ${P.dim('"skipCompatCheck": true')} in ocx.jsonc
105
- `}function OB(D){let{registry:F,ocxVersion:B,opencodeVersion:$}=D,_=[],Q=wB(F.ocx,B,"ocx");if(!Q.compatible)_.push(Q);if($){let Y=wB(F.opencode,$,"opencode");if(!Y.compatible)_.push(Y)}return _}function bB(D,F){for(let B of F)G.log(kH(D,B))}var RB=V(()=>{W2();fD()});import{randomUUID as ZB}from"crypto";import{existsSync as M0}from"fs";import{lstat as IH,mkdir as U6,rename as j6,rm as oF,stat as TH,writeFile as vH}from"fs/promises";import{dirname as Z8,isAbsolute as CH,join as F0,relative as uH,resolve as NB}from"path";function PH(D,F){if(!D?.installed)return null;for(let[B,$]of Object.entries(D.installed))if($.files?.some((_)=>_.path===F))return B;return null}function SB(D){let F=D.split("::")[1];if(!F)return D;return F.split("@")[0]||D}function xH(D){if(!D?.trim())throw new U("Component name cannot be empty");let F=D.trim();if(b4(F)){let B=O4(F);return{type:"npm",name:B.name,version:B.version}}if(F.includes("/")){let{namespace:B,component:$}=u0(F);return{type:"registry",namespace:B,component:$}}return{type:"registry",namespace:"",component:F}}function IB(D){let F=D.command("add").description(`Add components or npm plugins to your project.
105
+ `}function RB(D){let{registry:F,ocxVersion:B,opencodeVersion:$}=D,_=[],Q=ZB(F.ocx,B,"ocx");if(!Q.compatible)_.push(Q);if($){let Y=ZB(F.opencode,$,"opencode");if(!Y.compatible)_.push(Y)}return _}function NB(D,F){for(let B of F)W.log(xH(D,B))}var SB=V(()=>{G2();hD()});import{randomUUID as kB}from"crypto";import{existsSync as O0}from"fs";import{lstat as fH,mkdir as L6,rename as V6,rm as rF,stat as CB,writeFile as hH}from"fs/promises";import{dirname as S8,isAbsolute as mH,join as F0,relative as gH,resolve as IB}from"path";function dH(D,F){if(!D?.installed)return null;for(let[B,$]of Object.entries(D.installed))if($.files?.some((_)=>_.path===F))return B;return null}function TB(D){let F=D.split("::")[1];if(!F)return D;return F.split("@")[0]||D}function cH(D){if(!D?.trim())throw new U("Component name cannot be empty");let F=D.trim();if(N4(F)){let B=R4(F);return{type:"npm",name:B.name,version:B.version}}if(F.includes("/")){let{namespace:B,component:$}=u0(F);return{type:"registry",namespace:B,component:$}}return{type:"registry",namespace:"",component:F}}function uB(D){let F=D.command("add").description(`Add components or npm plugins to your project.
106
106
 
107
107
  Registry components: ocx add alias/component
108
- npm plugins: ocx add npm:package-name[@version]`).argument("<components...>","Components to install (alias/component or npm:package[@version])").option("--dry-run","Show what would be installed without making changes").option("--skip-compat-check","Skip version compatibility checks").option("--trust","Skip npm plugin validation (for packages that don't follow conventions)").option("-p, --profile <name>","Use specific profile").option("--from <url>","Use ephemeral registry (does not persist)");oD(F),w0(F),r0(F),F.action(async(B,$)=>{try{let _=$.json?{...$,quiet:!0,verbose:!1}:$,Q;if(_.profile){let Y=await o0.create(_.cwd??process.cwd(),{profile:_.profile});Q={cwd:yD(_.profile),getRegistries:()=>Y.getRegistries(),getComponentPath:()=>Y.getComponentPath()}}else if(_.global)Q=await mF.requireInitialized();else Q=await V0.requireInitialized(_.cwd??process.cwd());await V6(B,_,Q)}catch(_){t(_,{json:$.json})}})}async function V6(D,F,B){let $=B.cwd,_=D.map(xH),Q=_.filter((z)=>z.type==="npm"),Y=_.filter((z)=>z.type==="registry"),q=Boolean(F.json&&Q.length>0&&Y.length>0),H=q?{...F,json:!1,quiet:!0,verbose:!1}:F,J,X;if(Q.length>0)J=await yH(Q,H,$,!q);if(Y.length>0){let z=Y.map((M)=>M.namespace?`${M.namespace}/${M.component}`:M.component);X=await fH(z,H,B,!q)}if(q)LD({success:!0,plugins:J?.plugins??[],installed:X?.installed??[],opencode:X?.opencode??!1,dryRun:Boolean(J?.dryRun||X?.dryRun)})}async function yH(D,F,B,$=!0){let _=F.quiet?null:jD({text:"Validating npm packages..."});_?.start();try{let Q=[];for(let A of D)if(await s1(A.name),!F.trust)try{let K=await M8(A.name,A.version),j=R4(K);Q.push(...j.warnings)}catch(K){if(K instanceof U)throw _?.fail("Plugin validation failed"),new U(`${K.message}
108
+ npm plugins: ocx add npm:package-name[@version]`).argument("<components...>","Components to install (alias/component or npm:package[@version])").option("--dry-run","Show what would be installed without making changes").option("--skip-compat-check","Skip version compatibility checks").option("--trust","Skip npm plugin validation (for packages that don't follow conventions)").option("-p, --profile <name>","Use specific profile").option("--from <url>","Use ephemeral registry (does not persist)");rD(F),L0(F),t0(F),F.action(async(B,$)=>{try{let _=$.json?{...$,quiet:!0,verbose:!1}:$,Q;if(_.profile){let Y=await r0.create(_.cwd??process.cwd(),{profile:_.profile});Q={cwd:fD(_.profile),getRegistries:()=>Y.getRegistries(),getComponentPath:()=>Y.getComponentPath()}}else if(_.global)Q=await mF.requireInitialized();else Q=await U0.requireInitialized(_.cwd??process.cwd());await w6(B,_,Q)}catch(_){t(_,{json:$.json})}})}async function w6(D,F,B){let $=B.cwd,_=D.map(cH),Q=_.filter((z)=>z.type==="npm"),Y=_.filter((z)=>z.type==="registry"),q=Boolean(F.json&&Q.length>0&&Y.length>0),H=q?{...F,json:!1,quiet:!0,verbose:!1}:F,J,X;if(Q.length>0)J=await lH(Q,H,$,!q);if(Y.length>0){let z=Y.map((M)=>M.namespace?`${M.namespace}/${M.component}`:M.component);X=await pH(z,H,B,!q)}if(q)LD({success:!0,plugins:J?.plugins??[],installed:X?.installed??[],opencode:X?.opencode??!1,dryRun:Boolean(J?.dryRun||X?.dryRun)})}async function lH(D,F,B,$=!0){let _=F.quiet?null:jD({text:"Validating npm packages..."});_?.start();try{let Q=[];for(let A of D)if(await r1(A.name),!F.trust)try{let K=await j8(A.name,A.version),j=S4(K);Q.push(...j.warnings)}catch(K){if(K instanceof U)throw _?.fail("Plugin validation failed"),new U(`${K.message}
109
109
  hint OpenCode plugins must be ESM modules with an entry point
110
- hint Use \`--trust\` to add anyway`);throw K}if(_?.succeed(`Validated ${D.length} npm package(s)`),Q.length>0&&!F.quiet){G.info("");for(let A of Q)G.warn(A)}let q=(await d1(B))?.config.plugin??[],H=new Map;for(let A of q){let K=Z4(A);H.set(K,A)}let J=[],X=[];for(let A of D)if(H.get(A.name))X.push(A.name);else J.push(pF(A.name,A.version));if(X.length>0)throw new gD(`Plugin(s) already exist in opencode.json: ${X.join(", ")}.
111
- Remove the existing entry manually or use 'ocx update' if it's an installed component.`);let z=[...H.values(),...J];if(F.dryRun){let K={dryRun:!0,command:"add",wouldPerform:D.map((j)=>({action:"add",target:pF(j.name,j.version),details:{type:"npm plugin"}})),validation:{passed:!0},summary:`Would add ${D.length} npm plugin(s)`};if($||!F.json)z0(K,{json:F.json,quiet:F.quiet});return{plugins:D.map((j)=>pF(j.name,j.version)),dryRun:!0}}if(await c1(B,{plugin:z}),!F.quiet){G.info(""),G.success(`Added ${D.length} npm plugin(s) to opencode.json`);for(let A of D)G.info(` \u2713 ${pF(A.name,A.version)}`)}let M=D.map((A)=>pF(A.name,A.version));if(F.json&&$)LD({success:!0,plugins:M});return{plugins:M,dryRun:!1}}catch(Q){throw _?.fail("Failed to add npm plugins"),Q}}async function fH(D,F,B,$=!0){let _=Boolean(F.quiet||F.json),Q=B.cwd,Y=!!(F.global||F.profile),q=B.getRegistries(),H=q;if(F.from){let K=F.from.trim();if(!K)throw new U("--from URL cannot be empty");try{new URL(K)}catch{throw new U(`Invalid --from URL: ${K}`)}let j=new Set;for(let Z of D){let{namespace:s}=u0(Z);j.add(s)}if(j.size>1){let Z=Array.from(j).join(", ");throw new U(`Mixed registry prefixes in --from call: ${Z}.
112
- When using --from, all components must use the same prefix.`)}let S=Array.from(j)[0];if(!S)throw new U("No valid component references provided");await T2(K),H={...q,[S]:{url:K}}}let J={version:1,root:Q,installed:{}},X=await J0(Q);if(X)J=X;let z=_?null:jD({text:"Resolving dependencies..."});z?.start();let M=null,A=null;try{let K=new Set;for(let k of D){let{namespace:i}=u0(k);K.add(i)}for(let k of K){let i=H[k];if(i)await T2(i.url)}let j=await e9(H,D);if(F.verbose){G.info("Install order:");for(let k of j.installOrder)G.info(` - ${k}`)}let S=new Map,Z=new Map;for(let k of j.components)if(!Z.has(k.registryName))Z.set(k.registryName,k.baseUrl);for(let[k,i]of Z){let v=await T2(i);S.set(k,v)}if(z?.succeed(`Resolved ${j.components.length} components from ${S.size} registries`),!F.skipCompatCheck&&!_)for(let[k,i]of S){let v=OB({registry:{opencode:i.opencode,ocx:i.ocx},ocxVersion:O7});bB(k,v)}if(F.dryRun){let k=j.components.map((v)=>({action:"add",target:`${v.registryName}/${v.name}`,details:{type:v.type}}));if(j.npmDependencies.length>0||j.npmDevDependencies.length>0){let v=F.global||F.profile?Q:F0(Q,".opencode"),_D=[...j.npmDependencies,...j.npmDevDependencies].map((r)=>{let bD=r.lastIndexOf("@"),YD=bD>0?r.slice(0,bD):r,B0=bD>0?r.slice(bD+1):"*";return{name:YD,from:null,to:B0}});k.push(X4(v,_D))}let i={dryRun:!0,command:"add",wouldPerform:k,validation:{passed:!0},summary:`Would add ${j.components.length} component(s)`};if($||!F.json)z0(i,{json:F.json,quiet:F.quiet});return{installed:j.installOrder,opencode:Boolean(j.opencode),dryRun:!0}}let N=_?null:jD({text:"Fetching components..."});N?.start();let x=[];for(let k of j.components){let i=[];for(let r of k.files){let bD=await e2(k.baseUrl,k.name,r.path);i.push({path:r.path,content:Buffer.from(bD)})}let v=await j8(i);for(let r of k.files){let bD=n2(r.target,Y,Q),YD=F0(Q,bD);try{H0(Q,bD)}catch(B0){if(B0 instanceof aD)throw new U(`Invalid path "${YD}": ${B0.message}`);throw B0}}let f=Object.entries(J.installed).filter(([r,bD])=>xD(bD.registryUrl)===xD(k.baseUrl)&&bD.registryName===k.registryName&&bD.name===k.name);if(f.length>0){let r=f[0];if(r){let[bD,YD]=r;if(YD.hash!==v)throw N?.fail("Integrity check failed"),new d2(bD,YD.hash,v)}}let _D=E3(k.baseUrl,k.registryName,k.name,`sha256:${v}`);x.push({component:k,files:i,computedHash:v,canonicalId:_D})}N?.succeed(`Fetched ${j.components.length} components`);let O=new Map;for(let{component:k,files:i}of x)for(let v of i){let f=k.files.find((bD)=>bD.path===v.path);if(!f)continue;let _D=n2(f.target,Y,Q),r=F0(Q,_D);$F(O,{absolutePath:r,relativePath:_D,content:v.content,source:`${k.registryName}/${k.name}:${f.path}`})}let b=[];for(let k of O.values()){if(!M0(k.absolutePath))continue;let i=await Bun.file(k.absolutePath).text(),v=k.content.toString("utf-8");if(!p1(i,v)){let f=PH(J,k.relativePath);b.push({path:k.relativePath,owningComponent:f})}}if(b.length>0){let k=b.filter((f)=>f.owningComponent!==null),i=b.filter((f)=>f.owningComponent===null);if(!_){if(G.error(""),G.error("File conflicts detected:"),k.length>0){G.error(""),G.error("Files from installed components (use 'ocx update' or 'ocx remove'):");for(let f of k)if(f.owningComponent){let _D=SB(f.owningComponent);G.error(` \u2717 ${f.path} (from ${_D})`)}}if(i.length>0){G.error(""),G.error("Files not managed by OCX (resolve manually):");for(let f of i)G.error(` \u2717 ${f.path}`)}G.error("")}let v=`${b.length} file(s) have conflicts.
113
- `;if(k.length>0){let f=new Set(k.filter((_D)=>_D.owningComponent!==null).map((_D)=>SB(_D.owningComponent)));v+=`For OCX-managed files, use 'ocx update ${Array.from(f).join(" ")}' or 'ocx remove ${Array.from(f).join(" ")}'.
114
- `}if(i.length>0)v+="For unmanaged files, resolve conflicts manually by renaming or removing them.";throw new gD(v.trim())}let L=_?null:jD({text:"Installing components..."});L?.start(),A=await cH({cwd:Q,isFlattened:Y,trackOpencodeConfig:Boolean(j.opencode&&Object.keys(j.opencode).length>0),trackNpmManifests:j.npmDependencies.length>0||j.npmDevDependencies.length>0,quiet:F.quiet});let e=lH({quiet:F.quiet});M=e;for(let{component:k,files:i,computedHash:v,canonicalId:f}of x){let _D=await pH(k,i,Q,Y,e,{verbose:F.verbose});if(F.verbose){for(let YD of _D.skipped)G.info(` \u25CB Skipped ${YD} (unchanged)`);for(let YD of _D.overwritten)G.info(` \u2713 Overwrote ${YD}`);for(let YD of _D.written)G.info(` \u2713 Wrote ${YD}`)}if(!S.get(k.registryName))throw new U(`Registry index not found for "${k.registryName}". This is an internal error - please report it at https://github.com/${w7}/issues`);let bD=[];for(let YD of i){let B0=k.files.find((GF)=>GF.path===YD.path);if(!B0)throw Error(`File ${YD.path} not found in component manifest`);let s8=n2(B0.target,Y,Q);bD.push({path:s8,hash:_F(YD.content)})}J.installed[f]={registryUrl:k.baseUrl,registryName:k.registryName,name:k.name,revision:`sha256:${v}`,hash:v,files:bD,installedAt:new Date().toISOString(),...k.opencode&&{opencode:k.opencode}}}if(L?.succeed(`Installed ${j.components.length} components`),j.opencode&&Object.keys(j.opencode).length>0){let k=await c1(Q,j.opencode);if(!F.quiet&&k.changed)if(k.created)G.info(`Created ${k.path}`);else G.info(`Updated ${k.path}`)}let p=j.npmDependencies.length>0,FD=j.npmDevDependencies.length>0,KD=F.global||F.profile?F0(Q,"package.json"):F0(Q,".opencode/package.json");if(p||FD){let k=_?null:jD({text:`Updating ${KD}...`});k?.start();try{let i=!!(F.global||F.profile),v=await rH(Q,j.npmDependencies,j.npmDevDependencies,{isFlattened:i}),f=j.npmDependencies.length+j.npmDevDependencies.length;if(k?.succeed(`Added ${f} dependencies to ${KD}`),v.changed){let _D=await G4(v.packageDir);if(_D.success&&_D.action!=="none"){if(!_)G.info(`Invalidated ${F0(v.packageDir,"node_modules")} to force reinstall`)}else if(!_D.success){let r=F0(v.packageDir,"node_modules");G.warn(`Could not invalidate ${r}: ${_D.error?.message??"unknown error"}. Run \`rm -rf "${r}"\` manually to force reinstall.`)}}}catch(i){throw k?.fail(`Failed to update ${KD}`),i}}if(await K0(Q,J),!M)throw Error("Internal error: missing add write transaction after install phase.");if(await M.commit(),M=null,A?.commit(),A=null,F.json&&$)LD({success:!0,installed:j.installOrder,opencode:!!j.opencode});else if(!F.quiet)G.info(""),G.success(`Done! Installed ${j.components.length} components.`);return{installed:j.installOrder,opencode:!!j.opencode,dryRun:!1}}catch(K){if(M)await M.rollback(),M=null;if(A)await A.rollback(),A=null;if(z&&!z.isSpinning);else z?.fail("Failed to add components");throw K}}function K6(D,F,B){let $=B instanceof Error?B.message:String(B);return`${D} "${F}" (${$})`}function hH(D,F){let B=uH(F,D);return B!==""&&!B.startsWith("..")&&!CH(B)}async function mH(D,F){let B=NB(D),$=NB(F);while(hH(B,$)){let _=!0;try{if(!(await IH(B)).isDirectory())break}catch(Y){if(Y.code==="ENOENT")_=!1;else throw Y}try{if(_)await oF(B,{recursive:!1})}catch(Y){let q=Y.code;if(q==="ENOENT");else if(q==="ENOTEMPTY"||q==="EEXIST"||q==="EBUSY")break;else if(q==="ENOTDIR")break;else throw Y}let Q=Z8(B);if(Q===B)break;B=Q}}async function gH(D){if(!M0(D))return{path:D,existed:!1,content:""};return{path:D,existed:!0,content:await Bun.file(D).text()}}async function dH(D,F){if(D.existed){await U6(Z8(D.path),{recursive:!0}),await Bun.write(D.path,D.content);return}if(M0(D.path))await oF(D.path,{force:!0,recursive:!0});await mH(Z8(D.path),F)}async function cH(D){let F=[],B=new Set,$=!1,_=async(q)=>{if(B.has(q))return;B.add(q),F.push(await gH(q))};if(D.trackOpencodeConfig){let q=z8(D.cwd).path;await _(q)}if(D.trackNpmManifests){let q=D.isFlattened?D.cwd:F0(D.cwd,".opencode");if(await _(F0(q,"package.json")),!D.isFlattened)await _(F0(q,".gitignore"))}return await _(N2(D.cwd).path),{rollback:async()=>{if($)return;$=!0;let q=[];for(let H of[...F].reverse())try{await dH(H,D.cwd)}catch(J){q.push(K6("Add rollback cleanup warning: failed to restore",H.path,J))}if(!D.quiet)for(let H of q)G.warn(H)},commit:()=>{$=!0}}}function lH(D){let F=[],B=new Set,$=!1;return{writeFileAtomically:async({targetPath:q,resolvedTarget:H,content:J})=>{let X=Z8(q);if(!M0(X))await U6(X,{recursive:!0});if(M0(q)){if((await TH(q)).isDirectory())throw new U(`Cannot install "${H}": target path is a directory.`)}let z=`${q}.ocx-add-tmp-${ZB()}`;await vH(z,J),B.add(z);let M=null;if(M0(q))M=`${q}.ocx-add-backup-${ZB()}`,await j6(q,M),F.push({targetPath:q,backupPath:M});if(await j6(z,q),B.delete(z),!M)F.push({targetPath:q,backupPath:null})},rollback:async()=>{if($)return;$=!0;let q=[];for(let H of B)try{await oF(H,{force:!0})}catch(J){q.push(K6("Add rollback cleanup warning: failed to remove temp file",H,J))}for(let H of[...F].reverse())try{if(H.backupPath){if(M0(H.targetPath))await oF(H.targetPath,{force:!0,recursive:!0});if(M0(H.backupPath))await j6(H.backupPath,H.targetPath)}else if(M0(H.targetPath))await oF(H.targetPath,{force:!0,recursive:!0})}catch(J){q.push(K6("Add rollback cleanup warning: failed to restore target",H.targetPath,J))}if(!D.quiet)for(let H of q)G.warn(H)},commit:async()=>{if($)return;$=!0;for(let q of F){if(!q.backupPath||!M0(q.backupPath))continue;try{await oF(q.backupPath,{force:!0})}catch(H){if(!D.quiet){let J=H instanceof Error?H.message:String(H);G.warn(`Post-add cleanup warning: failed to remove backup "${q.backupPath}" (${J})`)}}}}}}async function pH(D,F,B,$,_,Q){let Y={written:[],skipped:[],overwritten:[]};for(let q of F){let H=D.files.find((z)=>z.path===q.path);if(!H)continue;let J=n2(H.target,$,B),X=F0(B,J);if(M0(X)){let z=await Bun.file(X).text(),M=q.content.toString("utf-8");if(p1(z,M)){Y.skipped.push(J);continue}Y.overwritten.push(J)}else Y.written.push(J);await _.writeFileAtomically({targetPath:X,resolvedTarget:J,content:q.content})}return Y}function kB(D){if(!D?.trim())throw new U(`Invalid npm dependency: expected non-empty string, got "${D}"`);let F=D.trim(),B=F.lastIndexOf("@");if(B>0){let $=F.slice(0,B),_=F.slice(B+1);if(!_)throw new U(`Invalid npm dependency: missing version after @ in "${D}"`);return{name:$,version:_}}return{name:F,version:"*"}}function nH(D,F){let B={...D.dependencies};for(let $ of F)B[$.name]=$.version;return{...D,dependencies:B}}function sH(D,F){let B={...D.devDependencies};for(let $ of F)B[$.name]=$.version;return{...D,devDependencies:B}}async function aH(D){let F=F0(D,"package.json");if(!M0(F))return{...iH};try{let B=await Bun.file(F).text();return JSON.parse(B)}catch(B){let $=B instanceof Error?B.message:String(B);throw new c(`Invalid ${F}: ${$}`)}}async function oH(D){let F=F0(D,".gitignore"),B=new Set(["package.json","bun.lock"]),$=["node_modules"],_=[];if(M0(F))_=(await Bun.file(F).text()).split(`
110
+ hint Use \`--trust\` to add anyway`);throw K}if(_?.succeed(`Validated ${D.length} npm package(s)`),Q.length>0&&!F.quiet){W.info("");for(let A of Q)W.warn(A)}let q=(await p1(B))?.config.plugin??[],H=new Map;for(let A of q){let K=k4(A);H.set(K,A)}let J=[],X=[];for(let A of D)if(H.get(A.name))X.push(A.name);else J.push(iF(A.name,A.version));if(X.length>0)throw new dD(`Plugin(s) already exist in opencode.json: ${X.join(", ")}.
111
+ Remove the existing entry manually or use 'ocx update' if it's an installed component.`);let z=[...H.values(),...J];if(F.dryRun){let K={dryRun:!0,command:"add",wouldPerform:D.map((j)=>({action:"add",target:iF(j.name,j.version),details:{type:"npm plugin"}})),validation:{passed:!0},summary:`Would add ${D.length} npm plugin(s)`};if($||!F.json)z0(K,{json:F.json,quiet:F.quiet});return{plugins:D.map((j)=>iF(j.name,j.version)),dryRun:!0}}if(await i1(B,{plugin:z}),!F.quiet){W.info(""),W.success(`Added ${D.length} npm plugin(s) to opencode.json`);for(let A of D)W.info(` \u2713 ${iF(A.name,A.version)}`)}let M=D.map((A)=>iF(A.name,A.version));if(F.json&&$)LD({success:!0,plugins:M});return{plugins:M,dryRun:!1}}catch(Q){throw _?.fail("Failed to add npm plugins"),Q}}async function pH(D,F,B,$=!0){let _=Boolean(F.quiet||F.json),Q=B.cwd,Y=!!(F.global||F.profile),q=B.getRegistries(),H=q;if(F.from){let K=F.from.trim();if(!K)throw new U("--from URL cannot be empty");try{new URL(K)}catch{throw new U(`Invalid --from URL: ${K}`)}let j=new Set;for(let R of D){let{namespace:s}=u0(R);j.add(s)}if(j.size>1){let R=Array.from(j).join(", ");throw new U(`Mixed registry prefixes in --from call: ${R}.
112
+ When using --from, all components must use the same prefix.`)}let S=Array.from(j)[0];if(!S)throw new U("No valid component references provided");await T2(K),H={...q,[S]:{url:K}}}let J={version:1,root:Q,installed:{}},X=await X0(Q);if(X)J=X;let z=_?null:jD({text:"Resolving dependencies..."});z?.start();let M=null,A=null;try{let K=new Set;for(let k of D){let{namespace:i}=u0(k);K.add(i)}for(let k of K){let i=H[k];if(i)await T2(i.url)}let j=await $4(H,D);if(F.verbose){W.info("Install order:");for(let k of j.installOrder)W.info(` - ${k}`)}let S=new Map,R=new Map;for(let k of j.components)if(!R.has(k.registryName))R.set(k.registryName,k.baseUrl);for(let[k,i]of R){let v=await T2(i);S.set(k,v)}if(z?.succeed(`Resolved ${j.components.length} components from ${S.size} registries`),!F.skipCompatCheck&&!_)for(let[k,i]of S){let v=RB({registry:{opencode:i.opencode,ocx:i.ocx},ocxVersion:R7});NB(k,v)}if(F.dryRun){let k=j.components.map((v)=>({action:"add",target:`${v.registryName}/${v.name}`,details:{type:v.type}}));if(j.npmDependencies.length>0||j.npmDevDependencies.length>0){let v=F.global||F.profile?Q:F0(Q,".opencode"),_D=[...j.npmDependencies,...j.npmDevDependencies].map((r)=>{let bD=r.lastIndexOf("@"),YD=bD>0?r.slice(0,bD):r,B0=bD>0?r.slice(bD+1):"*";return{name:YD,from:null,to:B0}});k.push(z4(v,_D))}let i={dryRun:!0,command:"add",wouldPerform:k,validation:{passed:!0},summary:`Would add ${j.components.length} component(s)`};if($||!F.json)z0(i,{json:F.json,quiet:F.quiet});return{installed:j.installOrder,opencode:Boolean(j.opencode),dryRun:!0}}let N=_?null:jD({text:"Fetching components..."});N?.start();let y=[];for(let k of j.components){let i=[];for(let r of k.files){let bD=await e2(k.baseUrl,k.name,r.path);i.push({path:r.path,content:Buffer.from(bD)})}let v=await U8(i);for(let r of k.files){let bD=n2(r.target,Y,Q),YD=F0(Q,bD);try{J0(Q,bD)}catch(B0){if(B0 instanceof oD)throw new U(`Invalid path "${YD}": ${B0.message}`);throw B0}}let f=Object.entries(J.installed).filter(([r,bD])=>xD(bD.registryUrl)===xD(k.baseUrl)&&bD.registryName===k.registryName&&bD.name===k.name);if(f.length>0){let r=f[0];if(r){let[bD,YD]=r;if(YD.hash!==v)throw N?.fail("Integrity check failed"),new d2(bD,YD.hash,v)}}let _D=L3(k.baseUrl,k.registryName,k.name,`sha256:${v}`);y.push({component:k,files:i,computedHash:v,canonicalId:_D})}N?.succeed(`Fetched ${j.components.length} components`);let O=new Map;for(let{component:k,files:i}of y)for(let v of i){let f=k.files.find((bD)=>bD.path===v.path);if(!f)continue;let _D=n2(f.target,Y,Q),r=F0(Q,_D);$F(O,{absolutePath:r,relativePath:_D,content:v.content,source:`${k.registryName}/${k.name}:${f.path}`})}let b=[];for(let k of O.values()){if(!O0(k.absolutePath))continue;let i=await Bun.file(k.absolutePath).text(),v=k.content.toString("utf-8");if(!s1(i,v)){let f=dH(J,k.relativePath);b.push({path:k.relativePath,owningComponent:f})}}if(b.length>0){let k=b.filter((f)=>f.owningComponent!==null),i=b.filter((f)=>f.owningComponent===null);if(!_){if(W.error(""),W.error("File conflicts detected:"),k.length>0){W.error(""),W.error("Files from installed components (use 'ocx update' or 'ocx remove'):");for(let f of k)if(f.owningComponent){let _D=TB(f.owningComponent);W.error(` \u2717 ${f.path} (from ${_D})`)}}if(i.length>0){W.error(""),W.error("Files not managed by OCX (resolve manually):");for(let f of i)W.error(` \u2717 ${f.path}`)}W.error("")}let v=`${b.length} file(s) have conflicts.
113
+ `;if(k.length>0){let f=new Set(k.filter((_D)=>_D.owningComponent!==null).map((_D)=>TB(_D.owningComponent)));v+=`For OCX-managed files, use 'ocx update ${Array.from(f).join(" ")}' or 'ocx remove ${Array.from(f).join(" ")}'.
114
+ `}if(i.length>0)v+="For unmanaged files, resolve conflicts manually by renaming or removing them.";throw new dD(v.trim())}let L=_?null:jD({text:"Installing components..."});L?.start(),A=await oH({cwd:Q,isFlattened:Y,trackOpencodeConfig:Boolean(j.opencode&&Object.keys(j.opencode).length>0),trackNpmManifests:j.npmDependencies.length>0||j.npmDevDependencies.length>0,quiet:F.quiet});let e=rH({quiet:F.quiet});M=e;for(let{component:k,files:i,computedHash:v,canonicalId:f}of y){let _D=await tH(k,i,Q,Y,e,{verbose:F.verbose});if(F.verbose){for(let YD of _D.skipped)W.info(` \u25CB Skipped ${YD} (unchanged)`);for(let YD of _D.overwritten)W.info(` \u2713 Overwrote ${YD}`);for(let YD of _D.written)W.info(` \u2713 Wrote ${YD}`)}if(!S.get(k.registryName))throw new U(`Registry index not found for "${k.registryName}". This is an internal error - please report it at https://github.com/${Z7}/issues`);let bD=[];for(let YD of i){let B0=k.files.find((WF)=>WF.path===YD.path);if(!B0)throw Error(`File ${YD.path} not found in component manifest`);let o8=n2(B0.target,Y,Q);bD.push({path:o8,hash:_F(YD.content)})}J.installed[f]={registryUrl:k.baseUrl,registryName:k.registryName,name:k.name,revision:`sha256:${v}`,hash:v,files:bD,installedAt:new Date().toISOString(),...k.opencode&&{opencode:k.opencode}}}if(L?.succeed(`Installed ${j.components.length} components`),j.opencode&&Object.keys(j.opencode).length>0){let k=await i1(Q,j.opencode);if(!F.quiet&&k.changed)if(k.created)W.info(`Created ${k.path}`);else W.info(`Updated ${k.path}`)}let p=j.npmDependencies.length>0,FD=j.npmDevDependencies.length>0,KD=F.global||F.profile?F0(Q,"package.json"):F0(Q,".opencode/package.json");if(p||FD){let k=_?null:jD({text:`Updating ${KD}...`});k?.start();try{let i=!!(F.global||F.profile),v=await _J(Q,j.npmDependencies,j.npmDevDependencies,{isFlattened:i}),f=j.npmDependencies.length+j.npmDevDependencies.length;if(k?.succeed(`Added ${f} dependencies to ${KD}`),v.changed){let _D=await M4(v.packageDir);if(_D.success&&_D.action!=="none"){if(!_)W.info(`Invalidated ${F0(v.packageDir,"node_modules")} to force reinstall`)}else if(!_D.success){let r=F0(v.packageDir,"node_modules");W.warn(`Could not invalidate ${r}: ${_D.error?.message??"unknown error"}. Run \`rm -rf "${r}"\` manually to force reinstall.`)}}}catch(i){throw k?.fail(`Failed to update ${KD}`),i}}if(await j0(Q,J),!M)throw Error("Internal error: missing add write transaction after install phase.");if(await M.commit(),M=null,A?.commit(),A=null,F.json&&$)LD({success:!0,installed:j.installOrder,opencode:!!j.opencode});else if(!F.quiet)W.info(""),W.success(`Done! Installed ${j.components.length} components.`);return{installed:j.installOrder,opencode:!!j.opencode,dryRun:!1}}catch(K){if(M)await M.rollback(),M=null;if(A)await A.rollback(),A=null;if(z&&!z.isSpinning);else z?.fail("Failed to add components");throw K}}function E6(D,F,B){let $=B instanceof Error?B.message:String(B);return`${D} "${F}" (${$})`}function iH(D,F){let B=gH(F,D);return B!==""&&!B.startsWith("..")&&!mH(B)}async function nH(D,F){let B=IB(D),$=IB(F);while(iH(B,$)){let _=!0;try{if(!(await fH(B)).isDirectory())break}catch(Y){if(Y.code==="ENOENT")_=!1;else throw Y}try{if(_)await rF(B,{recursive:!1})}catch(Y){let q=Y.code;if(q==="ENOENT");else if(q==="ENOTEMPTY"||q==="EEXIST"||q==="EBUSY")break;else if(q==="ENOTDIR")break;else throw Y}let Q=S8(B);if(Q===B)break;B=Q}}async function sH(D){let F;try{F=await CB(D)}catch(B){let $=B.code;if($==="ENOENT"||$==="ENOTDIR")return{path:D,state:"missing",content:""};throw B}if(!F.isFile())return{path:D,state:"non-file",content:""};return{path:D,state:"file",content:await Bun.file(D).text()}}async function aH(D,F){if(D.state==="file"){await L6(S8(D.path),{recursive:!0}),await Bun.write(D.path,D.content);return}if(D.state==="non-file")return;if(O0(D.path))await rF(D.path,{force:!0,recursive:!0});await nH(S8(D.path),F)}async function oH(D){let F=[],B=new Set,$=!1,_=async(q)=>{if(B.has(q))return;B.add(q),F.push(await sH(q))};if(D.trackOpencodeConfig){let q=A8(D.cwd).path;await _(q)}if(D.trackNpmManifests){let q=D.isFlattened?D.cwd:F0(D.cwd,".opencode");if(await _(F0(q,"package.json")),!D.isFlattened)await _(F0(q,".gitignore"))}return await _(N2(D.cwd).path),{rollback:async()=>{if($)return;$=!0;let q=[];for(let H of[...F].reverse())try{await aH(H,D.cwd)}catch(J){q.push(E6("Add rollback cleanup warning: failed to restore",H.path,J))}if(!D.quiet)for(let H of q)W.warn(H)},commit:()=>{$=!0}}}function rH(D){let F=[],B=new Set,$=!1;return{writeFileAtomically:async({targetPath:q,resolvedTarget:H,content:J})=>{let X=S8(q);if(!O0(X))await L6(X,{recursive:!0});if(O0(q)){if((await CB(q)).isDirectory())throw new U(`Cannot install "${H}": target path is a directory.`)}let z=`${q}.ocx-add-tmp-${kB()}`;await hH(z,J),B.add(z);let M=null;if(O0(q))M=`${q}.ocx-add-backup-${kB()}`,await V6(q,M),F.push({targetPath:q,backupPath:M});if(await V6(z,q),B.delete(z),!M)F.push({targetPath:q,backupPath:null})},rollback:async()=>{if($)return;$=!0;let q=[];for(let H of B)try{await rF(H,{force:!0})}catch(J){q.push(E6("Add rollback cleanup warning: failed to remove temp file",H,J))}for(let H of[...F].reverse())try{if(H.backupPath){if(O0(H.targetPath))await rF(H.targetPath,{force:!0,recursive:!0});if(O0(H.backupPath))await V6(H.backupPath,H.targetPath)}else if(O0(H.targetPath))await rF(H.targetPath,{force:!0,recursive:!0})}catch(J){q.push(E6("Add rollback cleanup warning: failed to restore target",H.targetPath,J))}if(!D.quiet)for(let H of q)W.warn(H)},commit:async()=>{if($)return;$=!0;for(let q of F){if(!q.backupPath||!O0(q.backupPath))continue;try{await rF(q.backupPath,{force:!0})}catch(H){if(!D.quiet){let J=H instanceof Error?H.message:String(H);W.warn(`Post-add cleanup warning: failed to remove backup "${q.backupPath}" (${J})`)}}}}}}async function tH(D,F,B,$,_,Q){let Y={written:[],skipped:[],overwritten:[]};for(let q of F){let H=D.files.find((z)=>z.path===q.path);if(!H)continue;let J=n2(H.target,$,B),X=F0(B,J);if(O0(X)){let z=await Bun.file(X).text(),M=q.content.toString("utf-8");if(s1(z,M)){Y.skipped.push(J);continue}Y.overwritten.push(J)}else Y.written.push(J);await _.writeFileAtomically({targetPath:X,resolvedTarget:J,content:q.content})}return Y}function vB(D){if(!D?.trim())throw new U(`Invalid npm dependency: expected non-empty string, got "${D}"`);let F=D.trim(),B=F.lastIndexOf("@");if(B>0){let $=F.slice(0,B),_=F.slice(B+1);if(!_)throw new U(`Invalid npm dependency: missing version after @ in "${D}"`);return{name:$,version:_}}return{name:F,version:"*"}}function DJ(D,F){let B={...D.dependencies};for(let $ of F)B[$.name]=$.version;return{...D,dependencies:B}}function FJ(D,F){let B={...D.devDependencies};for(let $ of F)B[$.name]=$.version;return{...D,devDependencies:B}}async function BJ(D){let F=F0(D,"package.json");if(!O0(F))return{...eH};try{let B=await Bun.file(F).text();return JSON.parse(B)}catch(B){let $=B instanceof Error?B.message:String(B);throw new c(`Invalid ${F}: ${$}`)}}async function $J(D){let F=F0(D,".gitignore"),B=new Set(["package.json","bun.lock"]),$=["node_modules"],_=[];if(O0(F))_=(await Bun.file(F).text()).split(`
115
115
  `).map((Y)=>Y.trim()).filter(Boolean);_=_.filter((Q)=>!B.has(Q));for(let Q of $)if(!_.includes(Q))_.push(Q);await Bun.write(F,`${_.join(`
116
116
  `)}
117
- `)}async function rH(D,F,B,$={}){let _=$.isFlattened?D:F0(D,".opencode");if(F.length===0&&B.length===0)return{changed:!1,packageDir:_,delta:[]};await U6(_,{recursive:!0});let Q=F.map(kB),Y=B.map(kB),q=new Set(Q.map((K)=>K.name)),H=Y.filter((K)=>q.has(K.name));if(H.length>0)throw new gD(`Package(s) appear in both dependencies and devDependencies: ${H.map((K)=>K.name).join(", ")}.
118
- A package cannot be in both fields. Remove from one list manually before adding.`);let J=await aH(_),X={...J.dependencies,...J.devDependencies},z=J;z=nH(z,Q),z=sH(z,Y),await Bun.write(F0(_,"package.json"),`${JSON.stringify(z,null,2)}
119
- `);let M={...z.dependencies,...z.devDependencies},A=J4(X,M);if(!$.isFlattened)await oH(_);return{changed:A.changed,packageDir:_,delta:A.entries}}var iH;var E6=V(()=>{gF();O3();s3();G0();DF();D4();tD();P0();l1();W4();BF();$D();PD();fD();a1();c2();k2();A8();iF();x0();m0();RB();iH={name:"opencode-plugins",private:!0,type:"module"}});import{join as tH,posix as eH}from"path";function DJ(D){if(D.length===0)return"Unknown parse error";let F=D[0];if(!F)return"Unknown parse error";return`${K2(F.error)} at offset ${F.offset}`}async function TB(D){let F=Bun.file(`${D}/registry.jsonc`),B=Bun.file(`${D}/registry.json`),$=await F.exists(),_=await B.exists();if(!$&&!_)return{success:!1,error:"No registry.jsonc or registry.json found in source directory",errorKind:"not_found"};let Q=$?F:B,Y=$?"registry.jsonc":"registry.json",q=await Q.text(),H=[],J=ND(q,H,{allowTrailingComma:!0});if(H.length>0){let X=DJ(H);return{success:!1,error:`Invalid JSONC in ${Y}: ${X}`,errorKind:"parse_error"}}return{success:!0,data:J}}function vB(D,F){let B=PF(D);if(B)return{valid:!1,errors:[`Schema compatibility issue: ${B.issue} - ${B.remediation}`]};return FJ(D,F)}function FJ(D,F){let B=i2.safeParse(D);if(!B.success)return{valid:!1,errors:B.error.errors.map((_)=>`${_.path.join(".")}: ${_.message}`)};return{valid:!0,errors:[],data:B.data}}async function BJ(D,F){let B=[];for(let $ of D.components)for(let _ of $.files){let Q=b2(_,$.type),Y=tH(F,"files",Q.path);if(!await Bun.file(Y).exists())B.push(`${$.name}: Source file not found at ${Q.path}`)}return{valid:B.length===0,errors:B}}function $J(D){let F=[],B=new Map(D.components.map((Q)=>[Q.name,Q]));function $(Q,Y,q,H){if(Y.has(Q))return[...H,Q].join(" -> ");if(q.has(Q))return null;let J=B.get(Q);if(!J)return null;Y.add(Q),H.push(Q);for(let X of J.dependencies){if(X.includes("/"))continue;let z=$(X,Y,q,H);if(z)return z}return Y.delete(Q),q.add(Q),H.pop(),null}let _=new Set;for(let Q of D.components){if(_.has(Q.name))continue;let Y=$(Q.name,new Set,_,[]);if(Y){F.push(`Circular dependency detected: ${Y}`);break}}return{valid:F.length===0,errors:F}}function _J(D){let F=[],B=new Map,$=(_)=>{let Y=_.normalize("NFC").replace(/\\/g,"/");return eH.normalize(Y).replace(/^\.\//,"")};for(let _ of D.components)for(let Q of _.files){let Y=b2(Q,_.type),q=$(Y.target),H=B.get(q);if(H)F.push(`Duplicate target "${q}" in components "${H.componentName}" and "${_.name}"`);else B.set(q,{componentName:_.name})}return{valid:F.length===0,errors:F}}async function*CB(D,F,B={}){let $=await BJ(D,F);for(let Q of $.errors)yield Q;let _=$J(D);for(let Q of _.errors)yield Q;if(!B.skipDuplicateTargets){let Q=_J(D);for(let Y of Q.errors)yield Y}}var uB=V(()=>{b0();P0()});async function N8(D,F={}){let B=await TB(D);if(!B.success)return{success:!1,errors:[B.error||"Failed to load registry"],failureType:"load",loadErrorKind:B.errorKind};let $=vB(B.data,D);if(!$.valid)return{success:!1,errors:$.errors,failureType:"schema"};let _=$.data;if(!_)throw Error("Registry validation succeeded but returned no parsed data");let Q=[];for await(let Y of CB(_,D,F))Q.push(Y);if(Q.length>0)return{success:!1,errors:Q,failureType:"rules"};return{success:!0,errors:[],registry:_}}var L6=V(()=>{uB()});function w6(D){return{file:D.filter((F)=>F.includes("Source file not found")),circular:D.filter((F)=>F.includes("Circular dependency")),duplicate:D.filter((F)=>F.includes("Duplicate target"))}}function C3(D,F={}){let B=w6(D),$=F.schemaErrors??0,_=D.length,Q=Math.max(0,_-$-B.file.length-B.circular.length-B.duplicate.length);return{valid:_===0,totalErrors:_,schemaErrors:$,sourceFileErrors:B.file.length,circularDependencyErrors:B.circular.length,duplicateTargetErrors:B.duplicate.length,otherErrors:Q}}import{relative as QJ,resolve as PB}from"path";function YJ(D,F){if(F==="not_found")return new MD(D);if(F==="parse_error")return new zD(D,"CONFIG_ERROR",XD.CONFIG);return new zD(D,"CONFIG_ERROR",XD.CONFIG)}function qJ(D,F){let B=C3(D,{schemaErrors:F==="schema"?D.length:0}),$={valid:!1,errors:D,summary:{valid:!1,totalErrors:B.totalErrors,schemaErrors:B.schemaErrors,sourceFileErrors:B.sourceFileErrors,circularDependencyErrors:B.circularDependencyErrors,duplicateTargetErrors:B.duplicateTargetErrors,otherErrors:B.otherErrors}};return new g2($)}function HJ(D,F){if(F==="schema"){G.error("\u2717 Registry schema");for(let $ of D)console.log(P.red(` ${$}`));return}let B=w6(D);if(B.file.length>0){G.error("\u2717 Source files");for(let $ of B.file)console.log(P.red(` ${$}`))}if(B.circular.length>0){G.error("\u2717 Circular dependencies");for(let $ of B.circular)console.log(P.red(` ${$}`))}if(B.duplicate.length>0){G.error("\u2717 Duplicate targets");for(let $ of B.duplicate)console.log(P.red(` ${$}`))}}function xB(D){D.command("build").description("Build a registry from source (for registry authors)").argument("[path]","Registry source directory",".").option("--out <dir>","Output directory","./dist").option("--cwd <path>","Working directory",process.cwd()).option("--json","Output as JSON",!1).option("-q, --quiet","Suppress output",!1).option("--dry-run","Validate and show what would be built").option("--show-validation","Display validation results before building",!1).action(async(F,B)=>{try{let $=PB(B.cwd,F),_=PB(B.cwd,B.out);if(B.showValidation){let H=!B.json&&!B.quiet;if(H)G.info("Running validation checks...");let J=await N8($,{skipDuplicateTargets:!1});if(!J.success){let[X="Registry validation failed"]=J.errors;if(J.failureType==="load")throw YJ(X,J.loadErrorKind);let z=J.failureType==="schema"?"schema":"rules",M=qJ(J.errors,z);if(B.json)throw M;if(!B.quiet)HJ(J.errors,z);process.exit(M.exitCode)}if(H)G.success("\u2713 Schema compatibility and structure"),G.success("\u2713 Source files"),G.success("\u2713 No circular dependencies"),G.success("\u2713 No duplicate targets"),console.log("")}let Q=jD({text:"Building registry...",quiet:B.quiet||B.json});if(!B.json)Q.start();let Y=await U3({source:$,out:_,dryRun:B.dryRun});if("dryRun"in Y&&Y.dryRun){if(!B.json)Q.stop();z0(Y,{json:B.json,quiet:B.quiet});return}let q=Y;if(!B.json){let H=`Built ${q.componentsCount} components to ${QJ(B.cwd,_)}`;if(Q.succeed(H),!process.stdout.isTTY)G.success(`Built ${q.componentsCount} components`)}if(B.json)LD({success:!0,data:{components:q.componentsCount,output:q.outputPath}})}catch($){if($ instanceof n0){if(B.json)t($,{json:!0});if(!B.quiet){G.error($.message);for(let _ of $.errors)console.log(P.red(` ${_}`))}process.exit(1)}t($,{json:B.json})}})}var yB=V(()=>{W2();o3();L6();BF();$D();PD();fD();m0()});import{existsSync as fB}from"fs";import{mkdir as JJ}from"fs/promises";import{join as O6}from"path";function hB(D){D.command("edit").description("Open configuration file in editor").option("-g, --global","Edit global ocx.jsonc").option("-p, --profile <name>","Edit specific profile's config").action(async(F)=>{try{await XJ(F)}catch(B){t(B)}})}async function XJ(D){if(D.global&&D.profile)throw new U("Cannot use both --global and --profile flags");let F;if(D.profile){let Q=s0.safeParse(D.profile);if(!Q.success)throw new U(`Invalid profile name "${D.profile}": ${Q.error.errors[0]?.message??"Invalid name"}`);if(await uD.requireInitialized(),!await uD.create().exists(D.profile))throw new CD(D.profile);F=Q0(D.profile)}else if(D.global){if(F=I2(),!fB(F))throw new c(`Global config not found at ${F}.
120
- Run 'ocx init --global' first.`)}else{let Q=o2(process.cwd());if(Q)F=O6(Q,J2);else{let Y=O6(process.cwd(),s2);if(await JJ(Y,{recursive:!0}),F=O6(Y,J2),!fB(F)){let q={$schema:"https://ocx.kdco.dev/schemas/ocx.json",registries:{}};await Bun.write(F,JSON.stringify(q,null,2)),G.info(`Created ${F}`)}}}let B=process.env.EDITOR||process.env.VISUAL||"vi",_=await Bun.spawn([B,F],{stdin:"inherit",stdout:"inherit",stderr:"inherit"}).exited;if(_!==0)throw Error(`Editor exited with code ${_}`)}var mB=V(()=>{a0();G0();Q8();$D();PD();fD()});function gB(D){D.command("show").description("Display resolved configuration for current directory").addOption(L0.json()).option("--origin","Show where each setting came from").option("-p, --profile <name>","Use specific profile").action(async(F)=>{try{await GJ(F)}catch(B){t(B,{json:F.json})}})}async function GJ(D){let F=await o0.create(process.cwd(),{profile:D.profile});if(D.origin){let $=F.resolveWithOrigin();if(D.json){let Q={};for(let[Y,q]of $.origins)Q[Y]=q;console.log(JSON.stringify({...$,origins:Q},null,2));return}if(console.log(P.bold("Resolved Configuration")),console.log(),$.profileName){let Q=$.origins.get("profileName");if(console.log(`${P.cyan("Profile:")} ${$.profileName}`),Q)console.log(` ${P.dim(`\u2190 ${Q.source}`)}`)}console.log(),console.log(P.cyan("Component Path:"),$.componentPath);let _=$.origins.get("componentPath");if(_)console.log(` ${P.dim(`\u2190 ${_.source} (${_.path})`)}`);console.log(),console.log(P.cyan("Registries:"));for(let[Q,Y]of Object.entries($.registries)){console.log(` ${P.green(Q)}: ${Y.url}`);let q=$.origins.get(`registries.${Q}`);if(q)console.log(` ${P.dim(`\u2190 ${q.source} (${q.path})`)}`)}if($.instructions.length>0){console.log(),console.log(P.cyan("Instructions:"));for(let Q of $.instructions)console.log(` ${Q}`)}if(Object.keys($.opencode).length>0){console.log(),console.log(P.cyan("OpenCode Config:"));for(let Q of Object.keys($.opencode)){let Y=$.origins.get(`opencode.${Q}`);if(console.log(` ${Q}:`,JSON.stringify($.opencode[Q])),Y)console.log(` ${P.dim(`\u2190 ${Y.source} (${Y.path})`)}`)}}return}let B=F.resolve();if(D.json){console.log(JSON.stringify(B,null,2));return}if(console.log(P.bold("Resolved Configuration")),console.log(),B.profileName)console.log(`${P.cyan("Profile:")} ${B.profileName}`);if(console.log(`${P.cyan("Component Path:")} ${B.componentPath}`),console.log(),console.log(P.cyan("Registries:")),Object.keys(B.registries).length===0)console.log(" (none)");else for(let[$,_]of Object.entries(B.registries))console.log(` ${P.green($)}: ${_.url}`);if(B.instructions.length>0){console.log(),console.log(P.cyan("Instructions:"));for(let $ of B.instructions)console.log(` ${$}`)}}var dB=V(()=>{W2();O3();PD();x0()});function cB(D){let F=D.command("config").description("View and edit configuration");gB(F),hB(F)}var lB=V(()=>{mB();dB()});import{existsSync as YF}from"fs";import{cp as WJ,mkdir as rF,readdir as pB,readFile as zJ,rm as MJ,writeFile as b6}from"fs/promises";import{dirname as iB,join as S8}from"path";function nB(D){let F=D.command("init").description("Initialize OCX configuration in your project");oD(F),w0(F),r0(F),F.option("--registry <path>","Scaffold a new OCX registry project at path").option("--namespace <name>","Registry namespace (e.g., my-org)").option("--author <name>","Author name for the registry").option("--canary","Use canary (main branch) instead of latest release").option("--local <path>","Use local template directory instead of fetching").action(async(B)=>{try{if(B.registry)await VJ(B.registry,B);else if(B.global)await UJ(B);else await KJ(B)}catch($){t($,{json:B.json})}})}async function KJ(D){let F=D.cwd??process.cwd(),{path:B,exists:$}=S2(F);if($)throw new gD(`ocx.jsonc already exists at ${B}
117
+ `)}async function _J(D,F,B,$={}){let _=$.isFlattened?D:F0(D,".opencode");if(F.length===0&&B.length===0)return{changed:!1,packageDir:_,delta:[]};await L6(_,{recursive:!0});let Q=F.map(vB),Y=B.map(vB),q=new Set(Q.map((K)=>K.name)),H=Y.filter((K)=>q.has(K.name));if(H.length>0)throw new dD(`Package(s) appear in both dependencies and devDependencies: ${H.map((K)=>K.name).join(", ")}.
118
+ A package cannot be in both fields. Remove from one list manually before adding.`);let J=await BJ(_),X={...J.dependencies,...J.devDependencies},z=J;z=DJ(z,Q),z=FJ(z,Y),await Bun.write(F0(_,"package.json"),`${JSON.stringify(z,null,2)}
119
+ `);let M={...z.dependencies,...z.devDependencies},A=G4(X,M);if(!$.isFlattened)await $J(_);return{changed:A.changed,packageDir:_,delta:A.entries}}var eH;var O6=V(()=>{gF();b3();a3();Q0();DF();_4();eD();P0();n1();A4();BF();$D();yD();hD();t1();c2();k2();K8();nF();x0();g0();SB();eH={name:"opencode-plugins",private:!0,type:"module"}});import{join as QJ,posix as YJ}from"path";function qJ(D){if(D.length===0)return"Unknown parse error";let F=D[0];if(!F)return"Unknown parse error";return`${K2(F.error)} at offset ${F.offset}`}async function PB(D){let F=Bun.file(`${D}/registry.jsonc`),B=Bun.file(`${D}/registry.json`),$=await F.exists(),_=await B.exists();if(!$&&!_)return{success:!1,error:"No registry.jsonc or registry.json found in source directory",errorKind:"not_found"};let Q=$?F:B,Y=$?"registry.jsonc":"registry.json",q=await Q.text(),H=[],J=ND(q,H,{allowTrailingComma:!0});if(H.length>0){let X=qJ(H);return{success:!1,error:`Invalid JSONC in ${Y}: ${X}`,errorKind:"parse_error"}}return{success:!0,data:J}}function yB(D,F){let B=PF(D);if(B)return{valid:!1,errors:[`Schema compatibility issue: ${B.issue} - ${B.remediation}`]};return HJ(D,F)}function HJ(D,F){let B=i2.safeParse(D);if(!B.success)return{valid:!1,errors:B.error.errors.map((_)=>`${_.path.join(".")}: ${_.message}`)};return{valid:!0,errors:[],data:B.data}}async function JJ(D,F){let B=[];for(let $ of D.components)for(let _ of $.files){let Q=b2(_,$.type),Y=QJ(F,"files",Q.path);if(!await Bun.file(Y).exists())B.push(`${$.name}: Source file not found at ${Q.path}`)}return{valid:B.length===0,errors:B}}function XJ(D){let F=[],B=new Map(D.components.map((Q)=>[Q.name,Q]));function $(Q,Y,q,H){if(Y.has(Q))return[...H,Q].join(" -> ");if(q.has(Q))return null;let J=B.get(Q);if(!J)return null;Y.add(Q),H.push(Q);for(let X of J.dependencies){if(X.includes("/"))continue;let z=$(X,Y,q,H);if(z)return z}return Y.delete(Q),q.add(Q),H.pop(),null}let _=new Set;for(let Q of D.components){if(_.has(Q.name))continue;let Y=$(Q.name,new Set,_,[]);if(Y){F.push(`Circular dependency detected: ${Y}`);break}}return{valid:F.length===0,errors:F}}function WJ(D){let F=[],B=new Map,$=(_)=>{let Y=_.normalize("NFC").replace(/\\/g,"/");return YJ.normalize(Y).replace(/^\.\//,"")};for(let _ of D.components)for(let Q of _.files){let Y=b2(Q,_.type),q=$(Y.target),H=B.get(q);if(H)F.push(`Duplicate target "${q}" in components "${H.componentName}" and "${_.name}"`);else B.set(q,{componentName:_.name})}return{valid:F.length===0,errors:F}}async function*xB(D,F,B={}){let $=await JJ(D,F);for(let Q of $.errors)yield Q;let _=XJ(D);for(let Q of _.errors)yield Q;if(!B.skipDuplicateTargets){let Q=WJ(D);for(let Y of Q.errors)yield Y}}var fB=V(()=>{b0();P0()});async function k8(D,F={}){let B=await PB(D);if(!B.success)return{success:!1,errors:[B.error||"Failed to load registry"],failureType:"load",loadErrorKind:B.errorKind};let $=yB(B.data,D);if(!$.valid)return{success:!1,errors:$.errors,failureType:"schema"};let _=$.data;if(!_)throw Error("Registry validation succeeded but returned no parsed data");let Q=[];for await(let Y of xB(_,D,F))Q.push(Y);if(Q.length>0)return{success:!1,errors:Q,failureType:"rules"};return{success:!0,errors:[],registry:_}}var b6=V(()=>{fB()});function Z6(D){return{file:D.filter((F)=>F.includes("Source file not found")),circular:D.filter((F)=>F.includes("Circular dependency")),duplicate:D.filter((F)=>F.includes("Duplicate target"))}}function u3(D,F={}){let B=Z6(D),$=F.schemaErrors??0,_=D.length,Q=Math.max(0,_-$-B.file.length-B.circular.length-B.duplicate.length);return{valid:_===0,totalErrors:_,schemaErrors:$,sourceFileErrors:B.file.length,circularDependencyErrors:B.circular.length,duplicateTargetErrors:B.duplicate.length,otherErrors:Q}}import{relative as GJ,resolve as hB}from"path";function zJ(D,F){if(F==="not_found")return new MD(D);if(F==="parse_error")return new zD(D,"CONFIG_ERROR",XD.CONFIG);return new zD(D,"CONFIG_ERROR",XD.CONFIG)}function MJ(D,F){let B=u3(D,{schemaErrors:F==="schema"?D.length:0}),$={valid:!1,errors:D,summary:{valid:!1,totalErrors:B.totalErrors,schemaErrors:B.schemaErrors,sourceFileErrors:B.sourceFileErrors,circularDependencyErrors:B.circularDependencyErrors,duplicateTargetErrors:B.duplicateTargetErrors,otherErrors:B.otherErrors}};return new g2($)}function AJ(D,F){if(F==="schema"){W.error("\u2717 Registry schema");for(let $ of D)console.log(P.red(` ${$}`));return}let B=Z6(D);if(B.file.length>0){W.error("\u2717 Source files");for(let $ of B.file)console.log(P.red(` ${$}`))}if(B.circular.length>0){W.error("\u2717 Circular dependencies");for(let $ of B.circular)console.log(P.red(` ${$}`))}if(B.duplicate.length>0){W.error("\u2717 Duplicate targets");for(let $ of B.duplicate)console.log(P.red(` ${$}`))}}function mB(D){D.command("build").description("Build a registry from source (for registry authors)").argument("[path]","Registry source directory",".").option("--out <dir>","Output directory","./dist").option("--cwd <path>","Working directory",process.cwd()).option("--json","Output as JSON",!1).option("-q, --quiet","Suppress output",!1).option("--dry-run","Validate and show what would be built").option("--show-validation","Display validation results before building",!1).action(async(F,B)=>{try{let $=hB(B.cwd,F),_=hB(B.cwd,B.out);if(B.showValidation){let H=!B.json&&!B.quiet;if(H)W.info("Running validation checks...");let J=await k8($,{skipDuplicateTargets:!1});if(!J.success){let[X="Registry validation failed"]=J.errors;if(J.failureType==="load")throw zJ(X,J.loadErrorKind);let z=J.failureType==="schema"?"schema":"rules",M=MJ(J.errors,z);if(B.json)throw M;if(!B.quiet)AJ(J.errors,z);process.exit(M.exitCode)}if(H)W.success("\u2713 Schema compatibility and structure"),W.success("\u2713 Source files"),W.success("\u2713 No circular dependencies"),W.success("\u2713 No duplicate targets"),console.log("")}let Q=jD({text:"Building registry...",quiet:B.quiet||B.json});if(!B.json)Q.start();let Y=await V3({source:$,out:_,dryRun:B.dryRun});if("dryRun"in Y&&Y.dryRun){if(!B.json)Q.stop();z0(Y,{json:B.json,quiet:B.quiet});return}let q=Y;if(!B.json){let H=`Built ${q.componentsCount} components to ${GJ(B.cwd,_)}`;if(Q.succeed(H),!process.stdout.isTTY)W.success(`Built ${q.componentsCount} components`)}if(B.json)LD({success:!0,data:{components:q.componentsCount,output:q.outputPath}})}catch($){if($ instanceof s0){if(B.json)t($,{json:!0});if(!B.quiet){W.error($.message);for(let _ of $.errors)console.log(P.red(` ${_}`))}process.exit(1)}t($,{json:B.json})}})}var gB=V(()=>{G2();r3();b6();BF();$D();yD();hD();g0()});import{existsSync as dB}from"fs";import{mkdir as jJ}from"fs/promises";import{join as R6}from"path";function cB(D){D.command("edit").description("Open configuration file in editor").option("-g, --global","Edit global ocx.jsonc").option("-p, --profile <name>","Edit specific profile's config").action(async(F)=>{try{await KJ(F)}catch(B){t(B)}})}async function KJ(D){if(D.global&&D.profile)throw new U("Cannot use both --global and --profile flags");let F;if(D.profile){let Q=a0.safeParse(D.profile);if(!Q.success)throw new U(`Invalid profile name "${D.profile}": ${Q.error.errors[0]?.message??"Invalid name"}`);if(await PD.requireInitialized(),!await PD.create().exists(D.profile))throw new CD(D.profile);F=_0(D.profile)}else if(D.global){if(F=cF(),!dB(F))throw new c(`Global config not found at ${F}.
120
+ Run 'ocx init --global' first.`)}else{let Q=o2(process.cwd());if(Q)F=R6(Q,y0);else{let Y=R6(process.cwd(),s2);if(await jJ(Y,{recursive:!0}),F=R6(Y,y0),!dB(F)){let q={$schema:"https://ocx.kdco.dev/schemas/ocx.json",registries:{}};await Bun.write(F,JSON.stringify(q,null,2)),W.info(`Created ${F}`)}}}let B=process.env.EDITOR||process.env.VISUAL||"vi",_=await Bun.spawn([B,F],{stdin:"inherit",stdout:"inherit",stderr:"inherit"}).exited;if(_!==0)throw Error(`Editor exited with code ${_}`)}var lB=V(()=>{o0();Q0();q8();$D();yD();hD()});function pB(D){D.command("show").description("Display resolved configuration for current directory").addOption(E0.json()).option("--origin","Show where each setting came from").option("-p, --profile <name>","Use specific profile").action(async(F)=>{try{await UJ(F)}catch(B){t(B,{json:F.json})}})}async function UJ(D){let F=await r0.create(process.cwd(),{profile:D.profile});if(D.origin){let $=F.resolveWithOrigin();if(D.json){let Q={};for(let[Y,q]of $.origins)Q[Y]=q;console.log(JSON.stringify({...$,origins:Q},null,2));return}if(console.log(P.bold("Resolved Configuration")),console.log(),$.profileName){let Q=$.origins.get("profileName");if(console.log(`${P.cyan("Profile:")} ${$.profileName}`),Q)console.log(` ${P.dim(`\u2190 ${Q.source}`)}`)}console.log(),console.log(P.cyan("Component Path:"),$.componentPath);let _=$.origins.get("componentPath");if(_)console.log(` ${P.dim(`\u2190 ${_.source} (${_.path})`)}`);console.log(),console.log(P.cyan("Registries:"));for(let[Q,Y]of Object.entries($.registries)){console.log(` ${P.green(Q)}: ${Y.url}`);let q=$.origins.get(`registries.${Q}`);if(q)console.log(` ${P.dim(`\u2190 ${q.source} (${q.path})`)}`)}if($.instructions.length>0){console.log(),console.log(P.cyan("Instructions:"));for(let Q of $.instructions)console.log(` ${Q}`)}if(Object.keys($.opencode).length>0){console.log(),console.log(P.cyan("OpenCode Config:"));for(let Q of Object.keys($.opencode)){let Y=$.origins.get(`opencode.${Q}`);if(console.log(` ${Q}:`,JSON.stringify($.opencode[Q])),Y)console.log(` ${P.dim(`\u2190 ${Y.source} (${Y.path})`)}`)}}return}let B=F.resolve();if(D.json){console.log(JSON.stringify(B,null,2));return}if(console.log(P.bold("Resolved Configuration")),console.log(),B.profileName)console.log(`${P.cyan("Profile:")} ${B.profileName}`);if(console.log(`${P.cyan("Component Path:")} ${B.componentPath}`),console.log(),console.log(P.cyan("Registries:")),Object.keys(B.registries).length===0)console.log(" (none)");else for(let[$,_]of Object.entries(B.registries))console.log(` ${P.green($)}: ${_.url}`);if(B.instructions.length>0){console.log(),console.log(P.cyan("Instructions:"));for(let $ of B.instructions)console.log(` ${$}`)}}var iB=V(()=>{G2();b3();yD();x0()});function nB(D){let F=D.command("config").description("View and edit configuration");pB(F),cB(F)}var sB=V(()=>{lB();iB()});import{existsSync as YF}from"fs";import{cp as VJ,mkdir as tF,readdir as aB,readFile as EJ,rm as LJ,writeFile as N6}from"fs/promises";import{dirname as oB,join as I8}from"path";function rB(D){let F=D.command("init").description("Initialize OCX configuration in your project");rD(F),L0(F),t0(F),F.option("--registry <path>","Scaffold a new OCX registry project at path").option("--namespace <name>","Registry namespace (e.g., my-org)").option("--author <name>","Author name for the registry").option("--canary","Use canary (main branch) instead of latest release").option("--local <path>","Use local template directory instead of fetching").action(async(B)=>{try{if(B.registry)await RJ(B.registry,B);else if(B.global)await ZJ(B);else await bJ(B)}catch($){t($,{json:B.json})}})}async function bJ(D){let F=D.cwd??process.cwd(),{path:B,exists:$}=S2(F);if($)throw new dD(`ocx.jsonc already exists at ${B}
121
121
 
122
122
  To reset, delete the config and run init again:
123
- rm ${B} && ocx init`);let _=D.quiet?null:jD({text:"Initializing OCX..."});_?.start();try{let Q={$schema:X1,registries:{}},Y=R2.parse(Q);await rF(iB(B),{recursive:!0});let q=JSON.stringify(Y,null,2);await b6(B,q,"utf-8");let H=await $4(F);if(_?.succeed("Initialized OCX configuration"),D.json)console.log(JSON.stringify({success:!0,path:B,opencodePath:H.path,opencodeCreated:H.created}));else if(!D.quiet){if(G.info(`Created ${B}`),H.created)G.info(`Created ${H.path}`);G.info(""),G.info("Next steps:"),G.info(" 1. Add a registry: ocx registry add <url>"),G.info(" 2. Install components: ocx add <component>")}}catch(Q){throw _?.fail("Failed to initialize"),Q}}async function UJ(D){let F=D.quiet?null:jD({text:"Initializing global profiles..."});F?.start();try{let B=[],$=[],_=I2();if(YF(_))$.push("globalConfig");else await rF(iB(_),{recursive:!0,mode:448}),await dF(_,{$schema:X1,registries:{}}),B.push("globalConfig");let Q=X2();if(!YF(Q))await rF(Q,{recursive:!0,mode:448});let Y=yD("default");if(!YF(Y))await rF(Y,{recursive:!0,mode:448});let q=Q0("default");if(YF(q))$.push("profileOcx");else await dF(q,N9),B.push("profileOcx");let H=G2("default");if(YF(H))$.push("profileOpencode");else await dF(H,{}),B.push("profileOpencode");let J=a2("default");if(YF(J))$.push("profileAgents");else await Bun.write(J,`# Profile Instructions
123
+ rm ${B} && ocx init`);let _=D.quiet?null:jD({text:"Initializing OCX..."});_?.start();try{let Q={$schema:G1,registries:{}},Y=Z2.parse(Q);await tF(oB(B),{recursive:!0});let q=JSON.stringify(Y,null,2);await N6(B,q,"utf-8");let H=await Y4(F);if(_?.succeed("Initialized OCX configuration"),D.json)console.log(JSON.stringify({success:!0,path:B,opencodePath:H.path,opencodeCreated:H.created}));else if(!D.quiet){if(W.info(`Created ${B}`),H.created)W.info(`Created ${H.path}`);W.info(""),W.info("Next steps:"),W.info(" 1. Add a registry: ocx registry add <url>"),W.info(" 2. Install components: ocx add <component>")}}catch(Q){throw _?.fail("Failed to initialize"),Q}}async function ZJ(D){let F=D.quiet?null:jD({text:"Initializing global profiles..."});F?.start();try{let B=[],$=[],_=cF();if(YF(_))$.push("globalConfig");else await tF(oB(_),{recursive:!0,mode:448}),await dF(_,{$schema:G1,registries:{}}),B.push("globalConfig");let Q=X2();if(!YF(Q))await tF(Q,{recursive:!0,mode:448});let Y=fD("default");if(!YF(Y))await tF(Y,{recursive:!0,mode:448});let q=_0("default");if(YF(q))$.push("profileOcx");else await dF(q,T9),B.push("profileOcx");let H=W2("default");if(YF(H))$.push("profileOpencode");else await dF(H,{}),B.push("profileOpencode");let J=a2("default");if(YF(J))$.push("profileAgents");else await Bun.write(J,`# Profile Instructions
124
124
 
125
125
  <!-- Add your custom instructions for this profile here -->
126
126
  <!-- These will be included when running \`ocx opencode -p default\` -->
127
- `,{mode:384}),B.push("profileAgents");if(F?.succeed("Initialized global profiles"),D.json)console.log(JSON.stringify({success:!0,files:{globalConfig:_,profileOcx:q,profileOpencode:H,profileAgents:J},created:B,existed:$}));else if(!D.quiet)if(B.length>0){for(let X of B){if(X==="globalConfig")G.info(`Created global config: ${_}`);if(X==="profileOcx")G.info(`Created profile config: ${q}`);if(X==="profileOpencode")G.info(`Created profile opencode config: ${H}`);if(X==="profileAgents")G.info(`Created profile instructions: ${J}`)}G.info(""),G.info("Next steps:"),G.info(" 1. Edit your profile config: ocx config edit -p default"),G.info(" 2. Add registries: ocx registry add <url> --name <name> --global"),G.info(" 3. Launch OpenCode: ocx opencode"),G.info(" 4. Create more profiles: ocx profile add <name> --global")}else G.info("Global profiles already initialized (all files exist)")}catch(B){throw F?.fail("Failed to initialize"),B}}async function VJ(D,F){let B=D,$=F.namespace??"my-registry",_=F.author??"Your Name";if(!/^[a-z0-9]+(-[a-z0-9]+)*$/.test($))throw new U("Invalid namespace format: must start with letter/number, use hyphens only between segments (e.g., 'my-registry')");if((await pB(B).catch(()=>[])).some((H)=>!H.startsWith(".")))throw new gD("Directory is not empty. Remove existing files or choose a different directory.");let q=F.quiet?null:jD({text:"Scaffolding registry..."});q?.start();try{if(q)q.text=F.local?"Copying template...":"Fetching template...";if(F.local)await rF(B,{recursive:!0}),await sB(F.local,B);else{let H=F.canary?"main":EJ();await wJ(B,H,F.verbose)}if(q)q.text="Configuring project...";if(await bJ(B,{namespace:$,author:_}),q?.succeed(`Created registry: ${$}`),F.json)console.log(JSON.stringify({success:!0,namespace:$,path:B}));else if(!F.quiet)G.info(""),G.info("Next steps:"),G.info(" 1. bun install"),G.info(" 2. Edit registry.jsonc with your components"),G.info(" 3. bun run build"),G.info(""),G.info("Deploy to:"),G.info(" Cloudflare: bunx wrangler deploy"),G.info(" Vercel: vercel"),G.info(" Netlify: netlify deploy")}catch(H){throw q?.fail("Failed to scaffold registry"),H}}async function sB(D,F){await WJ(D,F,{recursive:!0})}function EJ(){return"v2.0.3"}function LJ(D){let F=D==="main"?"heads/main":`tags/${D}`;return`https://github.com/${AJ}/archive/refs/${F}.tar.gz`}async function wJ(D,F,B){let $=LJ(F);if(B)G.info(`Fetching ${$}`);let _=await fetch($);if(!_.ok||!_.body)throw new RD(`Failed to fetch template from ${$}: ${_.statusText}`);let Q=S8(D,".ocx-temp");await rF(Q,{recursive:!0});try{let Y=S8(Q,"template.tar.gz"),q=await _.arrayBuffer();await b6(Y,Buffer.from(q));let H=Bun.spawn(["tar","-xzf",Y,"-C",Q],{stdout:"ignore",stderr:"pipe"});if(await H.exited!==0){let A=await new Response(H.stderr).text();throw Error(`Failed to extract template: ${A}`)}let z=(await pB(Q)).find((A)=>A.startsWith("ocx-"));if(!z)throw Error("Failed to find extracted template directory");let M=S8(Q,z,jJ);await sB(M,D)}finally{await MJ(Q,{recursive:!0,force:!0})}}function OJ(D){return D.split(/[-_\s]+/).map((F)=>F.charAt(0).toUpperCase()+F.slice(1).toLowerCase()).join(" ")}async function bJ(D,F){let B=["registry.jsonc","package.json","wrangler.jsonc","README.md","AGENTS.md"];for(let $ of B){let _=S8(D,$);if(!YF(_))continue;let Q=await zJ(_).then((Y)=>Y.toString());if(Q=Q.replace(/my-registry/g,F.namespace),Q=Q.replace(/My Registry/g,OJ(F.namespace)),Q=Q.replace(/Your Name/g,F.author),$==="registry.jsonc")if(/"\$schema"\s*:/.test(Q))Q=Q.replace(/("\$schema"\s*:\s*")[^"]*(")/,`$1${T0}$2`);else Q=Q.replace(/{/,`{
128
- "$schema": "${T0}",`);await b6(_,Q)}}var AJ="kdcokenny/ocx",jJ="examples/registry-starter";var aB=V(()=>{s3();_8();a0();G0();tD();l1();$D();PD();fD();x0();m0()});function RJ(D,F,B){let $=D.indexOf("/");if($===-1)throw Error(`Invalid legacy key: "${D}". Expected format: alias/component`);let _=D.slice(0,$),Q=D.slice($+1);if(!_||!Q)throw Error(`Invalid legacy key: "${D}". Both alias and component are required.`);let Y=E3(B,_,Q,F.version),q={registryUrl:B,registryName:_,name:Q,revision:F.version,hash:F.hash,files:F.files.map((H)=>({path:H,hash:""})),installedAt:F.installedAt,...F.updatedAt&&{updatedAt:F.updatedAt},owner:{type:"user"}};return[Y,q]}function k8(D,F,B){let $={},_=[],Q=Object.keys(D.installed).sort();for(let q of Q){let H=D.installed[q];if(!H)continue;let J=F.registries[H.registry];if(!J)throw new c(`Registry "${H.registry}" referenced in lock key "${q}" is not configured in ocx.jsonc. Add it before migrating.`);let[X,z]=RJ(q,H,J.url);$[X]=z,_.push({legacyKey:q,canonicalId:X,name:z.name,registryName:z.registryName})}return{receipt:{version:1,...B&&{root:B},installed:$},components:_}}function oB(D){let F=D.registries;if(!F||typeof F!=="object"||Array.isArray(F))return[];let B=[],$=F;for(let _ of Object.keys($).sort()){let Q=$[_];if(!Q||typeof Q!=="object"||Array.isArray(Q))continue;let Y=Q;for(let q of ZJ)if(q in Y)B.push({registry:_,field:q,action:"remove_deprecated"})}return B}var ZJ;var rB=V(()=>{tD();$D();ZJ=["version"]});import{existsSync as R6,readdirSync as NJ,readFileSync as F5,statSync as SJ}from"fs";import{rename as I8,writeFile as kJ}from"fs/promises";import{join as tB}from"path";function B5(D){D.command("migrate").description("Migrate legacy ocx.lock to receipt format (.ocx/receipt.jsonc)").option("--global","Migrate global config scope (includes profiles)").option("--apply","Apply migration (default is dry-run preview)").option("--json","Output as JSON").option("-q, --quiet","Suppress output").option("--cwd <path>","Working directory").action(async(F)=>{try{await TJ(F)}catch(B){t(B,{json:F.json})}})}async function TJ(D){if(D.global){await vJ(D);return}await lJ(D,"local",sJ(D),!1)}async function vJ(D){let F=D.cwd??X0(),B=CJ(F);if(!D.apply){let Y=[],q=new Set;for(let{label:X,path:z}of B){let M=N2(z),A=yF(z,{isFlattened:!0});if(M.exists&&A.exists)q.add(X);try{let K=await uJ(z,!0,{emitWarnings:!D.json&&!D.quiet});Y.push({...K,target:X})}catch(K){let j=D5(X,K);if(Y.push(j),!D.json&&!D.quiet)G.error(`[global:${X}] Preview failed: ${j.error}`)}}let H=eB(Y,"global",!1),J=xJ(H);if(D.json){if(tF(H,!1),J)process.exit(1);return}if(!D.quiet)pJ(Y,H,q);if(J)process.exit(1);return}let $=[],_=!1;for(let{label:Y,path:q}of B)try{let H=await PJ(q,!0);$.push({...H,target:Y})}catch(H){_=!0;let J=D5(Y,H);if($.push(J),!D.json&&!D.quiet)G.error(`[global:${Y}] Migration failed: ${J.error}`)}let Q=eB($,"global",!0);if(D.json){if(tF(Q,!0),_)process.exit(1);return}if(!D.quiet)iJ($,_);if(_)process.exit(1)}function CJ(D){let F=[];F.push({label:"root",path:D});let B=tB(D,"profiles");if(R6(B)&&SJ(B).isDirectory()){let _=NJ(B,{withFileTypes:!0}).filter((Q)=>Q.isDirectory()&&!Q.name.startsWith(".")).map((Q)=>Q.name).sort();for(let Q of _)F.push({label:`profile:${Q}`,path:tB(B,Q)})}return F}async function uJ(D,F,B){let $=B?.emitWarnings??!0,_=Z6(D),Q=N2(D),Y=yF(D,{isFlattened:F}),q=Q.exists&&Y.exists;if(Q.exists&&_.length===0&&!q)return{status:"already_v2",count:0,components:[],configActions:[]};if(!Y.exists&&!Q.exists&&_.length===0)return{status:"nothing_to_migrate",count:0,components:[],configActions:[]};let H=[];if(Y.exists&&!Q.exists)try{let J=await L3(D,{isFlattened:F}),X=await U0(D,{emitParseDiagnostics:$});if(J&&X)H=k8(J,X,D).components}catch{if($)G.warn(`[preview] Could not parse lock/config at "${D}"; component count may be incomplete.`)}return{status:"preview",count:H.length,components:H,configActions:_}}async function PJ(D,F){let B=Z6(D),$=N2(D),_=yF(D,{isFlattened:F}),Q=$.exists&&_.exists;if($.exists&&B.length===0&&!Q)return{status:"already_v2",count:0,components:[],configActions:[]};if(!_.exists&&!$.exists&&B.length===0)return{status:"nothing_to_migrate",count:0,components:[],configActions:[]};let Y=null;if(_.exists&&!$.exists){let X=await L3(D,{isFlattened:F});if(!X)throw new U("Failed to parse ocx.lock. The lock file exists but could not be read or contains invalid data.");let z=await U0(D);if(!z)throw new c("No ocx.jsonc found. The config is required to resolve registry URLs during migration.");let{receipt:M,components:A}=k8(X,z,D);Y={newReceipt:M,components:A}}let q=Y?.components??[],H=q.length;if(Y){await K0(D,Y.newReceipt);let X=T8(_.path);await I8(_.path,X)}if(Q){let X=T8(_.path);await I8(_.path,X)}if(B.length>0)await $5(D,B);return{status:Y!==null||Q||B.length>0?"migrated":"already_v2",count:H,components:q,configActions:B}}function eB(D,F,B){let $=D.some((X)=>X.status==="error"),_=D.some((X)=>X.status==="migrated"||X.status==="preview"),Q=D.every((X)=>X.status==="already_v2"||X.status==="nothing_to_migrate"),Y=D.reduce((X,z)=>X+z.count,0),q=D.flatMap((X)=>X.components),H=D.flatMap((X)=>X.configActions),J;if($)J=B?"partial_failure":"preview_with_errors";else if(Q)J=D.every((z)=>z.status==="nothing_to_migrate")?"nothing_to_migrate":"already_v2";else if(B)J=_?"migrated":"already_v2";else J=_?"preview":"already_v2";return{success:!$,status:J,scope:F,count:Y,components:q,configActions:H,targets:D}}function xJ(D){return D.status==="preview_with_errors"}function tF(D,F){let B=yJ(D,F);console.log(JSON.stringify(B,null,2))}function yJ(D,F){let B=fJ(D),$=B.flatMap((_)=>_.blockers??[]);return{...D,lifecycle_status:gJ(D.status,F),schema_version:IJ,blockers:$,targets:B}}function fJ(D){return(D.targets&&D.targets.length>0?D.targets:[hJ(D)]).map((B)=>mJ(B))}function hJ(D){return{target:D.scope,status:D.status,count:D.count,components:D.components,configActions:D.configActions,blockers:D.blockers??[]}}function mJ(D){let F=D.blockers??(D.status==="error"?[{code:"MIGRATE_BLOCKER",message:D.error??"Migration blocked",path:D.target}]:[]);return{...D,scope:D.scope??D.target,result:D.result??D.status,blockers:F}}function gJ(D,F){if(F)return D==="partial_failure"?"apply_failed":"apply_ok";return D==="preview_with_errors"?"preview_blocked":"preview_ok"}function D5(D,F){let B=dJ(F,D);return{target:D,status:"error",count:0,components:[],configActions:[],error:B.message,blockers:[B]}}function dJ(D,F){let B=D instanceof Error?D.message:String(D);return{code:cJ(D,B),message:B,path:F}}function cJ(D,F){if(typeof D==="object"&&D!==null&&"code"in D){let $=D.code;if(typeof $==="string"&&$.length>0)return $}let B=F.toLowerCase();if(B.includes("ocx.jsonc")||B.includes("registry"))return"CONFIG_ERROR";if(B.includes("parse")||B.includes("invalid"))return"VALIDATION_ERROR";return"MIGRATE_BLOCKER"}async function lJ(D,F,B,$){let _=Z6(B),Q=N2(B),Y=yF(B,{isFlattened:$}),q=Q.exists&&Y.exists;if(Q.exists&&_.length===0&&!q){let A={success:!0,status:"already_v2",scope:F,count:0,components:[],configActions:[]};if(D.json){tF(A,Boolean(D.apply));return}if(!D.quiet)G.success(`[${F}] Already migrated to receipt format (.ocx/receipt.jsonc).`);return}if(!Y.exists&&!Q.exists&&_.length===0){let A={success:!0,status:"nothing_to_migrate",scope:F,count:0,components:[],configActions:[]};if(D.json){tF(A,Boolean(D.apply));return}if(!D.quiet)G.info(`[${F}] Nothing to migrate. No legacy ocx.lock found.`);return}let H=null;if(Y.exists&&!Q.exists){let A=await L3(B,{isFlattened:$});if(!A)throw new U("Failed to parse ocx.lock. The lock file exists but could not be read or contains invalid data.");let K=await U0(B);if(!K)throw new c("No ocx.jsonc found. The config is required to resolve registry URLs during migration.");let{receipt:j,components:S}=k8(A,K,B);H={newReceipt:j,components:S}}let J=H?.components??[],X=J.length;if(!D.apply){let A={success:!0,status:"preview",scope:F,count:X,components:J,configActions:_};if(D.json){tF(A,!1);return}if(!D.quiet){if(X>0){G.info(`[${F}] Migration preview: ${X} component(s) would be migrated.`),G.break();for(let K of J)G.info(` ${K.legacyKey} \u2192 ${K.canonicalId}`);G.break()}if(q)G.info(`[${F}] Legacy ocx.lock would be backed up and removed (receipt already exists).`),G.break();if(_.length>0){G.info(`[${F}] Config normalization: ${_.length} deprecated field(s) would be removed.`);for(let K of _)G.info(` registries.${K.registry}.${K.field} \u2192 remove`);G.break()}if(X===0&&_.length===0&&!q)G.info(`[${F}] Nothing to migrate.`);else G.info("No changes made. Run with --apply to perform migration.")}return}if(H){await K0(B,H.newReceipt);let A=T8(Y.path);if(await I8(Y.path,A),!D.json&&!D.quiet){G.success(`[${F}] Migrated ${X} component(s) to receipt format (.ocx/receipt.jsonc).`),G.break();for(let K of J)G.success(` \u2713 ${K.legacyKey} \u2192 ${K.canonicalId}`);G.break(),G.info(`Legacy lock backed up to: ${A}`)}}if(q){let A=T8(Y.path);if(await I8(Y.path,A),!D.json&&!D.quiet)G.success(`[${F}] Removed stale legacy lock (receipt already exists).`),G.info(`Legacy lock backed up to: ${A}`)}if(_.length>0){if(await $5(B,_),!D.json&&!D.quiet){if(H)G.break();G.success(`[${F}] Normalized ${_.length} deprecated config field(s).`);for(let A of _)G.success(` \u2713 registries.${A.registry}.${A.field} removed`)}}let M={success:!0,status:H!==null||q||_.length>0?"migrated":"already_v2",scope:F,count:X,components:J,configActions:_};if(D.json){tF(M,!0);return}if(!H&&_.length>0&&!D.quiet)G.break(),G.success(`[${F}] Config normalization complete.`)}function pJ(D,F,B){if(F.status==="nothing_to_migrate"){G.info("[global] Nothing to migrate across all targets.");return}if(F.status==="already_v2"){G.success("[global] All targets already migrated.");return}G.info(`[global] Migration preview across ${D.length} target(s):`),G.break();for(let $ of D){let _=B.has($.target),Q=nJ($,_);G.info(` ${$.target}: ${Q}`)}if(G.break(),F.status==="preview_with_errors")G.warn("[global] Preview completed with errors on some targets. See above for details."),G.info("No changes made. Run with --apply to perform migration.");else G.info("No changes made. Run with --apply to perform migration.")}function iJ(D,F){G.break();let B=D.filter((Q)=>Q.status==="migrated"),$=D.filter((Q)=>Q.status==="already_v2"||Q.status==="nothing_to_migrate"),_=D.filter((Q)=>Q.status==="error");if(B.length>0){G.success(`[global] Migrated ${B.length} target(s):`);for(let Q of B)G.success(` \u2713 ${Q.target}`)}if($.length>0)G.info(`[global] ${$.length} target(s) already up to date.`);if(_.length>0){G.error(`[global] ${_.length} target(s) failed:`);for(let Q of _)G.error(` \u2717 ${Q.target}: ${Q.error}`)}if(F)G.break(),G.error("[global] Migration completed with errors. See above for details.")}function nJ(D,F){if(D.status==="error")return"error";if(D.status==="already_v2")return"already migrated";if(D.status==="nothing_to_migrate")return"nothing to migrate";let B=[];if(D.count>0)B.push(`${D.count} component(s) to migrate`);if(D.configActions.length>0)B.push(`${D.configActions.length} config field(s) to normalize`);if(F)B.push("legacy lock cleanup pending");if(B.length===0)return"nothing to migrate";return B.join(", ")}function sJ(D){if(D.global)return D.cwd??X0();return D.cwd??process.cwd()}function T8(D){let F=`${D}.bak`;if(!R6(F))return F;for(let B=1;B<=100;B++){let $=`${F}.${B}`;if(!R6($))return $}return`${F}.${Date.now()}`}function Z6(D){let F=S2(D);if(!F.exists)return[];try{let B=F5(F.path,"utf-8"),$=ND(B,[],{allowTrailingComma:!0});if(!$||typeof $!=="object"||Array.isArray($))return[];return oB($)}catch{return[]}}async function $5(D,F){if(F.length===0)return;let B=S2(D);if(!B.exists)return;let $=F5(B.path,"utf-8");for(let _ of F){let Q=AF($,["registries",_.registry,_.field],void 0,aJ);$=jF($,Q)}await kJ(B.path,$)}var IJ=1,aJ;var _5=V(()=>{b0();tD();$D();PD();fD();k2();rB();aJ={formattingOptions:{tabSize:2,insertSpaces:!0,eol:`
129
- `}}});import{basename as oJ,resolve as TV}from"path";function v8(){let{GIT_DIR:D,GIT_WORK_TREE:F,...B}=process.env;return B}async function rJ(D){let F=Bun.spawn(["git","symbolic-ref","--short","HEAD"],{cwd:D,env:v8(),stdout:"pipe",stderr:"pipe"});if(await F.exited===0){let H=(await new Response(F.stdout).text()).trim();if(H)return H}let $=Bun.spawn(["git","describe","--tags","--exact-match","HEAD"],{cwd:D,env:v8(),stdout:"pipe",stderr:"pipe"});if(await $.exited===0){let H=(await new Response($.stdout).text()).trim();if(H)return H}let Q=Bun.spawn(["git","rev-parse","--short","HEAD"],{cwd:D,env:v8(),stdout:"pipe",stderr:"pipe"});if(await Q.exited===0){let H=(await new Response(Q.stdout).text()).trim();if(H)return H}return null}async function tJ(D){let F=Bun.spawn(["git","rev-parse","--show-toplevel"],{cwd:D,env:v8(),stdout:"pipe",stderr:"pipe"});if(await F.exited!==0)return null;let _=(await new Response(F.stdout).text()).trim();if(!_)return null;return oJ(_)}async function Q5(D){let[F,B]=await Promise.all([tJ(D),rJ(D)]);return{repoName:F,branch:B}}var Y5=()=>{};import eJ from"path";function H5(){return Boolean(process.env.TMUX)}function DX(D){if(!H5())return;Bun.spawnSync(["tmux","rename-window",D]),Bun.spawnSync(["tmux","set-window-option","automatic-rename","off"])}function FX(D){if(!FF)return;process.stdout.write(`\x1B]0;${D}\x07`)}function J5(D){DX(D),FX(D)}function X5(){if(C8||!FF)return;process.stdout.write("\x1B[22;2t"),C8=!0}function N6(){if(!C8)return;if(H5())Bun.spawnSync(["tmux","set-window-option","automatic-rename","on"]);if(FF)process.stdout.write("\x1B[23;2t");C8=!1}function G5(D,F,B){let $=B.repoName??eJ.basename(D);if(!B.branch)return`ocx[${F}]:${$}`;let _=B.branch.length>q5?`${B.branch.slice(0,q5-3)}...`:B.branch;return`ocx[${F}]:${$}/${_}`}var q5=20,C8=!1;var W5=V(()=>{Z3()});import{randomUUID as BX}from"crypto";import{copyFile as $X,cp as _X,lstat as C2,mkdir as QX,mkdtemp as YX,readdir as A5,readFile as qX,realpath as D3,rename as HX,rm as JX,unlink as XX}from"fs/promises";import{tmpdir as GX}from"os";import{basename as WX,dirname as I6,isAbsolute as j5,join as z2,relative as T6}from"path";var{Glob:S6}=globalThis.Bun;function a(D,F){return new c(`ocx oc ${D} error: ${F}`)}function TD(D){if(D instanceof Error)return D.message;return String(D)}function jX(D){if(D.length===0)return"Unknown parse error";let F=D[0];if(!F)return"Unknown parse error";return`${K2(F.error)} at offset ${F.offset}`}function P8(D){return D.replaceAll("\\","/")}function k6(D){return D.startsWith("./")?D.slice(2):D}function v6(D,F){let B=T6(D,F);if(B.length===0)return!0;return!B.startsWith("..")&&!j5(B)}function KX(D){if(D.isFile())return"file";if(D.isDirectory())return"directory";if(D.isSymbolicLink())return"symlink";return"other"}function u3(D){return{entryType:KX(D),device:String(D.dev),inode:String(D.ino),mode:String(D.mode),size:String(D.size),mtimeMs:String(D.mtimeMs)}}function UX(D,F){return D.entryType===F.entryType&&D.device===F.device&&D.inode===F.inode&&D.mode===F.mode}function VX(D,F){return D.size===F.size&&D.mtimeMs===F.mtimeMs}async function eF(D){let F;try{F=await C2(D.absolutePath)}catch{throw a("validate",`Overlay path changed during ${D.phase}: ${D.overlayRelativePath}. ${v2}`)}if(D.mustRemainDirectory&&!F.isDirectory())throw a("validate",`Overlay path changed during ${D.phase}: ${D.overlayRelativePath}. ${v2}`);if(D.mustRemainFile&&!F.isFile())throw a("validate",`Overlay path changed during ${D.phase}: ${D.overlayRelativePath}. ${v2}`);let B=u3(F),$=UX(D.expectedSnapshot,B),Q=!(D.compareContent??!0)?!0:VX(D.expectedSnapshot,B);if(!$||!Q)throw a("validate",`Overlay path changed during ${D.phase}: ${D.overlayRelativePath}. ${v2}`)}async function u8(D,F,B){let _=P8(T6(D,F)).split("/").filter((Y)=>Y.length>0),Q=D;for(let Y of _){Q=z2(Q,Y);let q;try{q=await C2(Q)}catch(H){if(H.code==="ENOENT")return;throw a("validate",`Failed to inspect overlay destination path (${B}): ${TD(H)}`)}if(q.isSymbolicLink())throw a("validate",`Overlay destination path contains existing symlink (${B})`)}}function z5(D,F,B){for(let $ of B)try{new S6(k6($))}catch{throw a("validate",`Invalid project overlay policy at ${D}: ${F} contains invalid glob pattern "${$}"`)}}async function LX(D){if(!D)return{include:[],exclude:[]};let F=z2(D,J2),B=await wX(D,F);if(!B)return{include:[],exclude:[]};let $;try{$=await qX(B,"utf8")}catch(J){throw a("read",`Failed to read project overlay policy at ${F}: ${TD(J)}`)}let _=[],Q=ND($,_,{allowTrailingComma:!0});if(_.length>0)throw a("parse",`Failed to parse project overlay policy at ${F}: ${jX(_)}`);if(!Q||typeof Q!=="object"||Array.isArray(Q))throw a("validate",`Invalid project overlay policy at ${F}: root must be an object`);let Y=EX.safeParse(Q);if(!Y.success){let J=Y.error.issues[0],X=J?.path.length?J.path.join("."):"root",z=J?.message??"Invalid project overlay policy";throw a("validate",`Invalid project overlay policy at ${F}: ${X} ${z}`)}let q=Y.data.include??[],H=Y.data.exclude??[];return z5(F,"include",q),z5(F,"exclude",H),{include:q,exclude:H}}async function wX(D,F){let B;try{B=await C2(F)}catch(Q){let Y=Q.code;if(Y==="ENOENT"||Y==="ENOTDIR")return null;throw a("read",`Failed to inspect project overlay policy at ${F}: ${TD(Q)}`)}if(!B.isSymbolicLink())return F;let $;try{$=await D3(D)}catch(Q){throw a("validate",`Unable to resolve project config directory ${D}: ${TD(Q)}`)}let _;try{_=await D3(F)}catch(Q){let Y=Q.code;if(Y==="ENOENT"||Y==="ENOTDIR")throw a("validate",`Broken symlink in project overlay policy: ${F}`);throw a("read",`Failed to inspect project overlay policy symlink at ${F}: ${TD(Q)}`)}if(!v6($,_))throw a("validate",`Symlink escapes project overlay policy scope: ${F}`);return _}function OX(D,F){for(let B of F.include)if(new S6(k6(B)).match(D))return!0;for(let B of F.exclude)if(new S6(k6(B)).match(D))return!1;return!0}function bX(D,F){return D.filter((B)=>OX(B.overlayRelativePath,F)).map((B)=>({sourcePath:B.sourcePath,destinationRelativePath:B.overlayRelativePath,sourceSnapshot:B.sourceSnapshot}))}async function K5(D,F,B){let $;try{$=await D3(F)}catch(_){let Q=_.code;if(Q==="ENOENT"||Q==="ENOTDIR")throw a("validate",`Broken symlink in project overlay scope: ${B}`);throw a("read",`Failed to inspect symlink at ${B}: ${TD(_)}`)}if(!v6(D,$))throw a("validate",`Symlink escapes project overlay scope: ${B}`);throw a("validate",`Symlink entries are not supported in project overlay scope: ${B}`)}async function U5(D,F,B,$,_){let Q;try{Q=await C2(F)}catch(q){throw a("read",`Failed to inspect project overlay path ${B}: ${TD(q)}`)}if(Q.isSymbolicLink())await K5(D,F,B);let Y=u3(Q);if(Q.isDirectory()){await _.beforeDirectoryRead?.({absolutePath:F,overlayRelativePath:B});let q;try{q=await A5(F)}catch(H){throw a("read",`Failed to read project overlay directory ${B}: ${TD(H)}`)}q.sort((H,J)=>H.localeCompare(J));for(let H of q){let J=z2(F,H),X=P8(z2(B,H));await U5(D,J,X,$,_)}await eF({absolutePath:F,overlayRelativePath:B,expectedSnapshot:Y,phase:"overlay discovery",mustRemainDirectory:!0});return}if(!Q.isFile())return;$.push({sourcePath:F,overlayRelativePath:P8(B),sourceSnapshot:Y})}async function RX(D,F={}){let B;try{B=await D3(D)}catch(Y){throw a("validate",`Unable to resolve project config directory ${D}: ${TD(Y)}`)}let $;try{$=await C2(D)}catch(Y){throw a("validate",`Unable to inspect project overlay root ${D}: ${TD(Y)}`)}if(!$.isDirectory())throw a("validate",`Project overlay root changed before discovery: ${D}. ${v2}`);let _=u3($),Q=[];for(let Y of zX){let q=z2(D,Y);await F.beforeScopeInspect?.({scope:Y,scopeAbsolutePath:q,projectConfigDir:D}),await eF({absolutePath:D,overlayRelativePath:".opencode",expectedSnapshot:_,phase:"overlay discovery",mustRemainDirectory:!0});let H;try{H=await C2(q)}catch(J){let X=J.code;if(X==="ENOENT"||X==="ENOTDIR")continue;throw a("read",`Failed to inspect project overlay scope ${Y}: ${TD(J)}`)}if(H.isSymbolicLink())await K5(B,q,Y);await U5(B,q,Y,Q,F)}return Q.sort((Y,q)=>Y.overlayRelativePath.localeCompare(q.overlayRelativePath)),Q}function ZX(D){let F=I6(D),B=WX(D),$=`${process.pid}-${BX()}`;return z2(F,`.${B}.ocx-tmp-${$}`)}async function NX(D,F){let B=ZX(F);try{await $X(D,B),await HX(B,F)}catch($){try{await XX(B)}catch{}throw $}}async function SX(D,F,B={}){let $=B.publishAtomically??NX,_;try{_=await C2(F)}catch(Y){throw a("validate",`Unable to inspect merged overlay root ${F}: ${TD(Y)}`)}if(!_.isDirectory())throw a("validate",`Merged overlay root is not a directory: ${F}`);let Q=u3(_);for(let Y of D){if(await B.beforeSourceVerification?.(Y),Y.sourceSnapshot)await eF({absolutePath:Y.sourcePath,overlayRelativePath:Y.destinationRelativePath,expectedSnapshot:Y.sourceSnapshot,phase:"overlay source verification",mustRemainFile:!0});await eF({absolutePath:F,overlayRelativePath:".merged",expectedSnapshot:Q,phase:"overlay destination verification",mustRemainDirectory:!0,compareContent:!1});let q;try{q=H0(F,Y.destinationRelativePath)}catch(z){throw a("validate",`Overlay destination path is invalid (${Y.destinationRelativePath}): ${TD(z)}`)}await u8(F,q,Y.destinationRelativePath);let H=I6(q);await B.beforeDestinationParentCreate?.({operation:Y,destinationPath:q,destinationParentPath:H}),await u8(F,q,Y.destinationRelativePath);try{await QX(H,{recursive:!0})}catch(z){throw a("copy",`Failed to copy overlay file ${Y.destinationRelativePath}: ${TD(z)}`)}await u8(F,q,Y.destinationRelativePath);let J;try{J=await C2(H)}catch(z){throw a("validate",`Failed to inspect overlay destination parent (${Y.destinationRelativePath}): ${TD(z)}`)}if(!J.isDirectory())throw a("validate",`Overlay destination parent changed before publish (${Y.destinationRelativePath}). ${v2}`);let X=u3(J);await B.beforeDestinationPublish?.({operation:Y,destinationPath:q,destinationParentPath:H}),await eF({absolutePath:F,overlayRelativePath:".merged",expectedSnapshot:Q,phase:"overlay destination publish",mustRemainDirectory:!0,compareContent:!1}),await eF({absolutePath:H,overlayRelativePath:Y.destinationRelativePath,expectedSnapshot:X,phase:"overlay destination publish",mustRemainDirectory:!0,compareContent:!1}),await u8(F,q,Y.destinationRelativePath);try{await $(Y.sourcePath,q)}catch(z){if(z instanceof c)throw z;throw a("copy",`Failed to copy overlay file ${Y.destinationRelativePath}: ${TD(z)}`)}}}async function kX(D,F){let B;try{B=await A5(D)}catch($){throw a("copy",`Failed to read profile directory ${D}: ${TD($)}`)}for(let $ of B){let _=z2(D,$),Q=z2(F,$);try{await _X(_,Q,{recursive:!0,force:!0,errorOnExist:!1})}catch(Y){throw a("copy",`Failed to copy profile base file ${$}: ${TD(Y)}`)}}}async function M5(D){try{await JX(D,{recursive:!0,force:!0})}catch(F){throw a("cleanup",`Failed to remove temporary merged config directory ${D}: ${TD(F)}`)}}function IX(D,F){let B=P8(T6(D,F));if(!B||B===".")throw a("validate",`Overlay source path failed relative parsing: ${F}`);if(B===".."||B.startsWith("../")||j5(B))throw a("validate",`Overlay source path escapes project overlay scope: ${F}`);return B}function TX(D,F){let B=F.map(($)=>{if(!$.sourceSnapshot)throw a("validate",`Overlay source snapshot missing for ${$.destinationRelativePath}. ${v2}`);return{sourceRelativePath:IX(D,$.sourcePath),destinationRelativePath:$.destinationRelativePath,sourceSnapshot:$.sourceSnapshot}});return{version:AX,projectConfigDir:D,operations:B}}function vX(){return null}async function CX(D){let F=D.manifest.operations.map((B)=>({sourcePath:H0(D.manifest.projectConfigDir,B.sourceRelativePath),destinationRelativePath:B.destinationRelativePath,sourceSnapshot:B.sourceSnapshot}));await SX(F,D.mergedConfigDir,D.copySeams)}async function uX(D){if(D.manifest.operations.length===0)return"best-effort-js";let F=D.nativeHelper??vX();if(F)return await F.applyManifest(D.manifest,D.mergedConfigDir),"native-fd";if(D.hardeningMode==="native-fd-required")throw a("validate",`Native fd helper required for overlay merge, but none is available in this Bun/Node runtime. ${v2}`);return await CX({manifest:D.manifest,mergedConfigDir:D.mergedConfigDir,copySeams:D.copySeams}),"best-effort-js"}async function PX(D){let F=I6(D),B;try{B=await D3(F)}catch(_){throw a("validate",`Unable to resolve project directory ${F}: ${TD(_)}`)}let $;try{$=await D3(D)}catch(_){throw a("validate",`Unable to resolve project config directory ${D}: ${TD(_)}`)}if(!v6(B,$))throw a("validate",`Project .opencode root resolves outside project directory: ${D}`);return $}function xX(D){if(D instanceof c)return D;return a("copy",`Failed to prepare temporary merged config directory: ${TD(D)}`)}async function V5(D){let F=o2(D.projectDir),B=D.hardeningMode??"best-effort-js",$=null;try{$=await YX(z2(GX(),MX)),await kX(D.profileDir,$);let _="best-effort-js";if(F){let Y=await PX(F),q=await LX(Y),H=await RX(Y,D.seams?.collection),J=bX(H,q),X=TX(Y,J);_=await uX({manifest:X,mergedConfigDir:$,hardeningMode:B,copySeams:D.seams?.copy,nativeHelper:D.seams?.nativeHelper})}let Q=$;return{path:Q,cleanup:()=>M5(Q),hardeningLevel:_}}catch(_){let Q=xX(_);if($)try{await M5($)}catch(Y){Q.message=`${Q.message}
130
- Cleanup warning: ${TD(Y)}`}throw Q}}var zX,MX="ocx-oc-merged-",AX=1,v2="Full TOCTOU/symlink-swap hardening requires an fd-based native helper transaction.",EX;var E5=V(()=>{b0();_2();G0();$D();c2();zX=["agent","agents","skill","skills"];EX=W.object({include:W.array(W.string()).optional(),exclude:W.array(W.string()).optional()}).passthrough()});import*as e0 from"path";function yX(D){let F=new Set,B=[];for(let $=D.length-1;$>=0;$--){let _=D[$];if(!F.has(_))F.add(_),B.unshift(_)}return B}function fX(D){return D.configBin??D.envBin??"opencode"}function L5(D){return D.includes("/")||D.includes("\\")}function hX(D){let{configuredBin:F,cwd:B}=D,$=D.resolveExecutable??((Q)=>Bun.which(Q));if(!F.trim())throw Error("OpenCode launcher is empty and cannot be resolved to a stable path");if(L5(F))return e0.isAbsolute(F)?F:e0.resolve(B,F);let _=$(F);if(!_)throw Error(`OpenCode launcher "${F}" is not available in PATH and cannot be used as OPENCODE_BIN`);return e0.isAbsolute(_)?_:e0.resolve(B,_)}function mX(D){let F=D.resolveExecutable??((J)=>Bun.which(J)),B=D.argv??process.argv,$=D.execPath??process.execPath,_=D.isCompiledBinary??(typeof Bun<"u"&&typeof Bun.main==="string"&&Bun.main.startsWith("/$bunfs/")),Q=D.inheritedOcxBin?.trim(),Y=_?$:B[1],q=Q&&Q.length>0?Q:Y;if(!q?.trim())throw Error("OCX executable path is empty and cannot be resolved from the current process");if(L5(q))return e0.isAbsolute(q)?q:e0.resolve(D.cwd,q);let H=F(q);if(!H)throw Error(`OCX executable "${q}" is not available in PATH and cannot be persisted as OCX_BIN`);return e0.isAbsolute(H)?H:e0.resolve(D.cwd,H)}function gX(D){let F=Boolean(D.profileName),{OPENCODE_DISABLE_PROJECT_CONFIG:B,OPENCODE_BIN:$,OCX_CONTEXT:_,OCX_BIN:Q,OCX_PROFILE:Y,...q}=D.baseEnv;return{...q,...D.opencodeBin!==void 0&&{OPENCODE_BIN:D.opencodeBin},...F&&{OPENCODE_DISABLE_PROJECT_CONFIG:"true"},OPENCODE_CONFIG_DIR:D.configDir??(F?yD(D.profileName):X0()),...D.configContent&&{OPENCODE_CONFIG_CONTENT:D.configContent},...F&&{OCX_CONTEXT:"1"},...F&&D.ocxBin&&{OCX_BIN:D.ocxBin},...D.profileName&&{OCX_PROFILE:D.profileName}}}function w5(D){D.command("oc").alias("opencode").description("Launch OpenCode with resolved configuration").option("-p, --profile <name>","Use specific profile").option("--no-rename","Disable terminal/tmux window renaming").allowUnknownOption().allowExcessArguments(!0).action(async(F,B)=>{try{await dX(B.args,F)}catch($){t($)}})}async function dX(D,F){let B=process.cwd(),$=await o0.create(B,{profile:F.profile}),_=$.resolve(),Q=$.getProfile();if(_.profileName)G.info(`Using profile: ${_.profileName}`);let Y=Q?.ocx,q=F.rename!==!1&&Y?.renameWindow!==!1;if(_.profileName){let x=G2(_.profileName);if(!await Bun.file(x).exists())G.warn(`No opencode.jsonc found at ${x}. Create one to customize OpenCode settings.`)}let H=Array.isArray(_.opencode.instructions)?_.opencode.instructions:[],J=[..._.instructions,...H],X=yX(J),z=X.length>0||Object.keys(_.opencode).length>0?{..._.opencode,instructions:X.length>0?X:void 0}:void 0,M=null,A=null,K=null,j=null,S=null,Z=()=>{if(M)M.kill("SIGINT");else S=130},s=()=>{if(M)M.kill("SIGTERM");else S=143},N=()=>{if(q)N6()};try{if(process.on("SIGINT",Z),process.on("SIGTERM",s),process.on("exit",N),S!==null){j=S;return}if(_.profileName)A=await V5({projectDir:B,profileDir:yD(_.profileName)});if(S!==null){j=S;return}if(q){X5();let p=await Q5(B);if(S!==null){j=S;return}J5(G5(B,_.profileName??"default",p))}if(S!==null){j=S;return}let x=fX({configBin:Y?.bin,envBin:process.env.OPENCODE_BIN}),O=Boolean(_.profileName),b=O?hX({configuredBin:x,cwd:B}):x,L=O?mX({cwd:B,inheritedOcxBin:process.env.OCX_BIN}):void 0,e=z?JSON.stringify(z):void 0;try{M=Bun.spawn({cmd:[b,...D],cwd:B,env:gX({baseEnv:process.env,profileName:_.profileName??void 0,ocxBin:L,opencodeBin:b,configDir:A?.path,configContent:e}),stdin:"inherit",stdout:"inherit",stderr:"inherit"})}catch(p){throw a("spawn",`Failed to launch OpenCode binary "${x}": ${p instanceof Error?p.message:String(p)}`)}j=await M.exited}catch(x){K=x instanceof Error?x:a("spawn",`OpenCode process failed: ${String(x)}`)}finally{if(process.off("SIGINT",Z),process.off("SIGTERM",s),process.off("exit",N),q)N6();if(A)try{await A.cleanup()}catch(x){if(K!==null||S!==null||j!==null&&j!==0)G.warn(`Cleanup warning: ${x instanceof Error?x.message:String(x)}`);else K=x instanceof Error?x:a("cleanup",`Failed to remove temporary merged config directory: ${String(x)}`)}}if(K)throw K;if(j!==null)process.exit(j)}var O5=V(()=>{O3();G0();Y5();PD();fD();k2();W5();E5()});import{existsSync as F3}from"fs";import{mkdir as C6,mkdtemp as cX,rename as lX,rm as b5,writeFile as pX}from"fs/promises";import{dirname as R5,join as x8,relative as iX}from"path";function Z5(D,F,B){let $=B instanceof Error?B.message:String(B);return`${D} "${F}" (${$})`}function I5(D,F){let[B,$]=F.split("/");if(!B||!$)return;return`${xD(D)}/components/${$}.json`}function N5(D){if(!D)return null;let[F,B,...$]=D.split("/");if(!F||!B||$.length>0)return null;return{registryName:F,componentName:B}}function nX(D,F){if(!D)return{};let B;try{let Y=new URL(D),q=Y.pathname.match(/(?:^|\/)components\/([^/]+)\.json$/);if(q?.[1])B=decodeURIComponent(q[1]);else{let H=Y.pathname.match(/(?:^|\/)components\/([^/]+)\/.+$/);if(H?.[1])B=decodeURIComponent(H[1])}}catch{}let $=xD(D),_,Q=-1;for(let[Y,q]of Object.entries(F)){let H=xD(q.url);if(!($===H||$.startsWith(`${H}/`))||H.length<=Q)continue;_=Y,Q=H.length}return{registryName:_,componentName:B}}function sX(D){let F=D.depRefs[0]??`${D.namespace}/${D.component}`,B={...D.profileRegistries,...D.profileRegistries[D.namespace]?{}:{[D.namespace]:{url:D.registryUrl}}},$=D.error.registryName,_=D.error.qualifiedName,Q=N5(_);if(!$&&Q)$=Q.registryName;let Y=Q?.componentName,q=_&&!Q&&!_.includes("/")?_:void 0,H=nX(D.error.url,B);if(!$&&H.registryName)$=H.registryName;let J=Y??q??H.componentName;if((!_||!Q)&&$&&J)_=`${$}/${J}`;if(!_)_=F;if(!$)$=N5(_)?.registryName??D.namespace;let X=B[$]?.url||($===D.namespace?D.registryUrl:void 0);return{registryName:$,qualifiedName:_,fallbackUrl:D.error.url||(X?I5(X,_):void 0)}}function S5(D,F){let B=D.phase??F.fallbackPhase,$=D.url??F.fallbackUrl,_=[`phase: ${B}`,`qualifiedName: ${F.qualifiedName}`,`registryContext: ${F.registryContext}`,`registryName: ${F.registryName}`,...$?[`url: ${$}`]:[]];return new RD(`${D.message} (${_.join(", ")})`,{url:$,status:D.status,statusText:D.statusText,phase:B,qualifiedName:F.qualifiedName,registryContext:F.registryContext,registryName:F.registryName})}function k5(D,F){if(!D.startsWith(".opencode/"))throw new U(`Invalid embedded target "${D}": expected .opencode/ prefix for embedded profile files.`);let B=D.slice(10);if(!B)throw new U(`Invalid embedded target "${D}": missing path after .opencode/ prefix.`);let $;try{$=H0(F,B)}catch(Q){if(Q instanceof aD)throw new U(`Invalid embedded target "${D}": ${Q.message}`);throw Q}let _=iX(F,$).replace(/\\/g,"/");if(_==="."||_==="")throw new U(`Invalid embedded target "${D}": target must resolve to a file path.`);return _}async function u6(D){let{namespace:F,component:B,profileName:$,registryUrl:_,quiet:Q}=D;if(!s0.safeParse($).success)throw new U(`Invalid profile name: "${$}". Profile names must start with a letter and contain only alphanumeric characters, dots, underscores, or hyphens.`);let q;if(F)q=F;else throw new U(`Registry name is required for URL-based profile installs.
127
+ `,{mode:384}),B.push("profileAgents");if(F?.succeed("Initialized global profiles"),D.json)console.log(JSON.stringify({success:!0,files:{globalConfig:_,profileOcx:q,profileOpencode:H,profileAgents:J},created:B,existed:$}));else if(!D.quiet)if(B.length>0){for(let X of B){if(X==="globalConfig")W.info(`Created global config: ${_}`);if(X==="profileOcx")W.info(`Created profile config: ${q}`);if(X==="profileOpencode")W.info(`Created profile opencode config: ${H}`);if(X==="profileAgents")W.info(`Created profile instructions: ${J}`)}W.info(""),W.info("Next steps:"),W.info(" 1. Edit your profile config: ocx config edit -p default"),W.info(" 2. Add registries: ocx registry add <url> --name <name> --global"),W.info(" 3. Launch OpenCode: ocx opencode"),W.info(" 4. Create more profiles: ocx profile add <name> --global")}else W.info("Global profiles already initialized (all files exist)")}catch(B){throw F?.fail("Failed to initialize"),B}}async function RJ(D,F){let B=D,$=F.namespace??"my-registry",_=F.author??"Your Name";if(!/^[a-z0-9]+(-[a-z0-9]+)*$/.test($))throw new U("Invalid namespace format: must start with letter/number, use hyphens only between segments (e.g., 'my-registry')");if((await aB(B).catch(()=>[])).some((H)=>!H.startsWith(".")))throw new dD("Directory is not empty. Remove existing files or choose a different directory.");let q=F.quiet?null:jD({text:"Scaffolding registry..."});q?.start();try{if(q)q.text=F.local?"Copying template...":"Fetching template...";if(F.local)await tF(B,{recursive:!0}),await tB(F.local,B);else{let H=F.canary?"main":NJ();await kJ(B,H,F.verbose)}if(q)q.text="Configuring project...";if(await TJ(B,{namespace:$,author:_}),q?.succeed(`Created registry: ${$}`),F.json)console.log(JSON.stringify({success:!0,namespace:$,path:B}));else if(!F.quiet)W.info(""),W.info("Next steps:"),W.info(" 1. bun install"),W.info(" 2. Edit registry.jsonc with your components"),W.info(" 3. bun run build"),W.info(""),W.info("Deploy to:"),W.info(" Cloudflare: bunx wrangler deploy"),W.info(" Vercel: vercel"),W.info(" Netlify: netlify deploy")}catch(H){throw q?.fail("Failed to scaffold registry"),H}}async function tB(D,F){await VJ(D,F,{recursive:!0})}function NJ(){return"v2.0.4"}function SJ(D){let F=D==="main"?"heads/main":`tags/${D}`;return`https://github.com/${wJ}/archive/refs/${F}.tar.gz`}async function kJ(D,F,B){let $=SJ(F);if(B)W.info(`Fetching ${$}`);let _=await fetch($);if(!_.ok||!_.body)throw new ZD(`Failed to fetch template from ${$}: ${_.statusText}`);let Q=I8(D,".ocx-temp");await tF(Q,{recursive:!0});try{let Y=I8(Q,"template.tar.gz"),q=await _.arrayBuffer();await N6(Y,Buffer.from(q));let H=Bun.spawn(["tar","-xzf",Y,"-C",Q],{stdout:"ignore",stderr:"pipe"});if(await H.exited!==0){let A=await new Response(H.stderr).text();throw Error(`Failed to extract template: ${A}`)}let z=(await aB(Q)).find((A)=>A.startsWith("ocx-"));if(!z)throw Error("Failed to find extracted template directory");let M=I8(Q,z,OJ);await tB(M,D)}finally{await LJ(Q,{recursive:!0,force:!0})}}function IJ(D){return D.split(/[-_\s]+/).map((F)=>F.charAt(0).toUpperCase()+F.slice(1).toLowerCase()).join(" ")}async function TJ(D,F){let B=["registry.jsonc","package.json","wrangler.jsonc","README.md","AGENTS.md"];for(let $ of B){let _=I8(D,$);if(!YF(_))continue;let Q=await EJ(_).then((Y)=>Y.toString());if(Q=Q.replace(/my-registry/g,F.namespace),Q=Q.replace(/My Registry/g,IJ(F.namespace)),Q=Q.replace(/Your Name/g,F.author),$==="registry.jsonc")if(/"\$schema"\s*:/.test(Q))Q=Q.replace(/("\$schema"\s*:\s*")[^"]*(")/,`$1${T0}$2`);else Q=Q.replace(/{/,`{
128
+ "$schema": "${T0}",`);await N6(_,Q)}}var wJ="kdcokenny/ocx",OJ="examples/registry-starter";var eB=V(()=>{a3();Q8();o0();Q0();eD();n1();$D();yD();hD();x0();g0()});function vJ(D,F,B){let $=D.indexOf("/");if($===-1)throw Error(`Invalid legacy key: "${D}". Expected format: alias/component`);let _=D.slice(0,$),Q=D.slice($+1);if(!_||!Q)throw Error(`Invalid legacy key: "${D}". Both alias and component are required.`);let Y=L3(B,_,Q,F.version),q={registryUrl:B,registryName:_,name:Q,revision:F.version,hash:F.hash,files:F.files.map((H)=>({path:H,hash:""})),installedAt:F.installedAt,...F.updatedAt&&{updatedAt:F.updatedAt},owner:{type:"user"}};return[Y,q]}function T8(D,F,B){let $={},_=[],Q=Object.keys(D.installed).sort();for(let q of Q){let H=D.installed[q];if(!H)continue;let J=F.registries[H.registry];if(!J)throw new c(`Registry "${H.registry}" referenced in lock key "${q}" is not configured in ocx.jsonc. Add it before migrating.`);let[X,z]=vJ(q,H,J.url);$[X]=z,_.push({legacyKey:q,canonicalId:X,name:z.name,registryName:z.registryName})}return{receipt:{version:1,...B&&{root:B},installed:$},components:_}}function D5(D){let F=D.registries;if(!F||typeof F!=="object"||Array.isArray(F))return[];let B=[],$=F;for(let _ of Object.keys($).sort()){let Q=$[_];if(!Q||typeof Q!=="object"||Array.isArray(Q))continue;let Y=Q;for(let q of CJ)if(q in Y)B.push({registry:_,field:q,action:"remove_deprecated"})}return B}var CJ;var F5=V(()=>{eD();$D();CJ=["version"]});import{existsSync as S6,readdirSync as uJ,readFileSync as Q5,statSync as PJ}from"fs";import{rename as v8,writeFile as yJ}from"fs/promises";import{join as B5}from"path";function Y5(D){D.command("migrate").description("Migrate legacy ocx.lock to receipt format (.ocx/receipt.jsonc)").option("--global","Migrate global config scope (includes profiles)").option("--apply","Apply migration (default is dry-run preview)").option("--json","Output as JSON").option("-q, --quiet","Suppress output").option("--cwd <path>","Working directory").action(async(F)=>{try{await fJ(F)}catch(B){t(B,{json:F.json})}})}async function fJ(D){if(D.global){await hJ(D);return}await rJ(D,"local",FX(D),!1)}async function hJ(D){let F=D.cwd??W0(),B=mJ(F);if(!D.apply){let Y=[],q=new Set;for(let{label:X,path:z}of B){let M=N2(z),A=xF(z,{isFlattened:!0});if(M.exists&&A.exists)q.add(X);try{let K=await gJ(z,!0,{emitWarnings:!D.json&&!D.quiet});Y.push({...K,target:X})}catch(K){let j=_5(X,K);if(Y.push(j),!D.json&&!D.quiet)W.error(`[global:${X}] Preview failed: ${j.error}`)}}let H=$5(Y,"global",!1),J=cJ(H);if(D.json){if(eF(H,!1),J)process.exit(1);return}if(!D.quiet)tJ(Y,H,q);if(J)process.exit(1);return}let $=[],_=!1;for(let{label:Y,path:q}of B)try{let H=await dJ(q,!0);$.push({...H,target:Y})}catch(H){_=!0;let J=_5(Y,H);if($.push(J),!D.json&&!D.quiet)W.error(`[global:${Y}] Migration failed: ${J.error}`)}let Q=$5($,"global",!0);if(D.json){if(eF(Q,!0),_)process.exit(1);return}if(!D.quiet)eJ($,_);if(_)process.exit(1)}function mJ(D){let F=[];F.push({label:"root",path:D});let B=B5(D,"profiles");if(S6(B)&&PJ(B).isDirectory()){let _=uJ(B,{withFileTypes:!0}).filter((Q)=>Q.isDirectory()&&!Q.name.startsWith(".")).map((Q)=>Q.name).sort();for(let Q of _)F.push({label:`profile:${Q}`,path:B5(B,Q)})}return F}async function gJ(D,F,B){let $=B?.emitWarnings??!0,_=k6(D),Q=N2(D),Y=xF(D,{isFlattened:F}),q=Q.exists&&Y.exists;if(Q.exists&&_.length===0&&!q)return{status:"already_v2",count:0,components:[],configActions:[]};if(!Y.exists&&!Q.exists&&_.length===0)return{status:"nothing_to_migrate",count:0,components:[],configActions:[]};let H=[];if(Y.exists&&!Q.exists)try{let J=await w3(D,{isFlattened:F}),X=await K0(D,{emitParseDiagnostics:$});if(J&&X)H=T8(J,X,D).components}catch{if($)W.warn(`[preview] Could not parse lock/config at "${D}"; component count may be incomplete.`)}return{status:"preview",count:H.length,components:H,configActions:_}}async function dJ(D,F){let B=k6(D),$=N2(D),_=xF(D,{isFlattened:F}),Q=$.exists&&_.exists;if($.exists&&B.length===0&&!Q)return{status:"already_v2",count:0,components:[],configActions:[]};if(!_.exists&&!$.exists&&B.length===0)return{status:"nothing_to_migrate",count:0,components:[],configActions:[]};let Y=null;if(_.exists&&!$.exists){let X=await w3(D,{isFlattened:F});if(!X)throw new U("Failed to parse ocx.lock. The lock file exists but could not be read or contains invalid data.");let z=await K0(D);if(!z)throw new c("No ocx.jsonc found. The config is required to resolve registry URLs during migration.");let{receipt:M,components:A}=T8(X,z,D);Y={newReceipt:M,components:A}}let q=Y?.components??[],H=q.length;if(Y){await j0(D,Y.newReceipt);let X=C8(_.path);await v8(_.path,X)}if(Q){let X=C8(_.path);await v8(_.path,X)}if(B.length>0)await q5(D,B);return{status:Y!==null||Q||B.length>0?"migrated":"already_v2",count:H,components:q,configActions:B}}function $5(D,F,B){let $=D.some((X)=>X.status==="error"),_=D.some((X)=>X.status==="migrated"||X.status==="preview"),Q=D.every((X)=>X.status==="already_v2"||X.status==="nothing_to_migrate"),Y=D.reduce((X,z)=>X+z.count,0),q=D.flatMap((X)=>X.components),H=D.flatMap((X)=>X.configActions),J;if($)J=B?"partial_failure":"preview_with_errors";else if(Q)J=D.every((z)=>z.status==="nothing_to_migrate")?"nothing_to_migrate":"already_v2";else if(B)J=_?"migrated":"already_v2";else J=_?"preview":"already_v2";return{success:!$,status:J,scope:F,count:Y,components:q,configActions:H,targets:D}}function cJ(D){return D.status==="preview_with_errors"}function eF(D,F){let B=lJ(D,F);console.log(JSON.stringify(B,null,2))}function lJ(D,F){let B=pJ(D),$=B.flatMap((_)=>_.blockers??[]);return{...D,lifecycle_status:sJ(D.status,F),schema_version:xJ,blockers:$,targets:B}}function pJ(D){return(D.targets&&D.targets.length>0?D.targets:[iJ(D)]).map((B)=>nJ(B))}function iJ(D){return{target:D.scope,status:D.status,count:D.count,components:D.components,configActions:D.configActions,blockers:D.blockers??[]}}function nJ(D){let F=D.blockers??(D.status==="error"?[{code:"MIGRATE_BLOCKER",message:D.error??"Migration blocked",path:D.target}]:[]);return{...D,scope:D.scope??D.target,result:D.result??D.status,blockers:F}}function sJ(D,F){if(F)return D==="partial_failure"?"apply_failed":"apply_ok";return D==="preview_with_errors"?"preview_blocked":"preview_ok"}function _5(D,F){let B=aJ(F,D);return{target:D,status:"error",count:0,components:[],configActions:[],error:B.message,blockers:[B]}}function aJ(D,F){let B=D instanceof Error?D.message:String(D);return{code:oJ(D,B),message:B,path:F}}function oJ(D,F){if(typeof D==="object"&&D!==null&&"code"in D){let $=D.code;if(typeof $==="string"&&$.length>0)return $}let B=F.toLowerCase();if(B.includes("ocx.jsonc")||B.includes("registry"))return"CONFIG_ERROR";if(B.includes("parse")||B.includes("invalid"))return"VALIDATION_ERROR";return"MIGRATE_BLOCKER"}async function rJ(D,F,B,$){let _=k6(B),Q=N2(B),Y=xF(B,{isFlattened:$}),q=Q.exists&&Y.exists;if(Q.exists&&_.length===0&&!q){let A={success:!0,status:"already_v2",scope:F,count:0,components:[],configActions:[]};if(D.json){eF(A,Boolean(D.apply));return}if(!D.quiet)W.success(`[${F}] Already migrated to receipt format (.ocx/receipt.jsonc).`);return}if(!Y.exists&&!Q.exists&&_.length===0){let A={success:!0,status:"nothing_to_migrate",scope:F,count:0,components:[],configActions:[]};if(D.json){eF(A,Boolean(D.apply));return}if(!D.quiet)W.info(`[${F}] Nothing to migrate. No legacy ocx.lock found.`);return}let H=null;if(Y.exists&&!Q.exists){let A=await w3(B,{isFlattened:$});if(!A)throw new U("Failed to parse ocx.lock. The lock file exists but could not be read or contains invalid data.");let K=await K0(B);if(!K)throw new c("No ocx.jsonc found. The config is required to resolve registry URLs during migration.");let{receipt:j,components:S}=T8(A,K,B);H={newReceipt:j,components:S}}let J=H?.components??[],X=J.length;if(!D.apply){let A={success:!0,status:"preview",scope:F,count:X,components:J,configActions:_};if(D.json){eF(A,!1);return}if(!D.quiet){if(X>0){W.info(`[${F}] Migration preview: ${X} component(s) would be migrated.`),W.break();for(let K of J)W.info(` ${K.legacyKey} \u2192 ${K.canonicalId}`);W.break()}if(q)W.info(`[${F}] Legacy ocx.lock would be backed up and removed (receipt already exists).`),W.break();if(_.length>0){W.info(`[${F}] Config normalization: ${_.length} deprecated field(s) would be removed.`);for(let K of _)W.info(` registries.${K.registry}.${K.field} \u2192 remove`);W.break()}if(X===0&&_.length===0&&!q)W.info(`[${F}] Nothing to migrate.`);else W.info("No changes made. Run with --apply to perform migration.")}return}if(H){await j0(B,H.newReceipt);let A=C8(Y.path);if(await v8(Y.path,A),!D.json&&!D.quiet){W.success(`[${F}] Migrated ${X} component(s) to receipt format (.ocx/receipt.jsonc).`),W.break();for(let K of J)W.success(` \u2713 ${K.legacyKey} \u2192 ${K.canonicalId}`);W.break(),W.info(`Legacy lock backed up to: ${A}`)}}if(q){let A=C8(Y.path);if(await v8(Y.path,A),!D.json&&!D.quiet)W.success(`[${F}] Removed stale legacy lock (receipt already exists).`),W.info(`Legacy lock backed up to: ${A}`)}if(_.length>0){if(await q5(B,_),!D.json&&!D.quiet){if(H)W.break();W.success(`[${F}] Normalized ${_.length} deprecated config field(s).`);for(let A of _)W.success(` \u2713 registries.${A.registry}.${A.field} removed`)}}let M={success:!0,status:H!==null||q||_.length>0?"migrated":"already_v2",scope:F,count:X,components:J,configActions:_};if(D.json){eF(M,!0);return}if(!H&&_.length>0&&!D.quiet)W.break(),W.success(`[${F}] Config normalization complete.`)}function tJ(D,F,B){if(F.status==="nothing_to_migrate"){W.info("[global] Nothing to migrate across all targets.");return}if(F.status==="already_v2"){W.success("[global] All targets already migrated.");return}W.info(`[global] Migration preview across ${D.length} target(s):`),W.break();for(let $ of D){let _=B.has($.target),Q=DX($,_);W.info(` ${$.target}: ${Q}`)}if(W.break(),F.status==="preview_with_errors")W.warn("[global] Preview completed with errors on some targets. See above for details."),W.info("No changes made. Run with --apply to perform migration.");else W.info("No changes made. Run with --apply to perform migration.")}function eJ(D,F){W.break();let B=D.filter((Q)=>Q.status==="migrated"),$=D.filter((Q)=>Q.status==="already_v2"||Q.status==="nothing_to_migrate"),_=D.filter((Q)=>Q.status==="error");if(B.length>0){W.success(`[global] Migrated ${B.length} target(s):`);for(let Q of B)W.success(` \u2713 ${Q.target}`)}if($.length>0)W.info(`[global] ${$.length} target(s) already up to date.`);if(_.length>0){W.error(`[global] ${_.length} target(s) failed:`);for(let Q of _)W.error(` \u2717 ${Q.target}: ${Q.error}`)}if(F)W.break(),W.error("[global] Migration completed with errors. See above for details.")}function DX(D,F){if(D.status==="error")return"error";if(D.status==="already_v2")return"already migrated";if(D.status==="nothing_to_migrate")return"nothing to migrate";let B=[];if(D.count>0)B.push(`${D.count} component(s) to migrate`);if(D.configActions.length>0)B.push(`${D.configActions.length} config field(s) to normalize`);if(F)B.push("legacy lock cleanup pending");if(B.length===0)return"nothing to migrate";return B.join(", ")}function FX(D){if(D.global)return D.cwd??W0();return D.cwd??process.cwd()}function C8(D){let F=`${D}.bak`;if(!S6(F))return F;for(let B=1;B<=100;B++){let $=`${F}.${B}`;if(!S6($))return $}return`${F}.${Date.now()}`}function k6(D){let F=S2(D);if(!F.exists)return[];try{let B=Q5(F.path,"utf-8"),$=ND(B,[],{allowTrailingComma:!0});if(!$||typeof $!=="object"||Array.isArray($))return[];return D5($)}catch{return[]}}async function q5(D,F){if(F.length===0)return;let B=S2(D);if(!B.exists)return;let $=Q5(B.path,"utf-8");for(let _ of F){let Q=AF($,["registries",_.registry,_.field],void 0,BX);$=jF($,Q)}await yJ(B.path,$)}var xJ=1,BX;var H5=V(()=>{b0();eD();$D();yD();hD();k2();F5();BX={formattingOptions:{tabSize:2,insertSpaces:!0,eol:`
129
+ `}}});import{basename as $X,resolve as hV}from"path";function u8(){let{GIT_DIR:D,GIT_WORK_TREE:F,...B}=process.env;return B}async function _X(D){let F=Bun.spawn(["git","symbolic-ref","--short","HEAD"],{cwd:D,env:u8(),stdout:"pipe",stderr:"pipe"});if(await F.exited===0){let H=(await new Response(F.stdout).text()).trim();if(H)return H}let $=Bun.spawn(["git","describe","--tags","--exact-match","HEAD"],{cwd:D,env:u8(),stdout:"pipe",stderr:"pipe"});if(await $.exited===0){let H=(await new Response($.stdout).text()).trim();if(H)return H}let Q=Bun.spawn(["git","rev-parse","--short","HEAD"],{cwd:D,env:u8(),stdout:"pipe",stderr:"pipe"});if(await Q.exited===0){let H=(await new Response(Q.stdout).text()).trim();if(H)return H}return null}async function QX(D){let F=Bun.spawn(["git","rev-parse","--show-toplevel"],{cwd:D,env:u8(),stdout:"pipe",stderr:"pipe"});if(await F.exited!==0)return null;let _=(await new Response(F.stdout).text()).trim();if(!_)return null;return $X(_)}async function J5(D){let[F,B]=await Promise.all([QX(D),_X(D)]);return{repoName:F,branch:B}}var X5=()=>{};import YX from"path";function G5(){return Boolean(process.env.TMUX)}function qX(D){if(!G5())return;Bun.spawnSync(["tmux","rename-window",D]),Bun.spawnSync(["tmux","set-window-option","automatic-rename","off"])}function HX(D){if(!FF)return;process.stdout.write(`\x1B]0;${D}\x07`)}function z5(D){qX(D),HX(D)}function M5(){if(P8||!FF)return;process.stdout.write("\x1B[22;2t"),P8=!0}function I6(){if(!P8)return;if(G5())Bun.spawnSync(["tmux","set-window-option","automatic-rename","on"]);if(FF)process.stdout.write("\x1B[23;2t");P8=!1}function A5(D,F,B){let $=B.repoName??YX.basename(D);if(!B.branch)return`ocx[${F}]:${$}`;let _=B.branch.length>W5?`${B.branch.slice(0,W5-3)}...`:B.branch;return`ocx[${F}]:${$}/${_}`}var W5=20,P8=!1;var j5=V(()=>{N3()});import{randomUUID as JX}from"crypto";import{copyFile as XX,cp as WX,lstat as C2,mkdir as GX,mkdtemp as zX,readdir as V5,readFile as MX,realpath as F3,rename as AX,rm as jX,unlink as KX}from"fs/promises";import{tmpdir as UX}from"os";import{basename as VX,dirname as C6,isAbsolute as E5,join as z2,relative as u6}from"path";var{Glob:T6}=globalThis.Bun;function a(D,F){return new c(`ocx oc ${D} error: ${F}`)}function TD(D){if(D instanceof Error)return D.message;return String(D)}function OX(D){if(D.length===0)return"Unknown parse error";let F=D[0];if(!F)return"Unknown parse error";return`${K2(F.error)} at offset ${F.offset}`}function x8(D){return D.replaceAll("\\","/")}function v6(D){return D.startsWith("./")?D.slice(2):D}function P6(D,F){let B=u6(D,F);if(B.length===0)return!0;return!B.startsWith("..")&&!E5(B)}function bX(D){if(D.isFile())return"file";if(D.isDirectory())return"directory";if(D.isSymbolicLink())return"symlink";return"other"}function P3(D){return{entryType:bX(D),device:String(D.dev),inode:String(D.ino),mode:String(D.mode),size:String(D.size),mtimeMs:String(D.mtimeMs)}}function ZX(D,F){return D.entryType===F.entryType&&D.device===F.device&&D.inode===F.inode&&D.mode===F.mode}function RX(D,F){return D.size===F.size&&D.mtimeMs===F.mtimeMs}async function D3(D){let F;try{F=await C2(D.absolutePath)}catch{throw a("validate",`Overlay path changed during ${D.phase}: ${D.overlayRelativePath}. ${v2}`)}if(D.mustRemainDirectory&&!F.isDirectory())throw a("validate",`Overlay path changed during ${D.phase}: ${D.overlayRelativePath}. ${v2}`);if(D.mustRemainFile&&!F.isFile())throw a("validate",`Overlay path changed during ${D.phase}: ${D.overlayRelativePath}. ${v2}`);let B=P3(F),$=ZX(D.expectedSnapshot,B),Q=!(D.compareContent??!0)?!0:RX(D.expectedSnapshot,B);if(!$||!Q)throw a("validate",`Overlay path changed during ${D.phase}: ${D.overlayRelativePath}. ${v2}`)}async function y8(D,F,B){let _=x8(u6(D,F)).split("/").filter((Y)=>Y.length>0),Q=D;for(let Y of _){Q=z2(Q,Y);let q;try{q=await C2(Q)}catch(H){if(H.code==="ENOENT")return;throw a("validate",`Failed to inspect overlay destination path (${B}): ${TD(H)}`)}if(q.isSymbolicLink())throw a("validate",`Overlay destination path contains existing symlink (${B})`)}}function K5(D,F,B){for(let $ of B)try{new T6(v6($))}catch{throw a("validate",`Invalid project overlay policy at ${D}: ${F} contains invalid glob pattern "${$}"`)}}async function SX(D){if(!D)return{include:[],exclude:[]};let F=z2(D,y0),B=await kX(D,F);if(!B)return{include:[],exclude:[]};let $;try{$=await MX(B,"utf8")}catch(J){throw a("read",`Failed to read project overlay policy at ${F}: ${TD(J)}`)}let _=[],Q=ND($,_,{allowTrailingComma:!0});if(_.length>0)throw a("parse",`Failed to parse project overlay policy at ${F}: ${OX(_)}`);if(!Q||typeof Q!=="object"||Array.isArray(Q))throw a("validate",`Invalid project overlay policy at ${F}: root must be an object`);let Y=NX.safeParse(Q);if(!Y.success){let J=Y.error.issues[0],X=J?.path.length?J.path.join("."):"root",z=J?.message??"Invalid project overlay policy";throw a("validate",`Invalid project overlay policy at ${F}: ${X} ${z}`)}let q=Y.data.include??[],H=Y.data.exclude??[];return K5(F,"include",q),K5(F,"exclude",H),{include:q,exclude:H}}async function kX(D,F){let B;try{B=await C2(F)}catch(Q){let Y=Q.code;if(Y==="ENOENT"||Y==="ENOTDIR")return null;throw a("read",`Failed to inspect project overlay policy at ${F}: ${TD(Q)}`)}if(!B.isSymbolicLink())return F;let $;try{$=await F3(D)}catch(Q){throw a("validate",`Unable to resolve project config directory ${D}: ${TD(Q)}`)}let _;try{_=await F3(F)}catch(Q){let Y=Q.code;if(Y==="ENOENT"||Y==="ENOTDIR")throw a("validate",`Broken symlink in project overlay policy: ${F}`);throw a("read",`Failed to inspect project overlay policy symlink at ${F}: ${TD(Q)}`)}if(!P6($,_))throw a("validate",`Symlink escapes project overlay policy scope: ${F}`);return _}function IX(D,F){for(let B of F.include)if(new T6(v6(B)).match(D))return!0;for(let B of F.exclude)if(new T6(v6(B)).match(D))return!1;return!0}function TX(D,F){return D.filter((B)=>IX(B.overlayRelativePath,F)).map((B)=>({sourcePath:B.sourcePath,destinationRelativePath:B.overlayRelativePath,sourceSnapshot:B.sourceSnapshot}))}async function L5(D,F,B){let $;try{$=await F3(F)}catch(_){let Q=_.code;if(Q==="ENOENT"||Q==="ENOTDIR")throw a("validate",`Broken symlink in project overlay scope: ${B}`);throw a("read",`Failed to inspect symlink at ${B}: ${TD(_)}`)}if(!P6(D,$))throw a("validate",`Symlink escapes project overlay scope: ${B}`);throw a("validate",`Symlink entries are not supported in project overlay scope: ${B}`)}async function w5(D,F,B,$,_){let Q;try{Q=await C2(F)}catch(q){throw a("read",`Failed to inspect project overlay path ${B}: ${TD(q)}`)}if(Q.isSymbolicLink())await L5(D,F,B);let Y=P3(Q);if(Q.isDirectory()){await _.beforeDirectoryRead?.({absolutePath:F,overlayRelativePath:B});let q;try{q=await V5(F)}catch(H){throw a("read",`Failed to read project overlay directory ${B}: ${TD(H)}`)}q.sort((H,J)=>H.localeCompare(J));for(let H of q){let J=z2(F,H),X=x8(z2(B,H));await w5(D,J,X,$,_)}await D3({absolutePath:F,overlayRelativePath:B,expectedSnapshot:Y,phase:"overlay discovery",mustRemainDirectory:!0});return}if(!Q.isFile())return;$.push({sourcePath:F,overlayRelativePath:x8(B),sourceSnapshot:Y})}async function vX(D,F={}){let B;try{B=await F3(D)}catch(Y){throw a("validate",`Unable to resolve project config directory ${D}: ${TD(Y)}`)}let $;try{$=await C2(D)}catch(Y){throw a("validate",`Unable to inspect project overlay root ${D}: ${TD(Y)}`)}if(!$.isDirectory())throw a("validate",`Project overlay root changed before discovery: ${D}. ${v2}`);let _=P3($),Q=[];for(let Y of EX){let q=z2(D,Y);await F.beforeScopeInspect?.({scope:Y,scopeAbsolutePath:q,projectConfigDir:D}),await D3({absolutePath:D,overlayRelativePath:".opencode",expectedSnapshot:_,phase:"overlay discovery",mustRemainDirectory:!0});let H;try{H=await C2(q)}catch(J){let X=J.code;if(X==="ENOENT"||X==="ENOTDIR")continue;throw a("read",`Failed to inspect project overlay scope ${Y}: ${TD(J)}`)}if(H.isSymbolicLink())await L5(B,q,Y);await w5(B,q,Y,Q,F)}return Q.sort((Y,q)=>Y.overlayRelativePath.localeCompare(q.overlayRelativePath)),Q}function CX(D){let F=C6(D),B=VX(D),$=`${process.pid}-${JX()}`;return z2(F,`.${B}.ocx-tmp-${$}`)}async function uX(D,F){let B=CX(F);try{await XX(D,B),await AX(B,F)}catch($){try{await KX(B)}catch{}throw $}}async function PX(D,F,B={}){let $=B.publishAtomically??uX,_;try{_=await C2(F)}catch(Y){throw a("validate",`Unable to inspect merged overlay root ${F}: ${TD(Y)}`)}if(!_.isDirectory())throw a("validate",`Merged overlay root is not a directory: ${F}`);let Q=P3(_);for(let Y of D){if(await B.beforeSourceVerification?.(Y),Y.sourceSnapshot)await D3({absolutePath:Y.sourcePath,overlayRelativePath:Y.destinationRelativePath,expectedSnapshot:Y.sourceSnapshot,phase:"overlay source verification",mustRemainFile:!0});await D3({absolutePath:F,overlayRelativePath:".merged",expectedSnapshot:Q,phase:"overlay destination verification",mustRemainDirectory:!0,compareContent:!1});let q;try{q=J0(F,Y.destinationRelativePath)}catch(z){throw a("validate",`Overlay destination path is invalid (${Y.destinationRelativePath}): ${TD(z)}`)}await y8(F,q,Y.destinationRelativePath);let H=C6(q);await B.beforeDestinationParentCreate?.({operation:Y,destinationPath:q,destinationParentPath:H}),await y8(F,q,Y.destinationRelativePath);try{await GX(H,{recursive:!0})}catch(z){throw a("copy",`Failed to copy overlay file ${Y.destinationRelativePath}: ${TD(z)}`)}await y8(F,q,Y.destinationRelativePath);let J;try{J=await C2(H)}catch(z){throw a("validate",`Failed to inspect overlay destination parent (${Y.destinationRelativePath}): ${TD(z)}`)}if(!J.isDirectory())throw a("validate",`Overlay destination parent changed before publish (${Y.destinationRelativePath}). ${v2}`);let X=P3(J);await B.beforeDestinationPublish?.({operation:Y,destinationPath:q,destinationParentPath:H}),await D3({absolutePath:F,overlayRelativePath:".merged",expectedSnapshot:Q,phase:"overlay destination publish",mustRemainDirectory:!0,compareContent:!1}),await D3({absolutePath:H,overlayRelativePath:Y.destinationRelativePath,expectedSnapshot:X,phase:"overlay destination publish",mustRemainDirectory:!0,compareContent:!1}),await y8(F,q,Y.destinationRelativePath);try{await $(Y.sourcePath,q)}catch(z){if(z instanceof c)throw z;throw a("copy",`Failed to copy overlay file ${Y.destinationRelativePath}: ${TD(z)}`)}}}async function yX(D,F){let B;try{B=await V5(D)}catch($){throw a("copy",`Failed to read profile directory ${D}: ${TD($)}`)}for(let $ of B){let _=z2(D,$),Q=z2(F,$);try{await WX(_,Q,{recursive:!0,force:!0,errorOnExist:!1})}catch(Y){throw a("copy",`Failed to copy profile base file ${$}: ${TD(Y)}`)}}}async function U5(D){try{await jX(D,{recursive:!0,force:!0})}catch(F){throw a("cleanup",`Failed to remove temporary merged config directory ${D}: ${TD(F)}`)}}function xX(D,F){let B=x8(u6(D,F));if(!B||B===".")throw a("validate",`Overlay source path failed relative parsing: ${F}`);if(B===".."||B.startsWith("../")||E5(B))throw a("validate",`Overlay source path escapes project overlay scope: ${F}`);return B}function fX(D,F){let B=F.map(($)=>{if(!$.sourceSnapshot)throw a("validate",`Overlay source snapshot missing for ${$.destinationRelativePath}. ${v2}`);return{sourceRelativePath:xX(D,$.sourcePath),destinationRelativePath:$.destinationRelativePath,sourceSnapshot:$.sourceSnapshot}});return{version:wX,projectConfigDir:D,operations:B}}function hX(){return null}async function mX(D){let F=D.manifest.operations.map((B)=>({sourcePath:J0(D.manifest.projectConfigDir,B.sourceRelativePath),destinationRelativePath:B.destinationRelativePath,sourceSnapshot:B.sourceSnapshot}));await PX(F,D.mergedConfigDir,D.copySeams)}async function gX(D){if(D.manifest.operations.length===0)return"best-effort-js";let F=D.nativeHelper??hX();if(F)return await F.applyManifest(D.manifest,D.mergedConfigDir),"native-fd";if(D.hardeningMode==="native-fd-required")throw a("validate",`Native fd helper required for overlay merge, but none is available in this Bun/Node runtime. ${v2}`);return await mX({manifest:D.manifest,mergedConfigDir:D.mergedConfigDir,copySeams:D.copySeams}),"best-effort-js"}async function dX(D){let F=C6(D),B;try{B=await F3(F)}catch(_){throw a("validate",`Unable to resolve project directory ${F}: ${TD(_)}`)}let $;try{$=await F3(D)}catch(_){throw a("validate",`Unable to resolve project config directory ${D}: ${TD(_)}`)}if(!P6(B,$))throw a("validate",`Project .opencode root resolves outside project directory: ${D}`);return $}function cX(D){if(D instanceof c)return D;return a("copy",`Failed to prepare temporary merged config directory: ${TD(D)}`)}async function O5(D){let F=o2(D.projectDir),B=D.hardeningMode??"best-effort-js",$=null;try{$=await zX(z2(UX(),LX)),await yX(D.profileDir,$);let _="best-effort-js";if(F){let Y=await dX(F),q=await SX(Y),H=await vX(Y,D.seams?.collection),J=TX(H,q),X=fX(Y,J);_=await gX({manifest:X,mergedConfigDir:$,hardeningMode:B,copySeams:D.seams?.copy,nativeHelper:D.seams?.nativeHelper})}let Q=$;return{path:Q,cleanup:()=>U5(Q),hardeningLevel:_}}catch(_){let Q=cX(_);if($)try{await U5($)}catch(Y){Q.message=`${Q.message}
130
+ Cleanup warning: ${TD(Y)}`}throw Q}}var EX,LX="ocx-oc-merged-",wX=1,v2="Full TOCTOU/symlink-swap hardening requires an fd-based native helper transaction.",NX;var b5=V(()=>{b0();Q2();Q0();$D();c2();EX=["agent","agents","skill","skills"];NX=G.object({include:G.array(G.string()).optional(),exclude:G.array(G.string()).optional()}).passthrough()});import*as D2 from"path";function lX(D){let F=new Set,B=[];for(let $=D.length-1;$>=0;$--){let _=D[$];if(!F.has(_))F.add(_),B.unshift(_)}return B}function pX(D){return D.configBin??D.envBin??"opencode"}function Z5(D){return D.includes("/")||D.includes("\\")}function iX(D){let{configuredBin:F,cwd:B}=D,$=D.resolveExecutable??((Q)=>Bun.which(Q));if(!F.trim())throw Error("OpenCode launcher is empty and cannot be resolved to a stable path");if(Z5(F))return D2.isAbsolute(F)?F:D2.resolve(B,F);let _=$(F);if(!_)throw Error(`OpenCode launcher "${F}" is not available in PATH and cannot be used as OPENCODE_BIN`);return D2.isAbsolute(_)?_:D2.resolve(B,_)}function nX(D){let F=D.resolveExecutable??((J)=>Bun.which(J)),B=D.argv??process.argv,$=D.execPath??process.execPath,_=D.isCompiledBinary??(typeof Bun<"u"&&typeof Bun.main==="string"&&Bun.main.startsWith("/$bunfs/")),Q=D.inheritedOcxBin?.trim(),Y=_?$:B[1],q=Q&&Q.length>0?Q:Y;if(!q?.trim())throw Error("OCX executable path is empty and cannot be resolved from the current process");if(Z5(q))return D2.isAbsolute(q)?q:D2.resolve(D.cwd,q);let H=F(q);if(!H)throw Error(`OCX executable "${q}" is not available in PATH and cannot be persisted as OCX_BIN`);return D2.isAbsolute(H)?H:D2.resolve(D.cwd,H)}function sX(D){let F=Boolean(D.profileName),{OPENCODE_DISABLE_PROJECT_CONFIG:B,OPENCODE_BIN:$,OCX_CONTEXT:_,OCX_BIN:Q,OCX_PROFILE:Y,...q}=D.baseEnv;return{...q,...D.opencodeBin!==void 0&&{OPENCODE_BIN:D.opencodeBin},...F&&{OPENCODE_DISABLE_PROJECT_CONFIG:"true"},OPENCODE_CONFIG_DIR:D.configDir??(F?fD(D.profileName):W0()),...D.configContent&&{OPENCODE_CONFIG_CONTENT:D.configContent},...F&&{OCX_CONTEXT:"1"},...F&&D.ocxBin&&{OCX_BIN:D.ocxBin},...D.profileName&&{OCX_PROFILE:D.profileName}}}function R5(D){D.command("oc").alias("opencode").description("Launch OpenCode with resolved configuration").option("-p, --profile <name>","Use specific profile").option("--no-rename","Disable terminal/tmux window renaming").allowUnknownOption().allowExcessArguments(!0).action(async(F,B)=>{try{await aX(B.args,F)}catch($){t($)}})}async function aX(D,F){let B=process.cwd(),$=await r0.create(B,{profile:F.profile}),_=$.resolve(),Q=$.getProfile();if(_.profileName)W.info(`Using profile: ${_.profileName}`);let Y=Q?.ocx,q=F.rename!==!1&&Y?.renameWindow!==!1;if(_.profileName){let y=W2(_.profileName);if(!await Bun.file(y).exists())W.warn(`No opencode.jsonc found at ${y}. Create one to customize OpenCode settings.`)}let H=Array.isArray(_.opencode.instructions)?_.opencode.instructions:[],J=[..._.instructions,...H],X=lX(J),z=X.length>0||Object.keys(_.opencode).length>0?{..._.opencode,instructions:X.length>0?X:void 0}:void 0,M=null,A=null,K=null,j=null,S=null,R=()=>{if(M)M.kill("SIGINT");else S=130},s=()=>{if(M)M.kill("SIGTERM");else S=143},N=()=>{if(q)I6()};try{if(process.on("SIGINT",R),process.on("SIGTERM",s),process.on("exit",N),S!==null){j=S;return}if(_.profileName)A=await O5({projectDir:B,profileDir:fD(_.profileName)});if(S!==null){j=S;return}if(q){M5();let p=await J5(B);if(S!==null){j=S;return}z5(A5(B,_.profileName??"default",p))}if(S!==null){j=S;return}let y=pX({configBin:Y?.bin,envBin:process.env.OPENCODE_BIN}),O=Boolean(_.profileName),b=O?iX({configuredBin:y,cwd:B}):y,L=O?nX({cwd:B,inheritedOcxBin:process.env.OCX_BIN}):void 0,e=z?JSON.stringify(z):void 0;try{M=Bun.spawn({cmd:[b,...D],cwd:B,env:sX({baseEnv:process.env,profileName:_.profileName??void 0,ocxBin:L,opencodeBin:b,configDir:A?.path,configContent:e}),stdin:"inherit",stdout:"inherit",stderr:"inherit"})}catch(p){throw a("spawn",`Failed to launch OpenCode binary "${y}": ${p instanceof Error?p.message:String(p)}`)}j=await M.exited}catch(y){K=y instanceof Error?y:a("spawn",`OpenCode process failed: ${String(y)}`)}finally{if(process.off("SIGINT",R),process.off("SIGTERM",s),process.off("exit",N),q)I6();if(A)try{await A.cleanup()}catch(y){if(K!==null||S!==null||j!==null&&j!==0)W.warn(`Cleanup warning: ${y instanceof Error?y.message:String(y)}`);else K=y instanceof Error?y:a("cleanup",`Failed to remove temporary merged config directory: ${String(y)}`)}}if(K)throw K;if(j!==null)process.exit(j)}var N5=V(()=>{b3();Q0();X5();yD();hD();k2();j5();b5()});import{existsSync as B3}from"fs";import{mkdir as y6,mkdtemp as oX,rename as rX,rm as S5,writeFile as tX}from"fs/promises";import{dirname as k5,join as f8,relative as eX}from"path";function I5(D,F,B){let $=B instanceof Error?B.message:String(B);return`${D} "${F}" (${$})`}function u5(D,F){let[B,$]=F.split("/");if(!B||!$)return;return`${xD(D)}/components/${$}.json`}function T5(D){if(!D)return null;let[F,B,...$]=D.split("/");if(!F||!B||$.length>0)return null;return{registryName:F,componentName:B}}function DW(D,F){if(!D)return{};let B;try{let Y=new URL(D),q=Y.pathname.match(/(?:^|\/)components\/([^/]+)\.json$/);if(q?.[1])B=decodeURIComponent(q[1]);else{let H=Y.pathname.match(/(?:^|\/)components\/([^/]+)\/.+$/);if(H?.[1])B=decodeURIComponent(H[1])}}catch{}let $=xD(D),_,Q=-1;for(let[Y,q]of Object.entries(F)){let H=xD(q.url);if(!($===H||$.startsWith(`${H}/`))||H.length<=Q)continue;_=Y,Q=H.length}return{registryName:_,componentName:B}}function FW(D){let F=D.depRefs[0]??`${D.namespace}/${D.component}`,B={...D.profileRegistries,...D.profileRegistries[D.namespace]?{}:{[D.namespace]:{url:D.registryUrl}}},$=D.error.registryName,_=D.error.qualifiedName,Q=T5(_);if(!$&&Q)$=Q.registryName;let Y=Q?.componentName,q=_&&!Q&&!_.includes("/")?_:void 0,H=DW(D.error.url,B);if(!$&&H.registryName)$=H.registryName;let J=Y??q??H.componentName;if((!_||!Q)&&$&&J)_=`${$}/${J}`;if(!_)_=F;if(!$)$=T5(_)?.registryName??D.namespace;let X=B[$]?.url||($===D.namespace?D.registryUrl:void 0);return{registryName:$,qualifiedName:_,fallbackUrl:D.error.url||(X?u5(X,_):void 0)}}function v5(D,F){let B=D.phase??F.fallbackPhase,$=D.url??F.fallbackUrl,_=[`phase: ${B}`,`qualifiedName: ${F.qualifiedName}`,`registryContext: ${F.registryContext}`,`registryName: ${F.registryName}`,...$?[`url: ${$}`]:[]];return new ZD(`${D.message} (${_.join(", ")})`,{url:$,status:D.status,statusText:D.statusText,phase:B,qualifiedName:F.qualifiedName,registryContext:F.registryContext,registryName:F.registryName})}function C5(D,F){if(!D.startsWith(".opencode/"))throw new U(`Invalid embedded target "${D}": expected .opencode/ prefix for embedded profile files.`);let B=D.slice(10);if(!B)throw new U(`Invalid embedded target "${D}": missing path after .opencode/ prefix.`);let $;try{$=J0(F,B)}catch(Q){if(Q instanceof oD)throw new U(`Invalid embedded target "${D}": ${Q.message}`);throw Q}let _=eX(F,$).replace(/\\/g,"/");if(_==="."||_==="")throw new U(`Invalid embedded target "${D}": target must resolve to a file path.`);return _}async function x6(D){let{namespace:F,component:B,profileName:$,registryUrl:_,quiet:Q}=D;if(!a0.safeParse($).success)throw new U(`Invalid profile name: "${$}". Profile names must start with a letter and contain only alphanumeric characters, dots, underscores, or hyphens.`);let q;if(F)q=F;else throw new U(`Registry name is required for URL-based profile installs.
131
131
 
132
- Use a qualified component reference (e.g., 'my-registry/${B}') or specify --name to provide a registry alias.`);let H=yD($),J=`${q}/${B}`;if(F3(H))throw new gD(`Profile "${$}" already exists. Remove it first with 'ocx profile rm ${$} --global'.`);let z=Q?null:jD({text:`Fetching ${J}...`});z?.start();let M;try{M=await R3(_,B)}catch(O){if(z?.fail(`Failed to fetch ${J}`),O instanceof RD)throw S5(O,{registryContext:"source",registryName:q,qualifiedName:J,fallbackPhase:"packument-fetch",fallbackUrl:I5(_,J)});if(O instanceof MD)throw new MD(`Profile component "${J}" not found in registry.
132
+ Use a qualified component reference (e.g., 'my-registry/${B}') or specify --name to provide a registry alias.`);let H=fD($),J=`${q}/${B}`;if(B3(H))throw new dD(`Profile "${$}" already exists. Remove it first with 'ocx profile rm ${$} --global'.`);let z=Q?null:jD({text:`Fetching ${J}...`});z?.start();let M;try{M=await R3(_,B)}catch(O){if(z?.fail(`Failed to fetch ${J}`),O instanceof ZD)throw v5(O,{registryContext:"source",registryName:q,qualifiedName:J,fallbackPhase:"packument-fetch",fallbackUrl:u5(_,J)});if(O instanceof MD)throw new MD(`Profile component "${J}" not found in registry.
133
133
 
134
134
  Check the component name and ensure the registry is configured.`);throw O}if(M.type!=="profile")throw z?.fail("Invalid component type"),new U(`Component "${J}" is type "${M.type}", not "profile".
135
135
 
136
- Only profile components can be installed with 'ocx profile add --source <ns/comp> --global'.`);let A=p2(M);z?.succeed(`Fetched ${J}`);let K=Q?null:jD({text:"Downloading profile files..."});K?.start();let j=[],S=[];for(let O of A.files){let b=await e2(_,B,O.path),L={path:O.path,target:O.target,content:Buffer.from(b)};if(O.target.startsWith(".opencode/"))S.push(L);else j.push(L)}K?.succeed(`Downloaded ${A.files.length} files`);let Z=X2();await C6(Z,{recursive:!0,mode:448});let s=await cX(x8(Z,".staging-")),N=!1,x=!1;try{let O=Q?null:jD({text:"Writing profile files..."});O?.start();let b=new Map;for(let p of j){let FD=hF(p.target,s),KD=x8(s,FD);$F(b,{absolutePath:KD,relativePath:FD,content:p.content,source:`${B}:${p.path}`})}for(let p of S){let FD=k5(p.target,s),KD=hF(FD,s),k=x8(s,KD);$F(b,{absolutePath:k,relativePath:KD,content:p.content,source:`${B}:${p.path}`})}for(let p of b.values()){let FD=p.absolutePath,KD=R5(FD);if(!F3(KD))await C6(KD,{recursive:!0});await pX(FD,p.content)}O?.succeed(`Wrote ${b.size} profile files`),await K0(s,{version:1,root:H,installed:{}});let L=Q?null:jD({text:"Moving to profile directory..."});L?.start();let e=R5(H);if(!F3(e))await C6(e,{recursive:!0,mode:448});if(await lX(s,H),N=!0,L?.succeed("Profile installed"),M.dependencies.length>0){let p=Q?null:jD({text:"Installing dependencies..."});p?.start();let FD=M.dependencies.map((k)=>k.includes("/")?k:`${q}/${k}`),KD={};try{let k=x8(H,"ocx.jsonc");if(F3(k)){let f=await Bun.file(k).text(),_D=ND(f),r=Y2.safeParse(_D);if(r.success)KD=r.data.registries??{};else if(eD(_D)&&"registries"in _D)throw new c(`Invalid registries in profile "${$}": ${r.error.message}`)}await V6(FD,{profile:$,quiet:Q},{cwd:H,getRegistries:()=>KD,getComponentPath:()=>""}),p?.succeed(`Installed ${M.dependencies.length} dependencies`)}catch(k){if(p?.fail("Failed to install dependencies"),k instanceof RD){let i=sX({error:k,depRefs:FD,namespace:q,component:B,registryUrl:_,profileRegistries:KD});throw S5(k,{registryContext:"dependency",registryName:i.registryName,qualifiedName:i.qualifiedName,fallbackPhase:"packument-fetch",fallbackUrl:i.fallbackUrl})}throw k}}if(x=!0,!Q){G.info(""),G.success(`Installed profile "${$}" from ${J}`),G.info(""),G.info("Profile contents:");for(let p of j)G.info(` ${p.target}`);for(let p of S){let FD=k5(p.target,H);G.info(` ${FD}`)}}}catch(O){let b=[];try{if(F3(s))await b5(s,{recursive:!0})}catch(L){b.push(Z5("Profile add rollback cleanup warning: failed to remove staging directory",s,L))}if(N&&!x)try{if(F3(H))await b5(H,{recursive:!0,force:!0})}catch(L){b.push(Z5("Profile add rollback cleanup warning: failed to remove promoted profile",H,L))}if(!Q)for(let L of b)G.warn(L);throw O}}var T5=V(()=>{b0();G0();Q8();DF();tD();fF();P0();I1();$D();fD();c2();A8();m0();E6()});function aX(D){if(!D?.trim())throw new U("--source value cannot be empty");let F=D.trim();if((F.match(/\//g)||[]).length!==1)throw new U(`Invalid --source format: "${D}". Expected: namespace/component`);let[$,_]=F.split("/").map((Q)=>Q.trim());if(!$||!_)throw new U(`Invalid --source format: "${D}". Expected: namespace/component`);return{namespace:$,component:_}}async function oX(){let D=I2(),F=Bun.file(D);if(!await F.exists())return null;try{let B=await F.text(),$=ND(B,[],{allowTrailingComma:!0});return Y2.parse($)}catch(B){if(B instanceof Error)throw new c(`Failed to parse global config at "${D}": ${B.message}
136
+ Only profile components can be installed with 'ocx profile add --source <ns/comp> --global'.`);let A=p2(M);z?.succeed(`Fetched ${J}`);let K=Q?null:jD({text:"Downloading profile files..."});K?.start();let j=[],S=[];for(let O of A.files){let b=await e2(_,B,O.path),L={path:O.path,target:O.target,content:Buffer.from(b)};if(O.target.startsWith(".opencode/"))S.push(L);else j.push(L)}K?.succeed(`Downloaded ${A.files.length} files`);let R=X2();await y6(R,{recursive:!0,mode:448});let s=await oX(f8(R,".staging-")),N=!1,y=!1;try{let O=Q?null:jD({text:"Writing profile files..."});O?.start();let b=new Map;for(let p of j){let FD=hF(p.target,s),KD=f8(s,FD);$F(b,{absolutePath:KD,relativePath:FD,content:p.content,source:`${B}:${p.path}`})}for(let p of S){let FD=C5(p.target,s),KD=hF(FD,s),k=f8(s,KD);$F(b,{absolutePath:k,relativePath:KD,content:p.content,source:`${B}:${p.path}`})}for(let p of b.values()){let FD=p.absolutePath,KD=k5(FD);if(!B3(KD))await y6(KD,{recursive:!0});await tX(FD,p.content)}O?.succeed(`Wrote ${b.size} profile files`),await j0(s,{version:1,root:H,installed:{}});let L=Q?null:jD({text:"Moving to profile directory..."});L?.start();let e=k5(H);if(!B3(e))await y6(e,{recursive:!0,mode:448});if(await rX(s,H),N=!0,L?.succeed("Profile installed"),M.dependencies.length>0){let p=Q?null:jD({text:"Installing dependencies..."});p?.start();let FD=M.dependencies.map((k)=>k.includes("/")?k:`${q}/${k}`),KD={};try{let k=f8(H,"ocx.jsonc");if(B3(k)){let f=await Bun.file(k).text(),_D=ND(f),r=q2.safeParse(_D);if(r.success)KD=r.data.registries??{};else if(D0(_D)&&"registries"in _D)throw new c(`Invalid registries in profile "${$}": ${r.error.message}`)}await w6(FD,{profile:$,quiet:Q},{cwd:H,getRegistries:()=>KD,getComponentPath:()=>""}),p?.succeed(`Installed ${M.dependencies.length} dependencies`)}catch(k){if(p?.fail("Failed to install dependencies"),k instanceof ZD){let i=FW({error:k,depRefs:FD,namespace:q,component:B,registryUrl:_,profileRegistries:KD});throw v5(k,{registryContext:"dependency",registryName:i.registryName,qualifiedName:i.qualifiedName,fallbackPhase:"packument-fetch",fallbackUrl:i.fallbackUrl})}throw k}}if(y=!0,!Q){W.info(""),W.success(`Installed profile "${$}" from ${J}`),W.info(""),W.info("Profile contents:");for(let p of j)W.info(` ${p.target}`);for(let p of S){let FD=C5(p.target,H);W.info(` ${FD}`)}}}catch(O){let b=[];try{if(B3(s))await S5(s,{recursive:!0})}catch(L){b.push(I5("Profile add rollback cleanup warning: failed to remove staging directory",s,L))}if(N&&!y)try{if(B3(H))await S5(H,{recursive:!0,force:!0})}catch(L){b.push(I5("Profile add rollback cleanup warning: failed to remove promoted profile",H,L))}if(!Q)for(let L of b)W.warn(L);throw O}}var P5=V(()=>{b0();Q0();q8();DF();eD();fF();P0();v1();$D();hD();c2();K8();g0();O6()});function BW(D){if(!D?.trim())throw new U("--source value cannot be empty");let F=D.trim();if((F.match(/\//g)||[]).length!==1)throw new U(`Invalid --source format: "${D}". Expected: namespace/component`);let[$,_]=F.split("/").map((Q)=>Q.trim());if(!$||!_)throw new U(`Invalid --source format: "${D}". Expected: namespace/component`);return{namespace:$,component:_}}async function $W(){let D="global ocx config";try{let F=await N9();D=F.path;let B=F.content,$=ND(B,[],{allowTrailingComma:!0});return q2.parse($)}catch(F){if(F instanceof I2)throw F;if(F instanceof Error)throw new c(`Failed to parse global config at "${D}": ${F.message}
137
137
 
138
- Check the file for syntax errors or run: ocx config edit --global`);throw B}}async function rX(D){let F=await oX();if(!F)throw new c(`Registry "${D}" is not configured globally.
138
+ Check the file for syntax errors or run: ocx config edit --global`);throw F}}async function _W(D){let F;try{F=await $W()}catch($){if($ instanceof I2)throw new c(`Registry "${D}" is not configured globally.
139
139
 
140
140
  Profile installation requires global registry configuration.
141
- Run: ocx registry add <url> --name ${D} --global`);let B=F.registries[D];if(!B)throw new c(`Registry "${D}" is not configured globally.
141
+ ${$.message}
142
+ Run: ocx registry add <url> --name ${D} --global`);throw $}let B=F.registries[D];if(!B)throw new c(`Registry "${D}" is not configured globally.
142
143
 
143
144
  Profile installation requires global registry configuration.
144
- Run: ocx registry add <url> --name ${D} --global`);return{config:F,registryUrl:B.url}}function v5(D){D.command("add <name>").description("Create a new profile (--global required), clone from existing, or install from registry").option("--clone <profile>","Clone from existing global profile").option("--source <namespace/component>","Install from registry (requires --global)").option("--from <url>","Ephemeral registry URL for --source (does not persist)").option("-g, --global","Create global profile (required \u2014 local profiles are unsupported)").option("--json","Output as JSON").addHelpText("after",`
145
+ Run: ocx registry add <url> --name ${D} --global`);return{config:F,registryUrl:B.url}}function y5(D){D.command("add <name>").description("Create a new profile (--global required), clone from existing, or install from registry").option("--clone <profile>","Clone from existing global profile").option("--source <namespace/component>","Install from registry (requires --global)").option("--from <url>","Ephemeral registry URL for --source (does not persist)").option("-g, --global","Create global profile (required \u2014 local profiles are unsupported)").option("--json","Output as JSON").addHelpText("after",`
145
146
  Examples:
146
147
  $ ocx profile add work --global # Create global profile (~/.config/opencode/profiles/work/)
147
148
  $ ocx profile add work --clone dev --global # Clone from existing global profile
148
149
  $ ocx profile add work --source kdco/minimal --global # Install from configured registry
149
150
  $ ocx profile add work --source kdco/minimal --from http://r.com --global # Install from ephemeral registry
150
- `).action(async(F,B)=>{try{let $=await tX(F,B);if(B.json)LD({success:!0,data:$})}catch($){t($,{json:B.json})}})}async function tX(D,F){let B=F.json===!0;if(F.clone&&(F.source||F.from))throw new U(`--clone cannot be used with --source or --from.
151
+ `).action(async(F,B)=>{try{let $=await QW(F,B);if(B.json)LD({success:!0,data:$})}catch($){t($,{json:B.json})}})}async function QW(D,F){let B=F.json===!0;if(F.clone&&(F.source||F.from))throw new U(`--clone cannot be used with --source or --from.
151
152
 
152
153
  Use one of:
153
154
  ocx profile add <name> --clone <profile> --global # Clone existing profile
@@ -183,37 +184,37 @@ Example: --from https://registry.example.com`)}catch(Y){if(Y instanceof U)throw
183
184
  --from must be a valid registry URL (http:// or https://).
184
185
  Example: --from https://registry.example.com`)}}if(!F.global)throw new c(`Local profiles are unsupported. Use --global to create a global profile.
185
186
 
186
- ocx profile add ${D} --global`);let $="global",_=await uD.requireInitialized();if(F.clone)return await DG(_,D,F.clone,B),{name:D,scope:$,mode:"clone",cloneFrom:F.clone};if(F.source){let{namespace:Q,component:Y}=aX(F.source),q;if(F.from)q=xD(F.from.trim()),await u6({namespace:Q,component:Y,profileName:D,registryUrl:q,quiet:B});else q=(await rX(Q)).registryUrl,await u6({namespace:Q,component:Y,profileName:D,registryUrl:q,quiet:B});return{name:D,scope:$,mode:"registry",registry:{namespace:Q,component:Y,url:q,ephemeral:Boolean(F.from)}}}return await eX(_,D,B),{name:D,scope:$,mode:"empty"}}async function eX(D,F,B){if(await D.exists(F))throw new O2(F,`Remove it first with 'ocx profile rm ${F} --global'.`);if(await D.add(F),!B)G.success(`Created global profile "${F}"`)}async function DG(D,F,B,$){if(await D.exists(F))throw new O2(F,`Remove it first with 'ocx profile rm ${F} --global'.`);try{await D.get(B)}catch(q){if(q instanceof CD)throw new CD(B,`Profile '${B}' not found in global scope.`);if(q instanceof zD)throw q;throw new U(`Failed to load profile '${B}': ${q instanceof Error?q.message:String(q)}`)}await D.add(F);let Q=Q0(B),Y=Q0(F);if(await E9(Q,Y),!$)G.success(`Created global profile "${F}" (cloned from "${B}")`)}var C5=V(()=>{b0();_8();a0();G0();fF();$D();PD();fD();T5()});function u5(D){D.command("list").alias("ls").description("List profiles (use --global; local profiles are unsupported)").option("-g, --global","List global profiles (required \u2014 local profiles are unsupported)").addOption(L0.json()).action(async(F)=>{try{await FG(F)}catch(B){t(B,{json:F.json})}})}async function FG(D){if(!D.global)throw new c(`Local profiles are unsupported. Use --global to list global profiles.
187
+ ocx profile add ${D} --global`);let $="global",_=await PD.requireInitialized();if(F.clone)return await qW(_,D,F.clone,B),{name:D,scope:$,mode:"clone",cloneFrom:F.clone};if(F.source){let{namespace:Q,component:Y}=BW(F.source),q;if(F.from)q=xD(F.from.trim()),await x6({namespace:Q,component:Y,profileName:D,registryUrl:q,quiet:B});else q=(await _W(Q)).registryUrl,await x6({namespace:Q,component:Y,profileName:D,registryUrl:q,quiet:B});return{name:D,scope:$,mode:"registry",registry:{namespace:Q,component:Y,url:q,ephemeral:Boolean(F.from)}}}return await YW(_,D,B),{name:D,scope:$,mode:"empty"}}async function YW(D,F,B){if(await D.exists(F))throw new O2(F,`Remove it first with 'ocx profile rm ${F} --global'.`);if(await D.add(F),!B)W.success(`Created global profile "${F}"`)}async function qW(D,F,B,$){if(await D.exists(F))throw new O2(F,`Remove it first with 'ocx profile rm ${F} --global'.`);try{await D.get(B)}catch(q){if(q instanceof CD)throw new CD(B,`Profile '${B}' not found in global scope.`);if(q instanceof zD)throw q;throw new U(`Failed to load profile '${B}': ${q instanceof Error?q.message:String(q)}`)}await D.add(F);let Q=_0(B),Y=_0(F);if(await O9(Q,Y),!$)W.success(`Created global profile "${F}" (cloned from "${B}")`)}var x5=V(()=>{b0();Q8();o0();Q0();fF();$D();yD();hD();P5()});function f5(D){D.command("list").alias("ls").description("List profiles (use --global; local profiles are unsupported)").option("-g, --global","List global profiles (required \u2014 local profiles are unsupported)").addOption(E0.json()).action(async(F)=>{try{await HW(F)}catch(B){t(B,{json:F.json})}})}async function HW(D){if(!D.global)throw new c(`Local profiles are unsupported. Use --global to list global profiles.
187
188
 
188
- ocx profile list --global`);let B=await(await uD.requireInitialized()).list();if(D.json){console.log(JSON.stringify({profiles:B,initialized:!0},null,2));return}let $="Global profiles:",_="No global profiles found. Run 'ocx profile add <name> --global' to create one.";if(B.length===0){console.log(_);return}console.log($);for(let Q of B)console.log(` ${Q}`)}var P5=V(()=>{a0();$D();PD();x0()});function x5(D){D.command("move <old-name> <new-name>").alias("mv").description("Move (rename) a profile (use --global; local profiles are unsupported)").option("-g, --global","Move global profile (required \u2014 local profiles are unsupported)").option("--json","Output as JSON").action(async(F,B,$)=>{try{let _=await BG(F,B,$);if($.json)LD({success:!0,data:_})}catch(_){t(_,{json:$.json})}})}async function BG(D,F,B){if(!B.global)throw new c(`Local profiles are unsupported. Use --global to move a global profile.
189
+ ocx profile list --global`);let B=await(await PD.requireInitialized()).list();if(D.json){console.log(JSON.stringify({profiles:B,initialized:!0},null,2));return}let $="Global profiles:",_="No global profiles found. Run 'ocx profile add <name> --global' to create one.";if(B.length===0){console.log(_);return}console.log($);for(let Q of B)console.log(` ${Q}`)}var h5=V(()=>{o0();$D();yD();x0()});function m5(D){D.command("move <old-name> <new-name>").alias("mv").description("Move (rename) a profile (use --global; local profiles are unsupported)").option("-g, --global","Move global profile (required \u2014 local profiles are unsupported)").option("--json","Output as JSON").action(async(F,B,$)=>{try{let _=await JW(F,B,$);if($.json)LD({success:!0,data:_})}catch(_){t(_,{json:$.json})}})}async function JW(D,F,B){if(!B.global)throw new c(`Local profiles are unsupported. Use --global to move a global profile.
189
190
 
190
- ocx profile move ${D} ${F} --global`);let $=await uD.requireInitialized(),{warnActiveProfile:_}=await $.move(D,F);if(_&&!B.json)G.warn(`Moving active profile. Update OCX_PROFILE env var to "${F}".`);if(!B.json)G.success(`Moved global profile "${D}" \u2192 "${F}"`);return{from:D,to:F,scope:"global",warnActiveProfile:_}}var y5=V(()=>{a0();$D();PD();fD()});function f5(D){D.command("remove <name>").alias("rm").description("Delete a profile (use --global; local profiles are unsupported)").option("-g, --global","Remove global profile (required \u2014 local profiles are unsupported)").option("--json","Output as JSON").action(async(F,B)=>{try{let $=await $G(F,B);if(B.json)LD({success:!0,data:$})}catch($){t($,{json:B.json})}})}async function $G(D,F){if(!F.global)throw new c(`Local profiles are unsupported. Use --global to remove a global profile.
191
+ ocx profile move ${D} ${F} --global`);let $=await PD.requireInitialized(),{warnActiveProfile:_}=await $.move(D,F);if(_&&!B.json)W.warn(`Moving active profile. Update OCX_PROFILE env var to "${F}".`);if(!B.json)W.success(`Moved global profile "${D}" \u2192 "${F}"`);return{from:D,to:F,scope:"global",warnActiveProfile:_}}var g5=V(()=>{o0();$D();yD();hD()});function d5(D){D.command("remove <name>").alias("rm").description("Delete a profile (use --global; local profiles are unsupported)").option("-g, --global","Remove global profile (required \u2014 local profiles are unsupported)").option("--json","Output as JSON").action(async(F,B)=>{try{let $=await XW(F,B);if(B.json)LD({success:!0,data:$})}catch($){t($,{json:B.json})}})}async function XW(D,F){if(!F.global)throw new c(`Local profiles are unsupported. Use --global to remove a global profile.
191
192
 
192
- ocx profile remove <name> --global`);let B=await uD.requireInitialized();if(!await B.exists(D))throw new CD(D);if(await B.remove(D),!F.json)G.success(`Deleted global profile "${D}"`);return{name:D,scope:"global"}}var h5=V(()=>{a0();$D();PD();fD()});function m5(D){D.command("show [name]").description("Display profile contents (use --global; local profiles are unsupported)").option("-g, --global","Show global profile (required \u2014 local profiles are unsupported)").addOption(L0.json()).action(async(F,B)=>{try{await _G(F,B)}catch($){t($,{json:B.json})}})}async function _G(D,F){if(!F.global)throw new c(`Local profiles are unsupported. Use --global to show a global profile.
193
+ ocx profile remove <name> --global`);let B=await PD.requireInitialized();if(!await B.exists(D))throw new CD(D);if(await B.remove(D),!F.json)W.success(`Deleted global profile "${D}"`);return{name:D,scope:"global"}}var c5=V(()=>{o0();$D();yD();hD()});function l5(D){D.command("show [name]").description("Display profile contents (use --global; local profiles are unsupported)").option("-g, --global","Show global profile (required \u2014 local profiles are unsupported)").addOption(E0.json()).action(async(F,B)=>{try{await WW(F,B)}catch($){t($,{json:B.json})}})}async function WW(D,F){if(!F.global)throw new c(`Local profiles are unsupported. Use --global to show a global profile.
193
194
 
194
- ocx profile show [name] --global`);let B=await uD.requireInitialized(),$=D??await B.resolveProfile(),_=await B.get($);if(F.json){console.log(JSON.stringify(_,null,2));return}if(console.log(`Profile: ${_.name}`),console.log(`
195
- Files:`),console.log(` ocx.jsonc: ${Q0($)}`),_.opencode)console.log(` opencode.jsonc: ${G2($)}`);if(_.hasAgents)console.log(` AGENTS.md: ${a2($)}`);console.log(`
196
- OCX Config:`),console.log(JSON.stringify(_.ocx,null,2))}var g5=V(()=>{a0();G0();$D();PD();x0()});function d5(D){let F=D.command("profile").alias("p").description("Manage profiles (global only)");u5(F),v5(F),f5(F),x5(F),m5(F)}var c5=V(()=>{C5();P5();y5();h5();g5()});import{existsSync as QG}from"fs";import{dirname as l5,join as p5}from"path";async function YG(D,F,B){if(B.isLocked?.())throw Error("Registries are locked. Cannot add.");let $=D.trim();if(!$)throw new U("Registry URL is required");try{let K=new URL($);if(!["http:","https:"].includes(K.protocol))throw new U(`Invalid registry URL: ${$} (must use http or https)`)}catch(K){if(K instanceof U)throw K;throw new U(`Invalid registry URL: ${$}`)}let _=xD($),Q=F.name,Y=B.getRegistries(),q=Y[Q],H=qG(Y,_),{fetchRegistryIndex:J}=await Promise.resolve().then(() => (DF(),r9));await J(_);let X=q!==void 0,z=H!==null,M=X&&xD(q.url)===_,A=z&&H.name!==Q;if(F.dryRun){let K=[];if(X&&!M)K.push(`Registry '${Q}' already exists with a different URL (${q.url}). Run 'ocx registry remove ${Q}' first, then re-add.`);else if(A)K.push(`URL '${_}' is already registered under name '${H.name}'. Run 'ocx registry remove ${H.name}' first, then re-add.`);let j=X&&!M||A,S=X&&M,Z=B.targetLabel||"config";return{dryRun:!0,command:"registry add",wouldPerform:S?[]:[{action:"add",target:`registry:${Q}`,details:{url:_}}],validation:{passed:!j,warnings:K.length>0?K:void 0},summary:j?`Would fail: conflict detected for registry '${Q}'`:S?`Registry '${Q}' already configured with same URL (no-op)`:`Would add registry '${Q}' to ${Z}`}}if(X&&!M)throw new vF(Q,q.url,_,B.targetLabel);if(A)throw new vF(Q,_,_,B.targetLabel,H.name);if(X&&M)return{name:Q,url:_,updated:!1,alreadyConfigured:!0};return await B.setRegistry(Q,{url:_}),{name:Q,url:_,updated:!1,alreadyConfigured:!1}}function qG(D,F){for(let[B,$]of Object.entries(D))if(xD($.url)===F)return{name:B,config:$};return null}async function HG(D,F){if(F.isLocked?.())throw Error("Registries are locked. Cannot remove.");let B=F.getRegistries();if(!(D in B))throw Error(`Registry '${D}' not found.`);return await F.removeRegistry(D),{removed:D}}function JG(D){let F=D.getRegistries(),B=D.isLocked?.()??!1;return{registries:Object.entries(F).map(([_,Q])=>({name:_,url:Q.url})),locked:B}}async function P6(D,F,B){let $=F.getOptionValueSource("cwd")==="cli";if(D.global&&D.profile)throw new U("Cannot use both --global and --profile flags");if($&&D.profile)throw new U("Cannot use both --cwd and --profile flags");if(D.global&&$)throw new U("Cannot use both --global and --cwd flags");if(D.profile){if(N4(D.profile),!await(await uD.requireInitialized()).exists(D.profile))throw new CD(D.profile);let Y=Q0(D.profile);if(!QG(Y))throw new c(`Profile '${D.profile}' has no ocx.jsonc. Run 'ocx profile config ${D.profile}' to create it.`);return{scope:"profile",configPath:Y,configDir:l5(Y),targetLabel:`profile '${D.profile}' config`}}if(D.global){let Q=X0();return{scope:"global",configPath:p5(Q,"ocx.jsonc"),configDir:Q,targetLabel:"global config"}}let _=S2(B);return{scope:"local",configPath:_.path,configDir:_.exists?l5(_.path):p5(B,".opencode"),targetLabel:"local config"}}function i5(D){let F=D.command("registry").description("Manage registries"),B=F.command("add").description("Add a registry").argument("<url>","Registry URL").requiredOption("--name <name>","Registry alias (required, used as lookup key for alias/component refs)").option("--dry-run","Validate registry without adding to config");r0(B),K8(B),oD(B),B.action(async(Q,Y,q)=>{let H;try{let J=Y.cwd??process.cwd();H=await P6(Y,q,J);let{configDir:X,configPath:z}=H,M=await U0(X);if(!M){let j=H.scope==="global"?"Run 'ocx init --global' first.":H.scope==="profile"?`Run 'ocx profile config ${Y.profile}' to create it.`:"Run 'ocx init' first.";G.error(`${H.targetLabel} not found. ${j}`),process.exit(1)}let A=await YG(Q,Y,{getRegistries:()=>M.registries,isLocked:()=>M.lockRegistries??!1,setRegistry:async(j,S)=>{M.registries[j]=S,await e3(X,M,z)},targetLabel:H.targetLabel});if("dryRun"in A&&A.dryRun){z0(A,{json:Y.json,quiet:Y.quiet});return}let K=A;if(Y.json)LD({success:!0,data:K});else if(!Y.quiet)if(K.alreadyConfigured)G.info(`Registry already configured (no changes): ${K.name}`);else if(K.updated)G.success(`Updated registry in ${H.targetLabel}: ${K.name} -> ${K.url}`);else G.success(`Added registry to ${H.targetLabel}: ${K.name} -> ${K.url}`)}catch(J){t(J,{json:Y.json})}});let $=F.command("remove").description("Remove a registry").argument("<name>","Registry name");r0($),K8($),oD($),$.action(async(Q,Y,q)=>{try{let H=Y.cwd??process.cwd(),J=await P6(Y,q,H),X=await U0(J.configDir);if(!X){let M=J.scope==="global"?"Run 'ocx init --global' first.":J.scope==="profile"?`Run 'ocx profile config ${Y.profile}' to create it.`:"Run 'ocx init' first.";G.error(`${J.targetLabel} not found. ${M}`),process.exit(1)}let z=await HG(Q,{getRegistries:()=>X.registries,isLocked:()=>X.lockRegistries??!1,removeRegistry:async(M)=>{delete X.registries[M],await e3(J.configDir,X,J.configPath)}});if(Y.json)LD({success:!0,data:z});else if(!Y.quiet)G.success(`Removed registry from ${J.targetLabel}: ${z.removed}`)}catch(H){t(H,{json:Y.json})}});let _=F.command("list").description("List configured registries");r0(_),K8(_),oD(_),_.action(async(Q,Y)=>{try{let q=Q.cwd??process.cwd(),H=await P6(Q,Y,q),J=await U0(H.configDir);if(!J){let z=H.scope==="global"?"Run 'ocx init --global' first.":H.scope==="profile"?`Run 'ocx profile config ${Q.profile}' to create it.`:"Run 'ocx init' first.";G.warn(`${H.targetLabel} not found. ${z}`);return}let X=JG({getRegistries:()=>J.registries,isLocked:()=>J.lockRegistries??!1});if(Q.json)LD({success:!0,data:X});else if(!Q.quiet)if(X.registries.length===0)G.info("No registries configured.");else{let z=H.scope==="global"?" (global)":H.scope==="profile"?` (profile '${Q.profile}')`:"";G.info(`Configured registries${z}${X.locked?P.yellow(" (locked)"):""}:`);for(let M of X.registries)console.log(` ${P.cyan(M.name)}: ${M.url}`)}}catch(q){t(q,{json:Q.json})}})}var n5=V(()=>{W2();a0();G0();tD();BF();$D();PD();fD();k2();x0()});function XG(D){return D.includes("/")&&!D.includes("::")}function GG(D){try{let{namespace:F,component:B}=u0(D);return{registryName:F,componentName:B}}catch(F){throw new U(F instanceof Error?F.message:`Invalid component ref: '${D}'`)}}function WG(D,F){return`Ambiguous component reference '${D}'. Found ${F.length} installed matches:
195
+ ocx profile show [name] --global`);let B=await PD.requireInitialized(),$=D??await B.resolveProfile(),_=await B.get($);if(F.json){console.log(JSON.stringify(_,null,2));return}if(console.log(`Profile: ${_.name}`),console.log(`
196
+ Files:`),console.log(` ocx.jsonc: ${_0($)}`),_.opencode)console.log(` opencode.jsonc: ${W2($)}`);if(_.hasAgents)console.log(` AGENTS.md: ${a2($)}`);console.log(`
197
+ OCX Config:`),console.log(JSON.stringify(_.ocx,null,2))}var p5=V(()=>{o0();Q0();$D();yD();x0()});function i5(D){let F=D.command("profile").alias("p").description("Manage profiles (global only)");f5(F),y5(F),d5(F),m5(F),l5(F)}var n5=V(()=>{x5();h5();g5();c5();p5()});import{existsSync as GW}from"fs";import{dirname as s5,join as a5}from"path";async function zW(D,F,B){if(B.isLocked?.())throw Error("Registries are locked. Cannot add.");let $=D.trim();if(!$)throw new U("Registry URL is required");try{let K=new URL($);if(!["http:","https:"].includes(K.protocol))throw new U(`Invalid registry URL: ${$} (must use http or https)`)}catch(K){if(K instanceof U)throw K;throw new U(`Invalid registry URL: ${$}`)}let _=xD($),Q=F.name,Y=B.getRegistries(),q=Y[Q],H=MW(Y,_),{fetchRegistryIndex:J}=await Promise.resolve().then(() => (DF(),F4));await J(_);let X=q!==void 0,z=H!==null,M=X&&xD(q.url)===_,A=z&&H.name!==Q;if(F.dryRun){let K=[];if(X&&!M)K.push(`Registry '${Q}' already exists with a different URL (${q.url}). Run 'ocx registry remove ${Q}' first, then re-add.`);else if(A)K.push(`URL '${_}' is already registered under name '${H.name}'. Run 'ocx registry remove ${H.name}' first, then re-add.`);let j=X&&!M||A,S=X&&M,R=B.targetLabel||"config";return{dryRun:!0,command:"registry add",wouldPerform:S?[]:[{action:"add",target:`registry:${Q}`,details:{url:_}}],validation:{passed:!j,warnings:K.length>0?K:void 0},summary:j?`Would fail: conflict detected for registry '${Q}'`:S?`Registry '${Q}' already configured with same URL (no-op)`:`Would add registry '${Q}' to ${R}`}}if(X&&!M)throw new vF(Q,q.url,_,B.targetLabel);if(A)throw new vF(Q,_,_,B.targetLabel,H.name);if(X&&M)return{name:Q,url:_,updated:!1,alreadyConfigured:!0};return await B.setRegistry(Q,{url:_}),{name:Q,url:_,updated:!1,alreadyConfigured:!1}}function MW(D,F){for(let[B,$]of Object.entries(D))if(xD($.url)===F)return{name:B,config:$};return null}async function AW(D,F){if(F.isLocked?.())throw Error("Registries are locked. Cannot remove.");let B=F.getRegistries();if(!(D in B))throw Error(`Registry '${D}' not found.`);return await F.removeRegistry(D),{removed:D}}function jW(D){let F=D.getRegistries(),B=D.isLocked?.()??!1;return{registries:Object.entries(F).map(([_,Q])=>({name:_,url:Q.url})),locked:B}}async function f6(D,F,B){let $=F.getOptionValueSource("cwd")==="cli";if(D.global&&D.profile)throw new U("Cannot use both --global and --profile flags");if($&&D.profile)throw new U("Cannot use both --cwd and --profile flags");if(D.global&&$)throw new U("Cannot use both --global and --cwd flags");if(D.profile){if(I4(D.profile),!await(await PD.requireInitialized()).exists(D.profile))throw new CD(D.profile);let Y=_0(D.profile);if(!GW(Y))throw new c(`Profile '${D.profile}' has no ocx.jsonc. Run 'ocx profile config ${D.profile}' to create it.`);return{scope:"profile",configPath:Y,configDir:s5(Y),targetLabel:`profile '${D.profile}' config`}}if(D.global){let Q=W0();return{scope:"global",configPath:a5(Q,"ocx.jsonc"),configDir:Q,targetLabel:"global config"}}let _=S2(B);return{scope:"local",configPath:_.path,configDir:_.exists?s5(_.path):a5(B,".opencode"),targetLabel:"local config"}}function o5(D){let F=D.command("registry").description("Manage registries"),B=F.command("add").description("Add a registry").argument("<url>","Registry URL").requiredOption("--name <name>","Registry alias (required, used as lookup key for alias/component refs)").option("--dry-run","Validate registry without adding to config");t0(B),V8(B),rD(B),B.action(async(Q,Y,q)=>{let H;try{let J=Y.cwd??process.cwd();H=await f6(Y,q,J);let{configDir:X,configPath:z}=H,M=await K0(X);if(!M){let j=H.scope==="global"?"Run 'ocx init --global' first.":H.scope==="profile"?`Run 'ocx profile config ${Y.profile}' to create it.`:"Run 'ocx init' first.";W.error(`${H.targetLabel} not found. ${j}`),process.exit(1)}let A=await zW(Q,Y,{getRegistries:()=>M.registries,isLocked:()=>M.lockRegistries??!1,setRegistry:async(j,S)=>{M.registries[j]=S,await D8(X,M,z)},targetLabel:H.targetLabel});if("dryRun"in A&&A.dryRun){z0(A,{json:Y.json,quiet:Y.quiet});return}let K=A;if(Y.json)LD({success:!0,data:K});else if(!Y.quiet)if(K.alreadyConfigured)W.info(`Registry already configured (no changes): ${K.name}`);else if(K.updated)W.success(`Updated registry in ${H.targetLabel}: ${K.name} -> ${K.url}`);else W.success(`Added registry to ${H.targetLabel}: ${K.name} -> ${K.url}`)}catch(J){t(J,{json:Y.json})}});let $=F.command("remove").description("Remove a registry").argument("<name>","Registry name");t0($),V8($),rD($),$.action(async(Q,Y,q)=>{try{let H=Y.cwd??process.cwd(),J=await f6(Y,q,H),X=await K0(J.configDir);if(!X){let M=J.scope==="global"?"Run 'ocx init --global' first.":J.scope==="profile"?`Run 'ocx profile config ${Y.profile}' to create it.`:"Run 'ocx init' first.";W.error(`${J.targetLabel} not found. ${M}`),process.exit(1)}let z=await AW(Q,{getRegistries:()=>X.registries,isLocked:()=>X.lockRegistries??!1,removeRegistry:async(M)=>{delete X.registries[M],await D8(J.configDir,X,J.configPath)}});if(Y.json)LD({success:!0,data:z});else if(!Y.quiet)W.success(`Removed registry from ${J.targetLabel}: ${z.removed}`)}catch(H){t(H,{json:Y.json})}});let _=F.command("list").description("List configured registries");t0(_),V8(_),rD(_),_.action(async(Q,Y)=>{try{let q=Q.cwd??process.cwd(),H=await f6(Q,Y,q),J=await K0(H.configDir);if(!J){let z=H.scope==="global"?"Run 'ocx init --global' first.":H.scope==="profile"?`Run 'ocx profile config ${Q.profile}' to create it.`:"Run 'ocx init' first.";W.warn(`${H.targetLabel} not found. ${z}`);return}let X=jW({getRegistries:()=>J.registries,isLocked:()=>J.lockRegistries??!1});if(Q.json)LD({success:!0,data:X});else if(!Q.quiet)if(X.registries.length===0)W.info("No registries configured.");else{let z=H.scope==="global"?" (global)":H.scope==="profile"?` (profile '${Q.profile}')`:"";W.info(`Configured registries${z}${X.locked?P.yellow(" (locked)"):""}:`);for(let M of X.registries)console.log(` ${P.cyan(M.name)}: ${M.url}`)}}catch(q){t(q,{json:Q.json})}})}var r5=V(()=>{G2();o0();Q0();eD();BF();$D();yD();hD();k2();x0()});function KW(D){return D.includes("/")&&!D.includes("::")}function UW(D){try{let{namespace:F,component:B}=u0(D);return{registryName:F,componentName:B}}catch(F){throw new U(F instanceof Error?F.message:`Invalid component ref: '${D}'`)}}function VW(D,F){return`Ambiguous component reference '${D}'. Found ${F.length} installed matches:
197
198
  `+F.map((B)=>` - ${B}`).join(`
198
199
  `)+`
199
200
 
200
- Use one of the canonical IDs above.`}function zG(D){return`Component '${D}' is not installed.
201
- Run 'ocx search --installed' to see installed components.`}function MG(D,F){let B=Object.keys(F.installed);if(F.installed[D])return D;if(XG(D)){let{registryName:$,componentName:_}=GG(D),Q=B.filter((Y)=>{let q=Z2(Y);return q.registryName===$&&q.name===_}).sort();if(Q.length===1){let[Y]=Q;if(!Y)throw Error("Unexpected empty canonical ID result");return Y}if(Q.length>1)throw new U(WG(D,Q))}throw new MD(zG(D))}function y8(D,F){return D.map((B)=>MG(B,F))}var x6=V(()=>{P0();$D();iF()});import{realpathSync as s5}from"fs";import{rm as AG}from"fs/promises";import{sep as jG}from"path";function a5(D,F,B){let $=H0(D,B),_;try{_=s5($)}catch(Q){let Y=Q.code;if(Y==="ENOENT"||Y==="ENOTDIR")return{path:B,targetReal:null};if(Y==="ELOOP")throw new U(`Security violation: symlink loop detected at ${B}`);if(Y==="EACCES"||Y==="EPERM")throw new U(`Security violation: cannot verify path ${B}`);throw Q}if(_===F)throw new U(`Security violation: cannot delete project root directory (${B})`);if(!_.startsWith(F+jG))throw new U("Security violation: path escapes project directory");return{path:B,targetReal:_}}function KG(D,F,B){let $=a5(D,F,B.path);if(!B.targetReal){if($.targetReal)throw new U(`Security violation: missing target reappeared during removal (${B.path})`);return null}if(!$.targetReal)return null;if($.targetReal!==B.targetReal)throw new U(`Security violation: target changed during removal (${B.path})`);return $.targetReal}function UG(D){let F=new Set,B=[];for(let $ of D){if(F.has($))continue;F.add($),B.push($)}return B}function o5(D){let F=D.command("remove").description("Remove installed components").argument("<components...>","Component refs to remove (canonical ID or alias/component)");oD(F),F.option("-f, --force","Force removal even if files have been modified"),w0(F),F.option("--dry-run","Show what would be removed without making changes").action(async(B,$)=>{try{await VG(B,$)}catch(_){t(_,{json:$.json})}})}async function VG(D,F){let B=F.cwd??process.cwd(),$=await V0.requireInitialized(B);if(D.length===0)throw new U("No components specified. Specify at least one component ID.");let _=await J0($.cwd);if(!_||Object.keys(_.installed).length===0)throw new MD("No components installed.");let Q=UG(y8(D,_)),Y=F.quiet?null:jD({text:"Removing components..."});Y?.start();let q=[],H=[],J=[],X=[],z=!1,M;try{M=s5($.cwd)}catch(A){throw new U("Cannot resolve project directory")}try{for(let A of Q){let K=_.installed[A];if(!K)throw Error(`Resolved component '${A}' was not found in receipt.`);let j=[];for(let Z of K.files){if(!Z.path||Z.path===".")throw new U(`Invalid file path in receipt for '${A}': path cannot be empty or "."`);try{j.push(a5($.cwd,M,Z.path))}catch(s){if(s instanceof aD)throw new U(`Security violation in receipt for '${A}': ${s.message}`);throw s}}let S=await N3($.cwd,K);if(!S.intact){z=!0;let Z=S.modified.map((s)=>` - ${s}`).join(`
201
+ Use one of the canonical IDs above.`}function EW(D){return`Component '${D}' is not installed.
202
+ Run 'ocx search --installed' to see installed components.`}function LW(D,F){let B=Object.keys(F.installed);if(F.installed[D])return D;if(KW(D)){let{registryName:$,componentName:_}=UW(D),Q=B.filter((Y)=>{let q=R2(Y);return q.registryName===$&&q.name===_}).sort();if(Q.length===1){let[Y]=Q;if(!Y)throw Error("Unexpected empty canonical ID result");return Y}if(Q.length>1)throw new U(VW(D,Q))}throw new MD(EW(D))}function h8(D,F){return D.map((B)=>LW(B,F))}var h6=V(()=>{P0();$D();nF()});import{realpathSync as t5}from"fs";import{rm as wW}from"fs/promises";import{sep as OW}from"path";function e5(D,F,B){let $=J0(D,B),_;try{_=t5($)}catch(Q){let Y=Q.code;if(Y==="ENOENT"||Y==="ENOTDIR")return{path:B,targetReal:null};if(Y==="ELOOP")throw new U(`Security violation: symlink loop detected at ${B}`);if(Y==="EACCES"||Y==="EPERM")throw new U(`Security violation: cannot verify path ${B}`);throw Q}if(_===F)throw new U(`Security violation: cannot delete project root directory (${B})`);if(!_.startsWith(F+OW))throw new U("Security violation: path escapes project directory");return{path:B,targetReal:_}}function bW(D,F,B){let $=e5(D,F,B.path);if(!B.targetReal){if($.targetReal)throw new U(`Security violation: missing target reappeared during removal (${B.path})`);return null}if(!$.targetReal)return null;if($.targetReal!==B.targetReal)throw new U(`Security violation: target changed during removal (${B.path})`);return $.targetReal}function ZW(D){let F=new Set,B=[];for(let $ of D){if(F.has($))continue;F.add($),B.push($)}return B}function D$(D){let F=D.command("remove").description("Remove installed components").argument("<components...>","Component refs to remove (canonical ID or alias/component)");rD(F),F.option("-f, --force","Force removal even if files have been modified"),L0(F),F.option("--dry-run","Show what would be removed without making changes").action(async(B,$)=>{try{await RW(B,$)}catch(_){t(_,{json:$.json})}})}async function RW(D,F){let B=F.cwd??process.cwd(),$=await U0.requireInitialized(B);if(D.length===0)throw new U("No components specified. Specify at least one component ID.");let _=await X0($.cwd);if(!_||Object.keys(_.installed).length===0)throw new MD("No components installed.");let Q=ZW(h8(D,_)),Y=F.quiet?null:jD({text:"Removing components..."});Y?.start();let q=[],H=[],J=[],X=[],z=!1,M;try{M=t5($.cwd)}catch(A){throw new U("Cannot resolve project directory")}try{for(let A of Q){let K=_.installed[A];if(!K)throw Error(`Resolved component '${A}' was not found in receipt.`);let j=[];for(let R of K.files){if(!R.path||R.path===".")throw new U(`Invalid file path in receipt for '${A}': path cannot be empty or "."`);try{j.push(e5($.cwd,M,R.path))}catch(s){if(s instanceof oD)throw new U(`Security violation in receipt for '${A}': ${s.message}`);throw s}}let S=await S3($.cwd,K);if(!S.intact){z=!0;let R=S.modified.map((s)=>` - ${s}`).join(`
202
203
  `);if(F.force)X.push(`Component '${A}' has been modified but will be force-removed:
203
- ${Z}`);else X.push(`Component '${A}' has been modified. Use --force to remove anyway:
204
- ${Z}`)}J.push({canonicalId:A,files:j})}if(F.dryRun){Y?.stop();let A={dryRun:!0,command:"remove",wouldPerform:J.flatMap(({canonicalId:K,files:j})=>j.map((S)=>({action:"delete",target:S.path,details:{component:K}}))),validation:{passed:!z||Boolean(F.force),warnings:X.length>0?X:void 0},summary:`${J.length} component(s), ${J.reduce((K,j)=>K+j.files.length,0)} file(s) would be removed`};z0(A,{json:F.json,quiet:F.quiet,hints:z&&!F.force?["Add --force to remove modified files"]:void 0});return}if(z&&!F.force){Y?.fail("File integrity check failed");let A;for(let K of J){let j=_.installed[K.canonicalId];if(!j)continue;try{let S=await N3($.cwd,j);if(!S.intact){A={canonicalId:K.canonicalId,integrity:S};break}}catch(S){throw new U(`Failed to check integrity for '${K.canonicalId}': ${S instanceof Error?S.message:String(S)}`)}}if(A){let K=A.integrity.modified.length>0?`Modified files:
205
- ${A.integrity.modified.map((Z)=>` - ${Z}`).join(`
204
+ ${R}`);else X.push(`Component '${A}' has been modified. Use --force to remove anyway:
205
+ ${R}`)}J.push({canonicalId:A,files:j})}if(F.dryRun){Y?.stop();let A={dryRun:!0,command:"remove",wouldPerform:J.flatMap(({canonicalId:K,files:j})=>j.map((S)=>({action:"delete",target:S.path,details:{component:K}}))),validation:{passed:!z||Boolean(F.force),warnings:X.length>0?X:void 0},summary:`${J.length} component(s), ${J.reduce((K,j)=>K+j.files.length,0)} file(s) would be removed`};z0(A,{json:F.json,quiet:F.quiet,hints:z&&!F.force?["Add --force to remove modified files"]:void 0});return}if(z&&!F.force){Y?.fail("File integrity check failed");let A;for(let K of J){let j=_.installed[K.canonicalId];if(!j)continue;try{let S=await S3($.cwd,j);if(!S.intact){A={canonicalId:K.canonicalId,integrity:S};break}}catch(S){throw new U(`Failed to check integrity for '${K.canonicalId}': ${S instanceof Error?S.message:String(S)}`)}}if(A){let K=A.integrity.modified.length>0?`Modified files:
206
+ ${A.integrity.modified.map((R)=>` - ${R}`).join(`
206
207
  `)}`:"",j=A.integrity.missing.length>0?`Missing files:
207
- ${A.integrity.missing.map((Z)=>` - ${Z}`).join(`
208
+ ${A.integrity.missing.map((R)=>` - ${R}`).join(`
208
209
  `)}`:"",S=[K,j].filter(Boolean).join(`
209
210
  `);throw new U(`Component '${A.canonicalId}' has been modified. Use --force to remove anyway.
210
- ${S}`)}}for(let{canonicalId:A,files:K}of J){for(let j of K){let S=KG($.cwd,M,j);if(!S){if(F.verbose)G.info(` \u2298 Skipped ${j.path} (not found)`);continue}if(await AG(S,{force:!0}),F.verbose)G.info(` \u2713 Removed ${j.path}`)}delete _.installed[A],q.push(A)}if(await K0($.cwd,_),Y?.succeed(`Removed ${q.length} component(s)`),F.json)console.log(JSON.stringify({success:!0,removed:q,notFound:H},null,2));else if(!F.quiet){G.info("");for(let A of q){let K=Z2(A);G.success(`\u2713 Removed ${K.registryName}/${K.name}@${K.revision}`)}G.info(""),G.success(`Done! Removed ${q.length} component(s).`)}}catch(A){throw Y?.fail("Failed to remove components"),A}}var r5=V(()=>{gF();tD();x6();BF();$D();PD();fD();c2();iF();x0();m0()});var e5=d0((t5,f8)=>{((D,F)=>{if(typeof define==="function"&&define.amd)define([],F);else if(typeof f8==="object"&&f8.exports)f8.exports=F();else D.fuzzysort=F()})(t5,(D)=>{var F=(w,E)=>{if(!w||!E)return YD;var u=A(w);if(!f(E))E=M(E);var m=u.bitflags;if((m&E._bitflags)!==m)return YD;return j(u,E)},B=(w,E,u)=>{if(!w)return u?.all?K(E,u):bD;var m=A(w),g=m.bitflags,h=m.containsSpace,C=X(u?.threshold||0),o=u?.limit||_D,d=0,GD=0,HD=E.length;function $0(u2){if(d<o)GF.add(u2),++d;else if(++GD,u2._score>GF.peek()._score)GF.replaceTop(u2)}if(u?.key){var iD=u.key;for(var WD=0;WD<HD;++WD){var rD=E[WD],UD=v(rD,iD);if(!UD)continue;if(!f(UD))UD=M(UD);if((g&UD._bitflags)!==g)continue;var wD=j(m,UD);if(wD===YD)continue;if(wD._score<C)continue;wD.obj=rD,$0(wD)}}else if(u?.keys){var M2=u.keys,A0=M2.length;D:for(var WD=0;WD<HD;++WD){var rD=E[WD];{var nD=0;for(var JD=0;JD<A0;++JD){var iD=M2[JD],UD=v(rD,iD);if(!UD){k[JD]=B0;continue}if(!f(UD))UD=M(UD);k[JD]=UD,nD|=UD._bitflags}if((g&nD)!==g)continue}if(h)for(let VD=0;VD<m.spaceSearches.length;VD++)FD[VD]=r;for(var JD=0;JD<A0;++JD){if(UD=k[JD],UD===B0){i[JD]=B0;continue}if(i[JD]=j(m,UD,!1,h),i[JD]===YD){i[JD]=B0;continue}if(h)for(let OD=0;OD<m.spaceSearches.length;OD++){if(KD[OD]>-1000){if(FD[OD]>r){var dD=(FD[OD]+KD[OD])/4;if(dD>FD[OD])FD[OD]=dD}}if(KD[OD]>FD[OD])FD[OD]=KD[OD]}}if(h){for(let VD=0;VD<m.spaceSearches.length;VD++)if(FD[VD]===r)continue D}else{var qD=!1;for(let VD=0;VD<A0;VD++)if(i[VD]._score!==r){qD=!0;break}if(!qD)continue}var Y0=new q(A0);for(let VD=0;VD<A0;VD++)Y0[VD]=i[VD];if(h){var mD=0;for(let VD=0;VD<m.spaceSearches.length;VD++)mD+=FD[VD]}else{var mD=r;for(let OD=0;OD<A0;OD++){var wD=Y0[OD];if(wD._score>-1000){if(mD>r){var dD=(mD+wD._score)/4;if(dD>mD)mD=dD}}if(wD._score>mD)mD=wD._score}}if(Y0.obj=rD,Y0._score=mD,u?.scoreFn){if(mD=u.scoreFn(Y0),!mD)continue;mD=X(mD),Y0._score=mD}if(mD<C)continue;$0(Y0)}}else for(var WD=0;WD<HD;++WD){var UD=E[WD];if(!UD)continue;if(!f(UD))UD=M(UD);if((g&UD._bitflags)!==g)continue;var wD=j(m,UD);if(wD===YD)continue;if(wD._score<C)continue;$0(wD)}if(d===0)return bD;var A2=Array(d);for(var WD=d-1;WD>=0;--WD)A2[WD]=GF.poll();return A2.total=d+GD,A2},$=(w,E="<b>",u="</b>")=>{var m=typeof E==="function"?E:void 0,g=w.target,h=g.length,C=w.indexes,o="",d=0,GD=0,HD=!1,$0=[];for(var iD=0;iD<h;++iD){var WD=g[iD];if(C[GD]===iD){if(++GD,!HD)if(HD=!0,m)$0.push(o),o="";else o+=E;if(GD===C.length){if(m)o+=WD,$0.push(m(o,d++)),o="",$0.push(g.substr(iD+1));else o+=WD+u+g.substr(iD+1);break}}else if(HD)if(HD=!1,m)$0.push(m(o,d++)),o="";else o+=u;o+=WD}return m?$0:o},_=(w)=>{if(typeof w==="number")w=""+w;else if(typeof w!=="string")w="";var E=s(w);return H(w,{_targetLower:E._lower,_targetLowerCodes:E.lowerCodes,_bitflags:E.bitflags})},Q=()=>{O.clear(),b.clear()};class Y{get["indexes"](){return this._indexes.slice(0,this._indexes.len).sort((w,E)=>w-E)}set["indexes"](w){return this._indexes=w}["highlight"](w,E){return $(this,w,E)}get["score"](){return J(this._score)}set["score"](w){this._score=X(w)}}class q extends Array{get["score"](){return J(this._score)}set["score"](w){this._score=X(w)}}var H=(w,E)=>{let u=new Y;return u.target=w,u.obj=E.obj??YD,u._score=E._score??r,u._indexes=E._indexes??[],u._targetLower=E._targetLower??"",u._targetLowerCodes=E._targetLowerCodes??YD,u._nextBeginningIndexes=E._nextBeginningIndexes??YD,u._bitflags=E._bitflags??0,u},J=(w)=>{if(w===r)return 0;if(w>1)return w;return Math.E**(((-w+1)**0.04307-1)*-2)},X=(w)=>{if(w===0)return r;if(w>1)return w;return 1-Math.pow(Math.log(w)/-2+1,23.218017181332716)},z=(w)=>{if(typeof w==="number")w=""+w;else if(typeof w!=="string")w="";w=w.trim();var E=s(w),u=[];if(E.containsSpace){var m=w.split(/\s+/);m=[...new Set(m)];for(var g=0;g<m.length;g++){if(m[g]==="")continue;var h=s(m[g]);u.push({lowerCodes:h.lowerCodes,_lower:m[g].toLowerCase(),containsSpace:!1})}}return{lowerCodes:E.lowerCodes,_lower:E._lower,containsSpace:E.containsSpace,bitflags:E.bitflags,spaceSearches:u}},M=(w)=>{if(w.length>999)return _(w);var E=O.get(w);if(E!==void 0)return E;return E=_(w),O.set(w,E),E},A=(w)=>{if(w.length>999)return z(w);var E=b.get(w);if(E!==void 0)return E;return E=z(w),b.set(w,E),E},K=(w,E)=>{var u=[];u.total=w.length;var m=E?.limit||_D;if(E?.key)for(var g=0;g<w.length;g++){var h=w[g],C=v(h,E.key);if(C==YD)continue;if(!f(C))C=M(C);var o=H(C.target,{_score:C._score,obj:h});if(u.push(o),u.length>=m)return u}else if(E?.keys)for(var g=0;g<w.length;g++){var h=w[g],d=new q(E.keys.length);for(var GD=E.keys.length-1;GD>=0;--GD){var C=v(h,E.keys[GD]);if(!C){d[GD]=B0;continue}if(!f(C))C=M(C);C._score=r,C._indexes.len=0,d[GD]=C}if(d.obj=h,d._score=r,u.push(d),u.length>=m)return u}else for(var g=0;g<w.length;g++){var C=w[g];if(C==YD)continue;if(!f(C))C=M(C);if(C._score=r,C._indexes.len=0,u.push(C),u.length>=m)return u}return u},j=(w,E,u=!1,m=!1)=>{if(u===!1&&w.containsSpace)return S(w,E,m);var{_lower:g,lowerCodes:h}=w,C=h[0],o=E._targetLowerCodes,d=h.length,GD=o.length,WD=0,HD=0,$0=0;for(;;){var iD=C===o[HD];if(iD){if(L[$0++]=HD,++WD,WD===d)break;C=h[WD]}if(++HD,HD>=GD)return YD}var WD=0,rD=!1,UD=0,wD=E._nextBeginningIndexes;if(wD===YD)wD=E._nextBeginningIndexes=x(E.target);HD=L[0]===0?0:wD[L[0]-1];var M2=0;if(HD!==GD)for(;;)if(HD>=GD){if(WD<=0)break;if(++M2,M2>200)break;--WD;var A0=e[--UD];HD=wD[A0]}else{var iD=h[WD]===o[HD];if(iD){if(e[UD++]=HD,++WD,WD===d){rD=!0;break}++HD}else HD=wD[HD]}var nD=d<=1?-1:E._targetLower.indexOf(g,L[0]),JD=!!~nD,dD=!JD?!1:nD===0||E._nextBeginningIndexes[nD-1]===nD;if(JD&&!dD)for(var qD=0;qD<wD.length;qD=wD[qD]){if(qD<=nD)continue;for(var Y0=0;Y0<d;Y0++)if(h[Y0]!==E._targetLowerCodes[qD+Y0])break;if(Y0===d){nD=qD,dD=!0;break}}var mD=(VD)=>{var OD=0,o6=0;for(var D2=1;D2<d;++D2)if(VD[D2]-VD[D2-1]!==1)OD-=VD[D2],++o6;var r$=VD[d-1]-VD[0]-(d-1);if(OD-=(12+r$)*o6,VD[0]!==0)OD-=VD[0]*VD[0]*0.2;if(!rD)OD*=1000;else{var a8=1;for(var D2=wD[0];D2<GD;D2=wD[D2])++a8;if(a8>24)OD*=(a8-24)*10}if(OD-=(GD-d)/2,JD)OD/=1+d*d*1;if(dD)OD/=1+d*d*1;return OD-=(GD-d)/2,OD};if(!rD){if(JD)for(var qD=0;qD<d;++qD)L[qD]=nD+qD;var A2=L,u2=mD(A2)}else if(dD){for(var qD=0;qD<d;++qD)L[qD]=nD+qD;var A2=L,u2=mD(L)}else var A2=e,u2=mD(e);E._score=u2;for(var qD=0;qD<d;++qD)E._indexes[qD]=A2[qD];E._indexes.len=d;let y3=new Y;return y3.target=E.target,y3._score=E._score,y3._indexes=E._indexes,y3},S=(w,E,u)=>{var m=new Set,g=0,h=YD,C=0,o=w.spaceSearches,d=o.length,GD=0,HD=()=>{for(let dD=GD-1;dD>=0;dD--)E._nextBeginningIndexes[p[dD*2+0]]=p[dD*2+1]},$0=!1;for(var JD=0;JD<d;++JD){KD[JD]=r;var iD=o[JD];if(h=j(iD,E),u){if(h===YD)continue;$0=!0}else if(h===YD)return HD(),YD;var WD=JD===d-1;if(!WD){var rD=h._indexes,UD=!0;for(let qD=0;qD<rD.len-1;qD++)if(rD[qD+1]-rD[qD]!==1){UD=!1;break}if(UD){var wD=rD[rD.len-1]+1,M2=E._nextBeginningIndexes[wD-1];for(let qD=wD-1;qD>=0;qD--){if(M2!==E._nextBeginningIndexes[qD])break;E._nextBeginningIndexes[qD]=wD,p[GD*2+0]=qD,p[GD*2+1]=M2,GD++}}}if(g+=h._score/d,KD[JD]=h._score/d,h._indexes[0]<C)g-=(C-h._indexes[0])*2;C=h._indexes[0];for(var A0=0;A0<h._indexes.len;++A0)m.add(h._indexes[A0])}if(u&&!$0)return YD;HD();var nD=j(w,E,!0);if(nD!==YD&&nD._score>g){if(u)for(var JD=0;JD<d;++JD)KD[JD]=nD._score/d;return nD}if(u)h=E;h._score=g;var JD=0;for(let dD of m)h._indexes[JD++]=dD;return h._indexes.len=JD,h},Z=(w)=>w.replace(/\p{Script=Latin}+/gu,(E)=>E.normalize("NFD")).replace(/[\u0300-\u036f]/g,""),s=(w)=>{w=Z(w);var E=w.length,u=w.toLowerCase(),m=[],g=0,h=!1;for(var C=0;C<E;++C){var o=m[C]=u.charCodeAt(C);if(o===32){h=!0;continue}var d=o>=97&&o<=122?o-97:o>=48&&o<=57?26:o<=127?30:31;g|=1<<d}return{lowerCodes:m,bitflags:g,containsSpace:h,_lower:u}},N=(w)=>{var E=w.length,u=[],m=0,g=!1,h=!1;for(var C=0;C<E;++C){var o=w.charCodeAt(C),d=o>=65&&o<=90,GD=d||o>=97&&o<=122||o>=48&&o<=57,HD=d&&!g||!h||!GD;if(g=d,h=GD,HD)u[m++]=C}return u},x=(w)=>{w=Z(w);var E=w.length,u=N(w),m=[],g=u[0],h=0;for(var C=0;C<E;++C)if(g>C)m[C]=g;else g=u[++h],m[C]=g===void 0?E:g;return m},O=new Map,b=new Map,L=[],e=[],p=[],FD=[],KD=[],k=[],i=[],v=(w,E)=>{var u=w[E];if(u!==void 0)return u;if(typeof E==="function")return E(w);var m=E;if(!Array.isArray(E))m=E.split(".");var g=m.length,h=-1;while(w&&++h<g)w=w[m[h]];return w},f=(w)=>{return typeof w==="object"&&typeof w._bitflags==="number"},_D=1/0,r=-_D,bD=[];bD.total=0;var YD=null,B0=_(""),s8=(w)=>{var E=[],u=0,m={},g=(h)=>{for(var C=0,o=E[C],d=1;d<u;){var GD=d+1;C=d,GD<u&&E[GD]._score<E[d]._score&&(C=GD),E[C-1>>1]=E[C],d=1+(C<<1)}for(var HD=C-1>>1;C>0&&o._score<E[HD]._score;HD=(C=HD)-1>>1)E[C]=E[HD];E[C]=o};return m.add=(h)=>{var C=u;E[u++]=h;for(var o=C-1>>1;C>0&&h._score<E[o]._score;o=(C=o)-1>>1)E[C]=E[o];E[C]=h},m.poll=(h)=>{if(u!==0){var C=E[0];return E[0]=E[--u],g(),C}},m.peek=(h)=>{if(u!==0)return E[0]},m.replaceTop=(h)=>{E[0]=h,g()},m},GF=s8();return{single:F,go:B,prepare:_,cleanup:Q}})});var F$={};j2(F$,{runSearchCore:()=>D$,runSearchCommandAction:()=>EG});async function EG(D,F){if(F.installed){let $=await J0(F.cwd);if(!$||Object.keys($.installed).length===0){if(F.json)LD({success:!0,data:{components:[]}});else G.info("No components installed.");return}let _=Object.entries($.installed).map(([Q,Y])=>({name:`${Y.registryName}/${Y.name}`,registry:Y.registryUrl,version:Y.revision,installedAt:void 0}));if(F.json)LD({success:!0,data:{components:_}});else{G.info(`Installed components (${_.length}):`);for(let Q of _)console.log(` ${P.cyan(Q.name)} ${P.dim(`v${Q.version}`)} from ${Q.registry}`)}return}let B;if(F.profile){let $=await o0.create(F.cwd,{profile:F.profile});B={cwd:$.getCwd(),getRegistries:()=>$.getRegistries(),getComponentPath:()=>$.getComponentPath()}}else B=await V0.requireInitialized(F.cwd);await D$(D,F,B)}async function D$(D,F,B){let $=B.getRegistries();if(F.verbose)G.info(`Searching in ${Object.keys($).length} registries...`);let _=[],Q=jD({text:"Searching registries...",quiet:F.quiet||F.verbose});if(!F.json&&!F.verbose)Q.start();for(let[q,H]of Object.entries($))try{if(F.verbose)G.info(`Fetching index from ${q} (${H.url})...`);let J=await T2(H.url);if(F.verbose)G.info(`Found ${J.components.length} components in ${q}`);for(let X of J.components)_.push({name:`${q}/${X.name}`,description:X.description,type:X.type,registry:q})}catch(J){if(F.verbose)G.warn(`Failed to fetch registry ${q}: ${J instanceof Error?J.message:String(J)}`)}if(!F.json&&!F.verbose)Q.stop();let Y=_;if(D)Y=y6.default.go(D,_,{keys:["name","description"],limit:F.limit}).map((H)=>H.obj);else Y=Y.slice(0,F.limit);if(F.json){LD({success:!0,data:{components:Y}});return}if(Y.length===0){G.info("No components found.");return}G.info(`Found ${Y.length} components:`);for(let q of Y)console.log(` ${P.cyan(q.name)} ${P.dim(`(${q.type})`)} - ${q.description}`)}var y6;var B$=V(()=>{W2();gF();O3();DF();L1();fD();m0();y6=f3(e5(),1)});function LG(D){let F=parseInt(D,10);if(Number.isNaN(F)||F<=0)throw new X9("Must be a positive integer");return F}function $$(D){let F=D.command("search").alias("list").description("Search for components across registries or list installed").argument("[query]","Search query").option("--installed","List installed components only",!1).option("-p, --profile <name>","Use specific profile").addOption(new H2("--limit <n>","Limit results").default(20).argParser(LG));oD(F),w0(F),F.action(async(B,$)=>{try{let{runSearchCommandAction:_}=await Promise.resolve().then(() => (B$(),F$));await _(B,$)}catch(_){t(_,{json:$.json})}})}var _$=V(()=>{B8();PD();x0()});function Q$(D){let F=["curl","npm","yarn","pnpm","bun"],B=F.find(($)=>$===D);if(!B)throw new vD(`Invalid install method: "${D}"
211
- Valid methods: ${F.join(", ")}`);return B}function B3(){if(wG())return"curl";let D=process.argv[1]??"";if(OG(D))return"unknown";if(bG(D))return"yarn";if(RG(D))return"pnpm";if(ZG(D))return"bun";if(NG(D))return"npm";let F=process.env.npm_config_user_agent??"";if(F.includes("yarn"))return"yarn";if(F.includes("pnpm"))return"pnpm";if(F.includes("bun"))return"bun";if(F.includes("npm"))return"npm";return"unknown"}function h8(){if(typeof Bun<"u"&&Bun.main.startsWith("/$bunfs/"))return process.execPath;return process.argv[1]??process.execPath}var wG=()=>Bun.main.startsWith("/$bunfs/"),OG=(D)=>D.includes("/_npx/")||D.includes("/.cache/bunx/")||D.includes("/.pnpm/_temp/"),bG=(D)=>D.includes("/.yarn/global")||D.includes("/.config/yarn/global"),RG=(D)=>D.includes("/.pnpm/")||D.includes("/pnpm/global"),ZG=(D)=>D.includes("/.bun/bin")||D.includes("/.bun/install/global"),NG=(D)=>D.includes("/.npm/")||D.includes("/node_modules/");var m8=V(()=>{$D()});import{existsSync as h6,lstatSync as H$,readdirSync as SG,realpathSync as Y$,rmSync as kG,unlinkSync as J$}from"fs";import{homedir as X$}from"os";import g0 from"path";function f6(D,F=0){LD({success:!0,data:D}),process.exit(F)}function qF(D,F,B,$){let _={success:!1,error:{code:D,message:F,...$&&{details:$}},exitCode:B,meta:{timestamp:new Date().toISOString()}};LD(_),process.exit(B)}function m6(D){return D instanceof Error&&"code"in D}function P3(D){let F=X$();if(!F)return D;if(D===F)return"~";if(D.startsWith(F+g0.sep))return`~${D.slice(F.length)}`;return D}function d8(D,F){let B=g0.normalize(D),$=g0.normalize(F),_=g0.relative(B,$);if(_.startsWith("..")||g0.isAbsolute(_))return null;return _}function IG(D,F){return d8(D,F)!==null}function TG(D,F){if(!h6(F))return{contained:!0};try{let B=Y$(D),$=Y$(F);return{contained:d8(B,$)!==null}}catch(B){if(m6(B)&&(B.code==="EACCES"||B.code==="EPERM"))return{contained:!1,error:"permission"};return{contained:!1,error:"io"}}}function G$(D){try{let F=H$(D);if(F.isSymbolicLink())return{valid:!1,reason:"symlink"};if(!F.isDirectory())return{valid:!1,reason:"not-directory"};return{valid:!0}}catch(F){if(m6(F)){if(F.code==="ENOENT")return{valid:!1,reason:"not-found"};if(F.code==="EACCES"||F.code==="EPERM")return{valid:!1,reason:"permission"}}return{valid:!1,reason:"permission"}}}function x3(D){if(!h6(D))return"missing";try{let F=H$(D);if(F.isSymbolicLink())return"symlink";if(F.isDirectory())return"directory";return"file"}catch{return"missing"}}function vG(D){if(!h6(D))return!0;try{return SG(D).length===0}catch{return!1}}function q$(D){if(D.kind==="missing")return"safe";if(D.kind==="symlink")return IG(D.rootPath,D.absolutePath)?"safe":"forbidden";let F=TG(D.rootPath,D.absolutePath);if(F.error)return"error";return F.contained?"safe":"forbidden"}function HF(D){return D==="npm"||D==="pnpm"||D==="bun"||D==="yarn"}function c8(D){switch(D){case"npm":return"npm uninstall -g ocx";case"pnpm":return"pnpm remove -g ocx";case"bun":return"bun remove -g ocx";case"yarn":return"yarn global remove ocx";default:return"npm uninstall -g ocx"}}function g6(){let D=process.env.XDG_CONFIG_HOME||g0.join(X$(),".config");return g0.join(D,"opencode")}function W$(){let D=g6(),F=[],B=X2(),$=d8(D,B);if($){let q=x3(B);F.push({rootPath:D,relativePath:$,absolutePath:B,displayPath:P3(B),kind:q,deleteIfEmpty:!1,safetyStatus:q$({rootPath:D,absolutePath:B,kind:q})})}let _=I2(),Q=d8(D,_);if(Q){let q=x3(_);F.push({rootPath:D,relativePath:Q,absolutePath:_,displayPath:P3(_),kind:q,deleteIfEmpty:!1,safetyStatus:q$({rootPath:D,absolutePath:_,kind:q})})}let Y=x3(D);return F.push({rootPath:D,relativePath:".",absolutePath:D,displayPath:P3(D),kind:Y,deleteIfEmpty:!0,safetyStatus:Y==="missing"?"safe":"safe"}),F}function z$(){let D=B3();if(HF(D))return null;if(D==="curl"){let F=h8(),B=x3(F);return{rootPath:g0.dirname(F),relativePath:g0.basename(F),absolutePath:F,displayPath:P3(F),kind:B,deleteIfEmpty:!1,safetyStatus:B==="missing"?"safe":"safe"}}return null}function CG(D){if(D.kind==="missing")return{target:D,success:!0,skipped:!0,reason:"not found"};if(D.safetyStatus==="forbidden")return{target:D,success:!1,skipped:!0,reason:"containment violation",error:Error("Target escapes containment boundary")};if(D.deleteIfEmpty&&D.kind==="directory"){if(!vG(D.absolutePath))return{target:D,success:!0,skipped:!0,reason:"not empty"}}try{if(D.kind==="directory")kG(D.absolutePath,{recursive:!0,force:!0});else J$(D.absolutePath);return{target:D,success:!0,skipped:!1}}catch(F){let B=F instanceof Error?F:Error(String(F)),$=m6(F)&&(F.code==="EACCES"||F.code==="EPERM")?"permission denied":void 0;return{target:D,success:!1,skipped:!1,reason:$,error:B}}}function M$(D){return D.map(CG)}function A$(D,F={}){let B={rootPath:g0.dirname(D),relativePath:g0.basename(D),absolutePath:D,displayPath:P3(D),kind:x3(D),deleteIfEmpty:!1,safetyStatus:"safe"};if(B.kind==="missing")return{target:B,success:!0,skipped:!0,reason:"not found"};if(process.platform==="win32"){if(!F.suppressOutput)G.info(`To complete uninstall, manually delete: ${B.displayPath}`);return{target:B,success:!0,skipped:!0}}try{return J$(D),{target:B,success:!0,skipped:!1}}catch($){let _=$ instanceof Error?$:Error(String($));return{target:B,success:!1,skipped:!1,reason:"permission denied",error:_}}}function uG(D,F,B){let{dryRunResult:$,hints:_}=j$(D,F,B);z0($,{hints:_})}function j$(D,F,B){let $=D.filter((q)=>q.kind!=="missing"),_=[];for(let q of $)_.push({action:"delete",target:q.displayPath,details:{kind:q.kind,...q.deleteIfEmpty&&{deleteIfEmpty:!0}}});if(F&&F.kind!=="missing")_.push({action:"delete",target:F.displayPath,details:{kind:"binary"}});let Q=[];if(HF(B))Q.push(`Binary is managed by ${B}. Run: ${c8(B)}`);return{dryRunResult:{dryRun:!0,command:"self uninstall",wouldPerform:_,validation:{passed:!0},summary:_.length>0?`Would remove ${_.length} item(s)`:"Nothing to remove"},hints:Q}}function PG(D,F){if(D.filter(($)=>$.kind!=="missing").length>0||F&&F.kind!=="missing")G.info("Removing OCX files...")}function xG(D,F,B){G.break();for(let $ of D){if($.skipped){if($.reason==="not found")continue;if($.reason==="not empty"){G.info(`Kept ${W0.path($.target.displayPath)} (not empty)`);continue}if($.reason==="permission denied"){G.warn(`Skipped ${W0.path($.target.displayPath)} (permission denied)`);continue}if($.reason==="containment violation"){G.warn(`Skipped ${W0.path($.target.displayPath)} (containment violation)`);continue}}if($.success)G.success(`Removed ${W0.path($.target.displayPath)}`);else G.error(`Failed to remove ${$.target.displayPath}: ${$.error?.message}`)}if(F){if(F.skipped&&F.reason==="not found");else if(F.success&&!F.skipped)G.success(`Removed binary ${W0.path(F.target.displayPath)}`);else if(!F.success)G.error(`Failed to remove binary ${F.target.displayPath}: ${F.error?.message}`)}if(HF(B))G.break(),G.info(`Binary is managed by ${B}. To complete uninstall, run:`),G.log(` ${W0.command(c8(B))}`)}function yG(){G.info("Nothing to remove. OCX is not installed globally.")}function g8(D){return{path:D.target.displayPath,kind:D.target.kind,success:D.success,skipped:D.skipped,...D.reason&&{reason:D.reason},...D.error&&{error:D.error.message}}}async function fG(D){let F=g6(),B=G$(F);if(!B.valid)switch(B.reason){case"not-found":break;case"symlink":return qF("VALIDATION_ERROR","Safety error: Global config root is a symlink. Aborting.",hD.SAFETY_ERROR);case"not-directory":return qF("VALIDATION_ERROR","Safety error: Global config root is not a directory. Aborting.",hD.SAFETY_ERROR);case"permission":return qF("PERMISSION_ERROR","Error: Cannot access global config root (permission denied).",hD.ERROR)}let $=W$(),_=$.filter((Z)=>Z.safetyStatus==="forbidden");if(_.length>0)return qF("VALIDATION_ERROR","Safety error: Target escapes containment boundary.",hD.SAFETY_ERROR,{targets:_.map((Z)=>Z.displayPath)});let Q=$.filter((Z)=>Z.safetyStatus==="error");if(Q.length>0)return qF("PERMISSION_ERROR","Error: Cannot verify containment for targets (permission/IO error).",hD.ERROR,{targets:Q.map((Z)=>Z.displayPath)});let Y=B3(),q=z$(),H=$.filter((Z)=>Z.kind!=="missing"),J=Boolean(q&&q.kind!=="missing"),X=HF(Y);if(H.length===0&&!J&&!X)return f6({message:"Nothing to remove. OCX is not installed globally.",removed:[],skipped:[]},hD.SUCCESS);if(D.dryRun){let{dryRunResult:Z,hints:s}=j$($,q,Y);return f6({...Z,...s.length>0&&{hints:s}},hD.SUCCESS)}let z=M$($),M=null;if(q)M=A$(q.absolutePath,{suppressOutput:!0});let A=z.some((Z)=>!Z.success&&!Z.skipped),K=Boolean(M&&!M.success&&!M.skipped);if(A||K)return qF("PERMISSION_ERROR","Failed to remove one or more uninstall targets.",hD.ERROR,{configResults:z.map(g8),...M&&{binaryResult:g8(M)}});if(HF(Y))return qF("UPDATE_ERROR",`Binary is managed by ${Y}. Run: ${c8(Y)}`,hD.ERROR,{installMethod:Y,command:c8(Y),configResults:z.map(g8),...M&&{binaryResult:g8(M)}});let j=z.filter((Z)=>Z.success&&!Z.skipped).map((Z)=>Z.target.displayPath),S=z.filter((Z)=>Z.skipped).map((Z)=>({path:Z.target.displayPath,reason:Z.reason??"skipped"}));if(M){if(M.success&&!M.skipped)j.push(M.target.displayPath);else if(M.skipped)S.push({path:M.target.displayPath,reason:M.reason??"skipped"})}return f6({removed:j,skipped:S,installMethod:Y},hD.SUCCESS)}async function hG(D){if(D.json){await fG(D);return}let F=g6(),B=G$(F);if(!B.valid)switch(B.reason){case"not-found":break;case"symlink":G.error("Safety error: Global config root is a symlink. Aborting."),process.exit(hD.SAFETY_ERROR);break;case"not-directory":G.error("Safety error: Global config root is not a directory. Aborting."),process.exit(hD.SAFETY_ERROR);break;case"permission":G.error("Error: Cannot access global config root (permission denied)."),process.exit(hD.ERROR);break}let $=W$(),_=$.filter((j)=>j.safetyStatus==="forbidden");if(_.length>0){G.error("Safety error: Target escapes containment boundary:");for(let j of _)G.error(` ${j.displayPath}`);process.exit(hD.SAFETY_ERROR)}let Q=$.filter((j)=>j.safetyStatus==="error");if(Q.length>0){G.error("Error: Cannot verify containment for targets (permission/IO error):");for(let j of Q)G.error(` ${j.displayPath}`);process.exit(hD.ERROR)}let Y=B3(),q=z$(),H=$.filter((j)=>j.kind!=="missing"),J=q&&q.kind!=="missing",X=HF(Y);if(H.length===0&&!J&&!X)yG(),process.exit(hD.SUCCESS);if(D.dryRun)uG($,q,Y),process.exit(hD.SUCCESS);PG($,q);let z=M$($),M=null;if(q)M=A$(q.absolutePath);xG(z,M,Y);let A=z.some((j)=>!j.success&&!j.skipped),K=M&&!M.success&&!M.skipped;if(A||K)process.exit(hD.ERROR);if(HF(Y))process.exit(hD.ERROR);process.exit(hD.SUCCESS)}function K$(D){D.command("uninstall").description("Remove OCX global configuration and binary").option("--dry-run","Preview what would be removed").option("--json","Output as JSON").action(async(F)=>{try{await hG(F)}catch(B){t(B,{json:F.json})}})}var hD;var U$=V(()=>{G0();m8();BF();PD();fD();hD={SUCCESS:0,ERROR:1,SAFETY_ERROR:2}});class V${version="2.0.3"}var E$;var L$=V(()=>{E$=new V$});var O$={};j2(O$,{checkForUpdate:()=>c6,EXPLICIT_UPDATE_TIMEOUT_MS:()=>d6});function w$(D){let[F=""]=D.split("-"),B=F.split("."),$=parseInt(B[0]??"",10),_=parseInt(B[1]??"",10),Q=parseInt(B[2]??"",10);if(Number.isNaN($)||Number.isNaN(_)||Number.isNaN(Q))return null;return{major:$,minor:_,patch:Q}}function dG(D,F){let B=w$(D),$=w$(F);if(!B||!$)return null;if(B.major!==$.major)return B.major-$.major;if(B.minor!==$.minor)return B.minor-$.minor;return B.patch-$.patch}async function c6(D,F=mG){let $=(D??E$).version||"0.0.0-dev";if($==="0.0.0-dev")return{ok:!1,reason:"dev-version"};try{let Q=(await M8(gG,void 0,AbortSignal.timeout(F))).version,Y=dG(Q,$);if(Y===null)return{ok:!1,reason:"invalid-response"};return{ok:!0,current:$,latest:Q,updateAvailable:Y>0}}catch(_){if(_ instanceof Error){if(_.name==="AbortError"||_.name==="TimeoutError")return{ok:!1,reason:"timeout"};if(_ instanceof RD||_.name==="NetworkError")return{ok:!1,reason:"network-error"}}return{ok:!1,reason:"invalid-response"}}}var mG=200,d6=1e4,gG="ocx";var l6=V(()=>{$D();a1();L$()});import{chmodSync as cG,existsSync as JF,renameSync as p6,unlinkSync as l8}from"fs";function iG(){let D=process.env.OCX_DOWNLOAD_URL;if(D)return D.replace(/\/+$/,"");return pG}function i6(D){let F=`${process.arch}-${process.platform}`,B=b$[F];if(!B){let _=Object.keys(b$).join(", ");throw new vD(`Unsupported platform: ${F}
212
- Supported platforms: ${_}`)}return`${iG()}/v${D}/${B}`}async function nG(D,F,B={}){let $=B.quiet?null:jD({text:"Downloading update..."});$?.start();let _;try{_=await fetch(D,{redirect:"follow"})}catch(J){throw $?.fail("Download failed"),new vD(`Network error: ${J instanceof Error?J.message:String(J)}`)}if(!_.ok)throw $?.fail("Download failed"),new vD(`Failed to download: HTTP ${_.status} ${_.statusText}`);if(!_.body)throw $?.fail("Download failed"),new vD("Download failed: Empty response body");let Q=_.body.getReader(),Y=Bun.file(F).writer(),q=Number(_.headers.get("content-length")||0),H=0;try{while(!0){let{done:J,value:X}=await Q.read();if(J)break;if(await Y.write(X),H+=X.length,q>0&&$){let z=Math.round(H/q*100);$.text=`Downloading... ${z}%`}}await Y.end(),$?.succeed("Download complete")}catch(J){throw $?.fail("Download failed"),await Y.end(),new vD(`Download interrupted: ${J instanceof Error?J.message:String(J)}`)}}async function R$(D,F={}){let B=h8(),$=`${B}.new.${Date.now()}`,_=i6(D);await nG(_,$,F);try{cG($,493)}catch(Q){if(JF($))l8($);throw new vD(`Failed to set permissions: ${Q instanceof Error?Q.message:String(Q)}`)}return{tempPath:$,execPath:B}}function Z$(D,F){let B=`${F}.backup`;try{if(JF(F))p6(F,B);if(p6(D,F),JF(B))l8(B)}catch($){if(JF(B)&&!JF(F))try{p6(B,F)}catch{}if(JF(D))try{l8(D)}catch{}throw new vD(`Update failed: ${$ instanceof Error?$.message:String($)}`)}}function N$(D){if(JF(D))try{l8(D)}catch{}}var lG="kdcokenny/ocx",pG,b$;var S$=V(()=>{$D();m0();m8();pG=`https://github.com/${lG}/releases/download`,b$={"arm64-darwin":"ocx-darwin-arm64","x64-darwin":"ocx-darwin-x64","arm64-linux":"ocx-linux-arm64","x64-linux":"ocx-linux-x64","x64-win32":"ocx-windows-x64.exe"}});var k$={};j2(k$,{notifyUpdated:()=>p8,notifyUpdate:()=>sG,notifyUpToDate:()=>n6});function sG(D,F){if(!process.stdout.isTTY)return;console.error(`${P.cyan("info")}: update available - ${P.green(F)} (current: ${P.dim(D)})`),console.error(` run ${P.cyan("`ocx self update`")} to upgrade`)}function n6(D){console.error(`${P.cyan("info")}: ocx unchanged - ${P.dim(D)}`)}function p8(D,F){console.error(` ${P.green("ocx updated")} - ${F} (from ${D})`)}var s6=V(()=>{W2()});import{createHash as aG}from"crypto";function rG(D){let F=new Map;for(let B of D.split(`
213
- `)){let $=B.match(/^([a-fA-F0-9]{64})\s+\*?(.+)$/);if($?.[1]&&$[2])F.set($[2].trim(),$[1].toLowerCase())}return F}function tG(D){return aG("sha256").update(D).digest("hex")}async function I$(D){let F=`https://github.com/${oG}/releases/download/v${D}/SHA256SUMS.txt`,B=await fetch(F);if(!B.ok)throw new vD(`Failed to fetch checksums: ${B.status}`);let $=await B.text();return rG($)}async function T$(D,F,B){let _=await Bun.file(D).arrayBuffer(),Q=tG(Buffer.from(_));if(Q!==F)throw new d2(B,F,Q)}var oG="kdcokenny/ocx";var v$=V(()=>{$D()});var C$={};j2(C$,{runSelfUpdateCommand:()=>FW});async function FW(D){let F=D.method?Q$(D.method):B3(),B=D.json===!0,$=await c6(void 0,d6);if(!$.ok)throw new vD(DW[$.reason]);let{current:_,latest:Q,updateAvailable:Y}=$;if(!Y&&!D.force){if(B)LD({success:!0,data:{current:_,latest:Q,method:F,updated:!1}});else n6(_);return}let q=Q;switch(F){case"curl":{await BW(_,q,B);break}case"npm":case"pnpm":case"bun":case"yarn":case"unknown":{await $W(F,_,q,B);break}}if(B)LD({success:!0,data:{current:_,latest:q,method:F,updated:!0}})}async function BW(D,F,B){let _=i6(F).split("/").pop();if(!_)throw new vD("Failed to determine binary filename from download URL");let Y=(await I$(F)).get(_);if(!Y)throw new vD(`Security error: No checksum found for ${_}. Update aborted.`);let{tempPath:q,execPath:H}=await R$(F,{quiet:B});try{await T$(q,Y,_)}catch(J){throw N$(q),J}if(Z$(q,H),!B)p8(D,F)}async function i8(D){let F=Bun.spawn(D,{stdout:"pipe",stderr:"pipe"});if(await F.exited!==0){let $=await new Response(F.stderr).text();throw new vD(`Package manager command failed: ${$.trim()}`)}}async function $W(D,F,B,$){if(!eG.test(B))throw new vD(`Invalid version format: ${B}`);let _=$?null:jD({text:`Updating via ${D}...`});_?.start();try{switch(D){case"npm":{await i8(["npm","install","-g",`ocx@${B}`]);break}case"yarn":{await i8(["yarn","global","add",`ocx@${B}`]);break}case"pnpm":{await i8(["pnpm","install","-g",`ocx@${B}`]);break}case"bun":{await i8(["bun","install","-g",`ocx@${B}`]);break}case"unknown":throw new vD(`Could not detect install method. Update manually with one of:
211
+ ${S}`)}}for(let{canonicalId:A,files:K}of J){for(let j of K){let S=bW($.cwd,M,j);if(!S){if(F.verbose)W.info(` \u2298 Skipped ${j.path} (not found)`);continue}if(await wW(S,{force:!0}),F.verbose)W.info(` \u2713 Removed ${j.path}`)}delete _.installed[A],q.push(A)}if(await j0($.cwd,_),Y?.succeed(`Removed ${q.length} component(s)`),F.json)console.log(JSON.stringify({success:!0,removed:q,notFound:H},null,2));else if(!F.quiet){W.info("");for(let A of q){let K=R2(A);W.success(`\u2713 Removed ${K.registryName}/${K.name}@${K.revision}`)}W.info(""),W.success(`Done! Removed ${q.length} component(s).`)}}catch(A){throw Y?.fail("Failed to remove components"),A}}var F$=V(()=>{gF();eD();h6();BF();$D();yD();hD();c2();nF();x0();g0()});var $$=c0((B$,m8)=>{((D,F)=>{if(typeof define==="function"&&define.amd)define([],F);else if(typeof m8==="object"&&m8.exports)m8.exports=F();else D.fuzzysort=F()})(B$,(D)=>{var F=(w,E)=>{if(!w||!E)return YD;var u=A(w);if(!f(E))E=M(E);var m=u.bitflags;if((m&E._bitflags)!==m)return YD;return j(u,E)},B=(w,E,u)=>{if(!w)return u?.all?K(E,u):bD;var m=A(w),g=m.bitflags,h=m.containsSpace,C=X(u?.threshold||0),o=u?.limit||_D,d=0,WD=0,HD=E.length;function $0(u2){if(d<o)WF.add(u2),++d;else if(++WD,u2._score>WF.peek()._score)WF.replaceTop(u2)}if(u?.key){var nD=u.key;for(var GD=0;GD<HD;++GD){var tD=E[GD],UD=v(tD,nD);if(!UD)continue;if(!f(UD))UD=M(UD);if((g&UD._bitflags)!==g)continue;var wD=j(m,UD);if(wD===YD)continue;if(wD._score<C)continue;wD.obj=tD,$0(wD)}}else if(u?.keys){var M2=u.keys,M0=M2.length;D:for(var GD=0;GD<HD;++GD){var tD=E[GD];{var sD=0;for(var JD=0;JD<M0;++JD){var nD=M2[JD],UD=v(tD,nD);if(!UD){k[JD]=B0;continue}if(!f(UD))UD=M(UD);k[JD]=UD,sD|=UD._bitflags}if((g&sD)!==g)continue}if(h)for(let VD=0;VD<m.spaceSearches.length;VD++)FD[VD]=r;for(var JD=0;JD<M0;++JD){if(UD=k[JD],UD===B0){i[JD]=B0;continue}if(i[JD]=j(m,UD,!1,h),i[JD]===YD){i[JD]=B0;continue}if(h)for(let OD=0;OD<m.spaceSearches.length;OD++){if(KD[OD]>-1000){if(FD[OD]>r){var cD=(FD[OD]+KD[OD])/4;if(cD>FD[OD])FD[OD]=cD}}if(KD[OD]>FD[OD])FD[OD]=KD[OD]}}if(h){for(let VD=0;VD<m.spaceSearches.length;VD++)if(FD[VD]===r)continue D}else{var qD=!1;for(let VD=0;VD<M0;VD++)if(i[VD]._score!==r){qD=!0;break}if(!qD)continue}var q0=new q(M0);for(let VD=0;VD<M0;VD++)q0[VD]=i[VD];if(h){var gD=0;for(let VD=0;VD<m.spaceSearches.length;VD++)gD+=FD[VD]}else{var gD=r;for(let OD=0;OD<M0;OD++){var wD=q0[OD];if(wD._score>-1000){if(gD>r){var cD=(gD+wD._score)/4;if(cD>gD)gD=cD}}if(wD._score>gD)gD=wD._score}}if(q0.obj=tD,q0._score=gD,u?.scoreFn){if(gD=u.scoreFn(q0),!gD)continue;gD=X(gD),q0._score=gD}if(gD<C)continue;$0(q0)}}else for(var GD=0;GD<HD;++GD){var UD=E[GD];if(!UD)continue;if(!f(UD))UD=M(UD);if((g&UD._bitflags)!==g)continue;var wD=j(m,UD);if(wD===YD)continue;if(wD._score<C)continue;$0(wD)}if(d===0)return bD;var A2=Array(d);for(var GD=d-1;GD>=0;--GD)A2[GD]=WF.poll();return A2.total=d+WD,A2},$=(w,E="<b>",u="</b>")=>{var m=typeof E==="function"?E:void 0,g=w.target,h=g.length,C=w.indexes,o="",d=0,WD=0,HD=!1,$0=[];for(var nD=0;nD<h;++nD){var GD=g[nD];if(C[WD]===nD){if(++WD,!HD)if(HD=!0,m)$0.push(o),o="";else o+=E;if(WD===C.length){if(m)o+=GD,$0.push(m(o,d++)),o="",$0.push(g.substr(nD+1));else o+=GD+u+g.substr(nD+1);break}}else if(HD)if(HD=!1,m)$0.push(m(o,d++)),o="";else o+=u;o+=GD}return m?$0:o},_=(w)=>{if(typeof w==="number")w=""+w;else if(typeof w!=="string")w="";var E=s(w);return H(w,{_targetLower:E._lower,_targetLowerCodes:E.lowerCodes,_bitflags:E.bitflags})},Q=()=>{O.clear(),b.clear()};class Y{get["indexes"](){return this._indexes.slice(0,this._indexes.len).sort((w,E)=>w-E)}set["indexes"](w){return this._indexes=w}["highlight"](w,E){return $(this,w,E)}get["score"](){return J(this._score)}set["score"](w){this._score=X(w)}}class q extends Array{get["score"](){return J(this._score)}set["score"](w){this._score=X(w)}}var H=(w,E)=>{let u=new Y;return u.target=w,u.obj=E.obj??YD,u._score=E._score??r,u._indexes=E._indexes??[],u._targetLower=E._targetLower??"",u._targetLowerCodes=E._targetLowerCodes??YD,u._nextBeginningIndexes=E._nextBeginningIndexes??YD,u._bitflags=E._bitflags??0,u},J=(w)=>{if(w===r)return 0;if(w>1)return w;return Math.E**(((-w+1)**0.04307-1)*-2)},X=(w)=>{if(w===0)return r;if(w>1)return w;return 1-Math.pow(Math.log(w)/-2+1,23.218017181332716)},z=(w)=>{if(typeof w==="number")w=""+w;else if(typeof w!=="string")w="";w=w.trim();var E=s(w),u=[];if(E.containsSpace){var m=w.split(/\s+/);m=[...new Set(m)];for(var g=0;g<m.length;g++){if(m[g]==="")continue;var h=s(m[g]);u.push({lowerCodes:h.lowerCodes,_lower:m[g].toLowerCase(),containsSpace:!1})}}return{lowerCodes:E.lowerCodes,_lower:E._lower,containsSpace:E.containsSpace,bitflags:E.bitflags,spaceSearches:u}},M=(w)=>{if(w.length>999)return _(w);var E=O.get(w);if(E!==void 0)return E;return E=_(w),O.set(w,E),E},A=(w)=>{if(w.length>999)return z(w);var E=b.get(w);if(E!==void 0)return E;return E=z(w),b.set(w,E),E},K=(w,E)=>{var u=[];u.total=w.length;var m=E?.limit||_D;if(E?.key)for(var g=0;g<w.length;g++){var h=w[g],C=v(h,E.key);if(C==YD)continue;if(!f(C))C=M(C);var o=H(C.target,{_score:C._score,obj:h});if(u.push(o),u.length>=m)return u}else if(E?.keys)for(var g=0;g<w.length;g++){var h=w[g],d=new q(E.keys.length);for(var WD=E.keys.length-1;WD>=0;--WD){var C=v(h,E.keys[WD]);if(!C){d[WD]=B0;continue}if(!f(C))C=M(C);C._score=r,C._indexes.len=0,d[WD]=C}if(d.obj=h,d._score=r,u.push(d),u.length>=m)return u}else for(var g=0;g<w.length;g++){var C=w[g];if(C==YD)continue;if(!f(C))C=M(C);if(C._score=r,C._indexes.len=0,u.push(C),u.length>=m)return u}return u},j=(w,E,u=!1,m=!1)=>{if(u===!1&&w.containsSpace)return S(w,E,m);var{_lower:g,lowerCodes:h}=w,C=h[0],o=E._targetLowerCodes,d=h.length,WD=o.length,GD=0,HD=0,$0=0;for(;;){var nD=C===o[HD];if(nD){if(L[$0++]=HD,++GD,GD===d)break;C=h[GD]}if(++HD,HD>=WD)return YD}var GD=0,tD=!1,UD=0,wD=E._nextBeginningIndexes;if(wD===YD)wD=E._nextBeginningIndexes=y(E.target);HD=L[0]===0?0:wD[L[0]-1];var M2=0;if(HD!==WD)for(;;)if(HD>=WD){if(GD<=0)break;if(++M2,M2>200)break;--GD;var M0=e[--UD];HD=wD[M0]}else{var nD=h[GD]===o[HD];if(nD){if(e[UD++]=HD,++GD,GD===d){tD=!0;break}++HD}else HD=wD[HD]}var sD=d<=1?-1:E._targetLower.indexOf(g,L[0]),JD=!!~sD,cD=!JD?!1:sD===0||E._nextBeginningIndexes[sD-1]===sD;if(JD&&!cD)for(var qD=0;qD<wD.length;qD=wD[qD]){if(qD<=sD)continue;for(var q0=0;q0<d;q0++)if(h[q0]!==E._targetLowerCodes[qD+q0])break;if(q0===d){sD=qD,cD=!0;break}}var gD=(VD)=>{var OD=0,e6=0;for(var F2=1;F2<d;++F2)if(VD[F2]-VD[F2-1]!==1)OD-=VD[F2],++e6;var F_=VD[d-1]-VD[0]-(d-1);if(OD-=(12+F_)*e6,VD[0]!==0)OD-=VD[0]*VD[0]*0.2;if(!tD)OD*=1000;else{var r8=1;for(var F2=wD[0];F2<WD;F2=wD[F2])++r8;if(r8>24)OD*=(r8-24)*10}if(OD-=(WD-d)/2,JD)OD/=1+d*d*1;if(cD)OD/=1+d*d*1;return OD-=(WD-d)/2,OD};if(!tD){if(JD)for(var qD=0;qD<d;++qD)L[qD]=sD+qD;var A2=L,u2=gD(A2)}else if(cD){for(var qD=0;qD<d;++qD)L[qD]=sD+qD;var A2=L,u2=gD(L)}else var A2=e,u2=gD(e);E._score=u2;for(var qD=0;qD<d;++qD)E._indexes[qD]=A2[qD];E._indexes.len=d;let f3=new Y;return f3.target=E.target,f3._score=E._score,f3._indexes=E._indexes,f3},S=(w,E,u)=>{var m=new Set,g=0,h=YD,C=0,o=w.spaceSearches,d=o.length,WD=0,HD=()=>{for(let cD=WD-1;cD>=0;cD--)E._nextBeginningIndexes[p[cD*2+0]]=p[cD*2+1]},$0=!1;for(var JD=0;JD<d;++JD){KD[JD]=r;var nD=o[JD];if(h=j(nD,E),u){if(h===YD)continue;$0=!0}else if(h===YD)return HD(),YD;var GD=JD===d-1;if(!GD){var tD=h._indexes,UD=!0;for(let qD=0;qD<tD.len-1;qD++)if(tD[qD+1]-tD[qD]!==1){UD=!1;break}if(UD){var wD=tD[tD.len-1]+1,M2=E._nextBeginningIndexes[wD-1];for(let qD=wD-1;qD>=0;qD--){if(M2!==E._nextBeginningIndexes[qD])break;E._nextBeginningIndexes[qD]=wD,p[WD*2+0]=qD,p[WD*2+1]=M2,WD++}}}if(g+=h._score/d,KD[JD]=h._score/d,h._indexes[0]<C)g-=(C-h._indexes[0])*2;C=h._indexes[0];for(var M0=0;M0<h._indexes.len;++M0)m.add(h._indexes[M0])}if(u&&!$0)return YD;HD();var sD=j(w,E,!0);if(sD!==YD&&sD._score>g){if(u)for(var JD=0;JD<d;++JD)KD[JD]=sD._score/d;return sD}if(u)h=E;h._score=g;var JD=0;for(let cD of m)h._indexes[JD++]=cD;return h._indexes.len=JD,h},R=(w)=>w.replace(/\p{Script=Latin}+/gu,(E)=>E.normalize("NFD")).replace(/[\u0300-\u036f]/g,""),s=(w)=>{w=R(w);var E=w.length,u=w.toLowerCase(),m=[],g=0,h=!1;for(var C=0;C<E;++C){var o=m[C]=u.charCodeAt(C);if(o===32){h=!0;continue}var d=o>=97&&o<=122?o-97:o>=48&&o<=57?26:o<=127?30:31;g|=1<<d}return{lowerCodes:m,bitflags:g,containsSpace:h,_lower:u}},N=(w)=>{var E=w.length,u=[],m=0,g=!1,h=!1;for(var C=0;C<E;++C){var o=w.charCodeAt(C),d=o>=65&&o<=90,WD=d||o>=97&&o<=122||o>=48&&o<=57,HD=d&&!g||!h||!WD;if(g=d,h=WD,HD)u[m++]=C}return u},y=(w)=>{w=R(w);var E=w.length,u=N(w),m=[],g=u[0],h=0;for(var C=0;C<E;++C)if(g>C)m[C]=g;else g=u[++h],m[C]=g===void 0?E:g;return m},O=new Map,b=new Map,L=[],e=[],p=[],FD=[],KD=[],k=[],i=[],v=(w,E)=>{var u=w[E];if(u!==void 0)return u;if(typeof E==="function")return E(w);var m=E;if(!Array.isArray(E))m=E.split(".");var g=m.length,h=-1;while(w&&++h<g)w=w[m[h]];return w},f=(w)=>{return typeof w==="object"&&typeof w._bitflags==="number"},_D=1/0,r=-_D,bD=[];bD.total=0;var YD=null,B0=_(""),o8=(w)=>{var E=[],u=0,m={},g=(h)=>{for(var C=0,o=E[C],d=1;d<u;){var WD=d+1;C=d,WD<u&&E[WD]._score<E[d]._score&&(C=WD),E[C-1>>1]=E[C],d=1+(C<<1)}for(var HD=C-1>>1;C>0&&o._score<E[HD]._score;HD=(C=HD)-1>>1)E[C]=E[HD];E[C]=o};return m.add=(h)=>{var C=u;E[u++]=h;for(var o=C-1>>1;C>0&&h._score<E[o]._score;o=(C=o)-1>>1)E[C]=E[o];E[C]=h},m.poll=(h)=>{if(u!==0){var C=E[0];return E[0]=E[--u],g(),C}},m.peek=(h)=>{if(u!==0)return E[0]},m.replaceTop=(h)=>{E[0]=h,g()},m},WF=o8();return{single:F,go:B,prepare:_,cleanup:Q}})});var Q$={};j2(Q$,{runSearchCore:()=>_$,runSearchCommandAction:()=>NW});async function NW(D,F){if(F.installed){let $=await X0(F.cwd);if(!$||Object.keys($.installed).length===0){if(F.json)LD({success:!0,data:{components:[]}});else W.info("No components installed.");return}let _=Object.entries($.installed).map(([Q,Y])=>({name:`${Y.registryName}/${Y.name}`,registry:Y.registryUrl,version:Y.revision,installedAt:void 0}));if(F.json)LD({success:!0,data:{components:_}});else{W.info(`Installed components (${_.length}):`);for(let Q of _)console.log(` ${P.cyan(Q.name)} ${P.dim(`v${Q.version}`)} from ${Q.registry}`)}return}let B;if(F.profile){let $=await r0.create(F.cwd,{profile:F.profile});B={cwd:$.getCwd(),getRegistries:()=>$.getRegistries(),getComponentPath:()=>$.getComponentPath()}}else B=await U0.requireInitialized(F.cwd);await _$(D,F,B)}async function _$(D,F,B){let $=B.getRegistries();if(F.verbose)W.info(`Searching in ${Object.keys($).length} registries...`);let _=[],Q=jD({text:"Searching registries...",quiet:F.quiet||F.verbose});if(!F.json&&!F.verbose)Q.start();for(let[q,H]of Object.entries($))try{if(F.verbose)W.info(`Fetching index from ${q} (${H.url})...`);let J=await T2(H.url);if(F.verbose)W.info(`Found ${J.components.length} components in ${q}`);for(let X of J.components)_.push({name:`${q}/${X.name}`,description:X.description,type:X.type,registry:q})}catch(J){if(F.verbose)W.warn(`Failed to fetch registry ${q}: ${J instanceof Error?J.message:String(J)}`)}if(!F.json&&!F.verbose)Q.stop();let Y=_;if(D)Y=m6.default.go(D,_,{keys:["name","description"],limit:F.limit}).map((H)=>H.obj);else Y=Y.slice(0,F.limit);if(F.json){LD({success:!0,data:{components:Y}});return}if(Y.length===0){W.info("No components found.");return}W.info(`Found ${Y.length} components:`);for(let q of Y)console.log(` ${P.cyan(q.name)} ${P.dim(`(${q.type})`)} - ${q.description}`)}var m6;var Y$=V(()=>{G2();gF();b3();DF();O1();hD();g0();m6=h3($$(),1)});function SW(D){let F=parseInt(D,10);if(Number.isNaN(F)||F<=0)throw new z9("Must be a positive integer");return F}function q$(D){let F=D.command("search").alias("list").description("Search for components across registries or list installed").argument("[query]","Search query").option("--installed","List installed components only",!1).option("-p, --profile <name>","Use specific profile").addOption(new J2("--limit <n>","Limit results").default(20).argParser(SW));rD(F),L0(F),F.action(async(B,$)=>{try{let{runSearchCommandAction:_}=await Promise.resolve().then(() => (Y$(),Q$));await _(B,$)}catch(_){t(_,{json:$.json})}})}var H$=V(()=>{$8();yD();x0()});function J$(D){let F=["curl","npm","yarn","pnpm","bun"],B=F.find(($)=>$===D);if(!B)throw new vD(`Invalid install method: "${D}"
212
+ Valid methods: ${F.join(", ")}`);return B}function $3(){if(kW())return"curl";let D=process.argv[1]??"";if(IW(D))return"unknown";if(TW(D))return"yarn";if(vW(D))return"pnpm";if(CW(D))return"bun";if(uW(D))return"npm";let F=process.env.npm_config_user_agent??"";if(F.includes("yarn"))return"yarn";if(F.includes("pnpm"))return"pnpm";if(F.includes("bun"))return"bun";if(F.includes("npm"))return"npm";return"unknown"}function g8(){if(typeof Bun<"u"&&Bun.main.startsWith("/$bunfs/"))return process.execPath;return process.argv[1]??process.execPath}var kW=()=>Bun.main.startsWith("/$bunfs/"),IW=(D)=>D.includes("/_npx/")||D.includes("/.cache/bunx/")||D.includes("/.pnpm/_temp/"),TW=(D)=>D.includes("/.yarn/global")||D.includes("/.config/yarn/global"),vW=(D)=>D.includes("/.pnpm/")||D.includes("/pnpm/global"),CW=(D)=>D.includes("/.bun/bin")||D.includes("/.bun/install/global"),uW=(D)=>D.includes("/.npm/")||D.includes("/node_modules/");var d8=V(()=>{$D()});import{existsSync as d6,lstatSync as G$,readdirSync as PW,realpathSync as X$,rmSync as yW,unlinkSync as z$}from"fs";import{homedir as M$}from"os";import d0 from"path";function g6(D,F=0){LD({success:!0,data:D}),process.exit(F)}function qF(D,F,B,$){let _={success:!1,error:{code:D,message:F,...$&&{details:$}},exitCode:B,meta:{timestamp:new Date().toISOString()}};LD(_),process.exit(B)}function c6(D){return D instanceof Error&&"code"in D}function y3(D){let F=M$();if(!F)return D;if(D===F)return"~";if(D.startsWith(F+d0.sep))return`~${D.slice(F.length)}`;return D}function l8(D,F){let B=d0.normalize(D),$=d0.normalize(F),_=d0.relative(B,$);if(_.startsWith("..")||d0.isAbsolute(_))return null;return _}function xW(D,F){return l8(D,F)!==null}function fW(D,F){if(!d6(F))return{contained:!0};try{let B=X$(D),$=X$(F);return{contained:l8(B,$)!==null}}catch(B){if(c6(B)&&(B.code==="EACCES"||B.code==="EPERM"))return{contained:!1,error:"permission"};return{contained:!1,error:"io"}}}function A$(D){try{let F=G$(D);if(F.isSymbolicLink())return{valid:!1,reason:"symlink"};if(!F.isDirectory())return{valid:!1,reason:"not-directory"};return{valid:!0}}catch(F){if(c6(F)){if(F.code==="ENOENT")return{valid:!1,reason:"not-found"};if(F.code==="EACCES"||F.code==="EPERM")return{valid:!1,reason:"permission"}}return{valid:!1,reason:"permission"}}}function x3(D){if(!d6(D))return"missing";try{let F=G$(D);if(F.isSymbolicLink())return"symlink";if(F.isDirectory())return"directory";return"file"}catch{return"missing"}}function hW(D){if(!d6(D))return!0;try{return PW(D).length===0}catch{return!1}}function W$(D){if(D.kind==="missing")return"safe";if(D.kind==="symlink")return xW(D.rootPath,D.absolutePath)?"safe":"forbidden";let F=fW(D.rootPath,D.absolutePath);if(F.error)return"error";return F.contained?"safe":"forbidden"}function HF(D){return D==="npm"||D==="pnpm"||D==="bun"||D==="yarn"}function p8(D){switch(D){case"npm":return"npm uninstall -g ocx";case"pnpm":return"pnpm remove -g ocx";case"bun":return"bun remove -g ocx";case"yarn":return"yarn global remove ocx";default:return"npm uninstall -g ocx"}}function l6(){let D=process.env.XDG_CONFIG_HOME||d0.join(M$(),".config");return d0.join(D,"opencode")}function j$(){let D=l6(),F=[],B=X2(),$=l8(D,B);if($){let q=x3(B);F.push({rootPath:D,relativePath:$,absolutePath:B,displayPath:y3(B),kind:q,deleteIfEmpty:!1,safetyStatus:W$({rootPath:D,absolutePath:B,kind:q})})}let _=cF(),Q=l8(D,_);if(Q){let q=x3(_);F.push({rootPath:D,relativePath:Q,absolutePath:_,displayPath:y3(_),kind:q,deleteIfEmpty:!1,safetyStatus:W$({rootPath:D,absolutePath:_,kind:q})})}let Y=x3(D);return F.push({rootPath:D,relativePath:".",absolutePath:D,displayPath:y3(D),kind:Y,deleteIfEmpty:!0,safetyStatus:Y==="missing"?"safe":"safe"}),F}function K$(){let D=$3();if(HF(D))return null;if(D==="curl"){let F=g8(),B=x3(F);return{rootPath:d0.dirname(F),relativePath:d0.basename(F),absolutePath:F,displayPath:y3(F),kind:B,deleteIfEmpty:!1,safetyStatus:B==="missing"?"safe":"safe"}}return null}function mW(D){if(D.kind==="missing")return{target:D,success:!0,skipped:!0,reason:"not found"};if(D.safetyStatus==="forbidden")return{target:D,success:!1,skipped:!0,reason:"containment violation",error:Error("Target escapes containment boundary")};if(D.deleteIfEmpty&&D.kind==="directory"){if(!hW(D.absolutePath))return{target:D,success:!0,skipped:!0,reason:"not empty"}}try{if(D.kind==="directory")yW(D.absolutePath,{recursive:!0,force:!0});else z$(D.absolutePath);return{target:D,success:!0,skipped:!1}}catch(F){let B=F instanceof Error?F:Error(String(F)),$=c6(F)&&(F.code==="EACCES"||F.code==="EPERM")?"permission denied":void 0;return{target:D,success:!1,skipped:!1,reason:$,error:B}}}function U$(D){return D.map(mW)}function V$(D,F={}){let B={rootPath:d0.dirname(D),relativePath:d0.basename(D),absolutePath:D,displayPath:y3(D),kind:x3(D),deleteIfEmpty:!1,safetyStatus:"safe"};if(B.kind==="missing")return{target:B,success:!0,skipped:!0,reason:"not found"};if(process.platform==="win32"){if(!F.suppressOutput)W.info(`To complete uninstall, manually delete: ${B.displayPath}`);return{target:B,success:!0,skipped:!0}}try{return z$(D),{target:B,success:!0,skipped:!1}}catch($){let _=$ instanceof Error?$:Error(String($));return{target:B,success:!1,skipped:!1,reason:"permission denied",error:_}}}function gW(D,F,B){let{dryRunResult:$,hints:_}=E$(D,F,B);z0($,{hints:_})}function E$(D,F,B){let $=D.filter((q)=>q.kind!=="missing"),_=[];for(let q of $)_.push({action:"delete",target:q.displayPath,details:{kind:q.kind,...q.deleteIfEmpty&&{deleteIfEmpty:!0}}});if(F&&F.kind!=="missing")_.push({action:"delete",target:F.displayPath,details:{kind:"binary"}});let Q=[];if(HF(B))Q.push(`Binary is managed by ${B}. Run: ${p8(B)}`);return{dryRunResult:{dryRun:!0,command:"self uninstall",wouldPerform:_,validation:{passed:!0},summary:_.length>0?`Would remove ${_.length} item(s)`:"Nothing to remove"},hints:Q}}function dW(D,F){if(D.filter(($)=>$.kind!=="missing").length>0||F&&F.kind!=="missing")W.info("Removing OCX files...")}function cW(D,F,B){W.break();for(let $ of D){if($.skipped){if($.reason==="not found")continue;if($.reason==="not empty"){W.info(`Kept ${G0.path($.target.displayPath)} (not empty)`);continue}if($.reason==="permission denied"){W.warn(`Skipped ${G0.path($.target.displayPath)} (permission denied)`);continue}if($.reason==="containment violation"){W.warn(`Skipped ${G0.path($.target.displayPath)} (containment violation)`);continue}}if($.success)W.success(`Removed ${G0.path($.target.displayPath)}`);else W.error(`Failed to remove ${$.target.displayPath}: ${$.error?.message}`)}if(F){if(F.skipped&&F.reason==="not found");else if(F.success&&!F.skipped)W.success(`Removed binary ${G0.path(F.target.displayPath)}`);else if(!F.success)W.error(`Failed to remove binary ${F.target.displayPath}: ${F.error?.message}`)}if(HF(B))W.break(),W.info(`Binary is managed by ${B}. To complete uninstall, run:`),W.log(` ${G0.command(p8(B))}`)}function lW(){W.info("Nothing to remove. OCX is not installed globally.")}function c8(D){return{path:D.target.displayPath,kind:D.target.kind,success:D.success,skipped:D.skipped,...D.reason&&{reason:D.reason},...D.error&&{error:D.error.message}}}async function pW(D){let F=l6(),B=A$(F);if(!B.valid)switch(B.reason){case"not-found":break;case"symlink":return qF("VALIDATION_ERROR","Safety error: Global config root is a symlink. Aborting.",mD.SAFETY_ERROR);case"not-directory":return qF("VALIDATION_ERROR","Safety error: Global config root is not a directory. Aborting.",mD.SAFETY_ERROR);case"permission":return qF("PERMISSION_ERROR","Error: Cannot access global config root (permission denied).",mD.ERROR)}let $=j$(),_=$.filter((R)=>R.safetyStatus==="forbidden");if(_.length>0)return qF("VALIDATION_ERROR","Safety error: Target escapes containment boundary.",mD.SAFETY_ERROR,{targets:_.map((R)=>R.displayPath)});let Q=$.filter((R)=>R.safetyStatus==="error");if(Q.length>0)return qF("PERMISSION_ERROR","Error: Cannot verify containment for targets (permission/IO error).",mD.ERROR,{targets:Q.map((R)=>R.displayPath)});let Y=$3(),q=K$(),H=$.filter((R)=>R.kind!=="missing"),J=Boolean(q&&q.kind!=="missing"),X=HF(Y);if(H.length===0&&!J&&!X)return g6({message:"Nothing to remove. OCX is not installed globally.",removed:[],skipped:[]},mD.SUCCESS);if(D.dryRun){let{dryRunResult:R,hints:s}=E$($,q,Y);return g6({...R,...s.length>0&&{hints:s}},mD.SUCCESS)}let z=U$($),M=null;if(q)M=V$(q.absolutePath,{suppressOutput:!0});let A=z.some((R)=>!R.success&&!R.skipped),K=Boolean(M&&!M.success&&!M.skipped);if(A||K)return qF("PERMISSION_ERROR","Failed to remove one or more uninstall targets.",mD.ERROR,{configResults:z.map(c8),...M&&{binaryResult:c8(M)}});if(HF(Y))return qF("UPDATE_ERROR",`Binary is managed by ${Y}. Run: ${p8(Y)}`,mD.ERROR,{installMethod:Y,command:p8(Y),configResults:z.map(c8),...M&&{binaryResult:c8(M)}});let j=z.filter((R)=>R.success&&!R.skipped).map((R)=>R.target.displayPath),S=z.filter((R)=>R.skipped).map((R)=>({path:R.target.displayPath,reason:R.reason??"skipped"}));if(M){if(M.success&&!M.skipped)j.push(M.target.displayPath);else if(M.skipped)S.push({path:M.target.displayPath,reason:M.reason??"skipped"})}return g6({removed:j,skipped:S,installMethod:Y},mD.SUCCESS)}async function iW(D){if(D.json){await pW(D);return}let F=l6(),B=A$(F);if(!B.valid)switch(B.reason){case"not-found":break;case"symlink":W.error("Safety error: Global config root is a symlink. Aborting."),process.exit(mD.SAFETY_ERROR);break;case"not-directory":W.error("Safety error: Global config root is not a directory. Aborting."),process.exit(mD.SAFETY_ERROR);break;case"permission":W.error("Error: Cannot access global config root (permission denied)."),process.exit(mD.ERROR);break}let $=j$(),_=$.filter((j)=>j.safetyStatus==="forbidden");if(_.length>0){W.error("Safety error: Target escapes containment boundary:");for(let j of _)W.error(` ${j.displayPath}`);process.exit(mD.SAFETY_ERROR)}let Q=$.filter((j)=>j.safetyStatus==="error");if(Q.length>0){W.error("Error: Cannot verify containment for targets (permission/IO error):");for(let j of Q)W.error(` ${j.displayPath}`);process.exit(mD.ERROR)}let Y=$3(),q=K$(),H=$.filter((j)=>j.kind!=="missing"),J=q&&q.kind!=="missing",X=HF(Y);if(H.length===0&&!J&&!X)lW(),process.exit(mD.SUCCESS);if(D.dryRun)gW($,q,Y),process.exit(mD.SUCCESS);dW($,q);let z=U$($),M=null;if(q)M=V$(q.absolutePath);cW(z,M,Y);let A=z.some((j)=>!j.success&&!j.skipped),K=M&&!M.success&&!M.skipped;if(A||K)process.exit(mD.ERROR);if(HF(Y))process.exit(mD.ERROR);process.exit(mD.SUCCESS)}function L$(D){D.command("uninstall").description("Remove OCX global configuration and binary").option("--dry-run","Preview what would be removed").option("--json","Output as JSON").action(async(F)=>{try{await iW(F)}catch(B){t(B,{json:F.json})}})}var mD;var w$=V(()=>{Q0();d8();BF();yD();hD();mD={SUCCESS:0,ERROR:1,SAFETY_ERROR:2}});class O${version="2.0.4"}var b$;var Z$=V(()=>{b$=new O$});var N$={};j2(N$,{checkForUpdate:()=>i6,EXPLICIT_UPDATE_TIMEOUT_MS:()=>p6});function R$(D){let[F=""]=D.split("-"),B=F.split("."),$=parseInt(B[0]??"",10),_=parseInt(B[1]??"",10),Q=parseInt(B[2]??"",10);if(Number.isNaN($)||Number.isNaN(_)||Number.isNaN(Q))return null;return{major:$,minor:_,patch:Q}}function aW(D,F){let B=R$(D),$=R$(F);if(!B||!$)return null;if(B.major!==$.major)return B.major-$.major;if(B.minor!==$.minor)return B.minor-$.minor;return B.patch-$.patch}async function i6(D,F=nW){let $=(D??b$).version||"0.0.0-dev";if($==="0.0.0-dev")return{ok:!1,reason:"dev-version"};try{let Q=(await j8(sW,void 0,AbortSignal.timeout(F))).version,Y=aW(Q,$);if(Y===null)return{ok:!1,reason:"invalid-response"};return{ok:!0,current:$,latest:Q,updateAvailable:Y>0}}catch(_){if(_ instanceof Error){if(_.name==="AbortError"||_.name==="TimeoutError")return{ok:!1,reason:"timeout"};if(_ instanceof ZD||_.name==="NetworkError")return{ok:!1,reason:"network-error"}}return{ok:!1,reason:"invalid-response"}}}var nW=200,p6=1e4,sW="ocx";var n6=V(()=>{$D();t1();Z$()});import{chmodSync as oW,existsSync as JF,renameSync as s6,unlinkSync as i8}from"fs";function eW(){let D=process.env.OCX_DOWNLOAD_URL;if(D)return D.replace(/\/+$/,"");return tW}function a6(D){let F=`${process.arch}-${process.platform}`,B=S$[F];if(!B){let _=Object.keys(S$).join(", ");throw new vD(`Unsupported platform: ${F}
213
+ Supported platforms: ${_}`)}return`${eW()}/v${D}/${B}`}async function DG(D,F,B={}){let $=B.quiet?null:jD({text:"Downloading update..."});$?.start();let _;try{_=await fetch(D,{redirect:"follow"})}catch(J){throw $?.fail("Download failed"),new vD(`Network error: ${J instanceof Error?J.message:String(J)}`)}if(!_.ok)throw $?.fail("Download failed"),new vD(`Failed to download: HTTP ${_.status} ${_.statusText}`);if(!_.body)throw $?.fail("Download failed"),new vD("Download failed: Empty response body");let Q=_.body.getReader(),Y=Bun.file(F).writer(),q=Number(_.headers.get("content-length")||0),H=0;try{while(!0){let{done:J,value:X}=await Q.read();if(J)break;if(await Y.write(X),H+=X.length,q>0&&$){let z=Math.round(H/q*100);$.text=`Downloading... ${z}%`}}await Y.end(),$?.succeed("Download complete")}catch(J){throw $?.fail("Download failed"),await Y.end(),new vD(`Download interrupted: ${J instanceof Error?J.message:String(J)}`)}}async function k$(D,F={}){let B=g8(),$=`${B}.new.${Date.now()}`,_=a6(D);await DG(_,$,F);try{oW($,493)}catch(Q){if(JF($))i8($);throw new vD(`Failed to set permissions: ${Q instanceof Error?Q.message:String(Q)}`)}return{tempPath:$,execPath:B}}function I$(D,F){let B=`${F}.backup`;try{if(JF(F))s6(F,B);if(s6(D,F),JF(B))i8(B)}catch($){if(JF(B)&&!JF(F))try{s6(B,F)}catch{}if(JF(D))try{i8(D)}catch{}throw new vD(`Update failed: ${$ instanceof Error?$.message:String($)}`)}}function T$(D){if(JF(D))try{i8(D)}catch{}}var rW="kdcokenny/ocx",tW,S$;var v$=V(()=>{$D();g0();d8();tW=`https://github.com/${rW}/releases/download`,S$={"arm64-darwin":"ocx-darwin-arm64","x64-darwin":"ocx-darwin-x64","arm64-linux":"ocx-linux-arm64","x64-linux":"ocx-linux-x64","x64-win32":"ocx-windows-x64.exe"}});var C$={};j2(C$,{notifyUpdated:()=>n8,notifyUpdate:()=>FG,notifyUpToDate:()=>o6});function FG(D,F){if(!process.stdout.isTTY)return;console.error(`${P.cyan("info")}: update available - ${P.green(F)} (current: ${P.dim(D)})`),console.error(` run ${P.cyan("`ocx self update`")} to upgrade`)}function o6(D){console.error(`${P.cyan("info")}: ocx unchanged - ${P.dim(D)}`)}function n8(D,F){console.error(` ${P.green("ocx updated")} - ${F} (from ${D})`)}var r6=V(()=>{G2()});import{createHash as BG}from"crypto";function _G(D){let F=new Map;for(let B of D.split(`
214
+ `)){let $=B.match(/^([a-fA-F0-9]{64})\s+\*?(.+)$/);if($?.[1]&&$[2])F.set($[2].trim(),$[1].toLowerCase())}return F}function QG(D){return BG("sha256").update(D).digest("hex")}async function u$(D){let F=`https://github.com/${$G}/releases/download/v${D}/SHA256SUMS.txt`,B=await fetch(F);if(!B.ok)throw new vD(`Failed to fetch checksums: ${B.status}`);let $=await B.text();return _G($)}async function P$(D,F,B){let _=await Bun.file(D).arrayBuffer(),Q=QG(Buffer.from(_));if(Q!==F)throw new d2(B,F,Q)}var $G="kdcokenny/ocx";var y$=V(()=>{$D()});var x$={};j2(x$,{runSelfUpdateCommand:()=>HG});async function HG(D){let F=D.method?J$(D.method):$3(),B=D.json===!0,$=await i6(void 0,p6);if(!$.ok)throw new vD(qG[$.reason]);let{current:_,latest:Q,updateAvailable:Y}=$;if(!Y&&!D.force){if(B)LD({success:!0,data:{current:_,latest:Q,method:F,updated:!1}});else o6(_);return}let q=Q;switch(F){case"curl":{await JG(_,q,B);break}case"npm":case"pnpm":case"bun":case"yarn":case"unknown":{await XG(F,_,q,B);break}}if(B)LD({success:!0,data:{current:_,latest:q,method:F,updated:!0}})}async function JG(D,F,B){let _=a6(F).split("/").pop();if(!_)throw new vD("Failed to determine binary filename from download URL");let Y=(await u$(F)).get(_);if(!Y)throw new vD(`Security error: No checksum found for ${_}. Update aborted.`);let{tempPath:q,execPath:H}=await k$(F,{quiet:B});try{await P$(q,Y,_)}catch(J){throw T$(q),J}if(I$(q,H),!B)n8(D,F)}async function s8(D){let F=Bun.spawn(D,{stdout:"pipe",stderr:"pipe"});if(await F.exited!==0){let $=await new Response(F.stderr).text();throw new vD(`Package manager command failed: ${$.trim()}`)}}async function XG(D,F,B,$){if(!YG.test(B))throw new vD(`Invalid version format: ${B}`);let _=$?null:jD({text:`Updating via ${D}...`});_?.start();try{switch(D){case"npm":{await s8(["npm","install","-g",`ocx@${B}`]);break}case"yarn":{await s8(["yarn","global","add",`ocx@${B}`]);break}case"pnpm":{await s8(["pnpm","install","-g",`ocx@${B}`]);break}case"bun":{await s8(["bun","install","-g",`ocx@${B}`]);break}case"unknown":throw new vD(`Could not detect install method. Update manually with one of:
214
215
  npm install -g ocx@latest
215
216
  pnpm install -g ocx@latest
216
- bun install -g ocx@latest`)}if(_?.succeed(`Updated via ${D}`),!$)p8(F,B)}catch(Q){if(Q instanceof vD)throw _?.fail("Update failed"),Q;throw _?.fail("Update failed"),new vD(`Failed to run ${D}: ${Q instanceof Error?Q.message:String(Q)}`)}}var eG,DW;var u$=V(()=>{l6();m8();S$();s6();v$();$D();m0();eG=/^\d+\.\d+\.\d+(-[\w.]+)?$/,DW={"dev-version":"Cannot check for updates in development mode. Install via npm for update support.",timeout:"Update check timed out after 10s. Try again or check your network.","network-error":"Cannot reach npm registry. Verify your internet connection.","invalid-response":"Received invalid response from npm registry. Try again later."}});function P$(D){D.command("update").description("Update OCX to the latest version").option("-f, --force","Reinstall even if already up to date").option("--method <method>","Override install method detection (curl|npm|pnpm|bun)").option("--json","Output as JSON").action(async(F)=>{try{let{runSelfUpdateCommand:B}=await Promise.resolve().then(() => (u$(),C$));await B(F)}catch(B){t(B,{json:F.json})}})}var x$=V(()=>{PD()});function y$(D){let F=D.command("self").description("Manage the OCX CLI");K$(F),P$(F)}var f$=V(()=>{U$();x$()});import{randomUUID as h$}from"crypto";import{existsSync as XF}from"fs";import{mkdir as _W,rename as QW,rm as n8,stat as YW,writeFile as qW}from"fs/promises";import{dirname as HW,join as JW}from"path";function a6(D,F){return`ocx add${F.global?" --global":""} ${D}`}function m$(D){return D==="apply"?"Failed to update components":"Failed to check for updates"}function g$(D){let F=D.command("update [components...]").description("Update installed components");oD(F),w0(F),r0(F),F.option("--all","Update all installed components").option("--registry <name>","Update all components from a specific registry").option("--dry-run","Preview changes without applying").action(async(B,$)=>{try{await XW(B,$)}catch(_){t(_,{json:$.json})}})}async function XW(D,F){let B=F.cwd??process.cwd(),$=F.global?await mF.requireInitialized():await V0.requireInitialized(B);await GW(D,F,$)}async function GW(D,F,B,$){let _=B.getRegistries(),Q=B.getComponentPath(),Y=Q===""||Q===".",q=D.map(zW),H=await J0(B.cwd);if(!H||Object.keys(H.installed).length===0){if(D.length>0){let N=D[0];if(!N)throw Error("Unexpected: component name missing despite non-empty componentNames");throw new MD(`Component '${N}' is not installed. Run '${a6(N,F)}' first.`)}throw new MD(`No components installed. Run '${a6("<component>",F)}' first.`)}let J=D.length>0,X=F.all===!0,z=F.registry!==void 0;if(!J&&!X&&!z)throw new U(`Specify components, use --all, or use --registry <name>.
217
+ bun install -g ocx@latest`)}if(_?.succeed(`Updated via ${D}`),!$)n8(F,B)}catch(Q){if(Q instanceof vD)throw _?.fail("Update failed"),Q;throw _?.fail("Update failed"),new vD(`Failed to run ${D}: ${Q instanceof Error?Q.message:String(Q)}`)}}var YG,qG;var f$=V(()=>{n6();d8();v$();r6();y$();$D();g0();YG=/^\d+\.\d+\.\d+(-[\w.]+)?$/,qG={"dev-version":"Cannot check for updates in development mode. Install via npm for update support.",timeout:"Update check timed out after 10s. Try again or check your network.","network-error":"Cannot reach npm registry. Verify your internet connection.","invalid-response":"Received invalid response from npm registry. Try again later."}});function h$(D){D.command("update").description("Update OCX to the latest version").option("-f, --force","Reinstall even if already up to date").option("--method <method>","Override install method detection (curl|npm|pnpm|bun)").option("--json","Output as JSON").action(async(F)=>{try{let{runSelfUpdateCommand:B}=await Promise.resolve().then(() => (f$(),x$));await B(F)}catch(B){t(B,{json:F.json})}})}var m$=V(()=>{yD()});function g$(D){let F=D.command("self").description("Manage the OCX CLI");L$(F),h$(F)}var d$=V(()=>{w$();m$()});import{randomUUID as c$}from"crypto";import{existsSync as XF}from"fs";import{mkdir as WG,rename as GG,rm as a8,stat as zG,writeFile as MG}from"fs/promises";import{dirname as AG,join as jG}from"path";function t6(D,F){return`ocx add${F.global?" --global":""} ${D}`}function l$(D){return D==="apply"?"Failed to update components":"Failed to check for updates"}function p$(D){let F=D.command("update [components...]").description("Update installed components");rD(F),L0(F),t0(F),F.option("--all","Update all installed components").option("--registry <name>","Update all components from a specific registry").option("--dry-run","Preview changes without applying").action(async(B,$)=>{try{await KG(B,$)}catch(_){t(_,{json:$.json})}})}async function KG(D,F){let B=F.cwd??process.cwd(),$=F.global?await mF.requireInitialized():await U0.requireInitialized(B);await UG(D,F,$)}async function UG(D,F,B,$){let _=B.getRegistries(),Q=B.getComponentPath(),Y=Q===""||Q===".",q=D.map(EG),H=await X0(B.cwd);if(!H||Object.keys(H.installed).length===0){if(D.length>0){let N=D[0];if(!N)throw Error("Unexpected: component name missing despite non-empty componentNames");throw new MD(`Component '${N}' is not installed. Run '${t6(N,F)}' first.`)}throw new MD(`No components installed. Run '${t6("<component>",F)}' first.`)}let J=D.length>0,X=F.all===!0,z=F.registry!==void 0;if(!J&&!X&&!z)throw new U(`Specify components, use --all, or use --registry <name>.
217
218
 
218
219
  Examples:
219
220
  ocx update alias/component # Update specific component
@@ -221,12 +222,12 @@ Examples:
221
222
  ocx update --registry my-alias # Update all from a registry`);if(X&&J)throw new U(`Cannot specify components with --all.
222
223
  Use either 'ocx update --all' or 'ocx update <components>'.`);if(z&&J)throw new U(`Cannot specify components with --registry.
223
224
  Use either 'ocx update --registry <name>' or 'ocx update <components>'.`);if(X&&z)throw new U(`Cannot use --all with --registry.
224
- Use either 'ocx update --all' or 'ocx update --registry <name>'.`);let M=MW(H,q,F);if(M.length===0){if(z)throw new MD(`No installed components from registry '${F.registry}'.`);throw new MD("No matching components found to update.")}let A=F.quiet?null:jD({text:"Checking for updates..."});A?.start();let K=null,j="check",S=null,Z=[],s=[];try{for(let O of M){let b=O.component,L=H.installed[b];if(!L)throw new MD(`Component '${b}' not found in receipt.`);let{registryName:e,name:p}=L,FD=_[e];if(!FD)throw new c(`Registry alias '${e}' not configured. Component '${b}' cannot be updated.`);let k=(await W8(FD.url,p,void 0)).manifest,i=p2(k),v=[];for(let r of i.files){let bD=await e2(FD.url,p,r.path);v.push({path:r.path,content:Buffer.from(bD)})}let f=await j8(v),_D=`sha256:${f}`;if(f===L.hash)Z.push({qualifiedName:b,oldVersion:L.revision,newVersion:_D,status:"up-to-date"});else if(F.dryRun)Z.push({qualifiedName:b,oldVersion:L.revision,newVersion:_D,status:"would-update"});else Z.push({qualifiedName:b,oldVersion:L.revision,newVersion:_D,status:"updated"}),s.push({canonicalId:b,component:i,files:v,newHash:f,newVersion:_D,baseUrl:FD.url,registryName:e,name:p})}if(A?.succeed(`Checked ${M.length} component(s)`),F.dryRun){AW(Z,F);return}if(s.length===0){if(!F.quiet&&!F.json)G.info(""),G.success("All components are up to date.");if(F.json)console.log(JSON.stringify({success:!0,updated:[],upToDate:Z},null,2));return}j="apply",K=F.quiet?null:jD({text:"Updating components..."}),K?.start();let N=new Map,x=[];for(let O of s){let b=[];for(let L of O.files){let e=O.component.files.find((KD)=>KD.path===L.path);if(!e)throw new U(`File "${L.path}" not found in component manifest for "${O.registryName}/${O.name}".`);let p=n2(e.target,Y,B.cwd),FD=JW(B.cwd,p);$F(N,{absolutePath:FD,relativePath:p,content:L.content,source:`${O.registryName}/${O.name}:${e.path}`}),b.push({resolvedTarget:p,targetPath:FD,content:L.content})}x.push({update:O,preparedFiles:b})}S=await WW(x,{verbose:F.verbose,quiet:F.quiet,fileOps:$});for(let O of x){let{update:b,preparedFiles:L}=O,e=H.installed[b.canonicalId];if(!e)throw new MD(`Component '${b.canonicalId}' not found in receipt.`);let p=[];for(let FD of L)p.push({path:FD.resolvedTarget,hash:_F(FD.content)});H.installed[b.canonicalId]={registryUrl:e.registryUrl,registryName:e.registryName,name:e.name,revision:b.newVersion,hash:b.newHash,files:p,installedAt:e.installedAt,updatedAt:new Date().toISOString(),...b.component.opencode&&{opencode:b.component.opencode}}}if(await K0(B.cwd,H),!S)throw Error("Internal error: missing applied write transaction after update apply phase.");if(await S.commit(),S=null,K?.succeed(`Updated ${s.length} component(s)`),F.json)console.log(JSON.stringify({success:!0,updated:Z.filter((O)=>O.status==="updated"),upToDate:Z.filter((O)=>O.status==="up-to-date")},null,2));else if(!F.quiet){G.info("");for(let O of Z)if(O.status==="updated")G.info(` \u2713 ${O.qualifiedName} (${O.oldVersion} \u2192 ${O.newVersion})`);else if(O.status==="up-to-date"&&F.verbose)G.info(` \u25CB ${O.qualifiedName} (already up to date)`);G.info(""),G.success(`Done! Updated ${s.length} component(s).`)}}catch(N){if(j==="apply"){if(S)await S.rollback(),S=null;K?.fail(m$("apply"))}else A?.fail(m$("check"));throw N}}async function WW(D,F){let B=[],$=new Set,_=!1,Q=F.fileOps?.rename??QW,Y=async()=>{if(_)return;_=!0;for(let H of $)try{await n8(H,{force:!0})}catch{}for(let H of[...B].reverse())try{if(H.backupPath){if(XF(H.targetPath))await n8(H.targetPath,{force:!0,recursive:!0});if(XF(H.backupPath))await Q(H.backupPath,H.targetPath)}else if(XF(H.targetPath))await n8(H.targetPath,{force:!0,recursive:!0})}catch{}},q=async()=>{if(_)return;_=!0;for(let H of B){if(!H.backupPath)continue;if(XF(H.backupPath))try{await n8(H.backupPath,{force:!0})}catch(J){if(!F.quiet){let X=J instanceof Error?J.message:String(J);G.warn(`Post-update cleanup warning: failed to remove backup "${H.backupPath}" (${X})`)}}}};try{for(let H of D)for(let J of H.preparedFiles){let X=HW(J.targetPath);if(!XF(X))await _W(X,{recursive:!0});if(XF(J.targetPath)){if((await YW(J.targetPath)).isDirectory())throw new U(`Cannot update "${J.resolvedTarget}": target path is a directory.`)}let z=`${J.targetPath}.ocx-update-tmp-${h$()}`;await qW(z,J.content),$.add(z);let M=null;if(XF(J.targetPath))M=`${J.targetPath}.ocx-update-backup-${h$()}`,await Q(J.targetPath,M),B.push({targetPath:J.targetPath,backupPath:M});if(await Q(z,J.targetPath),$.delete(z),!M)B.push({targetPath:J.targetPath,backupPath:null});if(F.verbose)G.info(` \u2713 Updated ${J.resolvedTarget}`)}return{commit:q,rollback:Y}}catch(H){throw await Y(),H}}function zW(D){if(D.endsWith("@"))throw new c(`Invalid version specifier '${D}'. The trailing '@' has no version.
225
- Use '${D.slice(0,-1)}' to update to the latest version.`);return{component:D}}function MW(D,F,B){let $=Object.keys(D.installed);if(B.all)return $.map((Q)=>({component:Q}));if(B.registry)return $.filter((Q)=>{return D.installed[Q]?.registryName===B.registry}).map((Q)=>({component:Q}));let _=[];for(let Q of F){let Y=Q.component;if(!Y.includes("/")){let z=$.map((M)=>{let A=Z2(M);return`${A.registryName}/${A.name}`}).filter((M)=>M.endsWith(`/${Y}`));if(z.length===1)throw new U(`Ambiguous component '${Y}'. Did you mean '${z[0]}'?`);if(z.length>1)throw new U(`Ambiguous component '${Y}'. Found in multiple registries:
225
+ Use either 'ocx update --all' or 'ocx update --registry <name>'.`);let M=LG(H,q,F);if(M.length===0){if(z)throw new MD(`No installed components from registry '${F.registry}'.`);throw new MD("No matching components found to update.")}let A=F.quiet?null:jD({text:"Checking for updates..."});A?.start();let K=null,j="check",S=null,R=[],s=[];try{for(let O of M){let b=O.component,L=H.installed[b];if(!L)throw new MD(`Component '${b}' not found in receipt.`);let{registryName:e,name:p}=L,FD=_[e];if(!FD)throw new c(`Registry alias '${e}' not configured. Component '${b}' cannot be updated.`);let k=(await M8(FD.url,p,void 0)).manifest,i=p2(k),v=[];for(let r of i.files){let bD=await e2(FD.url,p,r.path);v.push({path:r.path,content:Buffer.from(bD)})}let f=await U8(v),_D=`sha256:${f}`;if(f===L.hash)R.push({qualifiedName:b,oldVersion:L.revision,newVersion:_D,status:"up-to-date"});else if(F.dryRun)R.push({qualifiedName:b,oldVersion:L.revision,newVersion:_D,status:"would-update"});else R.push({qualifiedName:b,oldVersion:L.revision,newVersion:_D,status:"updated"}),s.push({canonicalId:b,component:i,files:v,newHash:f,newVersion:_D,baseUrl:FD.url,registryName:e,name:p})}if(A?.succeed(`Checked ${M.length} component(s)`),F.dryRun){wG(R,F);return}if(s.length===0){if(!F.quiet&&!F.json)W.info(""),W.success("All components are up to date.");if(F.json)console.log(JSON.stringify({success:!0,updated:[],upToDate:R},null,2));return}j="apply",K=F.quiet?null:jD({text:"Updating components..."}),K?.start();let N=new Map,y=[];for(let O of s){let b=[];for(let L of O.files){let e=O.component.files.find((KD)=>KD.path===L.path);if(!e)throw new U(`File "${L.path}" not found in component manifest for "${O.registryName}/${O.name}".`);let p=n2(e.target,Y,B.cwd),FD=jG(B.cwd,p);$F(N,{absolutePath:FD,relativePath:p,content:L.content,source:`${O.registryName}/${O.name}:${e.path}`}),b.push({resolvedTarget:p,targetPath:FD,content:L.content})}y.push({update:O,preparedFiles:b})}S=await VG(y,{verbose:F.verbose,quiet:F.quiet,fileOps:$});for(let O of y){let{update:b,preparedFiles:L}=O,e=H.installed[b.canonicalId];if(!e)throw new MD(`Component '${b.canonicalId}' not found in receipt.`);let p=[];for(let FD of L)p.push({path:FD.resolvedTarget,hash:_F(FD.content)});H.installed[b.canonicalId]={registryUrl:e.registryUrl,registryName:e.registryName,name:e.name,revision:b.newVersion,hash:b.newHash,files:p,installedAt:e.installedAt,updatedAt:new Date().toISOString(),...b.component.opencode&&{opencode:b.component.opencode}}}if(await j0(B.cwd,H),!S)throw Error("Internal error: missing applied write transaction after update apply phase.");if(await S.commit(),S=null,K?.succeed(`Updated ${s.length} component(s)`),F.json)console.log(JSON.stringify({success:!0,updated:R.filter((O)=>O.status==="updated"),upToDate:R.filter((O)=>O.status==="up-to-date")},null,2));else if(!F.quiet){W.info("");for(let O of R)if(O.status==="updated")W.info(` \u2713 ${O.qualifiedName} (${O.oldVersion} \u2192 ${O.newVersion})`);else if(O.status==="up-to-date"&&F.verbose)W.info(` \u25CB ${O.qualifiedName} (already up to date)`);W.info(""),W.success(`Done! Updated ${s.length} component(s).`)}}catch(N){if(j==="apply"){if(S)await S.rollback(),S=null;K?.fail(l$("apply"))}else A?.fail(l$("check"));throw N}}async function VG(D,F){let B=[],$=new Set,_=!1,Q=F.fileOps?.rename??GG,Y=async()=>{if(_)return;_=!0;for(let H of $)try{await a8(H,{force:!0})}catch{}for(let H of[...B].reverse())try{if(H.backupPath){if(XF(H.targetPath))await a8(H.targetPath,{force:!0,recursive:!0});if(XF(H.backupPath))await Q(H.backupPath,H.targetPath)}else if(XF(H.targetPath))await a8(H.targetPath,{force:!0,recursive:!0})}catch{}},q=async()=>{if(_)return;_=!0;for(let H of B){if(!H.backupPath)continue;if(XF(H.backupPath))try{await a8(H.backupPath,{force:!0})}catch(J){if(!F.quiet){let X=J instanceof Error?J.message:String(J);W.warn(`Post-update cleanup warning: failed to remove backup "${H.backupPath}" (${X})`)}}}};try{for(let H of D)for(let J of H.preparedFiles){let X=AG(J.targetPath);if(!XF(X))await WG(X,{recursive:!0});if(XF(J.targetPath)){if((await zG(J.targetPath)).isDirectory())throw new U(`Cannot update "${J.resolvedTarget}": target path is a directory.`)}let z=`${J.targetPath}.ocx-update-tmp-${c$()}`;await MG(z,J.content),$.add(z);let M=null;if(XF(J.targetPath))M=`${J.targetPath}.ocx-update-backup-${c$()}`,await Q(J.targetPath,M),B.push({targetPath:J.targetPath,backupPath:M});if(await Q(z,J.targetPath),$.delete(z),!M)B.push({targetPath:J.targetPath,backupPath:null});if(F.verbose)W.info(` \u2713 Updated ${J.resolvedTarget}`)}return{commit:q,rollback:Y}}catch(H){throw await Y(),H}}function EG(D){if(D.endsWith("@"))throw new c(`Invalid version specifier '${D}'. The trailing '@' has no version.
226
+ Use '${D.slice(0,-1)}' to update to the latest version.`);return{component:D}}function LG(D,F,B){let $=Object.keys(D.installed);if(B.all)return $.map((Q)=>({component:Q}));if(B.registry)return $.filter((Q)=>{return D.installed[Q]?.registryName===B.registry}).map((Q)=>({component:Q}));let _=[];for(let Q of F){let Y=Q.component;if(!Y.includes("/")){let z=$.map((M)=>{let A=R2(M);return`${A.registryName}/${A.name}`}).filter((M)=>M.endsWith(`/${Y}`));if(z.length===1)throw new U(`Ambiguous component '${Y}'. Did you mean '${z[0]}'?`);if(z.length>1)throw new U(`Ambiguous component '${Y}'. Found in multiple registries:
226
227
  `+z.map((M)=>` - ${M}`).join(`
227
228
  `)+`
228
229
 
229
- Please use a fully qualified name (alias/component).`);throw new U(`Component '${Y}' must include a registry alias (e.g., 'kdco/${Y}').`)}let{namespace:q,component:H}=u0(Y),J=$.filter((z)=>{let M=Z2(z);return M.registryName===q&&M.name===H});if(J.length===0)throw new MD(`Component '${Y}' is not installed.
230
- Run '${a6(Y,B)}' to install it first.`);let X=J[0];if(!X)throw Error("Unexpected: matchingIds has length but first element is undefined");_.push({component:X})}return _}function AW(D,F){let B=D.filter((Q)=>Q.status==="would-update"),_={dryRun:!0,command:"update",wouldPerform:B.map((Q)=>({action:"update",target:Q.qualifiedName,details:{from:Q.oldVersion,to:Q.newVersion}})),validation:{passed:!0},summary:B.length>0?`Would update ${B.length} component(s)`:"All components are up to date"};z0(_,{json:F.json,quiet:F.quiet})}var d$=V(()=>{gF();DF();tD();P0();BF();$D();PD();fD();k2();A8();iF();x0();m0()});import{resolve as jW}from"path";function KW(D,F){if(F==="not_found")return new MD(D);if(F==="parse_error")return new zD(D,"CONFIG_ERROR",XD.CONFIG);return new zD(D,"CONFIG_ERROR",XD.CONFIG)}function UW(D,F){let B=C3(D,{schemaErrors:F==="schema"?D.length:0}),$={valid:!1,errors:D,summary:{valid:!1,totalErrors:B.totalErrors,schemaErrors:B.schemaErrors,sourceFileErrors:B.sourceFileErrors,circularDependencyErrors:B.circularDependencyErrors,duplicateTargetErrors:B.duplicateTargetErrors,otherErrors:B.otherErrors}};return new g2($)}function VW(D){for(let F of D)console.log(P.red(` ${F}`))}function c$(D){D.command("validate").description("Validate a registry source (for registry authors)").argument("[path]","Registry source directory",".").option("--cwd <path>","Working directory",process.cwd()).option("--json","Output as JSON",!1).option("-q, --quiet","Suppress output",!1).option("--no-duplicate-targets","Skip duplicate target validation").action(async(F,B)=>{try{let $=jW(B.cwd,F),_=await N8($,{skipDuplicateTargets:B.duplicateTargets===!1});if(!_.success){let[Q="Registry validation failed"]=_.errors;if(_.failureType==="load"){let q=KW(Q,_.loadErrorKind);if(!B.json&&B.quiet){let H=q instanceof zD?q.exitCode:XD.GENERAL;process.exit(H)}throw q}let Y=UW(_.errors,_.failureType==="schema"?"schema":"rules");if(B.json)throw Y;if(!B.quiet)G.error(Y.message),VW(_.errors);process.exit(Y.exitCode)}if(!B.quiet&&!B.json)G.success("\u2713 Registry source is valid");if(B.json)LD({success:!0,data:{valid:!0,errors:[],summary:C3([])}})}catch($){if(!B.json&&B.quiet){let _=$ instanceof zD?$.exitCode:XD.GENERAL;process.exit(_)}t($,{json:B.json})}})}var l$=V(()=>{W2();L6();$D();PD();fD()});function p$(D){let F=D.command("verify").description("Verify integrity of installed components").argument("[components...]","Components to verify (optional, verifies all if omitted)");oD(F),w0(F),F.action(async(B,$)=>{try{await EW(B,$)}catch(_){t(_,{json:$.json})}})}async function EW(D,F){let B=F.cwd??process.cwd(),$=await V0.requireInitialized(B),_=await J0($.cwd);if(!_||Object.keys(_.installed).length===0){if(F.json)console.log(JSON.stringify({success:!0,verified:[],errors:[]},null,2));else if(!F.quiet)G.info("No components installed.");return}let Q;if(D.length>0)Q=y8(D,_);else Q=Object.keys(_.installed);let Y=F.quiet||F.json?null:jD({text:"Verifying components..."});Y?.start();let q=[],H=!1;for(let J of Q){let X=_.installed[J];if(!X){if(D.length>0)G.warn(`Component '${J}' not found in receipt.`);continue}let z=await N3($.cwd,X);if(!z.intact)H=!0;q.push({canonicalId:J,intact:z.intact,modified:z.modified,missing:z.missing})}if(Y?.succeed(`Verified ${q.length} component(s)`),F.json){if(console.log(JSON.stringify({success:!H,verified:q.filter((J)=>J.intact),errors:q.filter((J)=>!J.intact)},null,2)),H)process.exit(XD.CONFLICT);return}if(!F.quiet){G.info("");for(let J of q)if(J.intact){if(F.verbose)G.success(`\u2713 ${J.canonicalId} - all files intact`)}else{G.error(`\u2717 ${J.canonicalId} - integrity check failed`);for(let X of J.modified)G.error(` Modified: ${X}`);for(let X of J.missing)G.error(` Missing: ${X}`)}}if(H){if(!F.quiet)G.info(""),G.warn("Some files have been modified or are missing. Review local changes with git, then run 'ocx update <alias/component>' or 'ocx update --all' to restore.");throw new gD("File integrity check failed for one or more components.")}if(!F.quiet)G.info(""),G.success("All components verified successfully.")}var i$=V(()=>{gF();tD();x6();$D();PD();fD();iF();x0();m0()});function LW(){if(process.env.OCX_SELF_UPDATE==="off")return!1;if(V4(process.env.OCX_NO_UPDATE_CHECK,!1))return!1;if(process.env.CI)return!1;if(!process.stdout.isTTY)return!1;return!0}function n$(D){D.hook("postAction",async(F,B)=>{if(B.name()==="update"&&B.parent?.name()==="self")return;let $=B.opts();if($.json||$.quiet)return;if(!LW())return;try{let[{checkForUpdate:_},{notifyUpdate:Q}]=await Promise.all([Promise.resolve().then(() => (l6(),O$)),Promise.resolve().then(() => (s6(),k$))]),Y=await _();if(Y.ok&&Y.updateAvailable)Q(Y.current,Y.latest)}catch{}})}var s$=V(()=>{Z3()});var a$={};j2(a$,{runCli:()=>OW});async function OW(D=process.argv){let F=new G9().name("ocx").description("OpenCode Extensions - Install agents, skills, plugins, and commands").version(wW);nB(F),IB(F),g$(F),$$(F),i5(F),xB(F),c$(F),y$(F),p$(F),o5(F),B5(F),d5(F),cB(F),w5(F),n$(F),await F.parseAsync(D)}var wW="2.0.3";var o$=V(()=>{B8();E6();yB();lB();aB();_5();O5();c5();n5();r5();_$();f$();d$();l$();i$();s$()});o3();L1();if(import.meta.main)bW();async function bW(){try{let{runCli:D}=await Promise.resolve().then(() => (o$(),a$));await D()}catch(D){let{handleError:F}=await Promise.resolve().then(() => (PD(),E4));F(D)}}export{i2 as registrySchema,K3 as packumentSchema,t3 as ocxLockSchema,R2 as ocxConfigSchema,l2 as componentManifestSchema,U3 as buildRegistry};
230
+ Please use a fully qualified name (alias/component).`);throw new U(`Component '${Y}' must include a registry alias (e.g., 'kdco/${Y}').`)}let{namespace:q,component:H}=u0(Y),J=$.filter((z)=>{let M=R2(z);return M.registryName===q&&M.name===H});if(J.length===0)throw new MD(`Component '${Y}' is not installed.
231
+ Run '${t6(Y,B)}' to install it first.`);let X=J[0];if(!X)throw Error("Unexpected: matchingIds has length but first element is undefined");_.push({component:X})}return _}function wG(D,F){let B=D.filter((Q)=>Q.status==="would-update"),_={dryRun:!0,command:"update",wouldPerform:B.map((Q)=>({action:"update",target:Q.qualifiedName,details:{from:Q.oldVersion,to:Q.newVersion}})),validation:{passed:!0},summary:B.length>0?`Would update ${B.length} component(s)`:"All components are up to date"};z0(_,{json:F.json,quiet:F.quiet})}var i$=V(()=>{gF();DF();eD();P0();BF();$D();yD();hD();k2();K8();nF();x0();g0()});import{resolve as OG}from"path";function bG(D,F){if(F==="not_found")return new MD(D);if(F==="parse_error")return new zD(D,"CONFIG_ERROR",XD.CONFIG);return new zD(D,"CONFIG_ERROR",XD.CONFIG)}function ZG(D,F){let B=u3(D,{schemaErrors:F==="schema"?D.length:0}),$={valid:!1,errors:D,summary:{valid:!1,totalErrors:B.totalErrors,schemaErrors:B.schemaErrors,sourceFileErrors:B.sourceFileErrors,circularDependencyErrors:B.circularDependencyErrors,duplicateTargetErrors:B.duplicateTargetErrors,otherErrors:B.otherErrors}};return new g2($)}function RG(D){for(let F of D)console.log(P.red(` ${F}`))}function n$(D){D.command("validate").description("Validate a registry source (for registry authors)").argument("[path]","Registry source directory",".").option("--cwd <path>","Working directory",process.cwd()).option("--json","Output as JSON",!1).option("-q, --quiet","Suppress output",!1).option("--no-duplicate-targets","Skip duplicate target validation").action(async(F,B)=>{try{let $=OG(B.cwd,F),_=await k8($,{skipDuplicateTargets:B.duplicateTargets===!1});if(!_.success){let[Q="Registry validation failed"]=_.errors;if(_.failureType==="load"){let q=bG(Q,_.loadErrorKind);if(!B.json&&B.quiet){let H=q instanceof zD?q.exitCode:XD.GENERAL;process.exit(H)}throw q}let Y=ZG(_.errors,_.failureType==="schema"?"schema":"rules");if(B.json)throw Y;if(!B.quiet)W.error(Y.message),RG(_.errors);process.exit(Y.exitCode)}if(!B.quiet&&!B.json)W.success("\u2713 Registry source is valid");if(B.json)LD({success:!0,data:{valid:!0,errors:[],summary:u3([])}})}catch($){if(!B.json&&B.quiet){let _=$ instanceof zD?$.exitCode:XD.GENERAL;process.exit(_)}t($,{json:B.json})}})}var s$=V(()=>{G2();b6();$D();yD();hD()});function a$(D){let F=D.command("verify").description("Verify integrity of installed components").argument("[components...]","Components to verify (optional, verifies all if omitted)");rD(F),L0(F),F.action(async(B,$)=>{try{await NG(B,$)}catch(_){t(_,{json:$.json})}})}async function NG(D,F){let B=F.cwd??process.cwd(),$=await U0.requireInitialized(B),_=await X0($.cwd);if(!_||Object.keys(_.installed).length===0){if(F.json)console.log(JSON.stringify({success:!0,verified:[],errors:[]},null,2));else if(!F.quiet)W.info("No components installed.");return}let Q;if(D.length>0)Q=h8(D,_);else Q=Object.keys(_.installed);let Y=F.quiet||F.json?null:jD({text:"Verifying components..."});Y?.start();let q=[],H=!1;for(let J of Q){let X=_.installed[J];if(!X){if(D.length>0)W.warn(`Component '${J}' not found in receipt.`);continue}let z=await S3($.cwd,X);if(!z.intact)H=!0;q.push({canonicalId:J,intact:z.intact,modified:z.modified,missing:z.missing})}if(Y?.succeed(`Verified ${q.length} component(s)`),F.json){if(console.log(JSON.stringify({success:!H,verified:q.filter((J)=>J.intact),errors:q.filter((J)=>!J.intact)},null,2)),H)process.exit(XD.CONFLICT);return}if(!F.quiet){W.info("");for(let J of q)if(J.intact){if(F.verbose)W.success(`\u2713 ${J.canonicalId} - all files intact`)}else{W.error(`\u2717 ${J.canonicalId} - integrity check failed`);for(let X of J.modified)W.error(` Modified: ${X}`);for(let X of J.missing)W.error(` Missing: ${X}`)}}if(H){if(!F.quiet)W.info(""),W.warn("Some files have been modified or are missing. Review local changes with git, then run 'ocx update <alias/component>' or 'ocx update --all' to restore.");throw new dD("File integrity check failed for one or more components.")}if(!F.quiet)W.info(""),W.success("All components verified successfully.")}var o$=V(()=>{gF();eD();h6();$D();yD();hD();nF();x0();g0()});function SG(){if(process.env.OCX_SELF_UPDATE==="off")return!1;if(w4(process.env.OCX_NO_UPDATE_CHECK,!1))return!1;if(process.env.CI)return!1;if(!process.stdout.isTTY)return!1;return!0}function r$(D){D.hook("postAction",async(F,B)=>{if(B.name()==="update"&&B.parent?.name()==="self")return;let $=B.opts();if($.json||$.quiet)return;if(!SG())return;try{let[{checkForUpdate:_},{notifyUpdate:Q}]=await Promise.all([Promise.resolve().then(() => (n6(),N$)),Promise.resolve().then(() => (r6(),C$))]),Y=await _();if(Y.ok&&Y.updateAvailable)Q(Y.current,Y.latest)}catch{}})}var t$=V(()=>{N3()});var e$={};j2(e$,{runCli:()=>IG});async function IG(D=process.argv){let F=new M9().name("ocx").description("OpenCode Extensions - Install agents, skills, plugins, and commands").version(kG);rB(F),uB(F),p$(F),q$(F),o5(F),mB(F),n$(F),g$(F),a$(F),D$(F),Y5(F),i5(F),nB(F),R5(F),r$(F),await F.parseAsync(D)}var kG="2.0.4";var D_=V(()=>{$8();O6();gB();sB();eB();H5();N5();n5();r5();F$();H$();d$();i$();s$();o$();t$()});r3();O1();if(import.meta.main)TG();async function TG(){try{let{runCli:D}=await Promise.resolve().then(() => (D_(),e$));await D()}catch(D){let{handleError:F}=await Promise.resolve().then(() => (yD(),O4));F(D)}}export{i2 as registrySchema,U3 as packumentSchema,e3 as ocxLockSchema,Z2 as ocxConfigSchema,l2 as componentManifestSchema,V3 as buildRegistry};
231
232
 
232
- //# debugId=471588A1A0C20C2C64756E2164756E21
233
+ //# debugId=D2781E24A4BFAB1164756E2164756E21